内核更新

This commit is contained in:
2016-07-22 14:33:13 +08:00
parent 265a9da552
commit c4ba53fd9e
10 changed files with 80 additions and 44 deletions

View File

@@ -1,6 +1,18 @@
## SentCMS介绍
> SentCMS网站管理系统是南昌腾速科技有限公司倾力打造的一款简单易用的网站管理系统SentCMS网站管理系统下文简称SentCMS继承了thinkphp5.0的优秀品质秉承“大道至简”的设计理念。SnetCMS为网站建设而生为网站建设减少90%的代码编写,只需前端设计师就可以设计出完美的网站,而如此完美的系统还是完全开源的。
## 安装
目前暂无安装文件,可按以下方法安装:
* 第一步、修改数据库配置文件 application/database.php
* 第二步、通过数据库导入工具比如phpmyadmin导入数据数据sql文件data/sql.sql
* 第三步、登录后台,后台地址 http://域名/admin
> 系统必须开启伪静态
初始账号admin密码admin888
## SentCMS特性包括
* 全新的路由体系,完美的路由解决方案
* 全新的系统架构采用thinkphp5.0内核框架
@@ -48,23 +60,10 @@
│ ├─ueditor.json 编辑配置文件
├─core thinkphp框架目录
├─data 缓存以及备份目录
├─extend 扩展类库目录(后期可能会变更目录)
├─public 公共资源库
├─uploads 上传文件目录
├─.htaccess Apache下伪静态文件
├─favicon.ico ico图标
├─index.php 入口文件
├─README.md 系统介绍文件
~~~
## 安装
目前暂无安装文件,可按以下方法安装:
* 第一步、修改数据库配置文件 application/database.php
* 第二步、通过数据库导入工具比如phpmyadmin导入数据数据sql文件data/sql.sql
* 第三步、登录后台,后台地址 http://域名/admin
> 系统必须开启伪静态
初始账号admin密码admin888
~~~

View File

