Файл: setk/ajax/profileCover/index.php
Строк: 44
<?
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();
$result = array();
$result['error'] = false;
if (isset($_GET['cover_id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `profileCoversList` WHERE `id` = '".intval($_GET['cover_id'])."'"), 0)) {
$cover = mysql_fetch_array(mysql_query("SELECT * FROM `profileCoversList` WHERE `id` = '".intval($_GET['cover_id'])."'"));
if ($user['profileCover'] != intval($_GET['cover_id'])) {
if ($user['money'] >= $cover['price']) {
mysql_query("UPDATE `user` SET `profileCover` = '$cover[id]', `money` = '".($user['money'] - $cover['price'])."' WHERE `id` = '$user[id]'");
$result['coverSrc'] = '/style/covers/'.$cover['id'].'.jpg';
} else {
$result['error'] = 'Вам не хватает монет';
}
} else {
$result['error'] = 'Эта обложка уже установлена';
}
} else {
$result['error'] = 'Обложка не найдена';
}
header("Content-type: text/json");
echo json_encode($result);
?>