<?
if($_GET['RSS'] == 'comments')
{
$result = mysql_query ("
SELECT comments.id AS comment_id, comments.picture, albums.id AS id, comments.name, comments.comment AS description, comments.timestamp AS last_updated
FROM `comments` , `albums`, `pictures`
WHERE albums.user = '" . USER . "'
AND comments.picture = pictures.id
AND pictures.album = albums.id
ORDER BY comment_id DESC LIMIT 25
");
}
else
{
$result = mysql_query ("
SELECT * FROM `albums` WHERE `last_updated` != 'NULL' AND `user` = '". USER ."' ORDER BY `last_updated` DESC LIMIT 25
");
}
if($result)
{
while ($row = mysql_fetch_assoc($result))
$arItem[] = $row;
}
//echo'<pre>';print_r($arItem);
########### get big title ###########
$stTitle = ucfirst(USER) . "'s Pictures ";
if($_GET['RSS'] == 'comments')
$stTitle = ucfirst(USER) . "'s Comments ";
########### get big link ###########
$stLink = 'http://';
$stLink .= $_SERVER['HTTP_HOST'];
$stLink .= $_SERVER["REQUEST_URI"];
$end = strrpos($stLink, '/');
$stLink = substr($stLink, 0, $end) . '/';
########### get little link ###########
function getLittleLink($item)
{
global $stLink;
$newLink = $stLink . '?album=' . $item['id'];
if($_GET['RSS'] == 'comments')
$newLink = $stLink . '?album=' . $item['id'] . '#' . $item['picture'];
return $newLink;
}
########### get little title ###########
function getLittleTitle($item)
{
$stTitle = $item['name'];
if($_GET['RSS'] == 'comments')
$stTitle = "Comment by: " . $item['name'];
return $stTitle;
}
if(isset($_GET['test']))
echo '<textarea rows=45 cols=90>';
else
header( "Content-type: application/xml" );
echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
?>
<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">]>
<rss version="2.0">
<channel>
<title><?= $stTitle ?></title>
<link><?= $stLink ?></link>
<description>Recently updated categories</description>
<language>en-us</language>
<pubDate><?= date('r') ?></pubDate>
<lastBuildDate><?= date('r') ?></lastBuildDate>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<? if (isset($arItem)): ?>
<? foreach($arItem as $item): ?>
<item>
<title><?= getLittleTitle($item) ?></title>
<link><?= getLittleLink($item) ?></link>
<? if ($item['description']): ?>
<description><?= $item['description'] ?></description>
<? endif; ?>
<pubDate><?= @date('r', strtotime($item['last_updated'])) ?></pubDate>
</item>
<? endforeach; ?>
<? endif; ?>
</channel>
</rss>
<? if(isset($_GET['test'])) echo '</textarea>'; ?>