Vergleich inc/class_feedgeneration.php - 1.2.1 - 1.2.9

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 3Zeile 3
 * MyBB 1.2
* Copyright � 2006 MyBB Group, All Rights Reserved
*

 * MyBB 1.2
* Copyright � 2006 MyBB Group, All Rights Reserved
*

 * Website: http://www.mybboard.com
* License: http://www.mybboard.com/eula.html

 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/eula.html

 *

 *

 * $Id: class_feedgeneration.php 1998 2006-07-19 07:05:51Z Kilroy $

 * $Id: class_feedgeneration.php 3177 2007-06-29 07:51:12Z chris $

 */

class FeedGenerator

 */

class FeedGenerator

Zeile 16Zeile 16
	 *
* @var string
*/

	 *
* @var string
*/

	var $feed_format = 'rss0.92';

	var $feed_format = 'rss2.0';


/**
* The XML to output.


/**
* The XML to output.

Zeile 46Zeile 46
	 */
function set_feed_format($feed_format)
{

	 */
function set_feed_format($feed_format)
{

		if($feed_format == 'rss2.0')

		if($feed_format == 'atom1.0')

		{

		{

			$this->feed_format = 'rss2.0';
}
elseif($feed_format == 'atom1.0')
{
$this->feed_format = 'atom1.0';

			$this->feed_format = 'atom1.0';





		}
else
{

		}
else
{

			$this->feed_format = 'rss0.92';

			$this->feed_format = 'rss2.0';

		}
}


		}
}


Zeile 64Zeile 60
	 * Sets the channel information for the RSS feed.
*
* @param array The channel information

	 * Sets the channel information for the RSS feed.
*
* @param array The channel information

	 */

	 */

	function set_channel($channel)

	function set_channel($channel)

	{

	{

		$this->channel = $channel;
}


		$this->channel = $channel;
}


Zeile 78Zeile 74
	function add_item($item)
{
$this->items[] = $item;

	function add_item($item)
{
$this->items[] = $item;

	}

	}



