Файловый менеджер - Редактировать - /var/www/fetish/core/src/cron.php
Назад
<?php namespace fetish; use \fetish\db; class cron { private static $minute, $hour, $day_of_month, $month, $day_of_week; private static $thread; public static function set($time_code,$thread) { self::setTime(); self::buildThreadLink($thread); $pass = false; $pass_1 = (self::active($time_code[0],self::$minute))?true:false; $pass_2 = (self::active($time_code[1],self::$hour))?true:false; $pass_3 = (self::active($time_code[2],self::$day_of_month))?true:false; $pass_4 = (self::active($time_code[3],self::$month))?true:false; $pass_5 = (self::active($time_code[4],self::$day_of_week))?true:false; if($pass_1 && $pass_2 && $pass_3 && $pass_4 && $pass_5){ if(file_exists(self::$thread)){ //Execute in another thread exec('php -e '.self::$thread.' > /dev/null &'); echo $thread.' - Running - '.date('Y-m-d H:i:s -- N')."\r\n"; }else{ echo 'File not found - '.self::$thread; } }else{ echo $thread.' - Waiting - '.date('Y-m-d H:i:s -- N')."\r\n"; } } private static function setTime() { self::$minute = date('i'); self::$hour = date('G'); self::$day_of_month = date('j'); self::$month = date('m'); self::$day_of_week = date('N'); } private static function buildThreadLink($thread) { //Route to cron directory self::$thread = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'cron'.str_replace('/', DIRECTORY_SEPARATOR, $thread).'.php'; } private static function active($time_code, $time) { if(strpos($time_code, '*') !== false && $time_code != '*'){ if($time % explode('/', $time_code)[1] == 0){ return true; } }else{ if($time_code == '*' || $time_code == $time){ return true; } } return false; } public static function log($cron, $result) { $instance_id = @file_get_contents("http://instance-data/latest/meta-data/instance-id"); $run_time = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]; db::query("INSERT INTO log_cron (`date`,`cron`,`result`,`run_time`,`instance`)VALUES(?,?,?,?,?)",[date('Y-m-d H:i:s'),$cron,$result,$run_time,$instance_id]); } } ?>
| ver. 1.4 |
Github
|
.
| PHP 7.0.33-0ubuntu0.16.04.16 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка