From 6bd0212a470df32d7da73fbe636447261c254f3f Mon Sep 17 00:00:00 2001 From: DariusIII Date: Wed, 23 Oct 2024 11:02:00 +0200 Subject: [PATCH] Prevent negative offset when browsing --- Blacklight/Books.php | 3 +++ Blacklight/Console.php | 3 +++ Blacklight/Games.php | 4 ++++ Blacklight/Movie.php | 3 +++ Blacklight/Music.php | 3 +++ Blacklight/Releases.php | 3 +++ Blacklight/XXX.php | 3 +++ 7 files changed, 22 insertions(+) diff --git a/Blacklight/Books.php b/Blacklight/Books.php index 1e853555d..2edad066e 100755 --- a/Blacklight/Books.php +++ b/Blacklight/Books.php @@ -104,6 +104,9 @@ class Books public function getBookRange($page, $cat, $start, $num, $orderBy, array $excludedCats = []): array { + $page = max(1, $page); + $start = max(1, $start); + $browseby = $this->getBrowseBy(); $catsrch = ''; if (\count($cat) > 0 && $cat[0] !== -1) { diff --git a/Blacklight/Console.php b/Blacklight/Console.php index 2354d6e8d..d2b183990 100755 --- a/Blacklight/Console.php +++ b/Blacklight/Console.php @@ -137,6 +137,9 @@ class Console */ public function getConsoleRange($page, $cat, $start, $num, $orderBy, array $excludedCats = []): array { + $page = max(1, $page); + $start = max(1, $start); + $browseBy = $this->getBrowseBy(); $catsrch = ''; if (\count($cat) > 0 && (int) $cat[0] !== -1) { diff --git a/Blacklight/Games.php b/Blacklight/Games.php index 821824d96..8144b90e2 100755 --- a/Blacklight/Games.php +++ b/Blacklight/Games.php @@ -168,6 +168,10 @@ class Games */ public function getGamesRange($page, $cat, $start, $num, array|string $orderBy = '', string $maxAge = '', array $excludedCats = []): array { + + $page = max(1, $page); + $start = max(1, $start); + $browseBy = $this->getBrowseBy(); $catsrch = ''; if (\count($cat) > 0 && $cat[0] !== -1) { diff --git a/Blacklight/Movie.php b/Blacklight/Movie.php index 33073214c..fe53a374e 100755 --- a/Blacklight/Movie.php +++ b/Blacklight/Movie.php @@ -167,6 +167,9 @@ class Movie */ public function getMovieRange($page, $cat, $start, $num, $orderBy, int $maxAge = -1, array $excludedCats = []) { + $page = max(1, $page); + $start = max(1, $start); + $catsrch = ''; if (\count($cat) > 0 && $cat[0] !== -1) { $catsrch = Category::getCategorySearch($cat); diff --git a/Blacklight/Music.php b/Blacklight/Music.php index 1d56a405a..4116fab1c 100755 --- a/Blacklight/Music.php +++ b/Blacklight/Music.php @@ -127,6 +127,9 @@ class Music */ public function getMusicRange($page, $cat, $start, $num, $orderBy, array $excludedCats = []): mixed { + $page = max(1, $page); + $start = max(1, $start); + $browseby = $this->getBrowseBy(); $catsrch = ''; if (\count($cat) > 0 && (int) $cat[0] !== -1) { diff --git a/Blacklight/Releases.php b/Blacklight/Releases.php index 78284a08d..fc10f34e6 100644 --- a/Blacklight/Releases.php +++ b/Blacklight/Releases.php @@ -50,6 +50,9 @@ class Releases extends Release */ public function getBrowseRange($page, $cat, $start, $num, $orderBy, int $maxAge = -1, array $excludedCats = [], int|string $groupName = -1, int $minSize = 0): mixed { + $page = max(1, $page); + $start = max(1, $start); + $orderBy = $this->getBrowseOrder($orderBy); $qry = sprintf( diff --git a/Blacklight/XXX.php b/Blacklight/XXX.php index 1b0e4b5be..458443f8a 100755 --- a/Blacklight/XXX.php +++ b/Blacklight/XXX.php @@ -71,6 +71,9 @@ class XXX */ public function getXXXRange($page, $cat, $start, $num, $orderBy, int $maxAge = -1, array $excludedCats = []): array { + $page = max(1, $page); + $start = max(1, $start); + $catSrch = ''; if (\count($cat) > 0 && $cat[0] !== -1) { $catSrch = Category::getCategorySearch($cat);