<?php
define('THIS_SCRIPT', 'plus_tools_postings');
require_once 'global.php';
$lang = load_lang($lang, 'plus_tools_postings' );
$stats = $lang["HtmlTitle"];
$istoptable = 0;

$chkAction = true;
$toolsid = ( !is_numeric($toolsid) || $toolsid<=0 ? 0 : $toolsid );
$touserid = ( !is_numeric($touserid) || $touserid<=0 ? 0 : $touserid );
$topicid = ( !is_numeric($topicid) || $topicid<=0 ? 0 : $topicid );
$replyid = ( !is_numeric($replyid) || $replyid<=0 ? 0 : $replyid );
$action = ( !is_numeric($action) || $action<=0 ? 0 : intval($action) );
$__toolsInfo = false;
$__toolsSetting = false;
if( $action === 0 ){
	if( $userid <= 0 ){
		head();
		showmsg($lang['MustLogin'],0,'',false);
		exit;
	}
	if( $toolsid <= 0 ){
		head();
		showmsg($lang['Error.strings1'],0,'',false);
		exit;
	}
	$__toolsInfo =& getToolsInfo();
	if( $__toolsInfo === false ){
		head();
		showmsg($lang['Error.strings1'],0,'',false);
		exit;
	}
	$__toolsSetting = explode(',',$__toolsInfo['toolssetting']);
	$stats = str_replace('{$ToolsName}',$__toolsInfo['toolsname'],$lang['HtmlTitle_Repl']);
}
if( $topicid === 0 || $replyid === 0 || $boardid === 0 ){
	$chkAction = false;
}

head();

$actionFunc = "__ToolsAction_{$toolsid}";
if( !function_exists($actionFunc) ){
	showmsg($lang['Error.strings1'],0,'',false);
	exit;
	
}

define('DEBUG',false);
//Start 检查用户使用道具权限
if( DEBUG !== true ){//调试时关闭检查
	if( $__toolsInfo['isstar'] == 0 ){
		showmsg($lang['Error.strings2'],0,'',false);
		exit;
	}
	if( $__toolsInfo['usergroupid'] == '' || strpos(",{$__toolsInfo['usergroupid']},",",{$usergroupid},") === false ){
		showmsg($lang['Error.strings3'],0,'',false);
		exit;
	}
	if( $boardid > 0 && ( $__toolsInfo['boardid'] == '' || strpos(",{$__toolsInfo['boardid']},",",{$boardid},") === false ) ){
		showmsg($lang['Error.strings4'],0,'',false);
		exit;
	}
	if( $userinfo['userpost'] <= $__toolsInfo['userpost'] || $userinfo['userwealth'] <= $__toolsInfo['userwealth'] || $userinfo['userep'] <= $__toolsInfo['userep'] || $userinfo['usercp'] <= $__toolsInfo['usercp'] ){
		showmsg($lang['Error.strings5'],0,'',false);
		exit;
	}
	if( $userid == 0 || $toolsid == 0 ){
		showmsg($lang['Error.strings1'],0,'',false);
		exit;
	}
}
	$__bussInfo = false;
	if( $query = $db->query("SELECT id,userid,username,toolsid,toolsname,toolscount,salecount,updatetime,salemoney,saleticket FROM {$dv}plus_tools_buss WHERE toolscount>0 AND userid='{$userid}' AND toolsid='{$toolsid}'") ){
		$__bussInfo = $db->fetch_array($query);
	}
if( DEBUG !== true ){//调试时关闭检查
	if( $__bussInfo === false ){
		showmsg($lang['Error.strings1'],0,'',false);
		exit;
	}
}
	$__userToolsInfo =& $__bussInfo;
//End 检查用户使用道具权限

require INC_PATH.'DV_Encoding.class.php';
$actionFunc();
require printout('plus_tools_postings');

$db->close();

function &getToolsInfo(){
	global $dv,$db,$touserid;
	$toolsInfo = false;
	if( $query = $db->query("SELECT id,toolsname,toolsinfo,isstar,sysstock,userstock,usermoney,userpost,userwealth,userep,usercp,usergroupid,boardid,userticket,buytype,toolsimg,toolssetting FROM {$dv}plus_tools_info WHERE id='{$GLOBALS['toolsid']}'") ){
		$toolsInfo = $db->fetch_array($query);
	}
	return $toolsInfo;
}


function UpdateUserTools($argUserID,$argToolsID,$argLessenNum){//更新用户及系统道具数量(用户ID，道具ID，减少数量)
	global $dv,$db,$__toolsInfo;
	$bussID = $db->scalar("SELECT id FROM {$dv}plus_tools_buss WHERE userid='{$argUserID}' AND toolsid='{$argToolsID}'");
	if( $bussID === false ){
		$toolsName = $db->scalar("SELECT toolsname FROM {$dv}plus_tools_info WHERE id='{$argToolsID}'");
		if( $toolsName !== false ){
			$db->query("INSERT INTO {$dv}plus_tools_buss(userid,username,toolsid,toolsname,toolscount) VALUES('{$argUserID}','".$db->escape_string($__toolsInfo['toolsname'])."','{$argToolsID}','".$db->escape_string($toolsName)."','".$db->escape_string($argLessenNum)."')");
		}
	} else{
		$db->query("UPDATE {$dv}plus_tools_buss SET toolscount=toolscount".($argLessenNum<0?('+'.abs($argLessenNum)):"-{$argLessenNum}")." WHERE userid='{$argUserID}' AND toolsid='{$argToolsID}'");
	}
	$db->query("UPDATE {$dv}plus_tools_info SET userstock=userstock".($argLessenNum<0?('+'.abs($argLessenNum)):"-{$argLessenNum}")." WHERE id='{$argToolsID}'");
}

function UpdateBussTools($argUserID,$argToolsID,$n){//更新用户道具数量(用户ID，道具ID，减少数量)
	global $dv,$db,$__toolsInfo;
	$bussID = $db->scalar("SELECT id FROM {$dv}plus_tools_buss WHERE userid='{$argUserID}' AND toolsid='{$argToolsID}'");
	if( $bussID === false ){
		$toolsName = $db->scalar("SELECT toolsname FROM {$dv}plus_tools_info WHERE id='{$argToolsID}'");
		if( $toolsName !== false ){
			$db->query("INSERT INTO {$dv}plus_tools_buss(userid,username,toolsid,toolsname,toolscount) VALUES('{$argUserID}','".$db->escape_string($__toolsInfo['toolsname'])."','{$argToolsID}','".$db->escape_string($toolsName)."','".$db->escape_string($argLessenNum)."')");
		}
	} else{
		$db->query("UPDATE {$dv}plus_tools_buss SET toolscount=toolscount".($argLessenNum<0?('+'.abs($argLessenNum)):"-{$argLessenNum}")." WHERE userid='{$argUserID}' AND toolsid='{$argToolsID}'");
	}
}

function &getDestuserInfo($argUserID){
	global $lang,$dv,$db,$__toolsSetting;
//Start 判断目标用户使用权限并取出目标用户信息
	$destUserInfo = false;
	if( $query = $db->query("SELECT userid,username,lockuser,userpost,usertopic,usermoney,userticket,userwealth,userep,usercp,userpower,usergroupid FROM {$dv}user WHERE userid='{$argUserID}'") ){
		$destUserInfo = $db->fetch_array($query);
	}
	if( $destUserInfo === false ){
		showmsg($lang['Error.strings6'],0,'',false);
		return false;
	}
	if( $destUserInfo['userpost'] <= $__toolsSetting[0] || $destUserInfo['userwealth'] <= $__toolsSetting[1] || $destUserInfo['userep'] <= $__toolsSetting[2] || $destUserInfo['usercp'] <= $__toolsSetting[3] ){
		showmsg($lang['Error.strings7'],0,'',false);
		return false;
	}
	return $destUserInfo;
//End 判断目标用户使用权限并取出目标用户信息
}

function LoadUserTools($argStr,$argAddID){
	global $db;
	$returnVal = '';
	if( $argStr.'' === '' ){
		$returnVal = $argAddID;
	} else{
		$returnVal = $argStr.','.$argAddID;
	}
	if( $returnVal !== '' ){
		return $returnVal;
	} else{
		return '';
	}
}

function LoadTitle(&$argStr){
	global $db,$lang;
	$Tpl_BoardID = $GLOBALS['boardid'];
	$Tpl_TopicID = $GLOBALS['topicid'];
	$Tpl_ReplyID = $GLOBALS['replyid'];
	$Tpl_Str = htmlspecialchars($argStr);
	eval('$returnVal = "'.addslashes($lang['template.strings6']).'";');
	return $returnVal;
}

function AllboardNumSub($argTodayNum,$argPostNum,$argTopicNum){//所有论坛发帖数减少
	global $dv,$db;
	$db->query("UPDATE {$dv}setup SET forum_todaynum=forum_todaynum-'{$argTodayNum}',forum_postnum=forum_postnum-'{$argPostNum}',forum_topicnum=forum_topicnum-'{$argTopicNum}'");
}

