<?php
define('THIS_SCRIPT', 'forumnews_setting');
include_once 'global.php';
$lang = load_lang($lang, 'forumnews_setting' );
checklogin();
header("content-Type: text/html; charset=".$charset);
head();
if ( strpos($sysinfo['flag'],'18,') === false ){
	show_msg($lang['readme_tit'],$lang['error.str1'],0,'','','','');
	exit;
}
PageLoad();
footer();
function Pageload(){
	global $dv,$db,$lang,$action,$doaction,$Ac_type,$record_row,$id,$stan_boarder,$boarder_stan_boarder,$ad_boarder,$sec_tranboarder,$sysusername;
	switch($action){
		case "addok":
			add_transfer();
		break;
		case "editok":
			edit_transfer();
		break;
		case "delok":
			del_transfer();
		break;
	}
	if($Ac_type=="newlist" or $Ac_type==""){
		transfer_list();
	}
include printout('forumnews_setting');
}
function add_transfer(){
	global $lang,$dv,$db,$sign_name,$transfer_code,$transfer_explain,$transfer_type,$time_format,$dataup_space,$record_num,$title_len,$forum_taxis,$limit_day,$view_type,$stan_boarder,$boarder_setup,$boarder_limit,$solitude_userid,$view_mode,$map_framenum,$limit_boarder_tran,$boarder_stan_boarder,$view_boarder,$view_num,$member_taxis,$ad_view_num,$ad_titlelen,$ad_boarder,$sec_viewnum,$sec_rownum,$sec_titlelen,$sec_tranboarder,$sec_boarderset,$sec_boarderlimit,$sec_filetype,$sec_viewtaxis,$tmp_start,$tmp_body,$tmp_end,$boarder_curid,$sort_boarder_curid,$updown_space,$grade_space,$boarder_newline,$pic_width,$pic_height,$tcolor1,$tcolor2,$newline_sign,$sysusername;
	$sign_name=str_replace(" ","",$_POST['sign_name']);
	$transfer_code=$_POST['transfer_code'];
	$transfer_explain=$_POST['transfer_explain'];
	$transfer_type=intval($_POST['transfer_type']);
	$time_format=$_POST['time_format'];
	$dataup_space=$_POST['dataup_space'];
	$tmp_start=$_POST['tmp_start'];
	$tmp_body=$_POST['tmp_body'];
	$tmp_end=$_POST['tmp_end'];
	$mem1=$sign_name.$lang['exp.chr'].$transfer_code.$lang['exp.chr'].$transfer_explain.$lang['exp.chr'].$transfer_type.$lang['exp.chr'].$time_format.$lang['exp.chr'].$dataup_space;
	$mem2=$tmp_start.$lang['exp.chr'].$tmp_body.$lang['exp.chr'].$tmp_end;
		//帖子调用变量;
	$record_num=$_POST['record_num'];
	$title_len=$_POST['title_len'];
	$forum_taxis=$_POST['forum_taxis'];
	$limit_day=$_POST['limit_day'];
	$view_type=$_POST['view_type'];
	$stan_boarder=$_POST['stan_boarder'];
	$boarder_setup=$_POST['boarder_setup'];
	$boarder_limit=$_POST['boarder_limit'];
	$solitude_userid=$_POST['solitude_userid'];
	$forum_mem=$record_num.$lang['exp.chr'].$title_len.$lang['exp.chr'].$forum_taxis.$lang['exp.chr'].$limit_day.$lang['exp.chr'].$view_type.$lang['exp.chr'].$stan_boarder.$lang['exp.chr'].$boarder_setup.$lang['exp.chr'].$boarder_limit.$lang['exp.chr'].$solitude_userid;
		//版块调用变量;
	$view_mode=$_POST['view_mode'];
	$map_framenum=$_POST['map_framenum'];
	$limit_boarder_tran=$_POST['limit_boarder_tran'];
	$boarder_stan_boarder=$_POST['boarder_stan_boarder'];
	$view_boarder=$_POST['view_boarder'];
	$boarder_curid=$_POST['boarder_curid'];
	$sort_boarder_curid=$_POST['sort_boarder_curid'];
	$updown_space=$_POST['updown_space'];
	$grade_space=$_POST['grade_space'];
	$boarder_newline=$_POST['boarder_newline'];
	$boarder_mem=$view_mode.$lang['exp.chr'].$map_framenum.$lang['exp.chr'].$limit_boarder_tran.$lang['exp.chr'].$boarder_stan_boarder.$lang['exp.chr'].$view_boarder.$lang['exp.chr'].$boarder_curid.$lang['exp.chr'].$sort_boarder_curid.$lang['exp.chr'].$updown_space.$lang['exp.chr'].$grade_space.$lang['exp.chr'].$boarder_newline.$lang['exp.chr'];
		//会员调用变量;
	$view_num=$_POST['view_num'];
	$member_taxis=$_POST['member_taxis'];
	$member_mem=$view_num.$lang['exp.chr'].$member_taxis;
		//公告调用变量;
	$ad_view_num=$_POST['ad_view_num'];
	$ad_titlelen=$_POST['ad_titlelen'];
	$ad_boarder=$_POST['ad_boarder'];
	$ad_mem=$ad_view_num.$lang['exp.chr'].$ad_titlelen.$lang['exp.chr'].$ad_boarder;
		//展区调用变量;
	$sec_viewnum=$_POST['sec_viewnum'];
	$sec_rownum=$_POST['sec_rownum'];
	$sec_titlelen=$_POST['sec_titlelen'];
	$sec_tranboarder=$_POST['sec_tranboarder'];
	$sec_boarderset=$_POST['sec_boarderset'];
	$sec_boarderlimit=$_POST['sec_boarderlimit'];
	$sec_filetype=$_POST['sec_filetype'];
	$sec_viewtaxis=$_POST['sec_viewtaxis'];
	$pic_width=$_POST['pic_width'];
	$pic_height=$_POST['pic_height'];
	$tcolor1=$_POST['tcolor1'];
	$tcolor2=$_POST['tcolor2'];
	$newline_sign=$_POST['newline_sign'];
	$sec_mem=$sec_viewnum.$lang['exp.chr'].$sec_rownum.$lang['exp.chr'].$sec_titlelen.$lang['exp.chr'].$sec_tranboarder.$lang['exp.chr'].$sec_boarderset.$lang['exp.chr'].$sec_boarderlimit.$lang['exp.chr'].$sec_filetype.$lang['exp.chr'].$sec_viewtaxis.$lang['exp.chr'].$pic_width.$lang['exp.chr'].$pic_height.$lang['exp.chr'].$tcolor1.$lang['exp.chr'].$tcolor2.$lang['exp.chr'].$newline_sign;
	$addtime=strtotime("now");
	$edittime=strtotime("now");
	$master=$sysusername;
	$endinfo=$addtime.$lang['exp.chr'].$edittime.$lang['exp.chr'].$master;
	switch ($transfer_type){
		case 1://帖子调用变量;
			$mem=$mem1.$lang['exp.chr'].$mem2.$lang['exp.chr'].$endinfo.$lang['exp.chr'].$forum_mem.$lang['exp.row'];
		break;
		case 2://信息调用变量;
			$mem=$mem1.$lang['exp.chr'].$mem2.$lang['exp.chr'].$endinfo.$lang['exp.row'];
		break;
		case 3://版块调用变量;
			$mem=$mem1.$lang['exp.chr'].$mem2.$lang['exp.chr'].$endinfo.$lang['exp.chr'].$boarder_mem.$lang['exp.row'];
		break;
		case 4://会员调用变量;
			$mem=$mem1.$lang['exp.chr'].$mem2.$lang['exp.chr'].$endinfo.$lang['exp.chr'].$member_mem.$lang['exp.row'];
		break;
		case 5://公告调用变量;
			$mem=$mem1.$lang['exp.chr'].$mem2.$lang['exp.chr'].$endinfo.$lang['exp.chr'].$ad_mem.$lang['exp.row'];
		break;
		case 6://展区调用变量;
			$mem=$mem1.$lang['exp.chr'].$mem2.$lang['exp.chr'].$endinfo.$lang['exp.chr'].$sec_mem.$lang['exp.row'];
		break;

	}
	if($sign_name=="" or $transfer_type===0 or $tmp_body==""){
		show_msg($lang['sys.info'],$lang['sys.info1'],0,'','',$lang['url'],$lang['cmdback']);
	exit;
	}
	if(strlen($sign_name)>10 or preg_match("/\\w/i",$sign_name)===0){
		show_msg($lang['sys.info'],$lang['sys.info2'],0,'','',$lang['url'],$lang['cmdback']);
	exit;
	}
	@chmod($lang['tran_dir'],0777);
	if(is_writable($lang['tran_dir'])){
		if (!$handle = fopen($lang['tran_dir'],'a')){
			show_msg($lang['sys.info'],$lang['sys.info3'],0,'','',$lang['url'],$lang['cmdback']);
		exit;
		}
		if (fwrite($handle, $mem)===FALSE) {
			show_msg($lang['sys.info'],$lang['sys.info3'],0,'','',$lang['url'],$lang['cmdback']);
		exit;
		}
		else{
			show_msg($lang['sys.info'],$lang['sys.info4'],1,'','',$lang['url'],$lang['cmdback']);
			fclose($handle);
		exit;
		}
	}
	else{
		show_msg($lang['sys.info'],$lang['sys.info3'],0,'','',$lang['url'],$lang['cmdback']);
	exit;
	}
}
function transfer_list(){
	global $lang,$record_row,$Ac_type;
	$record_row=array();
	@chmod($lang['tran_dir'],0777);
	if($fp=fopen($lang['tran_dir'],'r')){
		if(filesize($lang['tran_dir'])===0){
			show_msg($lang['sys.info'],$lang['sys.info5'],0,'','','forumnews_setting.php?Ac_type=add',$lang['cmdback']);
		exit;
		}
		else{
			$recordset=fread($fp,filesize($lang['tran_dir']));
			$record_row=explode($lang['exp.row'],$recordset);
			fclose($fp);
		}
	}
}
function edit_transfer(){
	global $lang,$id,$sign_name,$transfer_code,$transfer_explain,$transfer_type,$time_format,$dataup_space,$record_num,$title_len,$forum_taxis,$limit_day,$view_type,$stan_boarder,$boarder_setup,$boarder_limit,$solitude_userid,$view_mode,$map_framenum,$limit_boarder_tran,$boarder_stan_boarder,$view_boarder,$view_num,$member_taxis,$ad_view_num,$ad_titlelen,$ad_boarder,$sec_viewnum,$sec_rownum,$sec_titlelen,$sec_tranboarder,$sec_boarderset,$sec_boarderlimit,$sec_filetype,$sec_viewtaxis,$tmp_start,$tmp_body,$tmp_end,$boarder_curid,$sort_boarder_curid,$updown_space,$grade_space,$boarder_newline,$pic_width,$pic_height,$tcolor1,$tcolor2,$newline_sign,$sysusername;
	$get_row=intval($_GET['id']);
	$sign_name=str_replace(" ","",$_POST['sign_name']);
	$transfer_code=$_POST['transfer_code'];
	$transfer_explain=$_POST['transfer_explain'];
	$transfer_type=intval($_POST['transfer_type']);
	$time_format=$_POST['time_format'];
	$dataup_space=$_POST['dataup_space'];
	$tmp_start=$_POST['tmp_start'];
	$tmp_body=$_POST['tmp_body'];
	$tmp_end=$_POST['tmp_end'];
	$mem1=$sign_name.$lang['exp.chr'].$transfer_code.$lang['exp.chr'].$transfer_explain.$lang['exp.chr'].$transfer_type.$lang['exp.chr'].$time_format.$lang['exp.chr'].$dataup_space;
	$mem2=$tmp_start.$lang['exp.chr'].$tmp_body.$lang['exp.chr'].$tmp_end;
		//帖子调用变量;
	$record_num=$_POST['record_num'];
	$title_len=$_POST['title_len'];
	$forum_taxis=$_POST['forum_taxis'];
	$limit_day=$_POST['limit_day'];
	$view_type=$_POST['view_type'];
	$stan_boarder=$_POST['stan_boarder'];
	$boarder_setup=$_POST['boarder_setup'];
	$boarder_limit=$_POST['boarder_limit'];
	$solitude_userid=$_POST['solitude_userid'];
	$forum_mem=$record_num.$lang['exp.chr'].$title_len.$lang['exp.chr'].$forum_taxis.$lang['exp.chr'].$limit_day.$lang['exp.chr'].$view_type.$lang['exp.chr'].$stan_boarder.$lang['exp.chr'].$boarder_setup.$lang['exp.chr'].$boarder_limit.$lang['exp.chr'].$solitude_userid;
		//版块调用变量;
	$view_mode=$_POST['view_mode'];
	$map_framenum=$_POST['map_framenum'];
	$limit_boarder_tran=$_POST['limit_boarder_tran'];
	$boarder_stan_boarder=$_POST['boarder_stan_boarder'];
	$view_boarder=$_POST['view_boarder'];
	$boarder_curid=$_POST['boarder_curid'];
	$sort_boarder_curid=$_POST['sort_boarder_curid'];
	$updown_space=$_POST['updown_space'];
	$grade_space=$_POST['grade_space'];
	$boarder_newline=$_POST['boarder_newline'];
	$boarder_mem=$view_mode.$lang['exp.chr'].$map_framenum.$lang['exp.chr'].$limit_boarder_tran.$lang['exp.chr'].$boarder_stan_boarder.$lang['exp.chr'].$view_boarder.$lang['exp.chr'].$boarder_curid.$lang['exp.chr'].$sort_boarder_curid.$lang['exp.chr'].$updown_space.$lang['exp.chr'].$grade_space.$lang['exp.chr'].$boarder_newline.$lang['exp.chr'];
		//会员调用变量;
	$view_num=$_POST['view_num'];
	$member_taxis=$_POST['member_taxis'];
	$member_mem=$view_num.$lang['exp.chr'].$member_taxis;
		//公告调用变量;
	$ad_view_num=$_POST['ad_view_num'];
	$ad_titlelen=$_POST['ad_titlelen'];
	$ad_boarder=$_POST['ad_boarder'];
	$ad_mem=$ad_view_num.$lang['exp.chr'].$ad_titlelen.$lang['exp.chr'].$ad_boarder;
		//展区调用变量;
	$sec_viewnum=$_POST['sec_viewnum'];
	$sec_rownum=$_POST['sec_rownum'];
	$sec_titlelen=$_POST['sec_titlelen'];
	$sec_tranboarder=$_POST['sec_tranboarder'];
	$sec_boarderset=$_POST['sec_boarderset'];
	$sec_boarderlimit=$_POST['sec_boarderlimit'];
	$sec_filetype=$_POST['sec_filetype'];
	$sec_viewtaxis=$_POST['sec_viewtaxis'];
	$pic_width=$_POST['pic_width'];
	$pic_height=$_POST['pic_height'];
	$tcolor1=$_POST['tcolor1'];
	$tcolor2=$_POST['tcolor2'];
	$newline_sign=$_POST['newline_sign'];
	$sec_mem=$sec_viewnum.$lang['exp.chr'].$sec_rownum.$lang['exp.chr'].$sec_titlelen.$lang['exp.chr'].$sec_tranboarder.$lang['exp.chr'].$sec_boarderset.$lang['exp.chr'].$sec_boarderlimit.$lang['exp.chr'].$sec_filetype.$lang['exp.chr'].$sec_viewtaxis.$lang['exp.chr'].$pic_width.$lang['exp.chr'].$pic_height.$lang['exp.chr'].$tcolor1.$lang['exp.chr'].$tcolor2.$lang['exp.chr'].$newline_sign;
	$addtime=strtotime("now");
	$edittime=strtotime("now");
	$master=$sysusername;
	$endinfo=$addtime.$lang['exp.chr'].$edittime.$lang['exp.chr'].$master;
	switch ($transfer_type){
		case 1://帖子调用变量;
			$mem=$mem1.$lang['exp.chr'].$mem2.$lang['exp.chr'].$endinfo.$lang['exp.chr'].$forum_mem.$lang['exp.row'];
		break;
		case 2://信息调用变量;
			$mem=$mem1.$lang['exp.chr'].$mem2.$lang['exp.chr'].$endinfo.$lang['exp.row'];
		break;
		case 3://版块调用变量;
			$mem=$mem1.$lang['exp.chr'].$mem2.$lang['exp.chr'].$endinfo.$lang['exp.chr'].$boarder_mem.$lang['exp.row'];
		break;
		case 4://会员调用变量;
			$mem=$mem1.$lang['exp.chr'].$mem2.$lang['exp.chr'].$endinfo.$lang['exp.chr'].$member_mem.$lang['exp.row'];
		break;
		case 5://公告调用变量;
			$mem=$mem1.$lang['exp.chr'].$mem2.$lang['exp.chr'].$endinfo.$lang['exp.chr'].$ad_mem.$lang['exp.row'];
		break;
		case 6://展区调用变量;
			$mem=$mem1.$lang['exp.chr'].$mem2.$lang['exp.chr'].$endinfo.$lang['exp.chr'].$sec_mem.$lang['exp.row'];
		break;

	}
	@chmod($lang['tran_dir'],0777);
	if($fp=fopen($lang['tran_dir'],'r+')){
		$recordset=fread($fp,filesize($lang['tran_dir']));
		$record_row=explode($lang['exp.row'],$recordset);
		$num=count($record_row);
		for ($i=0;$i<$num;$i++){
			if(strcmp($i,$get_row)===0){
				$memboby.=$mem;
			}
			else{
				$memboby.=$record_row[$i].$lang['exp.row'];
			}
		}
		$memboby=substr($memboby,0,-3);echo $lang['tran_dir'];
		$rfp=fopen($lang['tran_dir'],'w');
		if(fwrite($rfp,$memboby)!==false){
			show_msg($lang['sys.info'],$lang['sys.info9'],1,'','',$lang['url'],$lang['cmdback']);
		exit;
		}
	}
	fclose($rfp);
	fclose($fp);
}
function del_transfer(){
	global $lang,$id;
	$get_row=$_POST['id'];
	if(count($get_row)=="" or count($get_row)===0){
		show_msg($lang['sys.info'],$lang['sys.info6'],0,'','',$lang['url'],$lang['cmdback']);
	exit;
	}
	@chmod($lang['tran_dir'],0777);
	if($fp=fopen($lang['tran_dir'],'r+')){
		$recordset=fread($fp,filesize($lang['tran_dir']));
		$record_row=explode($lang['exp.row'],$recordset);
		$num=count($record_row);
		for ($i=0;$i<$num;$i++){
			if(!in_array($i,$get_row)){
				$mem.=$record_row[$i].$lang['exp.row'];
			}
		}
		$mem=substr($mem,0,-3);
		$rfp=fopen($lang['tran_dir'],'w');
		if(fwrite($rfp,$mem)!==false){
			show_msg($lang['sys.info'],$lang['sys.info7'],1,'','',$lang['url'],$lang['cmdback']);
		exit;
		}
	}
	fclose($rfp);
	fclose($fp);
}
?>