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: pk TLD whois
#
# (c) 2012 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 = "http://pk5.pknic.net.pk/pk5/lookup.PK";
$res = "% Parsing via regex from '$url'\n\n";
$x = file_get_contents2($url, 'name='.$domain);
if (strpos($x, '<XPC_RESULT_NOTFOUND/>') !== false) {
define('BEGIN', '<td id="Tmain">');
define('END', '<XPC_RESULT_NOTFOUND/>');
} else {
define('BEGIN', '<p class="pkheading">');
define('END', '<SPAN class="sideHead">');
}
preg_match_all('@'.preg_quote(BEGIN, '@').'(.*)'.preg_quote(END, '@').'@ismU', $x, $m);
if (!isset($m[1][0])) {
echo "Error while parsing the web content. Could not find limitations.\n";
exit(1);
}
$x = $m[1][0];
$x = strip_tags($x);
// é -> É @ strtoupper()
/*
$locals = array('es_ES@euro', 'es_ES', 'es');
reset($locals);
while (list(, $locale) = each ($locals)) {
if ( setlocale(LC_CTYPE, $locale) == $locale ) {
break; // Exit when we were successfull
}
}
*/
$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);
$x = preg_replace("|\n+|", "\n", $x);
$x = str_replace(":\n", ": ", $x);
while (strpos($x, "\t") !== false) $x = str_replace("\t", '', $x);
while (strpos($x, ' ') !== false) $x = str_replace(' ', ' ', $x);
# Avoid "Contact person: Address:" if there is no contact person. Add a line break
$x = preg_replace('@^([^:\n]+):\s+([^\n:]+):@m', "\\1:\n\\2:", $x);
$x = make_tabs($x);
$x = trim($x);
$x = preg_replace("@\n\s+\n@", "\n\n", $x);
while (strpos($x, "\n\n") !== false) $x = str_replace("\n\n", "\n", $x);
$x = preg_replace('@The Domain record for(.*)\n@', 'The Domain record for\\1'."\n\n", $x);
$special_words = array(
'Technical Contact',
'Billing Contact',
'Nameservers'
);
foreach ($special_words as $s) {
$x = str_replace($s, "\n".uc_latin1($s)."\n", $x);
}
echo $res.trim_each_line($x)."\n";