<?php
if( !defined('ISDVBBS') ){
	header('HTTP/1.0 404 Not Found');
	exit;
}
global $spaceUserInfo;
$skinpath = $spaceUserInfo['s_path'];
require_once INC_PATH.'DV_Encoding.class.php';
if (empty($objEnc)) {
	$objEnc =& DV_Encoding::GetEncoding($charset);
}
print <<<EOT
			<!-- 主体内容左边区开始 -->
			<div class="Left">
				<!-- 控制面板开始 -->
				<div class="Panel">
					<h1>查询</h1>
					<form method="post" action="spacesearch.php" style="display:inline;">
						<input type="hidden" name="user" value="{$GLOBALS['spaceName']}" />
						<ul>
							<li><span><input type="text" name="keyword" value="" size="21"/></li>
							<li>
								<input type="radio" class="radio" name="sel" value="0" checked="checked" />标题
								<input type="radio" class="radio" name="sel" value="1" />作者
								<select name="stype">
									<option value="-1">分类</option>
EOT;
if (!empty($lang['spaceStype']) AND is_array($lang['spaceStype'])) {
	foreach ($lang['spaceStype'] AS $index => $val) {
		print <<<EOT
									<option value="{$index}">{$val}</option>
EOT;
	}//end foreach
}
print <<<EOT
								</select><hr />
							</li>
							<li><button name="loginsubmit" type="submit" value="true" style="width:60px">查 询</button></li>
						</ul>
					</form>
				</div>
				<!-- 控制面板结束 -->

				<!-- 栏目导航开始 -->
				<div class="Panel">
					<h1>栏目导航</h1>
					<ul class="Nav">
						<li>
EOT;
if (!empty($lang['spaceStype']) AND is_array($lang['spaceStype'])) {
	global $spaceConfig_Syschatcat_parent, $spaceConfig_UserCat;
	foreach ($lang['spaceStype'] AS $index => $val) {
		print <<<EOT
							<span><img alt="" src="{$skinpath}/images/i10.gif" /><b> {$val}</b></span>
EOT;
		if (!empty($spaceConfig_UserCat['result_set']) AND is_array($spaceConfig_UserCat['result_set'])) {
			foreach ($spaceConfig_UserCat['result_set'] AS $val2) {
				if ($val2['utype'] != $index) {
					continue;
				}
				print <<<EOT
							<span><img alt="" src="$skinpath/images/1.gif" /><a href="{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.showchannel.{$index}.{$val2['ucatid']}.html">{$val2['ucattitle']}</a> [{$val2['topicnum']}] <img alt="" src="$skinpath/images/rss.gif" /></span>
EOT;
			}//end foreach
		}
	}//end foreach
}
print <<<EOT
						</li>
					</ul>
				</div>
				<!-- 栏目导航结束 -->

				<!-- 最新图片开始 -->
				<div class="Panel">
					<h1>最新图片</h1>
					<div class="NewlyPhoto">
EOT;

