4 // Create our channel variables
9 // Create our image variables
14 function checkValues()
16 // Make sure all channel and image values are set
17 if($this->channelTitle == "")
18 die("Please specify a channel title");
20 if(ereg("$http://", $this->channelLink) == false)
21 die("Please specify a channel link");
23 if($this->channelDesc == "")
24 die("Please specify a channel description");
26 if($this->imageTitle == "")
27 die("Please specify an image title");
29 if(ereg("$http://", $this->imageLink) == false)
30 die("Please specify an image link");
32 if(ereg("$http://", $this->imageURL) == false)
33 die("Please specify an image URL");
36 // Connect to the database, generate the RSS XML and return it
37 function GetRSS($dbServer, $dbUser, $dbPass, $dbName, $tableName,
38 $titleFieldName, $descFieldName, $linkFieldName, $linkTemplate)
40 // Make sure all channel/image values have been set
43 $rssValue = "<?xml version=\"1.0\"?> \r \n";
44 $rssValue .= "<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\" \"../rss-0.91.dtd\">\r\n";
45 $rssValue .= "<rss version=\"0.91\">\r\n";
47 // Build the channel tag
48 $rssValue .= "<channel>\r\n";
49 $rssValue .= "<title>" . $this->channelTitle . "</title>\r\n";
50 $rssValue .= "<link>" . $this->channelLink . "</link>\r\n";
51 $rssValue .= "<description>" . $this->channelDesc . "</description>\r\n";
52 $rssValue .= "<language>en-us</language>\r\n";
53 $rssValue .= "</channel>\r\n";
55 // Build the image tag
56 $rssValue .= "<image>\r\n";
57 $rssValue .= "<title>" . $this->imageTitle . "</title>\r\n";
58 $rssValue .= "<url>" . $this->imageURL . "</url>\r\n";
59 $rssValue .= "<link>" . $this->imageLink . "</link>\r\n";
60 $rssValue .= "</image>\r\n";
62 // -- Table structure for table 'newsContent'
65 // CREATE TABLE newsContent (
66 // title varchar(40) default NULL,
67 // date date default NULL,
72 // Connect to the database and build the <item> tags
73 $svrConn = @mysql_connect($dbServer, $dbUser, $dbPass) or die("Couldn't
74 connect to database");
75 $dbConn = @mysql_select_db($dbName, $svrConn) or die("Couldn't select
78 // Make sure the table exists
80 $tResult = mysql_list_tables($dbName);
82 while($tRow = mysql_fetch_row($tResult))
84 if(strtolower($tableName) == strtolower($tRow[0]))
92 die("Table $tableName doesn't exist in the database!");
94 $rResult = mysql_query("select $titleFieldName, $descFieldName,
95 $linkFieldName from $tableName order by $linkFieldName desc limit 10") or
96 die ('An error occured while retrieving data from the database. Please <a
97 href="/About/index.shtml">contact the webmaster</a> if this problem
100 // The records were retrieved OK, let's start building the item tags
101 while($rRow = mysql_fetch_array($rResult))
103 $rssValue .= "<item>\r\n";
104 $rssValue .= "<title>" . $rRow[$titleFieldName] . "</title>\r\n";
105 $rssValue .= "<description>" . $rRow[$descFieldName] . "</description>\r\n";
106 $rssValue .= "<link>" . str_replace("{linkId}", $rRow[$linkFieldName],
107 $linkTemplate) . "</link>\r\n";
108 $rssValue .= "</item>\r\n";
111 // Add the closing rss tag and return the value
112 $rssValue .= "</rss>\r\n";
114 // end tag of GetRSS function
116 // end tag of the class