|
|
|
@ -2,6 +2,10 @@
@@ -2,6 +2,10 @@
|
|
|
|
|
/** |
|
|
|
|
* Command Controller |
|
|
|
|
*/ |
|
|
|
|
require_once __DIR__ . '/../../../lib/DirScanner.php'; |
|
|
|
|
require_once __DIR__ . '/../../../plugins/Parsedown.php'; |
|
|
|
|
require_once __DIR__ . '/../../../plugins/Common.php'; |
|
|
|
|
|
|
|
|
|
Class CommandController extends Controller { |
|
|
|
|
|
|
|
|
|
public function actionIndex() { |
|
|
|
@ -96,16 +100,75 @@ eof;
@@ -96,16 +100,75 @@ eof;
|
|
|
|
|
//服务器端机器人程序,负责图片、视频文件拍摄时间等信息扫描,并缓存结果供前端使用 |
|
|
|
|
public function actionMainBot() { |
|
|
|
|
$thisTime = date('Y-m-d H:i:s'); |
|
|
|
|
echo "[MainBot] Main bot started @{$thisTime}\n"; |
|
|
|
|
$botLogPrefix = '[MainBot]'; |
|
|
|
|
echo "{$botLogPrefix} Main bot started @{$thisTime}\n"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$menus = array(); //菜单,一级目录 |
|
|
|
|
$htmlReadme = array(); //Readme.md 内容,底部网站详细介绍 |
|
|
|
|
$htmlCateReadme = ''; //当前目录下的Readme.md 内容 |
|
|
|
|
$menus_sorted = array(); //Readme_sort.txt 说明文件内容,一级目录菜单从上到下的排序 |
|
|
|
|
|
|
|
|
|
$this->scanMediaFiles(); |
|
|
|
|
|
|
|
|
|
while (true) { |
|
|
|
|
$time = date('Y-m-d H:i:s'); |
|
|
|
|
echo "[MainBot] {$time}\n"; |
|
|
|
|
//while (true) { |
|
|
|
|
//$time = date('Y-m-d H:i:s'); |
|
|
|
|
//echo "{$botLogPrefix} {$time}\n"; |
|
|
|
|
|
|
|
|
|
//sleep(3); |
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sleep(3); |
|
|
|
|
protected function scanMediaFiles($dirpath = '') { |
|
|
|
|
$rootDir = __DIR__ . '/../../../www/' . FSC::$app['config']['content_directory']; |
|
|
|
|
if (empty($dirpath)) { |
|
|
|
|
$dirpath = $rootDir; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
echo "\n\n== Scanning directory {$dirpath} ...\n\n"; |
|
|
|
|
$scanner = new DirScanner(); |
|
|
|
|
$scanner->setWebRoot(FSC::$app['config']['content_directory']); |
|
|
|
|
$scanner->setRootDir($dirpath); |
|
|
|
|
|
|
|
|
|
$maxScanDeep = 0; //最大扫描目录级数 |
|
|
|
|
$dirTree = $scanner->scan($dirpath, $maxScanDeep); |
|
|
|
|
$scanResults = $scanner->getScanResults(); |
|
|
|
|
echo 'Total directories or files: ' . count($scanResults); |
|
|
|
|
echo "\n\n"; |
|
|
|
|
|
|
|
|
|
$supportedImageExts = FSC::$app['config']['supportedImageExts']; |
|
|
|
|
$supportedVideoExts = FSC::$app['config']['supportedVideoExts']; |
|
|
|
|
$supportedAudioExts = FSC::$app['config']['supportedAudioExts']; |
|
|
|
|
|
|
|
|
|
$cacheKey = 'MainBotScanedDirs'; |
|
|
|
|
|
|
|
|
|
if (!empty($scanResults)) { |
|
|
|
|
foreach ($scanResults as $id => $item) { |
|
|
|
|
$hadScanedDirs = Common::getCache($cacheKey); |
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
!empty($item['filename']) |
|
|
|
|
&& empty($item['original_ctime']) |
|
|
|
|
&& in_array($item['extension'], $supportedImageExts) |
|
|
|
|
&& !in_array($item['extension'], $scanner->exifSupportFileExtensions) |
|
|
|
|
) { |
|
|
|
|
echo "Image file no original_ctime: {$item['filename']}.{$item['extension']}, {$item['realpath']}\n"; |
|
|
|
|
}else if ( |
|
|
|
|
!empty($item['filename']) |
|
|
|
|
&& empty($item['original_ctime']) |
|
|
|
|
&& (in_array($item['extension'], $supportedVideoExts) || in_array($item['extension'], $supportedAudioExts)) |
|
|
|
|
) { |
|
|
|
|
echo "Video or audio file no original_ctime: {$item['filename']}.{$item['extension']}, {$item['realpath']}\n"; |
|
|
|
|
}else if (!empty($item['directory']) && empty($hadScanedDirs[$id])) { //if it's directory |
|
|
|
|
$hadScanedDirs[$id] = true; |
|
|
|
|
Common::setCache($cacheKey, $hadScanedDirs); |
|
|
|
|
|
|
|
|
|
sleep(1); |
|
|
|
|
$this->scanMediaFiles($item['realpath']); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|