Ahhhh l'index.php est plus clair là. Plus qu'à déboguer
This commit is contained in:
parent
de4b6a4658
commit
ccf2df8999
217
html/index.php
217
html/index.php
|
@ -17,10 +17,20 @@ $lnMysql=conn_bdd();
|
||||||
$arenas=get_arenas_list();
|
$arenas=get_arenas_list();
|
||||||
$lang=get_language_array();
|
$lang=get_language_array();
|
||||||
|
|
||||||
|
//check type of page
|
||||||
|
//$_GET['arena'] -> an arena
|
||||||
|
//$_GET['doc'] -> arena documentation
|
||||||
|
//$_GET['page'] -> a simple page like about page, legals etc...
|
||||||
|
//Nothing -> home page
|
||||||
|
|
||||||
|
$permitIndex=true; //will be set to false for pages that google or other bot must not index
|
||||||
|
|
||||||
if(isset($_GET['arena'])){
|
if(isset($_GET['arena'])){
|
||||||
//check if arena is list
|
//Arena
|
||||||
$currentArena = false;
|
|
||||||
foreach($arenas as $arena){
|
//check if arena exists
|
||||||
|
$currentArena = false;
|
||||||
|
foreach($arenas as $arena){
|
||||||
if($arena['id'] == $_GET['arena']){
|
if($arena['id'] == $_GET['arena']){
|
||||||
$currentArena = $_GET['arena'];
|
$currentArena = $_GET['arena'];
|
||||||
$currentArenaArr=$arena;
|
$currentArenaArr=$arena;
|
||||||
|
@ -31,31 +41,118 @@ if(isset($_GET['arena'])){
|
||||||
error(404,"Wrong parameter");
|
error(404,"Wrong parameter");
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
$hist=get_battles_history($currentArena);
|
||||||
|
|
||||||
|
|
||||||
|
$siteTitle=$currentArenaArr['title']." - bots Arena";
|
||||||
|
$siteDescription=$currentArenaArr['metaDescription'];
|
||||||
|
$mainSectionScript="../src/arenas/".$currentArena."/public.php";
|
||||||
|
$asideSectionContent='<h2>infos:</h2><p>'.$lang['DEV-YOUR-OWN-BOT'].'<br/> <a href="/'.$currentArena.'/doc">'.$lang['DOC_SPECS_LINKS'].'</a></p>
|
||||||
|
<h2>Scores</h2>';
|
||||||
|
foreach($hist as $sc){
|
||||||
|
$asideSectionContent.='<h3>'.$sc['bot1'].' VS '.$sc['bot2'].'</h3>
|
||||||
|
<ul>
|
||||||
|
<li>'.$sc['bot1']." ".$lang['VICTORIES'].":".$sc['player1Wins'].'</li>
|
||||||
|
<li>'.$sc['bot2']." ".$lang['VICTORIES'].":".$sc['player2Wins'].'</li>
|
||||||
|
<li>'.$lang['DRAW'].":".$sc['draws'].'</li>
|
||||||
|
</ul>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$cssAdditionalScript="";
|
||||||
|
if(isset($currentArenaArr['cssFile'])){
|
||||||
|
$cssAdditionalScript.='<style type="text/css"><!--'."\n".file_get_contents("../src/arenas/".$currentArena."/".$currentArenaArr['cssFile'])."\n--></style>";
|
||||||
|
}
|
||||||
|
//arena specific script js (if needed)
|
||||||
|
$jsAdditionalScript="";
|
||||||
|
if(isset($currentArenaArr['jsFile'])){
|
||||||
|
$jsAdditionalScript.='<script type="text/javascript"><!--'."\n".file_get_contents("../src/arenas/".$currentArena."/".$currentArenaArr['jsFile'])."\n--></script>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}elseif(isset($_GET['doc'])){
|
||||||
|
//arena's documentation page
|
||||||
|
|
||||||
|
//check if arena exists
|
||||||
|
$currentArena = false;
|
||||||
|
foreach($arenas as $arena){
|
||||||
|
if($arena['id'] == $_GET['doc']){
|
||||||
|
$currentArena = $_GET['doc'];
|
||||||
|
$currentArenaArr=$arena;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$currentArena){
|
||||||
|
error(404,"Wrong parameter");
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
$siteTitle="Specifications ".$currentArenaArr['title']." - bots Arena";
|
||||||
|
$siteDescription="documentation, faites votre propre bot pour ".$currentArenaArr['metaDescription'];
|
||||||
|
$mainSectionScript="../src/arenas/".$currentArenaArr['id']."/doc-".$lang['lang'].".html";
|
||||||
|
$asideSectionContent=''; //to do
|
||||||
|
$cssAdditionalScript="";
|
||||||
|
$jsAdditionalScript="";
|
||||||
|
|
||||||
|
}elseif(isset($_GET['page'])){
|
||||||
|
//simple page
|
||||||
|
switch($_GET['page']){
|
||||||
|
case "legals":
|
||||||
|
$siteTitle="Mentions légales - bots Arena";
|
||||||
|
$siteDescription="OSEF";
|
||||||
|
$mainSectionScript="../src/legals.html";
|
||||||
|
$asideSectionContent=''; //to do or not to do
|
||||||
|
$cssAdditionalScript="";
|
||||||
|
$jsAdditionalScript="";
|
||||||
|
break;
|
||||||
|
case "About":
|
||||||
|
$siteTitle="About - bots Arena";
|
||||||
|
$siteDescription="bots arena about page";
|
||||||
|
$mainSectionScript="../src/about.html";
|
||||||
|
$asideSectionContent=''; //to do or not to do
|
||||||
|
$cssAdditionalScript="";
|
||||||
|
$jsAdditionalScript="";
|
||||||
|
break;
|
||||||
|
case "addBot":
|
||||||
|
$siteTitle="Valider l'ajout d'une IA - bots Arena";
|
||||||
|
$siteDescription="bots arena about page";
|
||||||
|
$permitIndex=false;
|
||||||
|
$mainSectionScript="../src/addBot.php";
|
||||||
|
$asideSectionContent=''; //to do
|
||||||
|
$cssAdditionalScript="";
|
||||||
|
$jsAdditionalScript=""
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
error(404,"Not found");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
$currentArena = "";
|
//home page
|
||||||
|
$siteTitle="Bots Arena";
|
||||||
|
$siteDescription="bots arena main page. Program your own artificiel intelligence and let it play here";
|
||||||
|
$mainSectionScript="../src/home.php";
|
||||||
|
$asideSectionContent=''; //to do
|
||||||
|
$cssAdditionalScript="";
|
||||||
|
$jsAdditionalScript=""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//form submitting
|
//form submitting
|
||||||
if (isset($_POST['xd_check'])){
|
if (isset($_POST['xd_check'])){
|
||||||
//vérifier le numero de formulaire
|
//vérifier le numero de formulaire
|
||||||
if (($_SESSION['xd_check']!=$_POST['xd_check']) AND ($_POST['xd_check'] !="")){
|
if (($_SESSION['xd_check']!=$_POST['xd_check']) AND ($_POST['xd_check'] !="")){
|
||||||
error (400, 'Something wrong has appen');
|
error (400, 'Something wrong has appen');
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
//call the good act.php
|
//call the good act.php
|
||||||
if(($currentArena <> "") && (file_exists("../src/arenas/".$currentArena."/act.php"))){
|
if(($currentArena <> "") && (file_exists("../src/arenas/".$currentArena."/act.php"))){
|
||||||
require_once("../src/arenas/".$currentArena."/act.php");
|
require_once("../src/arenas/".$currentArena."/act.php");
|
||||||
}else{
|
}else{
|
||||||
require_once("../src/act.php");
|
require_once("../src/act.php");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//title
|
|
||||||
if($currentArena == ""){
|
|
||||||
$siteTitle = $lang['SITE_NAME'];
|
|
||||||
|
|
||||||
}else{
|
|
||||||
$siteTitle=$currentArenaArr['title'];
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
@ -63,35 +160,23 @@ if($currentArena == ""){
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="ROBOTS" content="INDEX, FOLLOW" />
|
<meta name="ROBOTS" content="<?php if($permitIndex){ echo "INDEX, FOLLOW";}else{echo "noindex, nofollow";}?>" />
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="author" content="Gnieark" />
|
<meta name="author" content="Gnieark" />
|
||||||
|
<meta name="description" content="<?php echo $siteDescription; ?>"/>
|
||||||
<title><?php echo $siteTitle; ?></title>
|
<title><?php echo $siteTitle; ?></title>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
@import url(/style.css);
|
@import url(/style.css);
|
||||||
</style>
|
</style>
|
||||||
<?php
|
<?php echo $cssAdditionalScript."\n".$jsAdditionalScript; ?>
|
||||||
//arena specific css script (if needed)
|
|
||||||
if(isset($currentArenaArr['cssFile'])){
|
|
||||||
echo '<style type="text/css"><!--'."\n";
|
|
||||||
echo file_get_contents("../src/arenas/".$currentArena."/".$currentArenaArr['cssFile']);
|
|
||||||
echo "\n--></style>";
|
|
||||||
}
|
|
||||||
//arena specific script js (if needed)
|
|
||||||
if(isset($currentArenaArr['jsFile'])){
|
|
||||||
echo '<script type="text/javascript"><!--'."\n";
|
|
||||||
echo file_get_contents("../src/arenas/".$currentArena."/".$currentArenaArr['jsFile']);
|
|
||||||
echo "\n--></script>";
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<h1><?php echo $siteTitle; ?></h1>
|
<h1><?php echo $siteTitle; ?></h1>
|
||||||
|
|
||||||
<nav id="languages"><a href="<?php echo $currentArena; ?>-fr">fr</a> <a href="<?php echo $currentArena; ?>-en">en</a></nav>
|
<nav id="languages"><a href="<?php echo $currentArena; ?>-fr">fr</a> <a href="<?php echo $currentArena; ?>-en">en</a></nav>
|
||||||
<nav id="menus"><a href="/"<?php if(($currentArena == "") && (!isset($_GET['doc']))) echo ' class="selected"'; ?>><?php echo $lang['HOME']; ?></a>
|
<nav id="menus"><a href="/"<?php if(($currentArena == "") && (!isset($_GET['doc']))) echo ' class="selected"'; ?>><?php echo $lang['HOME']; ?></a>
|
||||||
<?php
|
<?php
|
||||||
foreach($arenas as $arena){
|
foreach($arenas as $arena){
|
||||||
if( $arena['id'] == $currentArena){
|
if( $arena['id'] == $currentArena){
|
||||||
$class="selected";
|
$class="selected";
|
||||||
|
@ -100,55 +185,13 @@ if($currentArena == ""){
|
||||||
}
|
}
|
||||||
echo '<a href="'.$arena['url'].'" class="'.$class.'">'.$arena['title'].'</a>';
|
echo '<a href="'.$arena['url'].'" class="'.$class.'">'.$arena['title'].'</a>';
|
||||||
}
|
}
|
||||||
?></nav>
|
?></nav>
|
||||||
</header>
|
</header>
|
||||||
<section>
|
<section>
|
||||||
<?php
|
<?php
|
||||||
if(isset($_GET['doc'])){
|
include $mainSectionScript;
|
||||||
//on affiche une page de doc.
|
if($asideSectionContent <> ""){
|
||||||
$pageExists=false;
|
echo "<aside>".$asideSectionContent."</aside>";
|
||||||
foreach($arenas as $arena){
|
|
||||||
if($arena['id'] == $_GET['doc']){
|
|
||||||
if(file_exists("../src/arenas/".$arena['id']."/doc-".$lang['lang'].".html")){
|
|
||||||
$pageExists=true;
|
|
||||||
echo file_get_contents("../src/arenas/".$arena['id']."/doc-".$lang['lang'].".html");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!$pageExists){
|
|
||||||
error(404,"doc is missing");
|
|
||||||
die;
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
|
||||||
//on affiche une arene ou page d'accueil
|
|
||||||
switch($currentArena){
|
|
||||||
case "":
|
|
||||||
include ("../src/home.php");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
//battle history for this arena
|
|
||||||
$hist=get_battles_history($currentArena);
|
|
||||||
echo '<aside id="history">
|
|
||||||
<h2>infos:</h2>
|
|
||||||
<p>'.$lang['DEV-YOUR-OWN-BOT'].'<br/> <a href="/'.$currentArena.'/doc">'.$lang['DOC_SPECS_LINKS'].'</a></p>
|
|
||||||
<h2>Scores</h2>';
|
|
||||||
foreach($hist as $sc){
|
|
||||||
echo '<h3>'.$sc['bot1'].' VS '.$sc['bot2'].'</h3>
|
|
||||||
<ul>
|
|
||||||
<li>'.$sc['bot1']." ".$lang['VICTORIES'].":".$sc['player1Wins'].'</li>
|
|
||||||
<li>'.$sc['bot2']." ".$lang['VICTORIES'].":".$sc['player2Wins'].'</li>
|
|
||||||
<li>'.$lang['DRAW'].":".$sc['draws'].'</li>
|
|
||||||
</ul>';
|
|
||||||
}
|
|
||||||
echo '</aside>';
|
|
||||||
include ("../src/arenas/".$currentArena."/public.php");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
</section>
|
</section>
|
||||||
<footer>
|
<footer>
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
<h1>About</h1>
|
1
src/addBot.php
Normal file
1
src/addBot.php
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<h2>Add Bot</h2>
|
|
@ -0,0 +1 @@
|
||||||
|
<h1>Mentions légales</h1>
|
Loading…
Reference in New Issue
Block a user