<?php
if( !defined('ISDVBBS') ){
	header('HTTP/1.0 404 Not Found');
	exit;
}

global $imgurl,$styleurl,$boardid;
global $useindexstatic,$fsetting;
if($useindexstatic)
	echo '<? $useindexstatic_file=false;?>';

$showmsghide=get_cookie("msghide");
if(!defined('ISDVBBS')) exit('Access denied.Sorry, you can not access this file directly.');
	$title=!empty($boardid)? $title:$lang['dvhometitle'].$title;
	$forum_keyword=strip_tags($fsetting['keyword']);
	$pagecharset=$GLOBALS['charset'];
	if(strtolower($pagecharset)=='gbk'){
		$pagecharset='GB2312';
	}
	if ($GLOBALS['targeturl'] == '' || $GLOBALS['targeturl'] == 'left' || $fsetting['leftbar'] == 0){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?
	}
?>
<html xml:lang="zh-CN" lang="zh-CN" xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=<?=$pagecharset?>" />
	<title><?=strip_tags($title.$forum_keyword)?></title>
	<meta name="generator" content="dvbbs" />
	<meta name="keywords" content="<?=$fsetting['keyword']?>" />
	<meta name="description" content="<?=$fsetting['description']?>" />
	<meta name="MSSmartTagsPreventParsing" content="TRUE" />
	<meta http-equiv="MSThemeCompatible" content="Yes" />
	<link rel="SHORTCUT ICON" href="favicon.ico" />
	<link rel="stylesheet" type="text/css" href="<?=$styleurl?>" />
<?
global $ScriptName;
$indexscriptname = $fsetting['homepage'];
if (empty($indexscriptname)) {
	$indexscriptname = 'index.php';
}
if (!is_file(ROOT_PATH.$indexscriptname)) {
	$indexscriptname = 'index';
}
defined('THIS_SCRIPT') AND (false !== strpos($ScriptName, '.php')) AND ($ScriptName = THIS_SCRIPT);

switch($ScriptName){
	case $indexscriptname:
	case 'index':
		if( $boardid > 0 ){
			$link_title = htmlspecialchars($boardinfo['boardtype'].'-'.$lang['head.str1']);
?>
	<link title="<?=$link_title?>" type="application/rss+xml" rel="alternate" href="rssfeed.php?boardid=<?=$boardid?>&amp;rssid=4" />
<?
		}else{//if end  else begin
?>
	<link title="<?=$fsetting['forumname'].'-'.$lang['head.str2']?>" type="application/rss+xml" rel="alternate" href="rssfeed.php" />
<?
		}//else end 
		if( $boardid > 0 && $boardinfo['child'] > 0 ){
?>


<?
		}
	break;
	case 'dispbbs.php':
	case 'savvy_dispbbs.php':
	case 'dispbbs':
	case 'savvy_dispbbs':
	case 'dispargue':
		if( strpos($_SERVER['HTTP_USER_AGENT'],'MSIE') !== false ){
			$ibodystyle = 'height:auto;width:97%;padding-right:0px; overflow-x: hidden;';
		} else{
			$ibodystyle = 'min-height:130px;';
		}
		$board_settings[81]= $board_settings[81]?($board_settings[81].'px'):'normal';
?>

<?
	break;
} //end switch 
$fontsize = $board_settings[80];
$lineheight = $board_settings[81];
if($lineheight == 0)
	$lineheight= 'normal';
$indent = $board_settings[82];
?>
	<style>
		.bodys{height:100% !important; min-height:200px; font-size:<?=$fontsize?>pt;line-height:<?=$lineheight?>;text-indent:<?=$indent?>px;margin-top:10px;}
		.bodys p{font-size:<?=$fontsize?>pt;}
	</style>
	<script src="templates/lang/<?=$GLOBALS['fsetting']['lang']?>/js/main_new.js" type="text/javascript" language='JavaScript' charset='gbk'></script>
	<script language='JavaScript' charset='gbk'>var imgpath = '<?=$imgurl?>'</script>
	<script src="templates/lang/<?=$GLOBALS['fsetting']['lang']?>/js/main.js" type="text/javascript" language='JavaScript' charset='gbk'></script>
	<script src="templates/lang/<?=$GLOBALS['fsetting']['lang']?>/js/tab.js" type="text/javascript" language='JavaScript' charset='gbk'></script>
</head>
<body>
<div id="showAjax" style="z-index:100;display:none;"></div>
<div id="showAjaxPic" style="z-index:100;display:none;"></div>
<div id="showEditor" style="z-index:100;display:none;"></div>
<?
//savepost.php文件不显示头部
if($ScriptName == 'index') {
?>
<div id="popmenu" class="menuskin" onmouseover="clearhidemenu();highlightmenu(event,'on')" onmouseout="highlightmenu(event,'off');dynamichide(event)" style="z-index:100"></div>
<?
}
if($istoptable==1){//if begin  头部右边广告条
	if ( $userid != 0 ){
		if($useindexstatic){
		$user_mymsg ="<a href=\"usermain.php?action=inbox\">".$lang['menu.user_mymsg']."</a>(";
		$user_mymsg .= '<? if( $sendmsgnum > 0 )echo "<bgsound src=\"".$imgurl."mail.wav\" border=0 align=\"middle\"><a href=\"javascript:openScript(\'messanger.php?action=read&amp;id=".$sendmsgid."&amp;sender=".$sendmsguser."\',500,400)\"><font class=redfont>".$sendmsgnum."</font></a>)";else echo "<font color=gray>0</font>)";?>';
		}
		else{
			$user_mymsg ="<a href=\"usermain.php?action=inbox\">".$lang['menu.user_mymsg']."</a>(";
			$user_mymsg .= ( $sendmsgnum > 0 )?"<bgsound src=\"".$imgurl."mail.wav\" border=0 align=\"middle\"><a href=\"javascript:openScript('messanger.php?action=read&amp;id=".$sendmsgid."&amp;sender=".$sendmsguser."',500,400)\"><font class=redfont>".$sendmsgnum."</font></a>)" : "<font color=gray>0</font>)";
		}
	}
	if(!empty($_GET['groupboardid'])){
		$tmpid='?groupboardid='.$_GET['groupboardid'];
	}else{
		$tmpid='?boardid='.$boardid;
	}
$showmsginfo = <<<EOT
<span id="showmsgid" >
	<style>
	.new_msg_ic{ position:absolute; z-index:998; width:115px;height:50px;margin:2px auto auto -20px; background:url({$imgurl}new_msg_ic.png) no-repeat top;*background-image: none;*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, src={$imgurl}new_msg_ic.png, sizingMethod=scale);}
}
	</style>
	<span class="new_msg_ic"></span>
	<span style="position:absolute;margin-top:22px;z-index:999;margin-left:-.5em;line-height:1.3em;">
	<a style="color:#000; font-family:'宋体'" href="usermain.php?action=inbox">{$lang['global.msg']}</a><img style="cursor:pointer;position:absolute;margin-left:.3em" onclick="closemsg()" src="{$imgurl}close_msg.png" />
	</span>
</span>
<script language="JavaScript" language='JavaScript' charset='gbk'>
	function dvshowmsg(){	getObj('showmsgid').style.display="";}
	function closemsg(){	
		getObj('showmsgid').style.display="none";	
		var date = new Date();	
		date.setTime(date.getTime()+86400000);	
		document.cookie="dvbbs_msghide=1;expires=" + date.toGMTString() + " path=/";
	}
	setTimeout('dvshowmsg();',1500);
</script>
EOT;
?>
<!--<?php
print <<<EOT
-->
<div class="header">
<table width="100%">
<tr>
	<td width="200" rowspan="2" style="padding-top:20px"><a href="{$fsetting['forumurl']}"><img border="0" src="{$fsetting['forumlogo']}" alt=""/></a></td>
	<td align="right" height="28" style="font-family:宋体" >
