<?php
if( !defined('ISDVBBS') ){
	header('HTTP/1.0 404 Not Found');
	exit;
}
?><?php
require_once INC_PATH.'DV_Encoding.class.php';
require_once CACHE_PATH.'board/board_all.php';
print <<<EOT
<style>
.mainbar1{border-left : 1px solid #7AADC8; border-right : 1px solid #7AADC8; width : 98%; min-width :760px; margin : 0 auto;border-top : 1px solid #7AADC8;border-bottom : 1px solid #7AADC8; line-height:25px;background-color : #E4E8EF;height:25px;}
.mainbar{border-left : 1px solid #7AADC8; border-right : 1px solid #7AADC8; width : 98%; min-width :760px; margin : 0 auto;line-height:22px;background-color : #fff;}
.mainbar0{width : 98%;min-width :760px;margin : 0 auto;line-height:22px;background-color : #fff;}
.mainbar2{border-left : 1px solid #7AADC8;border-right : 1px solid #7AADC8;width : 98%;min-width :760px; margin : 0 auto;border-bottom : 1px solid #7AADC8; line-height:22px;background-color : #E4E8EF;}
.mainbar3{border-left : 1px solid #7AADC8; border-right : 1px solid #7AADC8;border-bottom : 1px solid #7AADC8;width : 98%;min-width :760px; margin : 0 auto;background-color : #fff;}
.mainbar4{border-left : 1px solid #7AADC8; border-right : 1px solid #7AADC8;border-top : 1px solid #7AADC8; width : 98%;min-width :760px;margin : 0 auto;background-color : #fff;height:25px;line-height:25px;}
/*th {background-image : url("templates/{$fsetting['styletpl']}/images/bg1.gif"); background-color : #4455aa; color : white; font-size : 12px; font-weight : bold; line-height: normal; } 
th a {color : #fff; text-decoration : none; } 
th a:hover {color : #fff;text-decoration : underline;} .tabletitle1 {background-color : #7AADC8; color : #fff;}
*/
.li1{border-left : 1px solid #7AADC8; line-height : 28px;height : 28px; text-align: center;}
.li2{border-left : 1px solid #7AADC8; line-height : 28px;height : 28px;background-color : #e4e8ef; text-align: center;}
.redfont {color : red;}
.bluefont {color : #7AADC8;}
</style>
EOT;
if ('manage' === $action) {
	print <<<EOT
	<div class="mainbox tableborder">
		<fieldset style="border : 1px dotted #ccc;text-align : left;line-height:22px;">
			<legend> <b>{$lang['tpl.string1']}</b> </legend>
			<ol style="margin-top:0px;margin-bottom:0px;list-style-position : inside;">
EOT;
	if (!empty($manageresult) AND is_array($manageresult)) {
		foreach ($manageresult AS $result) {
			$style = (empty($result['boardid']) ? ' style="color:red" ' : '');
			print <<<EOT
				<li style="padding:5px;"><div {$style}> {$lang['tpl.string2']}{$result['rootid']}{$lang['tpl.string79']}{$lang['tpl.string3']}{$result['announceid']}{$lang['tpl.string79']}{$lang['tpl.string4']}{$result['stats']}</div></li>
EOT;
		}
	}
	print <<<EOT
			</ol>
		</fieldset>
		<hr />
		<div>{$lang['tpl.string5']}</div>
	</div>
	<div class="mainbar1" style="text-align:center;"><a href="javascript:window.close()"> {$lang['tpl.string6']} </a> </div>
	<script type="text/javascript" language="javascript">
	setTimeout("window.close()",10000)
	</script>
EOT;
}
elseif ('view' === $action) {//查看单个审核帖
print <<<EOT
	<div class="mainbox tableborder" style="text-align : left;text-indent:24px;width:700px;line-height:28px;height : 28px;">
		<div>
			<div style="float:left;margin-left:0px;">{$lang['tpl.string7']}</div>
			<div style="float:right;margin-right:5px;"><a href="javascript:window.close()"> {$lang['tpl.string8']} </a></div>
		</div>
EOT;
		if ($postinfo['pardintid'] != 0) {
			print <<<EOT
			<div style="text-indent:10px;">
				<a href="dispbbs.asp?boardid={xml/row/@locktopic}&amp;id={xml/row/@rootid}" target="_blank" >{$lang['tpl.string9']}</a>
			</div>
EOT;
			$topictype = $lang['tpl.string10'];
		}
		else {
			$topictype = $lang['tpl.string11'];
		}
		require_once CACHE_PATH.'board/board_all.php';
		$currboardino =& $_DCACHE['all_forums']["{{$postinfo['locktopic']}}"];
		$postinfo['dateandtime'] = gmdate("Y-m-d H:i:s",$postinfo['dateandtime']+getUserTimeZoneOffset());
print <<<EOT
	</div>
	<div class="mainbar3" style="line-height:25px;text-indent:10px;width:700px;word-wrap : break-word ;word-break : break-all ;">
		<fieldset style="border : 1px dotted #ccc;text-align : left;line-height:22px;text-align : left;padding:10px;margin:10px;">
			<legend> <b>{$postinfo['topic']}</b></legend>
			<div style="text-align : center;">
				----{$lang['tpl.string12']}<a href="dispuser.asp?id={$postinfo['postuserid']}" target="_blank" >{$postinfo['username']}</a> {$lang['tpl.string13']}{$currboardino['boardtype']} {$lang['tpl.string14']}{$postinfo['dateandtime']}  {$lang['tpl.string15']}{$topictype} 
			</div>
			<div>{$postinfo['body']}</div>
		</fieldset>
	</div>
EOT;
}
elseif ('info' === $action) {//查看当前审核规则
	$settingscount = 0;
	$allsettings =& getAllAccessSettings();
	if (!empty($allsettings) AND is_array($allsettings)) {
		foreach ($allsettings AS $index => $dbinfo) {
			$settings = unserialize($dbinfo['setting']);
			if (false === $settings) {
				continue;
			}
			$settingscount++;
			$position = $index + 1;
			$settingsname = $settings['settings_name'];
			$strscope_newtopic = (true === $settings['scope']['newtopic'] ? $lang['tpl.str80'] : $lang['tpl.str81']);
			$strscope_newreply = (true === $settings['scope']['newreply'] ? $lang['tpl.str80'] : $lang['tpl.str81']);
			$strscope_reedit = (true === $settings['scope']['reedit'] ? $lang['tpl.str80'] : $lang['tpl.str81']);
			print <<<EOT
			<div class="th" style="width: 100%; margin-top:5px; text-indent:10px;">{$lang['tpl.string16']} {$position} . {$settingsname}</div>
			<div class="mainbox tableborder">
				<div style="float:left;width:100px;text-align : right;">
					<b>{$lang['tpl.string17']}</b>
				</div>
				<div class="li1" style="float:left; padding: 0px 10px;">{$strscope_newtopic} {$lang['tpl.string18']}</div>
				<div class="li1" style="float:left; padding: 0px 10px;">{$strscope_newreply} {$lang['tpl.string19']}</div>
				<div class="li1" style="float:left; padding: 0px 10px;">{$strscope_reedit} {$lang['tpl.string20']}</div>
				<div class="li1" style="float:left; padding: 0px 10px;"></div>
			</div>
EOT;
			if (!empty($settings['grade']) AND is_array($settings['grade'])) {
				foreach ($settings['grade'] AS $gradsettings) {
					$currusergroupid = $gradsettings['groupid'];
					if ($tmprs =& getUserGroupInfo($currusergroupid)) {
						$usergroupinfo =& $tmprs[0];
						unset($tmprs);
					}
					$topic_lessthan = ($gradsettings['topic_lessthan'] > 0 ? '<font class="redfont">'.$lang['tpl.str80'].'</font>' : '<font class="bluefont">'.$lang['tpl.str81'].'</font>');
					$post_lessthan = ($gradsettings['post_lessthan'] > 0 ? '<font class="redfont">'.$lang['tpl.str80'].'</font>' : '<font class="bluefont">'.$lang['tpl.str81'].'</font>');
					$register_lessthan = ($gradsettings['register_lessthan'] > 0 ? '<font class="redfont">'.$lang['tpl.str80'].'</font>' : '<font class="bluefont">'.$lang['tpl.str81'].'</font>');
					$delete_morethan = ($gradsettings['delete_morethan'] > 0 ? '<font class="redfont">'.$lang['tpl.str80'].'</font>' : '<font class="bluefont">'.$lang['tpl.str81'].'</font>');
					$shield = ($gradsettings['shield'] > 0 ? '<font class="redfont">'.$lang['tpl.str80'].'</font>' : '<font class="bluefont">'.$lang['tpl.str81'].'</font>');
					$check_content = (true === $gradsettings['check_content'] ? '<font class="redfont">'.$lang['tpl.str80'].'</font>' : '<font class="bluefont">'.$lang['tpl.str81'].'</font>');
print <<<EOT
					<div class="mainbox tableborder">
						<div style="float:left;width:100px;text-align : right;">
							<b>{$lang['tpl.string21']}</b>
						</div>
						<div class="li1" style="float:left; padding: 0px 10px;">
								{$usergroupinfo['usertitle']}(ID:{$currusergroupid})
						</div>
					</div>
					<div class="mainbox tableborder">
						<div style="float:left;width:100px;text-align : right;">
							<b>{$lang['tpl.string22']}</b>
						</div>
						<div class="li1" style="float:left; padding: 0px 10px;">
							{$topic_lessthan} {$lang['tpl.string23']} <b>{$gradsettings['topic_lessthan']}</b> {$lang['tpl.string24']}
						</div>
						<div class="li1" style="float:left; padding: 0px 10px;">
							{$post_lessthan} {$lang['tpl.string25']} <b>{$gradsettings['post_lessthan']}</b> {$lang['tpl.string24']}
						</div>
						<div class="li1" style="float:left; padding: 0px 10px;">
							{$register_lessthan} {$lang['tpl.string26']} <b>{$gradsettings['register_lessthan']}</b> {$lang['tpl.string27']}
						</div>
					</div>
					<div class="mainbox tableborder">
						<div style="float:left;width:100px;text-align : right;">&nbsp;</div>
						<div class="li1" style="float:left; padding: 0px 10px;">
							{$delete_morethan} {$lang['tpl.string28']} <b>{$gradsettings['delete_morethan']}</b> {$lang['tpl.string24']}
						</div>
						<div class="li1" style="float:left; padding: 0px 10px;">{$shield} {$lang['tpl.string29']}</div>
						<div class="li1" style="float:left; padding: 0px 10px;">{$check_content} {$lang['tpl.string30']}</div>
					</div>
EOT;
				}
			}
			$pic_audit = (true === $settings['check_content_misc']['pic_audit'] ? '<font class="redfont">'.$lang['tpl.str80'].'</font>' : '<font class="bluefont">'.$lang['tpl.str81'].'</font>');
			$link_audit = (true === $settings['check_content_misc']['link_audit'] ? '<font class="redfont">'.$lang['tpl.str80'].'</font>' : '<font class="bluefont">'.$lang['tpl.str81'].'</font>');
			$flash_audit = (true === $settings['check_content_misc']['flash_audit'] ? '<font class="redfont">'.$lang['tpl.str80'].'</font>' : '<font class="bluefont">'.$lang['tpl.str81'].'</font>');
			$media_audit = (true === $settings['check_content_misc']['media_audit'] ? '<font class="redfont">'.$lang['tpl.str80'].'</font>' : '<font class="bluefont">'.$lang['tpl.str81'].'</font>');
			$realplayer_audit = (true === $settings['check_content_misc']['realplayer_audit'] ? '<font class="redfont">'.$lang['tpl.str80'].'</font>' : '<font class="bluefont">'.$lang['tpl.str81'].'</font>');
			$sensitive_character_list = @implode('&nbsp;&nbsp;', $settings['sensitive_character_list']);
print <<<EOT
			<div class="mainbox tableborder">
				<div style="float:left;width:100px;text-align : right;">
					<b>{$lang['tpl.string31']}</b>
				</div>
				<div class="li1" style="float:left; padding: 0px 10px;">{$pic_audit} {$lang['tpl.string32']}
				</div>
				<div class="li1" style="float:left; padding: 0px 10px;">{$link_audit} {$lang['tpl.string33']}
				</div>
				<div class="li1" style="float:left; padding: 0px 10px;">{$flash_audit} {$lang['tpl.string34']}
				</div>
				<div class="li1" style="float:left; padding: 0px 10px;">{$media_audit} {$lang['tpl.string35']}
				</div>
				<div class="li1" style="float:left; padding: 0px 10px;">{$realplayer_audit} {$lang['tpl.string36']}
				</div>
			</div>
			<div class="mainbox tableborder">
				<div style="float:left;width:100px;text-align : right;">
					<b>{$lang['tpl.string37']}</b>
				</div>
				<div class="li1" style="float:left; padding: 0px 10px;height:100px;">{$sensitive_character_list}
				</div>
			</div>
			<div class="mainbox tableborder">
				<div style="float:left;width:100px;text-align : right;">
					<b>{$lang['tpl.string38']}</b>
				</div>
				<div class="li1" style="float:left; padding: 0px 10px;height:100px;">
EOT;
					if (!empty($settings['exempt_user_list']) AND is_array($settings['exempt_user_list'])) {
						$nbsp = '';
						foreach ($settings['exempt_user_list'] AS $username) {
							print $nbsp.'<a href="dispuser.php?name='.urlencode($username).'" target="_blank" class="bluefont">'.$username.'</a>';
							$nbsp = '&nbsp;&nbsp;';
						}
					}
		print <<<EOT
				</div>
			</div>
EOT;
		}
	}
	if ($settingscount > 0) {
print <<<EOT
		<div class="mainbox tableborder" style="text-align:center;height:25px;"><a href="javascript:window.close()"> {$lang['tpl.string8']} </a> </div>
EOT;
	}
	else {
print <<<EOT
		<div class="mainbox tableborder" style="text-align:center;"> {$lang['tpl.string39']}  </div>
		<div class="mainbox tableborder" style="text-align:center;"><a href="javascript:window.close()"> {$lang['tpl.string8']} </a> </div>
EOT;
	}
}
elseif ('add_exempt_user' === $action) {//豁免审核用户  addnocheck
	print <<<EOT
	<div class="th" style="width:600px;">
		<div>{$lang['tpl.string40']}</div>
	</div>
	<div class="mainbar3" style="line-height:28px;height:28px;width:600px;text-align:center;">
		<a href="accesstopic.php">{$lang['tpl.string41']}</a> 
	</div>
EOT;
} elseif ('unlock' === $action) {//解除固封
print <<<EOT
	<div class="th" style="width:600px;">
		<div>{$lang['tpl.string42']}</div>
	</div>
	<div class="mainbar3" style="line-height:28px;height:28px;width:600px;text-align:center;">
		<a href="javascript:history.go(-1)">{$lang['tpl.string43']}</a> 
	</div>
EOT;
}
else {
	$tablelist =& getTableList(array('getcount' => true));
	if ($tablelist['count'] > 0) {
		$auditlist =& getAuditList();
		$tplmsg = $lang['tpl.string44'].' <b><font color="red">'.$auditlist['RecordCount'].'</font></b>  '.$lang['tpl.string45'];
	} else {
		$auditlist = false;
		$tplmsg = $lang['tpl.string46'];
	}
	readme();
	print <<<EOT
	<script type="text/javascript" language="javascript">
	function CheckAll(form,v)  {
		for (var i=0;i<form.elements.length;i++) {
			var e = form.elements[i];
			if (e.type == 'radio' && e.value==v && e.name !='chkall') {
				e.checked =true; 
			}
		}
	}
	</script>
	<div class="mainbox">
		<fieldset style="border : 1px dotted #ccc;text-align : left;line-height:22px;">
			<legend> <b>{$lang['tpl.string47']}</b> </legend>
			<div style="text-indent:24px;">{$tplmsg}</div>
		</fieldset>
	</div>
	<table cellspacing="0" cellpadding="0" border="0" class="mainbox tableborder">
		<form name="recycle" action="accesstopic.php?action=manage" method="post" target1="_blank">
		<tr>
			<th>{$lang['tpl.string48']}</th>
			<th>{$lang['tpl.string49']}</th>
			<th>{$lang['tpl.string50']}</th>
			<th>{$lang['tpl.string51']}</th>
			<th>{$lang['tpl.string52']}</th>
			<th>{$lang['tpl.string53']}</th>
			<th>{$lang['tpl.string54']}</th>
			<th>{$lang['tpl.string55']}</th>
			<th>{$lang['tpl.string57']}</th>
		</tr>
EOT;
	if (!empty($auditlist['ResultSet']) AND is_array($auditlist['ResultSet'])) {
		$objenc =& DV_Encoding::GetEncoding($charset);
		$boardall =& $_DCACHE['all_forums'];
		foreach ($auditlist['ResultSet'] AS $currusername => $rsaudit) {
			if (0 === $tablelist['tableid']) {
				$strtype = $lang['tpl.string11'];
			} elseif (0 == $rsaudit['parentid']) {
				$strtype = $lang['tpl.string11'];
			} else {
				$strtype = $lang['tpl.string10'];
			}
			$id = $rsaudit['id'];
			$replyid = ((!is_numeric($rsaudit['replyid']) OR $rsaudit['replyid'] < 0) ? 0 : $rsaudit['replyid']);
			$title = $rsaudit['topic'].'{nbsp}'.$rsaudit['body'];
			$title = strip_tags(str_replace('{nbsp}', '&nbsp;&nbsp;', htmlspecialchars($objenc->SubString($title, 0, 30))));
			$currboardtype = strip_tags($boardall["{$rsaudit['bid']}"]['boardtype']);
			$encodedusername = urlencode($rsaudit['username']);
			$escapehtmlusername = htmlspecialchars($rsaudit['username']);
			$rsaudit['dateandtime'] = gmdate("Y-m-d H:i:s",$rsaudit['dateandtime']+getUserTimeZoneOffset());
print <<<EOT
		<input type="hidden" name="arrayid[]" value="{$id}"/>
		<input type="hidden" name="arrayreplyid[]" value="{$replyid}"/>
		<tr>
			<td><input type="radio" class="radio" name="pass_{$id}_{$replyid}" value="1"  style="margin:4px;" /></td>
			<td><input type="radio" class="radio" name="pass_{$id}_{$replyid}" value="0"  style="margin:4px;"/></td>
			<td><input type="radio" class="radio" name="pass_{$id}_{$replyid}" value="2"  style="margin:4px;" checked="checked" /></td>
			<td>{$strtype}</td>
			<td><a href="accesstopic.php?action=view&amp;id={$id}&amp;replyid={$replyid}" target="_blank" >{$title} </a></td>
			<td>{$rsaudit['dateandtime']}</td>
			<td>
				<a href="accesstopic.php?action=add_exempt_user&amp;username={$encodedusername}&amp;destboardid={$rsaudit['bid']}" target="_blank" title="{$lang['tpl.string58']}{$escapehtmlusername}" style="color:green;">{$lang['tpl.string59']}</a> | <a href="accesstopic.php?boardid={$boardid}&amp;tableid={$tablelist['tableid']}&amp;keyword={$encodedusername}" title="{$lang['tpl.string60']}{$escapehtmlusername}{$lang['tpl.string61']}">{$lang['tpl.string62']}</a> | <a href="admin_lockuser.php?action=lock_1&amp;name={$encodedusername}" target="_blank" title="{$lang['tpl.string63']}" style="color:red;">{$lang['tpl.string64']}</a>
			</td>
			<td><a href="dispuser.php?id={$rsaudit['userid']}" target="_blank" >{$rsaudit['username']}</a></td>
			<td>{$currboardtype}</td>
		</tr>
EOT;
		}
	}
print <<<EOT
		<tr>
			<td colspan="9">
				<input type="radio" class="radio" name="chkall" value="on" onclick="CheckAll(this.form,1);" style="margin:4px;" />{$lang['tpl.string65']}<input type="radio" class="radio" name="chkall" value="on" onclick="CheckAll(this.form,0);" style="margin:4px;"/>{$lang['tpl.string66']}<input type="radio" class="radio" name="chkall" value="on" onclick="CheckAll(this.form,2);" style="margin:4px;" checked="checked"/><b>{$lang['tpl.string67']}</b> <button type="submit" name="action" onMousemove="button_move(this)" onMouseout="button_out(this)">{$lang['tpl.string68']}</button>
				{$lang['tpl.string69']}<xsl:value-of select="$myscript" disable-output-escaping="yes" />{$strpagelist}
			</td>
		</tr>
		</form>
	</table>
EOT;
	$strpagelist = pagelist($auditlist['RecordCount'], $auditlist['PageSize'], $auditlist['AbsolutePage'], "accesstopic.php?action={$action}&amp;boardid={$boardid}&amp;tableid={$tablelist['tableid']}&amp;keyword=".urlencode($keyword), count($auditlist['ResultSet']));
EOT;
}

function readme()
{
	global $boardid, $master, $lang;
	$tablelist =& getTableList(array('getcount' => true));
	if (false === $tablelist OR $tablelist['count'] <= 0) {
		$topiccount = 0;
	} else {
		$auditlist =& getAuditList();
		$topiccount = $tablelist['Topic_RecordCount'];
	}
	if (0 == $tablelist['tableid']) {
	}
	$boardjumplist = boardjumplist($boardid, $lang['tpl.string69_1']);
	print <<<EOT
	<div class="mainbox">
		<fieldset style="border : 1px dotted #ccc;text-align : left;line-height:22px;">
			{$lang['tpl.string70']}
			</ol>
			<div style="float:right;margin-right:5px;line-height:22px;height:22px;">
				<a href="accesstopic.php?boardid={$boardid}">{$lang['tpl.string71']}</a> | <a href="accesstopic.php?action=info" class="bluefont" target="_blank">{$lang['tpl.string72']}</a>
			</div>
		</fieldset>
	</div>
	<div class="mainbox tableborder">
		<div>{$lang['tpl.string73']} </div>
		<form action="accesstopic.php" method="post">
		<div style="text-align : left;line-height:25px;height:25px;text-indent:10px;">{$lang['tpl.string74']}
			<select name="boardid" id="boardid" style="width:auto;">{$boardjumplist}</select>
			{$lang['tpl.string75']}
			<select name="tableid" id="tableid">
				<option value="0">{$lang['tpl.string76']}-[{$topiccount}]</option>
EOT;
					if(false !== $tablelist['TableList_IdIndex']) {
						foreach ($tablelist['TableList_IdIndex'] AS $table) {
							if ($table['id'] == $tablelist['tableid']) {
								$strselected = ' selected ';
							} else {
								$strselected = '';
							}
							print <<<EOT
								<option value="{$table['id']}" {$strselected} >{$table['tabletype']}-[{$table['RecordCount']}]</option>
EOT;
						}
					}
print <<<EOT
			</select>
			{$lang['tpl.string78']}<input type="text" name="keyword" value="{$GLOBALS['keyword']}" />&nbsp;&nbsp;
			<button type="submit" onMousemove="button_move(this)" onMouseout="button_out(this)">{$lang['tpl.string77']}</button>
		</form>
		</div>
	</div>
EOT;
}

function getGroupListById($groupid)
{
	static $grouplist = '';
	if (empty($grouplist)) {
		$allgroups =& getUserGroupInfo(0);
		if (!empty($allgroups) AND is_array($allgroups)) {
			foreach ($allgroups AS $usergroup ) {
				if ($usergroup == $groupid) {
					$selected = ' selected ';
				} else {
					$selected = '';
				}
				$grouplist .= '<option value="'.$usergroup['usergroupid'].'" '.$selected.'>'.$usergroup['usertitle'].'</option>';
			}
		}
	} else {
		$grouplist = str_replace(array(' selected ', 'value="'.$groupid.'"'), array('', 'value="'.$groupid.'" selected '), $grouplist);
	}
	return $grouplist;
}

?>