This repository has been archived by the owner on Apr 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
query.php
71 lines (55 loc) · 1.59 KB
/
query.php
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
<?php
require 'include/loader.php';
$domain = '';
if (IS_CLI) {
if ($argc < 2) {
throw new MissingDomainArgumentException();
}
$domain = $argv[1];
} else {
if (!isset($_REQUEST['domain'])) {
throw new MissingDomainArgumentException();
}
$domain = $_REQUEST['domain'];
}
$domain = extract_domain($domain);
if ($domain === false) {
throw new InvalidDomainSuffixException();
}
$client = new SoapClient(BEIAN_WSDL_URL);
$key = ISP_PASSWORD;
$rand = randstr(20);
$params = array(
'ispID' => ISP_ID,
'userName' => ISP_USERNAME,
'randVal' => $rand,
'pwdHash' => base64_encode(md5($key . $rand, true)),
'hashAlgorithm' => 0,
'queryConditionType' => 0,
'queryCondition' => extract_domain($domain),
);
$response = $client->__soapCall("isp_querybeianstatus", array($params));
if (!$response || !$response->return) {
throw new UnknownException();
}
$return = str_replace('GBK', 'UTF-8', $response->return);
$return = simplexml_load_string($return);
if (!$return) {
throw new InvalidXMLPayloadException();
}
if (intval($return->msg_code) !== 0) {
throw new MIITSOAPException($return->msg);
}
$ret = array(
'success' => true,
'domain' => $domain,
'status' => intval($return->StatusInfo->Bazt) == 0
);
if ($ret['status']) {
$ret = array_merge($ret, array(
'name' => (string) $return->StatusInfo->Wzmc,
'icp_subject' => (string) $return->StatusInfo->Ztbah,
'icp_site' => (string) $return->StatusInfo->Wzbah
));
}
response($ret);