?
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
Medium Priority
?
504 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 51

Assisted Solution

by:ahoffmann
ahoffmann earned 500 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 500 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
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.

 
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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

762 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