Subversion Repositories vgwhois

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 daniel-mar 1
#!/usr/bin/php
2
<?php
3
 
4
#
5
#  generic Whois - Subprogram "ge"
6
#
7
#  (c) 2018 by Daniel Marschall, ViaThinkSoft <www.viathinksoft.de>
8
#
9
#  Distribution, usage etc. pp. regulated by the current version of GPL.
10
#
11
#
12
#
13
# History:
14
# 2018-04-02  mar   Initial release
15
#
16
 
17
require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php';
18
 
19
$domain = isset($argv[1]) ? $argv[1] : '';
20
 
21
list($domainwotld, $tld) = explode('.', $domain, 2);
22
 
23
$headers = array(
24
	'Origin' => 'http://www.nic.net.ge',
25
	'Accept-Encodinpt-Language' => 'de-DE,de;q=0.9,en-DE;q=0.8,en;q=0.7,en-US;q=0.6',
26
	'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36',
27
	'Content-Type' => 'application/x-www-form-urlencoded',
28
	'Accept' => '*/*',
29
	'Referer' => 'http://www.nic.net.ge/',
30
	'X-Requested-With' => 'XMLHttpRequest'
31
);
32
 
33
//$url = 'http://www.nic.net.ge/Home/DomainCheckPreload';
34
//$post = '';
35
//$cont = file_get_contents2($url, $post, $headers);
36
 
37
$url = 'http://www.nic.net.ge/Home/DomainCheck';
38
$post = 'Domain='.urlencode($domainwotld).'&TopLevelDomain='.urlencode('.'.$tld);
39
$cont = file_get_contents2($url, $post, $headers);
40
 
41
$data = json_decode($cont); // Output is UTF8
42
 
43
if (!$data->Success) die("JSON request failed\n");
44
 
45
$html = $data->Data;
46
 
47
if (strpos($html, '<!-- end info -->') === false) {
48
	// Domain available
49
 
50
	echo "Domain $domain is available for registration\n\n";
51
 
52
	if (preg_match('@<!-- end infobox -->(.+)<!-- end status -->@ismU', $html, $m)) {
53
		$html = $m[1];
54
		$html = explode(',<br', $html)[0];
55
	} else {
56
		echo "Error parsing data. Showing full page\n";
57
		$html = preg_replace('@<script(.+)</script>@is', '', $html);
58
	}
59
} else {
60
	// Domain not available
61
 
62
	echo "Domain $domain is NOT available for registration\n\n";
63
 
64
	if (preg_match('@<!-- end infobox -->(.+)<!-- end info -->@ismU', $html, $m)) {
65
		$html = $m[1];
66
	} else {
67
		echo "Error parsing data. Showing full page\n";
68
		$html = preg_replace('@<script(.+)</script>@is', '', $html);
69
	}
70
}
71
 
72
$text = strip_tags($html);
73
 
74
$text = preg_replace('@^[ \t]+@ism', '', $text);
75
$text = preg_replace('@[ \t]+$@ism', '', $text);
76
$text = preg_replace("/(\r\n|\n|\r){2,}/", "$1", $text);
77
$text = trim($text)."\n";
78
 
79
echo $text;
80