Skip to content

Commit 6cf8e05

Browse files
authored
Merge branch 'develop' into fix/hardening-arg-array-6854
2 parents d28a08c + 67a596d commit 6cf8e05

File tree

6 files changed

+16
-18
lines changed

6 files changed

+16
-18
lines changed

include/global.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@
397397
print $li . 'the credentials in config.php are valid.' . $il;
398398
print $lu . $sp;
399399

400-
if (isset($_REQUEST['display_db_errors']) && !empty($config['DATABASE_ERROR'])) { // @phpstan-ignore-line
400+
if (isrv('display_db_errors') && !empty($config['DATABASE_ERROR'])) { // @phpstan-ignore-line
401401
print $ps . 'The following database errors occurred: ' . $ul;
402402

403403
foreach ($config['DATABASE_ERROR'] as $e) { // @phpstan-ignore-line
@@ -419,7 +419,7 @@
419419
print $li . 'the credentials in config.php are valid and correct.' . $il;
420420
print $lu . $sp;
421421

422-
if (isset($_REQUEST['display_db_errors']) && !empty($config['DATABASE_ERROR'])) { // @phpstan-ignore-line
422+
if (isrv('display_db_errors') && !empty($config['DATABASE_ERROR'])) { // @phpstan-ignore-line
423423
print $ps . 'The following database errors occurred: ' . $ul;
424424

425425
foreach ($config['DATABASE_ERROR'] as $e) { // @phpstan-ignore-line

include/global_languages.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@
4444

4545
// Repair legacy language support
4646
if (!empty($config['i18n_force_language'])) {
47-
$_REQUEST['language'] = $config['i18n_force_language'];
47+
set_request_var('language', $config['i18n_force_language']);
4848
}
4949

50-
if (!empty($_REQUEST['language'])) {
51-
$_REQUEST['language'] = repair_locale($_REQUEST['language']);
50+
if (!isempty_request_var('language')) {
51+
set_request_var('language', repair_locale(grv('language')));
5252
}
5353

5454
// determine whether or not we can support the language
5555
$user_locale = '';
5656

57-
if (!empty($_REQUEST['language']) && !empty($lang2locale[$_REQUEST['language']])) {
57+
if (!isempty_request_var('language') && !empty($lang2locale[grv('language')])) {
5858
// user requests another language
59-
$user_locale = apply_locale($_REQUEST['language']);
59+
$user_locale = apply_locale(grv('language'));
6060
unset($_SESSION['sess_current_date1']);
6161
unset($_SESSION['sess_current_date2']);
6262

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
/**

oauth2.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,25 +89,23 @@
8989
die('Provider missing');
9090
}
9191

92-
if (!isset($_GET['code'])) { // If we don't have an authorization code then get one
92+
if (!isrv('code')) { // If we don't have an authorization code then get one
9393
$authUrl = $provider->getAuthorizationUrl($options);
9494
$_SESSION['oauth2state'] = $provider->getState();
95-
header('Location: ' . $authUrl);
96-
97-
exit;
95+
cacti_redirect($authUrl, false);
9896

9997
// Check given state against previously stored one to mitigate CSRF attack
10098
}
10199

102-
if (empty($_GET['state']) || (isset($_SESSION['oauth2state']) && ($_GET['state'] !== $_SESSION['oauth2state']))) {
100+
if (isempty_request_var('state') || (isset($_SESSION['oauth2state']) && (grv('state') !== $_SESSION['oauth2state']))) {
103101
unset($_SESSION['oauth2state']);
104102

105103
exit('Invalid state');
106104
} else { // Try to get an access token (using the authorization code grant)
107105
$token = $provider->getAccessToken(
108106
'authorization_code',
109107
[
110-
'code' => $_GET['code']
108+
'code' => grv('code')
111109
]
112110
);
113111

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)