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

📄 generate.c

📁 100 病毒源碼,原始碼,無毒 ......
💻 C
📖 第 1 页 / 共 2 页
字号:
}int write_css(mconfig *ext_conf) {	char filename[255];	int f;	const char *def_css = "BODY {background: #eeeeee; }TH { font-family: arial,helvetica; font-size: 10pt; color: black; }TD { font-family: arial,helvetica; font-size: 10pt; color: black;background: #FFFFFF;}TD.TINYR { text-align: right; font-family: arial,helvetica; font-size: 9pt;color: black; }TD.CENTERB { text-align: center; font-weight: bolder; }TD.RIGHTB { text-align: right; font-weight: bolder; }TD.GROUPING { font-family: arial,helvetica; font-size: 10pt; color: black;background: #d0d0e0;}TD.MENU { background: #eeeeff;}";		sprintf(filename, "%s/modlogan.css", 		ext_conf->outputdir ? ext_conf->outputdir : ".");			if ((f = open (filename, O_CREAT | O_EXCL | O_WRONLY, S_IROTH | S_IRGRP | S_IWUSR | S_IRUSR)) != -1) {		printf("writing CSS-definition\n");		write (f, def_css, strlen(def_css));		close(f);	}		return 0;}int write_report_header(mconfig *ext_conf, FILE *f, char *sub, char *report) {	config_output *conf = ext_conf->output;		if (conf->page_style && !strcasecmp(conf->page_style, "onepage")) {		fprintf(f, "<CENTER><A NAME=\"%.3s%s\"></A><A HREF=\"#000\">[top]</A></CENTER>", sub, report);	} else if (conf->page_style && !strcasecmp(conf->page_style, "seppage")) {		fprintf(f, "<CENTER><A NAME=\"%s\"></A></CENTER>", report);	} else {		fprintf(f, "<CENTER><A NAME=\"%s\"></A><A HREF=\"#000\">[top]</A></CENTER>", report);	}		return 0;}int mplugins_output_generate_monthly_output(mconfig *ext_conf, mstate *state, char *subpath) {	unsigned int i;	FILE *f = NULL;	char filename[255];	data_History sumdat, maxdat;	int last_day = 1;	config_output *conf = ext_conf->output;	mlist *menu_items = mlist_init(), *l;	char last_sub[4] = { 0, 0, 0, 0 };	char last_report[4] = { 0, 0, 0, 0 };	mstate_telecom *statel = NULL;		if (!state->ext) return -1;		if (state->ext_type != M_STATE_TYPE_TELECOM) return -1;		statel = state->ext;		write_css(ext_conf);		get_menu_items(ext_conf, state, menu_items);		l = menu_items;	while (l) {/* sort the list */		mlist *min_l = NULL;		mlist *hl = l->next;		char *min = "";		char *last = ((data_StrInt *)l->data)->string;				while (hl) {			if (hl->data) {				if ( strcmp(((data_StrInt *)hl->data)->string, min) > 0 &&					strcmp(((data_StrInt *)hl->data)->string, last) < 0) {					min = ((data_StrInt *)hl->data)->string;					min_l = hl;				}			}			hl = hl->next;		}				if (min_l) {			data_StrInt *d;						d = l->data;			l->data = min_l->data;			min_l->data = d;		}				l = l->next;	}		l = menu_items;	while (l) {		data_StrInt *data = l->data;		char *sep_main, *sep_sub, *sep_report = NULL;			/* seperate menu string */		sep_main = strchr(data->string, '/');		sep_main++;		sep_sub = strchr(sep_main, '/');				if (sep_sub) {			sep_sub++;			sep_report = strchr(sep_sub, '/');			if (sep_report) {				sep_report++;			}		}	/* open file */			if (conf->page_style && !strcasecmp(conf->page_style, "onepage")) {			if (sep_main && strncmp(last_sub, sep_main, 3)) {				strncpy(last_sub, sep_main, 3);							sprintf(filename, "%s/m_usage_%04i%02i.html", 					ext_conf->outputdir ? ext_conf->outputdir : ".",					state->year, state->month);							if (f) {					file_end(f);					fclose(f);				}							if (!(f = fopen(filename, "w"))) {					return -1;			}	/* create menu */				file_start(f,ext_conf,state->timestamp);							write_menu(ext_conf, state,f, menu_items, last_sub);							fprintf (f, "</TD><TD>");			}		} else if (conf->page_style && !strcasecmp(conf->page_style, "seppage")) {			if (sep_sub && sep_report &&				(strncmp(last_sub, sep_sub, 3) != 0 ||			       	strncmp(last_report, sep_report, 3) != 0)) {			       					strncpy(last_report, sep_report, 3);				strncpy(last_sub, sep_sub, 3);								sprintf(filename, "%s/m_usage_%04i%02i_%.3s_%s.html", 					ext_conf->outputdir ? ext_conf->outputdir : ".",					state->year, state->month, 					sep_sub ? sep_sub : "",					sep_report ? sep_report : "");							if (f) {					file_end(f);					fclose(f);				}							if (!(f = fopen(filename, "w"))) {					return -1;			}	/* create menu */				file_start(f,ext_conf, state->timestamp);							write_menu(ext_conf, state,f, menu_items, last_sub);							fprintf (f, "</TD><TD>");			}		} else {			if (sep_sub && strncmp(last_sub, sep_sub, 3)) {				strncpy(last_sub, sep_sub, 3);							sprintf(filename, "%s/m_usage_%04i%02i_%s.html", 					ext_conf->outputdir ? ext_conf->outputdir : ".",					state->year, state->month, last_sub);							if (f) {					file_end(f);					fclose(f);				}							if (!(f = fopen(filename, "w"))) {					return -1;			}	/* create menu */				file_start(f,ext_conf, state->timestamp);							write_menu(ext_conf, state,f, menu_items, last_sub);							fprintf (f, "</TD><TD>");			}		}			/* write report */			switch (data->type) {			case M_REPORT_CALLED_NUM: 			{				write_report_header(ext_conf, f, sep_sub, sep_report);				table_start(f, table_header(conf->max_called_numbers, mhash_count(statel->called_numbers),_("Called Numbers")), 3);				fprintf(f,"<TR><TH>#</TH><TH bgcolor=\"%s\">%s</TH><TH>%s</TH></TR>\n",					conf->col_calls,					_("Calls"),					_("Telephone number")					);				show_mhash(ext_conf, f,statel->called_numbers, conf->max_called_numbers,INDEX);				table_end(f);				break;			}			case M_REPORT_CALLING_NUM: 			{				write_report_header(ext_conf, f, sep_sub, sep_report);				table_start(f, table_header(conf->max_calling_numbers, mhash_count(statel->calling_numbers),_("Called Numbers")), 3);				fprintf(f,"<TR><TH>#</TH><TH bgcolor=\"%s\">%s</TH><TH>%s</TH></TR>\n",					conf->col_calls,					_("Calls"),					_("Telephone number")					);				show_mhash(ext_conf, f,statel->calling_numbers, conf->max_calling_numbers,INDEX);				table_end(f);				break;			}			case M_REPORT_SUMMARY:			{				write_report_header(ext_conf, f, sep_sub, sep_report);				sumdat.files	= maxdat.files	= 0;				sumdat.hits	= maxdat.hits	= 0;					/* count the values */				for ( i = 0; i < 31; i++) {					if (statel->days[i].incomming_calls) last_day = i+1;					sumdat.files	+= statel->days[i].outgoing_calls;					sumdat.hits	+= statel->days[i].incomming_calls;					if (maxdat.files < statel->days[i].outgoing_calls)						maxdat.files	= statel->days[i].outgoing_calls;					if (maxdat.hits < statel->days[i].incomming_calls) 						maxdat.hits	= statel->days[i].incomming_calls;				}								table_start(f, _("Summary"), 3);					/* Totals */				fprintf(f,"<TR><TD>%s</TD><TD colspan=2 align=right>%li</TD></TR>\n", _("Total Incomming Calls"), sumdat.hits);				fprintf(f,"<TR><TD>%s</TD><TD colspan=2 align=right>%li</TD></TR>\n", _("Total Outgoing Calls"), sumdat.files);								fprintf(f,"<TR><TH>&nbsp;</TH><TH>%s</TH><TH>%s</TH></TR>\n", _("avg"), _("max"));								fprintf(f,"<TR><TD>%s</TD><TD align=right>%li</TD><TD align=right>%li</TD></TR>\n", _("Incomming Calls per Day"), sumdat.hits / last_day, maxdat.hits);				fprintf(f,"<TR><TD>%s</TD><TD align=right>%li</TD><TD align=right>%li</TD></TR>\n", _("Outgoing per Day"), sumdat.files / last_day, maxdat.files);					table_end(f);				break;			}			case M_REPORT_DAILY:			{				write_report_header(ext_conf, f, sep_sub, sep_report);					table_start(f, _("Daily Statistics"), 3);				fprintf(f,"<TR><TH>%s</TH><TH bgcolor=\"%s\">%s</TH><TH bgcolor=\"%s\">%s</TH></TR>\n",					_("Day"),					conf->col_calls,					_("Incomming Calls"),					conf->col_outgoing,					_("Outgoing Calls")					);				for ( i = 0; i < last_day; i++) {					fprintf(f,"<TR><TD>%i</TD><TD align=right>%li</TD><TD align=right>%li</TD></TR>\n",						i+1, 						statel->days[i].incomming_calls,						statel->days[i].outgoing_calls						);				}				table_end(f);				break;			}			case M_REPORT_HOURLY:			{				write_report_header(ext_conf, f, sep_sub, sep_report);					table_start(f, _("Hourly Statistics"), 3);				fprintf(f,"<TR><TH>%s</TH><TH bgcolor=\"%s\">%s</TH><TH bgcolor=\"%s\">%s</TH></TR>\n",					_("Day"),					conf->col_calls,					_("Incomming Calls"),					conf->col_outgoing,					_("Outgoing Calls")					);				for ( i = 0; i < 24; i++) {					fprintf(f,"<TR><TD>%i</TD><TD align=right>%li</TD><TD align=right>%li</TD></TR>\n",						i, 						statel->hours[i].incomming_calls,						statel->hours[i].outgoing_calls						);				}				table_end(f);				break;			}			default:				break;		}				l = l->next;	}		if (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];	config_output *conf = ext_conf->output;		sprintf(filename, "%s/index.html", 		ext_conf->outputdir ? ext_conf->outputdir : ".");		if (!(f = fopen(filename, "w"))) {		return -1;	}		file_start_index(f,ext_conf,0);		table_start(f, _("History"), -11);		fprintf(f,"<TR><TH>&nbsp;</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_calls,		_("Calls"),		conf->col_incomming,		_("Incomming"),		conf->col_outgoing,		_("Outgoing"),		"",		_("Visits"),		conf->col_xfer,		_("KBytes"),		"",		_("Hits"),		"",		_("Files"),		"",		_("Pages"),		"",		_("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 class=\"centerb\"><A HREF=\"%s\">%s&nbsp;%04i</A></TD>" \			"<TD class=\"tinyr\">%li</TD><TD class=\"tinyr\">%li</TD>" \			"<TD class=\"tinyr\">%li</TD><TD class=\"tinyr\">%li</TD>" \			"<TD class=\"tinyr\">%.0f</TD>" \			"<TD class=\"tinyr\">%li</TD><TD class=\"tinyr\">%li</TD>" \			"<TD class=\"tinyr\">%li</TD><TD class=\"tinyr\">%li</TD>" \			"<TD class=\"tinyr\">%.0f</TD>" \			"</TR>\n",			get_url(ext_conf, data->year, data->month, "000", "000"),			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_index(f);		fclose(f);		return 0;}

⌨️ 快捷键说明

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