He buscado y lo encontre, solo que no se por que no funciona.
Vi un aporte de abimaelrc y con ese estoy tratando solo que no me queda.
codigo php
Código PHP:
Ver original<?php
$ip = "189.143.104.60";
$obj = new CountryFromIP();
$countryName = $obj->GetCountryName($ip);
$flagPath = $obj->ReturnFlagPath();
if($countryName == "MEXICO")
{
echo "<meta http-equiv='Refresh' content='0;URL=http://www.google.com.mx/' />";
}
elseif($countryName == "ARGENTINA")
{
echo "<meta http-equiv='Refresh' content='0;URL=http://www.google.com.ar/' />";
}
elseif($countryName == "CHILE")
{
echo "<meta http-equiv='Refresh' content='0;URL=http://www.google.com.cl/' />";
}
else
{
echo "<meta http-equiv='Refresh' content='0;URL=http://www.google.cl/' />";
}
/**
* This class generates the country name and its flag from its IP address
*
*
* @author Rochak Chauhan
*/
class CountryFromIP {
private $CountryIPDatabase = 'ip-to-country.csv';
private $ip = '';
/**
* Function to validate IP ( please modify it according to your needs)
*
* @param $ip - string
*
* @return boolean
*/
public function ValdateIP($ip) {
if(count($ipArray) != 5) { echo "<font color='red' size='3'> <b>ERROR: </b> Invalid IP</font>";
return false;
}
else {
return true;
}
}
/**
* Function to return Country name from the IPDatabase
*
* @param $ip string
*
* @return string - name of the country, false otherwise
*/
public function GetCountryName($ip) {
$this->ip = $ip;
$csvArray = file($this->CountryIPDatabase);
for($i=0; $i<count($csvArray); $i++){ $arrayOfLine = explode(',', $setCsv); if($ip >= $arrayOfLine[0] && $ip <= $arrayOfLine[1] ) {
return $countryName = $arrayOfLine[4];
}
}
return false;
}
/**
* Function to return local path to Country's flag
*
* @param $ip - string
*
* @return string - local path to flag image
*/
public function ReturnFlagPath() {
return "flag/$countryName.gif";
}
else {
return false;
}
}
}
?>
falla en la parte de los if's a la hora de redireccionar, en que esta mal?
direccion del .csv
http://ip-to-country.webhosting.info...ountry.csv.zip
aporte
http://www.forosdelweb.com/f18/aport...visita-708776/