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
480 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 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