-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod.php
184 lines (130 loc) · 5.03 KB
/
mod.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
<?php
include "inc/init.php";
if(!isset($_GET['act']) || !isset($_GET['id']) || (!$user->exists($_GET['id'])) || !($user->hasPrivilege($_GET['id']))) {
header("Location: ". $set->url);
exit;
}
$u = $user->grabData($_GET['id']);
$page->title = "Moderator Panel";
$act = $_GET['act'];
$show_content = '';
if(($act == 'ban') && $user->group->canban && ($user->data->userid != $u->userid)) {
if($_POST) {
$period = $_POST['period'];
$reason = $_POST['reason'];
if(($period > 0 && $period <= $set->max_ban_period) && isset($reason[5])) {
$period *= 3600*24; // convert it into seconds
$db->query("UPDATE `".MLS_PREFIX."users` SET `banned` = '1' WHERE `userid` = '$u->userid'");
$db->query("INSERT INTO `".MLS_PREFIX."banned` SET `userid` = ?i, `by` = ?i, `until` = ?i, `reason` = ?s", $u->userid, $user->data->userid, time()+$period, $reason);
$page->success = "User has been banned successfully for ".(int)$_POST['period']." day(s) ! ";
} else {
$page->error = "Invalid period or reason !";
}
} else {
$ban_options = '';
for($i = 1; $i <= $set->max_ban_period; $i++)
$ban_options .= "<option value='$i'>$i day".($i == 1 ? '' : 's')."</option>";
$show_content = "
<form class='well form-horizontal' action='#' method='post'>
<fieldset>
<!-- Form Name -->
<legend>Ban ".$options->html($u->username)."</legend>
<!-- Select Basic -->
<div class='control-group'>
<label class='control-label' for='period'>Period</label>
<div class='controls'>
<select id='period' name='period' class='input-xlarge'>
$ban_options
</select>
</div>
</div>
<div class='control-group'>
<label class='control-label' for='reason'>Reason</label>
<div class='controls'>
<input type='text' id='reason' name='reason'>
</div>
</div>
<!-- Button -->
<div class='control-group'>
<label class='control-label' for='submit'></label>
<div class='controls'>
<button id='submit' name='submit' class='btn btn-primary'>Ban</button>
</div>
</div>
</fieldset>
</form>
";
// if he is already banned we show the unban option
if($u->banned) {
$banned = $user->getBan($u->userid);
$show_content = "
<form class='well form-horizontal' action='?act=unban&id=$u->userid' method='post'>
<fieldset>
<!-- Form Name -->
<legend>UnBan ".$options->html($u->username)."</legend>
".$options->info("This user was banned by <a href='$set->url/profile.php?u=$banned->by'>".$user->showName($banned->by)."</a> for `<i>".$options->html($banned->reason)."</i>`.",1)."
<!-- Button -->
<div class='control-group'>
<label class='control-label' for='submit'></label>
<div class='controls'>
<button id='submit' name='submit' class='btn btn-primary'>UnBan</button>
</div>
</div>
</fieldset>
</form>
";
}
}
} else if(($act == 'unban') && $user->group->canban) {
$db->query("UPDATE `".MLS_PREFIX."users` SET `banned` = '0' WHERE `userid` = ?i", $u->userid);
$db->query("DELETE FROM `".MLS_PREFIX."banned` WHERE `userid` = ?i", $u->userid);
header("Location: ". $set->url."/profile.php?u=$u->userid");
exit;
} else if(($act == 'avt') && $user->group->canhideavt) {
if($u->showavt == 0){
if($db->query("UPDATE `".MLS_PREFIX."users` SET `showavt` = '1' WHERE `userid` = ?i", $u->userid))
$_SESSION['success'] = 'Avatar showed successfully !';
} else
if($db->query("UPDATE `".MLS_PREFIX."users` SET `showavt` = '0' WHERE `userid` = ?i", $u->userid))
$_SESSION['success'] = 'Avatar hidden successfully !';
header("Location: ". $set->url."/profile.php?u=$u->userid");
exit;
} else if(($act == 'del') && $user->isAdmin() && ($user->data->userid != $u->userid)) {
if($_POST) { // we make sure that the users is deleted from all tables
$db->query("DELETE FROM `".MLS_PREFIX."users` WHERE `userid` = ?i", $u->userid);
$db->query("DELETE FROM `".MLS_PREFIX."privacy` WHERE `userid` = ?i", $u->userid);
$page->success = "You have deleted the user ".$options->html($u->username);
} else {
$show_content = "
<form class='well form-horizontal' action='?act=del&id=$u->userid' method='post'>
<fieldset>
<legend>Delete ".$options->html($u->username)."</legend>
".$options->error("You are about to DELETE ".$user->showName($u->userid).". Are you sure ?",1)."
<div class='control-group'>
<label class='control-label' for='submit'></label>
<div class='controls'>
<button id='submit' name='submit' class='btn btn-primary'>Yes DELETE</button> <a href='$set->url/profile.php?u=$u->userid' class='btn'>Cancel</a>
</div>
</div>
</fieldset>
</form>";
}
} else {
header("Location: ". $set->url."/profile.php?u=$u->userid");
exit;
}
include 'header.php';
echo "
<div class='container'>
<h3>Moderator Panel</h3>
<hr>
";
if(isset($page->error))
$options->error($page->error);
else if(isset($page->success))
$options->success($page->success);
echo "
$show_content
<br/> <a href='$set->url/profile.php?u=$u->userid' class='btn btn-primary'>Back to profile</a>
</div>";
include 'footer.php';