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