diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..342f51d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/PHPMailer"] + path = src/PHPMailer + url = git@github.com:PHPMailer/PHPMailer.git diff --git a/html/.htaccess b/html/.htaccess index 683757e..aa02c20 100644 --- a/html/.htaccess +++ b/html/.htaccess @@ -1,5 +1,9 @@ RewriteEngine On RewriteBase / +RewriteRule ^p/([a-zA-Z]{1,})/(.*)-([a-z]{2})$ index\.php?page=$1¶ms=$2&lang=$3 [L] +RewriteRule ^p/([a-zA-Z]{1,})/(.*)$ index\.php?page=$1¶ms=$2 [L] +RewriteRule ^p/(.*)-([a-z]{2})$ index\.php?page=$1&lang=$2 [L] +RewriteRule ^p/(.*)$ index\.php?page=$1 [L] RewriteRule ^([a-zA-Z]{1,})/doc-([a-z]{2})$ index\.php?doc=$1&lang=$2 [L] RewriteRule ^([a-zA-Z]{1,})/doc$ index\.php?doc=$1 [L] RewriteRule ^([a-zA-Z]{1,})-([a-z]{2})$ index\.php?arena=$1&lang=$2 [L] diff --git a/html/index.php b/html/index.php index 84b1f3c..6931987 100644 --- a/html/index.php +++ b/html/index.php @@ -17,10 +17,20 @@ $lnMysql=conn_bdd(); $arenas=get_arenas_list(); $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'])){ - //check if arena is list - $currentArena = false; - foreach($arenas as $arena){ + //Arena + + //check if arena exists + $currentArena = false; + foreach($arenas as $arena){ if($arena['id'] == $_GET['arena']){ $currentArena = $_GET['arena']; $currentArenaArr=$arena; @@ -31,30 +41,120 @@ if(isset($_GET['arena'])){ error(404,"Wrong parameter"); die; } + $hist=get_battles_history($currentArena); + + + $siteTitle=$currentArenaArr['title']." - bots Arena"; + $siteDescription=$currentArenaArr['metaDescription']; + $mainSectionScript="../src/arenas/".$currentArena."/public.php"; + $asideSectionContent='

infos:

'.$lang['DEV-YOUR-OWN-BOT'].'
'.$lang['DOC_SPECS_LINKS'].'

+

Scores

'; + foreach($hist as $sc){ + $asideSectionContent.='

'.$sc['bot1'].' VS '.$sc['bot2'].'

+ '; + } + + $cssAdditionalScript=""; + if(isset($currentArenaArr['cssFile'])){ + $cssAdditionalScript.='"; + } + //arena specific script js (if needed) + $jsAdditionalScript=""; + if(isset($currentArenaArr['jsFile'])){ + $jsAdditionalScript.='"; + } + + +}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{ - $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 if (isset($_POST['xd_check'])){ - //vérifier le numero de formulaire - if (($_SESSION['xd_check']!=$_POST['xd_check']) AND ($_POST['xd_check'] !="")){ - error (400, 'Something wrong has appen'); - die; - } - //call the good act.php - if(($currentArena <> "") && (file_exists("../src/arenas/".$currentArena."/act.php"))){ - require_once("../src/arenas/".$currentArena."/act.php"); - }else{ - require_once("../src/act.php"); - } + //vérifier le numero de formulaire + if (($_SESSION['xd_check']!=$_POST['xd_check']) AND ($_POST['xd_check'] !="")){ + error (400, 'Something wrong has appen'); + die; + } + //call the good act.php + if(($currentArena <> "") && (file_exists("../src/arenas/".$currentArena."/act.php"))){ + require_once("../src/arenas/".$currentArena."/act.php"); + }else{ + require_once("../src/act.php"); + } } -//title -if($currentArena == ""){ - $siteTitle = $lang['SITE_NAME']; - -}else{ - $siteTitle=$currentArenaArr['title']; + +if(!isset($currentArena)){ + $currentArena=""; } ?> @@ -63,92 +163,40 @@ if($currentArena == ""){ - + " /> + <?php echo $siteTitle; ?> - "; - } - //arena specific script js (if needed) - if(isset($currentArenaArr['jsFile'])){ - echo '"; - } - ?> + - +
-

- - -
- -

infos:

-

'.$lang['DEV-YOUR-OWN-BOT'].'
'.$lang['DOC_SPECS_LINKS'].'

-

Scores

'; - foreach($hist as $sc){ - echo '

'.$sc['bot1'].' VS '.$sc['bot2'].'

- '; - } - echo ''; - include ("../src/arenas/".$currentArena."/public.php"); - break; - } - } - - + ""){ + echo ""; + } ?>