Forum Moderators: coopster

Message Too Old, No Replies

Jacks Formail script

How to remove $referrer function

         

plopsybunny

5:56 pm on Mar 17, 2007 (gmt 0)

10+ Year Member



Hi there guys & gals,

I am struggling to implement Jack's Formmail script on a clients server. there is a shared IP which for security reasons will not respond to a ping request and even when entered into the script shows as invalid.

The scripting portions (default code) are shown below:

******************************************

// referers.. domains/ips that you will allow forms to
// reside on.
$referers = array ('example.com','www.example.com','121.0.0.111');

// function to check the referer for security reasons.
// contributed by some one who's name got lost.. Thanks
// goes out to him any way.
function check_referer($referers) {
if (count($referers)) {
$found = false;

$temp = explode("/",getenv("HTTP_REFERER"));
$referer = $temp[2];

if ($referer=="") {$referer = $_SERVER['HTTP_REFERER'];
list($remove,$stuff)=split('//',$referer,2);
list($home,$stuff)=split('/',$stuff,2);
$referer = $home;
}

for ($x=0; $x < count($referers); $x++) {
if (eregi ($referers[$x], $referer)) {
$found = true;
}
}
if ($referer =="")
$found = false;
if (!$found){
print_error("You are coming from an <b>unauthorized domain.</b>");
error_log("[FormMail.php] Illegal Referer. (".getenv("HTTP_REFERER").")", 0);
}
return $found;
} else {
return true; // not a good idea, if empty, it will allow it.
}
}
if ($referers)
check_referer($referers);

**************************

I have commented out the above code and tried deleting it but am still getting the Error message:

**************************

"The form was not submitted for the following reasons:

You are coming from an unauthorized domain.

Please use your browser's back button to return to the form and try again.

This form is powered by Jack's Formmail.php 5.0"

**************************

Any suggestions woud be greatly appreciated - hopefully I am doing something really dumb.

[edited by: dreamcatcher at 9:49 pm (utc) on Mar. 17, 2007]
[edit reason] Use example.com, thanks. [/edit]

cameraman

6:01 pm on Mar 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld!

Try this - just under this line:
function check_referer($referers) {

add:
return(true);

plopsybunny

6:16 pm on Mar 17, 2007 (gmt 0)

10+ Year Member



Thankyou so much for your speedy reply.

However I have to admit that I was even more dumb than normal... I forgot to re-direct the form to the live php script location :*

It is always true of me that I find the answer just as I have given up and asked for help.

thanks for being here for me ;)