I need to filter out the untrusted $ _SERVER ['PHP_SELF'] varialbe. This is a good approach:
function filterPhpSelf($str)
{
$phpself = basename(__FILE__);
$str = substr($str, 0, strpos($str,$phpself)) . $phpself;
return $unsafeStr;
}
where $ str is $ _SERVER ['PHP_SELF']?
source
to share