Login   Register  
PHP Classes
elePHPant
Icontem

File: whois.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of christian cannata  >  Whois class  >  whois.php  >  Download  
File: whois.php
Role: Class source
Content type: text/plain
Description: whois class file
Class: Whois class
Check if a domain is available using whois
Author: By
Last change: Update italian geographic extension and a bug with .eu
Date: 2 years ago
Size: 3,354 bytes
 

Contents

Class file image Download
<?php
class whois_search {
var 
$mappa_estensione_server = array (
      
"it" => "whois.nic.it",
      
"com" => "whois.internic.net",
      
"net"  => "whois.internic.net",
      
"org"  => "whois.publicinterestregistry.net",
      
"info" => "whois.afilias.info",
      
"biz"  => "whois.neulevel.biz",
      
"eu"  => "whois.eu",
      
"name"  => "whois.nic.name",
      
"mobi"  => "whois.dotmobiregistry.net",
      
"me" => "whois.meregistry.net",
      
"tel" => "whois.nic.tel",
      
"de" => "whois.denic.de",
      
"fr" =>"whois.nic.fr",
      
"es" =>"whois.ripe.net",
      
"pl" =>"whois.dns.pl",
      
"uk"=> "whois.nic.uk",
      
"in"=>"whois.inregistry.net",
      
"asia"=>"whois.nic.asia"
  
);
   var 
$cercaRisposta = array (
      
"it" => "available",
      
"com" => "no match",
      
"net"  => "no match",
      
"org"  => "not found",
      
"info" => "not found",
      
"biz"  => "not found",
      
"eu"  => "AVAILABLE",
      
"name"  => "no match",
      
"mobi"  => "not found",
      
"me" => "not found",
      
"in" => "not found",
      
"tel" => "not found",
      
"de" => "status: free",
      
"fr" =>"no entries found",
      
"es" =>"no entries found",
      
"pl" =>"no information available",
      
"uk"=> "no match for",
      
"asia"=>"not found"
  
);
 function 
do_whois($dominio2,$estensioni) {
  
$doppia=false;
  
$domini=array();
  for(
$i=0;$i<count($estensioni);$i++){
   
/*if(isset($_POST['estensioneGeo'])){
   $doppia=true;
   //$dominio2.=".".$_POST['estensioneGeo'];
   }*/
    
$dominio=$dominio2.".".$estensioni[$i];
    
$dominio strtolower(trim($dominio));
    
$pos_punto strrpos($dominio".");
    if (!
$pos_punto) {
      return 
"nome di dominio non valido";
    } else {
      if(
$doppia){
      
      }else{
        
$estensione substr($dominio$pos_punto 1);
        if (!
array_key_exists($estensione,$this->mappa_estensione_server)) {
        return 
"estensione <b><i>.".$estensione."</i></b> non supportata";
        }
      }
    }
    
$server $this->mappa_estensione_server[$estensione];
    
$puntatore_whois =  fsockopen($server43$errno$errstr30);
    
$html_output '';
    if (!
$puntatore_whois) {
      
$html_output "$errstr ($errno)";
    } else {
       
fputs($puntatore_whois"$dominio\r\n");
       while (!
feof($puntatore_whois)) {
         
$html_output .= fread($puntatore_whois,128);
       }
       
fclose ($puntatore_whois);
    }
    if(
$estensione!="eu")
    
$html=strtolower($html_output);
    else
    
$html=$html_output;
    if(
strstr($html,$this->cercaRisposta[$estensione]))
     
array_push($domini,array("dominio"=>$dominio2,"estensione"=>$estensioni[$i],"risultato"=>"ok","output"=>$html_output));
    else
     
array_push($domini,array("dominio"=>$dominio2,"estensione"=>$estensioni[$i],"risultato"=>"ko","output"=>$html_output));
    }
    return 
$domini;
  }
  function 
print_allowed_extension () {
    
$vettore_estensioni array_keys($this->mappa_estensione_server);
    
$estensioni_supportate '';
    for (
$i 0$i count($vettore_estensioni); $i++) {
      
$estensioni_supportate .= '&nbsp;.'.$vettore_estensioni [$i].'&nbsp;';
    }
    return 
$estensioni_supportate;
  }
}



$whois = new whois_search();
$appo=explode("-",$_POST['estensioni']);
unset(
$appo[count($appo)-1]);
echo 
json_encode($whois->do_whois($_POST['dominio'],$appo));

unset(
$whois);
?>