Version 3.3.4

This commit is contained in:
Neo committed 2025-12-19 00:35:52 -08:00
1 parent 78706903a2
commit fb6b5baabc
2206 files changed
+409828 -382984

No files matched your search

+331 -336
View File
@@ -1,337 +1,332 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Editor Library: Gateway
* Last Updated: $Date: 2011-05-05 07:03:47 -0400 (Thu, 05 May 2011) $
* </pre>
*
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @link http://hatynka.in
* @since 9th March 2005 11:03
* @version $Revision: 8644 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class hanEditor
{
/**
* Editor reference
*
* @var object
*/
public $class_editor;
/**
* Editing method (rte|std)
*
* @var string
*/
public $method = '';
/**
* RTE enabled?
*
* @var boolean
*/
public $rte_on = false;
/**
* Images directory (for acp)
*
* @var string
*/
public $image_dir = '';
/**
* Emoticons directory (for acp)
*
* @var string
*/
public $emo_dir = '';
/**
* Current editor id
*
* @var string
*/
public $editor_id = 'ed-0';
/**
* Remove emoticons from editor
*
* @var boolean
*/
public $remove_emoticons = false;
/**
* ACP editor id
*
* @var integer
*/
public $acp_editor_id = 0;
/**#@+
* Registry objects
*
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Constructor
*
* @param object $registry Registry object
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
/* Make object */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
}
/**
* Init method
*
* @param object Registry object
* @return @e void
*/
public function init()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$class = "";
if ( ! $this->settings['posting_allow_rte'] )
{
$this->member->setProperty( 'members_editor_choice', 'std' );
}
if ( ! $this->method )
{
$this->method = $this->memberData['members_editor_choice'];
}
//-----------------------------------------
// Make sure we haven't had any messin'
//-----------------------------------------
if ( isset( $_POST['editor_ids'] ) AND is_array( $_POST['editor_ids'] ) )
{
foreach( $_POST['editor_ids'] as $k => $v )
{
if ( isset($_POST[ $v . '_wysiwyg_used']) AND intval($_POST[ $v . '_wysiwyg_used']) == 1)
{
$this->method = 'rte';
}
else
{
$this->method = 'std';
}
}
}
if ( isset($_POST['ed-0_wysiwyg_used']) AND intval($_POST['ed-0_wysiwyg_used']) == 1 )
{
$this->method = 'rte';
}
//-----------------------------------------
// Force STD editor.. if needed
//-----------------------------------------
if ( ( isset($_POST['std_used']) AND intval($_POST['std_used']) ) )
{
$this->method = 'std';
}
//-----------------------------------------
// Which class
//-----------------------------------------
switch( $this->method )
{
case 'rte':
$class = 'class_editor_rte.php';
$this->rte_on = 1;
break;
case 'std':
$class = 'class_editor_std.php';
$this->rte_on = 0;
break;
default:
$class = 'class_editor_std.php';
$this->rte_on = 0;
}
//-----------------------------------------
// Load classes
//-----------------------------------------
require_once( IPS_ROOT_PATH . 'sources/classes/editor/class_editor.php' );/*noLibHook*/
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/' . $class, 'class_editor_module' );
$this->class_editor = new $classToLoad( $this->registry );
$this->class_editor->allow_unicode = IPS_ALLOW_UNICODE;
$this->class_editor->get_magic_quotes = IPS_MAGIC_QUOTES;
//-----------------------------------------
// Load lang file
//-----------------------------------------
ipsRegistry::getClass( 'class_localization')->loadLanguageFile( array( 'public_editors' ), 'core' );
//-----------------------------------------
// Init class
//-----------------------------------------
$this->class_editor->editorInit();
//-----------------------------------------
// Load skin and language
//-----------------------------------------
if ( IN_ACP )
{
$image_set = $this->DB->buildAndFetch( array( 'select' => 'set_image_dir, set_emo_dir', 'from' => 'skin_collections', 'where' => 'set_is_default=1' ) );
$this->image_dir = $image_set['set_image_dir'];
$this->emo_dir = $image_set['set_emo_dir'];
//-----------------------------------------
// Remove side panel
//-----------------------------------------
$this->remove_emoticons = true;
}
else
{
$this->emo_dir = ipsRegistry::getClass('output')->skin['set_emo_dir'];
}
}
/**
* Show the editor
*
* @param string Raw text with bbcode
* @param string Form field name
* @return string Editor HTML
*/
public function showEditor( $text, $form_field='post_content' )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$smilies = IPSLib::fetchEmoticonsAsJson( $this->emo_dir );
$total = 0;
$count = 0;
$smilie_id = 0;
//-----------------------------------------
// Load skin and language
//-----------------------------------------
//if ( IN_ACP )
//{
//-----------------------------------------
// Sort out editor id
//-----------------------------------------
$this->editor_id = 'ed-'.$this->acp_editor_id;
$this->acp_editor_id++;
//}
//-----------------------------------------
// Emoticons
//-----------------------------------------
$this->settings['_remove_emoticons'] = $this->remove_emoticons;
//-----------------------------------------
// Pre parse...
//-----------------------------------------
$text = $this->class_editor->processBeforeForm( $text );
//-----------------------------------------
// Weird script tag stuff...
//-----------------------------------------
if( $this->method == 'rte' )
{
$text = preg_replace( '#(<|&lt;|&amp;lt;|&\#60;)script#si', "&amp;lt;script", $text );
}
//-----------------------------------------
// Comment
//-----------------------------------------
if ( IN_ACP )
{
$return_html = $this->registry->getClass('output')->global_template->ips_editor( $form_field, $text, $this->settings['img_url'].'/folder_editor_images/', $this->rte_on, $this->editor_id, $smilies );
$return_html = preg_replace( '#([^/\.])js/#is', "\\1".$this->settings['board_url'] . '/' . PUBLIC_DIRECTORY . "/js/" , $return_html );
$return_html = str_replace( "<#IMG_DIR#>" , $this->settings['board_url'] . '/' . PUBLIC_DIRECTORY . "/style_images/{$this->image_dir}", $return_html );
}
else
{
$return_html = $this->registry->getClass('output')->getTemplate('editors')->ips_editor( $form_field, $text, $this->settings['img_url'].'/folder_editor_images/', $this->rte_on, $this->editor_id, $smilies );
}
return $return_html;
}
/**
* Retrieve the posted contents from the editor
*
* @param string Form field name OR raw text
* @param boolean Is definitely full text and not a field name
* @return string Editor HTML
*/
public function processRawPost( $form_field, $isDefinitelyFullText=false )
{
return $this->class_editor->processAfterForm( $form_field, $isDefinitelyFullText );
}
/**
* Runs through processBeforeForm
*
* @param string Raw text
* @return string Processed text
*/
public function unProcessRawPost( $text )
{
return $this->class_editor->processBeforeForm( $text );
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Editor Library: Gateway
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 10914 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class hanEditor
{
/**
* Editor reference
*
* @var object
*/
public $class_editor;
/**
* Editing method (rte|std)
*
* @var string
*/
public $method = '';
/**
* RTE enabled?
*
* @var boolean
*/
public $rte_on = false;
/**
* Images directory (for acp)
*
* @var string
*/
public $image_dir = '';
/**
* Emoticons directory (for acp)
*
* @var string
*/
public $emo_dir = '';
/**
* Current editor id
*
* @var string
*/
public $editor_id = 'ed-0';
/**
* Remove emoticons from editor
*
* @var boolean
*/
public $remove_emoticons = false;
/**
* ACP editor id
*
* @var integer
*/
public $acp_editor_id = 0;
/**#@+
* Registry objects
*
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Constructor
*
* @param object $registry Registry object
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
/* Make object */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
}
/**
* Init method
*
* @param object Registry object
* @return @e void
*/
public function init()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$class = "";
if ( ! $this->method )
{
$this->method = 'rte';
}
//-----------------------------------------
// Make sure we haven't had any messin'
//-----------------------------------------
if ( isset( $_POST['editor_ids'] ) AND is_array( $_POST['editor_ids'] ) )
{
foreach( $_POST['editor_ids'] as $k => $v )
{
if ( isset($_POST[ $v . '_wysiwyg_used']) AND intval($_POST[ $v . '_wysiwyg_used']) == 1)
{
$this->method = 'rte';
}
else
{
$this->method = 'std';
}
}
}
if ( isset($_POST['ed-0_wysiwyg_used']) AND intval($_POST['ed-0_wysiwyg_used']) == 1 )
{
$this->method = 'rte';
}
//-----------------------------------------
// Force STD editor.. if needed
//-----------------------------------------
if ( ( isset($_POST['std_used']) AND intval($_POST['std_used']) ) )
{
$this->method = 'std';
}
//-----------------------------------------
// Which class
//-----------------------------------------
switch( $this->method )
{
case 'rte':
$class = 'class_editor_rte.php';
$this->rte_on = 1;
break;
case 'std':
$class = 'class_editor_std.php';
$this->rte_on = 0;
break;
default:
$class = 'class_editor_std.php';
$this->rte_on = 0;
}
//-----------------------------------------
// Load classes
//-----------------------------------------
require_once( IPS_ROOT_PATH . 'sources/classes/editor/class_editor.php' );/*noLibHook*/
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/' . $class, 'class_editor_module' );
$this->class_editor = new $classToLoad( $this->registry );
$this->class_editor->allow_unicode = IPS_ALLOW_UNICODE;
$this->class_editor->get_magic_quotes = IPS_MAGIC_QUOTES;
//-----------------------------------------
// Load lang file
//-----------------------------------------
ipsRegistry::getClass( 'class_localization')->loadLanguageFile( array( 'public_editors' ), 'core' );
//-----------------------------------------
// Init class
//-----------------------------------------
$this->class_editor->editorInit();
//-----------------------------------------
// Load skin and language
//-----------------------------------------
if ( IN_ACP )
{
$image_set = $this->DB->buildAndFetch( array( 'select' => 'set_image_dir, set_emo_dir', 'from' => 'skin_collections', 'where' => 'set_is_default=1' ) );
$this->image_dir = $image_set['set_image_dir'];
$this->emo_dir = $image_set['set_emo_dir'];
//-----------------------------------------
// Remove side panel
//-----------------------------------------
$this->remove_emoticons = true;
}
else
{
$this->emo_dir = ipsRegistry::getClass('output')->skin['set_emo_dir'];
}
}
/**
* Show the editor
*
* @param string Raw text with bbcode
* @param string Form field name
* @return string Editor HTML
*/
public function showEditor( $text, $form_field='post_content' )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$smilies = IPSLib::fetchEmoticonsAsJson( $this->emo_dir );
$total = 0;
$count = 0;
$smilie_id = 0;
//-----------------------------------------
// Load skin and language
//-----------------------------------------
//if ( IN_ACP )
//{
//-----------------------------------------
// Sort out editor id
//-----------------------------------------
$this->editor_id = 'ed-'.$this->acp_editor_id;
$this->acp_editor_id++;
//}
//-----------------------------------------
// Emoticons
//-----------------------------------------
$this->settings['_remove_emoticons'] = $this->remove_emoticons;
//-----------------------------------------
// Pre parse...
//-----------------------------------------
$text = $this->class_editor->processBeforeForm( $text );
//-----------------------------------------
// Weird script tag stuff...
//-----------------------------------------
if( $this->method == 'rte' )
{
$text = preg_replace( '#(<|&lt;|&amp;lt;|&\#60;)script#si', "&amp;lt;script", $text );
}
//-----------------------------------------
// Comment
//-----------------------------------------
if ( IN_ACP )
{
$return_html = $this->registry->getClass('output')->global_template->ips_editor( $form_field, $text, $this->settings['img_url'].'/folder_editor_images/', $this->rte_on, $this->editor_id, $smilies );
$return_html = preg_replace( '#([^/\.])js/#is', "\\1".$this->settings['board_url'] . '/' . PUBLIC_DIRECTORY . "/js/" , $return_html );
$return_html = str_replace( "<#IMG_DIR#>" , $this->settings['board_url'] . '/' . PUBLIC_DIRECTORY . "/style_images/{$this->image_dir}", $return_html );
}
else
{
$return_html = $this->registry->getClass('output')->getTemplate('editors')->ips_editor( $form_field, $text, $this->settings['img_url'].'/folder_editor_images/', $this->rte_on, $this->editor_id, $smilies );
}
return $return_html;
}
/**
* Retrieve the posted contents from the editor
*
* @param string Form field name OR raw text
* @param boolean Is definitely full text and not a field name
* @return string Editor HTML
*/
public function processRawPost( $form_field, $isDefinitelyFullText=false )
{
return $this->class_editor->processAfterForm( $form_field, $isDefinitelyFullText );
}
/**
* Runs through processBeforeForm
*
* @param string Raw text
* @return string Processed text
*/
public function unProcessRawPost( $text )
{
return $this->class_editor->processBeforeForm( $text );
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+506 -474
View File
@@ -1,475 +1,507 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* BBCode parsing gateway.
* Last Updated: $Date: 2011-06-07 18:56:57 -0400 (Tue, 07 Jun 2011) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @link http://hatynka.in
* @since 9th March 2005 11:03
* @version $Revision: 8999 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
exit();
}
class parseBbcode
{
/**
* Registry Object Shortcuts
*
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**
* Allowed to update the caches if not present
*
* @var boolean
*/
public $allow_update_caches = true;
/**
* Parse emoticons?
*
* @var boolean
*/
public $parse_smilies = true;
/**
* Parse HTML?
* HIGHLY NOT RECOMMENDED IN MOST CASES
*
* @var boolean
*/
public $parse_html = false;
/**
* Parse bbcode?
*
* @var boolean
*/
public $parse_bbcode = true;
/**
* Strip quotes?
* Strips quotes from the resulting text
*
* @var boolean
*/
public $strip_quotes = false;
/**
* Auto convert newlines to html line breaks
*
* @var boolean
*/
public $parse_nl2br = true;
/**
* Bypass badwords?
*
* @var boolean
*/
public $bypass_badwords = false;
/**
* Section keyword for parsing area
*
* @var string
*/
public $parsing_section = 'post';
/**
* Group id of poster
*
* @var int
*/
public $parsing_mgroup = 0;
/**
* Value of mgroup_others for poster
*
* @var string
*/
public $parsing_mgroup_others = '';
/**
* Error code stored
*
* @var string
*/
public $error = '';
/**
* Warning code stored
*
* @var string
*/
public $warning = '';
/**
* BBCode library object
*
* @var object
*/
protected $bbclass;
/**
* Already loaded the classes?
*
* @var boolean
*/
protected $classes_loaded = false;
/**
* Constructor
*
* @param object Registry object
* @param string Parsing method to use
* @return @e void
*/
public function __construct( ipsRegistry $registry, $method='normal' )
{
/* Make object */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
$this->pre_edit_parse_method = $method;
/* Initialize our bbcode class */
$this->_loadClasses();
/* And some default properties */
$this->bypass_badwords = $this->memberData ? intval( $this->memberData['g_bypass_badwords'] ) : 0;
$this->strip_quotes = $this->settings['strip_quotes'];
}
/**
* Load the required bbcode classes and initialize the object
*
* @return @e void
*/
protected function _loadClasses()
{
$_NOW = IPSDebug::getMemoryDebugFlag();
if ( ! $this->classes_loaded )
{
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/bbcode/core.php', 'class_bbcode_core' );
if( $this->pre_edit_parse_method == 'legacy' )
{
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/bbcode/legacy.php', 'class_bbcode_legacy' );
}
$this->bbclass = new $classToLoad( $this->registry );
$this->classes_loaded = true;
$this->error =& $this->bbclass->error;
$this->warning =& $this->bbclass->warning;
}
IPSDebug::setMemoryDebugFlag( "BBCode classes loaded", $_NOW );
}
/**
* Pass off our settings to our bbcode handler
*
* @return @e void
*/
protected function _passSettings()
{
/* Clean out secondary groups just in case of ,, */
$this->parsing_mgroup_others = IPSText::cleanPermString( $this->parsing_mgroup_others );
//-----------------------------------------
// Pass the settings
//-----------------------------------------
$this->cache->updateCacheWithoutSaving( '_tmp_section', $this->parsing_section );
$this->bbclass->bypass_badwords = $this->bypass_badwords;
$this->bbclass->parse_smilies = $this->parse_smilies;
$this->bbclass->parse_html = $this->parse_html;
$this->bbclass->parse_bbcode = $this->parse_bbcode;
$this->bbclass->strip_quotes = $this->strip_quotes;
$this->bbclass->parse_nl2br = $this->parse_nl2br;
$this->bbclass->parsing_section = $this->parsing_section;
$this->bbclass->parsing_mgroup = $this->parsing_mgroup;
$this->bbclass->parsing_mgroup_others = $this->parsing_mgroup_others;
$this->bbclass->initOurBbcodes();
}
/**
* Parses the bbcode to be stored into the database.
* If all bbcodes are parse on display, this method does nothing really
*
* @param string Raw input text to parse
* @return string Parsed text ready to be stored in database
*/
public function preDbParse( $text )
{
$this->_passSettings();
//-----------------------------------------
// Pass off to the main handler
//-----------------------------------------
return $this->bbclass->preDbParse( trim($text) );
}
/**
* Parses the bbcode to be shown in the STD editor.
* If all bbcodes are parse on display, this method does nothing really
*
* @param string Raw input text to parse
* @return string Parsed text ready to be stored in database
*/
public function preEditParse( $text )
{
$this->_passSettings();
//-----------------------------------------
// Parse
//-----------------------------------------
return $this->bbclass->preEditParse( $text );
}
/**
* Parses the bbcode to be shown in the browser. Expects preDbParse has already been done before the save.
* If all bbcodes are parse on save, this method does nothing really
*
* @param string Raw input text to parse
* @return string Parsed text ready to be displayed
*/
public function preDisplayParse( $text )
{
$_NOW = IPSDebug::getMemoryDebugFlag();
$this->_passSettings();
//-----------------------------------------
// Parse
//-----------------------------------------
$text = $this->bbclass->preDisplayParse( $text );
IPSDebug::setMemoryDebugFlag( "PreDisplayParse completed", $_NOW );
return $text;
}
/**
* Parses the bbcode to be shown in the polls.
* Parses img and url, if enabled
*
* @param string Raw input text to parse
* @return string Parsed text ready to be displayed
*/
public function parsePollTags( $text )
{
$text = $this->bbclass->parseBbcode( $text, 'display', array( 'img', 'url' ) );
$text = $this->bbclass->finishNonParsed( $text, 'display' );
return $text;
}
/**
* Converts the STD contents to RTE compatible output
* Used when switching editors or taking the bbcode post and putting into the RTE
*
* @param string BBCode text
* @return string RTE-compatible text
*/
public function convertStdToRte( $t )
{
//-----------------------------------------
// Ensure no slashy slashy
//-----------------------------------------
$t = str_replace( '"','&quot;', $t );
$t = str_replace( "'",'&apos;', $t );
//-----------------------------------------
// Convert <>
//-----------------------------------------
if( $this->parse_nl2br )
{
$t = str_replace( "<br />", "\n", $t );
}
$t = str_replace( '<', '&lt;', $t );
$t = str_replace( '>', '&gt;', $t );
//-----------------------------------------
// RTE expects <br /> not \n
//-----------------------------------------
$t = str_replace( "\n", "<br />", str_replace( "\r\n", "\n", $t ) );
//-----------------------------------------
// Okay, convert ready for RTE
//-----------------------------------------
$t = $this->preDbParse( $t );
$t = $this->convertForRTE( $t );
return $t;
}
/**
* Converts "IP.Board HTML" to regular (RTE) HTML
*
* @param string Parsed text
* @return string RTE-compatible text
*/
public function convertForRTE( $t )
{
$this->_passSettings();
return $this->bbclass->convertForRTE( $t );
}
/**
* Strip all HTML and bbcode tags
*
* @param string BBCode + HTML text
* @param boolean Run through pre_edit_parse
* @return string Raw text with no tags
*/
public function stripAllTags( $t, $pre_edit_parse=true )
{
$this->_passSettings();
return $this->bbclass->stripAllTags( $t, $pre_edit_parse );
}
/**
* Strip quotes
*
* @param string Raw posted text
* @return string Raw text with no quotes
*/
public function stripQuotes( $t )
{
$this->_passSettings();
return $this->bbclass->stripBbcode( 'quote', $t );
}
/**
* Strip shared media
*
* @param string Raw posted text
* @return string Raw text with no shared media
*/
public function stripSharedMedia( $t )
{
$t = preg_replace( "#\[sharedmedia=([^\]]+?)\]#is", " ", $t );
return $t;
}
/**
* Strip emoticons
*
* @param string Raw posted text
* @return string Raw text with no emoticons
*/
public function stripEmoticons( $t )
{
$this->_passSettings();
return $this->bbclass->stripEmoticons( $t );
}
/**
* Unconvert emoticons
*
* @param string Raw posted text
* @return string Raw text with text emoticons
*/
public function unconvertSmilies( $t )
{
return IPSText::unconvertSmilies( $t );
}
/**
* Strip badwords
*
* @param string Raw posted text
* @return string Raw text with no badwords
*/
public function stripBadWords( $t )
{
$this->_passSettings();
return $this->bbclass->badWords( $t );
}
/**
* Check against blacklisted URLs
*
* @param string Raw posted text
* @return bool False if blacklisted url present, otherwise true
*/
public function checkBlacklistUrls( $t )
{
$this->_passSettings();
return $this->bbclass->checkBlacklistUrls( $t );
}
/**
* Make data in quotes "safe"
*
* @param string Raw posted text
* @return string Raw text safe for use in quote tag
*/
public function makeQuoteSafe( $t )
{
$this->_passSettings();
return $this->bbclass->makeQuoteSafe( $t );
}
/**
* Clean content from XSS (best shot at least)
*
* @param string Raw posted text
* @param boolean Attempt to fix script tag
* @return string Cleaned text
*/
public function xssHtmlClean( $t, $fixScript=true )
{
$this->_passSettings();
return $this->bbclass->checkXss( $t, $fixScript );
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* BBCode parsing gateway.
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 10914 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
exit();
}
class parseBbcode
{
/**
* Registry Object Shortcuts
*
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**
* Allowed to update the caches if not present
*
* @var boolean
*/
public $allow_update_caches = true;
/**
* Parse emoticons?
*
* @var boolean
*/
public $parse_smilies = true;
/**
* Parse HTML?
* HIGHLY NOT RECOMMENDED IN MOST CASES
*
* @var boolean
*/
public $parse_html = false;
public $skipXssCheck = false;
/**
* Parse bbcode?
*
* @var boolean
*/
public $parse_bbcode = true;
/**
* Strip quotes?
* Strips quotes from the resulting text
*
* @var boolean
*/
public $strip_quotes = false;
/**
* Auto convert newlines to html line breaks
*
* @var boolean
*/
public $parse_nl2br = true;
/**
* Bypass badwords?
*
* @var boolean
*/
public $bypass_badwords = false;
/**
* Section keyword for parsing area
*
* @var string
*/
public $parsing_section = 'post';
/**
* Group id of poster
*
* @var int
*/
public $parsing_mgroup = 0;
/**
* Value of mgroup_others for poster
*
* @var string
*/
public $parsing_mgroup_others = '';
/**
* Error code stored
*
* @var string
*/
public $error = '';
/**
* Warning code stored
*
* @var string
*/
public $warning = '';
/**
* BBCode library object
*
* @var object
*/
protected $bbclass;
/**
* Already loaded the classes?
*
* @var boolean
*/
protected $classes_loaded = false;
/**
* Constructor
*
* @param object Registry object
* @param string Parsing method to use
* @return @e void
*/
public function __construct( ipsRegistry $registry, $method='normal' )
{
/* Make object */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
$this->pre_edit_parse_method = $method;
/* Initialize our bbcode class */
$this->_loadClasses();
/* And some default properties */
$this->bypass_badwords = $this->memberData ? intval( $this->memberData['g_bypass_badwords'] ) : 0;
$this->strip_quotes = $this->settings['strip_quotes'];
}
/**
* Load the required bbcode classes and initialize the object
*
* @return @e void
*/
protected function _loadClasses()
{
$_NOW = IPSDebug::getMemoryDebugFlag();
if ( ! $this->classes_loaded )
{
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/bbcode/core.php', 'class_bbcode_core' );
if( $this->pre_edit_parse_method == 'legacy' )
{
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/bbcode/legacy.php', 'class_bbcode_legacy' );
}
$this->bbclass = new $classToLoad( $this->registry );
$this->classes_loaded = true;
$this->error =& $this->bbclass->error;
$this->warning =& $this->bbclass->warning;
}
IPSDebug::setMemoryDebugFlag( "BBCode classes loaded", $_NOW );
}
/**
* Pass off our settings to our bbcode handler
*
* @return @e void
*/
protected function _passSettings()
{
/* Clean out secondary groups just in case of ,, */
$this->parsing_mgroup_others = IPSText::cleanPermString( $this->parsing_mgroup_others );
//-----------------------------------------
// Pass the settings
//-----------------------------------------
$this->cache->updateCacheWithoutSaving( '_tmp_section', $this->parsing_section );
$this->bbclass->bypass_badwords = $this->bypass_badwords;
$this->bbclass->parse_smilies = $this->parse_smilies;
$this->bbclass->parse_html = $this->parse_html;
$this->bbclass->parse_bbcode = $this->parse_bbcode;
$this->bbclass->strip_quotes = $this->strip_quotes;
$this->bbclass->parse_nl2br = $this->parse_nl2br;
$this->bbclass->parsing_section = $this->parsing_section;
$this->bbclass->parsing_mgroup = $this->parsing_mgroup;
$this->bbclass->parsing_mgroup_others = $this->parsing_mgroup_others;
$this->bbclass->skipXssCheck = $this->skipXssCheck;
$this->bbclass->initOurBbcodes();
}
/**
* Parses the bbcode to be stored into the database.
* If all bbcodes are parse on display, this method does nothing really
*
* @param string Raw input text to parse
* @return string Parsed text ready to be stored in database
*/
public function preDbParse( $text )
{
$this->_passSettings();
//-----------------------------------------
// Pass off to the main handler
//-----------------------------------------
return $this->bbclass->preDbParse( trim($text) );
}
/**
* Parses the bbcode to be shown in the STD editor.
* If all bbcodes are parse on display, this method does nothing really
*
* @param string Raw input text to parse
* @return string Parsed text ready to be stored in database
*/
public function preEditParse( $text )
{
$this->_passSettings();
//-----------------------------------------
// Parse
//-----------------------------------------
return $this->bbclass->preEditParse( $text );
}
/**
* Parses the bbcode to be shown in the browser. Expects preDbParse has already been done before the save.
* If all bbcodes are parse on save, this method does nothing really
*
* @param string Raw input text to parse
* @return string Parsed text ready to be displayed
*/
public function preDisplayParse( $text )
{
$_NOW = IPSDebug::getMemoryDebugFlag();
$this->_passSettings();
//-----------------------------------------
// Parse
//-----------------------------------------
$text = $this->bbclass->preDisplayParse( $text );
IPSDebug::setMemoryDebugFlag( "PreDisplayParse completed", $_NOW );
return $text;
}
/**
* Parses the bbcode to be shown in the polls.
* Parses img and url, if enabled
*
* @param string Raw input text to parse
* @return string Parsed text ready to be displayed
*/
public function parsePollTags( $text )
{
$text = $this->bbclass->parseBbcode( $text, 'display', array( 'img', 'url' ) );
$text = $this->bbclass->finishNonParsed( $text, 'display' );
return $text;
}
/**
* Parse only specified bbcodes
*
* @param string Raw input text to parse
* @param string db or display - what mode to parse in
* @param mixed BBcode tag to parse, or array of bbcode tags to parse
* @return string Parsed text ready to be displayed
*/
public function parseSingleBbcodes( $text, $method='display', $codes=null )
{
$text = $this->bbclass->parseBbcode( $text, $method, $codes );
$text = $this->bbclass->finishNonParsed( $text, $method );
return $text;
}
/**
* Converts the STD contents to RTE compatible output
* Used when switching editors or taking the bbcode post and putting into the RTE
*
* @param string BBCode text
* @return string RTE-compatible text
*/
public function convertStdToRte( $t )
{
//-----------------------------------------
// Ensure no slashy slashy
//-----------------------------------------
$t = str_replace( '"','&quot;', $t );
$t = str_replace( "'",'&apos;', $t );
//-----------------------------------------
// Convert <>
//-----------------------------------------
if( $this->parse_nl2br )
{
$t = str_replace( "<br />", "\n", $t );
}
$t = str_replace( '<', '&lt;', $t );
$t = str_replace( '>', '&gt;', $t );
//-----------------------------------------
// RTE expects <br /> not \n
//-----------------------------------------
$t = str_replace( "\n", "<br />", str_replace( "\r\n", "\n", $t ) );
//-----------------------------------------
// Okay, convert ready for RTE
//-----------------------------------------
$t = $this->preDbParse( $t );
$t = $this->convertForRTE( $t );
return $t;
}
/**
* Converts "IP.Board HTML" to regular (RTE) HTML
*
* @param string Parsed text
* @return string RTE-compatible text
*/
public function convertForRTE( $t )
{
$this->_passSettings();
return $this->bbclass->convertForRTE( $t );
}
/**
* Strip all HTML and bbcode tags
*
* @param string BBCode + HTML text
* @param boolean Run through pre_edit_parse
* @return string Raw text with no tags
*/
public function stripAllTags( $t, $pre_edit_parse=true )
{
$this->_passSettings();
return $this->bbclass->stripAllTags( $t, $pre_edit_parse );
}
/**
* Strip quotes
*
* @param string Raw posted text
* @param string Tag to strip (defaults to 'quote')
* @return string Raw text with no quotes
*/
public function stripQuotes( $t, $tag='quote' )
{
$this->_passSettings();
if ( is_array( $tag ) )
{
foreach ( $tag as $_tag )
{
$t = $this->bbclass->stripBbcode( $_tag, $t );
}
return $t;
}
else
{
return $this->bbclass->stripBbcode( $tag, $t );
}
}
/**
* Strip shared media
*
* @param string Raw posted text
* @return string Raw text with no shared media
*/
public function stripSharedMedia( $t )
{
$t = preg_replace( '#\[sharedmedia=([^\]]+?)\]#is', " ", $t );
return $t;
}
/**
* Strip emoticons
*
* @param string Raw posted text
* @return string Raw text with no emoticons
*/
public function stripEmoticons( $t )
{
$this->_passSettings();
return $this->bbclass->stripEmoticons( $t );
}
/**
* Unconvert emoticons
*
* @param string Raw posted text
* @return string Raw text with text emoticons
*/
public function unconvertSmilies( $t )
{
return IPSText::unconvertSmilies( $t );
}
/**
* Strip badwords
*
* @param string Raw posted text
* @return string Raw text with no badwords
*/
public function stripBadWords( $t )
{
$this->_passSettings();
return $this->bbclass->badWords( $t );
}
/**
* Check against blacklisted URLs
*
* @param string Raw posted text
* @return bool False if blacklisted url present, otherwise true
*/
public function checkBlacklistUrls( $t )
{
$this->_passSettings();
return $this->bbclass->checkBlacklistUrls( $t );
}
/**
* Make data in quotes "safe"
*
* @param string Raw posted text
* @return string Raw text safe for use in quote tag
*/
public function makeQuoteSafe( $t )
{
$this->_passSettings();
return $this->bbclass->makeQuoteSafe( $t );
}
/**
* Clean content from XSS (best shot at least)
*
* @param string Raw posted text
* @param boolean Attempt to fix script tag
* @return string Cleaned text
*/
public function xssHtmlClean( $t, $fixScript=true )
{
$this->_passSettings();
return $this->bbclass->checkXss( $t, $fixScript );
}
}
+9 -9
View File
@@ -1,10 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
</html>