Rev 5 | Rev 22 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5 | Rev 11 | ||
---|---|---|---|
1 | #!/usr/bin/php |
1 | #!/usr/bin/php |
2 | <?php |
2 | <?php |
3 | 3 | ||
4 | # |
4 | # |
5 | # VWhois (ViaThinkSoft WHOIS, a fork of generic Whois / gwhois) |
5 | # VGWhoIs (ViaThinkSoft Global WhoIs, a fork of generic Whois / gwhois) |
6 | # Subprogram: pa TLD whois |
6 | # Subprogram: pa TLD whois |
7 | # |
7 | # |
8 | # (c) 2011-2012 by Daniel Marschall, ViaThinkSoft <info@daniel-marschall.de> |
8 | # (c) 2011-2012 by Daniel Marschall, ViaThinkSoft <info@daniel-marschall.de> |
9 | # |
9 | # |
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 | $domain = isset($argv[1]) ? $argv[1] : ''; |
15 | $domain = isset($argv[1]) ? $argv[1] : ''; |
16 | 16 | ||
17 | $url = "http://www.nic.pa/whois.php?nombre_d=$domain"; |
17 | $url = "http://www.nic.pa/whois.php?nombre_d=$domain"; |
18 | 18 | ||
19 | $res = "% Parsing via regex from '$url'\n\n"; |
19 | $res = "% Parsing via regex from '$url'\n\n"; |
20 | 20 | ||
21 | $x = file_get_contents2($url); |
21 | $x = file_get_contents2($url); |
22 | 22 | ||
23 | $x = preg_replace('|sans-serif">\s*</font>|ismU', 'sans-serif">-</font>', $x); |
23 | $x = preg_replace('|sans-serif">\s*</font>|ismU', 'sans-serif">-</font>', $x); |
24 | 24 | ||
25 | $x = strip_tags($x); |
25 | $x = strip_tags($x); |
26 | 26 | ||
27 | $ary = explode('Información del Dominio', $x, 2); |
27 | $ary = explode('Información del Dominio', $x, 2); |
28 | 28 | ||
29 | if (!isset($ary[1])) { |
29 | if (!isset($ary[1])) { |
30 | echo "Domain '$domain' does not exist."; |
30 | echo "Domain '$domain' does not exist."; |
31 | exit(2); |
31 | exit(2); |
32 | } |
32 | } |
33 | 33 | ||
34 | $x = 'Información del Dominio'.$ary[1]; |
34 | $x = 'Información del Dominio'.$ary[1]; |
35 | 35 | ||
36 | // é -> É @ strtoupper() |
36 | // é -> É @ strtoupper() |
37 | /* |
37 | /* |
38 | $locals = array('es_ES@euro', 'es_ES', 'es'); |
38 | $locals = array('es_ES@euro', 'es_ES', 'es'); |
39 | reset($locals); |
39 | reset($locals); |
40 | while (list(, $locale) = each ($locals)) { |
40 | while (list(, $locale) = each ($locals)) { |
41 | if ( setlocale(LC_CTYPE, $locale) == $locale ) { |
41 | if ( setlocale(LC_CTYPE, $locale) == $locale ) { |
42 | break; // Exit when we were successfull |
42 | break; // Exit when we were successfull |
43 | } |
43 | } |
44 | } |
44 | } |
45 | */ |
45 | */ |
46 | 46 | ||
47 | $x = str_replace(' ', ' ', $x); |
47 | $x = str_replace(' ', ' ', $x); |
48 | 48 | ||
49 | $x = html_entity_decode($x); |
49 | $x = html_entity_decode($x); |
50 | 50 | ||
51 | $x = str_replace("\t", ' ', $x); |
51 | $x = str_replace("\t", ' ', $x); |
52 | 52 | ||
53 | $x = preg_replace("| +|", ' ', $x); |
53 | $x = preg_replace("| +|", ' ', $x); |
54 | $x = preg_replace("|\n *|", "\n", $x); |
54 | $x = preg_replace("|\n *|", "\n", $x); |
55 | $x = preg_replace("| *\n|", "\n", $x); |
55 | $x = preg_replace("| *\n|", "\n", $x); |
56 | $x = preg_replace("|\n+|", "\n", $x); |
56 | $x = preg_replace("|\n+|", "\n", $x); |
57 | 57 | ||
58 | $x = str_replace(":\n", ": ", $x); |
58 | $x = str_replace(":\n", ": ", $x); |
59 | 59 | ||
60 | $x = str_replace("Nombre\n", 'Nombre ', $x); |
60 | $x = str_replace("Nombre\n", 'Nombre ', $x); |
61 | $x = str_replace("Contacto\n", 'Contacto ', $x); |
61 | $x = str_replace("Contacto\n", 'Contacto ', $x); |
62 | $x = str_replace("Fecha\n", 'Fecha ', $x); |
62 | $x = str_replace("Fecha\n", 'Fecha ', $x); |
63 | 63 | ||
64 | if (strpos($x, 'Fecha de Creación: 0000-00-00') !== false) { |
64 | if (strpos($x, 'Fecha de Creación: 0000-00-00') !== false) { |
65 | echo "Domain '$domain' does not exist!"; |
65 | echo "Domain '$domain' does not exist!"; |
66 | exit(2); |
66 | exit(2); |
67 | } |
67 | } |
68 | 68 | ||
69 | $special_words = array( |
69 | $special_words = array( |
70 | "Información del Dominio $domain", |
70 | "Información del Dominio $domain", |
71 | ); |
71 | ); |
72 | 72 | ||
73 | foreach ($special_words as $s) { |
73 | foreach ($special_words as $s) { |
74 | $x = str_replace($s, "\n".uc_latin1($s)."\n", $x); |
74 | $x = str_replace($s, "\n".uc_latin1($s)."\n", $x); |
75 | } |
75 | } |
76 | 76 | ||
77 | $x = str_replace("Datos Obtenidos de nuestra base de datos ...\n$domain\n", "\n>>>>", $x); |
77 | $x = str_replace("Datos Obtenidos de nuestra base de datos ...\n$domain\n", "\n>>>>", $x); |
78 | 78 | ||
79 | # Emulate tabulators. |
79 | # Emulate tabulators. |
80 | $cry = explode(">>>>", $x, 2); |
80 | $cry = explode(">>>>", $x, 2); |
81 | $x = make_tabs($cry[0]); |
81 | $x = make_tabs($cry[0]); |
82 | 82 | ||
83 | if (isset($cry[1])) $x .= '>>>> '.$cry[1]; |
83 | if (isset($cry[1])) $x .= '>>>> '.$cry[1]; |
84 | 84 | ||
85 | $x = trim($x); |
85 | $x = trim($x); |
86 | 86 | ||
87 | echo $res.trim_each_line($x)."\n"; |
87 | echo $res.trim_each_line($x)."\n"; |