<?php
/*============================*\
|| ###########################||
|| # vBulletin PHPFORCE增强包#||
|| # -------------------------||
|| # http://www.phpforce.cn  #||
|| ###########################||
\*============================*/

// #########################################
// 名称：银行文件 For 3.5
// 版本：2.0.0
// 时间：2006-1-14
// 作者：沙滩凉鞋
// 电邮：ceo@gameach.com
// #########################################
// ###############基本设置开始################
// 设置错误级别
error_reporting( E_ALL & ~E_NOTICE );
// 定义基本常量
define( 'THIS_SCRIPT', 'bank' );
// 预读必要模板
$phrasegroups = array(
	'bank',
	'postbit',
	'reputationlevel',
);
$globaltemplates = array( 'bank_index',
	'bank_rich',
	'bank_logoperates',
	'bank_log',
	);
// 预读指定模板
$actiontemplates = array();
// 调用必要文件
require_once( './global.php' );
// 是否开启银行
if (!$vbulletin->options['bank_onoff'])
{
	eval( standard_error( fetch_error( 'bank_disabled' ) ) );
}
// 是否有权访问
if ( !($permissions['hack_joey_permissions']& $vbulletin->bf_ugp_hack_joey_permissions['canenter']) )
{
	eval( standard_error( fetch_error( 'bank_cant_enter' ) ) );
}
// 设置默认动作
$vbulletin->input->clean_array_gpc( 'r', array( 'do' => TYPE_STR,
		's' => TYPE_STR,
		'money' => TYPE_UINT,
		'karma' => TYPE_UINT,
		'buy' => TYPE_BOOL,
		'user' => TYPE_STR,
		'type' => TYPE_UINT,
		'id' => TYPE_UINT,
		'page' => TYPE_UINT
		) );
