]>
git.ipfire.org Git - thirdparty/sarg.git/blob - repday.c
2 * AUTHOR: Pedro Lineu Orso pedro.orso@gmail.com
4 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
7 * please look at http://sarg.sourceforge.net/donations.php
8 * ---------------------------------------------------------------------
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
26 #include "include/conf.h"
27 #include "include/defs.h"
31 void report_day ( const char * user
)
41 char wdirname
[ MAXLEN
];
47 long long int v
[ 24 ] = { 0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L ,
48 0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L };
49 long long int t
[ 24 ] = { 0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L ,
50 0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L };
51 long long int tt
= 0 , ttt
= 0 ;
53 struct getwordstruct gwarea
;
55 sprintf ( arqout
, "%s/%s/d%s.html" , dirname
, user
, user
);
56 sprintf ( wdirname
, "%s/%s.day" , tmp
, user
);
58 if ( access ( wdirname
, R_OK
) != 0 )
61 if (( fp_in
= fopen ( wdirname
, "r" ))== NULL
) {
62 fprintf ( stderr
, "SARG: (repday) %s: %s \n " , text
[ 8 ], wdirname
);
66 if (( fp_ou
= fopen ( arqout
, "w" ))== NULL
) {
67 fprintf ( stderr
, "SARG: (repday) %s: %s \n " , text
[ 8 ], arqout
);
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
);
73 fputs ( "</head> \n " , fp_ou
);
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
);
78 if ( strcmp ( IndexTree
, "date" ) == 0 )
79 show_sarg ( fp_ou
, "../../../.." );
81 show_sarg ( 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
);
86 fputs ( "</table></div> \n " , fp_ou
);
87 fputs ( "<div align= \" center \" ><table cellpadding= \" 0 \" cellspacing= \" 0 \" > \n " , fp_ou
);
89 fprintf ( fp_ou
, "<tr><td class= \" header3 \" colspan= \" 2 \" >%s: %s</td></tr> \n " , text
[ 89 ], period
);
92 if ( strstr ( wuser
, "_" ) != 0 )
95 if ( strcmp ( Ip2Name
, "yes" ) == 0 )
96 if (( str
=( char *) strstr ( name
, "." )) != ( char *) NULL
) {
97 if (( str
=( char *) strstr ( str
+ 1 , "." )) != ( char *) NULL
)
98 ip2name ( wuser
, sizeof ( wuser
));
101 get_usertab_name ( wuser
, name
, sizeof ( name
));
103 if ( dotinuser
&& strchr ( name
, '_' )) {
104 subs ( name
, sizeof ( name
), "_" , "." );
107 fprintf ( fp_ou
, "<tr><th class= \" header3 \" colspan= \" 2 \" >%s: %s</th></tr> \n " , text
[ 90 ], name
);
109 fputs ( "<tr><td></td></tr><tr><td></td></tr> \n " , fp_ou
);
110 fputs ( "<tr><td></td></tr><tr><td></td></tr></table> \n " , fp_ou
);
112 fputs ( "<table cellpadding= \" 0 \" cellspacing= \" 2 \" > \n " , fp_ou
);
114 fputs ( "<tr><td></td> \n " , fp_ou
);
116 if ( strcmp ( datetimeby
, "bytes" ) == 0 )
117 strcpy ( html
, text
[ 93 ] );
119 strcpy ( html
, "H:M:S" );
121 for ( i
= 0 ; i
< hours
. len
; i
++ )
122 fprintf ( fp_ou
, "<td class= \" header3 \" >%02dH<br>%s</td> \n " , hours
. list
[ i
], html
);
124 "<td class= \" header3 \" >%s<br>%s</td></tr> \n " , text
[ 107 ], html
);
126 while ( fgets ( buf
, sizeof ( buf
), fp_in
)!= NULL
) {
128 getword_start (& gwarea
, buf
);
129 if ( getword ( data
, sizeof ( data
),& gwarea
, ' \t ' )< 0 ) {
130 printf ( "SARG: Maybe you have a broken record or garbage in your %s file. \n " , wdirname
);
138 if ( getword ( hour
, sizeof ( hour
),& gwarea
, ' \t ' )< 0 || getword_atoll (& elap
,& gwarea
, ' \t ' )< 0 ) {
139 printf ( "SARG: Maybe you have a broken record or garbage in your %s file. \n " , wdirname
);
143 if ( strcmp ( data
, odata
) != 0 ) {
144 for ( i
= 0 ; i
< hours
. len
; i
++ )
145 sprintf ( c
[ hours
. list
[ i
] ], "%s" , fixtime ( v
[ hours
. list
[ i
] ]));
147 for ( i
= 8 ; i
<= 17 ; i
++ )
148 if ( strcmp ( c
[ hours
. list
[ i
] ], "00:00:00" ) == 0 )
149 bzero ( c
[ hours
. list
[ i
] ], 12 );
151 fprintf ( fp_ou
, "<tr><td class= \" data \" >%s</td> \n " , odata
);
152 for ( i
= 0 ; i
< hours
. len
; i
++ )
153 fprintf ( fp_ou
, "<td class= \" data \" >%s</td> \n " , c
[ hours
. list
[ i
] ] );
154 fprintf ( fp_ou
, "<td class= \" data \" >%s</td> \n " , fixtime ( tt
) );
157 for ( i
= 0 ; i
< hours
. len
; i
++ ) v
[ hours
. list
[ i
] ]= 0 ;
170 for ( i
= 0 ; i
< hours
. len
; i
++ )
171 sprintf ( c
[ hours
. list
[ i
] ], "%s" , fixtime ( v
[ hours
. list
[ i
] ]));
173 for ( i
= 0 ; i
< hours
. len
; i
++ )
174 if ( strcmp ( c
[ hours
. list
[ i
] ], "00:00:00" ) == 0 ) bzero ( c
[ hours
. list
[ i
] ], 12 );
176 fprintf ( fp_ou
, "<tr><td class= \" data \" >%s</td> \n " , data
);
177 for ( i
= 0 ; i
< hours
. len
; i
++ )
178 fprintf ( fp_ou
, "<td class= \" data \" >%s</td> \n " , c
[ hours
. list
[ i
] ] );
179 fprintf ( fp_ou
, "<td class= \" data \" >%s</td></tr> \n " , fixtime ( tt
) );
181 for ( i
= 0 ; i
< hours
. len
; i
++ )
182 sprintf ( c
[ hours
. list
[ i
] ], "%s" , fixtime ( t
[ hours
. list
[ i
] ]));
184 fprintf ( fp_ou
, "<tr><td class= \" header \" >%s</td> \n " , text
[ 107 ] );
185 for ( i
= 0 ; i
< hours
. len
; i
++ )
186 fprintf ( fp_ou
, "<td class= \" header2 \" >%s</td> \n " , c
[ hours
. list
[ i
] ] );
187 fprintf ( fp_ou
, "<td class= \" header2 \" >%s</td></tr> \n " , fixtime ( ttt
) );
189 fputs ( "</table></div> \n " , fp_ou
);
193 fputs ( "</body> \n </html> \n " , fp_ou
);