Web Hosting Talk







View Full Version : Free Whois Script Code is inside


Ferman
10-07-2005, 12:36 PM
Free Whois Script Code is inside


$whois = array (
".com" => array ("type" => "Commercial", "server" => "whois.internic.net"),
".net" => array ("type" => "Network", "server" => "whois.internic.net"),
".org" => array ("type" => "Organisation", "server" => "whois.internic.net"),
".edu" => array ("type" => "Education", "server" => "whois.internic.net"),
".gov" => array ("type" => "Government", "server" => "whois.nic.gov"),
".biz" => array ("type" => "Business", "server" => "whois.pacificroot.com"),
".name" => array ("type" => "Name", "server" => "whois.nic.name"),
".info" => array ("type" => "Information", "server" => "whois.afilias.info"),
".au" => array ("type" => "Australia", "server" => "whois.ausregistry.net"),
".ca" => array ("type" => "Canada", "server" => "whois.cira.ca"),
".de" => array ("type" => "Germany", "server" => "whois.denic.de"),
".dk" => array ("type" => "Denmark", "server" => "whois.dk-hostmaster.dk"),
".fr" => array ("type" => "France", "server" => "whois.nic.fr"),
".ru" => array ("type" => "Russia", "server" => "whois.ripn.net"),
".uk" => array ("type" => "United Kingdom", "server" => "whois.nic.uk"),
".us" => array ("type" => "United States", "server" => "whois.us"),
);

echo "<HTML>\n";
echo "<HEAD>\n";
echo " <TITLE>Whois</TITLE>\n";
echo "</HEAD>\n\n";
echo "<BODY>\n";
echo ' <FORM METHOD="POST" ACTION="', "{$PHP_SELF}", '">', "\n";
echo ' Domain: <INPUT TYPE="text" NAME="domain" VALUE="', "{$domain}", '" SIZE="30">&nbsp;', "\n";
echo ' <INPUT TYPE="submit" VALUE="Lookup">', "\n";
echo ' </FORM>';

if (!empty ($domain))
{
echo '<BR>', "\n", '<HR NOSHADE>', "\n";

$tld = explode (".", $domain);
$tld = "." . $tld[count($tld)-1];
if (!array_key_exists ($tld, $whois))
{
die ("This script currently does not support the {$tld} TLD.");
}

ob_start();
system ("whois -h {$whois[$tld]["server"]} {$domain}");
$whoisdata = ob_get_contents();
ob_end_clean();
$whoisdata_txt = "<textarea cols=\"150\" rows=\"15\" readonly style=\"font:11px tahoma;\">$whoisdata</textarea>";
print_r (eregi_replace ("\n", "\n", $whoisdata_txt));
}

echo ' </BODY>', "\n", '</HTML>', "\n";

Bashar
10-07-2005, 12:56 PM
doesn't work for me though bashar.com/whois.php

hanz
10-07-2005, 12:58 PM
Doesn't work for me :( , it seems like my host has disabled system()
But thanks anyway! :D

Ferman
10-07-2005, 01:49 PM
it works

did you put php tags to beginning and end

<?php
$whois = array (
".com" => array ("type" => "Commercial", "server" => "whois.internic.net"),
".net" => array ("type" => "Network", "server" => "whois.internic.net"),
".org" => array ("type" => "Organisation", "server" => "whois.internic.net"),
".edu" => array ("type" => "Education", "server" => "whois.internic.net"),
".gov" => array ("type" => "Government", "server" => "whois.nic.gov"),
".biz" => array ("type" => "Business", "server" => "whois.pacificroot.com"),
".name" => array ("type" => "Name", "server" => "whois.nic.name"),
".info" => array ("type" => "Information", "server" => "whois.afilias.info"),
".au" => array ("type" => "Australia", "server" => "whois.ausregistry.net"),
".ca" => array ("type" => "Canada", "server" => "whois.cira.ca"),
".de" => array ("type" => "Germany", "server" => "whois.denic.de"),
".dk" => array ("type" => "Denmark", "server" => "whois.dk-hostmaster.dk"),
".fr" => array ("type" => "France", "server" => "whois.nic.fr"),
".ru" => array ("type" => "Russia", "server" => "whois.ripn.net"),
".uk" => array ("type" => "United Kingdom", "server" => "whois.nic.uk"),
".us" => array ("type" => "United States", "server" => "whois.us"),
);

echo "<HTML>\n";
echo "<HEAD>\n";
echo " <TITLE>Whois</TITLE>\n";
echo "</HEAD>\n\n";
echo "<BODY>\n";
echo ' <FORM METHOD="POST" ACTION="', "{$PHP_SELF}", '">', "\n";
echo ' Domain: <INPUT TYPE="text" NAME="domain" VALUE="', "{$domain}", '" SIZE="30">&nbsp;', "\n";
echo ' <INPUT TYPE="submit" VALUE="Lookup">', "\n";
echo ' </FORM>';

if (!empty ($domain))
{
echo '<BR>', "\n", '<HR NOSHADE>', "\n";

$tld = explode (".", $domain);
$tld = "." . $tld[count($tld)-1];
if (!array_key_exists ($tld, $whois))
{
die ("This script currently does not support the {$tld} TLD.");
}

ob_start();
system ("whois -h {$whois[$tld]["server"]} {$domain}");
$whoisdata = ob_get_contents();
ob_end_clean();
$whoisdata_txt = "<textarea cols=\"150\" rows=\"15\" readonly style=\"font:11px tahoma;\">$whoisdata</textarea>";
print_r (eregi_replace ("\n", "\n", $whoisdata_txt));
}

echo ' </BODY>', "\n", '</HTML>', "\n";
?>

Bashar
10-07-2005, 02:12 PM
Ferman come on :P i added php tags ofcourse

as u notice it show everything but doesn't show the output
does it need write permission to the dir its running from?

or maybe as hanz said system() is disabled on most hosts thats why it doesnt work.

Dan L
10-07-2005, 02:26 PM
If you have SAFE_MODE on in PHP, it disallows system/exec/et cetera.

That's probably what's wrong.

Ferman
10-07-2005, 03:06 PM
Originally posted by Bashar
Ferman come on :P i added php tags ofcourse

as u notice it show everything but doesn't show the output
does it need write permission to the dir its running from?

or maybe as hanz said system() is disabled on most hosts thats why it doesnt work.

ferman.net/whois.php
works fine for me

tried it in many ways
if you search domains with "www" it does not show the output
if you do not put <?php and ?> it does not show the output

Dan L
10-07-2005, 03:14 PM
$domain = ereg_replace('www.','',$domain);

That'll remove the www. automatically :)

Bashar
10-07-2005, 03:34 PM
bashar.com/whois.txt is the source, have a look

plus i dont run safe_mode phpsuexec all the way :)