davidlynch
04-16-2008, 08:47 PM
Hi,
Firstly, I'm new to Apache + php world
Having said so, let me show you my problem:
I'm trying to get the REFERRER WEBSITES that visits my site.
Most of my files are written in plain html, so I'm unable to code server side instructions.
So I put this simple javascript code:
<script type="text/javascript">
var url = "js/getreferrer.php";
var ref = document.referrer;
document.write('<script src="', url +'?ref='+ ref, '" type="text/JavaScript"><\/script>');
</script>
the getreferrer.php file just get the origin url and save it to a textfile:
<?php
$myFile = "listofreferrers.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
$referrer = $_GET['ref'];
$stringData = "$referrer\n";
fwrite($fh, $stringData);
fclose($fh);
?>
The result is that EVERY referrer url entry is replaced with the full URL of the page that uses de javascript code,
In english - if I visit my page called "http://site/file1.htm" from a search result on search engine "http://searchengine", my referrer recorded is "http://site/file1.htm" instead of "http://searchengine".
When I use PHP this problem doesn't arise, but I'm unable to use any other format than "html" file
Any help will be highly appreciatted
David
Firstly, I'm new to Apache + php world
Having said so, let me show you my problem:
I'm trying to get the REFERRER WEBSITES that visits my site.
Most of my files are written in plain html, so I'm unable to code server side instructions.
So I put this simple javascript code:
<script type="text/javascript">
var url = "js/getreferrer.php";
var ref = document.referrer;
document.write('<script src="', url +'?ref='+ ref, '" type="text/JavaScript"><\/script>');
</script>
the getreferrer.php file just get the origin url and save it to a textfile:
<?php
$myFile = "listofreferrers.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
$referrer = $_GET['ref'];
$stringData = "$referrer\n";
fwrite($fh, $stringData);
fclose($fh);
?>
The result is that EVERY referrer url entry is replaced with the full URL of the page that uses de javascript code,
In english - if I visit my page called "http://site/file1.htm" from a search result on search engine "http://searchengine", my referrer recorded is "http://site/file1.htm" instead of "http://searchengine".
When I use PHP this problem doesn't arise, but I'm unable to use any other format than "html" file
Any help will be highly appreciatted
David