botsArena/src/functions.php

46 lines
1.0 KiB
PHP
Raw Normal View History

2015-11-25 22:24:41 +01:00
<?php
2015-11-26 19:38:09 +01:00
function get_arenas_list(){
2015-11-25 22:24:41 +01:00
include (__DIR__."/arenas_lists.php");
if(isset($_GET['arena'])){
foreach ($arenas as $arena){
if($arena['id'] == $_GET['arena']){
$arenas['current'] = $arena;
break;
}
}
}
return $arenas;
2015-11-26 19:38:09 +01:00
}
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="";
2015-11-26 21:21:03 +01:00
if( isset($_GET['lang']) ){
2015-11-26 19:38:09 +01:00
$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;
2015-11-25 22:24:41 +01:00
}