View file guests/index.php

File size: 7.68Kb
<?
#########################################
/*
SM996
https://masteram.us/id3560
*/
########################################
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
$set['title']='Гостевая'; // заголовок страницы
include_once '../sys/inc/thead.php';
title();

$act=htmlspecialchars($_GET['act']);
$id=htmlspecialchars($_GET['id']);

include_once '../moduls/vip.inc.php';



if ($act=='sms'){
$msg=htmlspecialchars($_POST['text']);
$mat=antimat($msg);
if ($mat)$err='В тексте сообщения обнаружен мат: '.$mat;
if (strlen2($msg)>3024){$err='Сообщение слишком длинное';}
elseif (strlen2($msg)<2){$err='Короткое сообщение';}
elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `guest_sms` WHERE `user_id` = '$user[id]' AND `msg` = '".my_esc($msg)."' ORDER BY `id` DESC LIMIT 1"),0)!=0){$err='Ваше сообщение повторяет предыдущее';}
elseif(!isset($err)){
mysql_query("UPDATE `user` SET `guest` = '".($user['guest']+1)."' , `balls` = '".($user['balls']+1)."' WHERE `id` = '$user[id]'");

$msg = joke_text($msg,$user);
mysql_query("INSERT INTO `guest_sms` (`user_id`, `kom`, `text`, `date`) values('".$user['id']."', '".$id."', '".my_esc($msg)."', '".time()."')");


$bot = mysql_fetch_assoc(mysql_query("SELECT * FROM `guest_bot_sms` WHERE `kom` = '$id' AND `slovo` = '$msg' "));
if($bot){
$otvet=$bot['otvet'];
$rez = explode("*",trim($otvet));
$coun=count($rez)-1;
$r = rand(0,$coun);
$text=$rez[$r];
$bo = mysql_fetch_assoc(mysql_query("SELECT * FROM `guest_sms` WHERE `user_id` = '$bot[bot_id]' ORDER BY `id` DESC LIMIT 1"));
if($bo['text']==$text){
if($r==0 AND $coun>0){$text=$rez[$r+1];}
elseif($r>0 AND $r<$coun){$text=$rez[$r+1];}
elseif($r>0 AND $r==$coun){$text=$rez[$r-1];}
}
mysql_query("INSERT INTO `guest_sms` (`user_id`, `kom`, `text`, `date`) values('".$bot['bot_id']."', '".$id."', '".$text."', '".time()."')");
}


header('Location: ?act=kom&id='.$id.'');
}
echo''.$err.'';
}



if($act=="otvet"){
$guest_sm = mysql_fetch_assoc(mysql_query("SELECT * FROM `guest_sms` WHERE `id` = '".$id."' "));
$usser = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '".$guest_sm['user_id']."' "));
$otvet=get_user($usser['id']);
$otv=''.$otvet['nick'].', ';
if($usser){

echo '<center><div class="in"><a href="index.php">Комнаты</a>|<a href="/smiles/index.php">Смайлы</a>|</a> <a href="/bb.code.php">ВВ-коды</a></center>';
echo '<FORM method="POST" action="?act=sms&amp;id='.$guest_sm['kom'].'">
<textarea name="text" cols="40" rows="4" style="width: 100%;">'.$otv.'</textarea>
<br/>
<input type="submit" name="sendmsg" value="Отправить"/>
</FORM>';

}else{
echo '<div class="msg">Пользователя не существует.</div>';
}
include_once '../sys/inc/tfoot.php';

exit;
}

if($act=="kto_on"){

$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `guest_time` WHERE kom = '".$id."' AND `time`>'".(time()-120)."' "), 0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$q = mysql_query("SELECT * FROM `guest_time` WHERE kom = '".$id."' AND `time`>'".(time()-120)."' ORDER BY `time` DESC LIMIT $start, $set[p_str]");
echo "<table class='post'>\n";
if ($k_post==0)
{
echo "   <tr>\n";
echo "  <td class='p_t'>\n";
echo "Нет никого\n";
echo "  </td>\n";
echo "   </tr>\n";
}
while ($guest = mysql_fetch_array($q))
{
echo "   <tr>\n";

if ($set['set_show_icon']==2){
//echo "  <td class='icon48' rowspan='2'>\n";
echo "  </td>\n";
}
elseif ($set['set_show_icon']==1)
{
//echo "  <td class='icon14'>\n";
echo "  </td>\n";

}

echo "  <td class='noy'>\n";
echo "".on_status($guest['id'])."\n";
echo "".status($guest['id'])."\n";
echo "<a href='/info.php?id=$guest[id]'>\n";
$nikk = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '$guest[id]' "));
echo GradientText("$nikk[nick]", "$nikk[ncolor]", "$nikk[ncolor2]");
echo "</a>\n";
echo "".medal($guest['id'])."\n".vip($guest['id'])."";
if ($nikk['akimitsu_vip']==1) {echo'<img src="/vipi.gif" alt="" />'; }
echo " ".wap_web($ank['id'])." ";
echo "   </td>\n";
echo "   </tr>\n";
}

echo "</table>\n";


if ($k_page>1)str("?",$k_page,$page); // Вывод страниц



echo "<div class='p_m'><a href='?act=kom&id=$id'>Назад</a></div>";
include_once '../sys/inc/tfoot.php';
exit;
}