@@ -17,9 +17,9 @@ return array(
// 数据库名
'database' => 'sentcms_www',
// 数据库用户名
'username' => 'root',
'username' => 'sentcms_www',
// 数据库密码
'password' => 'nitbbs_org',
'password' => '',
// 数据库连接端口
'hostport' => '',
// 数据库连接参数

View File

@@ -238,8 +238,9 @@ class App
foreach ($params as $param) {
$name = $param->getName();
$class = $param->getClass();
if ($class && 'think\Request' == $class->getName()) {
$args[] = Request::instance();
if ($class) {
$className = $class->getName();
$args[] = method_exists($className, 'instance') ? $className::instance() : new $className();
} elseif (1 == $type && !empty($vars)) {
$args[] = array_shift($vars);
} elseif (0 == $type && isset($vars[$name])) {
@@ -465,7 +466,7 @@ class App
*/
public static function routeCheck($request, array $config)
{
$path = $request->path();
$path = rtrim($request->path(), '/');
$depr = $config['pathinfo_depr'];
$result = false;
// 路由检测

View File

@@ -195,12 +195,23 @@ class File extends SplFileObject
{
$extension = strtolower(pathinfo($this->getInfo('name'), PATHINFO_EXTENSION));
/* 对图像文件进行严格检测 */
if (in_array($extension, ['gif', 'jpg', 'jpeg', 'bmp', 'png', 'swf']) && !in_array(exif_imagetype($this->filename), [1, 2, 3, 4, 6])) {
if (in_array($extension, ['gif', 'jpg', 'jpeg', 'bmp', 'png', 'swf']) && !in_array($this->getImageType($this->filename), [1, 2, 3, 4, 6])) {
return false;
}
return true;
}
// 判断图像类型
protected function getImageType($image)
{
if (function_exists('exif_imagetype')) {
return exif_imagetype($image);
} else {
$info = getimagesize($image);
return $info[2];
}
}
/**
* 检测上传文件大小
* @param integer $size 最大大小

View File

@@ -99,7 +99,7 @@ class Loader
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DS);
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DS);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DS) . EXT;
@@ -155,13 +155,13 @@ class Loader
if (!$prefix) {
if ($prepend) {
self::$fallbackDirsPsr0 = array_merge(
(array)$paths,
(array) $paths,
self::$fallbackDirsPsr0
);
} else {
self::$fallbackDirsPsr0 = array_merge(
self::$fallbackDirsPsr0,
(array)$paths
(array) $paths
);
}
@@ -170,24 +170,23 @@ class Loader
$first = $prefix[0];
if (!isset(self::$prefixesPsr0[$first][$prefix])) {
self::$prefixesPsr0[$first][$prefix] = (array)$paths;
self::$prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
self::$prefixesPsr0[$first][$prefix] = array_merge(
(array)$paths,
(array) $paths,
self::$prefixesPsr0[$first][$prefix]
);
} else {
self::$prefixesPsr0[$first][$prefix] = array_merge(
self::$prefixesPsr0[$first][$prefix],
(array)$paths
(array) $paths
);
}
}
// 添加Psr4空间
private static function addPsr4($prefix, $paths, $prepend = false)
{
@@ -195,13 +194,13 @@ class Loader
// Register directories for the root namespace.
if ($prepend) {
self::$fallbackDirsPsr4 = array_merge(
(array)$paths,
(array) $paths,
self::$fallbackDirsPsr4
);
} else {
self::$fallbackDirsPsr4 = array_merge(
self::$fallbackDirsPsr4,
(array)$paths
(array) $paths
);
}
} elseif (!isset(self::$prefixDirsPsr4[$prefix])) {
@@ -211,23 +210,22 @@ class Loader
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
self::$prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
self::$prefixDirsPsr4[$prefix] = (array)$paths;
self::$prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
self::$prefixDirsPsr4[$prefix] = array_merge(
(array)$paths,
(array) $paths,
self::$prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
self::$prefixDirsPsr4[$prefix] = array_merge(
self::$prefixDirsPsr4[$prefix],
(array)$paths
(array) $paths
);
}
}
// 注册命名空间别名
public static function addNamespaceAlias($namespace, $original = '')
{
@@ -308,8 +306,8 @@ class Loader
public static function import($class, $baseUrl = '', $ext = EXT)
{
static $_file = [];
$key = $class . $baseUrl;
$class = str_replace(['.', '#'], [DS, '.'], $class);
$key = $class . $baseUrl;
$class = str_replace(['.', '#'], [DS, '.'], $class);
if (isset($_file[$key])) {
return true;
}
@@ -548,4 +546,4 @@ function __include_file($file)
function __require_file($file)
{
return require $file;
}
}

View File

@@ -1093,7 +1093,7 @@ class Route
foreach ($matches[1] as $name) {
if (strpos($name, '?')) {
$name = substr($name, 0, -1);
$replace[] = '((' . (isset($pattern[$name]) ? $pattern[$name] : '') . ')?)';
$replace[] = '(' . (isset($pattern[$name]) ? $pattern[$name] : '') . '?)';
} else {
$replace[] = '(' . (isset($pattern[$name]) ? $pattern[$name] : '') . ')';
}
@@ -1112,11 +1112,17 @@ class Route
if (0 === strpos($val, '[:')) {
// 可选参数
$val = substr($val, 1, -1);
$val = substr($val, 1, -1);
$optional = true;
} else {
$optional = false;
}
if (0 === strpos($val, ':')) {
// URL变量
$name = substr($val, 1);
if (!$optional && !isset($m1[$key])) {
return false;
}
if (isset($m1[$key]) && isset($pattern[$name]) && !preg_match('/^' . $pattern[$name] . '$/', $m1[$key])) {
// 检查变量规则
return false;

View File

@@ -19,6 +19,9 @@ use think\Route;
class Url
{
// 生成URL地址的root
protected static $root;
/**
* URL生成 支持路由反射
* @param string $url URL表达式
@@ -113,7 +116,7 @@ class Url
// 检测域名
$domain = self::parseDomain($url, $domain);
// URL组装
$url = $domain . Request::instance()->root() . '/' . ltrim($url, '/');
$url = $domain . (self::$root ?: Request::instance()->root()) . '/' . ltrim($url, '/');
return $url;
}
@@ -316,4 +319,11 @@ class Url
{
Cache::rm('think_route_map');
}
}
// 指定当前生成URL地址的root
public static function root($root)
{
self::$root = $root;
Request::instance()->root($root);
}
}

View File

@@ -561,7 +561,7 @@ class Validate
$result = $value instanceof \think\File;
break;
case 'image':
$result = $value instanceof \think\File && in_array(exif_imagetype($value->getRealPath()), [1, 2, 3, 6]);
$result = $value instanceof \think\File && in_array($this->getImageType($value->getRealPath()), [1, 2, 3, 6]);
break;
default:
if (isset(self::$type[$rule])) {
@@ -575,6 +575,17 @@ class Validate
return $result;
}
// 判断图像类型
protected function getImageType($image)
{
if (function_exists('exif_imagetype')) {
return exif_imagetype($image);
} else {
$info = getimagesize($image);
return $info[2];
}
}
/**
* 验证是否为合格的域名或者IP 支持AMXNSSOAPTRCNAMEAAAAA6 SRVNAPTRTXT 或者 ANY类型
* @access protected
@@ -699,7 +710,7 @@ class Validate
if ('jpeg' == $imageType) {
$imageType = 'jpg';
}
if (image_type_to_extension($type) != $imageType) {
if (image_type_to_extension($type, false) != $imageType) {
return false;
}
}

View File

@@ -284,7 +284,7 @@ abstract class Connection
if ($this->linkID) {
return $this->linkID->getAttribute(PDO::ATTR_DRIVER_NAME);
} else {
return basename(str_replace('\\', '/', $this->config['type']));
return $this->config['type'];
}
}

View File

@@ -359,7 +359,7 @@ class Query
static $builder = [];
$driver = $this->driver;
if (!isset($builder[$driver])) {
$class = '\\think\\db\\builder\\' . ucfirst($driver);
$class = false !== strpos($driver, '\\') ? $driver : '\\think\\db\\builder\\' . ucfirst($driver);
$builder[$driver] = new $class($this->connection);
}
// 设置当前查询对象