-
Notifications
You must be signed in to change notification settings - Fork 9
/
method.whois-curl.php
68 lines (59 loc) · 1.96 KB
/
method.whois-curl.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
<?php
require('./config.variables.php');
if (!function_exists('search')) {
/**
* Search more than one extension
* @param string $name
* @param array $extensions
* @return array
* @example search('emrecanoztas', array('com', 'net'));
*/
function search(string $name, array $extensions): array
{
$domain = '';
$address = '';
$output = '';
$info = array();
foreach ($extensions as $extension) {
if (array_key_exists($extension, EXTENSION_LIST)) {
$address = EXTENSION_LIST[$extension];
$domain = $name . '.' . $extension;
array_push($info, whois($domain, $address));
}
}
return($info);
}
}
if (!function_exists('whois')) {
/**
* Getting information about domain.
* @param string $domain
* @param string $address
* @return array
*
* @example whois('emrecanoztas.com', 'whois.crsnic.net')
*/
function whois(string $domain, string $address): array
{
$curl = null;
$output = '';
$info = array();
if (!function_exists('curl_version')) {
trigger_error('cURL is not found!');
} else {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $address);
curl_setopt($curl, CURLOPT_PORT, PORT);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, TIMEOUT);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $domain . "\r\n");
$output = curl_exec($curl);
curl_close($curl);
$info['domain'] = $domain;
!(strstr($output, 'No match for')) ? $info['status'] = 0 : $info['status'] = 1;
!(strstr($output, 'No match for')) ? $info['description'] = 'Not available' : $info['description'] = 'Available';
$info['whois'] = $output;
}
return($info);
}
}