Ver Mensaje Individual
  #11 (permalink)  
Antiguo 07/07/2009, 14:49
Avatar de Superlinux
Superlinux
 
Fecha de Ingreso: octubre-2005
Ubicación: Colombia
Mensajes: 662
Antigüedad: 18 años, 6 meses
Puntos: 1
Pregunta Respuesta: visualizar info dependiendo de la ip del cliente

hola amigos del foro .. creo que el error se debe a que mi servidor no acepta php orientado a objetos ..

lo pase ha estructurado .. pero no arroja ningun dato .. le faltara algo ???

Código PHP:
<html>
<body>
<?php
/**
 * This class generates the country name and its flag from its IP address
 *
 *
 * @author Rochak Chauhan
 */

    
$CountryIPDatabase 'CountryIPDatabase.txt';
    
$ip '';

    
/**
     * Function to validate IP ( please modify it according to your needs)
     *
     * @param $ip - string
     *
     * @return boolean
     */
    
function ValdateIP($ip) {
        
$ipArray explode(',',$ip);

        if(
count($ipArray) != 4) {
            echo 
"<font color='red' size='3'> <b>ERROR: </b> Invalid IP</font>";
            return 
false;
        }else{
            return 
true;
        }
//Fin del if
    
}//Fin del function ValdateIP($ip)

    /**
     * Function to return Country name from the IPDatabase
     *
     * @param $ip string
     * 
     * @return string - name of the country, false otherwise
     */
    
    
function GetCountryName($ip) {
        
        
$ip sprintf("%u"ip2long($ip));

        
$csvArray file($CountryIPDatabase);

        for(
$i=0$i<count($csvArray); $i++) {
            
$arrayOfLine explode(','$csvArray[$i]);
            if(
$ip >= $arrayOfLine[0] && $ip <= $arrayOfLine[1] ) {
                return 
$countryName $arrayOfLine[4];
            }
//Fin del if
        
}//Fin del for
        
return false;
    }
//Fin del function GetCountryName($ip)

    /**
     *  Function to return local path to Country's flag
     *
     * @param $ip - string
     *
     * @return string - local path to flag image
     */
    
    
function ReturnFlagPath() {

        if(
$countryName trim(ucwords(strtolower(GetCountryName($ip))) )) {
            
$countryName str_replace(' ','%20',$countryName);
            return 
"flag/$countryName.gif";
        }else{
            return 
false;
        }
//Fin del else
    
}//Fin del function ReturnFlagPath()

$ip $_SERVER["REMOTE_ADDR"];

$countryName =  GetCountryName($ip);
$flagPath =  ReturnFlagPath();

echo 
"<BR> <B>Country: </B>".$countryName;
echo 
"<BR> <B>Flag: </B> <img src=".$flagPath." border='0'>";

?> 
</body>
</html>
__________________
"La vida sigue su curso, tú toma parte de ella."