Файл: gonki.us/magazin.php
Строк: 64
<?php
require_once('system/incfiles/core.php');
if(empty($user)) header('Location: /auth.php');
if(isset($_GET['kupit'])){
$id = abs(intval($_GET['id']));
$auto = $db->query('SELECT * FROM `auto` WHERE `id` = "'.$id.'"')->fetch_array();
if(empty($id) or $auto['id'] == NULL) header('Location: /magazin.php');
if($user['money'] < $auto['money']) $err .= '<div class="error">Недостаточно монет для покупки!</div>';
if($user['dollars'] < $auto['dollars']) $err .= '<div class="error">Недостаточно баксов для покупки!</div>';
if(empty($err)){
$db->query("INSERT INTO `my_auto` SET `name` = '$auto[name]', `img` = '$auto[img]', `ls` = '$auto[ls]', `class` = '$auto[class]', `id_us` = '$user[id]', `neon` = '$auto[neon]'");
$inid = $db->insert_id;
$db->query("UPDATE `user` SET `auto` = '$inid', `dollars` = `dollars` - $auto[dollars], `money` = `money` - $auto[money] WHERE `id` = '$user[id]'");
header('Location: /');
}
}
$title = $copy.': Автосалон';
require_once(ROOT.'system/incfiles/header.php');
echo '<div class="razd5">Автосалон</div>';
if(isset($err)) echo $err;
$count = $db->query('SELECT * FROM `auto` WHERE `level` < '.$count_lvl.' OR `level` = "'.$count_lvl.'"')->num_rows;
$n = new navigator($count, '10');
$q = 'SELECT * FROM `auto` WHERE `level` < '.$count_lvl.' OR `level` = "'.$count_lvl.'" '.$n->limit;
$query = $db->query($q);
echo $n->back();
while($post = $query->fetch_array()){
echo '<div class="menu_j"><a href="?kupit&id='.$post['id'].'" class="top_menu_j"><span style="float:right"><b>'.$post['name'].' </b> <img src="/system/design/ico/ls.png" alt=""/> <font color="darkorange">'.$post['ls'].'л.с. </font><br /><img src="/system/design/ico/money.png" alt=""/> <font color="white">'.$post['money'].' </font> <img src="/system/design/ico/dollars.png" alt=""/> <font color="darkgreen">'.$post['dollars'].'</font></span><img src="'.$post['img'].'" alt="" style="width:100px"/><br /><img src="'.$post['neon'].'" alt="" style="width:100px; margin-top:-17px;"/></a></div>';
}
echo $n->next();
require_once(ROOT.'system/incfiles/footer.php');
?>