Ver Mensaje Individual
  #3 (permalink)  
Antiguo 14/09/2010, 13:10
markmb
 
Fecha de Ingreso: octubre-2009
Ubicación: En el ordenador
Mensajes: 504
Antigüedad: 17 años
Puntos: 10
Respuesta: Lenguaje Según País

Código PHP:
<? 


// Conectarse a la Database 
$dbh = mysql_connect("localhost", "usuario", "contraseña") or die("Could not connect: " . mysql_error()); 
mysql_select_db("base_de_datos"); 

// Verificar si la Cookie Existe 
if($_COOKIE["LenguajeMiWeb"] != ''){ 
$MiGalleta = $_COOKIE["LenguajeMiWeb"]; 
//Descomponer la Galleta para Obtener las Variables 
$MiGalleta_Descompuesta = explode('##@##',$MiGalleta); 
// Quitar Espacios en Blanco 
$Galleta_Lenguaje = trim($MiGalleta_Descompuesta[0]); 
$Galleta_País = trim($MiGalleta_Descompuesta[1]); 
$wea2 = mysql_query("SELECT HostDB,UsuaDB,ContDB,NombDB,LogoSup1,LogoSup2,LogoInf1,LogoInf2 FROM Login where Lenguaje = '$Galleta_Lenguaje' and Pais = '$Galleta_País'"); 
$row2 = mysql_fetch_row($wea2); 
$Idioma = $Galleta_Lenguaje; 
$ArraEnviar = $row2[HostDB]."##@##".$row2[UsuaDB]."##@##".$row2[ContDB]."##@##".$row2[NombDB]; 
define('URLLogoSup1',$row2[LogoSup1]); 
define('URLLogoSup2',$row2[LogoSup2]); 
define('URLLogoInf1',$row2[LogoInf1]); 
define('URLLogoInf2',$row2[LogoInf2]); 
//FIN ******
}else{ 
// Detectar Dominio (No existe la Cookie) 
$host = gethostbyaddr($REMOTE_ADDR);  
$dominio = substr( $host, (strrpos( $host,".")+1)); 
// Varificar las Variables Indicadas en la Database 
$wea = mysql_query("SELECT Lenguaje,Pais,HostDB,UsuaDB,ContDB,NombDB,LogoSup1,LogoSup2,LogoInf1,LogoInf2 FROM Login where Extencion ='$dominio'"); 
$row = mysql_fetch_row($wea); 
//El Else de ahí arriba, que tiene unos asteriscos, no se cerraría aquí?
// Verificar si Existe una Extención Así 
if ($row[Lenguaje] != ''){ 
// Crear Cookie 
setcookie("LenguajeMiWeb", $row[Lenguaje]."##@##".$row[Pais], time() + 432000); // 432.000 Segundos, son 5 Días 
$Idioma = $row[Lenguaje]; 
$ArraEnviar = $row[HostDB]."##@##".$row[UsuaDB]."##@##".$row[ContDB]."##@##".$row[NombDB]; 
define('URLLogoSup1',$row[LogoSup1]); 
define('URLLogoSup2',$row[LogoSup2]); 
define('URLLogoInf1',$row[LogoInf1]); 
define('URLLogoInf2',$row[LogoInf2]); 
//FIN 
}else{ 
// PONERLE LENGUAJE EXISTENTE Y LOGUITOS EXISTENTES PREDETERMINADOS, AGREGAR CARTEL DE ADVERTENCIA SOBRE ELLO USANDO UN DEFINE EN LA PARTE SUPERIOR DE SP.PHP 
} 

mysql_close($dbh); 


// Conectar la DB Correspondiente al País 
function Conectarse($Recibidas_Array){ 
$DBInfo = explode('##@##',$Recibidas_Array); 
// Quitar Espacios en Blanco 
$HostDB = trim($DBInfo[0]); $Usuari = trim($DBInfo[1]); $Cont = trim($DBInfo[3]); $NombreDB = trim($DBInfo[3]); 
global 
$link; if (!($link=mysql_connect($HostDB,$Usuari,$Cont))){exit();}if (!mysql_select_db($NombreDB,$link)){exit();}return $link;} 
Conectarse($ArraEnviar); 

if (
$Idioma == 'Español'){ 
/////////////////////////////////////// 
///////// DEFINE ESPAÑOL LENGUAJE 
/////////////////////////////////////// 
}elseif ($Idioma == 'Ingles'){ 
/////////////////////////////////////// 
///////// DEFINE INGLES LENGUAJE 
/////////////////////////////////////// 
}else{ 
/////////////////////////////////////// 
///////// DEFINE DEFAULT LENGUAJE 
/////////////////////////////////////// 
} 


?>
__________________
Buscando ideas para proyectos....

Esperando a tener 18 años....