From: Frédéric Marchal Date: Mon, 26 Jul 2010 14:38:27 +0000 (+0000) Subject: Fix the reporting of the IP addresses from which the user connected to the internet... X-Git-Tag: v2.3.1~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3ffc6fe84afb4a558e5651503df5976f38f09353;p=thirdparty%2Fsarg.git Fix the reporting of the IP addresses from which the user connected to the internet. The date column was limited to 8 characters which is too short for a date formated as dd/mm/yyyy. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e539a7..0f0c2a9 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ PROJECT(sarg C) SET(sarg_VERSION 2) SET(sarg_REVISION "3.1-pre1") SET(sarg_BUILD "") -SET(sarg_BUILDDATE "Jul-19-2010") +SET(sarg_BUILDDATE "Jul-26-2010") INCLUDE(AddFileDependencies) INCLUDE(CheckIncludeFile) diff --git a/html.c b/html.c index 8d617d3..1d90b0d 100644 --- a/html.c +++ b/html.c @@ -43,7 +43,6 @@ void htmlrel(void) char arqin[MAXLEN], arqou[MAXLEN], arqper[MAXLEN], arqip[MAXLEN]; char *url, tmsg[50], csort[MAXLEN]; char user[MAXLEN], duser[MAXLEN]; - char userhora[9], userdia[9]; char user_ip[MAXLEN], olduserip[MAXLEN], tmp2[MAXLEN], tmp3[MAXLEN]; char denied_report[255]; char *str; @@ -369,8 +368,9 @@ void htmlrel(void) exit(EXIT_FAILURE); } while((buf=longline_read(fp_ip,line1))!=NULL) { - if(strstr(buf,url) != 0) - fputs(buf,fp_ip2); + if(strstr(buf,url) != 0) { + fprintf(fp_ip2,"%s\n",buf); + } } longline_destroy(&line1); @@ -406,11 +406,11 @@ void htmlrel(void) debuga(_("Maybe you have a broken url in your %s file\n"),tmp3); exit(EXIT_FAILURE); } - if (getword(userdia,sizeof(userdia),&gwarea,'\t')<0) { + if (getword_skip(15,&gwarea,'\t')<0) { debuga(_("Maybe you have a broken day in your %s file\n"),tmp3); exit(EXIT_FAILURE); } - if (getword(userhora,sizeof(userhora),&gwarea,'\t')<0) { + if (getword_skip(15,&gwarea,'\t')<0) { debuga(_("Maybe you have a broken time in your %s file\n"),tmp3); exit(EXIT_FAILURE); } @@ -418,17 +418,27 @@ void htmlrel(void) debuga(_("Maybe you have a broken size in your %s file\n"),tmp3); exit(EXIT_FAILURE); } - if (getword_atoll(&userelap,&gwarea,'\t')<0) { + if (getword_atoll(&userelap,&gwarea,'\0')<0) { debuga(_("Maybe you have a broken elapsed time in your %s file\n"),tmp3); exit(EXIT_FAILURE); } if(strcmp(user_ip,olduserip) != 0) { - sprintf(wwork1,"%s",fixnum(unbytes,1)); - /* - This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable - to print a long long int unless it is exactly 64-bits long. - */ - fprintf(fp_ou,"%s%s%s%"PRIu64"\n",olduserip,wwork1,buildtime(unelap),(uint64_t)unelap); + if (olduserip[0]!='\0') { + fprintf(fp_ou,"%s",olduserip); + if((UserReportFields & USERREPORTFIELDS_CONNECT) != 0) + fputs("",fp_ou); + if((UserReportFields & USERREPORTFIELDS_BYTES) != 0) + fprintf(fp_ou,"%s",fixnum(unbytes,1)); + if((UserReportFields & USERREPORTFIELDS_SETYB) != 0) + fputs("",fp_ou); + if((UserReportFields & USERREPORTFIELDS_IN_CACHE_OUT) != 0) + fputs("",fp_ou); + if((UserReportFields & USERREPORTFIELDS_USED_TIME) != 0) + fprintf(fp_ou,"%s",buildtime(unelap)); + if((UserReportFields & USERREPORTFIELDS_MILISEC) != 0) + fprintf(fp_ou,"%s",fixnum2(unelap,1)); + fputs("\n",fp_ou); + } strcpy(olduserip,user_ip); unacc=0; @@ -436,8 +446,8 @@ void htmlrel(void) unelap=0; } - unbytes=unbytes+userbytes; - unelap=unelap+userelap; + unbytes+=userbytes; + unelap+=userelap; } fclose(fp_ip); @@ -446,12 +456,22 @@ void htmlrel(void) unlink(tmp2); unlink(tmp3); - sprintf(wwork1,"%s",fixnum(unbytes,1)); - /* - This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable - to print a long long int unless it is exactly 64-bits long. - */ - fprintf(fp_ou,"%s%s%s%"PRIu64"\n",olduserip,wwork1,buildtime(unelap),(uint64_t)unelap); + if (olduserip[0]!='\0') { + fprintf(fp_ou,"%s",olduserip); + if((UserReportFields & USERREPORTFIELDS_CONNECT) != 0) + fputs("",fp_ou); + if((UserReportFields & USERREPORTFIELDS_BYTES) != 0) + fprintf(fp_ou,"%s",fixnum(unbytes,1)); + if((UserReportFields & USERREPORTFIELDS_SETYB) != 0) + fputs("",fp_ou); + if((UserReportFields & USERREPORTFIELDS_IN_CACHE_OUT) != 0) + fputs("",fp_ou); + if((UserReportFields & USERREPORTFIELDS_USED_TIME) != 0) + fprintf(fp_ou,"%s",buildtime(unelap)); + if((UserReportFields & USERREPORTFIELDS_MILISEC) != 0) + fprintf(fp_ou,"%s",fixnum2(unelap,1)); + fputs("\n",fp_ou); + } } unacc=0; diff --git a/include/info.h b/include/info.h index 2a26162..b08f873 100755 --- a/include/info.h +++ b/include/info.h @@ -1,3 +1,3 @@ -#define VERSION PACKAGE_VERSION" Jul-19-2010" +#define VERSION PACKAGE_VERSION" Jul-26-2010" #define PGM PACKAGE_NAME #define URL "http://sarg.sourceforge.net"