Merge pull request #5563 from MrPetovan/bug/5470-fix-various-notices

Fix various notices
This commit is contained in:
Michael Vogel 2018-08-07 21:34:47 +02:00 committed by GitHub
commit eaf81e5e66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 27 deletions

View File

@ -29,11 +29,11 @@ function cal_init(App $a)
} }
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) { if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
return; System::httpExit(403, ['title' => L10n::t('Access denied.')]);
} }
if ($a->argc < 2) { if ($a->argc < 2) {
System::httpExit(403, ["title" => L10n::t('Access denied.')]); System::httpExit(403, ['title' => L10n::t('Access denied.')]);
} }
Nav::setSelected('events'); Nav::setSelected('events');
@ -41,7 +41,7 @@ function cal_init(App $a)
$nick = $a->argv[1]; $nick = $a->argv[1];
$user = DBA::selectFirst('user', [], ['nickname' => $nick, 'blocked' => false]); $user = DBA::selectFirst('user', [], ['nickname' => $nick, 'blocked' => false]);
if (!DBA::isResult($user)) { if (!DBA::isResult($user)) {
return; System::httpExit(404, ['title' => L10n::t('Page not found.')]);
} }
$a->data['user'] = $user; $a->data['user'] = $user;

View File

@ -1260,6 +1260,8 @@ function photos_content(App $a)
); );
if (DBA::isResult($prvnxt)) { if (DBA::isResult($prvnxt)) {
$prv = null;
$nxt = null;
foreach ($prvnxt as $z => $entry) { foreach ($prvnxt as $z => $entry) {
if ($entry['resource-id'] == $ph[0]['resource-id']) { if ($entry['resource-id'] == $ph[0]['resource-id']) {
$prv = $z - 1; $prv = $z - 1;
@ -1274,8 +1276,12 @@ function photos_content(App $a)
} }
} }
$edit_suffix = ((($cmd === 'edit') && $can_post) ? '/edit' : ''); $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' : ''); if (!is_null($prv)) {
$nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix . ($order_field === 'posted' ? '?f=&order=posted' : ''); $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' : '');
}
} }
} }

View File

@ -1399,16 +1399,12 @@ class App
} }
} }
if (!empty($_SESSION)) { $user_theme = Core\Session::get('theme', $system_theme);
$user_theme = defaults($_SESSION, 'theme', $system_theme);
} else {
$user_theme = $system_theme;
}
// Specific mobile theme override // 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'); $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 // --- means same mobile theme as desktop
if (!empty($user_mobile_theme) && $user_mobile_theme !== '---') { if (!empty($user_mobile_theme) && $user_mobile_theme !== '---') {

View File

@ -45,9 +45,24 @@ class Session
return isset($_SESSION[$name]); 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) public static function set($name, $value)

View File

@ -336,9 +336,11 @@ class Profile
$subscribe_feed = false; $subscribe_feed = false;
} }
$wallmessage = false;
$wallmessage_link = false;
if (remote_user() || (self::getMyURL() && x($profile, 'unkmail') && ($profile['uid'] != local_user()))) { if (remote_user() || (self::getMyURL() && x($profile, 'unkmail') && ($profile['uid'] != local_user()))) {
$wallmessage = L10n::t('Message'); $wallmessage = L10n::t('Message');
$wallmessage_link = 'wallmessage/' . $profile['nickname'];
if (remote_user()) { if (remote_user()) {
$r = q( $r = q(
@ -359,10 +361,9 @@ class Profile
$remote_url = $r[0]['url']; $remote_url = $r[0]['url'];
$message_path = preg_replace('=(.*)/profile/(.*)=ism', '$1/message/new/', $remote_url); $message_path = preg_replace('=(.*)/profile/(.*)=ism', '$1/message/new/', $remote_url);
$wallmessage_link = $message_path . base64_encode($profile['addr']); $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 // show edit profile to yourself

View File

@ -180,16 +180,8 @@ class Proxy
{ {
$query = parse_url($url, PHP_URL_QUERY); $query = parse_url($url, PHP_URL_QUERY);
$query = html_entity_decode($query); $query = html_entity_decode($query);
$query_list = explode('&', $query);
$arr = []; parse_str($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);
return $arr; return $arr;
} }