<!--<?php
if(!$action){print <<<EOT
--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=$db_charset" />
<title>home manage</title>
<style type="text/css">
body{font-family:tahoma;font-size:12px;margin:0;color:#666;background:#f5fcff;}
textarea,input,select{font-size:12px;}
textarea{border: 1px solid;border-color: #c0c0c0 #ededed #ededed #c0c0c0;}
.input,.input2 input{border: 1px solid;border-color: #c0c0c0 #ededed #ededed #c0c0c0;padding:2px 0px 1px 1px;font-size:1.0em;vertical-align:middle;color:#000;height:16px;margin-bottom:.3em;margin-right:.3em}
.btn{background:#d9d9d9;border-width:1px;vertical-align:middle;height:21px;padding-left:0.15em;padding-right:0.15em;border: 1px solid; border-color: #c0c0c0 #555 #555 #c0c0c0;}
table{border-top:0px;border-left:0px;border-bottom:2px}
td{border-right:1px;border-top:0px;font-size:12px;color:#666;}
h3{font-size:12px;color:#006699;margin:0;}
a { text-decoration: none; color:#0000ff}
.moduleA{ margin:.2em; border:1px solid #A6CBE7; line-height:110%; border-bottom-color:#66A0CC; border-right-color:#66A0CC;background:#fff;}
.moduleA h3{ color: #006699;padding:.5em; margin:0;font-family:Tahoma;font-size:12px;cursor:move }
.tableA { table-layout:fixed}
.tableAtd{ border:1px solid #D4E8F7;height:50px;}
.editButton{ float:right; font:12px/120% Tahoma; color:#CCC; text-decoration:none ; padding-left:0.5em; background:url($imgpath/button_edit.gif) no-repeat 0 .1em}
.editButton:hover{ background-position:.1em .2em}
.editBox{ background:#FFFFCF; margin:0 .2em .2em ; padding:.2em }
.editArea {border:1px solid #eee; width:96%; margin:auto;padding:.2em; background:#fff}

.menu1{position:absolute;border:#b9e6f5 1px solid;background:#f5fcff;z-index:1000;width:200px;height:255px;overflow-Y:auto}
.menu1 h3{height:28px;line-height:28px;background:#ffffff;border-bottom:1px dotted #acbccc;text-align:left;color:$headfontone;cursor:move;padding-left:1em;margin-bottom:.5em}
.menu1 div{padding:5px 10px;}

.checkon{border:1px solid #0A9800;background:#CAFFC0;cursor:move}
.move{position:absolute;}
.menu{position:absolute;background:#fff;border:1px solid $tablecolor;}
.menu td, .menu li,.menu ul{background:$headcolor;padding:0; margin:0}
.menu li{list-style:none;}
.menu a{display:block;padding:3px 15px 3px 15px}
.menu a:hover{background:$linkcolor;text-decoration:none;color:#fff;}
.menu ul.ul1 li a{display:inline;padding:0}
.h{border-bottom:4px solid $headborder;background:$headcolor;text-align:left;color:$headfontone;padding:5px 7px 3px 7px;}
.fr{float:right}
.c{clear:both}
form{padding:0;margin:0}
</style>
<script language="javascript">
var agt = navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_gecko = (navigator.product == "Gecko");
var imgpath  = '$imgpath';

function getObj(id){
	return document.getElementById(id);
}
function IsElement(id){
	return document.getElementById(id)!=null ? true : false;
}
function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
</script>
</head><body ondblclick="ShowMenu(event,'m_sysmod');">
<div id="showmenu" style="z-index:100;display:none;"></div>
<div style="width:93%;margin:auto;padding:10px 0 5px 0">
	<div class="fr">
	<input type="button" class="btn" value="保存布局" onclick="saveMode();" />
	<input type="button" class="btn" value="更新缓存" onclick="window.location='$basename&action=updatecache'" />
	</div>
	<input type="button" class="btn" value="系统模块" onclick="ShowMenu(event,'m_sysmod');" />
	<input type="button" class="btn" value="版块列表" onclick="ShowMenu(event,'m_forums');" />
	<input type="button" class="btn" value="自定义模块" onclick="ShowMenu(event,'m_ads');" />
</div>
<div id="menu" class="menu1" style="display:none"></div>
<div class="c"></div>
<div style="width:95%;margin:auto">
<table width="100%" border="0" cellspacing="10" cellpadding="0" class="tableA" id="no">
<!--
EOT;
for($i=1;$i<17;$i++){print <<<EOT
-->
	<tr>
		<td colspan="3" class="tableAtd" id="no_$i">&nbsp;
<!--
EOT;
if($home[$i]){
foreach($home[$i] as $key=>$value){print <<<EOT
-->
		<div class="moduleA" id="t_$value[name]"><h3 onmousedown="Drag._move(event);return false;"><a style="cursor:pointer" onclick="send('action=edit&type=$value[name]');" class="editButton">设置</a><a style="cursor:pointer" class="editButton" onclick="delMode('$value[name]')">删除</a><a style="cursor:pointer" class="editButton" onclick="updateMode('$value[name]')">更新</a>$value[title]</h3><div class="editBox"><div class="editArea"></div></div></div>
<!--
EOT;
}}
$i++;
print <<<EOT
-->
		</td>
	</tr>
	<tr>
		<td class="tableAtd" id="no_$i">&nbsp;
<!--
EOT;
if($home[$i]){
foreach($home[$i] as $key=>$value){print <<<EOT
-->
		<div class="moduleA" id="t_$value[name]"><h3 onmousedown="Drag._move(event);return false;"><a style="cursor:pointer" onclick="send('action=edit&type=$value[name]');" class="editButton">设置</a><a style="cursor:pointer" class="editButton" onclick="delMode('$value[name]')">删除</a><a style="cursor:pointer" class="editButton" onclick="updateMode('$value[name]')">更新</a>$value[title]</h3><div class="editBox"><div class="editArea"></div></div></div>
<!--
EOT;
}}
$i++;
print <<<EOT
-->
		</td>
		<td class="tableAtd" id="no_$i">&nbsp;
<!--
EOT;
if($home[$i]){
foreach($home[$i] as $key=>$value){print <<<EOT
-->
		<div class="moduleA" id="t_$value[name]"><h3 onmousedown="Drag._move(event);return false;"><a style="cursor:pointer" onclick="send('action=edit&type=$value[name]');" class="editButton">设置</a><a style="cursor:pointer" class="editButton" onclick="delMode('$value[name]')">删除</a><a style="cursor:pointer" class="editButton" onclick="updateMode('$value[name]')">更新</a>$value[title]</h3><div class="editBox"><div class="editArea"></div></div></div>
<!--
EOT;
}}
$i++;
print <<<EOT
-->
		</td>
		<td class="tableAtd" id="no_$i">&nbsp;
<!--
EOT;
if($home[$i]){
foreach($home[$i] as $key=>$value){print <<<EOT
-->
		<div class="moduleA" id="t_$value[name]"><h3 onmousedown="Drag._move(event);return false;"><a style="cursor:pointer" onclick="send('action=edit&type=$value[name]');" class="editButton">设置</a><a style="cursor:pointer" class="editButton" onclick="delMode('$value[name]')">删除</a><a style="cursor:pointer" class="editButton" onclick="updateMode('$value[name]')">更新</a>$value[title]</h3><div class="editBox"><div class="editArea"></div></div></div>
<!--
EOT;
}}print <<<EOT
-->
		</td>
	</tr>
<!--
EOT;
}print <<<EOT
-->
</table>
<div id="m_sysmod" class="menu1" style="display:none">
	<h3 onmousedown="dragMove(event);"><span class="fr" style="margin-top:2px;cursor:pointer" onclick="closeMenu();"><img src="$imgpath/close.gif" /></span>系统模块</h3>

<!--
EOT;
foreach($mode as $key=>$value){print <<<EOT
-->
	<div id="$value[name]" onclick="CheckOn(this)">$value[title]</div>
<!--
EOT;
}print <<<EOT
-->
</div>
<div id="m_forums" class="menu1" style="display:none;">
<h3 onmousedown="dragMove(event);"><span class="fr" style="margin-top:2px;cursor:pointer" onclick="closeMenu();"><img src="$imgpath/close.gif" /></span>版块列表</h3>
<!--
EOT;
foreach($forum as $key=>$value){
if($value['type']!='category' && $value['f_type']!='hidden'){print <<<EOT
-->
<div id="forums_$key" onclick="CheckOn(this)">$value[name]</div>
<!--
EOT;
}}print <<<EOT
-->
</div>
<div id="m_ads" class="menu1" style="display:none;">
<h3 onmousedown="dragMove(event);"><span class="fr" style="margin-top:2px;cursor:pointer" onclick="closeMenu();"><img src="$imgpath/close.gif" /></span>自定义模块</h3>
<div id="addads" style="cursor:pointer;color:#0000ff" onclick="sendmsg('$ajaxurl','action=addads',this.id);">添加新模块</div>
<!--
EOT;
foreach($ads as $key=>$value){print <<<EOT
-->
<div id="$value[name]" onclick="CheckOn(this)">$value[title]</div>
<!--
EOT;
}print <<<EOT
-->
</div>
</div>
</body>
</html>
<script src="$db_bbsurl/js/pw_drag.js"></script>
<script src="$db_bbsurl/js/pw_ajax.js"></script>
<script src="$db_bbsurl/js/global.js"></script>
<script language="javascript">
var dragX = dargY = 0;
function showselect(type){
	var selects = document.getElementsByTagName('select');
	for(i=0; i<selects.length; i++){
		selects[i].style.visibility = type;
	}
}
function ShowMenu(e,id){
	var e = is_ie ? window.event : e;
	var o = getObj('menu');
	o.innerHTML=getObj(id).innerHTML;
	o.style.display = '';
	var left = e.clientX;
	var top  = e.clientY;

	if(left > ietruebody().clientWidth/2){
		left -= o.offsetWidth;
	}
	if(top > ietruebody().clientHeight/2){
		top -= o.offsetHeight;
	}
	o.style.left = left + ietruebody().scrollLeft + 'px';
	o.style.top  = top + ietruebody().scrollTop + 15  + 'px';
}
function closeMenu(){
	getObj('menu').style.display = 'none';
}
function CheckOn(o){
	var p = o.parentNode;
	var s = p.getElementsByTagName('div');
	for(var i=0;i<s.length;i++){
		if(s[i].id == o.id){
			s[i].className   = 'checkon';
			if(p.id == 'menu'){
				getObj('m_forums').style.display = 'none';
				getObj('m_ads').style.display = 'none';
			}
			s[i].onmousedown = function(event){Drag._add(event);return false;};
		} else{
			s[i].className   = '';
			s[i].onmousedown = '';
		}
	}
}
function saveMode(){
	var o = getObj('no');
	var v = Array();
	var k = '';
	var tds = o.getElementsByTagName('td');
	for(var i=0;i<tds.length;i++){
		var ds = tds[i].getElementsByTagName('div');
		if(ds.length>0){
			k = tds[i].id.substr(3);
			for(var j=0;j<ds.length;j++){
				if(ds[j].id != ''){
					if(typeof v[k] == 'undefined'){
						v[k] = ds[j].id;
					} else{
						v[k] += ',' + ds[j].id;
					}
				}
			}
		}
	}
	var data = 'action=save';
	for(var i in v){
		data += '&p['+i+']='+v[i];
	}
	ajax.send('$ajaxurl',data,ajax.guide);
}
function updateMode(id){
	ajax.send('$ajaxurl','action=update&type='+id,ajax.guide);
}
function delMode(id){
	getObj('t_'+id).parentNode.removeChild(getObj('t_'+id));
}
function dragMove(e){
	if(is_ie){
		document.body.onselectstart = function(){return false;}
	}
	var o = getObj('menu');
	var x = e.clientX;
	var y = e.clientY;
	dragX = e.clientX - parseInt(o.offsetLeft);
	dragY = e.clientY - parseInt(o.offsetTop);
	document.onmousemove = dragMoving;
	document.onmouseup   = dragMoved;
}
function dragMoving(e){
	var e = is_ie ? window.event : e;
	var o = getObj('menu');
	var x = e.clientX;
	var y = e.clientY;
	o.style.left = x - dragX + 'px';
	o.style.top  = y - dragY + 'px';
}
function dragMoved(e){
	if(is_ie){
		document.body.onselectstart = function(){return true;}
	}
	document.onmousemove = '';
	document.onmouseup   = '';
}
function send(data){
	ajax.send('$ajaxurl',data,ajax.get);
}
function getdefault(){
	getObj('siteinfo').value = "会员总数:{\$totalmember}人\\n最新注册会员:{\$newmember}\\n主题数:{\$threads}主题\\n帖子数:{\$posts}个(含回帖)\\n今 日:灌了{\$tposts}帖\\n昨 日:灌了{\$yposts}帖\\n最高日:灌了{\$hposts}贴\\n在线总数:{\$usertotal}人\\n会员数:{\$userinbbs}人\\n游客数:{\$guestinbbs}人\\n最高在线:{\$higholnum}人\\n发生在:{\$higholtime}";
}
function reback(){
	getObj('siteinfo').value = getObj('siteinfo').defaultValue;
}
</script>
<!--
EOT;
}elseif($action=='edit'){print <<<EOT
-->
<form action="$ajaxurl" method="post" onsubmit="return false;">
<input type="hidden" name="type" value="$type" />
<input type="hidden" name="step" value="2" />
<table width="350" cellspacing="1" cellpadding="5">
<tr><th class="h" colspan="2" style="cursor:move" onmousedown="read.move(event);"><span class="fr" style="margin-top:2px;cursor:pointer" onclick="read.close();"><img src="$imgpath/close.gif" /></span>$rt[title]</th></tr>
<!--
EOT;
if(substr($type,0,4)=='ads_'){print <<<EOT
-->
<tr><td align="center">模块描述：</td>
<td><input class="input" type="text" name="title" size="20" value="$rt[title]" /></td></tr>
<tr><td align="center">模块内容：</td>
<td><textarea name="cache" style="width:230px;height:96px">$rt[cache]</textarea></td></tr>
<!--
EOT;
}else{print <<<EOT
-->
<tr><td width="25%" align="center">模块标题：</td>
<td><input class="input" type="text" name="title" size="20" value="$rt[title]" /></td></tr>
<tr><td align="center">更新频率：</td>
<td><input class="input" type="text" name="upstep" size="8" value="$rt[upstep]" /> (3600 为一小时)</td></tr>
<!--
EOT;
}if($type=='eye'){
${'c_'.$order} = 'checked';
print <<<EOT
-->
<tr><td align="center">指定帖子：</td>
<td><input class="input" type="text" name="config[tids]" value="$tids" size="20" /> (多个用 , 分开)</tr>
<tr><td align="center">显示个数：</td>
<td><input class="input" type="text" name="config[nums]" value="$nums" size="8" /></tr>
<tr>
<td align="center">排序方式：</td><td>
<input type="radio" name="config[order]" value="hits" $c_hits />点击率
<input type="radio" name="config[order]" value="replies" $c_replies />回复数
<input type="radio" name="config[order]" value="dig" $c_dig />支持数
</tr>
<tr><td align="center">搜索时间：</td>
<td><input class="input" type="text" name="config[time]" value="$time" size="8" /> (搜索几天内的帖子，能降低负载)</tr>
<!--
EOT;
}elseif($type=='tags'){
print <<<EOT
-->
<tr><td align="center">指定标签：</td>
<td><input class="input" type="text" name="config[tags]" value="$tags" size="20" /> (多个用 , 分开)</tr>
<tr><td align="center">显示个数：</td>
<td><input class="input" type="text" name="config[nums]" value="$nums" size="8" /></tr>
<!--
EOT;
}elseif($type=='recommend'){
${'c_'.$order} = 'checked';
print <<<EOT
-->
<tr><td align="center">指定帖子：</td>
<td><input class="input" type="text" name="config[tids]" value="$tids" size="20" /> (多个用 , 分开)</tr>
<tr><td align="center">显示图片：</td>
<td><input class="input" type="text" name="config[pic]" value="$pic" size="20" /> (留空使用默认)</tr>
<tr><td align="center">显示个数：</td>
<td><input class="input" type="text" name="config[nums]" value="$nums" size="8" /></tr>
<tr>
<td align="center">排序方式：</td><td>
<input type="radio" name="config[order]" value="hits" $c_hits />点击率
<input type="radio" name="config[order]" value="replies" $c_replies />回复数
<input type="radio" name="config[order]" value="dig" $c_dig />支持数
</tr>
<tr><td align="center">搜索时间：</td>
<td><input class="input" type="text" name="config[time]" value="$time" size="8" /> (搜索几天内的帖子，能降低负载)</tr>
<!--
EOT;
}elseif($type=='hottopic'){
${'c_'.$order} = 'checked';
print <<<EOT
-->
<tr><td align="center">显示个数：</td>
<td><input class="input" type="text" name="config[nums]" value="$nums" size="8" /></tr>
<tr>
<td align="center">排序方式：</td><td>
<input type="radio" name="config[order]" value="hits" $c_hits />点击率
<input type="radio" name="config[order]" value="replies" $c_replies />回复数
<input type="radio" name="config[order]" value="dig" $c_dig />支持数
</tr>
<tr><td align="center">搜索时间：</td>
<td><input class="input" type="text" name="config[time]" value="$time" size="8" /> (搜索几天内的帖子，能降低负载)</tr>
<!--
EOT;
}elseif($type=='forumsort'){print <<<EOT
-->
<tr><td align="center">显示个数：</td>
<td><input class="input" type="text" name="config[nums]" value="$nums" size="8" /></tr>
<!--
EOT;
}elseif($type=='bbsinfo'){print <<<EOT
-->
<tr><td align="center">展示信息：<br /><span onclick="getdefault();" style="cursor:pointer">[使用默认]</span><br /><span onclick="reback();" style="cursor:pointer">[还原设置]</span></td>
<td><textarea id="siteinfo" name="config[info]" style="width:230px;height:120px">$info</textarea></tr>
<!--
EOT;
}elseif($type=='newreply'){print <<<EOT
-->
<tr><td align="center">显示个数：</td>
<td><input class="input" type="text" name="config[nums]" value="$nums" size="8" /></tr>
<tr><td align="center">搜索时间：</td>
<td><input class="input" type="text" name="config[time]" value="$time" size="8" /> (搜索几天内的帖子，能降低负载)</tr>
<!--
EOT;
}elseif($type=='newtopic'){print <<<EOT
-->
<tr><td align="center">显示个数：</td>
<td><input class="input" type="text" name="config[nums]" value="$nums" size="8" /></tr>
<tr><td align="center">搜索时间：</td>
<td><input class="input" type="text" name="config[time]" value="$time" size="8" /> (搜索几天内的帖子，能降低负载)</tr>
<!--
EOT;
}elseif($type=='usersort'){
${'c_'.$order} = 'checked';
print <<<EOT
-->
<tr><td align="center">显示个数：</td>
<td><input class="input" type="text" name="config[nums]" value="$nums" size="8" /></tr>
<tr>
<td align="center">排序方式：</td><td>
<input type="radio" name="config[order]" value="postnum" $c_postnum />发帖数
<input type="radio" name="config[order]" value="rvrc" $c_rvrc />威望
<input type="radio" name="config[order]" value="money" $c_money />金钱
</tr>
<!--
EOT;
}elseif(substr($type,0,7)=='forums_'){print <<<EOT
-->
<tr><td align="center">显示个数：</td>
<td><input class="input" type="text" name="config[nums]" value="$nums" size="8" /></tr>
<tr><td align="center">搜索时间：</td>
<td><input class="input" type="text" name="config[time]" value="$time" size="8" /> (搜索几天内的帖子，能降低负载)</tr>
<tr><td align="center">版块图标：</td>
<td><input class="input" type="text" name="config[pic]" value="$pic" size="20" /> (留空使用默认)</tr>
<!--
EOT;
}print <<<EOT
-->
</table><ul><li style="text-align:center;padding:4px 0;"><input type="button" class="btn" onclick="ajax.submit(this.form);" value="提 交" /></li></ul></form>
<!--
EOT;
}elseif($action=='addads'){print <<<EOT
-->
<form action="$ajaxurl" method="post" onsubmit="return false;">
<input type="hidden" name="step" value="2" />
<table width="350" cellspacing="1" cellpadding="5">
<tr><th class="h" colspan="2" style="cursor:move" onmousedown="read.move(event);"><span class="fr" style="margin-top:2px;cursor:pointer" onclick="read.close();"><img src="$imgpath/close.gif" /></span>添加模块</th></tr>
<tr><td width="25%" align="center">唯一标志符：</td>
<td><input class="input" type="text" name="id" size="8" value="" />(只允许数字)</td></tr>
<tr><td align="center">模块描述：</td>
<td><input class="input" type="text" name="title" size="20" value="" /></td></tr>
<tr><td align="center">模块内容：</td>
<td><textarea name="cache" style="width:230px;height:96px"></textarea></td></tr>
</table><ul><li style="text-align:center;padding:4px 0;"><input type="button" class="btn" onclick="ajax.submit(this.form);" value="提 交" /></li></ul>
</form>
<!--
EOT;
}?>-->