function BoardNumSub($argBoardID,$argTopicNum,$argPostNum,$argTodayNum){//版面发帖数减少
	global $dv,$db,$boardid,$fsetting,$_DCACHE;
	if( empty($_DCACHE['all_forums']) ){
		include_once CACHE_PATH.'board/board_all.php';
	}
	$updateBoardIDList = $_DCACHE['all_forums']["{$boardid}"]['parentstr'].','.$boardid;
	$tmpRs = false;
	if( $query = $db->query("SELECT T.title,b.announceid,b.dateandtime,b.username,b.postuserid,b.rootid FROM ".$db->escape_string($fsetting['nowtablename'])." b INNER JOIN {$dv}topic T ON b.rootid=T.topicid WHERE b.boardid='{$argBoardID}' ORDER BY b.announceid DESC",array('pageSize'=>1)) ){
		$tmpRs = $db->fetch_array($query);
	}
	if( $tmpRs === false ){
		$tmpRs = array('title'=>$lang['template.strings7'],'announceid'=>0,'dateandtime'=>TIME_NOW,'username'=>$lang['template.strings7'],'postuserid'=>0,'rootid'=>0);
	} else{
		$objEnc =& DV_Encoding::GetEncoding($GLOBALS['charset']);
		$tmpRs['title'] = str_replace('$','',$objEnc->SubString($tmpRs['title'],0,15));
	}
	$lastPost = $tmpRs['username'].'$'.$tmpRs['announceid'].'$'.$tmpRs['dateandtime'].'$'.$tmpRs['title'].'$'.$uploadPic_n.'$'.$tmpRs['postuserid'].'$'.$tmpRs['rootid'].'$'.$boardid;
	//更新最后回复及帖子数
	$db->query("UPDATE {$dv}board SET postnum=postnum-'{$argPostNum}',topicnum=topicnum-'{$argTopicNum}',todaynum=todaynum-'{$argTodayNum}',lastpost='".$db->escape_string($lastPost)."' WHERE boardid IN(".$db->escape_string($updateBoardIDList).")");
}

function  newincept($argUuserName){//统计留言
	global $dv,$db;
	$newincept = $db->scalar("SELECT COUNT(1) FROM {$dv}message WHERE flag=0 AND issend=1 AND delr=0 AND incept='".$db->escape_string($argUuserName)."'");
	if( $newincept === false ){
		return 0;
	} else{
		return $newincept;
	}
}
function inceptid($argStype,$argUserName){
	global $dv,$db;
	$returnVal = '';
	$tmpRs =& $db->getResultSet("SELECT id,sender FROM {$dv}message WHERE flag=0 AND issend=1 AND delr=0 AND incept='".$db->escape_string($argUserName)."'",array('pageSize'=>1));
	if( $tmpRs !== false ){
		if( $argStyle == 1 ){
			$returnVal = $tmpRs[0]['id'];
		} elseif( $argStyle == 2 ){
			$returnVal = $tmpRs[0]['sender'];
		} else{
			$returnVal = "{$tmpRs[0]['id']}||{$tmpRs[0]['sender']}";
		}
	}
	return $returnVal;
}
function UPDATE_User_Msg($argUserName){//短信相关更新
	global $dv,$db;
	$newincept = newincept($argUserName);
	if( $newincept > 0 ){
		$msgInfo = "{$newincept}||".inceptid(3,$argUserName);
	} else{
		$msgInfo = "0||0||null";
	}
	$db->query("UPDATE {$dv}user SET usermsg='".$db->escape_string($msgInfo)."' WHERE username='".$db->escape_string($argUserName)."'");
}



/**
 *	道具:转让器，可进行道具、金币和点券的转让
 */
function __ToolsAction_1(){
	global $lang,$dv,$db,$__toolsInfo,$__toolsSetting,$touserid;
	$touserid = $GLOBALS['touserid'];
	if( $touserid <= 0 ){
		showmsg($lang['Error.strings6'],0,'',false);
		return false;
	}
	global $__destUserInfo;
	$__destUserInfo =& getDestuserInfo($touserid);
	if( $GLOBALS['toolsaction'] === 'SendTools' ){
		$SendToolsID = (!is_numeric($GLOBALS['sendtoolsid'])||$GLOBALS['sendtoolsid']<=0?0:$GLOBALS['sendtoolsid']);
		$SendToolsNum = (!is_numeric($GLOBALS['sendtoolsnum'])||$GLOBALS['sendtoolsnum']<=0?0:$GLOBALS['sendtoolsnum']);
		$SendMoneyNum = (!is_numeric($GLOBALS['sendmoneynum'])||$GLOBALS['sendmoneynum']<=0?0:$GLOBALS['sendmoneynum']);
		$SendTicketNum = (!is_numeric($GLOBALS['sendticketnum'])||$GLOBALS['sendticketnum']<=0?0:$GLOBALS['sendticketnum']);
		if( ($SendToolsID == 0 || $SendToolsNum == 0) && $SendMoneyNum == 0 && $SendTicketNum == 0 ){
			$LogMsg = $lang['Error.strings8'];
		} else{
			if( $GLOBALS['userid'] == $__destUserInfo['userid'] ){
				showmsg($lang['Error.strings9'],0,'',false);
				exit;
			}
			$LogMsg = str_replace('{$ToolsName}',$__toolsInfo['toolsname'],$lang['template.strings1']);
			//Start 金币转让
			if( $SendMoneyNum > 0 ){
				if( php_cCur($userinfo['usermoney']) < $SendMoneyNum ){
					showmsg($lang['Error.strings10'],0,'',false);
					exit;
				}
				$userinfo['usermoney'] = php_cCur($userinfo['usermoney']) - php_cCur($SendMoneyNum);
				$LogMsg .= str_replace('{$SendMoneyNum}',$SendMoneyNum,str_replace('{$ToUserName}',$__destuserInfo['username'],$lang['template.strings2']));
				UpdateUserInfoById($GLOBALS['userid'],array('usermoney'=>$userinfo['usermoney']));
				UpdateUserInfoById($__destUserInfo['userid'],array('usermoney'=>php_cCur($__destUserInfo['usermoney'])+php_cCur($SendMoneyNum)));
			}
			//End 金币转让
			//Start 点券转让
			if( $SendTicketNum > 0 ){
				if( php_cCur($userinfo['userticket']) < $SendTicketNum ){
					showmsg($lang['Error.strings10'],0,'',false);
					exit;
				}
				$userinfo['userticket'] = php_cCur($userinfo['userticket']) - php_cCur($SendTicketNum);
				$LogMsg .= str_replace('{$SendTicketNum}',$SendMoneyNum,str_replace('{$ToUserName}',$__destuserInfo['username'],$lang['template.strings3']));
				UpdateUserInfoById($GLOBALS['userid'],array('userticket'=>$userinfo['userticket']));
				UpdateUserInfoById($__destUserInfo['userid'],array('userticket'=>php_cCur($__destUserInfo['userticket'])+php_cCur($SendTicketNum)));
			}
			//End 点券转让
			//Start 道具转让
			if( $SendToolsID > 0 && $SendToolsNum > 0 ){
				$UserToolsNum = 0;
				$UserToolsNum = $db->scalar("SELECT toolscount FROM {$dv}plus_tools_buss WHERE toolscount>0 AND userid='{$GLOBALS['userid']}' AND toolsid='{$SendToolsID}'");
				if( $UserToolsNum === false ){
					showmsg($lang['Error.strings11'],0,'',false);
					exit;
				}
				if( $UserToolsNum < $SendToolsNum ){
					showmsg(str_replace('{$UserToolsNum}',$UserToolsNum,$lang['Error.strings12']),0,'',false);
					exit;
				}
				$_toolsName = $db->scalar("SELECT toolsname FROM {$dv}plus_tools_info WHERE id='{$SendToolsID}'");
				if( $_toolsName !== false ){
					$Tpl_ToUserName = $__destUserInfo['username'];
					$Tpl_SendToolsNum = $SendToolsNum;
					$Tpl_ToolsName = $_toolsName;
					eval('$LogMsg .= "'.addslashes($lang['template.strings4']).'";');
				}
				//更新用户和系统使用数量
				UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
				//更新用户道具数量
				UpdateBussTools($GLOBALS['userid'],$SendToolsID,$SendToolsNum);
				UpdateBussTools($__destUserInfo['userid'],$SendToolsID,-$SendToolsNum);
			}
			//End 道具转让
			ToolsLog($GLOBALS['toolsid'],1,0,0,2,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
		}
		showmsg($LogMsg,1,'',false);
		exit;
	} else{
		global $__toolsBussInfo;
		$__toolsBussInfo = $db->getResultSet("SELECT toolsid,toolsname,toolscount FROM {$dv}plus_tools_buss WHERE userid='{$GLOBALS['userid']}' ORDER BY toolscount DESC");
	}
}

/**
 *	道具:后悔药，可删除自己发表的帖子，有回复则不能删
 */
function __ToolsAction_2(){
	global $dv,$db,$lang,$__destUserInfo,$userid,$topicid,$__toolsInfo,$userinfo,$touserid;
	$__destUserInfo =& getDestuserInfo($touserid);
	if( $GLOBALS['userid'] != $__destUserInfo['userid'] ){
		showmsg($lang['Error.strings13'],0,'',false);
		exit;
	}
	$tmpRs = false;
	if( $query = $db->query("SELECT posttable,child FROM {$dv}topic WHERE topicid='{$topicid}' AND postuserid='{$userid}'") ){
		$tmpRs = $db->fetch_array($query);
	}
	if( $tmpRs === false ){
		showmsg($lang['Error.strings14'],0,'',false);
		exit;
	}
	if( $tmpRs['child'] > 0 ){
		showmsg($lang['Error.strings15'],0,'',false);
		exit;
	}
	$postTable = $tmpRs['posttable'];
	$tmpRs = false;
	if( $query = $db->query("SELECT topic,usetools,body,parentid,dateandtime FROM ".$db->escape_string($postTable)." WHERE announceid='{$GLOBALS['replyid']}' AND postuserid='{$userid}'") ){
		$tmpRs = $db->fetch_array($query);
	}
	if( $tmpRs === false ){
		showmsg($lang['Error.strings16'],0,'',false);
		exit;
	}
	$objEnc =& DV_Encoding::GetEncoding($GLOBALS['charset']);
	if( $tmpRs['topic'].'' === '' ){
		$tmpRs['topic'] = $objEnc->SubString($tmpRs['body'],0,25);
	}
	$ToolsIsToday = 0;
	$useTools = LoadUserTools($tmpRs['usetools'],$toolsid);
	if( dateDiff('d',$tmpRs['dateandtime'],TIME_NOW) == 0 ){
		$ToolsIsToday = 1;
	}
	if( $tmpRs['parentid'] == 0 ){
		$db->query("UPDATE {$dv}topic SET boardid=444,locktopic='{$GLOBALS['boardid']}',usetools='".$db->escape_string($useTools)."' WHERE topicid='{$GLOBALS['topicid']}'");
		$db->query("UPDATE ".$db->escape_string($postTable)." SET boardid=444,locktopic='{$GLOBALS['boardid']}',usetools='".$db->escape_string($useTools)."' WHERE announceid='{$GLOBALS['replyid']}'");
	} else{
		$db->query("UPDATE ".$db->escape_string($postTable)." SET boardid=444,locktopic='{$GLOBALS['boardid']}',usetools='".$db->escape_string($useTools)."' WHERE announceid='{$GLOBALS['replyid']}'");
	}
	//更新所有版面帖子数
	AllboardNumSub($ToolsIsToday,1,1);
	//更新相关版面帖子数
	BoardNumSub($GLOBALS['boardid'],1,1,$ToolsIsToday);
	UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
	$Tpl_ToolsName = $__toolsInfo['toolsname'];
	$Tpl_Title = LoadTitle($val['topic']);
	eval('$LogMsg = "'.addslashes($lang['template.strings5']).'";');
	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
	showmsg($LogMsg,1,'',false);
	exit;
}

/**
 *	道具:一级特赦令，可解除单帖屏蔽
 */
function __ToolsAction_3(){
	global $lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo;
	$postTable = $db->scalar("SELECT posttable FROM {$dv}topic WHERE topicid='{$GLOBALS['topicid']}'");
	if( $postTable === false ){
		showmsg($lang['Error.strings14'],0,'',false);
		exit;
	}
	$tmpRs = false;
	if( $query = $db->query("SELECT topic,usetools,body,postuserid FROM ".$db->escape_string($postTable)." WHERE announceid='{$GLOBALS['replyid']}' AND locktopic=2") ){
		$tmpRs = $db->fetch_array($query);
	}
	if( $tmpRs === false ){
		showmsg($lang['Error.strings17'],0,'',false);
		exit;
	}
	if( $tmpRs['topic'].'' === '' ){
		$objEnc =& DV_Encoding::GetEncoding($GLOBALS['charset']);
		$tmpRs['topic'] = $objEnc->SubString($tmpRs['body'],0,25);
	}
	//判断目标用户使用权限并取出目标用户信息
	$destUserInfo =& getDestuserInfo($tmpRs['postuserid']);
	$db->query("UPDATE ".$db->escape_string($postTable)." SET locktopic=0,usetools='".$db->escape_string($tmpRs['usetools'])."' WHERE announceid='{$GLOBALS['replyid']}'");
	UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
	$Tpl_ToolsName = $__toolsInfo['toolsname'];
	$Tpl_Title = LoadTitle($tmpRs['topic']);
	eval('$LogMsg = "'.addslashes($lang['template.strings8']).'";');
	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
	showmsg($LogMsg,1,'',false);
	exit;
}

/**
 *	道具:二级特赦令，可解除主题锁定
 */
function __ToolsAction_4(){
	global $lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo;
	if( $GLOBALS['chkAction'] === false ){
		showmsg($lang['Error.strings18'],0,'',false);
		exit;
	}
	$tmpRs = false;
	if( $query = $db->query("SELECT title,usetools,posttable FROM {$dv}topic WHERE topicid='{$GLOBALS['topicid']}' AND locktopic=1") ){
		$tmpRs = $db->fetch_array($query);
	}
	if( $tmpRs === false ){
		showmsg($lang['Error.strings19'],0,'',false);
		exit;
	}
	$tmpRs['usetools'] = LoadUserTools($tmpRs['usetools'],$GLOBALS['toolsid']);
	$db->query("UPDATE {$dv}topic SET locktopic=0,usetools='".$db->escape_string($tmpRs['usetools'])."' WHERE topicid='{$GLOBALS['topicid']}'");
	UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
	$Tpl_ToolsName = $__toolsInfo['toolsname'];
	$Tpl_Title = LoadTitle($tmpRs['title']);
	eval('$LosgMsg = "'.addslashes($lang['template.strings9']).'";');	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
	showmsg($LogMsg,1,'',false);
	exit;
}

/**
 *	道具:三级特赦令，解除自己或他人的屏蔽或锁定状态
 */
function __ToolsAction_5(){
	global $lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$touserid,$touserid;
	if( $GLOBALS['touserid'] <= 0 ){
		showmsg($lang['Error.strings18'],0,'',false);
		exit;
	}
	//判断目标用户使用权限并取出目标用户信息
	$destUserInfo =& getDestuserInfo($GLOBALS['touserid']);
	$destUserID = $db->scalar("SELECT userid FROM {$dv}user WHERE userid='{$GLOBALS['touserid']}' AND lockuser>0");
	if( $destUserID === false ){
		showmsg($lang['Error.strings20'],0,'',false);
		exit;
	}
	$db->query("UPDATE {$dv}user SET lockuser=0 WHERE userid='{$destUserID}'");
	UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
	$Tpl_ToolsName = $__toolsInfo['toolsname'];
	$Tpl_DestUserName = $destUserInfo['username'];
	eval('$LosgMsg = "'.addslashes($lang['template.strings10']).'";');	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
	showmsg($LogMsg,1,'',false);
	exit;
}

/**
 *	道具:吖噗鸡，可使帖子提升到第一页
 */
function __ToolsAction_6(){
	global $lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo;
	if( $GLOBALS['chkAction'] === false ){
		showmsg($lang['Error.strings18'],0,'',false);
		exit;
	}
	$tmpRs = false;
	if( $query = $db->query("SELECT title,usetools,posttable FROM {$dv}topic WHERE topicid='{$GLOBALS['topicid']}' AND locktopic=1") ){
		$tmpRs = $db->fetch_array($query);
	}
	if( $tmpRs === false ){
		showmsg($lang['Error.strings19'],0,'',false);
		exit;
	}
	$tmpRs['usetools'] = LoadUserTools($tmpRs['usetools'],$GLOBALS['toolsid']);
	$db->query("UPDATE {$dv}topic SET lastposttime='".TIME_NOW."',usetools='".$db->escape_string($tmpRs['usetools'])."' Where topicid='{$GLOBALS['topicid']}'");
	UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
	$Tpl_ToolsName = $__toolsInfo['toolsname'];
	$Tpl_Title = LoadTitle($tmpRs['title']);
	eval('$LosgMsg = "'.addslashes($lang['template.strings11']).'";');	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
	showmsg($LogMsg,1,'',false);
	exit;
}

/**
 *	道具:醒目灯，可将主题变色
 */
function __ToolsAction_7(){
	global $lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$__topicInfo7,$toolsColorList;
	if( $GLOBALS['chkAction'] === false ){
		showmsg($lang['Error.strings18'],0,'',false);
		exit;
	}
	$__topicInfo7 = false;
	if( $query = $db->query("SELECT title,usetools,posttable FROM {$dv}topic WHERE topicid='{$GLOBALS['topicid']}'") ){
		$__topicInfo7 = $db->fetch_array($query);
	}
	if( $__topicInfo7 === false ){
		showmsg($lang['Error.strings19'],0,'',false);
		exit;
	}
	$__topicInfo7['usetools'] = $db->escape_string(LoadUserTools($__topicInfo7['usetools'],$GLOBALS['toolsid']));
	$toolsColorList = "#000000,#F0F8FF,#FAEBD7,#00FFFF,#7FFFD4,#F0FFFF,#F5F5DC,#FFE4C4,#000000,#FFEBCD,#0000FF,#8A2BE2,#A52A2A,#DEB887,#5F9EA0,#7FFF00,#D2691E,#FF7F50,#6495ED,#FFF8DC,#DC143C,#00FFFF,#00008B,#008B8B,#B8860B,#A9A9A9,#006400,#BDB76B,#8B008B,#556B2F,#FF8C00,#9932CC,#8B0000,#E9967A,#8FBC8F,#483D8B,#2F4F4F,#00CED1,#9400D3,#FF1493,#00BFFF,#696969,#1E90FF,#B22222,#FFFAF0,#228B22,#FF00FF,#DCDCDC,#F8F8FF,#FFD700,#DAA520,#808080,#008000,#ADFF2F,#F0FFF0,#FF69B4,#CD5C5C,#4B0082,#FFFFF0,#F0E68C,#E6E6FA,#FFF0F5,#7CFC00,#FFFACD,#ADD8E6,#F08080,#E0FFFF,#FAFAD2,#90EE90,#D3D3D3,#FFB6C1,#FFA07A,#20B2AA,#87CEFA,#778899,#B0C4DE,#FFFFE0,#00FF00,#32CD32,#FAF0E6,#FF00FF,#800000,#66CDAA,#0000CD,#BA55D3,#9370DB,#3CB371,#7B68EE,#00FA9A,#48D1CC,#C71585,#191970,#F5FFFA,#FFE4E1,#FFE4B5,#FFDEAD,#000080,#FDF5E6,#808000,#6B8E23,#FFA500,#FF4500,#DA70D6,#EEE8AA,#98FB98,#AFEEEE,#DB7093,#FFEFD5,#FFDAB9,#CD853F,#FFC0CB,#DDA0DD,#B0E0E6,#800080,#FF0000,#BC8F8F,#4169E1,#8B4513,#FA8072,#F4A460,#2E8B57,#FFF5EE,#A0522D,#C0C0C0,#87CEEB,#6A5ACD,#708090,#FFFAFA,#00FF7F,#4682B4,#D2B48C,#008080,#D8BFD8,#FF6347,#40E0D0,#EE82EE,#F5DEB3,#FFFFFF,#F5F5F5,#FFFF00,#9ACD32";
	if( $GLOBALS['toolsaction'] === 'SendColor' ){
		if( strpos(",{$toolsColorList},",",{$GLOBALS['color']},") === false ){
			showmsg($lang['Error.strings21'],0,'',false);
			exit;
		}
		$__topicInfo7['title'] = '<font color="'.$GLOBALS['color'].'">'.$__topicInfo7['title'].'</font>';
		$db->query("UPDATE {$dv}topic SET title='".$db->escape_string($__topicInfo7['title'])."',topicmode=1,usetools='{$__topicInfo7['usetools']}' WHERE topicid='{$GLOBALS['topicid']}'");
		$db->query("UPDATE ".$db->escape_string($__topicInfo7['posttable'])." SET topic='".$db->escape_string($__topicInfo7['title'])."',usetools='{$__topicInfo7['usetools']}' WhERE rootid='{$GLOBALS['topicid']}' AND parentid=0 and forumtype=0");
		UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
		$Tpl_ToolsName = $__toolsInfo['toolsname'];
		$Tpl_Title = htmlspecialchars(LoadTitle($__topicInfo7['title']));
		eval('$LosgMsg = "'.addslashes($lang['template.strings12']).'";');	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
		showmsg($lang['template.strings37'],1,'',false);
		exit;
	}
}

/**
 *	道具:水晶球，可查看发帖用户IP
 */
function __ToolsAction_8(){
	global $lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$toolsColorList;
	$postTable = $db->scalar("SELECT usetools FROM {$dv}topic WHERE topicid='{$GLOBALS['topicid']}'");
	if( $postTable === false ){
		showmsg($lang['Error.strings14'],0,'',false);
		exit;
	}
	$tmpRs = false;
	if( $query = $db->query("SELECT topic,usetools,body,ip,postuserid FROM ".$db->escape_string($postTable)." WHERE announceid='{$GLOBALS['replyid']}'") ){
	}
	if( $tmpRs === false ){
		showmsg($lang['Error.strings16'],0,'',false);
		exit;
	}
	if( $tmpRs['topic'].'' === '' ){
		$objEnc =& DV_Encoding::GetEndoging($GLOBALS['charset']);
		$tmpRs['topic'] = $objEnc->SubString($tmpRs['body'],0,25);
	}
	$tmpRs['usetools'] = $db->escape_string(LoadUserTools($tmpRs['usetools'],$GLOBALS['toolsid']));
	//判断目标用户使用权限并取出目标用户信息
	getDestuserInfo($tmpRs['postuserid']);
	$db->query("UPDATE ".$db->escape_string($postTable)." SET usetools='{$tmpRs['usetools']}' WHERE announceid='{$GLOBALS['replyid']}'");
	UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
	$Tpl_ToolsName = $__toolsInfo['toolsname'];
	$Tpl_Title = htmlspecialchars(LoadTitle($tmpRs['topic']));
	$Tpl_ReplyID = $GLOBALS['replyid'];
	$Tpl_ToUserToolsIP = $tmpRs['ip'];
	eval('$LosgMsg = "'.addslashes($lang['template.strings13']).'";');	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
	showmsg($LogMsg,1,'',false);
	exit;
}

/**
 *	道具:追踪器，可查看发帖用户的IP和来源
 */
function __ToolsAction_9(){
	global $lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$toolsColorList;
	$postTable = $db->scalar("SELECT usetools FROM {$dv}topic WHERE topicid='{$GLOBALS['topicid']}'");
	if( $postTable === false ){
		showmsg($lang['Error.strings14'],0,'',false);
		exit;
	}
	$tmpRs = false;
	if( $query = $db->query("SELECT topic,usetools,body,ip,postuserid FROM ".$db->escape_string($postTable)." WHERE announceid='{$GLOBALS['replyid']}'") ){
	}
	if( $tmpRs === false ){
		showmsg($lang['Error.strings16'],0,'',false);
		exit;
	}
	if( $tmpRs['topic'].'' === '' ){
		$objEnc =& DV_Encoding::GetEndoging($GLOBALS['charset']);
		$tmpRs['topic'] = $objEnc->SubString($tmpRs['body'],0,25);
	}
	$tmpRs['usetools'] = $db->escape_string(LoadUserTools($tmpRs['usetools'],$GLOBALS['toolsid']));
	//判断目标用户使用权限并取出目标用户信息
	getDestuserInfo($tmpRs['postuserid']);
	$db->query("UPDATE ".$db->escape_string($postTable)." SET usetools='{$tmpRs['usetools']}' WHERE announceid='{$GLOBALS['replyid']}'");
	UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
	$Tpl_ToolsName = $__toolsInfo['toolsname'];
	$Tpl_Title = htmlspecialchars(LoadTitle($tmpRs['topic']));
	$Tpl_ReplyID = $GLOBALS['replyid'];
	$Tpl_ToUserToolsIP = $tmpRs['ip'];
	$Tpl_IPFrom = ipfrom($tmpRs['ip']);
	eval('$LosgMsg = "'.addslashes($lang['template.strings14']).'";');	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
	showmsg($LogMsg,1,'',false);
	exit;
}

/**
 *	道具:一星龙珠，可将用户所有负分转为0
 */
function __ToolsAction_10(){
	global $lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$toolsColorList,$touserid;
	if( $GLOBALS['touserid'] <= 0 ){
		showmsg($lang['Error.strings18'],0,'',false);
		exit;
	}
	//判断目标用户使用权限并取出目标用户信息
	$destUserInfo =& getDestuserInfo($GLOBALS['touserid']);
	//更新用户分值信息
	$db->query("UPDATE {$dv}user SET userwealth=(CASE WHEN userwealth<0 THEN 0 ELSE userwealth END),userep=(CASE WHEN userep<0 THEN 0 ELSE userep END),usercp=(CASE WHEN usercp<0 THEN 0 ELSE usercp END),userpower=(CASE WHEN userpower<0 THEN 0 ELSE userpower END),userdel=(CASE WHEN userdel<0 THEN 0 ELSE userdel END) WHERE userid='{$destUserInfo['userid']}'");
	//更新用户和系统使用数量
	UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
	$Tpl_ToolsName = $__toolsInfo['toolsname'];
	$Tpl_DestUserName = $destUserInfo['username'];
	eval('$LosgMsg = "'.addslashes($lang['template.strings15']).'";');	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
	showmsg($LogMsg,1,'',false);
	exit;
}

/**
 *	道具:二星龙珠，可将用户经验负分转为0
 */
function __ToolsAction_11(){
	global $lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$toolsColorList,$touserid;
	if( $GLOBALS['touserid'] <= 0 ){
		showmsg($lang['Error.strings18'],0,'',false);
		exit;
	}
	//判断目标用户使用权限并取出目标用户信息
	$destUserInfo =& getDestuserInfo($GLOBALS['touserid']);
	//更新用户分值信息
	$db->query("UPDATE {$dv}user SET userep=(CASE WHEN userep<0 THEN 0 ELSE userep END) WHERE userid='{$destUserInfo['userid']}'");
	//更新用户和系统使用数量
	UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
	$Tpl_ToolsName = $__toolsInfo['toolsname'];
	$Tpl_DestUserName = $destUserInfo['username'];
	eval('$LosgMsg = "'.addslashes($lang['template.strings15_1']).'";');	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
	showmsg($LogMsg,1,'',false);
	exit;
}

/**
 *	道具:狗仔队，可在用户上线第一时间获知
 */
function __ToolsAction_12(){
	global $lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$toolsColorList,$touserid;
	if( $GLOBALS['touserid'] <= 0 ){
		showmsg($lang['Error.strings18'],0,'',false);
		exit;
	}
	//判断目标用户使用权限并取出目标用户信息
	$destUserInfo =& getDestuserInfo($GLOBALS['touserid']);
	//更新用户信息
	$db->query("UPDATE {$dv}user SET followmsgid=(CASE WHEN followmsgid='' OR followmsgid IS NULL THEN '{$GLOBALS['membername']}' ELSE CONCAT(followmsgid,',','{$GLOBALS['membername']}') END) WHERE userid='{$destUserInfo['userid']}'");
	//更新用户和系统使用数量
	UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
	$Tpl_ToolsName = $__toolsInfo['toolsname'];
	$Tpl_DestUserName = $destUserInfo['username'];
	eval('$LosgMsg = "'.addslashes($lang['template.strings16']).'";');	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
	showmsg($LogMsg,1,'',false);
	exit;
}

/**
 *	道具:救生圈，可将帖子固顶6小时
 */
function __ToolsAction_13(){
	global $lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$toolsColorList;
	if( $GLOBALS['chkAction'] <= 0 ){
		showmsg($lang['Error.strings18'],0,'',false);
		exit;
	}
	$tmpRs = false;
	if( $query = $db->query("SELECT title,usetools,posttable FROM {$dv}topic WHERE topicid='{$GLOBALS['topicid']}'") ){
		$tmpRs = $db->fetch_array($query);
	}
	if( $tmpRs === false ){
		showmsg($lang['Error.strings14'],0,'',false);
		exit;
	}
	$tmpRs['usetools'] = $db->escape_string(LoadUserTools($tmpRs['usetools'],$GLOBALS['toolsid']));
	$db->query("UPDATE {$dv}topic SET lastposttime='".dateAdd('h', 6, TIME_NOW, '')."',usetools='{$tmpRs['usetools']}' WHERE topicid='{$GLOBALS['topicid']}'");
	UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
	$Tpl_ToolsName = $__toolsInfo['toolsname'];
	$Tpl_Title = $tmpRs['title'];
	eval('$LosgMsg = "'.addslashes($lang['template.strings17']).'";');	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
	showmsg($LosgMsg,1,'',false);
	exit;
}

/**
 *	道具:大救生圈，可将帖子固顶12小时
 */
function __ToolsAction_14(){
	global $lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$toolsColorList;
	if( $GLOBALS['chkAction'] <= 0 ){
		showmsg($lang['Error.strings18'],0,'',false);
		exit;
	}
	$tmpRs = false;
	if( $query = $db->query("SELECT title,usetools,posttable FROM {$dv}topic WHERE topicid='{$GLOBALS['topicid']}'") ){
		$tmpRs = $db->fetch_array($query);
	}
	if( $tmpRs === false ){
		showmsg($lang['Error.strings14'],0,'',false);
		exit;
	}
	$tmpRs['usetools'] = $db->escape_string(LoadUserTools($tmpRs['usetools'],$GLOBALS['toolsid']));
	$db->query("UPDATE {$dv}topic SET lastposttime='".dateAdd('h', 12, TIME_NOW, '')."',usetools='{$tmpRs['usetools']}' WHERE topicid='{$GLOBALS['topicid']}'");
	UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
	$Tpl_ToolsName = $__toolsInfo['toolsname'];
	$Tpl_Title = $tmpRs['title'];
	eval('$LogMsg = "'.addslashes($lang['template.strings18']).'";');	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
	showmsg($LogMsg,1,'',false);
	exit;
}

/**
 *	道具:时空转移机 可将自已的帖子移动到任意版面（隐含、特殊限定版面除外）。
 */
function __ToolsAction_15(){
	global $lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$toolsColorList;
}

/**
 *	道具:照妖镜 可查看匿名发帖用户名。
 */
function __ToolsAction_16(){
	global $lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$toolsColorList;
	$postTable = $db->scalar("SELECT posttable FROM {$dv}topic WHERE topicid='{$GLOBALS['topicid']}'");
	if( $postTable === false ){
		showmsg($lang['Error.strings14'],0,'',false);
		exit;
	}
	$tmpRs = false;
	if( $query = $db->query("SELECT topic,usetools,body,postuserid FROM ".$db->escape_string($postTable)." WHERE announceid='{$GLOBALS['replyid']}'") ){
		$tmpRs = $db->fetch_array($query);
	}
	if( $tmpRs === false ){
		showmsg($lang['Error.strings16'],0,'',false);
		exit;
	}
	if( $tmpRs['topic'].'' === '' ){
		$objEnc =& DV_Encoding::GetEncoding($GLOBALS['charset']);
		$tmpRs['topic'] = $objEnc->SubString($tmpRs['topic'],0,25);
	}
	$tmpRs['usetools'] = $db->escape_string(LoadUserTools($tmpRs['usetools'],$GLOBALS['toolsid']));
	//判断目标用户使用权限并取出目标用户信息
	$destUserInfo =& getDestuserInfo($tmpRs['postuserid']);
	$db->query("UPDATE ".$db->escape_string($postTable)." SET usetools='{$tmpRs['usetools']}' WHERE announceid='{$GLOBALS['replyid']}'");
	UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
	$Tpl_ToolsName = $__toolsInfo['toolsname'];
	$Tpl_Title = LoadTitle($tmpRs['topic']);
	$Tpl_PostUser = $destUserInfo['username'];
	eval('$LosgMsg = "'.addslashes($lang['template.strings19']).'";');	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
	showmsg($LogMsg,1,'',false);
	exit;
}

/**
 *	道具:晶体探测器 可将匿名发帖用户信息直接转为真实信息，并公开显示状态。
 */
function __ToolsAction_17(){
	global $lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$toolsColorList;
	$postTable = $db->scalar("SELECT posttable FROM {$dv}topic WHERE topicid='{$GLOBALS['topicid']}'");
	if( $postTable === false ){
		showmsg($lang['Error.strings14'],0,'',false);
		exit;
	}
	$tmpRs = false;
	if( $query = $db->query("SELECT topic,usetools,body,postuserid,parentid FROM ".$db->escape_string($postTable)." WHERE announceid='{$GLOBALS['replyid']}'") ){
		$tmpRs = $db->fetch_array($query);
	}
	if( $tmpRs === false ){
		showmsg($lang['Error.strings16'],0,'',false);
		exit;
	}
	if( $tmpRs['topic'].'' === '' ){
		$objEnc =& DV_Encoding::GetEncoding($GLOBALS['charset']);
		$tmpRs['topic'] = $objEnc->SubString($tmpRs['topic'],0,25);
	}
	$tmpRs['usetools'] = $db->escape_string(LoadUserTools($tmpRs['usetools'],$GLOBALS['toolsid']));
	//判断目标用户使用权限并取出目标用户信息
	$destUserInfo =& getDestuserInfo($tmpRs['postuserid']);
	if( $tmpRs['parentid'] == 0 ){
		$db->query("UPDATE {$dv}topic SET hidename=0 WHERE topicid='{$GLOBALS['topicid']}'");
	}
	$db->query("UPDATE ".$db->escape_string($postTable)." SET usetools='{$tmpRs['usetools']}',signflag=0 WHERE announceid='{$GLOBALS['replyid']}'");
	UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
	$Tpl_ToolsName = $__toolsInfo['toolsname'];
	$Tpl_Title = LoadTitle($tmpRs['topic']);
	eval('$LosgMsg = "'.addslashes($lang['template.strings20']).'";');	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
	showmsg($LogMsg,1,'',false);
	exit;
}

/**
 *	道具:精灵弓，可破坏小救生圈效果，对大救生圈效果破坏1/6
 */
function __ToolsAction_18(){
	global $lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$toolsColorList;
	if( $GLOBALS['chkAction'] <= 0 ){
		showmsg($lang['Error.strings18'],0,'',false);
		exit;
	}
	$tmpRs = false;
	if( $query = $db->query("SELECT title,usetools,posttable FROM {$dv}topic WHERE topicid='{$GLOBALS['topicid']}'") ){
		$tmpRs = $db->fetch_array($query);
	}
	if( $tmpRs === false ){
		showmsg($lang['Error.strings14'],0,'',false);
		exit;
	}
	if( $tmpRs['usetools'].'' === '' ){
		showmsg($lang['Error.strings23'],0,'',false);
		exit;
	}
	$canUserTools = false;
	if( strpos(",{$tmpRs['usetools']},",',13,') !== false ){
		$canUserTools = true;
	}
	if( strpos(",{$tmpRs['usetools']},",',14,') !== false ){
		$canUserTools = true;
	}
	if( $canUserTools === false ){
		showmsg($lang['Error.strings23'],0,'',false);
		exit;
	}
	$tmpRs['usetools'] = $db->escape_string(LoadUserTools($tmpRs['usetools'],$GLOBALS['toolsid']));
	if( strpos(",{$tmpRs['usetools']},",',13,') !== false ){
		$db->query("UPDATE {$dv}topic SET lastposttime='".dateAdd('h', -6, TIME_NOW, '')."',usetools='{$tmpRs['usetools']}' WHERE  topicid='{$GLOBALS['topicid']}'");
	} elseif( strpos(",{$tmpRs['usetools']},",',14,') !== false ){
		$db->query("UPDATE {$dv}topic SET lastposttime='".dateAdd('h', -2, TIME_NOW, '')."',usetools='{$tmpRs['usetools']}' WHERE  topicid='{$GLOBALS['topicid']}'");
	}
	UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
	$Tpl_ToolsName = $__toolsInfo['toolsname'];
	$Tpl_Title = LoadTitle($tmpRs['title']);
	eval('$LosgMsg = "'.addslashes($lang['template.strings21']).'";');	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
	showmsg($LogMsg,1,'',false);
	exit;
}

/**
 *	道具:水之母，可延长大小救生圈固顶效果时限的1/6
 */
function __ToolsAction_19(){
	global $lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$toolsColorList;
	if( $GLOBALS['chkAction'] <= 0 ){
		showmsg($lang['Error.strings18'],0,'',false);
		exit;
	}
	$tmpRs = false;
	if( $query = $db->query("SELECT title,usetools,posttable FROM {$dv}topic WHERE topicid='{$GLOBALS['topicid']}'") ){
		$tmpRs = $db->fetch_array($query);
	}
	if( $tmpRs === false ){
		showmsg($lang['Error.strings14'],0,'',false);
		exit;
	}
	if( $tmpRs['usetools'].'' === '' ){
		showmsg($lang['Error.strings23'],0,'',false);
		exit;
	}
	$canUserTools = false;
	if( strpos(",{$tmpRs['usetools']},",',13,') !== false ){
		$canUserTools = true;
	}
	if( strpos(",{$tmpRs['usetools']},",',14,') !== false ){
		$canUserTools = true;
	}
	if( $canUserTools === false ){
		showmsg($lang['Error.strings23'],0,'',false);
		exit;
	}
	$tmpRs['usetools'] = $db->escape_string(LoadUserTools($tmpRs['usetools'],$GLOBALS['toolsid']));
	if( strpos(",{$tmpRs['usetools']},",',13,') !== false ){
		$db->query("UPDATE {$dv}topic SET lastposttime='".dateAdd('h', 1 , TIME_NOW, '')."',usetools='{$tmpRs['usetools']}' WHERE  topicid='{$GLOBALS['topicid']}'");
	} elseif( strpos(",{$tmpRs['usetools']},",',14,') !== false ){
		$db->query("UPDATE {$dv}topic SET lastposttime='".dateAdd('h', 2, TIME_NOW, '')."',usetools='{$tmpRs['usetools']}' WHERE  topicid='{$GLOBALS['topicid']}'");
	}
	UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
	$Tpl_ToolsName = $__toolsInfo['toolsname'];
	$Tpl_Title = LoadTitle($tmpRs['title']);
	eval('$LosgMsg = "'.addslashes($lang['template.strings22']).'";');	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
	showmsg($LogMsg,1,'',false);
	exit;
}

/**
 *	道具:转生之炎,可将更改自已在论坛的用户名。。
 */
function __ToolsAction_20(){
	global $_POST,$lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$toolsColorList,$chkAction,$userid,$membername;
	if( $GLOBALS['toolsaction'] === 'ChangeID' ){
		if( ChkPost() === false ){
			showmsg($lang['Error.strings24'],0,'',false);
			exit;
		}
		$NewUserName = trim($_POST['name']);
		//验证用户名字符长度是否符合论坛标准
		list($userNameMinLength,$userNameMaxLength) = explode(',',$fsetting['usernamelength']);
		$objEnc = DV_Encoding::GetEncoding($GLOBALS['charset']);
		$newNameLength = $objEnc->StrLength($NewUserName);
		if( $NewUserName === '' || $newNameLength > $userNameMaxLength || $newNameLength < $userNameMinLength ){
			showmsg($lang['Error.strings25'],0,'',false);
			exit;
		}
		//验证用户名是否含有禁止字符；
		if( preg_match('#=|%|'.chr(32).'|\?|&|;|,|\'|'.chr(34).'|'.chr(9).'|'.preg_quote($lang['tpl.str37']).'|\$|'.preg_quote($lang['tpl.str38']).'|\|#i',$NewUserName) === 1 ){
			showmsg($lang['Error.strings26'],0,'',false);
			exit;
		}
		//验证用户名是注册过禁止字符；
		if( false ){
			showmsg($lang['Error.strings26'],0,'',false);
			exit;
		}
		//新用户名是否有重复
		$dbUserName = $db->scalar("SELECT username FROM {$dv}user WHERE username='{$NewUserName}'");
		if( $dbUserName !== false ){
			showmsg($lang['Error.strings27'],0,'',false);
			exit;
		}
		//更新道具表用户名数据
		$db->query("UPDATE {$dv}plus_tools_buss SET username='{$NewUserName}' WHERE userid='{$userid}'");
		$db->query("UPDATE {$dv}moneylog SET addusername='{$NewUserName}' WHERE adduserid='{$userid}'");
		//更新论坛用户名所有数据
		$db->query("UPDATE {$dv}admin SET adduser='{$NewUserName}' WHERE adduser='{$membername}'");
		$db->query("UPDATE {$dv}user SET username='{$NewUserName}' WHERE userid='{$userid}'");
		$db->query("UPDATE {$dv}bbsnews SET username='{$NewUserName}' WHERE username='{$membername}'");
		$db->query("UPDATE {$dv}besttopic SET postusername='{$NewUserName}' WHERE postuserid='{$userid}'");
		$db->query("UPDATE {$dv}bookmark SET username='{$NewUserName}' WHERE username='{$membername}'");
		$db->query("UPDATE {$dv}friend SET f_username='{$NewUserName}' WHERE f_userid='{$userid}'");
		$db->query("UPDATE {$dv}friend SET f_friend='{$NewUserName}' WHERE f_friend='{$membername}'");
		$db->query("UPDATE {$dv}log SET l_username='{$NewUserName}' WHERE l_username='{$membername}'");
		$db->query("UPDATE {$dv}message SET sender='{$NewUserName}' WHERE sender='{$membername}'");
		$db->query("UPDATE {$dv}message SET incept='{$NewUserName}' WHERE incept='{$membername}'");
		$db->query("UPDATE {$dv}online SET username='{$NewUserName}' WHERE userid='{$userid}'");
		$db->query("UPDATE {$dv}smallpaper SET s_username='{$NewUserName}' WHERE s_username='{$membername}'");
		$db->query("UPDATE {$dv}upfile SET f_username='{$NewUserName}' WHERE f_userid='{$userid}'");
		$db->query("UPDATE {$dv}topic SET postusername='{$NewUserName}' WHERE postuserid='{$userid}'");
		$arrTableName =& $db->getResultSet("SELECT tablename,tabletype FROM {$dv}tablelist");
		if( $arrTableName !== false && is_array($arrTableName) ){
			foreach( $arrTableName as $val ){
				$db->query("UPDATE /*! LOW_PRIORITY */ ".$db->escape_string($val)." SET userame='{$NewUserName}' WHERE postuserid='{$userid}'");
			}
		}
		//更新版块出现的用户名
		if( false ){
			if( $IsSqlDataBase === false ){//Mysql更新
				$db->query("UPDATE {$dv}board SET @tmpStr:=REPLACE(CONCAT('|',boardmaster,'|'),'|{$membername}|','|{$NewUserName}|'),boardmaster=(CASE WHEN (@tmpLen:=LENGTH(@tmpStr))>=3 THEN SUBSTRING(@tmpStr,2,@tmpLen-2) ELSE boardmaster END),@tmpStr:=REPLACE(CONCAT('$',lastpost,'$'),'${$membername}$','${$NewUserName}$'),lastpost=(CASE WHEN (@tmpLen:=LENGTH(@tmpStr))>=3 THEN SUBSTRING(@tmpStr,2,@tmpLen-2) ELSE lastpost END),@tmpStr:=REPLACE(CONCAT(',',boarduser,','),',{$membername},',',{$NewUserName},'),boarduser=(CASE WHEN (@tmpLen:=LENGTH(@tmpStr))>=3 THEN SUBSTRING(@tmpStr,2,@tmpLen-2) ELSE boarduser END)");
			} else{//MSSQL更新
				$db->query("DECLARE @tmpStr TEXT;DECLARE @tmpLen INT;");
				$db->query("UPDATE {$dv}board SET @tmpStr:=REPLACE('|'+boardmaster+'|','|{$membername}|','|{$NewUserName}|'),boardmaster=(CASE WHEN (@tmpLen=LEN(@tmpStr))>=3 THEN SUBSTRING(@tmpStr,2,@tmpLen-2) ELSE boardmaster END),@tmpStr=REPLACE('$'+lastpost+'$','${$membername}$','${$NewUserName}$'),lastpost=(CASE WHEN (@tmpLen=LEN(@tmpStr))>=3 THEN SUBSTRING(@tmpStr,2,@tmpLen-2) ELSE lastpost END),@tmpStr=REPLACE(','+boarduser+',',',{$membername},',',{$NewUserName},'),boarduser=(CASE WHEN (@tmpLen=LEN(@tmpStr))>=3 THEN SUBSTRING(@tmpStr,2,@tmpLen-2) ELSE boarduser END)");
			}
		} else{//以下代码是为数据库兼容性而特别设计的，此法效率相对较低
			$arrBoardInfo =& $db->getResultSet("SELECT boardid,boardmaster,lastpost,boarduser FROM {$dv}board");
			if( $arrBoardInfo !== false && is_array($arrBoardInfo) ){
				foreach( $arrBoardInfo as $val ){
					$comma = '';
					$setList = '';
					if( strpos("|{$val['boardmaster']}|","|{$membername}|") !== false ){
						$val['boardmaster'] = str_replace("|{$membername}|","|{$NewUserName}|","|{$val['boardmaster']}|");
						$setList .= "{$comma}boardmaster='".$db->escape_string(substr($val['boardmaster'],1,-2))."'";
						$comma = ',';
					}
					if( strpos("\${$val['lastpost']}\$","\${$membername}\$") !== false ){
						$val['lastpost'] = str_replace("|{$membername}|","|{$NewUserName}|","\${$val['lastpost']}\$");
						$setList .= "{$comma}lastpost='".$db->escape_string(substr($val['boardmaster'],1,-2))."'";
						$comma = ',';
					}
					if( strpos(",{$val['boarduser']},",",{$membername},") !== false ){
						$val['boarduser'] = str_replace("|{$membername}|","|{$NewUserName}|",",{$val['boarduser']},");
						$setList .= "{$comma}boarduser='".$db->escape_string(substr($val['boardmaster'],1,-2))."'";
						$setList .= $comma.$db->escape_string(substr($val['boarduser'],1,-2));
					}
					if( $setList !== '' ){
						$db->query("UPDATE /*! LOW_PRIORITY */ {$dv}board SET {$setList} WHERE boardid='{$val['boardid']}'");
					}
				}
			}
		}
		//更新主题回复用户名——考虑使用分卷更新的方法
		if( $query = $db->query("SELECT topicid,lastpost FROM {$dv}topic WHERE lastpost LIKE '{$membername}\$%'") ){
			while( $result = $db->fetch_array($query) ){
				if( strpos("\${$result['lastpost']}\$","\${$membername}\$") !== false ){
					$db->query("UPDATE {$dv}topic SET lastpost='".$db->escape_string(substr(str_replace("\${$membername}\$","\${$NewUserName}\$",$result['lastpost']),1,-2))."' WHERE topicid='{$result['topicid']}'");
				}
			}
		}
		UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
		$Tpl_ToolsName = $__toolsInfo['toolsname'];
		$Tpl_UserName = $membername;
		$Tpl_DestUserName = $NewUserName;
		eval('$LosgMsg = "'.addslashes($lang['template.strings23']).'";');	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
		showmsg($LogMsg,1,'',false);
		exit;
	}
}

/**
 *	道具:群发器,可发送论坛短消息给所有在线用户。
 */
function __ToolsAction_21(){
	global $_POST,$lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$toolsColorList,$chkAction,$userid,$membername;
	if( $GLOBALS['toolsaction'] === 'SendMsg' ){
		$MsgTitle = trim($GLOBALS['msgtitle']);
		$MsgBody = trim($GLOBALS['msgbody']);
		if( $MsgTitle === '' || strlen($MsgTitle) > 50 ){
			showmsg($lang['Error.strings28'],0,'',false);
			exit;
		}
		if( $MsgBody === '' || strlen($MsgBody) > $groupsetting[34] ){
			showmsg(str_replace('{$Number}',$groupsetting[34],$lang['Error.strings29']),0,'',false);
			exit;
		}
		$LogMsg = str_replace('{$Tpl_ToolsName}',$__toolsInfo['toolsname'],$lang['template.strings24']);
		$tmpRs =& $db->getResultSet("SELECT username FROM {$dv}online WHERE userid>0 AND userid<>'$userid'");
		if( $dbUserName === false ){
			showmsg($LogMsg,0,'',false);
			exit;
		}
		$MsgTitle = $db->escape_string($__toolsInfo['toolsname'])."--{$MsgTitle}";
		$number = 0;
		if( is_array($tmpRs) ){
			$number = count($tmpRs);
			foreach( $tmpRs as $val ){
				$db->query("INSERT INTO {$dv}message(incept,sender,title,content,sendtime,flag,issend) VALUES ('".$db->escape_string($val['username'])."','{$membername}','{$MsgTitle}','{$MsgBody}','".TIME_NOW."',0,1)");
				UPDATE_User_Msg($val['username']);
			}
		}
		//更新用户和系统使用数量
		UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
		$Tpl_ToolsName = $__toolsInfo['toolsname'];
		$Tpl_UserName = $membername;
		$Tpl_DestUserName = $NewUserName;
		$LogMsg .= str_replace('{$Tpl_Number}',$number,$lang['template.strings25']);
		ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
		showmsg($LogMsg,1,'',false);
		exit;
	}
}

/**
 *	道具:偷窥器，可查看他人金币、点券和道具等保密信息
 */
function __ToolsAction_22(){
	global $_POST,$lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$toolsColorList,$chkAction,$userid,$membername,$touserid;
	if( $GLOBALS['touserid'] <= 0 ){
		showmsg($lang['Error.strings18'],0,'',false);
		exit;
	}
	//判断目标用户使用权限并取出目标用户信息
	global $destUserInfo,$__BussInfo22;
	$destUserInfo =& getDestuserInfo($GLOBALS['touserid']);
	$__BussInfo22 =& $db->getResultSet("SELECT toolsname,toolscount FROM {$dv}plus_tools_buss WHERE toolscount>0 AND userid='{$destUserInfo['userid']}' ORDER BY toolscount DESC");
}

/**
 *	道具:查税卡，可对用户的金币执行一定比例的税收，收入归使用者，比例由系统定义
 */
function __ToolsAction_23(){
	global $_POST,$lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$__toolsSetting,$toolsColorList,$chkAction,$userid,$membername,$touserid;
	if( $GLOBALS['touserid'] <= 0 ){
		showmsg($lang['Error.strings18'],0,'',false);
		exit;
	}
	//判断目标用户使用权限并取出目标用户信息
	$destUserInfo =& getDestuserInfo($GLOBALS['touserid']);
	if( $userid === $destUserInfo['userid'] ){
		showmsg($lang['Error.strings9'],0,'',false);
		exit;
	}
	$GetPercent = php_cCur($__toolsSetting[4]);
	$GetPercentMoney = php_cCur($userinfo['usermoney']) + php_cCur($__toolsSetting[5]) * $GetPercent;
	$db->query("UPDATE {$dv}user SET usermoney='{$GetPercentMoney}' WHERE userid='{$userid}'");
	$db->query("UPDATE {$dv}user SET usermoney=usermoney-'". php_cCur($__toolsSetting[5])."' WHERE userid='{$destUserInfo['userid']}'");
	$userinfo['usermoney'] = $GetPercentMoney;
	//发短信通知目标用户
	$Tpl_MemberName = '';
	$strTitle = str_replace('{$Tpl_MemberName}',$Tpl_MemberName,$lang['template.strings26']);
	$Tpl_Number = php_cCur($destUserInfo['usermoney']) * $GetPercent;
	$Tpl_Percent = $GetPercent;
	eval('$strContent = "'.addslashes($lang['template.strings27']).'";');
	$db->query("INSERT INTO {$dv}message(incept,sender,title,content,sendtime,flag,issend) VALUES ('".$db->escape_string($destUserInfo['username'])."','{$membername}','".$db->escape_string($strTitle)."','".$db->escape_string($strContent)."','".time()."',0,1)");
	UPDATE_User_Msg($destUserInfo['username']);
	UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
	$Tpl_ToolsName = $__toolsInfo['toolsname'];
	$Tpl_DestUserName = $destUserInfo['username'];
	eval('$LogMsg = "'.addslashes($lang['template.strings28']).'";');
	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$GetPercentMoney}|{$userinfo['userticket']}");
	showmsg($LogMsg,1,'',false);
	exit;
}

