Jump to content

Stop Unauthorised Use


ryanh_106

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
Link to comment
https://forums.phpfreaks.com/topic/7325-stop-unauthorised-use/
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']
Link to comment
https://forums.phpfreaks.com/topic/7325-stop-unauthorised-use/#findComment-26685
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.
Link to comment
https://forums.phpfreaks.com/topic/7325-stop-unauthorised-use/#findComment-26881
Share on other sites

  • 2 weeks later...
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]
Link to comment
https://forums.phpfreaks.com/topic/7325-stop-unauthorised-use/#findComment-30192
Share on other sites

Archived

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

×
×
  • Create New...

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.