Location: PHPKode > scripts > PHP Classified script made easy > php-classified-script-made-easy/openclassifiedsdownload24124/Files/rss.class.php
<?
function XMLEntities($string)
    {
        $string2 = preg_replace('/[^a-zA-Z0-9\s]/', '', $string);
        return $string2;
    } 
  class RSS
  {
	public function RSS()
	{
		require_once ('rss_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()
	{

			$details = '<?xml version="1.0" encoding="ISO-8859-1" ?>
				<rss version="2.0">
					<channel>
						<title>Classifieds RSS Feed</title>
						<link></link>
						<description>Classifieds RSS Feed</description>
						<language>English</language>';
		return $details;
	}

	private function getItems()
	{
		$itemsTable = "classifieds";
		$this->dbConnect($itemsTable);
		$query = "SELECT * FROM ". $itemsTable." WHERE authorized = '1' ORDER BY date desc";
		$result = mysql_db_query (DB_NAME, $query, LINK);
		$items = '';
		while($row = mysql_fetch_array($result))
		{
            $l = $row['adid'];
			$items .= '<item>
				<title>'. XMLEntities($row["title"]) .'</title>
				<link>http://'.getenv("HTTP_HOST").'/classified-'.$l.'.php</link>
				<description><![CDATA[<strong>Price:</strong> '.XMLEntities($row["price"]).'<br/> <strong>Description:</strong>'. XMLEntities($row["description"]) .']]></description>
			</item>';
		}
		$items .= '</channel>
				</rss>';
		return $items;
	}

}

?>
Return current item: PHP Classified script made easy