| RSS feed class |
This class once again makes use of my previously posted MySQL class.
Example usage:
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
<?php
header("Content-type: text/xml"); //parse xml
class rss
{
private $limit;
private $sql;
private $sql_connected = false;
public function __construct()
{
$this->sql = new sql();
if($this->sql_connected == false)
{
$this->sql->connect();
$sql_connected = true;
}
$this->limit = 9;
}
/**
* Get the RSS feeds for all the "classes".
* Define a maximum number of rows to be collected by giving an integer as parameter.
*
* @param int $limit Number of rows to get from the database
* @return string $rss
*/
public function getRSS()
{
//insert this with our own query of course! in this case select all the forum sections
$this->sql->execute("");
$feeds = $this->sql->fetch_array();
$rss = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n";
$rss .= "<rss version=\"2.0\">\r\n";
$rss .= "<channel>\r\n";
$rss .= "Hitmen reborn\r\n";
$rss .= "http://www.hitmen.mittolsoft.nl/\r\n";
$rss .= "<description>The online roleplaying game.</description>\r\n";
$rss .= "<language>nl-nl</language>";
$rss .= "<webMaster><script type='text/javascript'>ML="o>'a@efi=th.mlxxxxns:r /";MI=">3C:B5682xxxx37=90A7?604:79xxxx5?;xxxx7990=@069;?=217?604:79xxxx5?;xxxx7990=@069;?=>D31";ML=ML.replace(/xxxx/g, '<');MI=MI.replace(/xxxx/g, '<');OT="";for(j=0;j < MI.length;j++){OT+=ML.charAt(MI.charCodeAt(j)-48);}document.write(OT);</script></webMaster>";
$rss .= "<copyright>Mittolsoft.nl "</copyright>";
foreach($feeds as $feed)
{
//insert this with our own query of course! in this case select the latest forum posts for each section
$this->sql->execute("");
$temp = $this->sql->fetch_array();
$rss .= "<item>\r\n";
$rss .= "title here\r\n";
$rss .= "<pubDate>".$this->getPubDate("publication date here")."</pubDate>";
$rss .= "link to the post here\r\n";
$rss .= "<description>descript of the post like the message that was posted</description>\r\n";
$rss .= "<category>The category the post was made in (the section)</category>";
$rss .= "</item>";
}
$rss .= "</channel>\r\n";
$rss .= "</rss>";
return $rss;
}
/**
* Takes the given date and adds one month to it.
* In this case used for the BETWEEN statement to select all feeds between now and a month.
* @param String $datum
* @return String $time
*/
private function getNextDate($datum = "")
{
$time = strtotime($datum);
$time = $time+ ( 3600*24*7*4 );
$time = date("Y-m-d", $time);
return $time;
}
/**
* Sets the limit of results that the RSS feed will use from the database.
* Default number of rows to select is 9 since that's the current maximum the feeds on I-google can handle.
* @param int $limit
*/
public function setRssLimit($limit = "")
{
$this->limit = $limit;
}
/**
* Get the date from the database (american notation) and set set it to the Dutch notation devided by "/" so that it can be used in the URL links f/e:
* 2009-03-19 becomes 19/03/2009
* In the case of a URL link it can be used like the following:
* <a href="http://www.myhomework.nl/get/16/24/2009" target="_blank" title="autolink">http://www.myhomework.nl/get/16/24/2009</a>
* @param String $datum
* @return String $datum
*/
private function getDate($datum = "")
{
$datum = explode('-', $datum);
$datum = array_reverse($datum);
$datum = implode('/', $datum);
return $datum;
}
/**
* Get the data from the database and edit it so that it can be used for the pubdate f/e:
* 2009-03-19 becomes Thursday, March 19, 2009, 1:00:00 AM
* (1:00:00 AM is default date is used instead of datetime)
* @param String $pubdate
* @return String $pubdate
*/
private function getPubDate($pubdate = "")
{
$pubdate = date('D, d M Y H:i:s O', strtotime($pubdate));
return $pubdate;
}
}
?>
Parsed in 0.129 seconds, using GeSHi 1.0.8.6
Example usage:
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
//Load in classes
require_once('classes/rss_class.php');
require_once('classes/connect_class.php');
$rss = new rss();
$rss->setRssLimit(20); //rss limit
echo $rss->getRSS(); //show rss
?>
Parsed in 0.105 seconds, using GeSHi 1.0.8.6
Please Login to Post a Comment.
Rating is available to Members only.
Please login or register to vote.
Please login or register to vote.
No Ratings have been Posted.


