-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrss-comments.php
142 lines (141 loc) · 4.41 KB
/
rss-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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
require_once(dirname(__FILE__).'/zp-core/folder-definitions.php');
define('OFFSET_PATH', 0);
require_once(ZENFOLDER . "/template-functions.php");
require_once(ZENFOLDER . "/functions-rss.php");
startRSSCache();
if (!getOption('RSS_comments')) {
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
include(ZENFOLDER. '/404.php');
exit();
}
if(getOption('zp_plugin_zenpage')) {
require_once(ZENFOLDER . '/'.PLUGIN_FOLDER. "/zenpage/zenpage-template-functions.php");
}
header('Content-Type: application/xml');
$host = getRSSHost();
$serverprotocol = getOption("server_protocol");
$id = getRSSID() ;
$title = getRSSTitle();
$type = getRSSType();
$locale = getRSSLocale();
$validlocale = getRSSLocaleXML();
$albumpath = getRSSImageAndAlbumPaths("albumpath");
$modrewritesuffix = getRSSImageAndAlbumPaths("modrewritesuffix");
$imagepath = getRSSImageAndAlbumPaths("imagepath");
$items = getOption('feed_items'); // # of Items displayed on the feed
?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title><?php echo strip_tags(get_language_string(getOption('gallery_title'), $locale))." - ".gettext("latest comments").$title; ?></title>
<link><?php echo $serverprotocol."://".$host.WEBPATH; ?></link>
<atom:link href="<?php echo $serverprotocol; ?>://<?php echo $host.WEBPATH; ?>/rss-comments.php" rel="self" type="application/rss+xml" />
<description><?php echo strip_tags(get_language_string(getOption('Gallery_description'), $locale)); ?></description>
<language><?php echo $validlocale; ?></language>
<pubDate><?php echo date("r", time()); ?></pubDate>
<lastBuildDate><?php echo date("r", time()); ?></lastBuildDate>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<generator>Zenphoto Comment RSS Generator</generator>
<?php
$comments = array();
switch($type) {
case 'gallery':
case 'album':
case 'image':
if($type == 'gallery') {
$type = 'all';
}
$comments = getLatestComments($items,$type,$id);
break;
case 'zenpage':
case 'news':
case 'page':
if($type == 'zenpage') {
$type = 'all';
}
if(function_exists('getLatestZenpageComments')) {
$comments = getLatestZenpageComments($items,$type,$id);
}
break;
case 'allcomments':
$type = 'all';
$comments= getLatestComments($items,$type,$id);
$comments_zenpage = array();
if(function_exists('getLatestZenpageComments')) {
$comments_zenpage = getLatestZenpageComments($items,$type,$id);
$comments = array_merge($comments,$comments_zenpage);
$comments = sortMultiArray($comments,'id',true);
$comments = array_splice($comments,0,$items);
}
break;
}
foreach ($comments as $comment) {
if($comment['anon'] === "0") {
$author = " ".gettext("by")." ".$comment['name'];
} else {
$author = "";
}
switch($comment['type']) {
case 'images':
$imagetag = $imagepath.$comment['filename'].$modrewritesuffix;
break;
case 'albums':
case 'news':
case 'pages':
$imagetag = "";
break;
}
switch($comment['type']) {
case 'images':
case 'albums':
$album = pathurlencode($comment['folder']);
$date = $comment['date'];
$category = $comment['albumtitle'];
$title = '';
if($comment['type'] != 'albums') {
if ($comment['title'] == "") {
$title = '';
} else {
$title = get_language_string($comment['title']);
}
}
$website = $comment['website'];
if(!empty($category)) {
$title = ": ".$title;
}
$commentpath = $serverprotocol.'://'.$host.WEBPATH.$albumpath.$album.$imagetag."#".$comment['id'];
break;
case 'news':
case 'pages':
$album = '';
$date = $comment['date'];
$category = '';
$title = get_language_string($comment['title']);
$titlelink = $comment['titlelink'];
$website = $comment['website'];
if(function_exists('getNewsURL')) {
switch($comment['type']) {
case 'news':
$commentpath = $serverprotocol.'://'.$host.getNewsURL($titlelink)."#".$comment['id'];
break;
case 'pages':
$commentpath = $serverprotocol.'://'.$host.getPageLinkURL($titlelink)."#".$comment['id'];
break;
}
}
break;
}
?>
<item>
<title><?php echo strip_tags($category.$title.$author); ?></title>
<link><?php echo '<![CDATA['.$commentpath.']]>';?></link>
<description><?php echo $comment['comment']; ?></description>
<category><?php echo strip_tags($category); ?></category>
<guid><?php echo '<![CDATA['.$commentpath.']]>';?></guid>
<pubDate><?php echo date("r",strtotime($date)); ?></pubDate>
</item>
<?php } ?>
</channel>
</rss>
<?php endRSSCache();?>