Subversion Repositories vgwhois

Rev

Rev 5 | Rev 22 | 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-2012 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://www.nic.pa/whois.php?nombre_d=$domain";

$res  = "% Parsing via regex from '$url'\n\n";

$x = file_get_contents2($url);

$x = preg_replace('|sans-serif">\s*</font>|ismU', 'sans-serif">-</font>', $x);

$x = strip_tags($x);

$ary = explode('Información del Dominio', $x, 2);

if (!isset($ary[1])) {
        echo "Domain '$domain' does not exist.";
        exit(2);
}

$x = 'Información del Dominio'.$ary[1];

// é -> É @ 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";