Esempio n. 1
0
<?php

/*======================================================================*\
|| #################################################################### ||
|| # kBank 2.4
|| # Coded by mrpaint
|| # Contact: mrpaint@gmail.com
|| # I'm a Vietnamese! Thank you for using this script
|| # Last Updated: 03:26 29-03-2009
|| #################################################################### ||
\*======================================================================*/
if (defined('VB_AREA') && $vbulletin->kbank['enabled']) {
    include_once DIR . '/kbank/functions.php';
    global $KBANK_HOOK_NAME;
    $KBANK_HOOK_NAME = KBANK_THREADBIT_DISPLAY;
    findItemToWork($thread['postuserid']);
    customize_userinfo_replaceUsername($thread['postusername']);
    customize_userinfo_replaceUsername($thread['lastposter']);
}
Esempio n. 2
0
function findItemsToWork($userids, $work = false, $allstatus = false, $query_hook = false)
{
    global $vbulletin, $kbank_active_items;
    if (!$vbulletin->kbank['itemEnabled']) {
        return false;
    }
    $didsomething = false;
    $userids_query = array();
    if ($query_hook['force']) {
        $userids_query[] = -1;
    }
    if (is_numeric($userids)) {
        $userids = array($userids);
    }
    if (is_array($userids)) {
        foreach ($userids as $userid) {
            if ($allstatus) {
                unset($kbank_active_items[$userid]);
            }
            if (is_numeric($userid) and $userid > 0 and !isset($kbank_active_items[$userid]) and !in_array($userid, $userids_query)) {
                $userids_query[] = intval($userid);
                $kbank_active_items[$userid] = array();
            }
        }
    }
    if (count($userids_query) > 0) {
        $items = $vbulletin->db->query_read("\n\t\t\tSELECT \n\t\t\t\titems.*\n\t\t\t\t,user.username AS username\n\t\t\t" . iif($query_hook['fulljoin'], $query_hook['fulljoin'], "FROM `" . TABLE_PREFIX . "kbank_items` AS items\n\t\t\t\t{$query_hook['join']}\n\t\t\t\tLEFT JOIN `" . TABLE_PREFIX . "user` AS user ON (user.userid = items.userid)") . "\n\t\t\tWHERE (\n\t\t\t\t" . iif($query_hook['idcheckfield'] !== false, iif($query_hook['idcheckfield'], $query_hook['idcheckfield'], 'items.userid') . " in (" . implode(',', $userids_query) . ")") . "\n\t\t\t\t{$query_hook['where']}\n\t\t\t\t)\n\t\t\t\tAND items.status > " . iif(!$allstatus, KBANK_ITEM_AVAILABLE, KBANK_ITEM_DELETED) . "\n\t\t\t\tAND (items.expire_time > " . TIMENOW . "\n\t\t\t\t\tOR items.expire_time < 0)\n\t\t\tORDER BY items.userid ASC, items.type ASC, items.expire_time DESC\n\t\t");
        DEVDEBUG('[kBank Item] findItemsToWorks query the database');
        $itemdatas = array();
        $itemtypeids = array();
        while ($itemdata = $vbulletin->db->fetch_array($items)) {
            $itemdatas[] = $itemdata;
            $itemtypeids[] = $itemdata['type'];
        }
        $vbulletin->db->free_result($items);
        unset($item);
        //Prepare itemtypes
        newItemType($itemtypeids, false, true);
        //Load items
        $userids2sort = array();
        foreach ($itemdatas as $itemdata) {
            $item =& newItem($itemdata['itemid'], $itemdata);
            $kbank_active_items[$itemdata['userid']][$itemdata['itemid']] = $item;
            if (!in_array($itemdata['userid'], $userids2sort)) {
                $userids2sort[] = $itemdata['userid'];
            }
        }
        //sorting
        foreach ($userids2sort as $userid) {
            if ($userid != -1 and is_array($kbank_active_items[$userid])) {
                usort($kbank_active_items[$userid], 'findItemsToWork_cmp');
                if (count($kbank_active_items[$userid]) > 1) {
                    //fix itemid, only work if more than 1 item
                    $items = array();
                    foreach ($kbank_active_items[$userid] as $item) {
                        if ($item) {
                            $items[$item->data['itemid']] = $item;
                        }
                    }
                    $kbank_active_items[$userid] = $items;
                }
            }
        }
    }
    if ($work) {
        foreach ($userids as $userid) {
            if (findItemToWork($userid)) {
                $didsomething = true;
            }
        }
    }
    return $didsomething;
}
Esempio n. 3
0
<?php

/*======================================================================*\
|| #################################################################### ||
|| # kBank 2.4
|| # Coded by mrpaint
|| # Contact: mrpaint@gmail.com
|| # I'm a Vietnamese! Thank you for using this script
|| # Last Updated: 03:26 29-03-2009
|| #################################################################### ||
\*======================================================================*/
if (defined('VB_AREA') && $vbulletin->kbank['enabled']) {
    include_once DIR . '/kbank/functions.php';
    $KBANK_HOOK_NAME = KBANK_MEMBER_COMPLETE;
    if ($userinfo['money']) {
        $userinfo['money'] = $userinfo['kbank'] = vb_number_format($userinfo['money'], $vbulletin->kbank['roundup']);
    }
    findItemToWork($userinfo['userid']);
    //vBB older than 3.7 support (no template_hook)
    if ($vbulletin->options['templateversion'] < '3.7.0') {
        include_once DIR . '/kbank/hook_member_profileblock_fetch_unwrapped.php';
    }
}
|| #################################################################### ||
\*======================================================================*/
global $vbulletin;
if (defined('VB_AREA') and $vbulletin->kbank['enabled']) {
    include_once DIR . '/kbank/functions.php';
    global $vbphrase, $kbank, $KBANK_HOOK_NAME, $ids, $kbank_done, $kbank_active_items;
    if (!$kbank_done) {
        if ($ids) {
            //Prepare with multi posts thread (ONE query for the whole page)
            findItemsToWork(explode(',', $ids), false, false, array('join' => "INNER JOIN `" . TABLE_PREFIX . "post` AS post ON (post.userid = items.userid)", 'idcheckfield' => 'post.postid'));
        }
        $kbank_done = true;
        //Tricky way to re-create musername if item found
        if (count($kbank_active_items[$post['userid']])) {
            $post['musername'] = null;
            $post['musername'] = fetch_musername($post);
        }
    }
    $KBANK_HOOK_NAME = KBANK_POSTBIT_COMPLETE;
    findItemToWork($this->post['userid'], false);
    if ($vbulletin->kbank['postbit_elements'] & $vbulletin->kbank['bitfield']['display_elements']['kbank_show_points']) {
        $showpoints = true;
        if ($post["{$vbulletin->kbank['field']}"]) {
            $post["{$vbulletin->kbank['field']}"] = $post['kbank'] = vb_number_format($post["{$vbulletin->kbank['field']}"], $vbulletin->kbank['roundup']);
        }
        if ($vbulletin->kbank['postbit_elements'] & $vbulletin->kbank['bitfield']['display_elements']['kbank_show_toprichest'] and $vbulletin->kbank_toprichest and isset($vbulletin->kbank_toprichest[$post['userid']])) {
            $post['kbank_toprichest'] = construct_phrase($vbphrase['kbank_misc_toprichest_show'], $vbulletin->kbank_toprichest[$post['userid']]['pos']);
        }
    }
    eval('$template_hook["postbit_userinfo_right_after_posts"] .= "' . fetch_template('kbank_postbit_right_after_posts') . '";');
}
 $showitems = true;
 //search for itemtype that user can produce
 $itemtypes = $vbulletin->db->query_read("SELECT *\n\t\t\tFROM `" . TABLE_PREFIX . "kbank_itemtypes` AS itemtypes\n\t\t\tWHERE userid LIKE '%,{$userinfo['userid']},%'");
 DEVDEBUG('[kBank Item] Query database for user itemtypes');
 if ($vbulletin->db->num_rows($itemtypes)) {
     $userinfo['kbank_itemtypes'] = '';
     while ($itemtypedata = $vbulletin->db->fetch_array($itemtypes)) {
         $userinfo['kbank_itemtypes'] .= '<li>' . "<a href=\"{$vbulletin->kbank['phpfile']}?do=shop&username={$userinfo['username']}&itemtypeid={$itemtypedata['itemtypeid']}\" target=\"_blank\">{$itemtypedata['name']}</a>" . '</li>';
     }
     unset($itemtypedata);
 }
 $vbulletin->db->free_result($itemtypes);
 //search for user items
 if ($vbulletin->userinfo['userid'] != $userinfo['userid']) {
     //skip 1 query if user is viewing his/her profile. Everything has been loaded!
     findItemToWork($userinfo['userid'], true);
 }
 global $kbank_active_items;
 if (count($kbank_active_items[$userinfo['userid']])) {
     $userinfo['kbank_active_items'] = $userinfo['kbank_selling_items'] = '';
     $items2show = fetchItemFromCache($kbank_active_items[$userinfo['userid']]);
     foreach ($items2show as $itemtypeid => $items2show_tmp) {
         foreach ($items2show_tmp as $item) {
             if ($item['status'] == KBANK_ITEM_SELLING) {
                 //Selling item
                 $userinfo['kbank_selling_items'] .= '<li>' . "<a href=\"{$vbulletin->kbank['phpfile']}?do=shop&username={$userinfo['username']}&itemtypeid={$itemtypeid}\" target=\"_blank\">{$item['name']}</a>" . iif($item['count'] > 1, " x<strong style=\"color:red\">{$item['count']}</strong>") . '</li>';
             } else {
                 $userinfo['kbank_active_items'] .= '<li>' . "<a href=\"{$vbulletin->kbank['phpfile']}?do=shop&itemtypeid={$itemtypeid}\" target=\"_blank\">{$item['name']}</a>" . iif(havePerm($vbulletin->userinfo, KBANK_PERM_ADMIN), " <em>{$item['status_str']}</em>") . iif($item['count'] > 1, " x<strong style=\"color:red\">{$item['count']}</strong>") . '</li>';
             }
         }
     }
Esempio n. 6
0
<?php

/*======================================================================*\
|| #################################################################### ||
|| # kBank 2.4
|| # Coded by mrpaint
|| # Contact: mrpaint@gmail.com
|| # I'm a Vietnamese! Thank you for using this script
|| # Last Updated: 03:27 29-03-2009
|| #################################################################### ||
\*======================================================================*/
if (defined('VB_AREA') && $vbulletin->kbank['enabled']) {
    include_once DIR . '/kbank/functions.php';
    global $KBANK_HOOK_NAME, $kbank_userinfo_tmp;
    $KBANK_HOOK_NAME = KBANK_FETCH_MUSERNAME;
    $kbank_userinfo_tmp = $user;
    $kbank_userinfo_tmp['userdisplaygroupid'] = $displaygroupid;
    if (!isset($vbulletin->userinfo)) {
        //userinfo has not been initialized! We believe fetch_musername is being called for current user
        //cache ALL user items
        $userids = array($user['userid']);
        if ($user['kbank_granted_count']) {
            $userids = array_merge($userids, explode('|', $user['kbank_granted_userid']));
        }
        findItemsToWork($userids, false, true);
    }
    if (findItemToWork($user['userid'])) {
        $user = $kbank_userinfo_tmp;
    }
}
Esempio n. 7
0
|| # Contact: mrpaint@gmail.com
|| # I'm a Vietnamese! Thank you for using this script
|| # Last Updated: 03:25 29-03-2009
|| #################################################################### ||
\*======================================================================*/
if (defined('VB_AREA') && $vbulletin->kbank['enabled']) {
    include_once DIR . '/kbank/functions.php';
    if ($user["{$vbulletin->kbank['field']}"]) {
        $user['kbank'] = vb_number_format($user["{$vbulletin->kbank['field']}"], $vbulletin->kbank['roundup']);
    }
    //prepair for some templates display
    $user['iskBankAdmin'] = iskBankAdmin($user['userid']);
    $user['kbank_grantedids_a'] = array($user['userid']);
    if ($user['kbank_granted_count']) {
        $user['kbank_granted'] = array();
        $user['kbank_grantedids'] = '';
        $granted_userid = explode('|', $user['kbank_granted_userid']);
        $granted_username = explode('|', $user['kbank_granted_username']);
        $granted_usergroupid = explode('|', $user['kbank_granted_usergroupid']);
        $granted_membergroupids = explode('|', $user['kbank_granted_membergroupids']);
        $granted_money = explode('|', $user["kbank_granted_{$vbulletin->kbank['field']}"]);
        for ($i = 0; $i < $user['kbank_granted_count']; $i++) {
            $user['kbank_granted'][$granted_userid[$i]] = array('userid' => $granted_userid[$i], 'username' => $granted_username[$i], 'usergroupid' => $granted_usergroupid[$i], 'membergroupids' => $granted_membergroupids[$i], $vbulletin->kbank['field'] => $granted_money[$i]);
            $user['kbank_grantedids'] .= ',' . $granted_userid[$i];
            $user['kbank_grantedids_a'][] = $granted_userid[$i];
        }
    }
    global $KBANK_HOOK_NAME;
    $KBANK_HOOK_NAME = KBANK_FETCH_USERINFO;
    findItemToWork($userid);
}
Esempio n. 8
0
                    $remain = construct_phrase($vbphrase['kbank_announce_tax_day'], floor($remain_raw / (60 * 60 * 24)));
                } else {
                    if ($remain_raw / (60 * 60) > 1) {
                        $remain = floor($remain_raw / (60 * 60)) . 'h';
                    } else {
                        if ($remain_raw / 60 > 1) {
                            $remain = floor($remain_raw / 60) . '\'';
                        } else {
                            $remain = $remain_raw . 's';
                        }
                    }
                }
                $kbank_system_announces[] = array('url' => $vbulletin->kbank['phpfile'] . '?do=tax', 'text' => construct_phrase($vbphrase['kbank_announce_tax'], vbdate($vbulletin->options['dateformat'], $usernextpay), $remain), 'css' => 'color: red; font-weight: bold');
            }
        }
        if (is_member_of($vbulletin->userinfo, $vbulletin->kbank['BankRuptGroupID'])) {
            //User is Bank Rupted! Display notice
            $kbank_system_announces[] = array('url' => $vbulletin->kbank['phpfile'] . '?do=tax', 'text' => construct_phrase($vbphrase['kbank_announce_tax_bankrupt']), 'css' => 'color: red; font-weight: bold');
        }
    }
    //Only build navbar item for registered user - moved from global_setup_complete
    if ($vbulletin->userinfo['userid']) {
        //button
        eval('$template_hook["navbar_buttons_left"] .= "' . fetch_template('kbank_navbar_button') . '";');
    }
    //Item hook
    $KBANK_HOOK_NAME = KBANK_GLOBAL_START;
    findItemToWork($vbulletin->userinfo['userid']);
    findItemExpire($vbulletin->userinfo['userid']);
    //Item hook - complete!
}