]>
Commit | Line | Data |
---|---|---|
25697a35 | 1 | /* |
94ff9470 | 2 | * SARG Squid Analysis Report Generator http://sarg.sourceforge.net |
1164c474 | 3 | * 1998, 2010 |
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 | { | |
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; | |
42 | }; | |
43 | ||
e43854ef | 44 | static struct param_list report_type_values[]= |
085c1e1f FM |
45 | { |
46 | {"users_sites",REPORT_TYPE_USERS_SITES,0}, | |
47 | {"topusers",REPORT_TYPE_TOPUSERS,0}, | |
48 | {"topsites",REPORT_TYPE_TOPSITES,0}, | |
49 | {"sites_users",REPORT_TYPE_SITES_USERS,0}, | |
50 | {"date_time",REPORT_TYPE_DATE_TIME,0}, | |
51 | {"denied",REPORT_TYPE_DENIED,0}, | |
52 | {"auth_failures",REPORT_TYPE_AUTH_FAILURES,0}, | |
53 | {"site_user_time_date",REPORT_TYPE_SITE_USER_TIME_DATE,0}, | |
54 | {"downloads",REPORT_TYPE_DOWNLOADS,0}, | |
55 | }; | |
56 | ||
e43854ef | 57 | static struct param_list data_field_values[]= |
085c1e1f FM |
58 | { |
59 | {"user",DATA_FIELD_USER,0}, | |
60 | {"date",DATA_FIELD_DATE,0}, | |
61 | {"time",DATA_FIELD_TIME,0}, | |
62 | {"url",DATA_FIELD_URL,0}, | |
63 | {"connect",DATA_FIELD_CONNECT,0}, | |
64 | {"bytes",DATA_FIELD_BYTES,0}, | |
65 | {"in_cache",DATA_FIELD_IN_CACHE,0}, | |
66 | {"out_cache",DATA_FIELD_OUT_CACHE,0}, | |
67 | {"elapsed",DATA_FIELD_ELAPSED,0}, | |
68 | }; | |
69 | ||
e43854ef | 70 | static struct param_list topuserfields_values[]= |
085c1e1f FM |
71 | { |
72 | {"NUM",TOPUSERFIELDS_NUM,0}, | |
73 | {"DATE_TIME",TOPUSERFIELDS_DATE_TIME,0}, | |
74 | {"USERID",TOPUSERFIELDS_USERID,0}, | |
75 | {"CONNECT",TOPUSERFIELDS_CONNECT,0}, | |
76 | {"BYTES",TOPUSERFIELDS_BYTES,0}, | |
77 | {"%BYTES",TOPUSERFIELDS_SETYB,0}, | |
78 | {"SETYB",TOPUSERFIELDS_SETYB,0}, | |
79 | {"IN-CACHE-OUT",TOPUSERFIELDS_IN_CACHE_OUT,0}, | |
80 | {"USED_TIME",TOPUSERFIELDS_USED_TIME,0}, | |
81 | {"MILISEC",TOPUSERFIELDS_MILISEC,0}, | |
82 | {"%TIME",TOPUSERFIELDS_PTIME,0}, | |
83 | {"TOTAL",TOPUSERFIELDS_TOTAL,0}, | |
84 | {"AVERAGE",TOPUSERFIELDS_AVERAGE,0}, | |
85 | }; | |
86 | ||
e43854ef | 87 | static struct param_list userreportfields_values[]= |
085c1e1f FM |
88 | { |
89 | {"CONNECT",USERREPORTFIELDS_CONNECT,0}, | |
90 | {"BYTES",USERREPORTFIELDS_BYTES,0}, | |
91 | {"%BYTES",USERREPORTFIELDS_SETYB,0}, | |
92 | {"SETYB",USERREPORTFIELDS_SETYB,0}, | |
93 | {"IN-CACHE-OUT",USERREPORTFIELDS_IN_CACHE_OUT,0}, | |
94 | {"USED_TIME",USERREPORTFIELDS_USED_TIME,0}, | |
95 | {"MILISEC",USERREPORTFIELDS_MILISEC,0}, | |
96 | {"%TIME",USERREPORTFIELDS_PTIME,0}, | |
97 | {"TOTAL",USERREPORTFIELDS_TOTAL,0}, | |
98 | {"AVERAGE",USERREPORTFIELDS_AVERAGE,0}, | |
99 | }; | |
100 | ||
e43854ef | 101 | static struct param_list index_values[]= |
0349fa24 FM |
102 | { |
103 | {"yes",INDEX_YES,~INDEX_YES}, | |
104 | {"no",INDEX_NO,~INDEX_NO}, | |
105 | {"only",INDEX_ONLY,~INDEX_ONLY}, | |
106 | }; | |
107 | ||
e43854ef | 108 | static struct param_list index_tree_values[]= |
0349fa24 FM |
109 | { |
110 | {"date",INDEX_TREE_DATE,~INDEX_TREE_DATE}, | |
111 | {"file",INDEX_TREE_FILE,~INDEX_TREE_FILE}, | |
112 | }; | |
113 | ||
e43854ef | 114 | static struct param_list ntml_userformat_values[]= |
f2ec8c75 FM |
115 | { |
116 | {"user",NTLMUSERFORMAT_USER,~NTLMUSERFORMAT_USER}, | |
117 | {"domainname+username",NTLMUSERFORMAT_DOMAINUSER,~NTLMUSERFORMAT_DOMAINUSER}, | |
118 | }; | |
119 | ||
e43854ef | 120 | static struct param_list recnouser_values[]= |
f2ec8c75 FM |
121 | { |
122 | {"ip",RECORDWITHOUTUSER_IP,~RECORDWITHOUTUSER_IP}, | |
123 | {"ignore",RECORDWITHOUTUSER_IGNORE,~RECORDWITHOUTUSER_IGNORE}, | |
124 | {"everybody",RECORDWITHOUTUSER_EVERYBODY,~RECORDWITHOUTUSER_EVERYBODY}, | |
125 | }; | |
126 | ||
e43854ef | 127 | static struct param_list datafileurl_values[]= |
f84a35a3 FM |
128 | { |
129 | {"ip",DATAFILEURL_IP,~DATAFILEURL_IP}, | |
130 | {"name",DATAFILEURL_NAME,~DATAFILEURL_NAME}, | |
131 | }; | |
132 | ||
e43854ef FM |
133 | static struct param_list displayvalue_values[]= |
134 | { | |
135 | {"bytes",DISPLAY_BYTES,~DISPLAY_BYTES}, | |
136 | {"abbreviation",DISPLAY_ABBREV,~DISPLAY_ABBREV}, | |
137 | }; | |
138 | ||
43cc1649 FM |
139 | static struct param_list datetime_values[]= |
140 | { | |
a28e7b10 FM |
141 | {"elap",DATETIME_ELAP,~DATETIME_ELAP}, |
142 | {"bytes",DATETIME_BYTE,~DATETIME_BYTE}, | |
43cc1649 FM |
143 | }; |
144 | ||
6e792ade | 145 | static int is_param(const char *param,const char *buf) |
0a4e18e1 FM |
146 | { |
147 | int plen; | |
148 | ||
149 | plen=strlen(param); | |
150 | if (strncmp(buf,param,plen) != 0) return(0); | |
151 | buf+=plen; | |
152 | if ((unsigned char)*buf>' ') return(0); | |
153 | return(1); | |
154 | } | |
155 | ||
4af2f8ff FM |
156 | static int getparam_string(const char *param,char *buf,char *value,int value_size) |
157 | { | |
158 | int plen; | |
159 | ||
160 | plen=strlen(param); | |
161 | if (strncmp(buf,param,plen) != 0) return(0); | |
162 | buf+=plen; | |
163 | if ((unsigned char)*buf>' ') return(0); | |
164 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
165 | ||
166 | if (strlen(buf)>=value_size) { | |
248a4787 | 167 | debuga(_("The string value of parameter \"%s\" is too long\n"),param); |
06b39c87 | 168 | exit(EXIT_FAILURE); |
4af2f8ff FM |
169 | } |
170 | strcpy(value,buf); | |
171 | fixnone(value); | |
172 | return(1); | |
173 | } | |
25697a35 | 174 | |
4af2f8ff | 175 | static int getparam_quoted(const char *param,char *buf,char *value,int value_size) |
25697a35 | 176 | { |
4af2f8ff FM |
177 | int plen; |
178 | int i; | |
25697a35 | 179 | |
4af2f8ff FM |
180 | plen=strlen(param); |
181 | if (strncmp(buf,param,plen) != 0) return(0); | |
182 | buf+=plen; | |
183 | if ((unsigned char)*buf>' ') return(0); | |
184 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
25697a35 | 185 | |
4af2f8ff | 186 | if (*buf != '\"') { |
248a4787 | 187 | debuga(_("Missing double quote after parameter \"%s\"\n"),param); |
06b39c87 | 188 | exit(EXIT_FAILURE); |
4af2f8ff FM |
189 | } |
190 | buf++; | |
25697a35 | 191 | |
4af2f8ff FM |
192 | value_size--; |
193 | for (i=0 ; i<value_size && *buf && *buf!='\"' ; i++) { | |
194 | value[i]=*buf++; | |
195 | } | |
196 | value[i]='\0'; | |
25697a35 | 197 | |
4af2f8ff | 198 | if (*buf != '\"') { |
248a4787 | 199 | debuga(_("Missing double quote after parameter \"%s\" or value is more than %d bytes long\n"),param,value_size); |
06b39c87 | 200 | exit(EXIT_FAILURE); |
4af2f8ff FM |
201 | } |
202 | fixnone(value); | |
203 | return(1); | |
204 | } | |
25697a35 | 205 | |
4af2f8ff FM |
206 | static int getparam_2words(const char *param,char *buf,char *word1,int word1_size,char *word2,int word2_size) |
207 | { | |
208 | int plen; | |
209 | int i; | |
210 | ||
211 | plen=strlen(param); | |
212 | if (strncmp(buf,param,plen) != 0) return(0); | |
213 | buf+=plen; | |
214 | if ((unsigned char)*buf>' ') return(0); | |
215 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
216 | ||
217 | for (i=0 ; i<word1_size && *buf && (unsigned char)*buf>' ' ; i++) | |
218 | word1[i]=*buf++; | |
219 | if (i>=word1_size) { | |
248a4787 | 220 | debuga(_("The first word of parameter \"%s\" is more than %d bytes long\n"),param,word1_size-1); |
06b39c87 | 221 | exit(EXIT_FAILURE); |
4af2f8ff FM |
222 | } |
223 | if (*buf!=' ') { | |
248a4787 | 224 | debuga(_("Missing second word for parameter \"%s\"\n"),param); |
06b39c87 | 225 | exit(EXIT_FAILURE); |
4af2f8ff FM |
226 | } |
227 | word1[i]=0; | |
25697a35 | 228 | |
4af2f8ff | 229 | while (*buf && (unsigned char)*buf<=' ') buf++; |
25697a35 | 230 | |
4af2f8ff FM |
231 | for (i=0 ; i<word2_size && *buf && (unsigned char)*buf>' ' ; i++) |
232 | word2[i]=*buf++; | |
233 | if (i>=word2_size) { | |
248a4787 | 234 | debuga(_("The second word of parameter \"%s\" is more than %d bytes long\n"),param,word2_size-1); |
06b39c87 | 235 | exit(EXIT_FAILURE); |
4af2f8ff FM |
236 | } |
237 | word2[i]=0; | |
25697a35 | 238 | |
4af2f8ff FM |
239 | fixnone(word1); |
240 | fixnone(word2); | |
241 | return(1); | |
242 | } | |
25697a35 | 243 | |
4af2f8ff FM |
244 | static int getparam_int(const char *param,char *buf,int *value) |
245 | { | |
246 | int plen; | |
247 | int next; | |
248 | ||
249 | plen=strlen(param); | |
250 | if (strncmp(buf,param,plen) != 0) return(0); | |
251 | buf+=plen; | |
252 | if ((unsigned char)*buf>' ') return(0); | |
253 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
254 | ||
255 | next=0; | |
256 | if (sscanf(buf,"%d%n",value,&next) != 1 || (unsigned char)buf[next] > ' ') { | |
248a4787 | 257 | debuga(_("The integer value of parameter \"%s\" is invalid\n"),param); |
06b39c87 | 258 | exit(EXIT_FAILURE); |
4af2f8ff FM |
259 | } |
260 | return(1); | |
261 | } | |
25697a35 | 262 | |
06b39c87 | 263 | static int getparam_bool(const char *param,char *buf,bool *value) |
246c8489 FM |
264 | { |
265 | int plen; | |
246c8489 | 266 | int i; |
f6ff06fa | 267 | const char *bool_str="yes,true,on,1"; |
246c8489 FM |
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 | ||
06b39c87 | 275 | *value=false; |
f6ff06fa FM |
276 | for ( ; *bool_str ; bool_str+=i) { |
277 | for (i=0 ; bool_str[i] && bool_str[i]!=',' ; i++); | |
278 | if (strncasecmp(bool_str,buf,i)==0) { | |
06b39c87 | 279 | *value=true; |
246c8489 FM |
280 | break; |
281 | } | |
f6ff06fa | 282 | if (bool_str[i]==',') i++; |
246c8489 FM |
283 | } |
284 | return(1); | |
285 | } | |
286 | ||
085c1e1f FM |
287 | static int getparam_list(const char *param,struct param_list *options,int noptions,char *buf,unsigned long int *value) |
288 | { | |
289 | int plen; | |
290 | char *str; | |
291 | int i; | |
292 | ||
293 | plen=strlen(param); | |
294 | if (strncmp(buf,param,plen) != 0) return(0); | |
295 | buf+=plen; | |
296 | if ((unsigned char)*buf>' ') return(0); | |
297 | while (*buf && (unsigned char)*buf<=' ') buf++; | |
298 | ||
299 | *value=0UL; | |
300 | while (*buf) { | |
301 | str=buf; | |
302 | while (*str && (unsigned char)*str>' ' && *str!=';') str++; | |
303 | if (*str) { | |
304 | *str++='\0'; | |
305 | while (*str && ((unsigned char)*str<=' ' || *str==';')) str++; | |
306 | } | |
307 | for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++); | |
308 | if (i>=noptions) { | |
248a4787 | 309 | debuga(_("Unknown value \"%s\" for parameter \"%s\"\n"),buf,param); |
06b39c87 | 310 | exit(EXIT_FAILURE); |
085c1e1f FM |
311 | } |
312 | if ((*value & options[i].exclude)!=0) { | |
248a4787 | 313 | debuga(_("Value \"%s\" conflicts with other selected values for parameter \"%s\"\n"),buf,param); |
06b39c87 | 314 | exit(EXIT_FAILURE); |
085c1e1f FM |
315 | } |
316 | *value|=options[i].value; | |
317 | buf=str; | |
318 | } | |
319 | return(1); | |
320 | } | |
321 | ||
4af2f8ff FM |
322 | static void parmtest(char *buf) |
323 | { | |
d5d021c5 | 324 | char wbuf[2048]; |
9c7c6346 | 325 | struct getwordstruct gwarea; |
25697a35 | 326 | |
4af2f8ff | 327 | while (*buf && (unsigned char)*buf<=' ') buf++; |
25697a35 | 328 | |
4af2f8ff FM |
329 | if(*buf == '#' || *buf == '\0') |
330 | return; | |
25697a35 | 331 | |
4af2f8ff | 332 | if(debugz) |
3c567423 | 333 | printf(_("SARG: TAG: %s\n"),buf); |
25697a35 | 334 | |
4af2f8ff | 335 | if (getparam_string("background_color",buf,BgColor,sizeof(BgColor))>0) return; |
25697a35 | 336 | |
4af2f8ff | 337 | if (getparam_string("text_color",buf,TxColor,sizeof(TxColor))>0) return; |
25697a35 | 338 | |
4af2f8ff | 339 | if (getparam_string("text_bgcolor",buf,TxBgColor,sizeof(TxBgColor))>0) return; |
25697a35 | 340 | |
4af2f8ff | 341 | if (getparam_string("title_color",buf,TiColor,sizeof(TiColor))>0) return; |
25697a35 | 342 | |
4af2f8ff | 343 | if (getparam_string("logo_image",buf,LogoImage,sizeof(LogoImage))>0) return; |
25697a35 | 344 | |
4af2f8ff | 345 | if (getparam_quoted("logo_text",buf,LogoText,sizeof(LogoText))>0) return; |
25697a35 | 346 | |
4af2f8ff | 347 | if (getparam_string("logo_text_color",buf,LogoTextColor,sizeof(LogoTextColor))>0) return; |
25697a35 | 348 | |
4af2f8ff | 349 | if (getparam_string("background_image",buf,BgImage,sizeof(BgImage))>0) return; |
25697a35 | 350 | |
e6414a9d | 351 | if (getparam_bool("show_sarg_info",buf,&ShowSargInfo)>0) return; |
25697a35 | 352 | |
e6414a9d | 353 | if (getparam_bool("show_sarg_logo",buf,&ShowSargLogo)>0) return; |
25697a35 | 354 | |
4af2f8ff | 355 | if (getparam_string("font_face",buf,FontFace,sizeof(FontFace))>0) return; |
25697a35 | 356 | |
4af2f8ff | 357 | if (getparam_string("header_color",buf,HeaderColor,sizeof(HeaderColor))>0) return; |
25697a35 | 358 | |
4af2f8ff | 359 | if (getparam_string("header_bgcolor",buf,HeaderBgColor,sizeof(HeaderBgColor))>0) return; |
25697a35 | 360 | |
4af2f8ff | 361 | if (getparam_string("font_size",buf,FontSize,sizeof(FontSize))>0) return; |
25697a35 | 362 | |
4af2f8ff | 363 | if (getparam_string("header_font_size",buf,HeaderFontSize,sizeof(HeaderFontSize))>0) return; |
25697a35 | 364 | |
4af2f8ff | 365 | if (getparam_string("title_font_size",buf,TitleFontSize,sizeof(TitleFontSize))>0) return; |
25697a35 | 366 | |
4af2f8ff | 367 | if (getparam_2words("image_size",buf,Width,sizeof(Width),Height,sizeof(Height))>0) return; |
25697a35 | 368 | |
4af2f8ff | 369 | if (getparam_quoted("title",buf,Title,sizeof(Title))>0) return; |
25697a35 | 370 | |
246c8489 | 371 | if (getparam_bool("resolve_ip",buf,&Ip2Name)>0) return; |
25697a35 | 372 | |
246c8489 | 373 | if (getparam_bool("user_ip",buf,&UserIp)>0) return; |
4af2f8ff FM |
374 | |
375 | if (getparam_string("max_elapsed",buf,MaxElapsed,sizeof(MaxElapsed))>0) return; | |
25697a35 | 376 | |
e6414a9d | 377 | if (is_param("date_format",buf)) { |
9c7c6346 FM |
378 | getword_start(&gwarea,buf); |
379 | if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) { | |
248a4787 | 380 | debuga(_("Maybe you have a broken record or garbage in \"date_format\" parameter\n")); |
06b39c87 | 381 | exit(EXIT_FAILURE); |
25697a35 | 382 | } |
9c7c6346 | 383 | strncpy(DateFormat,gwarea.current,1); |
4af2f8ff FM |
384 | fixnone(DateFormat); |
385 | return; | |
386 | } | |
25697a35 | 387 | |
e6414a9d | 388 | if (is_param("hours",buf)) { |
4af2f8ff | 389 | if( getnumlist( buf, &hours, 24, 24 ) ) { |
248a4787 | 390 | debuga(_("Error: Invalid syntax in hours tag!\n")); |
4af2f8ff | 391 | exit( 1 ); |
25697a35 | 392 | } |
4af2f8ff | 393 | } |
25697a35 | 394 | |
e6414a9d | 395 | if (is_param("weekdays",buf)) { |
4af2f8ff | 396 | if( getnumlist( buf, &weekdays, 7, 7 ) ) { |
248a4787 | 397 | debuga(_("Error: Invalid syntax in weekdays tag!\n")); |
4af2f8ff | 398 | exit( 1 ); |
25697a35 | 399 | } |
4af2f8ff | 400 | } |
25697a35 | 401 | |
4af2f8ff | 402 | if (getparam_2words("topuser_sort_field",buf,TopuserSortField,sizeof(TopuserSortField),TopuserSortOrder,sizeof(TopuserSortOrder))>0) return; |
25697a35 | 403 | |
4af2f8ff | 404 | if (getparam_2words("user_sort_field",buf,UserSortField,sizeof(UserSortField),UserSortOrder,sizeof(UserSortOrder))>0) return; |
25697a35 | 405 | |
6e792ade | 406 | if (is_param("access_log",buf)>0) { |
0a4e18e1 FM |
407 | if (AccessLogFromCmdLine==0) { |
408 | if (NAccessLog>=MAXLOGS) { | |
248a4787 | 409 | debuga(_("Too many log files in configuration file\n")); |
06b39c87 | 410 | exit(EXIT_FAILURE); |
0a4e18e1 | 411 | } |
1f482a8d | 412 | getparam_string("access_log",buf,AccessLog[NAccessLog],MAX_LOG_FILELEN); |
0a4e18e1 FM |
413 | NAccessLog++; |
414 | } | |
415 | return; | |
416 | } | |
25697a35 | 417 | |
1f482a8d FM |
418 | if (is_param("redirector_log",buf)>0) { |
419 | if (RedirectorLogFromCmdLine==0) { | |
420 | if (NRedirectorLogs>=MAX_REDIRECTOR_LOGS) { | |
421 | debuga(_("Too many redirector log files in configuration file\n")); | |
422 | exit(EXIT_FAILURE); | |
423 | } | |
424 | getparam_string("redirector_log",buf,RedirectorLogs[NRedirectorLogs],MAX_REDIRECTOR_FILELEN); | |
425 | NRedirectorLogs++; | |
426 | } | |
427 | return; | |
428 | } | |
429 | ||
4af2f8ff | 430 | if (getparam_string("useragent_log",buf,UserAgentLog,sizeof(UserAgentLog))>0) return; |
25697a35 | 431 | |
4af2f8ff | 432 | if (getparam_string("exclude_hosts",buf,ExcludeHosts,sizeof(ExcludeHosts))>0) return; |
25697a35 | 433 | |
4af2f8ff | 434 | if (getparam_string("exclude_codes",buf,ExcludeCodes,sizeof(ExcludeCodes))>0) return; |
25697a35 | 435 | |
4af2f8ff | 436 | if (getparam_string("exclude_users",buf,ExcludeUsers,sizeof(ExcludeUsers))>0) return; |
25697a35 | 437 | |
4af2f8ff | 438 | if (getparam_string("password",buf,PasswdFile,sizeof(PasswdFile))>0) return; |
25697a35 | 439 | |
4af2f8ff | 440 | if (getparam_string("temporary_dir",buf,TempDir,sizeof(TempDir))>0) return; |
25697a35 | 441 | |
085c1e1f | 442 | if (getparam_list("report_type",SET_LIST(report_type_values),buf,&ReportType)>0) return; |
25697a35 | 443 | |
4af2f8ff | 444 | if (getparam_string("output_dir",buf,OutputDir,sizeof(OutputDir))>0) return; |
25697a35 | 445 | |
4af2f8ff | 446 | if (getparam_string("output_email",buf,OutputEmail,sizeof(OutputEmail))>0) return; |
25697a35 | 447 | |
e6414a9d FM |
448 | if (getparam_2words("per_user_limit",buf,PerUserLimitFile,sizeof(PerUserLimitFile),wbuf,sizeof(wbuf))>0) { |
449 | PerUserLimit=atoi(wbuf); | |
450 | return; | |
451 | } | |
25697a35 | 452 | |
0511cf2d | 453 | if (getparam_int("lastlog",buf,&LastLog)>0) return; |
25697a35 | 454 | |
e6414a9d | 455 | if (getparam_bool("remove_temp_files",buf,&RemoveTempFiles)>0) return; |
25697a35 | 456 | |
4af2f8ff | 457 | if (getparam_string("replace_index",buf,ReplaceIndex,sizeof(ReplaceIndex))>0) return; |
25697a35 | 458 | |
0349fa24 | 459 | if (getparam_list("index_tree",SET_LIST(index_tree_values),buf,&IndexTree)>0) return; |
25697a35 | 460 | |
0349fa24 | 461 | if (getparam_list("index",SET_LIST(index_values),buf,&Index)>0) return; |
25697a35 | 462 | |
e6414a9d | 463 | if (getparam_bool("overwrite_report",buf,&OverwriteReport)>0) return; |
25697a35 | 464 | |
f2ec8c75 | 465 | if (getparam_list("records_without_userid",SET_LIST(recnouser_values),buf,&RecordsWithoutUser)>0) return; |
25697a35 | 466 | |
e6414a9d | 467 | if (getparam_bool("use_comma",buf,&UseComma)>0) return; |
25697a35 | 468 | |
4af2f8ff | 469 | if (getparam_string("mail_utility",buf,MailUtility,sizeof(MailUtility))>0) return; |
25697a35 | 470 | |
c0ec9cc7 | 471 | if (getparam_int("topsites_num",buf,&TopSitesNum)>0) return; |
25697a35 | 472 | |
fb7c5f27 | 473 | if (getparam_int("topuser_num",buf,&TopUsersNum)>0) return; |
25697a35 | 474 | |
4af2f8ff | 475 | if (getparam_string("usertab",buf,UserTabFile,sizeof(UserTabFile))>0) return; |
25697a35 | 476 | |
4af2f8ff | 477 | if (getparam_string("index_sort_order",buf,IndexSortOrder,sizeof(IndexSortOrder))>0) return; |
25697a35 | 478 | |
4af2f8ff | 479 | if (getparam_2words("topsites_sort_order",buf,TopsitesSortField,sizeof(TopsitesSortField),TopsitesSortType,sizeof(TopsitesSortType))>0) return; |
25697a35 | 480 | |
246c8489 | 481 | if (getparam_bool("long_url",buf,&LongUrl)>0) return; |
25697a35 | 482 | |
4af2f8ff | 483 | if (getparam_string("dansguardian_conf",buf,DansGuardianConf,sizeof(DansGuardianConf))>0) return; |
25697a35 | 484 | |
4af2f8ff | 485 | if (getparam_string("squidguard_conf",buf,SquidGuardConf,sizeof(SquidGuardConf))>0) return; |
25697a35 | 486 | |
43cc1649 | 487 | if (getparam_list("date_time_by",SET_LIST(datetime_values),buf,&datetimeby)>0) return; |
25697a35 | 488 | |
4af2f8ff FM |
489 | if (getparam_string("charset",buf,CharSet,sizeof(CharSet))>0) { |
490 | ccharset(CharSet); | |
491 | return; | |
492 | } | |
25697a35 | 493 | |
4af2f8ff | 494 | if (getparam_quoted("user_invalid_char",buf,UserInvalidChar,sizeof(UserInvalidChar))>0) return; |
25697a35 | 495 | |
4af2f8ff FM |
496 | if (getparam_quoted("include_users",buf,IncludeUsers+1,sizeof(IncludeUsers)-2)>0) { |
497 | IncludeUsers[0]=':'; | |
498 | strcat(IncludeUsers,":"); | |
499 | return; | |
500 | } | |
491b862f | 501 | |
4af2f8ff | 502 | if (getparam_quoted("exclude_string",buf,ExcludeString,sizeof(ExcludeString))>0) return; |
25697a35 | 503 | |
e6414a9d | 504 | if (getparam_bool("privacy",buf,&Privacy)>0) return; |
25697a35 | 505 | |
78015ea0 | 506 | if (getparam_quoted("privacy_string",buf,PrivacyString,sizeof(PrivacyString))>0) return; |
25697a35 | 507 | |
4af2f8ff | 508 | if (getparam_string("privacy_string_color",buf,PrivacyStringColor,sizeof(PrivacyStringColor))>0) return; |
25697a35 | 509 | |
e6414a9d | 510 | if (getparam_bool("show_successful_message",buf,&SuccessfulMsg)>0) return; |
25697a35 | 511 | |
e6414a9d | 512 | if (getparam_bool("show_read_statistics",buf,&ShowReadStatistics)>0) return; |
25697a35 | 513 | |
085c1e1f | 514 | if (getparam_list("topuser_fields",SET_LIST(topuserfields_values),buf,&TopUserFields)>0) return; |
25697a35 | 515 | |
e6414a9d | 516 | if (getparam_bool("bytes_in_sites_users_report",buf,&BytesInSitesUsersReport)>0) return; |
25697a35 | 517 | |
085c1e1f | 518 | if (getparam_list("user_report_fields",SET_LIST(userreportfields_values),buf,&UserReportFields)>0) return; |
25697a35 | 519 | |
4af2f8ff | 520 | if (getparam_string("datafile",buf,DataFile,sizeof(DataFile))>0) return; |
25697a35 | 521 | |
4af2f8ff | 522 | if (getparam_quoted("datafile_delimiter",buf,DataFileDelimiter,sizeof(DataFileDelimiter))>0) return; |
25697a35 | 523 | |
085c1e1f | 524 | if (getparam_list("datafile_fields",SET_LIST(data_field_values),buf,&DataFileFields)>0) return; |
25697a35 | 525 | |
f84a35a3 | 526 | if (getparam_list("datafile_url",SET_LIST(datafileurl_values),buf,&DataFileUrl)>0) return; |
25697a35 | 527 | |
4af2f8ff | 528 | if (getparam_string("parsed_output_log",buf,ParsedOutputLog,sizeof(ParsedOutputLog))>0) return; |
25697a35 | 529 | |
4af2f8ff | 530 | if (getparam_string("parsed_output_log_compress",buf,ParsedOutputLogCompress,sizeof(ParsedOutputLogCompress))>0) return; |
25697a35 | 531 | |
e43854ef | 532 | if (getparam_list("displayed_values",SET_LIST(displayvalue_values),buf,&DisplayedValues)>0) return; |
25697a35 | 533 | |
4af2f8ff | 534 | if (getparam_int("authfail_report_limit",buf,&AuthfailReportLimit)>0) return; |
25697a35 | 535 | |
4af2f8ff | 536 | if (getparam_int("denied_report_limit",buf,&DeniedReportLimit)>0) return; |
25697a35 | 537 | |
4af2f8ff | 538 | if (getparam_int("siteusers_report_limit",buf,&SiteUsersReportLimit)>0) return; |
25697a35 | 539 | |
4af2f8ff | 540 | if (getparam_int("dansguardian_report_limit",buf,&DansGuardianReportLimit)>0) return; |
25697a35 | 541 | |
4af2f8ff | 542 | if (getparam_int("squidguard_report_limit",buf,&SquidGuardReportLimit)>0) return; |
25697a35 | 543 | |
4af2f8ff | 544 | if (getparam_int("user_report_limit",buf,&UserReportLimit)>0) return; |
491b862f | 545 | |
4af2f8ff | 546 | if (getparam_int("download_report_limit",buf,&DownloadReportLimit)>0) return; |
491b862f | 547 | |
4af2f8ff | 548 | if (getparam_string("www_document_root",buf,wwwDocumentRoot,sizeof(wwwDocumentRoot))>0) return; |
25697a35 | 549 | |
4af2f8ff | 550 | if (getparam_string("block_it",buf,BlockIt,sizeof(BlockIt))>0) return; |
491b862f | 551 | |
4af2f8ff | 552 | if (getparam_string("external_css_file",buf,ExternalCSSFile,sizeof(ExternalCSSFile))>0) return; |
491b862f | 553 | |
e6414a9d | 554 | if (getparam_bool("user_authentication",buf,&UserAuthentication)>0) return; |
491b862f | 555 | |
d5d021c5 FM |
556 | if (getparam_string("AuthUserTemplateFile",buf,wbuf,sizeof(wbuf))>0) { |
557 | char dir[MAXLEN]; | |
491b862f | 558 | |
d5d021c5 FM |
559 | if (is_absolute(wbuf)) { |
560 | if (strlen(wbuf)>=sizeof(AuthUserTemplateFile)) { | |
561 | debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n")); | |
06b39c87 | 562 | exit(EXIT_FAILURE); |
d5d021c5 FM |
563 | } |
564 | strcpy(AuthUserTemplateFile,wbuf); | |
565 | } else { | |
566 | strcpy(dir,ConfigFile); | |
567 | if (snprintf(AuthUserTemplateFile,sizeof(AuthUserTemplateFile),"%s/%s",dirname(dir),wbuf)>=sizeof(AuthUserTemplateFile)) { | |
568 | debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n")); | |
06b39c87 | 569 | exit(EXIT_FAILURE); |
d5d021c5 FM |
570 | } |
571 | } | |
572 | return; | |
573 | } | |
4af2f8ff | 574 | |
6e792ade FM |
575 | if (is_param("download_suffix",buf)) { |
576 | char warea[MAXLEN]; | |
577 | ||
578 | getparam_quoted("download_suffix",buf,warea,sizeof(warea)); | |
579 | set_download_suffix(warea); | |
e6414a9d | 580 | return; |
6e792ade | 581 | } |
d6e703cc | 582 | |
e6414a9d | 583 | if (getparam_bool("graphs",buf,&Graphs)>0) return; |
4af2f8ff FM |
584 | |
585 | if (getparam_string("graph_days_bytes_bar_color",buf,GraphDaysBytesBarColor,sizeof(GraphDaysBytesBarColor))>0) return; | |
586 | ||
1f482a8d | 587 | if (getparam_string("redirector_log_format",buf,RedirectorLogFormat,sizeof(RedirectorLogFormat))>0) return; |
69fa7b48 FM |
588 | if (getparam_string("squidguard_log_format",buf,RedirectorLogFormat,sizeof(RedirectorLogFormat))>0) { |
589 | debuga(_("squidguard_log_format is deprecated and has been replaced by redirector_log_format. Please update your configuration file.\n")); | |
590 | return; | |
591 | } | |
4af2f8ff | 592 | |
69fa7b48 FM |
593 | if (getparam_bool("redirector_ignore_date",buf,&RedirectorIgnoreDate)>0) return; |
594 | if (getparam_bool("squidguard_ignore_date",buf,&RedirectorIgnoreDate)>0) { | |
595 | debuga(_("squidguard_ignore_date is deprecated and has been replaced by redirector_ignore_date. Please update your configuration file.\n")); | |
596 | return; | |
597 | } | |
4af2f8ff | 598 | |
e6414a9d | 599 | if (getparam_bool("dansguardian_ignore_date",buf,&DansguardianIgnoreDate)>0) return; |
4af2f8ff FM |
600 | |
601 | if (getparam_string("ulimit",buf,Ulimit,sizeof(Ulimit))>0) return; | |
602 | ||
f2ec8c75 | 603 | if (getparam_list("ntlm_user_format",SET_LIST(ntml_userformat_values),buf,&NtlmUserFormat)>0) return; |
4af2f8ff FM |
604 | |
605 | if (getparam_string("realtime_types",buf,RealtimeTypes,sizeof(RealtimeTypes))>0) return; | |
606 | ||
607 | if (getparam_string("realtime_unauthenticated_records",buf,RealtimeUnauthRec,sizeof(RealtimeUnauthRec))>0) return; | |
608 | ||
609 | if (getparam_int("realtime_refresh_time",buf,&realtime_refresh)>0) return; | |
610 | ||
611 | if (getparam_int("realtime_access_log_lines",buf,&realtime_access_log_lines)>0) return; | |
612 | ||
e3af0ae9 PO |
613 | if (getparam_string("LDAPHost",buf,LDAPHost,sizeof(LDAPHost))>0) return; |
614 | ||
965c4a6f | 615 | if (getparam_int("LDAPPort",buf,&LDAPPort)>0) return; |
e3af0ae9 | 616 | |
965c4a6f | 617 | if (getparam_int("LDAPProtocolVersion",buf,&LDAPProtocolVersion)>0) return; |
e3af0ae9 PO |
618 | |
619 | if (getparam_string("LDAPBindDN",buf,LDAPBindDN,sizeof(LDAPBindDN))>0) return; | |
620 | ||
621 | if (getparam_string("LDAPBindPW",buf,LDAPBindPW,sizeof(LDAPBindPW))>0) return; | |
622 | ||
623 | if (getparam_string("LDAPBaseSearch",buf,LDAPBaseSearch,sizeof(LDAPBaseSearch))>0) return; | |
624 | ||
625 | if (getparam_string("LDAPFilterSearch",buf,LDAPFilterSearch,sizeof(LDAPFilterSearch))>0) return; | |
626 | ||
627 | if (getparam_string("LDAPTargetAttr",buf,LDAPTargetAttr,sizeof(LDAPTargetAttr))>0) return; | |
628 | ||
3becf85c FM |
629 | if (getparam_string("graph_font",buf,GraphFont,sizeof(GraphFont))>0) return; |
630 | ||
4af2f8ff | 631 | if(strstr(buf,"squid24") != 0) { |
2824ec9b | 632 | squid24=true; |
4af2f8ff FM |
633 | return; |
634 | } | |
635 | ||
636 | if(strstr(buf,"byte_cost") != 0) { | |
9c7c6346 FM |
637 | getword_start(&gwarea,buf); |
638 | if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) { | |
248a4787 | 639 | debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n")); |
06b39c87 | 640 | exit(EXIT_FAILURE); |
4af2f8ff | 641 | } |
9c7c6346 FM |
642 | cost=atol(gwarea.current); |
643 | if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) { | |
248a4787 | 644 | debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n")); |
06b39c87 | 645 | exit(EXIT_FAILURE); |
491b862f | 646 | } |
9c7c6346 | 647 | nocost=my_atoll(gwarea.current); |
4af2f8ff FM |
648 | return; |
649 | } | |
650 | ||
3c567423 | 651 | printf(_("SARG: Unknown option %s\n"),buf); |
d6e703cc FM |
652 | } |
653 | ||
32e71fa4 | 654 | void getconf(void) |
d6e703cc FM |
655 | { |
656 | ||
657 | FILE *fp_in; | |
658 | char buf[MAXLEN]; | |
659 | ||
d2fe0c32 | 660 | if(debug) |
9f70c14e | 661 | debuga(_("Loading configuration from %s\n"),ConfigFile); |
d6e703cc FM |
662 | |
663 | if ((fp_in = fopen(ConfigFile, "r")) == NULL) { | |
9f70c14e | 664 | debuga(_("(getconf) Cannot open file %s\n"),ConfigFile); |
06b39c87 | 665 | exit(EXIT_FAILURE); |
d6e703cc FM |
666 | } |
667 | ||
4af2f8ff FM |
668 | while (fgets(buf, sizeof(buf), fp_in) != NULL) { |
669 | fixendofline(buf); | |
d6e703cc FM |
670 | |
671 | if(debugm) | |
3103300b | 672 | printf("SYSCONFDIR %s\n",buf); |
d6e703cc | 673 | |
d6e703cc FM |
674 | parmtest(buf); |
675 | ||
676 | } | |
677 | ||
678 | fclose(fp_in); | |
d6e703cc | 679 | return; |
25697a35 | 680 | } |