⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 core.pl

📁 Unix下基于Web的管理工具
💻 PL
📖 第 1 页 / 共 3 页
字号:
sub edit_require{local($rv, $mode, $list);$_[0]->{'value'} =~ /^(\S+)\s*(.*)$/; $mode = $1; $list = $2;$rv = sprintf      "<input type=radio name=require_mode value=0 %s> Default<br>\n",      $mode ? "" : "checked";$rv .= sprintf      "<input type=radio name=require_mode value=1 %s> Only these users:\n",      $mode eq "user" ? "checked" : "";$rv .= sprintf      "<input name=require_user size=20 value=\"%s\"><br>\n",      $mode eq "user" ? $list : "";$rv .= sprintf      "<input type=radio name=require_mode value=2 %s> Only these groups:\n",      $mode eq "group" ? "checked" : "";$rv .= sprintf      "<input name=require_group size=20 value=\"%s\"><br>\n",      $mode eq "group" ? $list : "";$rv .= sprintf      "<input type=radio name=require_mode value=3 %s> All valid users<br>\n",      $mode eq "valid-user" ? "checked" : "";return (1, "Restrict access by login", $rv);}sub save_require{if ($in{'require_mode'} == 0) { return ( [ ] ); }elsif ($in{'require_mode'} == 1) { return ( [ "user $in{'require_user'}" ] ); }elsif ($in{'require_mode'} == 2) { return ( [ "group $in{'require_group'}" ] ); }else { return ( [ "valid-user" ] ); }}sub edit_Satisfy{return (1, "Clients must satisfy",	&choice_input_vert($_[0]->{'value'}, "Satisfy", "", "Default,",			   "All access controls,all","Any access control,any"));}sub save_Satisfy{return &parse_choice("Satisfy", "");}########################################################################## Misc. directivessub edit_CoreDumpDirectory{return (1, "Core dump directory",	 &opt_input($_[0]->{'value'}, "CoreDumpDirectory", "Server root", 20).	 &file_chooser_button("CoreDumpDirectory", 1));}sub save_CoreDumpDirectory{return &parse_opt("CoreDumpDirectory", '^\S+$', "Invalid core dump directory");}sub edit_LockFile{return (1, "Server lock file",        &opt_input($_[0]->{'value'}, "LockFile", "Default", 20).        &file_chooser_button("LockFile", 0));}sub save_LockFile{return &parse_opt("LockFile", '^\S+', "Invalid lock file");}sub edit_LimitRequestBody{return (1, "Maximum request body size",	&opt_input($_[0]->{'value'}, "LimitRequestBody", "Default", 8)."bytes");}sub save_LimitRequestBody{return &parse_opt("LimitRequestBody", '^\d+$', "Invalid request body size");}sub edit_LimitRequestFields{return (1, "Maximum headers in request",	&opt_input($_[0]->{'value'}, "LimitRequestFields", "Default", 6));}sub save_LimitRequestFields{return &parse_opt("LimitRequestFields", '^\d+$', "Invalid number of headers");}sub edit_LimitRequestFieldsize{return (1, "Maximum request header size",	&opt_input($_[0]->{'value'}, "LimitRequestFieldsize", "Default", 6));}sub save_LimitRequestFieldsize{return &parse_opt("LimitRequestFieldsize", '^\d+$', "Invalid header size");}sub edit_LimitRequestLine{return (1, "Maximum request line size",	&opt_input($_[0]->{'value'}, "LimitRequestLine", "Default", 6));}sub save_LimitRequestLine{return &parse_opt("LimitRequestLine", '^\d+$', "Invalid request line size");}sub edit_PidFile{return (1, "Server PID file",        &opt_input($_[0]->{'value'}, "PidFile", "Default", 20).        &file_chooser_button("PidFile", 0));}sub save_PidFile{return &parse_opt("PidFile", '^\S+$', "Invalid PID file");}sub edit_ScoreBoardFile{return (1, "Shared memory scoreboard file",        &opt_input($_[0]->{'value'}, "ScoreBoardFile", "Default", 20).        &file_chooser_button("ScoreBoardFile", 0));}sub save_ScoreBoardFile{return &parse_opt("ScoreBoardFile", '^\S+$', "Invalid scoreboard file");}sub edit_ServerType{return (1, "Server execution",        &choice_input($_[0]->{'value'}, "ServerType", "standalone",                      "Standalone,standalone", "Run from inetd,inetd"));}sub save_ServerType{return &parse_choice("ServerType", "standalone");}sub edit_ServerTokens{return (1, "Server HTTP header",	&select_input($_[0]->{'value'}, "ServerTokens", "Full",		      "Version and OS and modules,Full",		      "Version and OS,OS", "Version only,Min"));}sub save_ServerTokens{return &parse_select("ServerTokens", "Full");}########################################################################## User/group directivessub edit_Group{local($rv, @ginfo);$rv = sprintf "<input type=radio name=Group value=0 %s> Default&nbsp;\n",       $_[0] ? "" : "checked";$rv .= sprintf "<input type=radio name=Group value=1 %s> Group name\n",        $_[0] && $_[0]->{'value'} !~ /^#/ ? "checked" : "";$rv .= sprintf "<input name=Group_name size=8 value=\"%s\"> %s&nbsp;\n",	$_[0]->{'value'} !~ /^#/ ? $_[0]->{'value'} : "",	&group_chooser_button("Group_name", 0);$rv .= sprintf "<input type=radio name=Group value=2 %s> Group ID\n",        $_[0]->{'value'} =~ /^#/ ? "checked" : "";$rv .= sprintf "<input name=Group_id size=6 value=\"%s\">\n",	 $_[0]->{'value'} =~ /^#(.*)$/ ? $1 : "";return (2, "Run as Unix group", $rv);}sub save_Group{if ($in{'Group'} == 0) { return ( [ ] ); }elsif ($in{'Group'} == 1) { return ( [ $in{'Group_name'} ] ); }elsif ($in{'Group_id'} !~ /^\-?\d+$/) {	&error("'$in{'Group_id'}' is not a valid group ID");	}else { return ( [ "#$in{'Group_id'}" ] ); }}sub edit_User{local($rv, @uinfo);$rv = sprintf "<input type=radio name=User value=0 %s> Default&nbsp;\n",       $_[0] ? "" : "checked";$rv .= sprintf "<input type=radio name=User value=1 %s> User name\n",        $_[0] && $_[0]->{'value'} !~ /^#/ ? "checked" : "";$rv .= sprintf "<input name=User_name size=8 value=\"%s\"> %s&nbsp;\n",	$_[0]->{'value'} !~ /^#/ ? $_[0]->{'value'} : "",	&user_chooser_button("User_name", 0);$rv .= sprintf "<input type=radio name=User value=2 %s> User ID\n",        $_[0]->{'value'} =~ /^#/ ? "checked" : "";$rv .= sprintf "<input name=User_id size=6 value=\"%s\">\n",	 $_[0]->{'value'} =~ /^#(.*)$/ ? $1 : "";return (2, "Run as Unix user", $rv);}sub save_User{if ($in{'User'} == 0) { return ( [ ] ); }elsif ($in{'User'} == 1) { return ( [ $in{'User_name'} ] ); }elsif ($in{'User_id'} !~ /^\-?\d+$/) {	&error("'$in{'User_id'}' is not a valid user ID");	}else { return ( [ "#$in{'User_id'}" ] ); }}########################################################################## Error handling directivessub edit_ErrorDocument{local($rv, $len, $i);$rv = "<table border width=100%>\n";$rv .= "<tr $tb> <td><b>Error code</b></td> <td><b>Response</b></td> ".       "<td><b>URL or message</b></td> </tr>\n";$len = @{$_[0]} + 1;for($i=0; $i<$len; $i++) {	$v = $_[0]->[$i]->{'value'};	if ($v =~ /^(\d+)\s+((http|ftp|gopher):\S+)$/)		{ $code = $1; $type = 0; $url = $2; }	elsif ($v =~ /^(\d+)\s+"?(.*)$/) { $code = $1; $type = 1; $url = $2; }	else { $code = ""; $type = 0; $url = ""; }	$rv .= "<tr $cb>\n";	$rv .= "<td><input name=ErrorDocument_code_$i size=3 value=$code></td>\n";	$rv .= "<td><input type=radio name=ErrorDocument_type_$i value=0 ".	       ($type==0 ? "checked" : "")."> Goto URL..\n";	$rv .= "<input type=radio name=ErrorDocument_type_$i value=1 ".	       ($type==1 ? "checked" : "")."> Show message..</td>\n";	$rv .= "<td><input name=ErrorDocument_url_$i size=40 value=\"$url\"></td>\n";	$rv .= "</tr>\n";	}$rv .= "</table>\n";return (2, "Custom error responses", $rv);}sub save_ErrorDocument{local($i, $code, $url, @rv);for($i=0; defined($in{"ErrorDocument_code_$i"}); $i++) {	$code = $in{"ErrorDocument_code_$i"}; $url = $in{"ErrorDocument_url_$i"};	if ($code !~ /\S/ && $url !~ /\S/) { next; }	$code =~ /^\d\d\d$/ || &error("'$code' is not a valid error code");	if ($in{"ErrorDocument_type_$i"} == 0) {		$url =~ /^\S+$/ || &error("'$url' is not a valid URL");		push(@rv, "$code $url");		}	elsif ($_[0]->{'version'} >= 1.2) { push(@rv, "$code \"$url"); }	else { push(@rv, "$code $url"); }	}return ( \@rv );}########################################################################## Logging directivessub edit_ErrorLog{if ($_[1]->{'version'} < 1.3) {	return (1, "Error log file",		&opt_input($_[0]->{'value'}, "ErrorLog", "Default", 20).		&file_chooser_button("ErrorLog", 0));	}else {	local $v = $_[0]->{'words'}->[0];	local $t = !$v ? 3 :		   $v eq 'syslog' ? 2 :		   $v =~ /^\|/ ? 1 : 0;	$rv = sprintf "<input type=radio name=ErrorLog_type value=3 %s>\n",		$t == 3 ? "checked" : "";	$rv .= "Default\n";	$rv .= sprintf "<input type=radio name=ErrorLog_type value=2 %s>\n",		$t == 2 ? "checked" : "";	$rv .= "System Log<br>\n";	$rv .= sprintf "<input type=radio name=ErrorLog_type value=0 %s>\n",		$t == 0 ? "checked" : "";	$rv .= sprintf "File <input name=ErrorLog_file size=25 value='%s'>\n",		$t == 0 ? $v : "";	$rv .= sprintf "<input type=radio name=ErrorLog_type value=1 %s>\n",		$t == 1 ? "checked" : "";	$rv .= sprintf "Program <input name=ErrorLog_prog size=25 value='%s'><br>\n",		$t == 1 ? substr($v, 1) : "";	return (2, "Error log to", $rv);	}}sub save_ErrorLog{if ($_[0]->{'version'} < 1.3) {	$in{'ErrorLog_def'} || &allowed_auth_file($in{'ErrorLog'}) ||		&error("Error log file is not under the allowed directory");	return &parse_opt("ErrorLog", '^\S+$', "Invalid error log file");	}else {	if ($in{'ErrorLog_type'} == 3) {		return ( [ ] );		}	elsif ($in{'ErrorLog_type'} == 0) {		$in{'ErrorLog_file'} =~ /\S/ ||		    &error("Missing error log file");		&allowed_auth_file($in{'ErrorLog_file'}) ||		    &error("Error log file is not under the allowed directory");		return ( [ $in{'ErrorLog_file'} ] );		}	elsif ($in{'ErrorLog_type'} == 1) {		$in{'ErrorLog_prog'} =~ /\S/ ||		    &error("Missing error log program");		$access{'pipe'} ||		    &error("You are not allowed to pipe logs to programs");		return ( [ "\"|$in{'ErrorLog_prog'}\"" ] );		}	else {		return ( [ "syslog" ] );		}	}}########################################################################## Module directivessub edit_ClearModuleList_AddModule{local($mods, @allmods, $d, %mods, $m, $i, $rv);($ver, $mods) = &httpd_info($config{'httpd_path'});@allmods = grep { !/^core$/ } @$mods;local $conf = &get_config();foreach $d (&find_directive_struct("LoadModule", $conf)) {	if ($d->{'words'}->[1] =~ /(mod_\S+)\.so/) {		push(@allmods, $1);		}	elsif ($d->{'words'}->[1] =~ /lib([^\/\s]+)\.so/) {		push(@allmods, "mod_$1");		}	}if (@{$_[0]}) {	# Only selected modules have been enabled	foreach $d (@{$_[1]}) {		local $modc = $d->{'value'};		$modc =~ s/\.c$//;		$mods{$modc} = "checked";		}	}else { foreach $m (@allmods) { $mods{$m} = "checked"; } }$rv = &choice_input(@{$_[0]} ? 1 : 0, "ClearModuleList", 1,		    "All modules,0", "Selected modules..,1")."<br>\n";$rv .= "<table>\n";foreach $m (@allmods) {	if ($i%4 == 0) { $rv .= "<tr>\n"; }	$rv .= "<td><input name=AddModule type=checkbox value=$m ".	       "$mods{$m}> $m</td>\n";	if ($i++%4 == 3) { $rv .= "</tr>\n"; }	}$rv .= "</table>\n";return (2, "Active modules", $rv);}sub save_ClearModuleList_AddModule{if ($in{'ClearModuleList'}) {	local @mods = split(/\0/, $in{'AddModule'});	return ( [ "" ], [ map { $_.".c" } @mods ] );	}else { return ( [ ], [ ] ); }}1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -