Free WHOIS script in ASP/PHP needed

Discussion in 'PHP' started by mwasiqansari, Jan 23, 2008.

  1. #1
    Hi

    I'm looking for a free WHOIS script in ASP/PHP for my website. I want something like they have at http://whois.net/

    I need it so that I can just have the form on a page of my site and it calls a results page just like their site does.

    I have looked around but many of them are crap.
     
    mwasiqansari, Jan 23, 2008 IP
  2. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
  3. mwasiqansari

    mwasiqansari Banned

    Messages:
    174
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I want an easy to use script, this script is not working well.
     
    mwasiqansari, Jan 24, 2008 IP
  4. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #4
    I wrote one from scratch for .com and .net.
    ***This is not an eyecandy script, use it as a template and create your own theme and style sheet on it.***
    
    <form method='post'>
    	Domain: <input type='text' name='domain'><input type='submit'>
    </form>
    <?php
    /** Pre Processing **/
    if (empty($_POST)) exit;
    list($domain, $ext) = explode(".", $_POST['domain']);
    
    /** Output **/
    echo whois($domain, $ext);
    
    /** Function **/
    function whois($domain, $ext){
    	$url = $domain.".".$ext;
    	
    	switch ($ext) {
    	case "com":
    		$whois = "whois.verisign-grs.com";
    	break;
    	case "net":
    		$whois = "whois.verisign-grs.com";
    	break;
    	}
    
    	$url = trim($url);
    	$f = fsockopen($whois, 43, $errno, $errstr, 30);
    	fputs($f, "$url\r\n");
    	$data = "";
    	while (!feof($f)) {
    		$data .= fread($f, 128);
    	}
    	fclose($f);
    	$url = strtoupper($url);
    	return (strpos($data, "No match for \"{$url}\"") ? "This domain is available for registration" : $data);
    }
    ?>
    
    PHP:
     
    Kaizoku, Jan 24, 2008 IP
  5. mwasiqansari

    mwasiqansari Banned

    Messages:
    174
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks Kaizoku!

    But it does not shows full information as in whois.net
     
    mwasiqansari, Jan 24, 2008 IP
  6. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #6
    If you want the extra info like alexa rank and all that, it's not too hard to do.
     
    Kaizoku, Jan 24, 2008 IP
  7. tamen

    tamen Peon

    Messages:
    182
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Here is a small script I've build to get the year a domain was registered:

    
    	function getRegisteredYear($domain)
    	{
    		if (strpos($domain, '.biz')) {
    			$cmd = 'whois '.$domain.' | grep -i \'Registration Date\' | head -n1 | egrep -o \'[[:digit:]]{4}\'';
    		} elseif (strpos($domain, '.us')) {
    			$cmd = 'whois '.$domain.' | grep -i \'Domain Registration Date\' | head -n1 | egrep -o \'[[:digit:]]{4}\'';
    		} else {
    			$cmd = 'whois '.$domain.' | grep -i \'creat\' | head -n1 | egrep -o \'[[:digit:]]{4}\'';
    		}
    		$res = exec($cmd);
    		return $res;
    	}
    
    Code (markup):
    You do need to be able to execute command via the exec command. If you just want to get the WHOIS-data use this:

    
    	function getWhoisData($domain)
    	{
    		return exec('whois '.$domain.');
    	}
    
    Code (markup):
     
    tamen, Jan 25, 2008 IP