>백엔드 개발 >PHP 튜토리얼 >方维源码,获取当前脚本为false 系统报错request_tainting 问题

方维源码,获取当前脚本为false 系统报错request_tainting 问题

WBOY
WBOY원래의
2016-06-06 20:48:281198검색

<code>$_FANWE['php_self'] = htmlspecialchars(getPhpSelf());
if($_FANWE['php_self'] === false)
        systemError('request_tainting');
</code>

$_FANWE是个全局变量,getPhpSelf()函数是获取当前脚本的函数,程序大大们,到底什么样的场景才会触发这个报错呢,不明白,恳请指明

附:

<code>function getPhpSelf()
{
    $php_self = '';
    $script_name = basename($_SERVER['SCRIPT_FILENAME']);
    if(basename($_SERVER['SCRIPT_NAME']) === $script_name)
        $php_self = $_SERVER['SCRIPT_NAME'];
    else if(basename($_SERVER['PHP_SELF']) === $script_name)
        $php_self = $_SERVER['PHP_SELF'];
    else if(isset($_SERVER['ORIG_SCRIPT_NAME']) && basename($_SERVER['ORIG_SCRIPT_NAME']) === $script_name)
        $php_self = $_SERVER['ORIG_SCRIPT_NAME'];
    else if(($pos = strpos($_SERVER['PHP_SELF'],'/'.$script_name)) !== false)
        $php_self = substr($_SERVER['SCRIPT_NAME'],0,$pos).'/'.$script_name;
    else if(isset($_SERVER['DOCUMENT_ROOT']) && strpos($_SERVER['SCRIPT_FILENAME'],$_SERVER['DOCUMENT_ROOT']) === 0)
        $php_self = str_replace('\\','/',str_replace($_SERVER['DOCUMENT_ROOT'],'',$_SERVER['SCRIPT_FILENAME']));
    else
        return false;
    return $php_self;
}
</code>

回复内容:

<code>$_FANWE['php_self'] = htmlspecialchars(getPhpSelf());
if($_FANWE['php_self'] === false)
        systemError('request_tainting');
</code>

$_FANWE是个全局变量,getPhpSelf()函数是获取当前脚本的函数,程序大大们,到底什么样的场景才会触发这个报错呢,不明白,恳请指明

附:

<code>function getPhpSelf()
{
    $php_self = '';
    $script_name = basename($_SERVER['SCRIPT_FILENAME']);
    if(basename($_SERVER['SCRIPT_NAME']) === $script_name)
        $php_self = $_SERVER['SCRIPT_NAME'];
    else if(basename($_SERVER['PHP_SELF']) === $script_name)
        $php_self = $_SERVER['PHP_SELF'];
    else if(isset($_SERVER['ORIG_SCRIPT_NAME']) && basename($_SERVER['ORIG_SCRIPT_NAME']) === $script_name)
        $php_self = $_SERVER['ORIG_SCRIPT_NAME'];
    else if(($pos = strpos($_SERVER['PHP_SELF'],'/'.$script_name)) !== false)
        $php_self = substr($_SERVER['SCRIPT_NAME'],0,$pos).'/'.$script_name;
    else if(isset($_SERVER['DOCUMENT_ROOT']) && strpos($_SERVER['SCRIPT_FILENAME'],$_SERVER['DOCUMENT_ROOT']) === 0)
        $php_self = str_replace('\\','/',str_replace($_SERVER['DOCUMENT_ROOT'],'',$_SERVER['SCRIPT_FILENAME']));
    else
        return false;
    return $php_self;
}
</code>

应该是服务器配置异常的时候。就会出现那个错误了。

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.