Solved

getting referring page

Posted on 2002-06-01
4
361 Views
Last Modified: 2012-06-27
This isn't REALLY a Perl question.  More of a 'script-calling' question.  I wrote a perl script that gets the $ENV{'HTTP_REFERER'} of the referring page and writes it to a database.  It's to keep track of where my visitors are coming from.  It works fine and dandy as I have written it.  Now the problem is that I'm not sure how to call my script from my web page.  I tried to put it in a cheezie tag like so: <img src="/cgi-bin/track.pl" width=0 height=0 border=0>.

The problem is that the script uses the page (my page) that the <img...> tag is on as the referer and not the page that the user came from in the first place.

To clarify:
Let's say my page is http://mysite.com/mypage.html  and the user comes from http://xyzsite.com/theirpage.html.  The referer variable in my script that I call from mypage.html should contain the string 'http://xyzsite.com/theirpage.html'.  How can I call my script from mypage.html so that it tricks my script into considering xyzsite.com's page as the referring page??
0
Comment
Question by:GorGor1
4 Comments
 
LVL 7

Accepted Solution

by:
yoren earned 50 total points
ID: 7049338
You can't do that directly. I'd suggest making mypage.html a dynamic page (CGI, etc.). You can then set a cookie (or dynamically add a CGI script parameter) equal to the referring site. Your script can then reference the cookie or CGI parameter instead of HTTP_REFERRER.
0
 
LVL 8

Expert Comment

by:jhurst
ID: 7065414
I partially aggree with the previos and differ too.  I would avoid the cookie if you can.

When I have needed to do this or other things, such as show different pages depending on the browser being used, what I have done is ensured that there is no page:

http://www.mySite.com/myPage.html

Then I have created an error404 script that will be invoked when any non-found happens.  In this page I check and see if the requested page was myPage.html.  If it was, then I do the logging, or whatever else and then transmit the page, which us now stored as something like myPage.html.x.
0
 

Expert Comment

by:rrbf
ID: 7069993
Your solution isn't that 'cheezie'. many do use it.
The more classical solution is to setup .html
as an SSI (server side include) to include the script with an <!--#include ... -->
if html extensions are not SSI enabled and you want to stick
to a .html rather than a .cgi or .pl or .shtml
you can do that in .htaccess with this line:
AddHandler server-parsed .shtml .html

check http://httpd.apache.org/docs/mod/mod_include.html
ssi are installed and enabled by default in most apache installs.
0
 
LVL 1

Author Comment

by:GorGor1
ID: 7070145
I can't use .htaccess because I'm not using apache.  I'm using IIS in win2k.  I found a solution and I'm working with it now.  I'll post the solution and accept an answer when I'm done.  Thanks!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now