<?php
define('THIS_SCRIPT', 'forum_wealth');
include_once 'global.php';
$lang = load_lang($lang,'forum_wealth');
checklogin();
header("content-Type: text/html; charset=".$charset);
head();
if ( strpos($sysinfo['flag'],'5,') === false ){
	show_msg($lang['readme_tit'],$lang['error.str1'],0,'','','','');
	exit;
}
PageLoad();
footer();
function Pageload(){
	global $dv,$db,$lang,$action,$get_boardtype,$wealth_val,$getskinid,$url;
	$url="javascript:void(window.history.back(-1))";
	getboard_id($get_boardtype);
	if($action=="save"){
		save_integral();
	}
include printout('forum_wealth');
}
function getboard_id($get_boardtype){
	global $dv,$db,$lang,$action,$b_id,$wealth_val,$url,$forum_user;
	if ( $get_boardtype != '' ){
		$wealth_val=array();
		$sql="select board_user from {$dv}board where boardid='".$get_boardtype."'";
		$result=$db->query($sql);
		$arr_list=$db->fetch_array($result);
		$wealth_val=explode(",",$arr_list['board_user']);
		$db->free_result($result);
	}else{
		$wealth_val = $forum_user;
	}
}
function save_integral(){
	global $dv,$db,$lang,$action,$getboardid,$getskinid,$forum_user,$money_reg,$money_put,$money_flo,$money_del;
	global $money_log,$exp_reg,$exp_put,$exp_flo,$exp_del,$exp_log,$charm_reg,$charm_put,$charm_flo,$charm_del;
	global $charm_log,$money_pink,$charm_pink,$exp_pink,$url;
	$get_boardtype=intval($_POST['get_boardtype']);	$forum_user=$money_reg.",".$money_put.",".$money_flo.",".$money_del.",".$money_log.",".$exp_reg.",".$exp_put.",".$exp_flo.",".$exp_del.",".$exp_log.",".$charm_reg.",".$charm_put.",".$charm_flo.",".$charm_del.",".$charm_log.",".$money_pink.",".$charm_pink.",".$exp_pink;
	$setup_result=$db->query("select forum_setting from {$dv}setup");
	$arr=$db->fetch_array($setup_result);
	$iforum_setting=explode("|||",$arr['forum_setting']);
	$forum_setting=$iforum_setting[0]."|||".$iforum_setting[1]."|||".$forum_user."|||".$iforum_setting[3]."|||".$iforum_setting[4]."|||".$iforum_setting[5];
	if(!checkIDList($forum_setting)){
		if($getskinid==1){
			$stmt_result=$db->query("update {$dv}setup set forum_setting='".$forum_setting."'");
			require_once INC_PATH.'BoardCache.class.php';
			$mycache =& new BoardCache($db);
			$mycache->createForumSetting();
			unset($mycache);
		}
	}
	if($getboardid=='' && $getskinid == ''){
		show_msg($lang['sys.info'],$lang['wealth.info10'],'0','','',$url,$lang['cmdback']);
		exit;
	}

	if($getboardid=='' && $getskinid == 1){
		$stmt_result=$db->query("update {$dv}setup set forum_setting='".$forum_setting."'");
		require_once INC_PATH.'BoardCache.class.php';
		$mycache =& new BoardCache($db);
		$mycache->createForumSetting();
		unset($mycache);
		show_msg($lang['sys.info'],$lang['succeed.info1'],'1','','',$url,$lang['cmdback']);
		exit;			
	}
	else{
		$idlist = implode(',',$getboardid);
			$sql="update {$dv}board set board_user='".$forum_user."' where boardid in(".$idlist.")";
			$result=$db->query($sql);
			if($result){
				show_msg($lang['sys.info'],$lang['succeed.info1'],'1','','',$url,$lang['cmdback']);
			exit;			
			}
			else{
				show_msg($lang['sys.info'],$lang['error.info1'],'0','','',$url,$lang['cmdback']);
			exit;	
			}
	}
}
?>