It appears as though random.php is not on the server (or at least in the link you posted above). Also, I noticed the following error in your code (which you posted above); and it is highlighted below in red.
Code:
<?php
function _local_replace_bad($value) {
# mail adress(ess) for reports...
$report_to = "sales@mydomain.co.uk"; // REPORT EMAIL, THIS CAN BE YOUR EMAIL ADDRESS
# array holding strings to check, we do not trust these strings in $_POST
$suspicious_str = array
(
"content-type:"
,"charset="
,"mime-version:"
,"multipart/mixed"
,"bcc:"
);
$suspect_found = false;
// remove added slashes from $value...
$value = stripslashes($value);
# checks if $value contains $suspect...
foreach($suspicious_str as $suspect) {
if(eregi($suspect, strtolower($value))) {
# if we found some suspicios string, then we add our string, so it
# will be messed a little bit. :)
$suspect_found = true;
$value = eregi_replace($suspect, "(anti-spam-".$suspect.")", $value);
}
}
if ($suspect_found) {
# if at least one suspicios string was found, then do something more
$ip = (empty($_SERVER['REMOTE_ADDR'])) ? 'empty' : $_SERVER['REMOTE_ADDR'];
$rf = (empty($_SERVER['HTTP_REFERER'])) ? 'empty' : $_SERVER['HTTP_REFERER'];
$ua = (empty($_SERVER['HTTP_USER_AGENT'])) ? 'empty' : $_SERVER['HTTP_USER_AGENT'];
$ru = (empty($_SERVER['REQUEST_URI'])) ? 'empty' : $_SERVER['REQUEST_URI'];
$rm = (empty($_SERVER['REQUEST_METHOD'])) ? 'empty' : $_SERVER['REQUEST_METHOD'];
# very often HTTP_USER_AGENT is empty. We consider this is 100% spam
if ($suspect_found && $ua == "empty") {
exit();
}
# if we are here, then HTTP_USER_AGENT is not empty. this is only 80-90% that it is spam
# Remember, that POST values were already changed. But we still want to inform our
# admin about this suspicios request.
if(isset($report_to) && !empty($report_to)) {
@mail(
$report_to,
"[ABUSE] [SUSPECT] @ " . $_SERVER['HTTP_HOST'] . " by " . $ip,
"Stopped possible mail-injection @ " .
$_SERVER['HTTP_HOST'] . " by " . $ip .
" (" . date('d/m/Y H:i:s') . ")\r\n\r\n" .
"*** IP/HOST\r\n" . $ip . "\r\n\r\n" .
"*** USER AGENT\r\n" . $ua . "\r\n\r\n" .
"*** REFERER\r\n" . $rf . "\r\n\r\n" .
"*** REQUEST URI\r\n" . $ru . "\r\n\r\n" .
"*** REQUEST METHOD\r\n" . $rm . "\r\n\r\n" .
"*** SUSPECT\r\n-----\r\n" . $value . "\r\n-----"
);
} # if report
} # if suscpect found
else {
return($value);
}
}
# what we do - is we simply check all posted values.
foreach($_POST as $f=>$v) {
$_POST[$f] = _local_replace_bad($v);
}
# if register_globals is set to "on", then we should overwrite them once again.
if (ini_get("register_globals") == 1)
extract($_POST, EXTR_OVERWRITE);
function checkOK($field)
{
if (eregi("BCC",$field) || eregi("CC",$field)){
header( "Location: m_error.html" ); // ERROR REDIRECT IF THERES AN INJECTION ATTEMPT
}
}
$email = $_POST['email'];
$name = $_POST['name'];
$message = $_POST['message'];
$address = $_POST['address'];
$mobile = $_POST['mobile'];
$phone = $_POST['phone'];
$options = $_POST['options'];
$ipaddress = $_SERVER['REMOTE_ADDR'];
$message = 'Name: ' . $name . "\n" .
'Address: ' . "\n" . $address . "\n\n" .
'Phone: ' . $phone . "\n" .
'Mobile: ' . $mobile . "\n" .
'options: ' . $options . "\n\n" .
'Message:' . "\n\n" . $message . "\n" .
'IP Address:' . "\n\n" . $ipaddress;
/////////////// I ADDED DEPTS, SO YOU CAN SEND MAIL TO DIFFERENT PLACES ////////
$dept = $_POST['dept'];
checkOK($dept);
if ($dept == 'sales') {
$email_address = 'sales@mydomain.co.uk'; // CHANGE TO EMAIL DESTINATION OR LEAVE BLANK
} else if ($dept == 'aftersales') {
$email_address = 'sales@mydomain.co.uk'; // CHANGE TO EMAIL DESTINATION OR LEAVE BLANK
} else {
$email_address = 'sales@mydomain.co.uk'; // CHANGE TO MAIN EMAIL DESTINATION
}
$subject = 'Web Enquiry'; // CHANGE TO SUBJECT OF EMAIL
/* //////// TEST JUST TO CHECK EMAIL HASNT BEEN TAMPERED WITH /////////////// */
/* //////// LOCATION REDIRECTS BACK TO A MESSAGE IF EMAIL IS MISSING ///////// */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
header( "Location: m_error.html" );
} else {
$string .= $subject;
$mailheaders = "From: $email <$email>";
mail($email_address, $string, $message, $mailheaders);
header( "Location: m_sent.html" ); // SUCCESS, EMAIL WAS SENT, LET THE USER KNOW
}
?>
Other than those things, every looks like it should work fine.
Hope this helps.
Bookmarks