Файл: public_html/modules/chat.php
Строк: 140
<?php
include $_SERVER['DOCUMENT_ROOT'].'/core/base.php';
$header = 'Разговоры';
include $_SERVER['DOCUMENT_ROOT'].'/core/head.php';
include $_SERVER['DOCUMENT_ROOT'].'/core/antimat.class.php';
if(!$u) exit(header('location: /')); // exit not cookies
?>
<style>
.mtb5 {
margin-top: 5px;
margin-bottom: 5px;
}
.hr3 {
height: 0;
font-size: 0;
border-top: 1px solid #13191e;
border-bottom: 1px solid #445561;
}
.smile {
border-width: 1px;
border-style: solid;
-moz-border-top-colors: none;
-moz-border-right-colors: none;
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
border-image: none;
color: #fff;
text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);
background-color: #ff8c00;
background-image: linear-gradient(to bottom, #ff8c00, #ff8c00);
background-repeat: repeat-x;
border-color: rgba(0, 0, 0, .1) rgba(0, 0, 0, .1) rgba(0, 0, 0, .25);
padding: 5px 0px;
height: 21px;
width: 40px;
font-size: 13px;
border-radius: 3px;
line-height: 19px;
}
.reset {
border-width: 1px;
border-style: solid;
-moz-border-top-colors: none;
-moz-border-right-colors: none;
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
border-image: none;
color: #fff;
text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);
background-color: #ff8c00;
background-image: linear-gradient(to bottom, #ff8c00, #ff8c00);
background-repeat: repeat-x;
border-color: rgba(0, 0, 0, .1) rgba(0, 0, 0, .1) rgba(0, 0, 0, .25);
padding: 5px 1px;
height: 21px;
width: 40px;
font-size: 13px;
border-radius: 3px;
line-height: 19px;
}
.pinter {
background-color: #34344C;
padding: 10px;
color: #fff;
word-wrap: break-word;
border-radius: 5px;
border: 1px solid #fff;
margin-bottom: 10px;
max-width: 100%;
margin-left: 0%;
}
.bymin {
width: 240px;
}
.panels {
background-color: #343434;
color: #fff;
word-wrap: break-word;
padding: 15px;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, .1);
}
</style>
<script type="text/javascript" src="/js/smiles.js"></script>
<script type="text/javascript">
function addSmiley(id, html) {
var e = document.getElementById(id);
if (e != null) {
e.value += ' ' + html + ' ';
e.focus();
}
}
function showSmilies() {
var e = document.getElementById('smiles');
if (e != null) {
if (e.style.display == 'block') { e.style.display = 'none'; } else { e.style.display = 'block'; }
}
}
</script>
<?
if(isset($_GET['del']))
{
$del = fl($_GET['del']);
if($u['admin'] == 0) redirect('/chat');
$db->query("DELETE FROM `chat` WHERE `id` = '".$del."'");
redirect('/chat');
}
if(isset($_POST['send'])){
$text = fl($_POST['text']);
$replySend = fl($_GET['reply']);
if($u['level'] < 5) $message = 'Писать в чате можно лишь с 5-го уровня.';
if(empty($text)) $message = 'Вы не ввели сообщение!';
$ban = $base -> query("SELECT * FROM `ban` WHERE `id_user` = '".$u['id']."' AND `time_ban` > '".time()."' ORDER BY `id` DESC LIMIT 1");
if($ban->num_rows > 0) $message = 'Ошибка, ваш профиль заблокирован!';
if($u['antispam'] > time()) $message = 'Отправлять сообщения можно раз в 5 сек.';
if($message) {
redirect('/chat', ''.$message.'');
}else{
if($replySend != 0 && $replySend != $u['id'])
{
$notText = '<a href="/chat">'.name($u['id']).' ответил вам в чате</a>';
$db->query("INSERT INTO `notifications` (user, text, time) VALUES ('".$replySend."', '".$notText."', '".time()."')");
}
$text = str_replace(array('r u','ru','RU','R U', 'net','n e t','NET','N E T', 'com', 'COM', 'C O M', 'рф', 'РФ', 'рф', 'tk', 'TK', 'T K','t k', 'esy.es', 'esy . es', 'e s y . e s', 'su', 's u', 'SU', 'S U', 'us', 'US', 'U S', 'u s', 'mobi','m o b i','MOBI','M O B I', 'ua', 'u a', 'U A', 'UA', 'keo.su', 'KEO.SU', 'KEO . SU','k e o . s u', 'K E O . SU', 'K E O.SU', 'worldbyte','WORLDBYTE','world byte','ml', 'ML', 'M L', 'm l', 'ga', 'g a', 'G A', 'GA', 'www','w w w','wap','w a p','h t t p','http'), '*', $text);
$sql = $db->query("INSERT INTO `chat` (`user`,`message`,`time`) VALUES ('".$u['id']."', '".$text."', '".time()."')");
setAntiSpamTime(5);
questUpdate($u['id'],4);
redirect('/chat');
}
}
$reply = isset($_GET['reply']) ? fl($_GET['reply']) : 0;
if($reply != 0) $replyText = name($reply,1); else $replyText = null;
echo"<div class = 'panels'>";
$count = $db -> query("SELECT * FROM `chat` ORDER BY `time` DESC") -> num_rows;
$k_page = k_page($count,10);
$page = page($k_page);
$start = 10*$page-10;
$sql = $db -> query("SELECT * FROM `chat` ORDER BY `time` DESC LIMIT $start, 10");
?>
<center><div id="smiles" style="display: none;">
<?
$smiles = $db->query("SELECT * FROM `smiles`");
while($sm = $smiles->fetch_object())
{
echo '<a href="javascript:tag('chatText',''.$sm->tag.'','')"><img src="'.$sm->image.'"></a> ';
}
?>
</div></center>
<form action="?send&reply=<?=$reply;?>" method="post">
<input type="text" id="chatText" name="text" value="<?=$replyText;?>" required><br>
<center><div class = "bymin">
<table width="100%">
<tr>
<td width="50px" valign="top">
<a class="form-btn-table" onclick="{ showSmilies(); return false; }" href="?about?smiles"><div class = "smile"><center><img src="/ico-smile.png" width="22" height="22"></center></div></a>
<td valign="top">
<center><input type="submit" name="send" value="Отправить"> </form> </center>
</td>
<td valign="top">
<a href = "?"><div class = "reset"><center> <img src="/ico-refresh.png" width="22" height="22"></center></div></a>
</td>
</tr>
</table></div> </center></br>
<?
if($count > 0)
{
while($q = $sql->fetch_object())
{
?>
<div class = "<?=($q->user == $u['id'] ? 'pinter' : 'pinter');?>">
<strong><big><img src="/images/users.png" width="35px"> <?=who($q->user);?></big></strong> <span style="float: right;"><small> <?=tm($q->time);?></small></span>
<?=($q->user != $u['id'] ? '<a href="?reply='.$q->user.'"> <img src="/ico-rarrow.png" width="17px"></a>' : '');?></br>
<?=setTextColor($q->user, viewText($q->message, 1, 1));?>
</span><?=($u['admin'] > 0 ? '<a href="?del='.$q->id.'"><font color = "orange">[Удалить]</font></a>' : '');?>
</div>
<?
}
echo"</div>";
if($count >= 10) echo str('/chat?',$k_page,$page);
}else{
echo '<center>В чате нет сообщений, будь первым :)</center></div>';
}
include_once ('../core/foot.php');