$_arrDBInfo =& getSpaceNewPic();
if (!empty($_arrDBInfo['ResultSet'])) {
		$_sArrPic=array();
		foreach( $_arrDBInfo['ResultSet'] AS $_index => $_val ){
			$_tpl_topic = $_val['title'];
			if( $objEnc->StrLength($_tpl_topic) > 20 ){
				$_tpl_topic = $objEnc->SubString($_tpl_topic,0,20).'...';
			}
			$_tpl_topic = Dv_FilterJS($_tpl_topic);
			//$sfilename = strtolower(trim($_val['sfilename']));
			if (1 == $_val['filetype']) {
				$_tpl_ViewPhoto = $_val['previewimage'].'';
				if( $_tpl_ViewPhoto === '' ){
					//$_tpl_ViewPhoto = $spaceSystemUpSetting[19].$_val['filename'];
					$_tpl_ViewPhoto = $_val['filename'];
				}
			} elseif (0 == $_val['filetype']) {
				if (1 == preg_match('#\.([a-zA-Z0-9]+?)$#i', trim($_val['sfilename']), $matchs)) {
					$matchs[1] = strtolower($matchs[1]);
					if ('rar' == $matchs[1] OR 'zip' == $matchs[1]) {
						$_tpl_ViewPhoto = 'space/images/rar.gif';
					} elseif ('txt' == $matchs[1]) {
						$_tpl_ViewPhoto = 'space/images/txt.gif';
					}
				} else {
					$_tpl_ViewPhoto = 'space/images/info.gif';
				}
			} elseif (2 == $_val['filetype']) {
				$_tpl_ViewPhoto = 'space/images/swf.gif';
			} elseif (3 == $_val['filetype']) {
				$_tpl_ViewPhoto = 'space/images/media.gif';
			} elseif (4 == $_val['filetype']) {
				$_tpl_ViewPhoto = 'space/images/media.gif';
			} else {
				$_tpl_ViewPhoto = 'space/images/info.gif';
			}
			$_sArrPic[$_index][SpacePic]   =$_tpl_ViewPhoto;
			$_sArrPic[$_index][SpaceTitle] =$_tpl_topic;
			$_sArrPic[$_index][SpaceICid]  =$_val['topicid'];
		}
		


print <<<EOT

					
					<script type="text/javascript" language="javascript">
					<!--			
					var xsTextBar = 1; //是否显示文字链接，1为显示，0为不显示
					var xsPlayBtn = 0; //是否显示播放按钮，1显示，0为不显示
					var xsImgSize = new Array(151,120); //幻灯图片的尺寸，格式为“宽度,高度”

					var xsImgs = new Array();
					var xsImgLinks = new Array();
					var xsImgTexts = new Array();

EOT;

					if (!empty($_sArrPic)) {
						foreach( $_sArrPic AS $_index => $_val ){

print <<<EOT
					xsImgs[{$_index}] = "{$spaceuploadbasedir}{$_val[SpacePic]}";
					xsImgLinks[{$_index}] = "{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.showtopic.{$_val['SpaceICid']}.html";
					xsImgTexts[{$_index}] = "{$_val[SpaceTitle]}";
EOT;
						}
					}
print <<<EOT
//-->
					</script>
					<script language="javascript" type="text/javascript" src="/js/dvSpaceNewPic.js"></script>

EOT;

}else{

print <<<EOT
					<img alt="" src="$skinpath/images/lady_060607_151x130_1.jpg" />
				    <div>暂未添加该信息</div>
EOT;
}
print <<<EOT
					</div>
				</div>
				<!-- 最新图片结束 -->

				<!-- 最新评论开始 -->
				<div class="Panel">
					<h1>最新评论</h1>
EOT;
if (!empty($spaceUserCat['spacepost']) AND is_array($spaceUserCat['spacepost']) ){
	print <<<EOT
					<ul class="line">
						<li class="CorpsLi">
EOT;
	foreach ($spaceUserCat['spacepost'] AS $spacepost) {
		$_tpl_title = $spacepost['title'].'';
		if( $_tpl_title === '' ){
			$_tpl_title = $spacepost['content'];
		}
		$_tpl_title = strip_tags($_tpl_title);
		if( $objEnc->StrLength($_tpl_title) > 16 ){
			$_tpl_title = $objEnc->SubString($_tpl_title,0,16).'...';
		}
		$_tpl_TopicID = $spacepost['rootid'];
		$_tpl_PostID = $spacepost['postid'];
		$_tpl_postusername = $spacepost['username'];
		print <<<EOT
							<span>·</span><a href="{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.showtopic.{$_tpl_TopicID}.{$_tpl_PostID}.html#{$_tpl_PostID}">{$_tpl_title}</a><br />
EOT;
	}//end foreach
	print <<<EOT
						</li>
					</ul>
EOT;
} else {
	print '<span style="display:block;margin:10px auto 0px auto;width:98%;">暂未添加该信息。</span><br />';
}
print <<<EOT
				</div>
				<!-- 最新评论结束 -->

				<!-- 最新播客开始 -->
				<div class="Panel">
					<h1>最新播客</h1>
					<ul class="line">
						<li class="CorpsLi">
