What is the previously written IPwhois class? Php *** Class: IPWhoisVerson1.0 * Info: GetIPsinformationform4whoisserver * Author: PhpUpStudiophpup.com * Date: 12122004 ** classIPWhois {var $ serverwhois.arin.net; var $ target; var $ timeout10; var $
What is the previously written IPwhois class? Php/*** Class: IPWhoisVerson1.0 * Info: GetIP 'sinformationform4whoisserver * Author: PhpUpStudiohttp: // phpup.com * Date: 12/12/2004 **/class IPWhois {var $ server = 'whois .arin.net '; var $ target; var $ timeout = 10; var $
Previously written IPwhois class
/**
*
* Class: IP Whois Verson 1.0
* Info: Get IP's information form 4 whois server
* Author: PhpUp Studio http://phpup.com
* Date: 12/12/2004
*
*/
Class IPWhois
{
Var $ server = 'whois .arin.net ';
Var $ target;
Var $ timeout = 10;
Var $ msg;
Function IPWhois ($ target)
{
$ This-> target = $ target;
}
Function ShowInfo ()
{
If ($ this-> _ CheckIP ($ this-> target ))
{
$ This-> msg = $ this-> _ GetInfo ($ this-> server );
If ($ this-> _ CheckInfo ($ this-> msg ))
{
$ This-> msg = $ this-> _ GetInfo ($ this-> server );
}
}
Else $ this-> msg ='
Please Enter An IP Address
';
Return $ this-> msg;
}
Function _ CheckIP ($ temptarget)
{
If (eregi ("[0-9] {1, 3 }. [0-9] {1, 3 }. [0-9] {1, 3 }. [0-9] {1, 3} ", $ temptarget ))
{
$ F = 1;
$ Detail = explode (".", $ temptarget );
Foreach ($ detail as $ v)
{
If ($ v> 255 | $ v <0)
{
$ F = 0;
Break;
}
}
}
Else $ f = 0;
Return $ f;
}
Function _ GetInfo ($ tempserver)
{
$ This-> msg = '';
If (! $ Sock = fsockopen ($ tempserver, 43, $ num, $ error, $ this-> timeout ))
{
Unset ($ sock );
$ This-> msg = "Timed-out connecting to $ tempserver (port 43 )";
}
Else
{
Fputs ($ sock, "$ this-> target/n ");
$ This-> msg. ="
IP Whois Information". $ This-> target ."
";
$ This-> msg. = "-----------------------------------------------------------------
";
While (! Feof ($ sock ))
$ This-> msg. = fgets ($ sock, 10240 );
$ This-> msg. = "-----------------------------------------------------------------
";
}
Fclose ($ sock );
Return nl2br ($ this-> msg );
}
Function _ CheckInfo ($ tempmsg)
{
If (eregi ("whois.ripe.net", $ tempmsg ))
{
$ This-> server = "whois.ripe.net ";
Return 1;
}
Elseif (eregi ("whois.apnic.net", $ tempmsg ))
{
$ This-> server = "whois.apnic.net ";
Return 1;
}
Elseif (eregi ("whois.lacnic.net", $ tempmsg ))
{
$ This-> server = "whois.lacnic.net ";
Return 1;
}
Else return 0;
}
}
?>
Call
Include './class. php ';
$ Target = isset ($ _ GET ['IP'])? Gethostbyname ($ _ GET ['IP']): 'null ';
If ('null' = $ target | ''= $ target) $ result ='
Please Input An IP Address
';
Else
{
$ Whois = new IPWhois ($ target );
// $ Result = "IP Whois Information
". $ _ POST ['IP']."
";
$ Result = $ whois-> ShowInfo ();
}
Echo $ result;
?>