]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Ported r144 from branches/v2_2_6_1 (useragent sort separator)
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Thu, 10 Dec 2009 08:46:31 +0000 (08:46 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Thu, 10 Dec 2009 08:46:31 +0000 (08:46 +0000)
CMakeLists.txt
ChangeLog
getconf.c
include/info.h
useragent.c

index f7d63200da8c2394791a8684732757dbdb3ed1d5..9dd4a0f69518376a97179c37acb0525f5424c6d0 100755 (executable)
@@ -3,7 +3,7 @@ PROJECT(sarg C)
 SET(sarg_VERSION 2)
 SET(sarg_REVISION 2)
 SET(sarg_BUILD "7rc1")
-SET(sarg_BUILDDATE "Dec-09-2009")
+SET(sarg_BUILDDATE "Dec-10-2009")
 
 INCLUDE(AddFileDependencies)
 INCLUDE(CheckIncludeFile)
index 6ed3df6ef0fa7df9ce4f0382e79fe1d2e3f87f25..e3417d637528cd9a2a127bafbaa228a1cbb75eb9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,8 +2,6 @@ SARG ChangeLog
 
 Dec-03-2009 Version 2.2.7
                - Extra compile and run time protection (FORTIFY_SOURCE) fixed in configure.
-               - Invalid sort field separator in useragent.c
-                       Thanks to Maxim Britov <maxim@office.modum.by>
                - Use tabulations as columns separator in intermediary files to avoid problems when a field of the log contains a space.
                - Input log file type detection partly rewritten to clearly distinguish which type is processed where.
                - Read the input log file from standard input if log file name is -.
@@ -12,6 +10,7 @@ Dec-09-2009 Version 2.2.6.1
                - Remove unecessary dependency on off_t.
                - Configuration doesn't fail if rlim_t is not available.
                - Test for the availability of -Werror=xxx flags in gcc.
+               - Fix sort delimiter when reading useragent log (thanks to Maxim Britov).
 
 Oct-14-2009 Version 2.2.6
                - Protection against buffer overflows in getword and friends and report the origin of the error instead of always blaming access.log.
index 93312d6179d7625269a36acd73ee21248b60e1a2..c4d6142e43dedd8edfff3362a1a12485e4fb42e6 100644 (file)
--- a/getconf.c
+++ b/getconf.c
@@ -294,7 +294,7 @@ static void parmtest(char *buf)
 
    if (getparam_string("privacy",buf,Privacy,sizeof(Privacy))>0) return;
 
-   if (getparam_quoted("privacy_string",buf,ExcludeString,sizeof(ExcludeString))>0) return;
+   if (getparam_quoted("privacy_string",buf,PrivacyString,sizeof(PrivacyString))>0) return;
 
    if (getparam_string("privacy_string_color",buf,PrivacyStringColor,sizeof(PrivacyStringColor))>0) return;
 
index fc91f62c56efba8c61a1ed4fb49ffc27b8328d7a..166789489ac11c14f956e80ac94b252682b9d376 100755 (executable)
@@ -1,3 +1,3 @@
-#define VERSION PACKAGE_VERSION" Dec-09-2009"
+#define VERSION PACKAGE_VERSION" Dec-10-2009"
 #define PGM PACKAGE_NAME
 #define URL "http://sarg.sourceforge.net"
index faff6d91be1816dce0ebaa24b85113caa71a2fb4..ff0789ad3301aec6150f731ac578426f1b588d4b 100644 (file)
@@ -51,8 +51,6 @@ void useragent(void)
    ipbefore[0]='\0';
    namebefore[0]='\0';
 
-   sprintf(hfile,"%s/%s/useragent.html", outdir,period);
-
    sprintf(tmp3,"%s/squagent.unsort",TempDir);
    sprintf(tmp2,"%s/squagent.log",TempDir);
 
@@ -100,7 +98,7 @@ void useragent(void)
       if(strlen(user) == 0)
          strcpy(user,ip);
 
-      fprintf(fp_ou,"%s\\%s\\%s\\%s\\\n",ip,data,agent,user);
+      fprintf(fp_ou,"%s\t%s\t%s\t%s\n",ip,data,agent,user);
       user[0]='\0';
    }
 
@@ -121,7 +119,7 @@ void useragent(void)
       debuga("%s: %s",text[54],tmp2);
    }
 
-   sprintf(csort,"sort -n -t \"\\\" -k 4,4 -k 3,3 -k 2,2 -k 1,1 -o \"%s\" \"%s\"",tmp2,tmp3);
+   sprintf(csort,"sort -n -t \"\t\" -k 4,4 -k 3,3 -k 2,2 -k 1,1 -o \"%s\" \"%s\"",tmp2,tmp3);
    cstatus=system(csort);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
@@ -136,6 +134,7 @@ void useragent(void)
 
    unlink(tmp3);
 
