]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/Network.php
Remove include/like
[friendica.git] / src / Util / Network.php
index b013f65a3df60c1cb6d1751de4bd3234d6adc208..85880a9499f24d2d03d0b37c7efafac63feb6cc2 100644 (file)
@@ -12,8 +12,8 @@ use Friendica\Core\Config;
 use Friendica\Network\Probe;
 use Friendica\Object\Image;
 use Friendica\Util\XML;
-
-require_once 'library/slinky.php';
+use DOMDocument;
+use DomXPath;
 
 class Network
 {
@@ -80,7 +80,7 @@ class Network
                $a = get_app();
 
                if (self::isUrlBlocked($url)) {
-                       logger('z_fetch_url: domain of ' . $url . ' is blocked', LOGGER_DATA);
+                       logger('domain of ' . $url . ' is blocked', LOGGER_DATA);
                        return $ret;
                }
 
@@ -185,7 +185,7 @@ class Network
                }
 
                if (curl_errno($ch) !== CURLE_OK) {
-                       logger('fetch_url error fetching ' . $url . ': ' . curl_error($ch), LOGGER_NORMAL);
+                       logger('error fetching ' . $url . ': ' . curl_error($ch), LOGGER_NORMAL);
                }
 
                $ret['errno'] = curl_errno($ch);
@@ -195,7 +195,7 @@ class Network
 
                $http_code = $curl_info['http_code'];
 
-               logger('fetch_url ' . $url . ': ' . $http_code . " " . $s, LOGGER_DATA);
+               logger($url . ': ' . $http_code . " " . $s, LOGGER_DATA);
                $header = '';
 
                // Pull out multiple headers, e.g. proxy and continuation headers
@@ -233,7 +233,7 @@ class Network
                        if (filter_var($newurl, FILTER_VALIDATE_URL)) {
                                $redirects++;
                                @curl_close($ch);
-                               return self::zFetchURL($newurl, $binary, $redirects, $opts);
+                               return self::curl($newurl, $binary, $redirects, $opts);
                        }
                }
 
@@ -248,8 +248,8 @@ class Network
                if (!$ret['success']) {
                        $ret['error'] = curl_error($ch);
                        $ret['debug'] = $curl_info;
-                       logger('z_fetch_url: error: '.$url.': '.$ret['return_code'].' - '.$ret['error'], LOGGER_DEBUG);
-                       logger('z_fetch_url: debug: '.print_r($curl_info, true), LOGGER_DATA);
+                       logger('error: '.$url.': '.$ret['return_code'].' - '.$ret['error'], LOGGER_DEBUG);
+                       logger('debug: '.print_r($curl_info, true), LOGGER_DATA);
                }
 
                $ret['body'] = substr($s, strlen($header));
@@ -399,70 +399,6 @@ class Network
                return $body;
        }
 
-       /**
-        * Generic XML return
-        * Outputs a basic dfrn XML status structure to STDOUT, with a <status> variable
-        * of $st and an optional text <message> of $message and terminates the current process.
-        */
-       public static function xmlExit($st, $message = '')
-       {
-               $result = ['status' => $st];
-
-               if ($message != '') {
-                       $result['message'] = $message;
-               }
-
-               if ($st) {
-                       logger('xml_status returning non_zero: ' . $st . " message=" . $message);
-               }
-
-               header("Content-type: text/xml");
-
-               $xmldata = ["result" => $result];
-
-               echo XML::fromArray($xmldata, $xml);
-
-               killme();
-       }
-
-       /**
-        * @brief Send HTTP status header and exit.
-        *
-        * @param integer $val         HTTP status result value
-        * @param array   $description optional message
-        *                             'title' => header title
-        *                             'description' => optional message
-        */
-       public static function httpStatusExit($val, $description = [])
-       {
-               $err = '';
-               if ($val >= 400) {
-                       $err = 'Error';
-                       if (!isset($description["title"])) {
-                               $description["title"] = $err." ".$val;
-                       }
-               }
-
-               if ($val >= 200 && $val < 300) {
-                       $err = 'OK';
-               }
-
-               logger('http_status_exit ' . $val);
-               header($_SERVER["SERVER_PROTOCOL"] . ' ' . $val . ' ' . $err);
-
-               if (isset($description["title"])) {
-                       $tpl = get_markup_template('http_status.tpl');
-                       echo replace_macros(
-                               $tpl,
-                               [
-                                       '$title' => $description["title"],
-                                       '$description' => $description["description"]]
-                       );
-               }
-
-               killme();
-       }
-
        /**
         * @brief Check URL to see if it's real
         *
@@ -835,45 +771,6 @@ class Network
                return $url;
        }
 
-       public static function shortenUrl($url)
-       {
-               $slinky = new Slinky($url);
-               $yourls_url = Config::get('yourls', 'url1');
-               if ($yourls_url) {
-                       $yourls_username = Config::get('yourls', 'username1');
-                       $yourls_password = Config::get('yourls', 'password1');
-                       $yourls_ssl = Config::get('yourls', 'ssl1');
-                       $yourls = new Slinky_YourLS();
-                       $yourls->set('username', $yourls_username);
-                       $yourls->set('password', $yourls_password);
-                       $yourls->set('ssl', $yourls_ssl);
-                       $yourls->set('yourls-url', $yourls_url);
-                       $slinky->set_cascade([$yourls, new Slinky_Ur1ca(), new Slinky_TinyURL()]);
-               } else {
-                       // setup a cascade of shortening services
-                       // try to get a short link from these services
-                       // in the order ur1.ca, tinyurl
-                       $slinky->set_cascade([new Slinky_Ur1ca(), new Slinky_TinyURL()]);
-               }
-               return $slinky->short();
-       }
-
-       /**
-        * @brief Encodes content to json
-        *
-        * This function encodes an array to json format
-        * and adds an application/json HTTP header to the output.
-        * After finishing the process is getting killed.
-        *
-        * @param array $x The input content
-        */
-       public static function jsonExit($x)
-       {
-               header("content-type: application/json");
-               echo json_encode($x);
-               killme();
-       }
-
        /**
         * @brief Find the matching part between two url
         *