Файл: chat/includes/panel/mod_chat.php
Строк: 190
<?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"><a href="../' . $set['admp'] . '/index.php"><b>' . $lng['admin_panel'] . '</b></a> | ' . $lng_chat['chat_settings'] . '</div>';
if ($mod == 'reset') {
db::query("UPDATE `chat_settings` SET `val`='1' WHERE `key` = 'access'");
db::query("UPDATE `chat_settings` SET `val`='0' WHERE `key` = 'balls'");
db::query("UPDATE `chat_settings` SET `val`='0' WHERE `key` = 'color_nik'");
db::query("UPDATE `chat_settings` SET `val`='0' WHERE `key` = 'color_nik_text'");
db::query("UPDATE `chat_settings` SET `val`='0' WHERE `key` = 'color_text'");
if ($chat_settings['auto_delete'])
db::query("UPDATE `chat_settings` SET `val`='" . time() . "' WHERE `key` = 'time'");
db::query("UPDATE `chat_settings` SET `val`='0' WHERE `key` = 'auto_delete'");
db::query("UPDATE `chat_settings` SET `val`='1' WHERE `key` = 'faq'");
db::query("UPDATE `chat_settings` SET `val`='0' WHERE `key` = 'leave_post'");
echo '<div class="gmenu">' . $lng['settings_default'] . '</div>';
$req = db::query("SELECT * FROM `chat_settings`");
$chat_settings = array();
while ($res = mysqli_fetch_row($req)) $chat_settings[$res[0]] = $res[1];
}
if (isset($_POST['submit'])) {
/*
-----------------------------------------------------------------
Сохраняем настройки чата
-----------------------------------------------------------------
*/
switch (intval($_POST['auto_delete'])) {
case 3:
$auto_dell = 86400;
break;
case 2:
$auto_dell = 172800;
break;
case 1:
$auto_dell = 604800;
break;
default :
$auto_dell = 0;
}
db::query("UPDATE `chat_settings` SET `val`='" . intval($_POST['access']) . "' WHERE `key` = 'access'");
db::query("UPDATE `chat_settings` SET `val`='" . intval($_POST['balls']) . "' WHERE `key` = 'balls'");
db::query("UPDATE `chat_settings` SET `val`='" . intval($_POST['color_nik']) . "' WHERE `key` = 'color_nik'");
db::query("UPDATE `chat_settings` SET `val`='" . intval($_POST['color_nik_text']) . "' WHERE `key` = 'color_nik_text'");
db::query("UPDATE `chat_settings` SET `val`='" . intval($_POST['color_text']) . "' WHERE `key` = 'color_text'");
if ($auto_dell != $chat_settings['auto_delete'])
db::query("UPDATE `chat_settings` SET `val`='" . time() . "' WHERE `key` = 'time'");
db::query("UPDATE `chat_settings` SET `val`='" . $auto_dell . "' WHERE `key` = 'auto_delete'");
db::query("UPDATE `chat_settings` SET `val`='" . (isset($_POST['faq']) ? 1 : 0) . "' WHERE `key` = 'faq'");
db::query("UPDATE `chat_settings` SET `val`='" . (isset($_POST['leave_post']) && $auto_dell ? intval($_POST['leave_post']) : 0) . "' WHERE `key` = 'leave_post'");
$req = db::query("SELECT * FROM `chat_settings`");
$chat_settings = array();
while ($res = mysqli_fetch_row($req)) $chat_settings[$res[0]] = $res[1];
echo '<div class="gmenu">' . $lng['settings_saved'] . '</div>';
}
$color = array('red', 'yelow', 'green', 'gray');
echo '<form action="?act=mod_chat" method="post">' .
'<div class="menu">';
/*
-----------------------------------------------------------------
Управление доступом к Чату
-----------------------------------------------------------------
*/
echo '<p><h3><img src="../images/' . $color[$chat_settings['access']] . '.gif" width="16" height="16" class="left"/> ' . $lng_chat['rights'] . '</h3>' .
'<div style="font-size: x-small">' .
' <label><input type="radio" value="2" name="access" ' . ($chat_settings['access'] == 2 ? 'checked="checked"' : '') . '/> ' . $lng_chat['access_open'] . '</label><br />' .
' <label><input type="radio" value="1" name="access" ' . ($chat_settings['access'] == 1 ? 'checked="checked"' : '') . '/> ' . $lng_chat['access_login'] . '</label><br />' .
' <label><input type="radio" value="0" name="access" ' . (!$chat_settings['access'] ? 'checked="checked"' : '') . '/> ' . $lng_chat['access_close'] . '</label>' .
'</div></p>' .
'<p><h3><img src="img/tables.png" width="16" height="16" class="left" /> ' . $lng_chat['table_balls'] . '</h3>' .
'<div style="font-size: x-small">' .
' <label><input type="radio" value="0" name="balls" ' . (!$chat_settings['balls'] == 1 ? 'checked="checked"' : '') . '/> ' . $lng_chat['table'] . ' <span style="font-style:italic">chat_users</span></label><br />' .
' <label><input type="radio" value="1" name="balls" ' . ($chat_settings['balls'] ? 'checked="checked"' : '') . '/> ' . $lng_chat['table'] . ' <span style="font-style:italic">users</span></label><br />' .
'   <span class="gray"><small>' . $lng_chat['to_text'] . ' <span style="font-style:italic">balans</span></small></span>' .
'</div></p>' .
'<p><h3><img src="img/color-swatches.png" width="16" height="16" class="left" /> ' . $lng_chat['value_color'] . '</h3>' .
'<div style="font-size: x-small"><ul>' .
'<li>' . $lng_chat['color_nick'] . ': <br /><input type="text" name="color_nik" value="' . $chat_settings['color_nik'] . '"/></li>' .
'<li>' . $lng_chat['color_source_in_the_text'] . ': <br /><input type="text" name="color_nik_text" value="' . $chat_settings['color_nik_text'] . '"/></li>' .
'<li>' . $lng_chat['color_your_posts'] . ': <br /><input type="text" name="color_text" value="' . $chat_settings['color_text'] . '"/><br />' .
'  <span class="gray"><small><span style="font-style:italic">0</span> - ' . $lng_chat['free'] . '</small></span></li>' .
'</ul></div></p>' .
'<p><h3><img src="img/clock_delete.png" width="16" height="16" class="left" /> ' . $lng_chat['auto_clear'] . '</h3>' .
'<div style="font-size: x-small">' .
' <label><input type="radio" value="3" name="auto_delete" ' . ($chat_settings['auto_delete'] == 86400 ? 'checked="checked"' : '') . '/> ' . $lng_chat['order_night'] . '</label><br />' .
' <label><input type="radio" value="2" name="auto_delete" ' . ($chat_settings['auto_delete'] == 172800 ? 'checked="checked"' : '') . '/> ' . $lng_chat['order_2_days'] . '</label><br />' .
' <label><input type="radio" value="1" name="auto_delete" ' . ($chat_settings['auto_delete'] == 604800 ? 'checked="checked"' : '') . '/> ' . $lng_chat['order_week'] . '</label><br />' .
' <label><input type="radio" value="0" name="auto_delete" ' . (!$chat_settings['auto_delete'] ? 'checked="checked"' : '') . '/> ' . $lng_chat['not_clear'] . '</label><br />' .
'   <label><input type="text" name="leave_post" size="3" maxlength="3" value="' . $chat_settings['leave_post'] . '"/> ' . $lng_chat['always_leave_post'] . '</label><br />' .
'     <span class="gray"><small><span style="font-style:italic">0</span> - ' . $lng_chat['do_not_leave_post'] . '</small></span>' .
'</div></p>' .
'<p><h3><img src="img/information.png" width="16" height="16" class="left" /> ' . $lng_chat['information'] . '</h3>' .
'<div style="font-size: x-small"><ul>' .
'<li><label><input type="checkbox" name="faq"' . ($chat_settings['faq'] ? ' checked="checked"' : '') . '/> ' . $lng_chat['upon_entering_the_room'] . '</label></li>' .
'</ul></div></p>' .
'</div><div class="gmenu">' .
'<input type="submit" name="submit" value="' . $lng['save'] . '"/>' .
'</div>' .
'</form>' .
'<div class="phdr"><a href="?act=mod_chat&mod=reset">' . $lng_chat['reset'] . '</a></div>' .
'<p><a href="menu.php">' . $lng_chat['menu'] . '</a><br /><a href="../' . $set['admp'] . '/index.php">' . $lng['admin_panel'] . '</a></p>';