############################################
# Configuration file for DirWrap Photo 2.0 #
############################################

#############################
# Variables For Your System #
#############################

# Set $ENV{path} to untaint it. Required to run script in taint mode.
# NOTE: you may have to add additional paths below depending upon your 
# PERL installation
$ENV{'PATH'} = '/usr/lib';

# Admin email address
$admin_email = 'your_email@your.com';

# Absolute path to your starting point. Needs leading and trailing "/"
$base_path = "/your/path/to/www/directory/"; 

# Absolute path to your templates. Needs leading and trailing "/"
$templates = "/your/path/to/templates"; 

# Base URL of your web site. Used to create links if $allow_dirwrap_links
# and $use_counter are both set to no. Needs a trailing "/"
$base_url = "http://www.your.domain/";       

# URL of script. Should be relative to $base_url above. Needs a leading "/"          
$dirwrap_url = "/your/cgi_url/dirwrap.cgi"; 

# URL to your images. Should be relative to $base_url above. 
# DO NOT include the the trailing "/"!
$image_url = "/images";

# Default template. DO NOT include the ".html"!
$default_template = "example";

# Default sort method. Possible values: by_name, by_date, by_r_date, 
# by_size, by_r_size
$default_sort = "by_r_date";

# Sendmail location. Enter the path to sendmail or equivalent and any options
# Used to send emails to the address defined by $admin_email if
# $send_admin_email is set to "yes" below. 
$sendmail_location = '/usr/bin/sendmail -t';

##################
# Security Parms #
##################

# Admin code for acessing counter admin functions
# BE SURE TO CHANGE THIS VALUE!!!!!
# The value will be case sensitive
$admin_code = "admin";

# Allow links to sub directories to generated with call to DirWrap? 
# If yes, you don't need an index file in the directory with an SSI call.
# If no, you need an index file with an SSI call to get the output dirwrapped.
# If set to no, dirwrap calls will be exposed to visitors in the form of links
# NOTE: If $use_counter is set to yes this parameter will only hide the dirwrap 
# call for directories. File links will still contain a dirwrap URL so that the 
# script can increment the counters.
# To totally hide all dirwrap calls you must set both $allow_dirwrap_links and 
# $use_counter to "no".
$allow_dirwrap_links = "yes";

# Allow input of path parameter? 
# If set to no the path parm in the dirwrap call (path=some/path) will not be 
# allowed. Setting this parm to "no" forces you to use SSI via an index file in 
# the directory you wish to list.
# If set to "yes" you will be able to include a path parm in the dirwrap call.
#
# If you are attempting to use server authentication to allow only certain
# groups to access certain directories you should set this to "no". Otherwise,
# savvy users could bypass the server authentication by supplying a specific path.
# If you are not trying to use server authentication to allow only certain groups
# to access certain directories and you are not using SSI via an index file in the 
# directory, leave this parm set to "yes"
$allow_path_parm = "yes";

# Deny access to the following directories:
@hidedirs = ("cgi-bin", "images", "thumbnails");

# Show hidden files? Hidden files are files that start with a "."
# For security reasons it's best to leave this set to no.
$show_hidden_files = "no";

# Hide files with the following names
@hidefiles = (".htaccess", "index.shtml", "index.html", "dirwrap_photo.cgi");

# Hide files with the following extensions:
# Enclose extension in quotes separated by , ie ("jpg", "txt")
# Use lower case (upper case extensions in filenames will be converted) 
# to hide files with no extension use "none". To hide all directories use "dir".
@hideexts = ("");

# Send emails to $admin_email when changes are made? Will send an email to the 
# address in $admin_email when someone performs any admin actions (delete counts,
# reset counts) or when file upload actions take place (file uploaded/deleted,
# directory created/deleted). The email will include a short description of what 
# occurred and a dump of the environment variables to aid in tracking what has
# happened.
$send_admin_email = "no";

#################
# Customization #
#################

# Parameters for new graphics. Values equal number of days
$new1 = "10";  # parm for newest (displays graphic called "new1.gif")
$new2 = "30";  # parm for next newest (displays graphic called "new2.gif")

# Hide file extensions?
$hide_ext = "no";

# Turn off file icons? Thumbnails will also be hidden.
$hide_icons = "no";

# Show size as Kbytes instead of Bytes?
$size_as_K = "yes";

