Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/05/2008, 10:50
manchilp
 
Fecha de Ingreso: enero-2008
Ubicación: La Plata
Mensajes: 136
Antigüedad: 16 años, 3 meses
Puntos: 3
De acuerdo [APORTE] Consultor de dominios .com .net .org y .info

Buenos dias , hice este pequeño script que averigua si tal dominio esta disponible o no. Esta echo en AJAX por lo que dividire el script en 3 , el index.html , el estilo.css que es opcional y el procesar.php que es el motor de este script.

index.html

Código HTML:
<html>
<head>
<link rel="stylesheet" type="text/css" href="estilo.css">
<script type="text/javascript">
function crearInstancia(){
			var aVersions = [ "MSXML2.XMLHttp.5.0",
					"MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0",
					"MSXML2.XMLHttp","Microsoft.XMLHttp"
			];
	
			if (window.XMLHttpRequest){
					// para IE7, Mozilla, Safari, etc: que usen el objeto nativo
					return new XMLHttpRequest();
			}else if (window.ActiveXObject){
					// de lo contrario utilizar el control ActiveX para IE5.x y IE6.x
					for (var i = 0; i < aVersions.length; i++) {
							try {
								var oXmlHttp = new ActiveXObject(aVersions[i]);
								return oXmlHttp;
							}catch (error) {
							//no necesitamos hacer nada especial
							}
				}
			}
}
function abrir(){
	AJAX = crearInstancia();
	if(AJAX){
		var url = 'procesar.php?id='+Math.random()*999999+'&dom='+document.getElementById('dominio').value+'&tipo='+document.getElementById('tipo').value;
		AJAX.open('GET',url,true);
		AJAX.onreadystatechange = function() {
			if(AJAX.readyState==1){
				document.getElementById('resp').innerHTML = 'Cargando...';
			}
			if(AJAX.readyState==4 && AJAX.status==200){
				if(AJAX.responseText==1){
					document.getElementById('resp').innerHTML = '<span class="si">El dominio se encuentra disponible</span>';
				}else{
					document.getElementById('resp').innerHTML = '<span class="no">El dominio no se encuentra disponible</span>';
				}
			}
		}
		AJAX.send(null);	
	}
}
</script>
</head>
<body>
<div id="all" align="center">
  <h1>Consulta de Dominios</h1>
  <input type="text" id="dominio" />
  <select id="tipo">
  	<option style="color:#000000;" value="0">.com</option>
    <option style="color:#0000FF;" value="1">.net</option>
    <option style="color:#0099FF;" value="2">.org</option>
    <option style="color:#00CCFF;" value="3">.info</option>
  </select>
  <br>
  <input type="button" id="buscar" value="Checar" onclick="abrir()" />
  
  <div id="resp" align="center"></div>
</div>
</body>
</html> 
procesar.php

Código PHP:
<?
$tipos 
= array('com','net','org','info');
$pag file_get_contents('http://dinamicanet.com/cgi-bin/wholite.cgi?dom='.$_GET['dom'].'&tld='.$tipos[$_GET['tipo']].'&action=search');
if(
ereg('NO ESTA DISPONIBLE',$pag)){
    echo 
0;
}else if (
ereg('DOMINIO DISPONIBLE',$pag)){
    echo 
1;
}
?>
y por ultimo , este archivo que es opcional , lo unico que hace es darle un poco mas de vida al script.
estilo.css
Código:
body{
font-family:"Trebuchet MS";}
h1{
color:#00CCFF;}
#all{
width:400px;
height:200px;
border:2px solid #00CCFF;
margin:0 auto;}
#dominio{
width:40%;
font-size:20px;
padding:2px;
border:1px solid #00CCFF;}
#buscar{
width:30%;
border:1px solid #000000;
color:#00CCFF;
margin:5px;
font-size:20px;}
select{
font-size:20px;}
.si{
font-weight:bold;
color:#00CC00;}
.no{
color:#990000;}
Espero que les haya servido , Suerte!