Example #1
0
File: Start.php Project: phpon/on
 public function start()
 {
     //Oraculum::Load('Request');
     $request = Request::request();
     $url = str_ireplace(URL, '', $request);
     $gets = Request::gets();
     if (isset($gets[BASE + 1])) {
         $page = $gets[BASE + 1];
     } else {
         $page = $this->_defaulturl;
         //throw new Exception('[Erro CGFC36] Nao foi possivel determinar a pagina atraves da URL');
     }
     if ($url == '') {
         $url = $this->_defaulturl;
     }
     if ($page == '') {
         $page = $this->_defaulturl;
     }
     App::loadControl()->loadPage($page, $url);
 }
Example #2
0
 private static function _exec()
 {
     define('CURRENT_MODULE', Dispatcher::getModuleName());
     define('CURRENT_CONTROLLER', Dispatcher::getControllerName());
     define('CURRENT_ACTION', Dispatcher::getActionName());
     $controllerName = CURRENT_CONTROLLER;
     $moduleName = CURRENT_MODULE;
     if ($moduleName) {
         $className = sprintf('controller\\%s\\%s', $moduleName, $controllerName);
     } else {
         $className = sprintf("controller\\%s", $controllerName);
     }
     //-----请求日志------//
     $params = array();
     $log = array('request_id' => REQUEST_ID, 'uri' => $_SERVER['REQUEST_URI'], 'class' => array('module' => CURRENT_MODULE, 'controller' => CURRENT_CONTROLLER, 'action' => CURRENT_ACTION), 'method' => Request::method(), 'params' => array_merge($params, Request::gets(), Request::posts()), 'stream' => Request::stream(), 'cookie' => Request::cookies(), 'ip' => Request::ip());
     C::log($log);
     if (!class_exists($className)) {
         throw new \RuntimeException('类不存在');
     }
     try {
         $obj = new \ReflectionClass($className);
         if ($obj->isAbstract()) {
             throw new \RuntimeException('抽象类不可被实例化');
         }
         $class = $obj->newInstance();
         //前置操作
         if ($obj->hasMethod(CURRENT_ACTION . 'Before')) {
             $beforeMethod = $obj->getMethod(CURRENT_ACTION . 'Before');
             if ($beforeMethod->isPublic() && !$beforeMethod->isStatic()) {
                 $beforeMethod->invoke($class);
             }
         }
         $method = $obj->getMethod(CURRENT_ACTION . 'Action');
         if ($method->isPublic() && !$method->isStatic()) {
             $method->invoke($class);
         }
         //后置操作
         if ($obj->hasMethod(CURRENT_ACTION . 'After')) {
             $afterMethod = $obj->getMethod(CURRENT_ACTION . 'After');
             if ($afterMethod->isPublic() && !$afterMethod->isStatic()) {
                 $afterMethod->invoke($class);
             }
         }
     } catch (\Exception $e) {
         self::_halt($e);
     }
 }
Example #3
0
File: Request.php Project: phpon/on
 public static function getVar($index = 1, $default = NULL)
 {
     $gets = Request::gets();
     if (is_string($index)) {
         if (($key = array_search($index, $gets)) === FALSE) {
             return $default;
         }
         $index = $key + 2;
     }
     $index = (int) $index - 1;
     return isset($gets[$index]) ? $gets[$index] : $default;
 }