Файл: setk/user/cover/select.php
Строк: 139
<?
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';
include_once('inc/configs.php');
only_reg();
$set['title'] = 'Сменить обложку';
include_once '../../sys/inc/thead.php';
title();
aut();
switch (@$_GET['action']):
case 'select':
if (!isset($_GET['cover_id']) || !mysql_result(mysql_query("SELECT COUNT(*) FROM `profileCoversList` WHERE `id` = '".intval(@$_GET['cover_id'])."'"), 0)) {
echo "<div class='mess'>n";
echo "Обложка не найдена<br />n";
echo "</div>n";
echo "<div class='foot'>n";
echo "<img src='/style/icons/str2.gif' /> <a href='?'>Назад</a><br />n";
echo '</div>';
include_once '../../sys/inc/tfoot.php';
exit();
}
$cover = mysql_fetch_array(mysql_query("SELECT * FROM `profileCoversList` WHERE `id` = '".intval($_GET['cover_id'])."'"));
$category = mysql_fetch_array(mysql_query("SELECT * FROM `profileCoversCategories` WHERE `id` = '$cover[id_category]'"));
if (isset($_POST['submit'])) {
if ($user['money'] < $cover['price'])$err[] = 'Вам не хватает монет что бы купить эту обложку';
elseif ($user['profileCover'] == $cover['id'])$err[] = 'Эта обложка уже установлена';
else {
mysql_query("UPDATE `user` SET `profileCover` = '$cover[id]' WHERE `id` = '$user[id]'");
header("Location: /info.php");
exit();
}
}
err();
echo "<form method='POST' action=''>n";
echo "<div>n";
echo "<div style='float: left;'>n";
echo "<img src='/style/covers/{$cover['id']}.jpg' alt='*' height='50' width='50' />n";
echo "</div>n";
echo "<div style='overflow: hidden;'>n";
echo "<b>Цена:</b> ".sklon_text($cover['price'], array('монета', 'монеты', 'монет'))."<br />n";
echo "<b>У Вас:</b> ".sklon_text($user['money'], array('монета', 'монеты', 'монет'))."<br />n";
echo "</div>n";
echo "<div style='clear: both;'></div>n";
echo "</div>n";
echo "<input type='submit' name='submit' value='Заменить' /><br />n";
echo "</form>n";
echo "<div class='foot'>n";
echo "<img src='/style/icons/str2.gif' alt='*' /> <a href='?action=category&category_id=$category[id]'>Назад</a><br />n";
echo "</div>n";
break;
case 'category':
if (!isset($_GET['category_id']) || !mysql_result(mysql_query("SELECT COUNT(*) FROM `profileCoversCategories` WHERE `id` = '".intval(@$_GET['category_id'])."'"), 0)) {
echo "<div class='mess'>n";
echo "Категория не найдена<br />n";
echo "</div>n";
echo "<div class='foot'>n";
echo "<img src='/style/icons/str2.gif' /> <a href='?'>Назад</a><br />n";
echo '</div>';
include_once '../../sys/inc/tfoot.php';
exit();
}
$category = mysql_fetch_array(mysql_query("SELECT * FROM `profileCoversCategories` WHERE `id` = '".intval($_GET['category_id'])."'"));
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `profileCoversList` WHERE `id_category` = '$category[id]'"), 0);
if (!$k_post)echo '<div class="mess">Нет обложок</div>';
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$q = mysql_query("SELECT * FROM `profileCoversList` WHERE `id_category` = '$category[id]' ORDER BY `price` ASC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_assoc($q)) {
if (!$num) { echo "<div class='nav1'>n"; $num = 1; } else { echo "<div class='nav2'>n"; $num = 0; }
echo "<div>n";
echo "<div style='float: left;'>n";
echo "<a href='?action=select&cover_id=$post[id]'>n";
echo "<img src='/style/covers/{$post['id']}.jpg' alt='*' height='50' width='50' />n";
echo "</a>n";
echo "</div>n";
echo "<div style='overflow: hidden;'>n";
echo "<b>Цена:</b> ".sklon_text($post['price'], array('монета', 'монеты', 'монет'))."<br />n";
echo "</div>n";
echo "<div style='clear: both;'></div>n";
echo "</div>n";
echo "</div>n";
}
if ($k_page > 1)str("?action=category&category_id=$category[id]&", $k_page, $page);
echo "<div class='foot'>n";
echo "<img src='/style/icons/str2.gif' /> <a href='?'>Назад</a><br />n";
echo '</div>';
break;
default:
$q = mysql_query("SELECT * FROM `profileCoversCategories` ORDER BY `name` DESC");
while ($post = mysql_fetch_assoc($q)) {
if (!$num) { echo "<div class='nav1'>n"; $num = 1; } else { echo "<div class='nav2'>n"; $num = 0; }
echo "<img src='/style/covers/category.png' /> <a href='?action=category&category_id=$post[id]'>".htmlspecialchars($post['name'])."</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `profileCoversList` WHERE `id_category` = '$post[id]'"), 0).")<br />n";
echo "</div>n";
}
echo "<div class='foot'>n";
echo "<img src='/style/icons/str2.gif' /> <a href='/info.php'>Назад</a><br />n";
echo "</div>n";
break;
endswitch;
include_once '../../sys/inc/tfoot.php';
?>