By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,949 Members | 1,554 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,949 IT Pros & Developers. It's quick & easy.

Information from referring page

P: n/a
Suppose I call an image creating script from an html doc like so:

<img src="http://www.example.com/imagescript.php">

How can I tell the URL of the document requesting the image?

I thought it would be $url = $_SERVER['HTTP_REFERER']; but this doesn't
seem to work
--
Regards,

Geoff Berrow
Jun 27 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
..oO(Geoff Berrow)
>Suppose I call an image creating script from an html doc like so:

<img src="http://www.example.com/imagescript.php">

How can I tell the URL of the document requesting the image?

I thought it would be $url = $_SERVER['HTTP_REFERER']; but this doesn't
seem to work
You can't do it with the HTTP referrer, because it is highly unreliable
and should never be relied upon. It can be faked and often enough it's
not available at all.

Dependent on what you're trying to do, you could append a query string
to the image script containing an ID or the name of the current page:

<img src="http://www.example.com/imagescript.php?page=42">

Then your script knows where the request most likely came from.

Just an idea.

Micha
Jun 27 '08 #2

P: n/a
Message-ID: <3m********************************@4ax.comfrom Michael
Fesser contained the following:
>Dependent on what you're trying to do, you could append a query string
to the image script containing an ID or the name of the current page:

<img src="http://www.example.com/imagescript.php?page=42">

Then your script knows where the request most likely came from.
Yes, I've done it like that and it works, but it's not so tidy.

I'm trying to recreate something like this page rank checker
http://pr.blogflux.com/ more out of curiosity more than anything.

I already have
<img src="http://www.ckdog.co.uk./pagerank/pr2.php?url=your_url_here>
working.

--
Regards,

Geoff Berrow
Jun 27 '08 #3

P: n/a
Geoff Berrow wrote:
Message-ID: <3m********************************@4ax.comfrom Michael
Fesser contained the following:
>Dependent on what you're trying to do, you could append a query string
to the image script containing an ID or the name of the current page:

<img src="http://www.example.com/imagescript.php?page=42">

Then your script knows where the request most likely came from.

Yes, I've done it like that and it works, but it's not so tidy.

I'm trying to recreate something like this page rank checker
http://pr.blogflux.com/ more out of curiosity more than anything.

I already have
<img src="http://www.ckdog.co.uk./pagerank/pr2.php?url=your_url_here>
working.

Unfortunately, Micha beat me to it and he's correct. HTTP_REFER is not
reliable, and, in fact, some firewalls strip it on purpose for security
reasons.

The bottom line is, you can't tell who's requesting it. All you can
really tell for sure are the URI being requested and the IP your server
is supposed to send it to. Nothing else is really accurate.

As to what they're doing - it looks like they're tying into Google's
page rank APIs. I've never done it (not worth the effort, IMHO), but
you can check the Google site to see how to do it.

But if all you want is the page rank, the Google toolbar (for your
browser) does it much better.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 28 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.