From 060e887a31cea31c5cafb99c1684ad2d0d71dc27 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 18 Aug 2018 08:20:50 +0200 Subject: [PATCH] And still there are notices that have to be removed ... (#5629) * And still there are notices that have to be removed ... * Notice removed in ACL part * Fix missing fields for notifications * Fixes issue 5630 --- mod/admin.php | 9 ++++++--- mod/lostpass.php | 8 ++++++-- mod/network.php | 12 ++++++------ mod/notifications.php | 4 ++++ mod/removeme.php | 3 ++- mod/viewcontacts.php | 4 ++-- mod/xrd.php | 8 ++++++++ src/Content/Text/BBCode.php | 2 +- src/Core/ACL.php | 10 +++++----- src/Model/Contact.php | 2 +- 10 files changed, 41 insertions(+), 21 deletions(-) diff --git a/mod/admin.php b/mod/admin.php index b2f84d0729..30073c655b 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -1689,11 +1689,14 @@ function admin_page_users_post(App $a) $body = sprintf($body, System::baseUrl(), $user['email'], $result['password'], Config::get('config', 'sitename')); notification([ - 'type' => SYSTEM_EMAIL, + 'type' => SYSTEM_EMAIL, + 'language' => $user['language'], + 'to_name' => $user['username'], 'to_email' => $user['email'], - 'subject' => L10n::t('Registration details for %s', Config::get('config', 'sitename')), + 'uid' => $user['uid'], + 'subject' => L10n::t('Registration details for %s', Config::get('config', 'sitename')), 'preamble' => $preamble, - 'body' => $body]); + 'body' => $body]); } if (x($_POST, 'page_users_block')) { diff --git a/mod/lostpass.php b/mod/lostpass.php index f4e8e1de7d..166da25fc2 100644 --- a/mod/lostpass.php +++ b/mod/lostpass.php @@ -23,7 +23,7 @@ function lostpass_post(App $a) } $condition = ['(`email` = ? OR `nickname` = ?) AND `verified` = 1 AND `blocked` = 0', $loginame, $loginame]; - $user = DBA::selectFirst('user', ['uid', 'username', 'email'], $condition); + $user = DBA::selectFirst('user', ['uid', 'username', 'email', 'language'], $condition); if (!DBA::isResult($user)) { notice(L10n::t('No valid account found.') . EOL); goaway(System::baseUrl()); @@ -69,6 +69,8 @@ function lostpass_post(App $a) notification([ 'type' => SYSTEM_EMAIL, + 'language' => $user['language'], + 'to_name' => $user['username'], 'to_email' => $user['email'], 'uid' => $user['uid'], 'subject' => L10n::t('Password reset requested at %s', $sitename), @@ -85,7 +87,7 @@ function lostpass_content(App $a) if ($a->argc > 1) { $pwdreset_token = $a->argv[1]; - $user = DBA::selectFirst('user', ['uid', 'username', 'email', 'pwdreset_time'], ['pwdreset' => $pwdreset_token]); + $user = DBA::selectFirst('user', ['uid', 'username', 'email', 'pwdreset_time', 'language'], ['pwdreset' => $pwdreset_token]); if (!DBA::isResult($user)) { notice(L10n::t("Request could not be verified. \x28You may have previously submitted it.\x29 Password reset failed.")); @@ -165,6 +167,8 @@ function lostpass_generate_password($user) notification([ 'type' => SYSTEM_EMAIL, + 'language' => $user['language'], + 'to_name' => $user['username'], 'to_email' => $user['email'], 'uid' => $user['uid'], 'subject' => L10n::t('Your password has been changed at %s', $sitename), diff --git a/mod/network.php b/mod/network.php index b99b4a2593..bda4ae6107 100644 --- a/mod/network.php +++ b/mod/network.php @@ -418,9 +418,9 @@ function networkFlatView(App $a, $update = 0) 'allow_location' => $a->user['allow_location'], 'default_location' => $a->user['default-location'], 'nickname' => $a->user['nickname'], - 'lockstate' => (((is_array($a->user) && - ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || - (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))) ? 'lock' : 'unlock'), + 'lockstate' => (is_array($a->user) && + (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || + strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock'), 'default_perms' => ACL::getDefaultUserPermissions($a->user), 'acl' => ACL::getFullSelectorHTML($a->user, true), 'bang' => '', @@ -574,9 +574,9 @@ function networkThreadedView(App $a, $update, $parent) 'allow_location' => $a->user['allow_location'], 'default_location' => $a->user['default-location'], 'nickname' => $a->user['nickname'], - 'lockstate' => ((($gid) || ($cid) || ($nets) || (is_array($a->user) && - ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || - (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))) ? 'lock' : 'unlock'), + 'lockstate' => ($gid || $cid || $nets || (is_array($a->user) && + (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || + strlen($a->user['deny_cid']) || strlen($a->user['deny_gid']))) ? 'lock' : 'unlock'), 'default_perms' => ACL::getDefaultUserPermissions($a->user), 'acl' => ACL::getFullSelectorHTML($a->user, true, $default_permissions), 'bang' => (($gid || $cid || $nets) ? '!' : ''), diff --git a/mod/notifications.php b/mod/notifications.php index 52521b017a..145c384350 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -133,6 +133,10 @@ function notifications_content(App $a) $notif_tpl = get_markup_template('notifications.tpl'); + if (!isset($notifs['ident'])) { + logger('Missing data in notifs: ' . System::callstack(20), LOGGER_DEBUG); + } + // Process the data for template creation if ($notifs['ident'] === 'introductions') { $sugg = get_markup_template('suggestions.tpl'); diff --git a/mod/removeme.php b/mod/removeme.php index 26853a38e7..b386ec12f5 100644 --- a/mod/removeme.php +++ b/mod/removeme.php @@ -38,7 +38,7 @@ function removeme_post(App $a) // send email to admins $admin_mails = explode(",", str_replace(" ", "", Config::get('config', 'admin_email'))); foreach ($admin_mails as $mail) { - $admin = DBA::selectFirst('user', ['uid', 'language', 'email'], ['email' => $mail]); + $admin = DBA::selectFirst('user', ['uid', 'language', 'email', 'username'], ['email' => $mail]); if (!DBA::isResult($admin)) { continue; } @@ -48,6 +48,7 @@ function removeme_post(App $a) 'preamble' => L10n::t('On your Friendica node an user deleted their account. Please ensure that their data is removed from the backups.'), 'body' => L10n::t('The user id is %d', local_user()), 'to_email' => $admin['email'], + 'to_name' => $admin['username'], 'uid' => $admin['uid'], 'language' => $admin['language'] ? $admin['language'] : 'en', 'show_in_notification_page' => false diff --git a/mod/viewcontacts.php b/mod/viewcontacts.php index 9219f49d9b..9446470e1b 100644 --- a/mod/viewcontacts.php +++ b/mod/viewcontacts.php @@ -17,7 +17,7 @@ use Friendica\Core\System; function viewcontacts_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) { @@ -32,7 +32,7 @@ function viewcontacts_init(App $a) ); if (!DBA::isResult($r)) { - return; + System::httpExit(404, ["title" => L10n::t('Page not found.')]); } $a->data['user'] = $r[0]; diff --git a/mod/xrd.php b/mod/xrd.php index 0cc5dba45b..61505f2996 100644 --- a/mod/xrd.php +++ b/mod/xrd.php @@ -12,6 +12,10 @@ use Friendica\Protocol\Salmon; function xrd_init(App $a) { if ($a->argv[0] == 'xrd') { + if (empty($_GET['uri'])) { + killme(); + } + $uri = urldecode(notags(trim($_GET['uri']))); if (defaults($_SERVER, 'HTTP_ACCEPT', '') == 'application/jrd+json') { $mode = 'json'; @@ -19,6 +23,10 @@ function xrd_init(App $a) $mode = 'xml'; } } else { + if (empty($_GET['resource'])) { + killme(); + } + $uri = urldecode(notags(trim($_GET['resource']))); if (defaults($_SERVER, 'HTTP_ACCEPT', '') == 'application/xrd+xml') { $mode = 'xml'; diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index b5654a2d5b..41f89e65dc 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -599,7 +599,7 @@ class BBCode extends BaseObject } } - return trim($data["text"] . ' ' . $return . ' ' . $data["after"]); + return trim(defaults($data, 'text', '') . ' ' . $return . ' ' . defaults($data, 'after', '')); } public static function removeShareInformation($Text, $plaintext = false, $nolink = false) diff --git a/src/Core/ACL.php b/src/Core/ACL.php index 20db290877..164333aae4 100644 --- a/src/Core/ACL.php +++ b/src/Core/ACL.php @@ -296,10 +296,10 @@ class ACL extends BaseObject '$showall' => L10n::t('Visible to everybody'), '$show' => L10n::t('show'), '$hide' => L10n::t('don\'t show'), - '$allowcid' => json_encode($default_permissions['allow_cid']), - '$allowgid' => json_encode($default_permissions['allow_gid']), - '$denycid' => json_encode($default_permissions['deny_cid']), - '$denygid' => json_encode($default_permissions['deny_gid']), + '$allowcid' => json_encode(defaults($default_permissions, 'allow_cid', '')), + '$allowgid' => json_encode(defaults($default_permissions, 'allow_gid', '')), + '$denycid' => json_encode(defaults($default_permissions, 'deny_cid', '')), + '$denygid' => json_encode(defaults($default_permissions, 'deny_gid', '')), '$networks' => $show_jotnets, '$emailcc' => L10n::t('CC: email addresses'), '$emtitle' => L10n::t('Example: bob@example.com, mary@example.com'), @@ -324,7 +324,7 @@ class ACL extends BaseObject */ public static function contactAutocomplete($search, $mode) { - if ((Config::get('system', 'block_public')) && (!local_user()) && (!remote_user())) { + if (Config::get('system', 'block_public') && !local_user() && !remote_user()) { return []; } diff --git a/src/Model/Contact.php b/src/Model/Contact.php index ddca508561..0d3f7e8789 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -366,7 +366,7 @@ class Contact extends BaseObject { if (!isset($contact['url'])) { - logger('Empty contact. ' . System::callstack(10), LOGGER_DEBUG); + logger('Empty contact: ' . json_encode($contact) . ' - ' . System::callstack(20), LOGGER_DEBUG); } // Contact already archived or "self" contact? => nothing to do