Rev 2 | Rev 11 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 5 | ||
---|---|---|---|
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 | # generic Whois - Subprogram "cu" |
6 | # Subprogram: cu TLD whois |
6 | # |
7 | # |
7 | # (c) 2011 by Daniel Marschall, ViaThinkSoft <www.viathinksoft.de> |
8 | # (c) 2011-2012 by Daniel Marschall, ViaThinkSoft <info@daniel-marschall.de> |
8 | # |
9 | # |
9 | # Distribution, usage etc. pp. regulated by the current version of GPL. |
10 | # License: https://www.gnu.org/licenses/gpl-2.0.html (GPL version 2) |
10 | # |
- | |
11 | # |
- | |
12 | # |
- | |
13 | # History: |
- | |
14 | # 2011-06-07 mar Initial release |
- | |
15 | # 2012-01-16 mar Fixed uppercase(). Added non-available-detection |
- | |
16 | # |
11 | # |
17 | 12 | ||
18 | require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php'; |
13 | require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php'; |
19 | 14 | ||
20 | $domain = isset($argv[1]) ? $argv[1] : ''; |
15 | $domain = isset($argv[1]) ? $argv[1] : ''; |
21 | 16 | ||
22 | define('BEGIN', '<!-- InstanceBeginEditable name="MainRgn" -->'); |
17 | define('BEGIN', '<!-- InstanceBeginEditable name="MainRgn" -->'); |
23 | define('END', '<!-- InstanceEndEditable -->'); |
18 | define('END', '<!-- InstanceEndEditable -->'); |
24 | 19 | ||
25 | $url = "http://www.nic.cu/dom_det.php?domsrch=$domain"; |
20 | $url = "http://www.nic.cu/dom_det.php?domsrch=$domain"; |
26 | 21 | ||
27 | $res = "% Parsing via regex from '$url'\n\n"; |
22 | $res = "% Parsing via regex from '$url'\n\n"; |
28 | 23 | ||
29 | $x = file_get_contents2($url); |
24 | $x = file_get_contents2($url); |
30 | 25 | ||
31 | 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); |
32 | 27 | ||
33 | if (!isset($m[1][0])) { |
28 | if (!isset($m[1][0])) { |
34 | 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"; |
35 | exit(1); |
30 | exit(1); |
36 | } |
31 | } |
37 | 32 | ||
38 | $x = $m[1][0]; |
33 | $x = $m[1][0]; |
39 | 34 | ||
40 | $x = strip_tags($x); |
35 | $x = strip_tags($x); |
41 | 36 | ||
42 | // é -> É @ strtoupper() |
37 | // é -> É @ strtoupper() |
43 | /* |
38 | /* |
44 | $locals = array('es_ES@euro', 'es_ES', 'es'); |
39 | $locals = array('es_ES@euro', 'es_ES', 'es'); |
45 | reset($locals); |
40 | reset($locals); |
46 | while (list(, $locale) = each ($locals)) { |
41 | while (list(, $locale) = each ($locals)) { |
47 | if ( setlocale(LC_CTYPE, $locale) == $locale ) { |
42 | if ( setlocale(LC_CTYPE, $locale) == $locale ) { |
48 | break; // Exit when we were successfull |
43 | break; // Exit when we were successfull |
49 | } |
44 | } |
50 | } |
45 | } |
51 | */ |
46 | */ |
52 | 47 | ||
53 | $x = str_replace(' ', ' ', $x); |
48 | $x = str_replace(' ', ' ', $x); |
54 | 49 | ||
55 | $x = html_entity_decode($x); |
50 | $x = html_entity_decode($x); |
56 | 51 | ||
57 | $x = preg_replace("| +|", ' ', $x); |
52 | $x = preg_replace("| +|", ' ', $x); |
58 | $x = preg_replace("|\n *|", "\n", $x); |
53 | $x = preg_replace("|\n *|", "\n", $x); |
59 | $x = preg_replace("| *\n|", "\n", $x); |
54 | $x = preg_replace("| *\n|", "\n", $x); |
60 | $x = preg_replace("|\n+|", "\n", $x); |
55 | $x = preg_replace("|\n+|", "\n", $x); |
61 | 56 | ||
62 | $x = str_replace(":\n", ": ", $x); |
57 | $x = str_replace(":\n", ": ", $x); |
63 | 58 | ||
64 | $special_words = array( |
59 | $special_words = array( |
65 | 'Detalles del dominio', |
60 | 'Detalles del dominio', |
66 | 'Información general del dominio', |
61 | 'Información general del dominio', |
67 | 'DNS Primario', |
62 | 'DNS Primario', |
68 | 'Contacto Técnico', |
63 | 'Contacto Técnico', |
69 | 'Contacto Administrativo', |
64 | 'Contacto Administrativo', |
70 | 'Contacto Financiero' |
65 | 'Contacto Financiero' |
71 | ); |
66 | ); |
72 | 67 | ||
73 | foreach ($special_words as $s) { |
68 | foreach ($special_words as $s) { |
74 | $x = str_replace($s, "\n".uc_latin1($s)."\n", $x); |
69 | $x = str_replace($s, "\n".uc_latin1($s)."\n", $x); |
75 | } |
70 | } |
76 | 71 | ||
77 | $x = str_replace('< Regresar a la página anterior', '', $x); |
72 | $x = str_replace('< Regresar a la página anterior', '', $x); |
78 | 73 | ||
79 | $x = make_tabs($x); |
74 | $x = make_tabs($x); |
80 | 75 | ||
81 | $x = trim($x); |
76 | $x = trim($x); |
82 | 77 | ||
83 | if (strpos($x, 'Dominio: Organización: Dirección:') !== false) { |
78 | if (strpos($x, 'Dominio: Organización: Dirección:') !== false) { |
84 | $x = 'Domain does not exist.'; |
79 | $x = 'Domain does not exist.'; |
85 | } |
80 | } |
86 | 81 | ||
87 | #does not work... |
82 | #does not work... |
88 | #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:') { |
89 | if (md5($x) == '82f755ffa4a436159afec22d69be304c') { |
84 | if (md5($x) == '82f755ffa4a436159afec22d69be304c') { |
90 | $x = 'Domain not available.'; |
85 | $x = 'Domain not available.'; |
91 | } |
86 | } |
92 | 87 | ||
93 | echo $res.trim_each_line($x)."\n"; |
88 | echo $res.trim_each_line($x)."\n"; |