tel8618217223380 / lotusphp

Automatically exported from code.google.com/p/lotusphp
0 stars 0 forks source link

Why Router::init use $_GET( key is not module or action) to detect module and action #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. open http://localhost/?status=abc
2. lotusphp will search class abcindexAction
3.

What is the expected output? What do you see instead?

lotusphp search class defaultindexAction

Please use labels and text to provide additional information.

the code is : 

  public function init()
  {
    $delimiter = $this->routingTable['delimiter'];
    $postfix = $this->routingTable['postfix'];
    $module = '';
    $action = '';
    $params = array();
    // HTTP HTTPS
    if (isset($_SERVER['SERVER_PROTOCOL']))
    {
      if (isset($_SERVER['PATH_INFO']))
      {
        // 忽略后缀
        $url = rtrim($_SERVER['PATH_INFO'], "$postfix");
        $url = explode($delimiter, trim($url, "/"));
      }
      else
      {
        $url = array();
        foreach($_GET as $v)
        {
          $url[]=$v;
        }
      }
      $params = $this->matchingRoutingTable($url);
      $module = $params['module'];
      $action = $params['action'];
    }

Original issue reported on code.google.com by gxd...@gmail.com on 15 Mar 2010 at 2:31

GoogleCodeExporter commented 9 years ago
// 不初始化路由表则使用默认配置如下
$config['router.routing_table'] = array(
    'pattern' => ":module/:action/*", // 匹配模板
    'default' => array('module' => 'default', // 默认值
        'action' => 'index' // 默认值
        ),
    'reqs' => array('module' => '[a-zA-Z0-9\.\-_]+', // 正则匹配
        'action' => '[a-zA-Z0-9\.\-_]+' // 正则匹配
        ),
    'varprefix' => ':', // 识别变量的前缀
    'delimiter' => '/', // 分隔符
    'postfix' => '', // url后缀
    'protocol' => 'PATH_INFO', // STANDARD REWRITE PATH_INFO
    );

Original comment by zhao5908@gmail.com on 26 Mar 2010 at 1:18