2005-08-29 11:07:12 +00:00
|
|
|
<?php
|
2005-07-27 09:57:53 +00:00
|
|
|
/*
|
|
|
|
Whois.php PHP classes to conduct whois queries
|
2005-07-16 15:32:07 +00:00
|
|
|
|
2005-07-27 09:57:53 +00:00
|
|
|
Copyright (C)1999,2005 easyDNS Technologies Inc. & Mark Jeftovic
|
|
|
|
|
|
|
|
Maintained by David Saez (david@ols.es)
|
|
|
|
|
|
|
|
For the most recent version of this package visit:
|
|
|
|
|
2005-08-31 15:26:22 +00:00
|
|
|
http://www.phpwhois.org
|
2005-07-27 09:57:53 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
2005-08-26 06:46:49 +00:00
|
|
|
*/
|
2005-08-29 11:07:12 +00:00
|
|
|
|
2006-04-30 15:06:10 +00:00
|
|
|
$out = implode("\n", file('example.html'));
|
|
|
|
|
|
|
|
$out = str_replace('{self}', $_SERVER['PHP_SELF'], $out);
|
|
|
|
|
|
|
|
$resout = extract_block($out, 'results');
|
|
|
|
|
|
|
|
if (isSet($_GET['query']))
|
2005-08-29 11:07:12 +00:00
|
|
|
{
|
2005-08-29 11:43:56 +00:00
|
|
|
$query = $_GET['query'];
|
|
|
|
|
2006-03-19 08:24:18 +00:00
|
|
|
if (!empty($_GET['output']))
|
|
|
|
$output = $_GET['output'];
|
|
|
|
else
|
|
|
|
$output = '';
|
|
|
|
|
2005-08-29 11:07:12 +00:00
|
|
|
include_once('whois.main.php');
|
2005-08-29 11:43:56 +00:00
|
|
|
include_once('whois.utils.php');
|
2005-08-29 11:07:12 +00:00
|
|
|
|
|
|
|
$whois = new Whois();
|
2006-01-20 11:42:02 +00:00
|
|
|
|
2006-04-30 15:06:10 +00:00
|
|
|
// Set to true if you want to allow proxy requests
|
2006-05-13 18:56:36 +00:00
|
|
|
$allowproxy = false;
|
2006-04-30 15:06:10 +00:00
|
|
|
|
2006-03-19 08:43:31 +00:00
|
|
|
// uncomment the following line to get faster but less acurate results
|
|
|
|
// $whois->deep_whois = false;
|
|
|
|
|
|
|
|
// To use special whois servers (see README)
|
2006-03-19 08:24:18 +00:00
|
|
|
//$whois->UseServer('uk','whois.nic.uk:1043?{hname} {ip} {query}');
|
|
|
|
//$whois->UseServer('au','whois-check.ausregistry.net.au');
|
2006-01-20 11:42:02 +00:00
|
|
|
|
2006-03-29 16:56:21 +00:00
|
|
|
// uncomment the following line to add support for non ICANN tld's
|
|
|
|
// $whois->non_icann = true;
|
|
|
|
|
2005-08-29 11:07:12 +00:00
|
|
|
$result = $whois->Lookup($query);
|
2006-04-30 15:06:10 +00:00
|
|
|
|
|
|
|
$resout = str_replace('{query}', $query, $resout);
|
|
|
|
|
2005-08-29 11:43:56 +00:00
|
|
|
switch ($output)
|
|
|
|
{
|
|
|
|
case 'object':
|
2005-09-05 15:24:03 +00:00
|
|
|
if ($whois->Query['status'] < 0)
|
|
|
|
{
|
2006-04-30 15:06:10 +00:00
|
|
|
$winfo = implode($whois->Query['errstr'],"\n<br></br>");
|
2005-09-05 15:24:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$utils = new utils;
|
2006-04-30 15:06:10 +00:00
|
|
|
$winfo = $utils->showObject($result);
|
2005-09-05 15:24:03 +00:00
|
|
|
}
|
2005-08-29 11:43:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'nice':
|
2006-04-30 15:06:10 +00:00
|
|
|
if (!empty($result['rawdata']))
|
|
|
|
{
|
2005-08-29 11:43:56 +00:00
|
|
|
$utils = new utils;
|
2006-04-30 15:06:10 +00:00
|
|
|
$winfo = $utils->showHTML($result);
|
2005-08-29 11:43:56 +00:00
|
|
|
}
|
2006-04-30 15:06:10 +00:00
|
|
|
else
|
|
|
|
{
|
2007-03-28 08:13:56 +00:00
|
|
|
if (isset($whois->Query['errstr']))
|
|
|
|
$winfo = implode($whois->Query['errstr'],"\n<br></br>");
|
|
|
|
else
|
|
|
|
$winfo = 'Unexpected error';
|
2005-08-29 11:43:56 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-04-30 15:06:10 +00:00
|
|
|
|
|
|
|
case 'proxy':
|
|
|
|
if ($allowproxy)
|
|
|
|
exit(serialize($result));
|
|
|
|
|
2005-08-29 11:43:56 +00:00
|
|
|
default:
|
2006-04-30 15:06:10 +00:00
|
|
|
if(!empty($result['rawdata']))
|
|
|
|
{
|
|
|
|
$winfo .= '<pre>'.implode($result['rawdata'],"\n").'</pre>';
|
2005-08-29 11:43:56 +00:00
|
|
|
}
|
2006-04-30 15:06:10 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$winfo = implode($whois->Query['errstr'],"\n<br></br>");
|
2005-08-29 11:43:56 +00:00
|
|
|
}
|
2006-05-13 18:56:36 +00:00
|
|
|
}
|
2006-04-30 15:06:10 +00:00
|
|
|
|
|
|
|
$resout = str_replace('{result}', $winfo, $resout);
|
2006-05-13 18:56:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
$resout = '';
|
|
|
|
|
2006-04-30 15:06:10 +00:00
|
|
|
echo str_replace('{results}', $resout, $out);
|
2005-08-29 11:07:12 +00:00
|
|
|
|
2006-04-30 15:06:10 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
function extract_block (&$plantilla,$mark,$retmark='')
|
|
|
|
{
|
|
|
|
$start = strpos($plantilla,'<!--'.$mark.'-->');
|
|
|
|
$final = strpos($plantilla,'<!--/'.$mark.'-->');
|
|
|
|
|
|
|
|
if ($start === false || $final === false) return;
|
|
|
|
|
|
|
|
$ini = $start+7+strlen($mark);
|
|
|
|
|
|
|
|
$ret=substr($plantilla,$ini,$final-$ini);
|
|
|
|
|
|
|
|
$final+=8+strlen($mark);
|
|
|
|
|
|
|
|
if ($retmark===false)
|
|
|
|
$plantilla=substr($plantilla,0,$start).substr($plantilla,$final);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ($retmark=='') $retmark=$mark;
|
|
|
|
$plantilla=substr($plantilla,0,$start).'{'.$retmark.'}'.substr($plantilla,$final);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $ret;
|
|
|
|
}
|
|
|
|
?>
|