ryanh_106 Posted April 13, 2006 Share Posted April 13, 2006 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 More sharing options...
lead2gold Posted April 13, 2006 Share Posted April 13, 2006 [!--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 More sharing options...
michaellunsford Posted April 14, 2006 Share Posted April 14, 2006 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 More sharing options...
ryanh_106 Posted April 24, 2006 Author Share Posted April 24, 2006 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 https://forums.phpfreaks.com/topic/7325-stop-unauthorised-use/#findComment-30183 Share on other sites More sharing options...
michaellunsford Posted April 24, 2006 Share Posted April 24, 2006 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.