Файл: my_games/index.php
Строк: 126
<?
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('/reg.php');
if(isset($_GET['admin']) && isset($user) && $user['id']==1)include_once 'inc/admin.php';
if(isset($_GET['play_game']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `user_games` WHERE `id` = '".intval($_GET['play_game'])."'"),0)!=0)
{
$pg=mysql_fetch_array(mysql_query("SELECT * FROM `user_games` WHERE `id` = '".intval($_GET['play_game'])."'"));
mysql_query("UPDATE `user_games` SET `last_time` = '$time' WHERE `id` = '$pg[id]'");
$game=mysql_fetch_array(mysql_query("SELECT * FROM `games` WHERE `id` = '$pg[id_game]'"));
$link=$game['link'];
header("Location:$link");
exit;
}
if(isset($_GET['add_game']))
{
$set['title']="Мои игры - Добавить игру";
include_once '../sys/inc/thead.php';
title();
aut();
if(isset($_GET['select_game']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `games` WHERE `id` = '".intval($_GET['select_game'])."'"),0)!=0)
{
$ng=mysql_fetch_array(mysql_query("SELECT * FROM `games` WHERE `id` = '".intval($_GET['select_game'])."'"));
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `user_games` WHERE `id_game` = '".intval($_GET['select_game'])."' AND `id_user` = '$user[id]'"),0)!=0)echo "<div class='err'>Игра <b>".htmlspecialchars($ng['name'])."</b> уже находится в вашем списке игр.</div>";
else
{
mysql_query("INSERT INTO `user_games` SET `id_game` = '$ng[id]', `id_user` = '$user[id]', `last_time` = '$time'");
msg("Игра <b>".htmlspecialchars($ng['name'])."</b> успешно добавлена в ваш список игр.");
}
}
$q=mysql_query("SELECT * FROM `games` ORDER BY `id` DESC");
if(mysql_num_rows($q)==0)echo "<div class='p_t'>Список пуст</div>";
while($post=mysql_fetch_array($q))
{
echo "<div class='foot'>";
echo "<img src='".htmlspecialchars($post['img'])."' height='16'> ".(mysql_result(mysql_query("SELECT COUNT(*) FROM `user_games` WHERE `id_game` = '$post[id]' AND `id_user` = '$user[id]'"),0)==0?"<a href='?add_game=1&select_game=$post[id]'>":null)."".htmlspecialchars($post['name'])."".(mysql_result(mysql_query("SELECT COUNT(*) FROM `user_games` WHERE `id_game` = '$post[id]' AND `id_user` = '$user[id]'"),0)==0?"</a>":null)."";
echo "</div>";
}
echo "<div class='foot'><img src='/style/icons/turn_left.png'/> <a href='?'>Назад</a></div>";
include_once '../sys/inc/tfoot.php';
}
$set['title']="Мои игры";
if (isset($user))$ank['id']=$user['id'];
if (isset($_GET['id']))$ank['id']=intval($_GET['id']);
$ank=get_user($ank['id']);
if(!$ank&&$ank['id']==0) {header("Location: /index.php?".SID);exit;}
if($ank['id']==0) {header("Location: /index.php?".SID);exit;}
if(isset($_GET['delete']) && isset($_POST['yes']) && isset($_GET['ok']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `user_games` WHERE `id` = '".intval($_GET['delete'])."' AND `id_user` = '$user[id]'"),0)!=0)
{
mysql_query("DELETE FROM `user_games` WHERE `id` = '".intval($_GET['delete'])."'");
$_SESSION['message'] = 'Удалено';
header("Location:?");exit ;
}else{
}
include_once '../sys/inc/thead.php';
title();
aut();
echo '<div class="foot">';
echo '<img src="/style/icons/str2.gif" alt="*" /> <a href="/info.php?id=' . $ank['id'] . '">' . $ank['nick'] . '</a> | ';if (isset($user) && $user['id']==$ank['id']){
echo'<b> Мои игры</b>';}else{echo'<b> Игры</b>';}
echo '</div>';
if(isset($_GET['delete']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `user_games` WHERE `id` = '".intval($_GET['delete'])."' AND `id_user` = '$user[id]'"),0)!=0)
{
$my = mysql_fetch_assoc(mysql_query("SELECT * FROM `user_games` WHERE `id` = '".intval($_GET['delete'])."' LIMIT 1"));
echo "<div class='mess'><center>";
echo "Действительно удалить? </b><br />";
echo "<a href='?delete=$my[id]&ok'> Да</a>|<a href='?'>Нет</a> n";
echo "</center></div>";
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user_games` WHERE `id_user` = '$ank[id]' "),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if ($k_post==0)
{
echo " <div class='mess'>n";
echo "Нет добавленых игрn";
echo " </div>n";
}
$num=0;
$q=mysql_query("SELECT * FROM `user_games` WHERE `id_user` = '$ank[id]' ORDER BY `last_time` DESC LIMIT $start, $set[p_str]");
while($post=mysql_fetch_array($q))
{
$game=mysql_fetch_array(mysql_query("SELECT * FROM `games` WHERE `id` = '$post[id_game]'"));
echo "<div class='nav1'>";
echo "<img src='".htmlspecialchars($game['img'])."' height='16'> <a href='?play_game=$post[id]'>".htmlspecialchars($game['name'])."</a>";
if (isset($user) && $user['id']==$ank['id']){
echo '<a href="?delete='.$post[id].'"> '; echo"<span style='float:right'> <img src='/style/icons/delete.gif' alt='*' title='Удалить'></a></style>n";
}
echo "</div>";
}
if (isset($user) && $user['id']==$ank['id']){
echo "<div class='nav1'><img src='/style/icons/yes.png'/> <a href='?add_game=1'>Добавить игру</a></br>";}
if( isset($user) && $ank['id']==1){
echo"<img src='/style/icons/cog.png' alt='*' title='Удалить'> <a href='?admin'> Админка</a> ";
echo'</div>';
}
if ($k_page>1)str("index.php?id=$ank[id]&",$k_page,$page); // Вывод страниц
echo '<div class="foot">';
echo '<img src="/style/icons/str2.gif" alt="*" /> <a href="/info.php?id=' . $ank['id'] . '">' . $ank['nick'] . '</a> | ';if (isset($user) && $user['id']==$ank['id']){
echo'<b> Мои игры</b>';}else{echo'<b> Игры</b>';}
echo '</div>';
include_once '../sys/inc/tfoot.php';
?>