~ubuntu-branches/ubuntu/natty/sarg/natty

« back to all changes in this revision

Viewing changes to repday.c

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2010-01-11 15:07:10 UTC
  • mfrom: (1.1.8 upstream) (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100111150710-mgvjhyjs13mrg0tb
Tags: 2.2.6-1
* New upstream release
  - Fixes issues in getword loop detection (Closes: #522284)
  - Removed patches integrated upstream
  - Fixes usertab parsing for IPv6 address (Closes: #504749)
  - Fixes typo in dansguardian_log.c (Closes: #540438)
  - Fixes error parsing squidGuard logs (Closes: #486895)

* debian/sarg-reports.conf
  - Fixed typo (Closes: #517356)

* debian/control
  - Added Build-Dep options on libgd2-xpm-dev (Closes: #540121)
  - Added Dependency on ${misc:Depends}
  - Added dependency on dpatch
  - Bumped Standard-Version to 3.8.3

* debian/compat
  - Upgraded debhelper compatibility to level 6

* debian/rules
  - Removed unnecessary upgrade of autoconf files
  - Added dpatch rules
  - Fixed configuration options and paths

* debian/patches/01_makefile-install-path
  - Fixed build-time installation paths

* debian/patches/02_config-file-references
  - Fixed references to configuration files

* debian/squid.conf
  - Sinced with upstream changes

* debian/{postrm,preinst,sarg.conf,sarg-reports,rules,dirs,sarg-reports.conf}
  - Moved configuration files to /etc/sarg and data directory to /var/lib/sarg
    (Closes: #553554, #502273)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * AUTHOR: Pedro Lineu Orso                         pedro.orso@gmail.com
3
 
 *                                                            1998, 2008
 
3
 *                                                            1998, 2009
4
4
 * SARG Squid Analysis Report Generator      http://sarg.sourceforge.net
5
5
 *
6
6
 * SARG donations:
24
24
 */
25
25
 
26
26
#include "include/conf.h"
 
27
#include "include/defs.h"
27
28
 
28
29
extern numlist hours;
29
30
 
30
 
void report_day(char *user, int *iprel, int *ipuser)
 
31
void report_day(const char *user)
31
32
{
32
33
 
33
34
   FILE *fp_in, *fp_ou;
70
71
   fprintf(fp_ou, "<!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);
71
72
   css(fp_ou);
72
73
   fputs("</head>\n",fp_ou);
73
 
   if(strlen(FontFace) > 0) fprintf(fp_ou,"<font face=%s>\n",FontFace);
74
 
   fprintf(fp_ou,"<body bgcolor=%s text=%s background='%s'>\n",BgColor,TxColor,BgImage);
75
 
   if(strlen(LogoImage) > 0) fprintf(fp_ou, "<center><table cellpadding=\"0\" cellspacing=\"0\">\n<tr><th class=\"logo\"><img src='%s' border=0 align=absmiddle width=%s height=%s>&nbsp;%s</th></tr>\n<tr><td height=\"5\"></td></tr>\n</table>\n",LogoImage,Width,Height,LogoText);
 
74
   //if(strlen(FontFace) > 0) fprintf(fp_ou,"<font face=%s>\n",FontFace);
 
75
   fprintf(fp_ou,"<body bgcolor=\"%s\" text=\"%s\" background=\"%s\">\n",BgColor,TxColor,BgImage);
 
76
   write_logo_image(fp_ou);
76
77
 
77
78
   if(strcmp(IndexTree,"date") == 0)
78
79
      show_sarg(fp_ou, "../../../..");
79
80
   else
80
81
      show_sarg(fp_ou, "../..");
81
82
 
82
 
   fputs("<center><table cellpadding=0 cellspacing=0>\n",fp_ou);
83
 
   sprintf(html,"<tr><th class=\"title\" colspan=2>%s</th></tr>\n",Title);
84
 
   fputs(html,fp_ou);
85
 
   
86
 
   fputs("</table></center>\n",fp_ou);
87
 
   fputs("<center><table cellpadding=0 cellspacing=0>\n",fp_ou);
88
 
 
89
 
   sprintf(html,"<tr><td class=\"header3\" colspan=\"2\">%s:&nbsp;%s</td></tr>\n",text[89],period);
90
 
   fputs(html,fp_ou);
 
83
   fputs("<div align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\">\n",fp_ou);
 
84
   fprintf(fp_ou,"<tr><th class=\"title\" colspan=\"2\">%s</th></tr>\n",Title);
 
85
 
 
86
   fputs("</table></div>\n",fp_ou);
 
87
   fputs("<div align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\">\n",fp_ou);
 
88
 
 
89
   fprintf(fp_ou,"<tr><td class=\"header3\" colspan=\"2\">%s:&nbsp;%s</td></tr>\n",text[89],period);
91
90
 
92
91
   strcpy(wuser,user);
93
92
   if(strstr(wuser,"_") != 0)
96
95
   if(strcmp(Ip2Name,"yes") == 0)
97
96
      if((str=(char *) strstr(name, ".")) != (char *) NULL) {
98
97
         if((str=(char *) strstr(str+1, ".")) != (char *) NULL)
99
 
            ip2name(wuser);
100
 
   }
101
 
 
102
 
   if(UserTabFile[0] != '\0') {
103
 
      sprintf(warea,":%s:",wuser);
104
 
      if((str=(char *) strstr(userfile,warea)) != (char *) NULL ) {
105
 
         z1=0;
106
 
         str2=(char *) strstr(str+1,":");
107
 
         str2++;
108
 
         bzero(name, MAXLEN);
109
 
         while(str2[z1] != ':') {
110
 
            name[z1]=str2[z1];
111
 
            z1++;
112
 
         }
113
 
      } else strcpy(name,wuser);
114
 
   } else strcpy(name,user);
115
 
 
116
 
   if(dotinuser && strstr(name,"_")) {
117
 
      str2=(char *)subs(name,"_",".");
118
 
      strcpy(name,str2);
119
 
   }
120
 
     
121
 
   sprintf(html,"<tr><th class=\"header3\" colspan=\"2\">%s:&nbsp;%s</th></tr>\n",text[90],name);
122
 
   fputs(html,fp_ou);
 
98
            ip2name(wuser,sizeof(wuser));
 
99
   }
 
100
 
 
101
   get_usertab_name(wuser,name,sizeof(name));
 
102
 
 
103
   if(dotinuser && strchr(name,'_')) {
 
104
      subs(name,sizeof(name),"_",".");
 
105
   }
 
106
 
 
107
   fprintf(fp_ou,"<tr><th class=\"header3\" colspan=\"2\">%s:&nbsp;%s</th></tr>\n",text[90],name);
123
108
 
124
109
   fputs("<tr><td></td></tr><tr><td></td></tr>\n",fp_ou);
125
110
   fputs("<tr><td></td></tr><tr><td></td></tr></table>\n",fp_ou);
126
111
 
127
 
   fputs("<table cellpadding=0 cellspacing=2>\n", fp_ou);
 
112
   fputs("<table cellpadding=\"0\" cellspacing=\"2\">\n", fp_ou);
128
113
 
129
 
   fputs( "<tr><td border=0></td>\n", fp_ou );
 
114
   fputs( "<tr><td></td>\n", fp_ou );
130
115
 
131
116
   if(strcmp(datetimeby,"bytes") == 0)
132
117
     strcpy( html, text[93] );
134
119
     strcpy( html, "H:M:S" );
135
120
 
136
121
   for( i = 0; i < hours.len; i++ )
137
 
     fprintf( fp_ou,
138
 
        "<td class=\"header3\">%02dH<br>%s</td>\n", hours.list[ i ], html );
 
122
     fprintf( fp_ou, "<td class=\"header3\">%02dH<br>%s</td>\n", hours.list[ i ], html );
139
123
   fprintf( fp_ou,
140
124
     "<td class=\"header3\">%s<br>%s</td></tr>\n", text[107], html );
141
125
 
142
126
   while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
143
 
      getword(data,sizeof(data),buf,' ');
 
127
      if (getword(data,sizeof(data),buf,' ')<0) {
 
128
         printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wdirname);
 
129
         exit(1);
 
130
      }
144
131
      if(!count) {
145
132
         strcpy(odata,data);
146
133
         count++;
147
134
      }
148
135
 
149
 
      getword(hour,sizeof(hour),buf,' ');
150
 
      getword(elap,sizeof(elap),buf,' ');
 
136
      if (getword(hour,sizeof(hour),buf,' ')<0 || getword(elap,sizeof(elap),buf,' ')<0) {
 
137
         printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wdirname);
 
138
         exit(1);
 
139
      }
151
140
      elap[strlen(elap)-1]='\0';
152
141
 
153
142
      if(strcmp(data,odata) != 0) {
154
143
         strcpy(oelap,elap);
155
144
 
156
 
         for( i = 0; i < hours.len; i++ )
157
 
           sprintf(c[ hours.list[ i ] ],"%s",fixtime(v[ hours.list[ i ] ]));
158
 
 
159
 
         for( i = 8; i <= 17; i++ )
160
 
           if(strcmp(c[ hours.list[ i ] ],"00:00:00") == 0)
161
 
                bzero(c[ hours.list[ i ] ],12);
162
 
 
163
 
         fprintf( fp_ou,
164
 
       "<tr><td class=\"data\">%s</td>\n", odata );
165
 
         for( i = 0; i < hours.len; i++ )
166
 
           fprintf( fp_ou,
167
 
             "<td class=\"data\">%s</td>\n", c[ hours.list[ i ] ] );
168
 
         fprintf( fp_ou,
169
 
           "<td class=\"data\">%s</td>\n", fixtime(tt) );
170
 
        
 
145
         for( i = 0; i < hours.len; i++ )
 
146
            sprintf(c[ hours.list[ i ] ],"%s",fixtime(v[ hours.list[ i ] ]));
 
147
 
 
148
         for( i = 8; i <= 17; i++ )
 
149
            if(strcmp(c[ hours.list[ i ] ],"00:00:00") == 0)
 
150
               bzero(c[ hours.list[ i ] ],12);
 
151
 
 
152
         fprintf(fp_ou, "<tr><td class=\"data\">%s</td>\n", odata );
 
153
         for( i = 0; i < hours.len; i++ )
 
154
            fprintf(fp_ou,"<td class=\"data\">%s</td>\n", c[ hours.list[ i ] ] );
 
155
         fprintf( fp_ou, "<td class=\"data\">%s</td>\n", fixtime(tt) );
 
156
 
171
157
         tt=0;
172
 
         for( i = 0; i < hours.len; i++ ) v[ hours.list[ i ] ]=0;
 
158
         for( i = 0; i < hours.len; i++ ) v[ hours.list[ i ] ]=0;
173
159
         strcpy(odata,data);
174
160
         strcpy(elap,oelap);
175
161
      }
188
174
 
189
175
   for( i = 0; i < hours.len; i++ )
190
176
     if(strcmp(c[ hours.list[ i ] ],"00:00:00") == 0) bzero(c[ hours.list[ i ] ],12);
191
 
 
192
 
   fprintf( fp_ou,
193
 
     "<tr><td class=\"data\">%s</td>\n", data );
 
177
 
 
178
   fprintf(fp_ou, "<tr><td class=\"data\">%s</td>\n", data );
194
179
   for( i = 0; i < hours.len; i++ )
195
 
     fprintf( fp_ou,
196
 
       "<td class=\"data\">%s</td>\n", c[ hours.list[ i ] ] );
197
 
   fprintf( fp_ou,
198
 
     "<td class=\"data\">%s</td></tr>\n", fixtime(tt) );
 
180
     fprintf(fp_ou, "<td class=\"data\">%s</td>\n", c[ hours.list[ i ] ] );
 
181
   fprintf(fp_ou, "<td class=\"data\">%s</td></tr>\n", fixtime(tt) );
199
182
 
200
183
   for( i = 0; i < hours.len; i++ )
201
184
     sprintf(c[ hours.list[ i ] ],"%s",fixtime(t[ hours.list[ i ] ]));
202
185
 
203
 
   fprintf( fp_ou,
204
 
     "<tr><td class=\"header\">%s</td>\n", text[107] );
 
186
   fprintf(fp_ou, "<tr><td class=\"header\">%s</td>\n", text[107] );
205
187
   for( i = 0; i < hours.len; i++ )
206
 
     fprintf( fp_ou,
207
 
       "<td class=\"header2\">%s</td>\n", c[ hours.list[ i ] ] );
208
 
   fprintf( fp_ou,
209
 
     "<td class=\"header2\">%s</td></tr>\n", fixtime(ttt) );
 
188
     fprintf(fp_ou, "<td class=\"header2\">%s</td>\n", c[ hours.list[ i ] ] );
 
189
   fprintf(fp_ou, "<td class=\"header2\">%s</td></tr>\n", fixtime(ttt) );
 
190
 
 
191
   fputs("</table></div>\n",fp_ou);
 
192
 
 
193
   show_info(fp_ou);
210
194
 
211
195
   fputs("</body>\n</html>\n",fp_ou);
212
 
 
213
 
   show_info(fp_ou);
214
 
 
215
196
   fclose(fp_in);
216
197
   fclose(fp_ou);
217
198
   return;