This repository has been archived by the owner on Nov 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadmin.php
216 lines (201 loc) · 8.96 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
<?php
ob_start();
include_once 'c.php';
include_once 'f.php';
session_start();
$act = isset($_GET['act']) ? $_GET['act'] : '';
if (!isset($_SESSION['admin']) || $_SESSION['admin'] != $settings['adminpass']) {
$act = '';
}
?>
<!doctype html>
<html>
<head>
<title><?= $settings['title']; ?> — Панель управления</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<link rel="stylesheet" href="/css/bootstrap.css">
<link rel="stylesheet" href="/css/bootstrap-responsive.css">
<link rel="stylesheet" href="/css/custom.css">
<script src="/js/jquery.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<style type="text/css">
.red{color: red}
.green{color: green}
</style>
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="/"><?= $settings['siteName']; ?></a>
<div class="navbar-content">
<ul class="nav ">
<li class="active">
<a href="/">Ключи</a>
</li>
<li>
<a href="/add">Добавить</a>
</li>
<li>
<a href="/faq.php">FAQ</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<br>
<div class="container">
<hr style="clear:both">
<?
switch ($act) {
case 'delallkeys':
if (isset($_POST['delallkeys']) and $_POST['ip'] != "")
{
$ip = $_POST['ip'];
mysql_query("DELETE FROM `keys` WHERE `ip` = '$ip'");
die ("OK");
}
elseif (isset($_POST['delallkeys']) and $_POST['ip'] == "")
{
die ("WHERE IS IP?");
}
echo "<form method=\"post\">";
echo "<input type=\"text\" name=\"ip\" placeholder=\"IP\" required><br>";
echo "<input type=\"submit\" name=\"delallkeys\" value=\"Удалить все ключи\">";
echo "</form>";
break;
case 'delallcomments':
if (isset($_POST['delallcomments']) and $_POST['ip'] != "")
{
$ip = $_POST['ip'];
mysql_query("DELETE FROM `comments` WHERE `ip` = '$ip'");
die ("OK");
}
elseif (isset($_POST['delallcomments']) and $_POST['ip'] == "")
{
die ("WHERE IS IP?");
}
echo "<form method=\"post\">";
echo "<input type=\"text\" name=\"ip\" placeholder=\"IP\" required><br>";
echo "<input type=\"submit\" name=\"delallcomments\" value=\"Удалить все комментарии\">";
echo "</form>";
break;
case 'delkey':
if (isset($_POST['delkey']) and $_POST['id'] != "")
{
$id = $_POST['id'];
mysql_query("DELETE FROM `keys` WHERE `id` = '$id'");
die ("OK");
}
elseif (isset($_POST['delkey']) and $_POST['id'] == "")
{
die ("WHERE IS ID?");
}
echo "<form method=\"post\">";
echo "<input type=\"text\" name=\"id\" placeholder=\"ID\" required><br>";
echo "<input type=\"submit\" name=\"delkey\" value=\"Удалить ключ\">";
echo "</form>";
break;
case 'delcomment':
if (isset($_POST['delcomment']) and $_POST['id'] != "")
{
$id = $_POST['id'];
mysql_query("DELETE FROM `comments` WHERE `id` = '$id'");
die ("OK");
}
elseif (isset($_post['delcomment']) and $_POST['id'] == "")
{
die ("WHERE IS ID?");
}
echo "<form method=\"post\">";
echo "<input type=\"text\" name=\"id\" placeholder=\"ID\" required><br>";
echo "<input type=\"submit\" name=\"delcomment\" value=\"Удалить комментарий\">";
echo "</form>";
break;
case 'delete_ban':
$ip = isset($_GET['ip'])?$_GET['ip']:null;
if (!$ip) {
die('Введи ip, сука');
}
$c = mysql_query("SELECT COUNT(*) FROM `bans` WHERE `ip` = '".mysql_real_escape_string($ip)."'");
if ($c < 0) {
die('Бан не найден');
}
mysql_query("DELETE FROM `bans` WHERE `ip` = '".mysql_real_escape_string($ip)."'");
header('location:/admin.php?act=ban');
break;
case'ban':
if (isset($_POST['ip'])) {
$ip = $_POST['ip'];
$time = intval($_POST['time_ban']);
$reason = mysql_real_escape_string(htmlspecialchars($_POST['reason']));
mysql_query("INSERT INTO `bans` (`ip`,`time`,`time_end`,`reason`) VALUES ('".$ip."',
'".time()."','".(time()+($time*60*60))."','".$reason."')");
header("Location:/admin.php?act=ban");
}else {
echo '
<form action="/admin.php?act=ban" method="post">
<b>Введите ойпи:</b><br>
<input type="text" name="ip" id=""/><br>
<b>Время:</b><br>
<select name="time_ban">
<option value="1">1 час</option>
<option value="3">3 часа</option>
<option value="24">1 день</option>
<option value="9999999999999999">Навсегда</option>
<!-- ну типо навсегда, ага -->
</select><br>
<b>Причина:</b><br>
<textarea name="reason"></textarea><br>
<input type="submit" value="Забанить" class="btn btn-primary"/>
</form>
';
echo '<hr/>
<h3>Пидорнутые:</h3><br>';
$q = mysql_query("SELECT * FROM `bans` ORDER BY `id` DESC");
while($a=mysql_fetch_array($q)){
echo '
<div class="well">
<b>IP:</b> '.$a['ip'].'<br/>
<b>Был забанен:</b> '.formatDate($a['time']).'<br/>
<b>Будет разбанен:</b> '.formatDate($a['time_end']).'<br/>
<b>Активен:</b> '.(time()<$a['time_end']?'<span class="green">Да</span>':'<span class="red">Нет</span>').'<br/>
<b>Причина:</b> '.$a['reason'].'<br />
<a href="/admin.php?act=delete_ban&ip='.$a['ip'].'">Удалить бан</a>
</div>
';
}
}
break;
default:
if (isset($_POST['pass'])) {
$pass = $_POST['pass'];
if ($pass == $settings['adminpass']) {
$_SESSION['admin'] = $pass;
}
header('location:/admin.php');
} else if (!isset($_SESSION['admin']) || $_SESSION['admin'] != $settings['adminpass']) {
echo '
<form action="/admin.php" method="post">
<b>Введи пароль:</b><br>
<input type="password" name="pass"/><br>
<input type="submit" value="OK"/>
</form>
';
} else {
echo '
<a href="/admin.php?act=ban">БАН ПО ОЙПИ</a><br>
<a href="/admin.php?act=delallkeys">Удалить все ключи</a><br>
<a href="/admin.php?act=delallcomments">Удалить все комментарии</a><br>
<a href="/admin.php?act=delkey">Удалить ключ</a><br>
<a href="/admin.php?act=delcomment">Удалить комментарий</a>
';
}
break;
}
?>
</div>
</body>
</html> <? ob_end_flush();