AutoIndex PHP Script (version 1.3.8) - Help File
by Justin Hagstrom
(JustinHagstrom [at] yahoo [dot] com)
AutoIndex is provided under the terms of the GNU General Public License (GPL).

http://autoindex.sourceforge.net/
Please post any questions/comments in the forum.

This script works with PHP version 4.1.0 and higher.
To run the script, simply upload the contents of this directory to a server with PHP support.
Then, point your browser to the AutoIndex.php file. If you want to change any of the default options, read the rest of this file...

 


 

In the php file, there are some variables you need to change...

 
The first one is called $base_dir. This is the folder that will be the root of the directory listing. Include a slash at the end.
Make sure to use forward slashes, rather than backslashes. Also, try to use a relative path if possible.
Examples:
 

./ (the folder the php file 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.

 

$imagepath 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.
Examples:
 

index_icons/winxp (relative to the php file)
/index_icons/apache (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.
Examples:
 
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.

 

$userlist 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 won't be able to download or browse through files without logging in first.)
This variable only matters when $use_login_system is set to 1.

 

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.
Examples:
 
?id=AutoIndex
/file.php?id=thisFile

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

if(isset($_REQUEST['id']) && strpos($_REQUEST['id'], '/') === false)
//if the POST or GET value for the id is set, and it doesn't contain any slashes
//REQUEST is a combination of the GET and POST arrays
{
	include($_REQUEST['id']); //include the file
}

This getting the value from POST is needed so that the forms will work (searching, logging in, etc).

 

$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 referer 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.
Example:
 
./log.txt (the folder the php file is in)
/home/user/public_html/some_folder/somefile.log (absolute path)
ftp://user:password@example.com/somefile.txt (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 won't be written to the log file.
(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.

 

$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 ('|')
http://autoindex.sourceforge.net|Main Site
http://autoindex.tacticalcenter.net|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.


 

Language Settings:

 

$lang is the default language to display the script in.
The choices are listed below...
(Default: 'en')
Filename  Language
------------------------
bg     |  Bulgarian
ca     |  Catalan
cz     |  Czech
da     |  Danish
de     |  German
en     |  English
es     |  Spanish
fi     |  Finnish
fr     |  French
hu     |  Hungarian
is     |  Icelandic
it     |  Italian
jp     |  Japanese
ko     |  Korean
lt     |  Lithuanian
ms     |  Malay
nl     |  Dutch
no     |  Norwegian
pl     |  Polish
pt_BR  |  Brazilian Portuguese
ro     |  Romanian
ru     |  Russian
sv     |  Swedish
th     |  Thai
zh     |  Chinese
------------------------

 

$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)