jcpunk has asked for the wisdom of the Perl Monks concerning the following question:
while i realize that this sort of check is more formality then effective (as even wget can spoof around this these days) it is a mandate for the project... so any assistance would be helpful in this. the basic goal is to make as few changes to the existing code as possible while making it actually check the reffering URLs, my logic error consisted of the fact that if the 1st thing in the list did not succeed then the whole function failed which is not the goal. but that isnt what i want to happen, just failure if none of the possibles are matchedmy @referers = ('$ips'); ... if ($#ARGV < 0) { $ENV{'REQUEST_METHOD'} =~ tr/[a-z]/[A-Z]/; if ($ENV{'REQUEST_METHOD'} eq 'POST') { if(&check_url) { #get data from the web via Cgi.pm } } else { #if it didnt come with data then it needs a form to get it &form; } } .... sub check_url { if ($ENV{'HTTP_REFERER'}) { my $referer; foreach $referer (@referers) { if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i +) { return 0; } else #the else { #spoken of return 1; # above } #consists of these 4 lines } } html_start("ERROR!"); #the two lines i want to run report_error("ERROR","Source check failed"); #if invali +d referer }
by the way thanks for all the help that was, is, and will be
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: http referers, if, else and failures
by grep (Monsignor) on Jun 24, 2003 at 21:23 UTC | |
|
Re: http referers, if, else and failures
by waswas-fng (Curate) on Jun 24, 2003 at 21:53 UTC | |
by YAFZ (Pilgrim) on Jun 25, 2003 at 21:40 UTC | |
by waswas-fng (Curate) on Jun 26, 2003 at 03:24 UTC | |
|
Re: http referers, if, else and failures
by Tomte (Priest) on Jun 24, 2003 at 21:10 UTC |