if($act=="kom"){
mysql_query("UPDATE `guest_time` SET `kom` = '".$id."' , `time` = '".time()."' WHERE `id` = '".$user['id']."'");
$onno = mysql_fetch_assoc(mysql_query("SELECT * FROM `guest_time` WHERE `kom` = '".$id."' AND `id` = '".$user['id']."'"));
if(!$onno){mysql_query("INSERT INTO `guest_time` (`id`, `kom`, `time`) values('".$user['id']."', '".$id."', '".time()."')");}
$onof = mysql_fetch_assoc(mysql_query("SELECT * FROM `guest_time` WHERE `kom` = '".$id."' AND `time` < '".time()."' "));
if($onof){mysql_query("DELETE FROM `guest_time` WHERE `id`='".$onof['id']."'");}


$on = mysql_result(mysql_query("SELECT COUNT(*) FROM `guest_time` WHERE kom = '$id' AND `time`>'".(time()-120)."'"), 0);
echo '<center><div class="in"><a href="index.php">Комнаты</a>| <a href="?act=kom&amp;id='.$id.'".rand(1000,9999)."/">Обновить</a>|</a><a href="?act=kto_on&amp;id='.$id.'">Кто здесь('.$on.')</a>|</a> <a href="/smiles/index.php">Смайлы</a>|</a> <a href="/bb.code.php">ВВ-коды</a></center>';
echo '<FORM method="POST" action="?act=sms&amp;id='.$id.'">';
panel_bb('textarea');
echo '
<textarea id="textarea" name="text" cols="40" rows="4" style="width: 100%;"></textarea>
<br/>
<input type="submit" name="sendmsg" value="Отправить"/>
</FORM>';


$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `guest_sms` WHERE `kom` ='".$id."' "),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
echo "<table class='post'>";
if ($k_post==0)
{
echo "   <tr>";
echo "  <td class='p_t'>";
echo "Нет сообщений";
echo "  </td>";
echo "   </tr>";
}
$q=mysql_query("SELECT * FROM `guest_sms` WHERE `kom` ='".$id."' ORDER BY id DESC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_assoc($q))
{
$date = date(' y/d/m в H:i', $post['date']);
$ank=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '$post[user_id]'"));
echo "   <tr>";
echo "  <div class='p_m'>";
avatar2($ank['id']);
echo "".on_status($ank['id'])."";
echo "".status($ank['id'])."";
echo '<a href="/info.php?id='.$ank['id'].'">';
echo GradientText("$ank[nick]", "$ank[ncolor]", "$ank[ncolor2]");
echo "</a><small>".$date."</small><br />";
echo output_text($post['text'], $post['user_id']);
echo "</br></br> <a href='?act=otvet&id=$post[id]'>Ответить</a> ";
echo "  </div";
echo "</table>";

}
if ($k_page>1)str('?act=kom&amp;id='.$id.'&amp;',$k_page,$page); // Вывод страниц
include_once '../sys/inc/tfoot.php';
exit;
}



if($user['group_access']>1){
echo'<div class="gmenu"><a href="admin.php">Админка</a><br /></div>';
}

$ko = mysql_query("SELECT * FROM `guest_kom` WHERE `id`");
while ($kom = mysql_fetch_assoc($ko)){
$on = mysql_result(mysql_query("SELECT COUNT(*) FROM `guest_time` WHERE kom = '".$kom['id']."' AND `time`>'".(time()-120)."'"),0);
echo'
<div class="gmenu"><a href="?act=kom&amp;id='.$kom['id'].'">'.$kom['name'].'('.$on.')</a></div>
';

}
$ko = mysql_fetch_assoc(mysql_query("SELECT * FROM `guest_kom` WHERE `id`"));
if(!$ko){
echo'<div class="gmenu">Нет комнат</div>';
}



include_once '../sys/inc/tfoot.php';
?>