Support for PHP 7 instead of PHP 4

Refactor control_html class to use constructor for initialization
This commit is contained in:
Aaron 2025-11-15 15:40:33 -05:00
parent 1e08e2ba83
commit b51e86fb73

View File

@ -202,40 +202,41 @@ function htmlposts_parse(&$message)
}
// Create a new class to control the parser options easily
if (!class_exists("control_html"))
{
class control_html
{
public $html_enabled;
function control_html()
{
// Is it enabled already? Save it in a var to later disallow disabling
$this->html_enabled = $parser->options['allow_html'];
}
function set_html($status)
{
$status = (int)$status;
if ($status != 0 && $status != 1) return false;
// if we're trying to disable it but it's enabled by default, disallow the action
if ($status == 0 && $this->html_enabled == 1)
return false;
global $parser;
// Set to desired status
$parser->options['allow_html'] = $status;
// for previewing posts
global $parser_options;
if (!empty($parser_options))
$parser_options['allow_html'] = $status;
return true;
}
}
}
if (!class_exists("control_html"))
{
class control_html
{
public $html_enabled;
function __construct()
{
// Is it enabled already? Save it in a var to later disallow disabling
global $parser;
$this->html_enabled = $parser->options['allow_html'];
}
function set_html($status)
{
$status = (int)$status;
if ($status != 0 && $status != 1) return false;
// if we're trying to disable it but it's enabled by default, disallow the action
if ($status == 0 && $this->html_enabled == 1)
return false;
global $parser;
// Set to desired status
$parser->options['allow_html'] = $status;
// for previewing posts
global $parser_options;
if (!empty($parser_options))
$parser_options['allow_html'] = $status;
return true;
}
}
}
// Create object if it doesn't exist
if (!is_object($control_html))