Jump to content

Script php para verificar disponibilidad de dominios


Recommended Posts

Buenas! mi primer tema! mi consulta es la siguiente:

 

En primer lugar, si alguien conoce algún script que permita verificar la disponibilidad de dominios .com estilo whois pero que no de informacion sobre los dominios registrados, simplemente que informe disponible o no disponible

 

y en segundo lugar es saber si hay algun requisito legal, o algo asi, que deba cumplir para tener un whois, o esto mismo que busco, o si es libre!

 

Gracias por su tiempo!

Link to comment
Share on other sites

Mira! apenas lo lei pense que no habia forma, pero me puse a investigar un poquito! al parecer existe una forma! Entonces agarre y pregunte en mi hosting de towebs si necesitaba algun permiso legal o algo asi para tener este tipo de scripts y resulta que no!!!! =D

lo que si espero que tengas pacienciaa y vas necesitar saber algo, de php, jquery y de html(obviamenchi XD)

 

En realidad funciona como un Whois clasico, digamos que el script verifica la existencia del dominio, si el dominio existe te va a dar la info, como en el who is, pero si esta disponible te va a dar un NO MATCH, Not found o algo asi!, espero que te sirva, yo aun no lo testee, pero testealo y contanos si te sirvio

ahi te va el code!

el php:

<?php
	/*
	 * byteWhois, un whois lookup para resellers!
	 * Desarrollado por      : Gerber Pacheco
	 * Sitio Web         : http://ignoranto.info
	 * Si conoces algun otro servidor whois, me gustaría que me envíes la info a [email protected]
	 * Este script devuelve un objeto Javascript (jSON) con 2 propiedades: "estado" y "whois"
	 */

	   $dominioNombre = $_GET['dominio'];
	   $dominioExtension = $_GET['tld'];

	   $estado = comprobarDominio($dominioNombre,$dominioExtension);
	   if ($estado == 'no-disponible'){   $whois = INFO_WHOIS;   }
	   else   {   $whois = "Dominio no registrado";   }


	   $data = array("estado" => "$estado","whois" => $whois );
	   echo json_encode($data);




	function servidorWhois($tld)
	{
	   switch($tld)
	   {
	      case 'com' :   $server = "whois.verisign-grs.com";
	                  $noFound = "No match"; break;

	      case 'net' :   $server = "whois.verisign-grs.com";
	                  $noFound = "No match"; break;

	      case 'org' :   $server = "whois.publicinterestregistry.net";
	                  $noFound = "NOT FOUND"; break;

	      case 'info':   $server = "whois.afilias.net";
	                  $noFound = "Not found"; break;

	      case 'biz' :   $server = "whois.nic.biz";
	                  $noFound = "Not found"; break;

	      default:      return null; break;
	   }
	   return $server.";".$noFound;
	}

	function comprobarDominio($dominioNombre, $dominioTld)
	{
	   $dominioCompleto = $dominioNombre.".".$dominioTld;
	   $serverInfo = servidorWhois($dominioTld);

	   if ($serverInfo)
	   {
	      $serverData = explode(";", $serverInfo);
	      $whoisServer = $serverData[0];
	      $noFound = $serverData[1];
	      $conexionServer = fsockopen($whoisServer,43);
	      fputs($conexionServer,"$dominioCompleto\r\n");
	      $respuesta = '';
	      while(!feof($conexionServer))
	      {
	         $respuesta .= fgets($conexionServer,128);
	      }
	      fclose($conexionServer);
	      if (ereg($noFound,$respuesta)) {
	         return "disponible";
	      }
	      else {
	         define ('INFO_WHOIS',$respuesta);
	         return "no-disponible";
	      }
	   }
	   else
	   {
	      return "tld-incorrecta";
	   }
	}


	?>

En el Html:

<html>
	   <head>
	      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	      <title>byteWhois! | Ignoranto.info</title>
	      <script src="jquery-1.3.2.min.js"></script>
	      <script language="Javascript">
	         $(document).ready(function(){
	            $("#whois").fadeIn("slow");
	         });
	         function whoisDominio()
	         {
	            dom = $("#dominio").val();
	            ext = $("#tld").val();
	            if(revisarDominio(dom))
	            {
	               $.getJSON('../php/byteWhois.php',{dominio:dom, tld:ext},
	               function(data){
	                  if (data.estado == 'no-disponible')   {
	                     mensajito("Dominio <span style='color:red;'>NO DISPONIBLE!</span>");
	                  }else{
	                     mensajito("Dominio <b>DISPONIBLE!</b>");
	                  }
	               });   
	            }
	            else
	            {
	               alert("El dominio ingresado no matiene un formato adecuado!");
	            }
	         }
	         function revisarDominio(dom)
	         {
	            re=/^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))$/
	            if(!re.exec(dom)){return false;} else {return true;}
	         }
	         function mensajito(msg)
	         {
	            $("#info").html(msg);
	            $("#info").slideDown();
	            setTimeout('$("#info").slideUp();',3000);
	         }
	      </script>
	      <style type="text/css">
	         body{   text-align:center;      }
	         #whois   {    display:none; width:300px; margin:auto;
	                  font-family:Verdana, Geneva, Arial, Helvetica, sans-serif;
	                  font-size:14px; border:1px black solid;
	                  background:#c5e97a;padding:10px;
	                  }
	         #whois .domain{   font-size:20px; text-align:right;   }   #whois .tld{font-size:20px;      }
	         #info {   padding:5px; margin:5px; border:1px gray solid;
	               background:#deed29; color:black; display:none; font-size:12px; font-weight:bolder;}
	         a{font-size:11px; text-decoration:none; color:#e87400;}
	         a:hover{text-decoration:underline; color:#e87400;}
	         #whoisData{display:none; width:680px; margin:auto; padding:5px ; border:1px gray solid; text-align:justify;}
	      </style>
	   </head>
	   <body>
	      <form id="whois" action="javascript: whoisDominio();">
	         <div id="info"></div>
	         <strong>Ignoranto byteWhois</strong><br>
	         Ingresa tu Dominio (sin "www.")<hr>
	         <input class='domain' id="dominio" type="text">
	         <select class='tld' id="tld">
	            <option value='com'>.com</option>
	            <option value='net'>.net</option>
	            <option value='org'>.org</option>
	            <option value='info'>.info</option>
	            <option value='biz'>.biz</option>
	         </select><br>
	         <input type="submit" value="¿Está disponible?">
	         <hr>
	         <a href="http://ignoranto.info">Desarrollo Web y más! [ignoranto Blog!]</a><br>
	      </form>
	   </body>
	</html>

Ojala Sirva Saludos!

Link to comment
Share on other sites

  • 1 month later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...