]>
Commit | Line | Data |
---|---|---|
25697a35 | 1 | /* |
94ff9470 | 2 | * SARG Squid Analysis Report Generator http://sarg.sourceforge.net |
110ce984 | 3 | * 1998, 2015 |
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" |
6068ae56 | 29 | #include "include/filelist.h" |
25697a35 | 30 | |
085c1e1f FM |
31 | #define SET_LIST(list) list,sizeof(list)/sizeof(list[0]) |
32 | ||
25697a35 | 33 | extern numlist hours, weekdays; |
6068ae56 | 34 | extern FileListObject AccessLog; |
2e29ae23 FM |
35 | extern int PerUserLimitsNumber; |
36 | extern struct PerUserLimitStruct PerUserLimits[MAX_USER_LIMITS]; | |
0b5356bb | 37 | extern enum PerUserFileCreationEnum PerUserFileCreation; |
66f507aa | 38 | extern char ImageDir[MAXLEN]; |
25697a35 | 39 | |
085c1e1f FM |
40 | struct param_list |
41 | { | |
9bd92830 FM |
42 | //! The name of the value of the parameter. |
43 | const char *name; | |
44 | //! The bit to set if the value is found. | |
45 | unsigned long int value; | |
46 | //! The value is invalid if any bit of this mask is set in the parameter. | |
47 | unsigned long int exclude; | |
085c1e1f FM |
48 | }; |
49 | ||
15d5372b FM |
50 | struct sort_list |
51 | { | |
9bd92830 FM |
52 | //! The name of the value of the parameter. |
53 | const char *name; | |
54 | //! The bit to set if the value is found. | |
55 | unsigned long int value; | |
15d5372b FM |
56 | }; |
57 | ||
0b5356bb FM |
58 | struct select_list |
59 | { | |
60 | //! The name of the value of the parameter. | |
61 | const char *name; | |
62 | //! The value to assign when the name is selected. | |
63 | int value; | |
64 | }; | |
65 | ||
e43854ef | 66 | static struct param_list report_type_values[]= |
085c1e1f | 67 | { |
9bd92830 FM |
68 | {"users_sites",REPORT_TYPE_USERS_SITES,0}, |
69 | {"topusers",REPORT_TYPE_TOPUSERS,0}, | |
70 | {"topsites",REPORT_TYPE_TOPSITES,0}, | |
71 | {"sites_users",REPORT_TYPE_SITES_USERS,0}, | |
72 | {"date_time",REPORT_TYPE_DATE_TIME,0}, | |
73 | {"denied",REPORT_TYPE_DENIED,0}, | |
74 | {"auth_failures",REPORT_TYPE_AUTH_FAILURES,0}, | |
75 | {"site_user_time_date",REPORT_TYPE_SITE_USER_TIME_DATE,0}, | |
76 | {"downloads",REPORT_TYPE_DOWNLOADS,0}, | |
085c1e1f FM |
77 | }; |
78 | ||
e43854ef | 79 | static struct param_list data_field_values[]= |
085c1e1f | 80 | { |
9bd92830 FM |
81 | {"user",DATA_FIELD_USER,0}, |
82 | {"date",DATA_FIELD_DATE,0}, | |
83 | {"time",DATA_FIELD_TIME,0}, | |
84 | {"url",DATA_FIELD_URL,0}, | |
85 | {"connect",DATA_FIELD_CONNECT,0}, | |
86 | {"bytes",DATA_FIELD_BYTES,0}, | |
87 | {"in_cache",DATA_FIELD_IN_CACHE,0}, | |
88 | {"out_cache",DATA_FIELD_OUT_CACHE,0}, | |
89 | {"elapsed",DATA_FIELD_ELAPSED,0}, | |
085c1e1f FM |
90 | }; |
91 | ||
e43854ef | 92 | static struct param_list topuserfields_values[]= |
085c1e1f | 93 | { |
9bd92830 FM |
94 | {"NUM",TOPUSERFIELDS_NUM,0}, |
95 | {"DATE_TIME",TOPUSERFIELDS_DATE_TIME,0}, | |
96 | {"USERID",TOPUSERFIELDS_USERID,0}, | |
8e134f1a | 97 | {"USERIP",TOPUSERFIELDS_USERIP,0}, |
9bd92830 FM |
98 | {"CONNECT",TOPUSERFIELDS_CONNECT,0}, |
99 | {"BYTES",TOPUSERFIELDS_BYTES,0}, | |
100 | {"%BYTES",TOPUSERFIELDS_SETYB,0}, | |
101 | {"SETYB",TOPUSERFIELDS_SETYB,0}, | |
102 | {"IN-CACHE-OUT",TOPUSERFIELDS_IN_CACHE_OUT,0}, | |
103 | {"USED_TIME",TOPUSERFIELDS_USED_TIME,0}, | |
104 | {"MILISEC",TOPUSERFIELDS_MILISEC,0}, | |
105 | {"%TIME",TOPUSERFIELDS_PTIME,0}, | |
106 | {"TOTAL",TOPUSERFIELDS_TOTAL,0}, | |
107 | {"AVERAGE",TOPUSERFIELDS_AVERAGE,0}, | |
085c1e1f FM |
108 | }; |
109 | ||
e43854ef | 110 | static struct param_list userreportfields_values[]= |
085c1e1f | 111 | { |
9bd92830 FM |
112 | {"CONNECT",USERREPORTFIELDS_CONNECT,0}, |
113 | {"BYTES",USERREPORTFIELDS_BYTES,0}, | |
114 | {"%BYTES",USERREPORTFIELDS_SETYB,0}, | |
115 | {"SETYB",USERREPORTFIELDS_SETYB,0}, | |
116 | {"IN-CACHE-OUT",USERREPORTFIELDS_IN_CACHE_OUT,0}, | |
117 | {"USED_TIME",USERREPORTFIELDS_USED_TIME,0}, | |
118 | {"MILISEC",USERREPORTFIELDS_MILISEC,0}, | |
119 | {"%TIME",USERREPORTFIELDS_PTIME,0}, | |
120 | {"TOTAL",USERREPORTFIELDS_TOTAL,0}, | |
121 | {"AVERAGE",USERREPORTFIELDS_AVERAGE,0}, | |
085c1e1f FM |
122 | }; |
123 | ||
e43854ef | 124 | static struct param_list index_values[]= |
0349fa24 | 125 | { |
9bd92830 FM |
126 | {"yes",INDEX_YES,~INDEX_YES}, |
127 | {"no",INDEX_NO,~INDEX_NO}, | |
128 | {"only",INDEX_ONLY,~INDEX_ONLY}, | |
0349fa24 FM |
129 | }; |
130 | ||
e43854ef | 131 | static struct param_list index_tree_values[]= |
0349fa24 | 132 | { |
9bd92830 FM |
133 | {"date",INDEX_TREE_DATE,~INDEX_TREE_DATE}, |
134 | {"file",INDEX_TREE_FILE,~INDEX_TREE_FILE}, | |
0349fa24 FM |
135 | }; |
136 | ||
9aaa3361 FM |
137 | static struct param_list indexfields_values[]= |
138 | { | |
139 | {"DIRSIZE",INDEXFIELDS_DIRSIZE,0}, | |
140 | }; | |
141 | ||
e43854ef | 142 | static struct param_list ntml_userformat_values[]= |
f2ec8c75 | 143 | { |
9bd92830 FM |
144 | {"user",NTLMUSERFORMAT_USER,~NTLMUSERFORMAT_USER}, |
145 | {"domainname+username",NTLMUSERFORMAT_DOMAINUSER,~NTLMUSERFORMAT_DOMAINUSER}, | |
f2ec8c75 FM |
146 | }; |
147 | ||
e43854ef | 148 | static struct param_list recnouser_values[]= |
f2ec8c75 | 149 | { |
9bd92830 FM |
150 | {"ip",RECORDWITHOUTUSER_IP,~RECORDWITHOUTUSER_IP}, |
151 | {"ignore",RECORDWITHOUTUSER_IGNORE,~RECORDWITHOUTUSER_IGNORE}, | |
152 | {"everybody",RECORDWITHOUTUSER_EVERYBODY,~RECORDWITHOUTUSER_EVERYBODY}, | |
f2ec8c75 FM |
153 | }; |
154 | ||
e43854ef | 155 | static struct param_list datafileurl_values[]= |
f84a35a3 | 156 | { |
9bd92830 FM |
157 | {"ip",DATAFILEURL_IP,~DATAFILEURL_IP}, |
158 | {"name",DATAFILEURL_NAME,~DATAFILEURL_NAME}, | |
f84a35a3 FM |
159 | }; |
160 | ||
e43854ef FM |
161 | static struct param_list displayvalue_values[]= |
162 | { | |
9bd92830 FM |
163 | {"bytes",DISPLAY_BYTES,~DISPLAY_BYTES}, |
164 | {"abbreviation",DISPLAY_ABBREV,~DISPLAY_ABBREV}, | |
e43854ef FM |
165 | }; |
166 | ||
43cc1649 FM |
167 | static struct param_list datetime_values[]= |
168 | { | |
9bd92830 FM |
169 | {"elap",DATETIME_ELAP,0}, |
170 | {"bytes",DATETIME_BYTE,0}, | |
43cc1649 FM |
171 | }; |
172 | ||
71d78774 FM |
173 | static struct param_list realtime_unauth_values[]= |
174 | { | |
9bd92830 FM |
175 | {"show",REALTIME_UNAUTH_REC_SHOW,~REALTIME_UNAUTH_REC_SHOW}, |
176 | {"ignore",REALTIME_UNAUTH_REC_IGNORE,~REALTIME_UNAUTH_REC_IGNORE}, | |
71d78774 FM |
177 | }; |
178 | ||
15d5372b FM |
179 | struct sort_list topuser_sort[]= |
180 | { | |
9bd92830 FM |
181 | {"BYTES",TOPUSER_SORT_BYTES}, |
182 | {"USER",TOPUSER_SORT_USER}, | |
183 | {"CONNECT",TOPUSER_SORT_CONNECT}, | |
184 | {"TIME",TOPUSER_SORT_TIME}, | |
15d5372b FM |
185 | }; |
186 | ||
187 | struct sort_list topsite_sort[]= | |
188 | { | |
9bd92830 FM |
189 | {"BYTES",TOPSITE_SORT_BYTES}, |
190 | {"CONNECT",TOPSITE_SORT_CONNECT}, | |
191 | {"TIME",TOPSITE_SORT_TIME}, | |
7d82ea1a | 192 | {"USER",TOPSITE_SORT_USER}, |
15d5372b FM |
193 | }; |
194 | ||
195 | struct sort_list user_sort[]= | |
196 | { | |
9bd92830 FM |
197 | {"BYTES",USER_SORT_BYTES}, |
198 | {"SITE",USER_SORT_SITE}, | |
199 | {"CONNECT",USER_SORT_CONNECT}, | |
200 | {"TIME",USER_SORT_TIME}, | |
15d5372b FM |
201 | }; |
202 | ||
0b5356bb FM |
203 | static struct select_list per_user_limit_create_file[]= |
204 | { | |
205 | {"always",PUFC_Always}, //always create an empty file | |
206 | {"as_required",PUFC_AsRequired}, //create the file if necessary (no empty file is created) | |
207 | }; | |
208 | ||
6e792ade | 209 | static int is_param(const char *param,const char *buf) |
0a4e18e1 | 210 | { |
9bd92830 | 211 | int plen; |
0a4e18e1 | 212 | |
9bd92830 FM |
213 | plen=strlen(param); |
214 | if (strncmp(buf,param,plen) != 0) return(0); | |
215 | buf+=plen; | |
216 | if ((unsigned char)*buf>' ') return(0); | |
217 | return(1); | |
0a4e18e1 FM |
218 | } |
219 | ||
4af2f8ff FM |
220 | static int getparam_string(const char *param,char *buf,char *value,int value_size) |
221 | { | |
9bd92830 FM |
222 | int plen; |
223 | ||
224 | plen=strlen(param); | |
225 | if (strncmp(buf,param,plen) != 0) return(0); | |
226 | buf+=plen; | |
227 | if ((unsigned char)*buf>' ') return(0); | |
228 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
229 | ||
230 | if (strlen(buf)>=value_size) { | |
231 | debuga(_("The string value of parameter \"%s\" is too long\n"),param); | |
232 | exit(EXIT_FAILURE); | |
233 | } | |
234 | strcpy(value,buf); | |
235 | fixnone(value); | |
236 | return(1); | |
4af2f8ff | 237 | } |
25697a35 | 238 | |
6068ae56 FM |
239 | /*! |
240 | * Get a pointer to the beginning of the string value defined by the | |
241 | * parameter. The returned value is NULL if the buffer doesn't contain | |
242 | * the parameter. | |
243 | * | |
244 | * \param param The parameter to look for. | |
245 | * \param buf The buffer containing the line read from the configuration | |
246 | * file. | |
247 | * | |
248 | * \return A pointer to the beginning of the parameter value or NULL if | |
249 | * the line is not for the requtested parameter. | |
250 | */ | |
251 | static char *getparam_stringptr(const char *param,char *buf) | |
252 | { | |
253 | int plen; | |
254 | ||
255 | plen=strlen(param); | |
256 | if (strncmp(buf,param,plen) != 0) return(NULL); | |
257 | buf+=plen; | |
258 | if ((unsigned char)*buf>' ') return(NULL); | |
259 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
260 | ||
261 | return(buf); | |
262 | } | |
263 | ||
4af2f8ff | 264 | static int getparam_quoted(const char *param,char *buf,char *value,int value_size) |
25697a35 | 265 | { |
9bd92830 FM |
266 | int plen; |
267 | int i; | |
268 | ||
269 | plen=strlen(param); | |
270 | if (strncmp(buf,param,plen) != 0) return(0); | |
271 | buf+=plen; | |
272 | if ((unsigned char)*buf>' ') return(0); | |
273 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
274 | ||
275 | if (*buf != '\"') { | |
276 | debuga(_("Missing double quote after parameter \"%s\"\n"),param); | |
277 | exit(EXIT_FAILURE); | |
278 | } | |
279 | buf++; | |
280 | ||
281 | value_size--; | |
282 | for (i=0 ; i<value_size && *buf && *buf!='\"' ; i++) { | |
283 | value[i]=*buf++; | |
284 | } | |
285 | value[i]='\0'; | |
286 | ||
287 | if (*buf != '\"') { | |
288 | debuga(_("Missing double quote after parameter \"%s\" or value is more than %d bytes long\n"),param,value_size); | |
289 | exit(EXIT_FAILURE); | |
290 | } | |
291 | fixnone(value); | |
292 | return(1); | |
4af2f8ff | 293 | } |
25697a35 | 294 | |
4af2f8ff FM |
295 | static int getparam_2words(const char *param,char *buf,char *word1,int word1_size,char *word2,int word2_size) |
296 | { | |
9bd92830 FM |
297 | int plen; |
298 | int i; | |
299 | ||
300 | plen=strlen(param); | |
301 | if (strncmp(buf,param,plen) != 0) return(0); | |
302 | buf+=plen; | |
303 | if ((unsigned char)*buf>' ') return(0); | |
304 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
305 | ||
306 | for (i=0 ; i<word1_size && *buf && (unsigned char)*buf>' ' ; i++) | |
307 | word1[i]=*buf++; | |
308 | if (i>=word1_size) { | |
309 | debuga(_("The first word of parameter \"%s\" is more than %d bytes long\n"),param,word1_size-1); | |
310 | exit(EXIT_FAILURE); | |
311 | } | |
312 | if (*buf!=' ') { | |
313 | debuga(_("Missing second word for parameter \"%s\"\n"),param); | |
314 | exit(EXIT_FAILURE); | |
315 | } | |
316 | word1[i]=0; | |
317 | ||
318 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
319 | ||
320 | for (i=0 ; i<word2_size && *buf && (unsigned char)*buf>' ' ; i++) | |
321 | word2[i]=*buf++; | |
322 | if (i>=word2_size) { | |
323 | debuga(_("The second word of parameter \"%s\" is more than %d bytes long\n"),param,word2_size-1); | |
324 | exit(EXIT_FAILURE); | |
325 | } | |
326 | word2[i]=0; | |
327 | ||
328 | fixnone(word1); | |
329 | fixnone(word2); | |
330 | return(1); | |
4af2f8ff | 331 | } |
25697a35 | 332 | |
4af2f8ff FM |
333 | static int getparam_int(const char *param,char *buf,int *value) |
334 | { | |
9bd92830 FM |
335 | int plen; |
336 | int next; | |
337 | ||
338 | plen=strlen(param); | |
339 | if (strncmp(buf,param,plen) != 0) return(0); | |
340 | buf+=plen; | |
341 | if ((unsigned char)*buf>' ') return(0); | |
342 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
343 | ||
344 | next=0; | |
345 | if (sscanf(buf,"%d%n",value,&next) != 1 || (unsigned char)buf[next] > ' ') { | |
346 | debuga(_("The integer value of parameter \"%s\" is invalid\n"),param); | |
347 | exit(EXIT_FAILURE); | |
348 | } | |
349 | return(1); | |
4af2f8ff | 350 | } |
25697a35 | 351 | |
06b39c87 | 352 | static int getparam_bool(const char *param,char *buf,bool *value) |
246c8489 | 353 | { |
9bd92830 FM |
354 | int plen; |
355 | int i; | |
356 | const char *bool_str="yes,true,on,1"; | |
357 | ||
358 | plen=strlen(param); | |
359 | if (strncmp(buf,param,plen) != 0) return(0); | |
360 | buf+=plen; | |
361 | if ((unsigned char)*buf>' ') return(0); | |
362 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
363 | ||
364 | *value=false; | |
365 | for ( ; *bool_str ; bool_str+=i) { | |
366 | for (i=0 ; bool_str[i] && bool_str[i]!=',' ; i++); | |
367 | if (strncasecmp(bool_str,buf,i)==0) { | |
368 | *value=true; | |
369 | break; | |
370 | } | |
371 | if (bool_str[i]==',') i++; | |
372 | } | |
373 | return(1); | |
246c8489 FM |
374 | } |
375 | ||
085c1e1f FM |
376 | static int getparam_list(const char *param,struct param_list *options,int noptions,char *buf,unsigned long int *value) |
377 | { | |
9bd92830 FM |
378 | int plen; |
379 | char *str; | |
380 | int i; | |
381 | ||
382 | plen=strlen(param); | |
383 | if (strncmp(buf,param,plen) != 0) return(0); | |
384 | buf+=plen; | |
385 | if ((unsigned char)*buf>' ') return(0); | |
386 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
387 | ||
388 | *value=0UL; | |
389 | while (*buf) { | |
390 | str=buf; | |
391 | while (*str && (unsigned char)*str>' ' && *str!=';') str++; | |
392 | if (*str) { | |
393 | *str++='\0'; | |
394 | while (*str && ((unsigned char)*str<=' ' || *str==';')) str++; | |
395 | } | |
396 | for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++); | |
397 | if (i>=noptions) { | |
398 | debuga(_("Unknown value \"%s\" for parameter \"%s\"\n"),buf,param); | |
399 | exit(EXIT_FAILURE); | |
400 | } | |
401 | if ((*value & options[i].exclude)!=0) { | |
402 | debuga(_("Value \"%s\" conflicts with other selected values for parameter \"%s\"\n"),buf,param); | |
403 | exit(EXIT_FAILURE); | |
404 | } | |
405 | *value|=options[i].value; | |
406 | buf=str; | |
407 | } | |
408 | return(1); | |
085c1e1f FM |
409 | } |
410 | ||
15d5372b FM |
411 | static int getparam_sort(const char *param,struct sort_list *options,int noptions,char *buf,unsigned long int *value) |
412 | { | |
9bd92830 FM |
413 | int plen; |
414 | char *str, *order; | |
415 | int i; | |
416 | ||
417 | plen=strlen(param); | |
418 | if (strncmp(buf,param,plen) != 0) return(0); | |
419 | buf+=plen; | |
420 | if ((unsigned char)*buf>' ') return(0); | |
421 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
422 | ||
423 | str=buf; | |
424 | order=NULL; | |
425 | while (*str && (unsigned char)*str>' ') str++; | |
426 | if (*str) { | |
427 | *str++='\0'; | |
428 | while (*str && (unsigned char)*str<=' ') str++; | |
429 | order=str; | |
430 | } | |
431 | for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++); | |
432 | if (i>=noptions) { | |
433 | debuga(_("Unknown sort criterion \"%s\" for parameter \"%s\"\n"),buf,param); | |
434 | exit(EXIT_FAILURE); | |
435 | } | |
436 | *value=options[i].value; | |
437 | ||
438 | if (order) { | |
439 | str=order; | |
440 | while (*str && (unsigned char)*str>' ') str++; | |
441 | if (*str) { | |
442 | *str++='\0'; | |
443 | while (*str && (unsigned char)*str<=' ') str++; | |
444 | } | |
445 | if (strcasecmp(order,"reverse")==0 || strcasecmp(order,"D")==0) { | |
446 | *value|=SORT_REVERSE; | |
447 | } else if (strcasecmp(order,"normal")!=0 && strcasecmp(order,"A")!=0) { | |
448 | debuga(_("Unknown sort order \"%s\" for parameter \"%s\"\n"),order,param); | |
449 | exit(EXIT_FAILURE); | |
450 | } | |
451 | } | |
452 | ||
453 | buf=str; | |
454 | return(1); | |
15d5372b FM |
455 | } |
456 | ||
0b5356bb FM |
457 | static int getparam_select(const char *param,struct select_list *options,int noptions,char *buf,int *value) |
458 | { | |
459 | int plen; | |
460 | char *str; | |
461 | int i; | |
462 | ||
463 | plen=strlen(param); | |
464 | if (strncmp(buf,param,plen) != 0) return(0); | |
465 | buf+=plen; | |
466 | if ((unsigned char)*buf>' ') return(0); | |
467 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
468 | ||
469 | str=buf; | |
470 | while (*buf && (unsigned char)*buf>' ' && *buf!=';') buf++; | |
471 | *buf='\0'; | |
472 | for (i=0 ; i<noptions && strcasecmp(str,options[i].name) ; i++); | |
473 | if (i>=noptions) { | |
474 | debuga(_("Unknown value \"%s\" for parameter \"%s\"\n"),str,param); | |
475 | exit(EXIT_FAILURE); | |
476 | } | |
477 | *value=options[i].value; | |
478 | return(1); | |
479 | } | |
480 | ||
2e29ae23 FM |
481 | static int getparam_userlimit(const char *param,char *buf) |
482 | { | |
483 | int plen; | |
484 | char *file_begin,*file_end; | |
485 | int limit; | |
486 | int digit; | |
3877d630 FM |
487 | char *str; |
488 | int i; | |
489 | enum PerUserOutputEnum output; | |
490 | const struct | |
491 | { | |
492 | const char *name; | |
493 | enum PerUserOutputEnum value; | |
494 | } output_types[]= | |
495 | { | |
496 | {"id",PUOE_UserId}, | |
497 | {"ip",PUOE_UserIp}, | |
498 | }; | |
2e29ae23 FM |
499 | |
500 | plen=strlen(param); | |
501 | if (strncmp(buf,param,plen) != 0) return(0); | |
502 | buf+=plen; | |
503 | if ((unsigned char)*buf>' ') return(0); | |
504 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
505 | ||
506 | /* | |
507 | options are made of a file name, an integer limit and an optional | |
508 | integer flag. The file name may contain spaces. We keep searching | |
509 | until a valid number is found after a space. | |
510 | */ | |
511 | file_begin=buf; | |
512 | do { | |
513 | while (*buf && (unsigned char)*buf>' ') buf++; | |
514 | if (*buf!=' ') { | |
515 | debuga(_("Missing limit in per_user_limit\n")); | |
516 | exit(EXIT_FAILURE); | |
517 | } | |
518 | file_end=buf; | |
519 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
520 | limit=0; | |
521 | while (*buf && isdigit(*buf)) { | |
522 | digit=*buf-'0'; | |
523 | if (limit>=(INT_MAX-digit)/10) break; | |
524 | limit=limit*10+digit; | |
525 | buf++; | |
526 | } | |
527 | } while (*buf && *buf!=' '); | |
528 | ||
3877d630 | 529 | output=PUOE_UserId; |
2e29ae23 FM |
530 | if (*buf==' ') { |
531 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
3877d630 FM |
532 | str=buf; |
533 | while (*buf && (unsigned char)*buf>' ') buf++; | |
534 | *buf='\0'; | |
535 | for (i=sizeof(output_types)/sizeof(output_types[0])-1 ; i>=0 ; i--) | |
536 | if (strcasecmp(output_types[i].name,str)==0) { | |
537 | output=output_types[i].value; | |
538 | break; | |
539 | } | |
540 | if (i<0) { | |
541 | debuga(_("Invalid output type in per_user_limit\n")); | |
2e29ae23 FM |
542 | exit(EXIT_FAILURE); |
543 | } | |
2e29ae23 FM |
544 | } |
545 | ||
546 | if (PerUserLimitsNumber>=MAX_USER_LIMITS) { | |
547 | debuga(_("Too many per_user_limit\n")); | |
548 | exit(EXIT_FAILURE); | |
549 | } | |
550 | *file_end='\0'; | |
551 | safe_strcpy(PerUserLimits[PerUserLimitsNumber].File,file_begin,sizeof(PerUserLimits[PerUserLimitsNumber].File)); | |
552 | PerUserLimits[PerUserLimitsNumber].Limit=limit; | |
3877d630 | 553 | PerUserLimits[PerUserLimitsNumber].Output=output; |
2e29ae23 FM |
554 | PerUserLimitsNumber++; |
555 | ||
556 | return(1); | |
557 | } | |
558 | ||
26810f86 FM |
559 | static void ccharset(char *CharSet) |
560 | { | |
561 | if (strcmp(CharSet,"Latin2") == 0) strcpy(CharSet,"ISO-8859-2"); | |
562 | else if (strcmp(CharSet,"Latin3") == 0) strcpy(CharSet,"ISO-8859-3"); | |
563 | else if (strcmp(CharSet,"Latin4") == 0) strcpy(CharSet,"ISO-8859-4"); | |
564 | else if (strcmp(CharSet,"Cyrillic") == 0) strcpy(CharSet,"ISO-8859-5"); | |
565 | else if (strcmp(CharSet,"Arabic") == 0) strcpy(CharSet,"ISO-8859-6"); | |
566 | else if (strcmp(CharSet,"Greek") == 0) strcpy(CharSet,"ISO-8859-7"); | |
567 | else if (strcmp(CharSet,"Hebrew") == 0) strcpy(CharSet,"ISO-8859-8"); | |
568 | else if (strcmp(CharSet,"Latin5") == 0) strcpy(CharSet,"ISO-8859-9"); | |
569 | else if (strcmp(CharSet,"Latin6") == 0) strcpy(CharSet,"ISO-8859-10"); | |
570 | else if (strcmp(CharSet,"Japan") == 0) strcpy(CharSet,"EUC-JP"); | |
571 | else if (strcmp(CharSet,"Koi8-r") == 0) strcpy(CharSet,"KOI8-R"); | |
572 | /* | |
573 | * Any other encoding name is left unchanged. | |
574 | */ | |
575 | return; | |
576 | } | |
577 | ||
4af2f8ff FM |
578 | static void parmtest(char *buf) |
579 | { | |
9bd92830 FM |
580 | char wbuf[2048]; |
581 | struct getwordstruct gwarea; | |
0b5356bb | 582 | int iVal; |
25697a35 | 583 | |
9bd92830 | 584 | while (*buf && (unsigned char)*buf<=' ') buf++; |
25697a35 | 585 | |
9bd92830 FM |
586 | if(*buf == '#' || *buf == '\0') |
587 | return; | |
25697a35 | 588 | |
cb59dc47 | 589 | if(debugz>=LogLevel_Process) |
9bd92830 | 590 | printf(_("SARG: TAG: %s\n"),buf); |
25697a35 | 591 | |
9bd92830 | 592 | if (getparam_string("background_color",buf,BgColor,sizeof(BgColor))>0) return; |
25697a35 | 593 | |
9bd92830 | 594 | if (getparam_string("text_color",buf,TxColor,sizeof(TxColor))>0) return; |
25697a35 | 595 | |
9bd92830 | 596 | if (getparam_string("text_bgcolor",buf,TxBgColor,sizeof(TxBgColor))>0) return; |
25697a35 | 597 | |
9bd92830 | 598 | if (getparam_string("title_color",buf,TiColor,sizeof(TiColor))>0) return; |
25697a35 | 599 | |
9bd92830 | 600 | if (getparam_string("logo_image",buf,LogoImage,sizeof(LogoImage))>0) return; |
25697a35 | 601 | |
9bd92830 | 602 | if (getparam_quoted("logo_text",buf,LogoText,sizeof(LogoText))>0) return; |
25697a35 | 603 | |
9bd92830 | 604 | if (getparam_string("logo_text_color",buf,LogoTextColor,sizeof(LogoTextColor))>0) return; |
25697a35 | 605 | |
9bd92830 | 606 | if (getparam_string("background_image",buf,BgImage,sizeof(BgImage))>0) return; |
25697a35 | 607 | |
9bd92830 | 608 | if (getparam_bool("show_sarg_info",buf,&ShowSargInfo)>0) return; |
25697a35 | 609 | |
9bd92830 | 610 | if (getparam_bool("show_sarg_logo",buf,&ShowSargLogo)>0) return; |
25697a35 | 611 | |
9bd92830 | 612 | if (getparam_string("font_face",buf,FontFace,sizeof(FontFace))>0) return; |
25697a35 | 613 | |
9bd92830 | 614 | if (getparam_string("header_color",buf,HeaderColor,sizeof(HeaderColor))>0) return; |
25697a35 | 615 | |
9bd92830 | 616 | if (getparam_string("header_bgcolor",buf,HeaderBgColor,sizeof(HeaderBgColor))>0) return; |
25697a35 | 617 | |
9bd92830 | 618 | if (getparam_string("font_size",buf,FontSize,sizeof(FontSize))>0) return; |
25697a35 | 619 | |
9bd92830 | 620 | if (getparam_string("header_font_size",buf,HeaderFontSize,sizeof(HeaderFontSize))>0) return; |
25697a35 | 621 | |
9bd92830 | 622 | if (getparam_string("title_font_size",buf,TitleFontSize,sizeof(TitleFontSize))>0) return; |
25697a35 | 623 | |
9bd92830 | 624 | if (getparam_2words("image_size",buf,Width,sizeof(Width),Height,sizeof(Height))>0) return; |
25697a35 | 625 | |
9bd92830 | 626 | if (getparam_quoted("title",buf,Title,sizeof(Title))>0) return; |
25697a35 | 627 | |
51b166d4 FM |
628 | if (strncasecmp(buf,"resolve_ip",10)==0) { |
629 | if (ip2name_config(buf+10)>0) return; | |
630 | } | |
25697a35 | 631 | |
9bd92830 | 632 | if (getparam_bool("user_ip",buf,&UserIp)>0) return; |
4af2f8ff | 633 | |
9bd92830 | 634 | if (getparam_string("max_elapsed",buf,MaxElapsed,sizeof(MaxElapsed))>0) return; |
25697a35 | 635 | |
9bd92830 FM |
636 | if (is_param("date_format",buf)) { |
637 | getword_start(&gwarea,buf); | |
638 | if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) { | |
00d1f9ed | 639 | debuga(_("Invalid record in \"date_format\" parameter\n")); |
9bd92830 FM |
640 | exit(EXIT_FAILURE); |
641 | } | |
81a022d8 | 642 | DateFormat=gwarea.current[0]; |
9bd92830 FM |
643 | return; |
644 | } | |
25697a35 | 645 | |
9bd92830 FM |
646 | if (is_param("hours",buf)) { |
647 | if( getnumlist( buf, &hours, 24, 24 ) ) { | |
648 | debuga(_("Error: Invalid syntax in hours tag!\n")); | |
649 | exit( 1 ); | |
650 | } | |
651 | return; | |
652 | } | |
25697a35 | 653 | |
9bd92830 FM |
654 | if (is_param("weekdays",buf)) { |
655 | if( getnumlist( buf, &weekdays, 7, 7 ) ) { | |
656 | debuga(_("Error: Invalid syntax in weekdays tag!\n")); | |
657 | exit( 1 ); | |
658 | } | |
659 | return; | |
660 | } | |
25697a35 | 661 | |
9bd92830 | 662 | if (getparam_sort("topuser_sort_field",SET_LIST(topuser_sort),buf,&TopuserSort)>0) return; |
25697a35 | 663 | |
9bd92830 | 664 | if (getparam_sort("user_sort_field",SET_LIST(user_sort),buf,&UserSort)>0) return; |
25697a35 | 665 | |
9bd92830 FM |
666 | if (is_param("access_log",buf)>0) { |
667 | if (AccessLogFromCmdLine==0) { | |
6068ae56 FM |
668 | char *FileName=getparam_stringptr("access_log",buf); |
669 | if (!AccessLog) | |
670 | AccessLog=FileList_Create(); | |
671 | if (!FileList_AddFile(AccessLog,FileName)) { | |
672 | debuga(_("Not enough memory to store the input log file names\n")); | |
9bd92830 FM |
673 | exit(EXIT_FAILURE); |
674 | } | |
9bd92830 FM |
675 | } |
676 | return; | |
677 | } | |
25697a35 | 678 | |
9bd92830 FM |
679 | if (is_param("redirector_log",buf)>0) { |
680 | if (RedirectorLogFromCmdLine==0) { | |
681 | if (NRedirectorLogs>=MAX_REDIRECTOR_LOGS) { | |
682 | debuga(_("Too many redirector log files in configuration file\n")); | |
683 | exit(EXIT_FAILURE); | |
684 | } | |
685 | getparam_string("redirector_log",buf,RedirectorLogs[NRedirectorLogs],MAX_REDIRECTOR_FILELEN); | |
686 | NRedirectorLogs++; | |
687 | } | |
688 | return; | |
689 | } | |
1f482a8d | 690 | |
9bd92830 | 691 | if (getparam_string("useragent_log",buf,UserAgentLog,sizeof(UserAgentLog))>0) return; |
25697a35 | 692 | |
9bd92830 | 693 | if (getparam_string("exclude_hosts",buf,ExcludeHosts,sizeof(ExcludeHosts))>0) return; |
25697a35 | 694 | |
9bd92830 | 695 | if (getparam_string("exclude_codes",buf,ExcludeCodes,sizeof(ExcludeCodes))>0) return; |
25697a35 | 696 | |
9bd92830 | 697 | if (getparam_string("exclude_users",buf,ExcludeUsers,sizeof(ExcludeUsers))>0) return; |
25697a35 | 698 | |
9bd92830 | 699 | if (getparam_string("password",buf,PasswdFile,sizeof(PasswdFile))>0) return; |
25697a35 | 700 | |
9bd92830 | 701 | if (getparam_string("temporary_dir",buf,TempDir,sizeof(TempDir))>0) return; |
25697a35 | 702 | |
9bd92830 | 703 | if (getparam_list("report_type",SET_LIST(report_type_values),buf,&ReportType)>0) return; |
25697a35 | 704 | |
9bd92830 | 705 | if (getparam_string("output_dir",buf,OutputDir,sizeof(OutputDir))>0) return; |
25697a35 | 706 | |
829a53c2 FM |
707 | if (getparam_bool("anonymous_output_files",buf,&AnonymousOutputFiles)>0) return; |
708 | ||
9bd92830 | 709 | if (getparam_string("output_email",buf,OutputEmail,sizeof(OutputEmail))>0) return; |
25697a35 | 710 | |
2e29ae23 | 711 | if (getparam_userlimit("per_user_limit",buf)>0) return; |
25697a35 | 712 | |
0b5356bb FM |
713 | if (getparam_select("per_user_limit_file_create",SET_LIST(per_user_limit_create_file),buf,&iVal)>0) { |
714 | PerUserFileCreation=(enum PerUserFileCreationEnum)iVal; | |
715 | return; | |
716 | } | |
717 | ||
9bd92830 | 718 | if (getparam_int("lastlog",buf,&LastLog)>0) return; |
25697a35 | 719 | |
9bd92830 | 720 | if (getparam_bool("remove_temp_files",buf,&RemoveTempFiles)>0) return; |
25697a35 | 721 | |
9bd92830 | 722 | if (getparam_string("replace_index",buf,ReplaceIndex,sizeof(ReplaceIndex))>0) return; |
25697a35 | 723 | |
9bd92830 | 724 | if (getparam_list("index_tree",SET_LIST(index_tree_values),buf,&IndexTree)>0) return; |
25697a35 | 725 | |
9bd92830 | 726 | if (getparam_list("index",SET_LIST(index_values),buf,&Index)>0) return; |
25697a35 | 727 | |
9aaa3361 FM |
728 | if (getparam_list("index_fields",SET_LIST(indexfields_values),buf,&IndexFields)>0) return; |
729 | ||
9bd92830 | 730 | if (getparam_bool("overwrite_report",buf,&OverwriteReport)>0) return; |
25697a35 | 731 | |
9bd92830 | 732 | if (getparam_list("records_without_userid",SET_LIST(recnouser_values),buf,&RecordsWithoutUser)>0) return; |
25697a35 | 733 | |
9bd92830 | 734 | if (getparam_bool("use_comma",buf,&UseComma)>0) return; |
25697a35 | 735 | |
9bd92830 | 736 | if (getparam_string("mail_utility",buf,MailUtility,sizeof(MailUtility))>0) return; |
25697a35 | 737 | |
9bd92830 | 738 | if (getparam_int("topsites_num",buf,&TopSitesNum)>0) return; |
25697a35 | 739 | |
9bd92830 | 740 | if (getparam_int("topuser_num",buf,&TopUsersNum)>0) return; |
25697a35 | 741 | |
9bd92830 | 742 | if (getparam_string("usertab",buf,UserTabFile,sizeof(UserTabFile))>0) return; |
25697a35 | 743 | |
9bd92830 | 744 | if (getparam_string("index_sort_order",buf,IndexSortOrder,sizeof(IndexSortOrder))>0) return; |
25697a35 | 745 | |
9bd92830 | 746 | if (getparam_sort("topsites_sort_order",SET_LIST(topsite_sort),buf,&TopsitesSort)>0) return; |
25697a35 | 747 | |
9bd92830 | 748 | if (getparam_bool("long_url",buf,&LongUrl)>0) return; |
25697a35 | 749 | |
9bd92830 | 750 | if (getparam_string("dansguardian_conf",buf,DansGuardianConf,sizeof(DansGuardianConf))>0) return; |
25697a35 | 751 | |
9bd92830 | 752 | if (getparam_string("squidguard_conf",buf,SquidGuardConf,sizeof(SquidGuardConf))>0) return; |
25697a35 | 753 | |
9bd92830 | 754 | if (getparam_list("date_time_by",SET_LIST(datetime_values),buf,&datetimeby)>0) return; |
25697a35 | 755 | |
9bd92830 FM |
756 | if (getparam_string("charset",buf,CharSet,sizeof(CharSet))>0) { |
757 | ccharset(CharSet); | |
758 | return; | |
759 | } | |
25697a35 | 760 | |
9bd92830 | 761 | if (getparam_quoted("user_invalid_char",buf,UserInvalidChar,sizeof(UserInvalidChar))>0) return; |
25697a35 | 762 | |
9bd92830 FM |
763 | if (getparam_quoted("include_users",buf,IncludeUsers+1,sizeof(IncludeUsers)-2)>0) { |
764 | IncludeUsers[0]=':'; | |
765 | strcat(IncludeUsers,":"); | |
766 | return; | |
767 | } | |
491b862f | 768 | |
9bd92830 | 769 | if (getparam_quoted("exclude_string",buf,ExcludeString,sizeof(ExcludeString))>0) return; |
25697a35 | 770 | |
9bd92830 | 771 | if (getparam_bool("privacy",buf,&Privacy)>0) return; |
25697a35 | 772 | |
9bd92830 | 773 | if (getparam_quoted("privacy_string",buf,PrivacyString,sizeof(PrivacyString))>0) return; |
25697a35 | 774 | |
9bd92830 | 775 | if (getparam_string("privacy_string_color",buf,PrivacyStringColor,sizeof(PrivacyStringColor))>0) return; |
25697a35 | 776 | |
9bd92830 | 777 | if (getparam_bool("show_successful_message",buf,&SuccessfulMsg)>0) return; |
25697a35 | 778 | |
9bd92830 | 779 | if (getparam_bool("show_read_statistics",buf,&ShowReadStatistics)>0) return; |
25697a35 | 780 | |
2f4787e6 FM |
781 | if (getparam_bool("show_read_percent",buf,&ShowReadPercent)>0) return; |
782 | ||
9bd92830 | 783 | if (getparam_list("topuser_fields",SET_LIST(topuserfields_values),buf,&TopUserFields)>0) return; |
25697a35 | 784 | |
9bd92830 | 785 | if (getparam_bool("bytes_in_sites_users_report",buf,&BytesInSitesUsersReport)>0) return; |
25697a35 | 786 | |
9bd92830 | 787 | if (getparam_list("user_report_fields",SET_LIST(userreportfields_values),buf,&UserReportFields)>0) return; |
25697a35 | 788 | |
9bd92830 | 789 | if (getparam_string("datafile",buf,DataFile,sizeof(DataFile))>0) return; |
25697a35 | 790 | |
9bd92830 | 791 | if (getparam_quoted("datafile_delimiter",buf,DataFileDelimiter,sizeof(DataFileDelimiter))>0) return; |
25697a35 | 792 | |
9bd92830 | 793 | if (getparam_list("datafile_fields",SET_LIST(data_field_values),buf,&DataFileFields)>0) return; |
25697a35 | 794 | |
9bd92830 | 795 | if (getparam_list("datafile_url",SET_LIST(datafileurl_values),buf,&DataFileUrl)>0) return; |
25697a35 | 796 | |
9bd92830 | 797 | if (getparam_string("parsed_output_log",buf,ParsedOutputLog,sizeof(ParsedOutputLog))>0) return; |
25697a35 | 798 | |
9bd92830 | 799 | if (getparam_string("parsed_output_log_compress",buf,ParsedOutputLogCompress,sizeof(ParsedOutputLogCompress))>0) return; |
25697a35 | 800 | |
9bd92830 | 801 | if (getparam_list("displayed_values",SET_LIST(displayvalue_values),buf,&DisplayedValues)>0) return; |
25697a35 | 802 | |
9bd92830 | 803 | if (getparam_int("authfail_report_limit",buf,&AuthfailReportLimit)>0) return; |
25697a35 | 804 | |
9bd92830 | 805 | if (getparam_int("denied_report_limit",buf,&DeniedReportLimit)>0) return; |
25697a35 | 806 | |
9bd92830 | 807 | if (getparam_int("siteusers_report_limit",buf,&SiteUsersReportLimit)>0) return; |
25697a35 | 808 | |
9bd92830 | 809 | if (getparam_int("dansguardian_report_limit",buf,&DansGuardianReportLimit)>0) return; |
25697a35 | 810 | |
9bd92830 | 811 | if (getparam_int("squidguard_report_limit",buf,&SquidGuardReportLimit)>0) return; |
25697a35 | 812 | |
9bd92830 | 813 | if (getparam_int("user_report_limit",buf,&UserReportLimit)>0) return; |
491b862f | 814 | |
9bd92830 | 815 | if (getparam_int("download_report_limit",buf,&DownloadReportLimit)>0) return; |
491b862f | 816 | |
9bd92830 | 817 | if (getparam_string("www_document_root",buf,wwwDocumentRoot,sizeof(wwwDocumentRoot))>0) return; |
25697a35 | 818 | |
9bd92830 | 819 | if (getparam_string("block_it",buf,BlockIt,sizeof(BlockIt))>0) return; |
491b862f | 820 | |
9bd92830 | 821 | if (getparam_string("external_css_file",buf,ExternalCSSFile,sizeof(ExternalCSSFile))>0) return; |
491b862f | 822 | |
9bd92830 | 823 | if (getparam_bool("user_authentication",buf,&UserAuthentication)>0) return; |
491b862f | 824 | |
9bd92830 FM |
825 | if (getparam_string("AuthUserTemplateFile",buf,wbuf,sizeof(wbuf))>0) { |
826 | char dir[MAXLEN]; | |
491b862f | 827 | |
9bd92830 FM |
828 | if (is_absolute(wbuf)) { |
829 | if (strlen(wbuf)>=sizeof(AuthUserTemplateFile)) { | |
830 | debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n")); | |
831 | exit(EXIT_FAILURE); | |
832 | } | |
a87d4d11 | 833 | safe_strcpy(AuthUserTemplateFile,wbuf,sizeof(AuthUserTemplateFile)); |
9bd92830 | 834 | } else { |
a87d4d11 | 835 | safe_strcpy(dir,ConfigFile,sizeof(dir)); |
9bd92830 FM |
836 | if (snprintf(AuthUserTemplateFile,sizeof(AuthUserTemplateFile),"%s/%s",dirname(dir),wbuf)>=sizeof(AuthUserTemplateFile)) { |
837 | debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n")); | |
838 | exit(EXIT_FAILURE); | |
839 | } | |
840 | } | |
841 | return; | |
842 | } | |
4af2f8ff | 843 | |
9bd92830 FM |
844 | if (is_param("download_suffix",buf)) { |
845 | char warea[MAXLEN]; | |
6e792ade | 846 | |
9bd92830 FM |
847 | getparam_quoted("download_suffix",buf,warea,sizeof(warea)); |
848 | set_download_suffix(warea); | |
849 | return; | |
850 | } | |
d6e703cc | 851 | |
8ddc656a FM |
852 | if (getparam_bool("graphs",buf,&Graphs)>0) { |
853 | #ifndef HAVE_GD | |
854 | if (Graphs) | |
855 | debugaz(_("No graphs available as sarg was not compiled with libgd. Set \"graphs\" to \"no\" in %s to disable this warning\n"), | |
856 | ConfigFile); | |
857 | #endif | |
858 | return; | |
859 | } | |
4af2f8ff | 860 | |
9bd92830 | 861 | if (getparam_string("graph_days_bytes_bar_color",buf,GraphDaysBytesBarColor,sizeof(GraphDaysBytesBarColor))>0) return; |
4af2f8ff | 862 | |
9bd92830 FM |
863 | if (getparam_string("redirector_log_format",buf,RedirectorLogFormat,sizeof(RedirectorLogFormat))>0) return; |
864 | if (getparam_string("squidguard_log_format",buf,RedirectorLogFormat,sizeof(RedirectorLogFormat))>0) { | |
865 | debuga(_("squidguard_log_format is deprecated and has been replaced by redirector_log_format. Please update your configuration file.\n")); | |
866 | return; | |
867 | } | |
4af2f8ff | 868 | |
9bd92830 FM |
869 | if (getparam_bool("redirector_filter_out_date",buf,&RedirectorFilterOutDate)>0) return; |
870 | if (getparam_bool("redirector_ignore_date",buf,&RedirectorFilterOutDate)>0) { | |
871 | /* | |
872 | Due to an old bug in sarg before version 2.3, the option was having the opposite action than implied by the name. | |
873 | */ | |
874 | 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")); | |
875 | RedirectorFilterOutDate=!RedirectorFilterOutDate; | |
876 | return; | |
877 | } | |
878 | if (getparam_bool("squidguard_ignore_date",buf,&RedirectorFilterOutDate)>0) { | |
879 | 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")); | |
880 | RedirectorFilterOutDate=!RedirectorFilterOutDate; | |
881 | return; | |
882 | } | |
4af2f8ff | 883 | |
9bd92830 FM |
884 | if (getparam_bool("dansguardian_filter_out_date",buf,&DansguardianFilterOutDate)>0) return; |
885 | if (getparam_bool("dansguardian_ignore_date",buf,&DansguardianFilterOutDate)>0) { | |
886 | 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")); | |
887 | DansguardianFilterOutDate=!DansguardianFilterOutDate; | |
888 | return; | |
889 | } | |
4af2f8ff | 890 | |
9bd92830 | 891 | if (getparam_string("ulimit",buf,Ulimit,sizeof(Ulimit))>0) return; |
4af2f8ff | 892 | |
9bd92830 | 893 | if (getparam_list("ntlm_user_format",SET_LIST(ntml_userformat_values),buf,&NtlmUserFormat)>0) return; |
4af2f8ff | 894 | |
9bd92830 | 895 | if (getparam_string("realtime_types",buf,RealtimeTypes,sizeof(RealtimeTypes))>0) return; |
4af2f8ff | 896 | |
9bd92830 | 897 | if (getparam_list("realtime_unauthenticated_records",SET_LIST(realtime_unauth_values),buf,&RealtimeUnauthRec)>0) return; |
4af2f8ff | 898 | |
9bd92830 | 899 | if (getparam_int("realtime_refresh_time",buf,&realtime_refresh)>0) return; |
4af2f8ff | 900 | |
9bd92830 | 901 | if (getparam_int("realtime_access_log_lines",buf,&realtime_access_log_lines)>0) return; |
4af2f8ff | 902 | |
9bd92830 | 903 | if (getparam_string("LDAPHost",buf,LDAPHost,sizeof(LDAPHost))>0) return; |
e3af0ae9 | 904 | |
9bd92830 | 905 | if (getparam_int("LDAPPort",buf,&LDAPPort)>0) return; |
e3af0ae9 | 906 | |
9bd92830 | 907 | if (getparam_int("LDAPProtocolVersion",buf,&LDAPProtocolVersion)>0) return; |
e3af0ae9 | 908 | |
9bd92830 | 909 | if (getparam_string("LDAPBindDN",buf,LDAPBindDN,sizeof(LDAPBindDN))>0) return; |
e3af0ae9 | 910 | |
9bd92830 | 911 | if (getparam_string("LDAPBindPW",buf,LDAPBindPW,sizeof(LDAPBindPW))>0) return; |
e3af0ae9 | 912 | |
9bd92830 | 913 | if (getparam_string("LDAPBaseSearch",buf,LDAPBaseSearch,sizeof(LDAPBaseSearch))>0) return; |
e3af0ae9 | 914 | |
9bd92830 | 915 | if (getparam_string("LDAPFilterSearch",buf,LDAPFilterSearch,sizeof(LDAPFilterSearch))>0) return; |
e3af0ae9 | 916 | |
9bd92830 | 917 | if (getparam_string("LDAPTargetAttr",buf,LDAPTargetAttr,sizeof(LDAPTargetAttr))>0) return; |
e3af0ae9 | 918 | |
fd75cd90 FM |
919 | if (getparam_string("LDAPNativeCharset",buf,LDAPNativeCharset,sizeof(LDAPNativeCharset))>0) return; |
920 | ||
9bd92830 | 921 | if (getparam_string("graph_font",buf,GraphFont,sizeof(GraphFont))>0) return; |
3becf85c | 922 | |
9bd92830 | 923 | if (getparam_string("sorttable",buf,SortTableJs,sizeof(SortTableJs))>0) return; |
ea275279 | 924 | |
22715352 | 925 | if (getparam_string("hostalias",buf,HostAliasFile,sizeof(HostAliasFile))>0) return; |
11767c6a | 926 | |
c4f0ea8f FM |
927 | if (getparam_string("useralias",buf,UserAliasFile,sizeof(UserAliasFile))>0) return; |
928 | ||
11767c6a | 929 | if (getparam_bool("keep_temp_log",buf,&KeepTempLog)>0) return; |
4d62cb0a FM |
930 | |
931 | if (getparam_int("max_successive_log_errors",buf,&NumLogSuccessiveErrors)>0) return; | |
932 | ||
933 | if (getparam_int("max_total_log_errors",buf,&NumLogTotalErrors)>0) return; | |
934 | ||
9bd92830 FM |
935 | if(strstr(buf,"squid24") != 0) { |
936 | squid24=true; | |
937 | return; | |
938 | } | |
4af2f8ff | 939 | |
9bd92830 FM |
940 | if(strstr(buf,"byte_cost") != 0) { |
941 | getword_start(&gwarea,buf); | |
942 | if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) { | |
943 | debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n")); | |
944 | exit(EXIT_FAILURE); | |
945 | } | |
946 | cost=atol(gwarea.current); | |
947 | if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) { | |
948 | debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n")); | |
949 | exit(EXIT_FAILURE); | |
950 | } | |
951 | nocost=my_atoll(gwarea.current); | |
952 | return; | |
953 | } | |
4af2f8ff | 954 | |
66f507aa FM |
955 | if (getparam_string("image_dir",buf,ImageDir,sizeof(ImageDir))>0) return; |
956 | ||
9bd92830 | 957 | printf(_("SARG: Unknown option %s\n"),buf); |
d6e703cc FM |
958 | } |
959 | ||
32e71fa4 | 960 | void getconf(void) |
d6e703cc | 961 | { |
9bd92830 FM |
962 | FILE *fp_in; |
963 | char buf[MAXLEN]; | |
d6e703cc | 964 | |
9bd92830 | 965 | if(debug) |
2eb432c7 | 966 | debuga(_("Loading configuration from \"%s\"\n"),ConfigFile); |
d6e703cc | 967 | |
9bd92830 | 968 | if ((fp_in = fopen(ConfigFile, "r")) == NULL) { |
96dadc9f | 969 | debuga(_("Cannot open file \"%s\": %s\n"),ConfigFile,strerror(errno)); |
9bd92830 FM |
970 | exit(EXIT_FAILURE); |
971 | } | |
d6e703cc | 972 | |
9bd92830 FM |
973 | while (fgets(buf, sizeof(buf), fp_in) != NULL) { |
974 | fixendofline(buf); | |
d6e703cc | 975 | |
4246ae8d | 976 | if (debugz>=LogLevel_Data) |
9bd92830 | 977 | printf("SYSCONFDIR %s\n",buf); |
d6e703cc | 978 | |
9bd92830 | 979 | parmtest(buf); |
d6e703cc | 980 | |
9bd92830 | 981 | } |
d6e703cc | 982 | |
204781f4 FM |
983 | if (fclose(fp_in)==EOF) { |
984 | debuga(_("Read error in \"%s\": %s\n"),ConfigFile,strerror(errno)); | |
985 | exit(EXIT_FAILURE); | |
986 | } | |
9bd92830 | 987 | return; |
25697a35 | 988 | } |