   *****************************************************************
   **                                                             **
   **             ___________________________________             **
   **            |                                   |            **
   **            |   [SimonStenhouse.NET] Download   |            **
   **            |___________________________________|            **
   **                                                             **
   **                                                             **
   **  ---------------------------------------------------------  **
   **                                                             **
   **  Author:  Simon Stenhouse                                   **
   **  Date:    02.11.2006                                        **
   **  Version: 1.5                                               **
   **  Website: http://www.simonstenhouse.net/                    **
   **  License: http://www.gnu.org/licenses/gpl.txt               **
   **                                                             **
   **  ---------------------------------------------------------  **
   **                                                             **
   **  Requirements:                                              **
   **                                                             **
   **   - PHP 4 >= 4.3.0 or PHP 5                                 **
   **                                                             **
   **  Features:                                                  **
   **                                                             **
   **   - Easy Installation                                       **
   **   - Limit the speed of downloads                            **
   **   - Supports unlimited file types                           **
   **   - Prevents the leeching of your files                     **
   **   - Flat file system (no database needed)                   **
   **   - Hides the actual location of your files                 **
   **   - Categorise your files for easy management               **
   **   - Show the size of a file in a user friendly way          **
   **   - Show the number of times a file has been downloaded     **
   **   - Logs all downloads as well as leech and hack attempts   **
   **                                                             **
   **  ---------------------------------------------------------  **
   **                                                             **
   **  Installation:                                              **
   **                                                             **
   **   1 Open download.php and adjust the settings in the        **
   **     configuration area as needed.                           **
   **                                                             **
   **   2 Upload download.php to your sites root directory.       **
   **                                                             **
   **   3 Open leech.php, modify it to suit your site, and        **
   **     then upload it to the root of your site.                **
   **                                                             **
   **   4 Open hack.php, modify it to suit your site, and         **
   **     then upload it to the root of your site.                **
   **                                                             **
   **   5 Create a directory named 'data' off of the root         **
   **     and then CHMOD 777 that directory.                      **
   **                                                             **
   **   6 Create a directory named 'hidden' off of the root.      **
   **     NOTE: I advise you to choose a different name for       **
   **     this directory, which is where your downloadable        **
   **     files will hide, and adjust the relevant setting        **
   **     in the configuration area.                              **
   **                                                             **
   **   7 For categories, create subdirectories in your "hidden"  **
   **     directory. Upload the test.txt files to try it out.     **
   **                                                             **
   **  ---------------------------------------------------------  **
   **                                                             **
   **  Resulting Structure:                                       **
   **                                                             **
   **   /download.php                                             **
   **   /leech.php                                                **
   **   /hack.php                                                 **
   **   /data/                                                    **
   **   /hidden/                                                  **
   **   /hidden/test.txt                                          **
   **   /hidden/test/ (category)                                  **
   **   /hidden/test/test.txt                                     **
   **                                                             **
   **  ---------------------------------------------------------  **
   **                                                             **
   **  Usage example:                                             **
   **                                                             **
   **   Download Link                                             **
   **   -------------                                             **
   **                                                             **
   **   There are 3 different ways to have your download links.   **
   **                                                             **
   **    1: This is the original configuration where you just     **
   **       supply the filename as the query string.              **
   **                                                             **
   **   <a href="download.php?test.txt">Download</a>              **
   **                                                             **
   **    2: This is an alternate to the above.                    **
   **       "file" is for the filename.                           **
   **                                                             **
   **   <a href="download.php?file=test.txt">Download</a>         **
   **                                                             **
   **    3: This one requires you to supply two arguments.        **
   **       "file" is for the filename.                           **
   **       "category" is for the category (subdirectory)         **
   **       in which the file is located.                         **
   **                                                             **
   **   <a href="download.php?file=test.txt&category=test">       **
   **    Download</a>                                             **
   **                                                             **
   **                                                             **
   **   File Size                                                 **
   **   ---------                                                 **
   **                                                             **
   **   1: If the file is NOT in a category.                      **
   **                                                             **
   **   <?php echo download_size('test.txt'); ?>                  **
   **                                                             **
   **   2: If the file IS in a category.                          **
   **                                                             **
   **   <?php echo download_size('test.txt', 'category'); ?>      **
   **                                                             **
   **                                                             **
   **   File Count                                                **
   **   ----------                                                **
   **                                                             **
   **   1: If the file is NOT in a category.                      **
   **                                                             **
   **   <?php echo download_count('test.txt'); ?>                 **
   **                                                             **
   **   2: If the file IS in a category.                          **
   **                                                             **
   **   <?php echo download_count('test.txt', 'category'); ?>     **
   **                                                             **
   **                                                             **
   **   See the included 'example.php' file for a more detailed   **
   **   example.                                                  **
   **                                                             **
   **  ---------------------------------------------------------  **
   **                                                             **
   **  History:                                                   **
   **                                                             **
   **   1.5 - 02.11.2006                                          **
   **                                                             **
   **         Added: Speed Limiter                                **
   **                                                             **
   **          You can now limit the download speed (in KB/s).    **
   **                                                             **
   **         Added: Categories                                   **
   **                                                             **
   **          You can now have subdirectories within your        **
   **          "hidden" download directory. Allows for greater    **
   **          organisation when you have many of files.          **
   **                                                             **
   **          See "Usage example" for more information.          **
   **                                                             **
   **         Added: Allow Null Referers                          **
   **                                                             **
   **          You can now choose whether to allow or deny null   **
   **          referers. Null referers are download requests      **
   **          from unknown sources.                              **
   **                                                             **
   **         Improved: download_size()                           **
   **                                                             **
   **          Reworked and optimised. Decimals for size units    **
   **          except bytes and kilobytes.                        **
   **                                                             **
   **         Improved: Download Logging                          **
   **                                                             **
   **          Changed so only completed downloads are logged.    **
   **                                                             **
   **         Fixed: Spaces in filename bug                       **
   **                                                             **
   **          Filenames with spaces now download correctly.      **
   **                                                             **
   **         Fixed: IE bug [0]                                   **
   **                                                             **
   **          Fixed so filenames with multiple dots (.) would    **
   **          download without the [0] included.For example,     **
   **          in IE the file "download1.3.zip" would download    **
   **          as "download1.3[0].zip".                           **
   **                                                             **
   **   1.2 - 25.03.2006                                          **
   **                                                             **
   **         Improved: Hack Attempt Check                        **
   **                                                             **
   **          Added some extra checks for hack attempts.         **
   **                                                             **
   **   1.1 - 24.12.2005                                          **
   **                                                             **
   **         Improved: download_count() and download_size()      **
   **                                                             **
   **          Changed these functions so they return their       **
   **          result instead of echo'ing them. Users can now     **
   **          do things like adding the download count of        **
   **          multiple files to get an overall total.            **
   **                                                             **
   **   1.0 - 26.11.2005                                          **
   **                                                             **
   **         Full Release with all features present.             **
   **                                                             **
   *****************************************************************