我搜索了其他问题,但找不到可行的解决方案。这是一个 CMS 程序,我尝试将文件上传到任何目录并收到以下错误:
Warning: preg_replace() [function.preg-replace]: Compilation failed: nothing to repeat at offset 3 in /home/...on line 1017
这是代码,有什么建议吗?
function _IsValidPath($Path)
{ // First check if the path starts with the starting directory
$basePath = preg_replace("/{1,}/", "/", $_SESSION['rootdirectory'] . '/' . // this line (1017) causing the error
$_SESSION["startingdirectory"]);
$sdPos = strpos($basePath, $Path);
if (!is_numeric($sdPos))
{
$sdPos = strpos($Path, $basePath);
}
if(is_numeric($sdPos) && $sdPos == 0)
{
// Make sure it doesn't contain any invalid characters
if(is_numeric(strpos($Path, "..")) ||
(is_numeric(strpos($Path, "./"))) ||
(is_numeric(strpos($Path, "//"))) ||
(is_numeric(strpos($Path, "\\"))) ||
(is_numeric(strpos($Path, "../"))) ||
(is_numeric(strpos($Path, "&"))) ||
(is_numeric(strpos($Path, "*"))) ||
(is_numeric(strpos($Path, " "))) ||
(is_numeric(strpos($Path, "'"))) ||
(is_numeric(strpos($Path, "\?"))) ||
(is_numeric(strpos($Path,"<"))) ||
(is_numeric(strpos($Path, ">"))))
{
return false;
}
else
{
// The path is OK
return true;
}
}
else
{
return false;
}
}