X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FModule%2FProxy.php;h=1c980fe11e7fcb6d6f33341d4ea86938d9c5e408;hb=f3da5b3a2f98883e4a06c345dfe2880394f7d21d;hp=d6c9a841c965587c334cec170b837f0be4e000ca;hpb=36f30533b75df3d32eb54d28a072807134cb12f7;p=friendica.git diff --git a/src/Module/Proxy.php b/src/Module/Proxy.php index d6c9a841c9..1c980fe11e 100644 --- a/src/Module/Proxy.php +++ b/src/Module/Proxy.php @@ -5,15 +5,11 @@ */ 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; use Friendica\Object\Image; -use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; use Friendica\Util\Proxy as ProxyUtils; @@ -32,7 +28,6 @@ class Proxy extends BaseModule * * Sets application instance and checks if /proxy/ path is writable. * - * @param \Friendica\App $app Application instance */ public static function init() { @@ -106,16 +101,18 @@ class Proxy extends BaseModule // If there is an error then return a blank image if ((substr($fetchResult->getReturnCode(), 0, 1) == '4') || (!$img_str)) { - self::responseError($request); + self::responseError(); // stop. } $image = new Image($img_str, $mime); if (!$image->isValid()) { - self::responseError($request); + self::responseError(); // stop. } + $basepath = $a->getBasePath(); + // Store original image if ($direct_cache) { // direct cache , store under ./proxy/ @@ -155,11 +152,11 @@ class Proxy extends BaseModule * 'size' => requested image size (int) * 'sizetype' => requested image size (string): ':micro', ':thumb', ':small', ':medium', ':large' * ] + * @throws \Exception */ private static function getRequestInfo() { $a = self::getApp(); - $url = ''; $size = 1024; $sizetype = ''; @@ -222,12 +219,13 @@ class Proxy extends BaseModule 'sizetype' => $sizetype, ]; } - - + + /** * @brief setup ./proxy folder for direct cache * * @return bool False if direct cache can't be used. + * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ private static function setupDirectCache() { @@ -246,16 +244,18 @@ class Proxy extends BaseModule return $direct_cache; } - - + + /** * @brief Try to reply with image in cachefile * - * @param array $request Array from getRequestInfo + * @param array $request Array from getRequestInfo * * @return string Cache file name, empty string if cache is not enabled. - * + * * If cachefile exists, script ends here and this function will never returns + * @throws \Friendica\Network\HTTPException\InternalServerErrorException + * @throws \ImagickException */ private static function responseFromCache(&$request) { @@ -267,13 +267,15 @@ class Proxy extends BaseModule } return $cachefile; } - + /** * @brief Try to reply with image in database * - * @param array $request Array from getRequestInfo + * @param array $request Array from getRequestInfo * * If the image exists in database, then script ends here and this function will never returns + * @throws \Friendica\Network\HTTPException\InternalServerErrorException + * @throws \ImagickException */ private static function responseFromDB(&$request) { @@ -291,15 +293,16 @@ class Proxy extends BaseModule * */ private static function responseError() { - header('Content-type: ' . $img->getType()); + header('Content-type: image/png'); echo file_get_contents('images/blank.png'); exit(); } - + /** * @brief Output the image with cache headers * - * @param Image $image + * @param Image $img + * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ private static function responseImageHttpCache(Image $img) {