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
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
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
Share on other sites

  • 2 weeks later...
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?
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.