$dress=mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `dressed`=0 AND `id` = '{$_GET['n']}' AND `owner` = '{$_SESSION['uid']}' LIMIT 1;"));
if($dress['id']){
mysql_query("UPDATE `inventory` SET `setsale` = '".$_GET['kredit']."' WHERE `id` = '{$_GET['n']}' AND `owner` = '{$_SESSION['uid']}' LIMIT 1;");
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','{$_SESSION['uid']}','\"".$user['login']."\" сдал предмет: \"".$dress['name']."\" id:(cap".$dress['id'].") [".$dress['duration']."/".$dress['maxdur']."] в комиссионку за ".$_GET['kredit']." кр. ',1,'".time()."');");
echo"<font color=red><b>Вы сдали в магазин \"{$dress['name']}\" за {$_GET['kredit']} кр.</b></font>";
}
}else{
echo"<font color=red><b>Не надо так делать</b></font>";
$dress=mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `dressed`=0 AND `id` = '{$_GET['back']}' AND `owner` = '{$_SESSION['uid']}' AND `setsale` > '0' LIMIT 1;"));
if($dress['id']){
mysql_query("UPDATE `users` set `money` = `money`-'1' WHERE id = {$_SESSION['uid']}");
mysql_query("UPDATE `inventory` SET `setsale` = '0' WHERE `id` = '{$_GET['back']}' AND `owner` = '{$_SESSION['uid']}' LIMIT 1;");
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','{$_SESSION['uid']}','\"".$user['login']."\" забрал предмет: \"".$dress['name']."\" id:(cap".$dress['id'].") [".$dress['duration']."/".$dress['maxdur']."] из комиссионки ',1,'".time()."');");
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','{$_SESSION['uid']}','\"".$user['login']."\" заплатил 1 кр за хранение предмета: \"".$dress['name']."\" id:(cap".$dress['id'].") [".$dress['duration']."/".$dress['maxdur']."] в комиссионке ',1,'".time()."');");
$dress=mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `dressed`=0 AND `id` = '{$set}' and `owner`!='".$user['id']."' AND `setsale` > '0' LIMIT 1;"));
$userfrom=mysql_fetch_array(mysql_query("SELECT `login`,`id` FROM `users` WHERE `id` = '".$dress['owner']."' LIMIT 1;"));
$d=mysql_fetch_array(mysql_query("SELECT sum(`massa`) FROM `inventory` WHERE `owner` = '{$_SESSION['uid']}' AND `dressed` = 0 AND `setsale` = 0 ; "));
if($userfrom['id']&&$dress['id']){
if(($dress['massa']+$d[0])>(get_meshok())){
echo"<font color=red><b>Недостаточно места в рюкзаке.</b></font>";
}elseif($user['money']>=$dress['setsale']){
if(mysql_query("UPDATE `inventory` SET `owner` = '{$user['id']}', `setsale` = 0 WHERE `id` = '{$set}' AND `setsale` > '0' LIMIT 1;")){
mysql_query("UPDATE `users` set `money` = `money`- '".$dress['setsale']."' WHERE id = {$_SESSION['uid']}");
mysql_query("UPDATE `users` set `money` = `money`+ '".$moneyto."' WHERE id = {$userfrom['id']}");
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','{$_SESSION['uid']}','\"".$user['login']."\" купил товар: \"".$dress['name']."\" id:(cap".$dress['id'].") [".$dress['duration']."/".$dress['maxdur']."] от \"".$userfrom['login']."\" за ".$dress['setsale']." кр. в комиссионке ',5,'".time()."');");
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','{$userfrom['id']}','\"".$user['login']."\" купил товар: \"".$dress['name']."\" id:(cap".$dress['id'].") [".$dress['duration']."/".$dress['maxdur']."] от \"".$userfrom['login']."\" за ".$dress['setsale']." кр. в комиссионке ',5,'".time()."');");
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','{$_SESSION['uid']}','\"".$user['login']."\" купил товар: \"".$dress['name']."\" id:(cap".$dress['id'].") [".$dress['duration']."/".$dress['maxdur']."] за ".$dress['setsale']." кр. в комиссионке ',1,'".time()."');");
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','{$userfrom['id']}','\"".$userfrom['login']."\" получил ".$moneyto." кр. за продажу товара: \"".$dress['name']."\" id:(cap".$dress['id'].") [".$dress['duration']."/".$dress['maxdur']."] через комиссионку ',1,'".time()."');");
$user['money']=$user['money']-$dress['setsale'];
$us=mysql_fetch_array(mysql_query("select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = '{$userfrom['id']}' LIMIT 1;"));
if($us[0]){
addchp('<font color=red>Внимание!</font> Успешно продан предмет "'.$dress['name'].'" за '.$dress['setsale'].' кр. Комиссия составила '.$komiss.' кр. Вам перечислено от комиссионного магазина '.$moneyto.' кр. ','{[]}'.$userfrom['login'].'{[]}');
}else{
// если в офе
mysql_query("INSERT INTO `telegraph` (`receiver`,`date`,`text`) values ('".$userfrom['id']."','','".'<font color=red>Внимание!</font> Успешно продан предмет "'.$dress['name'].'" за '.$dress['setsale'].' кр. Комиссия составила '.$komiss.' кр. Вам перечислено от комиссионного магазина '.$moneyto.' кр. '."');");
}
}
}else{
echo"<font color=red><b>Недостаточно денег или нет вещей в наличии.</b></font>";
}
}else{
echo"<font color=red><b>Вещь не найдена в магазине</b></font>";
}
}else{
echo"<font color=red><b>Не надо так делать</b></font>";
$dress=mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `dressed`=0 AND `id` = '{$_GET['id']}' AND `owner` = '{$_SESSION['uid']}' AND `setsale` > 0 LIMIT 1;"));
if($dress['id']){
if($user['money']>=0.1){
mysql_query("UPDATE `inventory` SET `setsale` = '".$_GET['kredit']."' WHERE `id` = '{$_GET['id']}' AND `owner` = '{$_SESSION['uid']}' LIMIT 1;");
$data=mysql_query("SELECT * FROM `inventory` WHERE `dressed`=0 AND `name` LIKE '".mysql_escape_string($_REQUEST['max'])."%' AND `setsale` > 0 ORDER by `setsale` ASC");
echo"<TR bgcolor=#C7C7C7><TD align=center colspan=2>Комиссия за услуги магазина составляет 10% от цены, по которой вы предлагаете предмет.</TD></TR>";
$data=mysql_query("SELECT * FROM `inventory` WHERE `setsale` = 0 AND `owner` = '{$_SESSION['uid']}' AND `dressed` = 0 AND `present` = '' ORDER by `update` DESC; ");
$data=mysql_query("SELECT DISTINCT `img`, `name`, `nalign`,`massa` FROM `inventory` WHERE `dressed`=0 AND `setsale` > 0 AND `present` = '' AND `otdel` = '".$_GET['otdel']."' GROUP BY `img` ORDER by `cost` ASC");
while($row=mysql_fetch_array($data)){
$item_name1=str_replace("+1","",$row[1]);
$item_name1=str_replace("+2","",$item_name1);
$item_name1=str_replace("+3","",$item_name1);
$item_name1=str_replace("+4","",$item_name1);
$item_name1=str_replace("+5","",$item_name1);
$item_name=str_replace(" (мф)","",$item_name1);
$item=mysql_fetch_array(mysql_query("SELECT count(`id`), min(duration), min(maxdur), max(duration), max(maxdur), min(setsale), max(setsale) FROM `inventory` WHERE `dressed`=0 AND `setsale` > 0 AND `present` = '' AND name LIKE '".$item_name."%';"));