Ajout de sécurité

This commit is contained in:
stiti 2024-06-06 21:39:22 +02:00
parent 283fae5d6b
commit becd86a661
2 changed files with 15 additions and 1 deletions

View File

@ -24,12 +24,20 @@ class Albums extends CI_Controller {
$albums = $this->model_music->getAlbums($limit, $offset, $order_by, $genre_id, $artist_id); $albums = $this->model_music->getAlbums($limit, $offset, $order_by, $genre_id, $artist_id);
$total_albums = $this->model_music->get_total_albums($genre_id, $artist_id); $total_albums = $this->model_music->get_total_albums($genre_id, $artist_id);
$total_pages = ceil($total_albums / $limit);
// Vérifier si la page demandée est valide
if ($page < 1 || $page > $total_pages) {
redirect('errors/error_404');
return;
}
if ($this->session->userdata('user_id')) { if ($this->session->userdata('user_id')) {
$user_id = $this->session->userdata('user_id'); $user_id = $this->session->userdata('user_id');
$data['user_playlists'] = $this->Model_playlist->get_user_playlists($user_id); $data['user_playlists'] = $this->Model_playlist->get_user_playlists($user_id);
} }
$data['total_pages'] = ceil($total_albums / $limit); $data['total_pages'] = $total_pages;
$data['current_page'] = $page; $data['current_page'] = $page;
$data['albums'] = $albums; $data['albums'] = $albums;
$data['order_by'] = $order_by; $data['order_by'] = $order_by;

View File

@ -29,6 +29,12 @@ class Musiques extends CI_Controller {
$total_musiques = $this->Model_music->get_total_musiques(); $total_musiques = $this->Model_music->get_total_musiques();
$total_pages = ceil($total_musiques / $limit); $total_pages = ceil($total_musiques / $limit);
// Vérifier si la page demandée est valide
if ($page < 1 || $page > $total_pages) {
redirect('errors/error_404');
return;
}
$current_page = $page; $current_page = $page;
$genres = $this->Model_music->getGenres(); $genres = $this->Model_music->getGenres();
$artists = $this->Model_music->getArtists(); $artists = $this->Model_music->getArtists();