Rev 5 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | daniel-mar | 1 | #!/usr/bin/php |
2 | <?php |
||
3 | |||
4 | # |
||
5 | # generic Whois - Subprogram "pa" |
||
6 | # |
||
7 | # (c) 2011 by Daniel Marschall, ViaThinkSoft <www.viathinksoft.de> |
||
8 | # |
||
9 | # Distribution, usage etc. pp. regulated by the current version of GPL. |
||
10 | # |
||
11 | # |
||
12 | # |
||
13 | # History: |
||
14 | # 2011-06-07 mar Initial release |
||
15 | # 2012-01-16 mar Fixed uppercase(). |
||
16 | # |
||
17 | |||
18 | require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php'; |
||
19 | |||
20 | $domain = isset($argv[1]) ? $argv[1] : ''; |
||
21 | |||
22 | $url = "http://www.nic.pa/whois.php?nombre_d=$domain"; |
||
23 | |||
24 | $res = "% Parsing via regex from '$url'\n\n"; |
||
25 | |||
26 | $x = file_get_contents2($url); |
||
27 | |||
28 | $x = preg_replace('|sans-serif">\s*</font>|ismU', 'sans-serif">-</font>', $x); |
||
29 | |||
30 | $x = strip_tags($x); |
||
31 | |||
32 | $ary = explode('Información del Dominio', $x, 2); |
||
33 | |||
34 | if (!isset($ary[1])) { |
||
35 | echo "Domain '$domain' does not exist."; |
||
36 | exit(2); |
||
37 | } |
||
38 | |||
39 | $x = 'Información del Dominio'.$ary[1]; |
||
40 | |||
41 | // é -> É @ strtoupper() |
||
42 | /* |
||
43 | $locals = array('es_ES@euro', 'es_ES', 'es'); |
||
44 | reset($locals); |
||
45 | while (list(, $locale) = each ($locals)) { |
||
46 | if ( setlocale(LC_CTYPE, $locale) == $locale ) { |
||
47 | break; // Exit when we were successfull |
||
48 | } |
||
49 | } |
||
50 | */ |
||
51 | |||
52 | $x = str_replace(' ', ' ', $x); |
||
53 | |||
54 | $x = html_entity_decode($x); |
||
55 | |||
56 | $x = str_replace("\t", ' ', $x); |
||
57 | |||
58 | $x = preg_replace("| +|", ' ', $x); |
||
59 | $x = preg_replace("|\n *|", "\n", $x); |
||
60 | $x = preg_replace("| *\n|", "\n", $x); |
||
61 | $x = preg_replace("|\n+|", "\n", $x); |
||
62 | |||
63 | $x = str_replace(":\n", ": ", $x); |
||
64 | |||
65 | $x = str_replace("Nombre\n", 'Nombre ', $x); |
||
66 | $x = str_replace("Contacto\n", 'Contacto ', $x); |
||
67 | $x = str_replace("Fecha\n", 'Fecha ', $x); |
||
68 | |||
69 | if (strpos($x, 'Fecha de Creación: 0000-00-00') !== false) { |
||
70 | echo "Domain '$domain' does not exist!"; |
||
71 | exit(2); |
||
72 | } |
||
73 | |||
74 | $special_words = array( |
||
75 | "Información del Dominio $domain", |
||
76 | ); |
||
77 | |||
78 | foreach ($special_words as $s) { |
||
79 | $x = str_replace($s, "\n".uc_latin1($s)."\n", $x); |
||
80 | } |
||
81 | |||
82 | $x = str_replace("Datos Obtenidos de nuestra base de datos ...\n$domain\n", "\n>>>>", $x); |
||
83 | |||
84 | # Emulate tabulators. |
||
85 | $cry = explode(">>>>", $x, 2); |
||
86 | $x = make_tabs($cry[0]); |
||
87 | |||
88 | if (isset($cry[1])) $x .= '>>>> '.$cry[1]; |
||
89 | |||
90 | $x = trim($x); |
||
91 | |||
92 | echo $res.trim_each_line($x)."\n"; |