Ejemplo n.º 1
0
 /**
  * 根据 php.ini 中的 magic quotes gpc 设置去除超全局变量中自动添加的转义符
  */
 private function _initOneTime()
 {
     if (self::$_root) {
         return;
     }
     self::$_root = $this;
     // 禁止 magic quotes
     set_magic_quotes_runtime(0);
     // 处理被 magic quotes 自动转义过的数据
     if (get_magic_quotes_gpc()) {
         $in = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
         while (list($k, $v) = each($in)) {
             foreach ($v as $key => $val) {
                 if (!is_array($val)) {
                     $in[$k][$key] = stripslashes($val);
                     continue;
                 }
                 $in[] =& $in[$k][$key];
             }
         }
         unset($in);
     }
     $url_mode = strtolower($this->getIni('dispatcher_url_mode'));
     if ($url_mode == self::URL_MODE_PATHINFO || $url_mode == self::URL_MODE_REWRITE) {
         $this->_router = new QRouter($this);
         $result = $this->_router->match($this->getPathinfo());
         if ($result) {
             foreach ($result as $var => $value) {
                 if (empty($_GET[$var])) {
                     $_GET[$var] = $_REQUEST[$var] = $value;
                 }
             }
         }
         self::$_url_mode = $url_mode;
     } else {
         self::$_url_mode = self::URL_MODE_STANDARD;
         $this->_router = null;
     }
 }