forked from ChristianBeer/ProFTPd-Admin
-
Notifications
You must be signed in to change notification settings - Fork 11
/
remove_user.php
115 lines (104 loc) · 3.5 KB
/
remove_user.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
<?php
/**
* This file is part of ProFTPd Admin
*
* @package ProFTPd-Admin
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
*
* @copyright Lex Brugman <[email protected]>
* @copyright Christian Beer <[email protected]>
* @copyright Ricardo Padilha <[email protected]>
*
*/
global $cfg;
include_once ("configs/config.php");
include_once ("includes/Session.php");
include_once ("includes/AdminClass.php");
$ac = new AdminClass($cfg);
$field_userid = $cfg['field_userid'];
$field_id = $cfg['field_id'];
if (empty($_REQUEST[$field_id])) {
header("Location: users.php");
die();
}
$id = $_REQUEST[$field_id];
if (!$ac->is_valid_id($id)) {
$errormsg = 'Invalid ID; must be a positive integer.';
} else {
$user = $ac->get_user_by_id($id);
if (!is_array($user)) {
$errormsg = 'User does not exist; cannot find ID '.$id.' in the database.';
} else {
$userid = $user[$field_userid];
}
}
if (empty($errormsg) && !empty($_REQUEST["action"]) && $_REQUEST["action"] == "reallyremove") {
$groups = $ac->get_groups();
foreach ($groups as $g_gid => $g_group) {
if (!$ac->remove_user_from_group($userid, $g_gid)) {
$errormsg = 'Cannot remove user "'.$userid.'" from group "'.$g_group.'"; see log files for more information.';
break;
}
}
if (empty($errormsg)) {
if ($ac->remove_user_by_id($id)) {
$infomsg = 'User "'.$userid.'" removed successfully.';
} else {
$errormsg = 'User "'.$userid.'" removal failed; see log files for more information.';
}
}
}
include ("includes/header.php");
?>
<?php include ("includes/messages.php"); ?>
<?php if (!empty($_REQUEST["action"]) && $_REQUEST["action"] == "reallyremove") { ?>
<!-- action: reallyremove -->
<div class="col-xs-12 col-sm-8 col-md-6 center">
<div class="panel panel-default">
<div class="panel-body">
<div class="row">
<div class="col-sm-12">
<!-- Actions -->
<div class="form-group">
<div class="col-sm-12">
<a class="btn btn-primary pull-right" href="users.php" role="button">View users »</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php } else { ?>
<!-- action: remove -->
<div class="col-xs-12 col-sm-8 col-md-6 center">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Remove user</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-sm-12">
<form role="form" class="form-horizontal" method="post">
<!-- GID -->
<div class="form-group">
<div class="col-sm-12">
<p>Please confirm removal of user "<?php echo $userid; ?>" with ID <?php echo $id; ?>.</p>
</div>
</div>
<!-- Actions -->
<div class="form-group">
<div class="col-sm-12">
<input type="hidden" name="<?php echo $field_id; ?>" value="<?php echo $id; ?>" />
<a class="btn btn-default" role="group" href="edit_user.php?action=show&<?php echo $field_id; ?>=<?php echo $id; ?>">Cancel</a>
<button type="submit" class="btn btn-danger pull-right" role="group" name="action" value="reallyremove" <?php if (isset($errormsg)) { echo 'disabled="disabled"'; } ?>>Remove user</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
<?php include ("includes/footer.php"); ?>