Файл: archive/www/musimka.ru/game/bar/cook.php
Строк: 90
<?php
include_once '../../connect.php';
include_once '../../head.php';
include_once 'inc/start.php';
$tmp=mysql_fetch_array(mysql_query("SELECT * FROM `bar_tmp` WHERE `id_u`='".$user_id."'"));
if(isset($_GET['id'])){
$id=abs(intval($_GET['id']));
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `bar_my_ingridient` WHERE `id_u`='".$user_id."' AND `id_i`='".$id."' AND `col`>'0'"),0)!=0){
if($tmp['i1']==0){
mysql_query("UPDATE `bar_tmp` SET `i1`='".$id."' WHERE `id_u`='".$user_id."'");
mysql_query("UPDATE `bar_my_ingridient` SET `col`=`col`-1 WHERE `id_u`='".$user_id."' AND `id_i`='".$id."'");
header("Location:cook.php");
exit;
}
elseif($tmp['i2']==0){
mysql_query("UPDATE `bar_tmp` SET `i2`='".$id."' WHERE `id_u`='".$user_id."'");
mysql_query("UPDATE `bar_my_ingridient` SET `col`=`col`-1 WHERE `id_u`='".$user_id."' AND `id_i`='".$id."'");
header("Location:cook.php");
exit;
}
elseif($tmp['i3']==0){
mysql_query("UPDATE `bar_tmp` SET `i3`='".$id."' WHERE `id_u`='".$user_id."'");
mysql_query("UPDATE `bar_my_ingridient` SET `col`=`col`-1 WHERE `id_u`='".$user_id."' AND `id_i`='".$id."'");
header("Location:cook.php");
exit;
}
}
}
if(isset($_POST['sub'])){
$recept=$tmp['i1']."".($tmp['i2']!=0 ? ";".$tmp['i2'] : "")."".($tmp['i3']!=0 ? ";".$tmp['i3'] : "");
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `bar_my_recept` WHERE `id_u`='".$user_id."' AND `in`='".$recept."'"),0)!=0){
$arr=mysql_fetch_array(mysql_query("SELECT * FROM `bar_my_recept` WHERE `id_u`='".$user_id."' AND `in`='".$recept."'"));
mysql_query("INSERT INTO `bar_coctails`(`name`,`id_u`,`id_r`) VALUES('".$arr['name']."','".$user_id."','".$arr['id_r']."')");
mysql_query("UPDATE `bar_tmp` SET `i1`='0',`i2`='0',`i3`='0' WHERE `id_u`='".$user_id."'");
$dels=explode(';',$recept);
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `bar_my_ingridient` WHERE `id_u`='".$user_id."' AND `id_i`='".$dels[0]."' AND `col`='0'"),0)==1)
mysql_query("DELETE FROM `bar_my_ingridient` WHERE `id_u`='".$user_id."' AND `id_i`='".$dels[0]."' AND `col`='0'");
if(isset($dels[1])){
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `bar_my_ingridient` WHERE `id_u`='".$user_id."' AND `id_i`='".$dels[1]."' AND `col`='0'"),0)==1)
mysql_query("DELETE FROM `bar_my_ingridient` WHERE `id_u`='".$user_id."' AND `id_i`='".$dels[1]."' AND `col`='0'");
}
if(isset($dels[2])){
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `bar_my_ingridient` WHERE `id_u`='".$user_id."' AND `id_i`='".$dels[2]."' AND `col`='0'"),0)==1)
mysql_query("DELETE FROM `bar_my_ingridient` WHERE `id_u`='".$user_id."' AND `id_i`='".$dels[2]."' AND `col`='0'");
}
header("Location:cook.php?msg");
exit;
}
else
bar_msg($diz['msg'],'У вас нет такого рецепта!');
}
if(isset($_POST['del'])){
mysql_query("UPDATE `bar_my_ingridient` SET `col`=`col`+1 WHERE `id_i`='".$tmp['i1']."' AND `id_u`='".$user_id."'");
mysql_query("UPDATE `bar_my_ingridient` SET `col`=`col`+1 WHERE `id_i`='".$tmp['i2']."' AND `id_u`='".$user_id."'");
mysql_query("UPDATE `bar_my_ingridient` SET `col`=`col`+1 WHERE `id_i`='".$tmp['i3']."' AND `id_u`='".$user_id."'");
mysql_query("UPDATE `bar_tmp` SET `i1`='0',`i2`='0',`i3`='0' WHERE `id_u`='".$user_id."'");
header("Location:cook.php");
exit;
}
if(isset($_GET['msg'])){
bar_msg($diz['msg'],'Коктейль успешно приготовлен');
}
echo "
<div class='".$diz['main']."'>
<img src='i/4.png' /> ".$bar_user['level']."
<img src='i/exp.png' /> ".$bar_user['exp']."
<img src='i/d.png' /> ".$bar_user['money']."
<br/><img src='i/bottle.png' />".$bar_user['alc']." ".nap($bar_user['alc'])."
<div class='".$diz['title2']."'>Приготовить коктейль</div>
<center>
<table>
<tr>
<td style='border: 2px solid #0090C4;
background-color: #fff;
height:48px;
width:48px;' align='center'>
<img src='i/".($tmp['i1']!=0 ? "i_" : "")."".$tmp['i1'].".png' />
</td>
<td style='border: 2px solid #0090C4;
background-color: #fff;
height:48px;
width:48px;' align='center'>
<img src='i/".($tmp['i2']!=0 ? "i_" : "")."".$tmp['i2'].".png' />
</td>
<td style='border: 2px solid #0090C4;
background-color: #fff;
height:48px;
width:48px;' align='center'>
<img src='i/".($tmp['i3']!=0 ? "i_" : "")."".$tmp['i3'].".png' />
</td>
</tr>
</table>
<img src='i/bar.gif' /><br/>
<form method='post' action='cook.php?'>
<input type='submit' name='sub' value='Смешать'/><input type='submit' name='del' value='Убрать'/></form></center>
<div class='".$diz['title2']."'>Ингридиенты</div>";
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `bar_my_ingridient` WHERE `id_u`='".$user_id."'"),0)!=0){
$total=mysql_result(mysql_query("SELECT COUNT(*) FROM `bar_my_ingridient` WHERE `id_u`='".$user_id."'"),0);
$quert=mysql_query("SELECT * FROM `bar_my_ingridient` WHERE `id_u`='".$user_id."' ORDER BY `id` ASC LIMIT ".$start.",5");
while($array=mysql_fetch_array($quert)){
echo '<table cellpadding="0">
<tr>
<td style="border: 2px solid #0090C4;
background-color: #fff;
height:48px;
width:48px;" align="center">
<img src="i/i_'.$array['id_i'].'.png" alt="." />
</td>
<td>
'.mysql_result(mysql_query("SELECT `name` FROM `bar_ingridient` WHERE `id`='".$array['id_i']."'"),0).'
<br/>
В баре: '.$array['col'].'<br/>
<a href="cook.php?id='.$array['id_i'].'">Выбрать</a>
</td></tr></table>';
}
if ($total > 5) {
echo bar_pagenav('cook.php?', $start, $total, 5);
}
}
else
echo "У вас нет ингридиентов!";
echo "</div>";
ret($diz['ret'],'Мой бар','index.php');
include_once '../../foot.php';
?>