<?
require_once('../connect/connect.php');
require_once('../blok/rss_class.php');
require_once('../cashe_region/_svod_region_0.php');
require_once('../cashe_catalog/_svod_catalog.php');


$dir = 'http://zaraysk.su/';
$can="../rss/index.xml";
	if(!file_exists($can))
		{
		$zag_can="Доска объявлений";
		$opis_can="Объявления";
			
		$channel = new RSSChannel(); 
		$channel->create($zag_can, $can, $opis_can);
		$channel->save($can);
		}

$channel = new RSSChannel(); 
$channel->load($can);

$aw=mysql_query("SELECT COUNT(id) as cou FROM board");
$aaw=mysql_fetch_array($aw);
$count_id=$aaw[0];
if($count_id > 20)
$qr="SELECT * FROM board ORDER BY data LIMIT ".($count_id-20).", 20";
else
$qr="SELECT * FROM board ORDER BY data LIMIT 20";

$r=mysql_query($qr);
while($rr=mysql_fetch_array($r))
	{
	if($rr['small']) 
	$opis_rss='<img border=0 style="margin: 3px 10px 0px 0px;" src="'.$dir.$rr['small'].'" align=left> ';
	else
	$opis_rss='';
	$opis_rss .= $arr_regions[0][$rr['region_0']];
	if($arr_regions[0][$rr['region_0']] != $rr['gorod'])
	$opis_rss .= ', '.$rr['gorod'];
	$opis_rss .= '<br>'.$rr['razdel'];
	$channel->addItem(
	$rr['zag'], 
	$dir.'items/'.$rr['zag_url'].'_'.$rr['id'], 
	$opis_rss, 
	$rr['contakt'], 
	'', 
	'', 
	$rr['data'],
	$rr['id']);
	}

$channel->save($can);

?> 