Subversion Repositories vgwhois

Rev

Rev 11 | Rev 45 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#!/usr/bin/php
<?php

#
#  VGWhoIs (ViaThinkSoft Global WhoIs, a fork of generic Whois / gwhois)
#  Subprogram: pa TLD whois
#
#  (c) 2011-2019 by Daniel Marschall, ViaThinkSoft <info@daniel-marschall.de>
#
#  License: https://www.gnu.org/licenses/gpl-2.0.html (GPL version 2)
#

require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php';

$domain = isset($argv[1]) ? $argv[1] : '';

$url = "http://nic.pa/es/whois/dominio/$domain";
$res  = "% Parsing via regex from '$url'\n\n";
$cont = file_get_contents($url);

file_put_contents('tmpx', $cont);

if (preg_match('@<h2>Nombre del Dominio:\s*(.+)\s*</h2>(.+)</div>@ismU', $cont, $m)) {
        $cont = "Domain ".$m[1].":\n".$m[2];
}

$x = strip_tags($cont);

// é -> É @ strtoupper()
/*
$locals = array('es_ES@euro', 'es_ES', 'es');
reset($locals);
while (list(, $locale) = each ($locals)) {
        if ( setlocale(LC_CTYPE, $locale) == $locale ) {
                break; // Exit when we were successfull
        }
}
*/

$x = str_replace('&nbsp;', ' ', $x);

$x = html_entity_decode($x);

$x = str_replace("\t", ' ', $x);

$x = preg_replace("| +|", ' ', $x);
$x = preg_replace("|\n *|", "\n", $x);
$x = preg_replace("| *\n|", "\n", $x);
$x = preg_replace("|\n+|", "\n", $x);

$x = str_replace(":\n", ": ", $x);

$x = str_replace("Nombre\n", 'Nombre ', $x);
$x = str_replace("Contacto\n", 'Contacto ', $x);
$x = str_replace("Fecha\n", 'Fecha ', $x);

if (strpos($x, 'Fecha de Creación: 0000-00-00') !== false) {
        echo "Domain '$domain' does not exist!";
        exit(2);
}

$special_words = array(
        "Información del Dominio $domain",
);

foreach ($special_words as $s) {
        $x = str_replace($s, "\n".uc_latin1($s)."\n", $x);
}

$x = str_replace("Datos Obtenidos de nuestra base de datos ...\n$domain\n", "\n>>>>", $x);

# Emulate tabulators.
$cry = explode(">>>>", $x, 2);
$x = make_tabs($cry[0]);

if (isset($cry[1])) $x .= '>>>> '.$cry[1];

$x = trim($x);

echo $res.trim_each_line($x)."\n";