AutoIndex PHP Script (version 1.4.3) - Help File
by Justin Hagstrom
(JustinHagstrom [at] yahoo [dot] com)
AutoIndex is provided under the terms of the GNU General Public License (GPL).
Please post any questions/comments in the forum.

To install and run the script, simply upload the contents of this directory to a server with PHP support (Works with all versions of PHP4 and PHP5).
Then, point your browser to the index.php file in that folder. The first time you do this, it will take you to a configuration page.
To use all the default values, just click the button at the bottom, or customize it however you want.
Information about the use of each variable is in this file.



$base_dir is the folder that will be the root of the directory listing.
This will be the starting point for the script. Nothing above this directory can be viewed, but its subfolders can.
Make sure to use forward slashes, rather than backslashes. Also, try to use a relative path if possible.

./ (the folder index.php is in)
./some folder/ (path relative to the php file)
/home/user/public_html/some_folder/ (absolute path)

If you're using an absolute path, you'll need to set $forceDownload to 1 (this is not recommended, though. It is better to use a path relative to the php script).


$icon_path is the path to the icons. Don't put a slash at the end.
Leave this blank to not show icons to the left of files and folders.

index_icons/winxp (relative to the php file)
/index_icons/kde (absolute path, relative to the server root)


$stylesheet is the path and filename of your css stylesheet.
Just modify the one that came with this, so it will match the rest of your site.

stylesheet.css (stylesheet.css is in the same folder as the php file)
/some_folder/some_stylesheet.css (absolute path to the stylesheet)


Optional Variables :


0 means false
1 means true


If $allow_uploads is set to 1, people will be able to upload files to your website. (Default: 0)
But if $use_login_system is also set to 1, you must create an account for them before they can upload.
The preset users are:

username: admin
password: admin
username: test
password: test

If you plan to use the login system, change the passwords or create different accounts and delete these!
All registered users will be able to upload, but only admins can create/delete accounts.
Also, if you want to allow uploads, make sure the folders you want to upload to are chmod'ed to allow PHP to write there.


$user_list contains the path to the text file where the usernames and encrypted passwords are stored.
Make sure the file is chmod'ed so PHP can read and write to it.
(This is only needed if $use_login_system is set to 1.)


If $allow_file_overwrites is set to 1, when uploading a file that already exists, the file will be replaced. (Default: 0)
In other words, this will allow people to overwrite existing files by uploading new ones.
This variable only matters when $allow_uploads is set to 1.


If $must_login_to_download is set to 1, users must login before they will see the list of files. (Default: 0)
(They will not be able to download or browse through files without logging in first.)
This variable only matters when $use_login_system is set to 1.


$banned_list contains the path to the text file where blocked IP addresses and/or hostnames are stored.
This list can be edited by logging in as an administrator, or you can directly edit the text file and add IP addresses and/or hostnames, each on a new line.
You can use wildcards in the entries (*, ?, +).


If $sub_folder_access is set to 0, folders will not be shown. (Default: 1)


$index: Leave this blank unless you use php includes on your webpage.
Make sure to put "ob_start();" and "session_start();" at the top of your index file. This will make sure headers are sent correctly.


The include in your index file should look something like this:

if (isset($_GET['id']) && strpos($_GET['id'], '/') === false)
//if the id parameter in the URL is set, and it doesn't contain any slashes
	include($_GET['id']); //include the file


$hidden_files contains an array of strings.
If a file or folder matches any of them, it will not be displayed.
They may contain wildcards (*, +, ?). For example, to hide all php files, add '*.php' to the list, or if you want to hide all files that begin with a period, add '.*'


$show_only_these_files contains an array of strings.
If there are any items in the array, the $hidden_files variable will be disabled, and only files that are listed here will be shown.
They may contain wildcards (*, +, ?). For example, to show only .txt files, add '*.txt' to the list.


$force_download should be set to a 1 or a 0. (Default: 0)
If it is set to 1, the file will be automatically downloaded, instead of letting the person's browser decide.


$bandwidth_limit is set to the max download speed (per client) in KB/s. 0 will turn it off.
The number can contain a decimal if you want.
NOTE: To use this feature, $forceDownload must be set to 1.


$anti_leech should be set to a 1 or a 0. (Default: 0)
This will compare the referrer and the name of your site to make sure they clicked on a link to download a file.
Setting this equal to 1 will prevent "leeching" by making sure they download files directly from a link on your site.


