1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-06-05 22:09:38 +02:00
Files
openstamanager/app/Http/Controllers/LegacyController.php
Dasc3er 91f4355c36 Introduzione del framework Laravel
Introduzione di Laravel 8 come wrapper per la versione legacy del gestionale, per favorire l'aggiornamento della struttura interna.
2020-12-31 16:17:16 +01:00

36 lines
915 B
PHP

<?php
namespace App\Http\Controllers;
use App\Exceptions\LegacyExitException;
use App\Exceptions\LegacyRedirectException;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Redirect;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class LegacyController extends Controller
{
public function index($path = 'index.php')
{
$base_path = realpath(__DIR__.'/../../../legacy/');
$file = realpath($base_path.'/'.$path);
if (strpos($file, $base_path) === false){
throw new NotFoundHttpException();
}
ob_start();
try {
require $file;
} catch (LegacyExitException $e) {
}catch (LegacyRedirectException $e){
return Redirect::to($e->getMessage());
}
$output = ob_get_clean();
$output = translateTemplate($output);
return new Response($output);
}
}