#!Pi3

# ===
#
# Top level configuration file
#
#	** IMPORTANT **
#	If you do nothing else then do this:
#

#... ###### Customize server settings

# Skip below to the definition of 'MainVirtualHostInformation', change
# the settings for Hostname (*Mandatory* redirects will not work without
# this!) and Administrator (optional).
#
# ===

# Include  standard IO and server stuff
include ../Conf/IO.cnf
include ../Conf/Server.cnf
include ../Conf/Pi3API.cnf

# ---
#
# IO Object for main listening socket.
#
# ---
<Object>
    Name ServerIOObject
    Class TCPIPIOClass
    Type Passive

# A hostname must be specified for the Pi3Web HTTP server. The hostname
# will be the used by the server to identify itself in URLs generated
# for redirects and will also be used to lookup the IP address that this
# server will listen on.
	BindHost localhost

# A TCP port must be specified for this HTTP server. The TCP port
# is the port that the HTTP will listen for requests on. This is
# typically 80 for HTTP servers. 
#
# Note that UNIX operating systems normally require that the server
# initially run as user 'root' to bind on ports between 0 and 1024
	BindPort 80

# Timeout accepting connections. -1 specifies no timeout.
	AcceptTimeout -1

# Specify timeout for sending data. -1 specifies no timeout. 

	RecvTimeout 60

# Specify timeout for receiving data. -1 specifies no timeout. 
	SendTimeout 45
	PeerIPVariable STRING:RemoteAddr
	PeerHostNameVariable STRING:RemoteHost
	LocalAddressVariable STRING:LocalAddr

# Flags
#
#   OwnDB - Object adds its own DB, rather than use the parents
#               this is necessary to avoid collision of values placed in
#               the DB between different connection. 
#
#   SetPeerAddress - IP address of remote peer with be put
#               into the specified variable.
#
#   DNSReverseLookup - Use reverse DNS to get the hostname of the 
#               peer and place it in the specified variable.
#
#   SetLocalAddress - Put local address in the specified variable.
	Flags OwnDB|SetPeerAddress|DNSReverseLookup|SetLocalAddress

# Pointer to file with lockfile name, to avoid collisions on accept
# with multiple processes
	AcceptLockFile  "../Logs/lockfile.txt"
</Object>

# ---
#
# Main virtual host object.
#
# ---
<Object>
	Name MainVirtualHostInformation
	Class VirtualHostClass

# Administrator for the primary virtual host
	Administrator webmaster@localhost

# Hostname that this server uses in redirects.
	HostName localhost

# Port that the server uses in redirects.
# Specify it only if it is not the standard port for the protocol in
# use, i.e. 80 for HTTP and 443 for HTTPS
#	ServerPort 80

</Object>

# ---
#
#    Thread dispatch object
#
#   This is an instance of MultiThreadedIOServerClass with appropriate
#   parameters
#
# ---
<Object>
	Name ThreadPoolDispatcher
	Class MultiThreadedIOServerClass

# The IOObject is the object that will be used for the listening socket
# it can be a real IOObject (such as TCP/IP), as test IO object which 
# feeds stub data into the server or a filter IO object which encrpts
# or logs data passed through it.
#
#    Example test IO object:
# 	IOObject TestIOObject
#
#    Log IO to file:
#	IOObject SnoopIO IOObject="ServerIOObject" OutFile="./snoop.dbg"
#
	IOObject ServerIOObject

# Dispatch accepted IO connection to the HTTPLogicObject
	LogicObject HTTPLogicObject

# Number of threads to use 
	MaxThreads 10

# Number of requests to exit after
	ExitAfter 1000

</Object>

# ---
#
# Main Pi3 object. 
#
# This is an instance of the UNIXDaemonClass to fork the server into
# one monitor process and 'NumberOfProcesses' child processes. 
#
# The monitor process automatically starts a new child processes whenever
# a child process exits.
#
# ---
<Object>
	Name Main
	Class UNIXDaemonClass

# Actual class to accept new IO requests and dispatch them
	ServerObject ThreadPoolDispatcher
	PIDFile "../Logs/pid.log"
	RLimitCpu Maximum

# User that child processes will run as. Server must run as root to 
# be able to change to the specified user. A user id number can be
# specified with #number. Server which start with root privileges should
# change to a user id with lesser privileges for security reasons.
#   User nobody

# Group that child processes will run as. Server must run as root to
# be able to change to a different group. A group id number can be
# specified with #number.
#   Group #-1

# generate a server unique lockfile name and write it into
# Logs/lockfile.txt
	LockFileName "../Logs/lockfile.txt"

# Message to write just before the server is ready to start accepting
# connections.
# default
	Message "Pi3Web HTTP Server Started"

# Specify the number of processes. 

	NumberOfProcesses 8

</Object>



# ===
#
# Features.pi3
#
#	Showcase features of Pi3Web server. Use this configuration
#	only for personal or workgroup use. Its not optimal
#	for use on the public internet. Here's why:
#
#		- Performance is slower because of all the extra
#	handlers that are added in and the funky things that they
#	do.
#
#		- Bigger and more complex is less secure against
#	attack than smaller and featureless. The server created
#	by this configuration is bigger and more complex.
#
# ===