<!--
EOT;
	if($userid==0){print <<<EOT
-->
	<a href="reg.php">{$lang['menu.user_reg']}</a> | <a href="login.php">{$lang['menu.user_login']}</a> | <a href="query.php?boardid={$boardid}">{$lang['menu.search']}</a>　
	<span>
<!--
EOT;
	}else{
	if($useindexstatic){
		$login_hidden= "<? if(\$userinfo['userhidden'] == 2){echo \"<a href='cookies.php?action=hidden'>".$lang['menu.login_hidden']."</a>\";}else{echo \"<a href='cookies.php?action=online'>".$lang['menu.login_up']."</a>\";} ?>";
	}
	else{
		if ( $userinfo['userhidden'] == 2 ){
		$login_hidden = "<a href=\"cookies.php?action=hidden\">{$lang['menu.login_hidden']}</a>";
		}else{
		$login_hidden = "<a href=\"cookies.php?action=online\">{$lang['menu.login_up']}</a>";
		}
	}

	$logout_id = get_cookie('logout_id');
	empty($logout_id) AND ($logout_id = dv_md5(uniqid(rand(), true))) AND set_cookie('logout_id', $logout_id, get_cookie('selected_cookiedate'));
	
	global $groupsetting;
	if (true === $master OR 1 == $groupsetting[70] OR $useindexstatic){
		if($useindexstatic)
			$showadmin.= '<?  if (true === $master OR 1 == $groupsetting[70]){?>';
		$showadmin .= "<a href='{$fsetting['manageurl']}' target=\"_blank\">{$lang['menu.manage']}</a> | ";
		$showadmin .= "<a href='infolist.php?t=even'>{$lang['menu.manage_even']}</a> | ";
		$showadmin .= "<a href='accesstopic.php'>{$lang['menu.manage_audit']}</a> | ";
		$showadmin .= "<a href='recycle.php'>{$lang['menu.manage_recyle']}</a> | ";
		if($useindexstatic)
			$showadmin.= '<? }?>';
	}
	$membername_str= ($useindexstatic)? '<?=$membername?>' : $membername;
	print <<<EOT
-->
	<a href="usermain.php"><b>{$membername_str}</b></a> {$user_mymsg}
<!--
EOT;

if($useindexstatic){
		print '<? $showmsghide=get_cookie("msghide"); if($sendmsgnum>0 and $showmsghide!=1){?>';
	print <<<EOT
-->
{$showmsginfo}
<!--
EOT;
	print '<? }?>';
}
else if($sendmsgnum>0 and $showmsghide!=1){
print <<<EOT
-->
{$showmsginfo}
<!--
EOT;
}
print <<<EOT
-->
	| <a href="login.php">{$lang['menu.login_reload']}</a> | {$login_hidden} | <a href="query.php?boardid={$boardid}">{$lang['menu.search']}</a> | <a href="usermain.php">{$lang['menu.user_cpmain']}</a> | <a href="show.php?boardid={$boardid}">{$lang['menu.show']}</a> | <a href="plus_tools_center.php">{$lang['menu.tools']}</a> | 
	{$showadmin} 
	<a href="login.php?action=logout&amp;logout_id={$logout_id}" onclick="return DoLogout('{$logout_id}')" >{$lang['menu.user_logout']}</a>
	<span>
<!--
EOT;
	}print <<<EOT
-->
	</span></td>
</tr>
<tr>
	<td align="right">{$forum_ads[0]}</td>
</tr>
</table>
<!--
EOT;
global $savvy_board;
include_once CACHE_PATH.'savvy_board.php';
$savvy_boardlist=explode(',',$savvy_board['boardidset']['boardid_set']);
foreach ($savvy_boardlist as $forumboardid){
	empty($_DCACHE['all_forums']) AND require(CACHE_PATH.'board/board_all.php');
	$f_all_board=$_DCACHE['all_forums'];
	if( $f_all_board[$forumboardid]['depth'] != 0){
		$forum_savvy_boardid=$forumboardid;
		break;
	}	
}
if(intval($fsetting['issavvy_show'])==1){
	$savvyshowstr='<a href="forum_savvy.php?boardid='.$forum_savvy_boardid.'" title='.$lang['menu.savvy'].'>'.$lang['menu.savvy'].'</a>';
}
else{	
	$savvyshowstr=$lang["menu.savvy"];
}
	
