]>
Commit | Line | Data |
---|---|---|
25697a35 | 1 | /* |
94ff9470 | 2 | * SARG Squid Analysis Report Generator http://sarg.sourceforge.net |
fbd133bb | 3 | * 1998, 2011 |
25697a35 GS |
4 | * |
5 | * SARG donations: | |
6 | * please look at http://sarg.sourceforge.net/donations.php | |
1164c474 FM |
7 | * Support: |
8 | * http://sourceforge.net/projects/sarg/forums/forum/363374 | |
25697a35 GS |
9 | * --------------------------------------------------------------------- |
10 | * | |
11 | * This program is free software; you can redistribute it and/or modify | |
12 | * it under the terms of the GNU General Public License as published by | |
13 | * the Free Software Foundation; either version 2 of the License, or | |
14 | * (at your option) any later version. | |
15 | * | |
16 | * This program is distributed in the hope that it will be useful, | |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | * GNU General Public License for more details. | |
20 | * | |
21 | * You should have received a copy of the GNU General Public License | |
22 | * along with this program; if not, write to the Free Software | |
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
24 | * | |
25 | */ | |
26 | ||
27 | #include "include/conf.h" | |
5f3cfd1d | 28 | #include "include/defs.h" |
25697a35 | 29 | |
085c1e1f FM |
30 | #define SET_LIST(list) list,sizeof(list)/sizeof(list[0]) |
31 | ||
25697a35 GS |
32 | extern numlist hours, weekdays; |
33 | ||
085c1e1f FM |
34 | struct param_list |
35 | { | |
9bd92830 FM |
36 | //! The name of the value of the parameter. |
37 | const char *name; | |
38 | //! The bit to set if the value is found. | |
39 | unsigned long int value; | |
40 | //! The value is invalid if any bit of this mask is set in the parameter. | |
41 | unsigned long int exclude; | |
085c1e1f FM |
42 | }; |
43 | ||
15d5372b FM |
44 | struct sort_list |
45 | { | |
9bd92830 FM |
46 | //! The name of the value of the parameter. |
47 | const char *name; | |
48 | //! The bit to set if the value is found. | |
49 | unsigned long int value; | |
15d5372b FM |
50 | }; |
51 | ||
e43854ef | 52 | static struct param_list report_type_values[]= |
085c1e1f | 53 | { |
9bd92830 FM |
54 | {"users_sites",REPORT_TYPE_USERS_SITES,0}, |
55 | {"topusers",REPORT_TYPE_TOPUSERS,0}, | |
56 | {"topsites",REPORT_TYPE_TOPSITES,0}, | |
57 | {"sites_users",REPORT_TYPE_SITES_USERS,0}, | |
58 | {"date_time",REPORT_TYPE_DATE_TIME,0}, | |
59 | {"denied",REPORT_TYPE_DENIED,0}, | |
60 | {"auth_failures",REPORT_TYPE_AUTH_FAILURES,0}, | |
61 | {"site_user_time_date",REPORT_TYPE_SITE_USER_TIME_DATE,0}, | |
62 | {"downloads",REPORT_TYPE_DOWNLOADS,0}, | |
085c1e1f FM |
63 | }; |
64 | ||
e43854ef | 65 | static struct param_list data_field_values[]= |
085c1e1f | 66 | { |
9bd92830 FM |
67 | {"user",DATA_FIELD_USER,0}, |
68 | {"date",DATA_FIELD_DATE,0}, | |
69 | {"time",DATA_FIELD_TIME,0}, | |
70 | {"url",DATA_FIELD_URL,0}, | |
71 | {"connect",DATA_FIELD_CONNECT,0}, | |
72 | {"bytes",DATA_FIELD_BYTES,0}, | |
73 | {"in_cache",DATA_FIELD_IN_CACHE,0}, | |
74 | {"out_cache",DATA_FIELD_OUT_CACHE,0}, | |
75 | {"elapsed",DATA_FIELD_ELAPSED,0}, | |
085c1e1f FM |
76 | }; |
77 | ||
e43854ef | 78 | static struct param_list topuserfields_values[]= |
085c1e1f | 79 | { |
9bd92830 FM |
80 | {"NUM",TOPUSERFIELDS_NUM,0}, |
81 | {"DATE_TIME",TOPUSERFIELDS_DATE_TIME,0}, | |
82 | {"USERID",TOPUSERFIELDS_USERID,0}, | |
83 | {"CONNECT",TOPUSERFIELDS_CONNECT,0}, | |
84 | {"BYTES",TOPUSERFIELDS_BYTES,0}, | |
85 | {"%BYTES",TOPUSERFIELDS_SETYB,0}, | |
86 | {"SETYB",TOPUSERFIELDS_SETYB,0}, | |
87 | {"IN-CACHE-OUT",TOPUSERFIELDS_IN_CACHE_OUT,0}, | |
88 | {"USED_TIME",TOPUSERFIELDS_USED_TIME,0}, | |
89 | {"MILISEC",TOPUSERFIELDS_MILISEC,0}, | |
90 | {"%TIME",TOPUSERFIELDS_PTIME,0}, | |
91 | {"TOTAL",TOPUSERFIELDS_TOTAL,0}, | |
92 | {"AVERAGE",TOPUSERFIELDS_AVERAGE,0}, | |
085c1e1f FM |
93 | }; |
94 | ||
e43854ef | 95 | static struct param_list userreportfields_values[]= |
085c1e1f | 96 | { |
9bd92830 FM |
97 | {"CONNECT",USERREPORTFIELDS_CONNECT,0}, |
98 | {"BYTES",USERREPORTFIELDS_BYTES,0}, | |
99 | {"%BYTES",USERREPORTFIELDS_SETYB,0}, | |
100 | {"SETYB",USERREPORTFIELDS_SETYB,0}, | |
101 | {"IN-CACHE-OUT",USERREPORTFIELDS_IN_CACHE_OUT,0}, | |
102 | {"USED_TIME",USERREPORTFIELDS_USED_TIME,0}, | |
103 | {"MILISEC",USERREPORTFIELDS_MILISEC,0}, | |
104 | {"%TIME",USERREPORTFIELDS_PTIME,0}, | |
105 | {"TOTAL",USERREPORTFIELDS_TOTAL,0}, | |
106 | {"AVERAGE",USERREPORTFIELDS_AVERAGE,0}, | |
085c1e1f FM |
107 | }; |
108 | ||
e43854ef | 109 | static struct param_list index_values[]= |
0349fa24 | 110 | { |
9bd92830 FM |
111 | {"yes",INDEX_YES,~INDEX_YES}, |
112 | {"no",INDEX_NO,~INDEX_NO}, | |
113 | {"only",INDEX_ONLY,~INDEX_ONLY}, | |
0349fa24 FM |
114 | }; |
115 | ||
e43854ef | 116 | static struct param_list index_tree_values[]= |
0349fa24 | 117 | { |
9bd92830 FM |
118 | {"date",INDEX_TREE_DATE,~INDEX_TREE_DATE}, |
119 | {"file",INDEX_TREE_FILE,~INDEX_TREE_FILE}, | |
0349fa24 FM |
120 | }; |
121 | ||
9aaa3361 FM |
122 | static struct param_list indexfields_values[]= |
123 | { | |
124 | {"DIRSIZE",INDEXFIELDS_DIRSIZE,0}, | |
125 | }; | |
126 | ||
e43854ef | 127 | static struct param_list ntml_userformat_values[]= |
f2ec8c75 | 128 | { |
9bd92830 FM |
129 | {"user",NTLMUSERFORMAT_USER,~NTLMUSERFORMAT_USER}, |
130 | {"domainname+username",NTLMUSERFORMAT_DOMAINUSER,~NTLMUSERFORMAT_DOMAINUSER}, | |
f2ec8c75 FM |
131 | }; |
132 | ||
e43854ef | 133 | static struct param_list recnouser_values[]= |
f2ec8c75 | 134 | { |
9bd92830 FM |
135 | {"ip",RECORDWITHOUTUSER_IP,~RECORDWITHOUTUSER_IP}, |
136 | {"ignore",RECORDWITHOUTUSER_IGNORE,~RECORDWITHOUTUSER_IGNORE}, | |
137 | {"everybody",RECORDWITHOUTUSER_EVERYBODY,~RECORDWITHOUTUSER_EVERYBODY}, | |
f2ec8c75 FM |
138 | }; |
139 | ||
e43854ef | 140 | static struct param_list datafileurl_values[]= |
f84a35a3 | 141 | { |
9bd92830 FM |
142 | {"ip",DATAFILEURL_IP,~DATAFILEURL_IP}, |
143 | {"name",DATAFILEURL_NAME,~DATAFILEURL_NAME}, | |
f84a35a3 FM |
144 | }; |
145 | ||
e43854ef FM |
146 | static struct param_list displayvalue_values[]= |
147 | { | |
9bd92830 FM |
148 | {"bytes",DISPLAY_BYTES,~DISPLAY_BYTES}, |
149 | {"abbreviation",DISPLAY_ABBREV,~DISPLAY_ABBREV}, | |
e43854ef FM |
150 | }; |
151 | ||
43cc1649 FM |
152 | static struct param_list datetime_values[]= |
153 | { | |
9bd92830 FM |
154 | {"elap",DATETIME_ELAP,0}, |
155 | {"bytes",DATETIME_BYTE,0}, | |
43cc1649 FM |
156 | }; |
157 | ||
71d78774 FM |
158 | static struct param_list realtime_unauth_values[]= |
159 | { | |
9bd92830 FM |
160 | {"show",REALTIME_UNAUTH_REC_SHOW,~REALTIME_UNAUTH_REC_SHOW}, |
161 | {"ignore",REALTIME_UNAUTH_REC_IGNORE,~REALTIME_UNAUTH_REC_IGNORE}, | |
71d78774 FM |
162 | }; |
163 | ||
15d5372b FM |
164 | struct sort_list topuser_sort[]= |
165 | { | |
9bd92830 FM |
166 | {"BYTES",TOPUSER_SORT_BYTES}, |
167 | {"USER",TOPUSER_SORT_USER}, | |
168 | {"CONNECT",TOPUSER_SORT_CONNECT}, | |
169 | {"TIME",TOPUSER_SORT_TIME}, | |
15d5372b FM |
170 | }; |
171 | ||
172 | struct sort_list topsite_sort[]= | |
173 | { | |
9bd92830 FM |
174 | {"BYTES",TOPSITE_SORT_BYTES}, |
175 | {"CONNECT",TOPSITE_SORT_CONNECT}, | |
176 | {"TIME",TOPSITE_SORT_TIME}, | |
15d5372b FM |
177 | }; |
178 | ||
179 | struct sort_list user_sort[]= | |
180 | { | |
9bd92830 FM |
181 | {"BYTES",USER_SORT_BYTES}, |
182 | {"SITE",USER_SORT_SITE}, | |
183 | {"CONNECT",USER_SORT_CONNECT}, | |
184 | {"TIME",USER_SORT_TIME}, | |
15d5372b FM |
185 | }; |
186 | ||
6e792ade | 187 | static int is_param(const char *param,const char *buf) |
0a4e18e1 | 188 | { |
9bd92830 | 189 | int plen; |
0a4e18e1 | 190 | |
9bd92830 FM |
191 | plen=strlen(param); |
192 | if (strncmp(buf,param,plen) != 0) return(0); | |
193 | buf+=plen; | |
194 | if ((unsigned char)*buf>' ') return(0); | |
195 | return(1); | |
0a4e18e1 FM |
196 | } |
197 | ||
4af2f8ff FM |
198 | static int getparam_string(const char *param,char *buf,char *value,int value_size) |
199 | { | |
9bd92830 FM |
200 | int plen; |
201 | ||
202 | plen=strlen(param); | |
203 | if (strncmp(buf,param,plen) != 0) return(0); | |
204 | buf+=plen; | |
205 | if ((unsigned char)*buf>' ') return(0); | |
206 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
207 | ||
208 | if (strlen(buf)>=value_size) { | |
209 | debuga(_("The string value of parameter \"%s\" is too long\n"),param); | |
210 | exit(EXIT_FAILURE); | |
211 | } | |
212 | strcpy(value,buf); | |
213 | fixnone(value); | |
214 | return(1); | |
4af2f8ff | 215 | } |
25697a35 | 216 | |
4af2f8ff | 217 | static int getparam_quoted(const char *param,char *buf,char *value,int value_size) |
25697a35 | 218 | { |
9bd92830 FM |
219 | int plen; |
220 | int i; | |
221 | ||
222 | plen=strlen(param); | |
223 | if (strncmp(buf,param,plen) != 0) return(0); | |
224 | buf+=plen; | |
225 | if ((unsigned char)*buf>' ') return(0); | |
226 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
227 | ||
228 | if (*buf != '\"') { | |
229 | debuga(_("Missing double quote after parameter \"%s\"\n"),param); | |
230 | exit(EXIT_FAILURE); | |
231 | } | |
232 | buf++; | |
233 | ||
234 | value_size--; | |
235 | for (i=0 ; i<value_size && *buf && *buf!='\"' ; i++) { | |
236 | value[i]=*buf++; | |
237 | } | |
238 | value[i]='\0'; | |
239 | ||
240 | if (*buf != '\"') { | |
241 | debuga(_("Missing double quote after parameter \"%s\" or value is more than %d bytes long\n"),param,value_size); | |
242 | exit(EXIT_FAILURE); | |
243 | } | |
244 | fixnone(value); | |
245 | return(1); | |
4af2f8ff | 246 | } |
25697a35 | 247 | |
4af2f8ff FM |
248 | static int getparam_2words(const char *param,char *buf,char *word1,int word1_size,char *word2,int word2_size) |
249 | { | |
9bd92830 FM |
250 | int plen; |
251 | int i; | |
252 | ||
253 | plen=strlen(param); | |
254 | if (strncmp(buf,param,plen) != 0) return(0); | |
255 | buf+=plen; | |
256 | if ((unsigned char)*buf>' ') return(0); | |
257 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
258 | ||
259 | for (i=0 ; i<word1_size && *buf && (unsigned char)*buf>' ' ; i++) | |
260 | word1[i]=*buf++; | |
261 | if (i>=word1_size) { | |
262 | debuga(_("The first word of parameter \"%s\" is more than %d bytes long\n"),param,word1_size-1); | |
263 | exit(EXIT_FAILURE); | |
264 | } | |
265 | if (*buf!=' ') { | |
266 | debuga(_("Missing second word for parameter \"%s\"\n"),param); | |
267 | exit(EXIT_FAILURE); | |
268 | } | |
269 | word1[i]=0; | |
270 | ||
271 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
272 | ||
273 | for (i=0 ; i<word2_size && *buf && (unsigned char)*buf>' ' ; i++) | |
274 | word2[i]=*buf++; | |
275 | if (i>=word2_size) { | |
276 | debuga(_("The second word of parameter \"%s\" is more than %d bytes long\n"),param,word2_size-1); | |
277 | exit(EXIT_FAILURE); | |
278 | } | |
279 | word2[i]=0; | |
280 | ||
281 | fixnone(word1); | |
282 | fixnone(word2); | |
283 | return(1); | |
4af2f8ff | 284 | } |
25697a35 | 285 | |
4af2f8ff FM |
286 | static int getparam_int(const char *param,char *buf,int *value) |
287 | { | |
9bd92830 FM |
288 | int plen; |
289 | int next; | |
290 | ||
291 | plen=strlen(param); | |
292 | if (strncmp(buf,param,plen) != 0) return(0); | |
293 | buf+=plen; | |
294 | if ((unsigned char)*buf>' ') return(0); | |
295 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
296 | ||
297 | next=0; | |
298 | if (sscanf(buf,"%d%n",value,&next) != 1 || (unsigned char)buf[next] > ' ') { | |
299 | debuga(_("The integer value of parameter \"%s\" is invalid\n"),param); | |
300 | exit(EXIT_FAILURE); | |
301 | } | |
302 | return(1); | |
4af2f8ff | 303 | } |
25697a35 | 304 | |
06b39c87 | 305 | static int getparam_bool(const char *param,char *buf,bool *value) |
246c8489 | 306 | { |
9bd92830 FM |
307 | int plen; |
308 | int i; | |
309 | const char *bool_str="yes,true,on,1"; | |
310 | ||
311 | plen=strlen(param); | |
312 | if (strncmp(buf,param,plen) != 0) return(0); | |
313 | buf+=plen; | |
314 | if ((unsigned char)*buf>' ') return(0); | |
315 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
316 | ||
317 | *value=false; | |
318 | for ( ; *bool_str ; bool_str+=i) { | |
319 | for (i=0 ; bool_str[i] && bool_str[i]!=',' ; i++); | |
320 | if (strncasecmp(bool_str,buf,i)==0) { | |
321 | *value=true; | |
322 | break; | |
323 | } | |
324 | if (bool_str[i]==',') i++; | |
325 | } | |
326 | return(1); | |
246c8489 FM |
327 | } |
328 | ||
085c1e1f FM |
329 | static int getparam_list(const char *param,struct param_list *options,int noptions,char *buf,unsigned long int *value) |
330 | { | |
9bd92830 FM |
331 | int plen; |
332 | char *str; | |
333 | int i; | |
334 | ||
335 | plen=strlen(param); | |
336 | if (strncmp(buf,param,plen) != 0) return(0); | |
337 | buf+=plen; | |
338 | if ((unsigned char)*buf>' ') return(0); | |
339 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
340 | ||
341 | *value=0UL; | |
342 | while (*buf) { | |
343 | str=buf; | |
344 | while (*str && (unsigned char)*str>' ' && *str!=';') str++; | |
345 | if (*str) { | |
346 | *str++='\0'; | |
347 | while (*str && ((unsigned char)*str<=' ' || *str==';')) str++; | |
348 | } | |
349 | for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++); | |
350 | if (i>=noptions) { | |
351 | debuga(_("Unknown value \"%s\" for parameter \"%s\"\n"),buf,param); | |
352 | exit(EXIT_FAILURE); | |
353 | } | |
354 | if ((*value & options[i].exclude)!=0) { | |
355 | debuga(_("Value \"%s\" conflicts with other selected values for parameter \"%s\"\n"),buf,param); | |
356 | exit(EXIT_FAILURE); | |
357 | } | |
358 | *value|=options[i].value; | |
359 | buf=str; | |
360 | } | |
361 | return(1); | |
085c1e1f FM |
362 | } |
363 | ||
15d5372b FM |
364 | static int getparam_sort(const char *param,struct sort_list *options,int noptions,char *buf,unsigned long int *value) |
365 | { | |
9bd92830 FM |
366 | int plen; |
367 | char *str, *order; | |
368 | int i; | |
369 | ||
370 | plen=strlen(param); | |
371 | if (strncmp(buf,param,plen) != 0) return(0); | |
372 | buf+=plen; | |
373 | if ((unsigned char)*buf>' ') return(0); | |
374 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
375 | ||
376 | str=buf; | |
377 | order=NULL; | |
378 | while (*str && (unsigned char)*str>' ') str++; | |
379 | if (*str) { | |
380 | *str++='\0'; | |
381 | while (*str && (unsigned char)*str<=' ') str++; | |
382 | order=str; | |
383 | } | |
384 | for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++); | |
385 | if (i>=noptions) { | |
386 | debuga(_("Unknown sort criterion \"%s\" for parameter \"%s\"\n"),buf,param); | |
387 | exit(EXIT_FAILURE); | |
388 | } | |
389 | *value=options[i].value; | |
390 | ||
391 | if (order) { | |
392 | str=order; | |
393 | while (*str && (unsigned char)*str>' ') str++; | |
394 | if (*str) { | |
395 | *str++='\0'; | |
396 | while (*str && (unsigned char)*str<=' ') str++; | |
397 | } | |
398 | if (strcasecmp(order,"reverse")==0 || strcasecmp(order,"D")==0) { | |
399 | *value|=SORT_REVERSE; | |
400 | } else if (strcasecmp(order,"normal")!=0 && strcasecmp(order,"A")!=0) { | |
401 | debuga(_("Unknown sort order \"%s\" for parameter \"%s\"\n"),order,param); | |
402 | exit(EXIT_FAILURE); | |
403 | } | |
404 | } | |
405 | ||
406 | buf=str; | |
407 | return(1); | |
15d5372b FM |
408 | } |
409 | ||
4af2f8ff FM |
410 | static void parmtest(char *buf) |
411 | { | |
9bd92830 FM |
412 | char wbuf[2048]; |
413 | struct getwordstruct gwarea; | |
25697a35 | 414 | |
9bd92830 | 415 | while (*buf && (unsigned char)*buf<=' ') buf++; |
25697a35 | 416 | |
9bd92830 FM |
417 | if(*buf == '#' || *buf == '\0') |
418 | return; | |
25697a35 | 419 | |
9bd92830 FM |
420 | if(debugz) |
421 | printf(_("SARG: TAG: %s\n"),buf); | |
25697a35 | 422 | |
9bd92830 | 423 | if (getparam_string("background_color",buf,BgColor,sizeof(BgColor))>0) return; |
25697a35 | 424 | |
9bd92830 | 425 | if (getparam_string("text_color",buf,TxColor,sizeof(TxColor))>0) return; |
25697a35 | 426 | |
9bd92830 | 427 | if (getparam_string("text_bgcolor",buf,TxBgColor,sizeof(TxBgColor))>0) return; |
25697a35 | 428 | |
9bd92830 | 429 | if (getparam_string("title_color",buf,TiColor,sizeof(TiColor))>0) return; |
25697a35 | 430 | |
9bd92830 | 431 | if (getparam_string("logo_image",buf,LogoImage,sizeof(LogoImage))>0) return; |
25697a35 | 432 | |
9bd92830 | 433 | if (getparam_quoted("logo_text",buf,LogoText,sizeof(LogoText))>0) return; |
25697a35 | 434 | |
9bd92830 | 435 | if (getparam_string("logo_text_color",buf,LogoTextColor,sizeof(LogoTextColor))>0) return; |
25697a35 | 436 | |
9bd92830 | 437 | if (getparam_string("background_image",buf,BgImage,sizeof(BgImage))>0) return; |
25697a35 | 438 | |
9bd92830 | 439 | if (getparam_bool("show_sarg_info",buf,&ShowSargInfo)>0) return; |
25697a35 | 440 | |
9bd92830 | 441 | if (getparam_bool("show_sarg_logo",buf,&ShowSargLogo)>0) return; |
25697a35 | 442 | |
9bd92830 | 443 | if (getparam_string("font_face",buf,FontFace,sizeof(FontFace))>0) return; |
25697a35 | 444 | |
9bd92830 | 445 | if (getparam_string("header_color",buf,HeaderColor,sizeof(HeaderColor))>0) return; |
25697a35 | 446 | |
9bd92830 | 447 | if (getparam_string("header_bgcolor",buf,HeaderBgColor,sizeof(HeaderBgColor))>0) return; |
25697a35 | 448 | |
9bd92830 | 449 | if (getparam_string("font_size",buf,FontSize,sizeof(FontSize))>0) return; |
25697a35 | 450 | |
9bd92830 | 451 | if (getparam_string("header_font_size",buf,HeaderFontSize,sizeof(HeaderFontSize))>0) return; |
25697a35 | 452 | |
9bd92830 | 453 | if (getparam_string("title_font_size",buf,TitleFontSize,sizeof(TitleFontSize))>0) return; |
25697a35 | 454 | |
9bd92830 | 455 | if (getparam_2words("image_size",buf,Width,sizeof(Width),Height,sizeof(Height))>0) return; |
25697a35 | 456 | |
9bd92830 | 457 | if (getparam_quoted("title",buf,Title,sizeof(Title))>0) return; |
25697a35 | 458 | |
9bd92830 | 459 | if (getparam_bool("resolve_ip",buf,&Ip2Name)>0) return; |
25697a35 | 460 | |
9bd92830 | 461 | if (getparam_bool("user_ip",buf,&UserIp)>0) return; |
4af2f8ff | 462 | |
9bd92830 | 463 | if (getparam_string("max_elapsed",buf,MaxElapsed,sizeof(MaxElapsed))>0) return; |
25697a35 | 464 | |
9bd92830 FM |
465 | if (is_param("date_format",buf)) { |
466 | getword_start(&gwarea,buf); | |
467 | if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) { | |
468 | debuga(_("Maybe you have a broken record or garbage in \"date_format\" parameter\n")); | |
469 | exit(EXIT_FAILURE); | |
470 | } | |
471 | strncpy(DateFormat,gwarea.current,1); | |
472 | fixnone(DateFormat); | |
473 | return; | |
474 | } | |
25697a35 | 475 | |
9bd92830 FM |
476 | if (is_param("hours",buf)) { |
477 | if( getnumlist( buf, &hours, 24, 24 ) ) { | |
478 | debuga(_("Error: Invalid syntax in hours tag!\n")); | |
479 | exit( 1 ); | |
480 | } | |
481 | return; | |
482 | } | |
25697a35 | 483 | |
9bd92830 FM |
484 | if (is_param("weekdays",buf)) { |
485 | if( getnumlist( buf, &weekdays, 7, 7 ) ) { | |
486 | debuga(_("Error: Invalid syntax in weekdays tag!\n")); | |
487 | exit( 1 ); | |
488 | } | |
489 | return; | |
490 | } | |
25697a35 | 491 | |
9bd92830 | 492 | if (getparam_sort("topuser_sort_field",SET_LIST(topuser_sort),buf,&TopuserSort)>0) return; |
25697a35 | 493 | |
9bd92830 | 494 | if (getparam_sort("user_sort_field",SET_LIST(user_sort),buf,&UserSort)>0) return; |
25697a35 | 495 | |
9bd92830 FM |
496 | if (is_param("access_log",buf)>0) { |
497 | if (AccessLogFromCmdLine==0) { | |
498 | if (NAccessLog>=MAXLOGS) { | |
499 | debuga(_("Too many log files in configuration file\n")); | |
500 | exit(EXIT_FAILURE); | |
501 | } | |
502 | getparam_string("access_log",buf,AccessLog[NAccessLog],MAX_LOG_FILELEN); | |
503 | NAccessLog++; | |
504 | } | |
505 | return; | |
506 | } | |
25697a35 | 507 | |
9bd92830 FM |
508 | if (is_param("redirector_log",buf)>0) { |
509 | if (RedirectorLogFromCmdLine==0) { | |
510 | if (NRedirectorLogs>=MAX_REDIRECTOR_LOGS) { | |
511 | debuga(_("Too many redirector log files in configuration file\n")); | |
512 | exit(EXIT_FAILURE); | |
513 | } | |
514 | getparam_string("redirector_log",buf,RedirectorLogs[NRedirectorLogs],MAX_REDIRECTOR_FILELEN); | |
515 | NRedirectorLogs++; | |
516 | } | |
517 | return; | |
518 | } | |
1f482a8d | 519 | |
9bd92830 | 520 | if (getparam_string("useragent_log",buf,UserAgentLog,sizeof(UserAgentLog))>0) return; |
25697a35 | 521 | |
9bd92830 | 522 | if (getparam_string("exclude_hosts",buf,ExcludeHosts,sizeof(ExcludeHosts))>0) return; |
25697a35 | 523 | |
9bd92830 | 524 | if (getparam_string("exclude_codes",buf,ExcludeCodes,sizeof(ExcludeCodes))>0) return; |
25697a35 | 525 | |
9bd92830 | 526 | if (getparam_string("exclude_users",buf,ExcludeUsers,sizeof(ExcludeUsers))>0) return; |
25697a35 | 527 | |
9bd92830 | 528 | if (getparam_string("password",buf,PasswdFile,sizeof(PasswdFile))>0) return; |
25697a35 | 529 | |
9bd92830 | 530 | if (getparam_string("temporary_dir",buf,TempDir,sizeof(TempDir))>0) return; |
25697a35 | 531 | |
9bd92830 | 532 | if (getparam_list("report_type",SET_LIST(report_type_values),buf,&ReportType)>0) return; |
25697a35 | 533 | |
9bd92830 | 534 | if (getparam_string("output_dir",buf,OutputDir,sizeof(OutputDir))>0) return; |
25697a35 | 535 | |
829a53c2 FM |
536 | if (getparam_bool("anonymous_output_files",buf,&AnonymousOutputFiles)>0) return; |
537 | ||
9bd92830 | 538 | if (getparam_string("output_email",buf,OutputEmail,sizeof(OutputEmail))>0) return; |
25697a35 | 539 | |
9bd92830 FM |
540 | if (getparam_2words("per_user_limit",buf,PerUserLimitFile,sizeof(PerUserLimitFile),wbuf,sizeof(wbuf))>0) { |
541 | PerUserLimit=atoi(wbuf); | |
542 | return; | |
543 | } | |
25697a35 | 544 | |
9bd92830 | 545 | if (getparam_int("lastlog",buf,&LastLog)>0) return; |
25697a35 | 546 | |
9bd92830 | 547 | if (getparam_bool("remove_temp_files",buf,&RemoveTempFiles)>0) return; |
25697a35 | 548 | |
9bd92830 | 549 | if (getparam_string("replace_index",buf,ReplaceIndex,sizeof(ReplaceIndex))>0) return; |
25697a35 | 550 | |
9bd92830 | 551 | if (getparam_list("index_tree",SET_LIST(index_tree_values),buf,&IndexTree)>0) return; |
25697a35 | 552 | |
9bd92830 | 553 | if (getparam_list("index",SET_LIST(index_values),buf,&Index)>0) return; |
25697a35 | 554 | |
9aaa3361 FM |
555 | if (getparam_list("index_fields",SET_LIST(indexfields_values),buf,&IndexFields)>0) return; |
556 | ||
9bd92830 | 557 | if (getparam_bool("overwrite_report",buf,&OverwriteReport)>0) return; |
25697a35 | 558 | |
9bd92830 | 559 | if (getparam_list("records_without_userid",SET_LIST(recnouser_values),buf,&RecordsWithoutUser)>0) return; |
25697a35 | 560 | |
9bd92830 | 561 | if (getparam_bool("use_comma",buf,&UseComma)>0) return; |
25697a35 | 562 | |
9bd92830 | 563 | if (getparam_string("mail_utility",buf,MailUtility,sizeof(MailUtility))>0) return; |
25697a35 | 564 | |
9bd92830 | 565 | if (getparam_int("topsites_num",buf,&TopSitesNum)>0) return; |
25697a35 | 566 | |
9bd92830 | 567 | if (getparam_int("topuser_num",buf,&TopUsersNum)>0) return; |
25697a35 | 568 | |
9bd92830 | 569 | if (getparam_string("usertab",buf,UserTabFile,sizeof(UserTabFile))>0) return; |
25697a35 | 570 | |
9bd92830 | 571 | if (getparam_string("index_sort_order",buf,IndexSortOrder,sizeof(IndexSortOrder))>0) return; |
25697a35 | 572 | |
9bd92830 | 573 | if (getparam_sort("topsites_sort_order",SET_LIST(topsite_sort),buf,&TopsitesSort)>0) return; |
25697a35 | 574 | |
9bd92830 | 575 | if (getparam_bool("long_url",buf,&LongUrl)>0) return; |
25697a35 | 576 | |
9bd92830 | 577 | if (getparam_string("dansguardian_conf",buf,DansGuardianConf,sizeof(DansGuardianConf))>0) return; |
25697a35 | 578 | |
9bd92830 | 579 | if (getparam_string("squidguard_conf",buf,SquidGuardConf,sizeof(SquidGuardConf))>0) return; |
25697a35 | 580 | |
9bd92830 | 581 | if (getparam_list("date_time_by",SET_LIST(datetime_values),buf,&datetimeby)>0) return; |
25697a35 | 582 | |
9bd92830 FM |
583 | if (getparam_string("charset",buf,CharSet,sizeof(CharSet))>0) { |
584 | ccharset(CharSet); | |
585 | return; | |
586 | } | |
25697a35 | 587 | |
9bd92830 | 588 | if (getparam_quoted("user_invalid_char",buf,UserInvalidChar,sizeof(UserInvalidChar))>0) return; |
25697a35 | 589 | |
9bd92830 FM |
590 | if (getparam_quoted("include_users",buf,IncludeUsers+1,sizeof(IncludeUsers)-2)>0) { |
591 | IncludeUsers[0]=':'; | |
592 | strcat(IncludeUsers,":"); | |
593 | return; | |
594 | } | |
491b862f | 595 | |
9bd92830 | 596 | if (getparam_quoted("exclude_string",buf,ExcludeString,sizeof(ExcludeString))>0) return; |
25697a35 | 597 | |
9bd92830 | 598 | if (getparam_bool("privacy",buf,&Privacy)>0) return; |
25697a35 | 599 | |
9bd92830 | 600 | if (getparam_quoted("privacy_string",buf,PrivacyString,sizeof(PrivacyString))>0) return; |
25697a35 | 601 | |
9bd92830 | 602 | if (getparam_string("privacy_string_color",buf,PrivacyStringColor,sizeof(PrivacyStringColor))>0) return; |
25697a35 | 603 | |
9bd92830 | 604 | if (getparam_bool("show_successful_message",buf,&SuccessfulMsg)>0) return; |
25697a35 | 605 | |
9bd92830 | 606 | if (getparam_bool("show_read_statistics",buf,&ShowReadStatistics)>0) return; |
25697a35 | 607 | |
9bd92830 | 608 | if (getparam_list("topuser_fields",SET_LIST(topuserfields_values),buf,&TopUserFields)>0) return; |
25697a35 | 609 | |
9bd92830 | 610 | if (getparam_bool("bytes_in_sites_users_report",buf,&BytesInSitesUsersReport)>0) return; |
25697a35 | 611 | |
9bd92830 | 612 | if (getparam_list("user_report_fields",SET_LIST(userreportfields_values),buf,&UserReportFields)>0) return; |
25697a35 | 613 | |
9bd92830 | 614 | if (getparam_string("datafile",buf,DataFile,sizeof(DataFile))>0) return; |
25697a35 | 615 | |
9bd92830 | 616 | if (getparam_quoted("datafile_delimiter",buf,DataFileDelimiter,sizeof(DataFileDelimiter))>0) return; |
25697a35 | 617 | |
9bd92830 | 618 | if (getparam_list("datafile_fields",SET_LIST(data_field_values),buf,&DataFileFields)>0) return; |
25697a35 | 619 | |
9bd92830 | 620 | if (getparam_list("datafile_url",SET_LIST(datafileurl_values),buf,&DataFileUrl)>0) return; |
25697a35 | 621 | |
9bd92830 | 622 | if (getparam_string("parsed_output_log",buf,ParsedOutputLog,sizeof(ParsedOutputLog))>0) return; |
25697a35 | 623 | |
9bd92830 | 624 | if (getparam_string("parsed_output_log_compress",buf,ParsedOutputLogCompress,sizeof(ParsedOutputLogCompress))>0) return; |
25697a35 | 625 | |
9bd92830 | 626 | if (getparam_list("displayed_values",SET_LIST(displayvalue_values),buf,&DisplayedValues)>0) return; |
25697a35 | 627 | |
9bd92830 | 628 | if (getparam_int("authfail_report_limit",buf,&AuthfailReportLimit)>0) return; |
25697a35 | 629 | |
9bd92830 | 630 | if (getparam_int("denied_report_limit",buf,&DeniedReportLimit)>0) return; |
25697a35 | 631 | |
9bd92830 | 632 | if (getparam_int("siteusers_report_limit",buf,&SiteUsersReportLimit)>0) return; |
25697a35 | 633 | |
9bd92830 | 634 | if (getparam_int("dansguardian_report_limit",buf,&DansGuardianReportLimit)>0) return; |
25697a35 | 635 | |
9bd92830 | 636 | if (getparam_int("squidguard_report_limit",buf,&SquidGuardReportLimit)>0) return; |
25697a35 | 637 | |
9bd92830 | 638 | if (getparam_int("user_report_limit",buf,&UserReportLimit)>0) return; |
491b862f | 639 | |
9bd92830 | 640 | if (getparam_int("download_report_limit",buf,&DownloadReportLimit)>0) return; |
491b862f | 641 | |
9bd92830 | 642 | if (getparam_string("www_document_root",buf,wwwDocumentRoot,sizeof(wwwDocumentRoot))>0) return; |
25697a35 | 643 | |
9bd92830 | 644 | if (getparam_string("block_it",buf,BlockIt,sizeof(BlockIt))>0) return; |
491b862f | 645 | |
9bd92830 | 646 | if (getparam_string("external_css_file",buf,ExternalCSSFile,sizeof(ExternalCSSFile))>0) return; |
491b862f | 647 | |
9bd92830 | 648 | if (getparam_bool("user_authentication",buf,&UserAuthentication)>0) return; |
491b862f | 649 | |
9bd92830 FM |
650 | if (getparam_string("AuthUserTemplateFile",buf,wbuf,sizeof(wbuf))>0) { |
651 | char dir[MAXLEN]; | |
491b862f | 652 | |
9bd92830 FM |
653 | if (is_absolute(wbuf)) { |
654 | if (strlen(wbuf)>=sizeof(AuthUserTemplateFile)) { | |
655 | debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n")); | |
656 | exit(EXIT_FAILURE); | |
657 | } | |
658 | strcpy(AuthUserTemplateFile,wbuf); | |
659 | } else { | |
660 | strcpy(dir,ConfigFile); | |
661 | if (snprintf(AuthUserTemplateFile,sizeof(AuthUserTemplateFile),"%s/%s",dirname(dir),wbuf)>=sizeof(AuthUserTemplateFile)) { | |
662 | debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n")); | |
663 | exit(EXIT_FAILURE); | |
664 | } | |
665 | } | |
666 | return; | |
667 | } | |
4af2f8ff | 668 | |
9bd92830 FM |
669 | if (is_param("download_suffix",buf)) { |
670 | char warea[MAXLEN]; | |
6e792ade | 671 | |
9bd92830 FM |
672 | getparam_quoted("download_suffix",buf,warea,sizeof(warea)); |
673 | set_download_suffix(warea); | |
674 | return; | |
675 | } | |
d6e703cc | 676 | |
9bd92830 | 677 | if (getparam_bool("graphs",buf,&Graphs)>0) return; |
4af2f8ff | 678 | |
9bd92830 | 679 | if (getparam_string("graph_days_bytes_bar_color",buf,GraphDaysBytesBarColor,sizeof(GraphDaysBytesBarColor))>0) return; |
4af2f8ff | 680 | |
9bd92830 FM |
681 | if (getparam_string("redirector_log_format",buf,RedirectorLogFormat,sizeof(RedirectorLogFormat))>0) return; |
682 | if (getparam_string("squidguard_log_format",buf,RedirectorLogFormat,sizeof(RedirectorLogFormat))>0) { | |
683 | debuga(_("squidguard_log_format is deprecated and has been replaced by redirector_log_format. Please update your configuration file.\n")); | |
684 | return; | |
685 | } | |
4af2f8ff | 686 | |
9bd92830 FM |
687 | if (getparam_bool("redirector_filter_out_date",buf,&RedirectorFilterOutDate)>0) return; |
688 | if (getparam_bool("redirector_ignore_date",buf,&RedirectorFilterOutDate)>0) { | |
689 | /* | |
690 | Due to an old bug in sarg before version 2.3, the option was having the opposite action than implied by the name. | |
691 | */ | |
692 | debuga(_("redirector_ignore_date is deprecated and has been replaced by redirector_filter_out_date that does the action implied by its name as opposed to redirector_ignore_date. Please update your configuration file.\n")); | |
693 | RedirectorFilterOutDate=!RedirectorFilterOutDate; | |
694 | return; | |
695 | } | |
696 | if (getparam_bool("squidguard_ignore_date",buf,&RedirectorFilterOutDate)>0) { | |
697 | debuga(_("squidguard_ignore_date is deprecated and has been replaced by redirector_filter_out_date that does the action implied by its name as opposed to squidguard_ignore_date. Please update your configuration file.\n")); | |
698 | RedirectorFilterOutDate=!RedirectorFilterOutDate; | |
699 | return; | |
700 | } | |
4af2f8ff | 701 | |
9bd92830 FM |
702 | if (getparam_bool("dansguardian_filter_out_date",buf,&DansguardianFilterOutDate)>0) return; |
703 | if (getparam_bool("dansguardian_ignore_date",buf,&DansguardianFilterOutDate)>0) { | |
704 | debuga(_("dansguardian_ignore_date is deprecated and has been replaced by dansguardian_filter_out_date that does the action implied by its name as opposed to dansguardian_ignore_date. Please update your configuration file.\n")); | |
705 | DansguardianFilterOutDate=!DansguardianFilterOutDate; | |
706 | return; | |
707 | } | |
4af2f8ff | 708 | |
9bd92830 | 709 | if (getparam_string("ulimit",buf,Ulimit,sizeof(Ulimit))>0) return; |
4af2f8ff | 710 | |
9bd92830 | 711 | if (getparam_list("ntlm_user_format",SET_LIST(ntml_userformat_values),buf,&NtlmUserFormat)>0) return; |
4af2f8ff | 712 | |
9bd92830 | 713 | if (getparam_string("realtime_types",buf,RealtimeTypes,sizeof(RealtimeTypes))>0) return; |
4af2f8ff | 714 | |
9bd92830 | 715 | if (getparam_list("realtime_unauthenticated_records",SET_LIST(realtime_unauth_values),buf,&RealtimeUnauthRec)>0) return; |
4af2f8ff | 716 | |
9bd92830 | 717 | if (getparam_int("realtime_refresh_time",buf,&realtime_refresh)>0) return; |
4af2f8ff | 718 | |
9bd92830 | 719 | if (getparam_int("realtime_access_log_lines",buf,&realtime_access_log_lines)>0) return; |
4af2f8ff | 720 | |
9bd92830 | 721 | if (getparam_string("LDAPHost",buf,LDAPHost,sizeof(LDAPHost))>0) return; |
e3af0ae9 | 722 | |
9bd92830 | 723 | if (getparam_int("LDAPPort",buf,&LDAPPort)>0) return; |
e3af0ae9 | 724 | |
9bd92830 | 725 | if (getparam_int("LDAPProtocolVersion",buf,&LDAPProtocolVersion)>0) return; |
e3af0ae9 | 726 | |
9bd92830 | 727 | if (getparam_string("LDAPBindDN",buf,LDAPBindDN,sizeof(LDAPBindDN))>0) return; |
e3af0ae9 | 728 | |
9bd92830 | 729 | if (getparam_string("LDAPBindPW",buf,LDAPBindPW,sizeof(LDAPBindPW))>0) return; |
e3af0ae9 | 730 | |
9bd92830 | 731 | if (getparam_string("LDAPBaseSearch",buf,LDAPBaseSearch,sizeof(LDAPBaseSearch))>0) return; |
e3af0ae9 | 732 | |
9bd92830 | 733 | if (getparam_string("LDAPFilterSearch",buf,LDAPFilterSearch,sizeof(LDAPFilterSearch))>0) return; |
e3af0ae9 | 734 | |
9bd92830 | 735 | if (getparam_string("LDAPTargetAttr",buf,LDAPTargetAttr,sizeof(LDAPTargetAttr))>0) return; |
e3af0ae9 | 736 | |
9bd92830 | 737 | if (getparam_string("graph_font",buf,GraphFont,sizeof(GraphFont))>0) return; |
3becf85c | 738 | |
9bd92830 | 739 | if (getparam_string("sorttable",buf,SortTableJs,sizeof(SortTableJs))>0) return; |
ea275279 | 740 | |
22715352 FM |
741 | if (getparam_string("hostalias",buf,HostAliasFile,sizeof(HostAliasFile))>0) return; |
742 | ||
9bd92830 FM |
743 | if(strstr(buf,"squid24") != 0) { |
744 | squid24=true; | |
745 | return; | |
746 | } | |
4af2f8ff | 747 | |
9bd92830 FM |
748 | if(strstr(buf,"byte_cost") != 0) { |
749 | getword_start(&gwarea,buf); | |
750 | if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) { | |
751 | debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n")); | |
752 | exit(EXIT_FAILURE); | |
753 | } | |
754 | cost=atol(gwarea.current); | |
755 | if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) { | |
756 | debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n")); | |
757 | exit(EXIT_FAILURE); | |
758 | } | |
759 | nocost=my_atoll(gwarea.current); | |
760 | return; | |
761 | } | |
4af2f8ff | 762 | |
9bd92830 | 763 | printf(_("SARG: Unknown option %s\n"),buf); |
d6e703cc FM |
764 | } |
765 | ||
32e71fa4 | 766 | void getconf(void) |
d6e703cc | 767 | { |
9bd92830 FM |
768 | FILE *fp_in; |
769 | char buf[MAXLEN]; | |
d6e703cc | 770 | |
9bd92830 FM |
771 | if(debug) |
772 | debuga(_("Loading configuration from %s\n"),ConfigFile); | |
d6e703cc | 773 | |
9bd92830 FM |
774 | if ((fp_in = fopen(ConfigFile, "r")) == NULL) { |
775 | debuga(_("(getconf) Cannot open file %s\n"),ConfigFile); | |
776 | exit(EXIT_FAILURE); | |
777 | } | |
d6e703cc | 778 | |
9bd92830 FM |
779 | while (fgets(buf, sizeof(buf), fp_in) != NULL) { |
780 | fixendofline(buf); | |
d6e703cc | 781 | |
9bd92830 FM |
782 | if(debugm) |
783 | printf("SYSCONFDIR %s\n",buf); | |
d6e703cc | 784 | |
9bd92830 | 785 | parmtest(buf); |
d6e703cc | 786 | |
9bd92830 | 787 | } |
d6e703cc | 788 | |
9bd92830 FM |
789 | fclose(fp_in); |
790 | return; | |
25697a35 | 791 | } |