1)); } $action = trim($_G['gp_action']); require_once DISCUZ_ROOT.'./data/plugindata/bank.lang.php'; $banklink = 'plugin.php?id=bank:bank'; @include DISCUZ_ROOT.'./data/cache/plugin_bank.php'; $banksettings = $_G['cache']['plugin']['bank']; $navbankname = $banksettings['bankname'] ? $banksettings['bankname'] : $scriptlang['bank']['bankname']; $navtitle = $navbankname; $navigation = ''.$navbankname.''; $extcredits = $_G['setting']['extcredits']; $bankname="extcredits{$banksettings['bankid']}"; $moneyname="extcredits{$banksettings['cashid']}"; $bankunit=$_G['settings']['extcredits'][$banksettings['bankid']]['unit']; $cashunit=$_G['settings']['extcredits'][$banksettings['cashid']]['unit']; $timestamp = $_G['timestamp']; $timeoffset = $_G['member']['timeoffset'] ? $_G['member']['timeoffset'] : $_G['setting']['timeoffset']; @include DISCUZ_ROOT.'./data/cache/cache_allbank.php'; if(!$extcredits{$banksettings['bankid']}){ showmessage('bank:bankid_invalid'); }elseif(!$extcredits{$banksettings['cashid']}){ showmessage('bank:cashid_invalid'); }elseif($extcredits{$banksettings['cashid']} == $extcredits{$banksettings['bankid']}){ showmessage('bank:sameid_error'); } $action = isset($action) && in_array($action, array('save', 'lixi','change','load','showroom','bankinfo')) ? $action : 'showroom'; if(!$_G['adminid'] == 1){ if ($banksettings['close']){ showmessage($banksettings['message']); } if (!$banksettings['allowchange'] && $action == 'change'){ showmessage('bank:service_not_available'); } } $query = DB::query("SELECT uid, $bankname, $moneyname, savemt FROM ".DB::table('common_member_count')." WHERE uid=".$_G['uid'].""); $userbank = DB::fetch($query); if(!$userbank) { showmessage('member_nonexistence', NULL, 'NOPERM'); } $allmoney = $userbank[$bankname] + $userbank[$moneyname]; $bank = $_G['gp_actionmoney'] ? intval(trim($_G['gp_actionmoney'])) : 0; $accrnum = $banksettings['accrual']*100; $changetaxnum = $banksettings['changetax']*100; $selltaxnum = $banksettings['selltax']*100; $changemoney = round(($userbank[$bankname]-$banksettings['minsave'])/($banksettings['changetax']+1)); $changemoney = $changemoney < '1' ? '0' : $changemoney; $savemt = ($userbank['savemt']==0) ? $scriptlang['bank']['no_depositrecord'] : gmdate("Y-n-j G:i", $userbank['savemt'] + $timeoffset * 3600); $userbank['avatar'] = avatar($_G['uid']); /*--存款---*/ if($action == "save") { if($bank < 1 || $bank > $userbank[$moneyname]){ showmessage('bank:wrong_amount',''.$banklink.''); }else{ $lixi = checklixi($userbank); $bank = intval($bank); DB::query("UPDATE ".DB::table('common_member_count')." SET $moneyname=$moneyname-$bank, savemt='$timestamp', $bankname=$bankname+$bank+$lixi WHERE uid='$_G[uid]'"); upbankcache(); showmessage('bank:deposit_succeed',''.$banklink.'&action=showroom'); } /*-利息結算---*/ }elseif($action=="lixi"){ $lixi=checklixi($userbank); DB::query("UPDATE ".DB::table('common_member_count')." SET $bankname=$bankname+$lixi,savemt='$timestamp' WHERE uid='$_G[uid]'"); upbankcache(); showmessage('bank:interest_posted', ''.$banklink.'&action=showroom'); /*-取款---*/ }elseif($action=="load") { if($bank < 1 || $bank > $userbank[$bankname]){ showmessage('bank:withdraw_fail'); }else{ $lixi = checklixi($userbank); $bank = intval($bank); DB::query("UPDATE ".DB::table('common_member_count')." SET $bankname=$bankname-$bank+$lixi,savemt='$timestamp', $moneyname=$moneyname+$bank WHERE uid='$_G[uid]'"); upbankcache(); showmessage('bank:withdraw_succeed',''.$banklink.'&action=showroom'); } /*-銀行轉賬---*/ }elseif($action=="change") { $changeuser = trim($_G['gp_changeuser']); $query = DB::query("SELECT uid, username FROM ".DB::table('common_member')." WHERE username = '$changeuser'"); $user2bankinfo = DB::fetch($query); if(!$user2bankinfo) { showmessage('bank:transfer_mem_notfound',"".$banklink.""); } $query = DB::query("SELECT uid, $bankname, savemt FROM ".DB::table('common_member_count')." WHERE uid = $user2bankinfo[uid]"); $user2bank = DB::fetch($query); $bank_tax = round($bank * $banksettings['changetax']); $changecost = intval($bank + $bank_tax); $yourbank = $userbank[$bankname] - $changecost; if ($bank < $banksettings['minsave']) { showmessage('bank:transfer_error',"".$banklink.""); }elseif($bank > $changemoney) { showmessage('bank:transfer_minsave_error',"".$banklink.""); }elseif($userbank[$bankname] - $changecost < $banksettings['minsave']) { showmessage('bank:transfer_hdlfee_error',"".$banklink.""); }elseif($discuz_uid==$user2bank['uid']) { showmessage('bank:transfer_self_notallow' , "".$banklink.""); } if (!submitcheck(submit)){ $bankaction=''.$scriptlang['bank']['transfer'].''; include template('bank:bank_submit'); exit; }else{ loaducenter(); $checkpassword = uc_user_login($_G['member']['username'], $_G['gp_password']); if($_G['gp_password'] == '' || $checkpassword[0] <= 0) { showmessage('credits_password_invalid'); }elseif ($bank < $banksettings['minsave']) { showmessage('bank:transfer_error',"".$banklink.""); }elseif($bank > $changemoney) { showmessage('bank:transfer_minsave_error',"".$banklink.""); }elseif($userbank[$bankname] - $changecost < $banksettings['minsave']) { showmessage('bank:transfer_hdlfee_error',"".$banklink.""); }elseif($discuz_uid==$user2bank['uid']) { showmessage('bank:transfer_self_notallow' , "".$banklink.""); } $lixi=checklixi($userbank); DB::query("UPDATE ".DB::table('common_member_count')." SET $bankname=$bankname-$changecost+$lixi,savemt='$timestamp' WHERE uid='$_G[uid]'"); $lixi = checklixi($user2bank); DB::query("UPDATE ".DB::table('common_member_count')." SET $bankname=$bankname+$bank+$lixi,savemt='$timestamp' WHERE uid = $user2bank[uid]"); $money2 = $user2bank[$bankname] + $lixi + $bank; $trantime = gmdate("Y-n-j G:i", $timestamp + $timeoffset * 3600); $subject = "".$scriptlang['bank']['pm_subject']." ".$_G['member']['username']." ".$scriptlang['bank']['pm_subject1'].""; $message="".$scriptlang['bank']['pm_message']." ".$user2bankinfo['username'].":\n\n".$scriptlang['bank']['pm_message1']." \[url=".$_G['siteurl']."home.php?mod=space&uid=".$_G['uid']."\]".$_G['member']['username']."\[/url\] ".$scriptlang['bank']['pm_message2']." \[b\]".$_G['setting']['bbname']." ".$navbankname."\[/b\] ".$scriptlang['bank']['pm_message3']." ".$bank." ".$scriptlang['bank']['pm_message4']."\n"; $message.="".$scriptlang['bank']['pm_message5']." ".$user2bank[$bankname]."".$scriptlang['bank']['pm_message6']." ".$lixi." ".$scriptlang['bank']['pm_message7']." ".$bank." ".$scriptlang['bank']['pm_message8']."\[b\]".$money2."\[/b\]".$cashunit."\n"; $message.="".$scriptlang['bank']['pm_message9']." \n"; $message.="\n\[b\]".$_G['setting']['bbname']." ".$navbankname."\[/b\]\n ".$trantime.""; loaducenter(); uc_pm_send($_G['uid'], $user2bank['uid'], $subject, $message, 1, 0, 0); // sendpm($user2bank['uid'], $subject, $message, $discuz_uid); $logs = "$timestamp\t$onlineip\t$discuz_user\t$changeuser\t$bank"; writelog('bankchg', $logs); showmessage('bank:transfer_succed',''.$banklink.'&action=showroom'); } /*--營業大廳---*/ }elseif($action=="showroom") { $bankaction = $scriptlang['bank']['bank_hall']; $userbanklixi=checklixi($userbank); $userbanklixi = empty($userbanklixi) ? $scriptlang['bank']['interest_clear'] : $userbanklixi; include template('bank:bank'); }elseif ($action=="bankinfo") { $bankaction= $scriptlang['bank']['acc_info']; $userbanklixi = checklixi($discuz_user) ? checklixi($discuz_user) : $scriptlang['bank']['interest_clear']; $cachetime = $banksettings['cachetime']*60; $bankcachetime = file_exists(DISCUZ_ROOT.'./data/cache/cache_bank.php') ? filemtime(DISCUZ_ROOT.'./data/cache/cache_bank.php') : '0'; $now = time(); if($now - $bankcachetime > $cachetime){ $totalbanklist = $totalmoneylist = $totalalllist =''; $query = DB::query("SELECT mc.uid, m.username, mc.$bankname FROM ".DB::table('common_member_count')." mc LEFT JOIN ".DB::table('common_member')." m ON mc.uid = m.uid ORDER BY mc.$bankname DESC Limit 22"); while($totalbank = DB::fetch($query)) { $totalbanklist .="

{$totalbank[$bankname]}".addslashes($totalbank['username'])."

"; } $query = DB::query("SELECT mc.uid, m.username, mc.$moneyname FROM ".DB::table('common_member_count')." mc LEFT JOIN ".DB::table('common_member')." m ON mc.uid = m.uid ORDER BY mc.$moneyname DESC Limit 22"); while($totalmoney = DB::fetch($query)) { $totalmoneylist .="

{$totalmoney[$moneyname]}".addslashes($totalmoney['username'])."

"; } $query = DB::query("SELECT mc.uid, m.username,(mc.$bankname+mc.$moneyname) as allmoney FROM ".DB::table('common_member_count')." mc LEFT JOIN ".DB::table('common_member')." m ON mc.uid = m.uid ORDER BY (mc.$bankname+mc.$moneyname) DESC Limit 22"); while($totalall = DB::fetch($query)) { $totalalllist .="

{$totalall['allmoney']}".addslashes($totalall['username'])."

"; } $dir = DISCUZ_ROOT.'./data/cache/'; $filename = 'cache_bank'; $newcachetime = time(); if($fp = @fopen("$dir$filename.php", 'wb')) { fwrite($fp, ""); fclose($fp); }else{ exit('Can not write to cache files, please check directory ./data/ and ./data/cache/ .'); } } @include DISCUZ_ROOT.'./data/cache/cache_bank.php'; $cacheupdate = gmdate("Y-n-j G:i", $newcachetime + $timeoffset * 3600); $nextupdate = gmdate("Y-n-j G:i", $newcachetime + $cachetime + $timeoffset * 3600); $userbanklixi = checklixi($discuz_user) ? checklixi($discuz_user) : $scriptlang['bank']['interest_clear']; clearstatcache(); include template('bank:bank'); } /*-清算利息---*/ function checklixi($userbank) { global $banksettings,$timestamp; $userbanklixi=0; $banktime = intval($userbank[savemt]); if ($banktime>0){ $presenttime=floor(($timestamp-$banktime)/86400); if ($presenttime>0){ $bankname="extcredits{$banksettings['bankid']}"; $userbanklixi=floor($userbank[$bankname]*$presenttime*$banksettings['accrual']); } } return $userbanklixi; } function upbankcache(){ global $bankname, $tablepre, $db; $allbankpeople = $allbankmoney = ''; $allbankpeople= DB::result_first("SELECT COUNT($bankname) AS banks FROM ".DB::table('common_member_count')." where $bankname>0"); $allbankmoney = DB::result_first("SELECT SUM($bankname) AS banks FROM ".DB::table('common_member_count').""); $dir = DISCUZ_ROOT.'./data/cache/'; $filename = 'cache_allbank'; if($fp = @fopen("$dir$filename.php", 'wb')) { fwrite($fp, ""); fclose($fp); } } ?>