Skip to content
Snippets Groups Projects
Commit e01497df authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Bilderproxy eingebaut ( erreichbar unter "/meta/picture?url=..."

Bilder der Bildersuche über den Proxy umgeleitet
parent f1734ea5
No related branches found
No related tags found
2 merge requests!73Updates from Master,!58Bilderproxy eingebaut ( erreichbar unter "/meta/picture?url=..."
<?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
...@@ -97,6 +97,7 @@ ...@@ -97,6 +97,7 @@
Route::get('meta/meta.ger3', 'MetaGerSearch@search'); Route::get('meta/meta.ger3', 'MetaGerSearch@search');
Route::get('meta/picture', 'Pictureproxy@get');
Route::get('qt', 'MetaGerSearch@quicktips'); Route::get('qt', 'MetaGerSearch@quicktips');
Route::get('tips', 'MetaGerSearch@tips'); Route::get('tips', 'MetaGerSearch@tips');
......
...@@ -716,4 +716,11 @@ class MetaGer ...@@ -716,4 +716,11 @@ class MetaGer
else else
return null; return null;
} }
public function getImageProxyLink($link)
{
$requestData = [];
$requestData["url"] = $link;
$link = action('Pictureproxy@get', $requestData);
return $link;
}
} }
\ No newline at end of file
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<div class="item"> <div class="item">
<div class="img"> <div class="img">
<a href="{{ $result->link }}" target="{{ $metager->getTab() }}"> <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> </a>
</div> </div>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment