Forum Moderators: coopster & phranque

Message Too Old, No Replies

http_referer for downloads

         

suzikz

2:20 am on Aug 14, 2003 (gmt 0)

10+ Year Member



Hi!

I found a program in perl that will check the http_referer and now, I have no idea where in HTML I would call this perl program, that would denie any one to get into the page, who doesn't have the right or no http_referer.

Here is the code

#!/usr/bin/perl

@referers=("www.something.com","something1.com");
&check_url;

# Return HTML Page or Redirect User
&return_html;

sub check_url {

# Localize the check_referer flag which determines if user is valid.
local($check_referer) = 0;

# If a referring URL was specified, for each valid referer, make sure
# that a valid referring URL was passed to .

if ($ENV{'HTTP_REFERER'}) {
foreach $referer (@referers) {
if ($ENV{'HTTP_REFERER'} =~ m¦https?://([^/]*)$referer¦i) {
$check_referer = 1;
last;
}
}
}
else {
$check_referer = 1;
}

# If the HTTP_REFERER was invalid, send back an error.
# It is possible that the referrer variable was simply not available for a variety of reasons.

if ($check_referer!= 1) {
print "Bad Referrer - Merchant should put in code to write to a log or mail themselves a
note to verify order was billed in something.com system"; }
}

***********************
What would be the code in HTML and where and is anything missing in my program?

Thank you for your help.

Suzi
suzi@stmdesigning.com

Key_Master

2:53 am on Aug 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can do the same thing with less code using SSI. Just change the referrer and insert the following code in your page. Requires SSI.

<!--#if expr="${HTTP_REFERER} != /^http://www.example.com/path/filename.ext$/" -->
<p>Bad Referrer - Merchant should put in code to write to a log or mail themselves a note to verify order was billed in something.com system</p>
<!--#endif -->

<!--#if expr="${HTTP_REFERER} = /^http://www.example.com/path/filename.ext$/" -->
<p>Good Referrer</p>
insert additional html here...
<!--#endif -->

suzikz

12:48 am on Aug 17, 2003 (gmt 0)

10+ Year Member



I am really lost. Can you help me how do I do that, step by step.

Thank you

Suzi

Fischerlaender

11:05 am on Aug 28, 2003 (gmt 0)

10+ Year Member



I have no idea where in HTML I would call this perl program

You don not call a perl program from within HTML. To let this work you have to set a link from an HTML page to this specific program. This program then delivers the appropriate HTML code to the browser, according to the rules you are using in the program.

I strongly recommend to read a little bit about CGI before trying this, because it's not as simple as HTML. Perhaps PHP is an alternative, which would IMO be easier to learn.

netcommr

4:36 pm on Aug 29, 2003 (gmt 0)

10+ Year Member



You don not call a perl program from within HTML

you can with an SSI call.

suzikz, we need to see the entire script to post a solution for you, the &return_html; subroutine is missing.