예제 #1
0
파일: kbank.php 프로젝트: 0hyeah/yurivn
     if (is_member_of($vbulletin->userinfo, $vbulletin->kbank['BankRuptGroupID'])) {
         if ($ban_record = $vbulletin->db->query_first("\n\t\t\t\t\tSELECT * FROM `" . TABLE_PREFIX . "userban`\n\t\t\t\t\tWHERE userid = adminid\n\t\t\t\t\t\tAND userid = {$vbulletin->userinfo['userid']}\n\t\t\t\t\t\t#AND reason = 'kbank_bankrupt_tax'")) {
             $user_new = array_merge($user_new, array('usergroupid' => $ban_record['usergroupid'], 'displaygroupid' => $ban_record['displaygroupid'], 'usertitle' => $ban_record['usertitle'], 'customtitle' => $ban_record['customtitle']));
             $vbulletin->db->query_write("\n\t\t\t\t\t\tDELETE FROM `" . TABLE_PREFIX . "userban`\n\t\t\t\t\t\tWHERE userid = {$vbulletin->userinfo['userid']}\n\t\t\t\t\t");
         } else {
             $user_new['usergroupid'] = $vbulletin->kbank['NormalGroupID'];
             $usergroup = $vbulletin->usergroupcache["{$user_new['usergroupid']}"];
             if (!$usergroup['usertitle']) {
                 $gettitle = $db->query_first("\n\t\t\t\t\t\t\tSELECT title\n\t\t\t\t\t\t\tFROM " . TABLE_PREFIX . "usertitle\n\t\t\t\t\t\t\tWHERE minposts <= {$vbulletin->userinfo['posts']}\n\t\t\t\t\t\t\tORDER BY minposts DESC\n\t\t\t\t\t\t");
                 $user_new['usertitle'] = $gettitle['title'];
             } else {
                 $user_new['usertitle'] = $usergroup['usertitle'];
             }
         }
     }
     $user_new['kbank_nextpay'] = calcMonthlyTaxPayTime($vbulletin->userinfo, 'next');
     $vbulletin->db->query_write(fetch_query_sql($user_new, 'user', "WHERE userid = {$vbulletin->userinfo['userid']}"));
     break;
 case 'bankrupt':
     $newug = $vbulletin->kbank['BankRuptGroupID'];
     if ($newug != 0 and $vbulletin->userinfo['usergroupid'] != $newug) {
         $set_query[] = "usergroupid = {$newug}";
     } else {
         $newug = 0;
     }
     if ($newug) {
         //Add ban record
         $ban_record = array('userid' => $vbulletin->userinfo['userid'], 'usergroupid' => $vbulletin->userinfo['usergroupid'], 'displaygroupid' => $vbulletin->userinfo['displaygroupid'], 'usertitle' => $vbulletin->userinfo['usertitle'], 'customtitle' => $vbulletin->userinfo['customtitle'], 'adminid' => $vbulletin->userinfo['userid'], 'bandate' => TIMENOW, 'liftdate' => 0, 'reason' => 'kbank_bankrupt_tax');
         $vbulletin->db->query_write(fetch_query_sql($ban_record, 'userban'));
         //Edit user info
         $user_new = array('usergroupid' => $newug);
예제 #2
0
파일: functions.php 프로젝트: 0hyeah/yurivn
function calcMonthlyTax($user, $checkonly = false)
{
    if (!is_numeric($user['userid'])) {
        return 0;
    }
    global $vbulletin;
    $paytime = calcMonthlyTaxPayTime($user, 0, $checkonly);
    //Fix tax calculation issue 30-12-2008
    //Old code: $timelimit = $paytime - $vbulletin->kbank['MonthlyTaxDays']*24*60*60;
    $timelimit = iif($user['kbank_nextpay'] != 0, $user['kbank_nextpay'] - $vbulletin->kbank['MonthlyTaxDays'] * 24 * 60 * 60, $paytime - $vbulletin->kbank['MonthlyTaxDays'] * 24 * 60 * 60);
    $nexttime = $paytime + iif($checkonly, 0, $vbulletin->kbank['MonthlyTaxDays'] * 24 * 60 * 60);
    $money = $user["{$vbulletin->kbank['field']}"];
    $hard = $soft = $extra_percent = 0;
    $hard = $vbulletin->options['kbank_member_monthly_tax_hard'];
    if ($hard != 0) {
        //Calculating profit
        $posts = $vbulletin->db->query_first("\n\t\t\tSELECT COUNT(*) as count, SUM(kbank) as total\n\t\t\tFROM `" . TABLE_PREFIX . "post`\n\t\t\tWHERE dateline >= {$timelimit}\n\t\t\t\tAND userid = {$user['userid']}\n\t\t");
        if ($vbulletin->kbank['MonthlyTaxSoftIncludeCompany']) {
            $company_groupids = implode(',', $vbulletin->kbank['CompanyGroupIDs']);
            if ($company_groupids) {
                $companies = array();
                $companies_count = 0;
                $companies_total = 0;
                $companies_cache = $vbulletin->db->query_read("\n\t\t\t\t\tSELECT \n\t\t\t\t\t\tcompany.userid as companyid, company.username as companyname,\n\t\t\t\t\t\tCOUNT(*) as count,\n\t\t\t\t\t\tSUM(IF(rec.to = {$user['userid']},rec.amount,-1*rec.amount)) as total\n\t\t\t\t\tFROM `" . TABLE_PREFIX . "kbank_donations` as rec\n\t\t\t\t\tINNER JOIN `" . TABLE_PREFIX . "user` as company \n\t\t\t\t\t\tON (\n\t\t\t\t\t\t\tcompany.userid <> {$user['userid']}\n\t\t\t\t\t\t\tAND (\n\t\t\t\t\t\t\t\tcompany.userid = rec.to\n\t\t\t\t\t\t\t\tOR company.userid = rec.from\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\tWHERE \n\t\t\t\t\t\ttime >= {$timelimit}\n\t\t\t\t\t\tAND (rec.from = {$user['userid']} OR rec.to = {$user['userid']})\n\t\t\t\t\t\tAND company.usergroupid IN ({$company_groupids})\n\t\t\t\t\t\tAND rec.comment NOT LIKE 'buy%'\n\t\t\t\t\tGROUP BY company.userid\n\t\t\t\t");
                while ($company = $vbulletin->db->fetch_array($companies_cache)) {
                    $company['name'] = getUsername($company['companyid'], $vbulletin->kbank['phpfile'] . '?do=history&username='******'username');
                    $companies[] = array('name' => $company['name'], 'count' => $company['count'], 'total' => $company['total']);
                    $companies_count += $company['count'];
                    $companies_total += $company['total'];
                }
                $vbulletin->db->free_result($companies_cache);
                unset($company);
            }
        }
        $kbank = array('count' => 0, 'total' => 0);
        $kbank_cache = $vbulletin->db->query_read("\n\t\t\tSELECT `from`,`to`,amount,comment\n\t\t\tFROM `" . TABLE_PREFIX . "kbank_donations`\n\t\t\tWHERE \n\t\t\t\ttime >= {$timelimit}\n\t\t\t\tAND `from` = 0\n\t\t\t\tAND `to` = {$user['userid']}\n\t\t\t\tAND postid <> 0\n\t\t\t\t#don't calculate admin donation\n\t\t");
        while ($kbank_rec = $vbulletin->db->fetch_array($kbank_cache)) {
            $comment_a = unserialize($kbank_rec['comment']);
            if (count($comment_a) > 1) {
                $comment_str = $comment_a['comment'];
            } else {
                $comment_str = $kbank_rec['comment'];
            }
            if (substr($comment_str, 0, 7) == 'produce' or substr($comment_str, 0, 3) == 'tax') {
                continue;
            }
            $kbank['count']++;
            $kbank['total'] += $kbank_rec['amount'];
        }
        $vbulletin->db->free_result($kbank_cache);
        unset($kbank_rec);
        $rules_count = preg_match_all('/(post' . iif($vbulletin->kbank['MonthlyTaxSoftIncludeCompany'], '|company') . '|kbank|total)(>|>!|:)(\\d+)=(\\d+)/', $vbulletin->kbank['MonthlyTaxSoftStep'], $rules, PREG_SET_ORDER);
        $soft = array('post' => array('count' => $posts['count'], 'amount' => $posts['total'], 'amount_remain' => $posts['total'], 'parts' => array(), 'tax' => 0), 'company' => array('count' => $companies_count, 'amount' => $companies_total, 'amount_remain' => $companies_total, 'parts' => array(), 'tax' => 0, 'info' => $companies), 'kbank' => array('count' => $kbank['count'], 'amount' => $kbank['total'], 'amount_remain' => $kbank['total'], 'parts' => array(), 'tax' => 0), 'total' => array('amount' => $posts['total'] + $companies_total + $kbank['total'], 'amount_remain' => $posts['total'] + $companies_total + $kbank['total'], 'parts' => array(), 'tax' => 0));
        foreach ($rules as $rule) {
            switch ($rule[2]) {
                case ':':
                    $step = floor($soft[$rule[1]]['amount'] / $rule[3]);
                    $percent = floor($step * $rule[4]);
                    $soft[$rule[1]]['amount_remain'] = 0;
                    $soft[$rule[1]]['parts'] = array(0 => array('amount' => $soft[$rule[1]]['amount'], 'percent' => $percent));
                    break;
                case '>':
                    $soft[$rule[1]]['amount_remain'] = 0;
                    $soft[$rule[1]]['parts'] = array(0 => array('amount' => $soft[$rule[1]]['amount'], 'percent' => floor($rule[4])));
                    break;
                case '>!':
                    if ($soft[$rule[1]]['amount_remain'] > $rule[3]) {
                        $part = array();
                        $part['amount'] = $soft[$rule[1]]['amount_remain'] - $rule[3];
                        $part['percent'] = floor($rule[4]);
                        $soft[$rule[1]]['amount_remain'] -= $part['amount'];
                        $soft[$rule[1]]['parts'][] = $part;
                    }
                    break;
            }
        }
        foreach ($soft as $type => $info) {
            $soft[$type]['tax'] = 0;
            if ($info['amount'] > 0 and count($info['parts'])) {
                foreach ($info['parts'] as $key => $part) {
                    $soft[$type]['parts'][$key]['tax'] = floor($part['amount'] * $part['percent'] / 100);
                    $soft[$type]['tax'] += $soft[$type]['parts'][$key]['tax'];
                }
            } else {
                $soft[$type]['parts'] = array();
            }
            $soft['sum'] += $soft[$type]['tax'];
        }
    }
    if (!is_member_of($user, $vbulletin->kbank['BankRuptGroupID'])) {
        $hard = 0;
    }
    return array('timelimit' => $timelimit, 'nexttime' => $nexttime, 'hard' => $hard, 'soft' => $soft['total'], 'money' => $money, 'tax_total' => $hard + $soft['sum'], 'hard_str' => vb_number_format($hard, $vbulletin->kbank['roundup']), 'soft_str' => vb_number_format($soft['sum'], $vbulletin->kbank['roundup']), 'money_str' => vb_number_format($money, $vbulletin->kbank['roundup']), 'tax_total_str' => vb_number_format($hard + $soft['sum'], $vbulletin->kbank['roundup']), 'soft_detail' => $soft);
}
예제 #3
0
|| #################################################################### ||
|| # kBank 2.4
|| # Coded by mrpaint
|| # 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') and $vbulletin->kbank['enabled']) {
    include_once DIR . '/kbank/functions.php';
    //Setup variables, call function from init.php
    GlobalStartCode();
    $kbank_system_announces = $kbank_announces = array();
    //Need to pay tax?
    if (THIS_SCRIPT != 'kbank' and VB_AREA != 'AdminCP' and $vbulletin->kbank['useMonthlyTax']) {
        $usernextpay = calcMonthlyTaxPayTime($vbulletin->userinfo, 0, 1);
        if (is_member_of($vbulletin->userinfo, $vbulletin->kbank['MemberGroupIDs']) and !is_member_of($vbulletin->userinfo, $vbulletin->kbank['BankRuptGroupID'])) {
            if ($usernextpay < TIMENOW) {
                //It's time to pay tax! Redirect to tax page
                $link = urlencode($_SERVER['REQUEST_URI']);
                $vbulletin->url = $vbulletin->options['bburl'] . '/' . $vbulletin->kbank['phpfile'] . '?' . $vbulletin->session->vars['sessionurl'] . "do=tax&referer={$link}";
                eval(print_standard_redirect(fetch_error('kbank_need_pay_tax'), 0, 0));
            }
            if ($usernextpay - max(1, $vbulletin->kbank['MonthlyTaxReminder']) * 24 * 60 * 60 < TIMENOW) {
                //User have to pay tax soon, display a notice
                $remain_raw = $usernextpay - TIMENOW;
                if ($remain_raw / (60 * 60 * 24) > 1) {
                    $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';