Viewing File: D:\INETPUB\VHOSTS\officespacebangalore.com\httpdocs\admin\login.php
<?php
require_once __DIR__ . '/../config.php';
if (admin_ok()) {
go('admin/index.php');
}
$error = '';
$oldUser = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
try {
check_csrf();
$oldUser = trim((string)($_POST['username'] ?? ''));
$password = (string)($_POST['password'] ?? '');
if ($oldUser === '' || $password === '') {
$error = 'Enter your username/email and password.';
} else {
$stmt = db()->prepare(
'SELECT aid, auser, aemail, apass FROM admin WHERE auser = :u OR aemail = :u LIMIT 1'
);
$stmt->execute(['u' => $oldUser]);
$admin = $stmt->fetch();
if ($admin && admin_password_matches((string)$admin['apass'], $password)) {
session_regenerate_id(true);
$_SESSION['admin_id'] = (int)$admin['aid'];
$_SESSION['admin_user'] = (string)$admin['auser'];
$_SESSION['csrf'] = bin2hex(random_bytes(32));
go('admin/index.php');
}
$error = 'Invalid username/email or password.';
}
} catch (Throwable $e) {
$error = 'Unable to sign in right now. Please verify the database settings in config.php.';
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Admin Login · <?=e(SITE_NAME)?></title>
<link rel="stylesheet" href="<?=url('assets/css/admin.css')?>">
</head>
<body class="login-page">
<div class="login-card">
<a class="admin-brand login-brand" href="<?=url()?>">
<span>P</span><strong><?=e(SITE_NAME)?></strong>
</a>
<div class="eyebrow">SECURE ADMIN BOARD</div>
<h1>Welcome back.</h1>
<p>Manage properties, enquiries, users and website content from one place.</p>
<?php if ($error): ?>
<div class="admin-flash error"><?=e($error)?></div>
<?php endif; ?>
<form method="post" autocomplete="on">
<input type="hidden" name="csrf" value="<?=e(csrf())?>">
<label>Username or email
<input type="text" name="username" value="<?=e($oldUser)?>" autocomplete="username" required autofocus>
</label>
<label>Password
<input type="password" name="password" autocomplete="current-password" required>
</label>
<button class="admin-btn admin-btn-wide" type="submit">Sign in <span>→</span></button>
</form>
<a class="login-back" href="<?=url()?>">← Back to website</a>
</div>
</body>
</html>
Back to Directory
File Manager