'.generate_key(50).'';
if (isset($_GET['feed'])
and preg_match('/^[A-Za-z0-9]{50}$/', $_GET['feed']))
{
$query = '
SELECT uf.user_id AS id,
ui.status,
uf.last_check,
u.'.$conf['user_fields']['username'].' AS username
FROM '.USER_FEED_TABLE.' AS uf
INNER JOIN '.USER_INFOS_TABLE.' AS ui
ON ui.user_id = uf.user_id
INNER JOIN '.USERS_TABLE.' AS u
ON u.'.$conf['user_fields']['id'].' = uf.user_id
WHERE uf.id = \''.$_GET['feed'].'\'
;';
$user = mysql_fetch_array(pwg_query($query));
}
if ( empty($user) )
{
page_not_found('Unknown/missing feed identifier');
}
$user['forbidden_categories'] = calculate_permissions($user['id'],
$user['status']);
if ('' == $user['forbidden_categories'])
{
$user['forbidden_categories'] = '0';
}
list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
include_once(PHPWG_ROOT_PATH.'include/feedcreator.class.php');
$base_url = get_host_url().cookie_path();
if ( strrpos($base_url, '/') !== strlen($base_url)-1 )
{
$base_url .= '/';
}
$page['root_path']=$base_url;
$rss = new UniversalFeedCreator();
$rss->title = $conf['gallery_title'];
$rss->title.= ' (as '.$user['username'].')';
$rss->link = $conf['gallery_url'];
// +-----------------------------------------------------------------------+
// | Feed creation |
// +-----------------------------------------------------------------------+
if ( !isset($_GET['image_only']) )
{
$news = news($user['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 = \''.$_GET['feed'].'\'
;';
pwg_query($query);
}
}
else
{ // update the last check to avoid deletion by maintenance task
$query = '
UPDATE '.USER_FEED_TABLE.'
SET last_check = \''.$dbnow.'\'
WHERE id = \''.$_GET['feed'].'\'
;';
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 element added', '%d elements added', $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 element added', '%d elements added', $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 element added',
'%d elements added', $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);
?>