HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/panomity.de/vr.panomity.com/api/pois.php
<?php
/**
 * POIs einer Szene für das Frontend.
 * GET ?pano_id=N&language=de → { pois: [{id,label,description,ath,atv}] }
 */

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, OPTIONS');
header('Content-Type: application/json; charset=utf-8');

if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
    http_response_code(200);
    exit;
}

$panoId = (int)($_GET['pano_id'] ?? 0);
$language = strtolower(trim((string)($_GET['language'] ?? 'en')));
if (!preg_match('/^[a-z]{2}$/', $language)) {
    $language = 'en';
}
if ($panoId <= 0) {
    http_response_code(400);
    echo json_encode(['ok' => false, 'error' => 'Invalid pano_id']);
    exit;
}

$db = new SQLite3(__DIR__ . '/../admin/data/vrm.db');
$db->busyTimeout(5000);

$pois = [];
$res = $db->query("SELECT name FROM sqlite_master WHERE type='table' AND name='pano_pois'");
if ($res->fetchArray()) {
    $stmt = $db->prepare('SELECT id, label_en, label_de, desc_en, desc_de, ath, atv
        FROM pano_pois WHERE pano_id = :id AND active = 1 ORDER BY id');
    $stmt->bindValue(':id', $panoId, SQLITE3_INTEGER);
    $result = $stmt->execute();
    while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
        $label = $language === 'de' ? ($row['label_de'] ?: $row['label_en']) : $row['label_en'];
        $desc = $language === 'de' ? ($row['desc_de'] ?: $row['desc_en']) : $row['desc_en'];
        $pois[] = [
            'id' => (int)$row['id'],
            'label' => (string)$label,
            'description' => (string)$desc,
            'ath' => (float)$row['ath'],
            'atv' => (float)$row['atv'],
        ];
    }
}
$db->close();

echo json_encode(['ok' => true, 'pano_id' => $panoId, 'language' => $language, 'pois' => $pois], JSON_UNESCAPED_UNICODE);