Файл: chat/list_drink.php
Строк: 108
<?php
require '../sid.php';
require '../config.php';
$link = connect_db();
list($user, $id, $ps) = check_login($link);
whorm(0, 'room');
include '../head.php';
$rm = isset($_GET['rm']) ? (int)$_GET['rm'] : 0;
$rooms = mysql_num_rows(mysql_query("SELECT * FROM `rooms` WHERE `id` = '$rm' LIMIT 1"));
if ($inf['barmen'] == 1) header('Location: index.php?') . exit();
$toUrl = '&rm='.$rm;
$mod = (isset($_GET['mod'])) ? $_GET['mod'] : NULL;
switch($mod) {
//Список разделов
default:
echo $div_title . 'Список товаров' . $div_end . $div_left;
$sql = mysql_query("SELECT *,(SELECT COUNT(*) FROM bot_bartender_product WHERE bot_bartender_product.cat_id = bot_bartender_cat.id ) AS count FROM bot_bartender_cat");
$d = 0;
while(false != ($res = mysql_fetch_assoc($sql))) {
echo ($dv ++ % 2) ? $div_tworazdel : $div_razdel;
echo '<a href="list_drink.php?mod=show&cat_id='.$res['id'].$toUrl.'">'.$res['name'].'</a> ('.$res['count'].')' . $div_end;
}
echo $div_razdel . 'Для заказа стриптиза используйте любую из команд:<br/>
<b>!стрип, !стриптиз, !strip или !striptiz</b><br/> Цена заказа 5 бубликов.' . $div_end . $div_end;
break;
//Список товаров
case show:
if (!isset($_GET['cat_id'])) header('Location: list_drink.php?' . $ref);
$cat_id = my_int($_GET['cat_id']);
$cat = mysql_fetch_assoc(mysql_query("SELECT name FROM bot_bartender_cat WHERE id = '$cat_id'"));
if (!isset($cat['name'])) header('Location: list_drink.php?' . $ref);
echo $div_title . $cat['name'] . $div_end . $div_left;
//Список напитков
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM bot_bartender_product WHERE cat_id = '$cat_id'"), 0);
if ($count) {
include '../navigator.php';
$n = new navigator($count, 5, 'list_drink.php?mod=show&cat_id='.$cat_id.$toUrl.'&');
$sql = mysql_query("SELECT * FROM bot_bartender_product WHERE cat_id = '$cat_id' {$n->limit}");
while(false != ($res = mysql_fetch_assoc($sql))) {
if (is_file('../upload/bot_bartender/'.$res['id'].'.img')) {
echo '<img src="../resize.php?img=upload/bot_bartender/'.$res['id'].'.img&width=75&height=0" alt=""/><br/>';
}
echo '<b>!'.$res['name'].'</b><br/>
Цена: '.$res['price'].'$<br/>
' . ($res['alcohol'] > 0 ? '+ ' . $res['alcohol'] : '- ' . abs($res['alcohol'])) . '%' . $block;
}
echo $n->navi();
} else echo 'Раздел пуст.<br/>';
echo $div_end . '« <a href="list_drink.php?'.$toUrl.'">Назад</a><br/>';
break;
//Угощение
case for_friend:
if (!isset($_GET['friend_id'])) header('Location: list_drink.php?' . $ref) . exit();
$friend_id = my_int($_GET['friend_id']);
if (isset($_GET['ok'])) {
$us = mysql_fetch_assoc(mysql_query("SELECT * FROM users WHERE id = '$friend_id'"));
$alk = mysql_fetch_assoc(mysql_query("SELECT * FROM bot_bartender_product WHERE id = '" . my_int($_GET['ok']) . "'"));
$us['alcohol'] += $alk['alcohol'];
if (!$us['id']) {
err('Такого пользователя нет!');
} elseif (!$alk['id']) {
err('Такого напитка нет!');
} elseif ($alk['price'] > $user['balls']) {
err('Недостаточно бубликов!');
} elseif ($us['alcohol'] > 100) {
err('Пользователь слишком пьян для этого напитка!');
} else {
mysql_query("UPDATE `users` SET `balls` = `balls` - '$alk[price]' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `users` SET `alcohol` = '$us[alcohol]' WHERE `id` = '$us[id]' LIMIT 1");
include 'bot_bartender.php';
$botB = new bot_bartender($user['alcohol'], $user['balls'], $user['id']);
$botRow = mysql_fetch_assoc(mysql_query("SELECT * FROM users WHERE id = '" . $botB->config['id_bot'] . "'"));
$img = is_file('../upload/bot_bartender/'.$alk['id'].'.img') ? ' <img src="../resize.php?img=upload/bot_bartender/'.$alk['id'].'.img&width=75&height=0" alt=""/>' : '';
$msg = '<b>'.cvetnik($user['id']).'</b> заказал для <b>'.cvetnik($us['id']).'</b> '.$alk['name'].$img.', заказ выполнен! <b>Тост:</b> '.$botB->toast();
$ids = mt_rand(100000, 999999);
mysql_query("
INSERT INTO `message` SET
`id` = '$ids',
`user` = 'Бармен',
`who` = '0',
`time` = '" . (time() + 1) . "',
`msg` = '$msg',
`room` = '$rm'
");
$botB = new bot_bartender($us['alcohol'], $us['balls'], $us['id']);
$botB->team = '<b>'.$user['user'].'</b> угостил: ' . $alk['name'];
$botB->setLog();
header('Location: room.php?&rm=' . $rm);
}
}
echo $div_title . 'Чем будем угощать?' . $div_end . $div_left;
//Список напитков
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `bot_bartender_product` WHERE `alcohol` > '0'"), 0);
if ($count) {
include '../navigator.php';
$n = new navigator($count, 5, 'list_drink.php?mod=for_friend&'.$toUrl.'&friend_id='.$friend_id.'&');
$sql = mysql_query("SELECT * FROM bot_bartender_product WHERE alcohol > 0 {$n->limit}");
while(false != ($res = mysql_fetch_assoc($sql))) {
if (is_file('../upload/bot_bartender/'.$res['id'].'.img')) {
echo '<img src="../resize.php?img=upload/bot_bartender/'.$res['id'].'.img&width=75&height=0" alt="" /><br/>';
}
echo '
<b>!' . $res['name'] . '</b><br/>
Цена: ' . $res['price'] . '$ ' . ($res['price'] > $user['balls'] ? '<small>[Недостаточно бубликов]</small>' : '<a href="list_drink.php?mod=for_friend&'.$toUrl.'&friend_id='.$friend_id.'&ok='.$res['id'].'">Купить</a>' ). '<br/>
'.($res['alcohol'] > 0 ? '+ ' . $res['alcohol'] : '- ' . abs($res['alcohol'])) . '%' . $block;
}
echo $n->navi();
} else echo 'Пусто...<br/>';
echo $div_end . $block . '« <a href="list_drink.php?'.$toUrl.'">Назад</a><br/>';
break;
}
echo '<a href="room.php?'.$toUrl.'">В комнату</a><br/>';
include '../foot.php';
?>