-
Notifications
You must be signed in to change notification settings - Fork 1
/
whois.php
executable file
·108 lines (90 loc) · 3.84 KB
/
whois.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
<?php
require_once("phpwhois-4.2.2/whois.main.php");
require_once("phpwhois-4.2.2/whois.utils.php");
require_once("registered-domains-php-master/effectiveTLDs.inc.php");
require_once("registered-domains-php-master/regDomain.inc.php");
getwhois("http://www.cd.rd.frontcoding.com");
function getwhois($query){
if(!is_numeric($query[0])){
$query = getRegisteredDomain(parse_url($query, PHP_URL_HOST));
}
echo $query;
$whois = new Whois();
// if(!$whois->ValidDomain($query)){
// return 'Sorry, the domain is not valid or not supported.';
// }
$insert_array = array();
$to_insert = "";
$values = "registrar, whois_server, referral_url, name_server, status, updated_date, creation_data, expiration_date, administrative_contact, technical_contact";
$result = $whois->Lookup($query);
$regyinfo = $result['regyinfo'];
$regrinfo = $result['regrinfo'];
$domain = $regrinfo['domain'];
$insert_array['whois_server'] = $regyinfo['referrer'];
$insert_array['registrar'] = $regyinfo['registrar'];
$insert_array['referral_url'] = $regyinfo['referrer'];
$insert_array['host_name'] = $domain['name'];
$insert_array['name_server'] = "";
foreach ($domain['nserver'] as $server => $address) {
$insert_array['name_server'] .= $server . ": " . $address . ", ";
}
$insert_array['status'] = "";
foreach ($domain['status'] as $status) {
$insert_array['status'] .= $status. ", ";
}
$insert_array['updated_date'] = $domain['changed'];
$insert_array['creation_date'] = $domain['created'];
$insert_array['expiration_date'] = $domain['expires'];
//CONTACT INFORMATION (may not exist)
// organization-> organization name
// name-> organization responsible
// type-> type of contact
// address-> array containing the address, the
// keys of that array could be just
// numbers, could have predefined
// subkeys or could be amix of numbers
// and predefined subkeys. Predefined
// subkeys are street, city,
// state, pcode and country
// phone-> phone, could also be an array of
// phone numers
// fax-> fax, same behaviour as phone
// email-> email, same behaviour as phone
$admin = $regrinfo['admin'];
$tech = $regrinfo['tech'];
$insert_array['administrative_contact'] = "";
$insert_array['administrative_contact'] .= " " . $admin['organization'];
$insert_array['administrative_contact'] .= " " . $admin['name'];
$insert_array['administrative_contact'] .= " " . $admin['type'];
foreach ($admin['address'] as $info) {
$insert_array['administrative_contact'] .= " " . $info;
}
$insert_array['administrative_contact'] .= " " . $admin['phone'];
$insert_array['administrative_contact'] .= " " . $admin['fax'];
$insert_array['administrative_contact'] .= " " . $admin['email'];
$insert_array['technical_contact'] = "";
$insert_array['technical_contact'] .= " " . $tech['organization'];
$insert_array['technical_contact'] .= " " . $tech['name'];
$insert_array['technical_contact'] .= " " . $tech['type'];
foreach ($tech['address'] as $info) {
$insert_array['technical_contact'] .= " " . $info;
}
$insert_array['technical_contact'] .= " " . $tech['phone'];
$insert_array['technical_contact'] .= " " . $tech['fax'];
$insert_array['technical_contact'] .= " " . $tech['email'];
print_r($insert_array['status']);
save_who_is($insert_array);
}
function save_who_is($who_is_data){
$columns = "registrar, whois_server, referral_url, name_server, status, updated_date, creation_date, expiration_date, administrative_contact, technical_contact";
$sql = "INSERT INTO web_host (" . $columns . ")";
$sql_values = " VALUES (";
$columns_array = explode(", ", $columns);
foreach ($columns_array as $column) {
$sql_values.= $who_is_data[$column] .", ";
}
$sql_values.=");";
$sql .= $sql_values;
echo $sql;
}
?>