Avoid warnings from probe

This commit is contained in:
Michael 2017-08-29 04:51:02 +00:00
parent 0c1c39b679
commit 4bc2076763

View File

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