<?php
require('ppframe.php');

$__seo -> ParseValueWithoutKey();

$un = $un ? $un : $__seo -> GetParams();

//echo $un;exit;

$tmpploguser = new PpLog_User();
$tmpploguser -> ReSet();
$tmpploguser -> LoadFromDBuseUniqID($un);
$uid = $tmpploguser -> U_ID;
$un = $tmpploguser->U[$tmpploguser->U_UniqueID];

if($tmpploguser->U[$tmpploguser->PriKey]<1 || $tmpploguser->U['pplogopen'] != 1) {
	header('HTTP/1.1 404 Not Found');
	exit;
}

$blogerinfo = $tmpploguser -> U;

$dir =  WORK_DIR.'temp/rss_cache_dir/';
if (!file_exists($dir)) {
	@mkdir($dir);
}
$cachefile = $dir.$un.'.php';
!isset($base_config['rss_ttl']) && $base_config['rss_ttl'] = 60;
if (file_exists($cachefile) && $timestamp - filemtime($cachefile) < $base_config['rss_ttl'] * 60) {
//if (false) {
	require($cachefile);
}else {
	Iimport('Lister_Pplog_Article');
	$lister_rss = new Lister_Pplog_Article();
	$lister_rss -> SetWhere("`author`='$uid'");
	$lister_rss -> SetBox(0);
	$lister_rss -> SetConfig(array('limit' => '0,60'));
	
	$lister_rss = $lister_rss -> GetLister('rss_prepare');
	
	$link = $__seo -> BaseUrlChange($base_config['pplog_root'].'u.php?'.$un);
	$lastbuilddate = GetMyDate('D, d M Y H:i:s',$timestamp) . ' GMT' . ($rtc['timezone'] > 0 ? '+' : '') . $rtc['timezone'];
	
	$str = "<?php\r\n";
	$str .= "\$link='$link';\r\n";
	$str .= "\$lastbuilddate='$lastbuilddate';\r\n";
	$str .= "\$lister_rss = " . var_export($lister_rss,true) .";\r\n";
	$str .= "?>";
	
	@touch($cachefile);
	$handle = @fopen($cachefile,'wb');
	@fwrite($handle,$str);
	@fclose($handle);
}


function rss_prepare(&$row) {
	$row['link'] = $GLOBALS['__seo'] -> BaseUrlChange($GLOBALS['base_config']['pplog_root'].'blog.php?'.$row['id']);
	$row['pubdate'] = GetMyDate('D, d M Y H:i:s',$row['posttime']) . ' GMT' . ($GLOBALS['rtc']['timezone'] > 0 ? '+' : '') . $GLOBALS['rtc']['timezone'];
	return $row;
}

$host = $_SERVER['HTTP_HOST'];

$sch = $_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http';

$host = $sch . '://' . $host ;

header('Content-type: application/xml');

Iimport('Template');
$tpl = new Template();
$tpl -> DisPlay('rss');

SeoOver();
?>