<?php
!function_exists('readover') && exit('Forbidden');

$cskindb = array();
if ($winduid && is_numeric($skin)) {
	$cskindb = $db->get_one('SELECT sid,name,stylepath,tplpath,yeyestyle,bgcolor,linkcolor,tablecolor,tdcolor,tablewidth,mtablewidth,headcolor,headborder,headfontone,headfonttwo,cbgcolor,cbgborder,cbgfont,forumcolorone,forumcolortwo FROM pw_styles WHERE sid='.pwEscape($skin).'AND uid='.pwEscape($winduid));
}
if ($cskindb) {
	$skin = $cskindb['name'];
	$db_showcss = 0;
	$cskindb['bgcolor'] = str_replace('&#41;',')',$cskindb['bgcolor']);
	extract($cskindb);
	unset($cskindb);
} else {
	if (strpos($skin,'..')===false && file_exists(D_P."data/style/$skin.php") && $db_styledb[$skin][1]==='1') {
		@include Pcv(D_P."data/style/$skin.php");
	} elseif (strpos($db_defaultstyle,'..')===false && file_exists(D_P."data/style/$db_defaultstyle.php")) {
		@include Pcv(D_P."data/style/$db_defaultstyle.php");
	} else {
		@include(D_P."data/style/wind.php");
	}
}
include_once(D_P.'data/bbscache/catedbs_'.$db_mode.'_cache.php');
if (!$catedbs) {
	$catedbs = array();
	PwNewDB();
	$rs = $db->query("SELECT fid,name FROM pw_forums WHERE type='category' AND cms!=1 AND childid>0 ORDER BY vieworder");
	while ($rt = $db->fetch_array($rs)) {
		$catedbs[$rt['fid']] = strip_tags($rt['name']);
	}
	writeover(D_P.'data/bbscache/catedbs_'.$db_mode.'_cache.php',"<?php\r\n\$catedbs=".pw_var_export($catedbs).";\r\n?>");
}
//頭部版塊,發帖導航
$head_forumlist = areaForumlist();
$head_postlist = areaForumlist('post','menu_post_nav');


if ($groupid != 'guest') {
	require_once(R_P.'require/showimg.php');
	list($faceurl) = showfacedesign($winddb['icon'],1);
	$lastlodate = get_date($winddb['lastvisit'],'Y-m-d');
} else {
	if ($db_question) {
		list(,$qcheck) = explode("\t",$db_qcheck);
		if ($qcheck) {
			$qkey = array_rand($db_question);
		}
	}
	$arr_logintype = array();
	if ($db_logintype) {
		for ($i = 0; $i < 3; $i++) {
			if ($db_logintype & pow(2,$i)) {
				$arr_logintype[] = $i;
			}
		}
	} else {
		$arr_logintype[0] = 0;
	}
}

//pw7.0
if (!in_array(SCR,array('register','login'))) {
	$myshortcut = true;
	$shortcutforum = array();
	if ($winddb['shortcut']) {
		isset($forum) || require(D_P.'data/bbscache/forum_cache.php');
		foreach (explode(',',$winddb['shortcut']) as $key => $value) {
			if ($value && isset($forum[$value])) {
				$shortcutforum[$value] = $forum[$value]['name'];
			}
		}
	}
	if (empty($shortcutforum)) {
		if (!$db_shortcutforum && $winduid) {
			require_once(R_P.'require/updateforum.php');
			$db_shortcutforum = updateshortcut();
		}
		$shortcutforum = $db_shortcutforum;
		$myshortcut = false;
	}
}

$msgsound = $head_pop = $menu_down = '';
if ($groupid == 'guest' && $db_regpopup == '1') {
	$head_pop = 'head_pop';
} elseif ($winddb['newpm']>0 && !$_COOKIE['msghide'] && $db_msgsound && $secondurl!='message.php' && $_G['maxmsg']>0) {
	$msgsound = "<bgsound src=\"$imgpath/$stylepath/msg.wav\" border=\"0\">";
}
$db_menuinit = "'td_hack' : 'menu_hack','td_skin' : 'menu_skin'";

if ($winduid) {
	$db_menuinit .= ",'td_u' : 'menu_u'";
}
if ($db_menu%2 == 1) {
	$db_menuinit .= ",'td_sort' : 'menu_sort'";
	$menu_down = "class=\"drop-item\"";
}
if ($db_union) {
	$db_union = explode("\t",stripslashes($db_union));
	$db_union[0] && $db_hackdb = array_merge((array)$db_hackdb,(array)unserialize($db_union[0]));
}


$db_skindb = array();
empty($db_styledb) && $db_styledb['wind'] = array('0' => 'wind','1' => '1');
foreach ($db_styledb as $key => $value) {
	$cname = $value[0] ? $value[0] : $key;
	$value[1] === '1' && $db_skindb[$key] = $cname;
}

$s_url = $pwServer['PHP_SELF'].'?';
foreach ($_GET as $key => $value) {
	$key!='skinco' && $value && $s_url .= "$key=".rawurlencode($value).'&';
}
$s_url = Char_cv($s_url);

if (file_exists(D_P."data/style/{$tplpath}_css.htm")) {
	$css_path = D_P."data/style/{$tplpath}_css.htm";
} else {
	$css_path = D_P.'data/style/wind_css.htm';
}

//pw7.0
if ($_COOKIE['inforhide'] || in_array(SCR,array('message','profile','u','register','login','userpay')) || $showlogin) {
	$infoboxstyle = 'style="display:none"';
	$one_key_class = 'one-show';
} else {
	$infoboxstyle = '';
	$one_key_class = 'one-hidden';
}

if (SCR=='index' || $SCR == 'm_home') {
	$key = empty($db_mode) ? ($defaultMode == 'bbs' ? 'home' : 'bbs') : (($defaultMode == $db_mode) ? 'home' : $db_mode);
	${'pwNavCurStyle_'.$key} = 'class="current"';
}

if (defined('M_P') && in_array(SCR,array('index','cate','mode','thread'))) {
	$pwModeCss = $pwModeImg.'/style.css';
} else {
	$pwModeCss = '';
}

require PrintEot('header');

?>