first commit

This commit is contained in:
浪子小新
2020-03-22 12:20:07 +08:00
commit bf9e9a2dfd
85 changed files with 17363 additions and 0 deletions
@@ -0,0 +1,44 @@
<?php
use Workerman\Worker;
use Workerman\Lib\Timer;
// watch Applications catalogue
// worker
$webDirSource = dirname(dirname(dirname(__FILE__)));
$worker = new Worker();
$worker->name = 'FileMonitor';
$worker->reloadable = false;
$worker->onWorkerStart = function()
{
global $webDirSource;
Timer::add(300, 'check_files_remove', $webDirSource);
};
// check files func
function check_files_remove($webDirSource)
{
// $files = [];
// $dateTime = date("Ymd",strtotime("-1 day"));
// if(is_dir($webDirSource)) {
// if($files = scandir($webDirSource)) {
// $files = array_slice($files,2);
// foreach($files as $file) {
// if ($file < $dateTime) {
// rmdir($webDirSource . $file);
// }
// }
// }
// }
$pdo = new PDO('sqlite:' . $webDirSource . '/sql');
$data = $pdo->query("select * from file_info where addtime < '".(time() - 60*60*2+5)."'")->fetchAll();
foreach($data as $item){
if(is_file($item['path'])){
unlink($item['path']);
}
$pdo->exec("delete from file_info where id=".$item['id']);
}
$pdo = null;
return;
}