Просмотр файла room.php

Размер файла: 9.56Kb
<?php
include 'sys/db.php';
include 'sys/conf.php';
include 'sys/start.php';
include 'sys/functions.php';
include 'sys/smiles.php';
$id = intval($_GET['id']);
$time = time();
if (isset($user))mysql_query("DELETE FROM `chat_who` WHERE `id_user` = '$user[id]'");
mysql_query("DELETE FROM `chat_who` WHERE `time` < '".($time-120)."'");
if (isset($user))mysql_query("INSERT INTO `chat_who` (`id_user`, `time`,  `room`) values('$user[id]', '$time', '$id')");
if ($user['set_refresh']!=0)header("Refresh: $user[set_refresh]; url=/room.php?id=$id");
$room = mysql_query("SELECT * FROM `room` WHERE `id` = '$id'");
if($rooms = mysql_fetch_array($room)){
$config_title_name = "".$rooms['name']."";
include 'style/head.php';
echo "<div class=title>Чат / <b>".$rooms['name']."</b></div>\n";}
if(isset($user['login'])){

if ($rooms['joker'] == '1'){
$flt = time()-$config_message_from_evil_Joker;
$af = mysql_query("SELECT * FROM `posts` WHERE `author_id`='2' and `time` >='$flt';");
$af1=mysql_num_rows($af);
if ($af1==0){
$jokes = mysql_query("SELECT * FROM `chat_joker`");
$n_jokes = mysql_num_rows($jokes);
if($n_jokes != '0'){$num_jokes = mt_rand(1,$n_jokes);}
$jokenum = mysql_query("SELECT * FROM `chat_joker` WHERE `id` = '$num_jokes'");
$jokenums = mysql_fetch_array($jokenum);
$joke = $jokenums[text];
mysql_query ("INSERT INTO `posts` (room_id,author_id,author_login,text,time) VALUES ('$id','2','Шутник','$joke','".time()."')");}
}
if ($id != '0') {
function pages($start, $total, $page, $onpage){
if ($start != 0) echo '<a href="'.$page.'?start='.($start - $onpage).'&id='.$_GET['id'].'">&lt;-Назад</a> ';
else echo '&lt;-Назад';
echo ' | ';
if ($total > $start + $onpage)
echo ' <a href="'.$page.'?start='.($start + $onpage).'&id='.$_GET['id'].'">Далее-&gt;</a>';
else echo 'Далее-&gt;';}
$total = mysql_result(mysql_query("SELECT COUNT(*)FROM `posts` WHERE `room_id` = '$id' "),0);
$start = isset($_GET['start']) ? abs((int)$_GET['start']) : 0;
if($start > $total) $start = 0;
if ($total < $start + 10) $end = $total;
else $end = $start + 10;
echo "<div class=content>\n";
echo "<a href='reply.php?id=$id' accesskey='1'>Сказать</a> [1]<br>\n";
echo "<a href='room.php?id=$id' accesskey='2'>Обновить</a> [2]<br>\n";
echo "<a href='who.php?id=$id' accesskey='3'>Кто в комнате?</a> [3]<br>\n";
echo"</div>\n";
if ($_GET['isset']==af) {echo "<div class=content>Сработал антифлуд! след. сообщение через 10 секунд!</div>\n";}
$posts = mysql_query("SELECT * FROM `posts` WHERE `room_id` = '$id' ORDER BY `id` DESC LIMIT $start, 10");
if(mysql_num_rows($posts) != 0){
while($post = mysql_fetch_array($posts)){
$authoropr = $post['author_id'];
$author = mysql_query("SELECT gender,time,notice FROM `users` WHERE `id` = '$authoropr'");
if($authorq = mysql_fetch_array($author)){
echo "<div class=content>\n";




if ($user[id] != $post[author_id]){
if ($authorq['gender']=='1')echo "<img src='img/man.gif' alt=''> ";
elseif ($authorq['gender']=='2')echo "<img src='img/woman.gif' alt=''> ";
elseif ($authorq['gender']=='3')echo "<img src='img/bot.gif' alt=''> ";
echo "<a href='reply.php?act=reply&id=$id&user_id=".$post['author_id']."'> <span style='color:#6F006F'><b>".$post['author']."</b></span></a> ";
}else{
if ($authorq['gender']=='1')echo "<img src='img/man.gif' alt=''> ";
elseif ($authorq['gender']=='2')echo "<img src='img/woman.gif' alt=''> ";
echo "<span style='color:#6F006F'><b>".$post['author']."</b></span> ";}
if ($post[author_id] == '2'){echo "<span style='color:#6F006F'><b>Шутник</b></span>  <img src='img/on.gif' alt=''>";}

$authortime = $authorq['time'];
if ($post[author_id] != '2' && $post[author_id] != '3' && $post[author_id] != '4'){
if ($authortime > time()-600) {
echo " <img src='img/on.gif' alt=''>";
}else{
echo " <img src='img/off.gif' alt=''>";
}}


if ($user['level']==1)echo "[<a href='add.php?act=del&id=".$post['id']."&pid=$id'><small>DEL</small></a>]\n";
elseif ($user['level']==2)echo "[<a href='add.php?act=del&id=".$post['id']."&pid=$id'><small>DEL</small></a>]\n";
elseif ($user['level']==3)echo "[<a href='add.php?act=del&id=".$post['id']."&pid=$id'><small>DEL</small></a>]\n";
echo "<div class='cit'>\n";
if ($post['emotion']!=NULL){
if ($post['emotion']==1)echo "[Радостно] ";
elseif ($post['emotion']==2)echo "[Печально] ";
elseif ($post['emotion']==3)echo "[Удивленно] ";
elseif ($post['emotion']==4)echo "[Ласково] ";
elseif ($post['emotion']==5)echo "[Смущенно] ";
elseif ($post['emotion']==6)echo "[Кокетливо] ";
elseif ($post['emotion']==7)echo "[Обиженно] ";
elseif ($post['emotion']==8)echo "[Настойчиво] ";
elseif ($post['emotion']==9)echo "[Шепотом] ";
elseif ($post['emotion']==10)echo "[Задумчиво] ";
elseif ($post['emotion']==11)echo "[Злобно] ";}

if ($post['color']>0){
if ($post['color']==1)echo "<font color=#ff0000>";
elseif ($post['color']==2)echo "<font color=#0000FF>";
elseif ($post['color']==3)echo "<font color=#FF00FF>";
elseif ($post['color']==4)echo "<font color=#009900>";
if ($config_smiles_onoff == 0){
if ($rooms['antimat']==0)echo smiles1(smiles2(smiles3(smiles4(smiles5(smiles6(antimat(antirek(br($post['text'])))))))))."</font>\n";
elseif ($rooms['antimat']==1) echo smiles1(smiles2(smiles3(smiles4(smiles5(smiles6(antirek(br($post['text']))))))))."</font>\n";
}elseif ($config_smiles_onoff == 1){
if ($authorq['posts'] <= 499) {
if ($rooms['antimat']==0)echo smiles1(antimat(antirek(br($post['text']))))."</font>\n";
elseif ($rooms['antimat']==1) echo smiles1(antirek(br($post['text'])))."</font>\n";
}elseif ($authorq['posts'] <= 999) {
if ($rooms['antimat']==0)echo smiles1(smiles2(antimat(antirek(br($post['text'])))))."</font>\n";
elseif ($rooms['antimat']==1) echo smiles1(smiles2(antirek(br($post['text']))))."</font>\n";
}elseif ($authorq['posts'] <= 2999) {
if ($rooms['antimat']==0)echo smiles1(smiles2(smiles3(antimat(antirek(br($post['text']))))))."</font>\n";
elseif ($rooms['antimat']==1) echo smiles1(smiles2(smiles3(antirek(br($post['text'])))))."</font>\n";
}elseif ($authorq['posts'] <= 4999) {
if ($rooms['antimat']==0)echo smiles1(smiles2(smiles3(smiles4(antimat(antirek(br($post['text'])))))))."</font>\n";
elseif ($rooms['antimat']==1) echo smiles1(smiles2(smiles3(smiles4(antirek(br($post['text']))))))."</font>\n";
}elseif ($authorq['posts'] <= 9999) {
if ($rooms['antimat']==0)echo smiles1(smiles2(smiles3(smiles4(smiles5(antimat(antirek(br($post['text']))))))))."</font>\n";
elseif ($rooms['antimat']==1) echo smiles1(smiles2(smiles3(smiles4(smiles5(antirek(br($post['text'])))))))."</font>\n";
}elseif ($authorq['posts'] >= 10000) {
if ($rooms['antimat']==0)echo smiles1(smiles2(smiles3(smiles4(smiles5(smiles6(antimat(antirek(br($post['text'])))))))))."</font>\n";
elseif ($rooms['antimat']==1) echo smiles1(smiles2(smiles3(smiles4(smiles5(smiles6(antirek(br($post['text']))))))))."</font>\n";
}}}else{
if ($config_smiles_onoff == 0){
if ($rooms['antimat']==0)echo smiles1(smiles2(smiles3(smiles4(smiles5(smiles6(antimat(antirek(br($post['text'])))))))))."\n";
elseif ($rooms['antimat']==1) echo smiles1(smiles2(smiles3(smiles4(smiles5(smiles6(antirek(br($post['text']))))))))."\n";
}elseif ($config_smiles_onoff == 1){
if ($authorq['posts'] <= 499) {
if ($rooms['antimat']==0)echo smiles1(antimat(antirek(br($post['text']))))."\n";
elseif ($rooms['antimat']==1) echo smiles1(antirek(br($post['text'])))."\n";
}elseif ($authorq['posts'] <= 999) {
if ($rooms['antimat']==0)echo smiles1(smiles2(antimat(antirek(br($post['text'])))))."\n";
elseif ($rooms['antimat']==1) echo smiles1(smiles2(antirek(br($post['text']))))."\n";
}elseif ($authorq['posts'] <= 2999) {
if ($rooms['antimat']==0)echo smiles1(smiles2(smiles3(antimat(antirek(br($post['text']))))))."\n";
elseif ($rooms['antimat']==1) echo smiles1(smiles2(smiles3(antirek(br($post['text'])))))."\n";
}elseif ($authorq['posts'] <= 4999) {
if ($rooms['antimat']==0)echo smiles1(smiles2(smiles3(smiles4(antimat(antirek(br($post['text'])))))))."\n";
elseif ($rooms['antimat']==1) echo smiles1(smiles2(smiles3(smiles4(antirek(br($post['text']))))))."\n";
}elseif ($authorq['posts'] <= 9999) {
if ($rooms['antimat']==0)echo smiles1(smiles2(smiles3(smiles4(smiles5(antimat(antirek(br($post['text']))))))))."\n";
elseif ($rooms['antimat']==1) echo smiles1(smiles2(smiles3(smiles4(smiles5(antirek(br($post['text'])))))))."\n";
}elseif ($authorq['posts'] >= 10000) {
if ($rooms['antimat']==0)echo smiles1(smiles2(smiles3(smiles4(smiles5(smiles6(antimat(antirek(br($post['text'])))))))))."\n";
elseif ($rooms['antimat']==1) echo smiles1(smiles2(smiles3(smiles4(smiles5(smiles6(antirek(br($post['text']))))))))."\n";
}}}






echo "</div></div>\n";
}else{
echo "<div class=content><img src='img/del.gif' alt=''> <b>".$post['author_login']."</b> <img src='img/off.gif' alt=''>\n";
if ($user['level']==1)echo "[<a href='add.php?act=del&id=".$post['id']."&pid=$id'><small>DEL</small></a>]\n";
elseif ($user['level']==2)echo "[<a href='add.php?act=del&id=".$post['id']."&pid=$id'><small>DEL</small></a>]\n";
elseif ($user['level']==3)echo "[<a href='add.php?act=del&id=".$post['id']."&pid=$id'><small>DEL</small></a>]\n";
echo "<div class='cit'>\n";
echo antirek(br($post['text']))."</div></div>\n";}



}}else{ echo "<div class=content>\n";echo "<br><img src='img/error.gif' alt=''> Сообщений нет! будь первым!<br><br></div>\n";}
echo "<div class=stat>\n";
pages($start, $total, 'room.php', 10);
echo "</div></div>\n";
echo "<div class=stat>\n";
}else{ echo " ID комнаты пустое!\n";}
echo "<a href='index.php'>Прихожая</a>";
echo "</div>\n";
}else{ header ("Location: index.php"); exit;}
include 'style/foot.php';
?>