/**



/**

Zeile 92Zeile 88
		{
// Ouput an Atom 1.0 formatted feed.
case "atom1.0":

		{
// Ouput an Atom 1.0 formatted feed.
case "atom1.0":

				$this->channel['date'] = date("Y-m-d\TH:i:s O", $this->channel['date']);

				$this->channel['date'] = gmdate("Y-m-d\TH:i:s\Z", $this->channel['date']);

				$this->xml .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$this->xml .= "<feed xmlns=\"http://www.w3.org/2005/Atom\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";

				$this->xml .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$this->xml .= "<feed xmlns=\"http://www.w3.org/2005/Atom\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";

				$this->xml .= "\t<title><![CDATA[".htmlspecialchars_uni($this->channel['title'])."]]></title>\n";
$this->xml .= "\t<id>".$this->channel['link']."</id>\n";
$this->xml .= "\t<link rel=\"alternate\" type=\"text/html\" href=\"".$this->channel['link']."\"/>\n";
$this->xml .= "\t<modified>".$this->channel['date']."</modified>\n";
$this->xml .= "\t<generator uri=\"http://mybboard.com\">MyBB</generator>\n";



				$this->xml .= "\t<title type=\"html\"><![CDATA[".$this->sanitize_content($this->channel['title'])."]]></title>\n";
$this->xml .= "\t<subtitle type=\"html\"><![CDATA[".$this->sanitize_content($this->channel['description'])."]]></subtitle>\n";
$this->xml .= "\t<link rel=\"self\" href=\"{$this->channel['link']}syndication.php\"/>\n";
$this->xml .= "\t<id>{$this->channel['link']}</id>\n";
$this->xml .= "\t<link rel=\"alternate\" type=\"text/html\" href=\"{$this->channel['link']}\"/>\n";
$this->xml .= "\t<updated>{$this->channel['date']}</updated>\n";
$this->xml .= "\t<generator uri=\"http://mybboard.net\">MyBB</generator>\n";

				break;
// The default is the RSS 2.0 format.
default:
$this->channel['date'] = date("D, d M Y H:i:s O", $this->channel['date']);
$this->xml .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";

				break;
// The default is the RSS 2.0 format.
default:
$this->channel['date'] = date("D, d M Y H:i:s O", $this->channel['date']);
$this->xml .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";

				$this->xml .= "<rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\"	xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";

				$this->xml .= "<rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";

				$this->xml .= "\t<channel>\n";

				$this->xml .= "\t<channel>\n";

				$this->xml .= "\t\t<title><![CDATA[".htmlspecialchars_uni($this->channel['title'])."]]></title>\n";

				$this->xml .= "\t\t<title><![CDATA[".$this->sanitize_content($this->channel['title'])."]]></title>\n";

				$this->xml .= "\t\t<link>".$this->channel['link']."</link>\n";

				$this->xml .= "\t\t<link>".$this->channel['link']."</link>\n";

				$this->xml .= "\t\t<description>".htmlspecialchars_uni($this->channel['description'])."</description>\n";

				$this->xml .= "\t\t<description><![CDATA[".$this->sanitize_content($this->channel['description'])."]]></description>\n";

				$this->xml .= "\t\t<pubDate>".$this->channel['date']."</pubDate>\n";
$this->xml .= "\t\t<generator>MyBB</generator>\n";
}

// Now loop through all of the items and add them to the feed XML.
foreach($this->items as $item)

				$this->xml .= "\t\t<pubDate>".$this->channel['date']."</pubDate>\n";
$this->xml .= "\t\t<generator>MyBB</generator>\n";
}

// Now loop through all of the items and add them to the feed XML.
foreach($this->items as $item)

		{

		{

			if(!$item['date'])
{
$item['date'] = time();

			if(!$item['date'])
{
$item['date'] = time();

Zeile 126Zeile 124
				// Output Atom 1.0 format feed.
case "atom1.0":
$item['date'] = date("Y-m-d\TH:i:s\Z", $item['date']);

				// Output Atom 1.0 format feed.
case "atom1.0":
$item['date'] = date("Y-m-d\TH:i:s\Z", $item['date']);

					$this->xml .= "\t<entry>\n";
if($item['author'])

					$this->xml .= "\t<entry xmlns=\"http://www.w3.org/2005/Atom\">\n";
if(!empty($item['author']))

					{
$this->xml .= "\t\t<author>\n";

					{
$this->xml .= "\t\t<author>\n";

						$this->xml .= "\t\t\t<name><![CDATA[".htmlspecialchars_uni($item['author'])."]]></name>\n";

						$this->xml .= "\t\t\t<name>".$this->sanitize_content($item['author'])."</name>\n";

						$this->xml .= "\t\t</author>\n";

						$this->xml .= "\t\t</author>\n";

					}
$this->xml .= "\t\t<title type=\"text/html\" mode=\"escaped\"><![CDATA[".htmlspecialchars_uni($item['title'])."]]></title>\n";
$this->xml .= "\t\t<link rel=\"alternate\" type=\"text/html\" href=\"".$item['link']."\" />\n";
$this->xml .= "\t\t<id>".$item['link']."</id>\n";
$this->xml .= "\t\t<modified>{$item['date']}</modified>\n";
$this->xml .= "\t\t<issued>{$item['date']}</issued>\n";
$this->xml .= "\t\t<summary type=\"text/plain\" mode=\"escaped\"><![CDATA[".strip_tags($item['description'])."]]></summary>\n";
$this->xml .= "\t\t<content type=\"text/html\" mode=\"escaped\" xml:base=\"".$item['link']."\"><![CDATA[{$item['description']}]]></content>\n";









					}
$this->xml .= "\t\t<published>{$item['date']}</published>\n";
if(empty($item['updated']))
{
$item['updated'] = $item['date'];
}
else
{
$item['updated'] = date("Y-m-d\TH:i:s\Z", $item['updated']);;
}
$this->xml .= "\t\t<updated>{$item['updated']}</updated>\n";
$this->xml .= "\t\t<link rel=\"alternate\" type=\"text/html\" href=\"{$item['link']}\" />\n";
$this->xml .= "\t\t<id>{$item['link']}</id>\n";
$this->xml .= "\t\t<title type=\"html\" xml:space=\"preserve\"><![CDATA[".$this->sanitize_content($item['title'])."]]></title>\n";
$this->xml .= "\t\t<content type=\"html\" xml:space=\"preserve\" xml:base=\"{$item['link']}\"><![CDATA[".strip_tags(str_replace("]]>", "]]&gt;", $item['description']))."]]></content>\n";
$this->xml .= "\t\t<draft xmlns=\"http://purl.org/atom-blog/ns#\">false</draft>\n";

					$this->xml .= "\t</entry>\n";
break;


					$this->xml .= "\t</entry>\n";
break;


Zeile 147Zeile 153
				default:
$item['date'] = date("D, d M Y H:i:s O", $item['date']);
$this->xml .= "\t\t<item>\n";

				default:
$item['date'] = date("D, d M Y H:i:s O", $item['date']);
$this->xml .= "\t\t<item>\n";

					$this->xml .= "\t\t\t<title><![CDATA[".htmlspecialchars_uni($item['title'])."]]></title>\n";

					$this->xml .= "\t\t\t<title><![CDATA[".$this->sanitize_content($item['title'])."]]></title>\n";

					$this->xml .= "\t\t\t<link>".$item['link']."</link>\n";
$this->xml .= "\t\t\t<pubDate>".$item['date']."</pubDate>\n";
if($item['author'])
{

					$this->xml .= "\t\t\t<link>".$item['link']."</link>\n";
$this->xml .= "\t\t\t<pubDate>".$item['date']."</pubDate>\n";
if($item['author'])
{

						$this->xml .= "\t\t\t<dc:creator><![CDATA[".htmlspecialchars_uni($item['author'])."]]></dc:creator>\n";

						$this->xml .= "\t\t\t<dc:creator>".$this->sanitize_content($item['author'])."</dc:creator>\n";

					}
$this->xml .= "\t\t\t<guid isPermaLink=\"false\">".$item['link']."</guid>\n";

					}
$this->xml .= "\t\t\t<guid isPermaLink=\"false\">".$item['link']."</guid>\n";

					$this->xml .= "\t\t\t<description><![CDATA[".strip_tags($item['description'])."]]></description>\n";
$this->xml .= "\t\t\t<content:encoded><![CDATA[".$item['description']."]]></content:encoded>\n";

					$this->xml .= "\t\t\t<description><![CDATA[".nl2br(strip_tags(str_replace("]]>", "]]&gt;", $item['description'])))."]]></description>\n";
$this->xml .= "\t\t\t<content:encoded><![CDATA[".nl2br($item['description'])."]]></content:encoded>\n";

					$this->xml .= "\t\t</item>\n";
break;

					$this->xml .= "\t\t</item>\n";
break;



 
			}
}

// Now, neatly end the feed XML.
switch($this->feed_format)
{

			}
}

// Now, neatly end the feed XML.
switch($this->feed_format)
{

			case "rss2.0":
$this->xml .= "\t</channel>\n";
$this->xml .= "</rss>";
break;

 
			case "atom1.0":
$this->xml .= "</feed>";
break;

			case "atom1.0":
$this->xml .= "</feed>";
break;

Zeile 177Zeile 178
				$this->xml .= "\t</channel>\n";
$this->xml .= "</rss>";
}

				$this->xml .= "\t</channel>\n";
$this->xml .= "</rss>";
}

 
	}

/**
* Sanitize content suitable for RSS feeds.
*
* @param string The string we wish to sanitize.
* @return string The cleaned string.
*/
function sanitize_content($content)
{
$content = preg_replace("#&([^\#])(?![a-z1-4]{1,10};)#i", "&#x26;$1", $content);
$content = str_replace("]]>", "]]&gt;", $content);
return htmlspecialchars_uni($content);

	}

/**

	}

/**

Zeile 187Zeile 201
		// Send an appropriate header to the browser.
switch($this->feed_format)
{

		// Send an appropriate header to the browser.
switch($this->feed_format)
{

			case "rss2.0":
header("Content-Type: text/xml");
break;

 
			case "atom1.0":

			case "atom1.0":

				header("Content-Type: application/atom+xml");

				header("Content-Type: application/atom+xml; charset=utf-8");

				break;
default:

				break;
default:

				header("Content-Type: text/xml");

				header("Content-Type: text/xml; charset=utf-8");

		}

// Output the feed XML. If the feed hasn't been generated, do so.

		}

// Output the feed XML. If the feed hasn't been generated, do so.