location.href='canalizaciya.php'"; exit; } $d = mysql_fetch_array(mysql_query("SELECT sum(`massa`) FROM `inventory` WHERE `owner` = '{$_SESSION['uid']}' AND `dressed` = 0 AND `setsale` = 0 ; ")); if ($user['room'] != 404) { header("Location: main.php"); die(); } if ($user['battle'] != 0) { header('location: fbattle.php'); die(); } if (($_GET['set'] OR $_POST['set'])) { if ($_GET['set']) { $set = $_GET['set']; } if ($_POST['set']) { $set = $_POST['set']; } if (!$_POST['count']) { $_POST['count'] =1; } $vear = mysql_query("SELECT maxdur,id FROM `inventory` WHERE `type`='200' and `name`='Жетон' and owner='".$user["id"]."'"); while($vls = mysql_fetch_array($vear)) { $zetons += $vls['maxdur']; $vls_id = $vls['id']; } $dress = mysql_fetch_array(mysql_query("SELECT * FROM `luka_shop` WHERE `id` = '{$set}' LIMIT 1;")); if (($dress['massa']*$_POST['count']+$d[0]) > (get_meshok())) { echo "Недостаточно места в рюкзаке."; } elseif(($zetons >= ($dress['zeton']*$_POST['count'])) && ($dress['count'] >= $_POST['count'])) { for($k=1;$k<=$_POST['count'];$k++) { if(mysql_query("INSERT INTO `inventory` (`prototype`,`owner`,`name`,`type`, `present`, `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`,`gmp`,`gmeshok` ) VALUES ('{$dress['id']}','{$_SESSION['uid']}','{$dress['name']}','{$dress['type']}', 'Подземка', {$dress['massa']},0.00,'{$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']}','".(($dress['goden'])?($dress['goden']*24*60*60+time()):"")."','{$dress['goden']}','{$dress['razdel']}','{$dress['gmp']}','{$dress['gmeshok']}' ) ;")) { $good = 1; } else { $good = 0; } } if ($good) { mysql_query("UPDATE `luka_shop` SET `count`=`count`-{$_POST['count']} WHERE `id` = '{$set}' LIMIT 1;"); echo "Вы купили {$_POST['count']} шт. \"{$dress['name']}\"."; $vsego = $zetons-$_POST['count']*$dress['zeton']; if($vsego<='0'){ mysql_query("DELETE FROM `inventory` WHERE `type`='200' and `name`='Жетон' and owner='".$user["id"]."'"); }else{ $mas = $vsego*0.1; mysql_query("UPDATE `inventory` set `maxdur` = '$vsego',massa='$mas' WHERE `type`='200' and `name`='Жетон' and owner='".$user["id"]."'");} $zetons -= $_POST['count']*$dress['zeton']; $limit=$_POST['count']; $invdb = mysql_query("SELECT `id` FROM `inventory` WHERE `name` = '".$dress['name']."' ORDER by `id` DESC LIMIT ".$limit." ;" ); //$invdb = mysql_query("SELECT id FROM `inventory` WHERE `name` = '".{$dress['name']}."' ORDER by `id` DESC LIMIT $limit ;" ); if ($limit == 1) { $dressinv = mysql_fetch_array($invdb); $dressid = "cap".$dressinv['id']; $dresscount=" "; } else { $dressid=""; while ($dressinv = mysql_fetch_array($invdb)) { $dressid .= "cap".$dressinv['id'].","; } $dresscount="(x".$_POST['count'].") "; } $allcost=$_POST['count']*$dress['zeton']; mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','{$_SESSION['uid']}','\"".$user['login']."\" купил товар: \"".$dress['name']."\" ".$dresscount."id:(".$dressid.") [0/".$dress['koll']."] за ".$allcost." жетон. ',1,'".time()."');"); } } else { echo "Недостаточно жетонов или нет вещей в наличии."; } } ?>