Файл: dev/bar.php
Строк: 245
<?
include_once '../sys/core/start.php';
include_once '../sys/core/compress.php';
include_once '../sys/core/sess.php';
include_once '../sys/core/home.php';
include_once '../sys/core/settings.php';
include_once '../sys/core/db_connect.php';
include_once '../sys/core/ipua.php';
include_once '../sys/core/fnc.php';
include_once '../sys/core/user.php';
include_once '../sys/inc/fnc_game.php';
include_once '../sys/inc/thead.php';
include_once '../sys/inc/uhead.php';
only_reg();
mysql_query("UPDATE `user` SET `bar_count` = '0' WHERE `id`='".$user['id']."'");
if(isset($_POST['close'])){
mysql_query("UPDATE `user` SET `bar_close` = '1' WHERE `id`='".$user['id']."'");
header("Location: /dev/bar.php");
}
if(isset($_POST['viev'])){
mysql_query("UPDATE `user` SET `bar_close` = '0' WHERE `id`='".$user['id']."'");
header("Location: /dev/bar.php");
}
if (isset($_POST['msg']) && isset($user))
{
$msg=htmlspecialchars($_POST['msg']);
if (strlen2($msg)>1024){$err[]='Сообщение слишком длинное!';}
elseif (strlen2($msg)<1){$err[]='Короткое сообщение!';}
elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `chat` WHERE `id_user` = '".$user['id']."' AND `msg` = '".my_esc($msg)."' LIMIT 1"),0)!=0){$err='Ваше сообщение повторяет предыдущее!';}
if(!isset($err)){
mysql_query("INSERT INTO `chat` (id_user, time, msg) values('".$user['id']."', '$time', '".my_esc($msg)."')");
$e=mysql_fetch_array(mysql_query("SELECT * FROM `user` "));
$q = $e['bar_count'] + 1;
mysql_query("UPDATE `user` SET `bar_count` = '".$q."' ");
}
}
if($user['acces']==5){
if(isset($_GET['all'])){
mysql_query("DELETE FROM `chat`");
header("Location: /dev/bar.php");
}
}
if(isset($_GET['delete']) && intval($_GET['delete'])!=NULL && $user['acces']>=1 && mysql_result(mysql_query("SELECT COUNT(*) FROM `chat` WHERE `id` = '".intval($_GET['delete'])."'"),0)!=0)
{
mysql_query("DELETE FROM `chat` WHERE `id` = '".intval($_GET['delete'])."'");
header("Location: /dev/bar.php");
}
if(isset($_GET['spam']) && intval($_GET['spam'])!=NULL && $user['acces']>=1 && mysql_result(mysql_query("SELECT COUNT(*) FROM `chat` WHERE `id` = '".intval($_GET['spam'])."'"),0)!=0)
{
mysql_query("UPDATE `chat` SET `spam` = '1' WHERE `id` = '".intval($_GET['spam'])."' LIMIT 1");
header("Location: /dev/bar.php");
}
if(isset($_GET['unspam']) && intval($_GET['unspam'])!=NULL && $user['acces']>=1 && mysql_result(mysql_query("SELECT COUNT(*) FROM `chat` WHERE `id` = '".intval($_GET['unspam'])."'"),0)!=0)
{
mysql_query("UPDATE `chat` SET `spam` = '0' WHERE `id` = '".intval($_GET['unspam'])."' LIMIT 1");
header("Location: /dev/bar.php");
}
if (isset($err))
{
err();
}
else
{
echo "<table class='wdt msg-table'><tr><td align='left' style='vertical-align: top; width: 10%'><img src='/style/img/images/face-mex.png'></td><td align='left' style='vertical-align: top'>";
echo "Добро пожаловать в бар! Здесь у вас есть возможность пообщаться с другими гонщиками. Мат и ругань неприемлемы в баре.</td></tr></table></td></tr></table>";
}
if ($user['bar_close'] == 0){
echo "<table cellspacing='0' cellpadding='0' width='100%' style='background: url(/style/img/images/stripbar_05.jpg);background-color:#330000;'>";
echo "<tr height='140px'><td style='padding-left: 130px; text-align:left; vertical-align:top;'><img src='/style/img/images/stripbar_02.gif'></td></tr>";
echo "<tr height='60px'></tr></table>";
if($user['acces']>=4){
echo '<table class="wdt brown-header"><tbody><tr><td align="left">Админ панель:</td></tr></tbody></table>';
echo '<table class="wdt gray-table"><tbody><tr>
<td width="33%"><form action="?all" method="post"><input class="race-btn" type="submit" value="Очистить чат"></form></td>
';
}
}
echo '<table class="wdt brown-header"><tbody><tr><td align="left">Меню:</td></tr></tbody></table>';
echo "<table class='wdt gray-table'><tbody><tr>";
echo "<td width='33%'><form action='/dev/online.php' method='post'><input class='race-btn' type='submit' value='Онлайн игроки'></form></td>";
echo "<td width='33%'><form action='/dev/bar.php?reflesh=".rand(99999,99999999)."' method='post'><input type='submit' class='race-btn' value='Обновить'></form></td>";
if ($user['bar_close'] == 0){
echo "<td width='33%'><form action='' method='post'><input class='race-btn' name='close' type='submit' value='Барная стойка'></form></td>";
}else{
echo "<td width='33%'><form action='' method='post'><input class='race-btn' name='viev' type='submit' value='Барная стойка'></form></td>";
}
?>
<script language="JavaScript" type="text/javascript">
function tag(text1, text2) {
if ((document.selection)) {
document.message.msg.focus();
document.message.document.selection.createRange().text = text1+document.message.document.selection.createRange().text+text2;
} else if(document.forms['message'].elements['msg'].selectionStart!=undefined) {
var element = document.forms['message'].elements['msg'];
var str = element.value;
var start = element.selectionStart;
var length = element.selectionEnd - element.selectionStart;
element.value = str.substr(0, start) + text1 + str.substr(start, length) + text2 + str.substr(start + length);
document.forms['message'].elements['msg'].focus();
} else document.message.msg.value += text1+text2;
document.forms['message'].elements['msg'].focus();}</script>
<?
echo '<table class="wdt brown-header"><tbody><tr><td align="left">Смайлики:</td></tr></tbody></table>';
echo '<div class="gray-table">';
$smiles = mysql_query("SELECT * FROM `smiles` ORDER BY `id` DESC LIMIT 50") or die(mysql_error());
$smiles_row = mysql_fetch_array($smiles);
do{
?>
<a style="padding: 2px; display: inline-table;" href="javascript:tag('<?=$smiles_row['zamena']?>','')"><div style="width: 20px;height: 20px;background: url(../style/img/smiles/<?=$smiles_row['name']?>.png) no-repeat;"></div></a>
<?
}while($smiles_row = mysql_fetch_array($smiles));
echo '</div>';
echo "<table class='wdt brown-header'><tr><td align='left'>Барная стойка:</td></tr></table>";
echo "<form action='/dev/bar.php' method='post' name='message'><table class='wdt gray-table'><td class='gray-table' align='left'><input type='text' name='msg' class='wdt' style='font-size: 16pt' maxlength='128' value=''></td>";
echo "<td class='white' width='30%'><input type='submit' class='wdt race-btn' value='Отправить'></td></table></form>";
function usertime($time = NULL) {
if(!$time) $time = time();
$data = date('j.n.y', $time);
if($data == date('j.n.y')) $res = 'Сегодня в '. date('G:i', $time);
elseif($data == date('j.n.y', time() - 86400)) $res = 'Вчера в '. date('G:i', $time);
else {
$m = array('0',
'Янв', 'Фев',
'Мар', 'Апр', 'Май',
'Июн', 'Июл', 'Авг',
'Сен', 'Окт', 'Ноя',
'Дек');
$res = date('j '. $m[date('n', $time)] .' Y в G:i', $time);
}
return $res;
}
$max = '8';
$chat_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `chat` "),0);
$k_page = k_page($chat_post,$max);
$page = page($k_page);
$start = $max*$page-$max;
if ($chat_post==0)
{
echo "<table class='wdt'>";
echo "<tr><td class='white' align='left' style='width: 140px; background-color: #222222;border-top: solid 1px #383838;border-bottom: 1px solid #1E1E1E;'>";
echo "<b>Нет сообщений</b></td></tr></table>";
}
$q=mysql_query("SELECT * FROM `chat` ORDER BY `id` DESC LIMIT $start, $max");
while($post=mysql_fetch_array($q)){
$ank_one=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '".$post['id_user']."'"));
$post_user=mysql_fetch_array(mysql_query("SELECT * FROM `taxi_user` WHERE `id_user`='".$post['id_user']."'"));
$post_user_taxi=mysql_fetch_array(mysql_query("SELECT * FROM `taxi` WHERE `id`='".$post_user['id_taxi']."'"));
$BAN=mysql_fetch_array(mysql_query("SELECT * FROM `ban` WHERE `id_user` = '".$post['id_user']."' AND `time` > '$time'"), 0);
if($post['spam'] == 0){$text=output_text($post['msg']);}else{$text= "<b class='red'>Сообщение удалено Администрацией</b>";}
$ons=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id`='".$post['id_user']."' and `date_last` > ".(time()-600).""), 0);
######## Определяем онлайн или офлайн
if($ons){$status = '<b class="green">online</b>';}else{$status = '<b class="red">offline</b>';}
######## Если игрок забанен
if($BAN){$banned = '<b style="font-size: 11px;" class="red">Banned</b></br>';}else{$banned = '';}
######## Ник пользователя
if($ank_one['acces']==5){$acces = "<b class='red'>Админ</b><br>"; }else{$acces = "";}
if($ank_one['acces']==5){ $nick = "<a style='vertical-align: top;' href='/dev/info.php?id=".$post['id_user']."'><b class='red'> $ank_one[nick]</b></a>"; }
if($ank_one['acces']==1){ $nick = "<a style='vertical-align: top;' href='/dev/info.php?id=".$post['id_user']."'><b class='green'> $ank_one[nick]</b></a>"; }
if($ank_one['acces']==0){ $nick = "<a style='vertical-align: top;' href='/dev/info.php?id=".$post['id_user']."'><b class='green'> $ank_one[nick]</b></a>"; }
if($post_user_taxi){$label = "<a style='font-size:11px;' href='/dev/taxi.php?id=".$post_user_taxi['id']."' class='yellow'>[$post_user_taxi[label]]</a>";}else{$label = ""; }
echo "
<table class='wdt gray-table'>
<tbody><tr style='border-bottom:1px #252525 solid;'>
<!-- место для аватарки --><td class='white' align='center' width='17%' style='padding-right: 5px;'><img src='/style/img/avatars/$ank_one[avatar].png' class='b-avatars-place1' alt=''></td>
<td class='white' align='left' width='55%'><font align='top' style='vertical-align: top;'>$label $nick</font></br><font class='txts'>$text</font></td>
<!-- место для инфы --><td class='white' align='left'>
<!-- ник --><b class='yellow'>".usertime($post['time'])."</b><br>
<b class='green'>$status</b><br>
$banned
<b>$acces</b>";
if($user['acces']==5){
echo "<a style='font-size: 12px;' href='/dev/bar.php?delete=".$post['id']."' class='red'>Удалить</a><br>";
if($post['spam'] == 1){
echo "<a style='font-size: 12px;' href='/dev/bar.php?unspam=".$post['id']."' class='red'>Спам</a> ";
}else{
echo "<a style='font-size: 12px;' href='/dev/bar.php?spam=".$post['id']."' class='red'>Спам</a> ";}
}
if($user['acces']==1){
echo "<a style='font-size: 12px;' href='/dev/bar.php?delete=".$post['id']."' class='red'>Удалить</a><br>";
if($post['spam'] == 1){
echo "<a style='font-size: 12px;' href='/dev/bar.php?unspam=".$post['id']."' class='red'>Спам</a> ";
}else{
echo "<a style='font-size: 12px;' href='/dev/bar.php?spam=".$post['id']."' class='red'>Спам</a> ";}
}
echo "
</td>
</tr></tbody></table>";
}
if($k_page>1) echo str('?close_cup&',$k_page,$page); // Вывод страниц
echo "<table class='wdt gray-table'>";
echo "<tr><td class='gray-table'><form action='/dev/map.php' method='post'><input type='submit' class='race-btn' value='Назад'></form></td>";
echo "<td class='gray-table' width='50%'><form action='/dev/bar.php?reflesh=".rand(99999,99999999)."' method='post'><input type='submit' class='race-btn' value='Обновить'></form></td></tr></table>";
include_once '../sys/inc/tfoot.php';
?>