<?php
define('THIS_SCRIPT', 'bank');
require_once 'global.php';
$dv_bopt   = isset($_GET['dv_bopt'])?intval($_GET['dv_bopt']):(isset($_POST['dv_bopt'])?intval($_POST['dv_bopt']):1);

$_thisfile = 'bank.php';
$lang = load_lang($lang, 'bank' );

!isset($userinfo['userid']) AND header("location:./index.php") AND exit;

$dv_bogj = new dv_bank();
$dv_bogj->dv_bopt = $dv_bopt;

$stats = $lang['hometitle'];
$arrNavMenu = array(0=>array('linktitle'=>$lang['tpl.bank.str1'],'linkurl'=>$_thisfile),1=>array('linktitle'=>$stats));

head(1,0,0,$arrNavMenu);
PageLoad();
footer();
class dv_bank{
	var $dv_status;//当前状态,0没有开户，1正常使用，2关闭
	var $dv_bmanages;
	var $dv_bopt;
	var $dv_vars;
	var $dv_trasvar;
	var $dv_money;
	var $dv_allmoney;
	var $dv_tem;
	var $dv_loanmoney;
	var $dv_enddate;
	var $dv_begdatetime;
	var $dv_updatetime;
	var $CurrentPage;
	var $Pcount;
	var $totalrec;
	var $PageNum;
	var $dv_ucount;
	var $dv_bnews;
	var $dv_temanagers;
	function dv_bank(){
		require_once('./bank_inc.php');
		$this->dv_bmanages = $idv_bmanages;
		$this->dv_temanagers = $idv_bmanages;
		$this->dv_bnews = $idv_news;
		$this->dv_trasvar = $idv_trasvar;
		$this->dv_getsta();
	}
	function dv_getsta(){
		global $db,$lang,$userinfo,$dv;
		$stmt = "SELECT username,bankstatus,bankpass,money,loanmoney,enddate,begdatetime,updatetime FROM {$dv}bankstatus WHERE userid=".$userinfo['userid']." and bankstatus=1 limit 1";
		if( $query = $db->query($stmt) ){
			$dv_num = $db->num_rows($query);
			$this->dv_status = $dv_num>0?1:0;	
			if(1==$this->dv_status){
				$row = $db->fetch_array($query);
				$this->dv_money = round(floatval($row['money']),3);
				$this->dv_loanmoney = round(floatval($row['loanmoney']),3);
				$this->dv_enddate = $row['enddate'];
				$this->dv_begdatetime = $row['begdatetime'];
				$this->dv_updatetime = $row['updatetime'];
				if(time()-strtotime($this->dv_updatetime)>86400){
					$this->dv_money = $this->dv_money + $this->dv_money * $this->dv_trasvar['lixi1'] * intval( ( time() - strtotime($this->dv_updatetime) ) / 86400);
					$db->query("update {$dv}bankstatus set money=$this->dv_money,updatetime=now() WHERE userid=".$userinfo['userid']."");
				}
				$mv_bmanages = $db->scalar("SELECT plus_setting  as money FROM {$dv}plus where plus_id='dv_bank' limit 1");
				$mv_bmanages = explode('|',$mv_bmanages);
				$mv_bmanages = $mv_bmanages[12];
				$mv_bmanages = explode(',',$mv_bmanages);
				$mv_bmanages = $mv_bmanages[2];
				if( !empty($this->dv_bmanages) && $mv_bmanages !='0' ){
					$this->dv_bmanages .= ','.$mv_bmanages;
				}else{
					$this->dv_bmanages = $mv_bmanages;
				}
				$this->dv_allmoney = round(floatval($db->scalar("SELECT sum(money) as money FROM {$dv}bankstatus")),2);
			}	
		} else{
			$this->dv_status = 0;
		}
		$this->dv_ucount = $db->scalar("SELECT count(1) FROM {$dv}bankstatus");
		!$this->dv_money AND $this->dv_money = 0;
	}
	function dv_openbank(){
		global $db,$lang,$userinfo,$dv,$_thisfile;
		$isstor = $db->scalar("SELECT count(1) FROM {$dv}bankstatus where userid=".$userinfo['userid']."");
		if(0 == $this->dv_status && 0 == $isstor){
			$stmt = "insert into {$dv}bankstatus set updatetime=now(),begdatetime=now(),userid=".$userinfo['userid'].",username='".$userinfo['username']."',bankstatus=1,bankpass='".md5('888888')."'";
			if( $query = $db->query($stmt) ){
				$this->dv_status = 1;
				$db->query("insert into {$dv}banklog set userid=".$userinfo['userid'].",username='".$userinfo['username']."',acttime=now(),action='".$lang['tpl.bank.str74']."'");
				showmsg($lang['tpl.bank.str97'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
			} else{
				$this->dv_status = 0;
			}
		}else{
			$stmt = "update {$dv}bankstatus set bankstatus=1 where userid=".$userinfo['userid']."";
			if( $query = $db->query($stmt) ){
				$this->dv_status = 1;
			} else{
				$this->dv_status = 0;
			}
		}
	}
	function dv_savemoney($mv_money){
		global $db,$lang,$userinfo,$dv, $_thisfile;
		if(!is_numeric($mv_money)){
			showmsg($lang['tpl.bank.str46'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}
		if( $mv_money <= 0 ) {
			showmsg($lang['tpl.bank.str60'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}
		if(floatval($mv_money)>floatval($userinfo['usermoney'])){
			showmsg($lang['tpl.bank.str47'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}
		
		if(1 == $this->dv_status){
			$stmt = "update {$dv}bankstatus set money=money+$mv_money where userid=".$userinfo['userid']."";
			$db->query($stmt);
			$stmt = "update {$dv}user set usermoney=usermoney-$mv_money where userid=".$userinfo['userid']."";
			$db->query($stmt);
			$db->query("insert into {$dv}banklog set userid=".$userinfo['userid'].",username='".$userinfo['username']."',acttime=now(),action='".$lang['tpl.bank.str8']."'");
			showmsg($lang['tpl.bank.str48'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}else{
			
		}
	
	}
	function dv_getmoney($mv_money){
		global $db,$lang,$userinfo,$dv, $_thisfile;
		if(!is_numeric($mv_money)){
			showmsg($lang['tpl.bank.str46'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}
		if( $mv_money <= 0 ) {
			showmsg($lang['tpl.bank.str60'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}
		if(floatval($mv_money)>floatval($this->dv_money)){
			showmsg($lang['tpl.bank.str49'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}
		
		if(1 == $this->dv_status){
			$stmt = "update {$dv}bankstatus set money=money-$mv_money where userid=".$userinfo['userid']."";
			$db->query($stmt);
			$stmt = "update {$dv}user set usermoney=usermoney+$mv_money where userid=".$userinfo['userid']."";
			$db->query($stmt);
			$db->query("insert into {$dv}banklog set userid=".$userinfo['userid'].",username='".$userinfo['username']."',acttime=now(),action='".$lang['tpl.bank.str9']."'");
			showmsg($lang['tpl.bank.str50'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}else{
			
		}
	
	}	
	function dv_trasmoney($mv_money,$mv_opt){
		global $db,$lang,$userinfo,$dv, $_thisfile;
		if(!is_numeric($mv_money)){
			showmsg($lang['tpl.bank.str46'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
			
		}
		if( floatval($mv_money)<= 0  ) {
			showmsg($lang['tpl.bank.str60'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}
		if(1 == intval($mv_opt) && floatval($mv_money)>floatval($userinfo['userep'])){
			showmsg($lang['tpl.bank.str52'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
			
		}elseif(2 == intval($mv_opt) && floatval($mv_money)>floatval($userinfo['usercp'])){
			showmsg($lang['tpl.bank.str52'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
			
		}if(3 == intval($mv_opt) && floatval($mv_money)>floatval($userinfo['userticket'])){
			showmsg($lang['tpl.bank.str52'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
			
		}
			
		if(1 == $this->dv_status){
			if( 1 == intval($mv_opt)){
				$this->dv_tem = floatval($mv_money / floatval($this->dv_trasvar['eptomony']));
				$stmt = "update {$dv}user set userep=userep-$mv_money where userid=".$userinfo['userid']."";
				$db->query($stmt);
			}elseif( 2 == intval($mv_opt)){
				$this->dv_tem = floatval($mv_money / floatval($this->dv_trasvar['cptomony']));
				$stmt = "update {$dv}user set usercp=usercp-$mv_money where userid=".$userinfo['userid']."";
				$db->query($stmt);
			}if( 3 == intval($mv_opt)){
				$this->dv_tem = floatval($mv_money / floatval($this->dv_trasvar['tickettomony']));
				$stmt = "update {$dv}user set userticket=userticket-$mv_money where userid=".$userinfo['userid']."";
				$db->query($stmt);
			}
		
			$stmt = "update {$dv}bankstatus set money=money+$this->dv_tem where userid=".$userinfo['userid']."";
			$db->query($stmt);
			$db->query("insert into {$dv}banklog set userid=".$userinfo['userid'].",username='".$userinfo['username']."',acttime=now(),action='".$lang['tpl.bank.str39']."'");
			showmsg($lang['tpl.bank.str51'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}else{
			
		}
	
	}	
	function dv_trasmoney2u($mv_money,$mv_username){
		global $db,$lang,$userinfo,$dv, $_thisfile;
		if(!is_numeric($mv_money)){
			showmsg($lang['tpl.bank.str46'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
			
		}
		if( $mv_money <= 0 ) {
			showmsg($lang['tpl.bank.str60'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}
		if(floatval($mv_money)>floatval($this->dv_money)){
			showmsg($lang['tpl.bank.str56'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}
		if(!$db->scalar("SELECT id FROM {$dv}bankstatus WHERE username='$mv_username' limit 1")){
			showmsg($lang['tpl.bank.str55'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}
			
		if(1 == $this->dv_status){
			$stmt = "update {$dv}bankstatus set money=money-$mv_money where userid=".$userinfo['userid']."";
			$db->query($stmt);
			$stmt = "update {$dv}bankstatus set money=money+$mv_money where username='$mv_username'";
			$db->query($stmt);
			$db->query("insert into {$dv}banklog set userid=".$userinfo['userid'].",username='".$userinfo['username']."',acttime=now(),action='".$lang['tpl.bank.str10']."'");
			showmsg($lang['tpl.bank.str57'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}else{
			
		}
	
	}	
	function dv_loan2umoney($mv_money,$mv_enddate){
		global $db,$lang,$userinfo,$dv, $_thisfile;
		if(!is_numeric($mv_money)||!is_numeric($mv_enddate)){
			showmsg($lang['tpl.bank.str46'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
			
		}
		if( $mv_money <= 0 ) {
			showmsg($lang['tpl.bank.str60'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}	
		if( floatval($this->dv_loanmoney) > 0 ){
			showmsg($lang['tpl.bank.str65'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}
		$dv_frmlevl = $userinfo['userep']/$this->dv_trasvar['eptomony']+$userinfo['usercp']/$this->dv_trasvar['cptomony']+$userinfo['userticket']/$this->dv_trasvar['tickettomony']+$this->dv_money-$this->dv_loanmoney;
		if(floatval($mv_money)>floatval($dv_frmlevl)){
			showmsg($lang['tpl.bank.str59'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}
		if(!in_array($mv_enddate,array('7','15','30','180'))){
			showmsg($lang['tpl.bank.str60'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}
		if(1 == $this->dv_status){
			$stmt = "update {$dv}bankstatus set money=money+$mv_money,loanmoney=loanmoney+$mv_money,enddate=$mv_enddate where userid=".$userinfo['userid']."";
			$db->query($stmt);
			$db->query("insert into {$dv}banklog set userid=".$userinfo['userid'].",username='".$userinfo['username']."',acttime=now(),action='".$lang['tpl.bank.str75']."'");
			showmsg($lang['tpl.bank.str61'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}else{
			
		}
	
	}	
	function dv_loanbumoney($mv_money){
		global $db,$lang,$userinfo,$dv, $_thisfile;
		if(!is_numeric($mv_money)){
			showmsg($lang['tpl.bank.str46'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
			
		}
		if( $mv_money <= 0 ) {
			showmsg($lang['tpl.bank.str60'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}
		if( $mv_money > floatval($this->dv_loanmoney) ) {
			showmsg($lang['tpl.bank.str62'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}
		if(!in_array($this->dv_enddate,array('7','15','30','180'))){
			showmsg($lang['tpl.bank.str60'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}
		$backmoney = $this->dv_loanmoney*(1+$this->dv_trasvar['lixi'.$this->dv_enddate]);
		if( $backmoney > floatval($this->dv_money) ) {
			showmsg($lang['tpl.bank.str63'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}
		if(1 == $this->dv_status){
			$loanmoney = $this->dv_loanmoney - $mv_money < 0 ? 0: $mv_money;
			$stmt = "update {$dv}bankstatus set money=money-$backmoney,loanmoney=loanmoney-$mv_money where userid=".$userinfo['userid']."";
			$db->query($stmt);
			$db->query("insert into {$dv}banklog set userid=".$userinfo['userid'].",username='".$userinfo['username']."',acttime=now(),action='".$lang['tpl.bank.str76']."'");
			showmsg($lang['tpl.bank.str64'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
		}else{
			
		}
	
	}	
	function getfhlist(){
		global $db,$lang,$userinfo,$dv, $_thisfile;
	    $dbResults = '';
	    $query = $db->query("select * from {$dv}bankstatus order by money desc limit 30");
		while( $result = $db->fetch_array($query) ){
			$dbResults[] = $result;
		}
		$db->free_result($query);
		return $dbResults;
	}
	function getlolist(){
		global $db,$lang,$userinfo,$dv, $_thisfile,$fsetting;
	    $dbResults = '';$where = '';
		$fv_bmangers = explode(",",$this->dv_bmanages);
		$PageListNum = $this->dv_trasvar['pagesize'];
		$this->CurrentPage = empty($GLOBALS['page']) ? 1 : intval($GLOBALS['page']);
		if(!in_array($userinfo['username'],$fv_bmangers)){
			$where = " where username='".$userinfo['username']."'";
		}
		
		$stmt = "select * from {$dv}banklog $where order by acttime,username desc";
		$scalar = $db->scalar("SELECT COUNT(1) FROM {$dv}banklog $where");
		
		$this->totalrec = ( $scalar !== null ? intval($scalar) : 0 );
		$dbResults = array();
		if( $query = $db->query($stmt,array('absolutePage'=>$this->CurrentPage,'pageSize'=>$PageListNum)) ){
			$page_count = 0;
			while( $result = $db->fetch_array($query) ){
				$page_count++;
				$dbResults[] = $result;
			}
			$db->free_result($query);
		}
		$this->PageNum = $PageListNum;
		$this->Pcount = ceil((float)$this->totalrec / (float)$PageListNum);
		if( $page_count == 0 ) $this->currentpage = 0;
		return $dbResults;
	}
	function dv_updateopt(){
		global $db,$lang,$userinfo,$dv, $_thisfile,$fsetting;
		$mv_var0 = intval(func_get_arg(0));
		if( 1 == $mv_var0 ){
			$mv_newsc = func_get_arg(1);
			$mv_newsc = str_replace("'","",$mv_newsc);
			$mv_newsc = str_replace("\r\n","<br />",$mv_newsc);			
		}elseif( 2 == $mv_var0 ){
			$mv_eptomony = trim(func_get_arg(1));
			$mv_eptomony = str_replace("'","",$mv_eptomony);
			$mv_cptomony = trim(func_get_arg(2));	
			$mv_cptomony = str_replace("'","",$mv_cptomony);
			$mv_tickettomony = trim(func_get_arg(3));
			$mv_tickettomony = str_replace("'","",$mv_tickettomony);
			
			$mv_lixi1 = trim(func_get_arg(4));
			$mv_lixi1 = str_replace("'","",$mv_lixi1);
			$mv_lixi7 = trim(func_get_arg(5));
			$mv_lixi7 = str_replace("'","",$mv_lixi7);
			$mv_lixi15 = trim(func_get_arg(6));
			$mv_lixi15 = str_replace("'","",$mv_lixi15);
			$mv_lixi30 = trim(func_get_arg(7));
			$mv_lixi30 = str_replace("'","",$mv_lixi30);
			$mv_lixi180 = trim(func_get_arg(8));
			$mv_lixi180 = str_replace("'","",$mv_lixi180);
			$mv_msg1money = trim(func_get_arg(9));
			$mv_msg1money = str_replace("'","",$mv_msg1money);
			$mv_news1money = trim(func_get_arg(10));
			$mv_news1money = str_replace("'","",$mv_news1money);
			
			if(!is_numeric($mv_eptomony)
			 || !is_numeric($mv_cptomony)
			 || !is_numeric($mv_tickettomony)
			 || !is_numeric($mv_lixi1)
			 || !is_numeric($mv_lixi7)
			 || !is_numeric($mv_lixi15)
			 || !is_numeric($mv_lixi30)
			 || !is_numeric($mv_lixi180)
			 || !is_numeric($mv_msg1money)
			 || !is_numeric($mv_news1money)
				  )
			{
				showmsg($lang['tpl.bank.str46'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
			}
		}else if( 3 == $mv_var0 ){
			$mv_admins = htmlentities(func_get_arg(1));
		}else if( 4 == $mv_var0 ){
			$mv_deldays = trim(func_get_arg(1));
			$mv_deltype = trim(func_get_arg(2));
			$mv_deldays = str_replace("'","",$mv_deldays);
			$mv_deltype = str_replace("'","",$mv_deltype);
			$mv_optarray = array($lang['tpl.bank.str74'],$lang['tpl.bank.str8'],$lang['tpl.bank.str9'],$lang['tpl.bank.str10'],$lang['tpl.bank.str39'],$lang['tpl.bank.str96'],'0');
			
			!in_array($mv_deltype,$mv_optarray) AND showmsg($lang['tpl.bank.str60'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;			
			(!is_numeric($mv_deldays) || $mv_deldays <= 0) AND showmsg($lang['tpl.bank.str46'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
			$mv_admins = explode(",",$this->dv_bmanages);
			if(in_array($userinfo['username'],$mv_admins)){
				$where  = "where TO_DAYS(now())-TO_DAYS(acttime) > $mv_deldays ";
				$where .= $mv_deltype=='0'?'':" and  action='$mv_deltype' ";
				$db->query("delete from {$dv}banklog $where");
				showmsg($lang['tpl.bank.str100'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
			}else{
				showmsg($lang['tpl.bank.str101'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
			}
			exit;
		}else if( 5 == $mv_var0 ){
			$isopengmoney = $this->dv_trasvar['isopengmoney']=='1'?'0':'1';
		}
		
		$mv_confile = './bank_inc.php';
		$fp = fopen($mv_confile, 'r');
		$configfile = fread($fp, filesize($mv_confile));
		fclose($fp);
		
		isset($mv_tickettomony) AND $configfile = preg_replace("/'tickettomony'\s*\=>.*?,/is", "'tickettomony'=>'".$mv_tickettomony."',", $configfile);
		isset($mv_tickettomony) AND $mv_tickettomony <= 0  AND showmsg($lang['tpl.bank.str60'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;

		isset($mv_cptomony) AND $configfile = preg_replace("/'cptomony'\s*\=>.*?,/is", "'cptomony'=>'".$mv_cptomony."',", $configfile);
		isset($mv_cptomony) AND $mv_cptomony <= 0  AND showmsg($lang['tpl.bank.str60'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;

		isset($mv_eptomony) AND $configfile = preg_replace("/'eptomony'\s*\=>.*?,/is", "'eptomony'=>'".$mv_eptomony."',", $configfile);
		isset($mv_eptomony) AND $mv_eptomony <= 0  AND showmsg($lang['tpl.bank.str60'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;

		isset($mv_lixi1) AND $configfile = preg_replace("/'lixi1'\s*\=>.*?,/is", "'lixi1'=>'".$mv_lixi1."',", $configfile);
		isset($mv_lixi1) AND $mv_lixi1 <= 0  AND showmsg($lang['tpl.bank.str60'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;

		isset($mv_lixi7) AND $configfile = preg_replace("/'lixi7'\s*\=>.*?,/is", "'lixi7'=>'".$mv_lixi7."',", $configfile);
		isset($mv_lixi7) AND $mv_lixi7 <= 0  AND showmsg($lang['tpl.bank.str60'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;

		isset($mv_lixi15) AND $configfile = preg_replace("/'lixi15'\s*\=>.*?,/is", "'lixi15'=>'".$mv_lixi15."',", $configfile);
		isset($mv_lixi15) AND $mv_lixi15 <= 0  AND showmsg($lang['tpl.bank.str60'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;

		isset($mv_lixi30) AND $configfile = preg_replace("/'lixi30'\s*\=>.*?,/is", "'lixi30'=>'".$mv_lixi30."',", $configfile);
		isset($mv_lixi30) AND $mv_lixi30 <= 0  AND showmsg($lang['tpl.bank.str60'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;

		isset($mv_lixi180) AND $configfile = preg_replace("/'lixi180'\s*\=>.*?,/is", "'lixi180'=>'".$mv_lixi180."',", $configfile);
		isset($mv_lixi180) AND $mv_lixi180 <= 0  AND showmsg($lang['tpl.bank.str60'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;

		isset($mv_msg1money) AND $configfile = preg_replace("/'msg1money'\s*\=>.*?,/is", "'msg1money'=>'".$mv_msg1money."',", $configfile);
		isset($mv_msg1money) AND $mv_msg1money <= 0  AND showmsg($lang['tpl.bank.str60'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;

		isset($mv_news1money) AND $configfile = preg_replace("/'news1money'\s*\=>.*?,/is", "'news1money'=>'".$mv_news1money."',", $configfile);
		isset($mv_news1money) AND $mv_news1money <= 0  AND showmsg($lang['tpl.bank.str60'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;

		isset($mv_newsc) AND $configfile = preg_replace("/[$]idv_news\s*\=\s*[\"'].*?[\"']/is", "\$idv_news='".$mv_newsc."'", $configfile);
		isset($mv_admins) AND $configfile = preg_replace("/[$]idv_bmanages\s*\=\s*[\"'].*?[\"']/is", "\$idv_bmanages='".$mv_admins."'", $configfile);

		isset($isopengmoney) AND $configfile = preg_replace("/'isopengmoney'\s*\=>.*?,/is", "'isopengmoney'=>'".$isopengmoney."',", $configfile);

		$fp = fopen($mv_confile, 'w') or die("$mv_confile 文件没有写的权限");
		fwrite($fp, trim($configfile));
		fclose($fp);		
		$db->query("insert into {$dv}banklog set userid=".$userinfo['userid'].",username='".$userinfo['username']."',acttime=now(),action='".$lang['tpl.bank.str96']."'");
		showmsg($lang['tpl.bank.str95'],0,$_thisfile.'?dv_bopt='.$this->dv_bopt) AND exit;
	}
}


function PageLoad(){
	global $userid,$lang,$db;
	if( intval($userid) == 0 ){
		showmsg($lang['MustLogin']);
		exit;
	} else{
		MainFunc();
	}
}//end function PageLoad
function MainFunc(){
	global $db,$boardid,$fsetting,$lang,$userinfo,$_DCACHE,$boardmaster,$master,$_thisfile,$dv_bogj,$_POST;
	if ( true || count($_forum) > 1 ){
		$TableWidth =& $_DCACHE['stylecss'][1];
		$color =& $_DCACHE['stylecss'][19];
		$user_Article =& $userinfo['userpost'];
		$user_Group =& $userinfo['userclass'];
		$user_Face = $UserFace;
		$user_Title =& $userinfo['usertitle'];
		$user_Wealth =& $userinfo['userwealth'];
		$user_EP =& $userinfo['userep'];
		$user_CP =& $userinfo['usercp'];
		$user_Money =& $userinfo['usermoney'];
		$user_Ticket =& $userinfo['userticket'];
		$user_IsBest =& $userinfo['userisbest'];
		$user_AddDate =& $userinfo['joindate'];
		$user_Logins =& $userinfo['userlogins'];
		$username =& $userinfo['username'];
		$msg_newincept = intval($userinfo['uermsg']);
		if( $forumChanSetting[13] == 1 && $forumChanSetting[0] == 1 ){
			$UserTicket = "<BR>{$lang['Dvbbs.lanstr11']}";
		} else{
			$UserTicket = '';
		}
		if(isset($_POST['dv_action1'])&&isset($_POST['dv_input1'])){
			$dv_bogj->dv_savemoney($_POST['dv_input1']);
		}elseif(isset($_POST['dv_action2'])&&isset($_POST['dv_input2'])){
			$dv_bogj->dv_getmoney($_POST['dv_input2']);
		}elseif(isset($_POST['dv_action3'])&&isset($_POST['dv_input31'])){
			$dv_bogj->dv_trasmoney($_POST['dv_input31'],1);
		}elseif(isset($_POST['dv_action4'])&&isset($_POST['dv_input41'])){
			$dv_bogj->dv_trasmoney($_POST['dv_input41'],2);
		}elseif(isset($_POST['dv_action5'])&&isset($_POST['dv_input51'])){
			$dv_bogj->dv_trasmoney($_POST['dv_input51'],3);
		}elseif(isset($_POST['dv_action6'])&&isset($_POST['dv_input61'])&&isset($_POST['dv_input62'])){
			$dv_bogj->dv_trasmoney2u($_POST['dv_input61'],$_POST['dv_input62']);
		}elseif(isset($_POST['dv_action7'])&&isset($_POST['dv_input71'])&&isset($_POST['dv_input72'])){
			$dv_bogj->dv_loan2umoney($_POST['dv_input71'],$_POST['dv_input72']);
		}elseif(isset($_POST['dv_action8'])&&isset($_POST['dv_input81'])){
			$dv_bogj->dv_loanbumoney($_POST['dv_input81']);
		}elseif(isset($_POST['dv_action9'])&&isset($_POST['dv_input9'])){
			$dv_bogj->dv_updateopt(1, $_POST['dv_input9']);
		}elseif(isset($_POST['dv_action10'])&&( isset($_POST['dv_input101']) ||isset($_POST['dv_input102']) || isset($_POST['dv_input103']) || isset($_POST['dv_input104']) || isset($_POST['dv_input105']) || isset($_POST['dv_input106']) || isset($_POST['dv_input107']) || isset($_POST['dv_input108']) || isset($_POST['dv_input109']) || isset($_POST['dv_input1010']) )){
			$dv_bogj->dv_updateopt(2, $_POST['dv_input101'],$_POST['dv_input102'],$_POST['dv_input103'],$_POST['dv_input104'],$_POST['dv_input105'],$_POST['dv_input106'],$_POST['dv_input107'],$_POST['dv_input108'],$_POST['dv_input109'],$_POST['dv_input1010']);
		}elseif(isset($_POST['dv_action11'])&&isset($_POST['dv_input11'])){
			$dv_bogj->dv_updateopt(3, $_POST['dv_input11']);
		}elseif(isset($_POST['dv_action12'])&&isset($_POST['dv_input1201'])&&isset($_POST['dv_input1202'])){
			$dv_bogj->dv_updateopt(4, $_POST['dv_input1201'], $_POST['dv_input1202']);
		}elseif(isset($_POST['dv_action72'])){
			$dv_bogj->dv_updateopt(5);
		}
		
		$dv_bogj->dv_vars['statutext'] = 0==$dv_bogj->dv_status?$lang['tpl.bank.str20']:$lang['tpl.bank.str21'];
		$lang['tpl.bank.str27'] = str_replace('{$_thisfile}',$_thisfile,$lang['tpl.bank.str27']);
		//行长列表
		$lang['tpl.bank.str29'] = str_replace('{$dv_bmanages}',$dv_bogj->dv_bmanages,$lang['tpl.bank.str29']);
		$lang['tpl.bank.str40'] = 22==$dv_bogj->dv_bopt?$lang['tpl.bank.str41']:(23==$dv_bogj->dv_bopt?$lang['tpl.bank.str42']:(24==$dv_bogj->dv_bopt?$lang['tpl.bank.str44']:(25==$dv_bogj->dv_bopt?$lang['tpl.bank.str58']:$lang['tpl.bank.str40'])));
		
		//关闭社区
		$dv_bogj->dv_status==2 AND showmsg($lang['tpl.bank.str32'],0,$_thisfile.'?dv_bopt=1') AND exit;
		//用户发出开启操作
		if(0 == $dv_bogj->dv_bopt){
			$dv_bogj->dv_openbank();
			$dv_bogj->dv_status==0 AND showmsg($lang['tpl.bank.str31'],0,$_thisfile.'?dv_bopt=1') AND exit;
		}elseif(1 == $dv_bogj->dv_bopt){
		}elseif(2 == $dv_bogj->dv_bopt || 21 == $dv_bogj->dv_bopt || 22 == $dv_bogj->dv_bopt || 23 == $dv_bogj->dv_bopt || 24 == $dv_bogj->dv_bopt || 25 == $dv_bogj->dv_bopt){
			$dv_bogj->dv_status==0 AND showmsg($lang['tpl.bank.str31'],0,$_thisfile.'?dv_bopt=1') AND exit;
			25 == $dv_bogj->dv_bopt AND '0'==$dv_bogj->dv_trasvar['isopengmoney'] AND showmsg($lang['tpl.bank.str103'],0,$_thisfile.'?dv_bopt=1') AND exit;
			(21 == $dv_bogj->dv_bopt OR 2 == $dv_bogj->dv_bopt) AND ($lang['tpl.bank.str40'] = str_replace('{$user_Money}',$user_Money,$lang['tpl.bank.str40']) AND $lang['tpl.bank.str40'] = str_replace('{$dv_Money}',$dv_bogj->dv_money,$lang['tpl.bank.str40'])); 
			 22 == $dv_bogj->dv_bopt AND $lang['tpl.bank.str40'] = str_replace('{$user_Money}',$user_Money,str_replace('{$dv_Money}',$dv_bogj->dv_money,str_replace('{$dv_Money}',$dv_bogj->dv_money,$lang['tpl.bank.str40'])));
			 23 == $dv_bogj->dv_bopt AND $lang['tpl.bank.str40'] = str_replace('{$user_Money}',$user_Money,str_replace('{$dv_Money}',$dv_bogj->dv_money,str_replace('{$user_EP}',$user_EP,str_replace('{$user_CP}',$user_CP,str_replace('{$user_Ticket}',$user_Ticket,str_replace('{$tickettomony}',$dv_bogj->dv_trasvar['tickettomony'],str_replace('{$eptomony}',$dv_bogj->dv_trasvar['eptomony'],str_replace('{$cptomony}',$dv_bogj->dv_trasvar['cptomony'],$lang['tpl.bank.str40']))))))));
		     24 == $dv_bogj->dv_bopt AND $lang['tpl.bank.str40'] = str_replace('{$user_Money}',$user_Money,str_replace('{$dv_Money}',$dv_bogj->dv_money,$lang['tpl.bank.str40']));
			 $dv_frmlevl = $user_EP/$dv_bogj->dv_trasvar['eptomony']+$user_CP/$dv_bogj->dv_trasvar['cptomony']+$tickettomony/$dv_bogj->dv_trasvar['tickettomony']+$dv_bogj->dv_money-$dv_bogj->dv_loanmoney;
			 25 == $dv_bogj->dv_bopt AND $lang['tpl.bank.str40'] =str_replace('{$user_Money}',$user_Money,str_replace('{$dv_Money}',$dv_bogj->dv_money,str_replace('{$user_EP}',$user_EP,str_replace('{$user_CP}',$user_CP,str_replace('{$user_Ticket}',$user_Ticket,str_replace('{$tickettomony}',$dv_bogj->dv_trasvar['tickettomony'],str_replace('{$eptomony}',$dv_bogj->dv_trasvar['eptomony'],str_replace('{$cptomony}',$dv_bogj->dv_trasvar['cptomony'],str_replace('{$dv_frmlevl}',$dv_frmlevl,$lang['tpl.bank.str40'])))))))));

		}elseif(3 == $dv_bogj->dv_bopt){
			$lang['tpl.bank.str43'] = str_replace('{$msg1money]}',$dv_bogj->dv_trasvar['msg1money'],$lang['tpl.bank.str43']);
			$lang['tpl.bank.str43'] = str_replace('{$news1money]}',$dv_bogj->dv_trasvar['news1money'],$lang['tpl.bank.str43']);
			$dv_bogj->dv_status==0 AND showmsg($lang['tpl.bank.str31'],0,$_thisfile.'?dv_bopt=1') AND exit;
		}elseif(4 == $dv_bogj->dv_bopt){
			$dv_bogj->dv_status==0 AND showmsg($lang['tpl.bank.str31'],0,$_thisfile.'?dv_bopt=1') AND exit;
		}elseif(5 == $dv_bogj->dv_bopt){
			5 == $dv_bogj->dv_bopt AND $lang['tpl.bank.str66'] =str_replace('{$tickettomony}',$dv_bogj->dv_trasvar['tickettomony'],str_replace('{$eptomony}',$dv_bogj->dv_trasvar['eptomony'],str_replace('{$cptomony}',$dv_bogj->dv_trasvar['cptomony'],$lang['tpl.bank.str66'])));
			$dv_bogj->dv_status==0 AND showmsg($lang['tpl.bank.str31'],0,$_thisfile.'?dv_bopt=1') AND exit;
		}elseif(6 == $dv_bogj->dv_bopt){
			$dv_bogj->dv_status==0 AND showmsg($lang['tpl.bank.str31'],0,$_thisfile.'?dv_bopt=1') AND exit;
		}elseif(7 == $dv_bogj->dv_bopt){
			$dv_bogj->dv_status==0 AND showmsg($lang['tpl.bank.str31'],0,$_thisfile.'?dv_bopt=1') AND exit;
		}elseif(71 == $dv_bogj->dv_bopt){
			$dv_bogj->dv_status==0 AND showmsg($lang['tpl.bank.str31'],0,$_thisfile.'?dv_bopt=1') AND exit;
		}elseif(72 == $dv_bogj->dv_bopt){
			$dv_bogj->dv_status==0 AND showmsg($lang['tpl.bank.str31'],0,$_thisfile.'?dv_bopt=1') AND exit;
			'1'==$dv_bogj->dv_trasvar['isopengmoney'] AND $lang['tpl.bank.str105'] = $lang['tpl.bank.str106'];
		}elseif(8 == $dv_bogj->dv_bopt){
			$dv_bogj->dv_status==0 AND showmsg($lang['tpl.bank.str31'],0,$_thisfile.'?dv_bopt=1') AND exit;
		}else{
			$dv_bogj->dv_bopt = 1;
		}
		$lang['tpl.bank.str40'] = str_replace('{$dv_loanmoney}',$dv_bogj->dv_loanmoney,$lang['tpl.bank.str40']);
		$lang['tpl.bank.str40'] = str_replace('{$_thisfile}',$_thisfile.'?dv_bopt='.$dv_bogj->dv_bopt,$lang['tpl.bank.str40']);
		require_once printout('bank');
	}
}

?>