<?php
/*
 * @ https://hospedagem.matrixch.store 
 * @ PHP 7.4
 * @ Decoder version: 1.0.2
 * @ Release: 17/06/2024
*/

include "includes/functions.php";
if (session_status() == PHP_SESSION_NONE) {
    session_start();
}
$log_check = $db->select("users", "*", "id = :id", "", [":id" => 1]);
$loggedinuser = !empty($log_check) ? $log_check[0]["username"] : NULL;
if (!empty($loggedinuser) && isset($_SESSION["name"]) && $_SESSION["name"] === $loggedinuser) {
    header("Location: dns.php");
    exit;
}
$data = ["id" => "1", "username" => "admin", "password" => "admin"];
$db->insertIfEmpty("users", $data);
if (isset($_POST["login"])) {
    $username = $_POST["username"];
    $userData = $db->select("users", "*", "username = :username", "", [":username" => $username]);
    if ($userData) {
        $storedPassword = $userData[0]["password"];
        $enteredPassword = $_POST["password"];
        if ($enteredPassword == $storedPassword) {
            session_regenerate_id();
            $_SESSION["loggedin"] = true;
            $_SESSION["name"] = $_POST["username"];
            if ($_POST["username"] == "admin") {
                header("Location: user.php");
            } else {
                header("Location: dns.php");
            }
        } else {
            header("Location: ./api/index.php");
        }
    } else {
        header("Location: ./api/index.php");
    }
    $db->close();
}
echo "<!DOCTYPE html>\r\n<html lang=\"en\">\r\n<head>\r\n\t<meta charset=\"utf-8\">\r\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">\r\n\t<meta name=\"author\" content=\"IBO V41\">\r\n\t<link rel=\"stylesheet\" href=\"https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css\">\r\n\t<link rel=\"stylesheet\" href=\"./css/css.css\">\r\n    <title>IBO V41</title>\r\n</head>\r\n<style>\r\nbody{\r\n  background-color: #181828;\r\n  background-image: url(\"./img/binding_dark.webp\");\r\n  color #fff;\r\n}\r\n\r\n#particles-js{\r\n  background-size: cover;\r\n  background-position: 50% 50%;\r\n  background-repeat: no-repeat;\r\n  /*width: 100%;\r\n  height: 100vh;*/\r\n  background: #8000FF;\r\n  display: flex;\r\n  justify-content: center;\r\n  align-items: center;\r\n\r\n}\r\n\r\n.particles-js-canvas-el{\r\n  position: fixed;\r\n}\r\n</style>\r\n<div id=\"js-particles\"></div>\r\n<br><br>\r\n        <div class=\"container\">\r\n            <div class=\"row\">\r\n                <div class=\"col-lg-4 mx-md-auto\">\r\n                    <div class=\"text-center\">\r\n                        <img class=\"w-75 p-3\" src=\"./img/logo.png\" alt=\"\">\r\n                    </div>\r\n                    <br>\r\n                    <form method=\"post\">\r\n                        <div class=\"form-group\">\r\n                            <input type=\"text\" class=\"form-control form-control-lg\"\r\n                                   placeholder=\"Username\" name=\"username\" required autofocus>\r\n                        </div>\r\n                        <div class=\"form-group\">\r\n                            <input type=\"text\" class=\"form-control form-control-lg\"\r\n                                   placeholder=\"Password\" name=\"password\" required>\r\n                        </div>\r\n                        <input type=\"submit\" class=\"btn btn-info\" value=\"CONECTAR\" name=\"login\">\r\n                    </form>\r\n\t\t\t\t\t<br>\r\n       <center><a clas=\"list-grup-item\" href=\"https://\"           
class=\"list-grup-item\" href=\"https://\" target=\"_blank\">PROJETO";
echo "IBO V41</a></center>\r\n                </div>\r\n            </div>\r\n        </div>\r\n<br><br>\r\n\r\n<script src=\"https://code.jquery.com/jquery-3.3.1.js\"></script>\r\n<script src=\"https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js\" integrity=\"sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49\" crossorigin=\"anonymous\"></script>\r\n<script src=\"https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js\" integrity=\"sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy\" crossorigin=\"anonymous\"></script>\r\n<script src=\"https://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js\"></script>\r\n<script src=\"js/particles.js\"></script>\r\n\r\n";

?>