Файл: user/cover/select.php
Строк: 108
<?
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 '<a class="link" href="?"><i class="fas fa-angle-left"></i> Назад</a>';
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 '<div class="mess">';
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>';
echo "<a class='link' href='?action=category&category_id=$category[id]'><i class='fas fa-angle-left'></i> Назад</a>";
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 '<a class="link" href="?"><i class="fas fa-angle-left"></i> Назад</a>';
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)) {
echo "<a rel class='link' href='?action=select&cover_id=$post[id]'><table>";
echo "<td width='15%'>";
echo "<img style='border-radius: 10%; border: 3px solid #fff; box-shadow: 0 1px 1px rgba(0,0,0,0.1);' src='/style/covers/{$post['id']}.jpg' alt='*' height='50' width='50' />n";
echo "</td>";
echo "<td><b>Цена:</b> ".sklon_text($post['price'], array('монета', 'монеты', 'монет'))."</td>";
echo '</table></a>';
}
if ($k_page > 1)str("?action=category&category_id=$category[id]&", $k_page, $page);
echo '<a class="link" href="?"><i class="fas fa-angle-left"></i> Назад</a>';
break;
default:
$q = mysql_query("SELECT * FROM `profileCoversCategories` ORDER BY `name` DESC");
while ($post = mysql_fetch_assoc($q)) {
echo "<a rel class='link' href='?action=category&category_id=$post[id]'><i class='fas fa-paint-roller'></i> ".htmlspecialchars($post['name'])." <span class='c'>".mysql_result(mysql_query("SELECT COUNT(*) FROM `profileCoversList` WHERE `id_category` = '$post[id]'"), 0)."</span></a>";
}
echo '<a class="link" href="/info.php"><i class="fas fa-angle-left"></i> На страничку</a>';
break;
endswitch;
include_once '../../sys/inc/tfoot.php';
?>