吾爱互联 发表于 2016-1-12 10:47:53

非THINKPHP框架下验证代码


        $authorization_key=$_SERVER['SERVER_NAME'];
        if(!isset($_COOKIE["authorization_check"])){
                $authorization='http://shouquan.5ahl.com/index.php?m=Biz&keyword='.$authorization_key;
                $authorization_check=file_get_contents($authorization);
                if (isset($authorization_check)) {
                        preg_match_all ("|li(.*)]+>|U",$authorization_check,$matches,PREG_SET_ORDER);
                        if (!empty($matches)) {
                                $authorization_check = $matches[0][1];
                        }
                        if(strlen($authorization_check)>5){
                                setcookie('authorization_check',$authorization_check,time()+3600);
                                //3600是COOKIE有效时间
                                $az=$authorization_check;
                        }else{
                                setcookie('authorization_check',0,time()+3600);
                        }
                }
        }else{
                $az=$_COOKIE["authorization_check"];
                //$az=cookie('authorization_check');//thinkphp下
        }
        $authorization_check = explode(",",$az);
        if(!in_array($authorization_key,$authorization_check)){
                //未授权运行的代码
                echo "你的程序未通过验证!";
                //设置301未授权跳转
                //header("HTTP/1.1 301 Moved Permanently");
                //header("Location: http://www.5ahl.com");
                //exit();
        }else{
                echo "成功验证";
                //已授权运行的代码
                //也可以将核心的代码在这里加密,已防止别人删除这段代码.
                //这种加密对于高手还是很容易破解的.如果想做到无法破解请将核心代码或本页代码用zend加密.
        }
页: [1]
查看完整版本: 非THINKPHP框架下验证代码