Zend - The PHP Company




External

Add Code


A whois interface for EVERYTHING.  

Type: class
Added by: jcostom
Entered: 03/03/2000
Last modified: 08/12/1999
Rating: ***** (22 votes)
Views: 19010
It's a real pain to remember which whois server to use for which kinds of queries. The geektools.com whois proxy takes care of all that for you, interfacing with the correct whois server for your query. This version avoids all of the assorted nastiness that comes along with executing programs on your server using user input, as it directly connects to the geektools whois proxy.

The geektools.com guys have done a considerable amount of work on the proxy, which is available from their site. ISPs who plan on using this code are encouraged to run their own local copy of the geektools proxy, and save the load on whois.geektools.com.

Want to see it in action?



<?
/*

Copyright (c) 2000, Jason Costomiris
All rights reserved.

Don't be scared, it's just a BSD-ish license.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright notice,
   this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
   must display the following acknowledgement:
   This product includes software developed by Jason Costomiris.
4. The name of the author may not be used to endorse or promote products
   derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/
    
Class whois {
        function 
lookup($lookup){
            
$whois "whois.geektools.com";
            
$fp fsockopen($whois43, &$errno, &$errstr30);
            if (!
$fp){
                
printf("Error: %s (%s)"$errstr$errno);
                
$data 0;
            } else {
                
$lookup .= "n";
                
fputs($fp$lookup);
                
// 16k of whois data should be way more
                // than enough
                
$data fread$fp16384 );
                
fclose($fp);
            }
            return 
$data;
        }
    }
?>


Usage Example


<? require("whoisclass.php"); ?>
<form method="POST" action="<? echo $PHP_SELF?>">
<input type="text" name="lookup">
<input type="submit" value="lookup">
</form>
<?
    
if($REQUEST_METHOD == "POST"){
        
$whois = new whois;
        
$data $whois->lookup($lookup);
        
printf("<pre>n%sn</pre>n"$data);
    }
?>


Rate This Script





Search



This Category All Categories