内核更新
This commit is contained in:
@@ -32,6 +32,7 @@ defined('CONF_EXT') or define('CONF_EXT', EXT); // 配置文件后缀
|
||||
defined('ENV_PREFIX') or define('ENV_PREFIX', 'PHP_'); // 环境变量的配置前缀
|
||||
defined('IS_API') or define('IS_API', false); // 是否API接口
|
||||
defined('APP_AUTO_RUN') or define('APP_AUTO_RUN', true); // 是否自动运行
|
||||
defined('AUTO_SCAN_PACKAGE') or define('AUTO_SCAN_PACKAGE', false); // 是否自动扫描非Composer安装类库
|
||||
|
||||
// 环境常量
|
||||
define('IS_CLI', PHP_SAPI == 'cli' ? true : false);
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
namespace think;
|
||||
|
||||
use think\App;
|
||||
use think\exception\HttpException;
|
||||
use think\exception\ClassNotFoundException;
|
||||
use think\Request;
|
||||
|
||||
@@ -60,16 +59,27 @@ class Loader
|
||||
if (!strpos($class, '\\')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 解析命名空间
|
||||
list($name, $class) = explode('\\', $class, 2);
|
||||
if (isset(self::$namespace[$name])) {
|
||||
// 注册的命名空间
|
||||
// 根命名空间
|
||||
$path = self::$namespace[$name];
|
||||
} elseif (is_dir(EXTEND_PATH . $name)) {
|
||||
// 扩展类库命名空间
|
||||
$path = EXTEND_PATH . $name . DS;
|
||||
} else {
|
||||
return false;
|
||||
// 非根命名空间检测
|
||||
foreach (self::$namespace as $ns => $val) {
|
||||
if (strpos($ns, '\\') && 0 === strpos($name . '\\' . $class, $ns)) {
|
||||
$path = $val;
|
||||
$class = substr($name . $class, strlen($ns));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isset($path)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$filename = $path . str_replace('\\', DS, $class) . EXT;
|
||||
if (is_file($filename)) {
|
||||
@@ -120,20 +130,85 @@ class Loader
|
||||
{
|
||||
// 注册系统自动加载
|
||||
spl_autoload_register($autoload ?: 'think\\Loader::autoload');
|
||||
|
||||
|
||||
if (is_dir(VENDOR_PATH . 'composer')) {
|
||||
// 注册Composer自动加载
|
||||
self::registerComposerLoader();
|
||||
self::$composerLoader = true;
|
||||
} elseif(is_file(VENDOR_PATH . 'think_autoload.php')) {
|
||||
self::$composerLoader = true;
|
||||
} elseif (is_file(VENDOR_PATH . 'think_autoload.php')) {
|
||||
// 读取Composer自动加载文件
|
||||
$autoload = include VENDOR_PATH . 'think_autoload.php';
|
||||
if (is_array($autoload)) {
|
||||
self::addMap($autoload);
|
||||
}
|
||||
} elseif (AUTO_SCAN_PACKAGE) {
|
||||
if (is_file(RUNTIME_PATH . 'class_namespace.php')) {
|
||||
self::addNamespace(include RUNTIME_PATH . 'class_namespace.php');
|
||||
if (is_file(RUNTIME_PATH . 'load_files.php')) {
|
||||
$files = include RUNTIME_PATH . 'load_files.php';
|
||||
foreach ($files as $file) {
|
||||
include $file;
|
||||
}
|
||||
}
|
||||
} elseif (is_dir(VENDOR_PATH)) {
|
||||
self::scanComposerPackage(VENDOR_PATH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 扫描composer package
|
||||
private static function scanComposerPackage($path)
|
||||
{
|
||||
// 自动扫描下载Composer安装类库
|
||||
$dirs = scandir($path, 1);
|
||||
$namespace = [];
|
||||
foreach ($dirs as $dir) {
|
||||
if ('.' != $dir && '..' != $dir && is_file($path . $dir . DS . 'composer.json')) {
|
||||
// 解析 package的composer.json 文件
|
||||
$namespace = array_merge($namespace, self::parseComposerPackage($path . $dir . DS));
|
||||
}
|
||||
}
|
||||
if (!empty($namespace)) {
|
||||
self::addNamespace($namespace);
|
||||
// 生成缓存
|
||||
file_put_contents(RUNTIME_PATH . 'class_namespace.php', "<?php\nreturn " . var_export($namespace, true) . ';');
|
||||
}
|
||||
if (!empty(self::$load)) {
|
||||
// 生成缓存
|
||||
file_put_contents(RUNTIME_PATH . 'load_files.php', "<?php\nreturn " . var_export(self::$load, true) . ';');
|
||||
}
|
||||
}
|
||||
|
||||
// 解析Composer Package
|
||||
private static function parseComposerPackage($package)
|
||||
{
|
||||
$content = file_get_contents($package . 'composer.json');
|
||||
$result = json_decode($content, true);
|
||||
$namespace = [];
|
||||
if (!empty($result['autoload'])) {
|
||||
$autoload = $result['autoload'];
|
||||
if (isset($autoload['psr-0'])) {
|
||||
foreach ($autoload['psr-0'] as $ns => $path) {
|
||||
$namespace[rtrim($ns, '\\')] = realpath($package . $path . DS . str_replace('\\', DS, $ns)) . DS;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($autoload['psr-4'])) {
|
||||
foreach ($autoload['psr-4'] as $ns => $path) {
|
||||
$namespace[rtrim($ns, '\\')] = realpath($package . $path) . DS;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($autoload['files'])) {
|
||||
foreach ($autoload['files'] as $file) {
|
||||
self::$load[] = realpath($package . $file);
|
||||
require $package . $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $namespace;
|
||||
}
|
||||
|
||||
// 注册composer自动加载
|
||||
private static function registerComposerLoader()
|
||||
{
|
||||
|
||||
@@ -646,7 +646,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
* @param bool $replace 是否replace
|
||||
* @return array|false
|
||||
*/
|
||||
public function saveAll($dataSet, $repalce = false)
|
||||
public function saveAll($dataSet, $replace = false)
|
||||
{
|
||||
$result = [];
|
||||
$db = $this->db();
|
||||
|
||||
@@ -479,9 +479,9 @@ INSERT INTO `sent_config` (`id`, `name`, `type`, `title`, `group`, `extra`, `rem
|
||||
(11, 'deny_visit', 'textarea', '超管专限控制器方法', 99, '', '仅超级管理员可访问的控制器方法', '', 1386644141, 1438075628, 1, '0:Addons/addhook\r\n1:Addons/edithook\r\n2:Addons/delhook\r\n3:Addons/updateHook\r\n4:Admin/getMenus\r\n5:Admin/recordList\r\n6:AuthManager/updateRules\r\n7:AuthManager/tree', 0),
|
||||
(12, 'admin_allow_ip', 'text', '后台允许访问IP', 99, '', '多个用逗号分隔,如果不配置表示不限制IP访问', '', 1387165454, 1452307198, 1, '', 12),
|
||||
(13, 'show_page_trace', 'bool', '是否显示页面Trace', 99, '0:关闭\r\n1:开启', '是否显示页面Trace信息', '', 1387165685, 1447306056, 1, '0', 1),
|
||||
(14, 'web_site_title', 'text', '网站标题', 1, '', '网站标题前台显示标题', '', 1378898976, 1379235274, 1, '内蒙古师范大学', 0),
|
||||
(14, 'web_site_title', 'text', '网站标题', 1, '', '网站标题前台显示标题', '', 1378898976, 1379235274, 1, 'SentCMS网站管理系统', 0),
|
||||
(15, 'web_site_url', 'text', '网站URL', 1, '', '网站网址', '', 1378898976, 1379235274, 1, 'http://n.dxpd.cn', 1),
|
||||
(16, 'web_site_description', 'textarea', '网站描述', 1, '', '网站搜索引擎描述', '', 1378898976, 1379235841, 1, '内蒙古师范大学', 3),
|
||||
(16, 'web_site_description', 'textarea', '网站描述', 1, '', '网站搜索引擎描述', '', 1378898976, 1379235841, 1, 'SentCMS网站管理系统', 3),
|
||||
(17, 'web_site_keyword', 'textarea', '网站关键字', 1, '', '网站搜索引擎关键字', '', 1378898976, 1381390100, 1, 'SentCMS网站管理系统,SentCMS', 6),
|
||||
(18, 'web_site_close', 'bool', '关闭站点', 1, '0:否,1:是', '站点关闭后其他用户不能访问,管理员可以正常访问', '', 1378898976, 1447321395, 1, '0', 4),
|
||||
(19, 'web_site_icp', 'text', '网站备案号', 1, '', '设置在网站底部显示的备案号,如“赣ICP备13006622号', '', 1378900335, 1379235859, 1, '赣ICP备13006622号', 7),
|
||||
@@ -1506,7 +1506,7 @@ CREATE TABLE IF NOT EXISTS `sent_seo_rule` (
|
||||
--
|
||||
|
||||
INSERT INTO `sent_seo_rule` (`id`, `title`, `app`, `controller`, `action`, `status`, `seo_title`, `seo_keywords`, `seo_description`, `sort`) VALUES
|
||||
(1, '整站标题', '', '', '', 1, '内蒙古师范大学', '内蒙古师范大学', '内蒙古师范大学', 7);
|
||||
(1, '整站标题', '', '', '', 1, 'SentCMS网站管理系统', 'SentCMS网站管理系统', 'SentCMS网站管理系统', 7);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user