📄 pi3file.cpp
字号:
const char *pTmp = M_LookupValueEx( pConfig, "HTTP",
"IndexFile", iTmp );
if ( !pTmp ) { break; };
os << " IndexFile=\"" << pTmp << "\"";
}
#define SECTION_P14 "\n\
CheckPath Condition=\"&cmp(&dblookup(response,string,ObjectMap),Redirect)\" \
StatusCode StatusCode=\"302\"\n\
CheckPath RefuseFileByMask AllowFileMask=\"EF\" RefuseStatus=404\n\
CheckPath RefuseFileByMask AllowFileMask=\"F\" RefuseStatus=403\n\
CheckPath ReturnCode ReturnCode=COMPLETED\n\
CheckAuth Authenticate\n\
CheckAccess AccessByFile RequirePermissions=\"R\"\n\
\n\
CheckType ConditionalGet \n\
CheckType CheckForDirectory SetType=\"internal/x-directory\"\n\
\n\
#\n\
# Otherwise: Set the media type based on the file extension\n\
#\n\
CheckType MIMETypeByExtension \n\
\n\
#\n\
# Set StatusCode 501 for not allowed HTTP verbs\n\
#\n\
CheckType Condition=\"¬(®exp(*$m*,\
"
os << SECTION_P14;
/*
** Advanced HTTP (1.1) settings
*/
__iOptions = atoi(L("HTTP", "Methods"));
if ( __iOptions & 1 ) { os << "GET"; };
if ( __iOptions & 2 ) { os << "HEAD"; };
if ( __iOptions & 4 ) { os << "POST"; };
if ( __iOptions & 8 ) { os << "PUT"; };
if ( __iOptions & 16 ) { os << "DELETE"; };
if ( __iOptions & 32 ) { os << "OPTIONS"; };
if ( __iOptions & 64 ) { os << "TRACE"; };
os << "))\" StatusCode StatusCode=\"501\"\n";
#define SECTION_P15 "\n\
#\n\
# Return 'COMPLETED' so an internal error will not be raised\n\
#\n\
CheckType ReturnCode ReturnCode=COMPLETED\n\
\n\
#\n\
# Most requests refer to a file, so put that first \n\
#\n\
# Handle GET and HEAD requests by sending a file if NEITHER\n\
# - the value of ObjectMap in the response DB is set\n\
# NOR\n\
# - the media type of the resource does match 'internal/*'\n\
#\n\
Handle Condition=\"¬(&or(&dblookup(response,string,ObjectMap),\\\n\
®exp('internal/*',$c)))\" SendFile"
os << SECTION_P15;
if (L("HTTP", "Ranges" )[0])
{
os << " Ranges=\"" << L("HTTP", "Ranges" ) << "\"";
}
if (L("HTTP", "ChunkLimit" )[0])
{
os << " ChunkLimit=\"" << L("HTTP", "ChunkLimit" ) << "\"";
}
os << endl;
/*
** Directory Index
*/
os << "\tHandle Condition=\"&cmp($c,internal/x-directory)\" ";
// allow customized directory index
if ( atoi(L( "DirIndex", "Layout" )) == 6 )
{ os << "CustomIndex" << endl; }
else
{ os << "DirIndex" << endl; }
/*
** Remaining response types
*/
#define SECTION_P15_1 "\
Handle Condition=\"&cmp($c,internal/x-server-parsed-html)\" SendSSI \\\n\
Exec=Yes ExecFileFixup=\"\\n\
/* exec file=\"\" maps to Standard CGI (Scripts) */\\\n\
&dbreplace(response,string,ObjectMap,Scripts)\\n\
&dbreplace(response,rfc822,Content-Type,internal/x-cgi)\"\n\
Handle Condition=\"&cmp($c,internal/x-imagemap)\" ImageMap\n\
Handle Condition=\"&cmp($c,internal/x-server-parsed-php)\" PHP4\n\
Handle SendFile"
os << SECTION_P15_1;
/*
** Advanced HTTP (1.1) settings
*/
#define empty ""
#define or " | "
const char *sep = empty;
__iOptions = atoi(L("HTTP", "Methods"));
if ( __iOptions ) { os << " Methods=\""; };
if ( __iOptions & 1 ) { os << sep << "GET"; sep = or; };
if ( __iOptions & 2 ) { os << sep << "HEAD"; sep = or; };
if ( __iOptions & 4 ) { os << sep << "POST"; sep = or; };
if ( __iOptions & 8 ) { os << sep << "PUT"; sep = or; };
if ( __iOptions & 16 ) { os << sep << "DELETE"; sep = or; };
if ( __iOptions & 32 ) { os << sep << "OPTIONS"; sep = or; };
if ( __iOptions & 64 ) { os << sep << "TRACE"; sep = or; };
if ( __iOptions ) { os << "\""; };
#undef empty
#undef or
if ((__iOptions & 4) && L("HTTP", "Description" )[0])
{
os << " \\" << endl << "DescriptionFile=\".desc\"";
}
if ((__iOptions & 4) && L("HTTP", "Annotation" )[0])
{
os << " \\" << endl << "Annotation=\"";
os << "From:\\t$A$MHost:\\t$h$MTime:\\t$t$MUrl:\\t\"$r\\\"$M\"";
}
if ((__iOptions & 4) && L("HTTP", "UploadPath" )[0])
{
os << " \\" << endl;
os << "UploadPath=\"" << L("HTTP", "UploadPath" ) << "\"";
}
if ((__iOptions & 4) && L("HTTP", "UploadLimit" )[0])
{
os << " \\" << endl;
os << "UploadLimit=\"" << L("HTTP", "UploadLimit" ) << "\"";
}
os << endl;
/*
** General logfiles
*/
/*
** Write in mappings
*/
iTmp = 0;
for(;; iTmp++ )
{
const char *pTmp = M_LookupValueEx( pConfig, "Logfiles",
"Logging", iTmp );
if ( !pTmp ) { break; };
/*
** Split the logfiles into type and path
*/
int i;
for( i=0; pTmp[i] && pTmp[i]!='\t'; i++);
PIString sType( pTmp, i );
pTmp = &(pTmp[i]);
for( i=0; pTmp[i] && isspace(pTmp[i]); i++);
pTmp = &(pTmp[i]);
PIString sPath( pTmp );
if ( sType=="Access (CLF)" )
{ os << " Log AccessLogger "; }
else if ( sType=="Referer Logfile" )
{ os << " Log RefererLogger "; }
os << "File=\"" << sPath << "\" \n";
};
os << " Log ReturnCode ReturnCode=COMPLETED\n\
Destroy DeleteTemporaryFiles\n\
</Object>\n\
\n";
#define SECTION_P30 "\n\
# ---\n\
#\n\
# HTTPLogicObject\n\
#\n\
# HTTP Logic object, dispatches requests to all other handlers\n\
#\n\
# ---\n\
<Object>\n\
Name HTTPLogicObject\n\
Class HTTPDispatcherClass\n\
ServerRoot ./../\n\
"
#define SECTION_P30_05 "\
DefaultHost MainVirtualHostInformation\n\
# MIMEFile is not used here because extensions to media mappings are done \n\
# explicitly with AddMIMEEntry \n\
# MIMEFile \"Fragment/Mime.typ\"\n\
"
#define SECTION_P30_01 "\n\
# Specifying a file for DebugLogFile effectively turns on debugging\n"
#define SECTION_P30_02 "\n\
#\n\
# The following to directives specify expressions to be logged\n\
# before and after each handler execution respectively.\n\
# The expression as given logs process/thread and handler context\n\
# information indented to the nested handler level.\n\
#\n\
# Timing information is also given for performance tuning.\n\
#\n\
# This logging information is EXTREMELY verbose. Don't even\n\
# think about using it in a production server\n\
#\n\
DebugBeforeHandler \"[$P:$k] &align(,$X)&align(,$X) |--> $T \\\n\
-------- &align($N,12) &align($R,12) $n \\\"$r\\\" $s\"\n\
DebugAfterHandler \"[$P:$k] &align(,$X)&align(,$X) |<-- $T \\\n\
&align($D,8) &align($N,12) &align($R,12) $n \\\"$r\\\" $s\"\n\
</Object>\n\
"
os << SECTION_P30;
/*
** Write in ServerStamp
*/
os << "\tServerStamp " << L( "HTTP", "ServerStamp" ) << endl;
/*
** Write in MIME types
*/
iTmp = 0;
for(;; iTmp++ )
{
const char *pTmp = M_LookupValueEx( pConfig, "MIMETypes",
"Mapping", iTmp );
if ( !pTmp ) { break; };
os << "\tAddMIMEEntry \"" << pTmp << "\"" << endl;
};
os << "\tKeepOpen \"" << L( "General", "KeepOpen" ) << '"' << endl;
if (!strcmp( L( "General", "KeepOpen" ), "On" ))
{
os << "\tKeepOpenCount " << L( "General", "KeepOpenCount" ) << endl;
os << "\tKeepOpenTimeout " << L( "General", "KeepOpenTimeout" ) << endl;
}
os << "\tDefaultMIMEType \"" << L( "Internal", "DefaultMIMEType" )
<< "\"" << endl;
os << SECTION_P30_05;
/*
** Error Log
*/
if (*L( "General", "ErrorLog" ))
{ os << "\tErrorLogFile \"Logs/error.txt\"" << endl; }
else
{ os << "#\tErrorLogFile \"Logs/error.txt\"" << endl; }
os << L( "Internal", "HandlerLine" ) << endl;
os << SECTION_P30_01;
/*
** Debug Log
*/
if (*L( "General", "Debug" ))
{ os << "\tDebugLogFile \"Logs/debug.txt\"" << endl; }
else
{ os << "#\tDebugLogFile \"Logs/debug.txt\"" << endl; }
os << SECTION_P30_02;
#define SECTION_P31 "\n\
# ---\n\
#\n\
# TopSiteLogic object, dispatch handlers for this website\n\
#\n\
# ---\n\
<Object>\n\
Name TopSiteLogic\n\
Class FlexibleHandlerClass\n\
"DEFAULT_HANDLERS"\n\
</Object>\n\
\n\
# ---\n\
#\n\
# SiteRoot object, root for this website\n\
#\n\
# ---\n\
<Object>\n\
Name TopSiteRoot\n\
Class SiteRootClass\n\
LogicObject \"TopSiteLogic\"\n\
Realm \"Administration\"\n\
ConfigFile \""
if (strstr(M_LookupValue( pConfig, "Internal", "HandlerLine" ), "TopSiteRoot" )) {
PIString Abs("");
RelativeToAbsolutePath( "./../",
M_LookupValue( pConfig, "Startup", "ConfigName" ), Abs );
os << SECTION_P31;
os << (const char *)Abs;
os << "\"\n\
</Object>\n\
";
}
/*
** Setup authentication
*/
#define SECTION_P60 "\n\
# ---\n\
#\n\
# Authenticate\n\
#\n\
# Handle authentication according to realm\n\
#\n\
# ---\n\
<Object>\n\
Name Authenticate\n\
Class FlexibleHandlerClass\n\
# Pass authentication if there is no realm \n\
CheckAuth Condition=\"¬(&dblookup(response,string,AuthenticationRealm))\" \\\n\
\t\tReturnCode ReturnCode=COMPLETED\n"
os << SECTION_P60;
for(iTmp = 0;; iTmp++ )
{
const char *pTmp = M_LookupValueEx( pConfig, "Realms", "Basic", iTmp );
if ( !pTmp ) { break; };
os << "\tCheckAuth BasicAuth_" << pTmp << endl;
};
for(iTmp = 0;; iTmp++ )
{
const char *pTmp = M_LookupValueEx( pConfig, "Realms", "Digest", iTmp );
if ( !pTmp ) { break; };
os << "\tCheckAuth DigestAuth_" << pTmp << endl;
};
for(iTmp = 0;; iTmp++ )
{
const char *pTmp = M_LookupValueEx( pConfig, "Realms", "Ntlm", iTmp );
if ( !pTmp ) { break; };
os << "\tCheckAuth NtlmAuth_" << pTmp << endl;
};
os << "</Object>" << endl;
/*
** Write information on the realms
*/
#define SECTION_P61 "\n\
# ---\n\
#\n\
# Authentication realm objects\n\
#\n\
# ---\n"
os << SECTION_P61;
iTmp = 0;
for(;; iTmp++ )
{
const char *pTmp = M_LookupValueEx( pConfig, "Realms",
"Basic", iTmp );
if ( !pTmp ) { break; };
os << "<Object>" << endl << "\tName BasicAuth_" << pTmp << endl;
os << "\tClass BasicAuthClass" << endl;
/*
** list all the users for this realm
*/
int iTmp2 = 0;
PIString sRealm( "__" );
sRealm.Concatenate( pTmp );
os << "\tRealm \"" << pTmp << "\"" << endl;
for(;; iTmp2++ )
{
const char *pTmp2 = M_LookupValueEx( pConfig, sRealm,
"Base64", iTmp2 );
if ( !pTmp2 ) { break; };
os << "\tBase64 \"" << pTmp2 << "\"" << endl;
};
os << "</Object>" << endl;
};
iTmp = 0;
for(;; iTmp++ )
{
const char *pTmp = M_LookupValueEx( pConfig, "Realms",
"Digest", iTmp );
if ( !pTmp ) { break; };
os << "<Object>" << endl << "\tName DigestAuth_" << pTmp << endl;
os << "\tClass DigestAuthClass" << endl;
/*
** list all the users for this realm
*/
int iTmp2 = 0;
PIString sRealm( "__" );
sRealm.Concatenate( pTmp );
os << "\tRealm \"" << pTmp << "\"" << endl;
for(;; iTmp2++ )
{
const char *pTmp2 = M_LookupValueEx( pConfig, sRealm,
"Digest", iTmp2 );
if ( !pTmp2 ) { break; };
int iLen = strlen( pTmp2 );
int j;
for( j=0; j<iLen && pTmp2[j]!='\t'; j++ );
PIString sUser(pTmp2, j);
os << "\tUser \"" << (const char *)sUser
<< ":" << &pTmp2[j+1] << "\"" << endl;
};
os << "</Object>" << endl;
};
iTmp = 0;
for(;; iTmp++ )
{
const char *pTmp = M_LookupValueEx( pConfig, "Realms",
"Ntlm", iTmp );
if ( !pTmp ) { break; };
os << "<Object>" << endl << "\tName NtlmAuth_" << pTmp << endl;
os << "\tClass NtlmAuthClass" << endl;
/*
** no users for a Ntlm realm
*/
os << "</Object>" << endl;
};
/*
** Setup Directory Index
*/
iTmp = atoi(L("DirIndex", "Layout"));
const char *pTmp = L("DirIndex", "SortColumn");
#define SECTION_I00 "\n\
# ---\n\
#\n\
# Directory listing - Layout: \
"
os << SECTION_I00;
os << __pLayoutNames[iTmp-1] << endl;
switch ( iTmp )
{
/*
** HTML table index
*/
case 1:
{
#define SECTION_I10 "\
#\n\
# ---\n\
<Object>\n\
Name DirIndex\n\
Class DirectoryIndexClass\n\
HeaderPattern \"<HTML><TITLE>Index of %p (%SB in %N files)</TITLE>\\\n\
<BODY BACKGROUND=\"/icons/\\\n\
&if(&cmpi($o,MainVirtualHostInformation),Pi3Tile.gif,H2Tile.gif)\"/*background depends on vhost*/\\\n\
BGCOLOR=\"#FFFFFF\">\\\n\
<H2>Index of %p (%SB in %N files)</H2>\\n\"\n\
ListTop \"<CENTER><TABLE CELLSPACING=0 CELLPADDING=0 WIDTH=100
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -