Subversion Repositories vgwhois

Rev

Rev 45 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 45 Rev 149
Line 10... Line 10...
10
#  License: https://www.gnu.org/licenses/gpl-2.0.html (GPL version 2)
10
#  License: https://www.gnu.org/licenses/gpl-2.0.html (GPL version 2)
11
#
11
#
12
 
12
 
13
require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php';
13
require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php';
14
 
14
 
-
 
15
ini_set('default_charset', 'UTF-8');
-
 
16
 
15
$domain = isset($argv[1]) ? $argv[1] : '';
17
$domain = isset($argv[1]) ? $argv[1] : '';
16
 
18
 
17
$url = "http://nic.pa/es/whois/dominio/$domain";
19
$url = "http://nic.pa/es/whois/dominio/$domain";
18
$res  = "% Parsing via regex from '$url'\n\n";
20
$res  = "% Parsing via regex from '$url'\n\n";
19
$cont = file_get_contents($url);
21
$cont = file_get_contents2($url);
20
 
22
 
21
if (preg_match('@<h2>Nombre del Dominio:\s*(.+)\s*</h2>(.+)</div>@ismU', $cont, $m)) {
23
if (preg_match('@<h2>Nombre del Dominio:\s*(.+)\s*</h2>(.+)</div>@ismU', $cont, $m)) {
22
	$cont = "Domain ".$m[1].":\n".$m[2];
24
	$cont = "Domain ".$m[1].":\n".$m[2];
23
}
25
}
24
 
26
 
25
$x = strip_tags($cont);
27
$x = strip_tags($cont);
26
 
28
 
27
// é -> É @ strtoupper()
-
 
28
/*
-
 
29
$locals = array('es_ES@euro', 'es_ES', 'es');
-
 
30
reset($locals);
-
 
31
while (list(, $locale) = each ($locals)) {
-
 
32
	if ( setlocale(LC_CTYPE, $locale) == $locale ) {
-
 
33
		break; // Exit when we were successfull
-
 
34
	}
-
 
35
}
-
 
36
*/
-
 
37
 
-
 
38
$x = str_replace('&nbsp;', ' ', $x);
29
$x = str_replace('&nbsp;', ' ', $x);
39
 
30
 
40
$x = html_entity_decode($x);
31
$x = html_entity_decode($x);
41
 
32
 
42
$x = str_replace("\t", ' ', $x);
33
$x = str_replace("\t", ' ', $x);
Line 50... Line 41...
50
 
41
 
51
$x = str_replace("Nombre\n", 'Nombre ', $x);
42
$x = str_replace("Nombre\n", 'Nombre ', $x);
52
$x = str_replace("Contacto\n", 'Contacto ', $x);
43
$x = str_replace("Contacto\n", 'Contacto ', $x);
53
$x = str_replace("Fecha\n", 'Fecha ', $x);
44
$x = str_replace("Fecha\n", 'Fecha ', $x);
54
 
45
 
55
if (strpos($x, 'Fecha de Creación: 0000-00-00') !== false) {
46
if (strpos($x, 'Fecha de Creación: 0000-00-00') !== false) {
56
	echo "Domain '$domain' does not exist!";
47
	echo "Domain '$domain' does not exist!";
57
	exit(2);
48
	exit(2);
58
}
49
}
59
 
50
 
60
$special_words = array(
51
$special_words = array(
61
        "Información del Dominio $domain",
52
        "Información del Dominio $domain",
62
);
53
);
63
 
54
 
64
foreach ($special_words as $s) {
55
foreach ($special_words as $s) {
65
        $x = str_replace($s, "\n".uc_latin1($s)."\n", $x);
56
        $x = str_replace($s, "\n".mb_strtoupper($s)."\n", $x);
66
}
57
}
67
 
58
 
68
$x = str_replace("Datos Obtenidos de nuestra base de datos ...\n$domain\n", "\n>>>>", $x);
59
$x = str_replace("Datos Obtenidos de nuestra base de datos ...\n$domain\n", "\n>>>>", $x);
69
 
60
 
70
# Emulate tabulators.
61
// Emulate tabulators.
71
$cry = explode(">>>>", $x, 2);
62
$cry = explode(">>>>", $x, 2);
72
$x = make_tabs($cry[0]);
63
$x = make_tabs($cry[0]);
73
 
64
 
74
if (isset($cry[1])) $x .= '>>>> '.$cry[1];
65
if (isset($cry[1])) $x .= '>>>> '.$cry[1];
75
 
66