forked from poppyred/1.6.x
/
dansguardian.groups.auth.php
executable file
·303 lines (228 loc) · 7.68 KB
/
dansguardian.groups.auth.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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<?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.groups.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-group"])){popup_group();exit;}
if(isset($_GET["choose-group"])){groups_fields();exit;}
if(isset($_GET["popup-members"])){group_members();exit;}
if(isset($_GET["RuleID"])){save();exit;}
if(isset($_GET["show-membrs"])){group_members_js();exit;}
if(isset($_GET["delete-js"])){delete_js();exit;}
if(isset($_GET["delete-id"])){delete_id();exit;}
if(isset($_GET["js-groups"])){js_group();exit;}
table_list();
function delete_id(){
$sql="DELETE FROM dansguardian_groups WHERE ID={$_GET["delete-id"]}";
$q=new mysql();
$q->QUERY_SQL($sql,"artica_backup");
}
function delete_js(){
$page=CurrentPageName();
$html="
var x_DeleteGroupAuth= function (obj) {
var res=obj.responseText;
if (res.length>0){alert(res);return;}
RefreshDansRulesIPList();
}
function DeleteGroupAuth(){
var XHR = new XHRConnection();
XHR.appendData('delete-id','{$_GET["delete-js"]}');
XHR.sendAndLoad('$page', 'GET',x_DeleteGroupAuth);
}
DeleteGroupAuth();";
echo $html;
}
function table_list(){
$page=CurrentPageName();
$dansg=new dansguardian_rules(null,$rule);
$rules=$dansg->hash_RulesList();
$tpl=new templates();
$group_legend=$tpl->_ENGINE_parse_body('{add_group}');
$please=$tpl->_ENGINE_parse_body('{PLEASE_SELECT_GROUP_FIRST}');
$view_members_text=$tpl->_ENGINE_parse_body('{view_members}');
$html="
<hr style='color:#005447'>
<div style='width:100%;text-align:right'>
". button("{add_group}","DansGuardianAuthAddGrp()")."</div>
<center style='padding:10px'>
<table style='width:99;border:2px solid #CCCCCC;padding:3px'>
<tr>
<th> </th>
<th style='font-size:14px;font-weight:bolder'>{organization}</th>
<th style='font-size:14px;font-weight:bolder'>{groups}</th>
<th style='font-size:14px;font-weight:bolder'>{members}</th>
<th style='font-size:14px;font-weight:bolder'>{rule}</th>
<th> </th>
<th> </th>
</tr>
";
$sql="SELECT * FROM dansguardian_groups ORDER BY RuleID DESC";
$q=new mysql();
$results=$q->QUERY_SQL($sql,"artica_backup");
while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
$num=$ligne["ID"];
$gpid=$ligne["group_id"];
$group=new groups($gpid);
$delete=imgtootltip("delete-32.png",'{delete}',"Loadjs('$page?delete-js=$num')");
$dansguardian_rule=$rules[$ligne["RuleID"]];
$members=count($group->members);
$view_members=null;
if($group->ou==null){$group->ou="{error}";$delete=null;}
if($group->groupName==null){$group->groupName="{error}";$delete=null;}
if($members>0){
$view_members=imgtootltip("view_members-32.png","{view_members}","Loadjs('$page?show-membrs=$gpid')");
}
$html=$html . "
<tr ". CellRollOver().">
<td width=1%><img src='img/group-32.png'></td>
<td style='font-size:14px;font-weight:bolder'>$group->ou</td>
<td style='font-size:14px;font-weight:bolder'>$group->groupName</td>
<td style='font-size:14px;font-weight:bolder' align='center'>$members</td>
<td style='font-size:14px;font-weight:bolder'>$dansguardian_rule</td>
<td style='font-size:14px;font-weight:bolder'>$view_members</td>
<td width=1%>$delete</td>
</tr>
";
}
$html=$html . "</table></center><hr style='color:#005447'>
<script>
function DansGuardianAuthAddGrp(){
YahooWin3(500,'$page?popup-group=yes','$group_legend');
}
function DansGuardianAuthChooseOrg(){
LoadAjax('dans-groups','$page?choose-group='+document.getElementById('ou').value);
}
var x_DansGuardianAuthAdd= function (obj) {
var res=obj.responseText;
if (res.length>0){alert(res);return;}
LoadAjax('dansguardian_auth','$page');
YahooWin3Hide();
}
function DansGuardianAuthAdd(){
if(!document.getElementById('gpid').value){
alert('$please');
return;
}
var gpid=document.getElementById('gpid').value;
var RuleID=document.getElementById('RuleID').value;
if(gpid.length==0){
alert('$please');
return;
}
if(RuleID.length==0){return;}
var XHR = new XHRConnection();
XHR.appendData('gpid',gpid);
XHR.appendData('RuleID',RuleID);
XHR.sendAndLoad('$page', 'GET',x_DansGuardianAuthAdd);
}
function DansGuardianShowMembers(gpid){
YahooWin3(500,'$page?popup-members='+gpid,'$view_members_text');
}
</script>
";
$tpl=new templates();
if($noecho==1){return $tpl->_ENGINE_parse_body($html);}
echo $tpl->_ENGINE_parse_body($html);
}
function js_group(){
$page=CurrentPageName();
$tpl=new templates();
$group_legend=$tpl->_ENGINE_parse_body('{add_group}');
$html="
";
echo $html;
}
function popup_group(){
$ldap=new clladp();
$orgs=$ldap->hash_get_ou(true);
$orgs[null]="{select}";
$organizations=Field_array_Hash($orgs,'ou',null,"DansGuardianAuthChooseOrg()",null,0,"font-size:15px;padding:4px");
$dansg=new dansguardian_rules();
$rules=$dansg->hash_RulesList();
$rules[null]="{select}";
$rules_list=Field_array_Hash($rules,'RuleID',null,null,null,0,"font-size:15px;padding:4px");
$html="
<table style='width:99%'>
<tr>
<td class=legend style='font-size:15px'>{organization}:</td>
<td>$organizations</td>
</tr>
<tr><td class=legend style='font-size:15px'>{groups}:</td>
<td><span id='dans-groups'></span>
</tr>
<tr>
<td class=legend style='font-size:15px'>{rule}:</td>
<td>$rules_list</td>
</tr>
<tr>
<td colspan=2 align='right'><hr>". button("{add}","DansGuardianAuthAdd()")."</td>
</tr>
</table>
";
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);
}
function groups_fields(){
$ou=$_GET["choose-group"];
if($ou==null){return null;}
$ldap=new clladp();
$tpl=new templates();
$hash=$ldap->hash_groups($ou,1);
$hash[null]=$tpl->_ENGINE_parse_body("{select}");
$groups=Field_array_Hash($hash,'gpid',null,null,null,0,"font-size:15px;padding:4px");
echo $groups;
}
function save(){
$sql="INSERT INTO dansguardian_groups(RuleID,group_id) VALUES('{$_GET["RuleID"]}','{$_GET["gpid"]}')";
$q=new mysql();
$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){echo $q->mysql_error;return;}
$sock=new sockets();
$sock->getFrameWork("cmd.php?reload-dansguardian");
}
function group_members_js(){
$tpl=new templates();
$page=CurrentPageName();
$view_members=$tpl->_ENGINE_parse_body("{view_members}");
$html="
YahooWin3(500,'$page?popup-members={$_GET["show-membrs"]}','$view_members');
";
echo $html;
}
function group_members(){
$gpid=$_GET["popup-members"];
$q=new mysql();
$sql="SELECT dngroup FROM dansguardian_groups WHERE group_id='{$gpid}'";
$ligne=@mysql_fetch_array($q->QUERY_SQL($sql,'artica_backup'));
if(trim($ligne["dngroup"])<>null){$group=new groups($ligne["dngroup"]);}else{
$group=new groups($gpid);}
$html="<H1>$group->groupName</H1>
<div style='height:300px;overflow:auto'>
<table style='width:99%'>";
while (list ($key, $member) = each ($group->members) ){
$html=$html."
<tr ". CellRollOver().">
<td width=1%><img src='img/identity-32.png'></td>
<td style='font-size:16px;padding:3px'>$member</td>
</tr>
";
}
$html=$html."</table></div>";
echo $html;
}
?>