<?
@session_start();
if(isset($user)){
//////////////Гостевая//////

if (isset($_GET['on'])) {
$_SESSION['g_post'] = 'false';
msg('Эфир успешно включен');
}
if (isset($_GET['off'])) {
$_SESSION['g_post'] = 'off';
msg('Параметры успешно записаны в сессию эфир отключен');
}
if (isset($_POST['wind'])){
mysql_query("UPDATE `user` SET `window` = '".intval($_POST['window'])."' WHERE `id` = '".$user['id']."'");
msg('Параметры успешно приняты');
}
if(!$_SESSION['g_post'])$_SESSION['g_post']='1';
if ($_SESSION['g_post']!='off'){
if (isset($_GET['set'])){
echo "<form method='post' action='?'>\n";
echo "Прямой эфир:<br />\n";
echo "<name='window'>\n";
echo "<input name=\"window\"  type=\"radio\" value=\"1\" ".($user['window']==1?" selected='selected'":null).">Из гостевой<br />\n";
echo "<input name=\"window\"  type=\"radio\" value=\"2\" ".($user['window']==2?" selected='selected'":null).">Из чата<br />\n";
echo "<input name=\"window\"  type=\"radio\" value=\"3\" ".($user['window']==3?" selected='selected'":null).">Из Форума<br />\n";
echo "<input type='submit' name='wind' value='Сохранить' />\n";
echo "</form>\n";
}
if($user['window']=='2'){
$q=mysql_query("SELECT * FROM `chat_post` WHERE (`privat` = '0'".(isset($user)?" OR `privat` = '$user[id]'":null).") ORDER BY `id` DESC LIMIT 1");
while ($post = mysql_fetch_assoc($q))
{
if ($post['umnik_st'])$post_icon=ICONS_COMMON.'chat_umnik.png';
elseif($post['shutnik'])$post_icon=ICONS_COMMON.'chat_shut.png';
else
{
$ank_w=get_user($post['id_user']);
$post_icon=ICONS_USER.'pol_'.$ank_w['pol'].'.png';
}
if ($post['umnik_st'])$post_title=$set['chat_umnik'].' ('.vremja($post['time']).')';
elseif ($post['shutnik'])$post_title=$set['chat_shutnik'].' ('.vremja($post['time']).')';
else
{
$post_title=((isset($user) &&  $post['privat']==$user['id'])?'[п] ':null)."<a href='/chat/room/$post[room]/".rand(1000,9999)."/$ank_w[id]/'><b>$ank_w[nick]</b></a> ".online($ank_w['id'])." (".vremja($post['time']).")";
}
$wtp = $post_title;
$post2 = "<a href='/chat/room/".$post['room']."/".rand(1000,9999)."/'>".output_text($post['msg'])."</a>";
}
}elseif($user['window']=='1'){
echo "<div class='title'><a href='guest/'>Прямой эфир из мини чат</a></div>";
$q=mysql_query("SELECT * FROM `guest` ORDER BY id DESC LIMIT 1");
while ($post = mysql_fetch_assoc($q)){
$ank_w=get_user($post['id_user']);
$wtp = "<a href='/guest/?page=1&response=$ank_w[id]'><b>$ank_w[nick]</b></a>".online($ank_w['id'])." (".vremja($post['time']).")\n";
$post2 = "<a href='/guest/'>".output_text($post['msg'])."</a>";
}
}
elseif($user['window']=='3'){
$q=mysql_query("SELECT * FROM `forum_p` ORDER BY id DESC LIMIT 1");
while ($post = mysql_fetch_assoc($q)){
$ank_w=get_user($post['id_user']);
$wtp= "<a href='/forum/$post[id_forum]/$post[id_razdel]/$post[id_them]/$post[id]/msg'><b>$ank_w[nick]</b></a>".online($ank_w['id'])."".vremja($post['time'])."";
$post2 = "<a href='/forum/".$post['id_forum']."/".$post['id_razdel']."/".$post['id_them']."/'>".output_text($post['msg'])."</a>";
}
}
echo "<div class='nav1'>$wtp</div><div class='nav2'>$post2</div>";
echo "<div class='nav1'><a href='?off'>Отключить эфир</a> / <a href='?set'>Настройки</a></div>";
}else{
echo "<div class='nav1'><a href='?on'>Включить эфир</a></div>";
}
}
?>
