<?
require("../config.php");
require("../func.php");
head();
aut();
ban();
$room = num($_GET['room']);
$room_info = mysql_fetch_assoc(mysql_query("SELECT * FROM `room` WHERE `id` = '".$room."'"));

if ( $config['status_chat'] == 0) {
    echo "<div class=\"head\">Чат</div><div class=\"main\">";
    echo link1 . 'Чат отключен' . div;
    navig();
    foot();
    exit();
}

echo "<div class=\"head\">Чат: <b>Меню</b></div><div class=\"katalog\">";

if ( $_GET['mod'] == 'pchat' ) {
    echo '<form action="menu.php?mod=save&room='.$room.'" method="post" name="form">';
    echo '<b>Чат:</b> Постов на стр.:<br/><input name="pchat" type="text" maxlength="20" value = "'.$max_msg_chat_session.'"/><br/>';
    echo '<input name="submit" type="submit" class="button" value="Сохранить" /></form><br/>';
}

if ( $_GET['mod'] == 'obnovt' ) {
    echo '<form action="menu.php?mod=save&room='.$room.'" method="post" name="form">';
    echo '<b>Время обновления:</b><br/><select name="obnovt">
    <option value="10">10</option>
    <option value="20">20</option>
    <option value="30">30</option>
    <option value="40">40</option>
    <option value="60">60</option>
    </select><br/ ><br/ >';
    echo '<input name="submit" type="submit" class="button" value="Сохранить" /></form><br/>';
}

if ( $_GET['mod'] == 'phis' ) {
    echo '<form action="menu.php?mod=save&room='.$room.'" method="post" name="form">';
    echo '<b>История:</b> Постов на стр.:<br/><input name="phis" type="text" maxlength="20" value = "'.$history_msg_chat_session.'"/><br/>';
    echo '<input name="submit" type="submit" class="button" value="Сохранить" /></form><br/>';
}

if ( $_GET['mod'] == 'save' ) {
    if ( $_POST['pchat'] ) {
        $result = num($_POST['pchat']);
         mysql_query("UPDATE `profile` SET `max` = '".$result."' WHERE `id` = '".$id_session."'");
        header('Location: menu.php?room='.$room.'');
    }
    
    if ( $_POST['obnovt'] ) {
        $result = num($_POST['obnovt']);
         mysql_query("UPDATE `profile` SET `obnov` = '".$result."' WHERE `id` = '".$id_session."'");
        header('Location: menu.php?room='.$room.'');
    }
    
    if ( $_POST['phis'] ) {
        $result = num($_POST['phis']);
         mysql_query("UPDATE `profile` SET `history` = '".$result."' WHERE `id` = '".$id_session."'");
        header('Location: menu.php?room='.$room.'');
    }
}

if ( $_GET['mod'] == 'vvod' ) {
    if ( $vvod_session == NULL) {
        $result = 1;
    } else {
        $result = 0;
    }
    mysql_query("UPDATE `profile` SET `vvod` = '".$result."' WHERE `id` = '".$id_session."'");
    header('Location: menu.php?room='.$room.'');
}

if ( $_GET['mod'] == 'emo' ) {
    if ( $emo_session == 0) {
        $result = 1;
    } else {
        $result = 0;
    }
    mysql_query("UPDATE `profile` SET `setting_emo` = '".$result."' WHERE `id` = '".$id_session."'");
    header('Location: menu.php?room='.$room.'');
}

if ( $_GET['mod'] == 'colorp' ) {
    if ( $colorp_session == 0) {
        $result = 1;
    } else {
        $result = 0;
    }
    mysql_query("UPDATE `profile` SET `setting_colorp` = '".$result."' WHERE `id` = '".$id_session."'");
    header('Location: menu.php?room='.$room.'');
}

if ( $_GET['mod'] == 'msgp' ) {
    if ( $msgp_session == 0) {
        $result = 1;
    } else {
        $result = 0;
    }
    mysql_query("UPDATE `profile` SET `msgp` = '".$result."' WHERE `id` = '".$id_session."'");
    header('Location: menu.php?room='.$room.'');
}


echo '<b>Чат:</b> Постов на стр.: <a href="menu.php?mod=pchat&room='.$room.'"><b>'.$max_msg_chat_session.'</b></a><br/>';
echo '<b>Чат:</b> Время обновления: <a href="menu.php?mod=obnovt&room='.$room.'"><b>'.$time_obnov_session.'</b></a><br/>';
echo '<b>История:</b> Постов на стр.: <a href="menu.php?mod=phis&room='.$room.'"><b>'.$history_msg_chat_session.'</b></a><br/><br/>';

if ($vvod_session == NULL)
echo '<b>Поле ввода:</b> <a href="menu.php?mod=vvod&room='.$room.'"><b>Вкл</b></a><br/>';
else
echo '<b>Поле ввода:</b> <a href="menu.php?mod=vvod&room='.$room.'"><b>Выкл</b></a><br/>';

if ($emo_session == 0)
echo '<b>Эмоции:</b> <a href="menu.php?mod=emo&room='.$room.'"><b>Вкл</b></a><br/>';
else
echo '<b>Эмоции:</b> <a href="menu.php?mod=emo&room='.$room.'"><b>Выкл</b></a><br/>';

if ($colorp_session == 0)
echo '<b>Цвет поста:</b> <a href="menu.php?mod=colorp&room='.$room.'"><b>Вкл</b></a><br/>';
else
echo '<b>Цвет поста:</b> <a href="menu.php?mod=colorp&room='.$room.'"><b>Выкл</b></a><br/>';

if ($msgp_session == 0)
echo '<b>Посты:</b> <a href="menu.php?mod=msgp&room='.$room.'"><b>Только мне</b></a><br/>';
else
echo '<b>Посты:</b> <a href="menu.php?mod=msgp&room='.$room.'"><b>Всем</b></a><br/>';
navig();
foot();
?>