一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

php 模擬post_驗證頁面的返回狀態(實例講解)

1.主要文件,訪問該頁面,該頁面根據“驗證頁面”的返回結果設置本文件的返回狀態 header('HTTP/1.1 '.$code.' '.$_status[$code])
復制代碼 代碼如下:
<?php
    ini_set('max_execution_time', 120);

    include("CheckConfig.php");

    function send_http_status($code) {
        static $_status = array(
        // Informational 1xx
=> 'Continue',
=> 'Switching Protocols',
        // Success 2xx
=> 'OK',
=> 'Created',
=> 'Accepted',
=> 'Non-Authoritative Information',
=> 'No Content',
=> 'Reset Content',
=> 'Partial Content',
        // Redirection 3xx
=> 'Multiple Choices',
=> 'Moved Permanently',
=> 'Moved Temporarily ',  // 1.1
=> 'See Other',
=> 'Not Modified',
=> 'Use Proxy',
        // 306 is deprecated but reserved
=> 'Temporary Redirect',
        // Client Error 4xx
=> 'Bad Request',
=> 'Unauthorized',
=> 'Payment Required',
=> 'Forbidden',
=> 'Not Found',
=> 'Method Not Allowed',
=> 'Not Acceptable',
=> 'Proxy Authentication Required',
=> 'Request Timeout',
=> 'Conflict',
=> 'Gone',
=> 'Length Required',
=> 'Precondition Failed',
=> 'Request Entity Too Large',
=> 'Request-URI Too Long',
=> 'Unsupported Media Type',
=> 'Requested Range Not Satisfiable',
=> 'Expectation Failed',
        // Server Error 5xx
=> 'Internal Server Error',
=> 'Not Implemented',
=> 'Bad Gateway',
=> 'Service Unavailable',
=> 'Gateway Timeout',
=> 'HTTP Version Not Supported',
=> 'Bandwidth Limit Exceeded'
        );
        if(array_key_exists($code,$_status)) {
            header('HTTP/1.1 '.$code.' '.$_status[$code]);
        }
    }

    function GetStatusCode($url)
    {
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url); //設置URL

        curl_setopt($curl, CURLOPT_HEADER, 1); //獲取Header
        curl_setopt($curl,CURLOPT_NOBODY,true); //Body就不要了吧,我們只是需要Head
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //數據存到成字符串吧,別給我直接輸出到屏幕了
        $data = curl_exec($curl); //開始執行啦~
        $HttpCode =curl_getinfo($curl,CURLINFO_HTTP_CODE); //我知道HTTPSTAT碼哦~
        curl_close($curl); //用完記得關掉他
        return $HttpCode;
    }

    function ResetUrl($url)
    {
        if(strpos($url,"?")>0)
            $url.="&rnd";
        else
            $url.="?rnd";
        $url.=rand();
        return $url;
    }

    function ShowStateInfo($UrlArr,$MailPara)
    {
        $count=count($UrlArr);
        if(isset($_REQUEST["start"]))
        {
            $start=$_REQUEST["start"]*1;
        }
        else
        {
            $start=1;
        }
        if(isset($_REQUEST["end"]))
        {
            $end=$_REQUEST["end"]*1;
        }
        else
        {
            $end=$start;
        }

        $start=$start-1;
        $end=$end-1;

        if($start<0)
        {
            $start=0;
        }

        if($start>=0 && $start<$count)
        {
            if($end>=$count)
            {
                $end=$count-1;
            }

            if($end<$start)
            {
                $end=$start;
            }
            $sTime=date("Y/m/d H:m:s");
            echo "開始時間".$sTime."<br/>";
            echo "檢測結果<br />";
            for($i=$start;$i<=$end;$i++)
            {
                $url=ResetUrl($UrlArr[$i]);
                $state=GetStatusCode($url);
                echo "  ".$state ." => <a href='http://".$url."' target='_blank'>".$url."<a>";
                if($state!="200")
                {
                    echo " <span style='color:red;font-weight:bold'>本條訪問出錯!</span><br/>";
                    send_http_status($state);

                    //發郵件
                    require("Mail.php");
                    $MailPara["Subject"]="網站監控結果";
                    $MailPara["Body"]="錯誤信息:狀態-><span style='color:red;font-weight:bold'>".$state."</span><br/>地址:".$url;
                    SendResultMail($MailPara);

                    break;
                }
                echo "<br/>";
            }
            $eTime=date("Y/m/d H:m:s");

            echo "結束時間".$eTime."<br/>";
        }

    }
    ShowStateInfo($UrlArr,$MailPara);
