mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 14:00:31 +02:00
[ticket/16574] Remove flash BBcode
PHPBB3-16574
This commit is contained in:
committed by
Marc Alexander
parent
d714c6db19
commit
28f98402f3
43
phpBB/phpbb/db/migration/data/v400/remove_flash.php
Normal file
43
phpBB/phpbb/db/migration/data/v400/remove_flash.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v400;
|
||||
|
||||
use phpbb\db\migration\migration;
|
||||
|
||||
class remove_flash extends migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return !$this->config->offsetExists('allow_post_flash');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return [
|
||||
'\phpbb\db\migration\data\v400\dev',
|
||||
];
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return [
|
||||
['config.remove', ['auth_flash_pm']],
|
||||
['config.remove', ['allow_post_flash']],
|
||||
['config.remove', ['allow_sig_flash']],
|
||||
|
||||
['permission.remove', ['f_flash', false]],
|
||||
['permission.remove', ['u_pm_flash']],
|
||||
];
|
||||
}
|
||||
}
|
@@ -251,7 +251,6 @@ class permissions
|
||||
'u_pm_bbcode' => array('lang' => 'ACL_U_PM_BBCODE', 'cat' => 'pm'),
|
||||
'u_pm_smilies' => array('lang' => 'ACL_U_PM_SMILIES', 'cat' => 'pm'),
|
||||
'u_pm_img' => array('lang' => 'ACL_U_PM_IMG', 'cat' => 'pm'),
|
||||
'u_pm_flash' => array('lang' => 'ACL_U_PM_FLASH', 'cat' => 'pm'),
|
||||
|
||||
'u_sendemail' => array('lang' => 'ACL_U_SENDEMAIL', 'cat' => 'misc'),
|
||||
'u_sendim' => array('lang' => 'ACL_U_SENDIM', 'cat' => 'misc'),
|
||||
@@ -289,7 +288,6 @@ class permissions
|
||||
'f_attach' => array('lang' => 'ACL_F_ATTACH', 'cat' => 'content'),
|
||||
'f_icons' => array('lang' => 'ACL_F_ICONS', 'cat' => 'content'),
|
||||
'f_bbcode' => array('lang' => 'ACL_F_BBCODE', 'cat' => 'content'),
|
||||
'f_flash' => array('lang' => 'ACL_F_FLASH', 'cat' => 'content'),
|
||||
'f_img' => array('lang' => 'ACL_F_IMG', 'cat' => 'content'),
|
||||
'f_sigs' => array('lang' => 'ACL_F_SIGS', 'cat' => 'content'),
|
||||
'f_smilies' => array('lang' => 'ACL_F_SMILIES', 'cat' => 'content'),
|
||||
|
@@ -136,7 +136,6 @@ class data_access
|
||||
'list' => 9,
|
||||
'*' => 9,
|
||||
'email' => 10,
|
||||
'flash' => 11,
|
||||
'attachment' => 12,
|
||||
);
|
||||
|
||||
|
@@ -37,13 +37,6 @@ interface renderer_interface
|
||||
*/
|
||||
public function get_viewcensors();
|
||||
|
||||
/**
|
||||
* Return the value of the "viewflash" option
|
||||
*
|
||||
* @return bool Option's value
|
||||
*/
|
||||
public function get_viewflash();
|
||||
|
||||
/**
|
||||
* Return the value of the "viewimg" option
|
||||
*
|
||||
@@ -66,14 +59,6 @@ interface renderer_interface
|
||||
*/
|
||||
public function set_viewcensors($value);
|
||||
|
||||
/**
|
||||
* Set the "viewflash" option
|
||||
*
|
||||
* @param bool $value Option's value
|
||||
* @return null
|
||||
*/
|
||||
public function set_viewflash($value);
|
||||
|
||||
/**
|
||||
* Set the "viewimg" option
|
||||
*
|
||||
|
@@ -57,7 +57,6 @@ class factory implements \phpbb\textformatter\cache_interface
|
||||
*/
|
||||
protected $custom_tokens = array(
|
||||
'email' => array('{DESCRIPTION}' => '{TEXT}'),
|
||||
'flash' => array('{WIDTH}' => '{NUMBER1}', '{HEIGHT}' => '{NUMBER2}'),
|
||||
'img' => array('{URL}' => '{IMAGEURL}'),
|
||||
'list' => array('{LIST_TYPE}' => '{HASHMAP}'),
|
||||
'quote' => array('{USERNAME}' => '{TEXT1}'),
|
||||
@@ -79,7 +78,6 @@ class factory implements \phpbb\textformatter\cache_interface
|
||||
'code' => '[CODE lang={IDENTIFIER;optional}]{TEXT}[/CODE]',
|
||||
'color' => '[COLOR={COLOR}]{TEXT}[/COLOR]',
|
||||
'email' => '[EMAIL={EMAIL;useContent} subject={TEXT1;optional;postFilter=rawurlencode} body={TEXT2;optional;postFilter=rawurlencode}]{TEXT}[/EMAIL]',
|
||||
'flash' => '[FLASH={NUMBER1},{NUMBER2} width={NUMBER1;postFilter=#flashwidth} height={NUMBER2;postFilter=#flashheight} url={URL;useContent} /]',
|
||||
'i' => '[I]{TEXT}[/I]',
|
||||
'img' => '[IMG src={IMAGEURL;useContent}]',
|
||||
'list' => '[LIST type={HASHMAP=1:decimal,a:lower-alpha,A:upper-alpha,i:lower-roman,I:upper-roman;optional;postFilter=#simpletext} #createChild=LI]{TEXT}[/LIST]',
|
||||
@@ -268,18 +266,6 @@ class factory implements \phpbb\textformatter\cache_interface
|
||||
$filter = new RegexpFilter('!^([\p{L}\p{N}\-+,_. ]+)$!Du');
|
||||
$configurator->attributeFilters->add('#inttext', $filter);
|
||||
|
||||
// Create custom filters for Flash restrictions, which use the same values as the image
|
||||
// restrictions but have their own error message
|
||||
$configurator->attributeFilters
|
||||
->add('#flashheight', __NAMESPACE__ . '\\parser::filter_flash_height')
|
||||
->addParameterByName('max_img_height')
|
||||
->addParameterByName('logger');
|
||||
|
||||
$configurator->attributeFilters
|
||||
->add('#flashwidth', __NAMESPACE__ . '\\parser::filter_flash_width')
|
||||
->addParameterByName('max_img_width')
|
||||
->addParameterByName('logger');
|
||||
|
||||
// Create a custom filter for phpBB's per-mode font size limits
|
||||
$configurator->attributeFilters
|
||||
->add('#fontsize', __NAMESPACE__ . '\\parser::filter_font_size')
|
||||
@@ -306,8 +292,8 @@ class factory implements \phpbb\textformatter\cache_interface
|
||||
$configurator->tags['QUOTE']->nestingLimit = PHP_INT_MAX;
|
||||
}
|
||||
|
||||
// Modify the template to disable images/flash/mentions depending on user's settings
|
||||
foreach (array('FLASH', 'IMG', 'MENTION') as $name)
|
||||
// Modify the template to disable images/mentions depending on user's settings
|
||||
foreach (['IMG', 'MENTION'] as $name)
|
||||
{
|
||||
$tag = $configurator->tags[$name];
|
||||
$tag->template = '<xsl:choose><xsl:when test="$S_VIEW' . $name . '">' . $tag->template . '</xsl:when><xsl:otherwise><xsl:apply-templates/></xsl:otherwise></xsl:choose>';
|
||||
|
@@ -218,7 +218,7 @@ class parser implements \phpbb\textformatter\parser_interface
|
||||
{
|
||||
$errors[] = array($msg, $context['max_size']);
|
||||
}
|
||||
else if (preg_match('/^MAX_(?:FLASH|IMG)_(HEIGHT|WIDTH)_EXCEEDED$/D', $msg, $m))
|
||||
else if (preg_match('/^MAX_IMG_(HEIGHT|WIDTH)_EXCEEDED$/D', $msg, $m))
|
||||
{
|
||||
$errors[] = array($msg, $context['max_' . strtolower($m[1])]);
|
||||
}
|
||||
@@ -301,50 +301,6 @@ class parser implements \phpbb\textformatter\parser_interface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter a flash object's height
|
||||
*
|
||||
* @see bbcode_firstpass::bbcode_flash()
|
||||
*
|
||||
* @param string $height
|
||||
* @param integer $max_height
|
||||
* @param Logger $logger
|
||||
* @return mixed Original value if valid, FALSE otherwise
|
||||
*/
|
||||
public static function filter_flash_height($height, $max_height, Logger $logger)
|
||||
{
|
||||
if ($max_height && $height > $max_height)
|
||||
{
|
||||
$logger->err('MAX_FLASH_HEIGHT_EXCEEDED', array('max_height' => $max_height));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter a flash object's width
|
||||
*
|
||||
* @see bbcode_firstpass::bbcode_flash()
|
||||
*
|
||||
* @param string $width
|
||||
* @param integer $max_width
|
||||
* @param Logger $logger
|
||||
* @return mixed Original value if valid, FALSE otherwise
|
||||
*/
|
||||
public static function filter_flash_width($width, $max_width, Logger $logger)
|
||||
{
|
||||
if ($max_width && $width > $max_width)
|
||||
{
|
||||
$logger->err('MAX_FLASH_WIDTH_EXCEEDED', array('max_width' => $max_width));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the value used in a [size] BBCode
|
||||
*
|
||||
|
@@ -48,11 +48,6 @@ class renderer implements \phpbb\textformatter\renderer_interface
|
||||
*/
|
||||
protected $viewcensors = false;
|
||||
|
||||
/**
|
||||
* @var bool Status of the viewflash option
|
||||
*/
|
||||
protected $viewflash = false;
|
||||
|
||||
/**
|
||||
* @var bool Status of the viewimg option
|
||||
*/
|
||||
@@ -167,7 +162,7 @@ class renderer implements \phpbb\textformatter\renderer_interface
|
||||
/**
|
||||
* Configure this renderer as per the user's settings
|
||||
*
|
||||
* Should set the locale as well as the viewcensor/viewflash/viewimg/viewsmilies options.
|
||||
* Should set the locale as well as the viewcensor/viewimg/viewsmilies options.
|
||||
*
|
||||
* @param \phpbb\user $user
|
||||
* @param \phpbb\config\config $config
|
||||
@@ -179,7 +174,6 @@ class renderer implements \phpbb\textformatter\renderer_interface
|
||||
$censor = $user->optionget('viewcensors') || !$config['allow_nocensors'] || !$auth->acl_get('u_chgcensors');
|
||||
|
||||
$this->set_viewcensors($censor);
|
||||
$this->set_viewflash($user->optionget('viewflash'));
|
||||
$this->set_viewimg($user->optionget('viewimg'));
|
||||
$this->set_viewsmilies($user->optionget('viewsmilies'));
|
||||
$this->set_usemention($config['allow_mentions'] && $auth->acl_get('u_mention'));
|
||||
@@ -221,14 +215,6 @@ class renderer implements \phpbb\textformatter\renderer_interface
|
||||
return $this->viewcensors;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_viewflash()
|
||||
{
|
||||
return $this->viewflash;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -310,15 +296,6 @@ class renderer implements \phpbb\textformatter\renderer_interface
|
||||
$this->renderer->setParameter('S_VIEWCENSORS', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set_viewflash($value)
|
||||
{
|
||||
$this->viewflash = $value;
|
||||
$this->renderer->setParameter('S_VIEWFLASH', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@@ -77,7 +77,7 @@ abstract class base implements reparser_interface
|
||||
|
||||
// Those BBCodes are disabled based on context and user permissions and that value is never
|
||||
// stored in the database. Here we test whether they were used in the original text.
|
||||
$bbcodes = array('flash', 'img', 'quote', 'url');
|
||||
$bbcodes = array('img', 'quote', 'url');
|
||||
foreach ($bbcodes as $bbcode)
|
||||
{
|
||||
$field_name = 'enable_' . $bbcode . '_bbcode';
|
||||
@@ -253,7 +253,6 @@ abstract class base implements reparser_interface
|
||||
$unparsed['enable_magic_url'],
|
||||
$unparsed['enable_smilies'],
|
||||
$unparsed['enable_img_bbcode'],
|
||||
$unparsed['enable_flash_bbcode'],
|
||||
$unparsed['enable_quote_bbcode'],
|
||||
$unparsed['enable_url_bbcode'],
|
||||
'text_reparser.' . $this->get_name()
|
||||
|
@@ -49,7 +49,7 @@ class user extends \phpbb\session
|
||||
protected $is_setup_flag;
|
||||
|
||||
// Able to add new options (up to id 31)
|
||||
var $keyoptions = array('viewimg' => 0, 'viewflash' => 1, 'viewsmilies' => 2, 'viewsigs' => 3, 'viewavatars' => 4, 'viewcensors' => 5, 'attachsig' => 6, 'bbcode' => 8, 'smilies' => 9, 'sig_bbcode' => 15, 'sig_smilies' => 16, 'sig_links' => 17);
|
||||
var $keyoptions = array('viewimg' => 0, 'viewsmilies' => 2, 'viewsigs' => 3, 'viewavatars' => 4, 'viewcensors' => 5, 'attachsig' => 6, 'bbcode' => 8, 'smilies' => 9, 'sig_bbcode' => 15, 'sig_smilies' => 16, 'sig_links' => 17);
|
||||
|
||||
public $profile_fields;
|
||||
|
||||
|
Reference in New Issue
Block a user