Location: PHPKode > scripts > Image Hotlink Log and Control > readme.txt
Hotlink Log and Image Watermarking Script
Copyright (C) 2005  SillyJokes.co.uk

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA


//// DESCRIPTION

This collection of scripts allows you to control and monitor the hotlinking of images
from your webserver, i.e. what happens when someone displays an image from your web server
on their web site by linking directly to it instead of hosting the image on their server.

Based on string searches inside the referrer (who is leeching the images) you can block, 
watermark, substitute, or simply pass through images with no alteration. The image
watermark is a piece of text that is written onto the image to mark it as yours.

You can view a report on which images are being hotlinked from your site, and by whom.
This report can be used to determine your hotlinking policy.

NOTE: These scripts support jpeg and gif files only.

//// REQUIREMENTS

In order to use this collection of scripts, you need to be using Apache as your webserver, 
with PHP installed and the mod_rewrite Apache module enabled. Please refer to the Apache documentation
or ask your hosting company to enable mod_rewrite. Your version of PHP should be at least 4.0 
and should have the basic graphics library installed. A very basic grasp of PHP will make this
easier to set up.


//// INSTALLATION

First of all, decide which directory on your server will contain the php scripts, and
which directory will contain the log files. Upload the php files to your chosen directory,
after editing hotlinklogconfig.php to suit your needs. Make sure that the directory
specified for the log files exists, and set up your watermarking captions- look for
$watermarksettings near the bottom of the file.

A default substitute image is provided in the package and should be copied to the same
directory as the php scripts. If you're planning to use image substitution then you will
most likely want to use your own image.

Next you need to set up the .htaccess file in your images directory, which will
be used by the mod_rewrite Apache module. This will divert image requests that are not from
your server through the image processing script.  There is an example .htaccess file included
in the package, which is named ht.access because Windows computers have problems with filenames
that start with a period. Add your domain names and any other domains which are allowed to
hotlink your images to this file, but bear in mind that this file is used every time a file is
accessed in the directory where it lives and all subdirectories, so don't make it too big.

Once you have set this file up and ftp'ed it to your images directory,
rename it to .htaccess (or whatever you have configured your .htaccess files to be named).
Examine this .htaccess file and modify it to suit your domain(s),and the location of
the PHP scripts. The .htaccess file will affect every subdirectory below the one in which it's
installed. If you have certain subdirectories which you do not want to be processed (for example,
banners or link buttons) then put an .htaccess file in those subdirectories which just contains
the following line:

RewriteEngine off

If you don't understand how .htaccess files and mod_rewrite work then I strongly recommend that
you read some of the documentation that is readily available on the internet.

If you have more than one directory that you wish to control hotlinking in, simply add another
copy of the .htaccess file there. It is inadvisable to put the .htaccess file in your web root
directory as this will process many more files than necessary.

As soon as the .htaccess file is in place, image processing will start, so make sure everything
else is set up first.

If you wish to stop loggin and processing hotlinked images, simply delete the .htaccess file
from your server.


//// REPORTS

Open hotlinklog.php in a browser to see your hotlinking stats. Click on a referrer domain to see
a list of images hotlinked by that domain, and the pages that link to the images. Log events
older than ENTRYTIMELIMIT in hotlinklogconfig.php will not be processed. By default, this time
limit is quite short, if your site doesn't have too much traffic then feel free to extend this
time limit.

The counter on the main hotlink stats page never resets. If you want to reset this counter, 
delete it from your server. It's file name is defined by COUNTERFILE in hotlinklogconfig.php.

To limit the size of the log file, you may wish to periodically flush old entries. Open 
hotlinklogflush.php in a browser to remove any entries that are older than FLUSHTIME, 
defined in hotlinklogconfig.php.

Return current item: Image Hotlink Log and Control