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
469 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 8

Expert Comment

by:RWJDCom
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

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…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

12 Experts available now in Live!

Get 1:1 Help Now