Version 3.1.4
This commit is contained in:
1 parent
1d4720f3e2
commit
ae5c01cc78
2563 files changed
+283048
-240689
No files matched your search
+260
-236
@@ -1,18 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.0.5
|
||||
* IP.Board v3.1.4
|
||||
* RSS handler: handles importing of RSS documents and exporting of RSS v2 documents
|
||||
* Last Updated: $Date: 2009-08-17 20:55:40 -0400 (Mon, 17 Aug 2009) $
|
||||
* Last Updated: $Date: 2010-04-19 18:35:00 -0400 (Mon, 19 Apr 2010) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: bfarber $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.iinvisionpower.com/community/board/license.html
|
||||
* @package Invision Power Services Kernel
|
||||
* @link http://www.iinvisionpower.com
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @package IP.Board
|
||||
* @subpackage Kernel
|
||||
* @link http://www.invisionpower.com
|
||||
* @since Monday 5th May 2008 14:00
|
||||
* @version $Revision: 314 $
|
||||
* @version $Revision: 392 $
|
||||
*
|
||||
* EXAMPLE: (CREATING AN RSS FEED)
|
||||
* <code>
|
||||
@@ -80,51 +83,51 @@ if ( ! defined( 'IPS_CLASSES_PATH' ) )
|
||||
class classRss
|
||||
{
|
||||
/**
|
||||
* Class file management object
|
||||
*
|
||||
* @access public
|
||||
* @var object
|
||||
*/
|
||||
* Class file management object
|
||||
*
|
||||
* @access public
|
||||
* @var classFileManagement
|
||||
*/
|
||||
public $classFileManagement;
|
||||
|
||||
/**
|
||||
* DOC type
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
* DOC type
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $doc_type = 'UTF-8';
|
||||
|
||||
/**
|
||||
* Original DOC type
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
* Original DOC type
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $orig_doc_type = "";
|
||||
|
||||
/**
|
||||
* Error capture
|
||||
*
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
* Error capture
|
||||
*
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public $errors = array();
|
||||
|
||||
/**
|
||||
* Use sockets flag
|
||||
*
|
||||
* @access public
|
||||
* @var integer
|
||||
*/
|
||||
* Use sockets flag
|
||||
*
|
||||
* @access public
|
||||
* @var integer
|
||||
*/
|
||||
public $use_sockets = 0;
|
||||
|
||||
/**#@+
|
||||
* Work item
|
||||
*
|
||||
* @access private
|
||||
* @var integer
|
||||
*/
|
||||
* Work item
|
||||
*
|
||||
* @access private
|
||||
* @var integer
|
||||
*/
|
||||
private $in_item = 0;
|
||||
private $in_image = 0;
|
||||
private $in_channel = 0;
|
||||
@@ -137,11 +140,11 @@ class classRss
|
||||
/**#@-*/
|
||||
|
||||
/**#@+
|
||||
* RSS Items
|
||||
*
|
||||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
* RSS Items
|
||||
*
|
||||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
public $rss_items = array();
|
||||
private $rss_headers = array();
|
||||
private $rss_images = array();
|
||||
@@ -149,11 +152,11 @@ class classRss
|
||||
/**#@-*/
|
||||
|
||||
/**#@+
|
||||
* RSS Parse Items
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
* RSS Parse Items
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $rss_title;
|
||||
private $rss_description;
|
||||
private $rss_link;
|
||||
@@ -165,11 +168,11 @@ class classRss
|
||||
/**#@-*/
|
||||
|
||||
/**#@+
|
||||
* RSS Parse Images
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
* RSS Parse Images
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $rss_img_url;
|
||||
private $rss_img_title;
|
||||
private $rss_img_link;
|
||||
@@ -179,11 +182,11 @@ class classRss
|
||||
/**#@-*/
|
||||
|
||||
/**#@+
|
||||
* RSS Channel items
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
* RSS Channel items
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $rss_chan_title;
|
||||
private $rss_chan_link;
|
||||
private $rss_chan_desc;
|
||||
@@ -192,73 +195,81 @@ class classRss
|
||||
/**#@-*/
|
||||
|
||||
/**#@+
|
||||
* Create: Channels
|
||||
*
|
||||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
* Create: Channels
|
||||
*
|
||||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
private $channels = array();
|
||||
private $items = array();
|
||||
private $channel_images = array();
|
||||
/**#@-*/
|
||||
|
||||
/**#@+
|
||||
* Set Authentication
|
||||
*
|
||||
* @access public
|
||||
* @var strings
|
||||
*/
|
||||
* Set Authentication
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $auth_req = 0;
|
||||
public $auth_user;
|
||||
public $auth_pass;
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* Final RSS Document
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
* Final RSS Document
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $rss_document = '';
|
||||
|
||||
/**
|
||||
* Convert char set
|
||||
*
|
||||
* @access public
|
||||
* @var integer
|
||||
*/
|
||||
* Convert char set
|
||||
*
|
||||
* @access public
|
||||
* @var integer
|
||||
*/
|
||||
public $convert_charset = 0;
|
||||
|
||||
/**
|
||||
* Convert newlines
|
||||
*
|
||||
* @access public
|
||||
* @var integer
|
||||
*/
|
||||
* Convert newlines
|
||||
*
|
||||
* @access public
|
||||
* @var integer
|
||||
*/
|
||||
public $collapse_newlines = 0;
|
||||
|
||||
/**
|
||||
* Destination charset
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
* Destination charset
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $destination_charset = 'UTF-8';
|
||||
|
||||
/**
|
||||
* Feed char set
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
* Feed char set
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $feed_charset = 'UTF-8';
|
||||
|
||||
/**
|
||||
* HTML decoding needed
|
||||
*
|
||||
* @access protected
|
||||
* @var bool
|
||||
*/
|
||||
protected $htmlDecodingNeeded = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->rss_tag_names = array( 'ITEM' => 'ITEM',
|
||||
@@ -286,11 +297,11 @@ class classRss
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the RSS document
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
* Create the RSS document
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function createRssDocument( )
|
||||
{
|
||||
if ( ! count( $this->channels ) )
|
||||
@@ -398,15 +409,15 @@ class classRss
|
||||
}
|
||||
|
||||
/**
|
||||
* Create RSS 2.0 document: Add channel
|
||||
*
|
||||
* title, link, description,language,pubDate,lastBuildDate,docs,generator
|
||||
* managingEditor,webMaster
|
||||
*
|
||||
* @access public
|
||||
* @param array Data to add
|
||||
* @return integer New channel ID
|
||||
*/
|
||||
* Create RSS 2.0 document: Add channel
|
||||
*
|
||||
* title, link, description,language,pubDate,lastBuildDate,docs,generator
|
||||
* managingEditor,webMaster
|
||||
*
|
||||
* @access public
|
||||
* @param array Data to add
|
||||
* @return integer New channel ID
|
||||
*/
|
||||
public function createNewChannel( $in=array() )
|
||||
{
|
||||
$this->channels[ $this->cur_channel ] = $in;
|
||||
@@ -423,42 +434,42 @@ class classRss
|
||||
}
|
||||
|
||||
/**
|
||||
* Create RSS 2.0 document: Add channel image item
|
||||
*
|
||||
* url, link, title, width, height, description
|
||||
*
|
||||
* @access public
|
||||
* @param integer Channel ID
|
||||
* @param array Array of image variables
|
||||
* @return void
|
||||
*/
|
||||
* Create RSS 2.0 document: Add channel image item
|
||||
*
|
||||
* url, link, title, width, height, description
|
||||
*
|
||||
* @access public
|
||||
* @param integer Channel ID
|
||||
* @param array Array of image variables
|
||||
* @return void
|
||||
*/
|
||||
public function addImageToChannel( $channel_id=0, $in=array() )
|
||||
{
|
||||
$this->channel_images[ $channel_id ][] = $in;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create RSS 2.0 document: Add item
|
||||
*
|
||||
* title,description,pubDate,guid,content,category,link
|
||||
*
|
||||
* @access public
|
||||
* @param integer Channel ID
|
||||
* @param array Array of item variables
|
||||
* @return void
|
||||
*/
|
||||
* Create RSS 2.0 document: Add item
|
||||
*
|
||||
* title,description,pubDate,guid,content,category,link
|
||||
*
|
||||
* @access public
|
||||
* @param integer Channel ID
|
||||
* @param array Array of item variables
|
||||
* @return void
|
||||
*/
|
||||
public function addItemToChannel( $channel_id=0, $in=array() )
|
||||
{
|
||||
$this->items[ $channel_id ][] = $in;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create RSS 2.0 document: Format Image
|
||||
*
|
||||
* @access public
|
||||
* @param array Array of item variables
|
||||
* @return string Image HTML
|
||||
*/
|
||||
* Create RSS 2.0 document: Format Image
|
||||
*
|
||||
* @access public
|
||||
* @param array Array of item variables
|
||||
* @return string Image HTML
|
||||
*/
|
||||
public function formatImage( $in=array() )
|
||||
{
|
||||
if ( ! $in['url'] )
|
||||
@@ -520,24 +531,24 @@ class classRss
|
||||
}
|
||||
|
||||
/**
|
||||
* Create RSS 2.0 document: Format unixdate to rfc date
|
||||
*
|
||||
* @access public
|
||||
* @param integer Unix timestamp
|
||||
* @return string Formatted date RFC date
|
||||
*/
|
||||
* Create RSS 2.0 document: Format unixdate to rfc date
|
||||
*
|
||||
* @access public
|
||||
* @param integer Unix timestamp
|
||||
* @return string Formatted date RFC date
|
||||
*/
|
||||
public function formatDate( $time )
|
||||
{
|
||||
return date( 'r', $time );
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract: Parse RSS document from URL
|
||||
*
|
||||
* @access public
|
||||
* @param string URI
|
||||
* @return void
|
||||
*/
|
||||
* Extract: Parse RSS document from URL
|
||||
*
|
||||
* @access public
|
||||
* @param string URI
|
||||
* @return void
|
||||
*/
|
||||
public function parseFeedFromUrl( $feed_location )
|
||||
{
|
||||
//-----------------------------------------
|
||||
@@ -569,7 +580,6 @@ class classRss
|
||||
if ( count( $this->classFileManagement->errors ) )
|
||||
{
|
||||
$this->errors = $this->classFileManagement->errors;
|
||||
@xml_parser_free($xml_parser); // Let's kill the parser before we return
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -629,12 +639,12 @@ class classRss
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract: Parse RSS document from file
|
||||
*
|
||||
* @access public
|
||||
* @param string Path
|
||||
* @return void
|
||||
*/
|
||||
* Extract: Parse RSS document from file
|
||||
*
|
||||
* @access public
|
||||
* @param string Path
|
||||
* @return void
|
||||
*/
|
||||
public function parseFeedFromFile( $feed_location )
|
||||
{
|
||||
//-------------------------------
|
||||
@@ -645,12 +655,12 @@ class classRss
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract: Parse RSS document from data
|
||||
*
|
||||
* @access public
|
||||
* @param string Raw RSS data
|
||||
* @return void
|
||||
*/
|
||||
* Extract: Parse RSS document from data
|
||||
*
|
||||
* @access public
|
||||
* @param string Raw RSS data
|
||||
* @return void
|
||||
*/
|
||||
public function parseFeedFromData( $data )
|
||||
{
|
||||
//-------------------------------
|
||||
@@ -683,14 +693,14 @@ class classRss
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract: Call back function for element handler
|
||||
*
|
||||
* @access private
|
||||
* @param object Parser object
|
||||
* @param string Tag name
|
||||
* @param array Attributes
|
||||
* @return void
|
||||
*/
|
||||
* Extract: Call back function for element handler
|
||||
*
|
||||
* @access private
|
||||
* @param object Parser object
|
||||
* @param string Tag name
|
||||
* @param array Attributes
|
||||
* @return void
|
||||
*/
|
||||
private function _parseStartElement( $parser, $name, $attrs )
|
||||
{
|
||||
//-------------------------------
|
||||
@@ -729,16 +739,21 @@ class classRss
|
||||
{
|
||||
$this->in_channel = 1;
|
||||
}
|
||||
|
||||
if( array_key_exists( 'html', $attrs ) AND $attrs['html'] == 1 )
|
||||
{
|
||||
$this->htmlDecodingNeeded = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract: Call back function for element handler
|
||||
*
|
||||
* @access private
|
||||
* @param object Parser object
|
||||
* @param string Tag name
|
||||
* @return void
|
||||
*/
|
||||
* Extract: Call back function for element handler
|
||||
*
|
||||
* @access private
|
||||
* @param object Parser object
|
||||
* @param string Tag name
|
||||
* @return void
|
||||
*/
|
||||
private function _parseEndElement( $parser, $name )
|
||||
{
|
||||
//-------------------------------
|
||||
@@ -834,8 +849,8 @@ class classRss
|
||||
$this->_killElements();
|
||||
$this->in_item = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( $this->in_channel )
|
||||
{
|
||||
$this->in_channel--;
|
||||
@@ -850,18 +865,29 @@ class classRss
|
||||
{
|
||||
$this->in_image--;
|
||||
}
|
||||
|
||||
$this->htmlDecodingNeeded = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract: Call back function for element handler
|
||||
*
|
||||
* @access private
|
||||
* @param object Parser object
|
||||
* @param string CDATA
|
||||
* @return void
|
||||
*/
|
||||
* Extract: Call back function for element handler
|
||||
*
|
||||
* @access private
|
||||
* @param object Parser object
|
||||
* @param string CDATA
|
||||
* @return void
|
||||
*/
|
||||
private function _parseCharacterData( $parser, $data )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Decode HTML if necessary
|
||||
//-----------------------------------------
|
||||
|
||||
//if( $this->htmlDecodingNeeded )
|
||||
//{
|
||||
// $data = html_entity_decode( $data, ENT_QUOTES );
|
||||
//}
|
||||
|
||||
if ( $this->in_image == 2 )
|
||||
{
|
||||
switch ($this->tag)
|
||||
@@ -956,12 +982,12 @@ class classRss
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal: Encode attribute
|
||||
*
|
||||
* @access private
|
||||
* @param string Raw Text
|
||||
* @return string Parsed Text
|
||||
*/
|
||||
* Internal: Encode attribute
|
||||
*
|
||||
* @access private
|
||||
* @param string Raw Text
|
||||
* @return string Parsed Text
|
||||
*/
|
||||
private function _xmlEncodeAttribute( $t )
|
||||
{
|
||||
$t = preg_replace("/&(?!#[0-9]+;)/s", '&', $t );
|
||||
@@ -974,12 +1000,12 @@ class classRss
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal: Dencode attribute
|
||||
*
|
||||
* @access private
|
||||
* @param string Raw Text
|
||||
* @return string Parsed Text
|
||||
*/
|
||||
* Internal: Dencode attribute
|
||||
*
|
||||
* @access private
|
||||
* @param string Raw Text
|
||||
* @return string Parsed Text
|
||||
*/
|
||||
private function _xmlDecodeAttribute( $t )
|
||||
{
|
||||
$t = str_replace( "&" , "&", $t );
|
||||
@@ -992,12 +1018,12 @@ class classRss
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal: Encode string
|
||||
*
|
||||
* @access private
|
||||
* @param string Raw Text
|
||||
* @return string Parsed Text
|
||||
*/
|
||||
* Internal: Encode string
|
||||
*
|
||||
* @access private
|
||||
* @param string Raw Text
|
||||
* @return string Parsed Text
|
||||
*/
|
||||
private function _xmlEncodeString( $v )
|
||||
{
|
||||
# Fix up encoded & " ' and any other funnky IPB data
|
||||
@@ -1024,12 +1050,12 @@ class classRss
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode CDATA XML attribute (Make safe for transport)
|
||||
*
|
||||
* @access private
|
||||
* @param string Raw data
|
||||
* @return string Converted Data
|
||||
*/
|
||||
* Encode CDATA XML attribute (Make safe for transport)
|
||||
*
|
||||
* @access private
|
||||
* @param string Raw data
|
||||
* @return string Converted Data
|
||||
*/
|
||||
private function _xmlConvertSafeCdata( $v )
|
||||
{
|
||||
# Legacy
|
||||
@@ -1044,12 +1070,12 @@ class classRss
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode CDATA XML attribute (Make safe for transport)
|
||||
*
|
||||
* @access private
|
||||
* @param string Raw data
|
||||
* @return string Converted Data
|
||||
*/
|
||||
* Decode CDATA XML attribute (Make safe for transport)
|
||||
*
|
||||
* @access private
|
||||
* @param string Raw data
|
||||
* @return string Converted Data
|
||||
*/
|
||||
private function _xmlUnconvertSafeCdata( $v )
|
||||
{
|
||||
# Legacy
|
||||
@@ -1064,23 +1090,23 @@ class classRss
|
||||
}
|
||||
|
||||
/**
|
||||
* Format text string
|
||||
*
|
||||
* @access private
|
||||
* @param string Raw data
|
||||
* @return string Converted Data
|
||||
*/
|
||||
* Format text string
|
||||
*
|
||||
* @access private
|
||||
* @param string Raw data
|
||||
* @return string Converted Data
|
||||
*/
|
||||
private function _formatString( $t )
|
||||
{
|
||||
return trim( $t );
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal: Reset arrays
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
* Internal: Reset arrays
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
private function _killElements()
|
||||
{
|
||||
$this->rss_link = "";
|
||||
@@ -1094,11 +1120,11 @@ class classRss
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal: Reset arrays
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
* Internal: Reset arrays
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
private function _killImageElements()
|
||||
{
|
||||
$this->rss_img_image = "";
|
||||
@@ -1110,11 +1136,11 @@ class classRss
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal: Reset arrays
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
* Internal: Reset arrays
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
private function _killChannelElements()
|
||||
{
|
||||
$this->rss_chan_title = "";
|
||||
@@ -1123,6 +1149,4 @@ class classRss
|
||||
$this->rss_chan_date = "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
||||
Reference in new issue
Block a user