diff --git a/app/Http/Controllers/Pictureproxy.php b/app/Http/Controllers/Pictureproxy.php index efcea2918e4dcd3a2f12cf2d2d6a71aae8591988..45312e78ead26b4110d6f72bbe6f05e0a1cee712 100644 --- a/app/Http/Controllers/Pictureproxy.php +++ b/app/Http/Controllers/Pictureproxy.php @@ -17,19 +17,24 @@ 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) + try{ + $file = file_get_contents($request->input('url')); + $responseCode = explode(" ", $http_response_header[0])[1]; + $contentType = ""; + foreach($http_response_header as $header) { - $tmp = explode(": ", $header); - $contentType = $tmp[1]; + if( strpos($header, "Content-Type:") === 0) + { + $tmp = explode(": ", $header); + $contentType = $tmp[1]; + } } + $response = Response::make($file, $responseCode); + $response->header('Content-Type', $contentType); + }catch(\ErrorException $e) + { + $response = Response::make("", 404); } - $response = Response::make($file, $responseCode); - $response->header('Content-Type', $contentType); return $response; } }