/**
 *	道具:均富卡，可使使用用户和目标用户金币数相同
 */
function __ToolsAction_24(){
	global $_POST,$lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$__toolsSetting,$toolsColorList,$chkAction,$userid,$membername,$touserid;
	if( $GLOBALS['touserid'] <= 0 ){
		showmsg($lang['Error.strings18'],0,'',false);
		exit;
	}
	//判断目标用户使用权限并取出目标用户信息
	$destUserInfo =& getDestuserInfo($GLOBALS['touserid']);
	if( $userid === $destUserInfo['userid'] ){
		showmsg($lang['Error.strings9'],0,'',false);
		exit;
	}
	$GetPercentMoney = php_cCur($userinfo['usermoney']);
	$db->query("UPDATE {$dv}user SET usermoney='{$GetPercentMoney}' WHERE userid='{$userid}'");
	$userinfo['usermoney'] = $GetPercentMoney;
	UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
	$Tpl_ToolsName = $__toolsInfo['toolsname'];
	$Tpl_PrecentMoney = $GetPercentMoney - $userinfo['usermoney'];
	eval('$LogMsg = "'.addslashes($lang['template.strings29']).'";');
	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$GetPercentMoney}|{$userinfo['userticket']}");
	showmsg($LogMsg,1,'',false);
	exit;
}