print <<<EOT
-->
<div class="menu">
	<span>
	<a href="{$ForumUrl}rssfeed.php?rssid=4&amp;boardid={$boardid}" target="_blank"><img src="{$imgurl}/rss.gif"  title="{$lang['dv_fsettings.global.str8']}" alt="{$lang['dv_fsettings.global.str8']}" /></a>
	<a href="boardhelp.php?boardid={$boardid}" title="{$lang['dv_fsettings.global.str10']}" alt="{$lang['dv_fsettings.global.str10']}"><img src="{$imgurl}/help.gif" alt="" /></a>
	</span>
	<a href="{$fsetting['forumurl']}">{$lang['dvhometitle']}</a> | <a href="spaceindex.php?stype=3&psearch=0&nsearch=0">{$lang['menu.space']}</a> | <a href="indivgroup.php" alt="{$lang['tpl.str91']}" title="{$lang['tpl.str91']}">{$lang['menu.group']}</a> | {$savvyshowstr} |  
		<em class="m_li_top" onmouseover="showmenu('menu_22',0);">
		  <a href="#">{$lang['menu.skin_main']}</a>
		  <div class="submenu" id="menu_22" onmouseout="hidemenu(1);hidemenu(0);">
			<ul>
			  <li><a href="cookies.php?action=stylemod&amp;skinid=0&amp;boardid={$boardid}&amp;stype=default">{$lang['menu.skin_reload']}</a></li>
			  <li onmouseover="showmenu('menu_221',1);" >
				<a href="#">{$lang['menu.skin_str1']}</a>
				<div class="submenu_z" id="menu_221" onmouseout="hidemenu(1);hidemenu(0);">
				  <ul>
<!--
EOT;
	if (is_array($_DCACHE['forum_css'])) {
		foreach($_DCACHE['forum_css'] as $key=>$val){

print <<<EOT
-->
					<li><a href="cookies.php?action=stylemod&amp;skinid={$key}&amp;boardid={$boardid}&amp;stype=style">{$val[0]}</a></li>
<!--
EOT;
		}
	}

print <<<EOT
-->
				  </ul>
				</div>
			  </li>
			  <li class="m_li_top" style="margin-top:4px;"  onmouseover="showmenu('menu_222',1);">
				<a href="#">{$lang['menu.skin_str2']}</a>
				<div class="submenu_z" id="menu_222" onmouseout="hidemenu(1);hidemenu(0);">
				  <ul>
<!--
EOT;
	if (is_array($_DCACHE['forum_lang'])) {
		foreach($_DCACHE['forum_lang'] as $key=>$val){

print <<<EOT
-->
					<li><a href="cookies.php?action=stylemod&amp;skinid={$key}&amp;boardid={$boardid}&amp;stype=lang">{$val[0]}</a></li>
<!--
EOT;
		}
	}

print <<<EOT
-->
				  </ul>
				</div>
			  </li>
			</ul>
		  </div>
		</em>
| <a href="boardstat.php?boardid={$boardid}">{$lang['menu.skin_stat']}</a>
<!-- 后台用户建立的导航栏 BEGIN-->
<!--
EOT;

	if($plus_arr) {
		foreach($plus_arr as $key => $val) {
			if($val['plus_type']==0) {
				if($val['sub']) {
print <<<EOT
-->
					  | 
					<em class="m_li_top" onmouseover="showmenu('sub_{$key}',0);">
					  <a href="{$val['url']}"{$val['target']}>{$val['plus_name']}</a>
					  <div class="submenu" id="sub_{$key}" onmouseout="hidemenu(1);hidemenu(0);">
						<ul>
<!--
EOT;
					foreach($val['sub'] as $v) {
print <<<EOT
-->
						<li><a href="{$plus_arr[$v]['url']}"{$plus_arr[$v]['target']}>{$plus_arr[$v]['plus_name']}</a></li>
<!--
EOT;
					}
print <<<EOT
-->
						</ul>
					  </div>
					</em>
<!--
EOT;
				}
				else {
print <<<EOT
-->
					| <a href="{$val['url']}"{$val['target']}>{$val['plus_name']}</a>
<!--
EOT;
				}
			}
		}
	}