EOT;
if (!empty($spaceUserCat['spacemusic']) AND is_array($spaceUserCat['spacemusic']) ){
	foreach ($spaceUserCat['spacemusic'] AS $spacemusic) {
		$_tpl_title = $spacepost['title'].'';
		if( $_tpl_title === '' ){
			$_tpl_title = $spacemusic['content'];
		}
		$_tpl_title = strip_tags($_tpl_title);
		if( $objEnc->StrLength($_tpl_title) > 16 ){
			$_tpl_title = $objEnc->SubString($_tpl_title,0,16).'...';
		}
		$_tpl_TopicID = $spacemusic['rootid'];
		$_tpl_PostID = $spacemusic['postid'];
		$_tpl_postusername = $spacemusic['username'];
		print <<<EOT
							<em><img src="{$skinpath}/images/player2.gif" alt="" /></em> <span>·</span><a href="{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.showtopic.{$_tpl_TopicID}.{$_tpl_PostID}.html#{$_tpl_PostID}">{$_tpl_title}</a><br />
EOT;
	}
} else {
	print '暂未添加该信息。<br />';
}
$joinspacetime = gmdate('Y年m月d日', $spaceUserInfo['joinspacetime']+getUserTimeZoneOffset());
$spaceupdatetime = gmdate('Y年m月d日', $spaceUserInfo['lastuptime']+getUserTimeZoneOffset());
global $arrArchiveLink;
$timestamp = '';
if (!empty($arrArchiveLink[2]) AND false !== strpos($arrArchiveLink[2], 'date_')) {
	list(, $tmpdate) = explode('date_', $arrArchiveLink[2]);
	list($yearnow, $monthnow1, $monthnow2, $daynow, $hournow, $minutenow, $secondnow, $t) = explode('-', dateFormat($tmpdate, 'Y-n-m-d-H-i-s-t'));
} else {
	list($yearnow, $monthnow1, $monthnow2, $daynow, $hournow, $minutenow, $secondnow, $t) = explode('-', gmdate('Y-n-m-d-H-i-s-t', TIME_NOW+getUserTimeZoneOffset()));
}
$pre_date_year = 'date_'.gmdate('Ymd', gmmktime(0, 0, 0, $monthnow2, $daynow, $yearnow - 1));
$next_date_year = 'date_'.gmdate('Ymd', gmmktime(0, 0, 0, $monthnow2, $daynow, $yearnow + 1));
$pre_date_month = 'date_'.gmdate('Ymd', gmmktime(0, 0, 0, $monthnow2 - 1, $daynow, $yearnow));
$next_date_month = 'date_'.gmdate('Ymd', gmmktime(0, 0, 0, $monthnow2 + 1, $daynow, $yearnow));
print <<<EOT
						</li>
					</ul>
				</div>
				<!-- 最新播客结束 -->

				<!-- 我的空间统计开始 -->
				<div class="Panel">
					<h1>我的空间统计</h1>
					<ul class="line">
						<li class="CorpsLi"><span>· </span>今日数:{$spaceUserInfo['todaynum']} <br />
						<span>· </span>文章数:{$spaceUserInfo['topicnum']} <br />
						<span>· </span>收藏数:{$spaceUserInfo['favnum']} <br />
						<span>· </span>图片数:{$spaceUserInfo['photonum']} <br />
						<span>· </span>评论数:{$spaceUserInfo['postnum']} <br />
						<span>· </span>开设时间:{$joinspacetime} <br />
						<span>· </span>更新时间:{$spaceupdatetime}</li>
					</ul>
				</div>
				<!-- 我的空间统计结束 -->

				<!-- 日期开始 -->
				<div class="Panel">
					<h1>日期</h1>
					<div id="calendar_body">
						<div id="calendar_top">
							<div id="lefta" onclick="top.location.href='{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.index.{$pre_date_year}.html#anchor_diary_topic'"></div>
							<div id="leftb" onclick="top.location.href='{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.index.{$pre_date_month}.html#anchor_diary_topic'"></div>
							<div id="rightb" onclick="top.location.href='{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.index.{$next_date_year}.html#anchor_diary_topic'"></div>
							<div id="righta" onclick="top.location.href='{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.index.{$next_date_month}.html#anchor_diary_topic'"></div>
							<a name="anchor_diary_topic">{$yearnow}年{$monthnow1}月</a>
						</div>
						<div id="calendar_week">
							<ul class="week_ul">
								<li><font color="#ff0000">日</font></li>
								<li>一</li>
								<li>二</li>
								<li>三</li>
								<li>四</li>
								<li>五</li>
								<li><font color="006600">六</font></li>
							 </ul>
						</div>
