diff --git a/framework/api/router.class.php b/framework/api/router.class.php index 9edc2ecf42..d4525b2782 100644 --- a/framework/api/router.class.php +++ b/framework/api/router.class.php @@ -757,4 +757,59 @@ class api extends router $this->config->vision = $vision ? $vision : $defaultVision; } + + /** + * 设置超级变量。 + * Set the super vars. + * + * @access public + * @return void + */ + public function setSuperVars() + { + if(isset($_SERVER['REQUEST_URI'])) + { + $uri = $_SERVER['REQUEST_URI']; + if(str_contains((string) $uri, '?')) + { + $parsedURL = parse_url((string) $uri); + if(isset($parsedURL['query'])) + { + parse_str($parsedURL['query'], $parsedQuery); + foreach($parsedQuery as $key => $value) + { + if(!isset($_GET[$key])) $_GET[$key] = $value; + } + } + } + } + + $this->post = new super('post'); + $this->get = new super('get'); + $this->server = new super('server'); + $this->cookie = new super('cookie'); + $this->session = new super('session', $this->tab); + + unset($_REQUEST); + + $_FILES = validater::filterFiles(); + $_POST = validater::filterSuper($_POST); + $_GET = validater::filterSuper($_GET); + $_COOKIE = validater::filterSuper($_COOKIE); + $_SERVER = validater::filterSuper($_SERVER); + + /* Filter common get and cookie vars. */ + if($this->config->framework->filterParam == 2) + { + global $filter; + foreach($filter->default->get as $key => $rules) + { + if(isset($_GET[$key]) and !validater::checkByRule($_GET[$key], $rules)) unset($_GET[$key]); + } + foreach($filter->default->cookie as $key => $rules) + { + if(isset($_COOKIE[$key]) and !validater::checkByRule($_COOKIE[$key], $rules)) unset($_COOKIE[$key]); + } + } + } } diff --git a/framework/base/router.class.php b/framework/base/router.class.php index c6873e4418..380f9020c9 100644 --- a/framework/base/router.class.php +++ b/framework/base/router.class.php @@ -764,13 +764,6 @@ class baseRouter $this->dataRoot = $this->wwwRoot . 'data' . DS; } - /** - * 设置超级变量。 - * Set the super vars. - * - * @access public - * @return void - */ public function setSuperVars() { if(isset($_SERVER['REQUEST_URI']))