86 lines
4.2 KiB
PHP
86 lines
4.2 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../includes/lang.php';
|
|
require_once __DIR__ . '/../db/config.php';
|
|
|
|
$error = '';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$account = $_POST['account'] ?? '';
|
|
$password = $_POST['password'] ?? '';
|
|
|
|
if (empty($account) || empty($password)) {
|
|
$error = 'Please fill in all fields';
|
|
} else {
|
|
$stmt = db()->prepare("SELECT * FROM users WHERE username = ? OR email = ?");
|
|
$stmt->execute([$account, $account]);
|
|
$user = $stmt->fetch();
|
|
|
|
if ($user && password_verify($password, $user['password_hash'])) {
|
|
if (session_status() === PHP_SESSION_NONE) session_start();
|
|
$_SESSION['user_id'] = $user['id'];
|
|
$_SESSION['username'] = $user['username'];
|
|
$_SESSION['uid'] = $user['uid'];
|
|
$_SESSION['role'] = $user['role'];
|
|
header('Location: /');
|
|
exit;
|
|
} else {
|
|
$error = 'Invalid account or password';
|
|
}
|
|
}
|
|
}
|
|
|
|
include __DIR__ . '/../includes/header.php';
|
|
?>
|
|
|
|
<div class="container py-5">
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-5">
|
|
<div class="card bg-dark border-0 shadow-lg p-4 p-md-5" style="border-radius: 30px; background: #161a1e !important; border: 1px solid var(--border) !important;">
|
|
<div class="text-center mb-5">
|
|
<div class="logo-container d-inline-flex mb-4">
|
|
<div class="logo-icon p-2" style="width: 45px; height: 45px;">
|
|
<svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
<path d="M12 2L2 7L12 12L22 7L12 2Z" fill="white"/>
|
|
<path d="M2 17L12 22L22 17" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
<path d="M2 12L12 17L22 12" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
</svg>
|
|
</div>
|
|
<span class="logo-text fs-1 ms-2" style="letter-spacing: 2px;">BYRO</span>
|
|
</div>
|
|
<h2 class="fw-bold text-white mb-2"><?= __('login') ?></h2>
|
|
<p class="text-muted"><?= __('welcome_back') ?></p>
|
|
</div>
|
|
|
|
<?php if ($error): ?>
|
|
<div class="alert alert-danger py-3 px-4 small border-0 bg-danger bg-opacity-10 text-danger rounded-4 mb-4">
|
|
<i class="bi bi-exclamation-triangle-fill me-2"></i><?= $error ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<form method="POST">
|
|
<div class="mb-4">
|
|
<label class="form-label text-muted small fw-bold"><?= __('account') ?></label>
|
|
<input type="text" name="account" class="form-control bg-black border-secondary text-white py-3 px-4 rounded-4" style="background: #0b0e11 !important; border-color: #2b3139 !important;" required>
|
|
</div>
|
|
|
|
<div class="mb-4">
|
|
<div class="d-flex justify-content-between">
|
|
<label class="form-label text-muted small fw-bold"><?= __('password') ?></label>
|
|
<a href="#" class="small text-primary text-decoration-none"><?= __('forgot_password') ?></a>
|
|
</div>
|
|
<input type="password" name="password" class="form-control bg-black border-secondary text-white py-3 px-4 rounded-4" style="background: #0b0e11 !important; border-color: #2b3139 !important;" required>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-primary w-100 py-3 fw-bold rounded-pill mb-4 shadow-primary"><?= __('login') ?></button>
|
|
|
|
<div class="text-center small text-muted">
|
|
<?= __('no_account') ?> <a href="/auth/register.php" class="text-primary fw-bold text-decoration-none"><?= __('register') ?></a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php include __DIR__ . '/../includes/footer.php'; ?>
|