query('SELECT sum(`massa`) AS `m` FROM `inventory` WHERE `owner` = ?i AND `dressed` = 0 AND `setsale` = 0', $user['id'])->fetch_assoc(); if ($user['battle'] != 0) { header('location: fbattle.php'); die(); } $bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id`=?i', $_SESSION['uid'])->fetch_assoc(); if (($_GET['set'] OR $_POST['set'])) { if ($_GET['set']) { $set = $_GET['set']; } if ($_POST['set']) { $set = $_POST['set']; } if (!$_POST['count']) { $_POST['count'] = 1; } if (!is_numeric($_POST['count']) || $_POST['count'] != ((int)$_POST['count'])) { $_POST['count'] = 0; $count_ok = 0; } elseif ($_POST['count'] < 1) { $_POST['count'] = 0; $count_ok = 0; } else $count_ok = 1; $dress = db::c()->query('SELECT * FROM `ashop` WHERE `id`=?i', $set)->fetch_assoc(); if ($count_ok == 0) { echo "Неправильно введено количество"; //$good = 0; } elseif (($dress['massa'] * $_POST['count'] + $itemWeight['m']) > (get_meshok())) { echo "Недостаточно места в рюкзаке."; //$good = 0; } elseif ($count_ok == 1 && ($bank['ekr'] >= ($dress['ecost'] * $_POST['count'])) && ($dress['count'] >= $_POST['count'])) { for ($k = 1; $k <= $_POST['count']; $k++) { if (isset($dress['goden'])) $goden = $dress['goden'] * 24 * 60 * 60 + time(); // Ну вот нахуя? db::c()->query(' INSERT INTO `inventory` ( `prototype`,`owner`,`name`,`type`,`massa`,`cost`,`img`,`maxdur`,`isrep`,`gsila`,`glovk`,`ginta`,`gintel`, `ghp`,`gnoj`,`gtopor`,`gdubina`,`gmech`,`gfire`,`gwater`,`gair`,`gearth`,`glight`,`ggray`,`gdark`, `needident`,`nsila`,`nlovk`,`ninta`,`nintel`,`nmudra`,`nvinos`,`nnoj`,`ntopor`,`ndubina`,`nmech`, `nfire`,`nwater`,`nair`,`nearth`,`nlight`,`ngray`,`ndark`,`mfkrit`,`mfakrit`,`mfuvorot`,`mfauvorot`, `bron1`,`bron2`,`bron3`,`bron4`,`maxu`,`minu`,`magic`,`nlevel`,`nalign`,`dategoden`,`goden`,`otdel`, `artefact`, `koll` ) VALUES (?i,?i,"?s",?i,?i,"?s","?s",?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i) ', $dress['id'], $_SESSION['uid'], $dress['name'], $dress['type'], $dress['massa'], $dress['cost'], $dress['img'], $dress['maxdur'], $dress['isrep'], $dress['gsila'], $dress['glovk'], $dress['ginta'], $dress['gintel'], $dress['ghp'], $dress['gnoj'], $dress['gtopor'], $dress['gdubina'], $dress['gmech'], $dress['gfire'], $dress['gwater'], $dress['gair'], $dress['gearth'], $dress['glight'], $dress['ggray'], $dress['gdark'], $dress['needident'], $dress['nsila'], $dress['nlovk'], $dress['ninta'], $dress['nintel'], $dress['nmudra'], $dress['nvinos'], $dress['nnoj'], $dress['ntopor'], $dress['ndubina'], $dress['nmech'], $dress['nfire'], $dress['nwater'], $dress['nair'], $dress['nearth'], $dress['nlight'], $dress['ngray'], $dress['ndark'], $dress['mfkrit'], $dress['mfakrit'], $dress['mfuvorot'], $dress['mfauvorot'], $dress['bron1'], $dress['bron3'], $dress['bron2'], $dress['bron4'], $dress['maxu'], $dress['minu'], $dress['magic'], $dress['nlevel'], $dress['nalign'], $goden, $dress['goden'], $dress['razdel'], $dress['artefact'], $dress['koll']); db::c()->query('UPDATE `ashop` SET `count` = `count`- ?i WHERE `id` = ?i', $_POST['count'], $set); $invdb = db::c()->query('SELECT `id` FROM `inventory` WHERE `name` = "?s" ORDER by `id` DESC LIMIT ?i', $dress['name'], $_POST['count']); if ($_POST['count'] == 1) { $dressinv = $invdb->fetch_assoc(); $dressid = "cap" . $dressinv['id']; $dresscount = " "; } else { $dressid = ""; while ($dressinv = $invdb->fetch_assoc()) { $dressid .= "cap" . $dressinv['id'] . ","; } $dresscount = "(x" . $_POST['count'] . ") "; } $allcost = $_POST['count'] * $dress['ecost']; $deloText = $user['login'] . " купил товар: " . $dress['name'] . $dresscount . "id:(" . $dressid . ") [0/" . $dress['maxdur'] . "] за " . $allcost . " екр."; db::c()->query('INSERT INTO `delo` (`author` ,`pers`, `text`, `type`, `date`) VALUES (?i, ?i, "?s", ?i, "?s")', 0, $user['id'], $deloText, 1, time()); echo "Вы купили {$_POST['count']} шт. \"{$dress['name']}\"."; db::c()->query('UPDATE `bank` set `ekr` = `ekr` - ?i WHERE `id` = ?i', $allcost, $_SESSION['uid']); $bank['ekr'] -= $allcost; } } else { echo "Недостаточно денег или нет вещей в наличии."; } } ?>