Rev 5 | 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: cu TLD whois |
6 | # Subprogram: cu 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 | define('BEGIN', '<!-- InstanceBeginEditable name="MainRgn" -->'); |
17 | define('BEGIN', '<!-- InstanceBeginEditable name="MainRgn" -->'); |
18 | define('END', '<!-- InstanceEndEditable -->'); |
18 | define('END', '<!-- InstanceEndEditable -->'); |
19 | 19 | ||
20 | $url = "http://www.nic.cu/dom_det.php?domsrch=$domain"; |
20 | $url = "http://www.nic.cu/dom_det.php?domsrch=$domain"; |
21 | 21 | ||
22 | $res = "% Parsing via regex from '$url'\n\n"; |
22 | $res = "% Parsing via regex from '$url'\n\n"; |
23 | 23 | ||
24 | $x = file_get_contents2($url); |
24 | $x = file_get_contents2($url); |
25 | 25 | ||
26 | preg_match_all('@'.preg_quote(BEGIN, '@').'(.*)'.preg_quote(END, '@').'@ismU', $x, $m); |
26 | preg_match_all('@'.preg_quote(BEGIN, '@').'(.*)'.preg_quote(END, '@').'@ismU', $x, $m); |
27 | 27 | ||
28 | if (!isset($m[1][0])) { |
28 | if (!isset($m[1][0])) { |
29 | echo "Error while parsing the web content. Could not find limitations.\n"; |
29 | echo "Error while parsing the web content. Could not find limitations.\n"; |
30 | exit(1); |
30 | exit(1); |
31 | } |
31 | } |
32 | 32 | ||
33 | $x = $m[1][0]; |
33 | $x = $m[1][0]; |
34 | 34 | ||
35 | $x = strip_tags($x); |
35 | $x = strip_tags($x); |
36 | 36 | ||
37 | // é -> É @ strtoupper() |
37 | // é -> É @ strtoupper() |
38 | /* |
38 | /* |
39 | $locals = array('es_ES@euro', 'es_ES', 'es'); |
39 | $locals = array('es_ES@euro', 'es_ES', 'es'); |
40 | reset($locals); |
40 | reset($locals); |
41 | while (list(, $locale) = each ($locals)) { |
41 | while (list(, $locale) = each ($locals)) { |
42 | if ( setlocale(LC_CTYPE, $locale) == $locale ) { |
42 | if ( setlocale(LC_CTYPE, $locale) == $locale ) { |
43 | break; // Exit when we were successfull |
43 | break; // Exit when we were successfull |
44 | } |
44 | } |
45 | } |
45 | } |
46 | */ |
46 | */ |
47 | 47 | ||
48 | $x = str_replace(' ', ' ', $x); |
48 | $x = str_replace(' ', ' ', $x); |
49 | 49 | ||
50 | $x = html_entity_decode($x); |
50 | $x = html_entity_decode($x); |
51 | 51 | ||
52 | $x = preg_replace("| +|", ' ', $x); |
52 | $x = preg_replace("| +|", ' ', $x); |
53 | $x = preg_replace("|\n *|", "\n", $x); |
53 | $x = preg_replace("|\n *|", "\n", $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 | 56 | ||
57 | $x = str_replace(":\n", ": ", $x); |
57 | $x = str_replace(":\n", ": ", $x); |
58 | 58 | ||
59 | $special_words = array( |
59 | $special_words = array( |
60 | 'Detalles del dominio', |
60 | 'Detalles del dominio', |
61 | 'Información general del dominio', |
61 | 'Información general del dominio', |
62 | 'DNS Primario', |
62 | 'DNS Primario', |
63 | 'Contacto Técnico', |
63 | 'Contacto Técnico', |
64 | 'Contacto Administrativo', |
64 | 'Contacto Administrativo', |
65 | 'Contacto Financiero' |
65 | 'Contacto Financiero' |
66 | ); |
66 | ); |
67 | 67 | ||
68 | foreach ($special_words as $s) { |
68 | foreach ($special_words as $s) { |
69 | $x = str_replace($s, "\n".uc_latin1($s)."\n", $x); |
69 | $x = str_replace($s, "\n".uc_latin1($s)."\n", $x); |
70 | } |
70 | } |
71 | 71 | ||
72 | $x = str_replace('< Regresar a la página anterior', '', $x); |
72 | $x = str_replace('< Regresar a la página anterior', '', $x); |
73 | 73 | ||
74 | $x = make_tabs($x); |
74 | $x = make_tabs($x); |
75 | 75 | ||
76 | $x = trim($x); |
76 | $x = trim($x); |
77 | 77 | ||
78 | if (strpos($x, 'Dominio: Organización: Dirección:') !== false) { |
78 | if (strpos($x, 'Dominio: Organización: Dirección:') !== false) { |
79 | $x = 'Domain does not exist.'; |
79 | $x = 'Domain does not exist.'; |
80 | } |
80 | } |
81 | 81 | ||
82 | #does not work... |
82 | #does not work... |
83 | #if ($x == 'DETALLES DEL DOMINIO\n\nINFORMACIÓN GENERAL DEL DOMINIO\n\nDominio: Organización: Dirección:\n\nDNS\nNombre: Dirección IP:\nContacto\nNombre: Organización: Dirección: Teléfono: Fax:') { |
83 | #if ($x == 'DETALLES DEL DOMINIO\n\nINFORMACIÓN GENERAL DEL DOMINIO\n\nDominio: Organización: Dirección:\n\nDNS\nNombre: Dirección IP:\nContacto\nNombre: Organización: Dirección: Teléfono: Fax:') { |
84 | if (md5($x) == '82f755ffa4a436159afec22d69be304c') { |
84 | if (md5($x) == '82f755ffa4a436159afec22d69be304c') { |
85 | $x = 'Domain not available.'; |
85 | $x = 'Domain not available.'; |
86 | } |
86 | } |
87 | 87 | ||
88 | echo $res.trim_each_line($x)."\n"; |
88 | echo $res.trim_each_line($x)."\n"; |