Subversion Repositories vgwhois

Rev

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