This commit is contained in:
Gnieark 2015-12-30 16:03:10 +01:00
parent 3e2d389aa3
commit d3f039bb95
3 changed files with 54 additions and 6 deletions

View File

@ -45,5 +45,6 @@ $lang = array(
'BOT_URL' => 'The URL of your bot', 'BOT_URL' => 'The URL of your bot',
'BOT_DESCRIPTION' => 'Description (html code will not be interpreted, URL will be converted into link):', 'BOT_DESCRIPTION' => 'Description (html code will not be interpreted, URL will be converted into link):',
'YOUR_EMAIL_FOR_BOT_VALIDATION' => 'Your email address (will serve to validate your bot)', 'YOUR_EMAIL_FOR_BOT_VALIDATION' => 'Your email address (will serve to validate your bot)',
'SAVE_BOT' => 'Save' 'SAVE_BOT' => 'Save',
'E_MAIL_EDIT_BOT' => "Hello Dude! \n Please Folow the next URL in order to validate your bot update."
); );

View File

@ -45,5 +45,6 @@ $lang = array(
'BOT_URL' => 'L\'adresse URL de votre bot', 'BOT_URL' => 'L\'adresse URL de votre bot',
'BOT_DESCRIPTION' => 'Description (le code html ne sera pas interprété, les URL seront transformées en lien)', 'BOT_DESCRIPTION' => 'Description (le code html ne sera pas interprété, les URL seront transformées en lien)',
'YOUR_EMAIL_FOR_BOT_VALIDATION' => 'Votre adresse e-mail (servira pour la validation de votre bot)', 'YOUR_EMAIL_FOR_BOT_VALIDATION' => 'Votre adresse e-mail (servira pour la validation de votre bot)',
'SAVE_BOT' => 'Enregistrer' 'SAVE_BOT' => 'Enregistrer',
'E_MAIL_EDIT_BOT' => "Bonjour Dude! \n Suivez l'URL suivante pour valider les modifications sur votre bot."
); );

View File

@ -1,5 +1,9 @@
<?php <?php
//Del unvalidated bots
mysqli_query($lnMysql "DELETE FROM bots WHERE active='0' AND TIMESTAMPDIFF(DAY, NOW(), date_inscription) > 2");
mysqli_query($lnMysql "DELETE FROM bot_modifs WHERE TIMESTAMPDIFF(DAY, NOW(), date_modification) > 2");
switch($_POST['act']){ switch($_POST['act']){
case "addBot": case "addBot":
//verifier les variables "botName""botGame""botURL""email""botDescription" //verifier les variables "botName""botGame""botURL""email""botDescription"
@ -99,7 +103,7 @@ switch($_POST['act']){
AND id='".mysqli_real_escape_string($lnMysql,$_POST['botId'])."'" AND id='".mysqli_real_escape_string($lnMysql,$_POST['botId'])."'"
); );
if(!$r=mysqli_fetch_row($rs)){ if(!$r=mysqli_fetch_row($rs)){
$err.= "L'adresse e-mail ne correspond pas à celle enregitrée\n"; $err.= "L'adresse e-mail ne correspond pas à celle enregistrée\n";
} }
//check name //check name
$rs=mysqli_query($lnMysql, $rs=mysqli_query($lnMysql,
@ -116,11 +120,53 @@ switch($_POST['act']){
if(!preg_match("/^(http|https):\/\//", $_POST['botURL'])){ if(!preg_match("/^(http|https):\/\//", $_POST['botURL'])){
$alerts.="L'URL n'est pas valide.\n"; $alerts.="L'URL n'est pas valide.\n";
} }
//******************* TO DO *******************************
if($err <> ""){ if($err <> ""){
//save bot on temp table
$secret=rand_str(8, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890');
mysqli_query($lnMysql,
" INSERT INTO bots_modifs( name, game, url, description, date_modification, validate_secret, author_email) VALUES (
'".mysqli_real_escape_string($lnMysql,html_entities($_POST['botName']))."',
'".mysqli_real_escape_string($lnMysql,$_POST['botGame'])."',
'".mysqli_real_escape_string($lnMysql,$_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."',
'".mysqli_real_escape_string($lnMysql,$_POST['email'])."'"
);
//send e-mail
include __DIR__."/config.php";
require __DIR__.'/PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
//$mail->IsHTML(true);
//$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'], 'Bots Arena');
$mail->Subject = 'BotsArena';
$mail->addAddress($_POST['email']);
$mail->Body = $lang['E_MAIL_EDIT_BOT']."\n".$siteParam['BASEURL'].'p/editBot/'.$secret."\n".$lang['E_MAIL_ADD_BOT_SIGNATURE'];
if (!$mail->send()) {
error(500,"Mailer Error: " . $mail->ErrorInfo);
} else {
//echo "Message sent!";
}
}else{ }else{
} }