Subversion Repositories vgwhois

Rev

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