<?php
define('THIS_SCRIPT', 'spacerss');
require_once 'space_global.php';
$lang = load_lang($lang, 'space.error' );
if( $spaceUserID == 0 ){
	spaceHeader(array('stats'=>$lang['HeaderTitle1_1'],'isSystem'=>false,'topEnable'=>false,'navEnable'=>false));
	spaceshowmsg($lang['spaceError.str43']);
}
$_strScriptNameUrl = getScriptUrl();
if( $urlRewriteEnable === false ){
	$ModHtmlLinked = "{$_strScriptNameUrl}space.php?{$spaceName}.html";
	$_strTopicLink = "{$_strScriptNameUrl}space.php?{$spaceName}/showtopic/";
} else{
	$ModHtmlLinked = "{$_strScriptNameUrl}{$spaceName}.html";
	$_strTopicLink = "{$_strScriptNameUrl}{$spaceName}/showtopic/";
}
if( empty($charset) ){
	$charset = 'gbk';
}
header("Content-Type:text/xml;charset={$charset}");
print '<'.'?xml version="1.0" encoding="'.$charset.'" ?'.">\r\n";
print <<<EOT
	<rss version="2.0">
		<channel>
			<title><![CDATA[{$spaceUserInfo['spacetitle']}]]></title>
			<link>{$ModHtmlLinked}</link>
			<description><![CDATA[{$spaceUserInfo['spacechildtitle']}]]></description>
EOT;
if( empty($spaceUserCat['result_set']) || !is_array($spaceUserCat['result_set']) ){
	print "\r\n\t\t\t<ErrorMsg>".strip_tags($lang['spaceError.str43'])."</ErrorMsg>";
} else{
	require_once INC_PATH.'DV_Encoding.class.php';
	$_objEnc =& DV_Encoding::GetEncoding($charset);	
	foreach( $spaceUserCat['result_set'] as $_val ){
		$_strPostDate = gmdate('Y-m-d H:i:s', $_val['posttime'] + getUserTimeZoneOffset());
		if( !isDate($_strPostDate) ){
			$_strPostDate = gmdate('Y-m-d H:i:s', TIME_NOW + getUserTimeZoneOffset());
		}
		$_strTitle = $_val['title'].'';
		if( $_objEnc->StrLength($_strTitle) > 150 ){
			$_strTitle = $_objEnc->SubString($_strTitle,0,150).'...';
		}
		$_strTitle = htmlspecialchars($_strTitle);
		$_strContent = strtolower($_val['titlenote']);
		$_strContent = htmlspecialchars(
						str_replace(
							array(
								 '<img src="skins/'
								,'<img src="images/'
								,'<img src="space/'
								,'<a href="space/'
								,'<a href="space.php'
								,'<a href="'.$spaceName
							)
							,array(
								 "<img src=\"{$_strScriptNameUrl}skins/"
								,"<img src=\"{$_strScriptNameUrl}images/"
								,"<img src=\"{$_strScriptNameUrl}space/"
								,"<a href=\"space/"
								,"<a href=\"{$_strScriptNameUrl}space.php"
								,"<a href=\"{$_strScriptNameUrl}{$spaceName}"
							)
							,$_strContent
						)
					   );
		print <<<EOT
			<item>
				<title><![CDATA[{$_strTitle}]]></title>
				<link>{$_strTopicLink}{$_val['topicid']}.html</link>
				<description><![CDATA[{$_strContent}]]></description>
				<author>{$_val['username']}</author>
				<pubDate>{$_strPostDate}</pubDate>
			</item>
EOT;
	}
}
print <<<EOT
		</channel>
	</rss>
EOT;
?>