Location: PHPKode > scripts > DNServer > dnserver/complex_example.php
<?
/*
**    DNServer (Public Domain)
**    Cesar Rodas <hide@address.com>
**
**    The Idea is to give a simple way to handle DNS querys and retrives an IP.
**    This project could be used as a DNS Trafic Balancer to mirrow sites with a 
**    close geografic position, of course with a IP2Country Module.
****************************************************************************************
**    La idea es dar una manera de manejar las peticiones de DNS y retornar un IP.
**    El proyecto puede ser usado como un Balanceador de Trafico hacia sitios espejos 
**    con una posicion geografica cercana, desde luego que con un modulo de IP2Country.
**
*/

/* The "complex" example xD */
include "DNServer.php";

$ips['www.google.com']['A'] = "192.168.0.1";
$ips['www.yahoo.com']['A'] = "192.168.0.1"; 
$ips['www.google.com']['MX'] = "192.168.2.1"; /* Mail eXchange*/
function dnshandler($dominio,$tipo)
{
    global $ips;
	if ( isset($ips[$dominio][$tipo]) )
		return $ips[$dominio][$tipo];
	else
    	return "127.0.0.1"; /* If not found return localhost */
}

$dns = new DNServer("dnshandler" /* callback function */, "127.0.0.1" /* needs the IP to listen in UnixLike OS in windows just need NULL*/);

?>
Return current item: DNServer