<?
include($_SERVER['DOCUMENT_ROOT']."/forum/SSI.php"); 
include($_SERVER['DOCUMENT_ROOT']."/inc/includes.php");
header("Content-type: text/xml; charset=utf-8");

$text = "";
/*$text .= '<?xml version="1.0" encoding="utf-8"?>';*/
$text .= '<rss version="2.0" xmlns:content="http://hoper.su/news/archive/">';
$text .= '<channel>';
$text .= '<title>hoper.su</title>';
$text .= '<link>http://hoper.su/</link>';
$text .= '<description>Регион Хопёр. Новости Прихопёрья</description>';
$text .= '<language>ru</language>';
$text .= '<managingEditor>hoper.su@gmail.com</managingEditor>';
$text .= '<generator>ХОПЁРЪ</generator>';

echo $text;

$result = mysql_query ("SELECT
									a.id_msg,
									a.poster_time,
									a.subject,
									LEFT(a.body, 300),
									a.id_topic,
									b.id_board,
									bb.name
								FROM hop_smf_messages as a
									left join hop_smf_topics as b
									on a.id_msg = b.id_first_msg 
										inner join hop_smf_boards as bb
										on b.id_board = bb.id_board
								where ((b.id_board = 1) or (b.id_board = 2) or (b.id_board = 3) 
										or (b.id_board = 4) or (b.id_board = 5))
								order by a.id_topic desc
								limit 10;
										");
//where b.id_board = $board
	//$num_rows = mysql_num_rows($result);
	$i = 0;										
	while(list($id, $poster_time, $subject, $body, $topic, $board, $board_name) = mysql_fetch_row ($result))
	{		
		$i++;
		
		$dat_path = get_path_by_date($poster_time);
		$p = get_part_by_id($board).'/'.$dat_path.'/';
		
		if ($board == 4)
			$subject = $subject.'. Фоторепортаж';
		else
			$subject = $subject;	
		
	echo '
	<item>
	<title>'.$subject.'</title>
	<guid isPermaLink="true">http://hoper.su/'.$p.$topic.'.html</guid>
	<link>http://hoper.su/'.$p.$topic.'.html</link>
	<description>
		<![CDATA[
		'.$body.'...		 
		]]>
	</description>
	<pubDate>'.$poster_time.'</pubDate>
	</item>';
	}


echo '</channel>';
echo '</rss>';


/*
$mstr = '1234._5678910.';

echo $mstr;
echo '<br><br>';

$mlen = strlen($mstr);

echo $mlen;
echo '<br><br>';


$pos = strpos($mstr, '._');
echo $pos;
echo '<br><br>';

$res1 = substr($mstr, 0,$pos+1);
echo $res1;
echo '<br><br>';

$pos2 = $mlen - $pos - 2;
echo $pos2;
echo '<br><br>';


$res2 = substr($mstr, -$pos2);
echo $res2;
echo '<br><br>';
*/

?>