This repository has been archived by the owner on May 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
internetbs_domaincheck.php
executable file
·74 lines (64 loc) · 2.04 KB
/
internetbs_domaincheck.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
72
73
74
<?php
if (file_exists('dbconnect.php')) {
require 'dbconnect.php';
} else {
require 'init.php';
}
require ROOTDIR . '/includes/functions.php';
require ROOTDIR . '/includes/registrarfunctions.php';
function parseResult($data)
{
$result = array ();
$arr = explode("\n", $data);
foreach ($arr as $str) {
list ( $varName, $value ) = explode("=", $str, 2);
$varName = trim($varName);
$value = trim($value);
$result [$varName] = $value;
}
return $result;
}
logactivity("Internetbs: Domain Check");
logactivity($postfields['Domain']);
$params = getregistrarconfigoptions('ibs');
$postfields = array ();
$postfields ['ApiKey'] = $params ['Username'];
$postfields ['Password'] = $params ['Password'];
$postfields ['ResponseFormat'] = 'TEXT';
$postfields ['Domain'] = $_GET['domain'];
$testMode = trim(strtolower($params ['TestMode'])) === "on";
if ($testMode) {
$url = 'https://testapi.internet.bs/domain/check';
} else {
$url = 'https://api.internet.bs/domain/check';
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, "WHMCS Internet.bs Corp. Domain Check");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
$data = curl_exec($ch);
$curl_err = false;
if (curl_error($ch)) {
$curl_err = 'CURL Error: ' . curl_errno($ch) . ' - ' . curl_error($ch);
exit('CURL Error: ' . curl_errno($ch) . ' - ' . curl_error($ch));
}
curl_close($ch);
if ($curl_err) {
$cronreport .= "Error connecting to API: $curl_err";
} else {
$result = parseResult($data);
if (!$result) {
$cronreport .= "Error connecting to API:<br>" . nl2br($data) . "<br>";
} else {
if (isset($result["status"]) && (strtoupper($result["status"]) === "AVAILABLE")) {
echo "domain found";
} else {
echo "domains not found";
}
}
}