Loading ...
Sorry, an error occurred while loading the content.

2407Patch for user tracking.

Expand Messages
  • zig241
    Dec 3, 2003
    • 0 Attachment
      Hello,
      I was looking for a way to track user activity on a web site so I
      created a quick and dirty patch for webalizer. I am using a
      certificate based authentication but I think that basic
      authentication should work as well (but I didn't try it).
      The patch will convert the user names on every monthly over view to
      links, one page per user per month with a list of the requested
      pages, timestamps and remote IPs.
      The log format I'm using is:
      CustomLog logs/ssl_request_log \
      "%h %l %{SSL_CLIENT_S_DN_CN}x %t \"%r\" %>s %b \"%{Referer}
      i\" \"%{User-agent}i\""

      And here is the patch (and I hope I helped somebody):


      *** webalizer.c 2003-05-18 21:37:00.000000000 +0000
      --- webalizer.c 2003-05-18 23:04:30.000000000 +0000
      ***************
      *** 230,235 ****
      --- 230,236 ----

      int main(int argc, char *argv[])
      {
      + FILE *fp;
      int i; /* generic
      counter */
      char *cp1, *cp2, *cp3, *str; /* generic char
      pointers */
      NLISTPTR lptr; /* generic list
      pointer */
      ***************
      *** 1102,1107 ****
      --- 1103,1145 ----
      }
      }

      + /* user tracking patch - write to user file */
      + if(strcmp("-", log_rec.ident) != 0)
      + {
      + cp3 = (char *)malloc(strlen(log_rec.ident) + 12);
      + sprintf(cp3,"%s_%04d%
      02d.htm",log_rec.ident,cur_year,cur_month);
      + if ( (fp=fopen(cp3,"r")) == NULL)
      + {
      + if ( (fp=fopen(cp3,"w")) != NULL)
      + {
      + fprintf(fp, "<html>\n");
      + fprintf(fp, "<head>\n");
      + fprintf(fp, "<title>Usage Statistics for User %
      s - %02d/%04d</title>\n", log_rec.ident, cur_month, cur_year);
      + fprintf(fp, "</head>\n");
      + fprintf(fp, "<BODY BGCOLOR=\"#E8E8E8\"
      TEXT=\"#000000\" LINK=\"#0000FF\" VLINK=\"#FF0000\">");
      + fprintf(fp,"<h1>User tracking for <font
      color=\"#FF0000\">%s</font> %02d/%04d</h1><br>\n<small>\n"
      + ,log_rec.ident, cur_month, cur_year);
      + fprintf(fp, "<A href=\"javascript:history.go(-1)
      \">Back</A>\n");
      + fprintf(fp,"<table><tr><td width=\"200
      \">Time</td><td width=\"100\">Host</td><td width=\"400\">"
      + "<font color=\"#FF0000
      \">URL</font></td></tr></table>\n<hr>\n");
      + fprintf(fp, "</body>\n");
      + fprintf(fp, "</html>\n");
      + fclose(fp);
      + }
      + }
      + if ( (fp=fopen(cp3,"r+")) != NULL)
      + {
      + fseek(fp, -16L, SEEK_END);
      + fprintf(fp,"<table><tr><td width=\"200\">%i-%02d-%
      02d %02d:%02d:%02d</td><td width=\"100\">%s</td><td width=\"400\">"
      + "<font color=\"#FF0000\">%
      s</font></td></tr></table>\n", rec_year, rec_month, rec_day,
      rec_hour, rec_min, rec_sec, log_rec.hostname ,log_rec.url);
      + fprintf(fp, "</body>\n");
      + fprintf(fp, "</html>\n");
      + fclose(fp);
      + }
      + free(cp3);
      + }
      + /* patch end */
      +
      /* referrer hash table */
      if (ntop_refs)
      {

      *** output.c 2003-05-18 21:36:48.000000000 +0000
      --- output.c 2003-05-18 21:37:43.000000000 +0000
      ***************
      *** 234,239 ****
      --- 234,240 ----
      fprintf(out_fp,"<SMALL>Generated by\n");
      fprintf(out_fp,"<A HREF=\"http://www.mrunix.net/webalizer/\">");
      fprintf(out_fp,"<STRONG>Webalizer Version %
      s</STRONG></A>\n",version);
      + fprintf(out_fp," Patched for user tracking by <a
      href=\"mailto:anoy@...\"><STRONG>Alon
      Noy</STRONG></a>\n");
      fprintf(out_fp,"</SMALL>\n</TD>\n");
      lptr=html_tail;
      if (lptr)
      ***************
      *** 1808,1815 ****
      if ((iptr->flag==OBJ_GRP)&&hlite_groups)
      fprintf(out_fp,"<STRONG>%
      s</STRONG></FONT></TD></TR>\n",
      iptr->string);
      ! else fprintf(out_fp,"%s</FONT></TD></TR>\n",
      ! iptr->string);
      tot_num--;
      i++;
      }
      --- 1809,1816 ----
      if ((iptr->flag==OBJ_GRP)&&hlite_groups)
      fprintf(out_fp,"<STRONG>%
      s</STRONG></FONT></TD></TR>\n",
      iptr->string);
      ! else fprintf(out_fp,"<a href=\"%s_%04d%02d.htm\">%
      s</a></FONT></TD></TR>\n",
      ! iptr->string, cur_year, cur_month, iptr->string);
      tot_num--;
      i++;
      }