print <<<EOT
-->
<!-- 后台用户建立的导航栏 END-->
</div>
</div>
<script type="text/JavaScript" language='JavaScript' charset='gbk'>	
function setUserTimeZoneOffset()
{
	var js_date = new Date();
	var timezoneoffset = -(js_date.getTimezoneOffset())*60;
	document.cookie = 'dvbbs_user_timezone_offset=' + timezoneoffset;
}
//setInterval('setUserTimeZoneOffset()', 1000);
setUserTimeZoneOffset();
function DoLogout(logoutId)
{	
	if (-1 == document.cookie.indexOf('logout_id')) {
		document.cookie = 'logout_id='+logoutId;
	}
	return true;
}//end function DoLogout
</script>
<!-- 
EOT;
?>
-->
<?
if($isnav==1){
	function _getBoardPopupMenuList($parentboardid = 0, $tokenid = 'tokenid')
	{
		$parentboardid = ($parentboardid <= 0 ? 0 : intval($parentboardid));
		global $_DCACHE,$membername,$groupsetting;
		empty($_DCACHE['all_forums']) AND require(CACHE_PATH.'board/board_all.php');
		$allforums = $_DCACHE['all_forums'];
		if ($parentboardid > 0 AND !isset($allforums[$parentboardid])) {
			return '';
		}
		(empty($tokenid)) AND ($tokenid = 'menu_token_'.dv_md5(uniqid(rand(), true)));
		$returnval = '';
		$style_top='';
		foreach ($allforums AS $currboardid => $val) {
			//Start 隐含版面处理
				if(1 == $val['hidden']) {// 
					$_strboardmaster = $_DCACHE['all_forums'][$val['boardid']]['boardmaster'];
					//预留超级版主和管理员的权限判断
					if(('1' != $groupsetting[37]) OR (  $membername AND  false === strpos("|{$_strboardmaster}|", "|{$membername}|"))){
						continue;
					}
				}
			if ($val['parentid'] == $parentboardid) {
				if ($val['child'] > 0) {
					if(strpos($_SERVER['PHP_SELF'],'forum_savvy.php')===false){//如果是论坛知道则改变连接
						$newtokenid = 'menu_token_'.dv_md5(uniqid(rand(), true));
						$returnval .= "<li class=\"m_li\" onmouseover=\"showmenu('{$newtokenid}', ".($val['depth']+1).");\"><a href=\"index.php?boardid=".$currboardid."\">".$val['boardtype']."</a>"._getBoardPopupMenuList($currboardid, $newtokenid)."</li>";
					}
					else{
						$newtokenid = 'menu_token_'.dv_md5(uniqid(rand(), true));
						$returnval .= "<li class=\"m_li\" onmouseover=\"showmenu('{$newtokenid}', ".($val['depth']+1).");\"><a href=\"forum_savvy.php?boardid=".$currboardid."\">".$val['boardtype']."</a>"._getBoardPopupMenuList($currboardid, $newtokenid)."</li>";
					}
				}
				else {

						if(strpos($_SERVER['PHP_SELF'],'forum_savvy.php')===false){//如果是论坛知道则改变连接
							$returnval .= "<li><a href=\"index.php?boardid={$currboardid}\">".$val['boardtype']."</a></li>";
						}
						else{
							$returnval .= "<li><a href=\"forum_savvy.php?boardid={$currboardid}\">".$val['boardtype']."</a></li>";	
						}
						$style_top ="submenu_z";
				}
			}
		}//end foreach
		if ('' !== $returnval) {
			$nextdepth = intval($allforums[$parentboardid]['depth']) + 2;
			$strhidemenu = '';
			for ($i = $nextdepth; $i >= 0; $i--) {
				$strhidemenu .= 'hidemenu('.$i.');';
			}
			$style_top = !empty($style_top) ? $style_top : 'submenu';
			return "<div class=\"{$style_top}\" id=\"{$tokenid}\" onmouseout=\"{$strhidemenu};\"><ul>".$returnval."</ul></div>";
		} else {
			return '';
		}
	}//end function _getBoardPopupMenuList
	$strNavMenu = "<ul style=\"display:inline;margin:0px;padding:0px\"><li class=\"m_li\" onmouseover=\"showmenu('menu_topmenu_0', 0);\" style=\"display:inline;\"><a href=\"{$fsetting['homepage']}\"><B>".$fsetting['forumname']."</B></a>"._getBoardPopupMenuList(0, 'menu_topmenu_0').'</li></ul>&nbsp;';
	if( !empty($arrNavMenu) ){
		if( is_array($arrNavMenu) ){
			$count = count($arrNavMenu);
			global $_DCACHE;
			$all_forums =& $_DCACHE['all_forums'];
			foreach( $arrNavMenu as $val ){
				if( empty($val) || !is_array($val)) continue;
				$strNavMenu .=$lang['header.menu.str1'];
				if (empty($val['linkurl'])) {
					$strNavMenu .= $val['linktitle'];
				}
				else {
					if ($val['board_child'] > 0) {
						$tokenid = 'menu_token_'.dv_md5(uniqid(rand(), true));
						$strNavMenu .= "<ul style=\"display:inline;margin:0px;padding:0px;margin-right:2px;\"><li class=\"m_li\" onmouseover=\"showmenu('{$tokenid}', ".intval($val['depth']).");\" style=\"display:inline;\"><a href=\"{$val['linkurl']}\">{$val['linktitle']}</a>"._getBoardPopupMenuList($val['board_id'], $tokenid)."</li></ul>";
					}
					else {
						$strNavMenu .= "<a href=\"{$val['linkurl']}\">{$val['linktitle']}</a>";
					}
				}
			}
		}
	}

?>
<div class="mainbox">	
	<div class="notice" style="height:30px; margin-bottom:0px;">
	<span><?=$strNavMenu?></span>
<?
if (!empty($boardid)){
	global $substype;

?>
	<form METHOD=POST ACTION="query.php?" style="margin:0;padding:0">
	<input type="text" name="keyword" />
	<select name="stype">
	<option value=2><?=$lang['global.so1']?></option>
	<option value=1><?=$lang['global.so2']?></option>
	<option value=3><?=$lang['global.so3']?></option>
	</select>
	<input type="hidden" name="substype" value="<?=(isset($substype)?strval($substype):"")?>">
	<button onmousemove="button_move(this)" onmouseout="button_out(this)" style=" margin-left:5px; text-indent:0px;" type="submit" name="so"> 搜 索 </button>
	</form>
<?
}#boardid end
else if((!empty($_GET['groupid'])) || ($ScriptName == 'indivgroup') || ($ScriptName == 'indivgroup_list')){
	$keyword=$_POST['keyword'];
	if($keyword==''){
		$keyword=$_GET['keyword'];
	}
?>
	<form method="post" action="indivgroup_list.php" name="searchfrm" style="margin:0;padding:0">
	<input type="text" name="keyword" title="<?=$lang['searchinfo']?>" value="<?=$keyword?>" onmouseover="this.className='TextBoxFocus'" onmouseout="this.className='TextBox'" /> <a href="javascript:document.searchfrm.submit();"><img src="<?=$imgurl?>search.gif" /></a>
	</form>
<?
}
?>
	</div>
</div><!-- mainbox end -->
<?
}#isnav end

}#istoptable end

?>