From fcfb9e975836c4abbbfd339d46bf8ea937747e57 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 7 Sep 2022 12:50:46 +0000 Subject: fix random php warnings --- include/auth.php | 4 ++-- include/bbcode.php | 17 +++++++++++------ include/channel.php | 6 +++--- include/conversation.php | 8 +++++++- include/nav.php | 8 +++++--- include/security.php | 3 ++- 6 files changed, 30 insertions(+), 16 deletions(-) (limited to 'include') diff --git a/include/auth.php b/include/auth.php index 07b8e2971..8a83f16fe 100644 --- a/include/auth.php +++ b/include/auth.php @@ -189,7 +189,7 @@ if((isset($_SESSION)) && (x($_SESSION, 'authenticated')) && call_hooks('logging_out', $args); - if($_SESSION['delegate'] && $_SESSION['delegate_push']) { + if(isset($_SESSION['delegate']) && isset($_SESSION['delegate_push'])) { $_SESSION = $_SESSION['delegate_push']; info( t('Delegation session ended.') . EOL); } @@ -337,7 +337,7 @@ else { // (i.e. expire when the browser is closed), even when there's a time expiration // on the cookie - $remember = $_POST['main_login_remember'] ?? $_POST['modal_login_remember']; + $remember = $_POST['main_login_remember'] ?? $_POST['modal_login_remember'] ?? false; if($remember) { $_SESSION['remember_me'] = 1; diff --git a/include/bbcode.php b/include/bbcode.php index 794cb25d0..100991afd 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -502,32 +502,37 @@ function bb_ShareAttributes($match) { $author = ""; preg_match("/author='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") + if (isset($matches[1]) && $matches[1] !== '') { $author = urldecode($matches[1]); + } $link = ""; preg_match("/link='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") + if (isset($matches[1]) && $matches[1] !== '') { $link = $matches[1]; + } $avatar = ""; preg_match("/avatar='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") + if (isset($matches[1]) && $matches[1] !== '') { $avatar = $matches[1]; + } $profile = ""; preg_match("/profile='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") + if (isset($matches[1]) && $matches[1] !== '') { $profile = $matches[1]; + } $posted = ""; preg_match("/posted='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") + if (isset($matches[1]) && $matches[1] !== '') { $posted = $matches[1]; + } $auth = ""; preg_match("/auth='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") { + if (isset($matches[1]) && $matches[1] !== '') { if($matches[1] === 'true') $auth = true; else diff --git a/include/channel.php b/include/channel.php index 4e84b1b32..0d02dff1e 100644 --- a/include/channel.php +++ b/include/channel.php @@ -2002,7 +2002,7 @@ function atoken_delete_and_sync($channel_id, $atoken_guid) { * @return int */ function get_theme_uid() { - $uid = (($_REQUEST['puid']) ? intval($_REQUEST['puid']) : 0); + $uid = $_REQUEST['puid'] ?? 0; if(local_channel()) { if((get_pconfig(local_channel(),'system','always_my_theme')) || (! $uid)) return local_channel(); @@ -2010,10 +2010,10 @@ function get_theme_uid() { if(! $uid) { $x = get_sys_channel(); if($x) - return $x['channel_id']; + return intval($x['channel_id']); } - return $uid; + return intval($uid); } /** diff --git a/include/conversation.php b/include/conversation.php index 685e6b15b..d450bc609 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1431,7 +1431,13 @@ function hz_status_editor($a, $x, $popup = false) { ]; call_hooks('jot_header_tpl_filter',$tplmacros); - App::$page['htmlhead'] .= replace_macros($tpl, $tplmacros); + + if (isset(App::$page['htmlhead'])) { + App::$page['htmlhead'] .= replace_macros($tpl, $tplmacros); + } + else { + App::$page['htmlhead'] = replace_macros($tpl, $tplmacros); + } $tpl = get_markup_template('jot.tpl'); diff --git a/include/nav.php b/include/nav.php index c2c87232b..0097a206b 100644 --- a/include/nav.php +++ b/include/nav.php @@ -19,6 +19,8 @@ function nav($template = 'default') { App::$page['htmlhead'] .= ''; $is_owner = (((local_channel()) && ((App::$profile_uid == local_channel()) || (App::$profile_uid == 0))) ? true : false); $observer = App::get_observer(); + $chans = []; + if (local_channel()) { $channel = App::get_channel(); @@ -35,7 +37,7 @@ function nav($template = 'default') { $sitelocation = (($is_owner) ? '' : App::$profile['reddress']); } else { - $sitelocation = ((App::$profile['reddress']) ? App::$profile['reddress'] : '@' . App::get_hostname()); + $sitelocation = ((isset(App::$profile['reddress'])) ? App::$profile['reddress'] : '@' . App::get_hostname()); } require_once('include/conversation.php'); @@ -336,8 +338,8 @@ function nav($template = 'default') { '$featured_apps' => t('Featured Apps'), '$url' => (($url) ? $url : z_root() . '/' . App::$cmd), '$settings_url' => $settings_url, - '$name' => ((!$is_owner) ? App::$profile['fullname'] : ''), - '$thumb' => ((!$is_owner) ? App::$profile['thumb'] : ''), + '$name' => ((!$is_owner && isset(App::$profile['fullname'])) ? App::$profile['fullname'] : ''), + '$thumb' => ((!$is_owner && isset(App::$profile['thumb'])) ? App::$profile['thumb'] : ''), '$form_security_token' => get_form_security_token('pconfig') ]); diff --git a/include/security.php b/include/security.php index 881adb818..de9f1f337 100644 --- a/include/security.php +++ b/include/security.php @@ -604,7 +604,8 @@ function public_permissions_sql($observer_hash) { function get_form_security_token($typename = '') { $timestamp = time(); - $sec_hash = hash('whirlpool', App::$observer['xchan_guid'] . ((local_channel()) ? App::$channel['channel_prvkey'] : '') . session_id() . $timestamp . $typename); + $guid = App::$observer['xchan_guid'] ?? ''; + $sec_hash = hash('whirlpool', $guid . ((local_channel()) ? App::$channel['channel_prvkey'] : '') . session_id() . $timestamp . $typename); return $timestamp . '.' . $sec_hash; } -- cgit v1.2.3