Rev 5 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | daniel-mar | 1 | #!/usr/bin/php |
2 | <?php |
||
3 | |||
4 | # |
||
11 | daniel-mar | 5 | # VGWhoIs (ViaThinkSoft Global WhoIs, a fork of generic Whois / gwhois) |
5 | daniel-mar | 6 | # Subprogram: ge TLD whois |
2 | daniel-mar | 7 | # |
5 | daniel-mar | 8 | # (c) 2018 by Daniel Marschall, ViaThinkSoft <info@daniel-marschall.de> |
2 | daniel-mar | 9 | # |
5 | daniel-mar | 10 | # License: https://www.gnu.org/licenses/gpl-2.0.html (GPL version 2) |
2 | daniel-mar | 11 | # |
12 | |||
13 | require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php'; |
||
14 | |||
15 | $domain = isset($argv[1]) ? $argv[1] : ''; |
||
16 | |||
17 | list($domainwotld, $tld) = explode('.', $domain, 2); |
||
18 | |||
19 | $headers = array( |
||
20 | 'Origin' => 'http://www.nic.net.ge', |
||
21 | 'Accept-Encodinpt-Language' => 'de-DE,de;q=0.9,en-DE;q=0.8,en;q=0.7,en-US;q=0.6', |
||
22 | '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', |
||
23 | 'Content-Type' => 'application/x-www-form-urlencoded', |
||
24 | 'Accept' => '*/*', |
||
25 | 'Referer' => 'http://www.nic.net.ge/', |
||
26 | 'X-Requested-With' => 'XMLHttpRequest' |
||
27 | ); |
||
28 | |||
29 | //$url = 'http://www.nic.net.ge/Home/DomainCheckPreload'; |
||
30 | //$post = ''; |
||
31 | //$cont = file_get_contents2($url, $post, $headers); |
||
32 | |||
33 | $url = 'http://www.nic.net.ge/Home/DomainCheck'; |
||
34 | $post = 'Domain='.urlencode($domainwotld).'&TopLevelDomain='.urlencode('.'.$tld); |
||
35 | $cont = file_get_contents2($url, $post, $headers); |
||
36 | |||
37 | $data = json_decode($cont); // Output is UTF8 |
||
38 | |||
39 | if (!$data->Success) die("JSON request failed\n"); |
||
40 | |||
41 | $html = $data->Data; |
||
42 | |||
43 | if (strpos($html, '<!-- end info -->') === false) { |
||
44 | // Domain available |
||
45 | |||
46 | echo "Domain $domain is available for registration\n\n"; |
||
47 | |||
48 | if (preg_match('@<!-- end infobox -->(.+)<!-- end status -->@ismU', $html, $m)) { |
||
49 | $html = $m[1]; |
||
50 | $html = explode(',<br', $html)[0]; |
||
51 | } else { |
||
52 | echo "Error parsing data. Showing full page\n"; |
||
53 | $html = preg_replace('@<script(.+)</script>@is', '', $html); |
||
54 | } |
||
55 | } else { |
||
56 | // Domain not available |
||
57 | |||
58 | echo "Domain $domain is NOT available for registration\n\n"; |
||
59 | |||
60 | if (preg_match('@<!-- end infobox -->(.+)<!-- end info -->@ismU', $html, $m)) { |
||
61 | $html = $m[1]; |
||
62 | } else { |
||
63 | echo "Error parsing data. Showing full page\n"; |
||
64 | $html = preg_replace('@<script(.+)</script>@is', '', $html); |
||
65 | } |
||
66 | } |
||
67 | |||
68 | $text = strip_tags($html); |
||
69 | |||
70 | $text = preg_replace('@^[ \t]+@ism', '', $text); |
||
71 | $text = preg_replace('@[ \t]+$@ism', '', $text); |
||
72 | $text = preg_replace("/(\r\n|\n|\r){2,}/", "$1", $text); |
||
73 | $text = trim($text)."\n"; |
||
74 | |||
75 | echo $text; |
||
76 |