game/spam.php

74 lines
2.4 KiB
PHP

<?php
use Core\Db;
const GAME = true;
include('_incl_data/__config.php');
include('_incl_data/class/__db_connect.php');
define('IP', UserIp::get());
$u = User::start();
if (isset($_GET['test_login']) || isset($_GET['test_login2'])) {
die();
}
if (isset($_GET['chat'])) {
$sp2 = Db::getRows('select * from chat where spam > 0 order by time desc ');
foreach ($sp2 as $row) {
echo date('d.m.Y H:i', $row['time']) . ' <b>' . $row['login'] . '</b>: ' . $row['text'] . '<hr>';
}
die();
}
if (!$u->info['admin']) {
die('Спамер? :)');
}
?>
<!DOCTYPE HTML>
<html lang="ru">
<head>
<title>Редактирование фильтра от спама</title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
<link href="https://img.new-combats.com/css/main.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/jquery.1.11.js"></script>
<body style="padding-top:0; margin-top:7px; height:100%; background-color:#dedede;">
<strong>Список запрещенных слов\ссылок:</strong> &nbsp;
<input onClick="location.href='/spam.php';" type="button" value="Обновить"><br><br>
<?php
$spam = Db::getValue('select data from spam_word where id = 1');
$spam = explode('|', $spam);
//
if (isset($_GET['del'])) {
echo '<div style="color: red;">Слово &quot;<b>' . $spam[floor(
(int)$_GET['del']
)] . '</b>&quot; удалено.<br><br></div>';
unset($spam[floor((int)$_GET['del'])]);
$spam = implode('|', $spam);
Db::sql('replace into spam_word set id = 1, data = ?', [$spam]);
$spam = explode('|', $spam);
} elseif (isset($_POST['add'])) {
$_POST['add'] = htmlspecialchars($_POST['add'], null);
echo '<div style="color: green">Слово &quot;<b>' . $_POST['add'] . '</b>&quot; добавлено.<br><br></div>';
$spam = implode('|', $spam);
$spam .= '|' . $_POST['add'];
Db::sql('replace into spam_word set id = 1, data = ?', [$spam]);
$spam = explode('|', $spam);
}
if (is_array($spam)) {
$i = 0;
while ($i < count($spam)) {
echo $spam[$i] . ' <a href="/spam.php?del=' . $i . '"><span style="color: red">x</span></a><hr>';
$i++;
}
}
?>
<form method="post">
<label>
<input type="text" name="add" value="" style="width:244px;">
</label> <input type="submit" value="Добавить">
</form>
</body>
</html>