<?php
if( !defined('ISDVBBS') ){
	header('HTTP/1.0 404 Not Found');
	exit;
}
//print '<pre>'.print_r($spaceUserInfo).'</pre>';
print <<<EOT
		<!-- 主体内容开始  -->
		<div class="MySpqceBody">
EOT;
global $spaceUserInfo, $fsetting, $spaceSystemUpSetting, $spaceuploadbasedir;
$spaceuploadbasedir = basename($fsetting['forumuploadname']).'/'.basename($spaceSystemUpSetting[19]).'/';
$skinpath = $spaceUserInfo['s_path'];
require printout('space.leftmenu');
//print '$skinpath:'.$skinpath;
require_once INC_PATH.'space.functions.php';
require_once INC_PATH.'DV_Encoding.class.php';
$objEnc =& DV_Encoding::GetEncoding($charset);
$Tpl_spaceName = $spaceName ? $spaceName : $spaceUserName;
$Tpl_spaceUrl = $ModHtmlLinked;
$_tpl_skinPath = $spaceUserInfo['s_path'];
$_tpl_spaceName = $spaceName ? $spaceName : $spaceUserName;
$_tpl_spaceUrl = $ModHtmlLinked;

print <<<EOT
		<link href="{$skinpath}css/myspace_style.css" type="text/css" rel="stylesheet" />
		<!-- 主体内容右边区开始 -->
			<div class="Right">
EOT;
switch($_strArchiveLink){
	case 'showtopic':
		showTopic();
		break;
	case 'showchannel':
		showChannel();
		break;
	default:
		topicList();
		break;
}
print <<<EOT
			</div>
			<!-- 主体内容右边区结束 -->
		</div>
		<!-- 主体内容结束  -->
EOT;

function topicList()	//首页主题显示
{
	global $spaceUserInfo, $lang, $spaceUserID, $spaceUserCat, $spaceSystemSetting, $spaceConfig_Syschatcat, $objEnc, $skinpath, $Tpl_spaceName, $Tpl_spaceUrl;
	$GLOBALS['DV_HTML_TITLE'] = "信息列表-{$spaceUserInfo['nickname']}的空间";
	if ($spaceUserID <= 0) {
		spaceShowMsg('用户不存在或填写的资料有误！您可以 <a href="spaceapply.php">申请我的空间</a> 或 <a href="login.php">登录论坛</a>', 0, '', false);
		return false;
	}
	if (empty($spaceUserCat) OR !is_array($spaceUserCat)) {
		//return false;
		/*
		spaceShowMsg('用户不存在或填写的资料有误！您可以 <a href="spaceapply.php">申请我的空间</a> 或 <a href="login.php">登录论坛</a>', 0, '', false);
		return false;//*/
	}
	$weatherA = explode('|',$spaceSystemSetting[13]);
	$weatherB = explode('|',$spaceSystemSetting[14]);
	$weather = count($weatherA);
	$topiclist =& getTopicList();
	if (empty($topiclist['ResultSet']) OR !is_array($topiclist['ResultSet'])) {
		spaceShowMsg('当前用户空间未有新帖！', 0, '', false);
		return false;
	}
	if (!empty($topiclist['ResultSet']) AND is_array($topiclist['ResultSet'])) {
		foreach ($topiclist['ResultSet'] AS $val) {
			$posttime = $val['posttime'].'';
			if(empty($posttime)){
				$posttime = gmdate('Y-m-d H:i:s', TIME_NOW + getUserTimeZoneOffset());
			} else {
				$posttime = gmdate('Y-m-d H:i:s', $posttime + getUserTimeZoneOffset());
			}
			$topictitle = $val['title'].'';
			if( $objEnc->StrLength($topictitle) > 150 ){
				$topictitle = $objEnc->SubString($topictitle).'...';
			}
			$topictitle = Dv_FilterJS($topictitle);
			$titlenote = trim($val['titlenote']);
			if ($val['weather'] > ($weather - 1) OR $val['weather'] < 0) {
				$strweatherA = '晴天';
				$strweatherB = 'sun.gif';
			} else{
				$strweatherA = $weatherA[$val['weather']];
				$strweatherB = $weatherB[$val['weather']];
			}
			$postusername = $val['username'];
			$child = $val['child'];
			$hits = $val['hits'];
			$topicid = $val['topicid'];
			$scatid = $val['scatid'];
			$postuserid = $val['userid'];
			$catid = $val['catid'];
			$stype = $val['stype'];
			$channel = $spaceConfig_Syschatcat[$scatid]['scattitle'];
			if (!empty($spaceUserCat['result_set']) AND is_array($spaceUserCat['result_set'])) {
				foreach( $spaceUserCat['result_set'] as $val2 ){
					if( $val2['ucatid'] == $val['catid'] ){
						$channel = $val2['ucattitle'];
						break;
					}
				}
			}
			print <<<EOT
				<div class="TopicBlock">
					<h1><em>{$posttime}   　<img alt="" src="space/images/weather/{$strweatherB}" border="0" /></em><img alt="" src="{$skinpath}images/icon_quote.gif" width="16" height="16" /><a title="#" href="{$Tpl_spaceUrl}{$Tpl_spaceName}.showtopic.{$topicid}.html" style="color:black;">{$topictitle}</a></h1>
					<h2> {$titlenote} </h2>
					<div><img alt="" src="{$skinpath}images/more.gif" width="9" height="10" /><a title="#" href="{$Tpl_spaceUrl}{$Tpl_spaceName}.showtopic.{$topicid}.html">阅读全文...</a><br />
					<center>
					分类:<a title="#" href="#">{$channel}</a> | <a href="#">固定链接</a> | <a href="#">评论: {$child}</a> | 引用: 0 | 查看次数: {$hits}
					<img alt="" src="{$skinpath}images/rss.gif" /></center></div>
				</div>
EOT;
		}
		if ($topiclist['RecordCount'] > 0) {
			global $arrArchiveLink;
			$_tpl_PageSearch = $GLOBALS['ModHtmlLinked'].urlencode("{$GLOBALS['spaceName']}.index.{$arrArchiveLink[2]}.");
			print <<<EOT
				<div style="width: auto; height: 30px; padding:0px; margin: 0px auto;overflow: hidden; font-size:12px;"><script type="text/javascript" language="JavaScript" src="space/script/pagination.js"></script>
				<script type="text/javascript" language="JavaScript">
				PageList({$topiclist['AbsolutePage']},3,{$topiclist['PageSize']},{$topiclist['RecordCount']},"{$_tpl_PageSearch}",5);
				</script></div>
EOT;
		}
	}
}

function showTopic()	//	频道文章显示
{
	global $spaceSetting,$master,$userid,$lang,$arrArchiveLink,$spaceUserID,$spaceUserCat,$spaceSystemSetting,$spaceUserInfo;
	global $skinpath,$dv,$db,$lang,$_objEnc,$_tpl_skinPath,$_tpl_spaceName,$_tpl_spaceUrl,$isSpaceMaster,$isSpaceOwner;
	$GLOBALS['DV_HTML_TITLE'] = "{$spaceUserInfo['nickname']}的空间-查看信息";
	if( count($arrArchiveLink) < 3 ){
		$_intRootID = 0;
	} else{
		$_arrTmp = explode('-', $arrArchiveLink[2]);
		if( count($_arrTmp) == 2 ){
			$_strTmp = str_replace('.html', '',strtolower($_arrTmp[1]));
			$_intPage = is_numeric($_strTmp) ? $_strTmp : 0;
			$_intRootID = $_arrTmp[0];
		} else{
			$_intPage = 1;
			$_strTmp = str_replace('.html','',strtolower($_arrTmp[0]));
			$_intRootID = is_numeric($_strTmp) ? $_strTmp : 0;
		}
	}
	if ($_intRootID <= 0) {
		spaceshowmsg('参数错误！', 0, '', false);
		return false;
	}
	$_arrWeatherA = explode('|',$spaceSystemSetting[13]);
	$_arrWeatherB = explode('|',$spaceSystemSetting[14]);
	$_intWeather = count($_arrWeatherA);
	$_arrTopicInfo =& getSpaceTopicBy($_intRootID);
	$GLOBALS['DV_HTML_TITLE'] = htmlspecialchars($_arrTopicInfo['title'])."-{$spaceUserInfo['nickname']}的空间";
	if( $_arrTopicInfo === false ){
		spaceshowmsg('查找的信息不存在或没有进行该管理操作权限。', 0, '', false);
		return false;
	}
	switch(intval($_arrTopicInfo['islock'])){
		case 1://认证
			break;
		case 2://关闭
			if( $_arrTopicInfo['userid'] != $userid && $master !== true ){
				spaceshowmsg('查找的信息不存在或没有进行该管理操作权限。', 0, '', false);
				return false;
			}
			break;
		case 3://隐藏
			if( $_arrTopicInfo['userid'] != $userid ){
				spaceshowmsg('查找的信息不存在或没有进行该管理操作权限。', 0, '', false);
				return false;
			}
			break;
	}
	$_arrTopicInfo['title'] = DV_FilterJS($_arrTopicInfo['title']);
	$db->query("UPDATE {$dv}space_topic SET hits=hits+1 WHERE topicid='{$_intRootID}'");
	if (2 == $_arrTopicInfo['stype']){
		$_strRedirectUrl = $db->scalar("SELECT content FROM {$dv}space_post WHERE parentid=0 AND rootid='{$_intRootID}'");
		header("Location:{$_strRedirectUrl}");
		return false;
	}
	$_arrTmp = array();
	if( !empty($spaceUserCat['result_set']) && is_array($spaceUserCat['result_set']) ){
		foreach( $spaceUserCat['result_set'] AS $_val ){
			if( $_val['utype'] == $_arrTopicInfo['catid'] ){
				$_arrTmp = $_val;
				break;
			}
		}
	}
	if( empty($_arrTmp) ){
		$_tpl_ChannelInfo = '';
	} else{
		$_tpl_ChannelInfo = $_arrTmp['ucatnote'];
	}
	$_tpl_VisitPic = $spaceSetting[12];
	$_arrVisitUser = false;
	if( $_arrTopicInfo['visituser'].'' !== '' ){
		$_arrVisitUser = unserialize($_arrTopicInfo['visituser']);
	}
	$_tpl_Vsisitstr = '';
	if( $_arrVisitUser === false ){
		$_tpl_VisitList = '暂没有访客留下脚印！';
		if( $GLOBALS['userid'] > 0 AND $GLOBALS['isSpaceOwner'] !== true ){
			$_tpl_Vsisitstr = "留下您的访问印记 <a href=\"spacepostings.php?user={$GLOBALS['spaceName']}&action=visit&rootid={$_intRootID}\" title=\"踩一脚，在此处留下我的访问印记\"><img src=\"{$_tpl_VisitPic}\" border=\"0\"/></a>";
		} else{
			$_tpl_Vsisitstr = '访友脚印';
		}
	} else{
		foreach( $_arrVisitUser['userlist'] as $_val ){
			if( $_val['usex'] == 0 ){
				$_tpl_VisitPic = $spaceSetting[13];
			} else{
				$_tpl_VisitPic = $spaceSetting[12];
			}
			if( $_tpl_Vsisitstr === '' ){
				if( $_val['uid'] == $userid ){
					$_tpl_Vsisitstr = '访友脚印';
				} else{
					$_tpl_Vsisitstr = "留下您的访问印记<a href=\"spacepostings.php?user={$GLOBALS['spaceName']}&action=visit&rootid={$_intRootID}\" title=\"踩一脚，在此处留下我的访问印记\"><img src=\"{$_tpl_VisitPic}\" border=\"0\"/></a>";
				}
			}
			is_numeric($_val['utime']) AND ($_val['utime'] = gmdate('Y-m-d H:i:s', $_val['utime']+getUserTimeZoneOffset()));
			$_tpl_VisitList .= "<div class=\"visituser\">{$_val['uname']}<br/><img src=\"{$_tpl_VisitPic}\" border=\"0\" alt=\"来源IP：{$_val['uip']};访问时间：{$_val['utime']}\"/></div>";
		}
	}
	$_arrTopicInfo['hits']++;
	$_tpl_WeekName = gmdate('D', $_arrTopicInfo['posttime']+getUserTimeZoneOffset());
	switch ($_tpl_WeekName) {
		case 'Sun':
			$_tpl_WeekName = '星期天';
			break;
		case 'Mon':
			$_tpl_WeekName = '星期一';
			break;
		case 'Tue':
			$_tpl_WeekName = '星期二';
			break;
		case 'Wed':
			$_tpl_WeekName = '星期三';
			break;
		case 'Thu':
			$_tpl_WeekName = '星期四';
			break;
		case 'Fri':
			$_tpl_WeekName = '星期五';
			break;
		case 'Sat':
			$_tpl_WeekName = '星期六';
			break;
	}//end switch
	if( $_arrTopicInfo['weather'] > $_intWeather || $_arrTopicInfo['weather'] < 0 ){
		$_tpl_Weather_A = '晴天';
		$_tpl_Weather_B = 'sun.gif';
	} else{
		$_tpl_Weather_A = $_arrWeatherA[$_arrTopicInfo['weather']];
		$_tpl_Weather_B = $_arrWeatherB[$_arrTopicInfo['weather']];
	}
	if( $isSpaceOwner === true ){
		$_tpl_PostUserName = $GLOBALS['spaceUserName'];
	} else{
		$_tpl_PostUserName = $GLOBALS['membername'];
	}
	//print '<pre>'.print_r($spaceUserCat['result_set'], true).'</pre>';
	if (!empty($_arrTmp)) {
		$tmpstr1 = " >> <a href=\"{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.showchannel.{$_arrTopicInfo['stype']}.{$_arrTmp['ucatid']}.html\">{$_arrTmp['ucattitle']}</a>";
		$tmpstr2 = "<a href=\"{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.showchannel.{$_arrTopicInfo['stype']}.{$_arrTmp['ucatid']}.html\">{$_arrTmp['ucattitle']}</a> | ";
	}
	print <<<EOT
			<script language="javascript" src="space/script/dv_main.js" type="text/javascript"></script>
			<script language="javascript" src="space/script/dv_form.js" type="text/javascript"></script>
			<script type="text/javascript" src="space/edit_plus/fckeditor/fckeditor.js"></script>
			<script language="JavaScript" src="space/script/pagination.js"></script>
			<div class="TopicBlock_file"> 
				<h1>
					<em>
					<img alt="" src="{$skinpath}images/rss.gif" /> 订阅
					　<!--<img alt="" src="{$skinpath}images/cback.gif" />上一篇
					　<img alt="" src="{$skinpath}images/cnext.gif" />下一篇-->
					</em>
				<a href="{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.index.html" alt="返回{$GLOBALS['spaceUserName']}首页">{$GLOBALS['spaceUserName']}的主页</a> &gt;&gt; <a href="{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.showchannel.{$_arrTopicInfo['stype']}.html">{$lang['spaceStype'][$_arrTopicInfo['stype']]}</a>{$tmpstr1} &gt;&gt; 浏览信息《{$_arrTopicInfo['title']}》 
				</h1>
				<h2>
					<em>
						{$tmpstr2}评论({$_arrTopicInfo['child']}) | 阅读({$_arrTopicInfo['hits']})  
					</em>
					<img src="{$skinpath}images/plus.gif" border="0" onclick="ShowList(this,'VisitList','{$skinpath}images/plus.gif','{$skinpath}images/nofollow.gif');" class="ImgOnclick" alt="查看详细访友列表" /> {$_tpl_Vsisitstr}
					<div id="VisitList" style="display:none;">{$_tpl_VisitList}</div>
				</h2>
			</div>
EOT;
	$_arrPostInfo =& getSpacePostBy($_intRootID,$_intPage);
	if (empty($_arrPostInfo['ResultSet'])) {
		print <<<EOT
			<div class="TopicBlock_file_index">
				查找的信息不存在或没有进行该管理操作权限。
			</div>
EOT;
	} else {
		$_tplfontsize = $spaceSetting[9];
		$_tpl_lineheight = $spaceSetting[10];
		print '<base target="_blank" />';
		foreach ($_arrPostInfo['ResultSet'] AS $_val) {
			$_tpl_Content =& spaceUbbCode($_val['content']);
			if(strpos($_tpl_Content,'原帖地址')!==false){			
				$_tpl_Content=str_replace('uploadfile/space/forum','uploadfile/forum',$_tpl_Content);
			}
			if( $userid > 0 && ( $userid==$_val['userid'] || $isSpaceMaster === true ) ){
				$_tpl_Edit = "[<a href=\"spacepostings.php?user={$GLOBALS['spaceName']}&action=edit&rootid={$_intRootID}&postid={$_val['postid']}\" alt=\"编辑\">编辑</a>]";
			} else{
				$_tpl_Edit = '';
			}
			if( $isSpaceMaster === true && $_val['parentid'] == 0 ){
				$_tpl_Manage = "[<a href=\"spacepostings.php?user={$GLOBALS['spaceName']}&action=isbest&rootid={$_intRootID}&postid={$_val['postid']}\" alt=\"精华操作\">精华</a>]";
			} else{
				$_tpl_Manage = '';
			}
			if( $isSpaceMaster === true || $isSpaceOwner === true ){
				$_tpl_Delete = "[<a href=\"spacepostings.php?user={$GLOBALS['spaceName']}&action=delete&rootid={$_intRootID}&postid={$_val['postid']}\" alt=\"删除\">删除</a>]\r\n[<a href=\"spacepostings.php?php={$GLOBALS['spaceName']}&action=reply&rootid={$_intRootID}&postid={$_val['postid']}\" alt=\"回复\">回复</a>]";
			} else{
				$_tpl_Delete = '';
			}
			if( $_val['userid'] == 0 ){
				$_tpl_PostUserName = '访客：'.str_replace('<','&lt;',$_val['username']);
			} else{
				$_tpl_PostUserName = str_replace('<','&lt;',$_val['username']);
			}
			is_numeric($_val['jointime']) AND ($_val['jointime'] = gmdate('Y-m-d', $_val['jointime']+getUserTimeZoneOffset()));
			if( $_val['parentid'] == 0 ){
				$_tpl_ReTitle = Dv_FilterJS($_val['title']);
				print <<<EOT
			<div class="TopicBlock_file_index">
				<h1><em>{$_tpl_WeekName}  　<img alt="{$_tpl_Weather_A}" src="space/images/weather/{$_tpl_Weather_B}" /></em><img alt="主题" src="{$skinpath}images/icon_quote.gif" width="16" height="16" align="absmiddle" />{$_tpl_ReTitle}</h1>
				<h2>{$_tpl_Content}</h2>
				<div style="color:#666666; text-align:right;"> 
					<a href="dispuser.php?id={$_val['userid']}" target="_blank" alt="查看个人资料">{$_tpl_PostUserName}</a> 发表于：{$_val['jointime']}
			{$_tpl_Edit}{$_tpl_Manage}{$_tpl_Delete}			
				</div>
			</div>
EOT;
			} else{
				$_tpl_ReTitle = "<img src=\"{$skinpath}images/write.gif\" border=\"0\" alt=\"评论\">&nbsp;".Dv_FilterJS($_val['title']);
				print <<<EOT
			<a name="{$_val['postid']}"></a>
			<div class="TopicBlock">
				<h1><em>2006-5-12</em>{$_tpl_ReTitle}</h1>
				<h2>{$_tpl_Content}</h2>
				<div style="color:#666666; text-align:right;"> 
					<a href="dispuser.php?id={$_val['userid']}" target="_blank" alt="查看个人资料">{$_tpl_PostUserName}</a> 发表于：{$_val['jointime']}
			{$_tpl_Edit}{$_tpl_Manage}{$_tpl_Delete}			
				</div>
			</div>
EOT;
			}
		}//end foreach
		$_tpl_PageSearch = getScriptUrl().$GLOBALS['ModHtmlLinked'].urlencode($GLOBALS['spaceName'].'.showtopic.'.$_intRootID);
		print <<<EOT
		<base target="_self" />
		<div style="width: auto; height: 30px; padding:0px; margin: 0px auto;overflow: hidden; font-size:12px;">
		<script type="text/javascript">		PageList('{$_intPage}',3,'{$_arrPostInfo['PageSize']}','{$_arrPostInfo['RecordCount']}',"{$_tpl_PageSearch}",5);
		</script></div>
EOT;
	}
	if ($spaceSystemSetting[2] != 1 AND $GLOBALS['userid'] <= 0) {
		//Nothing to do
	} else {	//	快速回复
		if( $spaceSetting[8] == 0 ){
			$_tpl_isalipay = '';
		} else{
			$_tpl_isalipay = "&nbsp;<a href=\"javascript:Dvbbs_foralipay('postcontent');\"><img src=\"space/images/alipay/icon_alipay.gif\" border=\"0\" alt=\"生成一个支付宝交易，支付宝买卖交易，免费、安全、快速！\"></a>";
		}
		print <<<EOT
			<script language="JavaScript">
			<!--
			window.onload = function()
			{
				var oFCKeditor = new FCKeditor( 'postcontent','96% !important;width:80%','200px','Basic' ) ;
				oFCKeditor.BasePath	= "space/edit_plus/fckeditor/" ;
				oFCKeditor.Config['SkinPath'] = "skins/office2003/"
				oFCKeditor.ReplaceTextarea() ;
			}
			//-->
			</script>
			<form method="post" action="spacepostings.php?user={$GLOBALS['_tpl_spaceName']}&action=save_reply" style="display:inline;">
				<table border="0" cellspacing="0" cellpadding="0" class="TopicBlock_write">
					<tr><td colspan="2" class="TopicBlock_write_td">快速回复</td></tr>
					<tr>
						<td class="TopicBlock_write_left">用户名：</td>
						<td class="TopicBlock_write_right"><input type="text" name="postusername" size="25" value="{$GLOBALS['membername']}" />
						</td>
					</tr>
EOT;
	if (1 == $spaceSystemSetting[5]){
		$getcodehtml=get_cercode(100,24,0,3);
		print <<<EOT
					<tr>
						<td class="TopicBlock_write_left">验证码：</td>
						<td class="TopicBlock_write_right">$getcodehtml
						</td>
					</tr>
EOT;
}
print <<<EOT
					<tr>
						<td class="TopicBlock_write_left">标题：</td>
						<td class="TopicBlock_write_right"><input type="text" size="40" name="title" onkeyup="javascript:Dv_Form.CheckLength(this,250);" />{$_tpl_isalipay}
						</td>
					</tr>
					<tr>
						<td class="TopicBlock_write_left">内容：</td>
						<td class="TopicBlock_write_right">
						<textarea cols="50" rows="8" name="postcontent" id="postcontent" style="height:160px;"></textarea>
						</td>
					</tr>
					<tr>
						<td class="TopicBlock_write_left">&nbsp;</td>
						<td class="TopicBlock_write_right">
						<input type="hidden" name="rootid" value="{$_intRootID}" />
						<input type="hidden" name="postid" value="0" />
						<button name="loginsubmit" type="submit" value="true" style="width:80px">提交信息</button>
						<button name="loginsubmit" type="reset" value="true" style="width:60px">重 置</button>
						</td>
					</tr>
				</table><br />
			</form>
EOT;
	}
}

