<?php
session_start();
require_once '../config.php';
load('middleware', 'user');
if ($_SESSION['user']['level'] == "") {
    header('location:' . base_url('id'));
}
$id = $_GET['id'];
if(!isset($id))
    die('No direct script access allowed!');
$query = mysqli_query($db, "SELECT * FROM users WHERE id = '$id'");
$q = mysqli_fetch_assoc($query);
if (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { ?>
<form method="POST">
<div class="form-group mb-3">
        <label>API KEY</label>
        <div class="input-group">
        <input type="text" class="form-control" placeholder="LynchStore" id="api_key" name="api_key" value="<?= $q['api_key'];?>" readonly>
        <button class="input-group-text" type="submit" name="btn_api_key"><i class="fa fa-random"></i></button>
    </div>
</div>
<div class="form-group mb-3">
    <label for="password" class="form-label">API ID</label>
    <div class="input-group">
        <input type="text" class="form-control" placeholder="LynchStore" id="api_id" name="api_id" value="<?= $q['api_id'];?>" readonly>
        <button class="input-group-text" type="submit" name="btn_api_id"><i class="fa fa-random"></i></button>
    </div>
</div>
<div class="alert bg-primary p-1" role="alert">
    <i style="color:white;" class="fas fa-info-circle align-middle"></i>
    <span style="color:white;">Lebih dari 1 IP Statis?<br>Pisahkan setiap IP dengan koma (,) Contoh: 192.1.1.1,192.1.1.2</span>
</div>
<div class="form-group">
    <label>Whitelist IP</label>
    <div class="input-group">
        <input type="text" name="whitelist" class="form-control" placeholder="192.168.1.1" value="<?= $_SESSION['user']['ip_static'];?>">
        <button class="input-group-text" type="submit" name="btn_whitelist">Simpan</button>
    </div>
</div>
<hr>
<div class="float-right mb-3">
    <button type="button" data-bs-dismiss="modal" aria-label="Close" class="btn btn-block bg-light fw-bold">BACK</button>
</div>
</form>
<?php } ?>