AutoIndex PHP Script - Help File
by Justin Hagstrom
Please post any questions/comments in the forum.
This script works with PHP version 4.1.0 and higher.
Click here to see a working demo of the script.
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.
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.
The next is called $index. Leave this blank unless you use php includes on your webpage.
Make sure to put "ob_start();" at the top of your index file. This will make sure headers are sent correctly.
Examples:
?id=AutoIndex |
/file.php?id=thisFile |
$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 |
(relative to the php file) |
/index_icons |
(absolute path) |
$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 :
The $pathNav variable should be set to a 1 or a 0. (Default: 1)
It it is 1, at the top of the page, the current directory path will be show.
Each folder displayed is a link to that folder.
$folders_first should be set to a 1 or a 0. (Default: 1)
If it is 1, all folders will be listed before files (then both are sorted alphabetically).
If it is 0, everything will be listed alphabetically.
$tableWidth and $tableHeight are the size of the entire table.
If it is just a number, it will be set to that many pixels.
If the number is followed by a % sign, the size will be that percent of the entire screen.
$show_extension should be set to a 1 or a 0. (Default: 1)
If it is 1, the file name extension will be shown, and if it is 0, it won't.
$antiLeech 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.
The $logFile 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 CHMODed to 777.
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) |
$DontLogTheseIPs 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)
$HiddenFiles contains an array of strings.
If a file or folder matches any of them, it will not be displayed.
$showDirSize 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.
$folderExpansion 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.
$showTotalCount should be set to a 1 or a 0. (Default: 0)
If it is 1, the total number of files and folders will be displayed at the bottom.
$showFolderCount 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).
$EnableSearching should be set to a 1 or a 0. (Default: 0)
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.
$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.
$headerPerFolder and $footerPerFolder should be set to a 1 or 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)
$HideTheseExtensions and $OnlyTheseExtensions are arrays of strings.
DO NOT add a . before the extension.
If you wanted to only show wav and mp3 files, set $OnlyTheseExtensions=array('mp3','wav');
If you wanted to block all exe files, set $HideTheseExtensions('exe');
$separateFilesAlphabetically and $separateFoldersAlphabetically should be set to a 1 or a 0. (Default: 0)
If it is set to 1, there will be a line break between files/folders that begin with different letters.
$forceDownload 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.
|