forked from poppyred/1.6.x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
miniadm.squid.macbrowser.php
executable file
·184 lines (142 loc) · 5.45 KB
/
miniadm.squid.macbrowser.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
session_start();$_SESSION["MINIADM"]=true;
ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string',null);
ini_set('error_append_string',null);
if(!isset($_SESSION["uid"])){header("location:miniadm.logon.php");}
include_once(dirname(__FILE__)."/ressources/class.templates.inc");
include_once(dirname(__FILE__)."/ressources/class.users.menus.inc");
include_once(dirname(__FILE__)."/ressources/class.miniadm.inc");
include_once(dirname(__FILE__)."/ressources/class.mysql.squid.builder.php");
include_once(dirname(__FILE__)."/ressources/class.user.inc");
include_once(dirname(__FILE__)."/ressources/class.squid.inc");
include_once(dirname(__FILE__)."/ressources/class.calendar.inc");
if(!$_SESSION["AsWebStatisticsAdministrator"]){die();}
if(isset($_GET["popup"])){popup();exit;}
if(isset($_GET["search-records"])){search_records();exit;}
if(isset($_GET["visits-day-js"])){visists_days_js();exit;}
if(isset($_GET["visits-day-popup"])){visists_days_popup();exit;}
js();
function js(){
$tpl=new templates();
$page=CurrentPageName();
header("content-type: application/x-javascript");
$title=$tpl->javascript_parse_text("{MAC}");
echo "YahooWin4('700','$page?popup=yes&field={$_GET["field"]}','$title')";
}
function visists_days_js(){
$tpl=new templates();
$page=CurrentPageName();
header("content-type: application/x-javascript");
$title=$tpl->javascript_parse_text("{MAC}::{$_GET["visits-day-js"]}");
echo "YahooWin5('700','$page?visits-day-popup=yes&MAC={$_GET["visits-day-js"]}','$title')";
}
function popup(){
$sock=new sockets();
$boot=new boostrap_form();
$tpl=new templates();
$page=CurrentPageName();
$t=time();
echo $boot->SearchFormGen("MAC","search-records")."<script>
ExecuteByClassName('SearchFunction');
</script>";
}
function FormatNumber($number, $decimals = 0, $thousand_separator = ' ', $decimal_point = '.'){
$tmp1 = round((float) $number, $decimals);
while (($tmp2 = preg_replace('/(\d+)(\d\d\d)/', '\1 \2', $tmp1)) != $tmp1)
$tmp1 = $tmp2;
return strtr($tmp1, array(' ' => $thousand_separator, '.' => $decimal_point));
}
function search_records(){
$q=new mysql_squid_builder();
$page=CurrentPageName();
$tpl=new templates();
$limitSql="LIMIT 0,150";
$t=time();
$searchstring=string_to_flexquery("search-records");
$sql="SELECT * FROM (SELECT SUM(hits) as hits,SUM(size) as size,MAC FROM members_mac GROUP BY MAC ORDER BY size DESC,hits DESC) as t WHERE 1 $searchstring";
writelogs($sql,__FUNCTION__,__FILE__,__LINE__);
$results = $q->QUERY_SQL($sql);
$sock=new sockets();
$boot=new boostrap_form();
if(!$q->ok){
echo "<p class=text-error>$q->mysql_error<hr><code>$sql</code></p>";
}
while ($ligne = mysql_fetch_assoc($results)) {
$ligne["MAC"]=strtolower($ligne["MAC"]);
$ligne["MAC"]=str_replace("-", ":", $ligne["MAC"]);
$ligne["size"]=FormatBytes($ligne["size"]/1024);
$ligne["hits"]=FormatNumber($ligne["hits"]);
$ligne2=mysql_fetch_array($q->QUERY_SQL("SELECT uid FROM webfilters_nodes WHERE MAC='{$ligne["MAC"]}'"));
$uid=$ligne2["uid"];
$explainMac=null;
if($uid<>null){$uid=" ($uid)";}
$linkVisit=$boot->trswitch("Loadjs('$page?visits-day-js={$ligne["MAC"]}')");
$ips=array();
$results2 = $q->QUERY_SQL("SELECT ipaddr FROM members_macip WHERE MAC='{$ligne["MAC"]}' ORDER BY ipaddr");
while ($ligne2 = mysql_fetch_assoc($results2)) {
$ips[]=$ligne2["ipaddr"];
}
if(count($ips)>0){$explainMac="$explainMac<div><i style='font-size:11px'>".@implode(", ", $ips)."</i></div>";}
$tr[]="
<tr id='$id'>
<td $link><i class='icon-globe'></i> {$ligne["MAC"]}$uid</a>$explainMac</td>
<td $linkVisit><i class='icon-download'></i> {$ligne["size"]} </td>
<td $linkVisit><i class='icon-signal'></i> {$ligne["hits"]} </td>
</tr>";
}
echo $tpl->_ENGINE_parse_body("
<table class='table table-bordered table-hover'>
<thead>
<tr>
<th>{MAC}</th>
<th>{size}</th>
<th>{hits}</th>
</tr>
</thead>
<tbody>
").@implode("\n", $tr)." </tbody>
</table>
";
}
function visists_days_popup(){
$q=new mysql_squid_builder();
$page=CurrentPageName();
$tpl=new templates();
$t=time();
$sql="SELECT SUM(hits) as hits,SUM(size) as size,MAC,zDate
FROM members_mac GROUP BY MAC,zDate HAVING MAC='{$_GET["MAC"]}' ORDER BY zDate ";
writelogs($sql,__FUNCTION__,__FILE__,__LINE__);
$results = $q->QUERY_SQL($sql);
$sock=new sockets();
$boot=new boostrap_form();
if(!$q->ok){
echo "<p class=text-error>$q->mysql_error<hr><code>$sql</code></p>";
}
while ($ligne = mysql_fetch_assoc($results)) {
$ligne["size"]=FormatBytes($ligne["size"]/1024);
$ligne["hits"]=FormatNumber($ligne["hits"]);
$xtime=strtotime($ligne["zDate"]." 00:00:00");
$dateT=date("{l} {F} d",$xtime);
if($tpl->language=="fr"){$dateT=date("{l} d {F} ",$xtime);}
$linkVisit=$boot->trswitch("Loadjs('miniadm.webstats.ByMAC.popup.php?MAC={$ligne["MAC"]}&xtime=$xtime')");
$tr[]=$tpl->_ENGINE_parse_body("
<tr id='{$ligne["MAC"]}'>
<td $linkVisit><i class='icon-time'></i> {$dateT}</a></td>
<td $linkVisit><i class='icon-download'></i> {$ligne["size"]} </td>
<td $linkVisit><i class='icon-signal'></i> {$ligne["hits"]} </td>
</tr>");
}
echo $tpl->_ENGINE_parse_body("
<table class='table table-bordered table-hover'>
<thead>
<tr>
<th>{date}</th>
<th>{size}</th>
<th>{hits}</th>
</tr>
</thead>
<tbody>
").@implode("\n", $tr)." </tbody>
</table>
";
}