This is a script to stop leechers stealing images from your server. Designed for those who have limited bandwidth and don't want to waste it decorating somebody else's web site.
Instead of linking to images directly, you link through the script, which upon request will verify that the referrer (the requesting web-site) is yours, or blank (optional).
The script is available in a zip file that contains the script and example HTML pages.
php_get_image.zip (26kb)
The following explains how to use this script on your own site:
See the sample file for a working example.
Note: Images do not need to be in a public location on the server, just so long as PHP can access them.
Tells the script where to get the images from. The parameter is relative to the location of the script.
The image directory does not need to be publicly accessible from the web server, it can be in any location that PHP can access. You can use ../ to access parent directories but note that ../ cannot be used in the filename parameter.
Specifies the name of the parameter to get the filename from.
For example, in the default configuration, this is set to 'f', so you would use 'get_image?f=filename.jpg'. If you changed it to 'file' then you would ues 'get_image?file=filename.jpg'. This parameter is case sensitive.
Specifies the file to use when a request comes from a non-allowed source.
Specifies which referers are valid. You can specify as many referers as you wish, just separate them with commas like below.
$allowed_refs = array ( "www.website1.com", "www.website2.com", "www.website3.com" );
Specifies whether an image should be shown when there isn't a referer present. I recommend setting this to true (default) as some users have their browser/personal firewall set to block the referring URL.