Файл: chat.php
Строк: 89
<?php
include_once('./inc/head.php');
include_once('./inc/prov.php');
title('Чат');
$profil = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$id_us."'"));
if($uinf['id'] == $profil['id'] or $uinf['adm'] == '1')
$new_msg = mysql_result(mysql_query("SELECT COUNT(*) FROM `ferm_privat` WHERE `komu` = '".$uinf['login']."' and `view` = '1'"), 0);
if($uinf['id'] == $profil['id'] or $uinf['adm'] == '1')
echo '<div class="title"><b>'.$uinf['login'].' <a href="./privat.php?privat=vhod"><img src="http://144.76.127.94/view/image/icons/post.png" height="15" width="15" align="top" alt="ic">'.$new_msg.'</a> | '.$uinf['hp'].'<img src="http://warbk.com/graph/ico/hp.png" width="16" height="16" > | <img src="http://warbk.com/img/lvl.png" width="16" height="16" > '.$uinf['lvl'].'</b> | <b>Золото: </b> '.$uinf['zoloto'].' <img src="./theme/gold.png" height="16" width="16" align="top" alt="ic"> | <b>Рубли: </b> '.$uinf['rub'].' <img src="http://144.76.127.94/view/image/icons/buy_gold.png" height="16" width="16" align="top" alt="ic"></div>';
echo '<div class="ftitle"><font color="lime">Чат</font></div>';
$count_c = mysql_result(mysql_query("SELECT COUNT(*) FROM `ferm_chat`"), 0); // подсчёт для навигации
$chat_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `ferm_chat`"), 0);
if($chat_count == '0') {
echo '<div class="content"><font color="lime"><center>Чат пуст</font></center></div>';
}
$chat_viewmsg = mysql_query("SELECT * FROM `ferm_chat` ORDER BY `id` DESC LIMIT $start, $kmess");
echo '<div class="content"><br />';
while($chat_viewm = mysql_fetch_assoc($chat_viewmsg)) {
$rand = rand(0000,9999);
echo '<b>(<a href="./privat.php?privat=otp&id='.$chat_viewm[id_avtor].'&'.$rand.'">'.$chat_viewm[avtor].'</a><br />';
echo ''.wordwrap($chat_viewm[text], 45, "n", 1).'';
echo '<br/>';
if($uinf[adm] == '1') {
echo '<div class="menulink"><a href="?del=msg&id_msg='.$chat_viewm[id].'">Удалить</a></div>';
}
}
if($uinf[adm] == '1') {
if(htmlspecialchars($_GET['del']) == 'msg') {
$id_chmsg = intval($_GET['id_msg']);
$del_chat_msg = mysql_query("DELETE FROM `ferm_chat` WHERE `id` = '".$id_chmsg."'");
header("Location: ?");
}
}
echo '<div class="m5"><form action="?send=msg" method="POST">';
echo '<div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"><input type="hidden" name="id1_hf_0" id="id1_hf_0" /></div>';
echo '<b>Сообщение:</b><br/><input style="height: 85;width: 95%;" type="text" name="text">';
echo '<input type="submit" class="btni" value="Написать"/></form>';
echo '</div></div>';
//echo '<div class="menulink"><b>(<a href="./listsmiles.php">Смайлы</a></b>)</div>';
if(htmlspecialchars($_GET['send']) == 'msg') {
$text = htmlspecialchars($_POST['text']);
if(!empty($text)) {
//include './inc/smiles.php'; // смайлы
$insert_chatmsg = mysql_real_escape_string(mysql_query("INSERT INTO `ferm_chat` VALUES(0, '".$uinf['login']."', '".$uinf['id']."', '".time()."', '$text')"));
header("Location: ?");
} else {
echo '<div class="content"><b>Текст сообщения пуст</b><br/></div>';
}
}
echo '</div>';
if ($count_c > $kmess) {
echo '<div class="content"><center>';
echo '' . pagenav('?', $start, $count_c, $kmess) . '';
echo '</center></div>';
}
include_once('./inc/foot.php');
?>