<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$IIIIIIIIIIl1 = new SQLite3('./a/.eggziedb.db');

$IIIIIIIIII1I = $IIIIIIIIIIl1->query('SELECT * FROM ibo WHERE id=\'' . $_GET['update'] . '\'');
$IIIIIIIIII1l = $IIIIIIIIII1I->fetchArray();

$id = $IIIIIIIIII1l['id'];
$mac_address = $IIIIIIIIII1l['mac_address'];
$expire_date = $IIIIIIIIII1l['expire_date'];
$username = $IIIIIIIIII1l['username'];
$password = $IIIIIIIIII1l['password'];

if (isset($_POST['submit'])) {
    $IIIIIII1lll1 = strtotime($_POST['expire_date']);
    $IIIIIII1ll1l = date('Y-m-d', $IIIIIII1lll1);
    $IIIIIII1ll11 = date('Y-m-d');
    $IIIIIII1l1II = date('h:m:s');
    $IIIIIII1l1Il = $IIIIIII1ll11 . 'T' . $IIIIIII1l1II . '.000000Z';
    $IIIIIIIIIIl1->exec('UPDATE ibo SET mac_address=\'' . $_POST['mac_address'] . '\', expire_date=\'' . $IIIIIII1ll1l . '\', username=\'' . $_POST['username'] . '\', url=\'' . $_POST['url'] . '\', title=\'' . $_POST['title'] . '\', password=\'' . $_POST['password'] . '\', created_at=\'' . $IIIIIII1l1Il . '\' WHERE id=\'' . $_POST['id'] . '\'');
    $IIIIIIIIIIl1->close();
    header('Location: users.php');
}

include 'includes/header.php';

$IIIIIII1l11I = $IIIIIIIIII1l['id'];
$IIIIIII1l11l = $IIIIIIIIII1l['mac_address'];
$IIIIIII1l111 = $IIIIIIIIII1l['expire_date'];
$IIIIIII11III = $IIIIIIIIII1l['username'];
$IIIIIII11IIl = $IIIIIIIIII1l['password'];
$IIIIIII11II1 = $IIIIIIIIII1l['url'];
$IIIIIII11IlI = $IIIIIIIIII1l['title'];
?>

<div class="container-fluid">

    <h1 class="h3 mb-1 text-gray-800">Atualizar Usuário</h1>

    <div class="card border-left-primary shadow h-100 card shadow mb-4">
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-primary"><i class="fas fa-user"></i> Editar Usuário</h6>
        </div>
        <div class="card-body">
            <form method="post">

                <div class="form-group">
                    <label class="control-label" for="mac_address">
                        <strong>Endereço MAC</strong>
                    </label>
                    <div class="input-group">
                        <input type="hidden" class="form-control text-primary" name="id" value="<?php echo $IIIIIII1l11I; ?>">
                        <input class="form-control text-primary" id="description" name="mac_address" value="<?php echo $IIIIIII1l11l; ?>" type="text" required/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label" for="username">
                        <strong>Usuário</strong>
                    </label>
                    <div class="input-group">
                        <input type="text" class="form-control text-primary" name="username" value="<?php echo $IIIIIII11III; ?>" id="discription" required/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label" for="password">
                        <strong>Senha</strong>
                    </label>
                    <div class="input-group">
                        <input type="text" class="form-control text-primary" name="password" value="<?php echo $IIIIIII11IIl; ?>" id="discription" required/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label" for="expire_date">
                        <strong>Validade</strong>
                    </label>
                    <div class="input-group">
                        <input type="text" class="form-control text-primary" name="expire_date" value="<?php echo $IIIIIII1l111; ?>" id="datepicker" />
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label" for="dns">
                        <strong>DNS</strong>
                    </label>
                    <div class="input-group">
                        <input type="text" class="form-control text-primary" name="url" value="<?php echo $IIIIIII11II1; ?>" id="discription" required/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label" for="title">
                        <strong>Nome do Servidor</strong>
                    </label>
                    <div class="input-group">
                        <input type="text" class="form-control text-primary" name="title" value="<?php echo $IIIIIII11IlI; ?>" id="discription" required/>
                    </div>
                </div>

                <div class="form-group">
                    <div>
                        <button class="btn btn-success btn-icon-split" name="submit" type="submit">
                            <span class="icon text-white-50"><i class="fas fa-check"></i></span>
                            <span class="text">Enviar</span>
                        </button>
                    </div>
                </div>

            </form>
        </div>
    </div>

</div>

<?php include 'includes/footer.php'; ?>
</body>
</html>