Файл: test.zfarm.mobi/mystylechat/linkindex.php
Строк: 195
<?
/////////////////////////
/*
Author MyStyle ZomBi.Biz
Год 2013 Права предоставлены автору Шехову Виталию Александровичу
http://vk.com/online_user
*/
/////////////////////////
$set[p_str]= 10;
$ku = $user;
if(intval($_GET['chat'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_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 `mystyle_chat` WHERE `id` = '".intval($_GET['chat'])."' AND `type` = 'room'"));
if(isset($_GET['edit']) && $ku['status']>1)
{
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 `mystyle_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=""><div class="">';
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>";
}
elseif(isset($_GET['clean']) && $ku['status']>1)
{
if($_GET['clean']=='ok')
{
mysql_query("delete from `mystyle_chat` where `mother` = '$chat[id]' and `type` = 'komm'");
header("Location:?chat=$chat[id]");
}
else echo '<div class="event"><h1>Подтверждение</h1></div><div class="content"><div class="block"><ul class="block"><li><span class="title">Вы уверены?</span></li><li class="pt"><img alt="" width="16" height="16" src="images/icons/tick.png"> <a href="?chat='.$chat['id'].'&clean=ok"><span>
Да, подтверждаю</span></a></li><li><img alt="" width="16" height="16" src="images/icons/cross.png"> <a href="?chat='.$chat['id'].'"><span>
Нет, отказываюсь</span></a></li></ul></div>';
}
elseif(isset($_GET['del_komm']) && intval($_GET['del_komm'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_chat` WHERE `id` = '".intval($_GET['del_komm'])."' AND `type` = 'komm'"),0)!=0 && $ku['status']>1)
{
mysql_query("delete from `mystyle_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']>1)
{
if($_GET['del']=='ok')
{
mysql_query("delete from `mystyle_chat` where `mother` = '$chat[id]' and `type` = 'komm'");
mysql_query("delete from `mystyle_chat` where `id` = '$chat[id]' and `type` = 'room'");
header("Location:?chat");
}
else echo '<div class="event"><h1>Подтверждение</h1></div><div class="content"><div class="block"><ul class="block"><li><span class="title">Вы уверены?</span></li><li class="pt"><img alt="" width="16" height="16" src="images/icons/tick.png"> <a href="?chat='.$chat['id'].'&del=ok"><span>
Да, подтверждаю</span></a></li><li><img alt="" width="16" height="16" src="images/icons/cross.png"> <a href="?chat='.$chat['id'].'"><span>
Нет, отказываюсь</span></a></li></ul></div>';
}
else
{
if(isset($_GET['otv']) && intval($_GET['otv'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_user` WHERE `id` = '".intval($_GET['otv'])."'"),0)!=0 && intval($_GET['otv'])!=$ku['id'])
{
$otv=mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_user` WHERE `id` = '".intval($_GET['otv'])."'"));
$otvu=mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_user` WHERE `id` = '$otv[id_user]'"));
}
//////////////////////////////////// ниже ставь ////////////////////////////////////////////////
echo "<div class='event'><h1>".hsc($chat['name'])."</h1></div>";
echo "<a class="btn" href='?chat=$chat[id]&".passgen()."'>Обновить</a><a class="btn" href='?chat'>Чаты</a><a class="btn" href='?smile'>Смайлы</a><a class="btn" href='?chat=$chat[id]".(!isset($_GET['write'])?"&write":null)."'>Написать</a>";
if(isset($_GET['add']) && $_GET['add']=='ok' && isset($_GET['write']))
{
$msg = htmlspecialchars(trim($_POST['msg']));
//$msg=$_POST['msg'];
$pr = mysql_query("SELECT COUNT(*) FROM `mystyle_chat` WHERE `msg` = '$msg' LIMIT 1");
if (mysql_result($pr, 0) != 0) {
header("Location:?chat=$chat[id]");
exit();
}
if($msg==NULL)
{
echo err_game("Слишком короткое сообщение");
$err=1;
}
if(!isset($err))
{
mysql_query("UPDATE `mystyle_user` SET `money` = '".($user['money']+50)."' WHERE `id` = '".$user['id']."'");
mysql_query("INSERT INTO `mystyle_chat` SET `msg` = '".my_esc($msg)."', `id_user` = '$ku[id]', `type` = 'komm', `mother` = '$chat[id]', `time` = '$time'".(isset($otv)?", `otvet` = '$otv[id]'":null)."");
header("Location:?chat=$chat[id]&write=yes");
exit;
}
}
/////////////////////////////
//Ответ
/////////////////////////////
$idq = intval($_REQUEST['idq']);
$sql = mysql_query("SELECT * FROM mystyle_user WHERE id = $idq") or die(mysql_error());
$us = mysql_fetch_assoc($sql);
if($idq) $komu = htmlspecialchars('' . $us['nick'] . ', ');
if(isset($_GET['write'])){
if($ban['id'])
{
echo "<div>
<li class='major'><span>".($ban['izg']==1?'Изгнание':"Обет Молчания до ".vremja($ban['time']))."</span>, выдал".($us_ban['pol']==2?'a':null)." <span>";
echo "".users($ban['id_who'])."</span><span>, (".$ban['msg'].")</span></li></div>";
}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><input class="code_input_input" name='msg' type='text' value='$komu' rows='3'></label><input class="btn bold" style="width: 100%; font-size: 16px;" type='submit' value='Отправить'></form></div>";
}
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_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 `mystyle_chat` WHERE `type` = 'komm' AND `mother` = '$chat[id]' ORDER BY `time` DESC LIMIT $start, $set[p_str]");
while($post=mysql_fetch_array($q))
{
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_user` WHERE `id` = '$post[id_user]'"));
if($post['otvet']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_user` WHERE `id` = '$post[otvet]'"),0)!=0)
{
$otvet=mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_user` WHERE `id` = '$post[otvet]'"));
$otvetu=mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_user` WHERE `id` = '$otvet[id_user]'"));
}
echo '<div class="btn"><span>';
echo " ".users($ank['id'])." <span class='minor small'> <span>".vremja($post['time'])."</span></span><p>".(isset($otvet)?"".($ku['id']==$otvet['id']?"<span class='rare'>":null)."$otvetu[nick]".($ku['id']==$otvet['id']?"</span>":null).", ":null)."".mat(smile(bbcode(check($post['msg']))))."</p><div>".($ank['id']!=$ku['id']?"<a class='small minor' href='?chat=$chat[id]&idq=$ank[id]&write'>Ответить</a>":null)."";
if($ku['status']>1)echo " <a class='small minor' href='?chat=$chat[id]&del_komm=$post[id]'>[удалить]</a>";
echo "</div></div>";
}
if ($k_page>1)str("?chat=$chat[id]&",$k_page,$page); // Вывод страниц
if($ku['status']>1)echo "<li><img alt='o' width='16' height='16' src='images/icons/delete.png'> <a href='?chat=$chat[id]&del'>Удалить</a></li>";
if($ku['status']>1)echo "<li><img alt='o' width='16' height='16' src='images/icons/delete.png'> <a href='?chat=$chat[id]&clean'>Очистить комнату</a></li>";
if($ku['status']>1)echo "<li><img alt='o' width='16' height='16' src='images/icons/forum_edit.png'> <a href='?chat=$chat[id]&edit'>Изменить название</a></li>";
echo "<li><img width='16' height='16' src='images/icons/chat.png' alt='o'> <a href='?chat'>Чаты</a></li>";
echo "</div>";
}
}
else
{
if(isset($_GET['add']) && $ku['status']>1)
{
echo '<div class="event"><h1>Создание комнаты</h1></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 `mystyle_chat` WHERE `type` = 'room'"), 0)+1;
mysql_query("INSERT INTO `mystyle_chat` SET `name` = '".my_esc($name)."', `id_user` = '$ku[id]', `type` = 'room', `mother` = '0', `time` = '$time', `admod` = '$admod', `pos` = '$pos', `opis` = '".my_esc($opis)."'");
header("Location:?chat");
exit;
}
}
echo '<div class="content"><div class="block">';
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>";
}
else
{
if (isset($_GET['up']) && $ku['status']>1)
{
$up=mysql_fetch_assoc(mysql_query("SELECT * FROM `mystyle_chat` WHERE `id` = '".intval($_GET['up'])."' AND `type` = 'room' LIMIT 1"));
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_chat` WHERE `pos` < '$up[pos]' AND `type` = 'room' LIMIT 1"),0)!=0)
{
mysql_query("UPDATE `mystyle_chat` SET `pos` = '".($up['pos'])."' WHERE `pos` = '".($up['pos']-1)."' AND `type` = 'room' LIMIT 1");
mysql_query("UPDATE `mystyle_chat` SET `pos` = '".($up['pos']-1)."' WHERE `id` = '".intval($_GET['up'])."' AND `type` = 'room' LIMIT 1");
}
}
elseif (isset($_GET['down']) && $ku['status']>1)
{
$down=mysql_fetch_assoc(mysql_query("SELECT * FROM `mystyle_chat` WHERE `id` = '".intval($_GET['down'])."' AND `type` = 'room' LIMIT 1"));
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_chat` WHERE `pos` > '$down[pos]' AND `type` = 'room' LIMIT 1"),0)!=0)
{
mysql_query("UPDATE `mystyle_chat` SET `pos` = '".($down['pos'])."' WHERE `pos` = '".($down['pos']+1)."' AND `type` = 'room' LIMIT 1");
mysql_query("UPDATE `mystyle_chat` SET `pos` = '".($down['pos']+1)."' WHERE `id` = '".intval($_GET['down'])."' AND `type` = 'room' LIMIT 1");
}
}
echo '<div class="content"><div class="block"><ul>';
$q=mysql_query("SELECT * FROM `mystyle_chat` WHERE `type` = 'room'".($ku['status']<=1?" AND `admod` = '0'":null)." ORDER BY `pos` ASC");
while($post=mysql_fetch_array($q))
{
$typert = 'room';
echo '<div><a class="btn" href="?chat='.$post['id'].'">
<img width="16" height="16" src="images/icons/chat.png" alt="o"> <span>'.hsc($post['name']).'</span>
<span class="fr like">('.mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_chat` WHERE `type` = 'komm' AND `mother` = '$post[id]'"), 0).')</span> <br />
'.(strlen2($post['opis'])!=NULL?"".hsc($post['opis'])."":null).'</a></div>';
if(isset($_GET['moderate']) && $ku['status']>1)echo "<a class="btn" href='?chat&moderate&up=$post[id]'><img width='16' height='16' src='images/icons/up.png' alt='o'></a> <a href='?chat&moderate&down=$post[id]'><img width='16' height='16' src='images/icons/down.png' alt='o'></a>";
}
echo "</ul>";
echo "<ul class='pt'>";
if($ku['status']>1)echo "<li><img width='16' height='16' src='images/icons/moderate.png' alt='o'> <a href='?chat".(!isset($_GET['moderate'])?"&moderate":null)."'>Управление</a></li><li><img width='16' height='16' src='images/icons/chat.png' alt='*' title='*'> <a href='?chat&add'>Создать комнату</a></li>";
echo "</ul></div>";
}
}
/////////////////////////
/*
Author MyStyle ZomBi.Biz
Год 2013 Права предоставлены автору Шехову Виталию Александровичу
http://vk.com/online_user
*/
/////////////////////////
?>