]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/Network.php
Add search types
[friendica.git] / src / Util / Network.php
index de4b45da9a35bcf7c60572b140af0c8ac13b17c6..e4e9c5af5bb5a75673017425b6cc298057fa74ac 100644 (file)
@@ -4,13 +4,13 @@
  */
 namespace Friendica\Util;
 
+use DOMDocument;
+use DomXPath;
+use Friendica\Core\Config;
 use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\Core\System;
-use Friendica\Core\Config;
 use Friendica\Network\CurlResult;
-use DOMDocument;
-use DomXPath;
 
 class Network
 {
@@ -232,7 +232,7 @@ class Network
 
                @curl_close($ch);
 
-               $a->saveTimestamp($stamp1, 'network');
+               $a->getProfiler()->saveTimestamp($stamp1, 'network', System::callstack());
 
                return $curlResponse;
        }
@@ -334,7 +334,7 @@ class Network
 
                curl_close($ch);
 
-               $a->saveTimestamp($stamp1, 'network');
+               $a->getProfiler()->saveTimestamp($stamp1, 'network', System::callstack());
 
                Logger::log('post_url: end ' . $url, Logger::DATA);
 
@@ -459,7 +459,6 @@ class Network
         * @param string $url The url to check the domain from
         *
         * @return boolean
-        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function isUrlBlocked($url)
        {
@@ -641,7 +640,7 @@ class Network
                $http_code = $curl_info['http_code'];
                curl_close($ch);
 
-               $a->saveTimestamp($stamp1, "network");
+               $a->getProfiler()->saveTimestamp($stamp1, "network", System::callstack());
 
                if ($http_code == 0) {
                        return $url;
@@ -683,7 +682,7 @@ class Network
                $body = curl_exec($ch);
                curl_close($ch);
 
-               $a->saveTimestamp($stamp1, "network");
+               $a->getProfiler()->saveTimestamp($stamp1, "network", System::callstack());
 
                if (trim($body) == "") {
                        return $url;
@@ -836,4 +835,28 @@ class Network
                        (strlen($query) ? "?".$query : '') .
                        (strlen($fragment) ? "#".$fragment : '');
        }
+
+
+       /**
+        * Switch the scheme of an url between http and https
+        *
+        * @param string $url URL
+        *
+        * @return string switched URL
+        */
+       public static function switchScheme($url)
+       {
+               $scheme = parse_url($url, PHP_URL_SCHEME);
+               if (empty($scheme)) {
+                       return $url;
+               }
+
+               if ($scheme === 'http') {
+                       $url = str_replace('http://', 'https://', $url);
+               } elseif ($scheme === 'https') {
+                       $url = str_replace('https://', 'http://', $url);
+               }
+
+               return $url;
+       }
 }