| 1 |
<?php |
| 2 |
// Exit if accessed directly |
| 3 |
if( !defined( 'ABSPATH' ) ) exit; |
| 4 |
|
| 5 |
class wpForoFeed{ |
| 6 |
|
| 7 |
function __construct(){} |
| 8 |
|
| 9 |
function rss2_url($echo = true, $general = false){ |
| 10 |
$url = wpforo_get_request_uri(); |
| 11 |
if(isset(WPF()->current_object['forumid'])){ $forumid = WPF()->current_object['forumid']; } |
| 12 |
if(isset(WPF()->current_object['topicid'])){ $topicid = WPF()->current_object['topicid']; } |
| 13 |
if(isset($forumid) && isset($topicid)){ |
| 14 |
$rss2 = $url . '?type=rss2&forum=' . intval($forumid) . '&topic=' . intval($topicid); |
| 15 |
} |
| 16 |
elseif(isset($forumid) && !isset($topicid)){ |
| 17 |
$rss2 = $url . '?type=rss2&forum=' . intval($forumid); |
| 18 |
} |
| 19 |
|
| 20 |
if($general){ |
| 21 |
if( $general == 'topic' ){ |
| 22 |
$rss2 = $url . '?type=rss2&forum=g&topic=g'; |
| 23 |
} |
| 24 |
elseif( $general == 'forum' ){ |
| 25 |
$rss2 = $url . '?type=rss2&forum=g'; |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
$rss2 = esc_url($rss2); |
| 30 |
|
| 31 |
if($echo){ |
| 32 |
echo $rss2; |
| 33 |
} |
| 34 |
else{ |
| 35 |
return $rss2; |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
function rss2_forum( $forum = array(), $topics = array() ){ |
| 40 |
if(empty($forum)) { |
| 41 |
if(!wpforo_feature('rss-feed')){ |
| 42 |
header('HTTP/1.0 404 Not Found', true, 404); |
| 43 |
die(); |
| 44 |
} |
| 45 |
else{ |
| 46 |
return; |
| 47 |
} |
| 48 |
} |
| 49 |
header("Content-Type: application/xml; charset" . get_option('blog_charset') ); |
| 50 |
echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>'; |
| 51 |
?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"> |
| 52 |
<channel> |
| 53 |
<title> |
| 54 |
<?php if(!isset($forum['title']) || !$forum['title']): ?> |
| 55 |
<?php echo esc_html(WPF()->general_options['title']) . ' - ' . wpforo_phrase('Recent Topics', false) ?> |
| 56 |
<?php else: ?> |
| 57 |
<?php echo esc_html($forum['title']); ?> - <?php echo esc_html(WPF()->general_options['title']); ?> |
| 58 |
<?php endif; ?> |
| 59 |
</title> |
| 60 |
<link><?php echo esc_url($forum['forumurl']); ?></link> |
| 61 |
<description><?php echo esc_html(WPF()->general_options['description']); ?></description> |
| 62 |
<language><?php bloginfo_rss( 'language' ); ?></language> |
| 63 |
<lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', date('Y-m-d H:i:s'), false); ?></lastBuildDate> |
| 64 |
<generator>wpForo</generator> |
| 65 |
<ttl>60</ttl> |
| 66 |
<?php if(!empty($topics)): ?> |
| 67 |
<?php foreach($topics as $topic): ?> |
| 68 |
<item> |
| 69 |
<title><?php echo wpforo_removebb(esc_html($topic['title'])); ?></title> |
| 70 |
<link><?php echo esc_url($topic['topicurl']); ?></link> |
| 71 |
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', $topic['created'], false); ?></pubDate> |
| 72 |
<description><![CDATA[<?php echo wpforo_removebb(esc_html($topic['description'])) ?>]]></description> |
| 73 |
<content:encoded><![CDATA[<?php echo wpforo_removebb(esc_html($topic['content'])) ?>]]></content:encoded> |
| 74 |
<category domain="<?php echo esc_url($forum['forumurl']); ?>"><?php echo esc_html($forum['title']); ?></category> |
| 75 |
<dc:creator><?php echo esc_html($topic['author']); ?></dc:creator> |
| 76 |
<guid isPermaLink="true"><?php echo esc_url($topic['topicurl']); ?></guid> |
| 77 |
</item> |
| 78 |
<?php endforeach; ?> |
| 79 |
<?php endif; ?> |
| 80 |
</channel> |
| 81 |
</rss> |
| 82 |
<?php |
| 83 |
exit(); |
| 84 |
} |
| 85 |
|
| 86 |
function rss2_topic( $forum = array(), $topic = array(), $posts = array() ){ |
| 87 |
if(empty($forum)) { |
| 88 |
if(!wpforo_feature('rss-feed')){ |
| 89 |
header('HTTP/1.0 404 Not Found', true, 404); |
| 90 |
die(); |
| 91 |
} |
| 92 |
else{ |
| 93 |
return; |
| 94 |
} |
| 95 |
} |
| 96 |
header("Content-Type: application/xml; charset" . get_option('blog_charset') ); |
| 97 |
echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>'; |
| 98 |
?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"> |
| 99 |
<channel> |
| 100 |
<title> |
| 101 |
<?php if(!isset($topic['title']) || !$topic['title']): ?> |
| 102 |
<?php echo esc_html(WPF()->general_options['title']) . ' - ' . wpforo_phrase('Recent Posts', false); ?> |
| 103 |
<?php else: ?> |
| 104 |
<?php echo esc_html($topic['title']); ?> - <?php echo esc_html($forum['title']); ?> |
| 105 |
<?php endif; ?> |
| 106 |
</title> |
| 107 |
<link><?php echo esc_url($topic['topicurl']); ?></link> |
| 108 |
<description><?php echo esc_html(WPF()->general_options['description']); ?></description> |
| 109 |
<language><?php bloginfo_rss( 'language' ); ?></language> |
| 110 |
<lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', date('Y-m-d H:i:s'), false); ?></lastBuildDate> |
| 111 |
<generator>wpForo</generator> |
| 112 |
<ttl>60</ttl> |
| 113 |
<?php if(!empty($posts)): ?> |
| 114 |
<?php foreach($posts as $post): ?> |
| 115 |
<item> |
| 116 |
<title><?php echo wpforo_removebb(esc_html($post['title'])); ?></title> |
| 117 |
<link><?php echo esc_url($post['posturl']); ?></link> |
| 118 |
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', $post['created'], false); ?></pubDate> |
| 119 |
<description><![CDATA[<?php echo wpforo_removebb(esc_html($post['description'])) ?>]]></description> |
| 120 |
<content:encoded><![CDATA[<?php echo wpforo_removebb(esc_html($post['content'])) ?>]]></content:encoded> |
| 121 |
<category domain="<?php echo esc_url($forum['forumurl']); ?>"><?php echo esc_html($forum['title']); ?></category> |
| 122 |
<dc:creator><?php echo esc_html($post['author']); ?></dc:creator> |
| 123 |
<guid isPermaLink="true"><?php echo esc_url($post['posturl']); ?></guid> |
| 124 |
</item> |
| 125 |
<?php endforeach; ?> |
| 126 |
<?php endif; ?> |
| 127 |
</channel> |
| 128 |
</rss> |
| 129 |
<?php |
| 130 |
exit(); |
| 131 |
} |
| 132 |
|
| 133 |
} |