#
# Load library definitions for classes used here.
#
include ../Conf/HTTP.cnf
include ../Conf/Fcgi.cnf
include ../Conf/Plugins.cnf
include ../Conf/ISAPI.cnf

# ---
#
# Documentation is handled as HTML regardless of file extension. Also,
# files have headers and footers attached to make them pretty.
#
# ---
<Object>
	Name DocumentMapper
	Class PathMapperClass
	#
	# leave calling card
	#
	Action "&dbreplace(response,string,ObjectMap,Pi3Docs)"
</Object>

# ---
#
# CGIMapper
#
#	Instance of PathMapperClass to Map CGI URLs
#
#	CGI Scripts set PATH_INFO. 
#
# ---
<Object>
	Name CGIMapper
	Class PathMapperClass
	CaseSensitive "No"
	#
	# Subdirectories below the mapping directory should be put in path info
	#
	PathInfo "Yes"
	#
	# Set the 'ObjectMap' variable in the response DB if this map is
	# successful
	#
	Action "&dbreplace(response,string,ObjectMap,Scripts)"
</Object>

# ---
#
# WinCGIMapper and FCGIMapper
#
# 	Like CGIMapper, except it leaves a different marker to cause
# 	a different object to handle the request.
#
# ---
<Object>
	Name WinCGIMapper
	Class PathMapperClass
	PathInfo "Yes"
	Action "&dbreplace(response,string,ObjectMap,WinScripts)"
</Object>
<Object>
	Name FCGIMapper
	Class PathMapperClass
	PathInfo "Yes"
	Action "&dbreplace(response,string,ObjectMap,FastCGIScripts)"
</Object>

# ---
#
# AdminMapper
#
# For protected spaces
#
# ---
<Object>
	Name AdminMapper
	Class PathMapperClass

	#
	# Set the authentication realm so the BasicAuth handler kicks in
	Action "&dbreplace(response,string,AuthenticationRealm,Admin)"
</Object>

# ---
#
# AccessLogger
#
#	An instance of ExpressionLoggerClass configured to generate an 
#	logfile
#
# ---
<Object>
	Name AccessLogger
	Class ExpressionLoggerClass

	#
	# Append
	#
	OpenMode "a"
	#
	# Line to log 
	Expression "$A $h - [$t] \"$r\" $s $b$M"
</Object>

# ---
#
# Start
#
#	Handle initial phases of requests, typically before we have enough
#	information to select different execution paths
#
# ---
<Object>
	Name Start
	Class FlexibleHandlerClass
	Init ReturnCode ReturnCode=COMPLETED
	Headers ReadRequestHeaders

	#
	# The handler 'VirtualHosts' is described below
	#
	HostMap VirtualHosts

	#
	# Mapping virtual paths to example directory with 'DirListType' set
	#
	Mapping DirectoryMappings

	#
	# Default mappings
	#
	Mapping MapToErrorDocument \
		IgnoreStatus="0 200" \
		DefaultMessage="/errors/unknown.htm" \
		301="/errors/301.ssi" \
		304="/errors/304.htm" \
		400="/errors/400.htm" \
		401="/errors/401.ssi" \
		403="/errors/403.ssi" \
		404="/errors/404.ssi" \
		500="/errors/500.ssi" \
		501="/errors/501.htm"
	Mapping UserDirectory UserDirectoryRoot="/home/" \
		HTMLDirectory="/public_html"
	Mapping CGIMapper From="/cgi-bin/" To="cgi-bin/"
	Mapping WinCGIMapper From="/cgi-win/" To="cgi-win/"
	Mapping FCGIMapper From="/cgi-fcgi/" To="cgi-fcgi/"
	Mapping DocumentMapper From="/pidocs/" To="Pi3Docs/" 
	Mapping PathMapper From="/errors/" To="Fragment/" 
	Mapping PathMapper From="/icons/" To="Icons/" 

# mapping to view logfiles disabled
#	Mapping PathMapper From="/logs/" To="Logs/" 

	Mapping AdminMapper From="/admin/" To="Logs/" 
	Mapping PathMapper From="/Pi3Expressions/" To="**internal**/" \
		Action="&dbreplace(response,string,ObjectMap,Pi3Expr)" \
		PathInfo="Yes"
	Mapping PathMapper From="/isapi/" To="Isapi/" \
		Action="&dbreplace(response,string,ObjectMap,ISAPI)" \
		PathInfo="Yes"

	#
	# Mapping specific to Host2
	#
	Mapping Host2Mappings

	#
	# Mapping specific to MainVirtualHostInformation
	#
	Mapping Host1Mappings
</Object>

