/
modcp.php
executable file
·194 lines (164 loc) · 6.3 KB
/
modcp.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
<?php
/**************************************************************************
* 0xBB ~ Bullettin Board *
**************************************************************************
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* =========================================================================*
* Software: 0xBB
* Software version: 2.0
* Author: KinG-InFeT
* Copyleft: GNU General Public License
* =========================================================================*
* modcp.php
***************************************************************************/
include "kernel.php";
show_header();
show_menu ();
list ($username, $password) = get_data ();
if (!login ($username, $password))
die (header('Location: index.php'));
if (!(level($username) == 'mod'))
die (header('Location: index.php'));
csrf_attemp($_SERVER['HTTP_REFERER']);
$usr = $username;
?>
<div class = 'path' id = 'path'>
<table>
<?php if(empty($_GET['mode'])) {?>
<tr><td><b><a href = 'index.php'>Home Forum</a></b></td></tr>
<?php }else{ ?>
<tr><td><b><a href = 'modcp.php'>Home MCP</a></b></td></tr>
<?php }?>
</table>
</div>
<div class = 'main_admin'>
<?php
switch (@$_GET ['mode']) {
case 1;
@$username = clear ($_POST ['username']);
if ($username) {
$query = "SELECT id,level FROM ". __PREFIX__ ."users WHERE username = '". $username ."'";
$row = mysql_fetch_row (mysql_query ($query));
if (!$row [0])
_err("Errore! L'Username Specificato non esiste!");
if($row[0] == nick2uid($usr))
_err("Errore! Banni il tuo stesso account?!");
if($row[1] == 'banned')
mysql_query("UPDATE ". __PREFIX__ ."users SET level= 'user' WHERE username = '". $username ."'") or _err(mysql_error());
else
mysql_query("UPDATE ". __PREFIX__ ."users SET level= 'banned' WHERE username = '". $username ."'") or _err(mysql_error());
print '<script>window.location="modcp.php?mode=1";</script>';
}else{
print "
<form action = 'modcp.php?mode=1' method = 'POST'>\n
<br /><b>Banna\Sbanna Utente:</b>\n<br /><br />\n
Inserire l'username: <input name = 'username' maxleght='20'><br />\n
<input type = 'submit' value = 'Banna'>\n
</form>\n";
}
print "<br /><b>Utenti Bannati:</b><p>\n";
$query = "SELECT id, username FROM ". __PREFIX__ ."users WHERE level = 'banned'";
$res = mysql_query ($query);
while ($row = mysql_fetch_row ($res))
print "<a href = 'profile.php?id=". $row[0] ."'>". $row[1] ."</a><br />\n";
break;
case 2:
@$ip = clear ($_REQUEST['ip']);
if (($ip) && (@$_GET['ban'] == 2)) {
$query = "SELECT * FROM ". __PREFIX__ ."ban_ip WHERE ip = '{$ip}'";
$row = mysql_fetch_row (mysql_query ($query));
if (!$row [2]) {
//ip inesistente quindi lo aggiungo
$ban_ip = "INSERT INTO ". __PREFIX__ ."ban_ip (
user_id, ip, banned
) VALUES (
'', '".$ip."', '1')";
mysql_query($ban_ip) or _err(mysql_error());
}else{
_err("Errore! Questo IP esiste nel Database!");
}
header ("Location: modcp.php?mode=2");
}
else {
?>
<form action = 'modcp.php?mode=2&ban=2' method = 'POST'>
<br /><b>Gestione Ban per IP:</b>
<p>Banna IP Esterno: <input name = 'ip'><br />
<input type = 'submit' value = 'Banna'></p>
</form>
<br /><br />
<?php
}
if(@$_GET['ban'] == 1) {
$query = "SELECT * FROM ". __PREFIX__ ."ban_ip WHERE ip = '{$ip}'";
$row = mysql_fetch_row (mysql_query ($query));
if($row[1] == nick2uid($usr))
_err("Errore! Questo IP da bannare è identico al tuo, ti banni?");
if ($row [3] == 0)
$query = "UPDATE ". __PREFIX__ ."ban_ip SET banned = '1' WHERE id = '". $row [0]. "'";
else
$query = "UPDATE ". __PREFIX__ ."ban_ip SET banned = '0' WHERE id = '". $row [0] ."'";
mysql_query ($query) or _err(mysql_error());
header ("Location: modcp.php?mode=2");
}
if((@$_GET['elimina'] == 1) && (!empty($_GET['id']))) {
$id = (int) $_GET['id'];
mysql_query("DELETE FROM ". __PREFIX__ ."ban_ip WHERE id = '". $id ."'") or _err(mysql_error());
print '<script>alert("IP Cancellato!); window.location="modcp.php?mode=2";</script>';
}
?>
<table border="1">
<tr><td>Username</td><td>IP</td><td>Bannato?</td><td></td></tr>
<?php
$query = "SELECT * FROM ". __PREFIX__ ."ban_ip";
$res = mysql_query ($query);
while ($row = mysql_fetch_row ($res)) {
if(($row[3] == 0) || ($row[3] == NULL))
$banned = "NO";
else
$banned = "SI";
if($banned == 'NO')
$banna = "<a href=\"modcp.php?mode=2&ip=".$row[2]."&ban=1\"><i>Banna</i></a> ~ <a href=\"modcp.php?mode=2&id=".$row[0]."&elimina=1\"><i>Elimina</i></a>";
else
$banna = "<a href=\"modcp.php?mode=2&ip=".$row[2]."&ban=1\"><i>Leva Ban</i></a> ~ <a href=\"modcp.php?mode=2&id=".$row[0]."&elimina=1\"><i>Elimina</i></a>";
if(!($row[1] == NULL))
$usr = "<a href = 'profile.php?id=".$row [1]."'>".user_id($row [1])."</a>";
else
$usr = "<i>IP Esterno</i>";
?>
<tr>
<td><?php print $usr; ?></td>
<td><?php print $row[2]; ?></td><td><?php print $banned; ?></td>
<td><?php print $banna; ?></td>
</tr>
<?php
}
?>
</table>
<?php
break;
default;
?><br /></br>
<b>Pannello di Controllo Moderatore:</b><p>
-> <a href = 'modcp.php?mode=1'>Banna Utente</a><br />
-> <a href = 'modcp.php?mode=2'>Banna IP</a><br />
<?php
break;
}
?>
</div>
</div>
<?php footer (); ?>
</body>
</html>