1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
| <?php
/*
* 检测域名是否被墙
* 2dph.com
*/
//查询域名
$domain = '2dph.com';
$post = array(
'func' => 'true'
,'m' => 'check'
,'a' => 'check'
,'domain'=> $domain
);
$rel = _qiang($post);
$arr = json_decode($rel,true);
if ($arr['strcode'] == 1) {
echo '该域名没有被墙';
}elseif ($arr['strcode'] == -1) {
echo '该域名被墙了';
}else{
echo '查询失败';
}
function _qiang($post) {
// 创建一个新cURL资源
$ch = curl_init();
// 设置URL和相应的选项
curl_setopt($ch, CURLOPT_URL, 'https://tool.22.cn/ajax/qiang.ashx?'.time());
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HEADER, 0);
//将curl_exec()获取的信息以文件流的形式返回,而不是直接输出
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//POST请求
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
//执行cURL会话
$response = curl_exec($ch);
// 关闭cURL资源,并且释放系统资源
curl_close($ch);
return $response;
}
|