From e01497dffcca1bd0ea72ef709887f3f494bb3135 Mon Sep 17 00:00:00 2001 From: Dominik Pfennig <dominik@suma-ev.de> Date: Wed, 8 Jun 2016 09:04:52 +0200 Subject: [PATCH] =?UTF-8?q?Bilderproxy=20eingebaut=20(=20erreichbar=20unte?= =?UTF-8?q?r=20"/meta/picture=3Furl=3D..."=20Bilder=20der=20Bildersuche=20?= =?UTF-8?q?=C3=BCber=20den=20Proxy=20umgeleitet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Pictureproxy.php | 37 ++++++++++++++++++++++++ app/Http/routes.php | 1 + app/MetaGer.php | 7 +++++ resources/views/metager3bilder.blade.php | 2 +- 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/Pictureproxy.php diff --git a/app/Http/Controllers/Pictureproxy.php b/app/Http/Controllers/Pictureproxy.php new file mode 100644 index 000000000..efcea2918 --- /dev/null +++ b/app/Http/Controllers/Pictureproxy.php @@ -0,0 +1,37 @@ +<?php + +namespace App\Http\Controllers; + +use App\Http\Controllers\Controller; +use Illuminate\Http\Request; +#use App\MetaGer\Forwarder; +#use App\MetaGer\Results; +#use App\MetaGer\Search; +use App; +use App\MetaGer; +use Response; + + +class Pictureproxy extends Controller +{ + function get(Request $request) { + if( $request->has('url') ) + { + $file = file_get_contents($request->input('url')); + $responseCode = explode(" ", $http_response_header[0])[1]; + $contentType = ""; + foreach($http_response_header as $header) + { + if( strpos($header, "Content-Type:") === 0) + { + $tmp = explode(": ", $header); + $contentType = $tmp[1]; + } + } + $response = Response::make($file, $responseCode); + $response->header('Content-Type', $contentType); + return $response; + } + } + +} \ No newline at end of file diff --git a/app/Http/routes.php b/app/Http/routes.php index 68ee0bb09..cb96a5c7e 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -97,6 +97,7 @@ Route::get('meta/meta.ger3', 'MetaGerSearch@search'); + Route::get('meta/picture', 'Pictureproxy@get'); Route::get('qt', 'MetaGerSearch@quicktips'); Route::get('tips', 'MetaGerSearch@tips'); diff --git a/app/MetaGer.php b/app/MetaGer.php index db6664aca..5fb13289c 100644 --- a/app/MetaGer.php +++ b/app/MetaGer.php @@ -716,4 +716,11 @@ class MetaGer else return null; } + public function getImageProxyLink($link) + { + $requestData = []; + $requestData["url"] = $link; + $link = action('Pictureproxy@get', $requestData); + return $link; + } } \ No newline at end of file diff --git a/resources/views/metager3bilder.blade.php b/resources/views/metager3bilder.blade.php index d9cc2295b..d5f267f77 100644 --- a/resources/views/metager3bilder.blade.php +++ b/resources/views/metager3bilder.blade.php @@ -7,7 +7,7 @@ <div class="item"> <div class="img"> <a href="{{ $result->link }}" target="{{ $metager->getTab() }}"> - <img src="{{ $result->image }}" width="150px" alt="Bild nicht gefunden"/> + <img src="{{ $metager->getImageProxyLink($result->image) }}" width="150px" alt="Bild nicht gefunden"/> </a> </div> </div> -- GitLab