function showChannel()	//	频道主题列表显示
{
	global $spaceSystemUpSetting,$lang,$spaceUserID,$spaceUserCat,$spaceSystemSetting,$objEnc,$isSpaceMaster,$isSpaceOwner,$spaceUserInfo;
	global $skinpath,$lang,$_tpl_skinPath,$_tpl_spaceName,$_tpl_spaceUrl,$arrArchiveLink,$userid,$spaceUserName,$spaceUserID;
	$_tpl_spaceUrl = $GLOBALS['ModHtmlLinked'];
	$_tpl_spaceName = $GLOBALS['spaceName'];
	$_intCount = count($arrArchiveLink);
	/*
	print '<!--'.print_r($arrArchiveLink, true).'-->';
	$_cat_tID = '';
	if( $_intCount > 2 ){
		$_arrTmp = explode('-',$arrArchiveLink[2]);
		if (2 == count($_arrTmp)) {
			$_strTmp = str_replace('.html','',$_arrTmp[1]);
			$_intPage = is_numeric($_strTmp) ? $_strTmp : '0' ;
			$_cat_tID = $_arrTmp[0];
		} else {
			$_intPage = '1';
			$_strTmp = str_replace('.html','',$_arrTmp[0]);
			$_cat_tID = is_numeric($_strTmp) ? $_strTmp : '0' ;
		}
	}
	$_catID = '';
	if( $_intCount > 3 ){
		$_arrTmp = explode('-',$arrArchiveLink[3]);
		if( count($_arrTmp) == 2 ){
			$_strTmp = str_replace('.html','',$_arrTmp[1]);
			$_intPage = is_numeric($_strTmp) ? $_strTmp : '0' ;
			$_catID = $_arrTmp[0];
		} else{
			$_intPage = '1';
			$_strTmp = str_replace('.html','',$_arrTmp[0]);
			$_catID = is_numeric($_strTmp) ? $_strTmp : '0' ;
		}
	}
	//*/

	$_intPage = 1;
	$_cat_tID = 0;
	$_catID = 0;
	if (4 == $_intCount) {
		if (is_numeric($arrArchiveLink[2])) {
			$_cat_tID = $arrArchiveLink[2];
		} elseif (false !== strpos($arrArchiveLink[2], '-')) {
			list($_cat_tID, $_intPage) = explode('-', $arrArchiveLink[2]);
		}
	} elseif (5 == $_intCount) {
		if (is_numeric($arrArchiveLink[2])) {
			$_cat_tID = $arrArchiveLink[2];
		}
		if (is_numeric($arrArchiveLink[3])) {
			$_catID = $arrArchiveLink[3];
		} elseif (false !== strpos($arrArchiveLink[3], '-')) {
			list($_catID, $_intPage) = explode('-', $arrArchiveLink[3]);
		}
	}
	if( !is_numeric($_cat_tID) ){
		return false;
	} else{
		//for other
	}

	$_tpl_Channel_Intro = '';
	$_tpl_catname2 = $_tpl_catname = '';
	if (!empty($spaceUserCat['result_set']) AND is_array($spaceUserCat['result_set']) ){
		$_tpl_Channel_Intro = $spaceUserCat['result_set'][0]['ucatnote'];
		foreach( $spaceUserCat['result_set'] as $_val ){
			if ($_val['utype'] == $_cat_tID AND $_val['ucatid'] == $_catID) {
				$_tpl_Channel_Intro = $_val['ucatnote'];
			}
			if ($_val['ucatid'] == $_catID) {
				$_tpl_catname2 = " - {$_val['ucattitle']} - ";
				$_tpl_catname = " &gt;&gt; <a href=\"{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.showchannel.{$_cat_tID}.{$_catID}.html\">{$_val['ucattitle']}</a>";
			}
		}
	}
	$_arrWeatherA = explode('|',$spaceSystemSetting[13]);
	$_arrWeatherB = explode('|',$spaceSystemSetting[14]);
	$_intWeather = count($_arrWeatherA) - 1;
	print <<<EOT
			<script language="javascript" src="space/script/dv_main.js" type="text/javascript"></script>
			<script language="javascript" src="space/script/dv_form.js" type="text/javascript"></script>
			<script type="text/javascript" src="space/edit_plus/fckeditor/fckeditor.js"></script>
			<script language="JavaScript" src="space/script/pagination.js"></script>
			<div class="TopicBlock_file"> 
				<h1>
					<a href="{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.index.html" alt="返回{$spaceUserName}首页">{$spaceUserName}的主页</a> &gt;&gt; <a href="{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.showchannel.{$_cat_tID}.html">{$lang['spaceStype'][$_cat_tID]}</a>{$_tpl_catname} &gt;&gt; 信息列表
				</h1>
EOT;
	$GLOBALS['DV_HTML_TITLE'] = "{$lang['spaceStype'][$_cat_tID]}{$_tpl_catname2}信息列表-{$spaceUserInfo['nickname']}的空间";
	if ($_catID > 0) {
		print <<<EOT
				<div style="margin: 0px auto 10px 0px; padding: 5px; width: auto; text-align: left; border: 1px dashed #b6cadf;">{$_tpl_Channel_Intro}</div>
EOT;
	}
	print <<<EOT
			</div>
EOT;
	if (4 == $_cat_tID) {	//	相册模式
		$_arrDBInfo =& getSpaceUpFile($_intPage,$_cat_tID,$_catID);
		if (empty($_arrDBInfo['ResultSet'])) {
			spaceshowmsg('查找的信息不存在或没有进行该管理操作权限。', 0, '', false);
			return false;
		}
		if( !is_numeric($spaceSystemSetting[9]) ){
			$spaceSystemSetting[9] = 3;
		}
		$_tpl_width = $spaceSystemSetting[14];
		$_tpl_height = $spaceSystemSetting[15];
		//$_intTmp = $spaceSystemSetting[9];
		$_intTmp = 3;
		global $spaceuploadbasedir;
		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';
			}
			$_tpl_PostDate = gmdate('Y-m-d H:i:s', $_val['dateandtime']+getUserTimeZoneOffset());
			if( $_index % $_intTmp == 0 ){
				if( $_index == 0 ){
					$_str_TR = '<div class="mytag_photo">';
				} else{
					$_str_TR = "</div>\r\n\t\t<div class=\"mytag_photo\">";
				}
			} else{
				$_str_TR = '';
			}
			$currsize = $_val['filesize'];
			$units = 'B';
			if ($currsize > 1024) {
				$currsize = $currsize / 1024;
				$units = 'KB';
			}
			if ($currsize > 1024) {
				$currsize = $currsize / 1024;
				$units = 'MB';
			}
			$currsize = number_format($currsize, 2);
			print <<<EOT
			{$_str_TR}
					<h1><div style="border:1px solid #fff;background:#fff;margin:auto;width:120px;height:120px;text-align:center;vertial-align:top;overflow:auto;"><a href="{$_tpl_spaceUrl}{$GLOBALS['spaceName']}.showtopic.{$_val['topicid']}.html"><img onload="javascript:if(this.width>120)this.style.width=120;if(this.height>120)this.style.height=120;" src="{$spaceuploadbasedir}{$_tpl_ViewPhoto}" alt="" style="vertical-align: middle; "/></a></div><div class="name"><a href="{$_tpl_spaceUrl}{$GLOBALS['spaceName']}.showtopic.{$_val['topicid']}.html">{$_tpl_topic}</a></div><div>时间：{$_tpl_PostDate}</div><div>大小：{$currsize}{$units}</div></h1>			
EOT;
		}
		print '</div>';
	} elseif (2 == $_cat_tID) {	//	链接模式
		$_arrDBInfo =& getSpaceTopic_link($_intPage,$_cat_tID,$_catID);
		if (empty($_arrDBInfo['ResultSet'])) {
			spaceshowmsg('查找的信息不存在或没有进行该管理操作权限。', 0, '', false);
			return false;
		}
		foreach( $_arrDBInfo['ResultSet'] AS $_val ){
			$_strLinkImg = $_val['titlenote'].'';
			if( $_strLinkImg !== '' ){
				$_tpl_LinkeLogo = "<div class=\"topic_r\">\r\n<a href=\"{$_tpl_spaceUrl}{$GLOBALS['spaceName']}.showtopic.{$_val['topicid']}.html\" target=\"_blank\"><img src=\"{$_strLinkImg}\" border=\"0\" alt=\"评论/回复：\"/></a>\r\n</div>";
			} else{
				$_tpl_LinkeLogo = '';
			}
			if( $userid > 0 && ( $userid == $_val['userid'] || $isSpaceMaster === true ) ){
				$_tpl_Edit = "[<a href=\"spacepostings.php?user={$GLOBALS['spaceName']}&action=edit&rootid={$_val['topicid']}&postid={$_val['postid']}\" alt=\"编辑\">编辑</a>]";
			} else{
				$_tpl_Edit = '';
			}
			if( $isSpaceOwner === true || $isSpaceMaster === true ){
				$_tpl_Manage = "[<a href=\"spacepostings.php?user={$GLOBALS['spaceName']}&action=isbest&rootid={$_val['topicid']}&postid={$_val['postid']}\" alt=\"精华操作\">精华</a>]";
				$_tpl_Delete = "[<a href=\"spacepostings.php?user={$GLOBALS['spaceName']}&action=delete&rootid={$_val['topicid']}&postid={$_val['postid']}\" alt=\"删除\">删除</a>]";
			} else{
				$_tpl_Manage = '';
				$_tpl_Delete = '';
			}
			$_tpl_topic = Dv_FilterJS($_val['title']);
			$_tpl_PostDate = gmdate('Y-m-d H:i:s', $_val['posttime']+getUserTimeZoneOffset());
			print <<<EOT
				<div class="TopicBlock">
					<h1><a href="{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.showtopic.{$_val['topicid']}.html" target="_blank"><img alt="" src="{$skinpath}images/icon_quote.gif" width="16" height="16" /></a>&nbsp;<a href="{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.showtopic.{$_val['topicid']}.html" target="_blank">{$_tpl_topic}</a></h1>
					<h2>点击：{$_val['hits']}</h2>
					<div>
						<center>
							<a href="dispuser.php?id={$_val['userid']}" target="_blank" alt="查看个人资料">{$_val['username']}</a> 添加于：{$_tpl_PostDate}{$_tpl_Edit}{$_tpl_Manage}{$_tpl_Delete}
						</center>
					</div>
				</div>
EOT;
		}
	} else {	//	其它模式
		$_arrDBInfo =& getSpaceTopic_Other($_intPage,$_cat_tID,$_catID);
		if (empty($_arrDBInfo['ResultSet'])) {
			spaceshowmsg('查找的信息不存在或没有进行该管理操作权限。', 0, '', false);
			return false;
		}
		foreach( $_arrDBInfo['ResultSet'] AS $_val ){
			$_tpl_topic = $_val['title'].'';
			if( $objEnc->StrLength($_tpl_topic) > 150 ){
				$_tpl_topic = $objEnc->SubString($_tpl_topic,0,150).'...';
			}
			//$_tpl_Content = spaceUbbCode($_val['titlenote']).'';
			$_tpl_Content = trim($_val['titlenote']).'';
			if ('' === $_tpl_Content) {
				$_tpl_Content = $_val[''];
			}
			$_tpl_PChannel = _getChannel($_val['catid']);
			if ('' === $_tpl_PChannel) {
				$_tpl_PChannel = gmdate('Y-m-d H:i:s', $_val['posttime']+getUserTimeZoneOffset());
			}
			if ($_tpl_PChannel !== '') {
				$_tpl_PChannel = " <a href=\"{$_tpl_spaceUrl}{$GLOBALS['spaceName']}.showchannel.{$_val['stype']}.{$_val['catid']}.html\">{$_tpl_PChannel}</a>";
			}
			$_tpl_PostDate = gmdate('Y年m月d日 H:i', $_val['posttime']+getUserTimeZoneOffset());
			if( $_val['weather'] > $_intWeather || $_val['weather'] < 0 ){
				$_tpl_Weather_A = '晴天';
				$_tpl_Weather_B = 'sun.gif';
			} else{
				$_tpl_Weather_A = $_arrWeatherA[$_val['weather']];
				$_tpl_Weather_B = $_arrWeatherB[$_val['weather']];
			}
			print <<<EOT
				<div class="TopicBlock">
					<h1><em>{$_tpl_PostDate}   　<img alt="{$_tpl_Weather_A}" src="space/images/weather/{$_tpl_Weather_B}"  /></em><a href="{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.showtopic.{$_val['topicid']}.html" target="_blank"><img alt="" src="{$skinpath}images/icon_quote.gif" width="16" height="16" /></a>&nbsp;<a href="{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.showtopic.{$_val['topicid']}.html">{$_tpl_topic}</a></h1>
					<h2>{$_tpl_Content}</h2>
					<div><img alt="" src="images/more.gif" width="9" height="10" /><a title="#" href="{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.showtopic.{$_val['topicid']}.html">阅读全文...</a><br />
					<center>
					<a href="dispuser.php?id={$_val['userid']}" target="_blank" alt="查看个人资料">{$_val['username']}</a> 发表于{$_tpl_PChannel} | <a href="{$GLOBALS['ModHtmlLinked']}{$GLOBALS['spaceName']}.showtopic.{$_val['topicid']}.html">评论({$_val['child']})</a> | 引用(0) </center></div>
				</div>
EOT;
		}
	}
	if (false !== $_arrDBInfo['ResultSet']) {
		if( $_catID > 0 ){
			$_tpl_PageSearch = $GLOBALS['ModHtmlLinked'].urlencode("{$GLOBALS['spaceName']}.showchannel.{$_cat_tID}.{$_catID}");
		} else{
			$_tpl_PageSearch = $GLOBALS['ModHtmlLinked'].urlencode("{$GLOBALS['spaceName']}.showchannel.{$_cat_tID}");
		}
		print <<<EOT
				<div style="width: auto; height: 30px; padding:0px; margin: 0px auto;overflow: hidden; font-size:12px;">
		<script type="text/javascript">
		PageList({$_arrDBInfo['AbsolutePage']},3,{$_arrDBInfo['PageSize']},{$_arrDBInfo['RecordCount']},"{$_tpl_PageSearch}",5);
		</script></div>
EOT;
	}
}
function _getChannel($channelid)
{
	global $spaceUserCat;
	static $cache = array();
	static $blncache1 = null;
	if (null === $blncache1) {
		$blncache1 = (!empty($spaceUserCat['result_set']) AND is_array($spaceUserCat['result_set']));
		$blncache2 = (!empty($spaceUserCat['result_set']) AND is_array($spaceUserCat['result_set']));
	}
	if (!$blncache1 AND !$blncache2) {
		return '';
	}
	if (empty($cache["{$channelid}"])) {
		foreach ($spaceUserCat['result_set'] AS $val) {
			if ($val['ucatid'] == $channelid) {
				$cache["{$channelid}"] = trim($val['ucattitle']);
				break;
			}
		}//end foreach
	}
	if (!isset($cache["{$channelid}"]) OR '' === $cache["{$channelid}"]) {
	}
	return trim($cache["{$channelid}"]);
}//end function 
?>