commit
412fae8775
3
.htaccess
Normal file
3
.htaccess
Normal file
|
@ -0,0 +1,3 @@
|
|||
php_flag display_startup_errors on
|
||||
php_flag display_errors on
|
||||
php_flag html_errors on
|
67
html/index.php
Normal file
67
html/index.php
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||
#
|
||||
# This file is part of botsArena.
|
||||
#
|
||||
# Copyright (C) Gnieark et contributeurs
|
||||
# Licensed under the GPL version 3.0 license.
|
||||
# See LICENSE file or
|
||||
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||
#
|
||||
# -- END LICENSE BLOCK -----------------------------------------
|
||||
//démmarrer une session php
|
||||
@session_start();
|
||||
|
||||
require_once("../src/functions.php");
|
||||
|
||||
|
||||
|
||||
$arenas=get_arenas_list();
|
||||
$lang=get_language_array();
|
||||
//form submitting
|
||||
if (isset($_POST['xd_check']))
|
||||
{
|
||||
//vérifier le numero de formulaire
|
||||
if (($_SESSION['xd_check']!=$_POST['xd_check']) AND ($_POST['xd_check'] !="")){
|
||||
erreur ('Something wrong has appen');
|
||||
die;
|
||||
}
|
||||
//call the good act.php
|
||||
if((isset($arenas['current'])) && (file_exists("src/arenas/act.php"))){
|
||||
require_once("src/arenas/act.php");
|
||||
}else{
|
||||
require_once("src/default/act.php");
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="ROBOTS" content="INDEX, FOLLOW" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="author" content="Gnieark" />
|
||||
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header>
|
||||
<nav id="languages"><a href="/fr">fr</a> <a href="/en">en</a></nav>
|
||||
<h1><?php
|
||||
if(isset($arenas['current'])){
|
||||
echo $arenas['current']['title'];
|
||||
}else{
|
||||
echo $lang['SITE_NAME'];
|
||||
} ?></h1>
|
||||
</header>
|
||||
<section>
|
||||
</section>
|
||||
<footer>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
5
lang/en.php
Normal file
5
lang/en.php
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
$lang=array(
|
||||
'SITE_NAME' => 'Artificials Intelligences\' arena',
|
||||
'SITE_DESCRIPTION' => 'blah blah blah but english'
|
||||
);
|
5
lang/fr.php
Normal file
5
lang/fr.php
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
$lang=array(
|
||||
'SITE_NAME' => 'Arène pour intelligences (ou persque) artificielles',
|
||||
'SITE_DESCRIPTION' => 'blah blah blah mais en francais'
|
||||
);
|
14
src/arenas_lists.php
Normal file
14
src/arenas_lists.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
$arenas=array(
|
||||
array(
|
||||
'id' => "tictactoe",
|
||||
'url' => "/tictactoe",
|
||||
'title' => "Tic Tac Toe"
|
||||
),
|
||||
array(
|
||||
'id' => "Battleship",
|
||||
'url' => "/battleship",
|
||||
'title' => "bataille Navale"
|
||||
)
|
||||
|
||||
);
|
46
src/functions.php
Normal file
46
src/functions.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
function get_arenas_list(){
|
||||
include (__DIR__."/arenas_lists.php");
|
||||
if(isset($_GET['arena'])){
|
||||
foreach ($arenas as $arena){
|
||||
if($arena['id'] == $_GET['arena']){
|
||||
$arenas['current'] = $arena;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $arenas;
|
||||
}
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user