]>
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 |
25697a35 GS |
66 | #include <gd.h> |
67 | #define HAVE_GD | |
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 | |
25697a35 | 110 | |
b3695c67 | 111 | #if defined(HAVE_FOPEN64) |
25697a35 | 112 | #define _FILE_OFFSET_BITS 64 |
936c9905 | 113 | #define MY_FOPEN fopen64 |
25697a35 GS |
114 | #else |
115 | #define MY_FOPEN fopen | |
116 | #endif | |
117 | ||
b3695c67 FM |
118 | #if !defined(HAVE_BZERO) |
119 | #define bzero(mem,size) memset(mem,0,size) | |
120 | #endif | |
121 | ||
122 | #if defined(IBERTY_LIB) && !defined(HAVE_MKSTEMP) | |
123 | int mkstemps(char *template, int suffixlen); | |
124 | #define mkstemp(template) mkstemps(template,0) | |
125 | #endif | |
126 | ||
eca2cec9 | 127 | #if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H) |
c0ec9cc7 FM |
128 | #include <libintl.h> |
129 | #define _(String) gettext(String) | |
130 | #ifdef gettext_noop | |
131 | #define N_(String) gettext_noop(String) | |
132 | #else | |
133 | #define N_(String) (String) | |
134 | #endif | |
135 | #else /* No NLS */ | |
136 | #define _(String) (String) | |
137 | #define N_(String) (String) | |
138 | #define textdomain(String) | |
139 | #define bindtextdomain(Domain,Directory) | |
eca2cec9 | 140 | #endif //NLS |
c0ec9cc7 | 141 | |
b3695c67 FM |
142 | #if defined(__MINGW32__) |
143 | #define mkdir(p,m) _mkdir(p) | |
144 | ||
145 | #ifndef WIFEXITED | |
146 | #define WIFEXITED(S) 1 | |
147 | #endif | |
148 | ||
149 | #ifndef WEXITSTATUS | |
150 | #define WEXITSTATUS(S) (S) | |
151 | #endif | |
152 | ||
153 | #endif /*__MINGW32__*/ | |
25697a35 GS |
154 | |
155 | #define MAXLEN 20000 | |
ac422f9b | 156 | #define MAX_URL_LEN 40000 |
e5b2c6f0 | 157 | #define MAX_TRUNCATED_URL 512 |
f2ec8c75 FM |
158 | #define MAX_USER_LEN 256 |
159 | #define MAX_USER_FNAME_LEN 128 | |
2240dcea FM |
160 | #define MAX_IP_LEN 64 |
161 | #define MAX_DATETIME_LEN 32 | |
0a4e18e1 | 162 | #define MAXLOGS 255 |
25697a35 | 163 | |
085c1e1f FM |
164 | #define REPORT_TYPE_USERS_SITES 0x0001UL |
165 | #define REPORT_TYPE_SITE_USER_TIME_DATE 0x0002UL | |
166 | #define REPORT_TYPE_TOPUSERS 0x0004UL | |
167 | #define REPORT_TYPE_TOPSITES 0x0008UL | |
168 | #define REPORT_TYPE_SITES_USERS 0x0010UL | |
169 | #define REPORT_TYPE_DATE_TIME 0x0020UL | |
170 | #define REPORT_TYPE_DENIED 0x0040UL | |
171 | #define REPORT_TYPE_AUTH_FAILURES 0x0080UL | |
172 | #define REPORT_TYPE_DOWNLOADS 0x0100UL | |
173 | ||
174 | #define DATA_FIELD_USER 0x0001UL | |
175 | #define DATA_FIELD_DATE 0x0002UL | |
176 | #define DATA_FIELD_TIME 0x0004UL | |
177 | #define DATA_FIELD_URL 0x0008UL | |
178 | #define DATA_FIELD_CONNECT 0x0010UL | |
179 | #define DATA_FIELD_BYTES 0x0020UL | |
180 | #define DATA_FIELD_IN_CACHE 0x0040UL | |
181 | #define DATA_FIELD_OUT_CACHE 0x0080UL | |
182 | #define DATA_FIELD_ELAPSED 0x0100UL | |
183 | ||
184 | #define TOPUSERFIELDS_NUM 0x0001UL | |
185 | #define TOPUSERFIELDS_DATE_TIME 0x0002UL | |
186 | #define TOPUSERFIELDS_USERID 0x0004UL | |
187 | #define TOPUSERFIELDS_CONNECT 0x0008UL | |
188 | #define TOPUSERFIELDS_BYTES 0x0010UL | |
189 | #define TOPUSERFIELDS_SETYB 0x0020UL | |
190 | #define TOPUSERFIELDS_IN_CACHE_OUT 0x0040UL | |
191 | #define TOPUSERFIELDS_USED_TIME 0x0080UL | |
192 | #define TOPUSERFIELDS_MILISEC 0x0100UL | |
193 | #define TOPUSERFIELDS_PTIME 0x0200UL | |
194 | #define TOPUSERFIELDS_TOTAL 0x0400UL | |
195 | #define TOPUSERFIELDS_AVERAGE 0x0800UL | |
196 | ||
197 | #define USERREPORTFIELDS_CONNECT 0x0001UL | |
198 | #define USERREPORTFIELDS_BYTES 0x0002UL | |
199 | #define USERREPORTFIELDS_SETYB 0x0004UL | |
200 | #define USERREPORTFIELDS_IN_CACHE_OUT 0x0008UL | |
201 | #define USERREPORTFIELDS_USED_TIME 0x0010UL | |
202 | #define USERREPORTFIELDS_MILISEC 0x0020UL | |
203 | #define USERREPORTFIELDS_PTIME 0x0040UL | |
204 | #define USERREPORTFIELDS_TOTAL 0x0080UL | |
205 | #define USERREPORTFIELDS_AVERAGE 0x0100UL | |
206 | ||
0349fa24 FM |
207 | #define INDEX_YES 0x0001UL |
208 | #define INDEX_NO 0x0002UL | |
209 | #define INDEX_ONLY 0x0004UL | |
210 | ||
211 | #define INDEX_TREE_DATE 0x0001UL | |
212 | #define INDEX_TREE_FILE 0x0002UL | |
213 | ||
f2ec8c75 FM |
214 | #define NTLMUSERFORMAT_USER 0x0001UL |
215 | #define NTLMUSERFORMAT_DOMAINUSER 0x0002UL | |
216 | ||
217 | #define RECORDWITHOUTUSER_IP 0x0001UL | |
218 | #define RECORDWITHOUTUSER_IGNORE 0x0002UL | |
219 | #define RECORDWITHOUTUSER_EVERYBODY 0x0004UL | |
220 | ||
f84a35a3 FM |
221 | #define DATAFILEURL_IP 0x0001UL |
222 | #define DATAFILEURL_NAME 0x0002UL | |
223 | ||
25697a35 | 224 | char outdir[MAXLEN]; |
d5d021c5 | 225 | char outdirname[MAXLEN]; |
25697a35 | 226 | char buf[MAXLEN]; |
d6e703cc | 227 | char period[MAXLEN]; |
d6e703cc FM |
228 | char code[MAXLEN]; |
229 | char code2[MAXLEN]; | |
25697a35 | 230 | char tmp[MAXLEN]; |
25697a35 GS |
231 | char parse_out[MAXLEN]; |
232 | char arqtt[MAXLEN]; | |
233 | char html[MAXLEN]; | |
25697a35 | 234 | char ConfigFile[MAXLEN]; |
25697a35 | 235 | char df[20]; |
25697a35 GS |
236 | char cdfrom[30]; |
237 | char cduntil[30]; | |
0511cf2d | 238 | int LastLog; |
e6414a9d | 239 | int RemoveTempFiles; |
25697a35 | 240 | char ReplaceIndex[256]; |
0349fa24 | 241 | unsigned long int Index; |
e6414a9d | 242 | int OverwriteReport; |
f2ec8c75 | 243 | unsigned long int RecordsWithoutUser; |
e6414a9d | 244 | int UseComma; |
4af2f8ff | 245 | char MailUtility[PATH_MAX]; |
c0ec9cc7 | 246 | int TopSitesNum; |
fb7c5f27 | 247 | int TopUsersNum; |
25697a35 GS |
248 | char ExcludeCodes[256]; |
249 | char TopsitesSortField[15]; | |
491b862f | 250 | char TopsitesSortType[20]; |
085c1e1f | 251 | unsigned long int ReportType; |
25697a35 GS |
252 | char UserTabFile[255]; |
253 | char warea[MAXLEN]; | |
254 | char name[MAXLEN]; | |
246c8489 FM |
255 | int LongUrl; |
256 | int Ip2Name; | |
0a4e18e1 FM |
257 | int NAccessLog; |
258 | char AccessLog[MAXLOGS][MAXLEN]; | |
259 | int AccessLogFromCmdLine; | |
25697a35 GS |
260 | char Title[MAXLEN]; |
261 | char BgColor[MAXLEN]; | |
262 | char BgImage[MAXLEN]; | |
263 | char TxColor[MAXLEN]; | |
264 | char TxBgColor[MAXLEN]; | |
265 | char TiColor[MAXLEN]; | |
266 | char LogoImage[MAXLEN]; | |
267 | char LogoText[MAXLEN]; | |
268 | char LogoTextColor[MAXLEN]; | |
269 | char Width[MAXLEN]; | |
270 | char Height[MAXLEN]; | |
271 | char FontFace[MAXLEN]; | |
272 | char HeaderColor[MAXLEN]; | |
273 | char HeaderBgColor[MAXLEN]; | |
274 | char FontSize[MAXLEN]; | |
275 | char PasswdFile[MAXLEN]; | |
276 | char TempDir[MAXLEN]; | |
277 | char OutputDir[MAXLEN]; | |
278 | char OutputEmail[MAXLEN]; | |
279 | char TopuserSortField[30]; | |
280 | char UserSortField[30]; | |
281 | char TopuserSortOrder[10]; | |
282 | char UserSortOrder[10]; | |
283 | char UserAgentLog[255]; | |
284 | char module[255]; | |
285 | char ExcludeHosts[255]; | |
286 | char ExcludeUsers[255]; | |
287 | char DateFormat[2]; | |
288 | char PerUserLimitFile[255]; | |
e6414a9d | 289 | int PerUserLimit; |
246c8489 | 290 | int UserIp; |
25697a35 GS |
291 | char MaxElapsed[255]; |
292 | char datetimeby[10]; | |
25697a35 GS |
293 | char CharSet[255]; |
294 | char UserInvalidChar[255]; | |
e6414a9d | 295 | int Graphs; |
25697a35 | 296 | char GraphDaysBytesBarColor[255]; |
e6414a9d | 297 | int Privacy; |
25697a35 GS |
298 | char PrivacyString[255]; |
299 | char PrivacyStringColor[30]; | |
300 | char IncludeUsers[MAXLEN]; | |
301 | char ExcludeString[MAXLEN]; | |
e6414a9d | 302 | int SuccessfulMsg; |
085c1e1f FM |
303 | unsigned long int TopUserFields; |
304 | unsigned long int UserReportFields; | |
25697a35 GS |
305 | char DataFile[MAXLEN]; |
306 | char DataFileDelimiter[3]; | |
085c1e1f | 307 | unsigned long int DataFileFields; |
f84a35a3 | 308 | unsigned long int DataFileUrl; |
e6414a9d | 309 | int ShowReadStatistics; |
25697a35 GS |
310 | char IndexSortOrder[5]; |
311 | char DansGuardianConf[MAXLEN]; | |
e6414a9d | 312 | int DansguardianIgnoreDate; |
25697a35 GS |
313 | char SquidGuardConf[MAXLEN]; |
314 | char SquidGuarddbHome[255]; | |
315 | char SquidGuardLogFormat[MAXLEN]; | |
491b862f | 316 | char SquidGuardLogAlternate[MAXLEN]; |
e6414a9d FM |
317 | int SquidguardIgnoreDate; |
318 | int ShowSargInfo; | |
319 | int BytesInSitesUsersReport; | |
320 | int ShowSargLogo; | |
25697a35 | 321 | char ParsedOutputLog[MAXLEN]; |
ff8d5836 | 322 | char ParsedOutputLogCompress[512]; |
25697a35 | 323 | char DisplayedValues[20]; |
933aca19 | 324 | char HeaderFontSize[5]; |
491b862f | 325 | char TitleFontSize[5]; |
25697a35 GS |
326 | char wwwDocumentRoot[MAXLEN]; |
327 | char ExternalCSSFile[MAXLEN]; | |
328 | char BlockIt[255]; | |
f2ec8c75 | 329 | unsigned long int NtlmUserFormat; |
0349fa24 | 330 | unsigned long int IndexTree; |
e6414a9d | 331 | int UserAuthentication; |
d5d021c5 | 332 | char AuthUserTemplateFile[1024]; |
25697a35 GS |
333 | char *str; |
334 | char *str2; | |
25697a35 GS |
335 | char val1[MAXLEN]; |
336 | char val2[MAXLEN]; | |
337 | char val3[MAXLEN]; | |
338 | char val4[MAXLEN]; | |
339 | char val5[MAXLEN]; | |
340 | char val6[MAXLEN]; | |
341 | char val7[MAXLEN]; | |
342 | char val8[MAXLEN]; | |
343 | char val9[MAXLEN]; | |
344 | char val10[MAXLEN]; | |
345 | char val11[MAXLEN]; | |
346 | char wwork1[MAXLEN]; | |
347 | char wwork2[MAXLEN]; | |
348 | char wwork3[MAXLEN]; | |
25697a35 | 349 | char mask[MAXLEN]; |
25697a35 GS |
350 | char site[MAXLEN]; |
351 | char us[50]; | |
352 | char email[MAXLEN]; | |
353 | char test[1]; | |
354 | char ouser2[255]; | |
355 | char user2[MAXLEN]; | |
356 | char wentp[512]; | |
357 | char addr[MAXLEN]; | |
491b862f GS |
358 | char Ulimit[6]; |
359 | char RealtimeTypes[1024]; | |
25697a35 | 360 | char cmd[255]; |
491b862f GS |
361 | char ImageFile[255]; |
362 | char tbuf[128]; | |
363 | char ip[25]; | |
364 | char RealtimeUnauthRec[15]; | |
e3af0ae9 PO |
365 | char LDAPHost[255]; |
366 | char LDAPBindDN[512]; | |
367 | char LDAPBindPW[255]; | |
965c4a6f FM |
368 | int LDAPPort; |
369 | int LDAPProtocolVersion; | |
e3af0ae9 PO |
370 | char LDAPBaseSearch[255]; |
371 | char LDAPFilterSearch[512]; | |
372 | char LDAPTargetAttr[64]; | |
3becf85c | 373 | char GraphFont[MAXLEN]; |
491b862f | 374 | |
25697a35 GS |
375 | int idate; |
376 | int smartfilter; | |
377 | int denied_count; | |
378 | int download_count; | |
379 | int authfail_count; | |
380 | int dansguardian_count; | |
381 | int squidguard_count; | |
c0ec9cc7 | 382 | int useragent_count; |
25697a35 GS |
383 | int limit_flag; |
384 | int color1; | |
385 | int color2; | |
386 | int color3; | |
387 | int z1, z2, z3; | |
388 | int ttopen; | |
25697a35 GS |
389 | int sarglog; |
390 | int isalog; | |
2357ef77 | 391 | int dfrom; |
25697a35 GS |
392 | int duntil; |
393 | int dataonly; | |
394 | int indexonly; | |
395 | int iprel; | |
396 | int userip; | |
397 | int langcode; | |
398 | int debug; | |
399 | int debugz; | |
400 | int debugm; | |
401 | int AuthfailReportLimit; | |
402 | int DeniedReportLimit; | |
94ff9470 | 403 | int DownloadReportLimit; |
25697a35 GS |
404 | int SiteUsersReportLimit; |
405 | int DansGuardianReportLimit; | |
406 | int SquidGuardReportLimit; | |
407 | int UserReportLimit; | |
491b862f GS |
408 | int realtime_refresh; |
409 | int realtime_access_log_lines; | |
410 | int realt; | |
491b862f | 411 | int rc; |
d6e703cc FM |
412 | int ntopsites; |
413 | int nsitesusers; | |
414 | int nrepday; | |
415 | int ndownload; | |
416 | int ntopuser; | |
417 | int squid24; | |
25697a35 GS |
418 | float perc; |
419 | ||
491b862f GS |
420 | long long int nocost; |
421 | float cost; | |
25697a35 GS |
422 | |
423 | typedef struct | |
424 | { int list[ 24 ]; | |
425 | int len; | |
426 | } numlist; | |
427 | ||
428 | DIR *dirp; | |
429 | struct dirent *direntp; |