Forum Moderators: coopster

Message Too Old, No Replies

how to stop other sites linking my script?

without using .htaccess

         

stevieWonders

6:13 pm on Sep 10, 2005 (gmt 0)

10+ Year Member



Hi, new here

I have created a php script that serves up images based on user text input. How do I limit access to the script to those that are using the script on my server/site? Right now anyone can call the script from anywhere which is going to eat my bandwidth.

I have tried doing .htaccess restrictions

//ErrorDocument 404 /index.htm
// SetEnvIfNoCase Referer "^http://myURL" local_ref=1
// <FilesMatch "\.(php)">
// Order Allow,Deny
// Allow from env=local_ref
// </FilesMatch>

Works fine but referrer can be turned off on users machine .. private headers disabled by firewall etc: which causes a broken link on my site.

So, anyone know how the php script itself can check if the call to the script is originating from my server?

encyclo

6:25 pm on Sep 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to the forums stevieWonders.

Have you tried setting a session cookie on your site pages (but not by your script) and checking for the presence of that cookie before generating the image?

stevieWonders

7:32 pm on Sep 10, 2005 (gmt 0)

10+ Year Member



Sometimes... a problem seems so big that it must involve a big solution .. and then someone slaps you with a simple solution and you go .. well Duh!

Thanks encyclo :)