| Server IP : 202.61.199.114 / Your IP : 216.73.217.139 Web Server : nginx/1.22.1 System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 User : web20 ( 1018) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/seaside.pacim.de/web/ |
Upload File : |
<?php
/**
* search-api.php – JSON-Endpunkt für die globale Live-Suche (Header).
* Hinter dem PaCIM-Login. Liefert normalisierte, nach Aktualität sortierte Treffer.
*
* GET q, limit -> { results: [...], hasMore: bool }
*/
require_once( __DIR__ . "/includes/config.inc.php" );
@ini_set( 'display_errors', '0' );
header( 'Content-Type: application/json; charset=utf-8' );
header( 'Cache-Control: no-store, no-cache, must-revalidate, max-age=0' );
if ( !isset( $_SESSION['user'] ) || $_SESSION['user'] != LOGIN_USER ) {
http_response_code( 403 );
echo json_encode( array( 'error' => 'unauthorized' ) );
exit();
}
$action = isset( $_REQUEST['action'] ) ? (string) $_REQUEST['action'] : '';
$uid = isset( $_SESSION['user_id'] ) ? (int) $_SESSION['user_id'] : 0;
$s = new search();
// Letzte Suchen des angemeldeten Benutzers
if ( $action === 'history' ) {
echo json_encode( array( 'history' => $s->recentSearches( $uid, 10 ) ) );
exit();
}
// Eine Suche zum Verlauf des Benutzers hinzufügen
if ( $action === 'record' ) {
$s->recordSearch( $uid, isset( $_POST['q'] ) ? (string) $_POST['q'] : '' );
echo json_encode( array( 'success' => true ) );
exit();
}
// Standard: Live-Suche
$q = isset( $_GET['q'] ) ? (string) $_GET['q'] : '';
$limit = isset( $_GET['limit'] ) ? (int) $_GET['limit'] : 15;
echo json_encode( $s->query( $q, $limit ) );