-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
37 lines (34 loc) · 864 Bytes
/
index.php
File metadata and controls
37 lines (34 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
//VAR ZONE
$KEY="pagelanguage";
$ENGLISH="en";
$SPANISH="es";
$URI_EN="http://www.guillermocebollero.es/cv/en";
$URI_ES="http://www.guillermocebollero.es/cv/es";
if(!isset($_COOKIE[$KEY])) {
//Si es la primera sesión, miramos que lenguajes acepta
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
switch ($lang){
//Ponemos la cookie y redirigimos
case $ENGLISH:
setcookie($KEY, $ENGLISH, time() + (10 * 365 * 24 * 60 * 60),"/");
header("Location: ".$URI_EN);
break;
default:
setcookie($KEY, $SPANISH, time() + (10 * 365 * 24 * 60 * 60),"/");
header("Location: ".$URI_ES);
break;
}
}else{
//Obtenemos el idioma y redirigimos
switch ($_COOKIE[$KEY]) {
case $ENGLISH:
header("Location: ".$URI_EN);
break;
default:
header("Location: ".$URI_ES);
break;
}
}
die();
?>