1.1.1.1.1 v1
This commit is contained in:
parent
439cee0453
commit
c56a30b688
255
admin.php
Normal file
255
admin.php
Normal file
@ -0,0 +1,255 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Admin Dashboard</title>
|
||||
<link rel="stylesheet" href="assets/css/styles.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header class="main-header">
|
||||
<div class="container">
|
||||
<a href="/" class="logo">AppCo</a>
|
||||
<nav class="main-nav">
|
||||
<ul>
|
||||
<li><a href="/">Home</a></li>
|
||||
<li><a href="/admin.php" class="active">Admin Panel</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
<div class="dashboard-header">
|
||||
<h1>Admin Dashboard</h1>
|
||||
</div>
|
||||
|
||||
<!-- Analytics Section -->
|
||||
<section class="analytics-cards">
|
||||
<div class="card">
|
||||
<h3>Total Users</h3>
|
||||
<div class="stat"><?php echo $stats['total_users']; ?></div>
|
||||
</div>
|
||||
<div class="card" style="border-left-color: #28a745;">
|
||||
<h3>KYC Approved</h3>
|
||||
<div class="stat"><?php echo $stats['kyc_approved']; ?></div>
|
||||
</div>
|
||||
<div class="card" style="border-left-color: #ffc107;">
|
||||
<h3>KYC Pending</h3>
|
||||
<div class="stat"><?php echo $stats['kyc_pending']; ?></div>
|
||||
</div>
|
||||
<div class="card" style="border-left-color: #dc3545;">
|
||||
<h3>KYC Rejected</h3>
|
||||
<div class="stat"><?php echo $stats['kyc_rejected']; ?></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- User Management Section -->
|
||||
<section class="user-management">
|
||||
<div class="user-management-header">
|
||||
<h2>User Management</h2>
|
||||
<button class="btn btn-primary" onclick="openModal('addUserModal')">Add User</button>
|
||||
</div>
|
||||
|
||||
<?php if ($notification): ?>
|
||||
<div class="alert alert-<?php echo $notification['type']; ?>" style="padding: 1rem; border-radius: 0.25rem; color: #fff; background-color: <?php echo $notification['type'] === 'success' ? '#28a745' : '#dc3545'; ?>; margin-bottom: 1rem;">
|
||||
<?php echo $notification['message']; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
<th>Email</th>
|
||||
<th>KYC Status</th>
|
||||
<th>Created At</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($users as $user): ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($user['id']); ?></td>
|
||||
<td><?php echo htmlspecialchars($user['name']); ?></td>
|
||||
<td><?php echo htmlspecialchars($user['email']); ?></td>
|
||||
<td>
|
||||
<span class="badge badge-<?php
|
||||
$status = strtolower(htmlspecialchars($user['kyc_status']));
|
||||
echo $status === 'approved' ? 'success' : ($status === 'pending' ? 'warning' : 'danger');
|
||||
?>">
|
||||
<?php echo htmlspecialchars($user['kyc_status']); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td><?php echo htmlspecialchars($user['created_at']); ?></td>
|
||||
<td>
|
||||
<button class="btn btn-secondary btn-sm edit-btn"
|
||||
style="background: #6c757d; color: white"
|
||||
data-id="<?php echo $user['id']; ?>"
|
||||
data-name="<?php echo htmlspecialchars($user['name']); ?>"
|
||||
data-email="<?php echo htmlspecialchars($user['email']); ?>"
|
||||
data-kyc="<?php echo htmlspecialchars($user['kyc_status']); ?>">
|
||||
Edit
|
||||
</button>
|
||||
<button class="btn btn-danger btn-sm delete-btn"
|
||||
style="background: #dc3545; color: white"
|
||||
data-id="<?php echo $user['id']; ?>">
|
||||
Delete
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<!-- Add User Modal -->
|
||||
<div id="addUserModal" class="modal">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h2>Add New User</h2>
|
||||
<span class="close-button" onclick="closeModal('addUserModal')">×</span>
|
||||
</div>
|
||||
<form action="admin.php" method="POST">
|
||||
<input type="hidden" name="action" value="add">
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="name">Name</label>
|
||||
<input type="text" id="name" name="name" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Email</label>
|
||||
<input type="email" id="email" name="email" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Password</label>
|
||||
<input type="password" id="password" name="password" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="kyc_status">KYC Status</label>
|
||||
<select id="kyc_status" name="kyc_status">
|
||||
<option>Pending</option>
|
||||
<option>Approved</option>
|
||||
<option>Rejected</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer" style="text-align: right;">
|
||||
<button type="button" class="btn btn-secondary" onclick="closeModal('addUserModal')" style="background: #6c757d; color: white">Close</button>
|
||||
<button type="submit" class="btn btn-primary" style="background: #007bff; color: white;">Save User</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Edit User Modal -->
|
||||
<div id="editUserModal" class="modal">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h2>Edit User</h2>
|
||||
<span class="close-button" onclick="closeModal('editUserModal')">×</span>
|
||||
</div>
|
||||
<form action="admin.php" method="POST">
|
||||
<input type="hidden" name="action" value="edit">
|
||||
<input type="hidden" name="id" id="edit-user-id">
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="edit-name">Name</label>
|
||||
<input type="text" id="edit-name" name="name" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="edit-email">Email</label>
|
||||
<input type="email" id="edit-email" name="email" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="edit-kyc_status">KYC Status</label>
|
||||
<select id="edit-kyc_status" name="kyc_status">
|
||||
<option>Pending</option>
|
||||
<option>Approved</option>
|
||||
<option>Rejected</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="edit-password">New Password (optional)</label>
|
||||
<input type="password" id="edit-password" name="password">
|
||||
<small>Leave blank to keep the current password.</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer" style="text-align: right;">
|
||||
<button type="button" class="btn btn-secondary" onclick="closeModal('editUserModal')" style="background: #6c757d; color: white">Close</button>
|
||||
<button type="submit" class="btn btn-primary" style="background: #007bff; color: white;">Save Changes</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Delete User Modal -->
|
||||
<div id="deleteUserModal" class="modal">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h2>Delete User</h2>
|
||||
<span class="close-button" onclick="closeModal('deleteUserModal')">×</span>
|
||||
</div>
|
||||
<form action="admin.php" method="POST">
|
||||
<input type="hidden" name="action" value="delete">
|
||||
<input type="hidden" name="id" id="delete-user-id">
|
||||
<div class="modal-body">
|
||||
<p>Are you sure you want to delete this user? This action cannot be undone.</p>
|
||||
</div>
|
||||
<div class="modal-footer" style="text-align: right;">
|
||||
<button type="button" class="btn btn-secondary" onclick="closeModal('deleteUserModal')" style="background: #6c757d; color: white">Cancel</button>
|
||||
<button type="submit" class="btn btn-danger" style="background: #dc3545; color: white">Delete User</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer style="text-align: center; padding: 2rem; margin-top: 2rem; background-color: #e9ecef;">
|
||||
<p>© <?php echo date("Y"); ?> AppCo. All Rights Reserved.</p>
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
function openModal(id) {
|
||||
document.getElementById(id).style.display = 'block';
|
||||
}
|
||||
|
||||
function closeModal(id) {
|
||||
document.getElementById(id).style.display = 'none';
|
||||
}
|
||||
|
||||
// Close modal if user clicks outside of it
|
||||
window.onclick = function(event) {
|
||||
if (event.target.className === 'modal') {
|
||||
event.target.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Populate edit modal
|
||||
document.querySelectorAll('.edit-btn').forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
document.getElementById('edit-user-id').value = this.dataset.id;
|
||||
document.getElementById('edit-name').value = this.dataset.name;
|
||||
document.getElementById('edit-email').value = this.dataset.email;
|
||||
document.getElementById('edit-kyc_status').value = this.dataset.kyc;
|
||||
openModal('editUserModal');
|
||||
});
|
||||
});
|
||||
|
||||
// Populate delete modal
|
||||
document.querySelectorAll('.delete-btn').forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
document.getElementById('delete-user-id').value = this.dataset.id;
|
||||
openModal('deleteUserModal');
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
339
assets/css/styles.css
Normal file
339
assets/css/styles.css
Normal file
@ -0,0 +1,339 @@
|
||||
/* General Body Styles */
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
background-color: #f8f9fa;
|
||||
color: #212529;
|
||||
margin: 0;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
/* Container */
|
||||
.container {
|
||||
max-width: 1140px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem 1rem;
|
||||
}
|
||||
|
||||
/* Header */
|
||||
header.main-header {
|
||||
background-color: #ffffff;
|
||||
border-bottom: 1px solid #e9ecef;
|
||||
padding: 1rem 0;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.04);
|
||||
}
|
||||
|
||||
header.main-header .container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.logo {
|
||||
font-size: 1.75rem;
|
||||
font-weight: bold;
|
||||
color: #007bff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.main-nav ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.main-nav li {
|
||||
margin-left: 1.5rem;
|
||||
}
|
||||
|
||||
.main-nav a {
|
||||
text-decoration: none;
|
||||
color: #495057;
|
||||
font-weight: 500;
|
||||
transition: color 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.main-nav a:hover, .main-nav a.active {
|
||||
color: #007bff;
|
||||
}
|
||||
|
||||
/* Hero Section */
|
||||
.hero {
|
||||
background: linear-gradient(45deg, #007bff, #6610f2);
|
||||
color: #ffffff;
|
||||
text-align: center;
|
||||
padding: 6rem 1rem;
|
||||
}
|
||||
|
||||
.hero h1 {
|
||||
font-size: 3.5rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.hero p {
|
||||
font-size: 1.25rem;
|
||||
max-width: 600px;
|
||||
margin: 0 auto 2rem auto;
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
.btn {
|
||||
display: inline-block;
|
||||
padding: 0.75rem 1.5rem;
|
||||
border-radius: 50px;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
transition: all 0.3s ease;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: #ffffff;
|
||||
color: #007bff;
|
||||
box-shadow: 0 4px 15px rgba(0, 123, 255, 0.2);
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 6px 20px rgba(0, 123, 255, 0.3);
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
border: 2px solid #ffffff;
|
||||
background-color: transparent;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background-color: #ffffff;
|
||||
color: #007bff;
|
||||
}
|
||||
|
||||
|
||||
/* Admin Dashboard Specific Styles */
|
||||
.dashboard-header {
|
||||
background-color: #fff;
|
||||
padding: 2rem;
|
||||
border-bottom: 1px solid #dee2e6;
|
||||
box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,.075);
|
||||
}
|
||||
|
||||
.dashboard-header h1 {
|
||||
margin: 0;
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.analytics-cards {
|
||||
display: flex;
|
||||
gap: 1.5rem;
|
||||
margin-bottom: 2rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.card {
|
||||
background-color: #fff;
|
||||
border-radius: 0.5rem;
|
||||
box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,.075);
|
||||
padding: 1.5rem;
|
||||
flex: 1;
|
||||
min-width: 220px;
|
||||
border-left: 5px solid #007bff;
|
||||
}
|
||||
|
||||
.card h3 {
|
||||
margin-top: 0;
|
||||
font-size: 1rem;
|
||||
color: #6c757d;
|
||||
}
|
||||
|
||||
.card .stat {
|
||||
font-size: 2.5rem;
|
||||
font-weight: bold;
|
||||
color: #343a40;
|
||||
}
|
||||
|
||||
.user-management {
|
||||
background-color: #fff;
|
||||
padding: 2rem;
|
||||
border-radius: 0.5rem;
|
||||
box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,.075);
|
||||
}
|
||||
|
||||
.user-management-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.user-management-header h2 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.table-responsive {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
th, td {
|
||||
padding: 1rem;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
thead th {
|
||||
background-color: #f8f9fa;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
tbody tr:hover {
|
||||
background-color: #f1f3f5;
|
||||
}
|
||||
|
||||
.badge {
|
||||
display: inline-block;
|
||||
padding: 0.35em 0.65em;
|
||||
font-size: .75em;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
vertical-align: baseline;
|
||||
border-radius: 0.25rem;
|
||||
}
|
||||
|
||||
.badge-success { background-color: #28a745; }
|
||||
.badge-warning { background-color: #ffc107; color: #212529; }
|
||||
.badge-danger { background-color: #dc3545; }
|
||||
|
||||
/* Modal Styles */
|
||||
.modal {
|
||||
display: none; /* Hidden by default */
|
||||
position: fixed; /* Stay in place */
|
||||
z-index: 1000; /* Sit on top */
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%; /* Full width */
|
||||
height: 100%; /* Full height */
|
||||
overflow: auto; /* Enable scroll if needed */
|
||||
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background-color: #fefefe;
|
||||
margin: 10% auto;
|
||||
padding: 2rem;
|
||||
border: 1px solid #888;
|
||||
width: 80%;
|
||||
max-width: 500px;
|
||||
border-radius: 0.5rem;
|
||||
box-shadow: 0 5px 15px rgba(0,0,0,0.3);
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-bottom: 1px solid #dee2e6;
|
||||
padding-bottom: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.modal-header h2 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.close-button {
|
||||
color: #aaa;
|
||||
float: right;
|
||||
font-size: 28px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.close-button:hover,
|
||||
.close-button:focus {
|
||||
color: black;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 0.5rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.form-group input, .form-group select {
|
||||
width: 100%;
|
||||
padding: 0.75rem;
|
||||
border: 1px solid #ced4da;
|
||||
border-radius: 0.25rem;
|
||||
}
|
||||
|
||||
/* Login/Register Page Specifics */
|
||||
.form-card {
|
||||
background-color: #fff;
|
||||
padding: 2.5rem;
|
||||
border-radius: 0.5rem;
|
||||
box-shadow: 0 0.25rem 0.75rem rgba(0,0,0,.075);
|
||||
max-width: 450px;
|
||||
margin: 2rem auto;
|
||||
}
|
||||
|
||||
.button {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 0.85rem;
|
||||
border-radius: 0.25rem;
|
||||
background-color: #007bff;
|
||||
color: #ffffff;
|
||||
border: none;
|
||||
font-size: 1rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
background-color: #0069d9;
|
||||
}
|
||||
|
||||
.text-center {
|
||||
text-align: center;
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
/* Flash Messages */
|
||||
.message {
|
||||
padding: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
border-radius: 0.25rem;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.message.error {
|
||||
color: #721c24;
|
||||
background-color: #f8d7da;
|
||||
border-color: #f5c6cb;
|
||||
}
|
||||
|
||||
.message.success {
|
||||
color: #155724;
|
||||
background-color: #d4edda;
|
||||
border-color: #c3e6cb;
|
||||
}
|
||||
31
dashboard.php
Normal file
31
dashboard.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>User Dashboard - Flatlogic</title>
|
||||
<link rel="stylesheet" href="assets/css/styles.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<header>
|
||||
<h1>Welcome to your Dashboard</h1>
|
||||
</header>
|
||||
<main>
|
||||
<p>This is your protected dashboard area.</p>
|
||||
<a href="logout.php" class="button">Logout</a>
|
||||
</main>
|
||||
<footer>
|
||||
<p>© <?php echo date("Y"); ?> Flatlogic. All rights reserved.</p>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
46
db/migrate.php
Normal file
46
db/migrate.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/config.php';
|
||||
|
||||
function run_migrations() {
|
||||
$pdo = db();
|
||||
$migration_files = glob(__DIR__ . '/migrations/*.sql');
|
||||
sort($migration_files);
|
||||
|
||||
foreach ($migration_files as $file) {
|
||||
echo "Running migration: " . basename($file) . "...\n";
|
||||
$sql = file_get_contents($file);
|
||||
try {
|
||||
$pdo->exec($sql);
|
||||
echo "Success.\n";
|
||||
} catch (PDOException $e) {
|
||||
die("Migration failed: " . $e->getMessage() . "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function seed_data() {
|
||||
$pdo = db();
|
||||
// Seed users only if the table is empty
|
||||
$stmt = $pdo->query('SELECT COUNT(*) FROM users');
|
||||
if ($stmt->fetchColumn() == 0) {
|
||||
echo "Seeding users...\n";
|
||||
$users = [
|
||||
['username' => 'admin', 'email' => 'admin@nic.app', 'password_hash' => password_hash('password', PASSWORD_DEFAULT), 'kyc_status' => 'approved'],
|
||||
['username' => 'alice', 'email' => 'alice@nic.app', 'password_hash' => password_hash('password', PASSWORD_DEFAULT), 'kyc_status' => 'pending'],
|
||||
['username' => 'bob', 'email' => 'bob@nic.app', 'password_hash' => password_hash('password', PASSWORD_DEFAULT), 'kyc_status' => 'rejected'],
|
||||
];
|
||||
|
||||
$stmt = $pdo->prepare("INSERT INTO users (username, email, password_hash, kyc_status) VALUES (:username, :email, :password_hash, :kyc_status)");
|
||||
|
||||
foreach ($users as $user) {
|
||||
$stmt->execute($user);
|
||||
}
|
||||
echo "Seeding complete.\n";
|
||||
} else {
|
||||
echo "Users table is not empty, skipping seed.\n";
|
||||
}
|
||||
}
|
||||
|
||||
run_migrations();
|
||||
seed_data();
|
||||
|
||||
9
db/migrations/001_create_users_table.sql
Normal file
9
db/migrations/001_create_users_table.sql
Normal file
@ -0,0 +1,9 @@
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
username TEXT UNIQUE,
|
||||
email TEXT UNIQUE,
|
||||
password_hash TEXT,
|
||||
profile_public BOOLEAN DEFAULT true,
|
||||
kyc_status TEXT, -- pending/approved/rejected
|
||||
created_at TIMESTAMP DEFAULT now()
|
||||
);
|
||||
26
home.php
Normal file
26
home.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
$pageTitle = "Welcome";
|
||||
include 'includes/header.php';
|
||||
?>
|
||||
|
||||
<div class="container mt-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-body text-center">
|
||||
<h1 class="card-title">Welcome, <?php echo htmlspecialchars($_SESSION['username']); ?>!</h1>
|
||||
<p class="card-text">This is your personalized home page. From here, you can access various features of the platform.</p>
|
||||
<a href="dashboard.php" class="btn btn-primary mt-3">Go to Dashboard</a>
|
||||
<a href="logout.php" class="btn btn-secondary mt-3">Logout</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
4
includes/footer.php
Normal file
4
includes/footer.php
Normal file
@ -0,0 +1,4 @@
|
||||
</main>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
40
includes/header.php
Normal file
40
includes/header.php
Normal file
@ -0,0 +1,40 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><?php echo $pageTitle ?? 'Flatlogic LAMP AI'; ?></title>
|
||||
<meta name="description" content="A modern web platform built with Flatlogic LAMP AI Agent.">
|
||||
|
||||
<!-- Open Graph / Facebook -->
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:url" content="<?php echo (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>">
|
||||
<meta property="og:title" content="<?php echo $pageTitle ?? 'Flatlogic LAMP AI'; ?>">
|
||||
<meta property="og:description" content="A modern web platform built with Flatlogic LAMP AI Agent.">
|
||||
<meta property="og:image" content="<?php echo $_SERVER['PROJECT_IMAGE_URL'] ?? ''; ?>">
|
||||
|
||||
<!-- Twitter -->
|
||||
<meta property="twitter:card" content="summary_large_image">
|
||||
<meta property="twitter:url" content="<?php echo (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>">
|
||||
<meta property="twitter:title" content="<?php echo $pageTitle ?? 'Flatlogic LAMP AI'; ?>">
|
||||
<meta property="twitter:description" content="A modern web platform built with Flatlogic LAMP AI Agent.">
|
||||
<meta property="twitter:image" content="<?php echo $_SERVER['PROJECT_IMAGE_URL'] ?? ''; ?>">
|
||||
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/styles.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body>
|
||||
<header class="main-header">
|
||||
<div class="container">
|
||||
<a href="/" class="logo">AppCo</a>
|
||||
<nav class="main-nav">
|
||||
<ul>
|
||||
<li><a href="/" class="active">Home</a></li>
|
||||
<li><a href="/login.php">Login</a></li>
|
||||
<li><a href="/register.php">Register</a></li>
|
||||
<li><a href="/admin.php">Admin Panel</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
<main>
|
||||
170
index.php
170
index.php
@ -1,150 +1,24 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
@ini_set('display_errors', '1');
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
$pageTitle = "Welcome to Your Application";
|
||||
include 'includes/header.php';
|
||||
?>
|
||||
|
||||
$phpVersion = PHP_VERSION;
|
||||
$now = date('Y-m-d H:i:s');
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>New Style</title>
|
||||
<?php
|
||||
// Read project preview data from environment
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
?>
|
||||
<?php if ($projectDescription): ?>
|
||||
<!-- Meta description -->
|
||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
||||
<!-- Open Graph meta tags -->
|
||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<!-- Twitter meta tags -->
|
||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<?php endif; ?>
|
||||
<?php if ($projectImageUrl): ?>
|
||||
<!-- Open Graph image -->
|
||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<!-- Twitter image -->
|
||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<?php endif; ?>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--bg-color-start: #6a11cb;
|
||||
--bg-color-end: #2575fc;
|
||||
--text-color: #ffffff;
|
||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
||||
color: var(--text-color);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
body::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
|
||||
animation: bg-pan 20s linear infinite;
|
||||
z-index: -1;
|
||||
}
|
||||
@keyframes bg-pan {
|
||||
0% { background-position: 0% 0%; }
|
||||
100% { background-position: 100% 100%; }
|
||||
}
|
||||
main {
|
||||
padding: 2rem;
|
||||
}
|
||||
.card {
|
||||
background: var(--card-bg-color);
|
||||
border: 1px solid var(--card-border-color);
|
||||
border-radius: 16px;
|
||||
padding: 2rem;
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.loader {
|
||||
margin: 1.25rem auto 1.25rem;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
@keyframes spin {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
.hint {
|
||||
opacity: 0.9;
|
||||
}
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px; height: 1px;
|
||||
padding: 0; margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap; border: 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
margin: 0 0 1rem;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
p {
|
||||
margin: 0.5rem 0;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
code {
|
||||
background: rgba(0,0,0,0.2);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 1rem;
|
||||
font-size: 0.8rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="card">
|
||||
<h1>Analyzing your requirements and generating your website…</h1>
|
||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||
<span class="sr-only">Loading…</span>
|
||||
</div>
|
||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
<main>
|
||||
<section class="hero">
|
||||
<div class="container">
|
||||
<h1>Your New Application is Live</h1>
|
||||
<p>Welcome to your newly launched platform. Powerful, scalable, and ready to conquer the world. Manage your operations from our streamlined admin panel.</p>
|
||||
<a href="/admin.php" class="btn btn-primary">Go to Admin Panel</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="features">
|
||||
<div class="container">
|
||||
<!-- You can add feature highlights here in the future -->
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
|
||||
58
login.php
Normal file
58
login.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
$error_message = '';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$email = trim($_POST['email']);
|
||||
$password = $_POST['password'];
|
||||
|
||||
if (empty($email) || empty($password)) {
|
||||
$error_message = 'Please fill in all fields.';
|
||||
} else {
|
||||
try {
|
||||
$db = db();
|
||||
$stmt = $db->prepare("SELECT id, username, password FROM users WHERE email = :email");
|
||||
$stmt->bindParam(':email', $email);
|
||||
$stmt->execute();
|
||||
$user = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($user && password_verify($password, $user['password'])) {
|
||||
$_SESSION['user_id'] = $user['id'];
|
||||
$_SESSION['username'] = $user['username']; // Store username for display
|
||||
header('Location: home.php'); // Redirect to home.php
|
||||
exit;
|
||||
} else {
|
||||
$error_message = 'Invalid email or password.';
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$error_message = 'Database error: ' . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
$pageTitle = "Login - Flatlogic";
|
||||
include 'includes/header.php';
|
||||
?>
|
||||
<div class="container">
|
||||
<header>
|
||||
<h1>Login</h1>
|
||||
</header>
|
||||
<main>
|
||||
<?php if ($error_message): ?>
|
||||
<div class="message error"><?php echo $error_message; ?></div>
|
||||
<?php endif; ?>
|
||||
<form action="login.php" method="post" class="form-card">
|
||||
<div class="form-group">
|
||||
<label for="email">Email</label>
|
||||
<input type="email" id="email" name="email" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Password</label>
|
||||
<input type="password" id="password" name="password" required>
|
||||
</div>
|
||||
<button type="submit" class="button">Login</button>
|
||||
</form>
|
||||
<p class="text-center">Don't have an account? <a href="register.php">Register here</a>.</p>
|
||||
</main>
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
6
logout.php
Normal file
6
logout.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
session_start();
|
||||
session_unset();
|
||||
session_destroy();
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
78
register.php
Normal file
78
register.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
require_once 'db/config.php';
|
||||
|
||||
$error_message = '';
|
||||
$success_message = '';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$username = trim($_POST['username']);
|
||||
$email = trim($_POST['email']);
|
||||
$password = $_POST['password'];
|
||||
|
||||
if (empty($username) || empty($email) || empty($password)) {
|
||||
$error_message = 'Please fill in all fields.';
|
||||
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$error_message = 'Invalid email format.';
|
||||
} else {
|
||||
try {
|
||||
$db = db();
|
||||
|
||||
// Check if email already exists
|
||||
$stmt = $db->prepare("SELECT id FROM users WHERE email = :email");
|
||||
$stmt->bindParam(':email', $email);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->fetch()) {
|
||||
$error_message = 'An account with this email already exists.';
|
||||
} else {
|
||||
$password_hash = password_hash($password, PASSWORD_DEFAULT);
|
||||
|
||||
$stmt = $db->prepare("INSERT INTO users (username, email, password) VALUES (:username, :email, :password)");
|
||||
$stmt->bindParam(':username', $username);
|
||||
$stmt->bindParam(':email', $email);
|
||||
$stmt->bindParam(':password', $password_hash);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
$success_message = 'Registration successful! You can now <a href="login.php">login</a>.';
|
||||
} else {
|
||||
$error_message = 'Registration failed. Please try again.';
|
||||
}
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$error_message = 'Database error: ' . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
$pageTitle = "Register - Flatlogic";
|
||||
include 'includes/header.php';
|
||||
?>
|
||||
<div class="container">
|
||||
<header>
|
||||
<h1>Register</h1>
|
||||
</header>
|
||||
<main>
|
||||
<?php if ($error_message): ?>
|
||||
<div class="message error"><?php echo $error_message; ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($success_message): ?>
|
||||
<div class="message success"><?php echo $success_message; ?></div>
|
||||
<?php else: ?>
|
||||
<form action="register.php" method="post" class="form-card">
|
||||
<div class="form-group">
|
||||
<label for="username">Username</label>
|
||||
<input type="text" id="username" name="username" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Email</label>
|
||||
<input type="email" id="email" name="email" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Password</label>
|
||||
<input type="password" id="password" name="password" required>
|
||||
</div>
|
||||
<button type="submit" class="button">Register</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<p class="text-center">Already have an account? <a href="login.php">Login here</a>.</p>
|
||||
</main>
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
Loading…
x
Reference in New Issue
Block a user