📄 xslt.pi3
字号:
#!../bin/Pi3
# ===
#
# Top level configuration
#
# ** 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
include ../Conf/HTTP.cnf
include ../Conf/Fcgi.cnf
include ../Conf/Pi3Perl.cnf
include ../Conf/XSLT.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 used by the server lookup the IP address that this server will
# listen on. A value of INADDR_ANY let the server listen on any IP address.
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 400
# Specify timeout for receiving data. -1 specifies no timeout.
SendTimeout 350
PeerIPVariable STRING:RemoteAddr
PeerHostNameVariable STRING:RemoteHost
LocalAddressVariable STRING:LocalAddr
ServerPortVariable STRING:ServerPort
# 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|DNSReverseLookup|SetPeerAddress|SetLocalAddress
</Object>
# ---
# Main virtual host object.
# ---
<Object>
Name MainVirtualHostInformation
Class VirtualHostClass
Administrator webmaster@localhost
HostName localhost
</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 20
# 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>
# ---
#
# 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 ReturnCode=COMPLETED
HostMap ReturnCode ReturnCode=COMPLETED
# Mapping DirectoryMappings
#
# Default mappings
#
Mapping MapToErrorDocument \
IgnoreStatus="0 200" \
DefaultMessage="/errors/unknown.htm" \
301="/errors/301.ssi" \
304="/errors/304.ssi" \
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 PathMapper From="/pidocs/" To="Pi3Docs\"
Mapping PathMapper From="/icons/" To="Icons\"
Mapping PathMapper From="/images/" To="Images\"
Mapping PathMapper From="/errors/" To="Fragment\"
Mapping PathMapper From="/admin/" To="Logs\" \
Action="&dbreplace(response,string,AuthenticationRealm,Administration)"
Mapping DocbookMapper From="/db/" To="WebRoot\db\"
Mapping PathMapper From="/" To="WebRoot\"
</Object>
# ---
#
# Default
#
# Handle requests that other handlers have passed up
#
# ---
<Object>
Name Default
Class FlexibleHandlerClass
CheckPath DirectoryExists IndexFile="index.ssi" IndexFile="index.html" IndexFile="index.htm" IndexFile="default.ssi" IndexFile="default.htm" IndexFile="default.html"
CheckPath RefuseFileByMask AllowFileMask="EF" RefuseStatus=404
CheckPath RefuseFileByMask AllowFileMask="F" RefuseStatus=403
CheckPath ReturnCode ReturnCode=COMPLETED
CheckAuth Authenticate
CheckAccess AccessByFile RequirePermissions="R"
# Old stuff !
#
# 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 Flag="RefreshOlderThanServer"
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)" TableHTML
Handle Condition="&cmp($c,internal/x-server-parsed-html)" SendSSI \
Exec=Yes ExecFileFixup="\n/* exec file="" maps to Standard CGI (Scripts) */\
&dbreplace(response,string,ObjectMap,Scripts)\n&dbreplace(response,rfc822,Content-Type,internal/x-cgi)"
Handle Condition="&cmp($c,internal/x-imagemap)" ImageMap
Handle Condition="&cmp($c,internal/x-server-parsed-xml)" XML
Handle SendFile
Log AccessLogger File="Logs/access.txt"
Log ReturnCode ReturnCode=COMPLETED
Destroy DeleteTemporaryFiles
</Object>
# ---
#
# HTTPLogicObject
#
# HTTP Logic object, dispatches requests to all other handlers
#
# ---
<Object>
Name HTTPLogicObject
Class HTTPDispatcherClass
KeepOpen "On"
DefaultMIMEType "application/octet-stream"
ServerRoot ./../
ServerStamp Pi3Web/2.0.3
DefaultHost MainVirtualHostInformation
MIMEFile "Fragment/Mime.typ"
ErrorLogFile "Logs/error.txt"
Handlers Start Docbook Default
# 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>
# ---
#
# Authenticate
#
# Handle authentication according to realm
#
# ---
<Object>
Name Authenticate
Class FlexibleHandlerClass
# Pass authentication if there is no realm
CheckAuth Condition="¬(&dblookup(response,string,AuthenticationRealm))" \
ReturnCode ReturnCode=COMPLETED
CheckAuth Pi3Perl File="../Pi3Perl/auth.pl" AuthFile="../Pi3Perl/Users.txt" \
Realm="Administration" Init="init" Execute="execute"
</Object>
# ---
#
# XML, SGML & XSLT logic handlers
#
# ---
<Object>
Name XML
Class FlexibleHandlerClass
CheckPath RefuseFileByMask AllowFileMask="EFD" RefuseStatus=404
CheckPath RefuseFileByMask AllowFileMask="F" RefuseStatus=403
CheckPath ReturnCode ReturnCode=COMPLETED
CheckAccess AccessByFile RequirePermissions="X"
CheckType ReturnCode ReturnCode=COMPLETED
# GET requests
Handle Condition="&cmp($m,GET)" XSLTransform
# fallback to POST method
Handle XSLTransform DefaultStylesheet="../WebRoot/default.xsl"
</Object>
<Object>
Name XSLTransform
Class XSLTClass
# These are the server variables that are sent to the
# stylesheet
Variable "AUTH_TYPE=\'$x\'"
Variable "CONTENT_TYPE=\'$C\'"
Variable "HTTPS=\'$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=\'$p\'"
Variable "SERVER_PROTOCOL=\'$H\'"
Variable "SERVER_SOFTWARE=\'$S\'"
ExtraHeaders Yes
ExtraHeadersPrefix "HTTP_"
ExtraHeadersIgnore "Content-Type"
Options NoNetEntities | SkipDtdLoading
# DefaultStylesheet "./default.xsl"
# DefaultContentType "text/plain"
# MaxDepth 255
# Options SkipDtdLoading | Validate | NoNetEntities | \
#WarnNetEntities | Verbose XInclude | SgmlCatalogs | Html | \
#Docbook | Timing | Profile | Debug
</Object>
<Object>
Name Docbook
Class FlexibleHandlerClass
Condition "&cmp(&dblookup(response,string,ObjectMap),DOCBOOK)"
CheckPath RefuseFileByMask AllowFileMask="EFD" RefuseStatus=404
CheckPath RefuseFileByMask AllowFileMask="F" RefuseStatus=403
CheckPath ReturnCode ReturnCode=COMPLETED
CheckAccess AccessByFile RequirePermissions="X"
CheckType ReturnCode ReturnCode=COMPLETED
# docbook xml
Handle Condition="&cmp($c,internal/x-server-parsed-xml)" XSLT \
Options="NoNetEntities | SkipDtdLoading" DefaultStylesheet="../WebRoot/db/html/docbook.xsl"
# docbook sgml
Handle XSLT Options="NoNetEntities | SkipDtdLoading | Docbook" \
DefaultStylesheet="../WebRoot/db/html/docbook.xsl"
</Object>
# ---
#
# Directory listing with HTML tables
#
# ---
<Object>
Name TableHTML
Class DirectoryIndexClass
HeaderPattern "<HTML><META HTTP-EQUIV="expires" CONTENT="0"><TITLE>Index of %p</TITLE>\
<BODY BACKGROUND="/icons/\
&if(&cmpi($o,MainVirtualHostInformation),Pi3Tile.gif,H2Tile.gif)"/*background depends on vhost*/\
BGCOLOR="#FFFFFF">\
<H2>Index of %p</H2>\n"
ListTop "<CENTER><TABLE CELLSPACING=0 CELLPADDING=0 WIDTH=100'%'>\
<TR>\
<TH NOWRAP ALIGN=LEFT></TH>\
<TH NOWARP ALIGN=LEFT><A HREF="%p?SortType=A">Type</A><BR>\ \
<TH NOWRAP ALIGN=LEFT><A HREF="%p?SortName=A">Name</A><BR>\ \
<TH NOWRAP ALIGN=LEFT><A HREF="%p?SortSize=A">Size</A><BR>\ \
<TH NOWRAP ALIGN=LEFT><A HREF="%p?SortDate=A">Last Modified</A><BR>\ \
<TH NOWRAP ALIGN=LEFT><A HREF="%p?SortDscr=A">Description</A><BR>\ \n"
FilePattern "<TR>\
<TD NOWRAP ALIGN=LEFT VALIGN=TOP>%m</TD><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 NOWRAP ALIGN=LEFT VALIGN=TOP>%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 ".. .."
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"
NewPattern "<IMG SRC="/icons/new.gif">"
NewTreshold 10
Options " Name | AbbrevSize | RelPath | Icon | MIMEType | SortType | TagNew"
</Object>
# ---
#
# SGMLMapper
#
# ---
<Object>
Name DocbookMapper
Class PathMapperClass
CaseSensitive "No"
PathInfo "Yes"
Action "&dbreplace(response,string,ObjectMap,DOCBOOK)"
</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>
# ---
#
# RefererLogger
#
# Log bad links only (HTTP error code 404)
#
# ---
<Object>
Name RefererLogger
Class ExpressionLoggerClass
#
# Append
#
OpenMode "a"
#
# Line to log
Expression "&if(&cmp($s,404),\
[$t] $h \"$r\" &dblookup(request,rfc822,Referer)$M)"
</Object>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -