From 34a507a783f9de322e8d42a9fb7033488cbfcc87 Mon Sep 17 00:00:00 2001 From: filesite Date: Fri, 30 Sep 2022 18:57:24 +0800 Subject: [PATCH] change array define --- conf/app.php | 15 +++- conf/template_googleimage.php | 4 +- conf/template_manual.php | 4 +- conf/template_webdirectory.php | 4 +- controller/Controller.php | 4 +- lib/DirScanner.php | 74 +++++++++---------- lib/FSC.php | 2 +- .../googleimage/controller/ListController.php | 8 +- .../googleimage/controller/SiteController.php | 6 +- themes/googleimage/views/site/index.php | 4 +- themes/manual/controller/SiteController.php | 2 +- themes/manual/controller/ViewController.php | 2 +- .../videoblog/controller/ListController.php | 8 +- .../videoblog/controller/SiteController.php | 6 +- .../videoblog/controller/ViewController.php | 2 +- themes/videoblog/views/site/index.php | 6 +- themes/videoblog/views/view/index.php | 6 +- .../controller/SiteController.php | 6 +- 18 files changed, 85 insertions(+), 78 deletions(-) diff --git a/conf/app.php b/conf/app.php index b3112fb..6f324a4 100644 --- a/conf/app.php +++ b/conf/app.php @@ -31,15 +31,22 @@ return array( //for themes /* //图片皮肤配置 - 'googleimage' => [ + 'googleimage' => array( 'imageHeight' => 350, //图片高度,单位:px 'contact' => 'FileSite图片网站订制联系:FileSite.io', - ], + ), */ //视频皮肤配置 - 'videoblog' => [ + 'videoblog' => array( 'imageHeight' => 180, //图片高度,单位:px 'contact' => 'FileSite视频网站订制联系:FileSite.io', - ], + ), + + //后台管理相关配置 + 'admin' => array( + 'username' => 'filesite', + 'password' => '88888888', + ), + ); diff --git a/conf/template_googleimage.php b/conf/template_googleimage.php index 38bca54..1442df7 100644 --- a/conf/template_googleimage.php +++ b/conf/template_googleimage.php @@ -25,8 +25,8 @@ return array( 'debug' => false, //for themes - 'googleimage' => [ + 'googleimage' => array( 'imageHeight' => 350, //图片高度,单位:px 'contact' => 'FileSite图片网站订制联系:FileSite.io', - ], + ), ); diff --git a/conf/template_manual.php b/conf/template_manual.php index 3590f1d..dd57268 100644 --- a/conf/template_manual.php +++ b/conf/template_manual.php @@ -25,8 +25,8 @@ return array( 'debug' => false, //for themes - //'googleimage' => [ + //'googleimage' => array( // 'imageHeight' => 350, //图片高度,单位:px // 'contact' => 'FileSite图片网站订制联系:FileSite.io', - //], + //), ); diff --git a/conf/template_webdirectory.php b/conf/template_webdirectory.php index 6905081..9189a75 100644 --- a/conf/template_webdirectory.php +++ b/conf/template_webdirectory.php @@ -25,8 +25,8 @@ return array( 'debug' => false, //for themes - //'googleimage' => [ + //'googleimage' => array( // 'imageHeight' => 350, //图片高度,单位:px // 'contact' => 'FileSite图片网站订制联系:FileSite.io', - //], + //), ); diff --git a/controller/Controller.php b/controller/Controller.php index 2008895..efc1662 100644 --- a/controller/Controller.php +++ b/controller/Controller.php @@ -214,7 +214,7 @@ Class Controller { if (!empty($names)) { $menus_sorted = array_keys($names); - $arr = []; + $arr = array(); foreach($menus_sorted as $name) { $index = array_search($name, $menu_dirs); array_push($arr, $menus[$index]); @@ -229,7 +229,7 @@ Class Controller { if (!empty($names)) { $sorted_dirs = array_keys($names); - $arr = []; + $arr = array(); foreach($sorted_dirs as $name) { foreach($dirTree as $index => $item) { if (!empty($item['directory']) && $item['directory'] == $name) { diff --git a/lib/DirScanner.php b/lib/DirScanner.php index 389319d..706f2c4 100644 --- a/lib/DirScanner.php +++ b/lib/DirScanner.php @@ -10,12 +10,12 @@ Class DirScanner { private $userIp = '127.0.0.1'; //用户IP地址 private $nginxSecureTimeout = 1800; //Nginx防盗链有效期,单位:秒 private $nginxSecureLinkMd5Pattern = '{secure_link_expires}{uri}{remote_addr} {secret}'; //Nginx防盗链MD5加密方式 - private $allowReadContentFileExtensions = [ //允许读取文件内容的文件类型 + private $allowReadContentFileExtensions = array( //允许读取文件内容的文件类型 'txt', 'md', 'url', - ]; - private $fields = [ //私有属性字段名和说明 + ); + private $fields = array( //私有属性字段名和说明 'directory' => '目录名', 'filename' => '文件名', 'realpath' => '完整路径', @@ -28,16 +28,16 @@ Class DirScanner { 'description' => '描述', 'keywords' => '关键词', 'snapshot' => '快照图片', - ]; + ); private $rootDir; //当前扫描的根目录 private $webRoot = '/content/'; //网站静态文件相对路径的根目录 private $scanningDirLevel = 0; //当前扫描的目录深度 private $scanStartTime = 0; //扫描开始时间,单位:秒 - private $scanResults = []; //目录扫描结果 - private $tree = []; //目录扫描树形结构 + private $scanResults = array(); //目录扫描结果 + private $tree = array(); //目录扫描树形结构 - protected $supportFileExtensions = [ //支持的文件类型 + protected $supportFileExtensions = array( //支持的文件类型 'txt', //纯文本 'md', //纯文本 'url', //快捷方式 @@ -49,8 +49,8 @@ Class DirScanner { 'mp4', //视频 'ts', //视频 'm3u8', //视频 - ]; - protected $maxReadFilesize = [ //默认每种文件读取内容最大大小 + ); + protected $maxReadFilesize = array( //默认每种文件读取内容最大大小 'txt' => 100*1024, //纯文本 'md' => 5*1024*1024, //纯文本 'url' => 20*1024, //快捷方式 @@ -62,8 +62,8 @@ Class DirScanner { 'mp4' => 100*1024*1024, //视频 'ts' => 10*1024*1024, //视频 'm3u8' => 10*1024*1024, //视频 - ]; - protected $securedFileExtensions = [ //开启Nginx防盗链的文件类型 + ); + protected $securedFileExtensions = array( //开启Nginx防盗链的文件类型 'jpg', //图片 'jpeg', //图片 'png', //图片 @@ -72,7 +72,7 @@ Class DirScanner { 'mp4', //视频 'ts', //视频 'm3u8', //视频 - ]; + ); public $scanTimeCost = 0; //上一次目录扫描耗时,单位:毫秒 @@ -93,7 +93,7 @@ Class DirScanner { if (empty($content)) {return [];} $content = trim($content); - $data = []; + $data = array(); if (in_array($field, ['title', 'snapshot'])) { if ($field == 'snapshot') { $img_realpath = realpath("{$pathinfo['dirname']}/{$content}"); @@ -143,12 +143,12 @@ Class DirScanner { private function isNginxSecureLinkMd5PatternValid($pattern) { $valid = true; - $fieldsNeeded = [ + $fieldsNeeded = array( '{secure_link_expires}', '{uri}', '{remote_addr}', '{secret}', - ]; + ); foreach($fieldsNeeded as $needle) { if (strstr($pattern, $needle) === false) { $valid = false; @@ -162,15 +162,15 @@ Class DirScanner { //根据路径生成目录数组 private function getDirData($realpath, $files) { $id = $this->getId($realpath); - $data = [ + $data = array( 'id' => $id, 'directory' => basename($realpath), 'realpath' => $realpath, 'path' => $this->getDirPath($id), - ]; + ); - $sub_dirs = []; - $sub_files = []; + $sub_dirs = array(); + $sub_files = array(); //try to merge description data if (!empty($files[$id])) { @@ -205,19 +205,19 @@ Class DirScanner { fclose($fp); $pathinfo = pathinfo($realpath); $extension = strtolower($pathinfo['extension']); - $data = [ + $data = array( 'id' => $id, 'filename' => $pathinfo['filename'], 'extension' => $extension, - 'fstat' => [ + 'fstat' => array( 'size' => $fstat['size'], 'atime' => $fstat['atime'], 'mtime' => $fstat['mtime'], 'ctime' => $fstat['ctime'], - ], + ), 'realpath' => $realpath, 'path' => $this->getFilePath( $id, $this->getRelativeDirname($pathinfo['dirname']), $pathinfo['filename'], $extension, $fstat['mtime'] ), - ]; + ); if ($extension == 'url') { $data['shortcut'] = $this->parseShortCuts($realpath, $pathinfo['filename']); @@ -251,7 +251,7 @@ Class DirScanner { //合并描述文件内容到md文件或者目录数据 //增加视频文件:mp4, m3u8描述文件支持 private function mergeDescriptionData($realpath) { - $data = []; + $data = array(); $ext = $this->parseDescriptionFiles($realpath); //try to find the md file @@ -337,7 +337,7 @@ Class DirScanner { } $webRoot = preg_replace('/\/$/', '', $this->webRoot); - $extensionPathMap = [ //默认每种文件读取内容最大大小 + $extensionPathMap = array( //默认每种文件读取内容最大大小 'txt' => '', 'md' => '/view/', 'url' => '/link/', @@ -349,7 +349,7 @@ Class DirScanner { 'ico' => "{$webRoot}{$directory}{$filename}.{$extension}", 'mp4' => "{$webRoot}{$directory}{$filename}.{$extension}", 'ts' => "{$webRoot}{$directory}{$filename}.{$extension}", - ]; + ); $path = isset($extensionPathMap[$extension]) ? $extensionPathMap[$extension] : ''; @@ -515,10 +515,10 @@ Class DirScanner { foreach($files as $file) { if (in_array($file, $ignore_files) || !$this->isValid($file)) {continue;} - $branch = []; + $branch = array(); $realpath = realpath("{$dir}{$file}"); if (is_dir($realpath)) { - $files = []; + $files = array(); if ($nextLevels >= 0) { $files = $this->scan($realpath, $levels); if (!empty($files)) { @@ -575,19 +575,19 @@ Class DirScanner { } //获取菜单,扫描结果中的目录结构 - public function getMenus($tree = []) { + public function getMenus($tree = array()) { $results = empty($tree) ? $this->tree : $tree; - $menus = []; + $menus = array(); if (empty($results)) {return $menus;} foreach ($results as $id => $item) { - $dir = []; + $dir = array(); if (!empty($item['directory'])) { - $dir = [ + $dir = array( 'id' => $item['id'], 'directory' => $item['directory'], 'path' => $item['path'], - ]; + ); if (!empty($item['snapshot'])) { $dir['snapshot'] = $item['snapshot']; } @@ -633,17 +633,17 @@ Class DirScanner { # split text into lines $lines = explode("\n", $content); - $titles = []; + $titles = array(); if (!empty($lines)) { foreach($lines as $line) { preg_match_all('/^#(.+)/u', $line, $matches); if (!empty($matches[1])) { foreach($matches[1] as $title) { $num = substr_count($title, '#'); - $titles[] = [ + $titles[] = array( 'name' => trim(str_replace('#', '', $title)), 'heading' => 'h' . ($num+1), - ]; + ); } } } @@ -656,7 +656,7 @@ Class DirScanner { public function fixMDUrls($realpath, $html) { $pathinfo = pathinfo($realpath); - $matches = []; + $matches = array(); //匹配图片地址 $reg_imgs = '/src="([^"]+)"/i'; diff --git a/lib/FSC.php b/lib/FSC.php index 226f635..d083875 100644 --- a/lib/FSC.php +++ b/lib/FSC.php @@ -7,7 +7,7 @@ Class FSC { protected static $start_time = 0; //call function in controller - public static function run($config = []) { + public static function run($config = array()) { self::$start_time = !empty($config['start_time']) ? $config['start_time'] : microtime(true); try { diff --git a/themes/googleimage/controller/ListController.php b/themes/googleimage/controller/ListController.php index bfc7d18..5e60b7d 100644 --- a/themes/googleimage/controller/ListController.php +++ b/themes/googleimage/controller/ListController.php @@ -9,10 +9,10 @@ Class ListController extends Controller { public function actionIndex() { //获取数据 - $menus = []; //菜单,一级目录 + $menus = array(); //菜单,一级目录 $htmlReadme = ''; //Readme.md 内容,底部网站详细介绍 $htmlCateReadme = ''; //当前目录下的Readme.md 内容 - $menus_sorted = []; //Readme_sort.txt 说明文件内容,一级目录菜单从上到下的排序 + $menus_sorted = array(); //Readme_sort.txt 说明文件内容,一级目录菜单从上到下的排序 $scanner = new DirScanner(); $scanner->setWebRoot(FSC::$app['config']['content_directory']); @@ -22,7 +22,7 @@ Class ListController extends Controller { //获取目录 $menus = $scanner->getMenus(); - $titles = []; + $titles = array(); $readmeFile = $scanner->getDefaultReadme(); if (!empty($readmeFile)) { if (!empty($readmeFile['sort'])) { @@ -72,7 +72,7 @@ Class ListController extends Controller { //根据目录结构以及当前目录获取面包屑 protected function getBreadcrumbs($menus, $subcate) { - $breads = []; + $breads = array(); array_push($breads, [ 'id' => $subcate['id'], diff --git a/themes/googleimage/controller/SiteController.php b/themes/googleimage/controller/SiteController.php index 3f9e268..5069597 100644 --- a/themes/googleimage/controller/SiteController.php +++ b/themes/googleimage/controller/SiteController.php @@ -9,10 +9,10 @@ Class SiteController extends Controller { public function actionIndex() { //获取数据 - $menus = []; //菜单,一级目录 + $menus = array(); //菜单,一级目录 $htmlReadme = ''; //Readme.md 内容,底部网站详细介绍 $htmlCateReadme = ''; //当前目录下的Readme.md 内容 - $menus_sorted = []; //Readme_sort.txt 说明文件内容,一级目录菜单从上到下的排序 + $menus_sorted = array(); //Readme_sort.txt 说明文件内容,一级目录菜单从上到下的排序 $scanner = new DirScanner(); $scanner->setWebRoot(FSC::$app['config']['content_directory']); @@ -22,7 +22,7 @@ Class SiteController extends Controller { //获取目录 $menus = $scanner->getMenus(); - $titles = []; + $titles = array(); $readmeFile = $scanner->getDefaultReadme(); if (!empty($readmeFile)) { if (!empty($readmeFile['sort'])) { diff --git a/themes/googleimage/views/site/index.php b/themes/googleimage/views/site/index.php index b382566..5c8bd92 100644 --- a/themes/googleimage/views/site/index.php +++ b/themes/googleimage/views/site/index.php @@ -42,7 +42,7 @@ eof;
-
\ No newline at end of file + diff --git a/themes/manual/controller/SiteController.php b/themes/manual/controller/SiteController.php index fa524e2..33be12d 100644 --- a/themes/manual/controller/SiteController.php +++ b/themes/manual/controller/SiteController.php @@ -9,7 +9,7 @@ Class SiteController extends Controller { public function actionIndex() { //获取数据 - $titles = []; + $titles = array(); $content = ''; $html = ''; diff --git a/themes/manual/controller/ViewController.php b/themes/manual/controller/ViewController.php index 9b20ea5..93282a8 100644 --- a/themes/manual/controller/ViewController.php +++ b/themes/manual/controller/ViewController.php @@ -15,7 +15,7 @@ Class ViewController extends Controller { } //获取数据 - $titles = []; + $titles = array(); $content = ''; $html = ''; diff --git a/themes/videoblog/controller/ListController.php b/themes/videoblog/controller/ListController.php index 505a15a..c219e98 100644 --- a/themes/videoblog/controller/ListController.php +++ b/themes/videoblog/controller/ListController.php @@ -9,10 +9,10 @@ Class ListController extends Controller { public function actionIndex() { //获取数据 - $menus = []; //菜单,一级目录 + $menus = array(); //菜单,一级目录 $htmlReadme = ''; //Readme.md 内容,底部网站详细介绍 $htmlCateReadme = ''; //当前目录下的Readme.md 内容 - $menus_sorted = []; //Readme_sort.txt 说明文件内容,一级目录菜单从上到下的排序 + $menus_sorted = array(); //Readme_sort.txt 说明文件内容,一级目录菜单从上到下的排序 $scanner = new DirScanner(); $scanner->setWebRoot(FSC::$app['config']['content_directory']); @@ -22,7 +22,7 @@ Class ListController extends Controller { //获取目录 $menus = $scanner->getMenus(); - $titles = []; + $titles = array(); $readmeFile = $scanner->getDefaultReadme(); if (!empty($readmeFile)) { if (!empty($readmeFile['sort'])) { @@ -72,7 +72,7 @@ Class ListController extends Controller { //根据目录结构以及当前目录获取面包屑 protected function getBreadcrumbs($menus, $subcate) { - $breads = []; + $breads = array(); if (!empty($subcate['directory'])) { array_push($breads, [ diff --git a/themes/videoblog/controller/SiteController.php b/themes/videoblog/controller/SiteController.php index 740b922..04494e5 100644 --- a/themes/videoblog/controller/SiteController.php +++ b/themes/videoblog/controller/SiteController.php @@ -9,10 +9,10 @@ Class SiteController extends Controller { public function actionIndex() { //获取数据 - $menus = []; //菜单,一级目录 + $menus = array(); //菜单,一级目录 $htmlReadme = ''; //Readme.md 内容,底部网站详细介绍 $htmlCateReadme = ''; //当前目录下的Readme.md 内容 - $menus_sorted = []; //Readme_sort.txt 说明文件内容,一级目录菜单从上到下的排序 + $menus_sorted = array(); //Readme_sort.txt 说明文件内容,一级目录菜单从上到下的排序 $scanner = new DirScanner(); $scanner->setWebRoot(FSC::$app['config']['content_directory']); @@ -22,7 +22,7 @@ Class SiteController extends Controller { //获取目录 $menus = $scanner->getMenus(); - $titles = []; + $titles = array(); $htmlReadme = ''; $readmeFile = $scanner->getDefaultReadme(); if (!empty($readmeFile)) { diff --git a/themes/videoblog/controller/ViewController.php b/themes/videoblog/controller/ViewController.php index a8f2376..54b95fc 100644 --- a/themes/videoblog/controller/ViewController.php +++ b/themes/videoblog/controller/ViewController.php @@ -26,7 +26,7 @@ Class ViewController extends ListController { //获取目录 $menus = $scanner->getMenus(); - $titles = []; + $titles = array(); $htmlReadme = ''; $readmeFile = $scanner->getDefaultReadme(); if (!empty($readmeFile)) { diff --git a/themes/videoblog/views/site/index.php b/themes/videoblog/views/site/index.php index 6293510..a633f44 100644 --- a/themes/videoblog/views/site/index.php +++ b/themes/videoblog/views/site/index.php @@ -42,8 +42,8 @@ eof;
-
\ No newline at end of file + diff --git a/themes/videoblog/views/view/index.php b/themes/videoblog/views/view/index.php index 034830b..a126caa 100644 --- a/themes/videoblog/views/view/index.php +++ b/themes/videoblog/views/view/index.php @@ -1,8 +1,8 @@ - \ No newline at end of file + diff --git a/themes/webdirectory/controller/SiteController.php b/themes/webdirectory/controller/SiteController.php index 26d2721..185ed40 100644 --- a/themes/webdirectory/controller/SiteController.php +++ b/themes/webdirectory/controller/SiteController.php @@ -9,12 +9,12 @@ Class SiteController extends Controller { public function actionIndex() { //获取数据 - $menus = []; //菜单,一级目录 + $menus = array(); //菜单,一级目录 $htmlReadme = ''; //Readme.md 内容,底部网站详细介绍 $htmlContact = ''; //Readme_contact.txt 说明文件内容,右侧悬浮菜单里的“联系我” - $menus_sorted = []; //Readme_sort.txt 说明文件内容,一级目录菜单从上到下的排序 + $menus_sorted = array(); //Readme_sort.txt 说明文件内容,一级目录菜单从上到下的排序 - $titles = []; + $titles = array(); $content = ''; $scanner = new DirScanner();