2016-10-31 21:00:30 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Helpers\Helper;
|
2024-07-04 16:54:50 -07:00
|
|
|
use Illuminate\Http\RedirectResponse;
|
2024-05-29 04:38:15 -07:00
|
|
|
use Illuminate\Support\Facades\Log;
|
2024-06-05 01:55:27 -07:00
|
|
|
use Illuminate\Support\Facades\Storage;
|
2024-07-04 16:54:50 -07:00
|
|
|
use \Illuminate\Http\Response;
|
2024-07-09 11:50:58 -07:00
|
|
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
2016-10-31 21:00:30 -07:00
|
|
|
class ActionlogController extends Controller
|
|
|
|
{
|
2024-07-04 16:54:50 -07:00
|
|
|
public function displaySig($filename) : RedirectResponse | Response | bool
|
2016-10-31 21:00:30 -07:00
|
|
|
{
|
2022-03-04 02:54:37 -08:00
|
|
|
// PHP doesn't let you handle file not found errors well with
|
|
|
|
// file_get_contents, so we set the error reporting for just this class
|
|
|
|
error_reporting(0);
|
|
|
|
|
2024-06-05 01:08:15 -07:00
|
|
|
$disk = config('filesystems.default');
|
|
|
|
switch (config("filesystems.disks.$disk.driver")) {
|
2024-07-04 16:54:50 -07:00
|
|
|
|
2024-06-17 14:40:06 -07:00
|
|
|
case 's3':
|
|
|
|
$file = 'private_uploads/signatures/'.$filename;
|
|
|
|
return redirect()->away(Storage::disk($disk)->temporaryUrl($file, now()->addMinutes(5)));
|
|
|
|
default:
|
|
|
|
$this->authorize('view', \App\Models\Asset::class);
|
|
|
|
$file = config('app.private_uploads').'/signatures/'.$filename;
|
|
|
|
$filetype = Helper::checkUploadIsImage($file);
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2024-06-17 14:40:06 -07:00
|
|
|
$contents = file_get_contents($file, false, stream_context_create(['http' => ['ignore_errors' => true]]));
|
|
|
|
if ($contents === false) {
|
|
|
|
Log::warning('File '.$file.' not found');
|
|
|
|
return false;
|
|
|
|
} else {
|
2024-07-04 16:54:50 -07:00
|
|
|
return response()->make($contents)->header('Content-Type', $filetype);
|
2024-06-17 14:40:06 -07:00
|
|
|
}
|
|
|
|
}
|
2016-10-31 21:00:30 -07:00
|
|
|
}
|
2024-06-17 14:40:06 -07:00
|
|
|
|
2024-11-11 05:50:53 -08:00
|
|
|
public function getStoredEula($filename) : Response | BinaryFileResponse | RedirectResponse
|
2024-07-04 16:54:50 -07:00
|
|
|
{
|
2022-03-16 11:51:40 -07:00
|
|
|
$this->authorize('view', \App\Models\Asset::class);
|
|
|
|
$file = config('app.private_uploads').'/eula-pdfs/'.$filename;
|
2024-11-11 05:50:53 -08:00
|
|
|
|
|
|
|
if (Storage::exists($file)) {
|
|
|
|
return response()->download($file);
|
|
|
|
}
|
|
|
|
|
|
|
|
return redirect()->back()->with('error', trans('general.file_does_not_exist'));
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-16 11:51:40 -07:00
|
|
|
}
|
2016-10-31 21:00:30 -07:00
|
|
|
}
|