/
dansguardian.db.status.php
221 lines (144 loc) · 5.73 KB
/
dansguardian.db.status.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?php
include_once('ressources/class.templates.inc');
include_once('ressources/class.ldap.inc');
include_once('ressources/class.users.menus.inc');
include_once('ressources/class.artica.inc');
include_once('ressources/class.ini.inc');
include_once('ressources/class.squid.inc');
include_once('ressources/class.dansguardian.inc');
header("Pragma: no-cache");
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate");
$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;}
js();
function js(){
$page=CurrentPageName();
$tpl=new templates();
$title=$tpl->_ENGINE_parse_body('{DANSGUARDIAN_BLACKLISTS_STATUS}');
$html="
var mem_rule_id='';
var mem_cat='';
var rule_main_mem='';
function DANSGUARDIAN_BLACKLISTS_STATUS(){
YahooWin2(770,'$page?popup=yes','$title','');
}
DANSGUARDIAN_BLACKLISTS_STATUS();";
echo $html;
}
//squidguard-db-status
function popup_squidguard(){
$sock=new sockets();
$datas=unserialize(base64_decode($sock->getFrameWork("cmd.php?squidguard-db-status=yes")));
$tpl=new templates();
$html="
<div style='font-size:14px;'>{DANSGUARDIAN_DB_STATUS_EXPLAIN}</div>
<div style='width:100%;height:350px;overflow:auto'>
<table style='width:100%'>
<tr>
<th style='font-size:14px' nowrap>{category}</th>
<th style='font-size:14px' nowrap>{domains}</th>
<th style='font-size:14px' nowrap>{urls}</th>
<th style='font-size:14px' nowrap>Regex</th>
<th style='font-size:14px' nowrap>{date}</th>
<th style='font-size:14px' nowrap>{squidguard_database_size}</th>
</tr>";
if(!is_array($datas)){
echo $tpl->_ENGINE_parse_body("<H2>{error_no_datas}</H2>");
return;
}
while (list ($path, $array) = each ($datas) ){
// if($path==null){continue;}
$category=squidguard_extract_category($path);
$Narray[$category][$array["type"]]["linesn"]=$array["linesn"];
$Narray[$category][$array["type"]]["size"]=$array["size"];
$Narray[$category][$array["type"]]["date"]=$array["date"];
}
while (list ($category, $array2) = each ($Narray) ){
if($array2["expressionlist"]["linesn"]==null){$array2["expressionlist"]["linesn"]=0;}
if($array2["domainlist"]["linesn"]==null){$array2["expressionlist"]["linesn"]=0;}
if($array2["urllist"]["linesn"]==null){$array2["expressionlist"]["linesn"]=0;}
if(is_array($array2["domainlist"])){
if($array2["domainlist"]["size"]==null){
$not_compiled=texttooltip("{not_compiled}","{compile_squidguard_databases}<hr><i>{compile_squidguard_databases_text}</i>","Loadjs('squidguard.status.php?compile=yes')",0,"color:red;font-size:14px;font-weight:bold");
$array2["domainlist"]["size"]="<span style='color:red'>$not_compiled</span>";
}else{$array2["domainlist"]["size"]=FormatBytes($array2["domainlist"]["size"]/1024);}
}else{
$array2["domainlist"]["size"]="-";
}
if($array2["domainlist"]["date"]==null){
$array2["domainlist"]["date"]=$array2["expressionlist"]["date"];
}
$date=date('d M y h:i',$array2["domainlist"]["date"]);
if(preg_match("#personal-categories\/(.+)#",$category,$re)){
$category="{personal}: {$re[1]}";
}
if(preg_match("#web-filter-plus\/BL\/(.+)#",$category,$re)){
$category="{professional}: {$re[1]}";
}
if(preg_match("#blacklist-artica\/(.+)#",$category,$re)){
$category="{artica_community}: {$re[1]}";
}
$html=$html."
<tr ". CellRollOver().">
<td style='font-size:14px' nowrap><strong>$category</strong></td>
<td style='font-size:14px' align='right' width=1%><strong>{$array2["domainlist"]["linesn"]}</strong></td>
<td style='font-size:14px' align='right' width=1%>{$array2["urllist"]["linesn"]}</td>
<td style='font-size:14px' align='right' width=1%>{$array2["expressionlist"]["linesn"]}</td>
<td style='font-size:14px' align='right' width=1% nowrap>$date</td>
<td style='font-size:14px' align='right' width=1%>{$array2["domainlist"]["size"]}</td>
</TR>
";
}
$html=$html."</table></div>";
echo $tpl->_ENGINE_parse_body($html,'squid.index.php');
}
function squidguard_extract_category($path){
$path=str_replace("/var/lib/squidguard/",'',$path);
$path=dirname($path);
return $path;
}
function popup(){
$sock=new sockets();
if($sock->GET_INFO('squidGuardEnabled')==1){popup_squidguard();exit;}
$tpl=new templates();
$datas=unserialize(base64_decode(@file_get_contents("ressources/logs/dansguardian.patterns")));
if(!is_array($datas)){
echo "<center><img src='img/database-urls-error-256.png'></center>";
exit;
}
$html="
<div style='font-size:14px;'>{DANSGUARDIAN_DB_STATUS_EXPLAIN}</div>
<div style='width:100%;height:350px;overflow:auto'>
<table style='width:100%'>
<tr>
<th style='font-size:14px' nowrap>{category}</th>
<th style='font-size:14px' nowrap>{domains}</th>
<th style='font-size:14px' nowrap>{urls}</th>
<th style='font-size:14px' nowrap>{pattern_date}</th>
</tr>";
//javascript:Loadjs('squidguard.status.php?compile=yes')
while (list ($num, $array) = each ($datas) ){
$Y=date('Y');
$d=date('Y-m-d');
$array[2]=str_replace($d,"{today}",$array[2]);
$array[2]=str_replace("$Y-","",$array[2]);
$html=$html."
<tr ". CellRollOver().">
<td style='font-size:14px'><strong>$num</strong></td>
<td style='font-size:14px' align='right' width=1%>{$array[0]}</td>
<td style='font-size:14px' align='right' width=1%>{$array[1]}</td>
<td style='font-size:14px' align='right' width=1% nowrap>{$array[2]}</td>
</TR>
";
}
$html=$html."</table></div>";
echo $tpl->_ENGINE_parse_body($html,'squid.index.php');
}
?>