]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/Network.php
Preview for Videos and images / Video resolution selection
[friendica.git] / src / Util / Network.php
index 7795b0cd29d980753771a2f76b45b315b4972f7f..2c9949ee23bd93061304b0eeb883f5cafb4630c1 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -24,6 +24,7 @@ namespace Friendica\Util;
 use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\DI;
+use Friendica\Model\Contact;
 
 class Network
 {
@@ -176,6 +177,35 @@ class Network
                return false;
        }
 
+       /**
+        * Checks if the provided url is on the list of domains where redirects are blocked.
+        * Returns true if it is or malformed URL, false if not.
+        *
+        * @param string $url The url to check the domain from
+        *
+        * @return boolean
+        */
+       public static function isRedirectBlocked(string $url)
+       {
+               $host = @parse_url($url, PHP_URL_HOST);
+               if (!$host) {
+                       return false;
+               }
+
+               $no_redirect_list = DI::config()->get('system', 'no_redirect_list', []);
+               if (!$no_redirect_list) {
+                       return false;
+               }
+
+               foreach ($no_redirect_list as $no_redirect) {
+                       if (fnmatch(strtolower($no_redirect), strtolower($host))) {
+                               return true;
+                       }
+               }
+
+               return false;
+       }
+
        /**
         * Check if email address is allowed to register here.
         *
@@ -235,7 +265,7 @@ class Network
                Hook::callAll('avatar_lookup', $avatar);
 
                if (! $avatar['success']) {
-                       $avatar['url'] = DI::baseUrl() . '/images/person-300.jpg';
+                       $avatar['url'] = DI::baseUrl() . Contact::DEFAULT_AVATAR_PHOTO;
                }
 
                Logger::log('Avatar: ' . $avatar['email'] . ' ' . $avatar['url'], Logger::DEBUG);