Subversion Repositories vgwhois

Rev

Rev 11 | Rev 45 | 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: pa TLD whois
2 daniel-mar 7
#
22 daniel-mar 8
#  (c) 2011-2019 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
 
22 daniel-mar 17
$url = "http://nic.pa/es/whois/dominio/$domain";
2 daniel-mar 18
$res  = "% Parsing via regex from '$url'\n\n";
22 daniel-mar 19
$cont = file_get_contents($url);
2 daniel-mar 20
 
22 daniel-mar 21
file_put_contents('tmpx', $cont);
2 daniel-mar 22
 
22 daniel-mar 23
if (preg_match('@<h2>Nombre del Dominio:\s*(.+)\s*</h2>(.+)</div>@ismU', $cont, $m)) {
24
	$cont = "Domain ".$m[1].":\n".$m[2];
2 daniel-mar 25
}
26
 
22 daniel-mar 27
$x = strip_tags($cont);
2 daniel-mar 28
 
29
// é -> É @ strtoupper()
30
/*
31
$locals = array('es_ES@euro', 'es_ES', 'es');
32
reset($locals);
33
while (list(, $locale) = each ($locals)) {
11 daniel-mar 34
	if ( setlocale(LC_CTYPE, $locale) == $locale ) {
2 daniel-mar 35
		break; // Exit when we were successfull
36
	}
37
}
38
*/
39
 
40
$x = str_replace('&nbsp;', ' ', $x);
41
 
42
$x = html_entity_decode($x);
43
 
44
$x = str_replace("\t", ' ', $x);
45
 
46
$x = preg_replace("| +|", ' ', $x);
47
$x = preg_replace("|\n *|", "\n", $x);
48
$x = preg_replace("| *\n|", "\n", $x);
49
$x = preg_replace("|\n+|", "\n", $x);
50
 
51
$x = str_replace(":\n", ": ", $x);
52
 
53
$x = str_replace("Nombre\n", 'Nombre ', $x);
54
$x = str_replace("Contacto\n", 'Contacto ', $x);
55
$x = str_replace("Fecha\n", 'Fecha ', $x);
56
 
57
if (strpos($x, 'Fecha de Creación: 0000-00-00') !== false) {
58
	echo "Domain '$domain' does not exist!";
59
	exit(2);
60
}
61
 
62
$special_words = array(
63
        "Información del Dominio $domain",
64
);
65
 
66
foreach ($special_words as $s) {
67
        $x = str_replace($s, "\n".uc_latin1($s)."\n", $x);
68
}
69
 
70
$x = str_replace("Datos Obtenidos de nuestra base de datos ...\n$domain\n", "\n>>>>", $x);
71
 
72
# Emulate tabulators.
73
$cry = explode(">>>>", $x, 2);
74
$x = make_tabs($cry[0]);
75
 
76
if (isset($cry[1])) $x .= '>>>> '.$cry[1];
77
 
78
$x = trim($x);
79
 
80
echo $res.trim_each_line($x)."\n";