Jump to content

Archived

This topic is now archived and is closed to further replies.

ryanh_106

Stop Unauthorised Use

Recommended Posts

Ok heres an interesting one,

I want to stop people using my php image generation script by doing view > source and find path to the script.

My images are created by a php script using GD so the code is

<img src="genpic.php?path=encryptedpath&size=thumbnail" />

Now when i do other include files i have a condition at the top saying if(!defined('INMYSITE')) die("stop using my stuff") to make sure it is only used as an include (obviously the constant is defined in my site somewhere). I would like to do something similar if possible with my image creation script, so it cant by used by typing the address in the address bar, only from within an image tag.

Is this possible?

Any ideas are appreciated

Share this post


Link to post
Share on other sites
[!--quoteo(post=364471:date=Apr 13 2006, 12:29 PM:name=Ryan Heath)--][div class=\'quotetop\']QUOTE(Ryan Heath @ Apr 13 2006, 12:29 PM) [snapback]364471[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Ok heres an interesting one,

I want to stop people using my php image generation script by doing view > source and find path to the script.

My images are created by a php script using GD so the code is

<img src="genpic.php?path=encryptedpath&size=thumbnail" />

Now when i do other include files i have a condition at the top saying if(!defined('INMYSITE')) die("stop using my stuff") to make sure it is only used as an include (obviously the constant is defined in my site somewhere). I would like to do something similar if possible with my image creation script, so it cant by used by typing the address in the address bar, only from within an image tag.

Is this possible?

Any ideas are appreciated
[/quote]
use:
$_SERVER['PHP_SELF']

Share this post


Link to post
Share on other sites
You could use $_SERVER['HTTP_REFERER'] to determine where they're coming from. Your script can verify that the referrer is your server and let the data go. If they type the address directly in their browser window, or hotlink from elsewhere, it won't let them have it.

a word of warning, though. I don't believe all browsers support the referer feature. So doing this might lock out folks with obscure browsers.

Share this post


Link to post
Share on other sites
I dont seem to have anything to do with HTTP_REFERRER on my server! looked through server variables on phpinfo and its not there, tried to work with script names and request URI but with no success, all seem to just refer to the image making scripts, any more ideas?

Share this post


Link to post
Share on other sites
that's the exact code...

$_SERVER['HTTP_REFERER']

you can see what's there by echoing it.

echo $_SERVER['HTTP_REFERER'];

that should tell you what page referred the visitor to your script. It should return something like:

[a href=\"http://www.example.com/page.html\" target=\"_blank\"]http://www.example.com/page.html[/a]


you can read about the pitfalls I had previously described at the PHP site.
[a href=\"http://us2.php.net/manual/en/reserved.variables.php\" target=\"_blank\"]http://us2.php.net/manual/en/reserved.variables.php[/a]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.