Пример #1
0
 static function Run()
 {
     Core::load('CMS.CLI');
     self::load_files(CMS_CLI::parms());
 }
Пример #2
0
 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);
     }
 }
Пример #3
0
 /**
  * Производит запуск веб-приложения
  *
  */
 public function run()
 {
     try {
         if (!isset(self::$component_names['CMSStockroom'])) {
             Core::load('CMS.Stockroom');
         }
         if (!isset(self::$component_names['CMSFSPages'])) {
             Core::load('CMS.FSPages');
         }
         self::before_run(CMS::env());
         // Если скрипт запущен из командной строки, то веб-приложение не запускается
         //TODO: create cli_application
         if (!isset($_SERVER['HTTP_HOST']) && !isset($_SERVER['REQUEST_URI'])) {
             CMS::$is_cli = true;
             Core::load('CMS.CLI');
             CMS_CLI::run();
             return;
         }
         if (self::$enable_rest) {
             self::application()->dispatcher();
         }
         return WS::run(self::application()->cms_action());
     } catch (Exception $e) {
         self::root_catcher($e);
     }
 }