日期:2014-05-17  浏览次数:20625 次

如何检查页面URL中是否有某个字符串?
鉴于安全,想获取本页面的url,检查里面是否有“script”这个字符串,若有则禁止访问或退出。该如何实现?

------解决方案--------------------
strstr strpos
------解决方案--------------------
you should have a html parser...
------解决方案--------------------
you should have a html parser. I suppose there are such php version in the wild.
------解决方案--------------------
PHP code

  function curPageURL()
{
    $pageURL = 'http';

    if ($_SERVER["HTTPS"] == "on")
    {
        $pageURL .= "s";
    }
    $pageURL .= "://";

    if ($_SERVER["SERVER_PORT"] != "80")
    {
        $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
    }
    else
    {
        $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
    }
    return $pageURL;
}