<?php
/**
 * GET /api/admin/settings_list.php
 * Admin-only. Returns every row in the settings table - rewards formula,
 * market geo scope, and OAuth keys. Never exposed to non-admins (OAuth
 * client secrets live here).
 */

require_once __DIR__ . '/../config/database.php';
require_once __DIR__ . '/../includes/response.php';
require_once __DIR__ . '/../includes/auth.php';

require_login();
require_role(['admin']);

$pdo = Database::connect();
$stmt = $pdo->query('SELECT setting_key, setting_value FROM settings');
$settings = [];
foreach ($stmt->fetchAll() as $row) {
    $settings[$row['setting_key']] = $row['setting_value'];
}

send_json(true, 'OK', ['settings' => $settings]);
