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:
frytimo
2025-03-04 14:25:47 -04:00
committed by GitHub
parent 1b19e40be4
commit d529021b3f
99 changed files with 265 additions and 295 deletions

View File

@@ -38,7 +38,7 @@
}
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
$list_row_edit_button = filter_var($_SESSION['theme']['list_row_edit_button']['boolean'] ?? false, FILTER_VALIDATE_BOOL);
//set the uuid
if (!empty($_GET['id']) && is_uuid($_GET['id'])) {

View File

@@ -38,7 +38,7 @@
}
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
$list_row_edit_button = filter_var($_SESSION['theme']['list_row_edit_button']['boolean'] ?? false, FILTER_VALIDATE_BOOL);
//get the contact attachment list
$sql = "select *, length(decode(attachment_content,'base64')) as attachment_size from v_contact_attachments ";

View File

@@ -92,7 +92,7 @@
//$contact_users = $_POST["contact_users"];
//$contact_groups = $_POST["contact_groups"];
$contact_user_uuid = ($_SESSION['contact']['permissions']['boolean'] == "true") ? ($_POST["contact_user_uuid"] ?? $_SESSION["user_uuid"]) : ($contact_user_uuid = $_POST["contact_user_uuid"] ?? null);
$contact_user_uuid = filter_var($_SESSION['contact']['permissions']['boolean'] ?? false, FILTER_VALIDATE_BOOLEAN) ? ($_POST["contact_user_uuid"] ?? $_SESSION["user_uuid"]) : ($contact_user_uuid = $_POST["contact_user_uuid"] ?? null);
$contact_group_uuid = $_POST["contact_group_uuid"] ?? null;
$contact_phones = $_POST["contact_phones"];
@@ -1529,7 +1529,7 @@ echo " </div>\n";
echo " </div>\n";
unset($contact_note);
if ($_SESSION['contact']['permissions']['boolean'] == "true") {
if (filter_var($_SESSION['contact']['permissions']['boolean'] ?? false, FILTER_VALIDATE_BOOL)) {
if (permission_exists('contact_user_view') || permission_exists('contact_group_view')) {
echo " <div class='form_set card'>\n";
echo " <div class='heading'>\n";

View File

@@ -38,7 +38,7 @@
}
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
$list_row_edit_button = filter_var($_SESSION['theme']['list_row_edit_button']['boolean'] ?? false, FILTER_VALIDATE_BOOL);
//get the contact list
$sql = "select * from v_contact_emails ";
@@ -71,7 +71,7 @@
echo "<th class='pct-15'>".$text['label-email_label']."</th>\n";
echo "<th>".$text['label-email_address']."</th>\n";
echo "<th class='hide-md-dn'>".$text['label-email_description']."</th>\n";
if (permission_exists('contact_email_edit') && $list_row_edit_button == 'true') {
if (permission_exists('contact_email_edit') && $list_row_edit_button) {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
@@ -96,7 +96,7 @@
echo " <td>".escape($row['email_label'])." ".($row['email_primary'] ? "&nbsp;<i class='fas fa-star fa-xs' style='float: right; margin-top: 0.5em; margin-right: -0.5em;' title=\"".$text['label-primary']."\"></i>" : null)."</td>\n";
echo " <td class='no-link'><a href='mailto:".escape($row['email_address'])."'>".escape($row['email_address'])."</a>&nbsp;</td>\n";
echo " <td class='description overflow hide-md-dn'>".escape($row['email_description'])."&nbsp;</td>\n";
if (permission_exists('contact_email_edit') && $list_row_edit_button == 'true') {
if (permission_exists('contact_email_edit') && $list_row_edit_button) {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";

View File

@@ -38,7 +38,7 @@
}
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
$list_row_edit_button = filter_var($_SESSION['theme']['list_row_edit_button']['boolean'] ?? false, FILTER_VALIDATE_BOOL);
//get the extension list
$sql = "select e.extension_uuid, e.extension, e.enabled, e.description ";
@@ -69,7 +69,7 @@
echo "<th>".$text['label-extension']."</th>\n";
echo "<th class='center'>".$text['label-enabled']."</th>\n";
echo "<th class='hide-md-dn'>".$text['label-description']."</th>\n";
if (permission_exists('extension_edit') && $list_row_edit_button == 'true') {
if (permission_exists('extension_edit') && $list_row_edit_button) {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
@@ -95,7 +95,7 @@
echo " </td>\n";
echo " <td class='center'>".$text['label-'.escape($row['enabled'])]."&nbsp;</td>\n";
echo " <td class='description overflow hide-md-dn'>".$row['description']."&nbsp;</td>\n";
if (permission_exists('extension_edit') && $list_row_edit_button == 'true') {
if (permission_exists('extension_edit') && $list_row_edit_button) {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";

View File

@@ -85,7 +85,7 @@
echo "<th>".$text['label-phone_type']."</th>\n";
echo "<th>".$text['label-phone_tools']."</th>\n";
echo "<th class='hide-md-dn'>".$text['label-phone_description']."</th>\n";
if (permission_exists('contact_phone_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
if (permission_exists('contact_phone_edit') && filter_var($_SESSION['theme']['list_row_edit_button']['boolean'] ?? false, FILTER_VALIDATE_BOOL)) {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
@@ -130,7 +130,7 @@
}
echo " </td>\n";
echo " <td class='description overflow hide-md-dn'>".escape($row['phone_description'])."&nbsp;</td>\n";
if (permission_exists('contact_phone_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
if (permission_exists('contact_phone_edit') && filter_var($_SESSION['theme']['list_row_edit_button']['boolean'] ?? false, FILTER_VALIDATE_BOOL)) {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";

View File

@@ -38,7 +38,7 @@
}
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
$list_row_edit_button = filter_var($_SESSION['theme']['list_row_edit_button']['boolean'] ?? false, FILTER_VALIDATE_BOOL);
//get the related contacts
$sql = "select ";
@@ -85,7 +85,7 @@
echo "<th>".$text['label-contact_relation_label']."</th>\n";
echo "<th>".$text['label-contact_relation_organization']."</th>\n";
echo "<th>".$text['label-contact_relation_name']."</th>\n";
if (permission_exists('contact_relation_edit') && $list_row_edit_button == 'true') {
if (permission_exists('contact_relation_edit') && $list_row_edit_button) {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
@@ -110,7 +110,7 @@
echo " <td>".escape($row['relation_label'])."&nbsp;</td>\n";
echo " <td class='no-link'><a href='contact_edit.php?id=".urlencode($row['contact_uuid'])."'>".escape($row['contact_organization'])."</a>&nbsp;</td>\n";
echo " <td class='no-link'><a href='contact_edit.php?id=".urlencode($row['contact_uuid'])."'>".escape($row['contact_name_given']).((!empty($row['contact_name_given']) && !empty($row['contact_name_family'])) ? ' ' : null).escape($row['contact_name_family'])."</a>&nbsp;</td>\n";
if (permission_exists('contact_relation_edit') && $list_row_edit_button == 'true') {
if (permission_exists('contact_relation_edit') && $list_row_edit_button) {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";

View File

@@ -39,7 +39,7 @@
}
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
$list_row_edit_button = filter_var($_SESSION['theme']['list_row_edit_button']['boolean'] ?? false, FILTER_VALIDATE_BOOL);
//get the list
$sql = "select * from v_contact_settings ";
@@ -78,7 +78,7 @@
echo "<th>".$text['label-contact_setting_value']."</th>";
echo "<th class='center'>".$text['label-enabled']."</th>";
echo "<th class='hide-md-dn'>".$text['label-description']."</th>";
if (permission_exists('contact_setting_edit') && $list_row_edit_button == 'true') {
if (permission_exists('contact_setting_edit') && $list_row_edit_button) {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
@@ -119,7 +119,7 @@
echo " </td>\n";
echo " <td class='center'>".$text['label-'.escape($row['contact_setting_enabled'])]."&nbsp;</td>\n";
echo " <td class='description overflow hide-md-dn'>".$row['contact_setting_description']."&nbsp;</td>\n";
if (permission_exists('contact_setting_edit') && $list_row_edit_button == 'true') {
if (permission_exists('contact_setting_edit') && $list_row_edit_button) {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";

View File

@@ -38,7 +38,7 @@
}
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
$list_row_edit_button = filter_var($_SESSION['theme']['list_row_edit_button']['boolean'] ?? false, FILTER_VALIDATE_BOOL);
//set the uuid
if (!empty($_GET['id']) && is_uuid($_GET['id'])) {
@@ -79,7 +79,7 @@
echo "<th class='pct-20'>".$text['label-time_start']."</th>\n";
echo "<th class='pct-20'>".$text['label-time_duration']."</th>\n";
echo "<th class='pct-40 hide-md-dn'>".$text['label-time_description']."</th>\n";
if (permission_exists('contact_time_edit') && $list_row_edit_button == 'true') {
if (permission_exists('contact_time_edit') && $list_row_edit_button) {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
@@ -115,7 +115,7 @@
echo " <td>".$time_start."&nbsp;</td>\n";
echo " <td>".$time."&nbsp;</td>\n";
echo " <td class='description overflow hide-md-dn'>".escape($row['time_description'])."&nbsp;</td>\n";
if (permission_exists('contact_time_edit') && $list_row_edit_button == 'true') {
if (permission_exists('contact_time_edit') && $list_row_edit_button) {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";

View File

@@ -73,7 +73,7 @@
echo "<th class='pct-15'>".$text['label-url_label']."</th>\n";
echo "<th>".$text['label-url_address']."</th>\n";
echo "<th class='hide-md-dn'>".$text['label-url_description']."</th>\n";
if (permission_exists('contact_url_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
if (permission_exists('contact_url_edit') && filter_var($_SESSION['theme']['list_row_edit_button']['boolean'] ?? false, FILTER_VALIDATE_BOOL)) {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
@@ -98,7 +98,7 @@
echo " <td>".escape($row['url_label'])." ".($row['url_primary'] ? "&nbsp;<i class='fas fa-star fa-xs' style='float: right; margin-top: 0.5em; margin-right: -0.5em;' title=\"".$text['label-primary']."\"></i>" : null)."</td>\n";
echo " <td class='no-link overflow no-wrap'><a href='".escape($row['url_address'])."' target='_blank'>".str_replace("http://", "", str_replace("https://", "", escape($row['url_address'])))."</a></td>\n";
echo " <td class='description overflow hide-md-dn'>".escape($row['url_description'])."&nbsp;</td>\n";
if (permission_exists('contact_url_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
if (permission_exists('contact_url_edit') && filter_var($_SESSION['theme']['list_row_edit_button']['boolean'] ?? false, FILTER_VALIDATE_BOOL)) {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";

View File

@@ -46,7 +46,7 @@
$show = $_GET["show"] ?? '';
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
$list_row_edit_button = filter_var($_SESSION['theme']['list_row_edit_button']['boolean'] ?? false, FILTER_VALIDATE_BOOL);
//get posted data
if (!empty($_POST['contacts'])) {
@@ -387,7 +387,7 @@
echo th_order_by('contact_title', $text['label-contact_title'], $order_by, $order, null, "class='hide-sm-dn'");
echo th_order_by('contact_role', $text['label-contact_role'], $order_by, $order, null, "class='hide-sm-dn'");
echo "<th class='shrink hide-sm-dn'>&nbsp;</th>\n";
if ($list_row_edit_button == 'true') {
if ($list_row_edit_button) {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
@@ -439,7 +439,7 @@
echo "&nbsp;";
}
echo " </td>\n";
if ($list_row_edit_button == 'true') {
if ($list_row_edit_button) {
echo " <td class='action-button'>";
echo button::create(['type'=>'button','title'=>$text['button-view'],'icon'=>$_SESSION['theme']['button_icon_view'],'link'=>$list_row_url]);
echo " </td>\n";