Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        modules
5
 * @package         news
6
 * @author          WebsiteBaker Project
7
 * @copyright       Ryan Djurovich
8
 * @copyright       Website Baker Org. e.V.
9
 * @link            http://websitebaker.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.3
12
 * @requirements    PHP 5.3.6 and higher
13
 * @version         $Id: rss.php 2 2017-07-02 15:14:29Z Manuela $
14
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/trunk/modules/news/rss.php $
15
 * @lastmodified    $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
16
 *
17
 */
18

    
19
// Check that GET values have been supplied
20
if(isset($_GET['page_id']) && is_numeric($_GET['page_id'])) {
21
    $page_id = intval($_GET['page_id']);
22
} else {
23
    // something is gone wrong, send error header
24
    header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
25
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Datum in der Vergangenheit
26
    if (preg_match('/fcgi/i', php_sapi_name())) {
27
        header("Status: 204 No Content"); // RFC7231, Section 6.3.5
28
    } else {
29
        header("HTTP/1.0 204  No Content");
30
    }
31
    flush();
32
    exit;
33
}
34

    
35
if(isset($_GET['group_id']) && is_numeric($_GET['group_id'])) {
36
    $group_id = $_GET['group_id'];
37
    define('GROUP_ID', $group_id);
38
}
39

    
40
// Include WB files
41
if ( !defined( 'WB_PATH' ) ){ require( dirname(dirname((__DIR__))).'/config.php' ); }
42
if ( !class_exists('frontend')) { require(WB_PATH.'/framework/class.frontend.php');  }
43
// Create new frontend object
44
if (!isset($wb) || !($wb instanceof frontend)) { $wb = new frontend(); }
45
$wb->page_id = $page_id;
46
$wb->get_page_details();
47
$wb->get_website_settings();
48

    
49
//checkout if a charset is defined otherwise use UTF-8
50
if(defined('DEFAULT_CHARSET')) {
51
    $charset=DEFAULT_CHARSET;
52
} else {
53
    $charset='utf-8';
54
}
55

    
56
// Sending XML header
57
header("Content-type: text/xml; charset=$charset" );
58

    
59
// Header info
60
// Required by CSS 2.0
61
echo '<?xml version="1.0" encoding="'.$charset.'"?>';
62
?>
63
<rss version="2.0">
64
    <channel>
65
        <title><![CDATA[<?php echo PAGE_TITLE; ?>]]></title>
66
        <link>http://<?php echo $_SERVER['SERVER_NAME']; ?></link>
67
        <description><![CDATA[<?php echo PAGE_DESCRIPTION; ?>]]></description>
68
<?php
69
// Optional header info
70
?>
71
        <language><?php echo strtolower(DEFAULT_LANGUAGE); ?></language>
72
        <copyright><?php $thedate = date('Y'); $websitetitle = WEBSITE_TITLE; echo "Copyright {$thedate}, {$websitetitle}"; ?></copyright>
73
        <managingEditor><?php echo SERVER_EMAIL; ?></managingEditor>
74
        <webMaster><?php echo SERVER_EMAIL; ?></webMaster>
75
        <category><?php echo WEBSITE_TITLE; ?></category>
76
        <generator>WebsiteBaker Content Management System</generator>
77
<?php
78
// Get news items from database
79
$time = time();
80
//Query
81
    $sql='SELECT * FROM `'.TABLE_PREFIX.'mod_news_posts` '
82
        .'WHERE `page_id`='.(int)$page_id.' '
83
        .       (isset($group_id) ? 'AND `group_id`='.(int)$group_id.' ' : '')
84
        .       'AND `active`=1 '
85
        .       'AND (`published_when`  = 0 OR `published_when` <= '.$time.') '
86
        .       'AND (`published_until` = 0 OR `published_until` >= '.$time.') '
87
        .'ORDER BY posted_when DESC';
88

    
89
$result = $database->query($sql);
90

    
91
//Generating the news items
92
while($item = $result->fetchRow( MYSQLI_ASSOC )){
93
    $description = stripslashes($item["content_short"]);
94
    $description = OutputFilterApi('WbLink|ReplaceSysvar', $description);
95
?>
96
    <item>
97
        <title><![CDATA[<?php echo stripslashes($item["title"]); ?>]]></title>
98
        <description><![CDATA[<?php echo $description; ?>]]></description>
99
        <link><?php echo WB_URL.PAGES_DIRECTORY.$item["link"].PAGE_EXTENSION; ?></link>
100
        <pubDate><?PHP echo date('r', $item["published_when"]); ?></pubDate>
101
        <guid><?php echo WB_URL.PAGES_DIRECTORY.$item["link"].PAGE_EXTENSION; ?></guid>
102
    </item>
103
<?php } ?>
104
    </channel>
105
</rss>
(27-27/36)