Subversion Repositories vgwhois

Rev

Rev 45 | 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: pa TLD whois
2 daniel-mar 7
#
22 daniel-mar 8
#  (c) 2011-2019 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
 
22 daniel-mar 19
$url = "http://nic.pa/es/whois/dominio/$domain";
2 daniel-mar 20
$res  = "% Parsing via regex from '$url'\n\n";
149 daniel-mar 21
$cont = file_get_contents2($url);
2 daniel-mar 22
 
22 daniel-mar 23
if (preg_match('@<h2>Nombre del Dominio:\s*(.+)\s*</h2>(.+)</div>@ismU', $cont, $m)) {
24
	$cont = "Domain ".$m[1].":\n".$m[2];
2 daniel-mar 25
}
26
 
22 daniel-mar 27
$x = strip_tags($cont);
2 daniel-mar 28
 
29
$x = str_replace('&nbsp;', ' ', $x);
30
 
31
$x = html_entity_decode($x);
32
 
33
$x = str_replace("\t", ' ', $x);
34
 
35
$x = preg_replace("| +|", ' ', $x);
36
$x = preg_replace("|\n *|", "\n", $x);
37
$x = preg_replace("| *\n|", "\n", $x);
38
$x = preg_replace("|\n+|", "\n", $x);
39
 
40
$x = str_replace(":\n", ": ", $x);
41
 
42
$x = str_replace("Nombre\n", 'Nombre ', $x);
43
$x = str_replace("Contacto\n", 'Contacto ', $x);
44
$x = str_replace("Fecha\n", 'Fecha ', $x);
45
 
149 daniel-mar 46
if (strpos($x, 'Fecha de Creación: 0000-00-00') !== false) {
2 daniel-mar 47
	echo "Domain '$domain' does not exist!";
48
	exit(2);
49
}
50
 
51
$special_words = array(
149 daniel-mar 52
        "Información del Dominio $domain",
2 daniel-mar 53
);
54
 
55
foreach ($special_words as $s) {
149 daniel-mar 56
        $x = str_replace($s, "\n".mb_strtoupper($s)."\n", $x);
2 daniel-mar 57
}
58
 
59
$x = str_replace("Datos Obtenidos de nuestra base de datos ...\n$domain\n", "\n>>>>", $x);
60
 
149 daniel-mar 61
// Emulate tabulators.
2 daniel-mar 62
$cry = explode(">>>>", $x, 2);
63
$x = make_tabs($cry[0]);
64
 
65
if (isset($cry[1])) $x .= '>>>> '.$cry[1];
66
 
67
$x = trim($x);
68
 
69
echo $res.trim_each_line($x)."\n";