Файл: angrm/room.php
Строк: 99
<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
$set['title']='Анаграмма'; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
include 'inc/admin_act.php';
if (isset($_POST['msg']) && isset($user))
{
$msg=$_POST['msg'];
$mat=antimat($msg);
if ($mat)$err[]='В тексте сообщения обнаружен мат: '.$mat;
if (strlen2($msg)>1024){$err[]='Сообщение слишком длинное';}
elseif (strlen2($msg)<2){$err[]='Короткое сообщение';}
elseif(!isset($err)){
mysql_query("INSERT INTO `anagramma_form` (id_user, time, msg) values('$user[id]', '$time', '".my_esc($msg)."')");
if ($_SESSION['original_text'] == mb_strtolower($_POST['msg'], "UTF-8")) {
$is_balls = count(preg_split("//u", $_SESSION['original_text'], -1, PREG_SPLIT_NO_EMPTY));
if ($is_balls <= 4)
$balls_get = 'балла';
elseif ($is_balls >= 5)
$balls_get = 'баллов';
mysql_query("INSERT INTO `anagramma_form`(`id`, `id_user`, `time`, `msg`) values('', '0', '$time', '".$user['nick']." получает ".$is_balls." ".$balls_get."! Правильное слово: ".$_SESSION['original_text']."')");
mysql_query("UPDATE `user` SET `balls` = '".($user['balls']+$is_balls)."' WHERE `id` = '$user[id]' LIMIT 1");
}
mysql_query("UPDATE `user` SET `rating_tmp` = '".($user['rating_tmp']+1)."' WHERE `id` = '$user[id]' LIMIT 1");
$_SESSION['message']='Сообщение успешно добавлено';
header ("Location: ?");
}
}
if (empty($_SESSION['original_text']) || $_SESSION['time']<time()-180 || isset($_POST['msg']) && $_SESSION['original_text'] == mb_strtolower($_POST['msg'], "UTF-8")) {
$txt = mysql_fetch_assoc(mysql_query("SELECT * FROM `anagramma` ORDER BY rand() "));
include_once 'inc/func.php';
$_SESSION['original_text'] = $txt['original_text'];
$_SESSION['time'] = $time;
$_SESSION['shuffle_text'] = utf_shuffle($txt['original_text'], "UTF-8");
}
err();
aut(); // форма авторизации
if (!empty($_SESSION['original_text'])) {
echo '<div style = "margin: 2px; padding: 8px; color: dimgray; border: 1px solid silver;">
<center>Слово:
<br />
<div style = "color: steelblue; margin: 6px;"><b>'.$_SESSION['shuffle_text'].'</b></div></center>';
if ($_SESSION['time']+180-time() >= 120) {
$time_s = '2 м.';
$sec = $_SESSION['time']+60-time();
} elseif($_SESSION['time']+180-time() >= 60) {
$time_s = '1 м.';
$sec = $_SESSION['time']+120-time();
} elseif($_SESSION['time']+180-time() <= 60){
$time_s = $_SESSION['time']+180-time();
$sec = NULL;
}
echo 'Осталось: '.$time_s.' '.$sec.' сек.';
echo '</div>';
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `anagramma_form`"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if (isset($user) && (!isset($_SESSION['antiflood']) || $_SESSION['antiflood']<$time-300))
{
echo "<form method="post" name='message' action="room.php?">";
echo '<textarea name="msg"></textarea><br />';
echo '<input value="Отправить" type="submit" />';
echo "</form>";
}
echo "<table class='post'>";
if ($k_post==0)
{
echo " <div class='mess'>n";
echo "Нет сообщенийn";
echo " </div>n";
}
$q=mysql_query("SELECT * FROM `anagramma_form` ORDER BY id DESC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_assoc($q))
{
$ank=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));
if ($ank['id'] == 0) {
$ank['id'] = 0;
$ank['nick'] = 'Игровой бот';
}
/*-----------зебра-----------*/
if ($num==0)
{echo '<div class="nav1">';
$num=1;
}elseif ($num==1)
{echo '<div class="nav2">';
$num=0;}
echo us($ank['id']).' ('.vremja($post['time']).')<br />';
echo output_text($post['msg']).'<br />';
if (user_access('guest_delete'))echo " <a href='delete.php?id=$post[id]'><img src='/style/icons/delete.gif' alt='*'></a>";
echo '</div>';
}
echo '</table>';
if ($k_page>1)str('?',$k_page,$page); // Вывод страниц
echo '<div class="mess">';
echo '<img src="/style/icons/str.gif" alt="*"> <a href="who.php">Кто здесь?</a><br />';
echo '</div>';
include 'inc/admin_form.php';
include_once '../sys/inc/tfoot.php';
?>