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

	$db = new SQLite3('./api/.db.db');

    $rowQuery = $db->query("SELECT applock FROM users WHERE id = 1");
    $applock = $rowQuery->fetchArray()[0];

	if(isset($_POST['update']))
	{
		$db->exec("UPDATE users SET applock='".SQLite3::escapeString($_POST["applock"])."' WHERE id = 1");
	}

	include ('includes/header.php');
?>

<div class="has-sidebar-left has-sidebar-tabs">
    <div class="container-fluid relative animatedParent animateOnce p-lg-5">
        <div class="col-lg mx-auto">
            <div class="card-body">
                <div class="card bg-primary text-white">
                    <div class="card-header card-header-warning">
                        <center>
                            <h2><i class="icon icon-lock-stripes2 s-24"></i>Lock the App</h2>
                        </center>
                    </div>
                    <div class="card-body">
                        <div class="col-12">
                        	<form method="post"> 
								<div class="form-group">
									<label class="form-label">Enter the password lock</label>
									<input class="form-control" name="applock" value="<?=$_POST['applock'] ?? $applock?>" type="text" >
								</div>
								<hr>
								<center>
									<button type="submit" name="update" class="btn btn-info">
										<i class="icon icon-check"></i>Save
									</button>
								</center>
							</form>
    					</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<?php include ('includes/footer.php');?>

</body>
</html>