Skip to content

Commit 67a596d

Browse files
hardening: modernize string comparisons with PHP 8 functions (#6863) (#6864)
1 parent 61d8e93 commit 67a596d

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

lib/time.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ function get_timespan(array &$span, int $curr_time, int $timespan_given, int $fi
193193
*/
194194
function month_shift(string $shift_size) : bool {
195195
// is monthly shifting required?
196-
return (strpos(cacti_strtolower($shift_size), 'month') !== false);
196+
return (str_contains(cacti_strtolower($shift_size), 'month'));
197197
}
198198

199199
/**

user_admin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,7 +1683,7 @@ function user_realms_edit(string $header_label) : void {
16831683

16841684
$local_user_auth_realms = __($user_auth_realms[$realm], $r['directory']);
16851685

1686-
$pos = (strpos($local_user_auth_realms, '->') !== false ? strpos($local_user_auth_realms, '->') + 2 : 0);
1686+
$pos = (str_contains($local_user_auth_realms, '->') ? strpos($local_user_auth_realms, '->') + 2 : 0);
16871687

16881688
if ($i == 0) {
16891689
print "<tr class='tableHeader'><th class='left' colspan='2'>" . __('Plugin Permissions') . '</th></tr>';
@@ -1718,7 +1718,7 @@ function user_realms_edit(string $header_label) : void {
17181718
$old_value = '';
17191719
}
17201720

1721-
$pos = (strpos($user_auth_realms[$realm], '->') !== false ? strpos($user_auth_realms[$realm], '->') + 2 : 0);
1721+
$pos = (str_contains($user_auth_realms[$realm], '->') ? strpos($user_auth_realms[$realm], '->') + 2 : 0);
17221722

17231723
print '<div class="flexChild">';
17241724
form_checkbox('section' . $realm, $old_value, substr($user_auth_realms[$realm], $pos), '', '', '', '', $name, true);

user_group_admin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,7 +1546,7 @@ function user_group_realms_edit(string $header_label) : void {
15461546

15471547
unset($all_realms[$realm]);
15481548

1549-
$pos = (strpos($user_auth_realms[$realm], '->') !== false ? strpos($user_auth_realms[$realm], '->') + 2 : 0);
1549+
$pos = (str_contains($user_auth_realms[$realm], '->') ? strpos($user_auth_realms[$realm], '->') + 2 : 0);
15501550

15511551
if ($i == 0) {
15521552
print "<tr class='tableHeader'><th colspan='2'>" . __('Plugin Permissions') . '</th></tr>';
@@ -1582,7 +1582,7 @@ function user_group_realms_edit(string $header_label) : void {
15821582
$old_value = '';
15831583
}
15841584

1585-
$pos = (strpos($user_auth_realms[$realm], '->') !== false ? strpos($user_auth_realms[$realm], '->') + 2 : 0);
1585+
$pos = (str_contains($user_auth_realms[$realm], '->') ? strpos($user_auth_realms[$realm], '->') + 2 : 0);
15861586

15871587
print '<div class="flexChild">';
15881588
form_checkbox('section' . $realm, $old_value, substr($user_auth_realms[$realm], $pos), '', '', '', '', $name, true);

0 commit comments

Comments
 (0)