diff --git a/mod/cal.php b/mod/cal.php index 5779b0316a..2cc0b4a592 100644 --- a/mod/cal.php +++ b/mod/cal.php @@ -29,11 +29,11 @@ function cal_init(App $a) } if (Config::get('system', 'block_public') && !local_user() && !remote_user()) { - return; + System::httpExit(403, ['title' => L10n::t('Access denied.')]); } if ($a->argc < 2) { - System::httpExit(403, ["title" => L10n::t('Access denied.')]); + System::httpExit(403, ['title' => L10n::t('Access denied.')]); } Nav::setSelected('events'); @@ -41,7 +41,7 @@ function cal_init(App $a) $nick = $a->argv[1]; $user = DBA::selectFirst('user', [], ['nickname' => $nick, 'blocked' => false]); if (!DBA::isResult($user)) { - return; + System::httpExit(404, ['title' => L10n::t('Page not found.')]); } $a->data['user'] = $user; diff --git a/mod/photos.php b/mod/photos.php index 04d4138fc6..c2b00c7345 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1260,6 +1260,8 @@ function photos_content(App $a) ); if (DBA::isResult($prvnxt)) { + $prv = null; + $nxt = null; foreach ($prvnxt as $z => $entry) { if ($entry['resource-id'] == $ph[0]['resource-id']) { $prv = $z - 1; @@ -1274,8 +1276,12 @@ function photos_content(App $a) } } $edit_suffix = ((($cmd === 'edit') && $can_post) ? '/edit' : ''); - $prevlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix . ($order_field === 'posted' ? '?f=&order=posted' : ''); - $nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix . ($order_field === 'posted' ? '?f=&order=posted' : ''); + if (!is_null($prv)) { + $prevlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix . ($order_field === 'posted' ? '?f=&order=posted' : ''); + } + if (!is_null($nxt)) { + $nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix . ($order_field === 'posted' ? '?f=&order=posted' : ''); + } } } diff --git a/src/App.php b/src/App.php index f583f151a6..d02ea73ca4 100644 --- a/src/App.php +++ b/src/App.php @@ -1399,16 +1399,12 @@ class App } } - if (!empty($_SESSION)) { - $user_theme = defaults($_SESSION, 'theme', $system_theme); - } else { - $user_theme = $system_theme; - } + $user_theme = Core\Session::get('theme', $system_theme); // Specific mobile theme override - if (($this->is_mobile || $this->is_tablet) && defaults($_SESSION, 'show-mobile', true)) { + if (($this->is_mobile || $this->is_tablet) && Core\Session::get('show-mobile', true)) { $system_mobile_theme = Config::get('system', 'mobile-theme'); - $user_mobile_theme = defaults($_SESSION, 'mobile-theme', $system_mobile_theme); + $user_mobile_theme = Core\Session::get('mobile-theme', $system_mobile_theme); // --- means same mobile theme as desktop if (!empty($user_mobile_theme) && $user_mobile_theme !== '---') { diff --git a/src/Core/Session.php b/src/Core/Session.php index b245c675b0..6d059eb4ef 100644 --- a/src/Core/Session.php +++ b/src/Core/Session.php @@ -45,9 +45,24 @@ class Session return isset($_SESSION[$name]); } - public static function get($name) + /** + * Retrieves a key from the session super global or the defaults if the key is missing or the value is falsy. + * + * Handle the case where session_start() hasn't been called and the super global isn't available. + * + * @param string $name + * @param mixed $defaults + * @return mixed + */ + public static function get($name, $defaults = null) { - return defaults($_SESSION, $name, null); + if (isset($_SESSION)) { + $return = defaults($_SESSION, $name, $defaults); + } else { + $return = $defaults; + } + + return $return; } public static function set($name, $value) diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 29601ad32d..2e1af26c76 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -336,9 +336,11 @@ class Profile $subscribe_feed = false; } + $wallmessage = false; + $wallmessage_link = false; + if (remote_user() || (self::getMyURL() && x($profile, 'unkmail') && ($profile['uid'] != local_user()))) { $wallmessage = L10n::t('Message'); - $wallmessage_link = 'wallmessage/' . $profile['nickname']; if (remote_user()) { $r = q( @@ -359,10 +361,9 @@ class Profile $remote_url = $r[0]['url']; $message_path = preg_replace('=(.*)/profile/(.*)=ism', '$1/message/new/', $remote_url); $wallmessage_link = $message_path . base64_encode($profile['addr']); + } else if (!empty($profile['nickname'])) { + $wallmessage_link = 'wallmessage/' . $profile['nickname']; } - } else { - $wallmessage = false; - $wallmessage_link = false; } // show edit profile to yourself diff --git a/src/Util/Proxy.php b/src/Util/Proxy.php index bb26185f46..3473e8d167 100644 --- a/src/Util/Proxy.php +++ b/src/Util/Proxy.php @@ -180,16 +180,8 @@ class Proxy { $query = parse_url($url, PHP_URL_QUERY); $query = html_entity_decode($query); - $query_list = explode('&', $query); - $arr = []; - - foreach ($query_list as $key_value) { - $key_value_list = explode('=', $key_value); - $arr[$key_value_list[0]] = $key_value_list[1]; - } - - unset($url, $query_list, $url); + parse_str($query, $arr); return $arr; }