-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathweb.php
More file actions
62 lines (52 loc) · 2.18 KB
/
web.php
File metadata and controls
62 lines (52 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
use Illuminate\Support\Facades\Route;
use Illuminate\Http\Request;
use App\Http\Controllers\TodayConsumptionController;
use App\Http\Controllers\GetSalesController;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/
// Configuration du middleware
Route::middleware(\App\Http\Middleware\Auth::class)->get('/test', function () {
return view('welcome');
})->name("test");
// Gestion des télés
Route::get('/TV/content', [\App\Http\Controllers\MediaController::class, 'content'])->name('TV.content');
Route::get('/TV/{tv}', [\App\Http\Controllers\TvController::class, 'show'])->name('TV.show');
// Téléchargement de fichier image
Route::prefix('/image')->group(function () {
//get image from ?url=
Route::get('/', function (Request $request) {
$url = $request->query('url');
//avoid path traversal
if (str_contains($url, '..')) {
return response()->json(['message' => 'Invalid url'], 400);
}
//in storage folder
$path = storage_path('app/public/' . $url);
if (File::exists($path)) {
return response()->file($path);
}
return response()->json(['message' => 'Image not found'], 404);
})->name('image');
});
// Gestion de l'authentification
Route::get('/auth',[\App\Http\Controllers\Connexion::class,'auth'])->name('auth_route');
Route::get('/logout',[\App\Http\Controllers\Connexion::class,'logout'])->name('logout_route');
// Téléchargement de fichier général
Route::get('/download/{filename}', function ($filename) {
$filename = str_replace('..', '', $filename);
if (Storage::exists('files/' . $filename)) {
return Storage::download('files/' . $filename);
} else {
return response()->json(['message' => 'Image not found'], 404);
}
})->name('download');
Route::get('/bourse',[\App\Http\Controllers\TransactionController::class,'getPrices']);