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
if(!preg_match("/^(http|https):\/\//", $_POST['botURL'])){
$alerts.="L'URL n'est pas valide.\n";
if (!preg_match("/^(http|https):\/\//", $_POST['botURL'])){
$alerts.="L'URL n'est pas valide.\n";
}
//email => doit être valide
@ -120,53 +120,67 @@ switch($_POST['act']){
$err.="Un bot du même nom existe déjà";
}
//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";
}
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,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(),
'".$secret."',
'".mysqli_real_escape_string($lnMysql,$_POST['email'])."'"
);
//send e-mail
include __DIR__."/config.php";
//save bot on temp table
$secret=rand_str(8, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890');
if( $_POST['botURL'] == "" ){
$rs=mysqli_query($lnMysql,
"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{
$botUrl = $_POST['botURL'];
}
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';
$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!";
}
$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!";
}
@ -178,7 +192,7 @@ switch($_POST['act']){
break;
default:
error(500,"erf");
error(404,"erf");
break;
}