sarg
2.4.0
About: SARG ia a Squid Analysis Report Generator. Fossies Dox: sarg-2.4.0.tar.gz ("unofficial" and yet experimental doxygen-generated source code documentation) 
|
Go to the documentation of this file.
72 strftime(date,
sizeof(date),
"%d/%m/%Y\t%H:%M:%S",&log_entry->
EntryTime);
73 fprintf(
fp_denied,
"%s\t%s\t%s\t%s\n",date,log_entry->
User,log_entry->
Ip,log_entry->
Url);
107 snprintf(ignored,
sizeof(ignored),
ngettext(
"%d more denied access not shown here…",
"%d more denied accesses not shown here…",count),count);
108 fprintf(fp_ou,
"<tr><td class=\"data\"></td><td class=\"data\"></td><td class=\"data\"></td><td class=\"data2 more\">%s</td></tr>\n",ignored);
149 debuga(__FILE__,__LINE__,
_(
"Creating denied accesses report...\n"));
151 if (snprintf(denied_sort,
sizeof(denied_sort),
"%s/denied.int_log",
tmp)>=
sizeof(denied_sort)) {
152 debuga(__FILE__,__LINE__,
_(
"Temporary directory path too long to sort the denied accesses\n"));
155 if (snprintf(csort,
sizeof(csort),
"sort -T \"%s\" -t \"\t\" -k 3,3 -k 5,5 -o \"%s\" \"%s\"",
tmp,denied_sort,
denied_unsort)>=
sizeof(csort)) {
156 debuga(__FILE__,__LINE__,
_(
"Sort command too long when sorting file \"%s\" to \"%s\"\n"),
denied_unsort,denied_sort);
159 cstatus=system(csort);
160 if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
161 debuga(__FILE__,__LINE__,
_(
"sort command return status %d\n"),WEXITSTATUS(cstatus));
162 debuga(__FILE__,__LINE__,
_(
"sort command: %s\n"),csort);
178 if ((fp_ou=
MY_FOPEN(report,
"w"))==NULL) {
179 debuga(__FILE__,__LINE__,
_(
"Cannot open file \"%s\": %s\n"),report,strerror(errno));
184 fputs(
"<tr><td class=\"header_c\">",fp_ou);
186 fputs(
"</td></tr>\n",fp_ou);
187 fprintf(fp_ou,
"<tr><th class=\"header_c\">%s</th></tr>\n",
_(
"Denied"));
190 fputs(
"<div class=\"report\"><table cellpadding=\"0\" cellspacing=\"2\">\n",fp_ou);
191 fprintf(fp_ou,
"<tr><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th></tr>\n",
_(
"USERID"),
_(
"IP/NAME"),
_(
"DATE/TIME"),
_(
"ACCESSED SITE"));
194 debuga(__FILE__,__LINE__,
_(
"Not enough memory to read file \"%s\"\n"),denied_sort);
200 if (
getword(data,
sizeof(data),&gwarea,
'\t')<0 ||
getword(hora,
sizeof(hora),&gwarea,
'\t')<0 ||
201 getword(user,
sizeof(user),&gwarea,
'\t')<0 ||
getword(ip,
sizeof(ip),&gwarea,
'\t')<0) {
202 debuga(__FILE__,__LINE__,
_(
"Invalid record in file \"%s\"\n"),denied_sort);
206 debuga(__FILE__,__LINE__,
_(
"Invalid url in file \"%s\"\n"),denied_sort);
209 if (sscanf(data,
"%d/%d/%d",&day,&month,&year)!=3)
continue;
211 strftime(data,
sizeof(data),
"%x",&t);
215 debuga(__FILE__,__LINE__,
_(
"Unknown user ID %s in file \"%s\"\n"),user,denied_sort);
226 if (strcmp(ouser,user) != 0) {
230 if (strcmp(oip,ip) != 0) {
237 if (strcmp(ouser2,uinfo->
label) == 0) {
243 strcpy(ouser2,uinfo->
label);
252 fprintf(fp_ou,
"<td class=\"data\"><a href=\"%s/%s.html\">%s</a></td><td class=\"data\">%s</td>",uinfo->
filename,uinfo->
filename,uinfo->
label,ip);
254 fprintf(fp_ou,
"<td class=\"data\">%s</td><td class=\"data\">%s</td>",uinfo->
label,ip);
256 fputs(
"<td class=\"data\"></td><td class=\"data\"></td>",fp_ou);
257 fprintf(fp_ou,
"<td class=\"data\">%s-%s</td><td class=\"data2\">",data,hora);
261 fprintf(fp_ou,
"\"><img src=\"%s/sarg-squidguard-block.png\"></a> ",
ImageFile);
264 fputs(
"</td></tr>\n",fp_ou);
275 fputs(
"</table></div>\n",fp_ou);
277 if (fclose(fp_ou)==EOF) {
278 debuga(__FILE__,__LINE__,
_(
"Write error in \"%s\": %s\n"),report,strerror(errno));
283 debuga(__FILE__,__LINE__,
_(
"Cannot delete \"%s\": %s\n"),denied_sort,strerror(errno));
struct tm EntryTime
The time corresponding to the entry.
int topuser
True if this user is in the topuser list.
void getword_start(struct getwordstruct *gwarea, const char *line)
void write_html_header(FILE *fp_ou, int depth, const char *title, int javascript)
void debuga(const char *File, int Line, const char *msg,...)
void output_html_url(FILE *fp_ou, const char *url)
char * HttpCode
HTTP code returned to the user for the entry.
What is known about a user.
char * longline_read(FileObject *fp_in, longline line)
int format_path(const char *file, int line, char *output_buffer, int buffer_size, const char *format,...)
const char * FileObject_GetLastCloseError(void)
bool KeepTempLog
True to keep the temporary files for inspection.
const char * FileObject_GetLastOpenError(void)
void denied_cleanup(void)
#define HTML_JS_NONE
Value to exclude all the javascripts from the html page.
struct userinfostruct * userinfo_find_from_id(const char *id)
const char * Ip
The IP address connecting to internet.
const char * label
The name of the user to display in the report.
char wwwDocumentRoot[20000]
unsigned long int ReportType
void close_html_header(FILE *fp_ou)
int getword_ptr(char *orig_line, char **word, struct getwordstruct *gwarea, char stop)
void computedate(int year, int month, int day, struct tm *t)
unsigned long int IndexTree
How to display the index of the reports.
Data read from an input log file.
char html[90]
The HTML representation of the date.
static char denied_unsort[20000]
Name of the file containing the unsorted denied entries.
const char * User
The user's name.
int getword(char *word, int limit, struct getwordstruct *gwarea, char stop)
FileObject * FileObject_Open(const char *FileName)
Include headers and define global variables. */.
#define ALIAS_PREFIX
The character prefixed in front of the host names that are aliased.
static FILE * fp_denied
The file handle to write the entries.
longline longline_create(void)
#define REPORT_TYPE_DENIED
const char * filename
The mangled name to use in file names of that user.
void longline_destroy(longline *line_ptr)
static bool denied_exists
True if at least one denied entry exists.
void debugaz(const char *File, int Line, const char *msg,...)
void write_html_trailer(FILE *fp_ou)
Declaration of the structures and functions.
#define ngettext(Msgid1, Msgid2, N)
void gen_denied_report(void)
struct periodstruct period
void denied_write(const struct ReadLogStruct *log_entry)
int FileObject_Close(FileObject *File)
static void show_ignored_denied(FILE *fp_ou, int count)
void output_html_link(FILE *fp_ou, const char *url, int maxlen)
@ LogLevel_Process
Process informational messages.