]>
Commit | Line | Data |
---|---|---|
b3695c67 | 1 | #include "config.h" |
25697a35 | 2 | #include "info.h" |
e3af0ae9 | 3 | #include "btree_cache.h" |
25697a35 | 4 | |
b3695c67 FM |
5 | #ifdef HAVE_WINDOWS_H |
6 | #include <windows.h> | |
7 | #endif | |
8 | #ifdef HAVE_STDIO_H | |
25697a35 GS |
9 | #include <stdio.h> |
10 | #endif | |
b3695c67 | 11 | #ifdef HAVE_STDLIB_H |
25697a35 GS |
12 | #include <stdlib.h> |
13 | #endif | |
b3695c67 | 14 | #ifdef HAVE_STRING_H |
25697a35 GS |
15 | #include <string.h> |
16 | #endif | |
b3695c67 | 17 | #ifdef HAVE_STRINGS_H |
25697a35 GS |
18 | #include <strings.h> |
19 | #endif | |
b3695c67 | 20 | #ifdef HAVE_SYS_TIME_H |
25697a35 GS |
21 | #include <sys/time.h> |
22 | #endif | |
b3695c67 | 23 | #ifdef HAVE_TIME_H |
25697a35 GS |
24 | #include <time.h> |
25 | #endif | |
b3695c67 | 26 | #ifdef HAVE_SYS_RESOURCE_H |
25697a35 GS |
27 | #include <sys/resource.h> |
28 | #endif | |
b3695c67 | 29 | #ifdef HAVE_UNISTD_H |
25697a35 GS |
30 | #include <unistd.h> |
31 | #endif | |
b3695c67 | 32 | #if defined(HAVE_SYS_DIRENT_H) && !defined(HAVE_DIRENT_H) |
25697a35 GS |
33 | #include <sys/dirent.h> |
34 | #endif | |
b3695c67 | 35 | #ifdef HAVE_DIRENT_H |
25697a35 GS |
36 | #include <dirent.h> |
37 | #endif | |
b3695c67 | 38 | #ifdef HAVE_SYS_SOCKET_H |
25697a35 GS |
39 | #include <sys/socket.h> |
40 | #endif | |
b3695c67 | 41 | #ifdef HAVE_NETDB_H |
25697a35 GS |
42 | #include <netdb.h> |
43 | #endif | |
b3695c67 | 44 | #ifdef HAVE_TYPES_H |
25697a35 GS |
45 | #include <types.h> |
46 | #endif | |
b3695c67 | 47 | #ifdef HAVE_NETINET_IN_H |
25697a35 GS |
48 | #include <netinet/in.h> |
49 | #endif | |
b3695c67 | 50 | #ifdef HAVE_ARPA_INET_H |
25697a35 GS |
51 | #include <arpa/inet.h> |
52 | #endif | |
b3695c67 | 53 | #ifdef HAVE_SYS_STAT_H |
25697a35 GS |
54 | #include <sys/stat.h> |
55 | #endif | |
b3695c67 | 56 | #ifdef HAVE_CTYPE_H |
25697a35 GS |
57 | #include <ctype.h> |
58 | #endif | |
b3695c67 | 59 | #ifdef HAVE_ERRNO_H |
25697a35 GS |
60 | #include <errno.h> |
61 | #endif | |
b3695c67 | 62 | #ifdef HAVE_SYS_WAIT_H |
d96e3ba6 FM |
63 | #include <sys/wait.h> |
64 | #endif | |
b3695c67 | 65 | #ifdef HAVE_GD_H |
2824ec9b | 66 | #define HAVE_GD 1 |
25697a35 | 67 | #include <gd.h> |
25697a35 GS |
68 | gdImagePtr im; |
69 | gdPoint points[4]; | |
70 | #endif | |
b3695c67 | 71 | #ifdef HAVE_GDFONTL_H |
25697a35 GS |
72 | #include <gdfontl.h> |
73 | #endif | |
b3695c67 | 74 | #ifdef HAVE_GDFONTT_H |
25697a35 GS |
75 | #include <gdfontt.h> |
76 | #endif | |
b3695c67 | 77 | #ifdef HAVE_GDFONTS_H |
25697a35 GS |
78 | #include <gdfonts.h> |
79 | #endif | |
b3695c67 | 80 | #ifdef HAVE_GDFONTMB_H |
25697a35 GS |
81 | #include <gdfontmb.h> |
82 | #endif | |
b3695c67 | 83 | #ifdef HAVE_GDFONTG_H |
25697a35 GS |
84 | #include <gdfontg.h> |
85 | #endif | |
b3695c67 | 86 | #ifdef HAVE_STDARG_H |
d2fe0c32 FM |
87 | #include <stdarg.h> |
88 | #endif | |
b3695c67 | 89 | #ifdef HAVE_INTTYPES_H |
2357ef77 FM |
90 | #include <inttypes.h> |
91 | #endif | |
b3695c67 | 92 | #ifdef HAVE_LIMITS_H |
4af2f8ff FM |
93 | #include <limits.h> |
94 | #endif | |
b3695c67 FM |
95 | #ifdef HAVE_WINSOCK_H |
96 | #include <winsock.h> | |
97 | #endif | |
e3af0ae9 PO |
98 | #ifdef HAVE_MATH_H |
99 | #include <math.h> | |
100 | #endif | |
a1de61fe FM |
101 | #ifdef HAVE_LOCALE_H |
102 | #include <locale.h> | |
103 | #endif | |
e6414a9d FM |
104 | #ifdef HAVE_EXECINFO_H |
105 | #include <execinfo.h> | |
106 | #endif | |
d5d021c5 FM |
107 | #ifdef HAVE_LIBGEN_H |
108 | #include <libgen.h> | |
109 | #endif | |
06b39c87 FM |
110 | #ifdef HAVE_STDBOOL_H |
111 | #include <stdbool.h> | |
112 | #else | |
113 | typedef int bool; | |
114 | #define true 1 | |
115 | #define false 0 | |
116 | #endif | |
25697a35 | 117 | |
b3695c67 | 118 | #if defined(HAVE_FOPEN64) |
25697a35 | 119 | #define _FILE_OFFSET_BITS 64 |
936c9905 | 120 | #define MY_FOPEN fopen64 |
25697a35 GS |
121 | #else |
122 | #define MY_FOPEN fopen | |
123 | #endif | |
124 | ||
b3695c67 FM |
125 | #if !defined(HAVE_BZERO) |
126 | #define bzero(mem,size) memset(mem,0,size) | |
127 | #endif | |
128 | ||
129 | #if defined(IBERTY_LIB) && !defined(HAVE_MKSTEMP) | |
130 | int mkstemps(char *template, int suffixlen); | |
131 | #define mkstemp(template) mkstemps(template,0) | |
132 | #endif | |
133 | ||
eca2cec9 | 134 | #if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H) |
c0ec9cc7 FM |
135 | #include <libintl.h> |
136 | #define _(String) gettext(String) | |
137 | #ifdef gettext_noop | |
138 | #define N_(String) gettext_noop(String) | |
139 | #else | |
140 | #define N_(String) (String) | |
141 | #endif | |
142 | #else /* No NLS */ | |
143 | #define _(String) (String) | |
144 | #define N_(String) (String) | |
06b39c87 | 145 | #define ngettext(String,Strings,num) (Strings) |
c0ec9cc7 FM |
146 | #define textdomain(String) |
147 | #define bindtextdomain(Domain,Directory) | |
eca2cec9 | 148 | #endif //NLS |
c0ec9cc7 | 149 | |
b3695c67 FM |
150 | #if defined(__MINGW32__) |
151 | #define mkdir(p,m) _mkdir(p) | |
152 | ||
153 | #ifndef WIFEXITED | |
154 | #define WIFEXITED(S) 1 | |
155 | #endif | |
156 | ||
157 | #ifndef WEXITSTATUS | |
158 | #define WEXITSTATUS(S) (S) | |
159 | #endif | |
160 | ||
161 | #endif /*__MINGW32__*/ | |
25697a35 | 162 | |
f0126186 FM |
163 | #ifndef __GNUC__ |
164 | # define __attribute__(x) | |
165 | #endif | |
166 | ||
25697a35 | 167 | #define MAXLEN 20000 |
ac422f9b | 168 | #define MAX_URL_LEN 40000 |
e5b2c6f0 | 169 | #define MAX_TRUNCATED_URL 512 |
f2ec8c75 FM |
170 | #define MAX_USER_LEN 256 |
171 | #define MAX_USER_FNAME_LEN 128 | |
2240dcea FM |
172 | #define MAX_IP_LEN 64 |
173 | #define MAX_DATETIME_LEN 32 | |
0a4e18e1 | 174 | #define MAXLOGS 255 |
25697a35 | 175 | |
085c1e1f FM |
176 | #define REPORT_TYPE_USERS_SITES 0x0001UL |
177 | #define REPORT_TYPE_SITE_USER_TIME_DATE 0x0002UL | |
178 | #define REPORT_TYPE_TOPUSERS 0x0004UL | |
179 | #define REPORT_TYPE_TOPSITES 0x0008UL | |
180 | #define REPORT_TYPE_SITES_USERS 0x0010UL | |
181 | #define REPORT_TYPE_DATE_TIME 0x0020UL | |
182 | #define REPORT_TYPE_DENIED 0x0040UL | |
183 | #define REPORT_TYPE_AUTH_FAILURES 0x0080UL | |
184 | #define REPORT_TYPE_DOWNLOADS 0x0100UL | |
185 | ||
186 | #define DATA_FIELD_USER 0x0001UL | |
187 | #define DATA_FIELD_DATE 0x0002UL | |
188 | #define DATA_FIELD_TIME 0x0004UL | |
189 | #define DATA_FIELD_URL 0x0008UL | |
190 | #define DATA_FIELD_CONNECT 0x0010UL | |
191 | #define DATA_FIELD_BYTES 0x0020UL | |
192 | #define DATA_FIELD_IN_CACHE 0x0040UL | |
193 | #define DATA_FIELD_OUT_CACHE 0x0080UL | |
194 | #define DATA_FIELD_ELAPSED 0x0100UL | |
195 | ||
196 | #define TOPUSERFIELDS_NUM 0x0001UL | |
197 | #define TOPUSERFIELDS_DATE_TIME 0x0002UL | |
198 | #define TOPUSERFIELDS_USERID 0x0004UL | |
199 | #define TOPUSERFIELDS_CONNECT 0x0008UL | |
200 | #define TOPUSERFIELDS_BYTES 0x0010UL | |
201 | #define TOPUSERFIELDS_SETYB 0x0020UL | |
202 | #define TOPUSERFIELDS_IN_CACHE_OUT 0x0040UL | |
203 | #define TOPUSERFIELDS_USED_TIME 0x0080UL | |
204 | #define TOPUSERFIELDS_MILISEC 0x0100UL | |
205 | #define TOPUSERFIELDS_PTIME 0x0200UL | |
206 | #define TOPUSERFIELDS_TOTAL 0x0400UL | |
207 | #define TOPUSERFIELDS_AVERAGE 0x0800UL | |
208 | ||
209 | #define USERREPORTFIELDS_CONNECT 0x0001UL | |
210 | #define USERREPORTFIELDS_BYTES 0x0002UL | |
211 | #define USERREPORTFIELDS_SETYB 0x0004UL | |
212 | #define USERREPORTFIELDS_IN_CACHE_OUT 0x0008UL | |
213 | #define USERREPORTFIELDS_USED_TIME 0x0010UL | |
214 | #define USERREPORTFIELDS_MILISEC 0x0020UL | |
215 | #define USERREPORTFIELDS_PTIME 0x0040UL | |
216 | #define USERREPORTFIELDS_TOTAL 0x0080UL | |
217 | #define USERREPORTFIELDS_AVERAGE 0x0100UL | |
218 | ||
0349fa24 FM |
219 | #define INDEX_YES 0x0001UL |
220 | #define INDEX_NO 0x0002UL | |
221 | #define INDEX_ONLY 0x0004UL | |
222 | ||
223 | #define INDEX_TREE_DATE 0x0001UL | |
224 | #define INDEX_TREE_FILE 0x0002UL | |
225 | ||
f2ec8c75 FM |
226 | #define NTLMUSERFORMAT_USER 0x0001UL |
227 | #define NTLMUSERFORMAT_DOMAINUSER 0x0002UL | |
228 | ||
229 | #define RECORDWITHOUTUSER_IP 0x0001UL | |
230 | #define RECORDWITHOUTUSER_IGNORE 0x0002UL | |
231 | #define RECORDWITHOUTUSER_EVERYBODY 0x0004UL | |
232 | ||
f84a35a3 FM |
233 | #define DATAFILEURL_IP 0x0001UL |
234 | #define DATAFILEURL_NAME 0x0002UL | |
235 | ||
25697a35 | 236 | char outdir[MAXLEN]; |
d5d021c5 | 237 | char outdirname[MAXLEN]; |
d6e703cc | 238 | char period[MAXLEN]; |
d6e703cc FM |
239 | char code[MAXLEN]; |
240 | char code2[MAXLEN]; | |
25697a35 | 241 | char tmp[MAXLEN]; |
25697a35 GS |
242 | char parse_out[MAXLEN]; |
243 | char arqtt[MAXLEN]; | |
244 | char html[MAXLEN]; | |
25697a35 | 245 | char ConfigFile[MAXLEN]; |
25697a35 | 246 | char df[20]; |
25697a35 GS |
247 | char cdfrom[30]; |
248 | char cduntil[30]; | |
0511cf2d | 249 | int LastLog; |
06b39c87 | 250 | bool RemoveTempFiles; |
25697a35 | 251 | char ReplaceIndex[256]; |
0349fa24 | 252 | unsigned long int Index; |
06b39c87 | 253 | bool OverwriteReport; |
f2ec8c75 | 254 | unsigned long int RecordsWithoutUser; |
06b39c87 | 255 | bool UseComma; |
4af2f8ff | 256 | char MailUtility[PATH_MAX]; |
c0ec9cc7 | 257 | int TopSitesNum; |
fb7c5f27 | 258 | int TopUsersNum; |
25697a35 GS |
259 | char ExcludeCodes[256]; |
260 | char TopsitesSortField[15]; | |
491b862f | 261 | char TopsitesSortType[20]; |
085c1e1f | 262 | unsigned long int ReportType; |
25697a35 GS |
263 | char UserTabFile[255]; |
264 | char warea[MAXLEN]; | |
265 | char name[MAXLEN]; | |
06b39c87 FM |
266 | bool LongUrl; |
267 | bool Ip2Name; | |
0a4e18e1 FM |
268 | int NAccessLog; |
269 | char AccessLog[MAXLOGS][MAXLEN]; | |
270 | int AccessLogFromCmdLine; | |
25697a35 GS |
271 | char Title[MAXLEN]; |
272 | char BgColor[MAXLEN]; | |
273 | char BgImage[MAXLEN]; | |
274 | char TxColor[MAXLEN]; | |
275 | char TxBgColor[MAXLEN]; | |
276 | char TiColor[MAXLEN]; | |
277 | char LogoImage[MAXLEN]; | |
278 | char LogoText[MAXLEN]; | |
279 | char LogoTextColor[MAXLEN]; | |
280 | char Width[MAXLEN]; | |
281 | char Height[MAXLEN]; | |
282 | char FontFace[MAXLEN]; | |
283 | char HeaderColor[MAXLEN]; | |
284 | char HeaderBgColor[MAXLEN]; | |
285 | char FontSize[MAXLEN]; | |
286 | char PasswdFile[MAXLEN]; | |
287 | char TempDir[MAXLEN]; | |
288 | char OutputDir[MAXLEN]; | |
289 | char OutputEmail[MAXLEN]; | |
290 | char TopuserSortField[30]; | |
291 | char UserSortField[30]; | |
292 | char TopuserSortOrder[10]; | |
293 | char UserSortOrder[10]; | |
294 | char UserAgentLog[255]; | |
295 | char module[255]; | |
296 | char ExcludeHosts[255]; | |
297 | char ExcludeUsers[255]; | |
298 | char DateFormat[2]; | |
299 | char PerUserLimitFile[255]; | |
e6414a9d | 300 | int PerUserLimit; |
06b39c87 | 301 | bool UserIp; |
25697a35 GS |
302 | char MaxElapsed[255]; |
303 | char datetimeby[10]; | |
25697a35 GS |
304 | char CharSet[255]; |
305 | char UserInvalidChar[255]; | |
06b39c87 | 306 | bool Graphs; |
25697a35 | 307 | char GraphDaysBytesBarColor[255]; |
06b39c87 | 308 | bool Privacy; |
25697a35 GS |
309 | char PrivacyString[255]; |
310 | char PrivacyStringColor[30]; | |
311 | char IncludeUsers[MAXLEN]; | |
312 | char ExcludeString[MAXLEN]; | |
06b39c87 | 313 | bool SuccessfulMsg; |
085c1e1f FM |
314 | unsigned long int TopUserFields; |
315 | unsigned long int UserReportFields; | |
25697a35 GS |
316 | char DataFile[MAXLEN]; |
317 | char DataFileDelimiter[3]; | |
085c1e1f | 318 | unsigned long int DataFileFields; |
f84a35a3 | 319 | unsigned long int DataFileUrl; |
06b39c87 | 320 | bool ShowReadStatistics; |
25697a35 GS |
321 | char IndexSortOrder[5]; |
322 | char DansGuardianConf[MAXLEN]; | |
06b39c87 | 323 | bool DansguardianIgnoreDate; |
25697a35 GS |
324 | char SquidGuardConf[MAXLEN]; |
325 | char SquidGuarddbHome[255]; | |
326 | char SquidGuardLogFormat[MAXLEN]; | |
491b862f | 327 | char SquidGuardLogAlternate[MAXLEN]; |
06b39c87 FM |
328 | bool SquidguardIgnoreDate; |
329 | bool ShowSargInfo; | |
330 | bool BytesInSitesUsersReport; | |
331 | bool ShowSargLogo; | |
25697a35 | 332 | char ParsedOutputLog[MAXLEN]; |
ff8d5836 | 333 | char ParsedOutputLogCompress[512]; |
25697a35 | 334 | char DisplayedValues[20]; |
933aca19 | 335 | char HeaderFontSize[5]; |
491b862f | 336 | char TitleFontSize[5]; |
25697a35 GS |
337 | char wwwDocumentRoot[MAXLEN]; |
338 | char ExternalCSSFile[MAXLEN]; | |
339 | char BlockIt[255]; | |
f2ec8c75 | 340 | unsigned long int NtlmUserFormat; |
0349fa24 | 341 | unsigned long int IndexTree; |
06b39c87 | 342 | bool UserAuthentication; |
d5d021c5 | 343 | char AuthUserTemplateFile[1024]; |
25697a35 GS |
344 | char val1[MAXLEN]; |
345 | char val2[MAXLEN]; | |
346 | char val3[MAXLEN]; | |
347 | char val4[MAXLEN]; | |
348 | char val5[MAXLEN]; | |
349 | char val6[MAXLEN]; | |
350 | char val7[MAXLEN]; | |
351 | char val8[MAXLEN]; | |
352 | char val9[MAXLEN]; | |
353 | char val10[MAXLEN]; | |
354 | char val11[MAXLEN]; | |
355 | char wwork1[MAXLEN]; | |
356 | char wwork2[MAXLEN]; | |
357 | char wwork3[MAXLEN]; | |
25697a35 | 358 | char mask[MAXLEN]; |
25697a35 GS |
359 | char site[MAXLEN]; |
360 | char us[50]; | |
361 | char email[MAXLEN]; | |
362 | char test[1]; | |
25697a35 GS |
363 | char user2[MAXLEN]; |
364 | char wentp[512]; | |
365 | char addr[MAXLEN]; | |
491b862f GS |
366 | char Ulimit[6]; |
367 | char RealtimeTypes[1024]; | |
25697a35 | 368 | char cmd[255]; |
491b862f | 369 | char ImageFile[255]; |
491b862f | 370 | char RealtimeUnauthRec[15]; |
e3af0ae9 PO |
371 | char LDAPHost[255]; |
372 | char LDAPBindDN[512]; | |
373 | char LDAPBindPW[255]; | |
965c4a6f FM |
374 | int LDAPPort; |
375 | int LDAPProtocolVersion; | |
e3af0ae9 PO |
376 | char LDAPBaseSearch[255]; |
377 | char LDAPFilterSearch[512]; | |
378 | char LDAPTargetAttr[64]; | |
3becf85c | 379 | char GraphFont[MAXLEN]; |
491b862f | 380 | |
25697a35 GS |
381 | int idate; |
382 | int smartfilter; | |
383 | int denied_count; | |
384 | int download_count; | |
385 | int authfail_count; | |
386 | int dansguardian_count; | |
387 | int squidguard_count; | |
c0ec9cc7 | 388 | int useragent_count; |
25697a35 GS |
389 | int limit_flag; |
390 | int color1; | |
391 | int color2; | |
392 | int color3; | |
393 | int z1, z2, z3; | |
394 | int ttopen; | |
25697a35 GS |
395 | int sarglog; |
396 | int isalog; | |
2357ef77 | 397 | int dfrom; |
25697a35 GS |
398 | int duntil; |
399 | int dataonly; | |
400 | int indexonly; | |
2824ec9b FM |
401 | bool iprel; |
402 | bool userip; | |
25697a35 GS |
403 | int langcode; |
404 | int debug; | |
405 | int debugz; | |
406 | int debugm; | |
407 | int AuthfailReportLimit; | |
408 | int DeniedReportLimit; | |
94ff9470 | 409 | int DownloadReportLimit; |
25697a35 GS |
410 | int SiteUsersReportLimit; |
411 | int DansGuardianReportLimit; | |
412 | int SquidGuardReportLimit; | |
413 | int UserReportLimit; | |
491b862f GS |
414 | int realtime_refresh; |
415 | int realtime_access_log_lines; | |
491b862f | 416 | int rc; |
d6e703cc FM |
417 | int ntopsites; |
418 | int nsitesusers; | |
419 | int nrepday; | |
420 | int ndownload; | |
421 | int ntopuser; | |
2824ec9b | 422 | bool squid24; |
25697a35 | 423 | |
491b862f GS |
424 | long long int nocost; |
425 | float cost; | |
25697a35 GS |
426 | |
427 | typedef struct | |
428 | { int list[ 24 ]; | |
429 | int len; | |
430 | } numlist; | |
431 | ||
432 | DIR *dirp; | |
433 | struct dirent *direntp; |