]> git.mxchange.org Git - friendica.git/commitdiff
Fix various notices
authorHypolite Petovan <hypolite@mrpetovan.com>
Sat, 15 Dec 2018 09:32:47 +0000 (04:32 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 15 Dec 2018 09:32:47 +0000 (04:32 -0500)
src/Content/Text/BBCode.php
src/Model/GContact.php
src/Protocol/Email.php
src/Protocol/OStatus.php
src/Protocol/PortableContact.php
src/Util/Network.php
src/Worker/GProbe.php

index e304f47637eeaf1b0b2d9cb10a0734d35340685c..6d2b152ee8de490c8013f3364023b2ac63aaeb8a 100644 (file)
@@ -626,7 +626,7 @@ class BBCode extends BaseObject
                        $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"];
                }
 
index 3acffb059d796f8f1a65efab0fe0854ab0e828fe..44d1edecd78c5dcdf2cec638600e7e8993ee4178 100644 (file)
@@ -966,8 +966,8 @@ class GContact
 
                $statistics = json_decode($curlResult->getBody());
 
-               if (!empty($statistics->config)) {
-                       if ($statistics->config->instance_with_ssl) {
+               if (!empty($statistics->config->instance_address)) {
+                       if (!empty($statistics->config->instance_with_ssl)) {
                                $server = "https://";
                        } else {
                                $server = "http://";
@@ -976,8 +976,8 @@ class GContact
                        $server .= $statistics->config->instance_address;
 
                        $hostname = $statistics->config->instance_address;
-               } elseif (!empty($statistics)) {
-                       if ($statistics->instance_with_ssl) {
+               } elseif (!empty($statistics->instance_address)) {
+                       if (!empty($statistics->instance_with_ssl)) {
                                $server = "https://";
                        } else {
                                $server = "http://";
index ba8c311901a9bc241db400ee96f45dd0253469ba..358ff27db00bb36e02d814dab0a912c1d70e0f8d 100644 (file)
@@ -117,7 +117,7 @@ class Email
                        return $ret;
                }
 
-               if (!$struc->parts) {
+               if (empty($struc->parts)) {
                        $ret['body'] = self::messageGetPart($mbox, $uid, $struc, 0, 'html');
                        $html = $ret['body'];
 
@@ -482,13 +482,11 @@ class Email
                        '[\r\n]\s*-----BEGIN PGP SIGNATURE-----\s*[\r\n].*'.
                        '[\r\n]\s*-----END PGP SIGNATURE-----(.*)/is';
 
-               preg_match($pattern, $message, $result);
-
-               $cleaned = trim($result[1].$result[2].$result[3]);
+               if (preg_match($pattern, $message, $result)) {
+                       $cleaned = trim($result[1].$result[2].$result[3]);
 
-               $cleaned = str_replace(["\n- --\n", "\n- -"], ["\n-- \n", "\n-"], $cleaned);
-
-               if ($cleaned == '') {
+                       $cleaned = str_replace(["\n- --\n", "\n- -"], ["\n-- \n", "\n-"], $cleaned);
+               } else {
                        $cleaned = $message;
                }
 
index 45000d77005e8b8bd6801a80809aab28d52d0182..361d333b40f2a208f4422401711dc3d110f89d75 100644 (file)
@@ -1543,8 +1543,10 @@ class OStatus
         */
        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 ACTIVITY_OBJ_NOTE;
        }
 
index 8a20142dbad9da74bd7a7f67f2bebf14c2977dbd..de49a8d3caba6932786dca9b50123ad511de2edf 100644 (file)
@@ -1375,7 +1375,7 @@ class PortableContact
                                                $site_name = $data['site_name'];
                                        }
 
-                                       $info = $data['info'];
+                                       $info = defaults($data, 'info', '');
                                        $register_policy = defaults($data, 'register_policy', REGISTER_CLOSED);
                                        if (in_array($register_policy, ['REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'])) {
                                                $register_policy = constant($data['register_policy']);
@@ -1383,7 +1383,7 @@ class PortableContact
                                                Logger::log("Register policy '$register_policy' from $server_url is invalid.");
                                                $register_policy = REGISTER_CLOSED; // set a default value
                                        }
-                                       $platform = $data['platform'];
+                                       $platform = defaults($data, 'platform', '');
                                }
                        }
                }
index e7707baf38a8182af47c77e287b40bc281c8d8c1..ab0958d6423ffae00d37a1b46792401c42b61ac7 100644 (file)
@@ -362,7 +362,7 @@ class Network
                /// @TODO Really suppress function outcomes? Why not find them + debug them?
                $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;
                }
 
index 4f51db2dfbc5662f9e645c19d1549e4b5b3c6178..49638c7c9482fbf76c23fe4c47bc60d6d71d6d45 100644 (file)
@@ -35,7 +35,7 @@ class GProbe {
                        $result = Cache::get("gprobe:".$urlparts["host"]);
                        if (!is_null($result)) {
                                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;
                                }
                        }