Merge pull request #6270 from MrPetovan/bug/5932-fix-notices

Fix various notices
This commit is contained in:
Michael Vogel 2018-12-16 08:41:28 +01:00 committed by GitHub
commit b6623216f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 17 deletions

View File

@ -626,7 +626,7 @@ class BBCode extends BaseObject
$data["title"] = $data["url"]; $data["title"] = $data["url"];
} }
if (($data["text"] == "") && ($data["title"] != "") && ($data["url"] == "")) { if (empty($data["text"]) && !empty($data["title"]) && empty($data["url"])) {
return $data["title"] . $data["after"]; return $data["title"] . $data["after"];
} }

View File

@ -966,8 +966,8 @@ class GContact
$statistics = json_decode($curlResult->getBody()); $statistics = json_decode($curlResult->getBody());
if (!empty($statistics->config)) { if (!empty($statistics->config->instance_address)) {
if ($statistics->config->instance_with_ssl) { if (!empty($statistics->config->instance_with_ssl)) {
$server = "https://"; $server = "https://";
} else { } else {
$server = "http://"; $server = "http://";
@ -976,8 +976,8 @@ class GContact
$server .= $statistics->config->instance_address; $server .= $statistics->config->instance_address;
$hostname = $statistics->config->instance_address; $hostname = $statistics->config->instance_address;
} elseif (!empty($statistics)) { } elseif (!empty($statistics->instance_address)) {
if ($statistics->instance_with_ssl) { if (!empty($statistics->instance_with_ssl)) {
$server = "https://"; $server = "https://";
} else { } else {
$server = "http://"; $server = "http://";

View File

@ -117,7 +117,7 @@ class Email
return $ret; return $ret;
} }
if (!$struc->parts) { if (empty($struc->parts)) {
$ret['body'] = self::messageGetPart($mbox, $uid, $struc, 0, 'html'); $ret['body'] = self::messageGetPart($mbox, $uid, $struc, 0, 'html');
$html = $ret['body']; $html = $ret['body'];
@ -482,13 +482,11 @@ class Email
'[\r\n]\s*-----BEGIN PGP SIGNATURE-----\s*[\r\n].*'. '[\r\n]\s*-----BEGIN PGP SIGNATURE-----\s*[\r\n].*'.
'[\r\n]\s*-----END PGP SIGNATURE-----(.*)/is'; '[\r\n]\s*-----END PGP SIGNATURE-----(.*)/is';
preg_match($pattern, $message, $result); if (preg_match($pattern, $message, $result)) {
$cleaned = trim($result[1].$result[2].$result[3]);
$cleaned = trim($result[1].$result[2].$result[3]); $cleaned = str_replace(["\n- --\n", "\n- -"], ["\n-- \n", "\n-"], $cleaned);
} else {
$cleaned = str_replace(["\n- --\n", "\n- -"], ["\n-- \n", "\n-"], $cleaned);
if ($cleaned == '') {
$cleaned = $message; $cleaned = $message;
} }

View File

@ -1543,8 +1543,10 @@ class OStatus
*/ */
private static function constructObjecttype(array $item) private static function constructObjecttype(array $item)
{ {
if (in_array($item['object-type'], [ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT])) if (!empty($item['object-type']) && in_array($item['object-type'], [ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT])) {
return $item['object-type']; return $item['object-type'];
}
return ACTIVITY_OBJ_NOTE; return ACTIVITY_OBJ_NOTE;
} }

View File

@ -1375,7 +1375,7 @@ class PortableContact
$site_name = $data['site_name']; $site_name = $data['site_name'];
} }
$info = $data['info']; $info = defaults($data, 'info', '');
$register_policy = defaults($data, 'register_policy', REGISTER_CLOSED); $register_policy = defaults($data, 'register_policy', REGISTER_CLOSED);
if (in_array($register_policy, ['REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'])) { if (in_array($register_policy, ['REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'])) {
$register_policy = constant($data['register_policy']); $register_policy = constant($data['register_policy']);
@ -1383,7 +1383,7 @@ class PortableContact
Logger::log("Register policy '$register_policy' from $server_url is invalid."); Logger::log("Register policy '$register_policy' from $server_url is invalid.");
$register_policy = REGISTER_CLOSED; // set a default value $register_policy = REGISTER_CLOSED; // set a default value
} }
$platform = $data['platform']; $platform = defaults($data, 'platform', '');
} }
} }
} }

View File

@ -362,7 +362,7 @@ class Network
/// @TODO Really suppress function outcomes? Why not find them + debug them? /// @TODO Really suppress function outcomes? Why not find them + debug them?
$h = @parse_url($url); $h = @parse_url($url);
if ((is_array($h)) && (@dns_get_record($h['host'], DNS_A + DNS_CNAME) || filter_var($h['host'], FILTER_VALIDATE_IP) )) { if (!empty($h['host']) && (@dns_get_record($h['host'], DNS_A + DNS_CNAME) || filter_var($h['host'], FILTER_VALIDATE_IP) )) {
return $url; return $url;
} }

View File

@ -35,7 +35,7 @@ class GProbe {
$result = Cache::get("gprobe:".$urlparts["host"]); $result = Cache::get("gprobe:".$urlparts["host"]);
if (!is_null($result)) { if (!is_null($result)) {
if (in_array($result["network"], [Protocol::FEED, Protocol::PHANTOM])) { if (in_array($result["network"], [Protocol::FEED, Protocol::PHANTOM])) {
Logger::log("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), Logger::DEBUG); Logger::log("DDoS attempt detected for ".$urlparts["host"]." by ".defaults($_SERVER, "REMOTE_ADDR", '').". server data: ".print_r($_SERVER, true), Logger::DEBUG);
return; return;
} }
} }