-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRSS.class.php
69 lines (61 loc) · 1.97 KB
/
RSS.class.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
<?
class RSS
{
public function RSS()
{
require_once ('pathto.../mysql_connect.php');
}
public function GetFeed()
{
return $this->getDetails() . $this->getItems();
}
private function dbConnect()
{
DEFINE ('LINK', mysql_connect (DB_HOST, DB_USER, DB_PASSWORD));
}
private function getDetails()
{
$detailsTable = "webref_rss_details";
$this->dbConnect($detailsTable);
$query = "SELECT * FROM ". $detailsTable;
$result = mysql_db_query (DB_NAME, $query, LINK);
while($row = mysql_fetch_array($result))
{
$details = '<?xml version="1.0" encoding="ISO-8859-1" ?>
<rss version="2.0">
<channel>
<title>'. $row['title'] .'</title>
<link>'. $row['link'] .'</link>
<description>'. $row['description'] .'</description>
<language>'. $row['language'] .'</language>
<image>
<title>'. $row['image_title'] .'</title>
<url>'. $row['image_url'] .'</url>
<link>'. $row['image_link'] .'</link>
<width>'. $row['image_width'] .'</width>
<height>'. $row['image_height'] .'</height>
</image>';
}
return $details;
}
private function getItems()
{
$itemsTable = "webref_rss_items";
$this->dbConnect($itemsTable);
$query = "SELECT * FROM ". $itemsTable;
$result = mysql_db_query (DB_NAME, $query, LINK);
$items = '';
while($row = mysql_fetch_array($result))
{
$items .= '<item>
<title>'. $row["title"] .'</title>
<link>'. $row["link"] .'</link>
<description><![CDATA['. $row["description"] .']]></description>
</item>';
}
$items .= '</channel>
</rss>';
return $items;
}
}
?>