|
@@ -11,8 +11,7 @@
|
|
|
/**
|
|
|
* 定义(define)
|
|
|
*/
|
|
|
-class core
|
|
|
-{
|
|
|
+class core {
|
|
|
|
|
|
/**
|
|
|
* 配置文件或配置数组
|
|
@@ -31,8 +30,7 @@ class core
|
|
|
* @param mixed &$variable
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public static function init($config = null, &$variable = null)
|
|
|
- {
|
|
|
+ public static function init($config = null, &$variable = null) {
|
|
|
|
|
|
// 引用参数处理
|
|
|
$self_flag = $variable === null;
|
|
@@ -113,8 +111,7 @@ class core
|
|
|
* @param bool $autoload_prepend
|
|
|
* @return bool
|
|
|
*/
|
|
|
- public static function stub($autoload_enable = null, $autoload_path = null, $autoload_extensions = null, $autoload_prepend = null)
|
|
|
- {
|
|
|
+ public static function stub($autoload_enable = null, $autoload_path = null, $autoload_extensions = null, $autoload_prepend = null) {
|
|
|
|
|
|
// 初始化自动载入功能
|
|
|
$array = array();
|
|
@@ -149,8 +146,7 @@ class core
|
|
|
* @param string $framework_parameter
|
|
|
* @return bool
|
|
|
*/
|
|
|
- public static function main($framework_enable = null, $framework_require = null, $framework_module = null, $framework_action = null, $framework_parameter = null)
|
|
|
- {
|
|
|
+ public static function main($framework_enable = null, $framework_require = null, $framework_module = null, $framework_action = null, $framework_parameter = null) {
|
|
|
|
|
|
// 一次跳转功能
|
|
|
$config = self::init(false);
|
|
@@ -206,8 +202,7 @@ class core
|
|
|
* @param string $filetype
|
|
|
* @return string
|
|
|
*/
|
|
|
- public static function path($filename, $filetype = null)
|
|
|
- {
|
|
|
+ public static function path($filename, $filetype = null) {
|
|
|
|
|
|
switch ($filetype) {
|
|
|
case 'extension' :
|
|
@@ -239,8 +234,7 @@ class core
|
|
|
* @param bool $_view_show
|
|
|
* @return string
|
|
|
*/
|
|
|
- public static function view($_view_file_global = null, $_view_vars = null, $_view_type = null, $_view_show = null)
|
|
|
- {
|
|
|
+ public static function view($_view_file_global = null, $_view_vars = null, $_view_type = null, $_view_show = null) {
|
|
|
|
|
|
// 视图全局参数
|
|
|
self::_view_variable($_view_file_global);
|
|
@@ -308,8 +302,7 @@ class core
|
|
|
* @param array $info
|
|
|
* @return $dbh
|
|
|
*/
|
|
|
- public static function connect($args = null, &$ref = null, $info = null)
|
|
|
- {
|
|
|
+ public static function connect($args = null, &$ref = null, $info = null) {
|
|
|
|
|
|
|
|
|
// 导入配置文件
|
|
@@ -523,8 +516,7 @@ class core
|
|
|
* @param array &$ref
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public static function execute($sql, $param = null, &$ref = null)
|
|
|
- {
|
|
|
+ public static function execute($sql, $param = null, &$ref = null) {
|
|
|
|
|
|
// 【基础功能】执行语句
|
|
|
$ref_flag = (func_num_args() > 2);
|
|
@@ -572,7 +564,7 @@ class core
|
|
|
} elseif (is_int($value) || is_float($value)) {
|
|
|
|
|
|
} else {
|
|
|
- $value = '\'' . mysqli_real_escape_string((string) $value, $dbh) . '\'';
|
|
|
+ $value = '\'' . mysqli_real_escape_string($dbh, (string) $value) . '\'';
|
|
|
}
|
|
|
$varname = $var . ++$key;
|
|
|
if ($key === 1) {
|
|
@@ -585,7 +577,7 @@ class core
|
|
|
$using .= ',' . $varname;
|
|
|
}
|
|
|
}
|
|
|
- mysql_query('PREPARE ' . $stmt . ' FROM \'' . mysqli_real_escape_string($sql, $dbh) . '\'', $dbh);
|
|
|
+ mysql_query('PREPARE ' . $stmt . ' FROM \'' . mysqli_real_escape_string($dbh, $sql) . '\'', $dbh);
|
|
|
if ($sql_set !== '') {
|
|
|
mysql_query($sql_set, $dbh);
|
|
|
}
|
|
@@ -634,8 +626,7 @@ class core
|
|
|
* @param array $extra
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public static function prepare($sql, $param = null, $format = null, $debug = null, $output = null, $extra = null)
|
|
|
- {
|
|
|
+ public static function prepare($sql, $param = null, $format = null, $debug = null, $output = null, $extra = null) {
|
|
|
|
|
|
// 【基础功能】准备SQL语句
|
|
|
$mysql_escape_search = array("\\", "\x00", "\n", "\r", "'", "\"", "\x1a");
|
|
@@ -1270,8 +1261,7 @@ class core
|
|
|
* @param int $start_index
|
|
|
* @return int
|
|
|
*/
|
|
|
- public static function sequence($tablename = 'sequence', $start_index = 1)
|
|
|
- {
|
|
|
+ public static function sequence($tablename = 'sequence', $start_index = 1) {
|
|
|
|
|
|
// 【基础功能】生成自增序列
|
|
|
$dbh = self::connect(true, $args, array('sequence', $tablename, $start_index));
|
|
@@ -1322,8 +1312,7 @@ class core
|
|
|
* @param mixed $struct
|
|
|
* @return array
|
|
|
*/
|
|
|
- public static function structs($array = null, $struct = null)
|
|
|
- {
|
|
|
+ public static function structs($array = null, $struct = null) {
|
|
|
|
|
|
// 【基础功能】构造对象数组
|
|
|
// 数组
|
|
@@ -1392,7 +1381,7 @@ class core
|
|
|
$data_int [$int2] = $data2;
|
|
|
$data_all [$key2] = $data2;
|
|
|
$data_all [$int2] = $data2;
|
|
|
- $int2 ++;
|
|
|
+ $int2++;
|
|
|
}
|
|
|
}
|
|
|
$point1 = &$return;
|
|
@@ -1468,7 +1457,7 @@ class core
|
|
|
case 'class|classtype' :
|
|
|
$i = 0;
|
|
|
foreach ($data_str as $key => $value) {
|
|
|
- if ($i ++ === 0) {
|
|
|
+ if ($i++ === 0) {
|
|
|
if (isset($data_int [0]) && preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $data_int [0]) && class_exists($data_int [0])) {
|
|
|
$point1 = new $data_int [0] ( );
|
|
|
} elseif (class_exists($classname)) {
|
|
@@ -1516,8 +1505,7 @@ class core
|
|
|
* @param mixed $struct
|
|
|
* @return array
|
|
|
*/
|
|
|
- public static function selects($field_sql = null, $table_param = null, $where_bool = null, $other = null, $struct = null)
|
|
|
- {
|
|
|
+ public static function selects($field_sql = null, $table_param = null, $where_bool = null, $other = null, $struct = null) {
|
|
|
|
|
|
// 【基础功能】静态选择数据
|
|
|
$dbh = self::connect(true, $args, array('selects', $field_sql, $table_param, $where_bool, $other, $struct));
|
|
@@ -1827,8 +1815,7 @@ class core
|
|
|
* @param string $class
|
|
|
* @return int
|
|
|
*/
|
|
|
- public static function inserts($table_sql = null, $column_set_param = null, $value_bool = null, $other = null, $class = null)
|
|
|
- {
|
|
|
+ public static function inserts($table_sql = null, $column_set_param = null, $value_bool = null, $other = null, $class = null) {
|
|
|
|
|
|
// 【基础功能】静态插入数据
|
|
|
$dbh = self::connect(true, $args, array('inserts', $table_sql, $column_set_param, $value_bool, $other, $class));
|
|
@@ -1888,8 +1875,7 @@ class core
|
|
|
* @param string $class
|
|
|
* @return int
|
|
|
*/
|
|
|
- public static function updates($table_sql = null, $set_param = null, $where_bool = null, $other = null, $class = null)
|
|
|
- {
|
|
|
+ public static function updates($table_sql = null, $set_param = null, $where_bool = null, $other = null, $class = null) {
|
|
|
|
|
|
// 【基础功能】静态修改数据
|
|
|
$dbh = self::connect(true, $args, array('updates', $table_sql, $set_param, $where_bool, $other, $class));
|
|
@@ -1949,8 +1935,7 @@ class core
|
|
|
* @param string $class
|
|
|
* @return int
|
|
|
*/
|
|
|
- public static function deletes($field_sql = null, $table_param = null, $where_bool = null, $other = null, $class = null)
|
|
|
- {
|
|
|
+ public static function deletes($field_sql = null, $table_param = null, $where_bool = null, $other = null, $class = null) {
|
|
|
|
|
|
// 【基础功能】静态删除数据
|
|
|
$dbh = self::connect(true, $args, array('deletes', $field_sql, $table_param, $where_bool, $other, $class));
|
|
@@ -2010,8 +1995,7 @@ class core
|
|
|
* @param string $class
|
|
|
* @return int
|
|
|
*/
|
|
|
- public static function replaces($table_sql = null, $column_set_param = null, $value_bool = null, $other = null, $class = null)
|
|
|
- {
|
|
|
+ public static function replaces($table_sql = null, $column_set_param = null, $value_bool = null, $other = null, $class = null) {
|
|
|
|
|
|
// 【基础功能】静态更新数据
|
|
|
$dbh = self::connect(true, $args, array('replaces', $table_sql, $column_set_param, $value_bool, $other, $class));
|
|
@@ -2067,8 +2051,7 @@ class core
|
|
|
* @param mixed $row
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public function struct($row = null)
|
|
|
- {
|
|
|
+ public function struct($row = null) {
|
|
|
|
|
|
// 验证方法名
|
|
|
if (!isset($this) || !($this instanceof self)) {
|
|
@@ -2088,7 +2071,7 @@ class core
|
|
|
if ($row === $i) {
|
|
|
return $value;
|
|
|
}
|
|
|
- $i ++;
|
|
|
+ $i++;
|
|
|
}
|
|
|
return;
|
|
|
} elseif (is_string($row)) {
|
|
@@ -2115,7 +2098,7 @@ class core
|
|
|
$this->$key2 = $value;
|
|
|
break;
|
|
|
}
|
|
|
- $i ++;
|
|
|
+ $i++;
|
|
|
}
|
|
|
} elseif ($key !== '') {
|
|
|
$this->$key = $value;
|
|
@@ -2134,8 +2117,7 @@ class core
|
|
|
* @param mixed $primary_index
|
|
|
* @return bool
|
|
|
*/
|
|
|
- public function select($tablename = '', $primary_index = 0)
|
|
|
- {
|
|
|
+ public function select($tablename = '', $primary_index = 0) {
|
|
|
|
|
|
// 验证方法名
|
|
|
if (!isset($this) || !($this instanceof self)) {
|
|
@@ -2158,7 +2140,7 @@ class core
|
|
|
if (is_int($primary_index) && $primary_index >= 0 && $primary_index < count($fieldvars)) {
|
|
|
$field_index = 0;
|
|
|
foreach ($fieldvars as $primary_name => $primary_value) {
|
|
|
- if ($primary_index === $field_index ++) {
|
|
|
+ if ($primary_index === $field_index++) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -2216,8 +2198,7 @@ class core
|
|
|
* @param mixed $primary_index
|
|
|
* @return bool
|
|
|
*/
|
|
|
- public function insert($tablename = '', $primary_index = 0)
|
|
|
- {
|
|
|
+ public function insert($tablename = '', $primary_index = 0) {
|
|
|
|
|
|
// 验证方法名
|
|
|
if (!isset($this) || !($this instanceof self)) {
|
|
@@ -2240,7 +2221,7 @@ class core
|
|
|
if (is_int($primary_index) && $primary_index >= 0 && $primary_index < count($fieldvars)) {
|
|
|
$field_index = 0;
|
|
|
foreach ($fieldvars as $primary_name => $primary_value) {
|
|
|
- if ($primary_index === $field_index ++) {
|
|
|
+ if ($primary_index === $field_index++) {
|
|
|
unset($fieldvars [$primary_name]);
|
|
|
break;
|
|
|
}
|
|
@@ -2290,8 +2271,7 @@ class core
|
|
|
* @param mixed $primary_index
|
|
|
* @return bool
|
|
|
*/
|
|
|
- public function update($tablename = '', $primary_index = 0)
|
|
|
- {
|
|
|
+ public function update($tablename = '', $primary_index = 0) {
|
|
|
|
|
|
// 验证方法名
|
|
|
if (!isset($this) || !($this instanceof self)) {
|
|
@@ -2314,7 +2294,7 @@ class core
|
|
|
if (is_int($primary_index) && $primary_index >= 0 && $primary_index < count($fieldvars)) {
|
|
|
$field_index = 0;
|
|
|
foreach ($fieldvars as $primary_name => $primary_value) {
|
|
|
- if ($primary_index === $field_index ++) {
|
|
|
+ if ($primary_index === $field_index++) {
|
|
|
unset($fieldvars [$primary_name]);
|
|
|
break;
|
|
|
}
|
|
@@ -2370,8 +2350,7 @@ class core
|
|
|
* @param mixed $primary_index
|
|
|
* @return bool
|
|
|
*/
|
|
|
- public function delete($tablename = '', $primary_index = 0)
|
|
|
- {
|
|
|
+ public function delete($tablename = '', $primary_index = 0) {
|
|
|
|
|
|
// 验证方法名
|
|
|
if (!isset($this) || !($this instanceof self)) {
|
|
@@ -2394,7 +2373,7 @@ class core
|
|
|
if (is_int($primary_index) && $primary_index >= 0 && $primary_index < count($fieldvars)) {
|
|
|
$field_index = 0;
|
|
|
foreach ($fieldvars as $primary_name => $primary_value) {
|
|
|
- if ($primary_index === $field_index ++) {
|
|
|
+ if ($primary_index === $field_index++) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -2440,8 +2419,7 @@ class core
|
|
|
* @param mixed $primary_index
|
|
|
* @return bool
|
|
|
*/
|
|
|
- public function replace($tablename = '', $primary_index = 0)
|
|
|
- {
|
|
|
+ public function replace($tablename = '', $primary_index = 0) {
|
|
|
|
|
|
// 验证方法名
|
|
|
if (!isset($this) || !($this instanceof self)) {
|
|
@@ -2464,7 +2442,7 @@ class core
|
|
|
if (is_int($primary_index) && $primary_index >= 0 && $primary_index < count($fieldvars)) {
|
|
|
$field_index = 0;
|
|
|
foreach ($fieldvars as $primary_name => $primary_value) {
|
|
|
- if ($primary_index === $field_index ++) {
|
|
|
+ if ($primary_index === $field_index++) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -2510,8 +2488,7 @@ class core
|
|
|
* @param string $filename
|
|
|
* @return array
|
|
|
*/
|
|
|
- private static function _init_file($filename)
|
|
|
- {
|
|
|
+ private static function _init_file($filename) {
|
|
|
|
|
|
if (strtolower(strrchr($filename, '.')) === '.php') {
|
|
|
$filepath = self::_path_config($filename);
|
|
@@ -2532,8 +2509,7 @@ class core
|
|
|
* @param string $varname
|
|
|
* @return array
|
|
|
*/
|
|
|
- private static function _init_env($varname)
|
|
|
- {
|
|
|
+ private static function _init_env($varname) {
|
|
|
|
|
|
//导入配置文件
|
|
|
static $static_htaccess;
|
|
@@ -2573,8 +2549,7 @@ class core
|
|
|
*
|
|
|
* @param array $array
|
|
|
*/
|
|
|
- private static function _init_extension($array)
|
|
|
- {
|
|
|
+ private static function _init_extension($array) {
|
|
|
|
|
|
// 数组参数处理
|
|
|
$config = array(
|
|
@@ -2634,8 +2609,7 @@ class core
|
|
|
*
|
|
|
* @param array $array
|
|
|
*/
|
|
|
- private static function _init_autoload($array)
|
|
|
- {
|
|
|
+ private static function _init_autoload($array) {
|
|
|
|
|
|
// 数组参数处理
|
|
|
$config = array(
|
|
@@ -2735,8 +2709,7 @@ class core
|
|
|
*
|
|
|
* @param array $array
|
|
|
*/
|
|
|
- private static function _stub_autoload($array)
|
|
|
- {
|
|
|
+ private static function _stub_autoload($array) {
|
|
|
|
|
|
static $static_config;
|
|
|
if ($static_config === null || $array !== array()) {
|
|
@@ -2750,8 +2723,7 @@ class core
|
|
|
*
|
|
|
* @param array $array
|
|
|
*/
|
|
|
- private static function _main_hide($array)
|
|
|
- {
|
|
|
+ private static function _main_hide($array) {
|
|
|
|
|
|
$hide_info = isset($array ['hide_info']) ? $array ['hide_info'] : '';
|
|
|
$hide_info_cli = isset($array ['hide_info_cli']) ? $array ['hide_info_cli'] : $hide_info;
|
|
@@ -2787,8 +2759,7 @@ class core
|
|
|
* @param array $return_array
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- private static function _main_framework($array, $return_array)
|
|
|
- {
|
|
|
+ private static function _main_framework($array, $return_array) {
|
|
|
// 1. 设置默认值、替换内置宏
|
|
|
list ($classname_static, $debug_backtrace_file) = self::_main_framework_first();
|
|
|
if (empty($array ['framework_require'])) {
|
|
@@ -3210,8 +3181,7 @@ class core
|
|
|
* @param bool $bool
|
|
|
* @return array
|
|
|
*/
|
|
|
- private static function _main_framework_first($bool = null)
|
|
|
- {
|
|
|
+ private static function _main_framework_first($bool = null) {
|
|
|
static $class = null;
|
|
|
static $file = null;
|
|
|
if ($class === null) {
|
|
@@ -3237,8 +3207,7 @@ class core
|
|
|
* @param mixed $prefix
|
|
|
* @return array
|
|
|
*/
|
|
|
- private static function _main_framework_resolve($string, $value_array, $flag, $prefix = null)
|
|
|
- {
|
|
|
+ private static function _main_framework_resolve($string, $value_array, $flag, $prefix = null) {
|
|
|
$result_array = array();
|
|
|
$length = strlen($string);
|
|
|
$last_pos = 0;
|
|
@@ -3418,8 +3387,7 @@ class core
|
|
|
* @param bool $strict
|
|
|
* @return array
|
|
|
*/
|
|
|
- private static function _main_framework_replace($string, $value_array, $strict)
|
|
|
- {
|
|
|
+ private static function _main_framework_replace($string, $value_array, $strict) {
|
|
|
$result = '';
|
|
|
$length = strlen($string);
|
|
|
$last_pos = 0;
|
|
@@ -3545,8 +3513,7 @@ class core
|
|
|
* @param string $filename
|
|
|
* @return string
|
|
|
*/
|
|
|
- private static function _path_extension($filename)
|
|
|
- {
|
|
|
+ private static function _path_extension($filename) {
|
|
|
|
|
|
$filepath = self::_path_file($filename);
|
|
|
$extension_path = isset(self::$config ['extension_path']) ? self::$config ['extension_path'] : null;
|
|
@@ -3568,8 +3535,7 @@ class core
|
|
|
* @param string $filename
|
|
|
* @return string
|
|
|
*/
|
|
|
- private static function _path_template($filename)
|
|
|
- {
|
|
|
+ private static function _path_template($filename) {
|
|
|
|
|
|
$filepath = self::_path_file($filename);
|
|
|
$template_path = isset(self::$config ['template_path']) ? self::$config ['template_path'] : null;
|
|
@@ -3591,8 +3557,7 @@ class core
|
|
|
* @param string $filename
|
|
|
* @return string
|
|
|
*/
|
|
|
- private static function _path_config($filename)
|
|
|
- {
|
|
|
+ private static function _path_config($filename) {
|
|
|
|
|
|
$filepath = self::_path_file($filename);
|
|
|
$config_path = isset(self::$config ['config_path']) ? self::$config ['config_path'] : null;
|
|
@@ -3614,8 +3579,7 @@ class core
|
|
|
* @param string $filename
|
|
|
* @return string
|
|
|
*/
|
|
|
- private static function _path_file($filename)
|
|
|
- {
|
|
|
+ private static function _path_file($filename) {
|
|
|
|
|
|
$first = strlen($filename) > 0 ? $filename[0] : '';
|
|
|
if ($first === '@') {
|
|
@@ -3633,8 +3597,7 @@ class core
|
|
|
*
|
|
|
* @param array $global
|
|
|
*/
|
|
|
- private static function _view_variable($global = null)
|
|
|
- {
|
|
|
+ private static function _view_variable($global = null) {
|
|
|
|
|
|
$variable = &self::$view;
|
|
|
if (!is_array($variable)) {
|