| Server IP : 72.60.21.38 / Your IP : 216.73.216.164 Web Server : LiteSpeed System : Linux uk-fast-web1372.main-hosting.eu 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64 User : u390967363 ( 390967363) PHP Version : 8.2.30 Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/u390967363/domains/aibenproperties.com/public_html/app/ |
Upload File : |
<?php
session_start();
require_once __DIR__ . '/includes/db.php';
require_once __DIR__ . '/includes/functions.php';
require_once __DIR__ . '/includes/mailer.php';
$error = '';
$success = '';
$defaultCompanyId = null;
try {
$companyStmt = $pdo->prepare("SELECT id FROM companies WHERE code = ? LIMIT 1");
$companyStmt->execute(['AIBEN']);
$defaultCompanyId = $companyStmt->fetchColumn() ?: null;
} catch (PDOException $e) {
$defaultCompanyId = null;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = trim($_POST['name'] ?? '');
$email = trim($_POST['email'] ?? '');
$password = trim($_POST['password'] ?? '');
$phone = trim($_POST['phone'] ?? '');
$honeypot = trim($_POST['website'] ?? '');
if ($honeypot !== '') {
$error = "Registration failed. Please try again.";
} elseif ($name && $email && $password) {
$identityCols = ['email','email_address','user_email','mail','username','login'];
$passCols = ['password','password_hash','passwd','pass'];
$roleCols = ['role','user_role'];
$identityCol = null;
$passCol = null;
$roleCol = null;
try {
foreach ($identityCols as $c) { if (function_exists('tableHasColumn') && tableHasColumn('users', $c)) { $identityCol = $c; break; } }
foreach ($passCols as $c) { if (function_exists('tableHasColumn') && tableHasColumn('users', $c)) { $passCol = $c; break; } }
foreach ($roleCols as $c) { if (function_exists('tableHasColumn') && tableHasColumn('users', $c)) { $roleCol = $c; break; } }
} catch (Throwable $e) {}
$exists = false;
foreach ($identityCols as $c) {
try {
$stmt = $pdo->prepare("SELECT id FROM users WHERE `{$c}` = ? LIMIT 1");
$stmt->execute([$email]);
if ($stmt->fetchColumn()) { $exists = true; break; }
} catch (Throwable $e) {
$m = strtolower((string)$e->getMessage());
if (strpos($m, 'unknown column') !== false || strpos($m, 'column not found') !== false) { continue; }
}
}
if ($exists) {
$error = "An account with this email already exists.";
} elseif (!$identityCol || !$passCol) {
$error = "Registration is temporarily unavailable. Please contact support.";
} else {
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
$cols = ["name", $identityCol, $passCol];
$vals = [$name, $email, $hashed_password];
if ($roleCol) { $cols[] = $roleCol; $vals[] = 'client'; }
if (tableHasColumn('users', 'company_id') && $defaultCompanyId) {
array_unshift($cols, "company_id");
array_unshift($vals, $defaultCompanyId);
}
if (tableHasColumn('users', 'phone') && $phone) {
$cols[] = "phone";
$vals[] = $phone;
}
$token = bin2hex(random_bytes(32));
$tokenHash = hash('sha256', $token);
$expires = date('Y-m-d H:i:s', time() + 86400);
if (tableHasColumn('users', 'email_verified')) { $cols[] = "email_verified"; $vals[] = 0; }
if (tableHasColumn('users', 'verification_token')) { $cols[] = "verification_token"; $vals[] = $tokenHash; }
if (tableHasColumn('users', 'verification_expires_at')) { $cols[] = "verification_expires_at"; $vals[] = $expires; }
$sql = "INSERT INTO users (" . implode(',', $cols) . ") VALUES (" . implode(',', array_fill(0, count($cols), '?')) . ")";
$stmt = $pdo->prepare($sql);
if ($stmt->execute($vals)) {
$user_id = $pdo->lastInsertId();
// Log action
if (function_exists('log_action')) {
log_action($pdo, $user_id, 'REGISTER', "New client registration: $name");
}
$appUrl = getSetting('app_url', '');
if (!$appUrl) { $appUrl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . '://' . ($_SERVER['HTTP_HOST'] ?? 'localhost') . rtrim(dirname($_SERVER['PHP_SELF'] ?? '/'), '/'); }
$verifyLink = rtrim($appUrl, '/') . '/verify-email.php?email=' . urlencode($email) . '&token=' . urlencode($token);
$subject = "Verify your email";
$body = "Hello $name,\n\nPlease verify your email to activate your account:\n$verifyLink\n\nThis link expires in 24 hours.\n\nRegards,\n" . getSetting('company_name', 'Aiben Properties');
sendEmail($email, $subject, $body);
$success = "Registration successful! Please check your email to verify your account.";
} else {
$error = "Registration failed. Please try again.";
}
}
} else {
$error = "Please fill in all required fields.";
}
}
// Branding
$sysCompanyName = getSetting('company_name', 'Aiben Properties');
$sysLogo = getSetting('company_logo', '');
$brandingDisplay = getSetting('branding_display', 'auto');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create Client Account | <?= htmlspecialchars($sysCompanyName) ?></title>
<!-- Bootstrap 5 -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- Custom CSS -->
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/auth.css">
</head>
<body class="auth-page">
<div class="auth-wrapper">
<!-- LEFT SIDE: BRANDING & VALUE PROP -->
<div class="auth-sidebar">
<div class="auth-sidebar-content">
<div class="auth-logo d-flex align-items-center">
<?php
$hasLogo = !empty($sysLogo);
$hasName = !empty($sysCompanyName);
$mode = $brandingDisplay ?: 'auto';
if ($mode === 'auto') { $mode = $hasLogo ? 'logo' : 'text'; }
$showLogo = ($mode === 'logo' || $mode === 'both') && $hasLogo;
$showName = ($mode === 'text' || $mode === 'both') && $hasName;
if ($showLogo) {
echo '<img src="'.htmlspecialchars($sysLogo).'" alt="'.htmlspecialchars($sysCompanyName).'" height="30" style="max-width:170px;object-fit:contain;filter: brightness(0) invert(1);">';
}
if ($showName) {
echo '<span class="ms-2 fw-semibold" style="font-size:1.1rem;">'.htmlspecialchars($sysCompanyName).'</span>';
}
if (!$showLogo && !$showName) {
echo '<i class="fa-solid fa-building-user text-white-50"></i>';
}
?>
</div>
<div class="mt-5">
<h2 class="text-white fw-bold mb-4">Experience Premium<br>Property Management</h2>
<ul class="auth-features">
<li>
<i class="fa-solid fa-chart-pie"></i>
<span><strong>Track Allocations:</strong> Monitor your property portfolio in real-time.</span>
</li>
<li>
<i class="fa-solid fa-file-invoice-dollar"></i>
<span><strong>Payment History:</strong> View transactions and download receipts instantly.</span>
</li>
<li>
<i class="fa-solid fa-file-contract"></i>
<span><strong>Digital Documents:</strong> Access lease agreements and deeds securely.</span>
</li>
<li>
<i class="fa-solid fa-bell"></i>
<span><strong>Smart Alerts:</strong> Get notified about due dates and estate updates.</span>
</li>
</ul>
</div>
</div>
<div class="auth-sidebar-footer text-white-50 small mt-auto">
© <?= date('Y') ?> <?= htmlspecialchars($sysCompanyName) ?>. All rights reserved.
</div>
</div>
<!-- RIGHT SIDE: SIGNUP FORM -->
<div class="auth-main">
<div class="auth-form-container">
<div class="auth-header">
<span class="badge bg-primary-subtle text-primary mb-2 px-3 py-2 rounded-pill">Client Dashboard</span>
<h1 class="auth-title">Create your Account</h1>
<p class="auth-subtitle">Join thousands of property owners managing their assets with ease.</p>
</div>
<?php if ($error): ?>
<div class="alert alert-danger d-flex align-items-center" role="alert">
<i class="fa-solid fa-circle-exclamation me-2"></i>
<div><?= htmlspecialchars($error) ?></div>
</div>
<?php endif; ?>
<?php if ($success): ?>
<div class="alert alert-success d-flex align-items-center" role="alert">
<i class="fa-solid fa-circle-check me-2"></i>
<div>
<?= htmlspecialchars($success) ?>
<div class="mt-2">
<a href="login.php" class="btn btn-sm btn-success">Login Now</a>
</div>
</div>
</div>
<?php else: ?>
<form method="POST" class="needs-validation" novalidate>
<div class="row g-3">
<input type="text" name="website" value="" style="position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden" tabindex="-1" autocomplete="off">
<div class="col-12">
<div class="form-floating">
<input type="text" class="form-control" id="name" name="name" placeholder="John Doe" required>
<label for="name">Full Name</label>
</div>
</div>
<div class="col-12">
<div class="form-floating">
<input type="email" class="form-control" id="email" name="email" placeholder="name@example.com" required>
<label for="email">Email Address</label>
</div>
</div>
<div class="col-12">
<div class="form-floating">
<input type="tel" class="form-control" id="phone" name="phone" placeholder="+234...">
<label for="phone">Phone Number (Optional)</label>
</div>
</div>
<div class="col-12">
<div class="form-floating position-relative">
<input type="password" class="form-control pe-5" id="password" name="password" placeholder="Password" required>
<label for="password">Create Password</label>
<button type="button" class="btn btn-link position-absolute top-50 end-0 translate-middle-y me-2 p-0 text-muted js-toggle-password" data-target="#password" aria-label="Show password">
<i class="fa-regular fa-eye"></i>
</button>
</div>
<div class="form-text text-muted small mt-1">
Must be at least 8 characters long.
</div>
</div>
<div class="col-12 mt-4">
<button type="submit" class="btn btn-auth">
Create Account <i class="fa-solid fa-arrow-right ms-2"></i>
</button>
</div>
<div class="col-12 text-center mt-3">
<p class="text-muted small">
Already have an account? <a href="login.php" class="text-decoration-none fw-bold" style="color: var(--primary);">Sign In</a>
</p>
</div>
</div>
</form>
<?php endif; ?>
</div>
</div>
</div>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
(function () {
function onToggle(btn) {
var sel = btn.getAttribute('data-target');
var input = sel ? document.querySelector(sel) : null;
if (!input) return;
var isPassword = (input.getAttribute('type') || '').toLowerCase() === 'password';
input.setAttribute('type', isPassword ? 'text' : 'password');
btn.setAttribute('aria-label', isPassword ? 'Hide password' : 'Show password');
var icon = btn.querySelector('i');
if (icon) {
icon.classList.remove('fa-eye', 'fa-eye-slash');
icon.classList.add(isPassword ? 'fa-eye-slash' : 'fa-eye');
}
}
document.querySelectorAll('.js-toggle-password').forEach(function (btn) {
btn.addEventListener('click', function () { onToggle(btn); });
});
})();
</script>
</body>
</html>