2 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
6 * please look at http://sarg.sourceforge.net/donations.php
8 * http://sourceforge.net/projects/sarg/forums/forum/363374
9 * ---------------------------------------------------------------------
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.
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.
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.
27 #include "include/conf.h"
28 #include "include/defs.h"
29 #include "include/filelist.h"
31 #define SET_LIST(list) list,sizeof(list)/sizeof(list[0])
33 extern numlist hours
, weekdays
;
34 extern FileListObject AccessLog
;
35 extern int PerUserLimitsNumber
;
36 extern struct PerUserLimitStruct PerUserLimits
[MAX_USER_LIMITS
];
37 extern enum PerUserFileCreationEnum PerUserFileCreation
;
41 //! The name of the value of the parameter.
43 //! The bit to set if the value is found.
44 unsigned long int value
;
45 //! The value is invalid if any bit of this mask is set in the parameter.
46 unsigned long int exclude
;
51 //! The name of the value of the parameter.
53 //! The bit to set if the value is found.
54 unsigned long int value
;
59 //! The name of the value of the parameter.
61 //! The value to assign when the name is selected.
65 static struct param_list report_type_values
[]=
67 {"users_sites",REPORT_TYPE_USERS_SITES
,0},
68 {"topusers",REPORT_TYPE_TOPUSERS
,0},
69 {"topsites",REPORT_TYPE_TOPSITES
,0},
70 {"sites_users",REPORT_TYPE_SITES_USERS
,0},
71 {"date_time",REPORT_TYPE_DATE_TIME
,0},
72 {"denied",REPORT_TYPE_DENIED
,0},
73 {"auth_failures",REPORT_TYPE_AUTH_FAILURES
,0},
74 {"site_user_time_date",REPORT_TYPE_SITE_USER_TIME_DATE
,0},
75 {"downloads",REPORT_TYPE_DOWNLOADS
,0},
78 static struct param_list data_field_values
[]=
80 {"user",DATA_FIELD_USER
,0},
81 {"date",DATA_FIELD_DATE
,0},
82 {"time",DATA_FIELD_TIME
,0},
83 {"url",DATA_FIELD_URL
,0},
84 {"connect",DATA_FIELD_CONNECT
,0},
85 {"bytes",DATA_FIELD_BYTES
,0},
86 {"in_cache",DATA_FIELD_IN_CACHE
,0},
87 {"out_cache",DATA_FIELD_OUT_CACHE
,0},
88 {"elapsed",DATA_FIELD_ELAPSED
,0},
91 static struct param_list topuserfields_values
[]=
93 {"NUM",TOPUSERFIELDS_NUM
,0},
94 {"DATE_TIME",TOPUSERFIELDS_DATE_TIME
,0},
95 {"USERID",TOPUSERFIELDS_USERID
,0},
96 {"CONNECT",TOPUSERFIELDS_CONNECT
,0},
97 {"BYTES",TOPUSERFIELDS_BYTES
,0},
98 {"%BYTES",TOPUSERFIELDS_SETYB
,0},
99 {"SETYB",TOPUSERFIELDS_SETYB
,0},
100 {"IN-CACHE-OUT",TOPUSERFIELDS_IN_CACHE_OUT
,0},
101 {"USED_TIME",TOPUSERFIELDS_USED_TIME
,0},
102 {"MILISEC",TOPUSERFIELDS_MILISEC
,0},
103 {"%TIME",TOPUSERFIELDS_PTIME
,0},
104 {"TOTAL",TOPUSERFIELDS_TOTAL
,0},
105 {"AVERAGE",TOPUSERFIELDS_AVERAGE
,0},
108 static struct param_list userreportfields_values
[]=
110 {"CONNECT",USERREPORTFIELDS_CONNECT
,0},
111 {"BYTES",USERREPORTFIELDS_BYTES
,0},
112 {"%BYTES",USERREPORTFIELDS_SETYB
,0},
113 {"SETYB",USERREPORTFIELDS_SETYB
,0},
114 {"IN-CACHE-OUT",USERREPORTFIELDS_IN_CACHE_OUT
,0},
115 {"USED_TIME",USERREPORTFIELDS_USED_TIME
,0},
116 {"MILISEC",USERREPORTFIELDS_MILISEC
,0},
117 {"%TIME",USERREPORTFIELDS_PTIME
,0},
118 {"TOTAL",USERREPORTFIELDS_TOTAL
,0},
119 {"AVERAGE",USERREPORTFIELDS_AVERAGE
,0},
122 static struct param_list index_values
[]=
124 {"yes",INDEX_YES
,~INDEX_YES
},
125 {"no",INDEX_NO
,~INDEX_NO
},
126 {"only",INDEX_ONLY
,~INDEX_ONLY
},
129 static struct param_list index_tree_values
[]=
131 {"date",INDEX_TREE_DATE
,~INDEX_TREE_DATE
},
132 {"file",INDEX_TREE_FILE
,~INDEX_TREE_FILE
},
135 static struct param_list indexfields_values
[]=
137 {"DIRSIZE",INDEXFIELDS_DIRSIZE
,0},
140 static struct param_list ntml_userformat_values
[]=
142 {"user",NTLMUSERFORMAT_USER
,~NTLMUSERFORMAT_USER
},
143 {"domainname+username",NTLMUSERFORMAT_DOMAINUSER
,~NTLMUSERFORMAT_DOMAINUSER
},
146 static struct param_list recnouser_values
[]=
148 {"ip",RECORDWITHOUTUSER_IP
,~RECORDWITHOUTUSER_IP
},
149 {"ignore",RECORDWITHOUTUSER_IGNORE
,~RECORDWITHOUTUSER_IGNORE
},
150 {"everybody",RECORDWITHOUTUSER_EVERYBODY
,~RECORDWITHOUTUSER_EVERYBODY
},
153 static struct param_list datafileurl_values
[]=
155 {"ip",DATAFILEURL_IP
,~DATAFILEURL_IP
},
156 {"name",DATAFILEURL_NAME
,~DATAFILEURL_NAME
},
159 static struct param_list displayvalue_values
[]=
161 {"bytes",DISPLAY_BYTES
,~DISPLAY_BYTES
},
162 {"abbreviation",DISPLAY_ABBREV
,~DISPLAY_ABBREV
},
165 static struct param_list datetime_values
[]=
167 {"elap",DATETIME_ELAP
,0},
168 {"bytes",DATETIME_BYTE
,0},
171 static struct param_list realtime_unauth_values
[]=
173 {"show",REALTIME_UNAUTH_REC_SHOW
,~REALTIME_UNAUTH_REC_SHOW
},
174 {"ignore",REALTIME_UNAUTH_REC_IGNORE
,~REALTIME_UNAUTH_REC_IGNORE
},
177 struct sort_list topuser_sort
[]=
179 {"BYTES",TOPUSER_SORT_BYTES
},
180 {"USER",TOPUSER_SORT_USER
},
181 {"CONNECT",TOPUSER_SORT_CONNECT
},
182 {"TIME",TOPUSER_SORT_TIME
},
185 struct sort_list topsite_sort
[]=
187 {"BYTES",TOPSITE_SORT_BYTES
},
188 {"CONNECT",TOPSITE_SORT_CONNECT
},
189 {"TIME",TOPSITE_SORT_TIME
},
190 {"USER",TOPSITE_SORT_USER
},
193 struct sort_list user_sort
[]=
195 {"BYTES",USER_SORT_BYTES
},
196 {"SITE",USER_SORT_SITE
},
197 {"CONNECT",USER_SORT_CONNECT
},
198 {"TIME",USER_SORT_TIME
},
201 static struct select_list per_user_limit_create_file
[]=
203 {"always",PUFC_Always
}, //always create an empty file
204 {"as_required",PUFC_AsRequired
}, //create the file if necessary (no empty file is created)
207 static int is_param(const char *param
,const char *buf
)
212 if (strncmp(buf
,param
,plen
) != 0) return(0);
214 if ((unsigned char)*buf
>' ') return(0);
218 static int getparam_string(const char *param
,char *buf
,char *value
,int value_size
)
223 if (strncmp(buf
,param
,plen
) != 0) return(0);
225 if ((unsigned char)*buf
>' ') return(0);
226 while (*buf
&& (unsigned char)*buf
<=' ') buf
++;
228 if (strlen(buf
)>=value_size
) {
229 debuga(_("The string value of parameter \"%s\" is too long\n"),param
);
238 * Get a pointer to the beginning of the string value defined by the
239 * parameter. The returned value is NULL if the buffer doesn't contain
242 * \param param The parameter to look for.
243 * \param buf The buffer containing the line read from the configuration
246 * \return A pointer to the beginning of the parameter value or NULL if
247 * the line is not for the requtested parameter.
249 static char *getparam_stringptr(const char *param
,char *buf
)
254 if (strncmp(buf
,param
,plen
) != 0) return(NULL
);
256 if ((unsigned char)*buf
>' ') return(NULL
);
257 while (*buf
&& (unsigned char)*buf
<=' ') buf
++;
262 static int getparam_quoted(const char *param
,char *buf
,char *value
,int value_size
)
268 if (strncmp(buf
,param
,plen
) != 0) return(0);
270 if ((unsigned char)*buf
>' ') return(0);
271 while (*buf
&& (unsigned char)*buf
<=' ') buf
++;
274 debuga(_("Missing double quote after parameter \"%s\"\n"),param
);
280 for (i
=0 ; i
<value_size
&& *buf
&& *buf
!='\"' ; i
++) {
286 debuga(_("Missing double quote after parameter \"%s\" or value is more than %d bytes long\n"),param
,value_size
);
293 static int getparam_2words(const char *param
,char *buf
,char *word1
,int word1_size
,char *word2
,int word2_size
)
299 if (strncmp(buf
,param
,plen
) != 0) return(0);
301 if ((unsigned char)*buf
>' ') return(0);
302 while (*buf
&& (unsigned char)*buf
<=' ') buf
++;
304 for (i
=0 ; i
<word1_size
&& *buf
&& (unsigned char)*buf
>' ' ; i
++)
307 debuga(_("The first word of parameter \"%s\" is more than %d bytes long\n"),param
,word1_size
-1);
311 debuga(_("Missing second word for parameter \"%s\"\n"),param
);
316 while (*buf
&& (unsigned char)*buf
<=' ') buf
++;
318 for (i
=0 ; i
<word2_size
&& *buf
&& (unsigned char)*buf
>' ' ; i
++)
321 debuga(_("The second word of parameter \"%s\" is more than %d bytes long\n"),param
,word2_size
-1);
331 static int getparam_int(const char *param
,char *buf
,int *value
)
337 if (strncmp(buf
,param
,plen
) != 0) return(0);
339 if ((unsigned char)*buf
>' ') return(0);
340 while (*buf
&& (unsigned char)*buf
<=' ') buf
++;
343 if (sscanf(buf
,"%d%n",value
,&next
) != 1 || (unsigned char)buf
[next
] > ' ') {
344 debuga(_("The integer value of parameter \"%s\" is invalid\n"),param
);
350 static int getparam_bool(const char *param
,char *buf
,bool *value
)
354 const char *bool_str
="yes,true,on,1";
357 if (strncmp(buf
,param
,plen
) != 0) return(0);
359 if ((unsigned char)*buf
>' ') return(0);
360 while (*buf
&& (unsigned char)*buf
<=' ') buf
++;
363 for ( ; *bool_str
; bool_str
+=i
) {
364 for (i
=0 ; bool_str
[i
] && bool_str
[i
]!=',' ; i
++);
365 if (strncasecmp(bool_str
,buf
,i
)==0) {
369 if (bool_str
[i
]==',') i
++;
374 static int getparam_list(const char *param
,struct param_list
*options
,int noptions
,char *buf
,unsigned long int *value
)
381 if (strncmp(buf
,param
,plen
) != 0) return(0);
383 if ((unsigned char)*buf
>' ') return(0);
384 while (*buf
&& (unsigned char)*buf
<=' ') buf
++;
389 while (*str
&& (unsigned char)*str
>' ' && *str
!=';') str
++;
392 while (*str
&& ((unsigned char)*str
<=' ' || *str
==';')) str
++;
394 for (i
=0 ; i
<noptions
&& strcasecmp(buf
,options
[i
].name
) ; i
++);
396 debuga(_("Unknown value \"%s\" for parameter \"%s\"\n"),buf
,param
);
399 if ((*value
& options
[i
].exclude
)!=0) {
400 debuga(_("Value \"%s\" conflicts with other selected values for parameter \"%s\"\n"),buf
,param
);
403 *value
|=options
[i
].value
;
409 static int getparam_sort(const char *param
,struct sort_list
*options
,int noptions
,char *buf
,unsigned long int *value
)
416 if (strncmp(buf
,param
,plen
) != 0) return(0);
418 if ((unsigned char)*buf
>' ') return(0);
419 while (*buf
&& (unsigned char)*buf
<=' ') buf
++;
423 while (*str
&& (unsigned char)*str
>' ') str
++;
426 while (*str
&& (unsigned char)*str
<=' ') str
++;
429 for (i
=0 ; i
<noptions
&& strcasecmp(buf
,options
[i
].name
) ; i
++);
431 debuga(_("Unknown sort criterion \"%s\" for parameter \"%s\"\n"),buf
,param
);
434 *value
=options
[i
].value
;
438 while (*str
&& (unsigned char)*str
>' ') str
++;
441 while (*str
&& (unsigned char)*str
<=' ') str
++;
443 if (strcasecmp(order
,"reverse")==0 || strcasecmp(order
,"D")==0) {
444 *value
|=SORT_REVERSE
;
445 } else if (strcasecmp(order
,"normal")!=0 && strcasecmp(order
,"A")!=0) {
446 debuga(_("Unknown sort order \"%s\" for parameter \"%s\"\n"),order
,param
);
455 static int getparam_select(const char *param
,struct select_list
*options
,int noptions
,char *buf
,int *value
)
462 if (strncmp(buf
,param
,plen
) != 0) return(0);
464 if ((unsigned char)*buf
>' ') return(0);
465 while (*buf
&& (unsigned char)*buf
<=' ') buf
++;
468 while (*buf
&& (unsigned char)*buf
>' ' && *buf
!=';') buf
++;
470 for (i
=0 ; i
<noptions
&& strcasecmp(str
,options
[i
].name
) ; i
++);
472 debuga(_("Unknown value \"%s\" for parameter \"%s\"\n"),str
,param
);
475 *value
=options
[i
].value
;
479 static int getparam_userlimit(const char *param
,char *buf
)
482 char *file_begin
,*file_end
;
487 enum PerUserOutputEnum output
;
491 enum PerUserOutputEnum value
;
499 if (strncmp(buf
,param
,plen
) != 0) return(0);
501 if ((unsigned char)*buf
>' ') return(0);
502 while (*buf
&& (unsigned char)*buf
<=' ') buf
++;
505 options are made of a file name, an integer limit and an optional
506 integer flag. The file name may contain spaces. We keep searching
507 until a valid number is found after a space.
511 while (*buf
&& (unsigned char)*buf
>' ') buf
++;
513 debuga(_("Missing limit in per_user_limit\n"));
517 while (*buf
&& (unsigned char)*buf
<=' ') buf
++;
519 while (*buf
&& isdigit(*buf
)) {
521 if (limit
>=(INT_MAX
-digit
)/10) break;
522 limit
=limit
*10+digit
;
525 } while (*buf
&& *buf
!=' ');
529 while (*buf
&& (unsigned char)*buf
<=' ') buf
++;
531 while (*buf
&& (unsigned char)*buf
>' ') buf
++;
533 for (i
=sizeof(output_types
)/sizeof(output_types
[0])-1 ; i
>=0 ; i
--)
534 if (strcasecmp(output_types
[i
].name
,str
)==0) {
535 output
=output_types
[i
].value
;
539 debuga(_("Invalid output type in per_user_limit\n"));
544 if (PerUserLimitsNumber
>=MAX_USER_LIMITS
) {
545 debuga(_("Too many per_user_limit\n"));
549 safe_strcpy(PerUserLimits
[PerUserLimitsNumber
].File
,file_begin
,sizeof(PerUserLimits
[PerUserLimitsNumber
].File
));
550 PerUserLimits
[PerUserLimitsNumber
].Limit
=limit
;
551 PerUserLimits
[PerUserLimitsNumber
].Output
=output
;
552 PerUserLimitsNumber
++;
557 static void parmtest(char *buf
)
560 struct getwordstruct gwarea
;
563 while (*buf
&& (unsigned char)*buf
<=' ') buf
++;
565 if(*buf
== '#' || *buf
== '\0')
569 printf(_("SARG: TAG: %s\n"),buf
);
571 if (getparam_string("background_color",buf
,BgColor
,sizeof(BgColor
))>0) return;
573 if (getparam_string("text_color",buf
,TxColor
,sizeof(TxColor
))>0) return;
575 if (getparam_string("text_bgcolor",buf
,TxBgColor
,sizeof(TxBgColor
))>0) return;
577 if (getparam_string("title_color",buf
,TiColor
,sizeof(TiColor
))>0) return;
579 if (getparam_string("logo_image",buf
,LogoImage
,sizeof(LogoImage
))>0) return;
581 if (getparam_quoted("logo_text",buf
,LogoText
,sizeof(LogoText
))>0) return;
583 if (getparam_string("logo_text_color",buf
,LogoTextColor
,sizeof(LogoTextColor
))>0) return;
585 if (getparam_string("background_image",buf
,BgImage
,sizeof(BgImage
))>0) return;
587 if (getparam_bool("show_sarg_info",buf
,&ShowSargInfo
)>0) return;
589 if (getparam_bool("show_sarg_logo",buf
,&ShowSargLogo
)>0) return;
591 if (getparam_string("font_face",buf
,FontFace
,sizeof(FontFace
))>0) return;
593 if (getparam_string("header_color",buf
,HeaderColor
,sizeof(HeaderColor
))>0) return;
595 if (getparam_string("header_bgcolor",buf
,HeaderBgColor
,sizeof(HeaderBgColor
))>0) return;
597 if (getparam_string("font_size",buf
,FontSize
,sizeof(FontSize
))>0) return;
599 if (getparam_string("header_font_size",buf
,HeaderFontSize
,sizeof(HeaderFontSize
))>0) return;
601 if (getparam_string("title_font_size",buf
,TitleFontSize
,sizeof(TitleFontSize
))>0) return;
603 if (getparam_2words("image_size",buf
,Width
,sizeof(Width
),Height
,sizeof(Height
))>0) return;
605 if (getparam_quoted("title",buf
,Title
,sizeof(Title
))>0) return;
607 if (strncasecmp(buf
,"resolve_ip",10)==0) {
608 if (ip2name_config(buf
+10)>0) return;
611 if (getparam_bool("user_ip",buf
,&UserIp
)>0) return;
613 if (getparam_string("max_elapsed",buf
,MaxElapsed
,sizeof(MaxElapsed
))>0) return;
615 if (is_param("date_format",buf
)) {
616 getword_start(&gwarea
,buf
);
617 if (getword_multisep(wbuf
,sizeof(wbuf
),&gwarea
,' ')<0) {
618 debuga(_("Maybe you have a broken record or garbage in \"date_format\" parameter\n"));
621 DateFormat
=gwarea
.current
[0];
625 if (is_param("hours",buf
)) {
626 if( getnumlist( buf
, &hours
, 24, 24 ) ) {
627 debuga(_("Error: Invalid syntax in hours tag!\n"));
633 if (is_param("weekdays",buf
)) {
634 if( getnumlist( buf
, &weekdays
, 7, 7 ) ) {
635 debuga(_("Error: Invalid syntax in weekdays tag!\n"));
641 if (getparam_sort("topuser_sort_field",SET_LIST(topuser_sort
),buf
,&TopuserSort
)>0) return;
643 if (getparam_sort("user_sort_field",SET_LIST(user_sort
),buf
,&UserSort
)>0) return;
645 if (is_param("access_log",buf
)>0) {
646 if (AccessLogFromCmdLine
==0) {
647 char *FileName
=getparam_stringptr("access_log",buf
);
649 AccessLog
=FileList_Create();
650 if (!FileList_AddFile(AccessLog
,FileName
)) {
651 debuga(_("Not enough memory to store the input log file names\n"));
658 if (is_param("redirector_log",buf
)>0) {
659 if (RedirectorLogFromCmdLine
==0) {
660 if (NRedirectorLogs
>=MAX_REDIRECTOR_LOGS
) {
661 debuga(_("Too many redirector log files in configuration file\n"));
664 getparam_string("redirector_log",buf
,RedirectorLogs
[NRedirectorLogs
],MAX_REDIRECTOR_FILELEN
);
670 if (getparam_string("useragent_log",buf
,UserAgentLog
,sizeof(UserAgentLog
))>0) return;
672 if (getparam_string("exclude_hosts",buf
,ExcludeHosts
,sizeof(ExcludeHosts
))>0) return;
674 if (getparam_string("exclude_codes",buf
,ExcludeCodes
,sizeof(ExcludeCodes
))>0) return;
676 if (getparam_string("exclude_users",buf
,ExcludeUsers
,sizeof(ExcludeUsers
))>0) return;
678 if (getparam_string("password",buf
,PasswdFile
,sizeof(PasswdFile
))>0) return;
680 if (getparam_string("temporary_dir",buf
,TempDir
,sizeof(TempDir
))>0) return;
682 if (getparam_list("report_type",SET_LIST(report_type_values
),buf
,&ReportType
)>0) return;
684 if (getparam_string("output_dir",buf
,OutputDir
,sizeof(OutputDir
))>0) return;
686 if (getparam_bool("anonymous_output_files",buf
,&AnonymousOutputFiles
)>0) return;
688 if (getparam_string("output_email",buf
,OutputEmail
,sizeof(OutputEmail
))>0) return;
690 if (getparam_userlimit("per_user_limit",buf
)>0) return;
692 if (getparam_select("per_user_limit_file_create",SET_LIST(per_user_limit_create_file
),buf
,&iVal
)>0) {
693 PerUserFileCreation
=(enum PerUserFileCreationEnum
)iVal
;
697 if (getparam_int("lastlog",buf
,&LastLog
)>0) return;
699 if (getparam_bool("remove_temp_files",buf
,&RemoveTempFiles
)>0) return;
701 if (getparam_string("replace_index",buf
,ReplaceIndex
,sizeof(ReplaceIndex
))>0) return;
703 if (getparam_list("index_tree",SET_LIST(index_tree_values
),buf
,&IndexTree
)>0) return;
705 if (getparam_list("index",SET_LIST(index_values
),buf
,&Index
)>0) return;
707 if (getparam_list("index_fields",SET_LIST(indexfields_values
),buf
,&IndexFields
)>0) return;
709 if (getparam_bool("overwrite_report",buf
,&OverwriteReport
)>0) return;
711 if (getparam_list("records_without_userid",SET_LIST(recnouser_values
),buf
,&RecordsWithoutUser
)>0) return;
713 if (getparam_bool("use_comma",buf
,&UseComma
)>0) return;
715 if (getparam_string("mail_utility",buf
,MailUtility
,sizeof(MailUtility
))>0) return;
717 if (getparam_int("topsites_num",buf
,&TopSitesNum
)>0) return;
719 if (getparam_int("topuser_num",buf
,&TopUsersNum
)>0) return;
721 if (getparam_string("usertab",buf
,UserTabFile
,sizeof(UserTabFile
))>0) return;
723 if (getparam_string("index_sort_order",buf
,IndexSortOrder
,sizeof(IndexSortOrder
))>0) return;
725 if (getparam_sort("topsites_sort_order",SET_LIST(topsite_sort
),buf
,&TopsitesSort
)>0) return;
727 if (getparam_bool("long_url",buf
,&LongUrl
)>0) return;
729 if (getparam_string("dansguardian_conf",buf
,DansGuardianConf
,sizeof(DansGuardianConf
))>0) return;
731 if (getparam_string("squidguard_conf",buf
,SquidGuardConf
,sizeof(SquidGuardConf
))>0) return;
733 if (getparam_list("date_time_by",SET_LIST(datetime_values
),buf
,&datetimeby
)>0) return;
735 if (getparam_string("charset",buf
,CharSet
,sizeof(CharSet
))>0) {
740 if (getparam_quoted("user_invalid_char",buf
,UserInvalidChar
,sizeof(UserInvalidChar
))>0) return;
742 if (getparam_quoted("include_users",buf
,IncludeUsers
+1,sizeof(IncludeUsers
)-2)>0) {
744 strcat(IncludeUsers
,":");
748 if (getparam_quoted("exclude_string",buf
,ExcludeString
,sizeof(ExcludeString
))>0) return;
750 if (getparam_bool("privacy",buf
,&Privacy
)>0) return;
752 if (getparam_quoted("privacy_string",buf
,PrivacyString
,sizeof(PrivacyString
))>0) return;
754 if (getparam_string("privacy_string_color",buf
,PrivacyStringColor
,sizeof(PrivacyStringColor
))>0) return;
756 if (getparam_bool("show_successful_message",buf
,&SuccessfulMsg
)>0) return;
758 if (getparam_bool("show_read_statistics",buf
,&ShowReadStatistics
)>0) return;
760 if (getparam_bool("show_read_percent",buf
,&ShowReadPercent
)>0) return;
762 if (getparam_list("topuser_fields",SET_LIST(topuserfields_values
),buf
,&TopUserFields
)>0) return;
764 if (getparam_bool("bytes_in_sites_users_report",buf
,&BytesInSitesUsersReport
)>0) return;
766 if (getparam_list("user_report_fields",SET_LIST(userreportfields_values
),buf
,&UserReportFields
)>0) return;
768 if (getparam_string("datafile",buf
,DataFile
,sizeof(DataFile
))>0) return;
770 if (getparam_quoted("datafile_delimiter",buf
,DataFileDelimiter
,sizeof(DataFileDelimiter
))>0) return;
772 if (getparam_list("datafile_fields",SET_LIST(data_field_values
),buf
,&DataFileFields
)>0) return;
774 if (getparam_list("datafile_url",SET_LIST(datafileurl_values
),buf
,&DataFileUrl
)>0) return;
776 if (getparam_string("parsed_output_log",buf
,ParsedOutputLog
,sizeof(ParsedOutputLog
))>0) return;
778 if (getparam_string("parsed_output_log_compress",buf
,ParsedOutputLogCompress
,sizeof(ParsedOutputLogCompress
))>0) return;
780 if (getparam_list("displayed_values",SET_LIST(displayvalue_values
),buf
,&DisplayedValues
)>0) return;
782 if (getparam_int("authfail_report_limit",buf
,&AuthfailReportLimit
)>0) return;
784 if (getparam_int("denied_report_limit",buf
,&DeniedReportLimit
)>0) return;
786 if (getparam_int("siteusers_report_limit",buf
,&SiteUsersReportLimit
)>0) return;
788 if (getparam_int("dansguardian_report_limit",buf
,&DansGuardianReportLimit
)>0) return;
790 if (getparam_int("squidguard_report_limit",buf
,&SquidGuardReportLimit
)>0) return;
792 if (getparam_int("user_report_limit",buf
,&UserReportLimit
)>0) return;
794 if (getparam_int("download_report_limit",buf
,&DownloadReportLimit
)>0) return;
796 if (getparam_string("www_document_root",buf
,wwwDocumentRoot
,sizeof(wwwDocumentRoot
))>0) return;
798 if (getparam_string("block_it",buf
,BlockIt
,sizeof(BlockIt
))>0) return;
800 if (getparam_string("external_css_file",buf
,ExternalCSSFile
,sizeof(ExternalCSSFile
))>0) return;
802 if (getparam_bool("user_authentication",buf
,&UserAuthentication
)>0) return;
804 if (getparam_string("AuthUserTemplateFile",buf
,wbuf
,sizeof(wbuf
))>0) {
807 if (is_absolute(wbuf
)) {
808 if (strlen(wbuf
)>=sizeof(AuthUserTemplateFile
)) {
809 debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
812 safe_strcpy(AuthUserTemplateFile
,wbuf
,sizeof(AuthUserTemplateFile
));
814 safe_strcpy(dir
,ConfigFile
,sizeof(dir
));
815 if (snprintf(AuthUserTemplateFile
,sizeof(AuthUserTemplateFile
),"%s/%s",dirname(dir
),wbuf
)>=sizeof(AuthUserTemplateFile
)) {
816 debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
823 if (is_param("download_suffix",buf
)) {
826 getparam_quoted("download_suffix",buf
,warea
,sizeof(warea
));
827 set_download_suffix(warea
);
831 if (getparam_bool("graphs",buf
,&Graphs
)>0) {
834 debugaz(_("No graphs available as sarg was not compiled with libgd. Set \"graphs\" to \"no\" in %s to disable this warning\n"),
840 if (getparam_string("graph_days_bytes_bar_color",buf
,GraphDaysBytesBarColor
,sizeof(GraphDaysBytesBarColor
))>0) return;
842 if (getparam_string("redirector_log_format",buf
,RedirectorLogFormat
,sizeof(RedirectorLogFormat
))>0) return;
843 if (getparam_string("squidguard_log_format",buf
,RedirectorLogFormat
,sizeof(RedirectorLogFormat
))>0) {
844 debuga(_("squidguard_log_format is deprecated and has been replaced by redirector_log_format. Please update your configuration file.\n"));
848 if (getparam_bool("redirector_filter_out_date",buf
,&RedirectorFilterOutDate
)>0) return;
849 if (getparam_bool("redirector_ignore_date",buf
,&RedirectorFilterOutDate
)>0) {
851 Due to an old bug in sarg before version 2.3, the option was having the opposite action than implied by the name.
853 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"));
854 RedirectorFilterOutDate
=!RedirectorFilterOutDate
;
857 if (getparam_bool("squidguard_ignore_date",buf
,&RedirectorFilterOutDate
)>0) {
858 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"));
859 RedirectorFilterOutDate
=!RedirectorFilterOutDate
;
863 if (getparam_bool("dansguardian_filter_out_date",buf
,&DansguardianFilterOutDate
)>0) return;
864 if (getparam_bool("dansguardian_ignore_date",buf
,&DansguardianFilterOutDate
)>0) {
865 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"));
866 DansguardianFilterOutDate
=!DansguardianFilterOutDate
;
870 if (getparam_string("ulimit",buf
,Ulimit
,sizeof(Ulimit
))>0) return;
872 if (getparam_list("ntlm_user_format",SET_LIST(ntml_userformat_values
),buf
,&NtlmUserFormat
)>0) return;
874 if (getparam_string("realtime_types",buf
,RealtimeTypes
,sizeof(RealtimeTypes
))>0) return;
876 if (getparam_list("realtime_unauthenticated_records",SET_LIST(realtime_unauth_values
),buf
,&RealtimeUnauthRec
)>0) return;
878 if (getparam_int("realtime_refresh_time",buf
,&realtime_refresh
)>0) return;
880 if (getparam_int("realtime_access_log_lines",buf
,&realtime_access_log_lines
)>0) return;
882 if (getparam_string("LDAPHost",buf
,LDAPHost
,sizeof(LDAPHost
))>0) return;
884 if (getparam_int("LDAPPort",buf
,&LDAPPort
)>0) return;
886 if (getparam_int("LDAPProtocolVersion",buf
,&LDAPProtocolVersion
)>0) return;
888 if (getparam_string("LDAPBindDN",buf
,LDAPBindDN
,sizeof(LDAPBindDN
))>0) return;
890 if (getparam_string("LDAPBindPW",buf
,LDAPBindPW
,sizeof(LDAPBindPW
))>0) return;
892 if (getparam_string("LDAPBaseSearch",buf
,LDAPBaseSearch
,sizeof(LDAPBaseSearch
))>0) return;
894 if (getparam_string("LDAPFilterSearch",buf
,LDAPFilterSearch
,sizeof(LDAPFilterSearch
))>0) return;
896 if (getparam_string("LDAPTargetAttr",buf
,LDAPTargetAttr
,sizeof(LDAPTargetAttr
))>0) return;
898 if (getparam_string("LDAPNativeCharset",buf
,LDAPNativeCharset
,sizeof(LDAPNativeCharset
))>0) return;
900 if (getparam_string("graph_font",buf
,GraphFont
,sizeof(GraphFont
))>0) return;
902 if (getparam_string("sorttable",buf
,SortTableJs
,sizeof(SortTableJs
))>0) return;
904 if (getparam_string("hostalias",buf
,HostAliasFile
,sizeof(HostAliasFile
))>0) return;
906 if (getparam_string("useralias",buf
,UserAliasFile
,sizeof(UserAliasFile
))>0) return;
908 if (getparam_bool("keep_temp_log",buf
,&KeepTempLog
)>0) return;
910 if (getparam_int("max_successive_log_errors",buf
,&NumLogSuccessiveErrors
)>0) return;
912 if (getparam_int("max_total_log_errors",buf
,&NumLogTotalErrors
)>0) return;
914 if(strstr(buf
,"squid24") != 0) {
919 if(strstr(buf
,"byte_cost") != 0) {
920 getword_start(&gwarea
,buf
);
921 if (getword_multisep(wbuf
,sizeof(wbuf
),&gwarea
,' ')<0) {
922 debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n"));
925 cost
=atol(gwarea
.current
);
926 if (getword_multisep(wbuf
,sizeof(wbuf
),&gwarea
,' ')<0) {
927 debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n"));
930 nocost
=my_atoll(gwarea
.current
);
934 printf(_("SARG: Unknown option %s\n"),buf
);
943 debuga(_("Loading configuration from %s\n"),ConfigFile
);
945 if ((fp_in
= fopen(ConfigFile
, "r")) == NULL
) {
946 debuga(_("(getconf) Cannot open file %s\n"),ConfigFile
);
950 while (fgets(buf
, sizeof(buf
), fp_in
) != NULL
) {
954 printf("SYSCONFDIR %s\n",buf
);