Project

General

Profile

« Previous | Next » 

Revision 1157

Added by Dietmar about 15 years ago

Ticket #770, #785, #792, #807, #809, fixes and recoded the news module

View differences:

rss.php
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
// Check that GET values have been supplied
27
if(isset($_GET['page_id']) AND is_numeric($_GET['page_id'])) {
28
	$page_id = $_GET['page_id'];
29
	define('PAGE_ID', $page_id);
30
} else {
31
	header('Location: '.WB_URL);
32
	exit(0);
33
}
34
if(isset($_GET['group_id']) AND is_numeric($_GET['group_id'])) {
35
	$group_id = $_GET['group_id'];
36
	define('GROUP_ID', $group_id);
37
}
38

  
39
// Include WB files
40
require_once('../../config.php');
41
require_once(WB_PATH.'/framework/class.frontend.php');
42
$database = new database();
43
$wb = new frontend();
44
$wb->page_id = $page_id;
45
$wb->get_page_details();
46
$wb->get_website_settings();
47

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

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

  
58
// Header info
59
// Required by CSS 2.0
60
echo '<?xml version="1.0" encoding="'.$charset.'"?>';
61
?> 
62
<rss version="2.0">
63
<channel>
64
<title><?php echo PAGE_TITLE; ?></title>
65
<link>http://<?php echo $_SERVER['SERVER_NAME']; ?></link>
66
<description> <?php echo PAGE_DESCRIPTION; ?></description>
67
<?php
68
// Optional header info 
69
?>
70
<language><?php echo strtolower(DEFAULT_LANGUAGE); ?></language>
71
<copyright><?php $thedate = date('Y'); $websitetitle = WEBSITE_TITLE; echo "Copyright {$thedate}, {$websitetitle}"; ?></copyright>
72
<managingEditor><?php echo SERVER_EMAIL; ?></managingEditor>
73
<webMaster><?php echo SERVER_EMAIL; ?></webMaster>
74
<category><?php echo WEBSITE_TITLE; ?></category>
75
<generator>Website Baker Content Management System</generator>
76

  
77
<?php
78
// Get news items from database
79
$t = TIME();
80
$time_check_str= "(published_when = '0' OR published_when <= ".$t.") AND (published_until = 0 OR published_until >= ".$t.")";
81
//Query
82
if(isset($group_id)) {
83
	$query = "SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE group_id=".$group_id." AND page_id = ".$page_id." AND active=1 AND ".$time_check_str." ORDER BY posted_when DESC";
84
} else {
85
	$query = "SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE page_id=".$page_id." AND active=1 AND ".$time_check_str." ORDER BY posted_when DESC";	
86
}
87
$result = $database->query($query);
88

  
89
//Generating the news items
90
while($item = $result->fetchRow($result)){ ?>
91

  
92
<item>
93
<title><![CDATA[<?php echo stripslashes($item["title"]); ?>]]></title>
94
<description><![CDATA[<?php echo stripslashes($item["content_short"]); ?>]]></description>
95
<guid><?php echo WB_URL.PAGES_DIRECTORY.$item["link"].PAGE_EXTENSION; ?></guid>
96
<link><?php echo WB_URL.PAGES_DIRECTORY.$item["link"].PAGE_EXTENSION; ?></link>
97
</item>
98

  
99
<?php } ?>
100

  
101
</channel>
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
// Check that GET values have been supplied
27
if(isset($_GET['page_id']) AND is_numeric($_GET['page_id']))
28
{
29
	$page_id = $_GET['page_id'];
30
	define('PAGE_ID', $page_id);
31
}
32
else
33
{
34
	header('Location: '.WB_URL);
35
	exit( 0 );
36
}
37
if(isset($_GET['group_id']) AND is_numeric($_GET['group_id'])) {
38
	$group_id = $_GET['group_id'];
39
	define('GROUP_ID', $group_id);
40
}
41

  
42
// Include WB files
43
require_once('../../config.php');
44
require_once(WB_PATH.'/framework/class.frontend.php');
45
$database = new database();
46
$wb = new frontend();
47
$wb->page_id = $page_id;
48
$wb->get_page_details();
49
$wb->get_website_settings();
50

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

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

  
61
// Header info
62
// Required by CSS 2.0
63
echo '<?xml version="1.0" encoding="'.$charset.'"?>';
64
?>
65
<rss version="2.0">
66
<channel>
67
<title><?php echo PAGE_TITLE; ?></title>
68
<link>http://<?php echo $_SERVER['SERVER_NAME']; ?></link>
69
<description> <?php echo PAGE_DESCRIPTION; ?></description>
70
<?php
71
// Optional header info
72
?>
73
<language><?php echo strtolower(DEFAULT_LANGUAGE); ?></language>
74
<copyright><?php $thedate = date('Y'); $websitetitle = WEBSITE_TITLE; echo "Copyright {$thedate}, {$websitetitle}"; ?></copyright>
75
<managingEditor><?php echo SERVER_EMAIL; ?></managingEditor>
76
<webMaster><?php echo SERVER_EMAIL; ?></webMaster>
77
<category><?php echo WEBSITE_TITLE; ?></category>
78
<generator>Website Baker Content Management System</generator>
79

  
80
<?php
81
// Get news items from database
82
$t = TIME();
83
$time_check_str= "(published_when = '0' OR published_when <= ".$t.") AND (published_until = 0 OR published_until >= ".$t.")";
84
//Query
85
if(isset($group_id)) {
86
	$query = "SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE group_id=".$group_id." AND page_id = ".$page_id." AND active=1 AND ".$time_check_str." ORDER BY posted_when DESC";
87
} else {
88
	$query = "SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE page_id=".$page_id." AND active=1 AND ".$time_check_str." ORDER BY posted_when DESC";
89
}
90
$result = $database->query($query);
91

  
92
//Generating the news items
93
while($item = $result->fetchRow($result)){ ?>
94

  
95
<item>
96
<title><![CDATA[<?php echo stripslashes($item["title"]); ?>]]></title>
97
<description><![CDATA[<?php echo stripslashes($item["content_short"]); ?>]]></description>
98
<guid><?php echo WB_URL.PAGES_DIRECTORY.$item["link"].PAGE_EXTENSION; ?></guid>
99
<link><?php echo WB_URL.PAGES_DIRECTORY.$item["link"].PAGE_EXTENSION; ?></link>
100
</item>
101

  
102
<?php } ?>
103

  
104
</channel>
102 105
</rss>

Also available in: Unified diff