Beispiel #1
0
 /**
  * @param null $input_parameters
  * @return bool
  */
 public function execute($input_parameters = null)
 {
     // Bool PDO bug
     if (is_array($input_parameters)) {
         foreach ($input_parameters as &$value_param) {
             if (is_bool($value_param)) {
                 $value_param = $value_param ? 't' : 'f';
             }
         }
     }
     if ($this->dump_mode) {
         $dump_sql = $this->queryString;
         if (is_array($input_parameters)) {
             foreach ($input_parameters as $param => $value) {
                 $dump_sql = str_replace(':' . $param, '\'<strong><i>' . $value . '</i></strong>\'', $dump_sql);
             }
         }
         print '<pre>' . $dump_sql . '</pre>';
     }
     try {
         $start_time = Core_Db_Log::getStartTime();
         $result = parent::execute($input_parameters);
         //@todo - 2nd PDO instance
         //			Core_Db_Log::log($this->queryString, $input_parameters, $start_time);
     } catch (Exception $e) {
         Core_ErrorLog::save(Core_ErrorLog::TYPE_DB, $e->getMessage());
         p404($e->getMessage(), 'dbError');
     }
     return $result;
 }
Beispiel #2
0
 /**
  *
  */
 protected function dispatch()
 {
     if ($this->dispatcher_is_breaked) {
         return;
     }
     $module = $this->request->getRoute('module');
     $controller = $this->request->getRoute('controller');
     $controller = Core_String::toClass($module) . '_' . Core_String::toClass($controller) . 'Controller';
     if (class_exists($controller, true)) {
         $controller_instance = new $controller();
         if (method_exists($controller_instance, 'init')) {
             $controller_instance->init();
         }
         if ($this->dispatcher_is_breaked) {
             return;
         }
         $action = $this->request->getRoute('action');
         $action = Core_String::toFunction($action) . 'Action';
         if (method_exists($controller_instance, $action)) {
             $controller_instance->{$action}();
             return;
         }
     }
     p404('Missing: ' . $controller . (!empty($action) ? '::' . $action : null));
 }
Beispiel #3
0
 /**
  * @throws Exception
  */
 protected function loadCfg()
 {
     if (PHP_SAPI != 'cli') {
         p404('only cli');
     }
     $match_id = $this->getRequest()->getArgv(1);
     cfg()->load($match_id, Core_Cfg::MATCH_TYPE_ID);
 }
Beispiel #4
0
 /**
  * @throws Exception
  */
 protected function loadCfg()
 {
     $match_id = PHP_SAPI == 'cli' ? $this->getRequest()->getArgv(1) : $this->getRequest()->cfg_id;
     cfg()->load($match_id, Core_Cfg::MATCH_TYPE_ID);
     Core_View::getInstance()->disableLayout();
     if (PHP_SAPI != 'cli') {
         p404('only admin or cli sapi');
     }
 }
Beispiel #5
0
 public function init()
 {
     if (isset($this->do_not_check_ip) && $this->do_not_check_ip) {
         return;
     }
     $client_ip = ip2long($this->getRequest()->getServer('REMOTE_ADDR'));
     $has_access = false;
     foreach ($this->allowed_ips as $row) {
         list($ip_from, $ip_to) = $row;
         if ($client_ip >= ip2long($ip_from) && $client_ip <= ip2long($ip_to)) {
             $has_access = true;
         }
     }
     if (!$has_access) {
         p404('invalid ip');
     }
 }