'.generate_key(50).'';
if ( !empty($feed_id) )
{
$query = '
SELECT user_id,
last_check
FROM '.USER_FEED_TABLE.'
WHERE id = \''.$feed_id.'\'
;';
$feed_row = mysql_fetch_assoc(pwg_query($query));
if ( empty($feed_row) )
{
page_not_found('Unknown/missing feed identifier');
}
if ($feed_row['user_id']!=$user['id'])
{ // new user
$user = build_user( $feed_row['user_id'], true );
}
}
else
{
$image_only = true;
if (!is_a_guest())
{// auto session was created - so switch to guest
$user = build_user( $conf['guest_id'], true );
}
}
// Check the status now after the user has been loaded
check_status(ACCESS_GUEST);
list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
include_once(PHPWG_ROOT_PATH.'include/feedcreator.class.php');
set_make_full_url();
$rss = new UniversalFeedCreator();
$rss->encoding=get_pwg_charset();
$rss->title = $conf['gallery_title'];
$rss->title.= ' (as '.$user['username'].')';
$rss->link = $conf['gallery_url'];
// +-----------------------------------------------------------------------+
// | Feed creation |
// +-----------------------------------------------------------------------+
$news = array();
if (!$image_only)
{
$news = news($feed_row['last_check'], $dbnow, true, true);
if (count($news) > 0)
{
$item = new FeedItem();
$item->title = sprintf(l10n('New on %s'),
format_date($dbnow, 'mysql_datetime') );
$item->link = $conf['gallery_url'];
// content creation
$item->description = '
';
foreach ($news as $line)
{
$item->description.= '- '.$line.'
';
}
$item->description.= '
';
$item->descriptionHtmlSyndicated = true;
$item->date = mysqldt_to_ts($dbnow);
$item->author = 'PhpWebGallery notifier';
$item->guid= sprintf('%s', $dbnow);;
$rss->addItem($item);
$query = '
UPDATE '.USER_FEED_TABLE.'
SET last_check = \''.$dbnow.'\'
WHERE id = \''.$feed_id.'\'
;';
pwg_query($query);
}
}
if ( !empty($feed_id) and empty($news) )
{// update the last check from time to time to avoid deletion by maintenance tasks
if ( !isset($feed_row['last_check'])
or time()-mysqldt_to_ts($feed_row['last_check']) > 30*24*3600 )
{
$query = '
UPDATE '.USER_FEED_TABLE.'
SET last_check = DATE_ADD(\''.$dbnow.'\', INTERVAL -15 DAY )
WHERE id = \''.$feed_id.'\'
;';
pwg_query($query);
}
}
$dates = get_recent_post_dates_array($conf['recent_post_dates']['RSS']);
foreach($dates as $date_detail)
{ // for each recent post date we create a feed item
$item = new FeedItem();
$date = $date_detail['date_available'];
$item->title = get_title_recent_post_date($date_detail);
$item->link = make_index_url(
array(
'chronology_field' => 'posted',
'chronology_style'=> 'monthly',
'chronology_view' => 'calendar',
'chronology_date' => explode('-', substr($date,0,10) )
)
);
$item->description .=
''.$conf['gallery_title'].'
';
$item->description .= get_html_description_recent_post_date($date_detail);
$item->descriptionHtmlSyndicated = true;
$item->date = mysqldt_to_ts($date);
$item->author = 'PhpWebGallery notifier';
$item->guid= sprintf('%s', 'pics-'.$date);;
$rss->addItem($item);
}
$fileName= $conf['local_data_dir'].'/tmp';
@mkdir($fileName); // just in case
$fileName.='/feed.xml';
// send XML feed
echo $rss->saveFeed('RSS2.0', $fileName, true);
?>