Файл: rayb.me/chat.php
Строк: 169
<?php
require_once ('system/func.php');
$title = 'Общий чат';
require_once ('system/header.php');
auth();
if(isset($user)) DB::Query("UPDATE `users_count` SET `chat` = '1' WHERE `id_user` = '$uid'");
if(isset($_GET['delpos']) and $user['access'] >= 2){
$id = text($_GET['delpos']);
$title = 'Очистить чат';
require_once 'system/header.php';
echo '<div class="block">';
echo '<div class="feedback">';
echo '<center>Очистить последние 10 сообщений?<br>';
echo '<a href="?delete_chat_pos" class="myButton"> Да </a>';
echo ' | ';
echo '<a href="/chat" class="myButton"> Нет </a>';
echo '</center></div></div>';
require_once 'system/footer.php';
exit;
}
if(isset($_GET['delvse']) and $user['access'] >= 2){
$id = text($_GET['delvse']);
$title = 'Очистить чат';
require_once 'system/header.php';
echo '<div class="block">';
echo '<div class="feedback">';
echo '<center>Очистить весь чат?<br>';
echo '<a href="?delete_chat_vse" class="myButton"> Да </a>';
echo ' | ';
echo '<a href="/chat" class="myButton"> Нет </a>';
echo '</center></div></div>';
require_once 'system/footer.php';
exit;
}
if(isset($_GET['delper']) and $user['access'] >= 2){
$id = text($_GET['delper']);
$title = 'Очистить чат?';
require_once 'system/header.php';
echo '<div class="block">';
echo '<div class="feedback">';
echo '<center>Очистить первые 10 сообщений?<br>';
echo '<a href="?delete_chat_per" class="myButton"> Да </a>';
echo ' | ';
echo '<a href="/chat" class="myButton"> Нет </a>';
echo '</center></div></div>';
require_once 'system/footer.php';
exit;
}
if(isset($_GET['delete_chat_pos']) and $user['access'] >= 2){
DB::Query("delete from `chat` order by id desc limit 10");
$_SESSION['msg'] = 'Очищено 10 последних сообщений';
go('?');
}
if(isset($_GET['delete_chat_vse']) and $user['access'] >= 2){
$text = "Чат очистил: [url=/profile/".$uid."]".$user['name']."[/url].";
DB::Query("delete from `chat`");
DB::Query("update `users_count` set `chat` = '1'");
DB::Query("insert into `chat` set `id_user` = '2', `time` = '".time()."', `text` = '".$text."'");
$_SESSION['msg'] = 'Чат весь очищен';
go('?');
}
if(isset($_GET['delete_chat_per']) and $user['access'] >= 2){
DB::Query("delete from `chat` limit 10");
$_SESSION['msg'] = 'Очищено первые 10 сообщений';
go('?');
}
if(isset($_GET['delete_post']) and $user['access'] >= 2){
DB::Query("delete from `chat` where `id` = '".text($_GET['delete_post'])."'");
$_SESSION['msg'] = 'Delete post';
go('?');
}
if(isset($_GET['text'])){
if(isset($_POST['text'])){
$text = text($_POST['text']);
if(strlen($text) < 1 or strlen($text) > 1200) $err = 'Длина сообщения должна быть в пределах 1-1200 символов';
//if($ban) $err = "Вы в муте, до снятия мута ".tl($ban['last']-time());
if($user['angels'] < 10000) $err = "Писать в чат можно набрав 10k ангелов";
if(($user['registr']+1800) > $user['online']) $err = "Общение в чате будет доступно через ".tls($user['registr']+1800 - $user['online']);
if($user['gold'] < 100000) $err = "Писать в чат можно прокочав бизнес комнаты";
if(!isset($err)){
DB::Query("insert into `chat` set `id_user` = '$uid', `time` = '".time()."', `text` = '$text'");
DB::Query("update `users_count` set `chat` = '0'");
if($qq['time_1'] < time()){
DB::Query("UPDATE `users` SET `q_1` = `q_1` + 1 WHERE `id` = " . $user['id'] . "");
}
DB::Query("update `users` set `ruby` = '".($user['ruby']+500)."' where `id` = '$uid'");
$_SESSION['msg'] = 'Сообщение отправлено, вы получаете 500 <img src="/img/ruby.png" alt="$" width="16" height="16"/> и '.rand(1,9).' балов';
go('/chat');
}else{
$_SESSION['msg'] = $err;
go('/chat');
}
}else{
$_SESSION['msg'] = 'Поле ввода пустое';
go('/chat');
}
}
if(($user['registr']+1800) > $user['online']) {
echo msg("Общение в чате будет доступно через ".tls($user['registr']+1800 - $user['online']));
}else{
$us_co = mysqli_fetch_assoc(DB::Query("SELECT * FROM `users_count` WHERE `id_user` = '".$uid."'"));
echo '<form name="form" method="post" action="?text">';
echo '<br/><center>';
if($us_co['gchat'] == 0){
echo '<a class="myButton" style="margin-left: 16px;" href="/gchat">';
echo 'Игра в Города ';
echo '<b>+</b>';
echo '</a>';
}else{
echo '<a class="myButton" style="margin-left: 16px;" href="/gchat">';
echo 'Игра в Города';
echo '</a>';
}
echo '</center><br/>';
echo '<center><textarea name="text" style="resize:vertical;" rows="5" onkeypress="ctrlEnter(event, this);"></textarea></center>';
echo '<div class="fight center">'.bbpanel("form", "text").'</div>';
?><script type='text/javascript'>
function ctrlEnter(event, formElem){
if((event.ctrlKey) && ((event.keyCode == 0xA)||(event.keyCode == 0xD))){
formElem.form.submit();
}
}
</script><br/><?
echo '<center><input type="submit" class="myButton" value="Отправить"/></center>';
echo '</form><br/>';
}
$set['p_str'] = 10;
$k_post = DB::result(DB::Query("select count(*) from `chat`"),0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];
if($k_post == 0) msg("Сообщений не найдено. Будешь первым?");
$q = DB::Query("select * from `chat` order by `id` desc limit ".$start.", ".$set['p_str']."");
while($post = mysqli_fetch_assoc($q)){
$ank = mysqli_fetch_assoc(DB::Query("select * from `users` where `id` = '".$post['id_user']."' limit 1"));
if(preg_match('/'.$user['name'].'/i', $post['text'])){
$to = ["".$user['name'].", " =>'[color=green]'.$user['name'].', [/color]'];
$post['text'] = strtr($post['text'], $to);
}
if($ank['id'] == $uid) {
echo icons_user2($ank['ico'],$ank['online']).'<font color="green">'.$ank['name'].'</font>';
echo '<span style="float:right;font-size: 9px; color:grey;pading:0px;margin:0px;">';
echo time_last($post['time']);
if($user['access'] >= 2) echo ' <a href="?delete_post='.$post['id'].'"><font color="red">(x)</font></a>';
echo '</span>';
echo '<span id="top_vs"></span>';
echo '<div class="statuse">';
echo '<span style="font-size: 15px; color:black;">'.text_msg($post['text']).'</span></div>';
}else{
echo icons_user2($ank['ico'],$ank['online']).'<a href="/profile/'.$ank['id'].'">'.$ank['name'].'</a>';
if($ank['access'] == 7){
echo '<span style="font-size: 10px; color:#FF0000;"> [R] </span>';
}elseif($ank['access'] == 6){
echo '<span style="font-size: 10px; color:#FF0000;"> [S] </span>';
}elseif($ank['access'] == 5){
echo '<span style="font-size: 10px; color:#FF4500;"> [A] </span>';
}elseif($ank['access'] == 4){
echo '<span style="font-size: 10px; color:#20859E;"> [M] </span>';
}elseif($ank['access'] == 3){
echo '<span style="font-size: 10px; color:#FF4500;"> [a] </span>';
}elseif($ank['access'] == 2){
echo '<span style="font-size: 10px; color:#20859E;"> [m] </span>';
}elseif($ank['access'] == 1){
echo '<span style="font-size: 10px; color:#000000;"> [t] </span>';
}
?><a href="javascript:tag('', '<?=$ank['name'] ?>, ', '')"> <img src="/img/otvet.png" alt="*" width="20" height="20"/> </a><?
echo '<span style="float:right;font-size: 9px; color:grey;pading:0px;margin:0px;">';
echo time_last($post['time']);
if($user['access'] >= 2) echo ' <a href="?delete_post='.$post['id'].'"><font color="red">(x)</font></a>';
echo '</span>';
echo '<span id="top_vs"></span>';
echo '<div class="statuse">';
echo '<span style="font-size: 15px; color:black;">'.text_msg($post['text']).'</span></div>';
}
if($ank['fonsms'] == 1){
echo '</span>';
}
}
if($user['access'] >= 2){
echo "<br/>";
echo "<center>";
echo msg('Очистка Чата');
echo "<a href='?delpos' class='myButton'>Посл. 10</a>";
echo "<a href='?delvse' class='myButton'>Всё</a>";
echo "<a href='?delper' class='myButton'>Перв. 10</a>";
echo "</center>";
}
echo '<br/>';
if($k_post > 10) str('?',$k_page,$page);
require_once 'system/footer.php';