<?php
define('THIS_SCRIPT', 'alldel');
include_once 'global.php';
$lang = load_lang($lang, 'alldel' );
checklogin();
header("content-Type: text/html; charset=".$charset);
head();
if ( strpos($sysinfo['flag'],'22,') === false ){
	show_msg($lang['readme_tit'],$lang['error.str1'],0,'','','','');
	exit;
}
PageLoad();
footer();
function Pageload(){
	global $dv,$db,$lang,$action,$reaction,$user_name,$day,$sourceid,$targetid,$speday_boardid,$noput_boardid,$user_boardid,$forward_day,$spe_numday,$noput_numday;
	switch ($reaction){
		case "form1":
			spedel_forum();
		break;
		case "form2":
			noputdel_forum();
		break;
		case "form3":
			user_forum();
		break;
		case "form4":
			forward_forum();
		break;
		case "date":
		movedate_forum();
		break;
		case "username":
		moveusername_forum();
		break;
	}
include printout('alldel');
}
function spedel_forum(){//删除指定日期内帖子;
	global $db,$lang,$dv,$speday_boardid,$spe_numday;
	$speday_boardid=intval($_POST['speday_boardid']);
	$spe_numday=intval($_POST['spe_numday']);
	$is=get_magic_quotes_runtime();
	if( $is == 0 ){
		set_magic_quotes_runtime(1);
		$is_1 = 1;
	}
	if($speday_boardid=="" or $speday_boardid==0){
		show_msg($lang['sys.info'],$lang['error.info2'],0,'','','alldel.php',$lang['cmdback']);
	exit;
	}
	if($spe_numday==""){
		show_msg($lang['sys.info'],$lang['error.info1'],0,'','','alldel.php',$lang['cmdback']);
	exit;
	}
	elseif($spe_numday!="" && $speday_boardid=="all"){
		$result=$db->query("select id,tablename,tabletype from {$dv}tablelist");
		while ($arrtablelist=$db->fetch_array($result)){
			$count=$db->scalar("select count(1) from ".$arrtablelist['tablename']." where dateandtime<'".dateAdd('d',-$spe_numday,gmdate('Y-m-d 23:59:59'), '')."'");
			$tableinfo.=$lang['template.str13'].$arrtablelist['tablename']."(".$count.")".$lang['template.str18'];
			$stmt=$db->query("delete from ".$arrtablelist['tablename']." where dateandtime<'".dateAdd('d',-$spe_numday,gmdate('Y-m-d 23:59:59'), '')."'");
		}
	}
	else{
		$result=$db->query("select id,tablename,tabletype from {$dv}tablelist");
		while ($arrtablelist=$db->fetch_array($result)){
			$count=$db->scalar("select count(1) from ".$arrtablelist['tablename']." where boardid='".$speday_boardid."' and dateandtime<'".dateAdd('d',-$spe_numday,gmdate('Y-m-d 23:59:59'), '')."'");
			$tableinfo.=$lang['template.str13'].$arrtablelist['tablename']."(".$count.")";
			$stmt=$db->query("delete from ".$arrtablelist['tablename']." where boardid='".$speday_boardid."' and dateandtime<'".dateAdd('d',-$spe_numday,gmdate('Y-m-d 23:59:59'), '')."'");
		}
	}
	$topic_count=$db->scalar("select count(1) from {$dv}topic where boardid='".$speday_boardid."' and dateandtime<'".dateAdd('d',-$spe_numday,gmdate('Y-m-d 23:59:59'), '')."'");
	$topic_result=$db->query("delete from {$dv}topic where boardid='".$speday_boardid."' and dateandtime<'".dateAdd('d',-$spe_numday,gmdate('Y-m-d 23:59:59'), '')."'");//删除表dv_topic的相关记录;
	$besttopic_result=$db->query("delete from {$dv}besttopic where boardid='".$speday_boardid."' and dateandtime<'".dateAdd('d',-$spe_numday,gmdate('Y-m-d 23:59:59'), '')."'");//删除表dv_besttopic的相关记录;

	if($stmt){
		show_msg($lang['sys.info'],$lang['suc.info1'].$tableinfo.'<br>'.$lang['template.str13'].'dv_topic:('.$topic_count.')',1,'','','alldel.php',$lang['cmdback']);
	exit;
	}
	else{
		show_msg($lang['sys.info'],$lang['suc.info2'],0,'','','alldel.php',$lang['cmdback']);
	exit;
	}
$db->free_result($topic_count);
$db->free_result($count);
$db->free_result($result);
	if( $is_1 == 1 ) set_magic_quotes_runtime($is);
}
function noputdel_forum(){//删除指定日期内没有回复的主题;
	global $dv,$lang,$dv,$noput_boardid;
	$noput_boardid=intval($_POST['noput_boardid']);
	$noput_numday=intval($_POST['noput_numday']);
	$is=get_magic_quotes_runtime();
	if( $is == 0 ){
		set_magic_quotes_runtime(1);
		$is_1 = 1;
	}
	if($noput_boardid=="" or $noput_boardid==0){
		show_msg($lang['sys.info'],$lang['error.info2'],0,'','','alldel.php',$lang['cmdback']);
	exit;
	}
	if($noput_numday==""){
		show_msg($lang['sys.info'],$lang['error.info1'],0,'','','alldel.php',$lang['cmdback']);
	exit;
	}
	elseif($noput_numday!="" && $noput_boardid=="all"){
		$tmptable=$db->query("select topicid,posttable,isvote from {$dv}topic where child=0 and dateandtime<'".dateAdd('d',-$noput_numday,gmdate('Y-m-d 23:59:59'), '')."'");
		while ($tmparr=$db->fetch_array($tmptable)){
			if(intval($tmparr['isvote'])==-1){
				continue;
			}
			$tmpt1=$db->query("delete from ".$tmparr['posttable']." where rootid='".$tmparr['topicid']."' and forumtype=0");
			$tmpt2=$db->query("delete from {$dv}besttopic where rootid='".$tmparr['topicid']."'");
		}
		$count=$db->scalar("select count(1) from {$dv}topic where boardid='".$noput_boardid."' and child=0 and dateandtime<'".dateAdd('d',-$noput_numday,gmdate('Y-m-d 23:59:59'), '')."'");
		$result=$db->query("delete from {$dv}topic where child=0 and dateandtime<'".dateAdd('d',-$noput_numday,gmdate('Y-m-d 23:59:59'), '')."'");
	}
	else{
		$tmptable=$db->query("select topicid,posttable,isvote from {$dv}topic where boardid='".$noput_boardid."' and child=0 and dateandtime<'".dateAdd('d',-$noput_numday,gmdate('Y-m-d 23:59:59'), '')."'");
		while ($tmparr=$db->fetch_array($tmptable)){
			if(intval($tmparr['isvote'])==-1){
				continue;
			}
			$tmpt1=$db->query("delete from ".$tmparr['posttable']." where rootid='".$tmparr['topicid']."' and forumtype=0");
			$tmpt2=$db->query("delete from {$dv}besttopic where rootid='".$tmparr['topicid']."'");
		}
		$count=$db->scalar("select count(1) from {$dv}topic where boardid='".$noput_boardid."' and child=0 and dateandtime<'".dateAdd('d',-$noput_numday,gmdate('Y-m-d 23:59:59'), '')."'");
		$result=$db->query("delete from {$dv}topic where boardid='".$noput_boardid."' and child=0 and dateandtime<'".dateAdd('d',-$noput_numday,gmdate('Y-m-d 23:59:59'), '')."'");
	}
	if($result){
		show_msg($lang['sys.info'],$lang['suc.info1'].$lang['template.str13'].'dv_topic'.' ('.$count.')'.$lang['template.str14'],1,'','','alldel.php',$lang['cmdback']);
	exit;
	}
	else{
		show_msg($lang['sys.info'],$lang['suc.info2'],0,'','','alldel.php',$lang['cmdback']);
	exit;
	}
$db->free_result($count);
$db->free_result($tmptable);
	if( $is_1 == 1 ) set_magic_quotes_runtime($is);
}
function user_forum(){//删除某用户的所有帖子;
	global $db,$lang,$dv,$user_boardid,$user_forum,$action;
	$user_boardid=$_POST['user_boardid'];
	$user_forum=str_replace(" ","",$_POST['user_forum']);
	$is=get_magic_quotes_runtime();
	if( $is == 0 ){
		set_magic_quotes_runtime(1);
		$is_1 = 1;
	}
	if($user_boardid==""){
		show_msg($lang['sys.info'],$lang['error.info2'],0,'','','alldel.php',$lang['cmdback']);
	exit;
	}
	if($user_forum==""){
		show_msg($lang['sys.info'],$lang['error.info3'],0,'','','alldel.php',$lang['cmdback']);
	exit;
	}
	else{
		$count=$db->scalar("select count(1) from {$dv}user where username='".$user_forum."'");
		if($count<=0){
			show_msg($lang['sys.info'],$lang['error.info4'],0,'','','alldel.php',$lang['cmdback']);//判断用户是否存在;
		exit;
		}
		else{
			$result=$db->query("select userid,usergroupid from {$dv}user where username='".$user_forum."'");
			$arruserlist=$db->fetch_array($result);
			if($arruserlist['usergroupid']=='1' or $arruserlist['usergroupid']=='2' or $arruserlist['usergroupid']=='3'){
				show_msg($lang['sys.info'],$lang['error.info5'],0,'','','alldel.php',$lang['cmdback']);
			exit;
			}
			else{
				if($user_boardid=="all"){
					$result_table=$db->query("select id,tablename,tabletype from {$dv}tablelist");
					while ($arrtablelist=$db->fetch_array($result_table)){
						$count=$db->scalar("select count(1) from ".$arrtablelist['tablename']." where postuserid='".$arruserlist['userid']."'");
						$hairnet+=$count;//该用户发帖数;
						$tableinfo.=$lang['template.str13'].$arrtablelist['tablename']."(".$count.")".$lang['template.str18'];//获得表信息;
						$stmt=$db->query("delete from ".$arrtablelist['tablename']." where postuserid='".$arruserlist['userid']."'");//删除所有的表中有关于该用户的帖子;
					}
					$distillate_result=$db->query("delete from {$dv}besttopic where postuserid='".$arruserlist['userid']."'");//删除精华;
					$up_result=$db->query("delete from {$dv}upfile where f_userid='".$arruserlist['userid']."'");//删除该用户一起上传的文件;
					$otherup_stmt=$db->query("select topicid,posttable from {$dv}topic where postuserid='".$arruserlist['userid']."'");
					while($arrothertable=$db->fetch_array($otherup_stmt)){
						$other_result=$db->query("delete from ".$arrothertable['posttable']." where rootid='".$arrothertable['topicid']."' and forumtype=0");//删除该用户发表的主题和跟帖;
					}
					$db->query("delete from {$dv}topic where boardid='".$user_boardid."' and postuserid='".$arruserlist['userid']."'");
					$update_result=$db->query("update {$dv}user set userpost=( CASE WHEN userpost-".$hairnet.">0 THEN userpost-".$hairnet." ELSE 0 END),userwealth=( CASE WHEN userwealth-".$hairnet*$forum_user[3].">0 THEN userwealth-".$hairnet*$forum_user[3]." ELSE 0 END),userep=( CASE WHEN userep-".$hairnet*$forum_user[8].">0 THEN userep-".$hairnet*$forum_user[8]." ELSE 0 END),usercp=( CASE WHEN usercp-".$hairnet*$forum_user[13].">0 THEN usercp-".$hairnet*$forum_user[13]." ELSE 0 END) where userid='".$user_boardid."'");
					if($stmt){
						show_msg($lang['sys.info'],$lang['suc.info1'].$tableinfo.'<br>'.$lang['template.str15'].$lang['template.str13'].'dv_topic,dv_besttopic,dv_upfile'.$lang['template.str16'],1,'','','alldel.php',$lang['cmdback']);
					exit;
					}
					else{
						show_msg($lang['sys.info'],$lang['suc.info2'],0,'','','alldel.php',$lang['cmdback']);
					exit;
					}
				}
				else{
					$result_table=$db->query("select id,tablename,tabletype from {$dv}tablelist");
					while ($arrtablelist=$db->fetch_array($result_table)){
						$count=$db->scalar("select count(1) from ".$arrtablelist['tablename']." where boardid='".$user_boardid."' and postuserid='".$arruserlist['userid']."'");
						$hairnet+=$count;//该用户发帖数;
						$tableinfo.=$lang['template.str13'].$arrtablelist['tablename']."(".$count.")".$lang['template.str18'];//获得表信息;
						$stmt=$db->query("delete from ".$arrtablelist['tablename']." where boardid='".$user_boardid."' and postuserid='".$arruserlist['userid']."'");//删除所有的表中有关于该用户的帖子;
					}
					$distillate_result=$db->query("delete from {$dv}besttopic where boardid='".$user_boardid."' and postuserid='".$arruserlist['userid']."'");//删除精华;
					$up_result=$db->query("delete from {$dv}upfile where f_boardid='".$user_boardid."' and f_userid='".$arruserlist['userid']."'");//删除该用户一起上传的文件;
					$otherup_stmt=$db->query("select topicid,posttable from {$dv}topic where boardid='".$user_boardid."' and postuserid='".$arruserlist['userid']."'");					
					while($arrothertable=$db->fetch_array($otherup_stmt)){
						$other_result=$db->query("delete from ".$arrothertable['posttable']." where rootid='".$arrothertable['topicid']."' and forumtype=0");//删除该用户发表的主题和跟帖;
					}
					$db->query("delete from {$dv}topic where boardid='".$user_boardid."' and postuserid='".$arruserlist['userid']."'");//删除TOPIC表里的贴子列表
					$update_result=$db->query("update {$dv}user set userpost=( CASE WHEN userpost-".$hairnet.">0 THEN userpost-".$hairnet." ELSE 0 END),userwealth=( CASE WHEN userwealth-".$hairnet*$forum_user[3].">0 THEN userwealth-".$hairnet*$forum_user[3]." ELSE 0 END),userep=( CASE WHEN userep-".$hairnet*$forum_user[8].">0 THEN userep-".$hairnet*$forum_user[8]." ELSE 0 END),usercp=( CASE WHEN usercp-".$hairnet*$forum_user[13].">0 THEN usercp-".$hairnet*$forum_user[13]." ELSE 0 END) where userid='".$user_boardid."'");
					if($stmt){
						show_msg($lang['sys.info'],$lang['suc.info1'].$tableinfo.'<br>'.$lang['template.str15'].$lang['template.str13'].'dv_topic,dv_besttopic,dv_upfile'.$lang['template.str16'],1,'','','alldel.php',$lang['cmdback']);
					exit;
					}
					else{
						show_msg($lang['sys.info'],$lang['suc.info2'],0,'','','alldel.php',$lang['cmdback']);
					exit;
					}
				}
			}
		}
	}
$db->free_result($otherup_stmt);
$db->free_result($result_table);
$db->free_result($result);
$db->free_result($count);
	if( $is_1 == 1 ) set_magic_quotes_runtime($is);
}
function forward_forum(){//删除指定日期内没有登录的用户;
	global $db,$lang,$dv,$forward_day;
	$forward_day=intval($_POST['forward_day']);
	$is=get_magic_quotes_runtime();
	if( $is == 0 ){
		set_magic_quotes_runtime(1);
		$is_1 = 1;
	}
	$getuser_result=$db->query("select userid,username,usergroupid from {$dv}user where lastlogin<'".dateAdd('d',-$forward_day,gmdate('Y-m-d 23:59:59'), '')."'");
	while($arrgetuser=$db->fetch_array($getuser_result)){
		if($arrgetuser['usergroupid']>3){
			$result=$db->query("select id,tablename,tabletype from {$dv}tablelist");
			while($arrtablelist=$db->fetch_array($result)){
				$delresult=$db->query("delete from ".$arrtablelist['tablename']." where postuserid='".$arrgetuser['userid']."'");
			}
		}
		$dv_besttopic_delresult=$db->query("delete from {$dv}besttopic where postuserid='".$arrgetuser['userid']."'");
		$dv_upfile_delresult=$db->query("delete from {$dv}upfile where f_userid='".$arrgetuser['userid']."'");
		$dv_message_delresult=$db->query("delete from {$dv}message where sender='".str_replace(" ","",$arrgetuser['username'])."'");
		$dv_friend_delresult=$db->query("delete from {$dv}friend where f_userid='".$arrgetuser['userid']."'");
		$dv_bookmark_delresult=$db->query("delete from {$dv}bookmark where username='".str_replace(" ","",$arrgetuser['username'])."'");
		$dv_topic_result=$db->query("select topicid,posttable from {$dv}topic where postuserid='".$arrgetuser['userid']."'");
		while($arrtopic=$db->fetch_array($dv_topic_result)){
			$topicresult=$db->query("delete from ".$arrtopic['posttable']." where rootid='".$arrtopic['topicid']."' and forumtype=0");
		}
		$del_result=$db->query("delete from {$dv}topic where postuserid='".$arrgetuser['userid']."'");
	}
	$user_num=$db->scalar("select count(1) from {$dv}user where lastlogin<'".dateAdd('d',-$forward_day,gmdate('Y-m-d 23:59:59'), '')."'");
	$del_userresult=$db->query("delete from {$dv}user where lastlogin<'".dateAdd('d',-$forward_day,gmdate('Y-m-d 23:59:59'), '')."'");
	if($del_userresult){
		show_msg($lang['sys.info'],$lang['suc.info1'].$lang['suc.info3'].$user_num.$lang['suc.info4'],1,'','','alldel.php',$lang['cmdback']);
	exit;
	}
	else{
		show_msg($lang['sys.info'],$lang['suc.info2'],0,'','','alldel.php',$lang['cmdback']);
	exit;	
	}
$db->free_result($user_num);
$db->free_result($dv_topic_result);
$db->free_result($result);
$db->free_result($getuser_result);
	if( $is_1 == 1 ) set_magic_quotes_runtime($is);
}
function movedate_forum(){//按日期移动;
	global $dv,$db,$lang,$day,$sourceid,$targetid;
	$backinfo='javascript:void(window.history.back(-1))';
	$forward_day=intval($_POST['forward_day']);
	$is=get_magic_quotes_runtime();
	if( $is == 0 ){
		set_magic_quotes_runtime(1);
		$is_1 = 1;
	}
	$day=intval($_POST['day']);
	$sourceid=intval($_POST['sourceid']);
	$targetid=intval($_POST['targetid']);
	if($day<0){
		show_msg($lang['sys.info'],$lang['move.info14'],0,'','',$backinfo,$lang['cmdback']);
		exit;	
	}
	if($sourceid==0 or $targetid==0){
		show_msg($lang['sys.info'],$lang['move.info13'],0,'','',$backinfo,$lang['cmdback']);
	exit;	
	}
	if($sourceid==$targetid){
		show_msg($lang['sys.info'],$lang['move.info16'],0,'','',$backinfo,$lang['cmdback']);
	exit;	
	}
	$result=$db->query("select posttable,isbest,istop,topicid from {$dv}topic where boardid ='".$sourceid."' and dateandtime<'".dateAdd('d',-$day,gmdate('Y-m-d 23:59:59'), '')."'");
	while ($arrinfo=$db->fetch_array($result)){
		$update_result1=$db->query("update ".$arrinfo['posttable']." set boardid='".$targetid."' where boardid='".$sourceid."' and rootid='".$arrinfo['topicid']."' and forumtype=0");
		$update_result2=$db->query("update {$dv}topic set boardid='".$targetid."' where boardid='".$sourceid."' and topicid='".$arrinfo['topicid']."'");
		if(intval($arrinfo['isbest'])==1){
			$update_result2=$db->query("update {$dv}besttopic set boardid='".$targetid."' where boardid='".$sourceid."' and rootid='".$arrinfo['topicid']."'");
		}
		if($arrinfo['istop']>0){
			$count_board1=$db->query("select boardtopstr from {$dv}board where boardid='".$sourceid."'");
			$arrcount_board1=$db->fetch_array($count_board1);
			$count_board2=$db->query("select boardtopstr from {$dv}board Where boardid='".$targetid."'");
			$arrcount_board2=$db->fetch_array($count_board2);
			$count_board1_str=str_replace((string)$arrcount_board1['boardtopstr'].",","",$arrcount_board1['boardtopstr']);
			$count_board1_str=str_replace(",".(string)$arrcount_board1['boardtopstr'],"",$count_board1_str);
			$count_board1_str=str_replace((string)$arrcount_board1,"",$count_board1_str);
			if($arrcount_board2['boardtopstr']=="" or empty($arrcount_board2['boardtopstr'])){
				$arrcount_board2['boardtopstr']=$arrinfo['topicid'];
			}
			elseif($arrcount_board2['boardtopstr']==$arrinfo['topicid']){
				$arrcount_board2['boardtopstr']=$arrcount_board2['boardtopstr'];
			}
			elseif(strpos($arrcount_board2['boardtopstr'],",".(string)$arrinfo['topicid'])>0){
				$arrcount_board2['boardtopstr']=$arrcount_board2['boardtopstr'];
			}
			else{
				$arrcount_board2['boardtopstr']=$arrcount_board2['boardtopstr'].",".(string)$arrinfo['topicid'];
			}
			$updateboard1=$db->query("update {$dv}board set boardtopstr='".$count_board1_str."' where boardid='".$sourceid."'");
			$updateboard2=$db->query("update {$dv}board set boardtopstr='".$arrcount_board2['boardtopstr']."' where boardid='".$targetid."'");
		}
	}//要在这加载缓存;
	if($update_result1 and $update_result2){
		show_msg($lang['sys.info'],$lang['move.info17'],1,'','',$backinfo,$lang['cmdback']);
	exit;
	}
	else{
		show_msg($lang['sys.info'],$lang['move.info18'],0,'','',$backinfo,$lang['cmdback']);
	exit;	
	}
$db->free_result($count_board1);
$db->free_result($count_board2);
$db->free_result($result);
	if( $is_1 == 1 ) set_magic_quotes_runtime($is);
}
function moveusername_forum(){//按用户移动;
	global $dv,$db,$lang,$user_name,$sourceid,$targetid;
	$backinfo='javascript:void(window.history.back(-1))';
	$forward_day=intval($_POST['forward_day']);
	$is=get_magic_quotes_runtime();
	if( $is == 0 ){
		set_magic_quotes_runtime(1);
		$is_1 = 1;
	}
	$user_name=str_replace(" ","",$_POST['user_name']);
	$sourceid=intval($_POST['sourceid']);
	$targetid=intval($_POST['targetid']);
	if($user_name==""){
		show_msg($lang['sys.info'],$lang['move.info15'],0,'','',$backinfo,$lang['cmdback']);
	exit;	
	}
	if($sourceid==0 or $targetid==0){
		show_msg($lang['sys.info'],$lang['move.info13'],0,'','',$backinfo,$lang['cmdback']);
	exit;	
	}
	if($sourceid==$targetid){
		show_msg($lang['sys.info'],$lang['move.info16'],0,'','',$backinfo,$lang['cmdback']);
	exit;	
	}
	$count_user=$db->scalar("select count(1) from {$dv}user where username='".$user_name."'");
	$user_result=$db->query("select userid from {$dv}user where username='".$user_name."'");
	$arruser=$db->fetch_array($user_result);
	if($count_user<=0){
		show_msg($lang['sys.info'],$lang['move.info19'],0,'','',$backinfo,$lang['cmdback']);
	exit;
	}
	else{
		$tableinfo_result=$db->query("select id,tablename,tabletype from {$dv}tablelist ");
		while($arrtablelist=$db->fetch_array($tableinfo_result)){
			$up_result=$db->query("update ".$arrtablelist['tablename']." set boardid='".$targetid."' where boardid='".$sourceid."' and postuserid='".$arruser['userid']."'");
		}
		$userinfo_result=$db->query("select topicid, posttable, istop from {$dv}topic where boardid='".$sourceid."' and postuserid='".$arruser['userid']."'");
		while($userinfolist=$db->fetch_array($userinfo_result)){
			$update_result1=$db->query("update ".$userinfolist['posttable']." set boardid='".$targetid."' where rootid='".$userinfolist['topicid']."' and forumtype=0");
			$update_result2=$db->query("update {$dv}topic set boardid='".$targetid."' where boardid='".$sourceid."' and topicid='".$userinfolist['topicid']."'");
			if($userinfolist['istop']>0){
				$user_board1=$db->query("select boardtopstr from {$dv}board where boardid='".$sourceid."'");
				$user_board2=$db->query("select boardtopstr from {$dv}board Where boardid='".$targetid."'");
				$arruser_board1=$db->fetch_array($user_board1);
				$arruser_board2=$db->fetch_array($user_board2);
				$user_board1_str=str_replace((string)$arruser_board1['boardtopstr'].",","",$arruser_board1['boardtopstr']);
				$user_board1_str=str_replace(",".(string)$arruser_board1['boardtopstr'],"",$user_board1_str);
				$user_board1_str=str_replace((string)$arruser_board1,"",$user_board1_str);
				if($arruser_board2['boardtopstr']=="" or empty($arruser_board2['boardtopstr'])){
					$arruser_board2['boardtopstr']=$userinfolist['topicid'];
				}
				elseif($arruser_board2['boardtopstr']==$userinfolist['topicid']){
					$arruser_board2['boardtopstr']=$arruser_board2['boardtopstr'];
				}
				elseif(strpos($arruser_board2['boardtopstr'],",".(string)$userinfolist['topicid'])>0){
					$arruser_board2['boardtopstr']=$arruser_board2['boardtopstr'];
				}
				else{
					$arruser_board2['boardtopstr']=$arruser_board2['boardtopstr'].",".(string)$userinfolist['topicid'];
				}
				$updateuser1=$db->query("update {$dv}board set boardtopstr='".$user_board1_str."' where boardid='".$sourceid."'");
				$updateuser2=$db->query("update {$dv}board set boardtopstr='".$arruser_board2['boardtopstr']."' where boardid='".$targetid."'");
			}
		}
	}//要在这加载缓存;
	if($updateuser1 and $updateuser2){
		show_msg($lang['sys.info'],$lang['move.info17'],1,'','',$backinfo,$lang['cmdback']);
	exit;
	}
	else{
		show_msg($lang['sys.info'],$lang['move.info18'],0,'','',$backinfo,$lang['cmdback']);
	exit;	
	}
$db->free_result($user_board1);
$db->free_result($user_board2);
$db->free_result($count_user);
$db->free_result($user_result);
$db->free_result($userinfo_result);
$db->free_result($tableinfo_result);
	if( $is_1 == 1 ) set_magic_quotes_runtime($is);
}
?>