Browse Source

change array define

master
filesite 2 years ago
parent
commit
34a507a783
  1. 15
      conf/app.php
  2. 4
      conf/template_googleimage.php
  3. 4
      conf/template_manual.php
  4. 4
      conf/template_webdirectory.php
  5. 4
      controller/Controller.php
  6. 74
      lib/DirScanner.php
  7. 2
      lib/FSC.php
  8. 8
      themes/googleimage/controller/ListController.php
  9. 6
      themes/googleimage/controller/SiteController.php
  10. 2
      themes/googleimage/views/site/index.php
  11. 2
      themes/manual/controller/SiteController.php
  12. 2
      themes/manual/controller/ViewController.php
  13. 8
      themes/videoblog/controller/ListController.php
  14. 6
      themes/videoblog/controller/SiteController.php
  15. 2
      themes/videoblog/controller/ViewController.php
  16. 4
      themes/videoblog/views/site/index.php
  17. 4
      themes/videoblog/views/view/index.php
  18. 6
      themes/webdirectory/controller/SiteController.php

15
conf/app.php

@ -31,15 +31,22 @@ return array( @@ -31,15 +31,22 @@ return array(
//for themes
/*
//图片皮肤配置
'googleimage' => [
'googleimage' => array(
'imageHeight' => 350, //图片高度,单位:px
'contact' => 'FileSite图片网站订制联系:<a href="https://filesite.io" target="_blank">FileSite.io</a>',
],
),
*/
//视频皮肤配置
'videoblog' => [
'videoblog' => array(
'imageHeight' => 180, //图片高度,单位:px
'contact' => 'FileSite视频网站订制联系:<a href="https://filesite.io" target="_blank">FileSite.io</a>',
],
),
//后台管理相关配置
'admin' => array(
'username' => 'filesite',
'password' => '88888888',
),
);

4
conf/template_googleimage.php

@ -25,8 +25,8 @@ return array( @@ -25,8 +25,8 @@ return array(
'debug' => false,
//for themes
'googleimage' => [
'googleimage' => array(
'imageHeight' => 350, //图片高度,单位:px
'contact' => 'FileSite图片网站订制联系:<a href="https://filesite.io" target="_blank">FileSite.io</a>',
],
),
);

4
conf/template_manual.php

@ -25,8 +25,8 @@ return array( @@ -25,8 +25,8 @@ return array(
'debug' => false,
//for themes
//'googleimage' => [
//'googleimage' => array(
// 'imageHeight' => 350, //图片高度,单位:px
// 'contact' => 'FileSite图片网站订制联系:<a href="https://filesite.io" target="_blank">FileSite.io</a>',
//],
//),
);

4
conf/template_webdirectory.php

@ -25,8 +25,8 @@ return array( @@ -25,8 +25,8 @@ return array(
'debug' => false,
//for themes
//'googleimage' => [
//'googleimage' => array(
// 'imageHeight' => 350, //图片高度,单位:px
// 'contact' => 'FileSite图片网站订制联系:<a href="https://filesite.io" target="_blank">FileSite.io</a>',
//],
//),
);

4
controller/Controller.php

@ -214,7 +214,7 @@ Class Controller { @@ -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 { @@ -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) {

74
lib/DirScanner.php

@ -10,12 +10,12 @@ Class DirScanner { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -72,7 +72,7 @@ Class DirScanner {
'mp4', //视频
'ts', //视频
'm3u8', //视频
];
);
public $scanTimeCost = 0; //上一次目录扫描耗时,单位:毫秒
@ -93,7 +93,7 @@ Class DirScanner { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -656,7 +656,7 @@ Class DirScanner {
public function fixMDUrls($realpath, $html) {
$pathinfo = pathinfo($realpath);
$matches = [];
$matches = array();
//匹配图片地址
$reg_imgs = '/src="([^"]+)"/i';

2
lib/FSC.php

@ -7,7 +7,7 @@ Class FSC { @@ -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 {

8
themes/googleimage/controller/ListController.php

@ -9,10 +9,10 @@ Class ListController extends Controller { @@ -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 { @@ -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 { @@ -72,7 +72,7 @@ Class ListController extends Controller {
//根据目录结构以及当前目录获取面包屑
protected function getBreadcrumbs($menus, $subcate) {
$breads = [];
$breads = array();
array_push($breads, [
'id' => $subcate['id'],

6
themes/googleimage/controller/SiteController.php

@ -9,10 +9,10 @@ Class SiteController extends Controller { @@ -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 { @@ -22,7 +22,7 @@ Class SiteController extends Controller {
//获取目录
$menus = $scanner->getMenus();
$titles = [];
$titles = array();
$readmeFile = $scanner->getDefaultReadme();
if (!empty($readmeFile)) {
if (!empty($readmeFile['sort'])) {

2
themes/googleimage/views/site/index.php

@ -42,7 +42,7 @@ eof; @@ -42,7 +42,7 @@ eof;
<div class="content">
<?php
$imgExts = ['jpg', 'jpeg', 'png', 'gif'];
$imgExts = array('jpg', 'jpeg', 'png', 'gif');
$category = $viewData['scanResults'][$selectedId];
//当前目录的描述介绍

2
themes/manual/controller/SiteController.php

@ -9,7 +9,7 @@ Class SiteController extends Controller { @@ -9,7 +9,7 @@ Class SiteController extends Controller {
public function actionIndex() {
//获取数据
$titles = [];
$titles = array();
$content = '';
$html = '';

2
themes/manual/controller/ViewController.php

@ -15,7 +15,7 @@ Class ViewController extends Controller { @@ -15,7 +15,7 @@ Class ViewController extends Controller {
}
//获取数据
$titles = [];
$titles = array();
$content = '';
$html = '';

8
themes/videoblog/controller/ListController.php

@ -9,10 +9,10 @@ Class ListController extends Controller { @@ -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 { @@ -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 { @@ -72,7 +72,7 @@ Class ListController extends Controller {
//根据目录结构以及当前目录获取面包屑
protected function getBreadcrumbs($menus, $subcate) {
$breads = [];
$breads = array();
if (!empty($subcate['directory'])) {
array_push($breads, [

6
themes/videoblog/controller/SiteController.php

@ -9,10 +9,10 @@ Class SiteController extends Controller { @@ -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 { @@ -22,7 +22,7 @@ Class SiteController extends Controller {
//获取目录
$menus = $scanner->getMenus();
$titles = [];
$titles = array();
$htmlReadme = '';
$readmeFile = $scanner->getDefaultReadme();
if (!empty($readmeFile)) {

2
themes/videoblog/controller/ViewController.php

@ -26,7 +26,7 @@ Class ViewController extends ListController { @@ -26,7 +26,7 @@ Class ViewController extends ListController {
//获取目录
$menus = $scanner->getMenus();
$titles = [];
$titles = array();
$htmlReadme = '';
$readmeFile = $scanner->getDefaultReadme();
if (!empty($readmeFile)) {

4
themes/videoblog/views/site/index.php

@ -42,8 +42,8 @@ eof; @@ -42,8 +42,8 @@ eof;
<div class="content">
<?php
$imgExts = ['jpg', 'jpeg', 'png', 'gif'];
$videoExts = ['mp4', 'm3u8'];
$imgExts = array('jpg', 'jpeg', 'png', 'gif');
$videoExts = array('mp4', 'm3u8');
$category = $viewData['scanResults'][$selectedId];
//当前目录的描述介绍

4
themes/videoblog/views/view/index.php

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
<?php
$videoUrl = '';
$poster = '';
$imgExts = ['jpg', 'jpeg', 'png', 'gif'];
$videoExts = ['mp4', 'm3u8'];
$imgExts = array('jpg', 'jpeg', 'png', 'gif');
$videoExts = array('mp4', 'm3u8');
if (!empty($viewData['video'])) {
$video = $viewData['video'];

6
themes/webdirectory/controller/SiteController.php

@ -9,12 +9,12 @@ Class SiteController extends Controller { @@ -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();

Loading…
Cancel
Save