Subversion Repositories vgwhois

Rev

Rev 5 | Go to most recent revision | Blame | Last modification | View Log | RSS feed

#!/usr/bin/php
<?php

#
#  VGWhoIs (ViaThinkSoft Global WhoIs, a fork of generic Whois / gwhois)
#  Subprogram: ge TLD whois
#
#  (c) 2018 by Daniel Marschall, ViaThinkSoft <info@daniel-marschall.de>
#
#  License: https://www.gnu.org/licenses/gpl-2.0.html (GPL version 2)
#

require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php';

$domain = isset($argv[1]) ? $argv[1] : '';

list($domainwotld, $tld) = explode('.', $domain, 2);

$headers = array(
        'Origin' => 'http://www.nic.net.ge',
        'Accept-Encodinpt-Language' => 'de-DE,de;q=0.9,en-DE;q=0.8,en;q=0.7,en-US;q=0.6',
        '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',
        'Content-Type' => 'application/x-www-form-urlencoded',
        'Accept' => '*/*',
        'Referer' => 'http://www.nic.net.ge/',
        'X-Requested-With' => 'XMLHttpRequest'
);

//$url = 'http://www.nic.net.ge/Home/DomainCheckPreload';
//$post = '';
//$cont = file_get_contents2($url, $post, $headers);

$url = 'http://www.nic.net.ge/Home/DomainCheck';
$post = 'Domain='.urlencode($domainwotld).'&TopLevelDomain='.urlencode('.'.$tld);
$cont = file_get_contents2($url, $post, $headers);

$data = json_decode($cont); // Output is UTF8

if (!$data->Success) die("JSON request failed\n");

$html = $data->Data;

if (strpos($html, '<!-- end info -->') === false) {
        // Domain available

        echo "Domain $domain is available for registration\n\n";

        if (preg_match('@<!-- end infobox -->(.+)<!-- end status -->@ismU', $html, $m)) {
                $html = $m[1];
                $html = explode(',<br', $html)[0];
        } else {
                echo "Error parsing data. Showing full page\n";
                $html = preg_replace('@<script(.+)</script>@is', '', $html);
        }
} else {
        // Domain not available

        echo "Domain $domain is NOT available for registration\n\n";

        if (preg_match('@<!-- end infobox -->(.+)<!-- end info -->@ismU', $html, $m)) {
                $html = $m[1];
        } else {
                echo "Error parsing data. Showing full page\n";
                $html = preg_replace('@<script(.+)</script>@is', '', $html);
        }
}

$text = strip_tags($html);

$text = preg_replace('@^[ \t]+@ism', '', $text);
$text = preg_replace('@[ \t]+$@ism', '', $text);
$text = preg_replace("/(\r\n|\n|\r){2,}/", "$1", $text);
$text = trim($text)."\n";

echo $text;