Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $id = $router->requestVar('id', -1);
- $admin = level(LEVEL_ADMIN);
- $router->codeUnless(404, $shopItem = Query::create()
- ->select('i.cost, e.*')
- ->from('ShopItem i')
- ->leftJoin('i.Effects e')
- ->where('id = ?', $id)
- ->fetchOne());
- $return_back = '<br />' . make_link(array('controller' => 'Shop', 'action' => 'index', 'cat' => $shopItem->category_id), lang('back_to_index'));
- $router->codeUnless(404, $char = $account->getMainChar());
- /* @var $char Character */
- if (!$admin)
- {
- if ($shopItem->cost > $account->User->points)
- {
- printf(lang('shop.cannot_buy_but_credit'), $shopItem->name,
- make_link('@vote', lang('acc.vote')), make_link('@credit', lang('acc.credit.add')), $return_back);
- return;
- }
- $this->codeIf(404, $shopItem->is_hidden
- || ($shopItem->is_vip && (empty($config['COST_VIP']) || !$account->vip)));
- }
- if ($shopItem->confirm($_POST))
- {
- if ($shopItem->is_lottery)
- {
- list($effect, $hasEffect) = $shopItem->giveTo($char, $_POST);
- if ($hasEffect)
- printf(lang('shop.lottery_bought'), $shopItem['name'], br2nl($effect));
- else //pretty complicated name, huh
- printf(lang('shop.lottery_owned_bought' . ( $admin ? '_admin' : '' )), $shopItem['name'], str_replace(tag('br'), '', $effect));
- echo $account->getUser()->decredit($shopItem['cost']);
- }
- else
- {
- if ($shopItem->giveTo($char, $_POST))
- echo sprintf(lang('shop.bought'), $shopItem['name']), $account->getUser()->decredit($shopItem['cost']);
- else
- printf(lang('shop.empty_buy'), $shopItem['name']);
- }
- }
- else
- {
- if (empty($errors))
- echo sprintf(lang('shop.buying_confirm'), $shopItem['name']), $shopItem->getConfirmationForm($_POST);
- else
- echo render_errors();
- }
- echo tag('br') . $return_back;
Add Comment
Please, Sign In to add comment