public function run() { if (strpos($_SERVER["REQUEST_URI"], "?")) { $a_request_uri = explode("?", $_SERVER["REQUEST_URI"]); $request_uri = $a_request_uri[0]; } else { $request_uri = $_SERVER["REQUEST_URI"]; } $request_uri = explode(Settings::getItem('webroot'), $request_uri); $route = Routes::getByUrl(Routes::getRealPathOfRequest($request_uri[1])); if (Routes::verifyRoute($request_uri[1])) { if (Settings::getItem('authentication') === true and Auth::verifyControllerAuth($route["controller"], $route["action"])) { if (Auth::verifyAuth()) { Dispatch::dispatch($request_uri[1], $route["controller"] . "Controller", $route["action"]); } else { foreach (Routes::getParse() as $route) { if (array_key_exists('behavior', $route)) { if ($route["behavior"] == "login") { Routes::httpRedirect(Routes::getUrlByName($route["name"])); } } } } } else { Dispatch::dispatch($request_uri[1], $route["controller"] . "Controller", $route["action"]); } } else { foreach (Routes::getParse() as $route) { if (array_key_exists('behavior', $route)) { if ($route["behavior"] == "404") { Routes::httpRedirect(Routes::getUrlByName($route["name"])); } } } } }
} else { return false; } } /** * 定义系统常量 */ private function define_GF_constant() { if ($this->url_model != 3) { define('__ROOT__', 'http://' . $_SERVER['HTTP_HOST']); //根目录URL路径 define('__GROUP__', __ROOT__ . '/' . $this->group_name . '/'); if ($this->group_name == C('default_group')) { define('__URL__', __ROOT__ . '/' . $this->module_name . '/'); define('__ACTION__', __ROOT__ . '/' . $this->module_name . '/' . $this->action_name); } else { define('__URL__', __ROOT__ . '/' . $this->group_name . '/' . $this->module_name . '/'); define('__ACTION__', __ROOT__ . '/' . $this->group_name . '/' . $this->module_name . '/' . $this->action_name); } define('__SELF__', __ROOT__ . $_SERVER['REQUEST_URI']); } define('GROUP_NAME', $this->group_name); define('MODULE_NAME', $this->module_name); define('ACTION_NAME', $this->action_name); } } //页面具体执行,从这一段开始 $D = new Dispatch(); $D->dispatch();