From 7052da745c17029971459fda2098bb3c917fab9f Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 11 Aug 2017 21:50:46 +0000 Subject: [PATCH 1/3] Issue 3615: Probing sometimes returned an empty "addr" field --- src/Network/Probe.php | 54 +++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Network/Probe.php b/src/Network/Probe.php index f54db70a62..5a70247afc 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -135,7 +135,7 @@ class Probe { $xrd_data = array(); foreach ($links["xrd"]["link"] as $value => $link) { - if (isset($link["@attributes"])) { + if (!empty($link["@attributes"])) { $attributes = $link["@attributes"]; } elseif ($value == "@attributes") { $attributes = $link; @@ -232,7 +232,7 @@ class Probe { } $host = $parts["host"]; - if (isset($parts["port"])) { + if (!empty($parts["port"])) { $host .= ':'.$parts["port"]; } @@ -271,7 +271,7 @@ class Probe { // Special treatment for Mastodon // Problem is that Mastodon uses an URL format like http://domain.tld/@nick // But the webfinger for this format fails. - if (!$webfinger && isset($nick)) { + if (!$webfinger && !empty($nick)) { // Mastodon uses a "@" as prefix for usernames in their url format $nick = ltrim($nick, '@'); @@ -339,8 +339,8 @@ class Probe { $data["photo"] = App::get_baseurl().'/images/person-175.jpg'; } - if (!isset($data["name"]) || ($data["name"] == "")) { - if (isset($data["nick"])) { + if (empty($data["name"])) { + if (!empty($data["nick"])) { $data["name"] = $data["nick"]; } @@ -349,7 +349,7 @@ class Probe { } } - if (!isset($data["nick"]) || ($data["nick"] == "")) { + if (empty($data["nick"])) { $data["nick"] = strtolower($data["name"]); if (strpos($data['nick'], ' ')) { @@ -480,9 +480,9 @@ class Probe { private static function detect($uri, $network, $uid) { $parts = parse_url($uri); - if (isset($parts["scheme"]) && isset($parts["host"]) && isset($parts["path"])) { + if (!empty($parts["scheme"]) && !empty($parts["host"]) && !empty($parts["path"])) { $host = $parts["host"]; - if (isset($parts["port"])) { + if (!empty($parts["port"])) { $host .= ':'.$parts["port"]; } @@ -609,18 +609,18 @@ class Probe { } else { // We overwrite the detected nick with our try if the previois routines hadn't detected it. // Additionally it is overwritten when the nickname doesn't make sense (contains spaces). - if ((!isset($result["nick"]) || ($result["nick"] == "") || (strstr($result["nick"], " "))) && ($nick != "")) { + if ((empty($result["nick"]) || (strstr($result["nick"], " "))) && ($nick != "")) { $result["nick"] = $nick; } - if ((!isset($result["addr"]) || ($result["addr"] == "")) && ($addr != "")) { + if (empty($result["addr"]) && ($addr != "")) { $result["addr"] = $addr; } } logger($uri." is ".$result["network"], LOGGER_DEBUG); - if (!isset($result["baseurl"]) || ($result["baseurl"] == "")) { + if (empty($result["baseurl"])) { $pos = strpos($result["url"], $host); if ($pos) { $result["baseurl"] = substr($result["url"], 0, $pos).$host; @@ -672,18 +672,18 @@ class Probe { $webfinger = array(); - if (isset($xrd_arr["xrd"]["subject"])) { + if (!empty($xrd_arr["xrd"]["subject"])) { $webfinger["subject"] = $xrd_arr["xrd"]["subject"]; } - if (isset($xrd_arr["xrd"]["alias"])) { + if (!empty($xrd_arr["xrd"]["alias"])) { $webfinger["aliases"] = $xrd_arr["xrd"]["alias"]; } $webfinger["links"] = array(); foreach ($xrd_arr["xrd"]["link"] as $value => $data) { - if (isset($data["@attributes"])) { + if (!empty($data["@attributes"])) { $attributes = $data["@attributes"]; } elseif ($value == "@attributes") { $attributes = $data; @@ -724,23 +724,23 @@ class Probe { return false; } - if (isset($json["fn"])) { + if (!empty($json["fn"])) { $data["name"] = $json["fn"]; } - if (isset($json["addr"])) { + if (!empty($json["addr"])) { $data["addr"] = $json["addr"]; } - if (isset($json["nick"])) { + if (!empty($json["nick"])) { $data["nick"] = $json["nick"]; } - if (isset($json["comm"])) { + if (!empty($json["comm"])) { $data["community"] = $json["comm"]; } - if (isset($json["tags"])) { + if (!empty($json["tags"])) { $keywords = implode(" ", $json["tags"]); if ($keywords != "") { $data["keywords"] = $keywords; @@ -752,31 +752,31 @@ class Probe { $data["location"] = $location; } - if (isset($json["about"])) { + if (!empty($json["about"])) { $data["about"] = $json["about"]; } - if (isset($json["key"])) { + if (!empty($json["key"])) { $data["pubkey"] = $json["key"]; } - if (isset($json["photo"])) { + if (!empty($json["photo"])) { $data["photo"] = $json["photo"]; } - if (isset($json["dfrn-request"])) { + if (!empty($json["dfrn-request"])) { $data["request"] = $json["dfrn-request"]; } - if (isset($json["dfrn-confirm"])) { + if (!empty($json["dfrn-confirm"])) { $data["confirm"] = $json["dfrn-confirm"]; } - if (isset($json["dfrn-notify"])) { + if (!empty($json["dfrn-notify"])) { $data["notify"] = $json["dfrn-notify"]; } - if (isset($json["dfrn-poll"])) { + if (!empty($json["dfrn-poll"])) { $data["poll"] = $json["dfrn-poll"]; } @@ -1008,7 +1008,7 @@ class Probe { // We don't have a width. So we just take everything that we got. // This is a Hubzilla workaround which doesn't send a width. - if ((sizeof($avatar) == 0) && isset($attr["src"])) { + if ((sizeof($avatar) == 0) && !empty($attr["src"])) { $avatar[] = $attr["src"]; } } From 51f6c469234209c8c3bff3e080daf8271f00000b Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 12 Aug 2017 05:08:45 +0000 Subject: [PATCH 2/3] Issue 3616: Don't create notifications for forum accounts --- include/enotify.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/enotify.php b/include/enotify.php index 39665d14d4..3b5672dcd8 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -45,9 +45,14 @@ function notification($params) { if (empty($sender_email)) $sender_email = t('noreply').'@'.$hostname; - $user = q("SELECT `nickname` FROM `user` WHERE `uid` = %d", intval($params['uid'])); - if ($user) - $nickname = $user[0]["nickname"]; + $user = dba::select('user', array('nickname', 'page-flags'), + array('uid' => $params['uid']), array('limit' => 1)); + + // There is no need to create notifications for forum accounts + if (!dbm::is_result($user) || in_array($user["page-flags"], array(PAGE_COMMUNITY, PAGE_PRVGROUP))) { + return; + } + $nickname = $user["nickname"]; // with $params['show_in_notification_page'] == false, the notification isn't inserted into // the database, and an email is sent if applicable. From 3b67ef3e9cca8f7a8e5e43521ac980d3ac27b71d Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sat, 12 Aug 2017 07:46:37 +0200 Subject: [PATCH 3/3] wrong url --- mod/invite.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/invite.php b/mod/invite.php index 0b8f5046f7..5982574fad 100644 --- a/mod/invite.php +++ b/mod/invite.php @@ -145,7 +145,7 @@ function invite_content(App $a) { . $linktxt . "\r\n" . "\r\n" . (($invonly) ? t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') .t('Once you have registered, please connect with me via my profile page at:') . "\r\n" . "\r\n" . App::get_baseurl() . '/profile/' . $a->user['nickname'] - . "\r\n" . "\r\n" . t('For more information about the Friendica project and why we feel it is important, please visit http://friendica.com') . "\r\n" . "\r\n" , + . "\r\n" . "\r\n" . t('For more information about the Friendica project and why we feel it is important, please visit http://friendi.ca') . "\r\n" . "\r\n" , '$submit' => t('Submit') ));