I am currently working on a way to 'make sure' that data is being sent to a webform from a list of valid http referers. The problem is that it doesnt work exactly as expected.. my initial coding had a logic error in it, however, when i attempt to fix my error the script no longer runs... well it not longer runs via a web interface, the commandline is fine. as it doesnt do http referer checks. can i get some assistence on this as the corner stone of my error is when i remove an else allthings fall apart.
my @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 }
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 matched

jcpunk

by the way thanks for all the help that was, is, and will be


In reply to http referers, if, else and failures by jcpunk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.