File size: 3.17Kb
<?php
/*********************************************************************/
#---------------------------KokirCMS Соц сети-------------------------#
#---------------------Kiriyan и kokir Сайт kiriyan.org----------------#
#-------------------------------2012 г.-------------------------------#
#------------------Связь ICQ 455002004. [email protected]#
#----------------------------Пример ewwap.ru--------------------------#
/*********************************************************************/
require('../inc/head.php');
if($user['rights'] < 2)
header("Location: index.php");
switch($mode)
{
case 'edit':
if(empty($_GET['id']) || !ctype_digit($_GET['id']))
header("Location: index.php");
$id = $_GET['id'];
$room = mysql_fetch_array(mysql_query("SELECt * FROM `chat_rooms` WHERE `id` = $id;"));
if(!$room)
header("Location: index.php");
if(isset($_POST['save']))
{
$caption = mb_substr(escstr($_POST['caption']), 0, 30);
if(mb_strlen($caption) >= 2)
{
mysql_query("UPDATE `chat_rooms` SET `caption` = '" . $caption . "' WHERE `id` = $id;");
header("Location: index.php");
}
}
echo '<div class="caption"><a href="index.php">Чат</a> » <a href="room.php?id=' . $id . '">' . $room['caption'] . '</a> » Редактировать</div>';
echo '<div class="menu">';
echo '<form action="" method="post">';
echo '<label>Название:<br/><input type="text" name="caption" maxlength="30" value="' . $room['caption'] . '"/></label><br/>';
echo '<input type="submit" name="save" value="Сохранить"/>';
echo '</form>';
echo '</div>';
break;
/*********************************************************************/
case 'delete':
if(empty($_GET['id']) || !ctype_digit($_GET['id']))
header("Location: index.php");
$id = $_GET['id'];
if(isset($_GET['accept']))
{
mysql_query("DELETE FROM `chat` WHERE `room` = $id;");
mysql_query("DELETE FROM `chat_rooms` WHERE `id` = $id;");
header("Location: index.php");
}
echo '<div class="menu adm">';
echo 'Вы уверены, что хотите удалить комнату?<br/><a href="?mode=delete&id=' . $id . '&accept">Да</a> | <a href="' . $home . '/chat">Нет</a>';
echo '</div>';
break;
/*********************************************************************/
default:
if(!empty($_POST['caption']))
{
$caption = mb_substr(escstr($_POST['caption']), 0, 30);
mysql_query("INSERT INTO `chat_rooms` VALUES(0, '" . $caption . "');");
header("Location: index.php");
}
echo '<div class="caption"><a href="index.php">Чат</a> » Создать комнату</div>';
echo '<div class="menu">';
echo '<form action="" method="post">';
echo '<label>Название:<br/><input type="text" name="caption" maxlength="30"/></label><br/>';
echo '<input type="submit" name="add" value="Создать"/>';
echo '</form>';
echo '</div>';
}
require('../inc/end.php');
?>