Вход Регистрация
Файл: rayb.me/gchat.php
Строк: 142
<?php

require_once ('system/func.php');
$title 'Игра Города';
require_once (
'system/header.php');

auth();

if(isset(
$user)) DB::Query("UPDATE `users_count` SET `gchat` = '1' WHERE `id_user` = '".$user['id']."'");

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['delete_chat_vse']) and $user['access'] >= 2){
    
$text "Рейб";
    
DB::Query("delete from `gchat`");
    
DB::Query("update `users_count` set `gchat` = '1'");
    
DB::Query("insert into `gchat` set `id_user` = '2', `time` = '".time()."', `text` = '".$text."'");
    
$_SESSION['msg'] = 'Чат весь очищен';
    
go('?');
}

if(isset(
$_GET['text'])){
    if(isset(
$_POST['text'])){
        
$text text($_POST['text']);
        
$sql DB::Query("SELECT COUNT(`id`) FROM `gchat` WHERE `text` = '$text'");
        if(
strlen($text) < or strlen($text) > 1200$err 'Длина сообщения должна быть в пределах 1-1200 символов';
        
$timegc mysql_query("SELECT * FROM `gchat` WHERE `id_user` = '".$user['id']."' ORDER BY `time` DESC");
        while(
$t mysql_fetch_assoc($timegc)){
            
$timeout $t['time'];
            if((
time()-$timeout) < 30){
                
$err 'Подождите 30 секунд, дайте возможность ответить другим.';
            }
        }
        
        if(
DB::result($sql0) > 0$err "Повторное слово!";
        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 `gchat` set `id_user` = '".$user['id']."', `time` = '".time()."', `text` = '".$text."'");
            
DB::Query("update `users_count` set `gchat` = '0'");
            
DB::Query("update `users` set `ball` = '".($user['ball']+9)."', `ruby` = '".($user['ruby']+500)."' where `id` = '$uid'");
            
$_SESSION['msg'] = 'Город опубликован, вы получаете 9 балов для задания и 500 рубинов';
            
go('?');
        }else{
            
$_SESSION['msg'] = $err;
            
go('?');
        }
    }else{
        
$_SESSION['msg'] = 'Поле ввода пустое';
        
go('?');
    }
}

if((
$user['registr']+1800) > $user['online']){
    echo 
msg("Любое общение будет доступно через ".tls($user['registr']+1800 $user['online']));
}else{
    echo 
"<center><small>Игра города! Держи правила игры, если конечно ты не знаеш их.<br/><a href='https://www.google.com/search?q=Правила+игры+города&oq=Правила+игры+города'>Правила игры города!</a><br/> Так же ограничена отправка сообщений от одного пользователя, 1 сообщение раз в 30 сек.<hr/>Чистка игры в 09:00 и в 21:00 по игре!</center></small>";
    echo 
'<form name="form" method="post" action="?text">';
    echo 
'<center><textarea name="text" style="resize:vertical;" rows="5" onkeypress="ctrlEnter(event, this);"></textarea></center>';
    echo 
'<span style="float:right;pading:px;margin:0px;">';
    echo 
'<a href="?"><img src="https://cdn.icon-icons.com/icons2/119/PNG/128/sync_update_19660.png" alt="*" width="40" height="40"/></a></span>';
    
$timegc mysql_fetch_assoc(mysql_query("SELECT * FROM `gchat` WHERE `id_user` = '".$user['id']."' ORDER BY `time` DESC"));
    
$t $timegc;
    
$timeout $t['time'];
    if((
time()-$timeout) < 30){
        echo 
'<center><a class="myButton" href="?">'.(30-(time()-$timeout)).'</a></center>';
    }else{
        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 `gchat`"),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 == 0msg("Название городов не найдено. Будешь первым?");

$q DB::Query("select * from `gchat` 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(isset(
$_GET['delete_post']) and $user['access'] >= 2){
        
$anks mysqli_fetch_assoc(DB::Query("select * from `gchat` where `id` = '".$_GET['delete_post']."' limit 1"));
        
DB::Query("delete from `gchat` where `id` = '".text($_GET['delete_post'])."'");
        
DB::Query("UPDATE `users` SET `ball` = `ball` - '9' WHERE `id` = '".$anks['id_user']."'");
        
$_SESSION['msg'] = 'Сообщения Удалены!';
        
go('?');
    }
    
    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> <small>'.$ank['ball'].'</small>';
    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>';
    }
    echo 
' <small>'.$ank['ball'].'</small>';
    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(
$user['access'] >= 2){
    echo 
"<br/>";
    echo 
"<center>";
    echo 
msg('Очистка Чата');
    echo 
"<a href='?delvse' class='myButton'>Всё</a>";
}
echo 
'<br/>';

if(
$k_post 10str('?',$k_page,$page);

require_once (
'system/footer.php');
Онлайн: 2
Реклама