1.主要文件,访问该页面,该页面根据“验证页面”的返回结果设置本文件的返回状态 header(‘http/1.1 ‘.$code.’ ‘.$_status[$code])
复制代码 代码如下:
<?php
ini_t(‘max_execution_time’, 120);
include(“checkconfig.php”);
function nd_http_status($code) {
static $_status = array(
// informational 1xx
=> ‘continue’,
=> ‘switching protocols’,
// success 2xx
=> ‘ok’,
=> ‘created’,
=> ‘accepted’,
=> ‘non-authoritative information’,
=> ‘no content’,
=> ‘ret content十四五规划主要内容’,
=> ‘partial content’,
// redirection 3xx
=> ‘multiple choices’,
=> ‘moved permanently’,
=> ‘moved temporarily ‘, // 1.1
=> ‘e other’,
=> ‘not modified’,
=> ‘u proxy’,
// 306 is deprecated but rerved
=> ‘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’,
// rver error 5xx
=> ‘internal rver error’,
=> ‘not implemented’,
=> ‘bad gateway’,
=> ‘rvice 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_topt($curl, curlopt_url, $url); //设置url
curl_topt($curl, curlopt_header, 1); //获取header
curl_topt($curl,curlopt_nobody,true); //body就不要了吧,我们只是需要head
curl_topt($curl, curlopt_returntransfer, 1); //数据存到成字符串吧,别给我直接输出到屏幕了
$data = curl_exec($curl); //开始执行啦~
$httpcode =curl_getinfo($curl,curlinfo_http_code); //我知道httpstat码哦~
curl_clo($curl); //用完记得关掉他
return $httpcode;
}
function returl($url)
{
if(strpos($url,”?”)>0)
$url.=”&rnd”;
el
$url.=”?rnd”;
$url.=rand();
return $url;
}
function showstateinfo($urlarr,$mailpara)
{
$count=count($urlarr);
if(ist($_request[“start”]))
{
$start=$_request[“start”]*1;
}
el
{
$start=1;
}
if(ist($_request[“end”]))
{
$end=$_request[“end”]*1;
}
el
{
$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=returl($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/>”;
nd_http_status($state);
//发邮件
require(“mail.php”);
$mailpara[“subject”]=”网站监控结果”;
$mailpara[“body”]=”错误信息:状态-><span style=’color:red;font-weight:bold’>”.$state.”</span><br/>地址:”.$url;
ndresultmail($mailpara);
break;
}
echo “<br/>”;
}
$etime=date(“y/m/d h:m:s”);
echo “结束时间”.$etime.”<br/>”;
}
}
showstateinfo($urlarr,$mailpara);
?>
2.邮件
复制代码 代码如下:
function ndresultmail($mailpara)
{
require(“phpmailer/class.phpmailer.php”);
$mail = new phpmailer();
$mail->chart = $mailpara[“chart”];
$mail->issmtp();
$mail->host = $mailpara[“host”];
$mail->port = $mailpara[“port”];
$mail->smtpauth = true;
$mail->urname = $mailpara[“frommail”];
$mail->password = $mailpara[“frommailpassword”];
$mail->from = $mailpara[“frommail̶黄水晶的功效1;];
$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->nd())
{
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/2066发挥党员作用495.html”
);
//邮箱发送相关信息
$mailpara=array(
“chart”=> “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昆虫记读后感800字”=> “agmail”, //收件人称呼
)
),
“subject”=> “”, //邮件标题
“body”=> “”, //邮件内容
“altbody”=> “附加信息” //附加信息,可以省略
);
?>
邮件主要使用”phpmailer”,
本文发布于:2023-04-06 09:40:21,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/ffa608e1a1d1245d7fee458ca4df05d3.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:php 模拟post.doc
本文 PDF 下载地址:php 模拟post.pdf
留言与评论(共有 0 条评论) |