have a look for yourself, <REMOVED> (feel free to send emails)
dont enter in the visual code (or enter it incorrectly) (or correctly) and see how all hell breaks loose (the loops of death!) where it should just pop-up with (one) an error message.
Code (mail.php)
[PHP]<?php
$subject = $_POST['subject'];
$message = $_POST['message'];
include 'config.inc.php ';
function alert_redirect( $alert) {
echo "
<html>
<head>
<script language='Javas cript'>
<!--
alert ('$alert')
window.location = '$homepage'
//-->
</script>
<title>$alert </title>
</head>
<body>
<div align='center'>
<h1>$alert</h1>
<form id='' name='' method='post' action='$homepa ge'>
<input type='submit' name='' id='' value='OK' />
</form>
</div>
</body>
</html>
";
}
require_once('r ecaptchalib.php ');
$resp = null;
$error = null;
$publickey = "__REMOVED_ _";
$privatekey = "__REMOVED_ _";
if ($_POST['recaptcha_resp onse_field']) {
$resp = recaptcha_check _answer ($privatekey,
$_SERVER['REMOTE_ADDR'],
$_POST['recaptcha_chal lenge_field'],
$_POST['recaptcha_resp onse_field']);
if ($resp->is_valid) {
} else {
alert_redirect( 'Please re-enter your reCAPTCHA visual identification code.');
exit();
}
}
session_start() ;
if(isset($_SESS ION['LastSent']))
{
if( $_SESSION['LastSent'] > (time() - $delay) )
{
alert_redirect( "You have sent a message in the last $delay seconds. Please wait $delay seconds until trying again.");
exit();
}
}
if( empty($subject) )
{
alert_redirect( 'Your message contained no subject.');
exit();
}
elseif( empty($message) )
{
alert_redirect( 'Your message contained no body.');
exit();
}
elseif (mail($to, $subject, $message, $headers))
{
$_SESSION['LastSent'] = time();
alert_redirect( 'Message sent.');
die();
} else {
alert_redirect( 'Error sending message.');
exit();
}[/PHP]
Code (config.inc.php )
[PHP]<?php
// Edit the below variables but do NOT remove the ' , " , : or ;
// $to - Who the script sends the emails to.
// $homepage - The place in which the script redirects the sender after the error/success message.
// $headers -- From: - Who the email says it is from.
// Reply-To: - Who the email says you should reply to.
// $delay - Amount of time (in seconds) until the sender can send another email. Prevents spamming.
// $publickey - Your reCAPTCHA public key, required to use the visual code confirmation function
// $privatekey - Your reCAPTCHA private key, required to use the visual code confirmation function
// **Get a public and private reCAPTCHA key free from http://recaptcha.net/api/getkey**
$to = '__REMOVED__';
$homepage = '__REMOVED__';
$headers =
"From: noreply@atyndal l.co.nr"
. "\r\n" .
"Reply-To: noreply@atyndal l.co.nr";
$delay = 180;
?>[/PHP]
What is wrong with this script, what code needs to be fixed/changed/deleted?
dont enter in the visual code (or enter it incorrectly) (or correctly) and see how all hell breaks loose (the loops of death!) where it should just pop-up with (one) an error message.
Code (mail.php)
[PHP]<?php
$subject = $_POST['subject'];
$message = $_POST['message'];
include 'config.inc.php ';
function alert_redirect( $alert) {
echo "
<html>
<head>
<script language='Javas cript'>
<!--
alert ('$alert')
window.location = '$homepage'
//-->
</script>
<title>$alert </title>
</head>
<body>
<div align='center'>
<h1>$alert</h1>
<form id='' name='' method='post' action='$homepa ge'>
<input type='submit' name='' id='' value='OK' />
</form>
</div>
</body>
</html>
";
}
require_once('r ecaptchalib.php ');
$resp = null;
$error = null;
$publickey = "__REMOVED_ _";
$privatekey = "__REMOVED_ _";
if ($_POST['recaptcha_resp onse_field']) {
$resp = recaptcha_check _answer ($privatekey,
$_SERVER['REMOTE_ADDR'],
$_POST['recaptcha_chal lenge_field'],
$_POST['recaptcha_resp onse_field']);
if ($resp->is_valid) {
} else {
alert_redirect( 'Please re-enter your reCAPTCHA visual identification code.');
exit();
}
}
session_start() ;
if(isset($_SESS ION['LastSent']))
{
if( $_SESSION['LastSent'] > (time() - $delay) )
{
alert_redirect( "You have sent a message in the last $delay seconds. Please wait $delay seconds until trying again.");
exit();
}
}
if( empty($subject) )
{
alert_redirect( 'Your message contained no subject.');
exit();
}
elseif( empty($message) )
{
alert_redirect( 'Your message contained no body.');
exit();
}
elseif (mail($to, $subject, $message, $headers))
{
$_SESSION['LastSent'] = time();
alert_redirect( 'Message sent.');
die();
} else {
alert_redirect( 'Error sending message.');
exit();
}[/PHP]
Code (config.inc.php )
[PHP]<?php
// Edit the below variables but do NOT remove the ' , " , : or ;
// $to - Who the script sends the emails to.
// $homepage - The place in which the script redirects the sender after the error/success message.
// $headers -- From: - Who the email says it is from.
// Reply-To: - Who the email says you should reply to.
// $delay - Amount of time (in seconds) until the sender can send another email. Prevents spamming.
// $publickey - Your reCAPTCHA public key, required to use the visual code confirmation function
// $privatekey - Your reCAPTCHA private key, required to use the visual code confirmation function
// **Get a public and private reCAPTCHA key free from http://recaptcha.net/api/getkey**
$to = '__REMOVED__';
$homepage = '__REMOVED__';
$headers =
"From: noreply@atyndal l.co.nr"
. "\r\n" .
"Reply-To: noreply@atyndal l.co.nr";
$delay = 180;
?>[/PHP]
What is wrong with this script, what code needs to be fixed/changed/deleted?
Comment