📄 output.c
字号:
"%s %s %d</TH></TR>\n", GREY,msg_dtot_ds,l_month[cur_month-1], cur_year); fprintf(out_fp,"<TR><TH HEIGHT=4></TH></TR>\n"); fprintf(out_fp,"<TR><TH ALIGN=center BGCOLOR=\"%s\">" \ "<FONT SIZE=\"-1\">%s</FONT></TH>\n" \ "<TH ALIGN=center BGCOLOR=\"%s\" COLSPAN=2>" \ "<FONT SIZE=\"-1\">%s</FONT></TH>\n" \ "<TH ALIGN=center BGCOLOR=\"%s\" COLSPAN=2>" \ "<FONT SIZE=\"-1\">%s</FONT></TH>\n" \ "<TH ALIGN=center BGCOLOR=\"%s\" COLSPAN=2>" \ "<FONT SIZE=\"-1\">%s</FONT></TH>\n" \ "<TH ALIGN=center BGCOLOR=\"%s\" COLSPAN=2>" \ "<FONT SIZE=\"-1\">%s</FONT></TH>\n" \ "<TH ALIGN=center BGCOLOR=\"%s\" COLSPAN=2>" \ "<FONT SIZE=\"-1\">%s</FONT></TH>\n" \ "<TH ALIGN=center BGCOLOR=\"%s\" COLSPAN=2>" \ "<FONT SIZE=\"-1\">%s</FONT></TH></TR>\n", GREY, msg_h_day, DKGREEN, msg_h_hits, LTBLUE, msg_h_files, CYAN, msg_h_pages, YELLOW, msg_h_visits, ORANGE, msg_h_sites, RED, msg_h_xfer); fprintf(out_fp,"<TR><TH HEIGHT=4></TH></TR>\n"); /* skip beginning blank days in a month */ for (i=0;i<hist_lday[cur_month-1];i++) if (tm_hit[i]!=0) break; if (i==hist_lday[cur_month-1]) i=0; for (;i<hist_lday[cur_month-1];i++) { fprintf(out_fp,"<TR><TD ALIGN=center>" \ "<FONT SIZE=\"-1\"><B>%d</B></FONT></TD>\n", i+1); fprintf(out_fp,"<TD ALIGN=right>" \ "<FONT SIZE=\"-1\"><B>%lu</B></FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-2\">%3.02f%%</FONT></TD>\n", tm_hit[i],PCENT(tm_hit[i],t_hit)); fprintf(out_fp,"<TD ALIGN=right>" \ "<FONT SIZE=\"-1\"><B>%lu</B></FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-2\">%3.02f%%</FONT></TD>\n", tm_file[i],PCENT(tm_file[i],t_file)); fprintf(out_fp,"<TD ALIGN=right>" \ "<FONT SIZE=\"-1\"><B>%lu</B></FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-2\">%3.02f%%</FONT></TD>\n", tm_page[i],PCENT(tm_page[i],t_page)); fprintf(out_fp,"<TD ALIGN=right>" \ "<FONT SIZE=\"-1\"><B>%lu</B></FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-2\">%3.02f%%</FONT></TD>\n", tm_visit[i],PCENT(tm_visit[i],t_visit)); fprintf(out_fp,"<TD ALIGN=right>" \ "<FONT SIZE=\"-1\"><B>%lu</B></FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-2\">%3.02f%%</FONT></TD>\n", tm_site[i],PCENT(tm_site[i],t_site)); fprintf(out_fp,"<TD ALIGN=right>" \ "<FONT SIZE=\"-1\"><B>%.0f</B></FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-2\">%3.02f%%</FONT></TD></TR>\n", tm_xfer[i]/1024,PCENT(tm_xfer[i],t_xfer)); } fprintf(out_fp,"<TR><TH HEIGHT=4></TH></TR>\n"); fprintf(out_fp,"</TABLE>\n"); fprintf(out_fp,"<P>\n");}/*********************************************//* HOURLY_TOTAL_TABLE - hourly table *//*********************************************/void hourly_total_table(){ int i,days_in_month; u_long avg_file=0; double avg_xfer=0.0; days_in_month=(l_day-f_day)+1; /* Hourly stats */ fprintf(out_fp,"<TABLE WIDTH=510 BORDER=2 CELLSPACING=1 CELLPADDING=1>\n"); fprintf(out_fp,"<TR><TH HEIGHT=4></TH></TR>\n"); fprintf(out_fp,"<TR><TH BGCOLOR=\"%s\" COLSPAN=13 ALIGN=center>"\ "%s %s %d</TH></TR>\n", GREY,msg_htot_hs,l_month[cur_month-1], cur_year); fprintf(out_fp,"<TR><TH HEIGHT=4></TH></TR>\n"); fprintf(out_fp,"<TR><TH ALIGN=center ROWSPAN=2 BGCOLOR=\"%s\">" \ "<FONT SIZE=\"-1\">%s</FONT></TH>\n" \ "<TH ALIGN=center BGCOLOR=\"%s\" COLSPAN=3>" \ "<FONT SIZE=\"-1\">%s</FONT></TH>\n" \ "<TH ALIGN=center BGCOLOR=\"%s\" COLSPAN=3>" \ "<FONT SIZE=\"-1\">%s</FONT></TH>\n" \ "<TH ALIGN=center BGCOLOR=\"%s\" COLSPAN=3>" \ "<FONT SIZE=\"-1\">%s</FONT></TH>\n" \ "<TH ALIGN=center BGCOLOR=\"%s\" COLSPAN=3>" \ "<FONT SIZE=\"-1\">%s</FONT></TH></TR>\n", GREY, msg_h_hour, DKGREEN, msg_h_hits, LTBLUE, msg_h_files, CYAN, msg_h_pages, RED, msg_h_xfer); fprintf(out_fp,"<TR><TH ALIGN=center BGCOLOR=\"%s\">" \ "<FONT SIZE=\"-2\">%s</FONT></TH>\n" \ "<TH ALIGN=center BGCOLOR=\"%s\" COLSPAN=2>" \ "<FONT SIZE=\"-2\">%s</FONT></TH>\n", DKGREEN, msg_h_avg, DKGREEN, msg_h_total); fprintf(out_fp,"<TH ALIGN=center BGCOLOR=\"%s\">" \ "<FONT SIZE=\"-2\">%s</FONT></TH>\n" \ "<TH ALIGN=center BGCOLOR=\"%s\" COLSPAN=2>" \ "<FONT SIZE=\"-2\">%s</FONT></TH>\n", LTBLUE, msg_h_avg, LTBLUE, msg_h_total); fprintf(out_fp,"<TH ALIGN=center BGCOLOR=\"%s\">" \ "<FONT SIZE=\"-2\">%s</FONT></TH>\n" \ "<TH ALIGN=center BGCOLOR=\"%s\" COLSPAN=2>" \ "<FONT SIZE=\"-2\">%s</FONT></TH>\n", CYAN, msg_h_avg, CYAN, msg_h_total); fprintf(out_fp,"<TH ALIGN=center BGCOLOR=\"%s\">" \ "<FONT SIZE=\"-2\">%s</FONT></TH>\n" \ "<TH ALIGN=center BGCOLOR=\"%s\" COLSPAN=2>" \ "<FONT SIZE=\"-2\">%s</FONT></TH></TR>\n", RED, msg_h_avg, RED, msg_h_total); fprintf(out_fp,"<TR><TH HEIGHT=4></TH></TR>\n"); for (i=0;i<24;i++) { fprintf(out_fp,"<TR><TD ALIGN=center>" \ "<FONT SIZE=\"-1\"><B>%d</B></FONT></TD>\n",i); fprintf(out_fp, "<TD ALIGN=right><FONT SIZE=\"-1\"><B>%lu</B></FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-1\"><B>%lu</B></FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-2\">%3.02f%%</FONT></TD>\n", th_hit[i]/days_in_month,th_hit[i], PCENT(th_hit[i],t_hit)); fprintf(out_fp, "<TD ALIGN=right><FONT SIZE=\"-1\"><B>%lu</B></FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-1\"><B>%lu</B></FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-2\">%3.02f%%</FONT></TD>\n", th_file[i]/days_in_month,th_file[i], PCENT(th_file[i],t_file)); fprintf(out_fp, "<TD ALIGN=right><FONT SIZE=\"-1\"><B>%lu</B></FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-1\"><B>%lu</B></FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-2\">%3.02f%%</FONT></TD>\n", th_page[i]/days_in_month,th_page[i], PCENT(th_page[i],t_page)); fprintf(out_fp, "<TD ALIGN=right><FONT SIZE=\"-1\"><B>%.0f</B></FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-1\"><B>%.0f</B></FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-2\">%3.02f%%</FONT></TD></TR>\n", (th_xfer[i]/days_in_month)/1024,th_xfer[i]/1024, PCENT(th_xfer[i],t_xfer)); avg_file += th_file[i]/days_in_month; avg_xfer+= (th_xfer[i]/days_in_month)/1024; } fprintf(out_fp,"<TR><TH HEIGHT=4></TH></TR>\n"); fprintf(out_fp,"</TABLE>\n<P>\n");}/*********************************************//* TOP_SITES_TABLE - generate top n table *//*********************************************/void top_sites_table(int flag){ u_long cnt=0, h_reg=0, h_grp=0, h_hid=0, tot_num; int i; HNODEPTR hptr, *pointer; cnt=a_ctr; pointer=h_array; while(cnt--) { /* calculate totals */ switch ( (int)((HNODEPTR)(*pointer)->flag) ) { case OBJ_REG: h_reg++; break; case OBJ_GRP: h_grp++; break; case OBJ_HIDE: h_hid++; break; } pointer++; } if ( (tot_num=h_reg+h_grp)==0 ) return; /* split if none */ i=(flag)?ntop_sitesK:ntop_sites; /* Hits or KBytes?? */ if (tot_num > i) tot_num = i; /* get max to do... */ if ((!flag) || (flag&&!ntop_sites)) /* now do <A> tag */ fprintf(out_fp,"<A NAME=\"TOPSITES\"></A>\n"); fprintf(out_fp,"<TABLE WIDTH=510 BORDER=2 CELLSPACING=1 CELLPADDING=1>\n"); fprintf(out_fp,"<TR><TH HEIGHT=4></TH></TR>\n"); if (flag) fprintf(out_fp,"<TR><TH BGCOLOR=\"%s\" ALIGN=CENTER COLSPAN=10>" \ "%s %lu %s %lu %s %s %s</TH></TR>\n", GREY, msg_top_top,tot_num,msg_top_of, t_site,msg_top_s,msg_h_by,msg_h_xfer); else fprintf(out_fp,"<TR><TH BGCOLOR=\"%s\" ALIGN=CENTER COLSPAN=10>" \ "%s %lu %s %lu %s</TH></TR>\n", GREY,msg_top_top, tot_num, msg_top_of, t_site, msg_top_s); fprintf(out_fp,"<TR><TH HEIGHT=4></TH></TR>\n"); fprintf(out_fp,"<TR><TH BGCOLOR=\"%s\" ALIGN=center>" \ "<FONT SIZE=\"-1\">#</FONT></TH>\n",GREY); fprintf(out_fp,"<TH BGCOLOR=\"%s\" ALIGN=center COLSPAN=2>" \ "<FONT SIZE=\"-1\">%s</FONT></TH>\n",DKGREEN,msg_h_hits); fprintf(out_fp,"<TH BGCOLOR=\"%s\" ALIGN=center COLSPAN=2>" \ "<FONT SIZE=\"-1\">%s</FONT></TH>\n",LTBLUE,msg_h_files); fprintf(out_fp,"<TH BGCOLOR=\"%s\" ALIGN=center COLSPAN=2>" \ "<FONT SIZE=\"-1\">%s</FONT></TH>\n",RED,msg_h_xfer); fprintf(out_fp,"<TH BGCOLOR=\"%s\" ALIGN=center COLSPAN=2>" \ "<FONT SIZE=\"-1\">%s</FONT></TH>\n",YELLOW,msg_h_visits); fprintf(out_fp,"<TH BGCOLOR=\"%s\" ALIGN=center>" \ "<FONT SIZE=\"-1\">%s</FONT></TH></TR>\n",CYAN,msg_h_hname); fprintf(out_fp,"<TR><TH HEIGHT=4></TH></TR>\n"); pointer=h_array; i=0; while(tot_num) { hptr=*pointer++; if (hptr->flag != OBJ_HIDE) { /* shade grouping? */ if (shade_groups && (hptr->flag==OBJ_GRP)) fprintf(out_fp,"<TR BGCOLOR=\"%s\">\n", GRPCOLOR); else fprintf(out_fp,"<TR>\n"); fprintf(out_fp, "<TD ALIGN=center><FONT SIZE=\"-1\"><B>%d</B></FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-1\"><B>%lu</B></FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-2\">%3.02f%%</FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-1\"><B>%lu</B></FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-2\">%3.02f%%</FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-1\"><B>%.0f</B></FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-2\">%3.02f%%</FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-1\"><B>%lu</B></FONT></TD>\n" \ "<TD ALIGN=right><FONT SIZE=\"-2\">%3.02f%%</FONT></TD>\n" \ "<TD ALIGN=left NOWRAP><FONT SIZE=\"-1\">", i+1,hptr->count, (t_hit==0)?0:((float)hptr->count/t_hit)*100.0,hptr->files, (t_file==0)?0:((float)hptr->files/t_file)*100.0,hptr->xfer/1024, (t_xfer==0)?0:((float)hptr->xfer/t_xfer)*100.0,hptr->visit, (t_visit==0)?0:((float)hptr->visit/t_visit)*100.0); if ((hptr->flag==OBJ_GRP)&&hlite_groups) fprintf(out_fp,"<STRONG>%s</STRONG></FONT></TD></TR>\n", hptr->string); else fprintf(out_fp,"%s</FONT></TD></TR>\n", hptr->string); tot_num--; i++; } } fprintf(out_fp,"<TR><TH HEIGHT=4></TH></TR>\n"); if ((!flag) || (flag&&!ntop_sites)) { if ( (all_sites) && ((h_reg+h_grp)>ntop_sites) ) { if (all_sites_page(h_reg, h_grp)) { fprintf(out_fp,"<TR BGCOLOR=\"%s\">",GRPCOLOR); fprintf(out_fp,"<TD COLSPAN=10 ALIGN=\"center\">\n"); fprintf(out_fp,"<FONT SIZE=\"-1\">"); fprintf(out_fp,"<A HREF=\"./site_%04d%02d.%s\">", cur_year,cur_month,html_ext); fprintf(out_fp,"%s</A></TD></TR>\n",msg_v_sites); if (flag) /* do we need to sort? */ qsort(h_array,a_ctr,sizeof(HNODEPTR),qs_site_cmph); } } } fprintf(out_fp,"</TABLE>\n<P>\n");}/*********************************************//* ALL_SITES_PAGE - HTML page of all sites *//*********************************************/int all_sites_page(u_long h_reg, u_long h_grp){ HNODEPTR hptr, *pointer; char site_fname[256], buffer[256]; FILE *out_fp; int i=(h_grp)?1:0; /* generate file name */ sprintf(site_fname,"site_%04d%02d.%s",cur_year,cur_month,html_ext); /* open file */ if ( (out_fp=open_out_file(site_fname))==NULL ) return 0; sprintf(buffer,"%s %d - %s",l_month[cur_month-1],cur_year,msg_h_sites); write_html_head(buffer, out_fp); fprintf(out_fp,"<FONT SIZE=\"-1\"></CENTER><PRE>\n"); fprintf(out_fp," %12s %12s %12s %12s %s\n", msg_h_hits, msg_h_files, msg_h_xfer, msg_h_visits, msg_h_hname); fprintf(out_fp,"---------------- ---------------- ---------------- " \ "---------------- --------------------\n\n"); /* Do groups first (if any) */ pointer=h_array; while(h_grp) { hptr=*pointer++; if (hptr->flag == OBJ_GRP) { fprintf(out_fp, "%-8lu %6.02f%% %8lu %6.02f%% %8.0f %6.02f%% %8lu %6.02f%% %s\n", hptr->count, (t_hit==0)?0:((float)hptr->count/t_hit)*100.0,hptr->files, (t_file==0)?0:((float)hptr->files/t_file)*100.0,hptr->xfer/1024, (t_xfer==0)?0:((float)hptr->xfer/t_xfer)*100.0,hptr->visit, (t_visit==0)?0:((float)hptr->visit/t_visit)*100.0, hptr->string); h_grp--; } } if (i) fprintf(out_fp,"\n"); /* Now do individual sites (if any) */ pointer=h_array; if (!hide_sites) while(h_reg) { hptr=*pointer++; if (hptr->flag == OBJ_REG) { fprintf(out_fp, "%-8lu %6.02f%% %8lu %6.02f%% %8.0f %6.02f%% %8lu %6.02f%% %s\n", hptr->count, (t_hit==0)?0:((float)hptr->count/t_hit)*100.0,hptr->files, (t_file==0)?0:((float)hptr->files/t_file)*100.0,hptr->xfer/1024, (t_xfer==0)?0:((float)hptr->xfer/t_xfer)*100.0,hptr->visit, (t_visit==0)?0:((float)hptr->visit/t_visit)*100.0,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -