un input type hidden sans id
* 1=> un input type hidden avec id
* 2=> juste la valeur
*/
if(!isset($_SESSION['xd_check'])){
//le générer
$_SESSION['xd_check']=rand_str(25);
}
switch($id){
case 0:
return "";
break;
case 1:
return "";
break;
case 2:
return $_SESSION['xd_check'];
break;
default:
return "";
break;
}
}
function get_language_array(){
/*
* Choisir la langue de l'utilisateur
* en priorisant parametre GET, cookie, info du navigateur
* Retourner l'array contenant les bonnes traductions
*/
$langsAvailable=array('fr','en');
$language="";
if( isset($_GET['lang']) ){
$lang = $_GET['lang'];
setcookie( 'lang', $language, time() + 60*60*24*30 );
}elseif( isset($_COOKIE['lang']) ){
$language=$_COOKIE['lang'];
}else{
if(in_array(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2),$langsAvailable)){
$language=substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
}
}
if(!in_array($language,$langsAvailable)){
$language="en";
}
include (__DIR__."/../lang/".$language.".php");
return $lang;
}