]>
git.ipfire.org Git - thirdparty/sarg.git/blob - denied.c
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 gen_denied_report()
31 FILE *fp_in
= NULL
, *fp_ou
= NULL
;
36 char denied_in
[MAXLEN
];
37 char denied_ou
[MAXLEN
];
55 sprintf(denied_in
,"%s/denied.log",TempDir
);
61 sprintf(per
,"%s/periodo",dirname
);
62 sprintf(report
,"%s/denied.html",dirname
);
64 if ((fp_in
= fopen(per
, "r")) == 0) {
65 fprintf(stderr
, "SARG: (denied) %s: %s\n",text
[45],per
);
69 fgets(periodo
,sizeof(periodo
),fp_in
);
72 if((fp_in
=fopen(denied_in
,"r"))==NULL
) {
73 fprintf(stderr
, "SARG: (denied) %s: %s\n",text
[8],denied_in
);
77 if((fp_ou
=fopen(report
,"w"))==NULL
) {
78 fprintf(stderr
, "SARG: (denied) %s: %s\n",text
[8],report
);
82 fputs("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"",fp_ou
);
83 fputs(" \"http://www.w3.org/TR/html4/loose.dtd\">\n",fp_ou
);
84 fputs("<html>\n",fp_ou
);
85 fputs("<head>\n",fp_ou
);
86 sprintf(html
," <meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">\n",CharSet
);
89 fputs("</head>\n",fp_ou
);
91 sprintf(url
,"<body bgcolor=%s text=%s background='%s'>\n",BgColor
,TxColor
,BgImage
);
94 fputs("<center><table cellpadding=0 cellspacing=0>\n",fp_ou
);
96 if(strlen(LogoImage
) > 0) {
97 fputs("<center><table cellpadding=\"0\" cellspacing=\"0\">\n",fp_ou
);
98 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
);
100 fputs("<tr><td height=\"5\"></td></tr>\n",fp_ou
);
101 fputs("</table>\n",fp_ou
);
104 show_sarg(fp_ou
, "..");
105 sprintf(url
,"<tr><th class=\"title\">%s</b></th></tr>\n",Title
);
108 sprintf(url
,"<tr><td class=\"header\">%s: %s</td></tr>\n",text
[89],periodo
);
110 sprintf(url
,"<tr><th class=\"header3\">%s %s</th></tr>\n",text
[46],text
[55]);
112 fputs("</table></center>\n",fp_ou
);
114 fputs("<center><table cellpadding=0 cellspacing=2>\n",fp_ou
);
115 fputs("<tr><td></td></tr>\n",fp_ou
);
116 fputs("<tr><td></td></tr>\n",fp_ou
);
117 fputs("<tr><td></td></tr>\n",fp_ou
);
118 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]);
121 while(fgets(buf
,sizeof(buf
),fp_in
)!=NULL
) {
122 getword(data
,buf
,' ');
123 getword(hora
,buf
,' ');
124 getword(user
,buf
,' ');
126 getword(url
,buf
,' ');
128 if((str
=(char *) strstr(user
, "_")) != (char *) NULL
) {
129 if((str
=(char *) strstr(str
+1, "_")) != (char *) NULL
)
133 if(strcmp(Ip2Name
,"yes") == 0)
141 if(strcmp(ouser
,user
) == 0)
145 if(strcmp(oip
,ip
) == 0)
151 if(UserTabFile
[0] != '\0') {
152 sprintf(warea
,":%s:",user
);
153 if((str
=(char *) strstr(userfile
,warea
)) != (char *) NULL
) {
155 str2
=(char *) strstr(str
+1,":");
158 while(str2
[z1
] != ':') {
162 } else strcpy(name
,user
);
163 } else strcpy(name
,user
);
165 if(dotinuser
&& strstr(name
,"_")) {
166 str2
=(char *)subs(name
,"_",".");
170 if(DeniedReportLimit
) {
171 if(strcmp(ouser2
,name
) == 0) {
177 if(count
>= DeniedReportLimit
)
181 if(strlen(BlockIt
) > 0)
182 sprintf(BlockImage
,"<a href=\"%s%s?url=%s\"><img src=\"../images/sarg-squidguard-block.png\" border=\"0\"></a> ",wwwDocumentRoot
,BlockIt
,url
);
183 else BlockImage
[0]='\0';
185 sprintf(html2
,"<tr><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s-%s</td><td class=\"data2\">%s<a href=\"%s\">%s</a></td></th>\n",name
,ip
,data
,hora
,BlockImage
,url
,url
);
189 fputs("</table>\n",fp_ou
);
192 fputs("</body></html>\n",fp_ou
);