温馨提醒
如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢
本文最后更新于2023年10月11日,已超过 180天没有更新
<?php //设置最大执行时间是 120秒 ini_set('max_execution_time',120); require('e/class/connect.php'); require('e/class/db_sql.php'); require('e/data/dbcache/class.php'); $link=db_connect(); $empire=new mysqlquery(); $wzurl="https://www.hhymw.com";//自己的网站地址 // 监测链接能否正常访问 function httpcode($url){ $ch = curl_init(); $timeout = 5; $user_agent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36"; curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_REFERER, $wzurl); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); $results=curl_exec($ch); $httpcode = curl_getinfo($ch,CURLINFO_HTTP_CODE); if($httpcode= 200) { if(strpos($results,'链接不存在')||$results=''||strpos($results,'404')){ return '地址失效!!!'; }else{ return '地址正常'; } }else{ return $httpcode; } curl_close($ch); } // 要监测的链接数组 $sql=$empire->query("select * from {$dbtbpre}ecms_download order by newstime desc limit 20 "); //查询下载数据表最新20条信息 $downpath=array(); while($r=$empire->fetch($sql)){ $finfor=$empire->fetch1("select * from {$dbtbpre}ecms_download_data_".$r['stb']." where id='$r[id]' limit 1"); $finfor['downpath']=$finfor['downpath'].$r['title'].$r['id']; $downpath[]=explode("::::::",$finfor['downpath']); } //区分下载地址 foreach ($downpath as $key => $value) { if(strpos($value[1],'https://') === 0){ $url=$value[1]; }else{ $url=$wzurl.$value[1]; } echo '编号:'.$key.'->标题:'.$value[4].' ->地址: '.$url.' ->状态: '.httpcode($url).'<br>'; //以下为JSON输出可以注释 /* echo json_encode( [ "bianhao" => $key, "title"=>$value[4], "titleurl"=>$url, "status" =>httpcode($url), ] ); */ }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论0+