# Alternate colors for rows. 
# Set both the same if you don't want alternating row colors
# Not used if $album_mode is set to yes
$bgcolor_1 = "#eeeeee";
$bgcolor_2 = "#ffffee";

# Wrap photos (jpegs) in a template? 
# Template must be named photo.html
# Template must reside in directory defined by $templates above
# $allow_dirwrap_links must be set to "yes"
$wrap_photo = "no";

##############################
# Table Row/Entry Formatting #
##############################

# Data output format is defined below. There are two output modes:   #
# Normal and Album. You can modify the output for each file by       #
# changing the sections below.                                       #
# Below is a list of all possible variables and what they represent: #
#                                                                    #
# $line_count = The line count in the table. Increments by one       #
#               for each directory and file listed. Not valid for    #
#               album mode.                                          #
#                                                                    #
# $new_graphic = The new graphic.                                    #
#                                                                    #
# $delete_graphic = A delete graphic linked to the file/directory    #
#                   delete function. Include only if you are         #
#                   allowing uploads and file/directory deletion     #
# $delete_link = Same as $delete graphic, without the graphic.       #
#                                                                    #
# $icon_thumbnail_link = The file icon or thumbnail image. This      #
#                        graphic will be linked to the file.         #
#                                                                    #
# $file_name_link = The file name. The file name will be linked to   #
#                   the file.                                        #
#                                                                    #
# $file_size = The size of the file.                                 #
#                                                                    #
# $modified_date = The date the file was last modified.              #
#                                                                    #
# $download_counter  = The file download count. Include only         #
#                      if you are using the download counter.        #
######################################################################

######################################################################
#                NORMAL MODE TABLE ROW FORMATTING                    #
######################################################################
# make_row: subroutine for formatting the table rows in normal mode. #
# Only applies if $album_format is set to "no".                      #
# You can modify this to match your needs by changing the order      #
# of the variables or by removing variables you don't want/use.      #
# Be sure to make your template match what you do here and vice      #
# versa.                                                             #
# IMPORTANT: Change only the information between the lines reading   #
# $table_row_format = <<EndRowFormat;                                #
# and                                                                #
# EndRowFormat                                                       #
# The $table_row_format = <<EndRowFormat; and EndRowFormat lines     #
# must not be changed!                                               #
######################################################################

sub make_row {

$table_row_format = <<EndRowFormat; 
<tr bgcolor="$color">
<td>$line_count</td>
<td>$new_graphic</td>
<td>$delete_graphic<br>$delete_link</td>
<td>$icon_thumbnail_link</td>
<td>$file_name_link</td>
<td>$file_size</td>
<td>$modified_date</td>
<td>$download_counter</td>
</tr>

EndRowFormat

} # end sub make_row

######################################################################
#                    ALBUM MODE TABLE FORMATTING                     #
######################################################################
# album_row: subroutine for formatting the table rows in album mode. #
# Only applies if $album_format is set to "yes".                     #
# You can modify this to match your needs by changing the order      #
# of the variables or by removing variables you don't want/use.      #
# Be sure to make your template match what you do here and vice      #
# versa.                                                             #
# IMPORTANT: Change only the information between the lines reading   #
# $table_row_format = <<EndRowFormat;                                #
# and                                                                #
# EndRowFormat                                                       #
# The $table_row_format = <<EndRowFormat; and EndRowFormat lines     #
# must not be changed!                                               #
######################################################################
sub album_row {

$table_row_format = <<EndRowFormat; 
<td align="center" valign="top">
$new_graphic <br><br>
$icon_thumbnail_link <br>
$file_name_link <br>
$file_size <br>
$download_counter<br>
$delete_link 
</td>

EndRowFormat

} # end sub album_row

##########################
# Download Counter Parms #
##########################

# use the built in download counter?
# NOTE: setting this value to yes means that file URLs will contain dirwrap calls
# While this doesn't directly override $allow_dirwrap_links, it does render it
# virtually meaningless since all individual files will be linked with a dirwrap 
# call. See $allow_dirwrap_links above for more info
$use_counter = "yes";

# absolute path to your counts file (for built-in download counter)
$counts_file = "/path/to/your/counts.dat"; 

# do you want a final line totalling all counts for the directory
$total_counts = "yes";

#############################
# File Upload Utility Parms #
#############################

# Enable upload tool?
$enable_uploads = "no";

# Make the user enter admin password for uploads, create directory, delete files?
$upload_requires_pw = "yes";

