📄 mod_info.c
字号:
if (!strcmp(module_name, entry->name)) { return entry->info; } entry++; } return 0;}static int display_info(request_rec *r){ module *modp = NULL; char buf[MAX_STRING_LEN], *cfname; char *more_info; const command_rec *cmd = NULL; const handler_rec *hand = NULL; server_rec *serv = r->server; int comma = 0; info_cfg_lines *mod_info_cfg_httpd = NULL; info_cfg_lines *mod_info_cfg_srm = NULL; info_cfg_lines *mod_info_cfg_access = NULL; r->allowed |= (1 << M_GET); if (r->method_number != M_GET) return DECLINED; r->content_type = "text/html"; ap_send_http_header(r); if (r->header_only) { return 0; } ap_hard_timeout("send server info", r); ap_rputs("<html><head><title>Server Information</title></head>\n", r); ap_rputs("<body><h1 align=center>Apache Server Information</h1>\n", r); if (!r->args || strcasecmp(r->args, "list")) { cfname = ap_server_root_relative(r->pool, ap_server_confname); mod_info_cfg_httpd = mod_info_load_config(r->pool, cfname, r); cfname = ap_server_root_relative(r->pool, serv->srm_confname); mod_info_cfg_srm = mod_info_load_config(r->pool, cfname, r); cfname = ap_server_root_relative(r->pool, serv->access_confname); mod_info_cfg_access = mod_info_load_config(r->pool, cfname, r); if (!r->args) { ap_rputs("<tt><a href=\"#server\">Server Settings</a>, ", r); for (modp = top_module; modp; modp = modp->next) { ap_rprintf(r, "<a href=\"#%s\">%s</a>", modp->name, modp->name); if (modp->next) { ap_rputs(", ", r); } } ap_rputs("</tt><hr>", r); } if (!r->args || !strcasecmp(r->args, "server")) { ap_rprintf(r, "<a name=\"server\"><strong>Server Version:</strong> " "<font size=+1><tt>%s</tt></a></font><br>\n", ap_get_server_version()); ap_rprintf(r, "<strong>Server Built:</strong> " "<font size=+1><tt>%s</tt></a></font><br>\n", ap_get_server_built()); ap_rprintf(r, "<strong>API Version:</strong> " "<tt>%d:%d</tt><br>\n", MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR); ap_rprintf(r, "<strong>Run Mode:</strong> <tt>%s</tt><br>\n", (ap_standalone ? "standalone" : "inetd")); ap_rprintf(r, "<strong>User/Group:</strong> " "<tt>%s(%d)/%d</tt><br>\n", ap_user_name, (int) ap_user_id, (int) ap_group_id); ap_rprintf(r, "<strong>Hostname/port:</strong> " "<tt>%s:%u</tt><br>\n", serv->server_hostname, serv->port); ap_rprintf(r, "<strong>Daemons:</strong> " "<tt>start: %d " "min idle: %d " "max idle: %d " "max: %d</tt><br>\n", ap_daemons_to_start, ap_daemons_min_free, ap_daemons_max_free, ap_daemons_limit); ap_rprintf(r, "<strong>Max Requests:</strong> " "<tt>per child: %d " "keep alive: %s " "max per connection: %d</tt><br>\n", ap_max_requests_per_child, (serv->keep_alive ? "on" : "off"), serv->keep_alive_max); ap_rprintf(r, "<strong>Threads:</strong> " "<tt>per child: %d </tt><br>\n", ap_threads_per_child); ap_rprintf(r, "<strong>Excess requests:</strong> " "<tt>per child: %d </tt><br>\n", ap_excess_requests_per_child); ap_rprintf(r, "<strong>Timeouts:</strong> " "<tt>connection: %d " "keep-alive: %d</tt><br>", serv->timeout, serv->keep_alive_timeout); ap_rprintf(r, "<strong>Server Root:</strong> " "<tt>%s</tt><br>\n", ap_server_root); ap_rprintf(r, "<strong>Config File:</strong> " "<tt>%s</tt><br>\n", ap_server_confname); ap_rprintf(r, "<strong>PID File:</strong> " "<tt>%s</tt><br>\n", ap_pid_fname); ap_rprintf(r, "<strong>Scoreboard File:</strong> " "<tt>%s</tt><br>\n", ap_scoreboard_fname); } ap_rputs("<hr><dl>", r); for (modp = top_module; modp; modp = modp->next) { if (!r->args || !strcasecmp(modp->name, r->args)) { ap_rprintf(r, "<dt><a name=\"%s\"><strong>Module Name:</strong> " "<font size=+1><tt>%s</tt></a></font>\n", modp->name, modp->name); ap_rputs("<dt><strong>Content handlers:</strong>", r); hand = modp->handlers; if (hand) { while (hand) { if (hand->content_type) { ap_rprintf(r, " <tt>%s</tt>\n", hand->content_type); } else { break; } hand++; if (hand && hand->content_type) { ap_rputs(",", r); } } } else { ap_rputs("<tt> <EM>none</EM></tt>", r); } ap_rputs("<dt><strong>Configuration Phase Participation:</strong> \n", r); if (modp->child_init) { ap_rputs("<tt>Child Init</tt>", r); comma = 1; } if (modp->create_dir_config) { if (comma) { ap_rputs(", ", r); } ap_rputs("<tt>Create Directory Config</tt>", r); comma = 1; } if (modp->merge_dir_config) { if (comma) { ap_rputs(", ", r); } ap_rputs("<tt>Merge Directory Configs</tt>", r); comma = 1; } if (modp->create_server_config) { if (comma) { ap_rputs(", ", r); } ap_rputs("<tt>Create Server Config</tt>", r); comma = 1; } if (modp->merge_server_config) { if (comma) { ap_rputs(", ", r); } ap_rputs("<tt>Merge Server Configs</tt>", r); comma = 1; } if (modp->child_exit) { if (comma) { ap_rputs(", ", r); } ap_rputs("<tt>Child Exit</tt>", r); comma = 1; } if (!comma) ap_rputs("<tt> <EM>none</EM></tt>", r); comma = 0; ap_rputs("<dt><strong>Request Phase Participation:</strong> \n", r); if (modp->post_read_request) { ap_rputs("<tt>Post-Read Request</tt>", r); comma = 1; } if (modp->header_parser) { if (comma) { ap_rputs(", ", r); } ap_rputs("<tt>Header Parse</tt>", r); comma = 1; } if (modp->translate_handler) { if (comma) { ap_rputs(", ", r); } ap_rputs("<tt>Translate Path</tt>", r); comma = 1; } if (modp->access_checker) { if (comma) { ap_rputs(", ", r); } ap_rputs("<tt>Check Access</tt>", r); comma = 1; } if (modp->ap_check_user_id) { if (comma) { ap_rputs(", ", r); } ap_rputs("<tt>Verify User ID</tt>", r); comma = 1; } if (modp->auth_checker) { if (comma) { ap_rputs(", ", r); } ap_rputs("<tt>Verify User Access</tt>", r); comma = 1; } if (modp->type_checker) { if (comma) { ap_rputs(", ", r); } ap_rputs("<tt>Check Type</tt>", r); comma = 1; } if (modp->fixer_upper) { if (comma) { ap_rputs(", ", r); } ap_rputs("<tt>Fixups</tt>", r); comma = 1; } if (modp->logger) { if (comma) { ap_rputs(", ", r); } ap_rputs("<tt>Logging</tt>", r); comma = 1; } if (!comma) ap_rputs("<tt> <EM>none</EM></tt>", r); comma = 0; ap_rputs("<dt><strong>Module Directives:</strong> ", r); cmd = modp->cmds; if (cmd) { while (cmd) { if (cmd->name) { ap_rprintf(r, "<dd><tt>%s - <i>", mod_info_html_cmd_string(cmd->name, buf, sizeof(buf))); if (cmd->errmsg) { ap_rputs(cmd->errmsg, r); } ap_rputs("</i></tt>\n", r); } else { break; } cmd++; } ap_rputs("<dt><strong>Current Configuration:</strong>\n", r); mod_info_module_cmds(r, mod_info_cfg_httpd, modp->cmds, "httpd.conf"); mod_info_module_cmds(r, mod_info_cfg_srm, modp->cmds, "srm.conf"); mod_info_module_cmds(r, mod_info_cfg_access, modp->cmds, "access.conf"); } else { ap_rputs("<tt> none</tt>\n", r); } more_info = find_more_info(serv, modp->name); if (more_info) { ap_rputs("<dt><strong>Additional Information:</strong>\n<dd>", r); ap_rputs(more_info, r); } ap_rputs("<dt><hr>\n", r); if (r->args) { break; } } } if (!modp && r->args && strcasecmp(r->args, "server")) { ap_rputs("<b>No such module</b>\n", r); } } else { for (modp = top_module; modp; modp = modp->next) { ap_rputs(modp->name, r); if (modp->next) { ap_rputs("<br>", r); } } } ap_rputs("</dl>\n", r); ap_rputs(ap_psignature("",r), r); ap_rputs("</body></html>\n", r); /* Done, turn off timeout, close file and return */ ap_kill_timeout(r); return 0;}static const char *add_module_info(cmd_parms *cmd, void *dummy, char *name, char *info){ server_rec *s = cmd->server; info_svr_conf *conf = (info_svr_conf *) ap_get_module_config(s->module_config, &info_module); info_entry *new = ap_push_array(conf->more_info); new->name = name; new->info = info; return NULL;}static const command_rec info_cmds[] ={ {"AddModuleInfo", add_module_info, NULL, RSRC_CONF, TAKE2, "a module name and additional information on that module"}, {NULL}};static const handler_rec info_handlers[] ={ {"server-info", display_info}, {NULL}};module MODULE_VAR_EXPORT info_module ={ STANDARD_MODULE_STUFF, NULL, /* initializer */ NULL, /* dir config creater */ NULL, /* dir merger --- default is to override */ create_info_config, /* server config */ merge_info_config, /* merge server config */ info_cmds, /* command table */ info_handlers, /* handlers */ NULL, /* filename translation */ NULL, /* check_user_id */ NULL, /* check auth */ NULL, /* check access */ NULL, /* type_checker */ NULL, /* fixups */ NULL, /* logger */ NULL, /* header parser */ NULL, /* child_init */ NULL, /* child_exit */ NULL /* post read-request */};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -