[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
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
?
515 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
Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

 
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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

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…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

656 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