-
Notifications
You must be signed in to change notification settings - Fork 4
/
rss.php
90 lines (81 loc) · 2.93 KB
/
rss.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
<?php
/**
*
* @category modules
* @package news_img
* @author WBCE Community
* @copyright 2004-2009, Ryan Djurovich
* @copyright 2009-2010, Website Baker Org. e.V.
* @copyright 2019-, WBCE Community
* @link https://www.wbce.org/
* @license http://www.gnu.org/licenses/gpl.html
* @platform WBCE
*
*/
// Check that GET values have been supplied
if(isset($_GET['section_id']) && is_numeric($_GET['section_id'])) {
$section_id = intval($_GET['section_id']);
} else {
die('section_id missing');
}
if(isset($_GET['page_id']) && is_numeric($_GET['page_id'])) {
$page_id = intval($_GET['page_id']);
} else {
die('page_id missing');
}
if(isset($_GET['group_id']) && is_numeric($_GET['group_id'])) {
$group_id = intval($_GET['group_id']);
define('GROUP_ID', $group_id);
}
// Include WB files
require_once '../../config.php';
require_once WB_PATH.'/framework/class.frontend.php';
$database = new database();
$wb = new frontend();
$wb->page_id = $page_id;
$wb->get_page_details();
$wb->get_website_settings();
//checkout if a charset is defined otherwise use UTF-8
if(defined('DEFAULT_CHARSET')) {
$charset=DEFAULT_CHARSET;
} else {
$charset='utf-8';
}
// Sending XML header
header("Content-type: text/xml; charset=$charset" );
// Header info
// Required by CSS 2.0
$t = TIME();
echo '<?xml version="1.0" encoding="'.$charset.'"?>';
?>
<rss version="2.0">
<channel>
<title><?php echo PAGE_TITLE; ?></title>
<link><?php echo WB_URL; ?></link>
<description> <?php echo PAGE_DESCRIPTION; ?></description>
<?php
// Optional header info
?>
<language><?php echo strtolower(DEFAULT_LANGUAGE); ?></language>
<copyright><?php $thedate = date('Y'); $websitetitle = WEBSITE_TITLE; echo "Copyright {$thedate}, {$websitetitle}"; ?></copyright>
<category><?php echo WEBSITE_TITLE; ?></category>
<?php
$time_check_str= "(`published_when` = '0' OR `published_when` <= ".$t.") && (`published_until` = 0 OR `published_until` >= ".$t.")";
//Query
if(isset($group_id)) {
$query = "SELECT * FROM `".TABLE_PREFIX."mod_news_img_posts` WHERE `group_id`=".$group_id." && `section_id` = ".$section_id." && `active`=1 && ".$time_check_str." ORDER BY `posted_when` DESC";
} else {
$query = "SELECT * FROM `".TABLE_PREFIX."mod_news_img_posts` WHERE `section_id`=".$section_id." && `active`=1 && ".$time_check_str." ORDER BY `posted_when` DESC";
}
$result = $database->query($query);
//Generating the news items
while($item = $result->fetchRow()){ ?>
<item>
<title><![CDATA[<?php echo stripslashes($item["title"]); ?>]]></title>
<description><![CDATA[<?php echo stripslashes($item["content_short"]); ?>]]></description>
<guid><?php echo WB_URL.PAGES_DIRECTORY.$item["link"].PAGE_EXTENSION; ?></guid>
<link><?php echo WB_URL.PAGES_DIRECTORY.$item["link"].PAGE_EXTENSION; ?></link>
</item>
<?php } ?>
</channel>
</rss>