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);
}
}
}
}
/************************************
* 修改部份
* 过滤首尾符号
***********************************/
$uri['first'] = trim($uri['first'], $this->params['sep_act']);
$request = explode($this->params['sep_act'], $uri['first']);
/**end******************************/
$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]);
}
}
// 网址解析
/************************************
* 修改部份
* app_dir/controller/action/id
* app_dir/ajax/controller/action/id
***********************************/
$args_count = count($uri['first']['args']);
if ($args_count < 5)
{
for ($i=0; $i<(5-$args_count); $i++)
{
$uri['first']['args'][] = '';
}
}
list($_app, $_controller, $_action, $_id, $_ajax) = $uri['first']['args'];
$route_rules = array(
"{$_app}/{$_controller}/{$_action}/{$_id}/{$_ajax}",
"{$_app}/{$_controller}/{$_action}/{$this->default_vars['action']}/{$_id}",
"{$_app}/{$_controller}/{$_action}/{$this->default_vars['action']}",
"{$_app}/{$_controller}/{$_action}/{$_id}",
"{$_app}/{$_controller}/{$this->default_vars['action']}/{$_action}",
"{$_app}/{$_controller}/{$this->default_vars['action']}",
"{$_app}/{$this->default_vars['controller']}/{$_controller}/{$_action}",
"{$_app}/{$this->default_vars['controller']}/{$this->default_vars['action']}/{$_controller}",
"{$_app}/{$this->default_vars['controller']}/{$this->default_vars['action']}",
"{$this->default_vars['app_dir']}/{$this->default_vars['controller']}/{$_app}/{$_controller}",
"{$this->default_vars['app_dir']}/{$this->default_vars['controller']}/{$this->default_vars['action']}/{$_app}",
"{$this->default_vars['app_dir']}/{$this->default_vars['controller']}/{$this->default_vars['action']}",
);
foreach ($route_rules as $key => $rule)
{
if (strpos($rule, '//') !== false) {
continue;
}
if (substr($rule, -1) === '/') {
continue;
}
list($_app, $_controller, $_action, $_id, $_ajax) = explode('/',$rule);
if ($_ajax === null) {
$_controller_file = ROOT_PATH . 'app/' . $_app . '/' . $_controller . '.php';
if (file_exists($_controller_file)
AND !strstr($_action, '=')
AND !strstr($_action, '__')
AND !strstr($_action, '-')
AND !strstr($_action, '.')) {
$__app_dir = $_app; //应用目录
$this->controller = $_controller; //控制器
$this->action = $_action; //动作
$args_var_str = $_id; //参数
$__app_dir = $_app;
break;
}
} else {
$_controller_file = ROOT_PATH . 'app/' . $_app . '/' . $_controller . '/' . $_action . '.php';
if (file_exists($_controller_file)
AND !strstr($_id, '=')
AND !strstr($_id, '__')
AND !strstr($_id, '-')
AND !strstr($_id, '.')) {
$__app_dir = $_app; //应用目录
$this->controller = $_controller . '/' . $_action; //控制器
$this->action = $_id; //动作
$args_var_str = $_ajax; //参数
break;
}
}
}
/**end******************************/
$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;
}
这家伙很懒,还没有设置简介