-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcheck.php
More file actions
73 lines (60 loc) · 1.71 KB
/
Copy pathcheck.php
File metadata and controls
73 lines (60 loc) · 1.71 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
use phpDocumentor\Reflection\DocBlock\Tags\Var_;
function http_test($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if (!empty($data)) {
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
$ret = curl_exec($ch);
curl_close($ch);
return $ret !== false;
}
function wx_test($url)
{
$url = 'https://mp.weixinbridge.com/mp/wapredirect?url='.$url;
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if (!empty($data)) {
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
$ret = curl_exec($ch);
$redirect = false;
if (!curl_errno($ch)) {
$info = curl_getinfo($ch);
if($info['http_code']==302 && strpos($info['redirect_url'],'https://weixin110.qq.com')===false){
$redirect = true;
}
}
curl_close($ch);
if($ret!==false && !$redirect){
return false;
}
return true;
}
$host = $_REQUEST['host'];
//$host = $_SERVER['argv'][1];
if (empty($host)) {
echo json_encode(['code' => 400]);
exit();
}
$rsp = http_test($host);
if (!$rsp) {
echo json_encode(['code' => 100]);
exit();
}
$rsp = wx_test($host);
if ($rsp) {
echo json_encode(['code' => 200]);
exit();
}
echo json_encode(['code' => 100]);