<?
require'config.php';
$user['avr'] = 0;
$align='left';

$rm = intval($_GET['rm']);
if (empty($rm)) header ('Location: enter?'.SID);
$rooms = $db->sql_fetchrow($db->sql_query("SELECT * FROM `rooms` WHERE `rm` = '$rm'"));
$title='Топик-'.$rooms['name'];
aut();

head();
$amarelle = mysql_fetch_array(mysql_query("SELECT * FROM `user_vip` WHERE `user_id` = '".$inf['id']."'"));
if (isset($amarelle['user_id']) AND $amarelle['user_vip_id'] >= 1){header ('Location: '.H.'enter');
}else{

if (empty($act)){

if ($ver!='wml')echo '<form action="topic?rm='.$rm.'&amp;act=add&amp;'.SID.'" method="post">';
if ($ver=='wml')echo '<br/><input name="topic'.$ref.'" value="'.$rooms['topic'].'" maxlength="20" title="Text"/><br/>';
else echo '<br/><input type="text" name="topic" value="'.$rooms['topic'].'" maxlength="20" title="Text"/><br/>';
if ($ver=='wml'){
echo '<br /><anchor title="go">Изменить<go href="tell?rm='.$rm.'&amp;act=add&amp;'.SID.'" method="post">';
echo '<postfield name="topic" value="topic'.$ref.'"/>
</go></anchor>';
echo '<br/><br />';
}else{
echo '<br /><input type="submit" class="ibutton" value="Изменить"/></form><br /><br />';
}

}else{
$topic = check($_POST['topic']);
if (strlen2($topic)<3){echo 'Топик должен быть больше 3 букв...'; exit;}

$topic = iconv('utf-8', 'windows-1251', $topic);
$topic = substr($topic,0,20);
$topic = iconv('windows-1251', 'utf-8', $topic);
if ($user['translit']==1)$topic = translit($topic);

$db->sql_query ("INSERT INTO logs (log,msg,time) VALUES ('topic','[b]".$user['user']."[/b] cменил топик в комнате [b]".$rooms['name']."[/b] на [b]".$topic."[/b]','$time')");

$db->sql_query("UPDATE `rooms` SET `topic` = '$topic' WHERE `rm` = '$rm';");

header ('Location: room?rm='.$rm.'&'.SID);  exit;

}


echo gb.'<a href="room?rm='.$rm.'">В чат </a>'.div;

foot();}
?>