hide bot url

This commit is contained in:
gnieark 2016-06-09 13:32:34 +02:00
parent 55e25b2201
commit 7a4dc1619e

View File

@ -27,8 +27,8 @@ switch($_POST['act']){
} }
//BotUrl //BotUrl
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";
} }
//email => doit être valide //email => doit être valide
@ -120,53 +120,67 @@ switch($_POST['act']){
$err.="Un bot du même nom existe déjà"; $err.="Un bot du même nom existe déjà";
} }
//BotUrl //BotUrl
if(!preg_match("/^(http|https):\/\//", $_POST['botURL'])){ if(($_POST['botURL'] <> "") && (!preg_match("/^(http|https):\/\//", $_POST['botURL']))){
$alerts.="L'URL n'est pas valide.\n"; $alerts.="L'URL n'est pas valide.\n";
} }
if($err == ""){ if($err == ""){
//save bot on temp table //save bot on temp table
$secret=rand_str(8, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890'); $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,htmlentities($_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(), if( $_POST['botURL'] == "" ){
'".$secret."', $rs=mysqli_query($lnMysql,
'".mysqli_real_escape_string($lnMysql,$_POST['email'])."'" "SELECT url FROM bots
); WHERE game='".mysqli_real_escape_string($lnMysql,$_POST['botGame'])."'
AND id ='".mysqli_real_escape_string($lnMysql,$_POST['botId'])."'"
);
$r=mysqli_fetch_row($rs);
$botUrl = $r[0];
}else{
//send e-mail $botUrl = $_POST['botURL'];
}
include __DIR__."/config.php";
mysqli_query($lnMysql,
" INSERT INTO bots_modifs( name, game, url, description, date_modification, validate_secret, author_email) VALUES (
'".mysqli_real_escape_string($lnMysql,htmlentities($_POST['botName']))."',
'".mysqli_real_escape_string($lnMysql,$_POST['botGame'])."',
'".mysqli_real_escape_string($lnMysql,$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'; require __DIR__.'/PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer; $mail = new PHPMailer;
$mail->isSMTP(); $mail->isSMTP();
//$mail->IsHTML(true); //$mail->IsHTML(true);
//$mail->SMTPDebug = 2; //$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html'; $mail->Debugoutput = 'html';
$mail->Host = $smtpParams['host']; $mail->Host = $smtpParams['host'];
$mail->Port = $smtpParams['port']; $mail->Port = $smtpParams['port'];
$mail->SMTPSecure = $smtpParams['secure']; $mail->SMTPSecure = $smtpParams['secure'];
$mail->SMTPAuth = true; $mail->SMTPAuth = true;
$mail->Username = $smtpParams['username']; $mail->Username = $smtpParams['username'];
$mail->Password = $smtpParams['pass']; $mail->Password = $smtpParams['pass'];
$mail->setFrom($smtpParams['username'], 'Bots Arena'); $mail->setFrom($smtpParams['username'], 'Bots Arena');
$mail->Subject = 'BotsArena'; $mail->Subject = 'BotsArena';
$mail->addAddress($_POST['email']); $mail->addAddress($_POST['email']);
$mail->Body = $lang['E_MAIL_EDIT_BOT']."\n".$siteParam['BASEURL'].'p/editBot/'.$secret."\n".$lang['E_MAIL_ADD_BOT_SIGNATURE']; $mail->Body = $lang['E_MAIL_EDIT_BOT']."\n".$siteParam['BASEURL'].'p/editBot/'.$secret."\n".$lang['E_MAIL_ADD_BOT_SIGNATURE'];
if (!$mail->send()) { if (!$mail->send()) {
error(500,"Mailer Error: " . $mail->ErrorInfo); error(500,"Mailer Error: " . $mail->ErrorInfo);
} else { } else {
//echo "Message sent!"; //echo "Message sent!";
} }
@ -178,7 +192,7 @@ switch($_POST['act']){
break; break;
default: default:
error(500,"erf"); error(404,"erf");
break; break;
} }