EOT;
$blntmp = !empty($spaceUserInfo['diary_topic']);
for ($crtday = 1; $crtday <= $t; ) {
	print <<<EOT
						<div class="calendar_day">
							<ul class="day_ul">
EOT;
	$arrweek = array(0=>array('otherday','&nbsp;', ''), 1=>array('otherday','&nbsp;', ''), 2=>array('otherday','&nbsp;', ''), 3=>array('otherday','&nbsp;', ''), 4=>array('otherday','', ''), 5=>array('otherday','&nbsp;', ''), 6=>array('otherday','&nbsp;', ''));
	//$currtimestamp = strtotime("{$yearnow}-{$monthnow2}-{$crtday}");
	$currtimestamp = gmmktime(0, 0, 0, $monthnow2, $crtday, $yearnow);
	$weeknumber = gmdate('w', $currtimestamp);
	for ($i = $weeknumber; $i < 7 ; $i++) {
		if ($crtday > $t) {
			break;
		}
		if ($crtday < 10) {
			$crtday = '0'.$crtday;
		}
		//$currtimestamp = strtotime("{$yearnow}-{$monthnow2}-{$crtday}");
		$currtimestamp = gmmktime(0, 0, 0, $monthnow2, $crtday, $yearnow);
		$weeknumber = gmdate('w', $currtimestamp);
		$arrweek[$weeknumber][1] = $crtday;
		if ($crtday == $daynow) {
			$arrweek[$weeknumber][0] = 'today';
		} elseif (true === $blntmp AND !empty($spaceUserInfo['diary_topic'][$currtimestamp-getUserTimeZoneOffset()])) {
			$arrweek[$weeknumber][0] = 'haved';
		}
		if (true === $blntmp AND !empty($spaceUserInfo['diary_topic'][$currtimestamp-getUserTimeZoneOffset()])) {
			$arrweek[$weeknumber][2] = " href=\"{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.index.{$yearnow}{$monthnow2}{$crtday}.html\"";
		}
		$crtday++;
	}//end for
	print <<<EOT
								<li class="daya"><a class="{$arrweek[0][0]}" {$arrweek[0][2]}>{$arrweek[0][1]}</a></li>
								<li class="daya"><a class="{$arrweek[1][0]}" {$arrweek[1][2]}>{$arrweek[1][1]}</a></li>
								<li class="daya"><a class="{$arrweek[2][0]}" {$arrweek[2][2]}>{$arrweek[2][1]}</a></li>
								<li class="daya"><a class="{$arrweek[3][0]}" {$arrweek[3][2]}>{$arrweek[3][1]}</a></li>
								<li class="daya"><a class="{$arrweek[4][0]}" {$arrweek[4][2]}>{$arrweek[4][1]}</a></li>
								<li class="daya"><a class="{$arrweek[5][0]}" {$arrweek[5][2]}>{$arrweek[5][1]}</a></li>
								<li class="daya"><a class="{$arrweek[6][0]}" {$arrweek[6][2]}>{$arrweek[6][1]}</a></li>
							</ul>
						</div>
EOT;
}//end for
print <<<EOT
					</div>
				</div>
				<!-- 日期结束 -->
				
				<!-- 友情链接开始 -->
				<div class="Link">
					<span><img alt="订阅本站的 rss 2.0 新闻组" src="$skinpath/images/xml.gif" /></span>
					<span><img alt="" src="$skinpath/images/w3c_xhtml.gif" /></span>
					<span><img alt="" src="$skinpath/images/w3c_css.gif" /></span>
					<span><img alt="" src="$skinpath/images/boke_icon.gif" /></span>
				</div>
				<!-- 友情链接结束 -->
			</div>
			<!-- 主体内容左边区结束 -->
EOT;
?>