Use boolean setting as true boolean (#7284)
* use boolean setting as true boolean * Update settings class to use the php filter_var function for boolean Using the built-in filter type for boolean seems like a better option as they are faster, already hardened, and more widely tested. I found this better method used originally by Mark J. Crane in 2022 in the content.php page so I included it here. * Update settings class to use the php filter_var function for boolean Using the built-in filter type for boolean seems like a better option as they are faster, already hardened, and more widely tested. I found this better method used originally by Mark J. Crane in 2022 in the content.php page so I included it here.
This commit is contained in:
@@ -166,8 +166,8 @@ class settings {
|
||||
* @param string $uuid uuid of the setting if available. If set to an empty string then a new uuid will be created.
|
||||
* @param string $category Category of the setting.
|
||||
* @param string $subcategory Subcategory of the setting.
|
||||
* @param string $type Type of the setting (array, numeric, text, etc)
|
||||
* @param string $value (optional) Value to set. Default is empty string.
|
||||
* @param string $type Type of the setting (array, numeric, text, etc)
|
||||
* @param bool $enabled (optional) True or False. Default is True.
|
||||
* @param string $description (optional) Description. Default is empty string.
|
||||
*/
|
||||
@@ -248,17 +248,7 @@ class settings {
|
||||
$subcategory = $row['default_setting_subcategory'];
|
||||
if (isset($row['default_setting_value']) && $row['default_setting_value'] !== '') {
|
||||
if ($name == "boolean") {
|
||||
if (gettype($row['default_setting_value']) === 'string') {
|
||||
if ($row['default_setting_value'] === 'true') {
|
||||
$this->settings[$category][$subcategory] = true;
|
||||
}
|
||||
else {
|
||||
$this->settings[$category][$subcategory] = false;
|
||||
}
|
||||
}
|
||||
elseif (gettype($row['default_setting_value']) === 'boolean') {
|
||||
$this->settings[$category][$subcategory] = $row['default_setting_value'];
|
||||
}
|
||||
$this->settings[$category][$subcategory] = filter_var($row['default_setting_value'], FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
elseif ($name == "array") {
|
||||
if (!isset($this->settings[$category][$subcategory]) || !is_array($this->settings[$category][$subcategory])) {
|
||||
@@ -318,17 +308,7 @@ class settings {
|
||||
$subcategory = $row['domain_setting_subcategory'];
|
||||
if (isset($row['domain_setting_value']) && $row['domain_setting_value'] !== '') {
|
||||
if ($name == "boolean") {
|
||||
if (gettype($row['domain_setting_value']) === 'string') {
|
||||
if ($row['domain_setting_value'] === 'true') {
|
||||
$this->settings[$category][$subcategory] = true;
|
||||
}
|
||||
else {
|
||||
$this->settings[$category][$subcategory] = false;
|
||||
}
|
||||
}
|
||||
elseif (gettype($row['domain_setting_value']) === 'boolean') {
|
||||
$this->settings[$category][$subcategory] = $row['domain_setting_value'];
|
||||
}
|
||||
$this->settings[$category][$subcategory] = filter_var($row['domain_setting_value'], FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
if ($name == "array") {
|
||||
if (!isset($this->settings[$category][$subcategory]) || !is_array($this->settings[$category][$subcategory])) {
|
||||
@@ -377,17 +357,7 @@ class settings {
|
||||
$subcategory = $row['user_setting_subcategory'];
|
||||
if (isset($row['user_setting_value']) && $row['user_setting_value'] !== '') {
|
||||
if ($name == "boolean") {
|
||||
if (gettype($row['user_setting_value']) === 'string') {
|
||||
if ($row['user_setting_value'] === 'true') {
|
||||
$this->settings[$category][$subcategory] = true;
|
||||
}
|
||||
else {
|
||||
$this->settings[$category][$subcategory] = false;
|
||||
}
|
||||
}
|
||||
elseif (gettype($row['user_setting_value']) === 'boolean') {
|
||||
$this->settings[$category][$subcategory] = $row['user_setting_value'];
|
||||
}
|
||||
$this->settings[$category][$subcategory] = filter_var($row['user_setting_value'], FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
elseif ($name == "array") {
|
||||
$this->settings[$category][$subcategory][] = $row['user_setting_value'];
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
ob_end_clean(); //clean the buffer
|
||||
|
||||
//clear the template
|
||||
//if (isset($_SESSION['theme']['cache']['boolean']) && $_SESSION['theme']['cache']['boolean'] == "false") {
|
||||
//if (!filter_var($_SESSION['theme']['cache']['boolean'] ?? false, FILTER_VALIDATE_BOOL)) {
|
||||
// $_SESSION["template_content"] = '';
|
||||
//}
|
||||
|
||||
@@ -285,7 +285,7 @@
|
||||
if (
|
||||
$authenticated &&
|
||||
file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH.'/app/session_timer/session_timer.php') &&
|
||||
$_SESSION['security']['session_timer_enabled']['boolean'] == 'true'
|
||||
filter_var($_SESSION['security']['session_timer_enabled']['boolean'] ?? false, FILTER_VALIDATE_BOOL)
|
||||
) {
|
||||
include_once PROJECT_PATH.'app/session_timer/session_timer.php';
|
||||
$view->assign('session_timer', $session_timer);
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@
|
||||
}
|
||||
}
|
||||
//regenerate sessions to avoid session id attacks such as session fixation
|
||||
if (array_key_exists('security',$_SESSION) && $_SESSION['security']['session_rotate']['boolean'] == "true") {
|
||||
if (array_key_exists('security',$_SESSION) && filter_var($_SESSION['security']['session_rotate']['boolean'] ?? true, FILTER_VALIDATE_BOOL)) {
|
||||
$_SESSION['session']['last_activity'] = time();
|
||||
if (!isset($_SESSION['session']['created'])) {
|
||||
$_SESSION['session']['created'] = time();
|
||||
|
||||
Reference in New Issue
Block a user