public function run($action) { if ($action == 'cli_dispatcher') { $class = get_class($this); $methods = get_class_methods($this); $thistime = (int) date('H') * 60 + (int) date('i'); $today = date('Ymd'); foreach ($methods as $method) { $callname = "{$class}::{$method}"; if ($method == 'daily_service') { $dstime = trim(WS::env()->config->cli->daily_service); if ($m = Core_Regexps::match_with_results('{^(\\d+)[^\\d]+(\\d+)$}', $dstime)) { $calltime = (int) $m[1] * 60 + (int) $m[2]; if ($thistime >= $calltime) { $last = CMS_CLI::get_call_time($callname); $lastday = date('Ymd', $last); if ($today != $lastday) { CMS_CLI::set_call_time($callname); $this->run_action($method); } } } } else { if ($m = Core_Regexps::match_with_results('{^every(\\d+)$}', $method)) { $d = (int) $m[1] * 60; $last = CMS_CLI::get_call_time($callname); if (time() - $d > $last) { CMS_CLI::set_call_time($callname); $this->run_action($method); } } elseif ($m = Core_Regexps::match_with_results('{^daily(\\d+)_(\\d+)$}', $method)) { $calltime = (int) $m[1] * 60 + (int) $m[2]; if ($thistime >= $calltime) { $last = CMS_CLI::get_call_time($callname); $lastday = date('Ymd', $last); if ($today != $lastday) { CMS_CLI::set_call_time($callname); $this->run_action($method); } } } } } } else { return $this->run_action($action); } }