From d3f039bb959a0fe641ac0d3519edfc45a73fe370 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Wed, 30 Dec 2015 16:03:10 +0100 Subject: [PATCH] bot edit --- lang/en.php | 3 ++- lang/fr.php | 3 ++- src/act.php | 54 +++++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 54 insertions(+), 6 deletions(-) diff --git a/lang/en.php b/lang/en.php index c32cb7a..2f6e3e4 100644 --- a/lang/en.php +++ b/lang/en.php @@ -45,5 +45,6 @@ $lang = array( 'BOT_URL' => 'The URL of your bot', '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)', - '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." ); \ No newline at end of file diff --git a/lang/fr.php b/lang/fr.php index eb3bfe4..dee78f9 100644 --- a/lang/fr.php +++ b/lang/fr.php @@ -45,5 +45,6 @@ $lang = array( '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)', '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." ); \ No newline at end of file diff --git a/src/act.php b/src/act.php index 9cd2cb6..f783aa8 100644 --- a/src/act.php +++ b/src/act.php @@ -1,5 +1,9 @@ 2"); +mysqli_query($lnMysql "DELETE FROM bot_modifs WHERE TIMESTAMPDIFF(DAY, NOW(), date_modification) > 2"); + switch($_POST['act']){ case "addBot": //verifier les variables "botName""botGame""botURL""email""botDescription" @@ -99,7 +103,7 @@ switch($_POST['act']){ AND id='".mysqli_real_escape_string($lnMysql,$_POST['botId'])."'" ); 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 $rs=mysqli_query($lnMysql, @@ -116,11 +120,53 @@ switch($_POST['act']){ if(!preg_match("/^(http|https):\/\//", $_POST['botURL'])){ $alerts.="L'URL n'est pas valide.\n"; } - //******************* TO DO ******************************* - - 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','$1://$2' + ,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{ }