]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Proxy.php
Rename App Methods
[friendica.git] / src / Module / Proxy.php
index 6287727dce630438d7bbc52ffa3008d956d416d9..14e842562f559b52947dfb6a3079f89ab99539a2 100644 (file)
@@ -8,6 +8,7 @@ namespace Friendica\Module;
 use Friendica\App;
 use Friendica\BaseModule;
 use Friendica\Core\Config;
+use Friendica\Core\L10n;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Model\Photo;
@@ -45,7 +46,7 @@ class Proxy extends BaseModule
                 *
                 * Question: Do we really need these three methods?
                 */
-               if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
+               if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
                        header('HTTP/1.1 304 Not Modified');
                        header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
                        header('Etag: ' . $_SERVER['HTTP_IF_NONE_MATCH']);
@@ -70,7 +71,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)) {
@@ -133,13 +134,17 @@ class Proxy extends BaseModule
                        $direct_cache = false;
                }
 
+               if (empty($_REQUEST['url'])) {
+                       System::httpExit(400, ["title" => L10n::t('Bad Request.')]);
+               }
+
                if (!$direct_cache) {
                        $urlhash = 'pic:' . sha1($_REQUEST['url']);
 
                        $cachefile = get_cachefile(hash('md5', $_REQUEST['url']));
                        if ($cachefile != '' && file_exists($cachefile)) {
                                $img_str = file_get_contents($cachefile);
-                               $mime = image_type_to_mime_type(exif_imagetype($cachefile));
+                               $mime = mime_content_type($cachefile);
 
                                header('Content-type: ' . $mime);
                                header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
@@ -187,11 +192,11 @@ class Proxy extends BaseModule
 
                        $tempfile = tempnam(get_temppath(), 'cache');
                        file_put_contents($tempfile, $img_str);
-                       $mime = image_type_to_mime_type(exif_imagetype($tempfile));
+                       $mime = mime_content_type($tempfile);
                        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(Network::getCurl()->getCode(), 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