Файл: zfarm.mobi/inc/communication/chat.php
Строк: 204
<?
$title='Чат';
include_once '../system/config.php';
include_once'../user/Chest.php';
if(isset($_GET['ban']) && ($ku['status']>0) && $ku['id']!=$ank['id'])
{
$chat=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_chat` WHERE `id` = '".intval($_GET['chat'])."' AND `type` = 'room'"));
$BanChat=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_chat` WHERE `id` = '".intval($_GET['ban'])."'"));
include_once'../user/BanChat.php';
}
if(intval($_GET['chat'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_chat` WHERE `id` = '".intval($_GET['chat'])."' AND `type` = 'room'".($ku['status']<=1?" AND `admod` = '0'":null).""),0)!=0)
{
$chat=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_chat` WHERE `id` = '".intval($_GET['chat'])."' AND `type` = 'room'"));
if(isset($_GET['edit']) && $ku['status']>0)
{
if($_GET['edit']=='ok')
{
$name=$_POST['name'];
$opis=$_POST['opis'];
if($name==NULL)
{
echo err_game("Слишком короткое название");
$err=1;
}
if(!isset($err))
{
if($_POST['admod']==1)$admod=1;else $admod=0;
mysql_query("UPDATE `kolhoz_chat` SET `name` = '".my_esc($name)."', `opis` = '".my_esc($opis)."', `admod` = '$admod' WHERE `id` = '$chat[id]'");
header("Location:/chat/$chat[id]");
exit;
}
}
echo '<div class="content"><div class="div">';
echo "<form action='/chat/$chat[id]/edit/ok' method='post'><ul><li><label><div>Название:</div><div><input type='text' class='wide' value='".hsc($chat['name'])."' name='name'></div></label></li><li><label><div>Описание:</div><div><textarea class='wide' rows='5' name='opis'>".hsc($chat['opis'])."</textarea></div></label></li>";
echo "<input type='checkbox' name='admod' value='1'".($chat['admod']==1?" checked='checked'":null)."> <span>Давать доступ только администрации</span><br/>";
echo "<li><input type='submit' value='Создать'></li></ul></form></div>";
include_once'../system/foot.php';
}
elseif(isset($_GET['clean']) && $ku['status']>0)
{
if($_GET['clean']=='ok')
{
mysql_query("delete from `kolhoz_chat` where `mother` = '$chat[id]' and `type` = 'komm'");
header("Location:/chat/$chat[id]");
}
else echo '<div class="title">Подтверждение</h2></div><div class="content"><div class="title"><ul class="block"><li><span >Вы уверены?</span></li><li class="pt"><img alt="" src="/img/icons/tick.png"> <a href="/chat/'.$chat['id'].'/clean/ok"><span>
Да, подтверждаю</span></a></li><li><img alt="" src="/img/icons/cross.png"> <a href="/chat/'.$chat['id'].'"><span>
Нет, отказываюсь</span></a></li></ul></div>';
include_once'../system/foot.php';
}
elseif(isset($_GET['del_komm']) && intval($_GET['del_komm'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_chat` WHERE `id` = '".intval($_GET['del_komm'])."' AND `type` = 'komm'"),0)!=0 && $ku['status']>0)
{
mysql_query("delete from `kolhoz_chat` where `mother` = '$chat[id]' and `type` = 'komm' and `id` = '".intval($_GET['del_komm'])."'");
header("Location:/chat/$chat[id]");
}
elseif(isset($_GET['del']) && $ku['status']>0)
{
if($_GET['del']=='ok')
{
mysql_query("delete from `kolhoz_chat` where `mother` = '$chat[id]' and `type` = 'komm'");
mysql_query("delete from `kolhoz_chat` where `id` = '$chat[id]' and `type` = 'room'");
header("Location:/chat");
}
else echo '<div class="title">Подтверждение</h2></div><div class="content"><div class="title"><ul class="block"><li><span >Вы уверены?</span></li><li class="pt"><img alt="" src="/img/icons/tick.png"> <a href="/chat/'.$chat['id'].'/del/ok"><span>
Да, подтверждаю</span></a></li><li><img alt="" src="/img/icons/cross.png"> <a href="/chat/'.$chat['id'].'"><span>
Нет, отказываюсь</span></a></li></ul></div>';
include_once'../system/foot.php';
}
else
{
if(isset($_GET['otv']) && intval($_GET['otv'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `id` = '".intval($_GET['otv'])."'"),0)!=0 && intval($_GET['otv'])!=$ku['id'])
{
$otv=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '".intval($_GET['otv'])."'"));
$otvu=$otv;
}
echo"<div class='rzd2'></div><div class='menuin2'>";
echo "<div class='title'><a href='/chat'>".hsc($chat['name'])."</a> <a href=''><img alt='o' src='/img/icons/refresh.png'> </a></h2></div>";
echo '<div class="content"><div class="div"><ul>';
echo "<img alt='' src='/img/icons/pencil.png'> <a href='/chat/$chat[id]".(!isset($_GET['write'])?"/write":null)."'>Написать</a></div></div><div class='div'>";
if(isset($_GET['add']) && $_GET['add']=='ok' && isset($_GET['write']) && !isset($molchi))
{
$msg=$_POST['msg'];
if($msg==NULL)
{
echo err_game("Слишком короткое сообщение");
$err=1;
}
if(preg_match("/(хуй|пидр|пизда|долбаеб|сука|уеба|еб)/",$_POST['msg']))
{
mysql_query("INSERT INTO `kolhoz_chat` SET `msg` = 'Пользователь $ku[nick] заблокирован на сутки.
Причина: Мат.', `id_user` = '0', `type` = 'komm', `mother` = '$chat[id]', `open` = '1', `time` = '$time'");
$timeAutoBan=time()+3600*24;
mysql_query("INSERT INTO `kolhoz_ban` SET `id_user` = '$ku[id]', `id_who` = '3', `msg` = 'Мат', `izg` = '0', `reason` = '".($_POST['msg'])."', `time` = '$timeAutoBan'");
$err=1;
}
if(($ku['level']<30) && (preg_match("#([a-z0-9s-.]){3,20}(.|,)([a-zs]){2,4}#si",$_POST['msg'])))
{
mysql_query("INSERT INTO `kolhoz_chat` SET `msg` = 'Пользователь $ku[nick] заблокирован на всегда.
Причина: Реклама сторонних ресурсов.', `id_user` = '0', `type` = 'komm', `mother` = '$chat[id]', `open` = '1', `time` = '$time'");
mysql_query("INSERT INTO `kolhoz_ban` SET `id_user` = '$ku[id]', `id_who` = '0', `msg` = 'Мат', `izg` = '1', `reason` = '".($_POST['msg'])."', `time` = '$timeAutoBan'");
$err=1;
}
if(!isset($err))
{
mysql_query("INSERT INTO `kolhoz_chat` SET `msg` = '".my_esc($msg)."', `id_user` = '$ku[id]', `type` = 'komm', `mother` = '$chat[id]', `open` = '1', `time` = '$time'".(isset($otv)?", `otvet` = '$otv[id]'":null)."");
mysql_query("UPDATE `kolhoz_user` SET `chat` = '".($ku['chat']+1)."' WHERE `id` = '".$ku['id']."'");
header("Location:/chat/$chat[id]/");
exit;
}
}
if(isset($_GET['write']))
{
if($ban['id'])
{
echo "<br><li class='major'><span>".($ban['izg']==1?'Изгнание':"У вашего аккаунта отключена возможность писать комментарии.")." <span></li>";
}
else echo "<div><form action='/chat/$chat[id]/write/yes/add/ok".(isset($otv)?"/otv/$otv[id]":null)."' method='post'><label>Сообщение".(isset($otv)?" для $otvu[nick]":null).":<br><textarea class='wide' rows='2' name='msg'></textarea></label><br><input type='submit' value='Отправить'></form></div>";
}
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_chat` WHERE `type` = 'komm' AND `mother` = '$chat[id]'"),0);
if ($k_post==0)
{
echo "пустo...";
}
$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 `kolhoz_chat` WHERE `type` = 'komm' AND `mother` = '$chat[id]' AND `open` = '1' ORDER BY `time` DESC LIMIT $start, $set[p_str]");
while($post=mysql_fetch_array($q))
{
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$post[id_user]'"));
if($post['otvet']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `id` = '$post[otvet]'"),0)!=0)
{
$otvet=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$post[otvet]'"));
$otvetu=$otvet;
}
echo "<li class='pt'><div><span>";
if($ank['id']>0)
{
echo on_k($ank['id']);
echo " <a class='' href='/user/$ank[id]'><span>".nc($ank['id'])."</span></a></span>";
}
else
{
echo'Системное сообщение';
}
echo"
<span class='minor small'> (<span>".vremja($post['time'])."</span>)</span></div>".(($post['otvet']!=0)?"".($ku['id']==$otvet['id']?"<span class='rare'>":null)."$otvetu[nick]".($ku['id']==$otvet['id']?"</span>":null).", ":null)."".output_text($post['msg'], $ank['id'])."<div>
";
if($ank['id']>0)
{
echo" ".($ank['id']!=$ku['id']?"<a style='font-size:12px;' href='/chat/$chat[id]/otv/$ank[id]/write'>[ответить]</a>":null)."";
}
if($ku['status']>0)echo " <a style='font-size:11px;' href='/chat/$chat[id]/Delete/$post[id]'>[x]</a>";
if($ku['status']>0)echo " <a style='font-size:11px;' href='/chat/$chat[id]/ban/$post[id]'>[бан]</a>";
echo "</div></li>";
}
if ($k_page>1)str("/chat/$chat[id]/",$k_page,$page); // Вывод страниц
echo "</ul>";
echo "<ul class='pt'>";
echo "<li></li><br>";
echo "<div><img src='/img/icons/smiles.png' alt='o'> <a href='/smiles'>Смайлы</a></div>";
echo "<li><img src='/img/icons/chat.png' alt='o'> <a href='/chat'>Чаты</a></li>";
echo "</ul></div>";
echo"</div></div><div class='rzd2'></div>";
include_once'../system/foot.php';
}
}
else
{
if(isset($_GET['add']) && $ku['status']>0)
{
echo '<div class="title">Создание комнаты</h2></div>';
if($_GET['add']=='ok')
{
$name=$_POST['name'];
$opis=$_POST['opis'];
if($name==NULL)
{
echo err_game("Слишком короткое название");
$err=1;
}
if(!isset($err))
{
if($_POST['admod']==1)$admod=1;else $admod=0;
$pos=mysql_result(mysql_query("SELECT MAX(`pos`) FROM `kolhoz_chat` WHERE `type` = 'room'"), 0)+1;
mysql_query("INSERT INTO `kolhoz_chat` SET `name` = '".my_esc($name)."', `id_user` = '$ku[id]', `type` = 'room', `mother` = '0', `time` = '$time', `admod` = '$admod', `pos` = '$pos', `opis` = '".my_esc($opis)."'");
mysql_query("UPDATE `kolhoz_user` SET `chat` = '".($ku['chat']+1)."' WHERE `id` = '".$ku['id']."'");
header("Location:/chat");
exit;
}
}
echo '<div class="content"><div class="div">';
echo "<form action='/chat/add/ok' method='post'><ul><li><label><div>Название:</div><div><input type='text' class='wide' value='' name='name'></div></label></li><li><label><div>Описание:</div><div><textarea class='wide' rows='5' name='opis'></textarea></div></label></li>";
echo "<input type='checkbox' name='admod' value='1'> <span>Давать доступ только администрации</span><br/>";
echo "<li><input type='submit' value='Создать'></li></ul></form></div>";
include_once'../system/foot.php';
}
else
{
if (isset($_GET['up']) && $ku['status']>0)
{
$up=mysql_fetch_assoc(mysql_query("SELECT * FROM `kolhoz_chat` WHERE `id` = '".intval($_GET['up'])."' AND `type` = 'room' LIMIT 1"));
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_chat` WHERE `pos` < '$up[pos]' AND `type` = 'room' LIMIT 1"),0)!=0)
{
mysql_query("UPDATE `kolhoz_chat` SET `pos` = '".($up['pos'])."' WHERE `pos` = '".($up['pos']-1)."' AND `type` = 'room' LIMIT 1");
mysql_query("UPDATE `kolhoz_chat` SET `pos` = '".($up['pos']-1)."' WHERE `id` = '".intval($_GET['up'])."' AND `type` = 'room' LIMIT 1");
}
}
elseif (isset($_GET['down']) && $ku['status']>0)
{
$down=mysql_fetch_assoc(mysql_query("SELECT * FROM `kolhoz_chat` WHERE `id` = '".intval($_GET['down'])."' AND `type` = 'room' LIMIT 1"));
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_chat` WHERE `pos` > '$down[pos]' AND `type` = 'room' LIMIT 1"),0)!=0)
{
mysql_query("UPDATE `kolhoz_chat` SET `pos` = '".($down['pos'])."' WHERE `pos` = '".($down['pos']+1)."' AND `type` = 'room' LIMIT 1");
mysql_query("UPDATE `kolhoz_chat` SET `pos` = '".($down['pos']+1)."' WHERE `id` = '".intval($_GET['down'])."' AND `type` = 'room' LIMIT 1");
}
}
echo"<div class='rzd2'></div><div class='menuin2'>";
echo'<div class="title">Куда идем?</div><div class="div">';
$q=mysql_query("SELECT * FROM `kolhoz_chat` WHERE `type` = 'room'".($ku['status']<=0?" AND `admod` = '0'":null)." ORDER BY `pos` ASC");
while($post=mysql_fetch_array($q))
{
echo "<li><img src='/img/icons/chat/$post[img].png' alt='o'> <a href='/chat/$post[id]'><span>".hsc($post['name'])."</span></a> <br>".(strlen2($post['opis'])!=NULL?"".hsc($post['opis'])."":null)."";
echo "</li>";
}
echo "</ul></div>";
echo"</div></div><div class='rzd2'></div>";
include_once'../system/foot.php';
}
}
?>