<?php
define('THIS_SCRIPT','bank');
include_once 'global.php';
$lang = load_lang($lang,'bank');
checklogin();
header("content-Type: text/html; charset=".$charset);
head();
if ( strpos($sysinfo['flag'],'54,') === false ){
	show_msg($lang['readme_tit'],$lang['error.str1'],0,'','','','');
	exit;
}
require_once('../bank_inc.php');
PageLoad();
footer();

function dv_updateopt(){
		global $db,$lang,$userinfo,$dv,$fsetting,$reaction;
		global $idv_trasvar, $idv_news;
		$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)
				  )
			{
				show_msg($lang['sys.info'],$lang['plus.info37'],0,'','',$lang['url'],$lang['cmdback'])
				 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['plus.info38'],$lang['plus.info39'],$lang['plus.info40'],$lang['plus.info41'],$lang['plus.info42'],$lang['plus.info43'],'0');
			
			!in_array($mv_deltype,$mv_optarray) AND 
				show_msg($lang['sys.info'],$lang['plus.info37'],0,'','',$lang['url'],$lang['cmdback'])
				 AND exit;
				 		
			(!is_numeric($mv_deldays) || $mv_deldays <= 0) AND show_msg($lang['sys.info'],$lang['plus.info37'],0,'','',$lang['url'],$lang['cmdback']) AND exit;
			//$mv_admins = explode(",",$this->dv_bmanages);
			$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");
			show_msg($lang['sys.info'],$lang['plus.info35'],0,'','',$lang['url'],$lang['cmdback'])
			 AND exit;
				 
			exit;
		}else if( 5 == $mv_var0 ){
			$isopengmoney = $idv_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 
		show_msg($lang['sys.info'],$lang['meun.info'],0,'','',$lang['url'],$lang['cmdback'])
		 AND exit;

		isset($mv_cptomony) AND $configfile = preg_replace("/'cptomony'\s*\=>.*?,/is", "'cptomony'=>'".$mv_cptomony."',", $configfile);
		isset($mv_cptomony) AND $mv_cptomony <= 0  AND show_msg($lang['sys.info'],$lang['meun.info'],0,'','',$lang['url'],$lang['cmdback'])
		 AND exit;

		isset($mv_eptomony) AND $configfile = preg_replace("/'eptomony'\s*\=>.*?,/is", "'eptomony'=>'".$mv_eptomony."',", $configfile);
		isset($mv_eptomony) AND $mv_eptomony <= 0  AND show_msg($lang['sys.info'],$lang['meun.info'],0,'','',$lang['url'],$lang['cmdback'])
		 AND exit;

		isset($mv_lixi1) AND $configfile = preg_replace("/'lixi1'\s*\=>.*?,/is", "'lixi1'=>'".$mv_lixi1."',", $configfile);
		isset($mv_lixi1) AND $mv_lixi1 <= 0  AND show_msg($lang['sys.info'],$lang['meun.info'],0,'','',$lang['url'],$lang['cmdback'])
		 AND exit;

		isset($mv_lixi7) AND $configfile = preg_replace("/'lixi7'\s*\=>.*?,/is", "'lixi7'=>'".$mv_lixi7."',", $configfile);
		isset($mv_lixi7) AND $mv_lixi7 <= 0  AND show_msg($lang['sys.info'],$lang['meun.info'],0,'','',$lang['url'],$lang['cmdback'])
		 AND exit;

		isset($mv_lixi15) AND $configfile = preg_replace("/'lixi15'\s*\=>.*?,/is", "'lixi15'=>'".$mv_lixi15."',", $configfile);
		isset($mv_lixi15) AND $mv_lixi15 <= 0  AND show_msg($lang['sys.info'],$lang['meun.info'],0,'','',$lang['url'],$lang['cmdback'])
		 AND exit;

		isset($mv_lixi30) AND $configfile = preg_replace("/'lixi30'\s*\=>.*?,/is", "'lixi30'=>'".$mv_lixi30."',", $configfile);
		isset($mv_lixi30) AND $mv_lixi30 <= 0  AND show_msg($lang['sys.info'],$lang['meun.info'],0,'','',$lang['url'],$lang['cmdback'])
		 AND exit;

		isset($mv_lixi180) AND $configfile = preg_replace("/'lixi180'\s*\=>.*?,/is", "'lixi180'=>'".$mv_lixi180."',", $configfile);
		isset($mv_lixi180) AND $mv_lixi180 <= 0  AND show_msg($lang['sys.info'],$lang['meun.info'],0,'','',$lang['url'],$lang['cmdback'])
		 AND exit;

		isset($mv_msg1money) AND $configfile = preg_replace("/'msg1money'\s*\=>.*?,/is", "'msg1money'=>'".$mv_msg1money."',", $configfile);
		isset($mv_msg1money) AND $mv_msg1money <= 0  AND show_msg($lang['sys.info'],$lang['meun.info'],0,'','',$lang['url'],$lang['cmdback'])
		 AND exit;

		isset($mv_news1money) AND $configfile = preg_replace("/'news1money'\s*\=>.*?,/is", "'news1money'=>'".$mv_news1money."',", $configfile);
		isset($mv_news1money) AND $mv_news1money <= 0  AND show_msg($lang['sys.info'],$lang['meun.info'],0,'','',$lang['url'],$lang['cmdback'])
		 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("/[$]i`\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);		
		show_msg($lang['sys.info'],$lang['plus.info35'],0,'','',$lang['url'],$lang['cmdback']);		EXIT;
	}

function Pageload(){
	global $lang;
 	global $idv_trasvar, $idv_news,$reaction;
	if(strval($idv_trasvar['isopengmoney'])=='0') $lang['plus.info33'] = $lang['plus.info43'];
	if(isset($_POST['dv_action9'])&&isset($_POST['dv_input9'])){
			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_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']);
	}else/*if(isset($_POST['dv_action11'])&&isset($_POST['dv_input11'])){
		dv_updateopt(3, $_POST['dv_input11']);
	}else*/if(isset($_POST['dv_action12'])&&isset($_POST['dv_input1201'])&&isset($_POST['dv_input1202'])){
		dv_updateopt(4, $_POST['dv_input1201'], $_POST['dv_input1202']);
	}elseif(isset($_POST['dv_action72'])){
		dv_updateopt(5);
	}	
	include printout('bank');
}

?>