forked from dtouzeau/artica
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dansguardian.categories.php
185 lines (136 loc) · 5.25 KB
/
dansguardian.categories.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
<?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");
if(!IsDansGuardianrights()){
$tpl=new templates();
echo "alert('".$tpl->javascript_parse_text("{ERROR_NO_PRIVS}")."');";
exit;
}
if(isset($_GET["popup"])){popup();exit;}
if(isset($_GET["DansGuardian_addcategory"])){main_rules_addcategory();exit;}
if(isset($_GET["DansGuardian_delcategory"])){main_rules_delcategory();exit;}
if(isset($_GET["display-categories"])){main_rules_categories_list($_GET["display-categories"]);exit;}
js();
function js(){
$tpl=new templates();
$page=CurrentPageName();
$rulename=base64_decode($_GET["rule-name"]);
$title=$tpl->_ENGINE_parse_body("{categories}");
$html="
function DANSGUARDIAN_LOAD_CATEGORIES(){
RTMMail(650,'$page?popup=yes&rule_main={$_GET["rule_main"]}','$title');
}
var x_dansguardian_addcategory=function(obj){
DANSGUARDIAN_LOAD_CATEGORIES();
}
function dansguardian_addcategory(){
var XHR = new XHRConnection();
XHR.appendData('DansGuardian_addcategory',document.getElementById('blacklist').value);
XHR.appendData('rule_main','{$_GET["rule_main"]}');
document.getElementById('main_rules_categories_list').innerHTML='<center style=\"width:100%\"><img src=img/wait_verybig.gif></center>';
XHR.sendAndLoad('$page', 'GET',x_dansguardian_addcategory);
}
function dansguardian_delcategory(hostname,rule_main,index){
var XHR = new XHRConnection();
hostname_mem=hostname;
rule_main_mem=rule_main;
XHR.appendData('DansGuardian_delcategory',index);
XHR.appendData('rule_main','{$_GET["rule_main"]}');
document.getElementById('main_rules_categories_list').innerHTML='<center style=\"width:100%\"><img src=img/wait_verybig.gif></center>';
XHR.sendAndLoad('$page', 'GET',x_dansguardian_addcategory);
}
var X_DansCategoryEnable= function (obj) {
var results=obj.responseText;
if(results.length>0){alert(results);}
}
function DansCategoryEnable(md,cat,index,rule_main){
var XHR = new XHRConnection();
XHR.appendData('rule_main','{$_GET["rule_main"]}');
if(document.getElementById(md).checked){
XHR.appendData('DansGuardian_addcategory',cat);
}else{
XHR.appendData('DansGuardian_delcategory',index);
}
XHR.sendAndLoad('$page', 'GET',X_DansCategoryEnable);
}
function DansGuardianRefreshCategories(){
LoadAjax('main_rules_categories_list','$page?display-categories={$_GET["rule_main"]}');
}
DANSGUARDIAN_LOAD_CATEGORIES()";
echo $html;
}
function strip_rulename($rulename){
if(preg_match('#(.+?);(.+)#',$rulename,$re)){
return $re[1];
}else{
return $rulename;
}
}
function popup($noecho=0){
$rule_main=$_GET["rule_main"];
$dans=new dansguardian_rules($_GET["hostname"],$rule_main);
$dansg=new dansguardian($_GET["hostname"]);
$rulename=strip_rulename($dansg->Master_rules_index[$rule_main]);
$html="
<input type='hidden' name='rule_main' value='$rule_main'>
<p class=caption>{categories_explain}</p>
<div id='main_rules_categories_list' style='width:100%;height:650px;overflow:auto'></div>
<script>
DansGuardianRefreshCategories();
</script>
";
$tpl=new templates();
if($noecho==1){return $tpl->_ENGINE_parse_body("$html","dansguardian.index.php");}
echo $tpl->_ENGINE_parse_body("$html");
}
function main_rules_categories_list($rule_main,$noecho=0){
$dans=new dansguardian_rules();
$html="
<table style='width:100%'>
<tr>
<th>{category}</th>
<th colspan=2>{enabled}</th>
</tr>";
$q=new mysql();
$sql="SELECT * FROM dansguardian_files WHERE filename='bannedsitelist' AND RuleID=$rule_main";
$results=$q->QUERY_SQL($sql,"artica_backup");
while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
$val=$ligne["pattern"];
$array_selected[$val]=$ligne["ID"];
}
$array_cat=$dans->array_blacksites;
while (list ($num, $val) = each ($array_cat) ){
if($array_selected[$num]>0){$enabled=1;}else{$enabled=0;}
$md=md5($num);
$html=$html."
<tr ". CellRollOver().">
<td><strong style='font-size:11px'>$val</td>
<td>".Field_checkbox("$md",1,$enabled,"DansCategoryEnable('$md','$num','{$array_selected[$num]}','$rule_main')")."</td>
<td>$num</td>
</tr>
";
}
$categ="<div style='width:100%;height:600px;overflow:auto'>$html</div>";
$tpl=new templates();
if($noecho==1){return $tpl->_ENGINE_parse_body($categ);}
echo $tpl->_ENGINE_parse_body("$categ");
}
function main_rules_addcategory(){
writelogs("add new category ->{$_GET["rule_main"]}={$_GET["DansGuardian_addcategory"]} ",__FUNCTION__,__FILE__);
$dans=new dansguardian_rules($_GET["hostname"],$_GET["rule_main"]);
$dans->AddCategory($_GET["DansGuardian_addcategory"],$_GET["rule_main"]);
}
function main_rules_delcategory(){
$dans=new dansguardian_rules($_GET["hostname"],$_GET["rule_main"]);
$dans->DelCategory($_GET["rule_main"],$_GET["DansGuardian_delcategory"]);
}
?>