-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.php
executable file
·117 lines (108 loc) · 3.88 KB
/
index.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/**
* WhoIS REST Services API
*
* You may not change or alter any portion of this comment or credits
* of supporting developers from this source code or any supporting source code
* which is considered copyrighted (c) material of the original comment or credit authors.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @copyright Chronolabs Cooperative http://syd.au.snails.email
* @license ACADEMIC APL 2 (https://sourceforge.net/u/chronolabscoop/wiki/Academic%20Public%20License%2C%20version%202.0/)
* @license GNU GPL 3 (http://www.gnu.org/licenses/gpl.html)
* @package whois-api
* @since 2.2.13
* @author Dr. Simon Antony Roberts <[email protected]>
* @version 2.2.14
* @description A REST API Interface which retrieves IPv4, IPv6, TLD, gLTD Whois Data
* @link http://internetfounder.wordpress.com
* @link https://github.com/Chronolabs-Cooperative/WhoIS-API-PHP
* @link https://sourceforge.net/p/chronolabs-cooperative
* @link https://facebook.com/ChronolabsCoop
* @link https://twitter.com/ChronolabsCoop
*
*/
$parts = explode(".", microtime(true));
mt_srand(mt_rand(-microtime(true), microtime(true))/$parts[1]);
mt_srand(mt_rand(-microtime(true), microtime(true))/$parts[1]);
mt_srand(mt_rand(-microtime(true), microtime(true))/$parts[1]);
mt_srand(mt_rand(-microtime(true), microtime(true))/$parts[1]);
$salter = ((float)(mt_rand(0,1)==1?'':'-').$parts[1].'.'.$parts[0]) / sqrt((float)$parts[1].'.'.intval(cosh($parts[0])))*tanh($parts[1]) * mt_rand(1, intval($parts[0] / $parts[1]));
header('Blowfish-salt: '. $salter);
global $domain, $protocol, $business, $entity, $contact, $referee, $peerings, $source;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'apiconfig.php';
$help=false;
if (!isset($_GET['whois']) || empty($_GET['whois'])) {
$help=true;
} elseif (isset($_GET['output']) || !empty($_GET['output'])) {
$whois = trim($_GET['whois']);
$output = trim($_GET['output']);
} else {
$help=true;
}
/**
* Buffers Help
*/
if ($help==true) {
if (function_exists("http_response_code"))
http_response_code(400);
include dirname(__FILE__).'/help.php';
exit;
}
/**
* Calculates Whitelist
*/
if (function_exists('whitelistGetIP') && function_exists('whitelistGetIPAddy') && defined('MAXIMUM_QUERIES'))
{
session_start();
if (!in_array(whitelistGetIP(true), whitelistGetIPAddy())) {
if (isset($_SESSION['reset']) && $_SESSION['reset']<microtime(true))
$_SESSION['hits'] = 0;
if ($_SESSION['hits']<=MAXIMUM_QUERIES) {
if (!isset($_SESSION['hits']) || $_SESSION['hits'] = 0)
$_SESSION['reset'] = microtime(true) + 3600;
$_SESSION['hits']++;
} else {
header("HTTP/1.0 404 Not Found");
if (function_exists("http_response_code"))
http_response_code(404);
exit;
}
}
}
/**
* Commences Execution of API Functions
*/
if (function_exists("http_response_code"))
http_response_code(200);
$whoisObj = new whois();
$data = $whoisObj->query($whois, $output);
switch ($output) {
default:
echo '<h1>'.$whois.' whois data</h1>';
echo '<pre style="font-family: \'Courier New\', Courier, Terminal; font-size: 0.77em;">';
echo print_r($data, true);
echo '</pre>';
break;
case 'raw':
echo "<?php\n\n return " . var_export($data, true) . ";\n\n?>";
break;
case 'json':
header('Content-type: application/json');
echo json_encode($data);
break;
case 'serial':
header('Content-type: text/html');
echo serialise($data);
break;
case 'xml':
header('Content-type: application/xml');
$dom = new XmlDomConstruct('1.0', 'utf-8');
$dom->fromMixed(array('root'=>$data));
echo $dom->saveXML();
break;
}
exit(0);
?>