当前位置:首页 > 代码·功能 > 正文

PHP监控魔门云是否GG cloudxns自动停止解析

前段时间不知道为什么一到凌晨 魔门云就开始不定时歇菜,估计是半夜没人维护机器就崩了吧2333

不过就那么歇菜也不是个办法咯,于是就想定时监控这魔门云状态 gg了就停止解析 本来是准备用cloudxns里的监控,后来...cloudxns不支持https监控 而且魔门云有时候虽然gg了但是状态码有时候还会是200或者301

然后就看了下cloudxns提供的api 文档还算简洁...不过PHPSDK不想说什么,智障!!没事还要装拓展...

<?php
function callInterfaceCommon($URL,$type,$params,$headers){ 
 $ch = curl_init(); 
 $timeout = 5; 
 curl_setopt ($ch, CURLOPT_URL, $URL); 
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);// 对认证证书来源的检查 
 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在 
 if( !empty( $headers)){ 
 		curl_setopt ($ch, CURLOPT_HTTPHEADER, $headers); 
 }else { 
 curl_setopt ($ch, CURLOPT_HTTPHEADER, array('Content-type: text/json')); 
 } 
 curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
 curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 
 switch ($type){ 
 case "GET" : curl_setopt($ch, CURLOPT_HTTPGET, true);break; 
 case "POST": curl_setopt($ch, CURLOPT_POST,true); 
 curl_setopt($ch, CURLOPT_POSTFIELDS,$params);break; 
 case "PUT" : curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, "PUT"); 
 curl_setopt($ch, CURLOPT_POSTFIELDS,$params);break; 
 case "DELETE":curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
 curl_setopt($ch, CURLOPT_POSTFIELDS,$params);break; 
 } 
 $file_contents = curl_exec($ch);//获得返回值 
 curl_close($ch); 
 return $file_contents;
}
function domain($status){
 do{
 $url = 'https://www.cloudxns.net/api2/record/pause';
 $api_key = '';//cloudxns的api_key
 $data = json_encode(array('id'=>3550589,'domain_id'=>112993,'status'=>$status));
 $secret_key = '';//cloudxns的secret_key
 $headers=array( "API-KEY:$api_key",
 				"API-REQUEST-DATE:".date(),
 				"API-HMAC:".md5($api_key.$url.$data.date().$secret_key)
 			); 
 $response = callInterfaceCommon($url, 'POST',$data,$headers); 
 $json = json_decode($response,true);
 }while($json['message']!='success');
}
function http($url){
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, $url);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_HEADER, 0);
 $output = curl_exec($ch);
 curl_close($ch);
 return $output;
}
$con = http('魔门云预览链接+文件路径');
if($con==date('D')){
 if(file_get_contents('status')=='no'){
 domain(1);
 }
 file_put_contents('status','ok');
 echo 'ok';
}else{
 if(file_get_contents('status')=='ok'){
 domain(0);
 }
 echo 'no';
 file_put_contents('status','no');
}
?>

魔门云预览链接+文件路径 放置一个用以输出特定内容的php文件 例如echo date('D') 我这里就是用这个咯

毫无技术可言,不过还算靠谱 cloudxns的API千万不要频繁访问,会被当作CC 然后IP...

标签:
上一篇: 下一篇:

12 条评论

评论加载中...
  1. 9楼
    Serbia Mozilla SeaMonkey Windows XP
    UK Chat  

    126086 313439Hey I was just seeking at your website in Firefox and the image at the top of the link cant show up properly. Just thought I would let you know. 783932

    2018年8月15日 22:50 评论
  2. 36038 149764hello, i came in to learn about this topic, thanks alot. will put this internet site into my bookmarks. 432680

    2018年8月14日 15:49 评论
  3. 7楼
    来自天朝的朋友 谷歌浏览器 Windows 7
    百影阁  

    再回来说一句话,魔门云现在好坑啊,以前挺好的,客服发现你频繁开关都主动找你, :bobo_gongxi:

    2017年8月21日 07:41 评论
  4. 6楼
    来自天朝的朋友 谷歌浏览器 Windows 10
    小萝博客  

    体验了一下,节点少,卡卡的

    2017年8月17日 18:53 评论
    • 小幻  

      恩,现在改的节点好坑

      2017年8月18日 09:49 评论
  5. 5楼
    来自天朝的朋友 QQ浏览器 Mac OS X 10_12_6
    April's Blog  

    大佬就爱开玩笑 技术贼6

    2017年8月16日 13:39 评论
    • 小幻  

      (。ò ∀ ó。)

      2017年8月18日 09:50 评论
  6. 4楼
    来自天朝的朋友 QQ浏览器  Android 7.1.2 Lenovo K3 Note Build/NJH47D
    祭夜  

    暂时放弃魔门云

    2017年8月15日 13:02 评论
  7. 地板
    来自天朝的朋友 QQ浏览器  Android 7.1.2 Lenovo K3 Note Build/NJH47D
    祭夜  

    已放弃魔门云

    2017年8月15日 13:00 评论
    • 小幻  

      23333

      2017年8月18日 09:47 评论
  8. 板凳
    来自天朝的朋友 谷歌浏览器 Windows 7
    百影阁  

    你这句“毫无技术可言”就让我自卑了。。。

    2017年8月14日 18:19 评论
  9. 沙发
    来自天朝的朋友 谷歌浏览器 Windows 10
    狂放  

    然而我已经不用魔门了,天天gg

    2017年8月12日 17:23 评论

发表评论

不理你。不要啊!吃饭。吃惊。吃西瓜。飞吻!恭喜!Hi纠结!膜拜!OK抛媚眼。泡泡糖。抛钱。忍!生闷气!调皮。偷看。委屈。献花。疑问?抓狂!

小提示:Ctrl+Enter快速提交助您一臂之力~
加载中……