<?php
$g5_path = $g4_path = '..'; // common.php 의 상대 경로
include_once($g5_path.'/common.php');
include_once(AMINA_PATH.'/lib/view.lib.php');
include_once(AMINA_PATH.'/lib/tag.lib.php');

//뽑아올 글 수
$rss_rows = 10;

$yoil = array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");

Header("Content-type: text/xml; charset=utf-8"); 
header("Cache-Control: no-cache, must-revalidate"); 
header("Pragma: no-cache");   

echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";

?>
<rss version="2.0">
<channel>
<title><?php echo specialchars_replace($config['cf_title']); ?></title>
<link><?php echo specialchars_replace(G5_URL); ?></link>
<description><?php echo specialchars_replace($config['cf_title']); ?></description>
<language>ko</language>
<pubDate><?php echo $yoil[date('w', G5_SERVER_TIME)]; ?>, <?php echo date('d M Y H:i:s', G5_SERVER_TIME); ?> +0900</pubDate>
<generator>AMINA SKIN for GNUBOARD</generator>
<?php
//RSS 추출
$topic = $topic ? "and bo_table = '$topic'" : "";
$result = sql_query(" select * from {$g5['board_new_table']} where wr_rss != '' $topic order by bn_id desc limit $rss_rows ");
for ($i=0; $row=sql_fetch_array($result); $i++) {

	//링크설정
	$link = G5_BBS_URL.'/board.php?bo_table='.$row['bo_table'].'&wr_id='.$row['wr_id']; //짧은 주소

    $board = sql_fetch(" select * from {$g5['board_table']} where bo_table = '{$row['bo_table']}' ");
	$row1 = sql_fetch(" select * from {$g5['write_prefix']}{$row[bo_table]} where wr_id = '$row[wr_id]' "); //글 정보 불러오기..

	$row1['file'] = get_file($row['bo_table'], $row['wr_id']);
	$row1['tag'] = amina_get_tag($row['bo_table'], $row['wr_id']);

	list($wr_img) = amina_thumb_img($row1['file'], $row1['wr_6'], $row1['wr_content'], 1, $row1['wr_4'], $row1['wr_8'], '');
	if($wr_img) {
		$wr_img = str_replace("../data", G5_DATA_URL, $wr_img);
		$wr_img = '<p><img src="'.$wr_img.'" border=0></p>';
	}

	$wr_icon = amina_array_icon($row1['wr_5']);
	$wr_content = ($wr_icon['po_view_point'] > 0 && $row1['wr_3']) ? amina_text($row1['wr_3']) : amina_cut($row1['wr_content'], 250);
?>
	<item>
	<title><?php echo specialchars_replace($row1['wr_subject']); ?></title>
	<link><?php echo specialchars_replace($link); ?></link>
	<description><?php echo specialchars_replace($wr_img.$wr_content); ?></description>
	<?php if($row1['tag']) { ?>
		<tag><![CDATA[<?php echo specialchars_replace($row1['tag']); ?>]]></tag>
	<?php } ?>
	<category><?php echo specialchars_replace($row1['ca_name']); ?></category>
	<author><?php echo specialchars_replace($row1['wr_name']); ?></author>
	<guid><?php echo specialchars_replace($link); ?></guid>
	<pubDate><?php echo $yoil[date('w', strtotime($row['bn_datetime']))]; ?>, <?php echo date('d M Y H:i:s', strtotime($row['bn_datetime'])); ?> +0900</pubDate>
	<comment><?php echo specialchars_replace($row1['wr_comment']); ?></comment>
	<hit><?php echo specialchars_replace($row1['wr_hit']); ?></hit>
	<good><?php echo specialchars_replace($row1['wr_good']); ?></good>
	</item>
<?php } ?>
</channel>
</rss>
