]>
git.ipfire.org Git - thirdparty/sarg.git/blob - siteuser.c
2 * AUTHOR: Pedro Lineu Orso pedro.orso@gmail.com
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"
52 sprintf(geral
,"%s/geral",dirname
);
53 sprintf(sites
,"%s/sites",dirname
);
54 sprintf(geral2
,"%s/geral2",dirname
);
55 sprintf(per
,"%s/periodo",dirname
);
56 sprintf(report
,"%s/siteuser.html",dirname
);
58 if ((fp_in
= fopen(per
, "r")) == 0) {
59 fprintf(stderr
, "SARG: (topuser) %s: %s\n",text
[45],per
);
63 fgets(periodo
,sizeof(periodo
),fp_in
);
66 sprintf(csort
,"sort -k 4,4 -k 1,1 -o '%s' '%s'",geral2
,geral
);
69 if((fp_in
=fopen(geral2
,"r"))==NULL
) {
70 fprintf(stderr
, "SARG: (topsite) %s: %s\n",text
[8],geral2
);
74 if((fp_ou
=fopen(report
,"w"))==NULL
) {
75 fprintf(stderr
, "SARG: (topsite) %s: %s\n",text
[8],report
);
79 fputs("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"",fp_ou
);
80 fputs(" \"http://www.w3.org/TR/html4/loose.dtd\">\n",fp_ou
);
81 fputs("<html>\n",fp_ou
);
82 fputs("<head>\n",fp_ou
);
83 sprintf(html
," <meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">\n",CharSet
);
86 fputs("</head>\n",fp_ou
);
88 if(strlen(FontFace
) > 0) {
89 sprintf(url
,"<font face=%s>\n",FontFace
);
93 sprintf(url
,"<body bgcolor=%s text=%s background='%s'>\n",BgColor
,TxColor
,BgImage
);
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 if(strcmp(IndexTree
,"date") == 0)
105 show_sarg(fp_ou
, "../../..");
107 show_sarg(fp_ou
, "..");
109 fputs("<center><table cellpadding=0 cellspacing=0>\n",fp_ou
);
110 sprintf(url
,"<tr><th class=\"title\">%s</th></tr>\n",Title
);
113 sprintf(url
,"<tr><td class=\"header3\">%s: %s</td></tr>\n",text
[89],periodo
);
115 sprintf(url
,"<tr><td class=\"header3\">%s</td></tr>\n",text
[85]);
117 fputs("</table></center>\n",fp_ou
);
119 fputs("<center><table cellpadding=0 cellspacing=2>\n",fp_ou
);
120 fputs("<tr><td></td></tr>\n",fp_ou
);
121 fputs("<tr><td></td></tr>\n",fp_ou
);
122 fputs("<tr><td></td></tr>\n",fp_ou
);
123 sprintf(url
,"<tr><th class=\"header\">%s</th><th class=\"header\">%s</th><th class=\"header\">%s</th></tr>\n",text
[100],text
[91],text
[103]);
129 if((users
=(char *) malloc(204800))==NULL
){
130 fprintf(stderr
, "SARG: ERROR: %s",text
[87]);
135 while(fgets(buf
,sizeof(buf
),fp_in
)!=NULL
) {
136 getword(user
,buf
,' ');
137 if(strcmp(user
,"TOTAL") == 0)
142 if(UserTabFile
[0] != '\0') {
143 sprintf(warea
,":%s:",user
);
144 if((str
=(char *) strstr(userfile
,warea
)) != (char *) NULL
) {
146 str2
=(char *) strstr(str
+1,":");
149 while(str2
[z1
] != ':') {
153 } else strcpy(name
,user
);
154 } else strcpy(name
,user
);
156 if(dotinuser
&& strstr(name
,"_")) {
157 str2
=(char *)subs(name
,"_",".");
161 if(strcmp(Ip2Name
,"yes") == 0)
164 if(strcmp(Ip2Name
,"yes") == 0)
167 getword(nacc
,buf
,' ');
168 getword(nbytes
,buf
,' ');
169 getword(url
,buf
,' ');
176 sprintf(wuser
," %s ",name
);
177 if(strstr(users
,wuser
) == 0 && strcmp(url
,ourl
) == 0) {
182 strcat(users
,"<br>");
187 if(SiteUsersReportLimit
) {
188 if(regs
>= SiteUsersReportLimit
)
192 if(strlen(BlockIt
) > 0)
193 sprintf(BlockImage
,"<a href=\"%s%s?url=%s\"><img src=\"../images/sarg-squidguard-block.png\" border=\"0\"></a> ",wwwDocumentRoot
,BlockIt
,ourl
);
194 else BlockImage
[0]='\0';
196 if(strcmp(url
,ourl
) != 0) {
197 sprintf(html
,"<tr><td class=\"data\">%d</td><td class=\"data2\">%s<a href=\"http://%s\">%s</td><td class=\"data2\">%s</td></tr>\n",regs
,BlockImage
,ourl
,ourl
,users
);
207 sprintf(html
,"<tr><td class=\"data\">%d</td><td class=\"data2\"><a href=\"http://%s\">%s</td><td class=\"data2\">%s</td></tr>\n",regs
,ourl
,ourl
,users
);
212 fputs("</table></center>\n",fp_ou
);
216 fputs("</body>\n</html>\n",fp_ou
);