-
Notifications
You must be signed in to change notification settings - Fork 0
/
rssfeed-comments.php
executable file
·52 lines (49 loc) · 1.97 KB
/
rssfeed-comments.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
@include('incs/config.inc.php');
@include('incs/db.inc.php');
@include('incs/functions.inc.php');
header("Content-type: application/xml");
# Here we create the query containing the RSS-version of the last 15 posts to the site.
$sql_xml = "SELECT (comments.date - ({$offset} * 3600)) as xml_date, (entries.date - ({$offset} * 3600)) as entrydate, slug, c_id, c_author, c_text, title, status from {$db_name}.entries, {$db_name}.comments WHERE comments.eid = entries.id and entries.status = '1' ORDER BY c_id DESC LIMIT 15";
# db-debugging
if(!$result_xml = @mysql_query($sql_xml))
{
print "<p>Error executing XML-query.".mysql_error()."</p>";
}
else
{
# Set date for last build.
putenv("TZ=CET");
$last_build_date = date("r", (time()) );
# Initiate the content-string that will be added to
$xml_string = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>
<rss version=\"2.0\" xmlns:icbm=\"http://postneo.com/icbm\">
<channel>
<title>. Comments from {$tagline} .</title>
<description>Comments on {$tagline}</description>
<link>http://{$domain_name}</link>
<lastBuildDate>{$last_build_date}</lastBuildDate>
<icbm:latitude>55.6773</icbm:latitude>
<icbm:longitude>12.5749</icbm:longitude>
";
while($row = @mysql_fetch_array($result_xml))
{
extract($row);
$text = htmlspecialchars($c_text);
$text = format_entry($c_text);
$pub_date = date("r", $xml_date);
$date = date("dmy", $xml_date);
$entry_date = date("dmy", $entrydate);
$xml_string .= "<item>\n\t";
$xml_string .= "<title>Comments from {$c_author} on '{$title}'</title>\n\t";
$xml_string .= "<description>{$text}</description>\n\t";
$xml_string .= "<link>http://{$domain_name}/".$entry_date."/".$slug."#c</link>\n\t";
$xml_string .= "<pubDate>{$pub_date}</pubDate>\n\t";
$xml_string .= "<guid>http://{$domain_name}/".$entry_date."/".$slug."</guid>\n\t";
$xml_string .= "<author>{$email} ({$c_author})</author>\n\t";
$xml_string .= "</item>\n";
}
$xml_string .= "</channel>\n</rss>";
}
print $xml_string;
?>