/**
 *	道具:均贫卡，可使目标用户和使用用户金币数相同
 */
function __ToolsAction_25(){
	global $_POST,$lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$__toolsSetting,$toolsColorList,$chkAction,$userid,$membername,$touserid;
	if( $GLOBALS['touserid'] <= 0 ){
		showmsg($lang['Error.strings18'],0,'',false);
		exit;
	}
	//判断目标用户使用权限并取出目标用户信息
	$destUserInfo =& getDestuserInfo($GLOBALS['touserid']);
	if( $userid === $destUserInfo['userid'] ){
		showmsg($lang['Error.strings9'],0,'',false);
		exit;
	}
	if( php_cCur($userinfo['usermoney']) < php_cCur($destUserInfo['usermoney']) ){
		//更新目标用户
		$GetPercentMoney = php_cCur($userinfo['usermoney']);
		$db->query("UPDATE {$dv}user SET usermoney='{$GetPercentMoney}' WHERE userid='{$destUserInfo['userid']}'");
		$Tpl_ToolsName = $__toolsInfo['toolsname'];
		$Tpl_DestUserName = $destUserInfo['username'];
		eval('$LogMsg = "'.addslashes($lang['template.strings30']).'";');
		//短信通知目标用户
		$Tpl_MemberName = $membername;
		$Tpl_GetPercentMoney = $GetPercentMoney;
		$Tpl_Number = php_cCur($destUserInfo['usermoney']) - php_cCur($userinfo['usermoney']);
		eval('$strContent = "'.addslashes($lang['template.strings32']).'";');
		$db->query("INSERT INTo {$dv}message(incept,sender,title,content,sendtime,flag,issend) VALUES('".$db->escape_string($destUserInfo['username'])."','{$membername}','".$db->escape(str_replace('{$Tpl_MemberName}',$membername,$lang['template.strings31']))."','".$db->escape_string($strContent)."','".TIME_NOW."',0,1)");
		UPDATE_User_Msg($destUserInfo['username']);
	} else{
		//更新使用用户
		$GetPercentMoney = php_cCur($destUserInfo['usermoney']);
		$db->query("UPDATE {$dv}user SET usermoney='{$GetPercentMoney}' WHERE userid='{$userid}'");
		$userinfo['usermoney'] = $GetPercentMoney;
		$Tpl_ToolsName = $__toolsInfo['toolsname'];
		$Tpl_DestUserName = $destUserInfo['username'];
		$Tpl_Percent = $GetPercentMoney - php_cCur($userinfo['usermoney']);
		eval('$LogMsg = "'.addslashes($lang['template.strings33']).'";');
	}
	UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
	showmsg($LogMsg,1,'',false);
	exit;
}

