Файл: chat/includes/panel/mod_messages.php
Строк: 76
<?php
/**
* @package Chat for JohnCMS
* @link http://johncms.com
* @copyright Copyright (C) 2010-2017 k_2
* @license LICENSE.txt (see attached file)
* @version VERSION.txt (see attached file)
* @author http://johncms.com/profile/?user=6251
*/
defined('_IN_JOHNCMS') or die('Error: restricted access');
// Проверяем права доступа
if ($rights < 9) {
header("Location: $home?err");
exit;
}
echo '<div class="phdr"><b><a href="../' . $set['admp'] . '/index.php">' . $lng['admin_panel'] . '</a></b> | ' . $lng_chat['cleaning'] . '</div>';
switch ($mod) {
case 'delete':
/*
-----------------------------------------------------------------
Полная очистка всех комнат
-----------------------------------------------------------------
*/
if (isset ($_GET['yes'])) {
$i = 0;
$room = db::query("SELECT * FROM `chat_rooms`");
while ($room_d = mysqli_fetch_assoc($room)) {
db::query("DELETE FROM `chat_room_" . $room_d['id'] . "`");
db::query("OPTIMIZE TABLE `chat_room_" . $room_d['id'] . "`");
++$i;
}
header("location: ?act=mod_messages&do=del");
exit;
} else {
echo '<div class="rmenu"><p>' . $lng_chat['remove_all_chat_messages'] . '</p>';
echo '<p><a href="?act=mod_messages&mod=delete&yes">' . $lng_chat['action_yes'] . '</a> | <a href="?act=mod_messages">' . $lng_chat['action_no'] . '</a></p></div>';
}
break;
case 'delete_s':
/*
-----------------------------------------------------------------
Полная очистка всех комнат от скрытых сообщений
-----------------------------------------------------------------
*/
if (isset ($_GET['yes'])) {
$i = 0;
$room = db::query("SELECT * FROM `chat_rooms`");
while ($room_d = mysqli_fetch_assoc($room)) {
db::query("DELETE FROM `chat_room_" . $room_d['id'] . "` WHERE `tip` = '1'");
db::query("OPTIMIZE TABLE `chat_room_" . $room_d['id'] . "`");
++$i;
}
header("location: ?act=mod_messages&do=del_s");
exit;
} else {
echo '<div class="rmenu"><p>' . $lng_chat['remove_hidden_chat_messages'] . '</p>';
echo '<p><a href="?act=mod_messages&mod=delete_s&yes">' . $lng_chat['action_yes'] . '</a> | <a href="?act=mod_messages">' . $lng_chat['action_no'] . '</a></p></div>';
}
break;
case 'delete_k':
/*
-----------------------------------------------------------------
Очистка определённой комнаты
-----------------------------------------------------------------
*/
if (isset ($_GET['yes'])) {
if (isset ($_GET['skr'])) {
// Очистка комнаты от скрытых сообщений
db::query("DELETE FROM `chat_room_" . $id . "` WHERE `tip` = '1'");
db::query("OPTIMIZE TABLE `chat_room_" . $id . "`");
header("location: ?act=mod_messages&do=del_k_s");
exit;
} else {
// Полная очистка комнаты
db::query("DELETE FROM `chat_room_" . $id . "`");
db::query("OPTIMIZE TABLE `chat_room_" . $id . "`");
header("location: ?act=mod_messages&do=del_k");
exit;
}
} else {
// Выбор комнаты для очистки
$i = 0;
$req = db::query("SELECT `id`, `name` FROM `chat_rooms`");
while ($res = mysqli_fetch_assoc($req)) {
$soob = db::result(db::query("SELECT COUNT(*) FROM `chat_room_" . $res['id'] . "`"), 0);
$soob_s = db::result(db::query("SELECT COUNT(*) FROM `chat_room_" . $res['id'] . "` WHERE `tip` = '1'"), 0);
echo ($i % 2) ? '<div class="list2">' : '<div class="list1">';
echo '<b>' . $res['name'] . '</b> <small>(' . $soob . '/<span class="red">' . $soob_s . '</span>)</small><br />';
if ($soob) {
echo '<div class="sub"><a href="?act=mod_messages&mod=delete_k&id=' . $res['id'] . '&yes">' . $lng_chat['completely'] . '</a>';
if ($soob_s)
echo ' | <a href="?act=mod_messages&mod=delete_k&id=' . $res['id'] . '&skr&yes">' . $lng_chat['hidden'] . '</a>';
echo '</div>';
}
echo '</div>';
++$i;
}
}
break;
default :
/*
-----------------------------------------------------------------
Меню управления сообщениями
-----------------------------------------------------------------
*/
switch ($do) {
case 'del':
echo '<div class="gmenu"><b>' . $lng_chat['chat_cleared'] . '</b></div>';
break;
case 'del_s':
echo '<div class="gmenu"><b>' . $lng_chat['hidden_messages_are_deleted'] . '</b></div>';
break;
case 'del_k_s':
echo '<div class="gmenu"><b>' . $lng_chat['room_free_of_hidden_messages'] . '</b></div>';
break;
case 'del_k':
echo '<div class="gmenu"><b>' . $lng_chat['room_emptied_completely'] . '</b></div>';
break;
default :
echo '';
}
$i = 0;
$soob = 0;
$soob_s = 0;
$room = db::query("SELECT * FROM `chat_rooms`");
while ($room_d = mysqli_fetch_assoc($room)) {
$soob = $soob + db::result(db::query("SELECT COUNT(*) FROM `chat_room_" . $room_d['id'] . "`"), 0);
$soob_s = $soob_s + db::result(db::query("SELECT COUNT(*) FROM `chat_room_" . $room_d['id'] . "` WHERE `tip` = '1'"), 0);
++$i;
}
echo '<div class="menu"><p><h3><img src="img/messages_delete.png" width="16" height="16" class="left" /> ' . $lng_chat['cleaning'] . '</h3><ul>';
echo '<li><a href="?act=mod_messages&mod=delete_k">' . $lng_chat['clear_some_room'] . '</a> <small>(' . $i . ')</small></li>';
if ($soob_s)
echo '<li><a href="?act=mod_messages&mod=delete_s">' . $lng_chat['remove_the_hidden_message'] . '</a> <small>(<span class="red">' . $soob_s . '</span>)</small></li>';
echo '<li><a href="?act=mod_messages&mod=delete">' . $lng_chat['delete_all_messages'] . '</a> <small>(' . $soob . ')</small></li>';
echo '</ul></p></div>';
}
if ($mod) {
echo '<div class="phdr"><a href="?act=mod_messages">' . $lng['back'] . '</a></div>';
echo '<p><a href="menu.php">' . $lng_chat['menu'] . '</a>';
} else {
echo '<div class="phdr"><a href="menu.php">' . $lng_chat['menu'] . '</a></div>';
echo '<p><a href="index.php">' . $lng_chat['to_chat'] . '</a>';
}
echo '<br /><a href="../' . $set['admp'] . '/index.php">' . $lng['admin_panel'] . '</a></p>';