channelTitle == "") die("Please specify a channel title"); if(ereg("$http://", $this->channelLink) == false) die("Please specify a channel link"); if($this->channelDesc == "") die("Please specify a channel description"); if($this->imageTitle == "") die("Please specify an image title"); if(ereg("$http://", $this->imageLink) == false) die("Please specify an image link"); if(ereg("$http://", $this->imageURL) == false) die("Please specify an image URL"); } // Connect to the database, generate the RSS XML and return it function GetRSS($dbServer, $dbUser, $dbPass, $dbName, $tableName, $titleFieldName, $descFieldName, $linkFieldName, $linkTemplate) { // Make sure all channel/image values have been set $this->checkValues(); $rssValue = " \r \n"; $rssValue .= "\r\n"; $rssValue .= "\r\n"; // Build the channel tag $rssValue .= "\r\n"; $rssValue .= "" . $this->channelTitle . "\r\n"; $rssValue .= "" . $this->channelLink . "\r\n"; $rssValue .= "" . $this->channelDesc . "\r\n"; $rssValue .= "en-us\r\n"; $rssValue .= "\r\n"; // Build the image tag $rssValue .= "\r\n"; $rssValue .= "" . $this->imageTitle . "\r\n"; $rssValue .= "" . $this->imageURL . "\r\n"; $rssValue .= "" . $this->imageLink . "\r\n"; $rssValue .= "\r\n"; // -- Table structure for table 'newsContent' // -- // // CREATE TABLE newsContent ( // title varchar(40) default NULL, // date date default NULL, // body text // ) // Connect to the database and build the tags $svrConn = @mysql_connect($dbServer, $dbUser, $dbPass) or die("Couldn't connect to database"); $dbConn = @mysql_select_db($dbName, $svrConn) or die("Couldn't select database"); // Make sure the table exists $tableExists = false; $tResult = mysql_list_tables($dbName); while($tRow = mysql_fetch_row($tResult)) { if(strtolower($tableName) == strtolower($tRow[0])) { $tableExists = true; break; } } if(!$tableExists) die("Table $tableName doesn't exist in the database!"); $rResult = mysql_query("select $titleFieldName, $descFieldName, $linkFieldName from $tableName order by $linkFieldName desc limit 10") or die ('An error occured while retrieving data from the database. Please contact the webmaster if this problem persists.'); // The records were retrieved OK, let's start building the item tags while($rRow = mysql_fetch_array($rResult)) { $rssValue .= "\r\n"; $rssValue .= "" . $rRow[$titleFieldName] . "\r\n"; $rssValue .= "" . $rRow[$descFieldName] . "\r\n"; $rssValue .= "" . str_replace("{linkId}", $rRow[$linkFieldName], $linkTemplate) . "\r\n"; $rssValue .= "\r\n"; } // Add the closing rss tag and return the value $rssValue .= "\r\n"; return $rssValue; // end tag of GetRSS function } // end tag of the class } ?>