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