Version 3.2.3

This commit is contained in:
Neo committed 2025-12-19 00:34:03 -08:00
1 parent ae5c01cc78
commit 78706903a2
2641 files changed
+228363 -201264

No files matched your search

+123 -124
View File
@@ -3,19 +3,19 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* IP.Board v3.2.3
* RSS handler: handles importing of RSS documents and exporting of RSS v2 documents
* Last Updated: $Date: 2010-04-19 18:35:00 -0400 (Mon, 19 Apr 2010) $
* Last Updated: $Date: 2011-09-29 22:09:09 -0400 (Thu, 29 Sep 2011) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @license This is NULLED!
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @link http://hatynka.in
* @since Monday 5th May 2008 14:00
* @version $Revision: 392 $
* @version $Revision: 9570 $
*
* EXAMPLE: (CREATING AN RSS FEED)
* <code>
@@ -72,12 +72,12 @@
* </code>
*/
if ( ! defined( 'IPS_CLASSES_PATH' ) )
if ( ! defined( 'IPS_KERNEL_PATH' ) )
{
/**
* Define classes path
*/
define( 'IPS_CLASSES_PATH', dirname(__FILE__) );
* Define classes path
*/
define( 'IPS_KERNEL_PATH', dirname(__FILE__) );
}
class classRss
@@ -120,89 +120,89 @@ class classRss
* @access public
* @var integer
*/
public $use_sockets = 0;
public $use_sockets = 1;
/**#@+
* Work item
*
* @access private
* @access protected
* @var integer
*/
private $in_item = 0;
private $in_image = 0;
private $in_channel = 0;
protected $in_item = 0;
protected $in_image = 0;
protected $in_channel = 0;
public $rss_count = 0;
public $rss_max_show = 3;
private $cur_item = 0;
private $cur_channel = 0;
private $set_ttl = 60;
private $tag = "";
protected $cur_item = 0;
protected $cur_channel = 0;
protected $set_ttl = 60;
protected $tag = "";
/**#@-*/
/**#@+
* RSS Items
*
* @access private
* @access protected
* @var array
*/
public $rss_items = array();
private $rss_headers = array();
private $rss_images = array();
private $rss_tag_names = array();
protected $rss_headers = array();
protected $rss_images = array();
protected $rss_tag_names = array();
/**#@-*/
/**#@+
* RSS Parse Items
*
* @access private
* @access protected
* @var string
*/
private $rss_title;
private $rss_description;
private $rss_link;
private $rss_date;
private $rss_creator;
private $rss_content;
private $rss_category;
private $rss_guid;
protected $rss_title;
protected $rss_description;
protected $rss_link;
protected $rss_date;
protected $rss_creator;
protected $rss_content;
protected $rss_category;
protected $rss_guid;
/**#@-*/
/**#@+
* RSS Parse Images
*
* @access private
* @access protected
* @var string
*/
private $rss_img_url;
private $rss_img_title;
private $rss_img_link;
private $rss_img_width;
private $rss_img_height;
private $rss_img_desc;
protected $rss_img_url;
protected $rss_img_title;
protected $rss_img_link;
protected $rss_img_width;
protected $rss_img_height;
protected $rss_img_desc;
/**#@-*/
/**#@+
* RSS Channel items
*
* @access private
* @access protected
* @var string
*/
private $rss_chan_title;
private $rss_chan_link;
private $rss_chan_desc;
private $rss_chan_date;
private $rss_chan_lang;
protected $rss_chan_title;
protected $rss_chan_link;
protected $rss_chan_desc;
protected $rss_chan_date;
protected $rss_chan_lang;
/**#@-*/
/**#@+
* Create: Channels
*
* @access private
* @access protected
* @var array
*/
private $channels = array();
private $items = array();
private $channel_images = array();
protected $channels = array();
protected $items = array();
protected $channel_images = array();
/**#@-*/
/**#@+
@@ -230,7 +230,7 @@ class classRss
* @access public
* @var integer
*/
public $convert_charset = 0;
public $convert_charset = 1;
/**
* Convert newlines
@@ -239,23 +239,7 @@ class classRss
* @var integer
*/
public $collapse_newlines = 0;
/**
* Destination charset
*
* @access public
* @var string
*/
public $destination_charset = 'UTF-8';
/**
* Feed char set
*
* @access public
* @var string
*/
public $feed_charset = 'UTF-8';
/**
* HTML decoding needed
*
@@ -268,7 +252,7 @@ class classRss
* Constructor
*
* @access public
* @return void
* @return @e void
*/
public function __construct()
{
@@ -300,7 +284,7 @@ class classRss
* Create the RSS document
*
* @access public
* @return void
* @return @e void
*/
public function createRssDocument( )
{
@@ -381,7 +365,7 @@ class classRss
$extra = ' isPermaLink="false"';
}
$tmp_data .= "\t\t<" . $tag . $extra . ">" . $this->_xmlEncodeString($data) . "</" . $tag . ">\n";
$tmp_data .= "\t\t<" . $tag . $extra . ">" . $this->_xmlEncodeString($data) . "</" . preg_replace( '#^(\S+?)(\s.*$|$)#', "\\1", $tag ) . ">\n";
}
$tmp_data .= "\t</item>\n";
@@ -441,7 +425,7 @@ class classRss
* @access public
* @param integer Channel ID
* @param array Array of image variables
* @return void
* @return @e void
*/
public function addImageToChannel( $channel_id=0, $in=array() )
{
@@ -456,7 +440,7 @@ class classRss
* @access public
* @param integer Channel ID
* @param array Array of item variables
* @return void
* @return @e void
*/
public function addItemToChannel( $channel_id=0, $in=array() )
{
@@ -516,7 +500,7 @@ class classRss
// Draw image
//-------------------------------
$img = "<img src='".$in['url']."' $title $alt $width $height />";
$img = "<img src='" . $in['url'] . "' {$title} {$alt} {$width} {$height} />";
//-------------------------------
// Linked?
@@ -524,7 +508,7 @@ class classRss
if ( $in['link'] )
{
$img = "<a href='".$in['link']."'>".$img."</a>";
$img = "<a href='" . $in['link'] . "'>" . $img . "</a>";
}
return $img;
@@ -547,7 +531,7 @@ class classRss
*
* @access public
* @param string URI
* @return void
* @return @e void
*/
public function parseFeedFromUrl( $feed_location )
{
@@ -555,7 +539,7 @@ class classRss
// Load file management class
//-----------------------------------------
require_once( IPS_CLASSES_PATH.'/classFileManagement.php' );
require_once( IPS_KERNEL_PATH.'/classFileManagement.php' );/*noLibHook*/
$this->classFileManagement = new classFileManagement();
$this->classFileManagement->use_sockets = $this->use_sockets;
@@ -583,37 +567,52 @@ class classRss
return FALSE;
}
$_foundIn = '';
if( preg_match( "#encoding=[\"'](\S+?)[\"']#si", $data, $matches ) )
{
$this->orig_doc_type = $matches[1];
$this->orig_doc_type = strtoupper($matches[1]);
$_foundIn = 'encoding';
}
if( preg_match( "#charset=(\S+?)#si", $data, $matches ) )
if( !$this->orig_doc_type AND preg_match( "#charset=(\S+?)#si", $data, $matches ) )
{
$this->orig_doc_type = $matches[1];
$this->orig_doc_type = strtoupper($matches[1]);
$_foundIn = 'charset';
}
//-----------------------------------------
// Charset conversion?
// We convert the actual content in the parse
// routines elsewhere, this causes issues
// If feed charset isn't supportd by XML lib,
// convert to UTF-8
// Edit - ALWAYS use utf-8. A wide html entity (&#8216;) is
// valid in iso-8859-1 output because it is an entity, however
// the XML library tries to convert all entities to their appropriate
// character which corrupts it.
// @link http://community.invisionpower.com/tracker/issue-33588-rss-import-character-issue
// @link http://us.php.net/manual/en/function.xml-set-character-data-handler.php#35065
//-----------------------------------------
$supported_encodings = array( "utf-8", "iso-8859-1", "us-ascii" );
$charset = in_array( strtolower($this->feed_charset), $supported_encodings ) ? $this->feed_charset : "";
$supported_encodings = array( "UTF-8"/*, "ISO-8859-1", "US-ASCII"*/ );
$charset = ( $this->orig_doc_type AND in_array( $this->orig_doc_type, $supported_encodings ) ) ? $this->orig_doc_type : "UTF-8";
/*if ( $this->convert_charset AND $data )
if ( $this->convert_charset AND $data )
{
if ( $this->feed_charset != $this->doc_type )
if ( $charset != $this->orig_doc_type )
{
$data = IPSText::convertCharsets( $data, $this->feed_charset, $this->doc_type );
$data = IPSText::convertCharsets( $data, $this->orig_doc_type, $charset );
# Replace any char-set= data
$data = preg_replace( "#encoding=[\"'](\S+?)[\"']#si", "encoding=\"".$this->doc_type."\"", $data );
$data = preg_replace( "#charset=(\S+?)#si" , "charset=".$this->doc_type , $data );
if( $_foundIn == 'encoding' )
{
$data = preg_replace( "#encoding=[\"'](\S+?)[\"']#si", "encoding=\"" . $charset . "\"", $data );
}
else
{
$data = preg_replace( "#charset=(\S+?)#si" , "charset=" . $charset, $data );
}
}
}*/
}
//-------------------------------
// Generate XML parser
//-------------------------------
@@ -643,7 +642,7 @@ class classRss
*
* @access public
* @param string Path
* @return void
* @return @e void
*/
public function parseFeedFromFile( $feed_location )
{
@@ -659,7 +658,7 @@ class classRss
*
* @access public
* @param string Raw RSS data
* @return void
* @return @e void
*/
public function parseFeedFromData( $data )
{
@@ -695,13 +694,13 @@ class classRss
/**
* Extract: Call back function for element handler
*
* @access private
* @access protected
* @param object Parser object
* @param string Tag name
* @param array Attributes
* @return void
* @return @e void
*/
private function _parseStartElement( $parser, $name, $attrs )
protected function _parseStartElement( $parser, $name, $attrs )
{
//-------------------------------
// Just in case
@@ -740,7 +739,7 @@ class classRss
$this->in_channel = 1;
}
if( array_key_exists( 'html', $attrs ) AND $attrs['html'] == 1 )
if( isset( $attrs['html'] ) AND $attrs['html'] == 1 )
{
$this->htmlDecodingNeeded = true;
}
@@ -749,12 +748,12 @@ class classRss
/**
* Extract: Call back function for element handler
*
* @access private
* @access protected
* @param object Parser object
* @param string Tag name
* @return void
* @return @e void
*/
private function _parseEndElement( $parser, $name )
protected function _parseEndElement( $parser, $name )
{
//-------------------------------
// Just in case
@@ -872,12 +871,12 @@ class classRss
/**
* Extract: Call back function for element handler
*
* @access private
* @access protected
* @param object Parser object
* @param string CDATA
* @return void
* @return @e void
*/
private function _parseCharacterData( $parser, $data )
protected function _parseCharacterData( $parser, $data )
{
//-----------------------------------------
// Decode HTML if necessary
@@ -984,11 +983,11 @@ class classRss
/**
* Internal: Encode attribute
*
* @access private
* @access protected
* @param string Raw Text
* @return string Parsed Text
*/
private function _xmlEncodeAttribute( $t )
protected function _xmlEncodeAttribute( $t )
{
$t = preg_replace("/&(?!#[0-9]+;)/s", '&amp;', $t );
$t = str_replace( "<", "&lt;" , $t );
@@ -1002,11 +1001,11 @@ class classRss
/**
* Internal: Dencode attribute
*
* @access private
* @access protected
* @param string Raw Text
* @return string Parsed Text
*/
private function _xmlDecodeAttribute( $t )
protected function _xmlDecodeAttribute( $t )
{
$t = str_replace( "&amp;" , "&", $t );
$t = str_replace( "&lt;" , "<", $t );
@@ -1020,11 +1019,11 @@ class classRss
/**
* Internal: Encode string
*
* @access private
* @access protected
* @param string Raw Text
* @return string Parsed Text
*/
private function _xmlEncodeString( $v )
protected function _xmlEncodeString( $v )
{
# Fix up encoded & " ' and any other funnky IPB data
$v = str_replace( '&amp;' , '&' , $v );
@@ -1052,11 +1051,11 @@ class classRss
/**
* Encode CDATA XML attribute (Make safe for transport)
*
* @access private
* @access protected
* @param string Raw data
* @return string Converted Data
*/
private function _xmlConvertSafeCdata( $v )
protected function _xmlConvertSafeCdata( $v )
{
# Legacy
//$v = str_replace( "<![CDATA[", "<!ᄁ|CDATA|", $v );
@@ -1072,11 +1071,11 @@ class classRss
/**
* Decode CDATA XML attribute (Make safe for transport)
*
* @access private
* @access protected
* @param string Raw data
* @return string Converted Data
*/
private function _xmlUnconvertSafeCdata( $v )
protected function _xmlUnconvertSafeCdata( $v )
{
# Legacy
$v = str_replace( "<!ᄁ|CDATA|", "<![CDATA[", $v );
@@ -1092,11 +1091,11 @@ class classRss
/**
* Format text string
*
* @access private
* @access protected
* @param string Raw data
* @return string Converted Data
*/
private function _formatString( $t )
protected function _formatString( $t )
{
return trim( $t );
}
@@ -1104,10 +1103,10 @@ class classRss
/**
* Internal: Reset arrays
*
* @access private
* @return void
* @access protected
* @return @e void
*/
private function _killElements()
protected function _killElements()
{
$this->rss_link = "";
$this->rss_title = "";
@@ -1122,10 +1121,10 @@ class classRss
/**
* Internal: Reset arrays
*
* @access private
* @return void
* @access protected
* @return @e void
*/
private function _killImageElements()
protected function _killImageElements()
{
$this->rss_img_image = "";
$this->rss_img_title = "";
@@ -1138,10 +1137,10 @@ class classRss
/**
* Internal: Reset arrays
*
* @access private
* @return void
* @access protected
* @return @e void
*/
private function _killChannelElements()
protected function _killChannelElements()
{
$this->rss_chan_title = "";
$this->rss_chan_link = "";