From 65c637b28e6e16a7eab992e470f83be28d6fd732 Mon Sep 17 00:00:00 2001 From: devil_gong Date: Fri, 11 Jan 2019 17:35:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E9=A2=98=E8=99=9A=E6=8B=9F=E6=9C=BA?= =?UTF-8?q?=E4=B8=8B=E5=9C=B0=E5=9D=80=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/config/app.php | 18 +++---- application/admin/controller/Common.php | 2 +- application/admin/controller/Ueditor.php | 2 +- .../admin/view/default/public/footer.html | 30 ++++++------ .../admin/view/default/public/header.html | 16 +++---- application/api/controller/Common.php | 2 +- application/index/controller/Common.php | 2 +- .../index/view/default/public/footer.html | 32 ++++++------- .../index/view/default/public/header.html | 18 +++---- application/install/controller/Common.php | 2 +- application/install/view/public/footer.html | 8 ++-- application/install/view/public/header.html | 12 ++--- application/service/ResourcesService.php | 4 +- application/service/ThemeService.php | 9 +++- public/core.php | 48 +++++++++---------- 15 files changed, 105 insertions(+), 100 deletions(-) diff --git a/application/admin/config/app.php b/application/admin/config/app.php index 3631d367c..977df45ed 100755 --- a/application/admin/config/app.php +++ b/application/admin/config/app.php @@ -59,7 +59,7 @@ return [ 'imageUrlPrefix' => '', // 上传保存路径,可以自定义保存路径和文件名格式 - 'imagePathFormat' => __MY_ROOT__.'static/upload/images/'.input('path_type', 'other').'/{yyyy}/{mm}/{dd}/{time}{rand:6}', + 'imagePathFormat' => __MY_ROOT_PUBLIC__.'static/upload/images/'.input('path_type', 'other').'/{yyyy}/{mm}/{dd}/{time}{rand:6}', // 涂鸦图片上传配置项 @@ -70,7 +70,7 @@ return [ 'scrawlFieldName' => 'upfile', // 上传保存路径,可以自定义保存路径和文件名格式 - 'scrawlPathFormat' => __MY_ROOT__.'static/upload/images/'.input('path_type', 'other').'/{yyyy}/{mm}/{dd}/{time}{rand:6}', + 'scrawlPathFormat' => __MY_ROOT_PUBLIC__.'static/upload/images/'.input('path_type', 'other').'/{yyyy}/{mm}/{dd}/{time}{rand:6}', // 上传大小限制,单位B 'scrawlMaxSize' => MyC('home_max_limit_image', 2048000, true), @@ -87,7 +87,7 @@ return [ 'snapscreenActionName' => 'uploadimage', // 上传保存路径,可以自定义保存路径和文件名格式 - 'snapscreenPathFormat' => __MY_ROOT__.'static/upload/images/'.input('path_type', 'other').'/{yyyy}/{mm}/{dd}/{time}{rand:6}', + 'snapscreenPathFormat' => __MY_ROOT_PUBLIC__.'static/upload/images/'.input('path_type', 'other').'/{yyyy}/{mm}/{dd}/{time}{rand:6}', // 图片访问路径前缀 'snapscreenUrlPrefix' => '', @@ -107,7 +107,7 @@ return [ 'catcherFieldName' => 'source', // 上传保存路径,可以自定义保存路径和文件名格式 - 'catcherPathFormat' => __MY_ROOT__.'static/upload/images/'.input('path_type', 'other').'/{yyyy}/{mm}/{dd}/{time}{rand:6}', + 'catcherPathFormat' => __MY_ROOT_PUBLIC__.'static/upload/images/'.input('path_type', 'other').'/{yyyy}/{mm}/{dd}/{time}{rand:6}', // 图片访问路径前缀 'catcherUrlPrefix' => '', @@ -127,7 +127,7 @@ return [ 'videoFieldName' => 'upfile', // 上传保存路径,可以自定义保存路径和文件名格式 - 'videoPathFormat' => __MY_ROOT__.'static/upload/video/'.input('path_type', 'other').'/{yyyy}/{mm}/{dd}/{time}{rand:6}', + 'videoPathFormat' => __MY_ROOT_PUBLIC__.'static/upload/video/'.input('path_type', 'other').'/{yyyy}/{mm}/{dd}/{time}{rand:6}', // 视频访问路径前缀 'videoUrlPrefix' => '', @@ -147,7 +147,7 @@ return [ 'fileFieldName' => 'upfile', // 上传保存路径,可以自定义保存路径和文件名格式 - 'filePathFormat' => __MY_ROOT__.'static/upload/file/'.input('path_type', 'other').'/{yyyy}/{mm}/{dd}/{time}{rand:6}', + 'filePathFormat' => __MY_ROOT_PUBLIC__.'static/upload/file/'.input('path_type', 'other').'/{yyyy}/{mm}/{dd}/{time}{rand:6}', // 文件访问路径前缀 'fileUrlPrefix' => '', @@ -164,7 +164,7 @@ return [ 'imageManagerActionName'=> 'listimage', // 指定要列出图片的目录 - 'imageManagerListPath' => __MY_ROOT__.'static/upload/images/'.input('path_type', 'other').'/', + 'imageManagerListPath' => __MY_ROOT_PUBLIC__.'static/upload/images/'.input('path_type', 'other').'/', // 每次列出文件数量 'imageManagerListSize' => 20, @@ -184,7 +184,7 @@ return [ 'fileManagerActionName' => 'listfile', // 指定要列出文件的目录 - 'fileManagerListPath' => __MY_ROOT__.'static/upload/file/'.input('path_type', 'other').'/', + 'fileManagerListPath' => __MY_ROOT_PUBLIC__.'static/upload/file/'.input('path_type', 'other').'/', // 文件访问路径前缀 'fileManagerUrlPrefix' => '', @@ -199,7 +199,7 @@ return [ 'videoManagerActionName' => 'listvideo', // 指定要列出文件的目录 - 'videoManagerListPath' => __MY_ROOT__.'static/upload/video/'.input('path_type', 'other').'/', + 'videoManagerListPath' => __MY_ROOT_PUBLIC__.'static/upload/video/'.input('path_type', 'other').'/', // 文件访问路径前缀 'videoManagerUrlPrefix' => '', diff --git a/application/admin/controller/Common.php b/application/admin/controller/Common.php index fbe3b4dce..0729ed62d 100755 --- a/application/admin/controller/Common.php +++ b/application/admin/controller/Common.php @@ -75,7 +75,7 @@ class Common extends Controller ConfigService::ConfigInit(); // url模式,后端采用兼容模式 - \think\facade\Url::root(__MY_ROOT__.'index.php?s='); + \think\facade\Url::root(__MY_ROOT_PUBLIC__.'index.php?s='); } /** diff --git a/application/admin/controller/Ueditor.php b/application/admin/controller/Ueditor.php index 028bc5339..40eab781d 100755 --- a/application/admin/controller/Ueditor.php +++ b/application/admin/controller/Ueditor.php @@ -130,7 +130,7 @@ class Ueditor extends Common $path = input('path'); if(!empty($path)) { - $path = (__MY_ROOT__ == '/') ? substr(ROOT_PATH, 0, -1).$path : str_replace(__MY_ROOT__, ROOT_PATH, $path); + $path = (__MY_ROOT_PUBLIC__ == '/') ? substr(ROOT_PATH, 0, -1).$path : str_replace(__MY_ROOT_PUBLIC__, ROOT_PATH, $path); if(file_exists($path)) { if(is_writable($path)) diff --git a/application/admin/view/default/public/footer.html b/application/admin/view/default/public/footer.html index 473832023..b56463f34 100755 --- a/application/admin/view/default/public/footer.html +++ b/application/admin/view/default/public/footer.html @@ -6,29 +6,29 @@ - - - + + + - - - + + + - + - + - - - - + + + + - + - + {{if !empty($module_js)}} - + {{/if}} \ No newline at end of file diff --git a/application/admin/view/default/public/header.html b/application/admin/view/default/public/header.html index aa50ff5ad..9bfb1348c 100755 --- a/application/admin/view/default/public/header.html +++ b/application/admin/view/default/public/header.html @@ -5,15 +5,15 @@ ShopXO后台管理系统 - - - - - - - + + + + + + + {{if !empty($module_css)}} - + {{/if}} - - - + + + + - - - + + + - + - - - + + + - + - + - - + + {{if !empty($module_js)}} - + {{/if}} {{:MyC('home_footer_info')}} \ No newline at end of file diff --git a/application/index/view/default/public/header.html b/application/index/view/default/public/header.html index 954d63161..e0e6e19e7 100755 --- a/application/index/view/default/public/header.html +++ b/application/index/view/default/public/header.html @@ -17,20 +17,20 @@ - - - - + + + + - - + + {{if !empty($module_css)}} - + {{/if}} - - - \ No newline at end of file + + + + \ No newline at end of file diff --git a/application/install/view/public/header.html b/application/install/view/public/header.html index 046e4469d..cf92b01d0 100755 --- a/application/install/view/public/header.html +++ b/application/install/view/public/header.html @@ -12,11 +12,11 @@ - - - - + + + + - - + + \ No newline at end of file diff --git a/application/service/ResourcesService.php b/application/service/ResourcesService.php index c004784c5..b937ea30d 100755 --- a/application/service/ResourcesService.php +++ b/application/service/ResourcesService.php @@ -42,7 +42,7 @@ class ResourcesService // 内容写入 case 'add': - return str_replace(array(__MY_PUBLIC_URL__.'static/', __MY_ROOT__.'static/'), '/static/', $content); + return str_replace(array(__MY_PUBLIC_URL__.'static/', __MY_ROOT_PUBLIC__.'static/'), '/static/', $content); } return $content; } @@ -58,7 +58,7 @@ class ResourcesService */ public static function AttachmentPathHandle($value) { - return empty($value) ? '' : str_replace([__MY_PUBLIC_URL__, __MY_ROOT__], DS, $value); + return empty($value) ? '' : str_replace([__MY_PUBLIC_URL__, __MY_ROOT_PUBLIC__], DS, $value); } /** diff --git a/application/service/ThemeService.php b/application/service/ThemeService.php index b5bb97061..41389eb95 100755 --- a/application/service/ThemeService.php +++ b/application/service/ThemeService.php @@ -42,9 +42,14 @@ class ThemeService { if($dh = opendir($dir)) { - $default_preview = __MY_URL__.'static'.DS.'common'.DS.'images'.DS.'default-preview.jpg'; + $default_preview = __MY_PUBLIC_URL__.'static'.DS.'common'.DS.'images'.DS.'default-preview.jpg'; while(($temp_file = readdir($dh)) !== false) { + if(in_array($temp_file, ['.', '..', 'index.html'])) + { + continue; + } + $config = $dir.$temp_file.DS.'config.json'; if(!file_exists($config)) { @@ -66,7 +71,7 @@ class ThemeService 'ver' => str_replace(array(',',','), ', ', htmlentities($data['ver'])), 'author' => htmlentities($data['author']), 'home' => isset($data['home']) ? $data['home'] : '', - 'preview' => file_exists($preview) ? __MY_URL__.'static'.DS.'index'.DS.$temp_file.DS.'images'.DS.'preview.jpg' : $default_preview, + 'preview' => file_exists($preview) ? __MY_PUBLIC_URL__.'static'.DS.'index'.DS.$temp_file.DS.'images'.DS.'preview.jpg' : $default_preview, 'is_delete' => ($temp_file == 'default') ? 0 : 1, ); } diff --git a/public/core.php b/public/core.php index e5ac4b417..4442c852c 100755 --- a/public/core.php +++ b/public/core.php @@ -9,39 +9,39 @@ // | Author: Devil // +---------------------------------------------------------------------- +// 检测PHP环境 +if(version_compare(PHP_VERSION,'5.6.0','<')) die('PHP版本最低 5.6.0'); + // 开启缓冲区 ob_start(); -// 检测PHP环境 -if(version_compare(PHP_VERSION,'5.3.0','<')) die('require PHP > 5.3.0 !'); - -// HTTP类型 -define('__MY_HTTP__', (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') ? 'http' : 'https'); - -// 根目录 -$my_root = empty($_SERVER['SCRIPT_NAME']) ? '' : substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/')+1); - -define('__MY_ROOT__', defined('IS_ROOT_ACCESS') ? $my_root.'public/' : $my_root); - -// 项目HOST -define('__MY_HOST__', empty($_SERVER['HTTP_HOST']) ? '' : $_SERVER['HTTP_HOST']); - -// 项目URL地址 -define('__MY_URL__', empty($_SERVER['HTTP_HOST']) ? '' : __MY_HTTP__.'://'.__MY_HOST__.$my_root); - -// 项目public目录URL地址 -define('__MY_PUBLIC_URL__', empty($_SERVER['HTTP_HOST']) ? '' : __MY_HTTP__.'://'.__MY_HOST__.__MY_ROOT__); - -// 当前页面url地址 -$request_url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; -define('__MY_VIEW_URL__', substr(__MY_URL__, 0, -1).$request_url); - // 系统版本 define('APPLICATION_VERSION', 'v1.2.0'); // 定义系统目录分隔符 define('DS', '/'); +// HTTP类型 +define('__MY_HTTP__', (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') ? 'http' : 'https'); + +// 根目录 +$my_root = empty($_SERVER['SCRIPT_NAME']) ? '' : substr($_SERVER['SCRIPT_NAME'], 1, strrpos($_SERVER['SCRIPT_NAME'], '/')); +define('__MY_ROOT__', defined('IS_ROOT_ACCESS') ? $my_root : str_replace('public'.DS, '', $my_root)); +define('__MY_ROOT_PUBLIC__', defined('IS_ROOT_ACCESS') ? DS.$my_root.'public'.DS : DS.$my_root); + +// 项目HOST +define('__MY_HOST__', empty($_SERVER['HTTP_HOST']) ? '' : $_SERVER['HTTP_HOST']); + +// 项目URL地址 +define('__MY_URL__', empty($_SERVER['HTTP_HOST']) ? '' : __MY_HTTP__.'://'.__MY_HOST__.DS.$my_root); + +// 项目public目录URL地址 +define('__MY_PUBLIC_URL__', empty($_SERVER['HTTP_HOST']) ? '' : __MY_HTTP__.'://'.__MY_HOST__.__MY_ROOT_PUBLIC__); + +// 当前页面url地址 +$request_url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; +define('__MY_VIEW_URL__', substr(__MY_URL__, 0, -1).$request_url); + // 系统根目录 define('ROOT_PATH', dirname(__FILE__).DS);