Subversion Repositories vgwhois

Compare Revisions

No changes between revisions

Regard whitespace Rev 1 → Rev 2

/trunk/main/subprograms/mq_gf_gp
0,0 → 1,91
#!/usr/bin/php
<?php
 
#
# generic Whois - Subprogram "mq_gf_gp"
#
# (c) 2012 by Daniel Marschall, ViaThinkSoft <www.viathinksoft.de>
#
# Distribution, usage etc. pp. regulated by the current version of GPL.
#
#
#
# History:
# 2012-11-19 mar Initial release
#
 
# TODO: for many domains, the format is completely different! do we have a good enough parser?
 
require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php';
 
$domain = isset($argv[1]) ? $argv[1] : '';
 
$url = "https://www.dom-enic.com/whois.html";
 
$res = "% Parsing via regex from '$url'\n\n";
 
// Split up "naked" domain name and TLD
if (!preg_match('@^(.*)(\.(mq|gf|gp))$@', $domain, $m)) {
echo "Error: Can only handle .mq, .gf and .gp TLDs.\n";
exit(1);
}
$domain = $m[1];
$ext = $m[2];
 
$x = file_get_contents2($url, 'domain='.urlencode($domain).'&' .
'extension='.urlencode($ext).'&' .
'Submit=Soumettre');
 
if (strpos($x, /* $domain. */ ' est disponible.') !== false) {
define('BEGIN', '<div align="center" class="texte1"><p>');
define('END', '</p></div>');
} else {
// For some domains it is <p> and not <h1>
$x = str_replace('<p class="titre1">WHOIS result</p>', '<h1 class="titre1">WHOIS result</h1>', $x);
define('BEGIN', '<h1 class="titre1">WHOIS result</h1>');
// define('END', '</div>');
// In comparison to </div>, this includes the disclaimer at the bottom:
define('END', '</td>');
}
 
preg_match_all('@'.preg_quote(BEGIN, '@').'(.*)'.preg_quote(END, '@').'@ismU', $x, $m);
 
if (!isset($m[1][0])) {
echo "Error while parsing the web content. Could not find limitations.\n";
exit(1);
}
$x = $m[1][0];
 
$x = preg_replace('@<br />(?!\n)@', "\n", $x);
$x = strip_tags($x);
 
$x = html_entity_decode($x);
 
// é -> É @ 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 = preg_replace("@\n\s+\n@", "\n\n", $x);
while (strpos($x, "\n\n\n") !== false) $x = str_replace("\n\n\n", "\n\n", $x);
 
$special_words = array(
'Registrant:',
'Administrative Contact:',
'Technical Contact:',
'Billing Contact:'
);
 
foreach ($special_words as $s) {
$x = str_replace($s, "\n".uc_latin1($s)."\n", $x);
}
 
$x = trim($x);
 
echo $res.trim_each_line($x)."\n";
Property changes:
Added: svn:executable
+*
\ No newline at end of property