From: Frédéric Marchal Date: Tue, 2 Mar 2010 12:10:39 +0000 (+0000) Subject: Early rejection of an access.log line outside of the requested date range X-Git-Tag: v2.3-pre2~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=809a7534af7fba4f166441ffefb316b6c77ad10b;p=thirdparty%2Fsarg.git Early rejection of an access.log line outside of the requested date range --- diff --git a/log.c b/log.c index 38e794b..2ae7676 100644 --- a/log.c +++ b/log.c @@ -878,9 +878,6 @@ int main(int argc,char *argv[]) } if(exstring) continue; - if ((str = strchr(linebuf, '\n')) != NULL) - *str = '\0'; /* strip \n */ - totregsl++; if(debugm) printf("BUF=%s\n",linebuf); @@ -1065,37 +1062,37 @@ int main(int argc,char *argv[]) } if (x==isa_cols[ISACOL_Ip]) { if (strlen(str)>=sizeof(ip)) { - printf("SARG: Maybe you have a broken IP in your %s file.\n",arq); + debuga(_("Maybe you have a broken IP in your %s file"),arq); exit(1); } strcpy(ip,str); } else if (x==isa_cols[ISACOL_UserName]) { if (strlen(str)>=sizeof(user)) { - printf("SARG: Maybe you have a broken user in your %s file.\n",arq); + debuga(_("Maybe you have a broken user in your %s file"),arq); exit(1); } strcpy(user,str); } else if (x==isa_cols[ISACOL_Date]) { if (strlen(str)>=sizeof(data)) { - printf("SARG: Maybe you have a broken date in your %s file.\n",arq); + debuga(_("Maybe you have a broken date in your %s file"),arq); exit(1); } strcpy(data,str); } else if (x==isa_cols[ISACOL_Time]) { if (strlen(str)>=sizeof(hora)) { - printf("SARG: Maybe you have a broken time in your %s file.\n",arq); + debuga(_("Maybe you have a broken time in your %s file"),arq); exit(1); } strcpy(hora,str); } else if (x==isa_cols[ISACOL_TimeTaken]) { if (strlen(str)>=sizeof(elap)) { - printf("SARG: Maybe you have a broken download duration in your %s file.\n",arq); + debuga(_("Maybe you have a broken download duration in your %s file"),arq); exit(1); } strcpy(elap,str); } else if (x==isa_cols[ISACOL_Bytes]) { if (strlen(str)>=sizeof(tam)) { - printf("SARG: Maybe you have a broken download size in your %s file.\n",arq); + debuga(_("Maybe you have a broken download size in your %s file"),arq); exit(1); } strcpy(tam,str); @@ -1103,7 +1100,7 @@ int main(int argc,char *argv[]) url=str; } else if (x==isa_cols[ISACOL_Status]) { if (strlen(str)>=sizeof(code)) { - printf("SARG: Maybe you have a broken access code in your %s file.\n",arq); + debuga(_("Maybe you have a broken access code in your %s file"),arq); exit(1); } strcpy(code,str); @@ -1116,102 +1113,21 @@ int main(int argc,char *argv[]) } getword_start(&gwarea,data); if (getword(ano,sizeof(ano),&gwarea,'-')<0){ - printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq); + debuga(_("Maybe you have a broken record or garbage in your %s file"),arq); exit(1); } if (getword(mes,sizeof(mes),&gwarea,'-')<0){ - printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq); + debuga(_("Maybe you have a broken record or garbage in your %s file"),arq); exit(1); } if (getword(dia,sizeof(dia),&gwarea,'\0')<0){ - printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq); + debuga(_("Maybe you have a broken record or garbage in your %s file"),arq); exit(1); } conv_month_name(mes); sprintf(data," %s/%s/%s:%s",dia,mes,ano,hora); } - if(strlen(user) > MAX_USER_LEN) { - if (debugm) printf("User too long: %s\n",user); - totregsx++; - continue; - } - - // include_users - if(IncludeUsers[0] != '\0') { - sprintf(val1,":%s:",user); - if((str=(char *) strstr(IncludeUsers,val1)) == (char *) NULL ) - continue; - } - - if(vercode(code)) { - if (debugm) printf("Excluded code: %s\n",code); - totregsx++; - continue; - } - - if(testvaliduserchar(user)) - continue; - -#if 0 - if((str = strstr(user,"%20")) != NULL) { - /* - This is a patch introduced to solve bug #1624251 reported at sourceforge but - the side effect is to truncate the name at the first space and merge the reports - of people whose name is identical up to the first space. - - The old code used to truncate the user name at the first % if a %20 was - found anywhere in the string. That means the string could be truncated - at the wrong place if another % occured before the %20. This new code should - avoid that problem and only truncate at the space. There is no bug - report indicating that anybody noticed this. - */ - *str='\0'; - } - - /* - Code prior to 2.2.7 used to replace any %xx by a dot as long as a %5c was - found in the user name. - */ - while((str = strstr(user,"%5c")) != NULL) { - *str='.'; - for (x=3 ; str[x] ; x++) str[x-2]=str[x]; - } -#endif - - urly=url; - - if(ilf!=ILF_Sarg) { - /* - The full URL is not saved in sarg log. There is no point in testing the URL to detect - a downloaded file. - */ - download_flag=is_download_suffix(url); - if (download_flag) { - download_url=url; - download_count++; - } - } - - // remove any protocol:// at the beginning of the URL - if ((str = strchr(url,'/')) != NULL && str[1] == '/') { - int i; - - str+=2; - for (i=0 ; str[i] ; i++) - url[i]=str[i]; - url[i]='\0'; - } - - if(!LongUrl) { - int i; - - for (i=0 ; i duntil) continue; } + + if(strlen(user) > MAX_USER_LEN) { + if (debugm) printf(_("User ID too long: %s\n"),user); + totregsx++; + continue; + } + + // include_users + if(IncludeUsers[0] != '\0') { + sprintf(val1,":%s:",user); + if((str=(char *) strstr(IncludeUsers,val1)) == (char *) NULL ) + continue; + } + + if(vercode(code)) { + if (debugm) printf(_("Excluded code: %s\n"),code); + totregsx++; + continue; + } + + if(testvaliduserchar(user)) + continue; + +#if 0 + if((str = strstr(user,"%20")) != NULL) { + /* + This is a patch introduced to solve bug #1624251 reported at sourceforge but + the side effect is to truncate the name at the first space and merge the reports + of people whose name is identical up to the first space. + + The old code used to truncate the user name at the first % if a %20 was + found anywhere in the string. That means the string could be truncated + at the wrong place if another % occured before the %20. This new code should + avoid that problem and only truncate at the space. There is no bug + report indicating that anybody noticed this. + */ + *str='\0'; + } + + /* + Code prior to 2.2.7 used to replace any %xx by a dot as long as a %5c was + found in the user name. + */ + while((str = strstr(user,"%5c")) != NULL) { + *str='.'; + for (x=3 ; str[x] ; x++) str[x-2]=str[x]; + } +#endif + + urly=url; + + if(ilf!=ILF_Sarg) { + /* + The full URL is not saved in sarg log. There is no point in testing the URL to detect + a downloaded file. + */ + download_flag=is_download_suffix(url); + if (download_flag) { + download_url=url; + download_count++; + } + } + + // remove any protocol:// at the beginning of the URL + if ((str = strchr(url,'/')) != NULL && str[1] == '/') { + int i; + + str+=2; + for (i=0 ; str[i] ; i++) + url[i]=str[i]; + url[i]='\0'; + } + + if(!LongUrl) { + int i; + + for (i=0 ; i