/**
 *	道具:抢夺卡，可随机抢夺目标用户身上1/3到1/2的卡片
 */
function __ToolsAction_26(){
	global $_POST,$lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$__toolsSetting,$toolsColorList,$chkAction,$userid,$membername,$touserid;
	if( $GLOBALS['touserid'] <= 0 ){
		showmsg($lang['Error.strings18'],0,'',false);
		exit;
	}
	//判断目标用户使用权限并取出目标用户信息
	$destUserInfo =& getDestuserInfo($GLOBALS['touserid']);
	if( $userid === $destUserInfo['userid'] ){
		showmsg($lang['Error.strings9'],0,'',false);
		exit;
	}
	$ToolsCount = $db->scalar("SELECT COUNT(1) FROM {$dv}plus_tools_buss WHERE toolscount>0 AND userid='{$userid}'");
	if( $ToolsCount <= 0 ){
		showmsg($lang['Error.strings30'],0,'',false);
		exit;
	}
	list($usec, $sec) = explode(' ', microtime());
	mt_srand( (float)$sec + ((float)$usec * 100000) );
	$rndnum = mt_rand(0,10000);
	if( $rndnum % 2 === 0 ){//获取目标用户1/3道具
		$ToolsCount = intval($ToolsCount/3);
	} else{//获取目标用户1/2道具
		$ToolsCount = intval($ToolsCount/2);
	}
	$Tpl_Number = 0;
	if( $query = $db->query("SELECT id,username,toolsid,toolsname FROM {$dv}plus_tools_buss WHERE toolscount>0 AND userid='{$userid}'",array('pageSize'=>$ToolsCount)) ){
		while( $result = $db->query($query) ){
			UpdateBussTools($userid,$result['toolsid'],-1);//给用户添加道具
			$db->query("UPDATE {$dv}plus_tools_buss SET toolscount=toolscount-1 WHERE id='{$result['id']}'");
			eval('$LogMsg = "'.addslashes($lang['template.strings34']).'";');			ToolsLog($result['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
			$SucMsg .= $LogMsg;
			$Tpl_Number++;
		}
	}
	$SucMsg .= str_replace('{$Tpl_Number}',$Tpl_Number,$lang['template.strings35']);
	showmsg($SucMsg,1,'',false);
	exit;
}

/**
 *	道具:复仇卡，当被人使用恶性道具引起损失，此道具会自动使用并惩罚所使用恶性道具方用户
 */
function __ToolsAction_27(){
	global $_POST,$lang,$dv,$db,$userinfo,$__toolsInfo,$_bussInfo,$__toolsSetting,$toolsColorList,$chkAction,$userid,$membername,$touserid;
	if( $GLOBALS['touserid'] <= 0 ){
		showmsg($lang['Error.strings18'],0,'',false);
		exit;
	}
	//判断目标用户使用权限并取出目标用户信息
	$destUserInfo =& getDestuserInfo($GLOBALS['touserid']);
	if( $userid === $destUserInfo['userid'] ){
		showmsg($lang['Error.strings9'],0,'',false);
		exit;
	}
	$Tpl_ToolsName = $__toolsInfo['toolsname'];
	$GetPercentMoney = php_cCur($destUserInfo['usermoney']);
	$Tpl_Number = $GetPercentMoney - php_cCur($userinfo['usermoney']);
	eval('$LogMsg = "'.addslashes($lang['template.strings36']).'";');
	UpdateUserTools($GLOBALS['userid'],$GLOBALS['toolsid'],1);
	ToolsLog($GLOBALS['toolsid'],1,0,0,1,$LogMsg,"{$userinfo['usermoney']}|{$userinfo['userticket']}");
	showmsg($LogMsg,1,'',false);
	exit;
}

/**
 *	道具:获赠金币帖 回复用户可自定数量金币赠送给帖主，赠送总数量在帖子中特殊显示。
 */
function __ToolsAction_28(){
	global $lang;
	showmsg($lang['Error.strings31'],0,'',false);
	exit;
}

/**
 *	道具:金币购买帖 发帖者可以定义帖子出售金币值，浏览者需要支付金币购买才可以查看帖子全部内容。
 */
function __ToolsAction_29(){
	global $lang;
	showmsg($lang['Error.strings32'],0,'',false);
	exit;
}

?>