Solved

howe do I write the REFERER page into my HTML source code Can this be done with javascript

Posted on 2006-06-27
8
489 Views
Last Modified: 2010-04-20
I have a script called makelog.pl. It is put into an image tag like this
<IMG src="http://www.veretekk.com/cgi-local/makelog.pl?MarketCenter,http://www.veretekk.com/index.html,ledeatjon ">

This is a snippet from the script (makelog.pl)
#==================================================#
# Is the refering page allowed to add to the log ? #
#==================================================#
#&check_url;
#sub check_url {
# if ($ENV{'HTTP_REFERER'}) {
#  foreach $referer (@referers) {
#   if ($ENV{'HTTP_REFERER'} =~ /$referer/i) {
#    $check_referer = 1;
#    last;
#    }
#   }
#  }
#  else {$check_referer = 1;}
#  if ($check_referer != 1) {exit;}
#}

Do I need to append to the script to grab the REFERER url or do I need to use a javascript to put the REFERER into the source code in the IMAGE URL?

Thomas
0
Comment
Question by:veretekk
  • 3
  • 3
  • 2
8 Comments
 
LVL 51

Assisted Solution

by:ahoffmann
ahoffmann earned 250 total points
ID: 16999627
the referer is set by the browser in the HTTP header and most likely removed by proxies for privacy reasons ;-)
You cannot access it by active scripting for security reason (except you have a buggy browser).
You need to use your own form (hidden) fields to store the refere link.
If you want to have a reliable referer field (if hidden or not) you need to sign it, otherwise it can be changed to whatever I want.
0
 
LVL 8

Accepted Solution

by:
RWJDCom earned 250 total points
ID: 17021524
Are you just trying to display the users REFERER on your web site?  If that's all your trying to do you can do that you can do it several ways...

.shtml
<input type="hidden" name="referer" value="<!--#echo var="HTTP_REFERER" -->">

.php
<input type="hidden" name="referer" value="<?=$HTTP_REFERER; ?>">

And for the data to be posted back to a logger as such you would just post the form back.  Otherwise if you just want to log it to a DB the code you pasted above is correct.  IF this is not what your trying to do you need to explain your question a little better, it's a bit difficult to understand what your trying to do.
0
 

Author Comment

by:veretekk
ID: 17021923
I figuered it out, thanks.

Clicking on this link http://www.wavefour.com/earthsmart/ takes you to a test page with this code on it:

<script language='Javascript'>if(document.referrer&&document.referrer!='')document.write('<img src=http://www.veretekk.com/cgi-local/makelog.pl?WAVEFOURearthsmart,http://www.wavefour.com/earthsmart/,thomas09,'+document.referrer+'>');</script>

Which uses the javascript to add the refferer's url into the graphic source pagelog.pl link.

I don't really know what I am doing, but it worked.

Thomas
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 8

Expert Comment

by:RWJDCom
ID: 17022094
Ohh..  I didn't know you were just trying to write the referrer information to the webpage to show in a link...  You don't have to go through all of that JavaScript programming to do that, if your website is a PHP page all ou need to do is put:

<img src="blah.pl?referrer=<?=$HTTP_REFERER; ?>">

That will cause the referrer information to be displayed without even having any JavaScript code on your main page.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 17022858
RWJDCom, how would you get $HTTP_REFERER; in your PHP script if it was not send by the browser for any reason?
0
 
LVL 8

Expert Comment

by:RWJDCom
ID: 17023805
Good question ahoffmann...  I'm not sure how you would accomplish that.  If the browsers not sending it then obvisouly you cannot use it.  :(
0
 

Author Comment

by:veretekk
ID: 17024806
I am making this refferer link for our subscribers to use on sites not under our control. We use PHP and have it set so PHP runs from HTML as well. If that was the only need for this script that is what we would do (<?php  echo $_SERVER['HTTP_REFERER'];?>).

But we have subscribers that use our tracking system, therefore I needed to make a script that could be used in most cases not depending on SSI or PHP on other sites and servers.

It seems to work for the most part. I am still in final BETA testing it. It still is not totally dependable.

This link:
http://www.wavefour.com/earthsmart/index.html
Has the script in it, but when I click on it from here, it is not picking it up. From other sites I have put this link it is picking it up.

Grrrrrrr.

Tom
0
 

Author Comment

by:veretekk
ID: 17024863
I am just putting this link here to test the PHP refferer to one of our server pages.
http://thomas09.etracking.net/

I want to see if the PHP refferer picks up this site when it is cliked on.

Please excuse my typing, I just came down with Bell's Paulsy and I feel like Quasimoto.

Tom
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

749 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