# Code for allowing users to do uploads if $upload_requires_pw is "yes"
# BE SURE TO CHANGE THIS VALUE!!!!!
# The value will be case sensitive
$upload_code = "admin";

###################
# Thumbnail Parms #
###################

# create and display thumbnail images?
$thumbnails = "yes";

# maximum dimension of thumbnails
$maxdimension = "100";

####################
# Album Mode Parms #
####################

# Use album mode? If set to yes you will be able to display multiple thumbnails
# per table row. 
$album_mode = "yes";

# How files to display on a row
$files_per_row = "5";

#####################
# Icon Associations #
#####################

# add and delete icon associations as you see fit
# associations are made by "extension","image" pairs
# images must be in the location specified by $image_url above

%icons = (
	# plain text files
	"txt","text.gif",  

	# Word files
	"doc","word.gif",  

	# Excel files
	"xls","excel.gif", 

	# PowerPoint files 
	"ppt","ppt.gif",  

	# Rich Text Format files
	"rtf","rtf.gif",  

	# Adobe PDF files
	"pdf","pdf.gif",  

	# Font files
	"fon","afont.gif",  

	# True Type Font files
	"ttf","ttfont.gif",  

	# Sound files
	"wav","sound.gif", "au","sound.gif",  

	# Music files
	"mp3","music.gif", "mid","music.gif",  

	# Compressed files
	"zip","zip.gif", "tar","zip.gif", "z","zip.gif", "gz","zip.gif", 

	# Web files 
	"htm","web.gif", "html","web.gif", "shtml","web.gif", "shtm","web.gif", "xml","web.gif", 

	# Video files 
	"mpg","video.gif", "mpeg","video.gif", "avi","video.gif", "mov","video.gif", "ram","video.gif", "rv","video.gif",  

	# Image files
	"gif","pic.gif", "png","pic.gif", "bmp","pic.gif", "tif","pic.gif", "tiff","pic.gif",  

	# Scripts
	"js","scripts.gif", "jse","scripts.gif", "vbs","scripts.gif", "vbe","scripts.gif", "pl","scripts.gif", "pm","scripts.gif", "cgi","scripts.gif",  

	# DLL files
	"dll","dll.gif",
	   
	# Jpeg files
	"jpg","jpic.gif", "jpeg","jpic.gif",  

	 );
	
############################
# Error Messages           #
# Modify to fit your needs #
############################

## Error Code 1: Someone tried to input a path parm with $allow_path_parm set to no
$e1 = "<center><b>Error code: 1<p>I'm sorry, but I am unable to complete your request. Please contact the page administrator and provide the error code listed above.</b></center>";

## Error Code 2: Someone tried to use a / or .. in the start of a $path or $directory var
$e2 = "<center><b>Error code: 2<p>I'm sorry, but I am unable to complete your request. Please contact the page administrator and provide the error code listed above.</b></center>";

## Error Code 3: Someone tried to get to a path or directory in the hidedirs array
$e3 = "<center><b>Error code: 3<p>I'm sorry, but I am unable to complete your request. Please contact the page administrator and provide the error code listed above.</b></center>";

## Error Code 4: Couldn't find the specified directory
$e4 = "<center><b>Error code: 4<p>Dirwrap was unable to find the specified directory!<p>$file_dir<p>This could be due to an incorrect absolute path in the configuration or an invalid path or directory. </b></center>";

## Error Code 5: Someone tried to use a / or .. in the start of a $temp var
$e5 = "<center><b>Error code: 5<p>I'm sorry, but I am unable to complete your request. Please contact the page administrator and provide the error code listed above.</b></center>";

## Error Code 6: Someone tried to view thumbnail directory directly
$e6 = "<center><b>Error code: 6<p>I'm sorry, but I am unable to complete your request. Please contact the page administrator and provide the error code listed above.</b></center>";

## Error Code 7: Someone tried to do the count subroutine on a directory
$e7 = "<center><b>Error code: 7<p>I'm sorry, but I am unable to complete your request. Please record the URL that brought you here and contact the page administrator and provide the URL and error code listed above.</b></center>";

## Error Code 8: Someone tried to do the count subroutine on a non-existent file
$e8 = "<center><b>Error code: 8<p>I'm sorry, but I am unable to complete your request. The file you are trying to view/download does not exist.</b></center>";

################################################
# File must return "true" value at termination #
################################################

1;