<?php
/* Script by BoxBR Apks Rebrand  Panels (c) - https://t.me/boxbrapk / http://boxbr.k6.com.br */


$db = new SQLite3('./api/.boxbrpanels.db');
$res = $db->query('SELECT * ' . "\n\t\t\t\t" . '  FROM USERS ' . "\n\t\t\t\t" . '  WHERE ID=\'1\'');
$row = $res->fetchArray();
$message = '<div class="alert alert-primary" id="flash-msg"><h4><i class="icon fa fa-check"></i>Profile Updated!</h4></div>';

if (isset($_POST['submit'])) {
	$db->exec('UPDATE USERS ' . "\n\t\t\t" . 'SET' . "\t" . 'NAME=\'' . $_POST['name'] . '\',' . "\n\t\t\t" . '    USERNAME=\'' . $_POST['username'] . '\', ' . "\n\t\t\t\t" . 'PASSWORD=\'' . $_POST['password'] . '\',' . "\n\t\t\t\t" . 'LOGO=\'' . $_POST['logo'] . '\'' . "\n\t\t\t" . 'WHERE ' . "\n\t\t\t\t" . 'ID=\'1\' ');
	session_start();
	session_regenerate_id();
	$_SESSION['loggedin'] = true;
	$_SESSION['name'] = $_POST['username'];
	header('Location: profile.php?m=' . $message);
}

$name = $row['NAME'];
$user = $row['USERNAME'];
$pass = $row['PASSWORD'];
$logo = $row['LOGO'];
include 'includes/header.php';
echo ' <!-- Begin Page Content -->' . "\n";
echo '        <div class="container-fluid">' . "\n";
echo "\n";

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

echo '          <h1 class="h3 mb-1 text-gray-800">Update Login</h1>' . "\n";
echo '         ' . "\n";
echo '          <!-- Content Row -->' . "\n";
echo '          <div class="row">' . "\n";
echo "\n";
echo '            <!-- First Column -->' . "\n";
echo '            <div class="col-lg-12">' . "\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 text-primary"><i class="fa fa-user"></i> Update Profile</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 " for="name">' . "\n";
echo '                            <strong>Name</strong>' . "\n";
echo '                            </label>' . "\n";
echo '                            <div class="input-group">' . "\n";
echo '                            <input type="text" class="form-control text-primary" name="name" value="' . $name . '" placeholder="Enter Name">' . "\n";
echo '                            </div>' . "\n";
echo '                            </div>' . "\n";
echo '                            <div class="form-group ">' . "\n";
echo '                            <label class="control-label " for="username">' . "\n";
echo '                            <strong>Username</strong>' . "\n";
echo '                            </label>' . "\n";
echo '                            <div class="input-group">' . "\n";
echo '                            <input type="text" class="form-control text-primary" name="username" value="' . $user . '" placeholder="Enter Username">' . "\n";
echo '                            </div>' . "\n";
echo '                            </div>' . "\n";
echo '                            <div class="form-group ">' . "\n";
echo '                            <label class="control-label " for="password">' . "\n";
echo '                            <strong>Password</strong>' . "\n";
echo '                            </label>' . "\n";
echo '                            <div class="input-group">' . "\n";
echo '                            <input type="text" class="form-control text-primary" name="password" value="' . $pass . '" placeholder="Enter Password">' . "\n";
echo '                            </div>' . "\n";
echo '                            </div>' . "\n";
echo '                            <div class="form-group ">' . "\n";
echo '                            <label class="control-label " for="logo">' . "\n";
echo '                            <strong>Logo</strong>' . "\n";
echo '                            </label>' . "\n";
echo '                            <div class="input-group">' . "\n";
echo '                            <input type="text" class="form-control text-primary" name="logo" value="' . $logo . '" placeholder="Enter Profile URL">' . "\n";
echo '                            </div>' . "\n";
echo '                            </div>' . "\n";
echo '                            <div class="form-group">' . "\n";
echo '                            <div>' . "\n";
echo '                        <button class="btn btn-success btn-icon-split" name="submit" type="submit">' . "\n";
echo '                        <span class="icon text-white-50"><i class="fas fa-check"></i></span><span class="text">Submit</span>' . "\n";
echo '                        </button>' . "\n";
echo '                            </div>' . "\n";
echo '                            </div>' . "\n";
echo '                            <img type="image" width="100px" src="' . $logo . '" alt="image" /></div>' . "\n";
echo '                </div>' . "\n";
echo '                            </form>' . "\n";
echo '                </div>' . "\n";
echo '            </div>' . "\n";
echo '                </div>' . "\n";
include 'includes/footer.php';
require 'includes/boxbr.php';
echo '</body>' . "\n";

?>