* Fix version of api request.

This commit is contained in:
zhujinyong
2021-11-18 14:37:26 +08:00
parent a796848a49
commit 0ee281b800
2 changed files with 4 additions and 14 deletions
+3 -13
View File
@@ -82,22 +82,12 @@ class api extends router
$this->httpMethod = strtolower($_SERVER['REQUEST_METHOD']);
if(!empty($_SERVER['PATH_INFO']))
{
$this->path = rtrim($_SERVER['PATH_INFO'], '/');
}
else
{
$this->path = rtrim((strpos($_SERVER['REQUEST_URI'], '?') > 0 ? strstr($_SERVER['REQUEST_URI'], '?', true) : $_SERVER['REQUEST_URI']), '/');
}
$dir = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/');
$this->path = rtrim((strpos($_SERVER['REQUEST_URI'], '?') > 0 ? strstr($_SERVER['REQUEST_URI'], '?', true) : $_SERVER['REQUEST_URI']), '/');
if($dir != '' and strpos($this->path, $dir) === 0) $this->path = substr($this->path, strlen($dir));
$subPos = strpos($this->path, '/', 1);
$this->version = $subPos ? substr($this->path, 1, $subPos - 1) : '';
$this->path = $subPos ? substr($this->path, $subPos) : $this->path;
$subPos = $dir ? strpos($dir, '/', 1) : 0;
$this->version = $subPos ? substr($dir, $subPos + 1) : '';
$this->loadApiLang();
}
+1 -1
View File
@@ -894,6 +894,6 @@ function isHttps()
*/
function htmlSpecialString($string, $flags = '', $encoding = 'UTF-8')
{
if(!$flags) $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401;
if(!$flags) $flags = defined('ENT_SUBSTITUTE') ? ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 : ENT_QUOTES;
return htmlspecialchars($string, $flags, $encoding);
}