Файл: moduls/adminchat.php
Строк: 146
<?
require_once '../core/system.php';
echo only_reg();
echo moder();
echo ban();
$header = 'Админ-Чат';
require_once H.'core/head.php';
switch($act) {
case 'post':
if(isset($_POST['msg'])){
$msg = check($_POST['msg']);
if(strlen($msg) < 3 or strlen($msg) > 400) $err = 'Длина сообщения должна быть в пределах 3 - 400 символов';
if($user[level] < 4) $err = 'В чате можно писать только с 4 уровня!';
if(!isset($err)) {
mysql_query("INSERT INTO `adminchat` SET `id_user` = '$user[id]', `msg` = '$msg', `time` = '".time()."'");
header('Location: ?');
$_SESSION['message'] = 'Сообщение добавлено!';
exit();
}else{
header('Location: ?');
$_SESSION['err'] = $err;
// Вывод ошибки
exit();
}
}else{
header('Location: ?');
$_SESSION['err'] = 'Введите текст';
exit();
}
break;
default:
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `adminchat`"),0);
$k_page = k_page($k_post,20);
$page = page($k_page);
$start = 20*$page-20;
echo '<a href="/common/rules2.php">Правила</a> | <a href="/smiles.php">Смайлы</a> | <a href="/bb_code.php">BB-коды</a> | <a href="?">Обновить</a></span></div></div>';
echo "<div class='mini-line'></div>";
if(isset($_GET['id'])) {
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $_GET[id] LIMIT 1"));
echo '<form class="player" method="post" action="?act=post">
<textarea name="msg" rows = "2" cols ="15" class = "text large">'.$ank[nick].', </textarea><br />
<span class="btn"><span class="end"><input class="label" type="submit" value="Отправить">Отправить</span></span>
</form>';
}else{
echo '<form class="player" method="post" action="?act=post">
<textarea name="msg" rows = "2" cols ="15" class = "text large"></textarea><br />
<span class="btn"><span class="end"><input class="label" type="submit" value="Отправить">Отправить</span></span>
</form>';
}
$q = mysql_query("SELECT * FROM `adminchat` ORDER BY `id` DESC LIMIT $start, 20");
echo "<div class='dot-line'></div>";
echo "<div class='player' style = 'color: #d3e2ed;'>";
while($post = mysql_fetch_assoc($q)) {
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));
if($ank[prava] >= 5 ){
$color = 'yellow';
}
if($ank[prava] == 7 ){
$color = 'green';
}
if($ank[id] == 995 || $ank[id] == 1 ){
$color = 'quality-0';
}
if($ank[id] == 13){
$color = 'green';
}
if($ank[prava] == 4 ){
$color = 'blue';
}
if($ank[prava] == 0 ){
$color = 'quality-0';
}
if($ank[prava] == 3 ){
$color = 'Vip';
}
if ($user['prava'] >= 4){
echo "<a style='text-decoration:none;' href='?del=msg&id_msg=".$post['id']."'>[<span class='red'>X</span>]</a>";}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '".$ank['id']."' AND `online` > '".(time()-600)."' LIMIT 1"),0)==1){
if ($ank['pol'] == 1 AND $ank['storona'] == 1) echo '<img src="/images/icon/hero_on_red_1.png" alt="d"/>';
if ($ank['pol'] == 1 AND $ank['storona'] == 0) echo '<img src="/images/icon/hero_on_blue_1.png" alt="d"/>';
if ($ank['pol'] == 0 AND $ank['storona'] == 1) echo '<img src="/images/icon/hero_on_red_0.png" alt="d"/>';
if ($ank['pol'] == 0 AND $ank['storona'] == 0) echo '<img src="/images/icon/hero_on_blue_0.png" alt="d"/>';
} else {
if ($ank['pol'] == 1) echo '<img src="/images/icon/hero_off_1.png" alt="d"/>';
if ($ank['pol'] == 0) echo '<img src="/images/icon/hero_off_0.png" alt="d"/>';
}
$nick = ($ank[prava] == 3) ? '<span style="color: #blue">'.$ank['nick'].'</span>' : $ank['nick'];
$nick = ($ank[prava] == 7) ? '<span style="color: #FF0000">'.$ank['nick'].'</span>' : $ank['nick'];
if($ank[id] == 995 || $ank[id] == 1 ){
$nick = '<span style = "color: #FFF8DC;">'.$ank['nick'].'</span>';
}
echo " <a href='/user/?id=$ank[id]'><b><span style = 'color: #FFF8DC;'>$nick</span></b></a>";
if($ank[prava] == 7 AND $ank[id] != 995 AND $ank[id] != 1){
echo "[<font color='red'>Созд</font>]";
}
if($ank[prava] == 5 ){
echo "[<font color='red'>Адм</font>]";
}
if($ank[prava] == 4 ){
echo "[<font color='green'>Мод</font>]";
}
echo "<span class='yellow'></span><span class='quality-0'>[".vremja($post['time'])."][<a href='?id=$ank[id]'>отв.</a>]</span>";
if(htmlspecialchars($_GET['del']) == 'msg') {
$id_chmsg = intval($_GET['id_msg']);
$del_chat_msg = mysql_query("DELETE FROM `adminchat` WHERE `id` = '".$id_chmsg."'");
header("Location: ?");
}
$str = str_replace("".$user['nick']."", "<b>".$user['nick']."</b>", ': <span class="'.$color.'">'.smiles($post['msg']).'</span><br>');
echo $str;
}
echo "</div>";
if ($k_page>1){
echo "<div class='dot-line'></div>";
str('?',$k_page,$page); // Вывод страниц
}
echo "<div class='mini-line'></div>";
echo "<div class='player menuList'>";
echo "<li><a href='/user/moder.php'><img src='/images/icon/user.png'>Список Модераторов</a></li>";
echo "</div>";
}
require_once H.'core/foot.php';
?>