Rev 5 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/usr/bin/php
<?php
#
# VGWhoIs (ViaThinkSoft Global WhoIs, a fork of generic Whois / gwhois)
# Subprogram: tt TLD whois
#
# (c) 2011 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] : '';
$url = "https://www.nic.tt/cgi-bin/search.pl";
$post = "name=$domain";
$res = "% Parsing via regex from '$url' with post parameters '$post'\n\n";
$x = file_get_contents2($url, $post);
preg_match_all('|<div id="main">(.*)<div id="foot">|ismU', $x, $m);
$x = $m[1][0];
# The Domain Name <font color=red>nia.tt</font> is available.
$x = str_replace('<font color=red>', '', $x);
$x = str_replace('</font>', '', $x);
# Entferne, wenn möglich:
# Domain Search Form
# Enter Domain Name:
$bry = explode('</form>', $x, 2);
$x = $bry[count($bry)-1];
$x = str_replace('>', ">\n", $x);
$x = strip_tags($x);
#   -> -- did they really do this? yeah...
$x = preg_replace('| (?!;)|ismU', ' ', $x);
// You might wonder why trim(html_entity_decode(' ')); doesn't reduce the string to an
// empty string, that's because the ' ' entity is not ASCII code 32
// (which is stripped by trim()) but ASCII code 160 (0xa0) in the default ISO 8859-1 characterset.
$x = str_replace(" ", " ", $x);
$x = html_entity_decode($x);
$x = preg_replace("| +|", ' ', $x);
$x = preg_replace("|\n *|", "\n", $x);
$x = preg_replace("|\n+|", "\n", $x);
$special_words = array(
'Domain Name',
'Registrant Name',
'Registrant Address',
'DNS Hostnames',
'DNS IP Addresses',
'Expiration Date',
'Administrative Contact',
'Technical Contact',
'Billing Contact'
);
foreach ($special_words as $s) {
$x = str_replace("\n$s\n", "\n\n".strtoupper($s)."\n\n", $x);
}
$x = trim($x);
echo $res.trim_each_line($x)."\n";