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

php 模擬post_驗(yàn)證頁(yè)面的返回狀態(tài)(實(shí)例講解)

1.主要文件,訪問(wèn)該頁(yè)面,該頁(yè)面根據(jù)“驗(yàn)證頁(yè)面”的返回結(jié)果設(shè)置本文件的返回狀態(tài) header('HTTP/1.1 '.$code.' '.$_status[$code])
復(fù)制代碼 代碼如下:
<?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); //設(shè)置URL

        curl_setopt($curl, CURLOPT_HEADER, 1); //獲取Header
        curl_setopt($curl,CURLOPT_NOBODY,true); //Body就不要了吧,我們只是需要Head
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //數(shù)據(jù)存到成字符串吧,別給我直接輸出到屏幕了
        $data = curl_exec($curl); //開始執(zhí)行啦~
        $HttpCode =curl_getinfo($curl,CURLINFO_HTTP_CODE); //我知道HTTPSTAT碼哦~
        curl_close($curl); //用完記得關(guān)掉他
        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 "開始時(shí)間".$sTime."<br/>";
            echo "檢測(cè)結(jié)果<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'>本條訪問(wèn)出錯(cuò)!</span><br/>";
                    send_http_status($state);

                    //發(fā)郵件
                    require("Mail.php");
                    $MailPara["Subject"]="網(wǎng)站監(jiān)控結(jié)果";
                    $MailPara["Body"]="錯(cuò)誤信息:狀態(tài)-><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 "結(jié)束時(shí)間".$eTime."<br/>";
        }

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

2.郵件
復(fù)制代碼 代碼如下:
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 "郵件發(fā)送失敗. <p>";
            echo "錯(cuò)誤原因: " . $mail->ErrorInfo ."<br/>";
            exit;
        }

        echo "郵件發(fā)送成功<br/>";
    }

3.配置文件
復(fù)制代碼 代碼如下:
<?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"
    );

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

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

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

        "Subject"=> "",                //郵件標(biāo)題
        "Body"=> "",            //郵件內(nèi)容
        "AltBody"=> "附加信息"                //附加信息,可以省略       
    );

?>

郵件主要使用"phpmailer",點(diǎn)擊下載

php技術(shù)php 模擬post_驗(yàn)證頁(yè)面的返回狀態(tài)(實(shí)例講解),轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 国产观看精品一区二区三区 | 九九99re在线视频精品免费 | 久草视频中文在线 | 亚洲欧美成人影院 | 久久久久亚洲国产 | 二区中文字幕 | 高清一区高清二区视频 | 久久久性 | 国产高清黄色 | 久青草国产手机视频免费观看 | 国产精品福利影院 | 亚洲成a人片毛片在线 | 一道精品视频一区二区三区男同 | 丁香综合激情 | 扒开双腿猛进入无遮挡软件 | 日本一区二区日本免费 | 影音先锋色偷偷米奇四色 | 国产精品视频1区 | 美女胸又大又黄又www的网站 | 五月天论坛 | 久久精品久久精品 | 九色综合伊人久久富二代 | 激情五月网站 | 日韩精品中文字幕视频一区 | 亚洲国产欧美在线成人aaaa | 国产成人福利免费视频 | 日韩精品中文字幕一区二区三区 | 成人福利在线免费观看 | 国产精品亚洲自在线播放页码 | 精品国产香蕉在线播出 | 色吊丝网站 | 天天干天天操天天做 | 日韩精品久久久免费观看夜色 | 精品久久天干天天天按摩 | 91插插插网站 | 日韩精品片 | 国产人成亚洲第一网站在线播放 | 国模青青丰满人体大尺度展示 | 国产欧美日韩综合精品一区二区三区 | 中文字幕综合久久久久 | 日韩经典欧美一区二区三区 |