]>
git.ipfire.org Git - thirdparty/sarg.git/blob - authfail.c
d3b0c63e1e39c26c79966047dbd868646241ae16
2 * AUTHOR: Pedro Lineu Orso orso@penguintech.com.br
4 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
7 * please look at http://sarg.sourceforge.net/donations.php
8 * ---------------------------------------------------------------------
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
26 #include "include/conf.h"
28 void authfail_report()
31 FILE *fp_in
= NULL
, *fp_ou
= NULL
;
36 char authfail_in
[MAXLEN
];
52 if(strlen(DataFile
) > 0) return;
56 sprintf(tmp4
,"%s/sarg/authfail.log.unsort",TempDir
);
63 sprintf(authfail_in
,"%s/authfail.log",TempDir
);
64 sprintf(per
,"%s/periodo",dirname
);
65 sprintf(report
,"%s/authfail.html",dirname
);
67 sprintf(csort
,"sort -b -T %s -k 3,3 -k 5,5 -o '%s' '%s'", TempDir
, authfail_in
, tmp4
);
71 if ((fp_in
= fopen(per
, "r")) == 0) {
72 fprintf(stderr
, "SARG: (authfail) %s: %s\n",text
[45],per
);
76 fgets(periodo
,sizeof(periodo
),fp_in
);
79 if((fp_in
=fopen(authfail_in
,"r"))==NULL
) {
80 fprintf(stderr
, "SARG: (authfail) %s: %s\n",text
[45],authfail_in
);
84 if((fp_ou
=fopen(report
,"w"))==NULL
) {
85 fprintf(stderr
, "SARG: (authfail) %s: %s\n",text
[45],report
);
89 fputs("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"",fp_ou
);
90 fputs(" \"http://www.w3.org/TR/html4/loose.dtd\">\n",fp_ou
);
91 fputs("<html>\n",fp_ou
);
92 fputs("<head>\n",fp_ou
);
93 sprintf(html
," <meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">\n",CharSet
);
96 fputs("</head>\n",fp_ou
);
98 if(strlen(FontFace
) > 0) {
99 sprintf(url
,"<font face=%s>\n",FontFace
);
103 sprintf(url
,"<body bgcolor=%s text=%s background='%s'>\n",BgColor
,TxColor
,BgImage
);
106 if(strlen(LogoImage
) > 0) {
107 fputs("<center><table cellpadding=\"0\" cellspacing=\"0\">\n",fp_ou
);
108 sprintf(url
,"<tr><th class=\"logo\"><img src='%s' border=0 align=absmiddle width=%s height=%s> %s</th></tr>\n",LogoImage
,Width
,Height
,LogoText
);
110 fputs("<tr><td height=\"5\"></td></tr>\n",fp_ou
);
111 fputs("</table>\n",fp_ou
);
114 if(strcmp(IndexTree
,"date") == 0)
115 show_sarg(fp_ou
, "../../..");
117 show_sarg(fp_ou
,"..");
118 fputs("<center><table cellpadding=0 cellspacing=0>\n",fp_ou
);
119 sprintf(url
,"<tr><th class=\"title\">%s</th></tr>\n",Title
);
122 sprintf(url
,"<tr><td class=\"header\">%s: %s</td></tr>\n",text
[89],periodo
);
124 sprintf(url
,"<tr><th class=\"header\">%s %s</th></tr>\n",text
[117],text
[55]);
126 fputs("</table></center>\n",fp_ou
);
128 fputs("<center><table cellpadding=0 cellspacing=2>\n",fp_ou
);
129 fputs("<tr><td></td></tr>\n",fp_ou
);
130 fputs("<tr><td></td></tr>\n",fp_ou
);
131 fputs("<tr><td></td></tr>\n",fp_ou
);
132 sprintf(url
,"<tr><th class=\"header\">%s</th><th class=\"header\">%s</th><th class=\"header\">%s</th><th class=\"header\">%s</th></tr>\n",text
[98],text
[111],text
[110],text
[91]);
135 while(fgets(buf
,sizeof(buf
),fp_in
)!=NULL
) {
136 getword(data
,buf
,' ');
137 getword(hora
,buf
,' ');
138 getword(user
,buf
,' ');
140 getword(url
,buf
,' ');
142 if((str
=(char *) strstr(user
, "_")) != (char *) NULL
) {
143 if((str
=(char *) strstr(str
+1, "_")) != (char *) NULL
)
147 if(strcmp(Ip2Name
,"yes") == 0)
155 if(strcmp(ouser
,user
) == 0)
159 if(strcmp(oip
,ip
) == 0)
165 if(UserTabFile
[0] != '\0') {
166 sprintf(warea
,":%s:",user
);
167 if((str
=(char *) strstr(userfile
,warea
)) != (char *) NULL
) {
169 str2
=(char *) strstr(str
+1,":");
172 while(str2
[z1
] != ':') {
176 } else strcpy(name
,user
);
177 } else strcpy(name
,user
);
179 if(dotinuser
&& strstr(name
,"_")) {
180 str2
=(char *)subs(name
,"_",".");
184 if(AuthfailReportLimit
) {
185 if(strcmp(ouser2
,name
) == 0) {
191 if(count
>= AuthfailReportLimit
)
195 sprintf(html2
,"<tr><td class=\"data2\">%s</td><td class=\"data2\">%s</td><td class=\"data2\">%s-%s</td><td class=\"data2\">%s<a href=\"%s\">%s</a></td></th>\n",name
,ip
,data
,hora
,BlockImage
,url
,url
);
199 fputs("</table>\n",fp_ou
);
203 fputs("</body>\n</html>\n",fp_ou
);