-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathAdmin.php
219 lines (209 loc) · 7.44 KB
/
Admin.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
<!DOCTYPE html>
<!--
Project: Bitcraft Service Desk (An Open Source ITSM Web App)
Lead Devs: Joshua Nasiatka, Allen Perry, Eugene Duffy
For: Software Engineering
Dev Date: Spring 2016
Status: Staging; Idea Testing; Development
-->
<?php
include("modules/mainhead.php");
if (!($myACL->hasPermission('access_admin')) && !($myACL->hasPermission('manage_templates')) && !($myACL->hasPermission('manage_users'))) {
header("location: /");
exit;
}
include_once 'modules/admin/head.php';
?>
<?php
if (isset($_POST['action'])) {
switch($_POST['action']) {
case 'saveRoles':
$redir = "?page=users&action=ViewAdmin&for=" . $_POST['userID'] . "&do=ChangeAccess";
foreach ($_POST as $k => $v) {
if (substr($k,0,5) == "role_") {
$roleID = str_replace("role_","",$k);
if ($v == '0' || $v == 'x') {
$strSQL = sprintf("DELETE FROM `user_roles` WHERE `userID` = %u AND `roleID` = %u",$_POST['userID'],$roleID);
} else {
$strSQL = sprintf("REPLACE INTO `user_roles` SET `userID` = %u, `roleID` = %u, `addDate` = '%s'",$_POST['userID'],$roleID,date ("Y-m-d H:i:s"));
}
mysql_query($strSQL);
}
}
break;
case 'savePerms':
$redir = "?page=users&action=ViewAdmin&for=" . $_POST['userID'] . "&do=ChangeAccess";
foreach ($_POST as $k => $v) {
if (substr($k,0,5) == "perm_") {
$permID = str_replace("perm_","",$k);
if ($v == 'x') {
$strSQL = sprintf("DELETE FROM `user_perms` WHERE `userID` = %u AND `permID` = %u",$_POST['userID'],$permID);
} else {
$strSQL = sprintf("REPLACE INTO `user_perms` SET `userID` = %u, `permID` = %u, `value` = %u, `addDate` = '%s'",$_POST['userID'],$permID,$v,date ("Y-m-d H:i:s"));
}
mysql_query($strSQL);
}
}
break;
case 'saveRoleInfo':
$redir = "?page=groups&action=ViewAdmin&for=" . $_POST['roleID'] . "&do=EditGroup";
$strSQL = sprintf("REPLACE INTO `roles` SET `ID` = %u, `roleName` = '%s'",$_POST['roleID'],$_POST['roleName']);
mysql_query($strSQL);
if (mysql_affected_rows() > 1)
{
$roleID = $_POST['roleID'];
} else {
$roleID = mysql_insert_id();
}
foreach ($_POST as $k => $v)
{
if (substr($k,0,5) == "perm_")
{
$permID = str_replace("perm_","",$k);
if ($v == 'X')
{
$strSQL = sprintf("DELETE FROM `role_perms` WHERE `roleID` = %u AND `permID` = %u",$roleID,$permID);
mysql_query($strSQL);
continue;
}
$strSQL = sprintf("REPLACE INTO `role_perms` SET `roleID` = %u, `permID` = %u, `value` = %u, `addDate` = '%s'",$roleID,$permID,$v,date ("Y-m-d H:i:s"));
mysql_query($strSQL);
}
}
break;
case 'deleteRole':
$redir = "?page=groups&action=ViewAdmin";
$strSQL = sprintf("DELETE FROM `roles` WHERE `ID` = %u LIMIT 1",$_POST['roleID']);
mysql_query($strSQL);
$strSQL = sprintf("DELETE FROM `user_roles` WHERE `roleID` = %u",$_POST['roleID']);
mysql_query($strSQL);
$strSQL = sprintf("DELETE FROM `role_perms` WHERE `roleID` = %u",$_POST['roleID']);
mysql_query($strSQL);
break;
}
header("location: Admin.php" . $redir);
}
?>
<?php echo "<body class='hold-transition skin-$skin sidebar-mini'>"; ?>
<div class="wrapper">
<?php
// build the user interface
include_once 'modules/header.php';
include_once 'modules/left_sidebar.php';
include_once 'modules/admin/functions.php';
include_once 'modules/admin/admin.php';
include_once 'modules/footer.php';
include_once 'modules/control_sidebar.php';
?>
</div><!-- ./wrapper -->
<!-- REQUIRED JS SCRIPTS -->
<!-- jQuery -->
<script src="bower/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="bower/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- AdminLTE App -->
<script src="bower/AdminLTE/dist/js/app.min.js"></script>
<!-- DataTables -->
<script src="bower/AdminLTE/plugins/datatables/jquery.dataTables.js"></script>
<script src="bower/AdminLTE/plugins/datatables/dataTables.bootstrap.js"></script>
<!-- SlimScroll -->
<script src="bower/AdminLTE/plugins/slimScroll/jquery.slimscroll.js"></script>
<!-- FastClick -->
<script src="bower/AdminLTE/plugins/fastclick/fastclick.min.js"></script>
<!-- InputMask -->
<script src="bower/AdminLTE/plugins/input-mask/jquery.inputmask.js"></script>
<script src="bower/AdminLTE/plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
<script src="bower/AdminLTE/plugins/input-mask/jquery.inputmask.extensions.js"></script>
<script src="bower/bootstrap-switch/dist/js/bootstrap-switch.min.js"></script>
<script src="bower/image-picker/image-picker/image-picker.min.js"></script>
<?php if($_GET['page'] == "cpanel" && $_GET['subpage'] == "backup_restore") {
echo "<script src='dist/js/backup_restore.js'></script>";
echo "<script>
var form_upload = $('.box');
if(isAdvancedUpload) {
var droppedFiles = false;
form_upload.on('drag dragstart dragend dragover dragenter dragleave drop', function(e) {
e.preventDefault();
e.stopPropagation();
})
.on('dragover dragenter', function() {
form_upload.addClass('is-dragover');
})
.on('dragleave dragend drop', function() {
form_upload.removeClass('is-dragover');
})
.on('drop', function(e) {
droppedFiles = e.originalEvent.dataTransfer.files;
});
}
</script>";
} ?>
<script>
$("[name='dev_on']").bootstrapSwitch();
$("[name='dev_alert']").bootstrapSwitch();
$("#main_logo_picker").imagepicker();
$("#main_logo_small_picker").imagepicker();
$("#top_bar_picker").imagepicker();
$(".alert.alert-success").fadeTo(2000, 500).slideUp(500, function(){
$(".alert.alert-success").alert('close');
window.location.href = window.location.href;
});
</script>
<!-- page script -->
<script>
$(function () {
$('#adm_acl').DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"info": true,
"autoWidth": false
});
});
$('body').on('click', '.btn-group', function (e) {
$(this).addClass('active');
$(this).siblings().removeClass('active');
});
jQuery(document).ready(function($) {
$("#sdesk li").hover(function () {
$(this).addClass("active");
}, function () {
$(this).removeClass("active");
});
$("#ddesk li").hover(function () {
$(this).addClass("active");
}, function () {
$(this).removeClass("active");
});
$(".clickableRow").click(function() {
window.document.location = $(this).data("href");
});
});
$(document).ready(function(){
//Manage hash in URL to open the right pill
var hash = window.location.hash;
// If a hash is provided
if(hash && hash.length>0)
{
// Manage Pill titles
$('ul.nav-pills li a').each(function( index ) {
if($(this).attr('href')==hash)
$(this).parent('li').addClass('active');
else
$(this).parent('li').removeClass('active');
});
// Manage Tab content
var hash = hash.substring(1); // Remove the #
$('div.tab-content div').each(function( index ) {
if($(this).attr('id')==hash)
$(this).addClass('active');
else
$(this).removeClass('active');
});
}
});
$('ul#adesk').toggle(200);
</script>
</body>
</html>