*/
#include "include/conf.h"
+#include "include/defs.h"
void htaccess(const char *name)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
void authfail_report(void)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
void ccharset(char *CharSet)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
void convlog(const char *arq, char *df, int dfrom, int duntil)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
void css(FILE *fp_css)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
void dansguardian_log(void)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
void dansguardian_report(void)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
void saverecs(char *dirname, char *user, long long int nacc, char *url, long long int nbytes, char *ip, char *hora, char *dia, long long int nelap, long long int incache, long long int oucache);
void grava_SmartFilter(char *dirname, char *user, char *ip, char *data, char *hora, char *url, char *smart);
*/
#include "include/conf.h"
+#include "include/defs.h"
void decomp(char *arq, char *zip, const char *tmp)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
void gen_denied_report(void)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
void download_report(void)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
int geramail(const char *dirname, int debug, const char *outdir, int userip, const char *email, const char *TempDir)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
int vhexclude(const char *excludefile, const char *url)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
extern numlist hours, weekdays;
*/
#include "include/conf.h"
+#include "include/defs.h"
int blue;
int white;
*/
#include "include/conf.h"
+#include "include/defs.h"
void htmlrel(void)
{
DIR *dirp;
struct dirent *direntp;
-
-// auth.c
-void htaccess(const char *name);
-
-// authfail.c
-void authfail_report(void);
-
-// charset.c
-void ccharset(char *CharSet);
-
-// convlog.c
-void convlog(const char *arq, char *df, int dfrom, int duntil);
-
-// css.c
-void css(FILE *fp_css);
-
-// dansguardian_log.c
-void dansguardian_log(void);
-
-// dansguardian_report.c
-void dansguardian_report(void);
-
-// datafile.c
-void data_file(char *tmp);
-
-// decomp.c
-void decomp(char *arq, char *zip, const char *tmp);
-void recomp(const char *arq, const char *zip) ;
-
-// denied.c
-void gen_denied_report(void);
-
-// download.c
-void download_report(void);
-
-// email.c
-int geramail(const char *dirname, int debug, const char *outdir, int userip, const char *email, const char *TempDir);
-
-// exclude.c
-int vhexclude(const char *excludefile, const char *url);
-int vuexclude(const char *excludeuser, const char *user);
-
-// getconf.c
-void getconf(void);
-
-// grepday.c
-void greport_day(const char *user);
-
-// html.c
-void htmlrel(void);
-
-// indexonly.c
-void index_only(const char *dirname,int debug);
-
-// ip2name.c
-void ip2name(char *ip,int ip_len);
-void name2ip(char *name);
-
-// language.c
-void language_load(const char *language);
-
-// lastlog.c
-void mklastlog(const char *outdir);
-
-// index.c
-void make_index(void);
-
-// realtime.c
-void realtime(void);
-
-// repday.c
-void report_day(const char *user);
-
-// report.c
-void gravatmp(char *oldaccuser, char *dirname, char *oldurl, long long int nacc, long long int nbytes, char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache);
-void gerarel(void);
-
-// siteuser.c
-void siteuser(void);
-
-// smartfilter.c
-void smartfilter_report(void);
-
-// sort.c
-void sort_users_log(const char *tmp, int debug);
-void tmpsort(void);
-
-// splitlog.c
-void splitlog(const char *arq, char *df, int dfrom, int duntil, char *convert);
-
-// squidguard_log.c
-void squidguard_log(void);
-
-// squidguard_report.c
-void squidguard_report(void);
-
-// topsites.c
-void topsites(void);
-
-// topuser.c
-void topuser(void);
-
-// totday.c
-void day_totalize(const char *tmp, const char *user, int indexonly);
-
-// totger.c
-int totalger(const char *dirname, int debug, const char *outdir);
-
-// usage.c
-void usage(const char *prog);
-
-// useragent.c
-void useragent(void);
-
-// util.c
-int getword(char *word, int limit, char *line, int stop);
-int getword_multisep(char *word, int limit, char *line, int stop);
-int getword3(char *word, int limit, char *line, int stop);
-void name_month(char *month,int month_len);
-void conv_month_name(char *month);
-void buildymd(const char *dia, const char *mes, const char *ano, char *wdata);
-void date_from(char *date, char *dfrom, char *duntil);
-int getnumlist( char *, numlist *, const int, const int );
-void fixip(char *ip);
-char *fixnum(long long int value, int n);
-char *fixnum2(long long int value, int n);
-void fixnone(char *str);
-void fixper(char *tbuf, char *period, const char *duntil);
-char *fixtime(long int elap);
-void show_info(FILE *fp_ou);
-void show_sarg(FILE *fp_ou, const char *ind);
-void write_html_header(FILE *fp_ou, const char * ind);
-void write_html_trailer(FILE *fp_ou);
-char *subs(char *str, char *from, char *to);
-void conv_month(char *month);
-void debuga(const char *msg);
-void debugaz(const char *head, const char *msg);
-void my_lltoa(unsigned long long int n, char s[], int len);
-char *get_size(const char *path, const char *file);
-void url_module(char *url, char *w2);
-void strip_latin(char *line);
-char *buildtime(long long int elap);
-void obtdate(const char *dirname, const char *name, char *data);
-void obtuser(const char *dirname, const char *name, char *tuser);
-void obttotal(const char *dirname, const char *name, char *tbytes, char *tuser, char *media);
-void version(void);
-int vercode(const char *code);
-void load_excludecodes(void);
-void my_mkdir(const char *name);
-int testvaliduserchar(const char *user);
-char *strlow(char *string);
-char *strup(char *string);
-void builddia(char *dia, const char *mes, const char *ano, const char *df, char *wdata);
-void vrfydir(const char *dir, const char *per1, const char *addr, const char *site, const char *us, const char *form);
-void gperiod(void);
-void removetmp(const char *outdir);
-void zdate(char *ftime, const char *DateFormat);
-void baddata(void);
-void maketmp(char *user, char *dirname, int debug, int indexonly);
-void maketmp_hour(char *user, char *dirname, int indexonly);
+// auth.c
+void htaccess(const char *name);
+
+// authfail.c
+void authfail_report(void);
+
+// charset.c
+void ccharset(char *CharSet);
+
+// convlog.c
+void convlog(const char *arq, char *df, int dfrom, int duntil);
+
+// css.c
+void css(FILE *fp_css);
+
+// dansguardian_log.c
+void dansguardian_log(void);
+
+// dansguardian_report.c
+void dansguardian_report(void);
+
+// datafile.c
+void data_file(char *tmp);
+
+// decomp.c
+void decomp(char *arq, char *zip, const char *tmp);
+void recomp(const char *arq, const char *zip) ;
+
+// denied.c
+void gen_denied_report(void);
+
+// download.c
+void download_report(void);
+
+// email.c
+int geramail(const char *dirname, int debug, const char *outdir, int userip, const char *email, const char *TempDir);
+
+// exclude.c
+int vhexclude(const char *excludefile, const char *url);
+int vuexclude(const char *excludeuser, const char *user);
+
+// getconf.c
+void getconf(void);
+
+// grepday.c
+void greport_day(const char *user);
+
+// html.c
+void htmlrel(void);
+
+// indexonly.c
+void index_only(const char *dirname,int debug);
+
+// ip2name.c
+void ip2name(char *ip,int ip_len);
+void name2ip(char *name);
+
+// language.c
+void language_load(const char *language);
+
+// lastlog.c
+void mklastlog(const char *outdir);
+
+// index.c
+void make_index(void);
+
+// realtime.c
+void realtime(void);
+
+// repday.c
+void report_day(const char *user);
+
+// report.c
void gravatmp(char *oldaccuser, char *dirname, char *oldurl, long long int nacc, long long int nbytes, char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache);
-void gravatmp_hora(char *dirname, char *user, char *data, char *hora, char *elap, char *accbytes, int indexonly);
-void gravatmpf(char *oldaccuser, char *dirname, char *oldurl, long long int nacc, long long int nbytes, char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache);
-void gravaporuser(char *user, char *dirname, char *url, char *ip, char *data, char *hora, char *tam, char *elap, int indexonly);
-void gravager(char *dirname, char *user, long long int nacc, char *url, long long int nbytes, char *ip, char *hora, char *dia, long long int nelap, long long int incache, long long int oucache);
-void grava_SmartFilter(char *dirname, char *user, char *ip, char *data, char *hora, char *url, char *smart);
+void gerarel(void);
+
+// siteuser.c
+void siteuser(void);
+
+// smartfilter.c
+void smartfilter_report(void);
+
+// sort.c
+void sort_users_log(const char *tmp, int debug);
+void tmpsort(void);
+
+// splitlog.c
+void splitlog(const char *arq, char *df, int dfrom, int duntil, char *convert);
+
+// squidguard_log.c
+void squidguard_log(void);
+
+// squidguard_report.c
+void squidguard_report(void);
+
+// topsites.c
+void topsites(void);
+
+// topuser.c
+void topuser(void);
+
+// totday.c
+void day_totalize(const char *tmp, const char *user, int indexonly);
+
+// totger.c
+int totalger(const char *dirname, int debug, const char *outdir);
+
+// usage.c
+void usage(const char *prog);
+
+// useragent.c
+void useragent(void);
+
+// util.c
+int getword(char *word, int limit, char *line, int stop);
+int getword_multisep(char *word, int limit, char *line, int stop);
+int getword3(char *word, int limit, char *line, int stop);
+void name_month(char *month,int month_len);
+void conv_month_name(char *month);
+void buildymd(const char *dia, const char *mes, const char *ano, char *wdata);
+void date_from(char *date, char *dfrom, char *duntil);
+int getnumlist( char *, numlist *, const int, const int );
+void fixip(char *ip);
+char *fixnum(long long int value, int n);
+char *fixnum2(long long int value, int n);
+void fixnone(char *str);
+void fixper(char *tbuf, char *period, const char *duntil);
+char *fixtime(long int elap);
+void show_info(FILE *fp_ou);
+void show_sarg(FILE *fp_ou, const char *ind);
+void write_html_header(FILE *fp_ou, const char * ind);
+void write_html_trailer(FILE *fp_ou);
+char *subs(char *str, char *from, char *to);
+void conv_month(char *month);
+void debuga(const char *msg);
+void debugaz(const char *head, const char *msg);
+void my_lltoa(unsigned long long int n, char s[], int len);
+char *get_size(const char *path, const char *file);
+void url_module(char *url, char *w2);
+void strip_latin(char *line);
+char *buildtime(long long int elap);
+void obtdate(const char *dirname, const char *name, char *data);
+void obtuser(const char *dirname, const char *name, char *tuser);
+void obttotal(const char *dirname, const char *name, char *tbytes, char *tuser, char *media);
+void version(void);
+int vercode(const char *code);
+void load_excludecodes(void);
+void my_mkdir(const char *name);
+int testvaliduserchar(const char *user);
+char *strlow(char *string);
+char *strup(char *string);
+void builddia(char *dia, const char *mes, const char *ano, const char *df, char *wdata);
+void vrfydir(const char *dir, const char *per1, const char *addr, const char *site, const char *us, const char *form);
+void gperiod(void);
+void removetmp(const char *outdir);
+void zdate(char *ftime, const char *DateFormat);
+void baddata(void);
+char *get_param_value(const char *param,char *line);
-#define VERSION "2.2.5 Jul-07-2009"
+#define VERSION "2.2.5 Jul-08-2009"
#define PGM "sarg"
#define URL "http://sarg.sourceforge.net"
*/
#include "include/conf.h"
+#include "include/defs.h"
void make_index(void)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
void index_only(const char *dirname,int debug)
*/
#include "include/conf.h"
+#include "include/defs.h"
void ip2name(char *ip,int ip_len)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
void language_load(const char *language)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
void mklastlog(const char *outdir)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
#define LEGACY_WRITE_USER
#define LEGACY_WRITE_DOWNLOAD
*/
#include "include/conf.h"
+#include "include/defs.h"
int getdata(char *, FILE *);
void datashow(char *);
*/
#include "include/conf.h"
+#include "include/defs.h"
extern numlist hours;
#include "include/conf.h"
#include "include/defs.h"
+static void maketmp(const char *user, const char *dirname, int debug, int indexonly);
+static void maketmp_hour(const char *user, const char *dirname, int indexonly);
+static void gravatmp_hora(char *dirname, char *user, char *data, char *hora, char *elap, char *accbytes, int indexonly);
+static void gravatmpf(char *oldaccuser, char *dirname, char *oldurl, long long int nacc, long long int nbytes, char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache);
+static void gravaporuser(char *user, char *dirname, char *url, char *ip, char *data, char *hora, char *tam, char *elap, int indexonly);
+static void gravager(char *dirname, char *user, long long int nacc, char *url, long long int nbytes, char *ip, char *hora, char *dia, long long int nelap, long long int incache, long long int oucache);
+static void grava_SmartFilter(char *dirname, char *user, char *ip, char *data, char *hora, char *url, char *smart);
+
void gerarel(void)
{
if((strcmp(direntp->d_name+dlen,logext) != 0) ||
(strncmp(direntp->d_name,"download.log",12) == 0) ||
(strncmp(direntp->d_name,"denied.log",10) == 0) ||
- (strncmp(direntp->d_name,"authfail.log.unsort",19) == 0))
+ (strncmp(direntp->d_name,"authfail.log.unsort",19) == 0))
continue;
if (snprintf(tmp3,sizeof(tmp3),"%s/%s",tmp,direntp->d_name)>=sizeof(tmp3)) {
fprintf(stderr, "SARG: (report) directory entry too long: %s/%s\n",tmp,direntp->d_name);
incache=0;
oucache=0;
}
- } else {
+ } else {
if(strcmp(oldurl,accurl) != 0 || strcmp(oldaccuser,accuser) != 0){
strcpy(oldmsg,"OK");
if(strstr(oldacccode,"DENIED") != 0)
nelap=0;
incache=0;
oucache=0;
- if(strcmp(oldaccuser,accuser) != 0)
- ind2=0;
- }
- }
- nacc++;
- nbytes+=my_atoll(accbytes);
- nelap+=my_atoll(accelap);
-
- if(strstr(ReportType,"site_user_time_date") != 0) {
- if(!ttopen) {
- ind2++;
- strcpy(siteind,accurl);
- str=siteind;
- for(z1=0; str[z1]; z1++) {
- if(str[z1]=='?' || str[z1]=='-' || str[z1]=='.' || str[z1]==':' || str[z1]=='/' || str[z1]=='\\' || str[z1]=='*' ||
- str[z1]=='\'' || str[z1]=='\"' || str[z1]=='$')
- str[z1]='_';
+ if(strcmp(oldaccuser,accuser) != 0)
+ ind2=0;
}
- sprintf(arqtt,"%s/%s",dirname,accuser);
- if(access(arqtt, R_OK) != 0)
- my_mkdir(arqtt);
- sprintf(arqtt,"%s/%s/tt%s-%s.html",dirname,accuser,accuser,siteind);
- if(strlen(arqtt) > 255) {
- strncpy(val7,arqtt,255);
- bzero(arqtt,MAXLEN);
- strcpy(arqtt,val7);
- }
- if ((fp_tt = fopen(arqtt, "w")) == 0) {
- fprintf(stderr, "SARG: (report) %s: %s\n",text[45],arqtt);
- exit(1);
- }
- ttopen=1;
-
- if(strcmp(Privacy,"yes") == 0)
- sprintf(httplink,"<font size=%s color=%s><href=http://%s>%s", \
- FontSize,PrivacyStringColor,PrivacyString,PrivacyString);
- else
- sprintf(httplink,"<font size=%s><a href=http://%s>%s</A>",FontSize,accurl,accurl);
-
- sprintf(ltext110,"%s",text[110]);
- for(s=ltext110; *s; ++s)
- *s=tolower(*s);
-
- fprintf(fp_tt, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html>\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">\n",CharSet);
- css(fp_tt);
- fputs("</head>\n",fp_tt);
- fprintf(fp_tt,"<body bgcolor=%s text=%s background='%s'>\n",BgColor,TxColor,BgImage);
- if(strlen(LogoImage) > 0) fprintf(fp_tt, "<center><table cellpadding=\"0\" cellspacing=\"0\">\n<tr><th class=\"logo\"><img src='%s' border=0 align=absmiddle width=%s height=%s> %s</th></tr>\n<tr><td height=\"5\"></td></tr>\n</table>\n",LogoImage,Width,Height,LogoText);
-
- if(strcmp(IndexTree,"date") == 0)
- show_sarg(fp_tt, "../../../..");
- else
- show_sarg(fp_tt, "../..");
-
- fputs("<center><table cellpadding=0 cellspacing=0>\n",fp_tt);
- fprintf(fp_tt,"<tr><th class=\"title\" colspan=\"2\">%s</th></tr>\n",Title);
-
- strcpy(u2,user);
- if(strcmp(Ip2Name,"yes") == 0)
- ip2name(u2,sizeof(u2));
- if(UserTabFile[0] != '\0') {
- sprintf(warea,":%s:",u2);
- if((str=(char *) strstr(userfile,warea)) != (char *) NULL ) {
- z1=0;
- str2=(char *) strstr(str+1,":");
- str2++;
- bzero(name, MAXLEN);
- while(str2[z1] != ':') {
- name[z1]=str2[z1];
- z1++;
- }
+ }
+ nacc++;
+ nbytes+=my_atoll(accbytes);
+ nelap+=my_atoll(accelap);
+
+ if(strstr(ReportType,"site_user_time_date") != 0) {
+ if(!ttopen) {
+ ind2++;
+ strcpy(siteind,accurl);
+ str=siteind;
+ for(z1=0; str[z1]; z1++) {
+ if(str[z1]=='?' || str[z1]=='-' || str[z1]=='.' || str[z1]==':' || str[z1]=='/' || str[z1]=='\\' || str[z1]=='*' ||
+ str[z1]=='\'' || str[z1]=='\"' || str[z1]=='$')
+ str[z1]='_';
+ }
+ sprintf(arqtt,"%s/%s",dirname,accuser);
+ if(access(arqtt, R_OK) != 0)
+ my_mkdir(arqtt);
+ sprintf(arqtt,"%s/%s/tt%s-%s.html",dirname,accuser,accuser,siteind);
+ if(strlen(arqtt) > 255) {
+ strncpy(val7,arqtt,255);
+ bzero(arqtt,MAXLEN);
+ strcpy(arqtt,val7);
+ }
+ if ((fp_tt = fopen(arqtt, "w")) == 0) {
+ fprintf(stderr, "SARG: (report) %s: %s\n",text[45],arqtt);
+ exit(1);
+ }
+ ttopen=1;
+
+ if(strcmp(Privacy,"yes") == 0)
+ sprintf(httplink,"<font size=%s color=%s><href=http://%s>%s", \
+ FontSize,PrivacyStringColor,PrivacyString,PrivacyString);
+ else
+ sprintf(httplink,"<font size=%s><a href=http://%s>%s</A>",FontSize,accurl,accurl);
+
+ sprintf(ltext110,"%s",text[110]);
+ for(s=ltext110; *s; ++s)
+ *s=tolower(*s);
+
+ fprintf(fp_tt, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html>\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">\n",CharSet);
+ css(fp_tt);
+ fputs("</head>\n",fp_tt);
+ fprintf(fp_tt,"<body bgcolor=%s text=%s background='%s'>\n",BgColor,TxColor,BgImage);
+ if(strlen(LogoImage) > 0) fprintf(fp_tt, "<center><table cellpadding=\"0\" cellspacing=\"0\">\n<tr><th class=\"logo\"><img src='%s' border=0 align=absmiddle width=%s height=%s> %s</th></tr>\n<tr><td height=\"5\"></td></tr>\n</table>\n",LogoImage,Width,Height,LogoText);
+
+ if(strcmp(IndexTree,"date") == 0)
+ show_sarg(fp_tt, "../../../..");
+ else
+ show_sarg(fp_tt, "../..");
+
+ fputs("<center><table cellpadding=0 cellspacing=0>\n",fp_tt);
+ fprintf(fp_tt,"<tr><th class=\"title\" colspan=\"2\">%s</th></tr>\n",Title);
+
+ strcpy(u2,user);
+ if(strcmp(Ip2Name,"yes") == 0)
+ ip2name(u2,sizeof(u2));
+ if(UserTabFile[0] != '\0') {
+ sprintf(warea,":%s:",u2);
+ if((str=(char *) strstr(userfile,warea)) != (char *) NULL ) {
+ z1=0;
+ str2=(char *) strstr(str+1,":");
+ str2++;
+ bzero(name, MAXLEN);
+ while(str2[z1] != ':') {
+ name[z1]=str2[z1];
+ z1++;
+ }
+ } else strcpy(name,u2);
} else strcpy(name,u2);
- } else strcpy(name,u2);
- if(dotinuser && strstr(name,"_")) {
- str2=(char *)subs(name,"_",".");
- strcpy(name,str2);
+ if(dotinuser && strstr(name,"_")) {
+ str2=(char *)subs(name,"_",".");
+ strcpy(name,str2);
+ }
+
+ fprintf(fp_tt,"<tr><td class=\"header\" colspan=\"2\">%s: %s</td></tr>\n",text[89],period);
+ fprintf(fp_tt,"<tr><td class=\"header\" colspan=\"2\">%s: %s</td></tr>\n",text[90],name);
+ fprintf(fp_tt,"<tr><td class=\"header\" colspan=\"2\">%s: %s, %s</td></tr>\n",text[104],UserSortField,UserSortOrder);
+ fprintf(fp_tt,"<tr><th class=\"header3\" colspan=2>%s</th></tr>\n",text[32]);
+
+ fputs("</table></center>\n",fp_tt);
+ fputs("<center><table cellpadding=\"0\" cellspacing=\"2\">\n",fp_tt);
+ fputs("<tr><td></td><td></td></tr>",fp_tt);
+ bzero(tmp4, MAXLEN);
+ strncpy(tmp4,text[110],4);
+ fprintf(fp_tt,"<tr><th class=\"header\">%s</th><th class=\"header\">%s</th><th class=\"header\">%s</th></tr>\n",text[91],tmp4,text[110]+5);
}
- fprintf(fp_tt,"<tr><td class=\"header\" colspan=\"2\">%s: %s</td></tr>\n",text[89],period);
- fprintf(fp_tt,"<tr><td class=\"header\" colspan=\"2\">%s: %s</td></tr>\n",text[90],name);
- fprintf(fp_tt,"<tr><td class=\"header\" colspan=\"2\">%s: %s, %s</td></tr>\n",text[104],UserSortField,UserSortOrder);
- fprintf(fp_tt,"<tr><th class=\"header3\" colspan=2>%s</th></tr>\n",text[32]);
-
- fputs("</table></center>\n",fp_tt);
- fputs("<center><table cellpadding=\"0\" cellspacing=\"2\">\n",fp_tt);
- fputs("<tr><td></td><td></td></tr>",fp_tt);
- bzero(tmp4, MAXLEN);
- strncpy(tmp4,text[110],4);
- fprintf(fp_tt,"<tr><th class=\"header\">%s</th><th class=\"header\">%s</th><th class=\"header\">%s</th></tr>\n",text[91],tmp4,text[110]+5);
- }
-
- sprintf(html,"<tr><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td></tr>\n",accurl,accdia,acchora);
-
- if(strcmp(html,html_old) != 0)
- fputs(html,fp_tt);
- strcpy(html_old, html);
- } else bzero(ltext110, 50);
-
- strcpy(wcrc,acccode);
- if (getword(crc2,sizeof(crc2),wcrc,'/')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",tmp3);
- exit(1);
- }
+ sprintf(html,"<tr><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td></tr>\n",accurl,accdia,acchora);
- if(strstr(crc2,"MISS") != 0)
- oucache+=my_atoll(accbytes);
- else incache+=my_atoll(accbytes);
+ if(strcmp(html,html_old) != 0)
+ fputs(html,fp_tt);
+ strcpy(html_old, html);
+ } else bzero(ltext110, 50);
- strcpy(oldurl,accurl);
+ strcpy(wcrc,acccode);
+ if (getword(crc2,sizeof(crc2),wcrc,'/')<0) {
+ printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",tmp3);
+ exit(1);
+ }
- if(strcmp(accuser,oldaccuser) != 0) {
- strcpy(wdirname,dirname);
- day_totalize(tmp,oldaccuser,indexonly);
- }
+ if(strstr(crc2,"MISS") != 0)
+ oucache+=my_atoll(accbytes);
+ else incache+=my_atoll(accbytes);
- strcpy(oldaccuser,accuser);
- strcpy(oldacccode,acccode);
- strcpy(oldaccelap,accelap);
- strcpy(oldaccip,accip);
- strcpy(oldaccdia,accdia);
- strcpy(oldacchora,acchora);
+ strcpy(oldurl,accurl);
+
+ if(strcmp(accuser,oldaccuser) != 0) {
+ strcpy(wdirname,dirname);
+ day_totalize(tmp,oldaccuser,indexonly);
+ }
+
+ strcpy(oldaccuser,accuser);
+ strcpy(oldacccode,acccode);
+ strcpy(oldaccelap,accelap);
+ strcpy(oldaccip,accip);
+ strcpy(oldaccdia,accdia);
+ strcpy(oldacchora,acchora);
+ }
+ bzero(user,MAXLEN);
+ fclose(fp_in);
+ unlink(tmp3);
}
- bzero(user,MAXLEN);
- fclose(fp_in);
- unlink(tmp3);
-}
strcpy(oldmsg,"OK");
if(strstr(oldacccode,"DENIED") != 0)
return;
}
-
-void maketmp(char *user, char *dirname, int debug, int indexonly)
+static void maketmp(const char *user, const char *dirname, int debug, int indexonly)
{
FILE *fp_ou;
}
-void maketmp_hour(char *user, char *dirname, int indexonly)
+static void maketmp_hour(const char *user, const char *dirname, int indexonly)
{
FILE *fp_ou;
}
-void gravatmp_hora(char *dirname, char *user, char *data, char *hora, char *elap, char *bytes, int indexonly)
+static void gravatmp_hora(char *dirname, char *user, char *data, char *hora, char *elap, char *bytes, int indexonly)
{
FILE *fp_ou;
}
-void gravaporuser(char *user, char *dirname, char *url, char *ip, char *data, char *hora, char *tam, char *elap, int indexonly)
+static void gravaporuser(char *user, char *dirname, char *url, char *ip, char *data, char *hora, char *tam, char *elap, int indexonly)
{
FILE *fp_ou;
}
-void gravatmpf(char *oldaccuser, char *dirname, char *oldurl, long long int nacc, long long int nbytes, char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache)
+static void gravatmpf(char *oldaccuser, char *dirname, char *oldurl, long long int nacc, long long int nbytes, char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache)
{
FILE *fp_ou;
}
-void gravager(char *dirname, char *user, long long int nacc, char *url, long long int nbytes, char *ip, char *hora, char *dia, long long int nelap, long long int incache, long long int oucache)
+static void gravager(char *dirname, char *user, long long int nacc, char *url, long long int nbytes, char *ip, char *hora, char *dia, long long int nelap, long long int incache, long long int oucache)
{
FILE *fp_ou;
}
-void grava_SmartFilter(char *dirname, char *user, char *ip, char *data, char *hora, char *url, char *smart)
+static void grava_SmartFilter(char *dirname, char *user, char *ip, char *data, char *hora, char *url, char *smart)
{
FILE *fp_ou;
*/
#include "include/conf.h"
+#include "include/defs.h"
void siteuser(void)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
void smartfilter_report(void)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
void tmpsort(void)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
void splitlog(const char *arq, char *df, int dfrom, int duntil, char *convert)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
static char **files_done = NULL;
static int nfiles_done = 0;
-void read_log(char *wentp, FILE *fp_ou)
+static void read_log(const char *wentp, FILE *fp_ou)
{
FILE *fp_in = NULL;
char bufbsf[255];
char logdir[MAXLEN];
char year[10], day[10], mon[10];
char user[MAXLEN];
- int x, y;
+ int y;
int cstatus;
+ char *str;
+ char *str2;
str2 = user;
fprintf(stderr, "SARG: (squidguard) %s: %s\n",text[8],SquidGuardConf);
exit(1);
}
-
+
+ logdir[0]=0;
while(fgets(buf,sizeof(buf),fp_guard)!=NULL) {
if(strstr(buf,"\n") != 0)
buf[strlen(buf)-1]='\0';
- if(strstr(buf,"logdir ") != 0) {
- if (getword(logdir,sizeof(logdir),buf,' ')<0 || getword(logdir,sizeof(logdir),buf,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",SquidGuardConf);
+ if((str=get_param_value("logdir",buf))!=NULL) {
+ if (getword(logdir,sizeof(logdir),str,' ')<0) {
+ printf("SARG: Maybe you have an invalid logdir line in your %s file.\n",SquidGuardConf);
exit(1);
}
- }
- if((str=(char *) strstr(buf, "log")) != (char *) NULL ) {
- str=str+3;
- str2[0]='\0';
- y=0;
- while(*str == ' ')
- str++;
- if (str == (char *) strstr(str, "anonymous"))
- str+=9;
+ } else if((str=get_param_value("log",buf))!=NULL) {
+ if((str2=get_param_value("anonymous",str))!=NULL)
+ str=str2;
- for (x=0; x<=strlen(str); x++) {
- if (str[x] != ' ' && str[x] != '\t') {
- str2[y] = str[x];
- y++;
- }
- }
- if(strchr(str2,' ') != 0) {
- if (getword(warea,sizeof(warea),str2,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",SquidGuardConf);
- exit(1);
- }
- strcpy(str2,warea);
- }
- if(strchr(str2,'#') != 0) {
- if (getword(warea,sizeof(warea),str2,'#')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",SquidGuardConf);
- exit(1);
+ /*
+ If logdir is defined, we prepend it to the log file name, otherwise, we assume
+ the log directive provides an absolute file name to the log file. Therefore,
+ we don't need to add an additionnal / at the beginning of the log file name.
+ */
+ y=(logdir[0]) ? sprintf(wentp,"%s/",logdir) : 0;
+ /*
+ Spaces are allowed in the name of the log file. The file name ends at the first #
+ because it is assumed it is an end of line comment. Any space before the # is then
+ removed. Any control character (i.e. a character with a code lower than 32) ends
+ the file name. That includes the terminating zero.
+ */
+ while((unsigned char)*str>=' ' && *str!='#' && y<sizeof(wentp)-1)
+ wentp[y++]=*str++;
+ if(*str=='#') {
+ str--;
+ while(*str==' ' && y>0) {
+ str--;
+ y--;
}
- strcpy(str2,warea);
}
- sprintf(wentp,"%s/%s",logdir,str2);
+ wentp[y]=0;
read_log(wentp,fp_ou);
}
}
*/
#include "include/conf.h"
+#include "include/defs.h"
void squidguard_report(void)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
void topsites(void)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
void topuser(void)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
void day_totalize(const char *tmp, const char *user, int indexonly)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
int totalger(const char *dirname, int debug, const char *outdir)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
void usage(const char *prog)
{
*/
#include "include/conf.h"
+#include "include/defs.h"
void useragent(void)
{
// #define LEGACY_TESTVALIDUSERCHAR
#include "include/conf.h"
+#include "include/defs.h"
static char mtab1[12][4]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
static char mtab2[12][3]={"01","02","03","04","05","06","07","08","09","10","11","12"};
printf("SARG Version: %s\n",VERSION);
exit(0);
}
+
+char *get_param_value(const char *param,char *line)
+{
+ int plen;
+
+ while (*line==' ' || *line=='\t') line++;
+ plen=strlen(param);
+ if (strncasecmp(line,param,plen)) return(NULL);
+ if (line[plen]!=' ' && line[plen]!='\t') return(NULL);
+ line+=plen;
+ while (*line==' ' || *line=='\t') line++;
+ return(line);
+}