# ---
#
# Default
#
#	Handle requests that other handlers have passed up
#
# ---
<Object>
	Name Default
	Class FlexibleHandlerClass
	CheckPath DirectoryExists IndexFile="index.html" IndexFile="index.htm"
	CheckPath RefuseFileByMask AllowFileMask="EF" RefuseStatus=404
	CheckPath RefuseFileByMask AllowFileMask="F" RefuseStatus=403
	CheckPath ReturnCode ReturnCode=COMPLETED
	CheckAuth BasicAuth Realm="Admin"
	CheckAuth ReturnCode ReturnCode=COMPLETED
	CheckAccess AccessByFile RequirePermissions="R"

	#
	# Cause a '501 Not Implemented' Message for requests that
	# are not 'GET' or 'HEAD', i.e.
	#	if !( Method=='GET' || Method=='HEAD' ) 
	#	then
	#		set status = 501
	#	endif
	#
	CheckType Condition="¬(&or(&cmpi($m,GET),&cmpi($m,HEAD)))" \
		StatusCode StatusCode="501"
	CheckType ConditionalGet
	CheckType CheckForDirectory SetType="internal/x-directory"

	#
	# Otherwise: Set the media type based on the file extension
	#
	CheckType MIMETypeByExtension 

	#
	# Return 'COMPLETED' so an internal error will not be raised
	#
	CheckType ReturnCode ReturnCode="COMPLETED"

	#
	# Most requests refer to a file, so put that first 
	#
	# Handle the request by sending a file if
	#	- The Value of ObjectMap in the response DB is ""
	#	AND
	#	- The Media type of the resource does not match internal/* 
	#
	Handle Condition="&and(¬(&dblookup(response,string,ObjectMap)),\
¬(®exp('internal/*',$c)))" SendFile
	Handle Condition="&cmp($c,internal/x-directory)" DirectoryIndexes
	Handle Condition="&cmp($c,internal/x-server-parsed-html)" SendSSI \
		Exec=Yes ExecFileFixup="\
/* exec file="" maps to Standard CGI (Scripts) */\
&dbreplace(response,string,ObjectMap,Scripts)\
&dbreplace(response,rfc822,Content-Type,internal/x-cgi)"
	Handle Condition="&cmp($c,internal/x-imagemap)" ImageMap
	Handle SendFile
	Log AccessLogger File="Logs/access.txt"
	Log ReturnCode ReturnCode=COMPLETED
	Destroy DeleteTemporaryFiles
</Object>

# ---
#
# Documentation
#
#	Handler sequence for documentation.
#
# ---
<Object>
	Name Documentation
	Class FlexibleHandlerClass

	#
	# Only execute this sequence for the documentation (check for
	# the appropriate marker).
	#
	# Don't handle special resource types (internal/...)
	#
	Condition "&and(&cmp(&dblookup(response,string,ObjectMap),Pi3Docs),\
¬(®exp('internal/*',$c)))"

	#
	# Check if file is a directory
	# 
	CheckType CheckForDirectory SetType="internal/x-directory"

	#
	# Lookup media type by extension
	#
	CheckType MIMETypeByExtension

	#
	# Force all non-internal media types to 'text/html'
	#
	CheckType Condition="¬(®exp('internal/*',$c))" Action \
		Pi3Expression="&dbreplace(response,rfc822,Content-Type,text/html)"

	#
	# Return 'COMPLETED' so as not to fall into other cases
	#
	CheckType ReturnCode ReturnCode="COMPLETED"

	#
	# For documentation, Send documentation with header and footer
	#
	Handle SendFile HeaderPattern="<BODY BACKGROUND="/icons/\
&if(&cmpi($o,MainVirtualHostInformation),Pi3Tile.gif,H2Tile.gif)"/*background depends on vhost*/\
BGCOLOR="#FFFFFF">\n"
</Object>

# ---
#
# FastCGIIOObject
# 
# IOObject for communicating with fast CGI application servers. This
# one uses the TCP/IP transport.
#
# ---
<Object>
	Name FastCGIIOObject
	Class TCPIPIOClass
	Type Active

	# Timeouts. -1 specifies no timeout.
	RecvTimeout 20
	SendTimeout 20
</Object>

# ---
# 
# Scripts, WinScripts, ISAPI, FastCGIScripts, Pi3Expr
#
#	Handler sequences for resources which have mapped to these
# 	respective types
#
# ---
<Object>
	Name Scripts
	Class FlexibleHandlerClass
	Condition "&cmp(&dblookup(response,string,ObjectMap),Scripts)"
	CheckPath RefuseFileByMask AllowFileMask="EFD" RefuseStatus=404
	CheckPath RefuseFileByMask AllowFileMask="F" RefuseStatus=403
	CheckPath ReturnCode ReturnCode=COMPLETED
	CheckAccess AccessByFile RequirePermissions="X"
	CheckType ReturnCode ReturnCode=COMPLETED
	Handle StandardCGI
</Object>
<Object>
	Name WinScripts
	Class FlexibleHandlerClass
	Condition "&cmp(&dblookup(response,string,ObjectMap),WinScripts)"
	CheckPath RefuseFileByMask AllowFileMask="EFD" RefuseStatus=404
	CheckPath RefuseFileByMask AllowFileMask="F" RefuseStatus=403
	CheckPath ReturnCode ReturnCode=COMPLETED
	CheckAccess AccessByFile RequirePermissions="X"
	CheckType ReturnCode ReturnCode=COMPLETED
	Handle WinCGI
