]> git.mxchange.org Git - friendica.git/commitdiff
Avoid warnings from probe
authorMichael <heluecht@pirati.ca>
Tue, 29 Aug 2017 04:51:02 +0000 (04:51 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 29 Aug 2017 04:51:02 +0000 (04:51 +0000)
src/Network/Probe.php

index aa2e27c81d500dcfdf9514a377aaf4c2f58abba2..10aac01393052982ccbeaa1eee063765e68d34c3 100644 (file)
@@ -1139,39 +1139,41 @@ class Probe {
                        $data["addr"] = str_replace('acct:', '', $webfinger["subject"]);
                }
                $pubkey = "";
-               foreach ($webfinger["links"] as $link) {
-                       if (($link["rel"] == "http://webfinger.net/rel/profile-page")
-                               && ($link["type"] == "text/html")
-                               && ($link["href"] != "")
-                       ) {
-                               $data["url"] = $link["href"];
-                       } elseif (($link["rel"] == "salmon") && ($link["href"] != "")) {
-                               $data["notify"] = $link["href"];
-                       } elseif (($link["rel"] == NAMESPACE_FEED) && ($link["href"] != "")) {
-                               $data["poll"] = $link["href"];
-                       } elseif (($link["rel"] == "magic-public-key") && ($link["href"] != "")) {
-                               $pubkey = $link["href"];
-
-                               if (substr($pubkey, 0, 5) === 'data:') {
-                                       if (strstr($pubkey, ',')) {
-                                               $pubkey = substr($pubkey, strpos($pubkey, ',') + 1);
-                                       } else {
-                                               $pubkey = substr($pubkey, 5);
-                                       }
-                               } elseif (normalise_link($pubkey) == 'http://') {
-                                       $ret = z_fetch_url($pubkey);
-                                       if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
-                                               return false;
+               if (is_array($webfinger["links"])) {
+                       foreach ($webfinger["links"] as $link) {
+                               if (($link["rel"] == "http://webfinger.net/rel/profile-page")
+                                       && ($link["type"] == "text/html")
+                                       && ($link["href"] != "")
+                               ) {
+                                       $data["url"] = $link["href"];
+                               } elseif (($link["rel"] == "salmon") && ($link["href"] != "")) {
+                                       $data["notify"] = $link["href"];
+                               } elseif (($link["rel"] == NAMESPACE_FEED) && ($link["href"] != "")) {
+                                       $data["poll"] = $link["href"];
+                               } elseif (($link["rel"] == "magic-public-key") && ($link["href"] != "")) {
+                                       $pubkey = $link["href"];
+
+                                       if (substr($pubkey, 0, 5) === 'data:') {
+                                               if (strstr($pubkey, ',')) {
+                                                       $pubkey = substr($pubkey, strpos($pubkey, ',') + 1);
+                                               } else {
+                                                       $pubkey = substr($pubkey, 5);
+                                               }
+                                       } elseif (normalise_link($pubkey) == 'http://') {
+                                               $ret = z_fetch_url($pubkey);
+                                               if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
+                                                       return false;
+                                               }
+                                               $pubkey = $ret['body'];
                                        }
-                                       $pubkey = $ret['body'];
-                               }
 
-                               $key = explode(".", $pubkey);
+                                       $key = explode(".", $pubkey);
 
-                               if (sizeof($key) >= 3) {
-                                       $m = base64url_decode($key[1]);
-                                       $e = base64url_decode($key[2]);
-                                       $data["pubkey"] = metopem($m, $e);
+                                       if (sizeof($key) >= 3) {
+                                               $m = base64url_decode($key[1]);
+                                               $e = base64url_decode($key[2]);
+                                               $data["pubkey"] = metopem($m, $e);
+                                       }
                                }
                        }
                }