<?php
if ($c['level'] == "superadmin") {

    if (isset($_POST['upload'])) {
        $id             = mysqli_real_escape_string($koneksi, $_POST['id']);
        $api_token      = mysqli_real_escape_string($koneksi, $_POST['api_token']);
        $callback_token = mysqli_real_escape_string($koneksi, $_POST['callback_token']);
        $callback_url   = mysqli_real_escape_string($koneksi, $_POST['callback_url']);
        $status         = mysqli_real_escape_string($koneksi, $_POST['status']);

        $update = mysqli_query($koneksi, "
            UPDATE tb_goldslot_config SET
                api_token      = '$api_token',
                callback_token = '$callback_token',
                callback_url   = '$callback_url',
                status         = '$status'
            WHERE id = '$id'
        ");

        if ($update) {
            echo "<script>alert('Konfigurasi GoldSlotPalace berhasil disimpan!'); window.location='?page=goldslot&sub=config';</script>";
        } else {
            echo "<script>alert('Gagal menyimpan konfigurasi: " . mysqli_error($koneksi) . "'); window.location='?page=goldslot&sub=config';</script>";
        }
    } else {
        echo "<script>window.location='?page=goldslot&sub=config';</script>";
    }

} else {
    echo "<script>window.location='?page=dashboard';</script>";
}
?>