<?php

$giftid = get_module_pref("giftid");
$cat = get_module_pref("giftcat");
//First, let's determine just what the item is, and record it thusly
require_once './modules/mysticalshop/lib.php';
$gift = mysticalshop_additem($giftid, $cat);
if ($gift['name'] !== false) {
    output("`n`2%s`2 compliments you on your gift:`n`n", $shopkeep);
    output('`2"It suits you quite well, %s`2. Do enjoy it," %s `2says.', $session['user']['name'], $shopkeep);
    debuglog('picked up the gift (ID is ' . $giftid . ').');
    //It's done!
    modulehook("mysticalshop-gift", array());
    set_module_pref("gifted", 0);
}
output_notl('`0`n`n');
<?php

if (is_numeric($id)) {
    //time to buy our goods. Sorry, no credit cards accepted
    require_once './modules/mysticalshop/lib.php';
    $nameprice = mysticalshop_additem($id, $cat);
    $name = $nameprice['name'];
    if ($nameprice['name'] !== false) {
        $gold = $nameprice['gold'];
        $gems = $nameprice['gems'];
        output("`n`2%s `2compliments you on the purchase of %s`2.`n`n", $shopkeep, $name);
        output("\"You wear it well, friend,\" the shopkeep comments.");
        //subtract price
        mysticalshop_applydiscount($gold, $gems, $disnum);
        $session['user']['gold'] -= $gold;
        $session['user']['gems'] -= $gems;
        debuglog('bought ' . $name . ' for ' . $gold . ' gold and ' . $gems . ' gems.');
    }
    output_notl('`0`n`n');
} else {
    output('Item not available for purchase.');
}
//
modulehook("mysticalshop-buy", array());
addnav('Merchandise');
addnav('Overview of Goods', $from . 'op=shop&what=enter');