?>

2.郵件
復制代碼 代碼如下:
function SendResultMail($MailPara)
    {
        require("phpmailer/class.phpmailer.php");

        $mail = new phpMailer();
        $mail->CharSet = $MailPara["CharSet"];
        $mail->IsSMTP();
        $mail->Host = $MailPara["Host"];
        $mail->Port = $MailPara["Port"];

        $mail->SMTPAuth = true;

        $mail->Username = $MailPara["FromMail"];
        $mail->Password = $MailPara["FromMailPassword"];
        $mail->From = $MailPara["FromMail"];
        $mail->FromName = $MailPara["FromMailName"];

        foreach($MailPara["To"] as $toMail)
        {
            $mail->AddAddress($toMail["ToMail"], $toMail["ToMailName"]);
        }

        $mail->Subject = $MailPara["Subject"];
        $mail->Body = $MailPara["Body"];
        $mail->AltBody = $MailPara["AltBody"];

        if(!$mail->Send())
        {
            echo "郵件發送失敗. <p>";
            echo "錯誤原因: " . $mail->ErrorInfo ."<br/>";
            exit;
        }

        echo "郵件發送成功<br/>";
    }

3.配置文件
復制代碼 代碼如下:
<?php
    $UrlArr=array(
        "localhost/test/281892.shtml",
        "localhost/test/all-229-1-221.shtml",
        "localhost/testclass/all-254-1-1.shtml",
        "localhost/test/cheng/bd/1988478.html",
        "localhost/test/asd/2066495.html"
    );

    //郵箱發送相關信息
    $MailPara=array(
        "CharSet"=> "GB2312",
        "Host"=> "smtp.exmail.qq.com",            // 郵箱服務地址
        "Port"=>25,

        "FromMail"=> "fdsafdsafd@fdasfds.com",    // 發件人郵箱地址
        "FromMailPassword"=> "*********", // 發件人郵箱密碼
        "FromMailName"=> "檢測",            //發件人稱呼

        "To"=>array(
            array(
                "ToMail"=>"defdafdsafdsafdf@qq.com",        //收件人郵箱地址
                "ToMailName"=> "bqq",            //收件人稱呼
            ),
            array(
                "ToMail"=>"abfdsafdsafdsafc@gmail.com",        //收件人郵箱地址
                "ToMailName"=> "agmail",            //收件人稱呼
            )
        ),

        "Subject"=> "",                //郵件標題
        "Body"=> "",            //郵件內容
        "AltBody"=> "附加信息"                //附加信息,可以省略       
    );

?>

郵件主要使用"phpmailer",點擊下載

php技術php 模擬post_驗證頁面的返回狀態(實例講解),轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 国产精品免费αv视频 | 小处雏一区二区三区精 | 久久亚洲aⅴ精品网站婷婷 久久亚洲不卡一区二区 | 午夜dj观看在线影院 | 久久久影院| 天天干夜夜怕 | 91在线视频免费观看 | 一级一级特黄女人精品毛片视频 | 免费人成网站尤物在线观看 | 91av国产在线 | 四虎最新网 | 成人观看天堂在线影片 | 国内精自视频品线六区免费 | 伊人久久久久久久久久 | 婷婷亚洲综合五月天小说在线 | 色老大综合久久综合热 | 国产亚洲欧洲精品 | 一级做性色a爰片久久毛片 一级做性色a爰片久久毛片免费 | 日韩美在线 | 一级毛片免费不卡 | 九色91精品国产网站 | 日本高清中文字幕一区二区三区 | 亚洲热在线观看 | 国产真实乱在线更新 | 国产午夜人做人免费视频中文 | 国产精品第一区在线观看 | 国产精品无内丝袜高跟鞋 | 国产在线视频91 | 国产码一区二区三区 | 蕾丝视频成人★在线观看 | 亚洲综合色婷婷在线观看 | 日韩一区二区三区免费 | 久久久99精品免费观看 | 欧美一级特黄aa大片婷婷 | 激情乱人伦 | 九月色婷婷 | 色久悠悠影院 | 色爽| 国产精品综合一区二区 | 国产在线精品一区二区三区不卡 | 精品自拍视频在线观看 |