How to prevent others from using my PHP script?

I have a php script that processes and outputs (displays) an image. I use my PHP script in HTML as follows:

<img src="MyScript.php?Parm1=Value1&Parm2=Value2">

The problem is that I have limited bandwidth on my server and I do not want others to use my script. But, as anyone can see this from the source and use of HTML, and this will be a problem for my server.

Is there a way to prevent others from using it? For example, will the script be executed only from my local server?

+4
source share
1 answer

HTTP referent

HTTP- - HTTP- , - ( URI IRI) . , - , .

. , HTTP-, 99% , , , .

PHP $_SERVER['HTTP_REFERER']. , URL- .

Apache .htaccess RewriteEngine:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://www.yourdomain.com/.*
RewriteRule .*\.php - [NC,F]

Cookies

, . cookie . cookie HTML. script, :

  • ?
  • cookie , ? ,
  • - , , X ? ,

, , HTML.

.

+4

All Articles