u
This commit is contained in:
@@ -10,7 +10,15 @@ if(isset($_SESSION["login"])){
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
|
||||
<title>Cyberhex login page</title>
|
||||
<title>Cyberhex login page</title>
|
||||
<style>
|
||||
.bg-image {
|
||||
background-image: url('/logo.png');
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
height: 100vh; /* Set height to viewport height */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
@@ -218,111 +226,113 @@ async function checkRegistration() {
|
||||
}
|
||||
|
||||
</script>
|
||||
<div class="container mt-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4>Login to Cyberhex</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="login.php" method="post">
|
||||
<div class="form-group">
|
||||
<label for="username">Username:</label>
|
||||
<input type="text" class="form-control" id="username" name="username" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Password:</label>
|
||||
<input type="password" class="form-control" id="password" name="password" required>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<button style="align:left" type="submit" class="btn btn-primary btn-block">Login with password</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<center>Or</center>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button style="align:right" type="button" class="btn btn-primary btn-block" onclick="checkRegistration()">Login with a passkey</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<br><br>
|
||||
<div class="alert alert-danger" role="alert" style="display:none" id="no_passkey">
|
||||
You do not have a passkey associatet with your account.
|
||||
<div class="container-fluid bg-image">
|
||||
<div class="container mt-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4>Login to Cyberhex</h4>
|
||||
</div>
|
||||
<!-- php code to verify password-->
|
||||
<?php
|
||||
// Check if the form is submitted
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
//include db pw
|
||||
include "../../../config.php";
|
||||
|
||||
// Retrieve user input
|
||||
$username = htmlspecialchars($_POST["username"]);
|
||||
$password = $_POST["password"];
|
||||
<div class="card-body">
|
||||
<form action="login.php" method="post">
|
||||
<div class="form-group">
|
||||
<label for="username">Username:</label>
|
||||
<input type="text" class="form-control" id="username" name="username" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Password:</label>
|
||||
<input type="password" class="form-control" id="password" name="password" required>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<button style="align:left" type="submit" class="btn btn-primary btn-block">Login with password</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<center>Or</center>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button style="align:right" type="button" class="btn btn-primary btn-block" onclick="checkRegistration()">Login with a passkey</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<br><br>
|
||||
<div class="alert alert-danger" role="alert" style="display:none" id="no_passkey">
|
||||
You do not have a passkey associatet with your account.
|
||||
</div>
|
||||
<!-- php code to verify password-->
|
||||
<?php
|
||||
// Check if the form is submitted
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
//include db pw
|
||||
include "../../../config.php";
|
||||
|
||||
// Retrieve user input
|
||||
$username = htmlspecialchars($_POST["username"]);
|
||||
$password = $_POST["password"];
|
||||
|
||||
|
||||
// Create a connection
|
||||
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD, $DB_DATABASE);
|
||||
// Create a connection
|
||||
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD, $DB_DATABASE);
|
||||
|
||||
// Check the connection
|
||||
if ($conn->connect_error) {
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
$sql = "SELECT * FROM users WHERE username = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("s", $username);
|
||||
|
||||
// Execute the statement
|
||||
$stmt->execute();
|
||||
// Check the connection
|
||||
if ($conn->connect_error) {
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
$sql = "SELECT * FROM users WHERE username = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("s", $username);
|
||||
|
||||
// Execute the statement
|
||||
$stmt->execute();
|
||||
|
||||
// Get the result
|
||||
$result = $stmt->get_result();
|
||||
|
||||
// Check if the user exists and verify the password
|
||||
if ($result->num_rows > 0) {
|
||||
$row = $result->fetch_assoc();
|
||||
if($row["allow_pw_login"]==1){
|
||||
if (password_verify($password, $row['password'])) {
|
||||
$_SESSION["username"]=$username;
|
||||
$_SESSION["login"]=true;
|
||||
$_SESSION["perms"]=$row["perms"];
|
||||
$_SESSION["email"]=$row["email"];
|
||||
$_SESSION["telegram_id"]=$row["telegram_id"];
|
||||
$_SESSION["allow_pw_login"]=$row["allow_pw_login"];
|
||||
|
||||
echo '<script>window.location.href = "/system/secure_zone/php/index.php";</script>';
|
||||
exit();
|
||||
} else {
|
||||
echo '<div class="alert alert-danger" role="alert">
|
||||
Incorrect username or password.
|
||||
</div>';
|
||||
// Get the result
|
||||
$result = $stmt->get_result();
|
||||
|
||||
// Check if the user exists and verify the password
|
||||
if ($result->num_rows > 0) {
|
||||
$row = $result->fetch_assoc();
|
||||
if($row["allow_pw_login"]==1){
|
||||
if (password_verify($password, $row['password'])) {
|
||||
$_SESSION["username"]=$username;
|
||||
$_SESSION["login"]=true;
|
||||
$_SESSION["perms"]=$row["perms"];
|
||||
$_SESSION["email"]=$row["email"];
|
||||
$_SESSION["telegram_id"]=$row["telegram_id"];
|
||||
$_SESSION["allow_pw_login"]=$row["allow_pw_login"];
|
||||
|
||||
echo '<script>window.location.href = "/system/secure_zone/php/index.php";</script>';
|
||||
exit();
|
||||
} else {
|
||||
echo '<div class="alert alert-danger" role="alert">
|
||||
Incorrect username or password.
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
else{
|
||||
echo '<div class="alert alert-danger" role="alert">
|
||||
Password login is disabled on your account. Please use your passkey
|
||||
</div>';
|
||||
}
|
||||
} else {
|
||||
echo '<div class="alert alert-danger" role="alert">
|
||||
Password login is disabled on your account. Please use your passkey
|
||||
</div>';
|
||||
Incorrect username or password.
|
||||
</div>';
|
||||
}
|
||||
} else {
|
||||
echo '<div class="alert alert-danger" role="alert">
|
||||
Incorrect username or password.
|
||||
</div>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Close the connection
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
// Close the connection
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
BIN
src/server/logo.png
Normal file
BIN
src/server/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 95 KiB |
Reference in New Issue
Block a user