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 "gt" |
||
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(). Spaces between NSs. |
||
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.gt/cgi-bin/whois.cgi?domain=$domain"; |
||
23 | |||
24 | $res = "% Parsing via regex from '$url'\n\n"; |
||
25 | |||
26 | $x = file_get_contents2($url); |
||
27 | $x = strip_tags($x); |
||
28 | |||
29 | # $x = preg_replace('|:\s*([^\s])|ismU', ': $1', $x); |
||
30 | $x = preg_replace('|^\s*([^\s])|ismU', '$1', $x); |
||
31 | |||
32 | // é -> É @ strtoupper() |
||
33 | /* |
||
34 | $locals = array('es_ES@euro', 'es_ES', 'es'); |
||
35 | reset($locals); |
||
36 | while (list(, $locale) = each ($locals)) { |
||
37 | if ( setlocale(LC_CTYPE, $locale) == $locale ) { |
||
38 | break; // Exit when we were successfull |
||
39 | } |
||
40 | } |
||
41 | */ |
||
42 | |||
43 | $x = html_entity_decode($x); |
||
44 | |||
45 | $special_words = array( |
||
46 | 'Información del Dominio'."\n".$domain, |
||
47 | 'Contactos Administrativos', |
||
48 | 'Contactos Técnicos', |
||
49 | 'Servidores', |
||
50 | 'Fecha de Expiración (dd/mm/aaaa)' |
||
51 | ); |
||
52 | |||
53 | foreach ($special_words as $s) { |
||
54 | $x = str_replace($s, "\n".uc_latin1($s)."\n", $x); |
||
55 | } |
||
56 | |||
57 | $x = str_replace('Inicio', '', $x); // Back to mainpage |
||
58 | |||
59 | $x = str_replace('Primario', "Primario\n\n", $x); |
||
60 | $x = str_replace('Secundario', "Secundario\n\n", $x); |
||
61 | |||
62 | $x = trim($x); |
||
63 | |||
64 | echo $res.trim_each_line($x)."\n"; |