Вход Регистрация
Файл: public_html/chat.php
Строк: 87
<?php
include ('./system/system.php');
$title 'Чат';
include (
'./system/head.php');
if(!
$user) {
header('location: /index.php');
exit();
}
if(isset(
$_GET['truncate'])) {
if(
$user['access'] >= 1) {
mysql_query("delete from `chat`");
header('location: ?');
exit();
}
}
if(isset(
$_GET['new_msg']) && $user['ban_time'] < time()){
if(
$user['level'] < 5) {
echo 
'<div class="block small red center">Писать в чат разрешено с 5 уровня!</div>';
include (
'./system/foot.php');
exit();
}
if(isset(
$_POST['text'])){
$text _string($_POST['text']);
$to _string(_num($_GET['to']));
if(
strlen($text) < or strlen($text) > 1000) {
echo 
'<div class="block small red center">Длина сообщения 1-1000 символов!</div>
<a href="/chat.php" class="link"><img src="/images/icons/forward.png"> Вернуться</a>'
;
include (
'./system/foot.php');
exit();
}
mysql_query("INSERT INTO `chat` SET `id_user` = '$user[id]', `time` = '".time()."', `komu` = '".$to."', `text` = '".$text."'");
header('Location: /chat.php');
exit();
}else{
header('Location: /chat.php');
exit();
}
}
if(isset(
$_GET['delete_post']) and $user['access'] >= 1){
$del _string(_num($_GET['delete_post']));
$logs_chat_del mysql_query('SELECT * FROM `chat` where `id` = "'.$del.'"');
$log_chat mysql_fetch_array($logs_chat_del);
mysql_query("INSERT INTO `chat_logs` SET `id_user` = '".$log_chat['id_user']."', `time_msg` = '".$log_chat['time']."', `time` = '".time()."', `user_del` = '".$user['id']."', `text` = '".$log_chat['text']."'");
mysql_query("DELETE FROM `chat` WHERE `id` = '".$del."'");
header('Location: ?');
exit();
}
if(
$user['ban_time'] < time()) {
echo 
"<div class='block'>";
if(isset(
$_GET['to'])){
echo 
"<form method='post' action='?new_msg=$_GET[to]&to=$_GET[to]'>";
$opponent mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = $_GET[to] LIMIT 1"));
echo 
"<textarea name='text' class='text' style='width: 97%'>$opponent[login], </textarea>
<input type='submit' class='submit' value='Отправить'> <a href='?' class='none'><img src='/images/icons/update.png'></a> <span style='float: right'><a href='/smiles.php' class='none'><img src='/images/icons/smiles.png'> </a></span></form>"
;
}else{
echo 
"<form method='post' action='?new_msg'>
<textarea name='text' class='text' style='width: 97%'></textarea>
<input type='submit' class='submit' value='Отправить'> <a href='?' class='none' ><img src='/images/icons/update.png'></a> <span style='float: right'><a href='/smiles.php' class='none'><img src='/images/icons/smiles.png'></a></span></form>"
;
}
echo 
'</div>';
}else{
echo 
'<div class="block small red center">Вам запрещено писать в чат!</div>';
}
$set['p_str'] = 10;
$k_post mysql_result(mysql_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'];
$q mysql_query("SELECT * FROM `chat` ORDER BY `id` DESC LIMIT $start$set[p_str]");
while(
$post mysql_fetch_assoc($q)) {
$ank mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = $post[id_user] LIMIT 1"));
echo 
"<div class='block'> <img src='/images/race/$ank[race].png'> <a href='/profile.php?id=$ank[id]'> $ank[login]</a>";
if(
$ank['access'] == 1) echo ' <b>[MD]</b>';
if(
$ank['access'] == 2) echo ' <b>[ADM]</b>';
if(
$user['id'] == $ank['id'])echo ": ";
if(
$user['id'] != $ank['id'])echo " <a href='?to=$ank[id]' class='none'>(»)</a>: ";
$msg str_replace(array($user[login].','), "<b>$user[login],</b> "$post['text']);
if(
$ank['access'] != 0) echo '<font color="#f09050">';
echo 
''.smiles($msg).'';
if(
$ank['access'] != 0) echo '</font>';
if(
$user['access'] == 0) echo "</div>";
if(
$user['access'] >= 1) echo " <a href='?delete_post=$post[id]' class='red small'> (x)</a></div>";
}
if(
$k_post<1) {
echo 
'<div class="block small red center">Сообщений нет!</div>';
}
if(
$k_post >&& $user['access'] >= 1) {
echo 
'<a href="?truncate" class="link"><img src="/images/icons/forward.png"> Очистить чат</a>';
}
if(
$k_page>1)  echo str('?',$k_page,$page);
include (
'./system/foot.php');
?>
Онлайн: 0
Реклама