Subversion Repositories vgwhois

Rev

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: pk TLD whois
2 daniel-mar 7
#
5 daniel-mar 8
#  (c) 2012 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
$url = "http://pk5.pknic.net.pk/pk5/lookup.PK";
18
 
19
$res  = "% Parsing via regex from '$url'\n\n";
20
 
21
$x = file_get_contents2($url, 'name='.$domain);
22
 
23
if (strpos($x, '<XPC_RESULT_NOTFOUND/>') !== false) {
24
	define('BEGIN', '<td id="Tmain">');
25
	define('END',   '<XPC_RESULT_NOTFOUND/>');
26
} else {
27
	define('BEGIN', '<p class="pkheading">');
28
	define('END',   '<SPAN class="sideHead">');
29
}
30
 
31
preg_match_all('@'.preg_quote(BEGIN, '@').'(.*)'.preg_quote(END, '@').'@ismU', $x, $m);
32
 
33
if (!isset($m[1][0])) {
34
	echo "Error while parsing the web content. Could not find limitations.\n";
35
	exit(1);
36
}
37
$x = $m[1][0];
38
 
39
$x = strip_tags($x);
40
 
41
// é -> É @ strtoupper()
42
/*
43
$locals = array('es_ES@euro', 'es_ES', 'es');
44
reset($locals);
45
while (list(, $locale) = each ($locals)) {
46
	if ( setlocale(LC_CTYPE, $locale) == $locale ) {                
47
		break; // Exit when we were successfull
48
	}
49
}
50
*/
51
 
52
$x = str_replace('&nbsp;', ' ', $x);
53
 
54
$x = html_entity_decode($x);
55
 
56
$x = preg_replace("| +|", ' ', $x);
57
$x = preg_replace("|\n *|", "\n", $x);
58
$x = preg_replace("| *\n|", "\n", $x);
59
$x = preg_replace("|\n+|", "\n", $x);
60
 
61
$x = str_replace(":\n", ": ", $x);
62
 
63
while (strpos($x, "\t") !== false) $x = str_replace("\t", '', $x);
64
while (strpos($x, '  ') !== false) $x = str_replace('  ', ' ', $x);
65
 
66
# Avoid "Contact person: Address:" if there is no contact person. Add a line break
67
$x = preg_replace('@^([^:\n]+):\s+([^\n:]+):@m', "\\1:\n\\2:", $x);
68
 
69
$x = make_tabs($x);
70
 
71
$x = trim($x);
72
 
73
$x = preg_replace("@\n\s+\n@", "\n\n", $x);
74
 
75
while (strpos($x, "\n\n") !== false) $x = str_replace("\n\n", "\n", $x);
76
 
77
$x = preg_replace('@The Domain record for(.*)\n@', 'The Domain record for\\1'."\n\n", $x);
78
 
79
$special_words = array(
80
	'Technical Contact',
81
	'Billing Contact',
82
	'Nameservers'
83
);
84
 
85
foreach ($special_words as $s) {
86
	$x = str_replace($s, "\n".uc_latin1($s)."\n", $x);
87
}
88
 
89
echo $res.trim_each_line($x)."\n";