📄 generate.c
字号:
fprintf(f, "%s <a href=\"%s\">%s %s</a>\n", _("Output generated by"),"http://www.kneschke.de/projekte/modlogan/", PACKAGE, VERSION); fprintf(f, "</BODY></HTML>\n"); }}void file_start_index(FILE *f, mconfig *ext_conf, time_t timestamp) { char buf[255]; struct tm *_tm; time_t t; config_output *conf = ext_conf->output; int show_default = 1; if (conf->html_header) { FILE *inf = fopen (conf->html_header, "r"); if (inf == NULL) { fprintf(stderr, "%s.%d: %s: %s", __FILE__, __LINE__, _("Can't open page header"),strerror(errno)); } else { char buf[255]; while (fgets(buf, sizeof(buf)-1, inf)) { if (fputs(buf, f) == EOF) { fprintf(stderr, "%s.%d: %s: %s", __FILE__, __LINE__, _("Can't write header"),strerror(errno)); break; } } show_default = 0; fclose(inf); } } if (show_default) { fprintf(f, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n\n"); fprintf(f, "<HTML><HEAD><TITLE>Statistics</TITLE>"); fprintf(f, "<LINK REL=STYLESHEET HREF=\"modlogan.css\" type=\"text/css\">"); fprintf(f, "<META http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">", conf->cont_charset); fprintf(f, "<META http-equiv=\"Content-Language\" content=\"%s\">", conf->cont_language); fprintf(f, "</HEAD>\n"); fprintf(f, "<BODY bgcolor=\"%s\">\n", conf->col_body); fprintf(f, "<H1>%s %s</H1>\n", _("Statistics for"), conf->hostname); if (timestamp != 0) { t = timestamp; _tm = localtime(&t); strftime(buf, sizeof(buf), "%X %x", _tm); fprintf(f, "<b>%s: </b>%s<br>\n", _("Last record"), buf); } t = time(NULL); _tm = localtime(&t); strftime(buf, sizeof(buf), "%X %x", _tm); fprintf(f, "<b>%s: </b>%s<br>\n", _("Generated at"), buf); fprintf(f, "<HR><br>\n"); }}void file_end_index(FILE *f, mconfig *ext_conf) { config_output *conf = ext_conf->output; int show_default = 1; if (conf->html_footer) { FILE *inf = fopen (conf->html_footer, "r"); if (inf == NULL) { fprintf(stderr, "%s.%d: %s: %s", __FILE__, __LINE__, _("Can't open page footer"),strerror(errno)); } else { char buf[255]; while (fgets(buf, sizeof(buf)-1, inf)) { if (fputs(buf, f) == EOF) { fprintf(stderr, "%s.%d: %s: %s", __FILE__, __LINE__, _("Can't write footer"),strerror(errno)); break; } } show_default = 0; fclose(inf); } } if (show_default) {/* Tell the users that this is valid HTML 4.0 :) */ fprintf(f, "<HR>"); if (conf->show_validation_links) { fprintf(f, "<a href=\"http://validator.w3.org/check/referer\"><img border=0 "\ "src=\"http://validator.w3.org/images/vh40\" "\ "alt=\"Valid HTML 4.0!\" height=31 width=88 align=\"right\"></a>");/* Tell the users that this is even valid CSS :) */ fprintf(f, "<A HREF=\"http://jigsaw.w3.org/css-validator/check/referer/\"><IMG border=0 width=\"88\" height=\"31\""); fprintf(f, "SRC=\"http://jigsaw.w3.org/css-validator/images/vcss.gif\" ALT=\"Valid CSS!\" align=\"right\"></A>"); } fprintf(f, "%s <a href=\"%s\">%s %s</a>\n", _("Output generated by"),"http://www.kneschke.de/projekte/modlogan/", PACKAGE, VERSION); fprintf(f, "</BODY></HTML>\n"); }}char *table_header(int maxcount, int count, char *str) { static char trans_buf[255]; sprintf(trans_buf, "%d %s %d %s", (maxcount > count) || (maxcount < 0) ? count : maxcount, _("of"), count, str); return trans_buf; }#define M_TYPE_REPORT 1#define M_TYPE_PAGE 2#define M_REPORT_REQ_URL 1#define M_REPORT_REF_URL 2#define M_REPORT_OS 3#define M_REPORT_HOSTS 4#define M_REPORT_ENTRY_PAGES 5#define M_REPORT_EXIT_PAGES 6#define M_REPORT_USERAGENT 7#define M_REPORT_INDEXED 8#define M_REPORT_REQ_PROT 9#define M_REPORT_REQ_METH 10#define M_REPORT_STATUS_CODES 11#define M_REPORT_ROBOTS 12#define M_REPORT_BOOKMARKS 13#define M_REPORT_BROKEN_LINKS 14#define M_REPORT_INTERNAL_ERROR 15#define M_REPORT_SEARCH_ENGINE 16#define M_REPORT_SEARCH_STRINGS 17#define M_REPORT_COUNTRIES 18#define M_REPORT_SUMMARY 19#define M_REPORT_HOURLY 20#define M_REPORT_DAILY 21#define M_PAGE_INDEX 128#define M_PAGE_001 129#define M_PAGE_002 130#define M_PAGE_003 131#define M_PAGE_004 132#define M_PAGE_000 133int get_menu_items (mconfig *ext_conf, mstate *state, mlist *l) { data_StrInt *data; config_output *conf = ext_conf->output; int i = 0; mstate_web *staweb = state->ext; data = createStr2Int("/000", M_TYPE_PAGE, M_PAGE_INDEX); mlist_insert(l, data);/* page 0 */ data = createStr2Int("/000/000", M_TYPE_PAGE, M_PAGE_000); mlist_insert(l, data); data = createStr2Int("/000/000/000", M_TYPE_REPORT, M_REPORT_SUMMARY); mlist_insert(l, data); data = createStr2Int("/000/000/001", M_TYPE_REPORT, M_REPORT_DAILY); mlist_insert(l, data); data = createStr2Int("/000/000/002", M_TYPE_REPORT, M_REPORT_HOURLY); mlist_insert(l, data); /* page 1 */ i = 0; if (conf->max_req_urls && mhash_count(staweb->req_url_hash)) { data = createStr2Int("/000/001/001", M_TYPE_REPORT, M_REPORT_REQ_URL); mlist_insert(l, data); i = 1; } if (conf->max_ref_urls && mhash_count(staweb->ref_url_hash)) { data = createStr2Int("/000/001/002", M_TYPE_REPORT, M_REPORT_REF_URL); mlist_insert(l, data); i = 1; } if (conf->max_entry_pages && mhash_count(staweb->entry_pages)) { data = createStr2Int("/000/001/003", M_TYPE_REPORT, M_REPORT_ENTRY_PAGES); mlist_insert(l, data); i = 1; } if (conf->max_exit_pages && mhash_count(staweb->exit_pages)) { data = createStr2Int("/000/001/004", M_TYPE_REPORT, M_REPORT_EXIT_PAGES); mlist_insert(l, data); i = 1; } if (i) { data = createStr2Int("/000/001", M_TYPE_PAGE, M_PAGE_001); mlist_insert(l, data); }/* page 2 */ i = 0; if (conf->max_os && mhash_count(staweb->os_hash)) { data = createStr2Int("/000/002/001", M_TYPE_REPORT, M_REPORT_OS); mlist_insert(l, data); i = 1; } if (conf->max_hosts && mhash_count(staweb->host_hash)) { data = createStr2Int("/000/002/002", M_TYPE_REPORT, M_REPORT_HOSTS); mlist_insert(l, data); i = 1; } if (conf->max_ua && mhash_count(staweb->ua_hash)) { data = createStr2Int("/000/002/003", M_TYPE_REPORT, M_REPORT_USERAGENT); mlist_insert(l, data); i = 1; } if (conf->max_countries && mhash_count(staweb->country_hash)) { data = createStr2Int("/000/002/004", M_TYPE_REPORT, M_REPORT_COUNTRIES); mlist_insert(l, data); i = 1; } if (i) { data = createStr2Int("/000/002", M_TYPE_PAGE, M_PAGE_002); mlist_insert(l, data); } /* page 3 */ i = 0; if (conf->max_indexed_pages && mhash_count(staweb->indexed_pages)) { data = createStr2Int("/000/003/001", M_TYPE_REPORT, M_REPORT_INDEXED); mlist_insert(l, data); i = 1; } if (conf->max_robots && mhash_count(staweb->robots)) { data = createStr2Int("/000/003/002", M_TYPE_REPORT, M_REPORT_ROBOTS); mlist_insert(l, data); i = 1; } if (conf->max_bookmarks && mhash_count(staweb->bookmarks)) { data = createStr2Int("/000/003/003", M_TYPE_REPORT, M_REPORT_BOOKMARKS); mlist_insert(l, data); i = 1; } if (conf->max_search_engines && mhash_count(staweb->searchsite)) { data = createStr2Int("/000/003/004", M_TYPE_REPORT, M_REPORT_SEARCH_ENGINE); mlist_insert(l, data); i = 1; } if (conf->max_search_strings && mhash_count(staweb->searchstring)) { data = createStr2Int("/000/003/005", M_TYPE_REPORT, M_REPORT_SEARCH_STRINGS); mlist_insert(l, data); i = 1; } if (i) { data = createStr2Int("/000/003", M_TYPE_PAGE, M_PAGE_003); mlist_insert(l, data); }/* page 4 */ i = 0; if (conf->max_req_prot && mhash_count(staweb->req_prot_hash)) { data = createStr2Int("/000/004/001", M_TYPE_REPORT, M_REPORT_REQ_PROT); mlist_insert(l, data); i = 1; } if (conf->max_req_meth && mhash_count(staweb->req_meth_hash)) { data = createStr2Int("/000/004/002", M_TYPE_REPORT, M_REPORT_REQ_METH); mlist_insert(l, data); i = 1; } if (conf->max_status_codes && mhash_count(staweb->status_hash)) { data = createStr2Int("/000/004/003", M_TYPE_REPORT, M_REPORT_STATUS_CODES); mlist_insert(l, data); i = 1; } if (conf->max_broken_links && mhash_count(staweb->status_missing_file)) { data = createStr2Int("/000/004/004", M_TYPE_REPORT, M_REPORT_BROKEN_LINKS); mlist_insert(l, data); i = 1; } if (conf->max_internal_errors && mhash_count(staweb->status_internal_error)) { data = createStr2Int("/000/004/005", M_TYPE_REPORT, M_REPORT_INTERNAL_ERROR); mlist_insert(l, data); i = 1; } if (i) { data = createStr2Int("/000/004", M_TYPE_PAGE, M_PAGE_004); mlist_insert(l, data); } return 0;}char * get_menu_item(int type) { switch(type) { case M_REPORT_REQ_URL: return _("Requested URL's"); case M_REPORT_REF_URL: return _("Referrers"); case M_REPORT_OS: return _("Operating system"); case M_REPORT_HOSTS: return _("Hosts"); case M_REPORT_ENTRY_PAGES: return _("Entry Pages"); case M_REPORT_EXIT_PAGES: return _("Exit Pages"); case M_REPORT_USERAGENT: return _("Browsers"); case M_REPORT_INDEXED: return _("Indexed Pages"); case M_REPORT_REQ_PROT: return _("Request Protocol"); case M_REPORT_REQ_METH: return _("Request Method"); case M_REPORT_STATUS_CODES: return _("Status Code"); case M_REPORT_ROBOTS: return _("Robots"); case M_REPORT_BOOKMARKS: return _("Bookmarked Pages"); case M_REPORT_BROKEN_LINKS: return _("Broken Links"); case M_REPORT_INTERNAL_ERROR: return _("Internal Errors"); case M_REPORT_SEARCH_ENGINE: return _("SearchEngines"); case M_REPORT_SEARCH_STRINGS: return _("SearchStrings"); case M_REPORT_COUNTRIES: return _("Countries"); case M_REPORT_SUMMARY: return _("Summary"); case M_REPORT_HOURLY: return _("Hourly Statistics"); case M_REPORT_DAILY: return _("Daily Statistics"); case M_PAGE_INDEX: return _("Index"); case M_PAGE_000: return _("Overview"); case M_PAGE_001: return _("URLs"); case M_PAGE_002: return _("User"); case M_PAGE_003: return _("Searchengines"); case M_PAGE_004: return _("Server Internals"); default: return "(null)"; }}char *get_url(mconfig *ext_conf, int year, int month, char *sub, char *report) { static char filename[255]; config_output *conf = ext_conf->output; if (conf->page_style && !strcasecmp(conf->page_style, "onepage")) { sprintf(filename, "m_usage_%04i%02i.html%s%.3s%s", year, month, sub ? "#" : "", sub ? sub : "", report ? report : ""); } else if (conf->page_style && !strcasecmp(conf->page_style, "seppage")) { sprintf(filename, "m_usage_%04i%02i_%.3s_%s.html", year, month, sub ? sub : "", report ? report : ""); } else { sprintf(filename, "m_usage_%04i%02i_%.3s.html%s%s", year, month, sub, report ? "#" : "", report ? report : ""); } return filename;}int write_menu_page(mconfig *ext_conf, mstate *state,FILE *f, int type, char *sub, char *report) { fprintf(f, "<TR><TD class=\"menu\"> <a href=\"%s\">[%s]</A></TD></TR>\n", get_url(ext_conf, state->year, state->month, sub, report), get_menu_item(type)); return 0;}int write_menu_report(mconfig *ext_conf, mstate *state,FILE *f, int type, char *sub, char *report) { fprintf(f, "<TR><TD class=\"menu\"> <a href=\"%s\">[%s]</A></TD></TR>\n", get_url(ext_conf, state->year, state->month, sub, report), get_menu_item(type)); return 0;}int write_menu (mconfig *ext_conf, mstate *state,FILE *f, mlist *l, char *sub) { config_output *conf = ext_conf->output; fprintf(f, "<TABLE>\n"); while (l) { data_StrInt *data = l->data; char *sep_main, *sep_sub, *sep_report; /* seperate menu string */ sep_main = strchr(data->string, '/'); sep_sub = strchr(sep_main+1, '/'); sep_main++; if (!sep_sub) { fprintf(f, "<TR><TD class=\"menu\"><a href=\"index.html\">[%s]</A></TD></TR>\n", get_menu_item(data->type)); } else { sep_sub++; sep_report = strchr(sep_sub, '/'); if (!sep_report) { if (conf->page_style && (!strcasecmp(conf->page_style, "seppage") || !strcasecmp(conf->page_style, "onepage")) ) { if (l->next) { data_StrInt *_data = l->next->data; char *_sep_main, *_sep_sub, *_sep_report; /* seperate menu string */ _sep_main = strchr(_data->string, '/'); _sep_sub = strchr(_sep_main+1, '/'); _sep_main++; if (_sep_sub) { _sep_sub++; _sep_report = strchr(_sep_sub, '/'); if (_sep_report) { _sep_report++; write_menu_page(ext_conf, state, f, data->type, sep_sub, _sep_report); } } } } else { write_menu_page(ext_conf, state, f, data->type, sep_sub, NULL); } } else { sep_report++; if (conf->page_style && !strcasecmp(conf->page_style, "onepage")) { write_menu_report(ext_conf, state, f, data->type, sep_sub, sep_report); } else if (!strncmp(sub, sep_sub,3)) write_menu_report(ext_conf, state, f, data->type, sep_sub, sep_report); } } l = l->next; } fprintf(f, "</TABLE>"); return 0;}int write_css(mconfig *ext_conf, char *subpath) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -