forked from poppyred/1.6.x
/
squid.user.stats.php
executable file
·138 lines (101 loc) · 3.21 KB
/
squid.user.stats.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
include_once('ressources/class.templates.inc');
include_once('ressources/class.ldap.inc');
include_once('ressources/class.users.menus.inc');
include_once('ressources/class.squid.inc');
include_once (dirname(__FILE__) .'/ressources/jpgraph-3/src/jpgraph.php');
include_once (dirname(__FILE__) .'/ressources/jpgraph-3/src/jpgraph_line.php');
include_once (dirname(__FILE__) .'/ressources/jpgraph-3/src/jpgraph_pie.php');
include_once (dirname(__FILE__) .'/ressources/jpgraph-3/src/jpgraph_pie3d.php');
$user=new usersMenus();
if(!$user->AsSquidAdministrator){
$tpl=new templates();
echo "alert('".$tpl->javascript_parse_text("{ERROR_NO_PRIVS}")."');";
exit;
}
if(isset($_GET["popup"])){popup();exit;}
if(isset($_GET["today"])){today();exit;}
if(isset($_GET["week"])){today();exit;}
if(isset($_GET["month"])){today();exit;}
if(isset($_GET["users-table"])){users_table();exit;}
js();
function js(){
$page=CurrentPageName();
$usr=$_GET["user"];
$html="
function WebUserStatisticsLoad(){
YahooWin4('750','$page?popup=$usr','$usr');
}
WebUserStatisticsLoad();";
echo $html;
}
function popup(){
$page=CurrentPageName();
$tpl=new templates();
$user=$_GET["popup"];
$array["today"]='{today}';
$array["week"]='{this_week}';
$array["month"]='{this_month}';
while (list ($num, $ligne) = each ($array) ){
$html[]= $tpl->_ENGINE_parse_body("<li><a href=\"$page?$num=$user\"><span>$ligne</span></a></li>\n");
}
echo "
<div id=main_config_squid_user_stats style='width:100%;height:600px;overflow:auto'>
<ul>". implode("\n",$html)."</ul>
</div>
<script>
$(document).ready(function(){
$('#main_config_squid_user_stats').tabs({
load: function(event, ui) {
$('a', ui.panel).click(function() {
$(ui.panel).load(this.href);
return false;
});
}
});
});
</script>";
}
function today(){
if(isset($_GET["today"])){
$user=$_GET["today"];
$t="today";
$Q1=" AND DATE_FORMAT( zdate, '%Y-%m-%d' )=DATE_FORMAT( NOW(), '%Y-%m-%d' )";
}
if(isset($_GET["week"])){
$t="week";
$user=$_GET["week"];
$Q1=" AND WEEK( zdate)=WEEK( NOW()) AND YEAR(zdate)=YEAR(NOW())";
}
if(isset($_GET["month"])){
$t="month";
$user=$_GET["month"];
$Q1=" AND MONTH( zdate)=MONTH( NOW()) AND YEAR(zdate)=YEAR(NOW())";
}
$dansguardian_events="dansguardian_events_".date('Ym');
$sql="SELECT SUM(QuerySize) as tsize, sitename FROM $dansguardian_events WHERE CLIENT='$user'{$Q1} GROUP BY sitename ORDER BY SUM(QuerySize) DESC";
$html="
<br>
<center>
<table style='width:500px;border:1px solid #CCCCCC'>
<tr>
<th colspan=2>{website}</th>
<th>size</th>
</tr>
";
$q=new mysql();
$results=$q->QUERY_SQL($sql,"artica_events");
while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
$js="Loadjs('squid.uris.stats.php?domain={$ligne["sitename"]}&user=$user&t=$t')";
$html=$html."
<tr". CellRollOver().">
<td width=1%><img src='img/web-22.png'></td>
<td style='font-size:13px' ". CellRollOver($js,"{display_queries_list}").">{$ligne["sitename"]}</td>
<td style='font-size:13px'>". FormatBytes($ligne["tsize"]/1024)."</td>
</tr>
";
}
$html=$html."</table></center>";
echo $html;
}
?>