// 设置默认动作
if ( empty( $vbulletin->GPC['do'] ) )
{
	$vbulletin->GPC['do'] = "index";
}
// 设置默认权限
$disallow['snl']=iif( $permissions['hack_joey_permissions']& $vbulletin->bf_ugp_hack_joey_permissions['cansaveandload'],FALSE,TRUE);
$disallow['remit']=iif( $permissions['hack_joey_permissions']& $vbulletin->bf_ugp_hack_joey_permissions['canremit'],FALSE,TRUE);
$disallow['exchange']=iif( $permissions['hack_joey_permissions']& $vbulletin->bf_ugp_hack_joey_permissions['canexchange'],FALSE,TRUE);
// ###############银行界面开始################
// 银行大厅
if ( $vbulletin->GPC['do'] == 'index' || $vbulletin->GPC['do'] == 'banklog')
{
	// 开始判断结息
	if ( $vbulletin->userinfo['savemt'] )
	{
		// 计算结息时间
		$days = floor( ( time() - $vbulletin->userinfo['savemt'] ) / 86400 );
		if ( $days >= 1 )
		{
			$user_accrual = floor( $vbulletin->userinfo['bank'] * $days * $vbulletin->options['bank_accrual'] );
			// 更新金钱信息
			$db->query_write( "
				UPDATE `" . TABLE_PREFIX . "user`
				SET `bank` = `bank` + " . $user_accrual . ",`savemt` = '" . time() . "'
				WHERE `userid` = '" . $vbulletin->userinfo['userid'] . "'
			" );
			// 写入日志信息
			$db->query_write( "
				INSERT INTO `" . TABLE_PREFIX . "bank_log` (`userid`,`operate`,`sum`,`logtime`,`note`)
				VALUES (" . $vbulletin->userinfo['userid'] . ",5," . $user_accrual . ",'" . time() . "','')
			" );
		}
	}
	// 处理结息时间
	if ( $vbulletin->userinfo['savemt'] )
	{
		$bank_accrual_time = vbdate( $vbulletin->options['dateformat'], $vbulletin->userinfo['savemt'], true );
	}
	else
	{
		$bank_accrual_time = $vbphrase['bank_no_info'];
	}
	// 获取银行信息
	$bank_info = $db->query_first( "
		SELECT COUNT(`bank`) AS `accounts`, SUM(`bank`) AS `asset`
		FROM `" . TABLE_PREFIX . "user`
		WHERE `bank`>0
	" );
	$bank_accounts = intval( $bank_info['accounts'] );
	$bank_asset = intval( $bank_info['asset'] );
	$bank_available = round( $vbulletin->userinfo['bank'] / (1+$vbulletin->options['bank_exchangepoundage']) );
	$bank_accrual = floatval( $vbulletin->options['bank_accrual'] * 100 ) . "%";
	$bank_poundage = floatval( $vbulletin->options['bank_poundage'] * 100 ) . "%";
	$bank_user_asset = intval( $vbulletin->userinfo['money']+$vbulletin->userinfo['bank'] );
	$bank_exchange_rate = floatval( $vbulletin->options['bank_exchangerate'] );
	$bank_exchange_limit = intval( $vbulletin->options['bank_exchangelimit'] );
	$bank_exchange_min = intval( $vbulletin->options['bank_exchangemin'] );
	$bank_exchange_poundage = floatval( $vbulletin->options['bank_exchangepoundage'] * 100 ) . "%";
	// 获取富翁排行
	$richlist = $db->query_read( "
		SELECT `userid`,`username`,`bank`
		FROM `" . TABLE_PREFIX . "user`
		WHERE `bank`>0
		ORDER BY `bank`
		DESC
		LIMIT 10
	" );
	while ( $rich = $db->fetch_array( $richlist ) )
	{
		eval( '$bank_rich .= "' . fetch_template( 'bank_rich' ) . '";' );
	}
	$operates = explode( "|", $vbphrase['bank_operates'] );
if ($vbulletin->GPC['do'] == 'banklog')
{
	if ($vbulletin->GPC['type'])
	{
		$tsql = 'AND operate = '.$vbulletin->GPC['type'];
	}
	$banklogs=true;
		// 获取操作日志
	$loglist = $db->query_read( "
		SELECT `operate`,`sum`,`logtime`,`note`
		FROM `" . TABLE_PREFIX . "bank_log`
		WHERE `userid` = '" . $vbulletin->userinfo['userid'] . "' $tsql
		ORDER BY `id`	DESC
		LIMIT ".(($vbulletin->GPC['page'] ? ($vbulletin->GPC['page']-1) : '0')*$vbulletin->options['bank_log_num']).", ".$vbulletin->options['bank_log_num']
	 );
    $logsum = $db->query_first("
		SELECT COUNT(id) AS sums
		FROM `" . TABLE_PREFIX . "bank_log`
		WHERE `userid` = '" . $vbulletin->userinfo['userid'] . "' $tsql
		ORDER BY `id`	DESC
    ");
	$pagenav = construct_page_nav(($vbulletin->GPC['page'] ? $vbulletin->GPC['page'] : '1'), $vbulletin->options['bank_log_num'], $logsum["sums"], 'bank.php?' . $session[sessionurl] . "&amp;do=banklog&amp;type=". $vbulletin->GPC['type']);
		foreach($operates as $x => $oname)
		{
			$oname = $oname!='&nbsp;' ? $oname : $vbphrase['bank_log_all'];
			eval( '$logoperates .= "' . fetch_template( 'bank_logoperates' ) . '";' );
		}
}
else
{
		// 获取操作日志
	$loglist = $db->query_read( "
		SELECT `operate`,`sum`,`logtime`,`note`
		FROM `" . TABLE_PREFIX . "bank_log`
		WHERE `userid` = '" . $vbulletin->userinfo['userid'] . "'
		ORDER BY `id`
		DESC
		LIMIT 10
	 ");
}
	if ( $db->num_rows( $loglist ) )
	{
		// 设置操作数组
		while ( $log = $db->fetch_array( $loglist ) )
		{
			$log['time'] = vbdate( $vbulletin->options['dateformat'], $log['logtime'], true ) . "&nbsp;" . vbdate( $vbulletin->options['timeformat'], $log['logtime'], true );
			$log['operate'] = $operates[$log[operate]];
			$log['sum'] = iif( $log['sum'] > 0, "+$log[sum]", $log['sum'] );
			eval( '$bank_log .= "' . fetch_template( 'bank_log' ) . '";' );
		}
	}
}
if ( $vbulletin->GPC['do'] == 'save' )
{
	// 处理基本数据
	if ( !($permissions['hack_joey_permissions']& $vbulletin->bf_ugp_hack_joey_permissions['cansaveandload']) )
	{
		eval( standard_error( fetch_error( 'bank_havent_permission' ) ) );
	}elseif ( empty( $vbulletin->GPC['money'] ) )
	{
		eval( standard_error( fetch_error( 'bank_null' ) ) );
	}elseif ( !ereg( '^[0-9]{1,10}$', $vbulletin->GPC['money'] ) )
	{
		eval( standard_error( fetch_error( 'bank_not_number' ) ) );
	}elseif ( $vbulletin->GPC['money'] < $vbulletin->options['bank_min'] )
	{
		eval( standard_error( fetch_error( 'bank_not_enough' ) ) );
	}elseif ( $vbulletin->GPC['money'] > $vbulletin->userinfo['money'] )
	{
		eval( standard_error( fetch_error( 'bank_too_much' ) ) );
	}
	else
	{
		// 更新金钱信息
		$db->query_write( "
			UPDATE `" . TABLE_PREFIX . "user`
			SET `money` = `money`-" . $vbulletin->GPC['money'] . ", `bank`=`bank`+" . $vbulletin->GPC['money'] . ", `savemt`='" . time() . "'
			WHERE `userid` = '" . $vbulletin->userinfo[userid] . "'
		" );
		// 写入日志信息
		$db->query_write( "
			INSERT INTO `" . TABLE_PREFIX . "bank_log` (`userid`,`operate`,`sum`,`logtime`,`note`)
			VALUES (" . $vbulletin->userinfo['userid'] . ",1," . $vbulletin->GPC['money'] . ",'" . time() . "','')
		" );
		// 设置转向地址
		$vbulletin->url = "bank.php?$session[sessionurl_q]do=index";
		eval( print_standard_redirect( 'bank_ok' ) );
	}
}
// 活期取款
if ( $vbulletin->GPC['do'] == 'load' )
{
	// 处理基本数据
	if ( !($permissions['hack_joey_permissions']& $vbulletin->bf_ugp_hack_joey_permissions['cansaveandload']) )
	{
		eval( standard_error( fetch_error( 'bank_havent_permission' ) ) );
	}elseif ( empty( $vbulletin->GPC['money'] ) )
	{
		eval( standard_error( fetch_error( 'bank_null' ) ) );
	}elseif ( !ereg( '^[0-9]{1,10}$', $vbulletin->GPC['money'] ) )
	{
		eval( standard_error( fetch_error( 'bank_not_number' ) ) );
	}elseif ( $vbulletin->GPC['money'] < $vbulletin->options['bank_min'] )
	{
		eval( standard_error( fetch_error( 'bank_not_enough' ) ) );
	}elseif ( $vbulletin->GPC['money'] > $vbulletin->userinfo['bank'] )
	{
		eval( standard_error( fetch_error( 'bank_too_much' ) ) );
	}
	else
	{
		// 更新金钱信息
		$db->query_write( "
			UPDATE `" . TABLE_PREFIX . "user`
			SET `money` = `money`+" . $vbulletin->GPC['money'] . ", `bank`=`bank`-" . $vbulletin->GPC['money'] . "
			WHERE `userid` = '" . $vbulletin->userinfo['userid'] . "'
		" );
		// 写入日志信息
		$db->query_write( "
			INSERT INTO `" . TABLE_PREFIX . "bank_log` (`userid`,`operate`,`sum`,`logtime`,`note`)
			VALUES (" . $vbulletin->userinfo['userid'] . ",2,-" . $vbulletin->GPC['money'] . ",'" . time() . "','')
		" );
		// 设置转向地址
		$vbulletin->url = "bank.php?$session[sessionurl_q]do=index";
		eval( print_standard_redirect( 'bank_ok' ) );
	}
}
// 转帐业务
if ( $vbulletin->GPC['do'] == 'remit' )
{
	// 处理基本数据
	$after_charge = round( $vbulletin->GPC['money'] * ( $vbulletin->options['bank_poundage'] + 1 ) );
	$charge = $after_charge - $vbulletin->GPC['money'];
	if ( !($permissions['hack_joey_permissions']& $vbulletin->bf_ugp_hack_joey_permissions['canremit']) )
	{
		eval( standard_error( fetch_error( 'bank_havent_permission' ) ) );
	}elseif ( empty( $vbulletin->GPC['money'] ) OR empty( $vbulletin->GPC['user'] ) )
	{
		eval( standard_error( fetch_error( 'bank_null' ) ) );
	}elseif ( !ereg( '^[0-9]{1,10}$', $vbulletin->GPC['money'] ) )
	{
		eval( standard_error( fetch_error( 'bank_not_number' ) ) );
	}elseif ( $vbulletin->GPC['money'] < $vbulletin->options['bank_min'] )
	{
		eval( standard_error( fetch_error( 'bank_not_enough' ) ) );
	}elseif ( $after_charge > $vbulletin->userinfo['bank'] )
	{
		eval( standard_error( fetch_error( 'bank_too_much' ) ) );
	}elseif ( $vbulletin->GPC['user'] == $vbulletin->userinfo['username'] )
	{
		eval( standard_error( fetch_error( 'bank_self' ) ) );
	}elseif ( !$aim_user = $db->query_first( "
		SELECT `userid`
		FROM `" . TABLE_PREFIX . "user`
		WHERE `username`='" . $vbulletin->GPC['user'] . "'
	" ) )
	{
		eval( standard_error( fetch_error( 'bank_user_error' ) ) );
	}
	else
	{
		// 更新金钱信息
		$db->query_write( "
			UPDATE `" . TABLE_PREFIX . "user`
			SET `bank`=`bank`-" . $after_charge. "
			WHERE `userid` = '" . $vbulletin->userinfo['userid'] . "'
		" );
		$db->query_write( "
			UPDATE `" . TABLE_PREFIX . "user`
			SET `bank`=`bank`+" . $vbulletin->GPC['money'] . "
			WHERE `userid` = '" . $aim_user['userid'] . "'
		" );
		// 写入日志信息
		$note = $db->escape_string("<a href=\"member.php?u=" . $vbulletin->userinfo['userid'] . "\">" . $vbulletin->userinfo['username'] . "</a>");
		$db->query_write( "
			INSERT INTO `" . TABLE_PREFIX . "bank_log` (`userid`,`operate`,`sum`,`logtime`,`note`)
			VALUES (" . $aim_user['userid'] . ",3," . $vbulletin->GPC['money'] . ",'" . time() . "', '".$note."')
		" );
		$note = $db->escape_string("<a href=\"member.php?u=" . $aim_user['userid'] . "\">" . $vbulletin->GPC['user'] . "</a>");
		$db->query_write( "
			INSERT INTO `" . TABLE_PREFIX . "bank_log` (`userid`,`operate`,`sum`,`logtime`,`note`)
			VALUES (" . $vbulletin->userinfo['userid'] . ",4,-" . $vbulletin->GPC['money'] . ",'" . time() . "','".$note."')
		" );
		$db->query_write( "
			INSERT INTO `" . TABLE_PREFIX . "bank_log` (`userid`,`operate`,`sum`,`logtime`,`note`)
			VALUES (" . $vbulletin->userinfo['userid'] . ",6,-" . $charge . ",'" . time() . "','" . $db->escape_string($vbphrase['bank_remit']) . "')
		" );
		// 自动发送短信
		if ( $vbulletin->options['bank_sendpm'] )
		{
			$pmdm = & datamanager_init( 'PM', $vbulletin, ERRTYPE_ARRAY );
			$pmdm->set( 'fromuserid', $vbulletin->userinfo['userid'] );
			$pmdm->set( 'fromusername', $vbulletin->userinfo['username'] );
			$pmdm->set( 'title', $vbphrase['bank_message_title'] );
			$pmdm->set( 'message', $vbphrase['bank_message_content'] );
			$pmdm->set_recipients( $vbulletin->GPC['user'], $vbulletin->userinfo['permissions'] );
			$pmdm->set( 'dateline', TIMENOW );
			if ( $pmdm->errors )
			{
				return $pmdm->errors;
			}
			$pmdm->save();
		}
		// 设置转向地址
		$vbulletin->url = "bank.php?$session[sessionurl_q]do=index";
		eval( print_standard_redirect( 'bank_ok' ) );
	}
}
// 金钱声望互换
if ( $vbulletin->GPC['do'] == 'exchange' )
{
	// 金钱换声望
	if ( $vbulletin->GPC['buy'] )
	{
		// 处理基本数据
		$money = round( $vbulletin->GPC['karma'] / $vbulletin->options['bank_exchangerate'] );
		$after_charge = round( $money * ( $vbulletin->options['bank_exchangepoundage'] + 1 ) );
		$charge = $after_charge - $money;
		if ( !($permissions['hack_joey_permissions']& $vbulletin->bf_ugp_hack_joey_permissions['canexchange']) )
		{
			eval( standard_error( fetch_error( 'bank_havent_permission' ) ) );
		}elseif ( $vbulletin->userinfo['reputation']<$vbulletin->options['bank_exchangelimit']  )
		{
			eval( standard_error( fetch_error( 'bank_karma_less_than' ) ) );
		}elseif ( empty( $vbulletin->GPC['karma'] ) )
		{
			eval( standard_error( fetch_error( 'bank_null' ) ) );
		}elseif ( !ereg( '^[0-9]{1,10}$', $vbulletin->GPC['karma'] ) )
		{
			eval( standard_error( fetch_error( 'bank_not_number' ) ) );
		}elseif ( $money < $vbulletin->options['bank_min'] )
		{
			eval( standard_error( fetch_error( 'bank_not_enough' ) ) );
		}elseif ( $vbulletin->GPC['karma'] < 1 )
		{
			eval( standard_error( fetch_error( 'bank_karma_not_enough' ) ) );
		}elseif ( $after_charge > $vbulletin->userinfo['bank'] )
		{
			eval( standard_error( fetch_error( 'bank_too_much' ) ) );
		}
		else
		{
			// 更新金钱信息
			$db->query_write( "
				UPDATE `" . TABLE_PREFIX . "user`
				SET `bank`=`bank`-" . $after_charge . ", `reputation`=`reputation`+" . $vbulletin->GPC['karma'] . "
				WHERE `userid` = '" . $vbulletin->userinfo['userid'] . "'
			" );
			// 写入日志信息
			$db->query_write( "
				INSERT INTO `" . TABLE_PREFIX . "bank_log` (`userid`,`operate`,`sum`,`logtime`,`note`)
				VALUES (" . $vbulletin->userinfo['userid'] . ",9,-" . $after_charge . ",'" . time() . "','+".$db->escape_string($vbulletin->GPC['karma'].$vbphrase['reputation'])."')
			" );
			$db->query_write( "
				INSERT INTO `" . TABLE_PREFIX . "bank_log` (`userid`,`operate`,`sum`,`logtime`,`note`)
				VALUES (" . $vbulletin->userinfo['userid'] . ",6,-" . $charge . ",'" . time() . "','" . $db->escape_string($vbphrase['bank_money2karma']) . "')
			" );
			// 设置转向地址
			$vbulletin->url = "bank.php?$session[sessionurl_q]do=index";
			eval( print_standard_redirect( 'bank_ok' ) );
		}
	}
	// 声望换金钱
	else
	{
		// 处理基本数据
		$money = round( $vbulletin->GPC['karma'] / $vbulletin->options['bank_exchangerate'] );
		$after_charge = round( $money * ( 1 - $vbulletin->options['bank_exchangepoundage'] ) );
		$charge = $money - $after_charge;
		if ( !($permissions['hack_joey_permissions']& $vbulletin->bf_ugp_hack_joey_permissions['canexchange']) )
		{
			eval( standard_error( fetch_error( 'bank_havent_permission' ) ) );
		}elseif ( $vbulletin->userinfo['reputation']<$vbulletin->options['bank_exchangelimit']  )
		{
			eval( standard_error( fetch_error( 'bank_karma_less_than' ) ) );
		}elseif ( empty( $vbulletin->GPC['karma'] ) )
		{
			eval( standard_error( fetch_error( 'bank_null' ) ) );
		}elseif ( !ereg( '^[0-9]{1,10}$', $vbulletin->GPC['karma'] ) )
		{
			eval( standard_error( fetch_error( 'bank_not_number' ) ) );
		}elseif ( $money < $vbulletin->options['bank_min'] )
		{
			eval( standard_error( fetch_error( 'bank_not_enough' ) ) );
		}elseif ( $vbulletin->GPC['karma'] < $vbulletin->options['bank_exchangemin'] )
		{
			eval( standard_error( fetch_error( 'bank_karma_less_than_std' ) ) );
		}elseif ( $vbulletin->GPC['karma'] > $vbulletin->userinfo['reputation'] )
		{
			eval( standard_error( fetch_error( 'bank_karma_more_than' ) ) );
		}
		else
		{
			// 更新金钱信息
			$db->query_write( "
				UPDATE `" . TABLE_PREFIX . "user`
				SET `bank`=`bank`+" . $after_charge . ", `reputation`=`reputation`-" . $vbulletin->GPC['karma'] . "
				WHERE `userid` = '" . $vbulletin->userinfo['userid'] . "'
			" );
			// 写入日志信息
			$db->query_write( "
				INSERT INTO `" . TABLE_PREFIX . "bank_log` (`userid`,`operate`,`sum`,`logtime`,`note`)
				VALUES (" . $vbulletin->userinfo['userid'] . ",10," . $after_charge . ",'" . time() . "','-".$db->escape_string($vbulletin->GPC['karma'].$vbphrase['reputation'])."')
			" );
			$db->query_write( "
				INSERT INTO `" . TABLE_PREFIX . "bank_log` (`userid`,`operate`,`sum`,`logtime`,`note`)
				VALUES (" . $vbulletin->userinfo['userid'] . ",6,-" . $charge . ",'" . time() . "','" . $db->escape_string($vbphrase['bank_karma2money']) . "')
			" );
			// 设置转向地址
			$vbulletin->url = "bank.php?$session[sessionurl_q]do=index";
			eval( print_standard_redirect( 'bank_ok' ) );
		}
	}
}
// VBZH - PHPForce - Joey奖励帖子 惩罚帖子
if ($_REQUEST['do'] == 'bank_rating')
{
	$vbulletin->input->clean_array_gpc( 'r', array(
		'id' => TYPE_UINT,
		'rating' => TYPE_UINT,
		'fine' => TYPE_UINT
		) );
	if (!($permissions['hack_joey_permissions'] & $vbulletin->bf_ugp_hack_joey_permissions['canpraiseandpunish']) AND !can_moderate($threadinfo['forumid'], 'canrateposters'))
	{
	eval( standard_error( fetch_error( 'bank_cant_rating' ) ) );
	}
	elseif ( empty( $vbulletin->GPC['id'] ) OR !ereg( '^[0-9]{1,10}$', $vbulletin->GPC['id'] ) OR !$postinfo = verify_id( 'post', $vbulletin->GPC['id'], 1, 1 ) )
	{
		eval(standard_error(  fetch_error( 'bank_post_id_error')));
	}elseif ( ($postinfo['userid'] == $vbulletin->userinfo['userid']) AND !$vbulletin->options['bank_ratingself'] )
	{
	eval( standard_error( fetch_error( 'bank_self' ) ) );
	}
	else
	{
		$threadinfo = verify_id( 'thread', $postinfo['threadid'], 1, 1 );
		if (!( $permissions['hack_joey_permissions'] & $vbulletin->bf_ugp_hack_joey_permissions['canpraiseandpunish']) AND !can_moderate($threadinfo['forumid'], 'canrateposters'))
		{
			eval( standard_error( fetch_error( 'bank_cant_rating' ) ) );
		}
		// 检查24小时内奖励惩罚次数
		if ( $vbulletin->options['bank_ratingnum'] && !($permissions['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']))
		{
			$timecut = TIMENOW - 86400;
			$ratingsql = $db->query_first( "
				SELECT COUNT(*) AS count
				FROM `" . TABLE_PREFIX . "rating`
				WHERE `fromuserid`=" . $vbulletin->userinfo['userid'] . " AND `dateline` >= " . $timecut . "
			" );
			if ( $ratingsql['count'] >= $vbulletin->options['bank_ratingnum'] )
			{
				eval( standard_error( fetch_error( 'bank_no_change' ) ) );
			}
		}
		if (!$vbulletin->GPC['rating'])
			{
				$vbulletin->GPC['rating']=0;
			}
		if ($vbulletin->GPC['fine']==1)
			{
				$bounty2=explode(',', $vbulletin->options['bank_fine']);
				$money = $bounty2[$vbulletin->GPC['rating']] * -1;
			}
		else
			{
				$bounty=explode(',', $vbulletin->options['bank_bounty']);
				$money = $bounty[$vbulletin->GPC['rating']];
			}

		// 更新金钱信息
		$db->query_write( "
			UPDATE `" . TABLE_PREFIX . "user`
			SET `money` = `money`+$money
			WHERE `userid` = '".$postinfo['userid']."'
		" );
		$db->query_write( "
			UPDATE `" . TABLE_PREFIX . "post`
			SET `bonus` = `bonus`+$money
			WHERE `postid` = '".$postinfo['postid']."'
		" );
		$db->query_write( "
			INSERT INTO `" . TABLE_PREFIX . "rating` (`rating`, `fromuserid`, `touserid`, `topostid`, `dateline`)
			VALUES ('".$money."',".$vbulletin->userinfo['userid'].",".$postinfo['userid'].",".$postinfo['postid'].",".time().")
		" );
		// 将贴子的奖惩记录增加到银行日记
		$db->query_write("INSERT INTO " . TABLE_PREFIX . "bank_log (userid,operate,sum,logtime,note) VALUES (".$postinfo['userid'].",'" . iif($money>0,7,8) . "','" . $money . "','" . time() . "','".$vbphrase['post'].":<a href=\"showpost.php?p=" . $postinfo['postid'] . "\">" . $postinfo['title'] . "</a><br />by <a href=\"member.php?u=" . $vbulletin->userinfo['userid'] . "\">" . $vbulletin->userinfo['username'] . "</a>')");

		$vbulletin->url = "showthread.php?" . $vbulletin->session->vars['sessionurl'] . "p=".$postinfo['postid']."#post".$postinfo['postid'];
		eval( print_standard_redirect( 'bank_ok' ) );
	}
}

// ###############生成模板开始################
$navbits = array();
$navbits["bank.php?do=index"] = $vbphrase['bank'];
$navbits[''] = $vbphrase['bank'];
$navbits = construct_navbits( $navbits );
eval( '$navbar = "' . fetch_template( 'navbar' ) . '";' );
eval( 'print_output("' . fetch_template( 'bank_index' ) . '");' );

/*========================================*\
|| ########################################
|| ########################################
\*========================================*/
?>
