Файл: setk/plugins/games/association/index.php
Строк: 198
<?
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';
only_reg();
// Если первый раз в игре
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `association_stat` WHERE `id_user` = '" . $user['id'] . "'"), 0) == 0)
{
// Запись в базу
mysql_query("INSERT INTO `association_stat` (`id_user`, `time`, `money`) values('$user[id]', '$time', '100')");
}
// Стата юзера
$stat = mysql_fetch_array(mysql_query("SELECT * FROM `association_stat` WHERE `id_user` = '" . $user['id'] . "' LIMIT 1"));
// Задание
$word = mysql_fetch_array(mysql_query("SELECT * FROM `association` WHERE `id` > '" . $stat['id_game'] . "' LIMIT 1"));
if (isset($_POST['word']))
{
if ($_POST['word'] != $word['word'])
$err[] = 'Ответ не верный';
if (!$err)
{
if ($_SESSION['num'] == 0)$rating = 10;
else $rating = 10 - $_SESSION['num'];
mysql_query("update `association_stat` set `money` = `money` + '1', `win` = `win` + '1', `rating` = `rating` + '$rating', `id_game` = '$word[id]' where `id_user` = '$user[id]' limit 1");
$_SESSION['num'] = 0;
$_SESSION['value'] = null;
header('Location: ?');
exit;
}
}
// Задаем сессию
if (!isset($_SESSION['value']))
{
$_SESSION['value'] = null;
$_SESSION['num'] = 0;
}
// Функция разбивает слово на символы
function mb_str_split($str)
{
preg_match_all('#.{1}#uis', $str, $out);
return $out[0];
}
// Открываем букву
if (isset($_GET['act']) && $_GET['act'] == 'word' && $_SESSION['num'] < strlen2($word['word']))
{
if ($stat['money'] >= '19')
{
$w = mb_str_split($word['word']);
$_SESSION['value'] = $_SESSION['value'] . $w[$_SESSION['num']];
$_SESSION['num'] = $_SESSION['num'] + 1;
mysql_query("update `association_stat` set `money` = `money` - '19' where `id_user` = '$user[id]' limit 1");
header('Location: ?');
exit;
}
else
{
$err[] = 'У вас не достаточно монет';
}
}
// Открываем подсказку
if (isset($_GET['act']) && $_GET['act'] == 'hint')
{
if ($stat['money'] >= '29')
{
$_SESSION['hint'] = $word['hint'];
mysql_query("update `association_stat` set `money` = `money` - '29' where `id_user` = '$user[id]' limit 1");
header('Location: ?');
exit;
}
else
{
$err[] = 'У вас не достаточно монет';
}
}
// Пропускаем слово
if (isset($_GET['act']) && $_GET['act'] == 'go')
{
if ($stat['money'] >= '29')
{
mysql_query("update `association_stat` set `money` = `money` - '29' where `id_user` = '$user[id]' limit 1");
if ($_SESSION['num'] == 0)$rating = 10;
else $rating = 10 - $_SESSION['num'];
mysql_query("update `association_stat` set `money` = `money` + '1', `win` = `win` + '1', `rating` = `rating` + '$rating', `id_game` = '$word[id]' where `id_user` = '$user[id]' limit 1");
header('Location: ?');
exit;
}
else
{
$err[] = 'У вас не достаточно монет';
}
}
// Часть слова
$value = $_SESSION['value'];
$set['title'] = 'Одним словом'; // заголовок страницы
include_once '../../../sys/inc/thead.php';
err();
title();
aut();
?><link rel="stylesheet" href="style/style.css">
<?
if ($webbrowser == 'web')
{
?><style>
.ass_text{
padding:0;
}
</style>
<script type="text/javascript">
$(document).ready(function ()
{
$('.td_img a').click(function ()
{
var o=$(this).parent();
var url=o.find('img').attr('src');
var html='<a id="ass" href="#close" class="clone"><img src="'+url+'" /></a>'
o.append(html);
o=o.find('.clone');
o.animate({width:'100%',height:'100%'});
o.click(function ()
{
$(this).remove();
});
});
});
</script>
<?
$link_1 = '#big';
$link_2 = '#big';
}
else
{
$link_1 = 'image/' . $word['code'] . '_1.jpg';
$link_2 = 'image/' . $word['code'] . '_1.jpg';
}
echo '<div class="body_game">';
if (isset($word['id']))
{
?>
<table class="table_state" style="text-align:center;">
<tr>
<td class="td_state_left">
<!--Блок рейтинга-->
<a href="top.php"><div class="ass_rate_logo"></div>
<div class="ass_state"><div class="ass_rate"></div>
<div class="ass_text"><?=$stat['rating']?></div>
</div></a>
</td>
<td class="td_state_right">
<!--Блок баланса-->
<a href="money.php"><div class="ass_coins_logo"></div>
<div class="ass_state"><div class="ass_coins"></div>
<div class="ass_text"><?=$stat['money']?></div>
</div></a>
</td>
</tr>
</table>
<!--Таблица отображения картинок-->
<table style="text-align:center;" id="img">
<tr>
<td class="td_img">
<a id='ass' href='<?=$link_1?>'><img src="image/<?=$word['code']?>_1.jpg" class="img"/><div class="hover"></div></a>
</td>
<td class="plus"></td>
<td class="td_img">
<a id='ass' href='<?=$link_2?>'><img src="image/<?=$word['code']?>_2.jpg" class="img" /><div class="hover"></div></a>
</td>
</tr>
</table>
<table style="position: relative; padding-left:100px; margin:3px;"><div class="ass_info_left"></div><div class="ass_info">
<div class="ass_info_text">Cлово из <b><?=strlen2($word['word'])?></b> букв</div>
</div><div class="ass_info_right"></div></table>
<?
if (isset($_SESSION['hint']))
{
echo '<div class="ass_msg">' . output_text($_SESSION['hint']) . '</div>';
$_SESSION['hint'] = null;
}
?>
<form class="ass_form" name="message" action="?" method="post">
<table style="margin:2px;">
<?
if ($_SESSION['num'] > 0)
{
$s = mb_str_split($_SESSION['value']);
for ($i = 0; $i < $_SESSION['num']; $i++)
{
echo '<div class="ass_word">' . $s[$i] . '</div>';
}
}
?>
</table>
<input type="text" name="word" value="<?=$value?>" placeholder="Слово..."/><input class="submit" type="submit" value="Ответить" />
</form>
<table><tr>
<td class="ass_menu">
<table style="margin:5px; display:inline-block; float:left;"><a href="?act=word"><div class="ass_info_left"></div><div class="ass_info">
<div class="ass_icon_coins">19</div><div class="ass_info_text">Открыть букву</div>
</div><div class="ass_info_right"></div></a></table>
</td>
<td class="ass_menu">
<table style="margin:5px; display:inline-block;"><a href="?act=hint"><div class="ass_info_left"></div><div class="ass_info">
<div class="ass_icon_coins">29</div><div class="ass_info_text">Подсказка</div>
</div><div class="ass_info_right"></div></a></table>
</td>
<td class="ass_menu">
<table style="margin:5px; display:inline-block;"><a href="?act=go"><div class="ass_info_left"></div><div class="ass_info">
<div class="ass_icon_coins">29</div><div class="ass_info_text">Пропустить</div>
</div><div class="ass_info_right"></div></a></table>
</td>
<td class="ass_menu">
<table style="margin:5px; display:inline-block;"><a href="info.php"><div class="ass_help"></div></a></table>
</td>
</tr></table>
<?if ($user['level'] > 2){?>
<table style="margin:5px; display:inline-block;"><a href="add.php"><div class="ass_info_left"></div><div class="ass_info">
<div class="ass_info_text">Добавить задания</div>
</div><div class="ass_info_right"></div></a></table>
<?}
}
else
{
echo '<center><img src="style/main_menu_logo_2_1.png" /></center>';
echo '<div class="ass_msg">';
echo 'К cожалению в нашей базе задания закончились.. <br />';
echo 'Если вы загляните в игру завтра, то уверен появится еще куча заданий для отгадывания слов =)';
echo '</div>';
}
echo '</div>';
include_once '../../../sys/inc/tfoot.php';
?>