Размер файла: 12.22Kb
<?php
@session_start();
require_once $_SERVER['DOCUMENT_ROOT']."/includes/start.php";
if(isset($_SESSION['auth']) and $_SESSION['auth']==1){
///ПРОВЕРКА $_GET['rm']
if(eregi("[^0-9]" , $_GET['rm'])){
header ("Location: /enter.php?"); exit;
}
if(isset($HTTP_GET_VARS['rm'])){
$rm = $HTTP_GET_VARS['rm'];
}
$rm = mysql_escape_string($rm);
mysql_query ("Select rm from rooms where rm='".$rm."';");
if(mysql_affected_rows()==0){
header ("Location: /enter.php?"); exit;
}else{
$room = mysql_fetch_assoc(mysql_query("SELECT * FROM `rooms` WHERE `rm` = '".$rm."' LIMIT 1"));
}
///УДАЛЕНИЕ СООБЩЕНИЯ
if($_GET['go']=='delete' && $usr['status']>3){
if(isset($_GET['id'])){
$del = $_GET['id'];
}else{
$del = "";
}
if($del!==""){
mysql_query("DELETE FROM `msg` WHERE `id` = '$del' and rm='$rm'");
mysql_query("OPTIMIZE TABLE `msg`");
header ("Location: room.php?rm=$rm"); exit;
}else{
header ("Location: room.php?rm=$rm"); exit;
}}
///ОЧИСТКА КОМНАТЫ
if($_GET['go']=='clear' && $usr['status']>3){
mysql_query( "Delete from msg where rm=$rm" );
mysql_query( "OPTIMIZE TABLE msg WHERE rm=$rm" );
mysql_query( "TRUNCATE TABLE msg WHERE rm=$rm" );
header ("Location: room.php?rm=$rm"); exit;
}
///ВЕРХ СТРАНИЦЫ+АВТООБНОВЛЕНИЕ ЧЕРЕЗ КАЖДЫЕ 30 СЕКУНД
echo $_up; echo '<meta http-equiv="Refresh" content="30" />';
///ЗАПИСЬ В БД ЮЗЕРОВ (КОМНАТА И ВРЕМЯ)
$mtime = time();
mysql_query("update users set rtime=$mtime where login='$usr[login]' limit 1");
mysql_query("update users set room=$rm where id='$usr[id]' limit 1");
echo '
<center><b>
'.$room['name'].' ('.mysql_result(mysql_query('SELECT COUNT(*) FROM `users` WHERE `room` = "'.$rm.'" and `rtime`>"'.intval( time( ) - 100 ).'"'),0).')
</b></center><br>';
echo '<a href="global_say.php?rm='.$rm.'">Сказать</a> | ';
if($usr['status']>3){
echo '<a href="admin_say.php?rm='.$rm.'"><b>Обьявление</b></a> | <a href="?rm='.$rm.'&go=clear"><b>Очистить</b></a> | ';
}
echo '<a href="?rm='.$rm.'">Обновать</a> | <a href="faq.php?smiles">Смайлы</a> | <a href="?history.php?rm='.$rm.'">История</a><br>';
echo '<div style="padding:3px 5px 3px 5px;" class="MSG">
<form method="post" action="fast_say.php?rm='.$rm.'">
<input name="text" maxlength="150" size="40%"/> <input value="Отправить" type="submit"/>
</form></div><div class="list">';
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `msg` WHERE rm=$rm"), 0);
$data = mysql_query("SELECT * FROM `msg` WHERE rm = $rm ORDER BY `id` DESC LIMIT 15");
if($total==0){
echo 'Сообщений нет...';
}else{
while($res = mysql_fetch_array($data)){
$fi = mysql_query( "select `login`,`clogin`,`ctext` from `users` where id='$res[from_id]';" );
$fi_info = @mysql_fetch_array( @$fi );
$from_login = $fi_info['login'];
///ЦВЕТ НИКА
if($fi_info['clogin']==1){
$from_login='<font color="black">'.$from_login.'</font>';
}
if($fi_info['clogin']==2){
$from_login='<font color="#666">'.$from_login.'</font>';
}
if($fi_info['clogin']==3){
$from_login='<font color="#300">'.$from_login.'</font>';
}
if($fi_info['clogin']==4){
$from_login='<font color="red">'.$from_login.'</font>';
}
if($fi_info['clogin']==5){
$from_login='<font color="#f00">'.$from_login.'</font>';
}
if($fi_info['clogin']==6){
$from_login='<font color="#030">'.$from_login.'</font>';
}
if($fi_info['clogin']==7){
$from_login='<font color="green">'.$from_login.'</font>';
}
if($fi_info['clogin']==8){
$from_login='<font color="#0f0">'.$from_login.'</font>';
}
if($fi_info['clogin']==9){
$from_login='<font color="#003">'.$from_login.'</font>';
}
if($fi_info['clogin']==10){
$from_login='<font color="blue">'.$from_login.'</font>';
}
if($fi_info['clogin']==11){
$from_login='<font color="#00f">'.$from_login.'</font>';
}
if($fi_info['clogin']==12){
$from_login='<font color="#330">'.$from_login.'</font>';
}
if($fi_info['clogin']==13){
$from_login='<font color="yellow">'.$from_login.'</font>';
}
if($fi_info['clogin']==14){
$from_login='<font color="#ff0">'.$from_login.'</font>';
}
if($fi_info['clogin']==15){
$from_login='<font color="#303">'.$from_login.'</font>';
}
if($fi_info['clogin']==16){
$from_login='<font color="#A0A">'.$from_login.'</font>';
}
if($fi_info['clogin']==17){
$from_login='<font color="#f0f">'.$from_login.'</font>';
}
if($fi_info['clogin']==18){
$from_login='<font color="#033">'.$from_login.'</font>';
}
if($fi_info['clogin']==19){
$from_login='<font color="#0aa">'.$from_login.'</font>';
}
if($fi_info['clogin']==20){
$from_login='<font color="#0aa">'.$from_login.'</font>';
}
///ЦВЕТ ТЕКСТА
if($fi_info['ctext']==1){
$clr_text='#000';
}
if($fi_info['ctext']==2){
$clr_text='#fff';
}
if($fi_info['ctext']==3){
$clr_text='#666';
}
if($fi_info['ctext']==4){
$clr_text='#ff0';
}
if($fi_info['ctext']==5){
$clr_text='#f60';
}
if($fi_info['ctext']==6){
$clr_text='#00f';
}
if($fi_info['ctext']==7){
$clr_text='#0ff';
}
if($fi_info['ctext']==8){
$clr_text='#82e';
}
if($fi_info['ctext']==9){
$clr_text='#f00';
}
if($fi_info['ctext']==10){
$clr_text='#0f0';
}
///ГРАДИЕНТ НИК
if($fi_info['clogin']=="gradient"){
$gr = mysql_query("select `start`,`end` from `grN` where id_user='$res[from_id]';" );
$gr_login = @mysql_fetch_array( @$gr );
$from_login = GradientText("$from_login", "$gr_login[start]", "$gr_login[end]");
}
if($from_login==""){
$from_login='[Удален]';
}
if($res['from_id']==$usr['id'] && $res['for_id']!=='' && $res['type']=='private' or $res['for_id']==$usr['id'] && $res['type']=='private'){
$for_id = mysql_query( "select `login` from `users` where id='$res[for_id]';" );
$for_id_info = @mysql_fetch_array( @$for_id );
$for_id_login = $for_id_info['login'];
echo '<span style="background:#DADADA;"><font color="black">'.$res['time'].'</font> <a href="for_say.php?rm='.$rm.'&who='.$res['from_id'].'"><b><u>'.$from_login.'</b></u></a>: <b>приватно для <b><u>'.$for_id_login.'</b></u></b>: <font color="'.$clr_text.'">'.$res['text'].'</font>';
if($usr['status']>3){
echo '[<a href="?go=delete&id='.$res['id'].'&rm='.$rm.'">x</a>]';
}
echo '</span><br>';
}else{
if($res['type']!=='private' && $res['for_id']==''){
if($res['type']=="slap"){
echo '<span style="background:#DADADA;color:#B205FC;"><font color="black">'.$res['time'].' <b><u>Робот</b></u></font>: <b>'.$res['text'].'</b>';
if($usr['status']>3){
echo '[<a href="?go=delete&id='.$res['id'].'&rm='.$rm.'">x</a>]';
}
echo '</span><br>';
}elseif($res['type']=="welMSG"){
echo '<font color="black">'.$res['time'].'</font> <b><u>Робот</b></u>: <b>'.$res['text'].'</b>';
if($usr['status']>3){
echo '[<a href="?go=delete&id='.$res['id'].'&rm='.$rm.'">x</a>]';
}
echo '<br>';
}elseif($res['type']=="PRED"){
echo '<span style="background:#FFB9A1;color:red;"><font color="black">'.$res['time'].'</font> <b><u>Робот</b></u>: <b>'.$res['text'].'</b>';
if($usr['status']>3){
echo '[<a href="?go=delete&id='.$res['id'].'&rm='.$rm.'">x</a>]';
}
echo '</span><br>';
}elseif($res['type']=="PRESENT"){
echo '<span style="background:#FFB9A1;color:red;"><font color="black">'.$res['time'].'</font> <b><u>Робот</b></u>: <b>'.$res['text'].'</b>';
if($usr['status']>3){
echo '[<a href="?go=delete&id='.$res['id'].'&rm='.$rm.'">x</a>]';
}
echo '</span><br>';
}elseif($res['type']=="adminMSG"){
echo '<font color="black">'.$res['time'].' <img src="/imgs/ads.gif"/> <b style="color:#3D9900;"><u>Сообщение</b></u>:</font><div style="background:#EEEEEE;color:#000;border-top:1px solid #CCCCCC;border-bottom:1px solid #CCCCCC;padding:1px 5px 1px 5px;">'.$res['text'].'';
if($usr['status']>3){
echo '[<a href="?go=delete&id='.$res['id'].'&rm='.$rm.'">x</a>]';
}
echo '</div>';
}else{
if($res['from_id']==$usr['id']){
echo '<span style="background:#BDD6A9;"><font color="black">'.$res['time'].'</font> <a href="for_say.php?rm='.$rm.'&who='.$res['from_id'].'"><b><u>'.$from_login.'</b></u></a>: <font color="'.$clr_text.'">'.$res['text'].'</font>';
if($usr['status']>3){
echo ' [<a href="?go=delete&id='.$res['id'].'&rm='.$rm.'">x</a>]';
}
echo '</span><br>';
}else{
echo '<font color="black">'.$res['time'].'</font> <a href="for_say.php?rm='.$rm.'&who='.$res['from_id'].'"><b><u>'.$from_login.'</b></u></a>: <font color="'.$clr_text.'">'.$res['text'].'</font>';
if($usr['status']>3){
echo ' [<a href="?go=delete&id='.$res['id'].'&rm='.$rm.'">x</a>]';
}
echo '<br>';
}
}
}else{
if($res['type']!=='private' && $res['for_id']!==''){
$dfor_id = mysql_query( "select `login` from `users` where id='$res[for_id]';" );
$dfor_id_info = @mysql_fetch_array( @$dfor_id );
$dfor_id_login = $dfor_id_info['login'];
if($res['from_id']==$usr['id'] or $res['for_id']==$usr['id']){
echo '<span style="background:#DADADA;"><font color="#000">'.$res['time'].'</font> <a href="for_say.php?rm='.$rm.'&who='.$res['from_id'].'"><b><u>'.$from_login.'</b></u></a>: <b>для <a href="for_say.php?rm='.$rm.'&who='.$res['for_id'].'"><b><u>'.$dfor_id_login.'</b></u></a></b>: <font color="'.$clr_text.'">'.$res['text'].'</font>';
if($usr['status']>3){
echo '[<a href="?go=delete&id='.$res['id'].'&rm='.$rm.'">x</a>]';
}
echo '</span><br>';
}else{
echo '<font color="#000">'.$res['time'].'</font> <a href="for_say.php?rm='.$rm.'&who='.$res['from_id'].'"><b><u>'.$from_login.'</b></u></a>: <b>для <a href="for_say.php?rm='.$rm.'&who='.$res['for_id'].'"><b><u>'.$dfor_id_login.'</b></u></a></b>: <font color="'.$clr_text.'">'.$res['text'].'</font>';
if($usr['status']>3){
echo '[<a href="?go=delete&id='.$res['id'].'&rm='.$rm.'">x</a>]';
}
echo '<br>';
}
}
}}}}
echo '</div><div style="padding:3px;" class="MSG">В комнате:</div><div class="list">';
$q_online = mysql_query("SELECT `id`,`login`,`clogin` FROM users WHERE rtime>'".intval( time( ) - 100 )."' AND `room`='$rm' order by rtime desc;" );
while($donline = mysql_fetch_array($q_online)){
if($donline['clogin']==1){ $donline['login']='<font color="black">'.$donline['login'].'</font>'; }
if($donline['clogin']==2){ $donline['login']='<font color="#666">'.$donline['login'].'</font>'; }
if($donline['clogin']==3){ $donline['login']='<font color="#300">'.$donline['login'].'</font>'; }
if($donline['clogin']==4){ $donline['login']='<font color="red">'.$donline['login'].'</font>'; }
if($donline['clogin']==5){ $donline['login']='<font color="#f00">'.$donline['login'].'</font>'; }
if($donline['clogin']==6){ $donline['login']='<font color="#030">'.$donline['login'].'</font>'; }
if($donline['clogin']==7){ $donline['login']='<font color="green">'.$donline['login'].'</font>'; }
if($donline['clogin']==8){ $donline['login']='<font color="#0f0">'.$donline['login'].'</font>'; }
if($donline['clogin']==9){ $donline['login']='<font color="#003">'.$donline['login'].'</font>'; }
if($donline['clogin']==10){ $donline['login']='<font color="blue"><b><u>'.$donline['login'].'</b></u></font>'; }
if($donline['clogin']==10){ $donline['login']='<font color="#00f"><b><u>'.$donline['login'].'</b></u></font>'; }
if($donline['clogin']==10){ $donline['login']='<font color="330"><b><u>'.$donline['login'].'</b></u></font>'; }
if($donline['clogin']==10){ $donline['login']='<font color="yellow"><b><u>'.$donline['login'].'</b></u></font>'; }
///ГРАДИЕНТ НИК
if($donline['clogin']=="gradient"){
$gr = mysql_query("select `start`,`end` from `grN` where id_user='$donline[id]';" );
$gr_login = @mysql_fetch_array( @$gr );
$donline[login] = GradientText("$donline[login]", "$gr_login[start]", "$gr_login[end]");
}
echo '<a href="/u'.$donline['id'].'"><font color="'.$donline['clogin'].'">'.$donline['login'].'</font></a>, ';
}
echo '</div>';
echo $_down;
}else{
header ("Location: /?"); exit;
}
?>