/** * 设置 session * @return bool */ public function setSession() { if (is_run_evn()) { if ($this->getSessionStatus()) { $config = static::$_config['sys']['session']; if ($config['domain']) { ini_set('session.cookie_domain', $config['domain']); } if ($config['expire']) { ini_set('session.gc_maxlifetime', $config['expire']); ini_set('session.cookie_lifetime', $config['expire']); } if ($config['use_cookies']) { ini_set('session.use_cookies', $config['use_cookies'] ? 1 : 0); } if ($config['cache_limiter']) { session_cache_limiter($config['cache_limiter']); } if ($config['cache_expire']) { session_cache_expire($config['cache_expire']); } $seeion = new \Upadd\Bin\Session\SessionFile(); session_set_save_handler(array($seeion, 'open'), array($seeion, 'close'), array($seeion, 'read'), array($seeion, 'write'), array($seeion, 'destroy'), array($seeion, 'gc')); session_start(); } } }
/** * 获取访问路径 * @return string */ protected static function getHttpUrl() { if (is_run_evn()) { if (isset($_SERVER['REQUEST_URI'])) { return $_SERVER['REQUEST_URI']; } } else { return 'cli'; } }
/** * 打印错误或是异常 * @param array $error */ private static function printError($error = []) { if ($error) { if (is_run_evn()) { echo '<pre>'; print_r($error); echo '</pre>'; } else { print_r($error); } } }
/** * Instantiation Action * @return mixed */ public function Instantiation() { try { if (class_exists($this->_action)) { Config::setFileVal('sys', 'request', ['action' => $this->_action, 'method' => $this->_method]); /** * 实例化控制器 */ $class = new $this->_action(); /** * 获取方法 */ $method = $this->_method; $tmpData = null; if (is_run_evn()) { $class->init(); $tmpData = func_get_args(); } else { $tmpData = $this->_cliData; } $result = call_user_func_array(array($class, $method), $tmpData); $this->_responseType = $class->getResponseType(); return $result; } else { throw new UpaddException('There is no Action'); } } catch (UpaddException $e) { if (is_run_evn()) { p($e->getMessage()); } else { print_r($e->getMessage()); } } }