]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Proxy.php
Merge pull request #6226 from annando/oembed-array
[friendica.git] / src / Module / Proxy.php
index 0de45b332518e433b58df1e0990f0242e257ab3a..29e0f4f52f4903c151419133d661a8a4335f9507 100644 (file)
@@ -17,8 +17,6 @@ use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
 use Friendica\Util\Proxy as ProxyUtils;
 
-require_once 'include/security.php';
-
 /**
  * @brief Module Proxy
  */
@@ -71,7 +69,7 @@ class Proxy extends BaseModule
                $thumb = false;
                $size = 1024;
                $sizetype = '';
-               $basepath = $a->get_basepath();
+               $basepath = $a->getBasePath();
 
                // If the cache path isn't there, try to create it
                if (!is_dir($basepath . '/proxy') && is_writable($basepath)) {
@@ -105,7 +103,7 @@ class Proxy extends BaseModule
                                $sizetype = ':thumb';
                                $url = substr($url, 0, -6);
                        } elseif (substr($url, -6) == ':small') {
-                               $size = 175;
+                               $size = 300;
                                $url = substr($url, 0, -6);
                                $sizetype = ':small';
                        } elseif (substr($url, -7) == ':medium') {
@@ -188,7 +186,8 @@ class Proxy extends BaseModule
                        // It shouldn't happen but it does - spaces in URL
                        $_REQUEST['url'] = str_replace(' ', '+', $_REQUEST['url']);
                        $redirects = 0;
-                       $img_str = Network::fetchUrl($_REQUEST['url'], true, $redirects, 10);
+                       $fetchResult = Network::fetchUrlFull($_REQUEST['url'], true, $redirects, 10);
+                       $img_str = $fetchResult->getBody();
 
                        $tempfile = tempnam(get_temppath(), 'cache');
                        file_put_contents($tempfile, $img_str);
@@ -196,7 +195,7 @@ class Proxy extends BaseModule
                        unlink($tempfile);
 
                        // If there is an error then return a blank image
-                       if ((substr($a->get_curl_code(), 0, 1) == '4') || (!$img_str)) {
+                       if ((substr($fetchResult->getReturnCode(), 0, 1) == '4') || (!$img_str)) {
                                $img_str = file_get_contents('images/blank.png');
                                $mime = 'image/png';
                                $cachefile = ''; // Clear the cachefile so that the dummy isn't stored