</Object>
<Object>
	Name ISAPI
	Class FlexibleHandlerClass
	Condition "&cmp(&dblookup(response,string,ObjectMap),ISAPI)"
	CheckPath RefuseFileByMask AllowFileMask="EFD" RefuseStatus=404
	CheckPath RefuseFileByMask AllowFileMask="F" RefuseStatus=403
	CheckPath ReturnCode ReturnCode=COMPLETED
	CheckAccess AccessByFile RequirePermissions="X"
	CheckType ReturnCode ReturnCode=COMPLETED
	Handle ISAPI20
</Object>
<Object>
	Name FastCGIScripts
	Class FlexibleHandlerClass
	Condition "&cmp(&dblookup(response,string,ObjectMap),FastCGIScripts)"
	CheckPath RefuseFileByMask AllowFileMask="EFD" RefuseStatus=404
	CheckPath RefuseFileByMask AllowFileMask="F" RefuseStatus=403
	CheckPath ReturnCode ReturnCode=COMPLETED
	CheckAccess ReturnCode ReturnCode="COMPLETED"
	CheckType ReturnCode ReturnCode="COMPLETED"
	Handle FastCGI \
		IOObject="FastCGIIOObject" \
		Variable="AUTH_TYPE=$x" \
		Variable="CONTENT_LENGTH=$Y" \
		Variable="CONTENT_TYPE=$C" \
		Variable="HTTPS=$g" \
		Variable="&if($K,HTTPS_KEYSIZE=$K,)" \
		Variable="&if($K,HTTPS_SECRETKEYSIZE=$G,)" \
		Variable="PATH_INFO=$I" \
		Variable="PATH_TRANSLATED=$Z" \
		Variable="QUERY_STRING=$q" \
		Variable="REMOTE_ADDR=$A" \
		Variable="REMOTE_HOST=$h" \
		Variable="REMOTE_IDENT=$i" \
		Variable="REMOTE_USER=$u" \
		Variable="REQUEST_METHOD=$m" \
		Variable="SCRIPT_NAME=$z" \
		Variable="SERVER_NAME=$v" \
		Variable="SERVER_PORT=&if($p,$p,&if($K,443,80))" \
		Variable="SERVER_PROTOCOL=$H" \
		Variable="SERVER_SOFTWARE=$S"
