]>
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 | |
25697a35 | 107 | |
b3695c67 | 108 | #if defined(HAVE_FOPEN64) |
25697a35 | 109 | #define _FILE_OFFSET_BITS 64 |
936c9905 | 110 | #define MY_FOPEN fopen64 |
25697a35 GS |
111 | #else |
112 | #define MY_FOPEN fopen | |
113 | #endif | |
114 | ||
b3695c67 FM |
115 | #if !defined(HAVE_BZERO) |
116 | #define bzero(mem,size) memset(mem,0,size) | |
117 | #endif | |
118 | ||
119 | #if defined(IBERTY_LIB) && !defined(HAVE_MKSTEMP) | |
120 | int mkstemps(char *template, int suffixlen); | |
121 | #define mkstemp(template) mkstemps(template,0) | |
122 | #endif | |
123 | ||
c0ec9cc7 FM |
124 | #ifdef ENABLE_NLS |
125 | #include <libintl.h> | |
126 | #define _(String) gettext(String) | |
127 | #ifdef gettext_noop | |
128 | #define N_(String) gettext_noop(String) | |
129 | #else | |
130 | #define N_(String) (String) | |
131 | #endif | |
132 | #else /* No NLS */ | |
133 | #define _(String) (String) | |
134 | #define N_(String) (String) | |
135 | #define textdomain(String) | |
136 | #define bindtextdomain(Domain,Directory) | |
137 | #endif | |
138 | ||
b3695c67 FM |
139 | #if defined(__MINGW32__) |
140 | #define mkdir(p,m) _mkdir(p) | |
141 | ||
142 | #ifndef WIFEXITED | |
143 | #define WIFEXITED(S) 1 | |
144 | #endif | |
145 | ||
146 | #ifndef WEXITSTATUS | |
147 | #define WEXITSTATUS(S) (S) | |
148 | #endif | |
149 | ||
150 | #endif /*__MINGW32__*/ | |
25697a35 GS |
151 | |
152 | #define MAXLEN 20000 | |
0a4e18e1 | 153 | #define MAXLOGS 255 |
25697a35 | 154 | |
085c1e1f FM |
155 | #define REPORT_TYPE_USERS_SITES 0x0001UL |
156 | #define REPORT_TYPE_SITE_USER_TIME_DATE 0x0002UL | |
157 | #define REPORT_TYPE_TOPUSERS 0x0004UL | |
158 | #define REPORT_TYPE_TOPSITES 0x0008UL | |
159 | #define REPORT_TYPE_SITES_USERS 0x0010UL | |
160 | #define REPORT_TYPE_DATE_TIME 0x0020UL | |
161 | #define REPORT_TYPE_DENIED 0x0040UL | |
162 | #define REPORT_TYPE_AUTH_FAILURES 0x0080UL | |
163 | #define REPORT_TYPE_DOWNLOADS 0x0100UL | |
164 | ||
165 | #define DATA_FIELD_USER 0x0001UL | |
166 | #define DATA_FIELD_DATE 0x0002UL | |
167 | #define DATA_FIELD_TIME 0x0004UL | |
168 | #define DATA_FIELD_URL 0x0008UL | |
169 | #define DATA_FIELD_CONNECT 0x0010UL | |
170 | #define DATA_FIELD_BYTES 0x0020UL | |
171 | #define DATA_FIELD_IN_CACHE 0x0040UL | |
172 | #define DATA_FIELD_OUT_CACHE 0x0080UL | |
173 | #define DATA_FIELD_ELAPSED 0x0100UL | |
174 | ||
175 | #define TOPUSERFIELDS_NUM 0x0001UL | |
176 | #define TOPUSERFIELDS_DATE_TIME 0x0002UL | |
177 | #define TOPUSERFIELDS_USERID 0x0004UL | |
178 | #define TOPUSERFIELDS_CONNECT 0x0008UL | |
179 | #define TOPUSERFIELDS_BYTES 0x0010UL | |
180 | #define TOPUSERFIELDS_SETYB 0x0020UL | |
181 | #define TOPUSERFIELDS_IN_CACHE_OUT 0x0040UL | |
182 | #define TOPUSERFIELDS_USED_TIME 0x0080UL | |
183 | #define TOPUSERFIELDS_MILISEC 0x0100UL | |
184 | #define TOPUSERFIELDS_PTIME 0x0200UL | |
185 | #define TOPUSERFIELDS_TOTAL 0x0400UL | |
186 | #define TOPUSERFIELDS_AVERAGE 0x0800UL | |
187 | ||
188 | #define USERREPORTFIELDS_CONNECT 0x0001UL | |
189 | #define USERREPORTFIELDS_BYTES 0x0002UL | |
190 | #define USERREPORTFIELDS_SETYB 0x0004UL | |
191 | #define USERREPORTFIELDS_IN_CACHE_OUT 0x0008UL | |
192 | #define USERREPORTFIELDS_USED_TIME 0x0010UL | |
193 | #define USERREPORTFIELDS_MILISEC 0x0020UL | |
194 | #define USERREPORTFIELDS_PTIME 0x0040UL | |
195 | #define USERREPORTFIELDS_TOTAL 0x0080UL | |
196 | #define USERREPORTFIELDS_AVERAGE 0x0100UL | |
197 | ||
0349fa24 FM |
198 | #define INDEX_YES 0x0001UL |
199 | #define INDEX_NO 0x0002UL | |
200 | #define INDEX_ONLY 0x0004UL | |
201 | ||
202 | #define INDEX_TREE_DATE 0x0001UL | |
203 | #define INDEX_TREE_FILE 0x0002UL | |
204 | ||
2357ef77 | 205 | FILE *fp_tt; |
25697a35 GS |
206 | |
207 | char outdir[MAXLEN]; | |
208 | char dirname[MAXLEN]; | |
209 | char buf[MAXLEN]; | |
210 | char url[MAXLEN]; | |
211 | char urly[MAXLEN]; | |
212 | char user[MAXLEN]; | |
d6e703cc | 213 | char period[MAXLEN]; |
d6e703cc FM |
214 | char code[MAXLEN]; |
215 | char code2[MAXLEN]; | |
25697a35 | 216 | char tmp[MAXLEN]; |
25697a35 GS |
217 | char tmp3[MAXLEN]; |
218 | char tmp4[MAXLEN]; | |
219 | char tmp5[MAXLEN]; | |
220 | char tmp6[MAXLEN]; | |
d6e703cc | 221 | char tmp7[MAXLEN]; |
25697a35 GS |
222 | char parse_out[MAXLEN]; |
223 | char arqtt[MAXLEN]; | |
224 | char html[MAXLEN]; | |
225 | char datestimes[MAXLEN]; | |
226 | char ConfigFile[MAXLEN]; | |
227 | char href[MAXLEN]; | |
228 | char href2[MAXLEN]; | |
229 | char href3[MAXLEN]; | |
230 | char df[20]; | |
491b862f | 231 | char day[3], month[4], year[5]; |
25697a35 GS |
232 | char ltext110[50]; |
233 | char cdfrom[30]; | |
234 | char cduntil[30]; | |
0511cf2d | 235 | int LastLog; |
e6414a9d | 236 | int RemoveTempFiles; |
25697a35 | 237 | char ReplaceIndex[256]; |
0349fa24 | 238 | unsigned long int Index; |
e6414a9d | 239 | int OverwriteReport; |
d6e703cc | 240 | char u2[255]; |
25697a35 | 241 | char RecordsWithoutUser[20]; |
e6414a9d | 242 | int UseComma; |
4af2f8ff | 243 | char MailUtility[PATH_MAX]; |
c0ec9cc7 | 244 | int TopSitesNum; |
fb7c5f27 | 245 | int TopUsersNum; |
25697a35 GS |
246 | char ExcludeCodes[256]; |
247 | char TopsitesSortField[15]; | |
491b862f | 248 | char TopsitesSortType[20]; |
085c1e1f | 249 | unsigned long int ReportType; |
25697a35 GS |
250 | char UserTabFile[255]; |
251 | char warea[MAXLEN]; | |
252 | char name[MAXLEN]; | |
246c8489 FM |
253 | int LongUrl; |
254 | int Ip2Name; | |
25697a35 | 255 | char language[255]; |
d6e703cc | 256 | char bufy[MAXLEN]; |
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]; | |
293 | char csort[255]; | |
294 | char CharSet[255]; | |
295 | char UserInvalidChar[255]; | |
e6414a9d | 296 | int Graphs; |
25697a35 | 297 | char GraphDaysBytesBarColor[255]; |
e6414a9d | 298 | int Privacy; |
25697a35 GS |
299 | char PrivacyString[255]; |
300 | char PrivacyStringColor[30]; | |
301 | char IncludeUsers[MAXLEN]; | |
302 | char ExcludeString[MAXLEN]; | |
e6414a9d | 303 | int SuccessfulMsg; |
085c1e1f FM |
304 | unsigned long int TopUserFields; |
305 | unsigned long int UserReportFields; | |
25697a35 GS |
306 | char DataFile[MAXLEN]; |
307 | char DataFileDelimiter[3]; | |
085c1e1f | 308 | unsigned long int DataFileFields; |
491b862f | 309 | char DataFileUrl[20]; |
25697a35 | 310 | char SiteUserTimeDateType[10]; |
e6414a9d | 311 | int ShowReadStatistics; |
25697a35 GS |
312 | char IndexSortOrder[5]; |
313 | char DansGuardianConf[MAXLEN]; | |
e6414a9d | 314 | int DansguardianIgnoreDate; |
25697a35 GS |
315 | char SquidGuardConf[MAXLEN]; |
316 | char SquidGuarddbHome[255]; | |
317 | char SquidGuardLogFormat[MAXLEN]; | |
491b862f | 318 | char SquidGuardLogAlternate[MAXLEN]; |
e6414a9d FM |
319 | int SquidguardIgnoreDate; |
320 | int ShowSargInfo; | |
321 | int BytesInSitesUsersReport; | |
322 | int ShowSargLogo; | |
25697a35 | 323 | char ParsedOutputLog[MAXLEN]; |
ff8d5836 | 324 | char ParsedOutputLogCompress[512]; |
25697a35 | 325 | char DisplayedValues[20]; |
933aca19 | 326 | char HeaderFontSize[5]; |
491b862f | 327 | char TitleFontSize[5]; |
25697a35 GS |
328 | char wwwDocumentRoot[MAXLEN]; |
329 | char ExternalCSSFile[MAXLEN]; | |
330 | char BlockIt[255]; | |
331 | char BlockImage[512]; | |
332 | char NtlmUserFormat[30]; | |
0349fa24 | 333 | unsigned long int IndexTree; |
e6414a9d | 334 | int UserAuthentication; |
25697a35 GS |
335 | char AuthUserFile[255]; |
336 | char AuthName[512]; | |
337 | char AuthType[255]; | |
338 | char Require[512]; | |
25697a35 GS |
339 | char *str; |
340 | char *str2; | |
341 | char text[200][255]; | |
342 | char val1[MAXLEN]; | |
343 | char val2[MAXLEN]; | |
344 | char val3[MAXLEN]; | |
345 | char val4[MAXLEN]; | |
346 | char val5[MAXLEN]; | |
347 | char val6[MAXLEN]; | |
348 | char val7[MAXLEN]; | |
349 | char val8[MAXLEN]; | |
350 | char val9[MAXLEN]; | |
351 | char val10[MAXLEN]; | |
352 | char val11[MAXLEN]; | |
353 | char wwork1[MAXLEN]; | |
354 | char wwork2[MAXLEN]; | |
355 | char wwork3[MAXLEN]; | |
25697a35 | 356 | char mask[MAXLEN]; |
25697a35 | 357 | char html_old[MAXLEN]; |
25697a35 GS |
358 | char site[MAXLEN]; |
359 | char us[50]; | |
360 | char email[MAXLEN]; | |
361 | char test[1]; | |
362 | char ouser2[255]; | |
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 GS |
369 | char ImageFile[255]; |
370 | char tbuf[128]; | |
371 | char ip[25]; | |
372 | char RealtimeUnauthRec[15]; | |
e3af0ae9 PO |
373 | char LDAPHost[255]; |
374 | char LDAPBindDN[512]; | |
375 | char LDAPBindPW[255]; | |
965c4a6f FM |
376 | int LDAPPort; |
377 | int LDAPProtocolVersion; | |
e3af0ae9 PO |
378 | char LDAPBaseSearch[255]; |
379 | char LDAPFilterSearch[512]; | |
380 | char LDAPTargetAttr[64]; | |
491b862f | 381 | |
25697a35 GS |
382 | int idate; |
383 | int smartfilter; | |
384 | int denied_count; | |
385 | int download_count; | |
386 | int authfail_count; | |
387 | int dansguardian_count; | |
388 | int squidguard_count; | |
c0ec9cc7 | 389 | int useragent_count; |
25697a35 GS |
390 | int limit_flag; |
391 | int color1; | |
392 | int color2; | |
393 | int color3; | |
394 | int z1, z2, z3; | |
395 | int ttopen; | |
396 | int ind2; | |
397 | int sarglog; | |
398 | int isalog; | |
2357ef77 | 399 | int dfrom; |
25697a35 GS |
400 | int duntil; |
401 | int dataonly; | |
402 | int indexonly; | |
403 | int iprel; | |
404 | int userip; | |
405 | int langcode; | |
406 | int debug; | |
407 | int debugz; | |
408 | int debugm; | |
409 | int AuthfailReportLimit; | |
410 | int DeniedReportLimit; | |
94ff9470 | 411 | int DownloadReportLimit; |
25697a35 GS |
412 | int SiteUsersReportLimit; |
413 | int DansGuardianReportLimit; | |
414 | int SquidGuardReportLimit; | |
415 | int UserReportLimit; | |
94ff9470 | 416 | int dotinuser; |
491b862f GS |
417 | int realtime_refresh; |
418 | int realtime_access_log_lines; | |
419 | int realt; | |
491b862f | 420 | int rc; |
d6e703cc FM |
421 | int ntopsites; |
422 | int nsitesusers; | |
423 | int nrepday; | |
424 | int ndownload; | |
425 | int ntopuser; | |
426 | int squid24; | |
25697a35 GS |
427 | float perc; |
428 | ||
491b862f GS |
429 | long long int nocost; |
430 | float cost; | |
25697a35 GS |
431 | |
432 | typedef struct | |
433 | { int list[ 24 ]; | |
434 | int len; | |
435 | } numlist; | |
436 | ||
437 | DIR *dirp; | |
438 | struct dirent *direntp; |