commit
dfd0bec941
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "src/PHPMailer"]
|
||||
path = src/PHPMailer
|
||||
url = git@github.com:PHPMailer/PHPMailer.git
|
|
@ -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]
|
||||
|
|
242
html/index.php
242
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='<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{
|
||||
$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 == ""){
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<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 name="author" content="Gnieark" />
|
||||
<meta name="description" content="<?php echo $siteDescription; ?>"/>
|
||||
<title><?php echo $siteTitle; ?></title>
|
||||
<style type="text/css">
|
||||
@import url(/style.css);
|
||||
@import url(/style.css);
|
||||
</style>
|
||||
<?php
|
||||
//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>";
|
||||
}
|
||||
?>
|
||||
<?php echo $cssAdditionalScript."\n".$jsAdditionalScript; ?>
|
||||
</head>
|
||||
<body>
|
||||
<body>
|
||||
<header>
|
||||
<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="menus"><a href="/"<?php if(($currentArena == "") && (!isset($_GET['doc']))) echo ' class="selected"'; ?>><?php echo $lang['HOME']; ?></a>
|
||||
<?php
|
||||
foreach($arenas as $arena){
|
||||
if( $arena['id'] == $currentArena){
|
||||
$class="selected";
|
||||
}else{
|
||||
$class="";
|
||||
}
|
||||
echo '<a href="'.$arena['url'].'" class="'.$class.'">'.$arena['title'].'</a>';
|
||||
<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="menus"><a href="/"<?php if(($currentArena == "") && (!isset($_GET['doc']))) echo ' class="selected"'; ?>><?php echo $lang['HOME']; ?></a>
|
||||
<?php
|
||||
|
||||
foreach($arenas as $arena){
|
||||
if( $arena['id'] == $currentArena){
|
||||
$class="selected";
|
||||
}else{
|
||||
$class="";
|
||||
}
|
||||
?></nav>
|
||||
echo '<a href="'.$arena['url'].'" class="'.$class.'">'.$arena['title'].'</a>';
|
||||
}
|
||||
?></nav>
|
||||
</header>
|
||||
<section>
|
||||
<?php
|
||||
if(isset($_GET['doc'])){
|
||||
//on affiche une page de doc.
|
||||
$pageExists=false;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
<?php
|
||||
include $mainSectionScript;
|
||||
if($asideSectionContent <> ""){
|
||||
echo "<aside>".$asideSectionContent."</aside>";
|
||||
}
|
||||
?>
|
||||
</section>
|
||||
<footer>
|
||||
|
|
1
src/PHPMailer
Submodule
1
src/PHPMailer
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 7c8b786228bb9e1561ff60a2d6f7f6ce91be6fee
|
|
@ -0,0 +1 @@
|
|||
<h1>About</h1>
|
42
src/act.php
42
src/act.php
|
@ -43,10 +43,8 @@ switch($_POST['act']){
|
|||
}else{
|
||||
//enregistrer le bot et envoyer un email pour la validation
|
||||
|
||||
$secret=rand_str(8, '$-_.+!*\'(),ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890');
|
||||
|
||||
$rs=mysqli_query($lnMysql,
|
||||
"INSERT INTO bots (name,game,url,description,active,date_inscription,validate_secret) VALUES
|
||||
$secret=rand_str(8, '$-_.+!*(),ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890');
|
||||
$sql = "INSERT INTO bots (name,game,url,description,active,date_inscription,validate_secret) VALUES
|
||||
( '".mysqli_real_escape_string($lnMysql,htmlentities($_POST['botName']))."',
|
||||
'".mysqli_real_escape_string($lnMysql,$_POST['botGame'])."',
|
||||
'".mysqli_real_escape_string($lnMysql,htmlentities($_POST['botURL']))."',
|
||||
|
@ -54,18 +52,19 @@ switch($_POST['act']){
|
|||
preg_replace('#^(http|https|mailto|ftp)://(([a-z0-9\/\.\?-_=\#@:~])*)#i','<a href="$1://$2">$1://$2</a>'
|
||||
,nl2br(htmlentities($_POST['botDescription'])))
|
||||
)."',
|
||||
'NOW(),
|
||||
'".$secret."'"
|
||||
);
|
||||
|
||||
include (__DIR__."/config.php");
|
||||
require_once (__DIR__."/class.phpmailer.php");
|
||||
|
||||
|
||||
'0',
|
||||
NOW(),
|
||||
'".$secret."')";
|
||||
// echo $sql;
|
||||
$rs=mysqli_query($lnMysql,$sql);
|
||||
|
||||
include __DIR__."/config.php";
|
||||
require __DIR__.'/PHPMailer/PHPMailerAutoload.php';
|
||||
|
||||
$mail = new PHPMailer;
|
||||
$mail->isSMTP();
|
||||
$mail->SMTPDebug = 2;
|
||||
//$mail->IsHTML(true);
|
||||
//$mail->SMTPDebug = 2;
|
||||
$mail->Debugoutput = 'html';
|
||||
$mail->Host = $smtpParams['host'];
|
||||
$mail->Port = $smtpParams['port'];
|
||||
|
@ -73,21 +72,18 @@ switch($_POST['act']){
|
|||
$mail->SMTPAuth = true;
|
||||
$mail->Username = $smtpParams['username'];
|
||||
$mail->Password = $smtpParams['pass'];
|
||||
$mail->setFrom($smtpParams['username'], 'First Last');
|
||||
$mail->setFrom($smtpParams['username'], 'Bots Arena');
|
||||
$mail->Subject = 'BotsArena';
|
||||
$mail->msgHTML=$lang['E_MAIL_ADD_BOT_INTRO_HTML'].'<p><a href="'.$siteParam['BASEURL'].'validateBot/'.$secret.'">'.$siteParam['BASEURL'].'validateBot/'.$secret.'</a></p>'.$lang['E_MAIL_ADD_BOT_SIGNATURE_HTML'];
|
||||
$mail->AltBody = $lang['E_MAIL_ADD_BOT_INTRO']."\n".$siteParam['BASEURL'].'validateBot/'.$secret."\n".$lang['E_MAIL_ADD_BOT_SIGNATURE'];
|
||||
$mail->addAddress($_POST['email']);
|
||||
//$mail->msgHTML=$lang['E_MAIL_ADD_BOT_INTRO_HTML'].'<p><a href="'.$siteParam['BASEURL'].'validateBot/'.$secret.'">'.$siteParam['BASEURL'].'validateBot/'.$secret.'</a></p>'.$lang['E_MAIL_ADD_BOT_SIGNATURE_HTML'];
|
||||
$mail->Body = $lang['E_MAIL_ADD_BOT_INTRO']."\n".$siteParam['BASEURL'].'validateBot/'.$secret."\n".$lang['E_MAIL_ADD_BOT_SIGNATURE'];
|
||||
if (!$mail->send()) {
|
||||
echo "Mailer Error: " . $mail->ErrorInfo;
|
||||
error(500,"Mailer Error: " . $mail->ErrorInfo);
|
||||
} else {
|
||||
echo "Message sent!";
|
||||
}
|
||||
|
||||
|
||||
|
||||
//echo "Message sent!";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo "TODO";
|
||||
break;
|
||||
default:
|
||||
|
|
1
src/addBot.php
Normal file
1
src/addBot.php
Normal file
|
@ -0,0 +1 @@
|
|||
<h2>Add Bot</h2>
|
|
@ -4,13 +4,15 @@ $arenas=array(
|
|||
'id' => "tictactoe",
|
||||
'url' => "/tictactoe",
|
||||
'title' => "Tic Tac Toe",
|
||||
'metaDescription' => 'Affrontements de bots au TicTacToe, morpion',
|
||||
'jsFile'=> "js.js",
|
||||
'cssFile'=> "style.css"
|
||||
),
|
||||
array(
|
||||
'id' => "Battleship",
|
||||
'url' => "/Battleship",
|
||||
'title' => "bataille Navale"
|
||||
'title' => "bataille Navale",
|
||||
'metaDescription' => 'Affrontements de bots à la battaille navale'
|
||||
)
|
||||
|
||||
);
|
|
@ -0,0 +1 @@
|
|||
<h1>Mentions légales</h1>
|
Loading…
Reference in New Issue
Block a user