$_G['mnid'] = 'mn_common'; $magiclist = array(); $_G['tpp'] = 12; $page = max(1, intval($_GET['page'])); $action = $_GET['action']; $operation = $_GET['operation']; $start_limit = ($page - 1) * $_G['tpp']; $comma = $typeadd = $filteradd = $forumperm = $targetgroupperm = ''; $magicarray = is_array($_G['cache']['magics']) ? $_G['cache']['magics'] : array(); if (!$_G['uid'] && ($operation || $action == 'mybox')) { showmessage('not_loggedin', NULL, array(), array('login' => 1)); } if (!$_G['group']['allowmagics']) { showmessage('magics_nopermission'); } $totalweight = getmagicweight($_G['uid'], $magicarray); $allowweight = $_G['group']['maxmagicsweight'] - $totalweight; $location = 0; if (empty($action) && !empty($_GET['mid'])) { $_GET['magicid'] = C::t('common_member_magic')->fetch_magicid_by_identifier($_G['uid'], $_GET['mid']); if ($_GET['magicid']) { $action = 'mybox'; $operation = 'use'; } else { $action = 'shop'; $operation = 'buy'; $location = 1; } } $action = empty($action) ? 'shop' : $action; $actives[$action] = ' class="a"';
function givemagic($username, $magicid, $magicnum, $totalnum, $totalprice, $givemessage, $magicarray) { global $_G; $member = C::t('common_member')->fetch_by_username($username); if (!$member) { showmessage('magics_target_member_nonexistence'); } elseif ($member['uid'] == $_G['uid']) { showmessage('magics_give_myself'); } $member = array_merge(C::t('common_usergroup_field')->fetch($member['groupid']), $member); $totalweight = getmagicweight($member['uid'], $magicarray); $magicweight = $magicarray[$magicid]['weight'] * $magicnum; if ($magicarray[$magicid]['weight'] && $magicweight + $totalweight > $member['maxmagicsweight']) { $num = floor(($member['maxmagicsweight'] - $totalweight) / $magicarray[$magicid]['weight']); $num = max(0, $num); showmessage('magics_give_weight_range_invalid', '', array('num' => $num)); } getmagic($magicid, $magicnum, $magicweight, $totalweight, $member['uid'], $member['maxmagicsweight']); notification_add($member['uid'], 'magic', 'magics_receive', array('magicname' => $magicarray[$magicid]['name'], 'msg' => $givemessage)); updatemagiclog($magicid, '3', $magicnum, $magicarray[$magicid]['price'], $member['uid']); if (empty($totalprice)) { usemagic($magicid, $totalnum, $magicnum); showmessage('magics_give_succeed', 'home.php?mod=magic&action=mybox', array('toname' => $username, 'num' => $magicnum, 'magicname' => $magicarray[$magicid]['name'])); } }
function givemagic($username, $magicid, $magicnum, $totalnum, $totalprice, $givemessage, $magicarray) { global $_G; $member = DB::fetch_first("SELECT m.uid, m.username, u.maxmagicsweight FROM " . DB::table('common_member') . " m LEFT JOIN " . DB::table('common_usergroup_field') . " u ON u.groupid=m.groupid WHERE m.username='******'"); if (!$member) { showmessage('magics_target_nonexistence'); } elseif ($member['uid'] == $_G['uid']) { showmessage('magics_give_myself'); } $totalweight = getmagicweight($member['uid'], $magicarray); $magicweight = $magicarray[$magicid]['weight'] * $magicnum; if ($magicarray[$magicid]['weight'] && $magicweight + $totalweight > $member['maxmagicsweight']) { $num = floor(($member['maxmagicsweight'] - $totalweight) / $magicarray[$magicid]['weight']); $num = max(0, $num); showmessage('magics_give_weight_range_invalid', '', array('num' => $num)); } getmagic($magicid, $magicnum, $magicweight, $totalweight, $member['uid'], $member['maxmagicsweight']); notification_add($member['uid'], 'magic', 'magics_receive', array('magicname' => $magicarray[$magicid]['name'], 'msg' => $givemessage)); updatemagiclog($magicid, '3', $magicnum, $magicarray[$magicid]['price'], $member['uid']); if (empty($totalprice)) { usemagic($magicid, $totalnum, $magicnum); showmessage('magics_give_succeed', 'home.php?mod=magic&action=mybox', array('toname' => $username, 'num' => $magicnum, 'magicname' => $magicarray[$magicid]['name'])); } }
function givemagic($username, $magicid, $magicnum, $totalnum, $totalprice) { global $db, $tablepre, $discuz_uid, $discuz_user, $creditstrans, $creditstransextra, $magicarray; $member = $db->fetch_first("SELECT m.uid, m.username, u.maxmagicsweight FROM {$tablepre}members m LEFT JOIN {$tablepre}usergroups u ON u.groupid=m.groupid WHERE m.username='******'"); if (!$member) { showmessage('magics_target_nonexistence'); } elseif ($member['uid'] == $discuz_uid) { showmessage('magics_give_myself'); } $totalweight = getmagicweight($member['uid'], $magicarray); $magicweight = $magicarray[$magicid]['weight'] * $magicnum; getmagic($magicid, $magicnum, $magicweight, $totalweight, $member['uid'], $member['maxmagicsweight']); sendpm($member['uid'], 'magics_receive_subject', 'magics_receive_message', 0); updatemagiclog($magicid, '3', $magicnum, $magicarray[$magicid]['price'], '0', '0', $member['uid']); if (empty($totalprice)) { usemagic($magicid, $totalnum, $magicnum); showmessage('magics_give_succeed', '', 1); } }
} elseif (!$magicstatus && $adminid != 1) { showmessage('magics_close'); } elseif (!$allowmagics) { showmessage('magics_perm'); } require_once DISCUZ_ROOT . './include/magic.func.php'; require_once DISCUZ_ROOT . './forumdata/cache/cache_magics.php'; $magiclist = array(); $page = max(1, intval($page)); $start_limit = ($page - 1) * $tpp; $action = empty($action) ? 'shop' : $action; $comma = $typeadd = $filteradd = $forumperm = $targetgroupperm = ''; $magicarray = is_array($_DCACHE['magics']) ? $_DCACHE['magics'] : array(); $operationarray = array('use', 'sell', 'drop', 'give', 'my', 'buy', 'down', 'uselog', 'buylog', 'givelog', 'receivelog', 'marketlog'); $operation = !empty($operation) && in_array($operation, $operationarray) ? $operation : ''; $totalweight = getmagicweight($discuz_uid, $magicarray); if (!empty($typeid)) { $typeadd = '&typeid=' . intval($typeid); $filteradd = "AND type='" . intval($typeid) . "'"; } if ($action == 'shop') { $discuz_action = 170; if (empty($operation)) { $operation = ''; $query = $db->query("SELECT COUNT(*) FROM {$tablepre}magics WHERE available='1' {$filteradd}"); $magiccount = $db->result($query, 0); $multipage = multi($magiccount, $tpp, $page, "magic.php?action=shop{$typeadd}"); $query = $db->query("SELECT magicid, name, identifier, description, price, num, salevolume, weight FROM {$tablepre}magics WHERE available='1' {$filteradd} ORDER BY displayorder LIMIT {$start_limit},{$tpp}"); while ($magic = $db->fetch_array($query)) { $magic['price'] = $magicsdiscount ? intval($magic['price'] * ($magicsdiscount / 10)) : intval($magic['price']); $magic['pic'] = strtolower($magic['identifier']) . '.gif';