Rev 11 | 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: cu TLD whois |
2 | daniel-mar | 7 | # |
149 | daniel-mar | 8 | # (c) 2011-2024 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 | |||
149 | daniel-mar | 15 | ini_set('default_charset', 'UTF-8'); |
16 | |||
2 | daniel-mar | 17 | $domain = isset($argv[1]) ? $argv[1] : ''; |
18 | |||
19 | define('BEGIN', '<!-- InstanceBeginEditable name="MainRgn" -->'); |
||
20 | define('END', '<!-- InstanceEndEditable -->'); |
||
21 | |||
149 | daniel-mar | 22 | $url = "https://www.nic.cu/dom_det.php?domsrch=$domain"; |
2 | daniel-mar | 23 | |
24 | $res = "% Parsing via regex from '$url'\n\n"; |
||
25 | |||
26 | $x = file_get_contents2($url); |
||
27 | |||
28 | preg_match_all('@'.preg_quote(BEGIN, '@').'(.*)'.preg_quote(END, '@').'@ismU', $x, $m); |
||
29 | |||
30 | if (!isset($m[1][0])) { |
||
149 | daniel-mar | 31 | echo "Error while parsing the web content (RegEx failed).\n"; |
2 | daniel-mar | 32 | exit(1); |
33 | } |
||
34 | |||
35 | $x = $m[1][0]; |
||
36 | |||
37 | $x = strip_tags($x); |
||
38 | |||
39 | $x = str_replace(' ', ' ', $x); |
||
40 | |||
41 | $x = html_entity_decode($x); |
||
42 | |||
43 | $x = preg_replace("| +|", ' ', $x); |
||
44 | $x = preg_replace("|\n *|", "\n", $x); |
||
45 | $x = preg_replace("| *\n|", "\n", $x); |
||
46 | $x = preg_replace("|\n+|", "\n", $x); |
||
47 | |||
48 | $x = str_replace(":\n", ": ", $x); |
||
49 | |||
50 | $special_words = array( |
||
51 | 'Detalles del dominio', |
||
149 | daniel-mar | 52 | 'Información general del dominio', |
2 | daniel-mar | 53 | 'DNS Primario', |
149 | daniel-mar | 54 | 'Contacto Técnico', |
2 | daniel-mar | 55 | 'Contacto Administrativo', |
56 | 'Contacto Financiero' |
||
57 | ); |
||
58 | |||
59 | foreach ($special_words as $s) { |
||
149 | daniel-mar | 60 | $x = str_replace($s, "\n".mb_strtoupper($s)."\n", $x); |
2 | daniel-mar | 61 | } |
62 | |||
149 | daniel-mar | 63 | $x = str_replace('< Regresar a la página anterior', '', $x); |
2 | daniel-mar | 64 | |
65 | $x = make_tabs($x); |
||
66 | |||
67 | $x = trim($x); |
||
68 | |||
149 | daniel-mar | 69 | if (preg_match('@Dominio: *Organización: *Dirección:@', $x)) { |
2 | daniel-mar | 70 | $x = 'Domain does not exist.'; |
71 | } |
||
72 | |||
73 | echo $res.trim_each_line($x)."\n"; |