最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時(shí)間:2013年10月28日 09:05:39   作者:  
php模擬post_驗(yàn)證頁面的返回狀態(tài)(實(shí)例講解)。需要的朋友可以過來參考下,希望對(duì)大家有所幫助

1.主要文件,訪問該頁面,該頁面根據(jù)“驗(yàn)證頁面”的返回結(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 "&nbsp;&nbsp;".$state ."&nbsp;=>&nbsp;<a href='http://".$url."' target='_blank'>".$url."<a>";
                if($state!="200")
                {
                    echo " <span style='color:red;font-weight:bold'>本條訪問出錯(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)擊下載

相關(guān)文章

  • yii2中使用Active Record模式的方法

    yii2中使用Active Record模式的方法

    這篇文章主要介紹了yii2中使用Active Record模式的方法,結(jié)合實(shí)例分析了Yii2中使用Active Record模式的具體步驟與相關(guān)操作方法,需要的朋友可以參考下
    2016-01-01
  • Thinkphp3.2.3分頁使用實(shí)例解析

    Thinkphp3.2.3分頁使用實(shí)例解析

    這篇文章主要介紹了Thinkphp3.2.3分頁使用實(shí)例,采取調(diào)用公共函數(shù)中的函數(shù)方法實(shí)現(xiàn)分頁,感興趣的小伙伴們可以參考一下
    2016-07-07
  • 網(wǎng)頁的分頁下標(biāo)生成代碼(PHP后端方法)

    網(wǎng)頁的分頁下標(biāo)生成代碼(PHP后端方法)

    網(wǎng)頁的分頁選擇效果直接影響用戶的使用體驗(yàn)。類似功能的方法有很多,我在這里寫的方法主要是的優(yōu)勢(shì)在于前后端分離,可以自己定義長(zhǎng)度和分頁的行數(shù)
    2016-02-02
  • tp5(thinkPHP5)框架連接數(shù)據(jù)庫的方法示例

    tp5(thinkPHP5)框架連接數(shù)據(jù)庫的方法示例

    這篇文章主要介紹了tp5(thinkPHP5)框架連接數(shù)據(jù)庫的方法,結(jié)合實(shí)例形式較為詳細(xì)的分析了基于thinkPHP5框架連接數(shù)據(jù)庫的相關(guān)配置、數(shù)據(jù)讀取、模板渲染等操作技巧,需要的朋友可以參考下
    2018-12-12
  • PHP中比較時(shí)間大小實(shí)例

    PHP中比較時(shí)間大小實(shí)例

    這篇文章主要介紹了PHP中比較時(shí)間大小實(shí)例,可能是最基礎(chǔ)的寫法了,直接用運(yùn)算符比較,需要的朋友可以參考下
    2014-08-08
  • PHP函數(shù)addslashes和mysql_real_escape_string的區(qū)別

    PHP函數(shù)addslashes和mysql_real_escape_string的區(qū)別

    這篇文章主要介紹了PHP函數(shù)addslashes和mysql_real_escape_string的區(qū)別,以及一個(gè)SQL注入漏洞介紹,需要的朋友可以參考下
    2014-04-04
  • 解決Laravel 使用insert插入數(shù)據(jù),字段created_at為0000的問題

    解決Laravel 使用insert插入數(shù)據(jù),字段created_at為0000的問題

    今天小編就為大家分享一篇解決Laravel 使用insert插入數(shù)據(jù),字段created_at為0000的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2019-10-10
  • PHP實(shí)現(xiàn)的7組經(jīng)緯度與距離的計(jì)算函數(shù)demo

    PHP實(shí)現(xiàn)的7組經(jīng)緯度與距離的計(jì)算函數(shù)demo

    這篇文章主要為大家介紹了PHP實(shí)現(xiàn)的7組經(jīng)緯度與距離的計(jì)算函數(shù)demo,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-05-05
  • phpstudy本地環(huán)境搭建超詳細(xì)圖文教程

    phpstudy本地環(huán)境搭建超詳細(xì)圖文教程

    這篇文章主要給大家介紹了關(guān)于phpstudy本地環(huán)境搭建超詳細(xì)圖文教程的相關(guān)資料,phpStudy是集安全、高效、功能于一體且完全免費(fèi)的一鍵服務(wù)器環(huán)境搭建軟件,文中通過圖文介紹的非常詳細(xì),需要的朋友可以參考下
    2023-07-07
  • TP5框架使用QueryList采集框架爬小說操作示例

    TP5框架使用QueryList采集框架爬小說操作示例

    這篇文章主要介紹了TP5框架使用QueryList采集框架爬小說操作,結(jié)合實(shí)例形式分析了TP5結(jié)合QueryList采集框架爬17k小說的相關(guān)原理、步驟與實(shí)現(xiàn)技巧,需要的朋友可以參考下
    2020-03-03

最新評(píng)論

隆尧县| 平乐县| 远安县| 土默特右旗| 石嘴山市| 辛集市| 蒙城县| 合作市| 邮箱| 商南县| 新巴尔虎左旗| 综艺| 宁强县| 甘谷县| 台江县| 渭南市| 都江堰市| 洪雅县| 平阴县| 台前县| 衢州市| 正定县| 兰考县| 宁武县| 炉霍县| 通化市| 蕉岭县| 吉安县| 漾濞| 利津县| 巨鹿县| 会同县| 恭城| 福安市| 晴隆县| 邵武市| 兴安县| 广河县| 苏尼特左旗| 雷波县| 于田县|