Implementierung des validators

This commit is contained in:
rirat-0
2026-06-17 20:14:07 +02:00
parent b3c74c2172
commit 1e6ac0fcd9
2 changed files with 87 additions and 6 deletions
+12 -6
View File
@@ -1,4 +1,7 @@
<?php
require_once __DIR__ . '/../../validators/search-validator.php';
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
@@ -8,11 +11,16 @@ $query = $_SESSION["search_query"] ?? "";
$totalResultsCount = count($all_results);
$limit = isset($_GET['limit']) ? (int)$_GET['limit'] : 10;
if (!in_array($limit, [10, 20, 50, 100])) {
$limit = 10;
if (!searchLimitValidator($limit)) {
$limit = 10; // Fallback auf Standardwert bei Manipulation
}
if (!empty($query) && !searchQueryValidator($query)) {
$all_results = [];
$totalResultsCount = 0;
$_SESSION["message"] = "missing_parameters";
}
// Gesamtseitenzahl
$totalPages = max(1, ceil($totalResultsCount / $limit));
// Aktuelle Seite auslesen und validieren
@@ -23,11 +31,8 @@ if ($currentPage < 1) {
$currentPage = $totalPages;
}
// Startpunkt im Array berechnen (Offset)
$offset = ($currentPage - 1) * $limit;
// Nur die Ergebnisse für die aktuelle Seite ausschneiden
//$results = array_slice($all_results, $offset, $limit);
$results = $all_results;
$resultCount = count($results);
@@ -78,6 +83,7 @@ $resultCount = count($results);
</div>
</div>
<!-- Dropdown-Menu fuer Filter-Optionen -->
<div class="s-res-sidebar-box">
<h3 class="s-res-sidebar-title">Kategorie filtern</h3>
<select id="category-filter" class="s-res-limit-select" style="width: 100%; padding: 8px; border-radius: 6px; border: 1px solid #cbd5e1;">