</Object>
<Object>
	Name Pi3Expr
	Class FlexibleHandlerClass
	Condition "&cmp(&dblookup(response,string,ObjectMap),Pi3Expr)"
	CheckPath ReturnCode ReturnCode="COMPLETED"
	CheckAccess ReturnCode ReturnCode="COMPLETED"
	CheckType ReturnCode ReturnCode=COMPLETED
	Handle SendPi3Expression HTTPEquiv="Content-Type: text/html" \
		Pi3Expression="\
/*											 */\
/*											 */\
/* A Large Pi3Expression to send to the client */\
/*			  in one go					  */\
/*											 */\
/*   This will generate a dynamic HTML page	*/\
/*											 */\
<TITLE>Pi3Expressions - DB Dump</TITLE>\
<HTML><BODY BACKGROUND="/icons/Pi3Tile.gif">\
<CENTER><H2>Pi3Expressions - DB Dump</H2>\
<A NAME="index">$M\
<UL>$M\
<LI><A HREF="#connection">Connection DB</A>$M\
<LI><A HREF="#request">Request DB</A>$M\
<LI><A HREF="#response">Response DB</A>$M\
<LI><A HREF="#host">Host DB</A>$M\
</UL>$M\
<HR>$M\
<A NAME="connection">$M\
<H3>Dump of Connection DB <I>dblookup(connection,...)</I></H3>$M\
<TABLE BORDER=1 CELLPADDING=5><TH>Type<TH>Variable<TH>Value$M\
&dblookup(connection,string,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
&dblookup(connection,rfc822,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
&dblookup(connection,opaque,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
</TABLE>\
<A HREF="#index">Index</A>$M\
<HR>$M\
<A NAME="request">$M\
<H3>Dump of Request DB <I>dblookup(request,...)</I></H3>$M\
<TABLE BORDER=1 CELLPADDING=5><TH>Type<TH>Variable<TH>Value$M\
&dblookup(request,string,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
&dblookup(request,rfc822,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
&dblookup(request,opaque,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
</TABLE>\
<A HREF="#index">Index</A>$M\
<HR>$M\
<A NAME="response">$M\
<H3>Dump of Response DB <I>dblookup(response,...)</I></H3>$M\
<TABLE BORDER=1 CELLPADDING=5><TH>Type<TH>Variable<TH>Value$M\
&dblookup(response,string,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
&dblookup(response,rfc822,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
&dblookup(response,opaque,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
</TABLE>\
<A HREF="#index">Index</A>$M\
<HR>$M\
<A NAME="host">$M\
<H3>Dump of Host DB <I>dblookup(host,...)</I></H3>$M\
<TABLE BORDER=1 CELLPADDING=5><TH>Type<TH>Variable<TH>Value$M\
&dblookup(host,string,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
&dblookup(host,rfc822,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
&dblookup(host,opaque,,,<TR><TD><B>&_(2)</B><TD>&_(1)<TD>&_()$M)\
</TABLE>\
<A HREF="#index">Index</A>$M\
</CENTER><HR></BODY></HTML>"

</Object>

# ---
#
#	Virtual hosting handlers and configuration
#
# ---

#
# Host2 Virtual host object
<Object>
	Name Host2
	Class VirtualHostClass
	Administrator mr_web@Host2.dom
	HostName www.johnroy.com/host2
	ServerPort 80
</Object>

#
# Virtual host mappings
#
<Object>
	Name VirtualHosts
	Class FlexibleHandlerClass

	#
	# if the URL starts with '/host2/' assign to virtual host 2
	#
	HostMap VirtualHostByURL VirtualHostObject="Host2" URLPath="/host2/"

	#
	# Introduce a mapping
	Mapping Host2Mappings
</Object>

#
# Override some mappings for Host2 only
#
<Object>
	Name Host2Mappings
	Class FlexibleHandlerClass

	#
	# These mappings only apply to Host2
	#
	Condition "&cmp($o,Host2)"

	#
	# map to second document root
	#
	Mapping PathMapper From="/" To="WebRoot2/"
</Object>

#
# Host1 mappings
#
<Object>
	Name Host1Mappings
	Class FlexibleHandlerClass
	#
	# These mappings only apply to MainVirtualHostInformation
	#
	Condition "&cmp($o,MainVirtualHostInformation)"
	#
	# map to first document root
	#
	Mapping PathMapper From="/" To="WebRoot/"
</Object>

# ---
#
# HTTPLogicObject
#
# 	HTTP Logic object, dispatches requests to all other handlers
#
# ---
<Object>
	Name HTTPLogicObject
	Class HTTPDispatcherClass
	Handlers Start Scripts WinScripts FastCGIScripts Documentation Pi3Expr ISAPI Default
	KeepOpen On
	ServerRoot ./../
	ServerStamp Pi3Web/0.9b4
	DefaultHost MainVirtualHostInformation
	MIMEFile "Fragment/Mime.typ"
	DefaultMIMEType "application/octet-stream"
	ErrorLogFile "Logs/error.txt"

	# Specifying a file for DebugLogFile effectively turns on debugging
#	DebugLogFile "Logs/debug.txt"

	#
	# The following to directives specify expressions to be logged
	# before and after each handler execution respectively.
	# The expression as given logs process/thread and handler context
	# information indented to the nested handler level.
	#
	# Timing information is also given for performance tuning.
	#
	# This logging information is EXTREMELY verbose. Don't even
	# think about using it in a production server
	#
	DebugBeforeHandler "[$P:$k] &align(,$X)&align(,$X) |--> $T \
-------- &align($N,12) &align($R,12) $n \"$r\" $s"
	DebugAfterHandler "[$P:$k] &align(,$X)&align(,$X) |<-- $T \
&align($D,8) &align($N,12) &align($R,12) $n \"$r\" $s"
</Object>

# ---
#
#	Directory listing handlers and configuration
#
# ---
<Object>
	Name DirectoryMappings
	Class FlexibleHandlerClass

	#
	# 1..Simple HTML
	#
	# simple HTML, no icons or descriptions
	Mapping DocumentMapper From="/dir_SimpleHTML/" To="Pi3Docs/features/" \
		Action="&dbreplace(response,string,DirListType,SimpleHTML)"

	#
	# 2..Simple DOS like format with alternate name
	# 
	Mapping DocumentMapper From="/dir_DOS/" To="Pi3Docs/features/" \
		Action="&dbreplace(response,string,DirListType,DOS)"

	#
	# 3..Fixed pitch HTML with icons and descriptions
	# plain HTML
	Mapping DocumentMapper From="/dir_TableHTML/" \
		To="Pi3Docs/features/" \
		Action="&dbreplace(response,string,DirListType,TableHTML)"

	#
	# 4..HTML with tables
	#
	# HTML with tables
	Mapping DocumentMapper From="/dir_PlainHTML/" To="Pi3Docs/features/" \
		Action="&dbreplace(response,string,DirListType,PlainHTML)"

	# 
	# 5..Raw tab delimited text
	#
	# Tab delimited text
	Mapping DocumentMapper From="/dir_TDT/" To="Pi3Docs/features/" \
		Action="&dbreplace(response,string,DirListType,TDT)"
</Object>

#
# Directory Indexes
#
<Object>
	Name DirectoryIndexes
	Class FlexibleHandlerClass

	# 1..Simple HTML
	Handle Condition="&cmp(&dblookup(response,string,DirListType),SimpleHTML)" \
		SimpleHTML

	# 2..Simple DOS format
	Handle Condition="&cmp(&dblookup(response,string,DirListType),DOS)" DOS

	# 3..Plain HTML
	Handle Condition="&cmp(&dblookup(response,string,DirListType),PlainHTML)" \
		PlainHTML 

	# 4..HTML with tables
	Handle Condition="&cmp(&dblookup(response,string,DirListType),TableHTML)" \
		 TableHTML 

	# 5..Raw tab delimited text
	Handle Condition="&cmp(&dblookup(response,string,DirListType),TDT)" TDT

	#
	# The default index type used for examples other than the
	# sample directory will be a table HTML index
	#
	Handle TableHTML
</Object>

# ---
#
# Simple HTML
#
# ---
<Object>
	Name SimpleHTML
	Class DirectoryIndexClass
	HeaderPattern "<HTML><TITLE>Simple index of %p</TITLE>\
<H2>Simple index of %p</H2>\n"
	ListTop "\
<PRE><B>\
&align(Name,23) \
&align(Size,6)  \
&align(Last Modified,18)\
\n<HR SIZE=1 NOSHADE></B>\n"
	FilePattern "\
<A HREF="%r">&align(&abbrev(%n,23,...)</A>,27) /*	link to file */\
&align(%s,6)  /*									size */\
&align(%l,18)/*										last modified date */\
\n"
	LastModifiedFormat "%d-%b-%y %H:%M"
	Include "*"
	SwapFileName ".. Parent Directory"
	ListBottom "</PRE>\n"
	FooterPattern "<HR SIZE=1 NOSHADE>\
Contact the hostmaster <A HREF="mailto:$a"<I>$a</I></A>.\
</HTML>"
	HeaderFile "HEADER"
	FooterFile "README"
	Exclude "."
	Exclude "~*"
	Exclude ".desc"
	Exclude "README"
	Exclude "HEADER"
	Options " Name | Size | RelPath "
</Object>

# ---
#
# Simple DOS formatted index
#
# ---
<Object>
	Name DOS
	Class DirectoryIndexClass
	HeaderPattern "<HTML><TITLE>DOS style index of %p - </TITLE>\
<H2>DOS style index of %p - </H2>\n\
"
	ListTop "<PRE>\
&align(Last Modified,24,left)\
&align(Size,14) \
&align('(8,3) Name',12) \
Name \n<HR SIZE=1 NOSHADE>"
	FilePattern "\
&align(%l,24)\
&if(%b,&align('<DIR>',18,left),&align(%s,14,right)) \
<A HREF="%r">&align(&abbrev(%a,12,...)</A>,16,left) \
<A HREF="%r">%n</A> \n"
	LastModifiedFormat "%d/%m/%y  %I:%M%p"
	Include "*"
	DescriptionFile ".desc"
	ListBottom "</PRE>\n"
	FooterPattern "<HR SIZE=1 NOSHADE>\
Contact the hostmaster <A HREF="mailto:$a"<I>$a</I></A>.\
</HTML>"
	HeaderFile "HEADER"
	FooterFile "README"
	Exclude "."
	Exclude "~*"
	Exclude ".desc"
	Exclude "README"
	Exclude "HEADER"
	Options " AltName | Name | FormatSize | RelPath "
</Object>

# ---
#
# Plain HTML directory listing with icons
#
# ---
<Object>
	Name PlainHTML
	Class DirectoryIndexClass
	HeaderPattern "<HTML><TITLE>Plain HTML index of %p</TITLE>\
<BODY BACKGROUND="/icons/\
&if(&cmpi($o,MainVirtualHostInformation),Pi3Tile.gif,H2Tile.gif)"/*background depends on vhost*/\
BGCOLOR="#FFFFFF">\
<H2>Plain HTML index of %p</H2>\n"
	ListTop "\
<PRE>\
<IMG SRC="/icons/blank.gif" BORDER=NONE ALT="  ">\
 &align(Name,23) &align(Last Modified,18)\
&align(Size,6)  Description\n<HR SIZE=1 NOSHADE>"
	FilePattern "\
<A HREF="%r"><IMG SRC="%i" BORDER=NONE ALT="[]"></A>/*icon is a link */\
 <A HREF="%r">&align(&abbrev(%n,23,...)</A>,27) /*	link to file */\
&align(%l,18)/*										last modified date */\
&align(%s,6)  /*									size */\
&if(%d,%d,<I>%c</I>)/*								description, or MIME */\
\n"
	LastModifiedFormat "%d-%b-%y %H:%M"
	Include "*"
	MIMEIcon "text/html /icons/layout.gif"
	MIMEIcon "text/x-code /icons/c.gif"
	MIMEIcon "text/x-perl /icons/p.gif"
	MIMEIcon "text/* /icons/text.gif"
	MIMEIcon "internal/x-directory /icons/folder.gif"
	MIMEIcon "audio/* /icons/sound2.gif"
	MIMEIcon "image/* /icons/image2.gif"
	MIMEIcon "application/x-uuencoded /icons/uuencoded.gif"
	MIMEIcon "application/x-tar /icons/compressed.gif"
	MIMEIcon "application/x-gzip /icons/compressed.gif"
	MIMEIcon "application/x-sh /icons/script.gif"
	MIMEIcon "application/* /icons/binary.gif"
	MIMEIcon "x-world/x-vrml /icons/burst.gif"
	MIMEIcon "*/* /icons/unknown.gif"
	DescriptionFile ".desc"
	SwapFileName ".. Parent Directory"
	ListBottom "</PRE>\n"
	FooterPattern "<HR SIZE=1 NOSHADE>\
Contact the hostmaster <A HREF="mailto:$a"<I>$a</I></A>.\
</BODY></HTML>"
	HeaderFile "HEADER"
	FooterFile "README"
	Exclude "."
	Exclude "~*"
	Exclude ".desc"
	Exclude "README"
	Exclude "HEADER"
	Options " Name | AbbrevSize | RelPath | Icon | MIMEType "
</Object>

# ---
#
# Directory listing with HTML tables
#
# ---
<Object>
	Name TableHTML
	Class DirectoryIndexClass
	HeaderPattern "<HTML><TITLE>Enhanced HTML index of %p</TITLE>\
<BODY BACKGROUND="/icons/\
&if(&cmpi($o,MainVirtualHostInformation),Pi3Tile.gif,H2Tile.gif)"/*background depends on vhost*/\
BGCOLOR="#FFFFFF">\
<H2>Enhanced HTML index of %p</H2>\n"
	ListTop "<CENTER><TABLE CELLSPACING=0 CELLPADDING=0 WIDTH=100'%'>\
<TR>\
<TH NOWARP ALIGN=LEFT>\
<IMG SRC="/icons/blank.gif" ALIGN=MIDDLE BORDER=NONE ALT="">\
<TH NOWRAP ALIGN=LEFT>Name<BR><HR SIZE=1 NOSHADE>\
<TH NOWRAP ALIGN=LEFT>Size<BR><HR SIZE=1 NOSHADE>\
<TH NOWRAP ALIGN=LEFT>Last Modified<BR><HR SIZE=1 NOSHADE>\
<TH NOWRAP ALIGN=LEFT>Description<BR><HR SIZE=1 NOSHADE>\n"
	FilePattern "<TR>\
<TD NOWRAP ALIGN=LEFT VALIGN=TOP>\
<A HREF="%r"><IMG SRC="%i" BORDER=NONE ALIGN=MIDDLE ALT=""></A>\
<TD NOWRAP ALIGN=LEFT VALIGN=TOP><A HREF="%r">&abbrev(%n,20,...)</A>\
<TD NOWRAP ALIGN=LEFT VALIGN=TOP>%s<TD>%l\
<TD NOWRAP ALIGN=LEFT VALIGN=TOP>&if(%d,%d,<I>%c</I>)\n"
	ListBottom "</TABLE></CENTER>\n"
	LastModifiedFormat "%d-%b-%y %H:%M"
	Include "*"
	MIMEIcon "text/html /icons/layout.gif"
	MIMEIcon "text/x-code /icons/c.gif"
	MIMEIcon "text/x-perl /icons/p.gif"
	MIMEIcon "text/* /icons/text.gif"
	MIMEIcon "internal/x-directory /icons/folder.gif"
	MIMEIcon "audio/* /icons/sound2.gif"
	MIMEIcon "image/* /icons/image2.gif"
	MIMEIcon "application/x-uuencoded /icons/uuencoded.gif"
	MIMEIcon "application/x-tar /icons/compressed.gif"
	MIMEIcon "application/x-gzip /icons/compressed.gif"
	MIMEIcon "application/x-sh /icons/script.gif"
	MIMEIcon "application/* /icons/binary.gif"
	MIMEIcon "x-world/x-vrml /icons/burst.gif"
	MIMEIcon "*/* /icons/unknown.gif"
	DescriptionFile ".desc"
	SwapFileName ".. Parent Directory"
	FooterPattern "<HR SIZE=1 NOSHADE>\
Contact the hostmaster <A HREF="mailto:$a"<I>$a</I></A>.\
</BODY></HTML>"
	HeaderFile "HEADER"
	FooterFile "README"
	Exclude "."
	Exclude "~*"
	Exclude ".desc"
	Exclude "README"
	Exclude "HEADER"
	Options " Name | AbbrevSize | RelPath | Icon | MIMEType "
</Object>

# ---
#
# Raw tab delimited directory index. For input into other
# applications. This data could be cut and pasted into a 
# spreadsheet application.
#
# ---
<Object>
	Name TDT
	Class DirectoryIndexClass
	FilePattern "%r\t%n\t%l\t%s\t%c\n"
	LastModifiedFormat "%d-%b-%y %H:%M"
	Include "*"
	Exclude "."
	Exclude "~*"
	Exclude ".desc"
	Exclude "README"
	Exclude "HEADER"
	HTTPEquiv "Content-Type: text/plain"
	Options " Name | Size | RelPath "
</Object>

# ---
#
# CGIFileIOObject
# 	
#	IOObject used for communication between web browser and
#	server.
#
# ---
<Object>
	Name CGIFileIOObject
	Class PipeIOClass
	ReadTimeout -1
	WriteTimeout 10
	NoYield "Read"
</Object>

# ---
#
# StandardCGI
#
# Configuration for Standard CGI
#
# ---
<Object>
	Name StandardCGI
	Class CGIClass
	
	# Specify the IO object use to communicate with the CGI program
	FileIOObject CGIFileIOObject

	# Snoop IO objects can be instantiated in the IO chain with a line
	# like this. They log all IO trafic. This is useful for debugging.
#	FileIOObject SnoopIOObject IOObject="CGIFileIOObject" OutFile="cgi.dbg" 

	DefaultCommandLine "%p%q"
	CommandLineByExt .bat="cmd.exe /c %p%q"
	CommandLineByExt .cmd="cmd.exe /c %p%q"
	CommandLineByExt .pl="perl %p%q"
	IncludeParentsEnvironment Yes
	EnvironmentSize 8192
	
	# These are the environment variables that are sent to the
	# CGI program
	Variable "AUTH_TYPE=$x"
	Variable "CONTENT_LENGTH=$Y"
	Variable "CONTENT_TYPE=$C"
	Variable "HTTPS=$g"
	Variable "&if($K,HTTPS_KEYSIZE=$K,)"
	Variable "&if($K,HTTPS_SECRETKEYSIZE=$G,)"
	Variable "GATEWAY_INTERFACE=CGI/1.1"
	Variable "PATH_INFO=$I"
	Variable "PATH_TRANSLATED=$Z"
	Variable "QUERY_STRING=$q"
	Variable "REMOTE_ADDR=$A"
	Variable "REMOTE_HOST=$h"
	Variable "REMOTE_IDENT=$i"
	Variable "REMOTE_USER=$u"
	Variable "REQUEST_METHOD=$m"
	Variable "SCRIPT_NAME=$z"
	Variable "SERVER_NAME=$v"
	Variable "SERVER_PORT=&if($p,$p,&if($K,443,80))"
	Variable "SERVER_PROTOCOL=$H"
	Variable "SERVER_SOFTWARE=$S"
	ExtraHeaders Yes
	ExtraHeadersPrefix "HTTP_"
	ExtraHeadersIgnore "Content-Type Content-Length"
	SendCRLF Yes
</Object>

# ---
#
# WinCGI
#
# Handle windows CGI
#
# ---
<Object>
	Name WinCGI
	Class CGIClass
	FileIOObject CGIFileIOObject
	DefaultCommandLine "%p %d"
	IncludeParentsEnvironment Yes
	EnvironmentSize 8192
	Variable "AUTH_TYPE=$x"
	Variable "CONTENT_LENGTH=$Y"
	Variable "CONTENT_TYPE=$C"
	Variable "HTTPS=$g"
	Variable "&if($K,HTTPS_KEYSIZE=$K,)"
	Variable "&if($K,HTTPS_SECRETKEYSIZE=$G,)"
	Variable "GATEWAY_INTERFACE=CGI/1.1"
	Variable "PATH_INFO=$I"
	Variable "PATH_TRANSLATED=$Z"
	Variable "QUERY_STRING=$q"
	Variable "REMOTE_ADDR=$A"
	Variable "REMOTE_HOST=$h"
	Variable "REMOTE_IDENT=$i"
	Variable "REMOTE_USER=$u"
	Variable "REQUEST_METHOD=$m"
	Variable "SCRIPT_NAME=$z"
	Variable "SERVER_NAME=$v"
	Variable "SERVER_PORT=&if($p,$p,&if($K,443,80))"
	Variable "SERVER_PROTOCOL=$H"
	Variable "SERVER_SOFTWARE=$S"
	ExtraHeaders Yes
	ExtraHeadersPrefix "HTTP_"
	ExtraHeadersIgnore "Content-Type Content-Length"

	# Generate windows CGI filenames by preappending the
	# process id to the unique identifier.
	DataFile "cgi-temp/$P_%u.ini"
	StdinFile "cgi-temp/$P_%u.in"
	StdoutFile "cgi-temp/$P_%u.out"
	DataBlock "\
[CGI]$M\
Request Protocol=$H$M\
Request Method=$m$M\
Physical Path=$f$M\
CGI Version=CGI/1.1 (Win)$M\
Content Type=$C/* short for  &dblookup(request,rfc822,Content-Type)*/$M\
Content Length=$Y/* short for &dblookup(request,rfc822,Content-Length)*/$M\
$M\
[Accept]$M\
$M\
[System]$M\
Output File=%o$M\
Content File=%i$M\
$M\
[Accept]$M\
$M\
[Extra Headers]$M\
$M\
[Form Literal]$M\
$M\
[Form External]$M\
$M\
[Form File]$M\
$M\
[Form Huge]$M\
$M\
"
	SendCRLF Yes
</Object>