Forum Moderators: coopster

Message Too Old, No Replies

Retrieve the Remote Referer via Readfile(URL)

Is it possible?

         

Simsi

11:25 pm on May 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi All

A problem...I have content which users retrieve from my server using readfile("http://www.mysite/myfile.txt"). Now I want to log the referer to gather stats on who's calling it.

I've done a RewriteRule to pass the .txt call above through a php script which passes back the data. Works fine. I was hoping in the PHP I could reference $_SERVER['HTTP_REFERER'] to log the calls, but I can't...it doesn't seem to capture it. As an aside, I can get the HOST of the refering site, but that's not much good if it's on a shared server.

I tried another method - instead of readfile() using include_once() - worked as far as getting the content over, but same problem - unable to track the referer.

Is there a way?

I don't want to pass it over manually as obviously users could manipulate it.

Many thanks in anticipation.

Ian

[edited by: Simsi at 11:27 pm (utc) on May 26, 2008]

Zipper

8:54 am on May 27, 2008 (gmt 0)

10+ Year Member



Were you calling the text file directly? HTTP_REFERER always returns empty unless it's referred from a link. Regardless, it's often manipulated by browsers so you cannot rely on its accuracy.

Simsi

9:20 am on May 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes it's direct in that it's effectively an "include" within the page on the remote server. So what you say explains why its not going over.

Is there any alternative way of achieving this?