* Re implement setSuperVars in the API router and remove csrf validation.

This commit is contained in:
liuruogu
2025-12-31 08:59:21 +00:00
parent 0b092eff08
commit a32fd5b3ff
2 changed files with 55 additions and 7 deletions
+55
View File
@@ -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]);
}
}
}
}
-7
View File
@@ -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']))