+   sprintf(hfile,"%s/%s/useragent.html", outdir,period);
    if((fp_ht=fopen(hfile,"w"))==NULL) {
       fprintf(stderr, "SARG: (useragent) %s: %s\n",text[45],hfile);
       exit(1);
@@ -146,8 +145,8 @@ void useragent(void)
 
    fprintf(fp_ht, "<!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);
    fputs("</head>\n",fp_ht);
-   if(strlen(FontFace) > 0) fprintf(fp_ht,"<font face=%s>\n",FontFace);
-   fprintf(fp_ht,"<body bgcolor=%s text=%s background='%s'>\n",BgColor,TxColor,BgImage);
+   if(FontFace[0] != '\0') fprintf(fp_ht,"<font face=\"%s\">\n",FontFace);
+   fprintf(fp_ht,"<body bgcolor=\"%s\" text=\"%s\" background=\"%s\">\n",BgColor,TxColor,BgImage);
    write_logo_image(fp_ht);
 
    if(strcmp(IndexTree,"date") == 0)
@@ -168,10 +167,10 @@ void useragent(void)
    fputs("<div align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\">\n",fp_ht);
    fputs("<tr><td></td><td></td></tr>",fp_ht);
 
-   fprintf(fp_ou,"<tr><th align=left bgcolor=%s><font size=%s color=%s>%s</font></th><th bgcolor=%s align=left><font size=%s color=%s>%s</font></th></tr>\n",HeaderBgColor,FontSize,HeaderColor,text[98],HeaderBgColor,FontSize,HeaderColor,text[106]);
+   fprintf(fp_ou,"<tr><th align=\"left\" bgcolor=\"%s\"><font size=\"%s\" color=\"%s\">%s</font></th><th bgcolor=\"%s\" align=\"left\"><font size=\"%s\" color=\"%s\">%s</font></th></tr>\n",HeaderBgColor,FontSize,HeaderColor,text[98],HeaderBgColor,FontSize,HeaderColor,text[106]);
 
    while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
-      if (getword(ip,sizeof(ip),buf,'\\')<0) {
+      if (getword(ip,sizeof(ip),buf,'\t')<0) {
          printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",tmp2);
          exit(1);
       }
@@ -184,19 +183,19 @@ void useragent(void)
          } else strcpy(ip,namebefore);
       }
 
-      if (getword(data,sizeof(data),buf,'\\')<0 || getword(agent,sizeof(agent),buf,'\\')<0 ||
-          getword(user,sizeof(user),buf,'\\')<0) {
+      if (getword(data,sizeof(data),buf,'\t')<0 || getword(agent,sizeof(agent),buf,'\t')<0 ||
+          getword(user,sizeof(user),buf,'\t')<0) {
          printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",tmp2);
          exit(1);
       }
 
       if(strcmp(user,user_old) != 0) {
-         fprintf(fp_ht,"<tr><td align=left bgcolor=%s><font size=%s>%s</td><td align=left bgcolor=%s><font size=%s>%s</td></tr>\n",TxBgColor,FontSize,user,TxBgColor,FontSize,agent);
+         fprintf(fp_ht,"<tr><td align=\"left\" bgcolor=\"%s\"><font size=\"%s\">%s</td><td align=\"left\" bgcolor=\"%s\"><font size=\"%s\">%s</td></tr>\n",TxBgColor,FontSize,user,TxBgColor,FontSize,agent);
          strcpy(user_old,user);
          strcpy(agent_old,agent);
       } else {
          if(strcmp(agent,agent_old) != 0) {
-            fprintf(fp_ht,"<tr><td></td><td align=left bgcolor=%s><font size=%s>%s</td></tr>\n",TxBgColor,FontSize,agent);
+            fprintf(fp_ht,"<tr><td></td><td align=\"left\" bgcolor=\"%s\"><font size=\"%s\">%s</td></tr>\n",TxBgColor,FontSize,agent);
             strcpy(agent_old,agent);
          }
       }
@@ -206,7 +205,7 @@ void useragent(void)
    fclose(fp_in);
    fclose(fp_ou);
 
-   sprintf(csort,"sort -n -t \"\\\" -k 3,3 -o \"%s\" \"%s\"",tmp3,tmp2);
+   sprintf(csort,"sort -n -t \"\t\" -k 3,3 -o \"%s\" \"%s\"",tmp3,tmp2);
    cstatus=system(csort);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
@@ -229,8 +228,8 @@ void useragent(void)
    agent_old[0]='\0';
 
    while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
-      if (getword(ip,sizeof(ip),buf,'\\')<0 || getword(data,sizeof(data),buf,'\\')<0 ||
-          getword(agent,sizeof(agent),buf,'\\')<0) {
+      if (getword(ip,sizeof(ip),buf,'\t')<0 || getword(data,sizeof(data),buf,'\t')<0 ||
+          getword(agent,sizeof(agent),buf,'\t')<0) {
          printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",tmp);
          exit(1);
       }
@@ -293,7 +292,7 @@ void useragent(void)
       perc=atoi(tagent) * 100;
       perc=perc / agentot2;
 
-      fprintf(fp_ht,"<tr><td align=left bgcolor=%s><font size=%s>%s</td><td align=right bgcolor=%s><font size=%s>%d</td><td align=right bgcolor=%s><font size=%s>%3.2f</td></tr>\n",TxBgColor,FontSize,buf,TxBgColor,FontSize,atoi(tagent),TxBgColor,FontSize,perc);
+      fprintf(fp_ht,"<tr><td align=\"left\" bgcolor=\"%s\"><font size=\"%s\">%s</td><td align=\"right\" bgcolor=\"%s\"><font size=\"%s\">%d</td><td align=\"right\" bgcolor=\"%s\"><font size=\"%s\">%3.2f</td></tr>\n",TxBgColor,FontSize,buf,TxBgColor,FontSize,atoi(tagent),TxBgColor,FontSize,perc);
    }
 
    fputs("</table></html>\n",fp_ht);