'.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 = array();
$user = build_user( $feed_row['user_id'], true );
}
}
else
{
$image_only = true;
if (!$user['is_the_guest'])
{// auto session was created - so switch to guest
$user = array();
$user = build_user( $conf['guest_id'], true );
}
}
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->title = $conf['gallery_title'];
$rss->title.= ' (as '.$user['username'].')';
$rss->link = $conf['gallery_url'];
// +-----------------------------------------------------------------------+
// | Feed creation |
// +-----------------------------------------------------------------------+
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 = ts_to_iso8601(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);
}
}
else
{
if ( !empty($feed_id) )
{// update the last check to avoid deletion by maintenance task
$query = '
UPDATE '.USER_FEED_TABLE.'
SET last_check = \''.$dbnow.'\'
WHERE id = \''.$feed_id.'\'
;';
pwg_query($query);
}
}
$dates = get_recent_post_dates( 5, 6, 6);
foreach($dates as $date_detail)
{ // for each recent post date we create a feed item
$date = $date_detail['date_available'];
$exploded_date = explode_mysqldt($date);
$item = new FeedItem();
$item->title = l10n_dec('%d new element', '%d new elements', $date_detail['nb_elements']);
$item->title .= ' ('.$lang['month'][(int)$exploded_date['month']].' '.$exploded_date['day'].')';
$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 .=
''
.l10n_dec('%d new element', '%d new elements', $date_detail['nb_elements'])
.' ('
.''
.l10n('recent_pics_cat').''
.')'
.'';
foreach( $date_detail['elements'] as $element )
{
$tn_src = get_thumbnail_url($element);
$item->description .= '';
}
$item->description .= '...
';
$item->description .=
''
.l10n_dec('%d category updated', '%d categories updated',
$date_detail['nb_cats'])
.'';
$item->description .= '';
foreach( $date_detail['categories'] as $cat )
{
$item->description .=
'- '
.get_cat_display_name_cache($cat['uppercats'])
.' ('.
l10n_dec('%d new element',
'%d new elements', $cat['img_count']).')'
.'
';
}
$item->description .= '
';
$item->descriptionHtmlSyndicated = true;
$item->date = ts_to_iso8601(mysqldt_to_ts($date));
$item->author = 'PhpWebGallery notifier';
$item->guid= sprintf('%s', 'pics-'.$date);;
$rss->addItem($item);
}
// send XML feed
echo $rss->saveFeed('RSS2.0', '', true);
?>