public function parse_uri($request_main) { if (get_setting('url_rewrite_enable') == 'Y' AND $request_routes = get_request_route(false)) { if (!$request_main) { $request_main = '/'; } foreach($request_routes as $key => $val) { if (preg_match('/^' . $val[0] . '/', $request_main)) { $request_main = preg_replace('/^' . $val[0] . '/', $val[1], $request_main); return $request_main; } } } return $request_main; } public function set_rewrite() { if (!defined('G_INDEX_SCRIPT')) { return false; } $request_main = $this->request_main; if (!$request_main OR $this->index_script == $request_main) { $this->controller = 'main'; $this->action = 'index'; return $this; } $request = explode('?', $request_main, 2); if (count($request) == 1) { $request = explode('&', $request_main, 2); } $uri = array( 'first' => array_shift($request), 'last' => ltrim(implode($request), '?') ); if ($uri['last']) { parse_str($uri['last'], $query_string); foreach ($query_string AS $key => $val) { if (!$_GET[$key]) { if (! strstr($val, '%')) { $_GET[$key] = $val; } else { $_GET[$key] = urldecode($val); } } } } $request = explode($this->params['sep_act'], $uri['first']); $uri['first'] = array( 'pattern' => '', 'args' => $request ); $__app_dir = $this->default_vars['app_dir']; // 应用目录 $this->controller = $this->default_vars['controller']; // 控制器 $this->action = $this->default_vars['action']; // 动作 $args_var_str = ''; // 删除空值 foreach ($uri['first']['args'] AS $key => $val) { if (strstr($val, $this->params['sep_value']) AND !$start_key) { $start_key = $key; } else if ($start_key) { $uri['first']['args'][$start_key] .= $this->params['sep_act'] . $val; unset($uri['first']['args'][$key]); } } $args_count = count($uri['first']['args']); switch ($args_count) { default: return $this; break; case 1: $args_var_str = $uri['first']['args'][0]; break; case 2: $__app_dir = $uri['first']['args'][0] ? $uri['first']['args'][0] : $this->default_vars['app_dir']; // 应用目录 $args_var_str = $uri['first']['args'][1]; break; case 3: $args_var_str = $uri['first']['args'][2]; $__app_dir = $uri['first']['args'][0] ? $uri['first']['args'][0] : $this->default_vars['app_dir']; // 应用目录 if (file_exists(ROOT_PATH . 'app/' . $__app_dir . '/' . $uri['first']['args'][1] . '.php')) { $this->controller = $uri['first']['args'][1]; // 控制器 } else { $this->controller = $this->default_vars['controller']; // 控制器 $this->action = $uri['first']['args'][1]; // 动作 } break; case 4: $args_var_str = $uri['first']['args'][3]; $__app_dir = $uri['first']['args'][0] ? $uri['first']['args'][0] : $this->default_vars['app_dir']; // 应用目录 $this->controller = $uri['first']['args'][1] ? $uri['first']['args'][1] : $this->default_vars['controller']; // 控制器 $this->action = $uri['first']['args'][2] ? $uri['first']['args'][2] : $this->default_vars['action']; // 动作 break; case 5: $args_var_str = $uri['first']['args'][4]; $__app_dir = $uri['first']['args'][0] ? $uri['first']['args'][0] : $this->default_vars['app_dir']; // 应用目录 $this->controller = $uri['first']['args'][2] ? $uri['first']['args'][1] . '/' . $uri['first']['args'][2] : $this->default_vars['controller']; // 控制器 $this->action = $uri['first']['args'][3] ? $uri['first']['args'][3] : $this->default_vars['action']; // 动作 break; } $this->app_dir = ROOT_PATH . 'app/' . $__app_dir . '/'; $_GET['c'] = $this->controller; $_GET['act'] = $this->action; $_GET['app'] = $__app_dir; if ($args_var_str) { if (substr($args_var_str, 0, strlen($this->params['sep_var'])) == $this->params['sep_var']) { $args_var_str = substr($args_var_str, strlen($this->params['sep_var'])); } if (!strstr($args_var_str,'-')) { $_GET['id'] = urldecode($args_var_str); } $uri['last'] = explode($this->params['sep_var'], $args_var_str); foreach ($uri['last'] as $val) { @list($k, $v) = explode($this->params['sep_value'], $val, 2); if ($k) { if (! strstr($v, '%')) { $_GET[$k] = $v; } else { $_GET[$k] = urldecode($v); } } } } foreach ($_GET AS $key => $val) { if (strstr($key, '/')) { unset($_GET[$key]); } } return $this; }
这家伙很懒,还没有设置简介