Jump to content


Photo

Stop Unauthorised Use


  • Please log in to reply
4 replies to this topic

#1 ryanh_106

ryanh_106
  • Members
  • PipPipPip
  • Advanced Member
  • 48 posts

Posted 13 April 2006 - 04:29 PM

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

#2 lead2gold

lead2gold
  • Members
  • PipPipPip
  • Advanced Member
  • 164 posts
  • LocationOttawa, On

Posted 13 April 2006 - 05:52 PM

[!--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) View Post[/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']

#3 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 14 April 2006 - 05:34 AM

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.

#4 ryanh_106

ryanh_106
  • Members
  • PipPipPip
  • Advanced Member
  • 48 posts

Posted 24 April 2006 - 05:26 PM

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?

#5 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 24 April 2006 - 05:37 PM

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]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users