commit
6a1fe00008
|
@ -64,7 +64,8 @@ aside{
|
|||
}
|
||||
|
||||
form textarea, form input, form select {width:40%;}
|
||||
form input[type=checkbox], fieldset input[type=radio] { width:15px; }
|
||||
form input[type=checkbox], form input[type=radio] { width:15px; }
|
||||
form input[type=submit]{width: 100%;}
|
||||
form label {
|
||||
float:left;
|
||||
width:40%;
|
||||
|
|
25
install.sql
25
install.sql
|
@ -1,23 +1,26 @@
|
|||
CREATE TABLE `arena_history` (
|
||||
=======
|
||||
CREATE TABLE IF NOT EXISTS `arena_history` (
|
||||
>>>>>>> origin/master
|
||||
`game` varchar(8) NOT NULL,
|
||||
`player1_id` int(11) NOT NULL,
|
||||
`player2_id` int(11) NOT NULL,
|
||||
`player1_winsCount` int(11) NOT NULL,
|
||||
`player2_winsCount` int(11) NOT NULL,
|
||||
`nulCount` int(11) NOT NULL
|
||||
`nulCount` int(11) NOT NULL,
|
||||
PRIMARY KEY (`game`,`player1_id`,`player2_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
ALTER TABLE `arena_history`
|
||||
ADD PRIMARY KEY (`game`,`player1_id`,`player2_id`);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `bots` (
|
||||
`id` int(11) NOT NULL,
|
||||
CREATE TABLE `bots` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` text NOT NULL,
|
||||
`game` varchar(10) NOT NULL,
|
||||
`url` int(11) NOT NULL,
|
||||
`url` text NOT NULL,
|
||||
`description` text NOT NULL,
|
||||
`active` int(1) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
ALTER TABLE `bots`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
`active` int(1) NOT NULL,
|
||||
`date_inscription` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`validate_secret` varchar(8) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
|
||||
|
||||
INSERT INTO `bots` VALUES (1,'moul','tictactoe','http://tictactoe.m.42.am/','moul\'s Tic Tac Toe resolver in Golang. <a href=\"https://github.com/moul/tictactoe\">Open sourced</a> using Minimax algorithm',1,'2015-12-03 10:55:34',''),(2,'stupidAI','tictactoe','http://morpionmaster.tinad.fr/stupidIa.php','A PHP script that choose next case by... random. <a href=\"https://github.com/jeannedhack/programmingChallenges/blob/master/morpionsFights/Master/stupidIa.php>By Gnieark, here on github</a>',1,'2015-12-03 10:55:34',''),(3,'Gnieark','tictactoe','http://morpionmaster.tinad.fr/gnieark.php','Gnieark\'s PHP AI, using minmax algorythm. <a href=\"https://github.com/gnieark/tictactoeChallenge\">Published on github</a>',1,'2015-12-03 10:55:34','');
|
||||
|
|
|
@ -12,5 +12,9 @@ $lang=array(
|
|||
'MAKE_DUEL' => 'Provoquer un duel',
|
||||
'FIGHT' => 'Baston!',
|
||||
'DEV-YOUR-OWN-BOT' => 'Developpez votre bot et envoyez le dans cette arène.',
|
||||
'DOC_SPECS_LINKS' =>'Voici les spécifications techniques'
|
||||
'DOC_SPECS_LINKS' =>'Voici les spécifications techniques',
|
||||
'E_MAIL_ADD_BOT_INTRO' => 'Un grand merci pour la participation. Juste un click sur le lien suivant pour valider l\ajout du bot',
|
||||
'E_MAIL_ADD_BOT_INTRO_HTML' => '<p>Un grand merci pour la participation.</p><p>Juste un click sur le lien suivant pour valider l\ajout du bot</p>',
|
||||
'E_MAIL_ADD_BOT_SIGNATURE' => 'Gnieark',
|
||||
'E_MAIL_ADD_BOT_SIGNATURE_HTML' => '<p><i>Gnieark.</i></p>',
|
||||
);
|
97
src/act.php
Normal file
97
src/act.php
Normal file
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
|
||||
switch($_POST['act']){
|
||||
case "addBot":
|
||||
//verifier les variables "botName""botGame""botURL""email""botDescription"
|
||||
|
||||
$alerts="";
|
||||
|
||||
//botGame -> doit exister
|
||||
$arenaExists=false;
|
||||
foreach($arenas as $arena){
|
||||
if($_POST['botGame'] == $arena['id']){
|
||||
$arenaExists=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!$arenaExists){
|
||||
error(404,"wrong post parameter");
|
||||
}
|
||||
|
||||
//botname -> il ne doit pas y avoir un autre bot du même nom sur le même jeu
|
||||
$rs=mysqli_query($lnMysql,
|
||||
"SELECT 1
|
||||
FROM bots
|
||||
WHERE name='".mysqli_real_escape_string($lnMysql,htmlentities($_POST['botName']))."'
|
||||
AND game='".mysqli_real_escape_string($lnMysql,$_POST['botGame'])."';");
|
||||
if(mysqli_num_rows($rs) > 0){
|
||||
$alerts.="Un bot existant pour ce je porte le même nom\n";
|
||||
}
|
||||
|
||||
//BotUrl (doit retourner un code 200)
|
||||
if(!preg_match("/^(http|https):\/\//", $_POST['botURL'])){
|
||||
$alerts.="L'URL n'est pas valide\n";
|
||||
}
|
||||
|
||||
//email => doit être valide
|
||||
if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
|
||||
$alerts.="L'email n'est pas valide\n";
|
||||
}
|
||||
|
||||
if($alerts <>""){
|
||||
echo $alerts;
|
||||
}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
|
||||
( '".mysqli_real_escape_string($lnMysql,htmlentities($_POST['botName']))."',
|
||||
'".mysqli_real_escape_string($lnMysql,$_POST['botGame'])."',
|
||||
'".mysqli_real_escape_string($lnMysql,htmlentities($_POST['botURL']))."',
|
||||
'".mysqli_real_escape_string($lnMysql,
|
||||
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");
|
||||
|
||||
|
||||
|
||||
$mail = new PHPMailer;
|
||||
$mail->isSMTP();
|
||||
$mail->SMTPDebug = 2;
|
||||
$mail->Debugoutput = 'html';
|
||||
$mail->Host = $smtpParams['host'];
|
||||
$mail->Port = $smtpParams['port'];
|
||||
$mail->SMTPSecure = $smtpParams['secure'];
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = $smtpParams['username'];
|
||||
$mail->Password = $smtpParams['pass'];
|
||||
$mail->setFrom($smtpParams['username'], 'First Last');
|
||||
$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'];
|
||||
if (!$mail->send()) {
|
||||
echo "Mailer Error: " . $mail->ErrorInfo;
|
||||
} else {
|
||||
echo "Message sent!";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
echo "TODO";
|
||||
break;
|
||||
default:
|
||||
error(500,"erf");
|
||||
break;
|
||||
|
||||
}
|
3884
src/class.phpmailer.php
Normal file
3884
src/class.phpmailer.php
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,17 @@
|
|||
<?php
|
||||
$siteParam=array("BASEURL" => "http://botsarena.tinad.fr/");
|
||||
$mysqlParams=array(
|
||||
'host' => 'localhost',
|
||||
'user' => '',
|
||||
'pass' => '',
|
||||
'database'=>''
|
||||
);
|
||||
$smtpParams=array(
|
||||
//exemple for gmail
|
||||
'auth' => true,
|
||||
'secure' => 'tls',
|
||||
'host' => 'smtp.gmail.com',
|
||||
'port' => 587,
|
||||
'username' => "email@gmail.com",
|
||||
'pass' => ""
|
||||
);
|
|
@ -16,8 +16,8 @@ echo $lang['SITE_DESCRIPTION'];?>
|
|||
?>
|
||||
</select></p>
|
||||
<p><label for="botURL">URL du bot:</label><input type="text" name="botURL" id="botURL" placeholder="http://"/></p>
|
||||
<p><label>Description:</label><textarea></textarea></p>
|
||||
<p><label>Description:</label><textarea name="botDescription"></textarea></p>
|
||||
<p><label for="email">Votre e-mail (sera utilisé pour valider l'inscription du bot)</label><input type="text" name="email" id="email"/></p>
|
||||
<p><input type="submit" value="Enregistrer mon bot"/></p>
|
||||
</form>
|
||||
</article>
|
||||
</article>
|
||||
|
|
Loading…
Reference in New Issue
Block a user