📄 generate.c
字号:
d = (double)staweb->allvisitlength / sumdat.visits; } else { d = 0; } fprintf(f,"<TR><TD>%s</TD><TD align=right>%.2f</TD><TD align=right>%s</TD></TR>\n", _("Pages per visit"), d, "---"); s_200 = mhash_get_value(staweb->status_hash, "200"); s_304 = mhash_get_value(staweb->status_hash, "304"); d = ((double)s_304/(s_200+s_304)) * 100; fprintf(f,"<TR><TD>%s</TD><TD align=right>%.2f%%</TD><TD align=right>%s</TD></TR>\n", _("Cache Hit ratio"), d, "---"); table_end(f); ref = create_pic_31_day(ext_conf, state, subpath); if (ref && strlen(ref)) { fprintf(f, "%s", ref); } table_start(f, _("Daily Statistics"), 6); fprintf(f,"<TR><TH>%s</TH><TH bgcolor=\"%s\">%s</TH><TH bgcolor=\"%s\">%s</TH><TH bgcolor=\"%s\">%s</TH><TH bgcolor=\"%s\">%s</TH><TH bgcolor=\"%s\">%s</TH></TR>\n", _("Day"), conf->col_hits, _("Hits"), conf->col_files, _("Files"), conf->col_pages, _("Pages"), conf->col_visits, _("Visits"), conf->col_xfer, _("KBytes") ); for ( i = 0; i < last_day; i++) { fprintf(f,"<TR><TD>%i</TD><TD align=right>%li</TD><TD align=right>%li</TD><TD align=right>%li</TD><TD align=right>%li</TD><TD align=right>%.0f</TD></TR>\n", i+1, staweb->days[i].hits, staweb->days[i].files, staweb->days[i].pages, staweb->days[i].visits, staweb->days[i].xfersize / 1024 ); } table_end(f); ref = create_pic_24_hour(ext_conf, state, subpath); if (ref && strlen(ref)) { fprintf(f, "%s", ref); } table_start(f, _("Hourly Statistics"), 6); fprintf(f,"<TR><TH>%s</TH><TH bgcolor=\"%s\">%s</TH><TH bgcolor=\"%s\">%s</TH><TH bgcolor=\"%s\">%s</TH><TH bgcolor=\"%s\">%s</TH><TH bgcolor=\"%s\">%s</TH></TR>\n", _("Hour"), conf->col_hits, _("Hits"), conf->col_files, _("Files"), conf->col_pages, _("Pages"), conf->col_visits, _("Visits"), conf->col_xfer, _("KBytes") ); for ( i = 0; i < 24; i++) { fprintf(f,"<TR><TD>%i</TD><TD align=right>%li</TD><TD align=right>%li</TD><TD align=right>%li</TD><TD align=right>%li</TD><TD align=right>%.0f</TD></TR>\n", i, staweb->hours[i].hits, staweb->hours[i].files, staweb->hours[i].pages, staweb->hours[i].visits, staweb->hours[i].xfersize / 1024 ); } table_end(f); if (conf->max_req_urls > 0) { table_start(f, table_header(conf->max_req_urls, mhash_count(staweb->req_url_hash),_("Requested URL's")), 3); fprintf(f,"<TR><TH>#</TH><TH bgcolor=\"%s\">%s</TH><TH>%s</TH></TR>\n", conf->col_hits, _("Hits"), _("URL") ); show_mhash(ext_conf, f,staweb->req_url_hash, conf->max_req_urls,HIGHLIGHT | GROUPING | INDEX); table_end(f); } if (conf->max_os > 0) { table_start(f, table_header(conf->max_os, mhash_count(staweb->os_hash), _("Used Operating Systems")), 4); fprintf(f,"<TR><TH>#</TH><TH bgcolor=\"%s\">%s</TH><TH bgcolor=\"%s\">%s</TH><TH>%s</TH></TR>\n", conf->col_hits, _("Hits"), conf->col_visits, _("Visits"), _("Operating System") ); show_mhash(ext_conf, f,staweb->os_hash, conf->max_os, GROUPING | VISITS | INDEX); table_end(f); } if (conf->max_hosts > 0) { table_start(f, table_header(conf->max_hosts, mhash_count(staweb->host_hash),_("Hosts")), 3); fprintf(f,"<TR><TH>#</TH><TH bgcolor=\"%s\">%s</TH><TH>%s</TH></TR>\n", conf->col_hits, _("Hits"), _("Host") ); show_mhash(ext_conf, f,staweb->host_hash, conf->max_hosts, GROUPING | INDEX); table_end(f); } if (conf->max_ref_urls > 0) { table_start(f, table_header(conf->max_ref_urls, mhash_count(staweb->ref_url_hash),_("Referring URL's")), 3); fprintf(f,"<TR><TH>#</TH><TH bgcolor=\"%s\">%s</TH><TH>%s</TH></TR>\n", conf->col_hits, _("Hits"), _("Referrer") ); show_mhash(ext_conf, f,staweb->ref_url_hash, conf->max_ref_urls, HIGHLIGHT | GROUPING | INDEX); table_end(f); } if (conf->max_entry_pages > 0) { table_start(f, table_header(conf->max_entry_pages, mhash_count(staweb->entry_pages),_("Entry Pages")), 3); fprintf(f,"<TR><TH>#</TH><TH bgcolor=\"%s\">%s</TH><TH>%s</TH></TR>\n", conf->col_hits, _("Hits"), _("Entry Page") ); show_mhash(ext_conf, f,staweb->entry_pages, conf->max_entry_pages, HIGHLIGHT | INDEX); table_end(f); } if (conf->max_exit_pages > 0) { table_start(f, table_header(conf->max_exit_pages, mhash_count(staweb->exit_pages),_("Exit Pages")), 3); fprintf(f,"<TR><TH>#</TH><TH bgcolor=\"%s\">%s</TH><TH>%s</TH></TR>\n", conf->col_hits, _("Hits"), _("Exit Page") ); show_mhash(ext_conf, f,staweb->exit_pages, conf->max_exit_pages, HIGHLIGHT | INDEX); table_end(f); } if (conf->max_indexed_pages > 0) { table_start(f, table_header(conf->max_indexed_pages, mhash_count(staweb->indexed_pages),_("Indexed Pages")), 3); fprintf(f,"<TR><TH>#</TH><TH bgcolor=\"%s\">%s</TH><TH>%s</TH></TR>\n", conf->col_hits, _("Hits"), _("Indexed Page") ); show_mhash(ext_conf, f,staweb->indexed_pages, conf->max_indexed_pages,HIGHLIGHT | INDEX); table_end(f); } if (conf->max_ua > 0) { table_start(f, table_header(conf->max_ua, mhash_count(staweb->ua_hash),_("Used Browsers")), 4); fprintf(f,"<TR><TH>#</TH><TH bgcolor=\"%s\">%s</TH><TH bgcolor=\"%s\">%s</TH><TH>%s</TH></TR>\n", conf->col_hits, _("Hits"), conf->col_visits, _("Visits"), _("Browser") ); show_mhash(ext_conf, f,staweb->ua_hash, conf->max_ua, GROUPING | VISITS | INDEX); table_end(f); } if (conf->max_req_prot > 0) { table_start(f, table_header(conf->max_req_prot, mhash_count(staweb->req_prot_hash),_("Used Request Protocol")), 3); fprintf(f,"<TR><TH>#</TH><TH bgcolor=\"%s\">%s</TH><TH>%s</TH></TR>\n", conf->col_hits, _("Hits"), _("Protocol") ); show_mhash(ext_conf, f,staweb->req_prot_hash, conf->max_req_prot,0 | INDEX); table_end(f); } if (conf->max_req_meth > 0) { table_start(f, table_header(conf->max_req_meth, mhash_count(staweb->req_meth_hash),_("Used Request Method")), 3); fprintf(f,"<TR><TH>#</TH><TH bgcolor=\"%s\">%s</TH><TH>%s</TH></TR>\n", conf->col_hits, _("Hits"), _("Method") ); show_mhash(ext_conf, f,staweb->req_meth_hash,conf->max_req_meth,0 | INDEX); table_end(f); } if (conf->max_status_codes > 0) { table_start(f, table_header(conf->max_status_codes, mhash_count(staweb->status_hash),_("Status Code")), 2); fprintf(f,"<TR><TH bgcolor=\"%s\">%s</TH><TH>%s</TH></TR>\n", conf->col_hits, _("Hits"), _("Status Code") ); show_status_mhash(f,staweb->status_hash, conf->max_status_codes); table_end(f); } if (conf->max_robots > 0) { table_start(f, table_header(conf->max_robots, mhash_count(staweb->robots),_("Robots")), 3); fprintf(f,"<TR><TH>#</TH><TH bgcolor=\"%s\">%s</TH><TH>%s</TH></TR>\n", conf->col_hits, _("Hits"), _("Robot") ); show_mhash(ext_conf, f,staweb->robots, conf->max_robots,0 | INDEX); table_end(f); } if (conf->max_bookmarks > 0) { table_start(f, table_header(conf->max_bookmarks, mhash_count(staweb->bookmarks),_("Bookmarked Pages")), 3); fprintf(f,"<TR><TH>#</TH><TH bgcolor=\"%s\">%s</TH><TH>%s</TH></TR>\n", conf->col_hits, _("Hits"), _("Bookmarked Page") ); show_mhash(ext_conf, f,staweb->bookmarks,conf->max_bookmarks,HIGHLIGHT | INDEX); table_end(f); } if (conf->max_broken_links > 0) { table_start(f, table_header(conf->max_broken_links, mhash_count(staweb->status_missing_file),_("Missing File / Broken Link")), 3); fprintf(f,"<TR><TH>#</TH><TH bgcolor=\"%s\">%s</TH><TH>%s</TH></TR>\n", conf->col_hits, _("Hits"), _("Broken Link") ); show_mhash(ext_conf, f,staweb->status_missing_file,conf->max_broken_links,GROUPING | INDEX); table_end(f); } if (conf->max_internal_errors > 0) { table_start(f, table_header(conf->max_internal_errors, mhash_count(staweb->status_internal_error),_("Internal Errors")), 2); show_mhash(ext_conf, f,staweb->status_internal_error,conf->max_internal_errors,0); table_end(f); } if (conf->max_search_strings > 0) { table_start(f, table_header(conf->max_search_strings, mhash_count(staweb->searchstring),_("SearchStrings")), 3); fprintf(f,"<TR><TH>#</TH><TH bgcolor=\"%s\">%s</TH><TH>%s</TH></TR>\n", conf->col_hits, _("Hits"), _("Search String") ); show_mhash(ext_conf, f,staweb->searchstring, conf->max_search_strings,0 | INDEX); table_end(f); } if (conf->max_search_engines > 0) { table_start(f, table_header(conf->max_search_engines, mhash_count(staweb->searchsite),_("SearchEngines")), 3); fprintf(f,"<TR><TH>#</TH><TH bgcolor=\"%s\">%s</TH><TH>%s</TH></TR>\n", conf->col_hits, _("Hits"), _("Search Engine") ); show_mhash(ext_conf, f,staweb->searchsite, conf->max_search_engines, HIGHLIGHT | GROUPING | INDEX); table_end(f); } if (conf->max_countries > 0) { ref = create_pic_countries(ext_conf, state, subpath); if (ref && strlen(ref)) { fprintf(f, "%s", ref); } table_start(f, table_header(conf->max_countries, mhash_count(staweb->country_hash),_("Countries")), 4); fprintf(f,"<TR><TH>#</TH><TH bgcolor=\"%s\">%s</TH><TH bgcolor=\"%s\">%s</TH><TH>%s</TH></TR>\n", conf->col_hits, _("Hits"), conf->col_visits, _("Visits"), _("Country") ); show_mhash(ext_conf, f, staweb->country_hash, conf->max_countries, VISITS | INDEX); table_end(f); } file_end(f); fclose(f); return 0;}int mplugins_output_generate_history_output(mconfig *ext_conf, mlist *history, char *subpath) { mlist *l = history; FILE *f; char filename[255]; char *ref; config_output *conf = ext_conf->output; sprintf(filename, "%s%s%s/index.html", ext_conf->outputdir ? ext_conf->outputdir : ".", subpath ? "/" : "", subpath ? subpath : "" ); if (!(f = fopen(filename, "w"))) { return -1; } file_start(f,ext_conf); ref = create_pic_12_month(ext_conf, history, subpath); if (ref && strlen(ref)) { fprintf(f, "%s", ref); } table_start(f, _("History"), 11); fprintf(f,"<TR><TH> </TH><TH colspan=5>%s</TH><TH colspan=5>%s</TH></TR>", _("Average/day"), _("Totals") ); fprintf(f,"<TR><TH>%s</TH>" \ "<TH bgcolor=\"%s\">%s</TH><TH bgcolor=\"%s\">%s</TH>" \ "<TH bgcolor=\"%s\">%s</TH><TH bgcolor=\"%s\">%s</TH>" \ "<TH bgcolor=\"%s\">%s</TH>" \ "<TH bgcolor=\"%s\">%s</TH><TH bgcolor=\"%s\">%s</TH>" \ "<TH bgcolor=\"%s\">%s</TH><TH bgcolor=\"%s\">%s</TH>" \ "<TH bgcolor=\"%s\">%s</TH>" \ "</TR>\n", _("Month"), conf->col_hits, _("Hits"), conf->col_files, _("Files"), conf->col_pages, _("Pages"), conf->col_visits, _("Visits"), conf->col_xfer, _("KBytes"), conf->col_hits, _("Hits"), conf->col_files, _("Files"), conf->col_pages, _("Pages"), conf->col_visits, _("Visits"), conf->col_xfer, _("KBytes") ); /* go to the last element */ while (l->next) l = l->next; while (l) { data_History *data = ((data_History *)l->data); if (!data) break; fprintf(f,"<TR><TD><A HREF=\"m_usage_%04i%02i.html\">%s %04i</A></TD>" \ "<TD align=\"right\">%li</TD><TD align=\"right\">%li</TD>" \ "<TD align=\"right\">%li</TD><TD align=\"right\">%li</TD>" \ "<TD align=\"right\">%.0f</TD>" \ "<TD align=\"right\">%li</TD><TD align=\"right\">%li</TD>" \ "<TD align=\"right\">%li</TD><TD align=\"right\">%li</TD>" \ "<TD align=\"right\">%.0f</TD>" \ "</TR>\n", data->year, data->month, get_month_string(data->month,1), data->year, data->hits / data->count, data->files / data->count, data->pages/ data->count, data->visits/ data->count, data->xfersize / 1024 / data->count, data->hits, data->files, data->pages, data->visits, data->xfersize / 1024 ); l = l->prev; } table_end(f); file_end(f); fclose(f); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -