<?php
/**
*
* @ This file is created by http://DeZender.Net
* @ deZender (PHP7 Decoder for SourceGuardian Encoder)
*
* @ Version			:	4.1.0.1
* @ Author			:	DeZender
* @ Release on		:	29.08.2020
* @ Official site	:	http://DeZender.Net
*
*/

$db = new SQLite3('./a/.eggziedb.db');
$res = $db->query('SELECT * ' . "\n\t\t\t\t" . '  FROM ibo ' . "\n\t\t\t\t" . '  WHERE id=\'' . $_GET['update'] . '\'');
$row = $res->fetchArray();
$id = $row['id'];
$mac_address = $row['mac_address'];
$expire_date = $row['expire_date'];
$username = $row['username'];
$password = $row['password'];

if (isset($_POST['submit'])) {
	$we = strtotime('+ 5years');
	$ne = date('Y-m-d', $we);
	$start = date('Y-m-d');
	$end = date('h:m:s');
	$full = $start . 'T' . $end . '.000000Z';
	$created_at = date('yyyy-MM-dd\'T\'hh:mm:ss.SSSSSS\'Z\'');
	$db->exec('UPDATE ibo SET mac_address=\'' . $_POST['mac_address'] . '\',' . "\n\t\t\t\t\t\t\t\t" . 'expire_date=\'' . $ne . '\',' . "\n\t\t\t\t\t\t\t\t" . 'username=\'' . $_POST['username'] . '\',' . "\n\t\t\t\t\t\t\t\t" . 'url=\'' . $_POST['url'] . '\',' . "\n\t\t\t\t\t\t\t\t" . 'title=\'' . $_POST['title'] . '\',' . "\n\t\t\t\t\t\t\t\t" . 'password=\'' . $_POST['password'] . '\',' . "\n\t\t\t\t\t\t\t\t" . 'created_at=\'' . $full . '\'' . "\n\t\t\t\t\t\t" . '  WHERE ' . "\n\t\t\t\t\t\t\t" . '  id=\'' . $_POST['id'] . '\'');
	$db->close();
	header('Location: users.php?success');
}

include 'includes/header.php';
$userupdate_id = $row['id'];
$userupdate_mac_address = $row['mac_address'];
$userupdate_expire_date = $row['expire_date'];
$userupdate_username = $row['username'];
$userupdate_password = $row['password'];
$userupdate_url = $row['url'];
$userupdate_title = $row['title'];
echo ' <!-- Begin Page Content -->' . "\n";
echo '        <div class="container-fluid">' . "\n";
echo "\n";

if (isset($_GET['succes'])) {
	echo $msg_delete;
}

if (isset($_GET['success'])) {
	echo $msg_success;
}

echo '          <!-- Page Heading -->' . "\n";
echo '          <h1 class="h3 mb-1" style="color:' . $colour_head_16 . ';"> User Management</h1>' . "\n";
echo "\n";
echo '              <!-- Custom codes -->' . "\n";
echo '                <div class="card border-left-primary shadow h-100 card shadow mb-4">' . "\n";
echo '                <div class="card-header py-3">' . "\n";
echo '                <h6 class="m-0 font-weight-bold" style="color:' . $colour_head_11 . ';"><i class="fa fa-user"></i> Edit User</h6>' . "\n";
echo '                </div>' . "\n";
echo '                <div class="card-body">' . "\n";
echo '                        <form method="post">' . "\n";
echo '                        <div class="form-group">' . "\n";
echo '                                    <label class="control-label " style="color:' . $colour_head_18 . ';" for="mac_address"><strong>' . "\n";
echo '                                        Mac Address</strong>' . "\n";
echo '                                    </label>' . "\n";
echo '                                    <div class="input-group">' . "\n";
echo '                                        <input type="hidden" name="id" value="' . $userupdate_id . '">' . "\n";
echo '                                        <input class="form-control" style="background-color:' . $colour_head_17 . ';color:' . $colour_head_10 . ';" class="form-control" id="mac_address" name="mac_address"  value="' . $userupdate_mac_address . '" type="text"/>' . "\n";
echo '                                    </div>' . "\n";
echo '                                    </div>' . "\n";
echo '                        <div class="form-group">' . "\n";
echo '                                    <label class="control-label " style="color:' . $colour_head_18 . ';" for="username"><strong>' . "\n";
echo '                                        Username</strong>' . "\n";
echo '                                    </label>' . "\n";
echo '                                    <div class="input-group">' . "\n";
echo '                                        <input class="form-control" style="background-color:' . $colour_head_17 . ';color:' . $colour_head_10 . ';" class="form-control" id="username" name="username" value="' . $userupdate_username . '" type="text"/>' . "\n";
echo '                                    </div>' . "\n";
echo '                                    </div>' . "\n";
echo '                        <div class="form-group">' . "\n";
echo '                                    <label class="control-label " style="color:' . $colour_head_18 . ';" for="password"><strong>' . "\n";
echo '                                        Password</strong>' . "\n";
echo '                                    </label>' . "\n";
echo '                                    <div class="input-group">' . "\n";
echo '                                        <input class="form-control" style="background-color:' . $colour_head_17 . ';color:' . $colour_head_10 . ';" class="form-control" id="password" name="password"  value="' . $userupdate_password . '" type="text"/>' . "\n";
echo '                                    </div>' . "\n";
echo '                                    </div>' . "\n";
echo '                            <div class="form-group">' . "\n";
echo '                                <label class="control-label" style="color:' . $colour_head_18 . ';"' . "\n" . 'for="dns"><strong>Url</strong></label>' . "\n";
echo '                                <select class="select form-control" id="select" name="url">' . "\n";
echo '<option value="">--Select--</option>';
$hostres = $db->query('SELECT * FROM portals');

while ($hostrow = $hostres->fetchArray()) {
	$selected = ($hostrow['id'] == $userupdate_url ? ' selected' : '');
	echo "\n" . '<option value="' . $hostrow['id'] . '"' . $selected . '>' . $hostrow['name'] . '</option>';
}

echo '</select>' . "\n";
echo '                                ' . "\n";
echo '        </div>' . "\n";
echo '                        <div class="form-group">' . "\n";
echo '                                    <label class="control-label " style="color:' . $colour_head_18 . ';" for="title"><strong>' . "\n";
echo '                                        Title</strong>' . "\n";
echo '                                    </label>' . "\n";
echo '                                    <div class="input-group">' . "\n";
echo '                                        <input class="form-control" style="background-color:' . $colour_head_17 . ';color:' . $colour_head_10 . ';" class="form-control" id="title" name="title" value="' . $userupdate_title . '" type="text"/>' . "\n";
echo '                                    </div>' . "\n";
echo '                                    </div>' . "\n";
echo '                                    ' . "\n";
echo '                                <div class="form-group">' . "\n";
echo '                                        <button class="btn btn-success btn-icon-split" style="background-color:' . $colour_head_btn . ';border-color:' . $colour_head_btn . ';color:' . $colour_head_10 . ';" name="submit" type="submit">' . "\n";
echo '                        <span class="icon text-white-50"><i class="fas fa-check" style="color:' . $colour_head_10 . ';"></i></span><span class="text">Submit</span>' . "\n";
echo '                        </button>' . "\n";
echo '                                    </div>' . "\n";
echo "\n";
echo '                                </div>' . "\n";
echo '                            </form>' . "\n";
echo '                </div>' . "\n";
echo '              </div>' . "\n";
include 'includes/footer.php';
require 'includes/egz.php';
echo '</body>' . "\n";

?>