$enable_searching should be set to a 1 or a 0. (Default: 1)
If it is 1, people will be able to search for a file or folder containing a string.
It will search the folder you are currently in, and all subfolders.
Searching is not case sensitive.


The $log_file contains the full path to the file to write the access log.
Leave it blank to turn off logging.
The log file can be a local file, or on an FTP server.
If it's a local file on non-windows systems, make sure the log file is chmod'ed to allow PHP to write to the file.

./log.txt (the folder the php file is in)
/home/user/public_html/some_folder/somefile.log (absolute path) (stored on ftp server)

$dont_log_these_ips contains an array of strings (which are IP addresses).
Any access from an IP on this list will not be written to the log file.
You can also add hostnames to the list, and use wildcards (*, +, ?).
(i.e. put your own IP in here so you don't fill up the log file when you access your site)


$download_count contains a string which is the filename of the file to keep track of how many times files have been downloaded.
The file must be chmod'ed to allow PHP to read AND write to the file.
Leave blank to disable this feature.
NOTE: When downloading a file from an IP addresses in the $dont_log_these_ips array, the count will NOT increase.


$links_file contains the path to a text file with the URL of files that you want to be listed as links.
Separate each entry with a new line.
If you want, you can change how the links is displayed, by putting some text after a pipe ('|')|Main Site|Forum

If no link description is present, the link itself will be displayed.
NOTE: This isn't really meant to be done by hand - you can use the built-in editor when you log in as an admin.


$description_file contains the path to a text file with descriptions for files.
The format is: [$base_dir][full filename and path][a pipe, '|'][description for file]
Here's an example: ./somefile.txt|This is a text file.
Separate each entry with a new line.
NOTE: This isn't really meant to be done by hand: you can login as an admin and click "edit description" next to any file.


$show_dir_size should be set to a 1 or a 0. (Default: 1)
If it is set to 1, the total size of the folder will be shown under size.
If it is 0, it will display "[dir]" under size.
NOTE: If you are trying to index many files (meaning a few thousand), you will notice a speed improvement with this turned off.


$folder_expansion should be set to a 1 or a 0. (Default: 0)
If it is set to 1, when you click on the folder icon, it will expand the folder and list its contents.
Clicking on the folder name will take you into that folder.
If it is set to 0, both clicking on the icon and name will take you into the folder.


$show_folder_count should be set to a 1 or a 0. (Default: 0)
If it is 1, the total number of files in a folder will be shown next to that folder.
Files are counted recursively (files in subfolders are counted).


$header and $footer are the paths to 2 files.
The files must be text files (.html .txt .php , etc...)
Header will be displayed at the top, and footer will be displayed at the bottom.
Leave blank to not include a file.


$header_per_folder and $footer_per_folder should be set to a 1 or 0. (Default: 0)
If they are 0, the header/footer will be taken from the absolute or relative path in the $header/$footer variable.
If they are 1, the current directory will be added to the beginning of the file to be included. (don't add a path to the $header/$footer variables - just the filename)


$days_new contains the number of days old a file can be and still have [New] written next to it. (Default: 0)
If it set to 0, this feature will be disabled.
NOTE: this can contain any number, not just a 1 or 0 value, and it can contain a decimal if you want.


$md5_show is a feature that will let users get the md5sum of a specific file. (Default: 0)
If set to 0 it will be disabled.
Otherwise, the number will represent the maximum file size (in megabytes) to allow the md5sum to be calculated (I'd recommend something close to 10).
The number can contain a decimal if you want.
NOTE: PHP version 4.2.0 or higher is required for this feature to work.


$thumbnail_height is a feature that will show thumbnails next to images. (NOTE: GDlib 2.0.1 or higher is required)
Setting it to 0 will disable this feature, and setting it to any other number will set the size of the thumbnail.
(100 is a good setting to start with.)


$show_type_column, $show_size_column, and $show_date_column are set to 1 or 0.
Setting them to 1 will show the column, and setting it to 0 will not display the column.


Language Settings:


$lang is the default language to display the script in.
The choices are listed below...
(Default: 'en')

$lang settingLanguage
pt_BRBrazilian Portuguese
zh_TWChinese Traditional


$path_to_language_files is the path to where the *.php language files are located.
Default: ./languages/


If $select_language is set to 1, there will be an option at the bottom of the script for
the user to choose which language the script is displayed in. (Default: 0)