This commit is contained in:
Flatlogic Bot 2026-02-23 09:05:29 +00:00
parent 09834541c3
commit 8d996da0d9
22 changed files with 2362 additions and 183 deletions

73
about.php Normal file
View File

@ -0,0 +1,73 @@
<?php
require_once __DIR__ . '/includes/header.php';
?>
<section class="hero" style="height: 40vh; background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.7)), url('https://images.pexels.com/photos/112460/pexels-photo-112460.jpeg?auto=compress&cs=tinysrgb&w=1200') center/cover no-repeat;">
<h1>About AfgCars</h1>
<p>Afghanistan's Premier Marketplace for Luxury & Reliable Vehicles.</p>
</section>
<div class="container">
<div class="grid" style="grid-template-columns: 1fr 1fr; align-items: center; gap: 4rem;">
<div class="glass" style="padding: 2.5rem;">
<h2 style="color: var(--primary-color); margin-bottom: 1.5rem;">Our Mission</h2>
<p style="margin-bottom: 1rem; color: var(--text-secondary);">
Founded in 2026, AfgCars aims to revolutionize the automotive industry in Afghanistan by providing a safe, transparent, and efficient platform for buying and selling premium vehicles.
</p>
<p style="color: var(--text-secondary);">
We bridge the gap between high-end luxury and everyday reliability, ensuring that every citizen has access to the best automotive options with verified seller information and comprehensive vehicle details.
</p>
</div>
<div>
<img src="https://images.pexels.com/photos/3183150/pexels-photo-3183150.jpeg?auto=compress&cs=tinysrgb&w=600" alt="Team" style="width: 100%; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.5);">
</div>
</div>
</div>
<div class="container">
<h2 class="section-title">Our Physical Locations</h2>
<div class="grid">
<div class="glass" style="padding: 2rem; text-align: center;">
<h3 style="color: var(--primary-color); margin-bottom: 1rem;">Kabul Main Showroom</h3>
<p style="color: var(--text-secondary);">Wazir Akbar Khan, Street 15</p>
<p style="color: var(--text-secondary);">Kabul, Afghanistan</p>
<p style="color: var(--text-primary); margin-top: 1rem;">+93 700 123 456</p>
</div>
<div class="glass" style="padding: 2rem; text-align: center;">
<h3 style="color: var(--primary-color); margin-bottom: 1rem;">Herat Branch</h3>
<p style="color: var(--text-secondary);">Jada-e-Main, Near Blue Mosque</p>
<p style="color: var(--text-secondary);">Herat, Afghanistan</p>
<p style="color: var(--text-primary); margin-top: 1rem;">+93 700 987 654</p>
</div>
<div class="glass" style="padding: 2rem; text-align: center;">
<h3 style="color: var(--primary-color); margin-bottom: 1rem;">Mazar-i-Sharif Office</h3>
<p style="color: var(--text-secondary);">Balkh Gate Road</p>
<p style="color: var(--text-secondary);">Mazar-i-Sharif, Afghanistan</p>
<p style="color: var(--text-primary); margin-top: 1rem;">+93 700 456 789</p>
</div>
</div>
</div>
<div class="container" style="text-align: center; background: rgba(212, 175, 55, 0.05); padding: 5rem 5%;">
<h2 style="margin-bottom: 2rem;">Why trust us?</h2>
<div class="grid" style="grid-template-columns: repeat(4, 1fr);">
<div>
<h1 style="color: var(--primary-color);">500+</h1>
<p style="color: var(--text-secondary);">Premium Cars Sold</p>
</div>
<div>
<h1 style="color: var(--primary-color);">24/7</h1>
<p style="color: var(--text-secondary);">Support Availability</p>
</div>
<div>
<h1 style="color: var(--primary-color);">100%</h1>
<p style="color: var(--text-secondary);">Verified Sellers</p>
</div>
<div>
<h1 style="color: var(--primary-color);">5</h1>
<p style="color: var(--text-secondary);">Major Cities</p>
</div>
</div>
</div>
<?php require_once __DIR__ . '/includes/footer.php'; ?>

115
add_car.php Normal file
View File

@ -0,0 +1,115 @@
<?php
require_once __DIR__ . '/includes/header.php';
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit;
}
$error = '';
$success = false;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$brand = $_POST['brand'] ?? '';
$model = $_POST['model'] ?? '';
$year = $_POST['year'] ?? '';
$price = $_POST['price'] ?? '';
$city = $_POST['city'] ?? '';
$description = $_POST['description'] ?? '';
$image_url = $_POST['image_url'] ?? ''; // For simplicity, we use URL or placeholder
$pdo = db();
try {
$pdo->beginTransaction();
$stmt = $pdo->prepare("INSERT INTO cars (user_id, brand, model, year, price, city, description, status) VALUES (?, ?, ?, ?, ?, ?, ?, 'pending')");
$stmt->execute([$_SESSION['user_id'], $brand, $model, $year, $price, $city, $description]);
$carId = $pdo->lastInsertId();
if ($image_url) {
$stmt = $pdo->prepare("INSERT INTO car_images (car_id, image_path, is_main) VALUES (?, ?, 1)");
$stmt->execute([$carId, $image_url]);
}
$pdo->commit();
$success = true;
} catch (Exception $e) {
$pdo->rollBack();
$error = "Failed to list car: " . $e->getMessage();
}
}
$cities = ['Kabul', 'Herat', 'Mazar-i-Sharif', 'Kandahar', 'Jalalabad', 'Kunduz', 'Ghazni', 'Balkh'];
?>
<div class="container" style="max-width: 800px;">
<div class="box" style="padding: 4rem;">
<h1 style="margin-bottom: 1rem; font-size: 2.5rem; font-weight: 900;">List Your Vehicle</h1>
<p style="color: var(--text-secondary); margin-bottom: 3rem;">Provide details about your car. Our team will review and approve your listing within 24 hours.</p>
<?php if ($success): ?>
<div class="glass" style="padding: 2rem; border-color: var(--success); background: rgba(46, 213, 115, 0.05); color: var(--success); margin-bottom: 3rem; text-align: center; border-radius: 16px;">
<h3 style="margin-bottom: 0.5rem;">🎉 Listing Submitted!</h3>
<p>Your car has been sent for approval. You can track its status in your dashboard.</p>
<div style="margin-top: 1.5rem;">
<a href="dashboard.php" class="btn btn-primary btn-sm">Go to Dashboard</a>
</div>
</div>
<?php endif; ?>
<?php if ($error): ?>
<div class="alert alert-error" style="margin-bottom: 2rem;"><?= $error ?></div>
<?php endif; ?>
<form method="POST">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;">
<div class="form-group">
<label>Brand</label>
<input type="text" name="brand" class="form-control" required placeholder="e.g. Toyota">
</div>
<div class="form-group">
<label>Model</label>
<input type="text" name="model" class="form-control" required placeholder="e.g. Land Cruiser">
</div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;">
<div class="form-group">
<label>Year</label>
<input type="number" name="year" class="form-control" required placeholder="2024" min="1990" max="<?= date('Y') + 1 ?>">
</div>
<div class="form-group">
<label>Price (USD)</label>
<input type="number" name="price" class="form-control" required placeholder="55000">
</div>
</div>
<div class="form-group">
<label>City</label>
<select name="city" class="form-control" required>
<?php foreach ($cities as $c): ?>
<option value="<?= $c ?>"><?= $c ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label>Image URL (Optional)</label>
<input type="url" name="image_url" class="form-control" placeholder="https://example.com/car.jpg">
<small style="color: var(--text-secondary); margin-top: 0.5rem; display: block;">For this prototype, please provide a direct link to an image.</small>
</div>
<div class="form-group">
<label>Description</label>
<textarea name="description" class="form-control" rows="5" required placeholder="Describe the condition, features, and any other relevant details..."></textarea>
</div>
<div style="margin-top: 3rem; display: flex; gap: 1.5rem;">
<button type="submit" class="btn btn-primary" style="flex: 2; padding: 1.2rem;">Submit Listing</button>
<a href="dashboard.php" class="btn btn-outline" style="flex: 1; text-align: center; padding: 1.2rem;">Cancel</a>
</div>
</form>
</div>
</div>
<?php require_once __DIR__ . '/includes/footer.php'; ?>

116
admin_cars.php Normal file
View File

@ -0,0 +1,116 @@
<?php
session_start();
require_once __DIR__ . '/db/config.php';
if (!isset($_SESSION['user_id']) || ($_SESSION['role'] ?? '') !== 'admin') {
header('Location: login.php');
exit;
}
$pdo = db();
// Handle Status Changes
if (isset($_GET['action']) && isset($_GET['id'])) {
$action = $_GET['action'];
$id = $_GET['id'];
if ($action === 'approve') {
$pdo->prepare("UPDATE cars SET status = 'approved' WHERE id = ?")->execute([$id]);
} elseif ($action === 'reject') {
$pdo->prepare("UPDATE cars SET status = 'rejected' WHERE id = ?")->execute([$id]);
} elseif ($action === 'hot') {
$pdo->prepare("UPDATE cars SET is_hot_deal = NOT is_hot_deal WHERE id = ?")->execute([$id]);
} elseif ($action === 'delete') {
$pdo->prepare("UPDATE cars SET deleted_at = NOW() WHERE id = ?")->execute([$id]);
}
header('Location: admin_cars.php');
exit;
}
$cars = $pdo->query("
SELECT c.*, u.name as owner_name
FROM cars c
JOIN users u ON c.user_id = u.id
WHERE c.deleted_at IS NULL
ORDER BY c.created_at DESC
")->fetchAll();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Manage Cars | Admin</title>
<link rel="stylesheet" href="assets/css/style.css?v=<?= time() ?>">
</head>
<body style="background: #050505;">
<div class="dashboard-container">
<aside class="sidebar">
<a href="index.php" class="sidebar-brand">AFGCARS</a>
<ul class="sidebar-menu">
<li><a href="admin_dashboard.php"><span>Dashboard</span></a></li>
<li><a href="admin_cars.php" class="active"><span>Manage Cars</span></a></li>
<li><a href="admin_users.php"><span>Users</span></a></li>
<li><a href="admin_messages.php"><span>Messages</span></a></li>
</ul>
<div class="sidebar-footer">
<a href="logout.php" style="color: var(--danger); text-decoration: none; font-weight: 600;">Logout</a>
</div>
</aside>
<main class="main-content">
<h1 style="margin-bottom: 2rem; font-weight: 900;">Manage Car Listings</h1>
<div class="glass" style="padding: 2rem;">
<div class="table-container">
<table>
<thead>
<tr>
<th>Car Details</th>
<th>Owner</th>
<th>Price</th>
<th>Status</th>
<th>Featured</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($cars as $car): ?>
<tr>
<td>
<div style="font-weight: 700;"><?= htmlspecialchars($car['brand'] . ' ' . $car['model']) ?></div>
<div style="font-size: 0.8rem; color: var(--text-secondary);"><?= $car['year'] ?> - <?= $car['city'] ?></div>
</td>
<td><?= htmlspecialchars($car['owner_name']) ?></td>
<td style="font-weight: 700; color: var(--primary-color);">$<?= number_format($car['price']) ?></td>
<td>
<span class="badge badge-<?= $car['status'] === 'approved' ? 'success' : ($car['status'] === 'pending' ? 'warning' : 'danger') ?>">
<?= ucfirst($car['status']) ?>
</span>
</td>
<td>
<a href="admin_cars.php?action=hot&id=<?= $car['id'] ?>" style="text-decoration: none; font-size: 1.2rem;">
<?= $car['is_hot_deal'] ? '🔥' : '❄️' ?>
</a>
</td>
<td>
<div style="display: flex; gap: 0.8rem;">
<?php if ($car['status'] !== 'approved'): ?>
<a href="admin_cars.php?action=approve&id=<?= $car['id'] ?>" style="color: var(--success); text-decoration: none; font-weight: 700; font-size: 0.8rem;">Approve</a>
<?php endif; ?>
<?php if ($car['status'] !== 'rejected'): ?>
<a href="admin_cars.php?action=reject&id=<?= $car['id'] ?>" style="color: var(--warning); text-decoration: none; font-weight: 700; font-size: 0.8rem;">Reject</a>
<?php endif; ?>
<a href="admin_cars.php?action=delete&id=<?= $car['id'] ?>" onclick="return confirm('Are you sure?')" style="color: var(--danger); text-decoration: none; font-weight: 700; font-size: 0.8rem;">Delete</a>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</main>
</div>
</body>
</html>

156
admin_dashboard.php Normal file
View File

@ -0,0 +1,156 @@
<?php
session_start();
require_once __DIR__ . '/db/config.php';
// Check if user is admin
if (!isset($_SESSION['user_id']) || ($_SESSION['role'] ?? '') !== 'admin') {
header('Location: login.php');
exit;
}
$pdo = db();
// Fetch Stats
$totalCars = $pdo->query("SELECT COUNT(*) FROM cars WHERE deleted_at IS NULL")->fetchColumn();
$pendingCars = $pdo->query("SELECT COUNT(*) FROM cars WHERE status = 'pending' AND deleted_at IS NULL")->fetchColumn();
$totalUsers = $pdo->query("SELECT COUNT(*) FROM users WHERE deleted_at IS NULL")->fetchColumn();
$totalPurchases = $pdo->query("SELECT COUNT(*) FROM purchases")->fetchColumn();
// Fetch Recent Cars
$recentCars = $pdo->query("
SELECT c.*, u.name as owner_name
FROM cars c
JOIN users u ON c.user_id = u.id
WHERE c.deleted_at IS NULL
ORDER BY c.created_at DESC
LIMIT 5
")->fetchAll();
// Fetch Recent Messages
$recentMessages = $pdo->query("SELECT * FROM contact_messages ORDER BY created_at DESC LIMIT 5")->fetchAll();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Dashboard | AfgCars</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/style.css?v=<?= time() ?>">
</head>
<body style="background: #050505;">
<div class="dashboard-container">
<!-- Sidebar -->
<aside class="sidebar">
<a href="index.php" class="sidebar-brand">AFGCARS</a>
<ul class="sidebar-menu">
<li><a href="admin_dashboard.php" class="active"><span>Dashboard</span></a></li>
<li><a href="admin_cars.php"><span>Manage Cars</span></a></li>
<li><a href="admin_users.php"><span>Users</span></a></li>
<li><a href="admin_messages.php"><span>Messages</span></a></li>
<li><a href="admin_settings.php"><span>Settings</span></a></li>
</ul>
<div class="sidebar-footer">
<a href="logout.php" style="color: var(--danger); font-size: 0.9rem; text-decoration: none; font-weight: 600;">Logout</a>
</div>
</aside>
<!-- Main Content -->
<main class="main-content">
<header style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 3rem;">
<div>
<h1 style="font-size: 2rem; font-weight: 900;">Dashboard Overview</h1>
<p style="color: var(--text-secondary);">Welcome back, <?= htmlspecialchars($_SESSION['user_name']) ?></p>
</div>
<div style="display: flex; gap: 1rem;">
<a href="index.php" class="btn-auth">View Site</a>
</div>
</header>
<!-- Stats Grid -->
<div class="stats-grid">
<div class="stat-card glass">
<span class="stat-label">Total Listings</span>
<span class="stat-value"><?= $totalCars ?></span>
</div>
<div class="stat-card glass" style="border-left: 4px solid var(--warning);">
<span class="stat-label">Pending Approval</span>
<span class="stat-value"><?= $pendingCars ?></span>
</div>
<div class="stat-card glass">
<span class="stat-label">Total Users</span>
<span class="stat-value"><?= $totalUsers ?></span>
</div>
<div class="stat-card glass" style="border-left: 4px solid var(--success);">
<span class="stat-label">Purchases</span>
<span class="stat-value"><?= $totalPurchases ?></span>
</div>
</div>
<div style="display: grid; grid-template-columns: 2fr 1fr; gap: 2rem;">
<!-- Recent Listings -->
<div class="glass" style="padding: 2rem;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem;">
<h3 style="font-weight: 800;">Recent Car Listings</h3>
<a href="admin_cars.php" style="color: var(--primary-color); text-decoration: none; font-size: 0.85rem; font-weight: 600;">View All</a>
</div>
<div class="table-container">
<table>
<thead>
<tr>
<th>Car</th>
<th>Owner</th>
<th>Price</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($recentCars as $car): ?>
<tr>
<td>
<div style="font-weight: 600;"><?= htmlspecialchars($car['brand'] . ' ' . $car['model']) ?></div>
<div style="font-size: 0.8rem; color: var(--text-secondary);"><?= $car['year'] ?></div>
</td>
<td><?= htmlspecialchars($car['owner_name']) ?></td>
<td style="color: var(--primary-color); font-weight: 700;">$<?= number_format($car['price']) ?></td>
<td>
<span class="badge badge-<?= $car['status'] === 'approved' ? 'success' : ($car['status'] === 'pending' ? 'warning' : 'danger') ?>">
<?= ucfirst($car['status']) ?>
</span>
</td>
<td><a href="car_detail.php?id=<?= $car['id'] ?>" style="color: var(--info); text-decoration: none; font-weight: 600; font-size: 0.85rem;">View</a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<!-- Recent Messages -->
<div class="glass" style="padding: 2rem;">
<h3 style="font-weight: 800; margin-bottom: 1.5rem;">Recent Messages</h3>
<?php if (empty($recentMessages)): ?>
<p style="color: var(--text-secondary); font-size: 0.9rem;">No new messages.</p>
<?php else: ?>
<div style="display: flex; flex-direction: column; gap: 1.5rem;">
<?php foreach ($recentMessages as $msg): ?>
<div style="border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 1rem;">
<div style="display: flex; justify-content: space-between; margin-bottom: 0.3rem;">
<span style="font-weight: 700; font-size: 0.9rem;"><?= htmlspecialchars($msg['name']) ?></span>
<span style="font-size: 0.7rem; color: var(--text-secondary);"><?= date('M d', strtotime($msg['created_at'])) ?></span>
</div>
<p style="font-size: 0.85rem; color: var(--text-secondary); line-height: 1.4;">
<?= htmlspecialchars(substr($msg['message'], 0, 80)) ?>...
</p>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</div>
</main>
</div>
</body>
</html>

86
admin_messages.php Normal file
View File

@ -0,0 +1,86 @@
<?php
session_start();
require_once __DIR__ . '/db/config.php';
if (!isset($_SESSION['user_id']) || ($_SESSION['role'] ?? '') !== 'admin') {
header('Location: login.php');
exit;
}
$pdo = db();
if (isset($_GET['action']) && isset($_GET['id'])) {
$id = $_GET['id'];
if ($_GET['action'] === 'read') {
$pdo->prepare("UPDATE contact_messages SET status = 'read' WHERE id = ?")->execute([$id]);
} elseif ($_GET['action'] === 'delete') {
$pdo->prepare("DELETE FROM contact_messages WHERE id = ?")->execute([$id]);
}
header('Location: admin_messages.php');
exit;
}
$messages = $pdo->query("SELECT * FROM contact_messages ORDER BY created_at DESC")->fetchAll();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Manage Messages | Admin</title>
<link rel="stylesheet" href="assets/css/style.css?v=<?= time() ?>">
</head>
<body style="background: #050505;">
<div class="dashboard-container">
<aside class="sidebar">
<a href="index.php" class="sidebar-brand">AFGCARS</a>
<ul class="sidebar-menu">
<li><a href="admin_dashboard.php"><span>Dashboard</span></a></li>
<li><a href="admin_cars.php"><span>Manage Cars</span></a></li>
<li><a href="admin_users.php"><span>Users</span></a></li>
<li><a href="admin_messages.php" class="active"><span>Messages</span></a></li>
</ul>
<div class="sidebar-footer">
<a href="logout.php" style="color: var(--danger); text-decoration: none; font-weight: 600;">Logout</a>
</div>
</aside>
<main class="main-content">
<h1 style="margin-bottom: 2rem; font-weight: 900;">Customer Inquiries</h1>
<div class="grid" style="grid-template-columns: 1fr;">
<?php if (empty($messages)): ?>
<div class="glass" style="padding: 4rem; text-align: center;">
<p style="color: var(--text-secondary);">No messages found.</p>
</div>
<?php else: ?>
<?php foreach ($messages as $msg): ?>
<div class="glass" style="padding: 2.5rem; border-left: 4px solid <?= $msg['status'] === 'unread' ? 'var(--primary-color)' : 'transparent' ?>;">
<div style="display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1.5rem;">
<div>
<h3 style="margin-bottom: 0.3rem;"><?= htmlspecialchars($msg['subject']) ?></h3>
<p style="font-size: 0.85rem; color: var(--text-secondary);">From: <strong><?= htmlspecialchars($msg['name']) ?></strong> (<?= htmlspecialchars($msg['email']) ?>)</p>
</div>
<div style="text-align: right;">
<div style="font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 0.5rem;"><?= date('M d, Y H:i', strtotime($msg['created_at'])) ?></div>
<span class="badge badge-<?= $msg['status'] === 'unread' ? 'warning' : 'success' ?>"><?= ucfirst($msg['status']) ?></span>
</div>
</div>
<div style="background: rgba(255,255,255,0.02); padding: 2rem; border-radius: 12px; margin-bottom: 2rem; line-height: 1.8; color: var(--text-secondary);">
<?= nl2br(htmlspecialchars($msg['message'])) ?>
</div>
<div style="display: flex; gap: 1rem;">
<?php if ($msg['status'] === 'unread'): ?>
<a href="admin_messages.php?action=read&id=<?= $msg['id'] ?>" class="btn-auth">Mark as Read</a>
<?php endif; ?>
<a href="mailto:<?= $msg['email'] ?>" class="btn-auth" style="border-color: var(--primary-color); color: var(--primary-color);">Reply via Email</a>
<a href="admin_messages.php?action=delete&id=<?= $msg['id'] ?>" onclick="return confirm('Delete this message?')" class="btn-auth" style="border-color: var(--danger); color: var(--danger);">Delete</a>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</main>
</div>
</body>
</html>

94
admin_users.php Normal file
View File

@ -0,0 +1,94 @@
<?php
session_start();
require_once __DIR__ . '/db/config.php';
if (!isset($_SESSION['user_id']) || ($_SESSION['role'] ?? '') !== 'admin') {
header('Location: login.php');
exit;
}
$pdo = db();
if (isset($_GET['action']) && isset($_GET['id'])) {
$id = $_GET['id'];
if ($_GET['action'] === 'activate') {
$pdo->prepare("UPDATE users SET status = 'active' WHERE id = ?")->execute([$id]);
} elseif ($_GET['action'] === 'deactivate') {
$pdo->prepare("UPDATE users SET status = 'inactive' WHERE id = ?")->execute([$id]);
} elseif ($_GET['action'] === 'delete') {
$pdo->prepare("UPDATE users SET deleted_at = NOW() WHERE id = ?")->execute([$id]);
}
header('Location: admin_users.php');
exit;
}
$users = $pdo->query("SELECT * FROM users WHERE deleted_at IS NULL ORDER BY created_at DESC")->fetchAll();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Manage Users | Admin</title>
<link rel="stylesheet" href="assets/css/style.css?v=<?= time() ?>">
</head>
<body style="background: #050505;">
<div class="dashboard-container">
<aside class="sidebar">
<a href="index.php" class="sidebar-brand">AFGCARS</a>
<ul class="sidebar-menu">
<li><a href="admin_dashboard.php"><span>Dashboard</span></a></li>
<li><a href="admin_cars.php"><span>Manage Cars</span></a></li>
<li><a href="admin_users.php" class="active"><span>Users</span></a></li>
<li><a href="admin_messages.php"><span>Messages</span></a></li>
</ul>
<div class="sidebar-footer">
<a href="logout.php" style="color: var(--danger); text-decoration: none; font-weight: 600;">Logout</a>
</div>
</aside>
<main class="main-content">
<h1 style="margin-bottom: 2rem; font-weight: 900;">User Management</h1>
<div class="glass" style="padding: 2rem;">
<div class="table-container">
<table>
<thead>
<tr>
<th>User Info</th>
<th>Role</th>
<th>Status</th>
<th>Joined</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($users as $u): ?>
<tr>
<td>
<div style="font-weight: 700;"><?= htmlspecialchars($u['name']) ?></div>
<div style="font-size: 0.8rem; color: var(--text-secondary);"><?= htmlspecialchars($u['email']) ?></div>
</td>
<td><span class="badge badge-<?= $u['role'] === 'admin' ? 'danger' : 'success' ?>"><?= strtoupper($u['role']) ?></span></td>
<td><span class="badge badge-<?= $u['status'] === 'active' ? 'success' : 'warning' ?>"><?= ucfirst($u['status']) ?></span></td>
<td><?= date('M d, Y', strtotime($u['created_at'])) ?></td>
<td>
<div style="display: flex; gap: 0.8rem;">
<?php if ($u['status'] === 'active'): ?>
<a href="admin_users.php?action=deactivate&id=<?= $u['id'] ?>" style="color: var(--warning); text-decoration: none; font-weight: 700; font-size: 0.8rem;">Deactivate</a>
<?php else: ?>
<a href="admin_users.php?action=activate&id=<?= $u['id'] ?>" style="color: var(--success); text-decoration: none; font-weight: 700; font-size: 0.8rem;">Activate</a>
<?php endif; ?>
<a href="admin_users.php?action=delete&id=<?= $u['id'] ?>" onclick="return confirm('Delete this user?')" style="color: var(--danger); text-decoration: none; font-weight: 700; font-size: 0.8rem;">Delete</a>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</main>
</div>
</body>
</html>

500
assets/css/style.css Normal file
View File

@ -0,0 +1,500 @@
:root {
--primary-color: #d4af37; /* Gold */
--secondary-color: #1a1a1a; /* Dark Gray */
--bg-color: #0b0b0b;
--card-bg: rgba(255, 255, 255, 0.05);
--glass-border: rgba(255, 255, 255, 0.1);
--text-primary: #ffffff;
--text-secondary: #a0a0a0;
--transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
--sidebar-width: 260px;
--danger: #ff4757;
--success: #2ed573;
--warning: #ffa502;
--info: #1e90ff;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Inter', system-ui, -apple-system, sans-serif;
background-color: var(--bg-color);
color: var(--text-primary);
line-height: 1.6;
overflow-x: hidden;
}
/* Glassmorphism utility */
.glass {
background: rgba(255, 255, 255, 0.03);
backdrop-filter: blur(15px);
-webkit-backdrop-filter: blur(15px);
border: 1px solid var(--glass-border);
border-radius: 20px;
box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
transition: var(--transition);
}
.glass:hover {
border-color: rgba(212, 175, 55, 0.3);
background: rgba(255, 255, 255, 0.05);
}
/* Navbar */
nav {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1.2rem 6%;
position: sticky;
top: 0;
z-index: 1000;
background: rgba(11, 11, 11, 0.8);
backdrop-filter: blur(20px);
border-bottom: 1px solid var(--glass-border);
}
.logo {
font-size: 1.6rem;
font-weight: 900;
color: var(--primary-color);
text-transform: uppercase;
letter-spacing: 3px;
text-decoration: none;
background: linear-gradient(45deg, var(--primary-color), #fff);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.nav-links {
display: flex;
gap: 3rem;
list-style: none;
}
.nav-links a {
color: var(--text-primary);
text-decoration: none;
font-size: 0.9rem;
font-weight: 600;
transition: var(--transition);
text-transform: uppercase;
letter-spacing: 1px;
opacity: 0.7;
}
.nav-links a:hover {
color: var(--primary-color);
opacity: 1;
}
/* Hero Section */
.hero {
height: 85vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
padding: 0 10%;
background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.7)), url('https://images.pexels.com/photos/170811/pexels-photo-170811.jpeg?auto=compress&cs=tinysrgb&w=1920') center/cover no-repeat fixed;
border-bottom: 1px solid var(--glass-border);
}
.hero h1 {
font-size: 5.5rem;
margin-bottom: 1.5rem;
font-weight: 900;
letter-spacing: -2px;
line-height: 1;
}
.hero p {
font-size: 1.2rem;
color: var(--text-secondary);
max-width: 600px;
margin-bottom: 3.5rem;
}
/* Buttons */
.btn {
padding: 0.9rem 2.2rem;
border-radius: 12px;
text-decoration: none;
font-weight: 700;
transition: var(--transition);
cursor: pointer;
border: 1px solid transparent;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
font-size: 0.95rem;
}
.btn-primary {
background: var(--primary-color);
color: #000;
box-shadow: 0 8px 25px rgba(212, 175, 55, 0.25);
}
.btn-primary:hover {
transform: translateY(-4px);
box-shadow: 0 12px 35px rgba(212, 175, 55, 0.4);
background: #e5be48;
}
.btn-outline {
background: transparent;
border: 1px solid var(--glass-border);
color: var(--text-primary);
}
.btn-outline:hover {
background: rgba(255, 255, 255, 0.05);
border-color: var(--primary-color);
color: var(--primary-color);
}
.btn-auth {
padding: 0.6rem 1.4rem;
border-radius: 10px;
text-decoration: none;
font-weight: 600;
font-size: 0.85rem;
transition: var(--transition);
border: 1px solid var(--glass-border);
background: rgba(255, 255, 255, 0.05);
color: var(--text-primary);
}
.btn-auth:hover {
background: var(--primary-color);
color: #000;
border-color: var(--primary-color);
}
/* Grid & Layout */
.container {
padding: 5rem 6%;
max-width: 1400px;
margin: 0 auto;
}
.section-title {
font-size: 2.8rem;
margin-bottom: 4rem;
text-align: center;
font-weight: 900;
letter-spacing: -1px;
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
gap: 3rem;
}
/* Admin Dashboard Layout */
.dashboard-container {
display: flex;
min-height: 100vh;
}
.sidebar {
width: var(--sidebar-width);
background: rgba(15, 15, 15, 0.9);
border-right: 1px solid var(--glass-border);
padding: 2rem 1.5rem;
display: flex;
flex-direction: column;
position: fixed;
height: 100vh;
z-index: 100;
}
.main-content {
flex: 1;
margin-left: var(--sidebar-width);
padding: 2.5rem;
}
.sidebar-brand {
font-size: 1.4rem;
font-weight: 900;
color: var(--primary-color);
margin-bottom: 3rem;
padding-left: 1rem;
text-decoration: none;
}
.sidebar-menu {
list-style: none;
flex: 1;
}
.sidebar-menu li {
margin-bottom: 0.8rem;
}
.sidebar-menu a {
display: flex;
align-items: center;
padding: 0.8rem 1.2rem;
color: var(--text-secondary);
text-decoration: none;
border-radius: 12px;
transition: var(--transition);
font-weight: 600;
}
.sidebar-menu a:hover, .sidebar-menu a.active {
background: rgba(212, 175, 55, 0.1);
color: var(--primary-color);
}
.sidebar-footer {
padding-top: 2rem;
border-top: 1px solid var(--glass-border);
}
/* Dashboard Stats Card */
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 1.5rem;
margin-bottom: 3rem;
}
.stat-card {
padding: 2rem;
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.stat-value {
font-size: 2.2rem;
font-weight: 900;
color: var(--text-primary);
}
.stat-label {
color: var(--text-secondary);
font-size: 0.9rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 1px;
}
/* Tables */
.table-container {
overflow-x: auto;
margin-top: 2rem;
}
table {
width: 100%;
border-collapse: collapse;
text-align: left;
}
th {
padding: 1.2rem;
border-bottom: 1px solid var(--glass-border);
color: var(--text-secondary);
font-weight: 600;
text-transform: uppercase;
font-size: 0.8rem;
letter-spacing: 1px;
}
td {
padding: 1.2rem;
border-bottom: 1px solid rgba(255,255,255,0.03);
font-size: 0.95rem;
}
tr:hover td {
background: rgba(255,255,255,0.02);
}
.badge {
padding: 0.4rem 0.8rem;
border-radius: 6px;
font-size: 0.75rem;
font-weight: 700;
text-transform: uppercase;
}
.badge-success { background: rgba(46, 213, 115, 0.1); color: var(--success); }
.badge-warning { background: rgba(255, 165, 2, 0.1); color: var(--warning); }
.badge-danger { background: rgba(255, 71, 87, 0.1); color: var(--danger); }
/* Alerts */
.alert {
padding: 1rem 1.5rem;
border-radius: 12px;
margin-bottom: 2rem;
font-weight: 600;
}
.alert-success {
background: rgba(46, 213, 115, 0.1);
color: var(--success);
border: 1px solid rgba(46, 213, 115, 0.2);
}
/* Car Card Enhancement */
.car-card {
overflow: hidden;
background: rgba(255, 255, 255, 0.02);
}
.car-info {
padding: 1.8rem;
}
.car-price {
color: var(--primary-color);
font-size: 1.6rem;
font-weight: 900;
}
/* Forms */
.form-group {
margin-bottom: 1.5rem;
}
.form-control {
width: 100%;
padding: 0.9rem 1.2rem;
background: rgba(255,255,255,0.03);
border: 1px solid var(--glass-border);
border-radius: 12px;
color: #fff;
font-size: 0.95rem;
transition: var(--transition);
}
.form-control:focus {
border-color: var(--primary-color);
background: rgba(255,255,255,0.06);
outline: none;
box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.1);
}
/* Specialized Box Component */
.box {
background: rgba(255, 255, 255, 0.02);
border: 1px solid var(--glass-border);
border-radius: 24px;
padding: 2.5rem;
transition: var(--transition);
position: relative;
overflow: hidden;
}
.box::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(135deg, rgba(212, 175, 55, 0.05), transparent);
pointer-events: none;
}
.box:hover {
transform: translateY(-5px);
border-color: rgba(212, 175, 55, 0.2);
background: rgba(255, 255, 255, 0.04);
}
@media (max-width: 992px) {
.sidebar { width: 80px; padding: 2rem 0.5rem; }
.sidebar-brand, .sidebar-menu span { display: none; }
.main-content { margin-left: 80px; }
}
@media (max-width: 768px) {
.hero h1 { font-size: 3.5rem; }
.nav-links { display: none; }
}
/* Footer Styles */
footer {
background: rgba(11, 11, 11, 0.8);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border-top: 1px solid var(--glass-border);
padding: 6rem 6% 3rem;
margin-top: 5rem;
}
.footer-grid {
display: grid;
grid-template-columns: 2fr 1fr 1fr 1.5fr;
gap: 4rem;
max-width: 1400px;
margin: 0 auto;
}
.footer-col h4 {
color: var(--primary-color);
font-size: 1.1rem;
font-weight: 800;
margin-bottom: 2rem;
text-transform: uppercase;
letter-spacing: 2px;
}
.footer-col ul {
list-style: none;
}
.footer-col ul li {
margin-bottom: 1rem;
}
.footer-col ul li a {
color: var(--text-secondary);
text-decoration: none;
transition: var(--transition);
font-size: 0.95rem;
}
.footer-col ul li a:hover {
color: var(--primary-color);
padding-left: 5px;
}
.footer-bottom {
margin-top: 6rem;
padding-top: 3rem;
border-top: 1px solid rgba(255, 255, 255, 0.05);
text-align: center;
}
.footer-bottom p {
color: var(--text-secondary);
font-size: 0.9rem;
}
@media (max-width: 1200px) {
.footer-grid {
grid-template-columns: 1fr 1fr;
}
}
@media (max-width: 600px) {
.footer-grid {
grid-template-columns: 1fr;
gap: 3rem;
}
}

View File

@ -1,39 +1,13 @@
document.addEventListener('DOMContentLoaded', () => {
const chatForm = document.getElementById('chat-form');
const chatInput = document.getElementById('chat-input');
const chatMessages = document.getElementById('chat-messages');
const appendMessage = (text, sender) => {
const msgDiv = document.createElement('div');
msgDiv.classList.add('message', sender);
msgDiv.textContent = text;
chatMessages.appendChild(msgDiv);
chatMessages.scrollTop = chatMessages.scrollHeight;
};
chatForm.addEventListener('submit', async (e) => {
e.preventDefault();
const message = chatInput.value.trim();
if (!message) return;
appendMessage(message, 'visitor');
chatInput.value = '';
try {
const response = await fetch('api/chat.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ message })
document.addEventListener('DOMContentLoaded', function() {
console.log('AfgCars Premium Marketplace Initialized');
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
const data = await response.json();
// Artificial delay for realism
setTimeout(() => {
appendMessage(data.reply, 'bot');
}, 500);
} catch (error) {
console.error('Error:', error);
appendMessage("Sorry, something went wrong. Please try again.", 'bot');
}
});
});
});
});

144
car_detail.php Normal file
View File

@ -0,0 +1,144 @@
<?php
require_once __DIR__ . '/includes/header.php';
$pdo = db();
$id = $_GET['id'] ?? 0;
$stmt = $pdo->prepare("SELECT c.*, u.name as seller_name FROM cars c JOIN users u ON c.user_id = u.id WHERE c.id = ? AND c.status = 'approved'");
$stmt->execute([$id]);
$car = $stmt->fetch();
if (!$car) {
echo "<div class='container' style='text-align: center; padding: 10rem 5%;'><h1>Car not found.</h1><a href='cars.php' class='btn btn-primary' style='margin-top: 2rem;'>Back to Marketplace</a></div>";
require_once __DIR__ . '/includes/footer.php';
exit;
}
// Get images
$stmt = $pdo->prepare("SELECT * FROM car_images WHERE car_id = ?");
$stmt->execute([$id]);
$images = $stmt->fetchAll();
$mainImage = '';
foreach ($images as $img) {
if ($img['is_main']) {
$mainImage = $img['image_path'];
break;
}
}
if (!$mainImage && !empty($images)) $mainImage = $images[0]['image_path'];
// Similar cars
$stmt = $pdo->prepare("SELECT c.*, ci.image_path FROM cars c LEFT JOIN car_images ci ON c.id = ci.car_id AND ci.is_main = 1 WHERE c.brand = ? AND c.id != ? AND c.status = 'approved' LIMIT 3");
$stmt->execute([$car['brand'], $id]);
$similar = $stmt->fetchAll();
?>
<div class="container" style="padding-top: 2rem;">
<div style="display: grid; grid-template-columns: 1.5fr 1fr; gap: 4rem;">
<div>
<div id="main-car-image" class="glass" style="height: 550px; background-image: url('<?= htmlspecialchars($mainImage ?: 'assets/images/placeholder-car.jpg') ?>'); background-size: cover; background-position: center; border-radius: 20px; margin-bottom: 2rem; box-shadow: 0 20px 40px rgba(0,0,0,0.5);"></div>
<?php if (count($images) > 1): ?>
<div style="display: flex; gap: 1rem; margin-bottom: 3rem;">
<?php foreach ($images as $img): ?>
<div class="glass" style="width: 100px; height: 80px; background-image: url('<?= htmlspecialchars($img['image_path']) ?>'); background-size: cover; background-position: center; cursor: pointer; border-radius: 12px; transition: var(--transition);" onclick="document.getElementById('main-car-image').style.backgroundImage='url(\'<?= htmlspecialchars($img['image_path']) ?>\')'"></div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<div class="glass" style="padding: 3rem; border-left: 4px solid var(--primary-color);">
<h2 style="margin-bottom: 2rem; display: flex; align-items: center; gap: 1rem;">
<span>📜</span> Detailed Description
</h2>
<div style="color: var(--text-secondary); line-height: 2; font-size: 1.1rem;">
<?= nl2br(htmlspecialchars($car['description'])) ?>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-top: 3rem; border-top: 1px solid var(--glass-border); padding-top: 2rem;">
<div>
<p style="color: var(--primary-color); font-weight: 700; margin-bottom: 0.5rem; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 1px;">Vehicle Condition</p>
<p style="color: var(--text-primary);">Excellent / Premium</p>
</div>
<div>
<p style="color: var(--primary-color); font-weight: 700; margin-bottom: 0.5rem; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 1px;">Transmission</p>
<p style="color: var(--text-primary);">Automatic</p>
</div>
<div>
<p style="color: var(--primary-color); font-weight: 700; margin-bottom: 0.5rem; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 1px;">Fuel Type</p>
<p style="color: var(--text-primary);">Petrol / Hybrid</p>
</div>
<div>
<p style="color: var(--primary-color); font-weight: 700; margin-bottom: 0.5rem; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 1px;">Import Status</p>
<p style="color: var(--text-primary);">Custom Cleared</p>
</div>
</div>
</div>
</div>
<div>
<div class="glass" style="padding: 3rem; position: sticky; top: 120px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem;">
<span style="background: rgba(212, 175, 55, 0.2); color: var(--primary-color); padding: 6px 16px; border-radius: 50px; font-weight: 700; font-size: 0.85rem; border: 1px solid var(--primary-color);"><?= $car['year'] ?> MODEL</span>
<span style="color: var(--text-secondary); font-size: 0.9rem; font-weight: 500;">📍 <?= $car['city'] ?>, AFG</span>
</div>
<h1 style="font-size: 3rem; margin-bottom: 1rem; line-height: 1.1; font-weight: 800;"><?= htmlspecialchars($car['brand'] . ' ' . $car['model']) ?></h1>
<div class="car-price" style="font-size: 2.5rem; margin-bottom: 2.5rem;">$<?= number_format($car['price']) ?></div>
<div style="background: rgba(255,255,255,0.02); padding: 2rem; border-radius: 16px; margin-bottom: 2.5rem; border: 1px solid var(--glass-border);">
<p style="color: var(--text-secondary); margin-bottom: 1rem; display: flex; align-items: center; gap: 0.8rem;">
<span style="opacity: 0.5;">👤</span> Seller: <strong style="color: var(--text-primary);"><?= htmlspecialchars($car['seller_name']) ?></strong>
</p>
<p style="color: var(--text-secondary); display: flex; align-items: center; gap: 0.8rem;">
<span style="opacity: 0.5;">🆔</span> Listing ID: <strong style="color: var(--text-primary);">#AFG-<?= str_pad($car['id'], 5, '0', STR_PAD_LEFT) ?></strong>
</p>
</div>
<?php if (isset($_SESSION['user_id'])): ?>
<a href="purchase.php?id=<?= $car['id'] ?>" class="btn btn-primary" style="width: 100%; text-align: center; margin-bottom: 1.5rem; padding: 1.2rem; font-size: 1.1rem;">Initiate Purchase</a>
<a href="#" class="btn btn-outline" style="width: 100%; text-align: center; padding: 1.2rem;">Add to Favorites</a>
<?php else: ?>
<div style="text-align: center; padding: 2rem; border: 1px dashed var(--glass-border); border-radius: 16px;">
<p style="margin-bottom: 1.5rem; color: var(--text-secondary); font-size: 0.95rem;">Interested in this vehicle? Log in to contact the seller.</p>
<a href="login.php" class="btn btn-primary" style="width: 100%; text-align: center;">Login to Proceed</a>
</div>
<?php endif; ?>
<div style="margin-top: 3rem; text-align: center;">
<p style="color: var(--text-secondary); font-size: 0.8rem;">Share this listing:</p>
<div style="display: flex; gap: 1rem; justify-content: center; margin-top: 1rem; font-size: 1.5rem;">
<span style="cursor: pointer; opacity: 0.6;">📱</span>
<span style="cursor: pointer; opacity: 0.6;">💬</span>
<span style="cursor: pointer; opacity: 0.6;">📧</span>
</div>
</div>
</div>
</div>
</div>
<?php if ($similar): ?>
<div style="margin-top: 6rem;">
<h2 class="section-title" style="text-align: left;">Similar Premium Vehicles</h2>
<div class="grid">
<?php foreach ($similar as $s): ?>
<div class="car-card glass">
<div class="car-img-container" style="overflow: hidden; height: 200px;">
<div class="car-img" style="background-image: url('<?= htmlspecialchars($s['image_path'] ?: 'assets/images/placeholder-car.jpg') ?>'); background-size: cover; background-position: center; height: 100%;"></div>
</div>
<div class="car-info">
<div class="car-meta">
<span>📅 <?= htmlspecialchars($s['year']) ?></span>
<span>📍 <?= htmlspecialchars($s['city']) ?></span>
</div>
<h3><?= htmlspecialchars($s['brand'] . ' ' . $s['model']) ?></h3>
<div class="car-price">$<?= number_format($s['price']) ?></div>
<a href="car_detail.php?id=<?= $s['id'] ?>" class="btn btn-outline" style="width: 100%; text-align: center;">View Details</a>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
</div>
<?php require_once __DIR__ . '/includes/footer.php'; ?>

99
cars.php Normal file
View File

@ -0,0 +1,99 @@
<?php
require_once __DIR__ . '/includes/header.php';
$pdo = db();
$search = $_GET['q'] ?? '';
$brand = $_GET['brand'] ?? '';
$city = $_GET['city'] ?? '';
$query = "SELECT c.*, ci.image_path FROM cars c LEFT JOIN car_images ci ON c.id = ci.car_id AND ci.is_main = 1 WHERE c.status = 'approved'";
$params = [];
if ($search) {
$query .= " AND (c.brand LIKE ? OR c.model LIKE ?)";
$params[] = "%$search%";
$params[] = "%$search%";
}
if ($brand) {
$query .= " AND c.brand = ?";
$params[] = $brand;
}
if ($city) {
$query .= " AND c.city = ?";
$params[] = $city;
}
$query .= " ORDER BY c.created_at DESC";
$stmt = $pdo->prepare($query);
$stmt->execute($params);
$cars = $stmt->fetchAll();
$brands = $pdo->query("SELECT DISTINCT brand FROM cars WHERE status = 'approved'")->fetchAll(PDO::FETCH_COLUMN);
$cities = ['Kabul', 'Herat', 'Mazar-i-Sharif', 'Kandahar', 'Jalalabad', 'Kunduz', 'Ghazni', 'Balkh'];
?>
<div class="container" style="padding-top: 2rem;">
<h1 class="section-title">Premium Marketplace</h1>
<form class="glass" style="padding: 2.5rem; margin-bottom: 4rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; align-items: end; border-left: 4px solid var(--primary-color);">
<div class="form-group" style="margin-bottom: 0;">
<label>Keyword</label>
<input type="text" name="q" value="<?= htmlspecialchars($search) ?>" class="form-control" placeholder="Search brand or model...">
</div>
<div class="form-group" style="margin-bottom: 0;">
<label>Brand</label>
<select name="brand" class="form-control">
<option value="">All Brands</option>
<?php foreach ($brands as $b): ?>
<option value="<?= htmlspecialchars($b) ?>" <?= $brand == $b ? 'selected' : '' ?>><?= htmlspecialchars($b) ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group" style="margin-bottom: 0;">
<label>City</label>
<select name="city" class="form-control">
<option value="">All Cities</option>
<?php foreach ($cities as $c): ?>
<option value="<?= htmlspecialchars($c) ?>" <?= $city == $c ? 'selected' : '' ?>><?= htmlspecialchars($c) ?></option>
<?php endforeach; ?>
</select>
</div>
<div style="display: flex; gap: 0.5rem;">
<button type="submit" class="btn btn-primary" style="flex: 2;">Apply Filters</button>
<a href="cars.php" class="btn btn-outline" style="flex: 1; text-align: center; display: flex; align-items: center; justify-content: center; padding: 0;"></a>
</div>
</form>
<div class="grid">
<?php if (empty($cars)): ?>
<div style="grid-column: 1/-1; text-align: center; padding: 6rem; background: rgba(255,255,255,0.02); border-radius: 20px;">
<div style="font-size: 4rem; margin-bottom: 1.5rem; opacity: 0.3;">🚗💨</div>
<h2 style="color: var(--text-secondary);">No vehicles found</h2>
<p style="color: var(--text-secondary); margin-bottom: 2rem;">We couldn't find any cars matching your current filters.</p>
<a href="cars.php" class="btn btn-primary">Clear all filters</a>
</div>
<?php else: ?>
<?php foreach ($cars as $car): ?>
<div class="car-card glass">
<div class="car-img-container" style="overflow: hidden; height: 240px; position: relative;">
<div class="car-img" style="background-image: url('<?= htmlspecialchars($car['image_path'] ?: 'assets/images/placeholder-car.jpg') ?>'); background-size: cover; background-position: center; height: 100%;"></div>
<?php if ($car['is_hot_deal']): ?>
<div style="position: absolute; top: 1rem; left: 1rem; background: var(--primary-color); color: #000; padding: 0.4rem 1rem; border-radius: 50px; font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px;">Hot Deal</div>
<?php endif; ?>
</div>
<div class="car-info">
<div class="car-meta">
<span>📅 <?= htmlspecialchars($car['year']) ?></span>
<span>📍 <?= htmlspecialchars($car['city']) ?></span>
</div>
<h3><?= htmlspecialchars($car['brand'] . ' ' . $car['model']) ?></h3>
<div class="car-price">$<?= number_format($car['price']) ?></div>
<a href="car_detail.php?id=<?= $car['id'] ?>" class="btn btn-outline" style="width: 100%; text-align: center;">View Details</a>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
<?php require_once __DIR__ . '/includes/footer.php'; ?>

107
contact.php Normal file
View File

@ -0,0 +1,107 @@
<?php
require_once __DIR__ . '/includes/header.php';
$success = false;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = $_POST['name'] ?? '';
$email = $_POST['email'] ?? '';
$subject = $_POST['subject'] ?? '';
$message = $_POST['message'] ?? '';
$pdo = db();
$stmt = $pdo->prepare("INSERT INTO contact_messages (name, email, subject, message) VALUES (?, ?, ?, ?)");
if ($stmt->execute([$name, $email, $subject, $message])) {
$success = true;
}
}
?>
<section class="hero" style="height: 40vh; background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.7)), url('https://images.pexels.com/photos/3311574/pexels-photo-3311574.jpeg?auto=compress&cs=tinysrgb&w=1200') center/cover no-repeat;">
<h1>Get in Touch</h1>
<p>Have questions? Our team is here to help you find the perfect vehicle.</p>
</section>
<div class="container" style="max-width: 1200px; margin-top: -5rem;">
<div style="display: grid; grid-template-columns: 1fr 2fr; gap: 3rem;">
<div style="display: flex; flex-direction: column; gap: 2rem;">
<div class="glass" style="padding: 2.5rem; border-left: 4px solid var(--primary-color);">
<h3 style="color: var(--primary-color); margin-bottom: 1.5rem; display: flex; align-items: center; gap: 0.8rem;">
<span>📍</span> Visit Us
</h3>
<p style="font-size: 1rem; color: var(--text-secondary); line-height: 1.8;">
Wazir Akbar Khan, District 10,<br>
Kabul, Afghanistan
</p>
<p style="margin-top: 1.5rem; font-weight: 700; font-size: 1.2rem;">+93 799 123 456</p>
</div>
<div class="glass" style="padding: 2.5rem; border-left: 4px solid var(--primary-color);">
<h3 style="color: var(--primary-color); margin-bottom: 1.5rem; display: flex; align-items: center; gap: 0.8rem;">
<span>🕒</span> Working Hours
</h3>
<div style="display: flex; justify-content: space-between; margin-bottom: 0.8rem;">
<span style="color: var(--text-secondary);">Sat - Wed:</span>
<span style="font-weight: 600;">8:00 - 18:00</span>
</div>
<div style="display: flex; justify-content: space-between;">
<span style="color: var(--text-secondary);">Thursday:</span>
<span style="font-weight: 600;">8:00 - 13:00</span>
</div>
</div>
<div class="glass" style="padding: 2.5rem; border-left: 4px solid var(--primary-color);">
<h3 style="color: var(--primary-color); margin-bottom: 1.5rem; display: flex; align-items: center; gap: 0.8rem;">
<span>✉️</span> Support Email
</h3>
<p style="font-size: 1rem; color: var(--text-secondary);">info@afgcars.af</p>
<p style="font-size: 1rem; color: var(--text-secondary);">support@afgcars.af</p>
</div>
</div>
<div class="glass" style="padding: 4rem;">
<h2 style="margin-bottom: 2rem; font-size: 2rem;">Send us a message</h2>
<?php if ($success): ?>
<div class="alert alert-success" style="margin-bottom: 3rem;">
Message sent successfully! Our representative will contact you within 24 hours.
</div>
<?php endif; ?>
<form method="POST">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 2rem;">
<div class="form-group">
<label>Your Name</label>
<input type="text" name="name" class="form-control" required placeholder="John Doe">
</div>
<div class="form-group">
<label>Email Address</label>
<input type="email" name="email" class="form-control" required placeholder="john@example.com">
</div>
</div>
<div class="form-group">
<label>Subject</label>
<input type="text" name="subject" class="form-control" required placeholder="Inquiry about Toyota Land Cruiser">
</div>
<div class="form-group">
<label>How can we help?</label>
<textarea name="message" class="form-control" rows="6" required placeholder="Write your message here..."></textarea>
</div>
<button type="submit" class="btn btn-primary" style="width: 100%; padding: 1.2rem; font-size: 1.1rem;">Send Message</button>
</form>
</div>
</div>
</div>
<div class="container" style="margin-top: 4rem;">
<div class="glass" style="height: 450px; width: 100%; position: relative; overflow: hidden;">
<!-- Map Placeholder -->
<div style="position: absolute; inset: 0; background: url('https://images.pexels.com/photos/1051073/pexels-photo-1051073.jpeg?auto=compress&cs=tinysrgb&w=1200') center/cover; filter: grayscale(1) contrast(1.2) brightness(0.5);"></div>
<div style="position: relative; height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; background: rgba(0,0,0,0.4);">
<div style="font-size: 4rem; margin-bottom: 1rem;">📍</div>
<h2 style="font-size: 2.5rem; text-transform: uppercase; letter-spacing: 3px;">Our Location</h2>
<p style="color: var(--primary-color); font-weight: 700;">VISIT US IN KABUL</p>
<a href="https://maps.google.com" target="_blank" class="btn btn-outline" style="margin-top: 2rem;">Open in Google Maps</a>
</div>
</div>
</div>
<?php require_once __DIR__ . '/includes/footer.php'; ?>

112
dashboard.php Normal file
View File

@ -0,0 +1,112 @@
<?php
session_start();
require_once __DIR__ . '/db/config.php';
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit;
}
if (($_SESSION['role'] ?? '') === 'admin') {
header('Location: admin_dashboard.php');
exit;
}
$pdo = db();
$userId = $_SESSION['user_id'];
// Fetch user's purchases
$purchases = $pdo->prepare("
SELECT p.*, c.brand, c.model, c.year, c.price
FROM purchases p
JOIN cars c ON p.car_id = c.id
WHERE p.user_id = ?
ORDER BY p.created_at DESC
");
$purchases->execute([$userId]);
$myPurchases = $purchases->fetchAll();
// Fetch user's listings
$listings = $pdo->prepare("
SELECT * FROM cars
WHERE user_id = ? AND deleted_at IS NULL
ORDER BY created_at DESC
");
$listings->execute([$userId]);
$myCars = $listings->fetchAll();
require_once __DIR__ . '/includes/header.php';
?>
<div class="container" style="padding-top: 3rem;">
<div style="display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 3rem; border-bottom: 1px solid var(--glass-border); padding-bottom: 2rem;">
<div>
<h1 style="font-size: 2.5rem; font-weight: 900;">Welcome, <?= htmlspecialchars($_SESSION['user_name']) ?></h1>
<p style="color: var(--text-secondary);">Manage your car listings and view your purchase history.</p>
</div>
<a href="logout.php" class="btn btn-outline" style="border-color: var(--danger); color: var(--danger);">Sign Out</a>
</div>
<div style="display: grid; grid-template-columns: 2fr 1fr; gap: 3rem;">
<!-- Listings -->
<div>
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem;">
<h2 style="font-weight: 800;">My Listings</h2>
<a href="add_car.php" class="btn btn-primary btn-sm" style="padding: 0.6rem 1.2rem; font-size: 0.8rem;">+ List New Car</a>
</div>
<?php if (empty($myCars)): ?>
<div class="glass" style="padding: 4rem; text-align: center;">
<p style="color: var(--text-secondary); margin-bottom: 1.5rem;">You haven't listed any cars yet.</p>
<a href="add_car.php" class="btn btn-outline">Start Selling</a>
</div>
<?php else: ?>
<div class="grid" style="grid-template-columns: 1fr;">
<?php foreach ($myCars as $car): ?>
<div class="glass" style="padding: 1.5rem; display: flex; justify-content: space-between; align-items: center;">
<div>
<h3 style="margin-bottom: 0.3rem;"><?= htmlspecialchars($car['brand'] . ' ' . $car['model']) ?></h3>
<span class="badge badge-<?= $car['status'] === 'approved' ? 'success' : ($car['status'] === 'pending' ? 'warning' : 'danger') ?>">
<?= ucfirst($car['status']) ?>
</span>
<span style="margin-left: 1rem; color: var(--text-secondary); font-size: 0.9rem;">$<?= number_format($car['price']) ?></span>
</div>
<div style="display: flex; gap: 1rem;">
<a href="car_detail.php?id=<?= $car['id'] ?>" class="btn btn-outline" style="padding: 0.5rem 1rem; font-size: 0.8rem;">View</a>
<a href="edit_car.php?id=<?= $car['id'] ?>" class="btn btn-auth" style="padding: 0.5rem 1rem; font-size: 0.8rem;">Edit</a>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<!-- Purchases -->
<div>
<h2 style="font-weight: 800; margin-bottom: 2rem;">Recent Activity</h2>
<div class="glass" style="padding: 2rem;">
<h4 style="margin-bottom: 1.5rem; color: var(--primary-color);">Purchase History</h4>
<?php if (empty($myPurchases)): ?>
<p style="color: var(--text-secondary); font-size: 0.9rem;">No purchases found.</p>
<?php else: ?>
<div style="display: flex; flex-direction: column; gap: 1.5rem;">
<?php foreach ($myPurchases as $p): ?>
<div style="border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 1rem;">
<div style="display: flex; justify-content: space-between; margin-bottom: 0.3rem;">
<span style="font-weight: 700; font-size: 0.9rem;"><?= htmlspecialchars($p['brand'] . ' ' . $p['model']) ?></span>
<span style="font-size: 0.8rem; color: var(--primary-color); font-weight: 700;">$<?= number_format($p['price']) ?></span>
</div>
<div style="display: flex; justify-content: space-between; align-items: center;">
<span style="font-size: 0.75rem; color: var(--text-secondary);"><?= date('M d, Y', strtotime($p['created_at'])) ?></span>
<span class="badge badge-success" style="font-size: 0.65rem;">Completed</span>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php require_once __DIR__ . '/includes/footer.php'; ?>

77
db/seed_cars.php Normal file
View File

@ -0,0 +1,77 @@
<?php
require_once __DIR__ . '/config.php';
try {
$pdo = db();
// Get admin user id
$adminId = $pdo->query("SELECT id FROM users WHERE role = 'admin' LIMIT 1")->fetchColumn();
if (!$adminId) {
die("Admin user not found. Please run setup.php first.");
}
// Clear existing cars to avoid duplicates during seeding if needed,
// but better to just check count or add specifically.
$stmt = $pdo->query("SELECT COUNT(*) FROM cars");
if ($stmt->fetchColumn() > 5) {
echo "Cars already seeded.";
exit;
}
$afghanCities = ['Kabul', 'Herat', 'Mazar-i-Sharif', 'Kandahar', 'Jalalabad', 'Kunduz', 'Ghazni', 'Balkh'];
$brands = [
'Toyota' => ['Corolla', 'Camry', 'Land Cruiser', 'Hilux', 'Prado', '4Runner'],
'Mercedes-Benz' => ['G-Wagon', 'S-Class', 'E-Class', 'C-Class', 'GLE'],
'Lexus' => ['LX570', 'RX350', 'GX460', 'ES350'],
'Hyundai' => ['Elantra', 'Tucson', 'Santa Fe', 'Accent'],
'Honda' => ['Civic', 'CR-V', 'Accord'],
'Ford' => ['F-150', 'Mustang', 'Explorer'],
'BMW' => ['X5', 'X6', '5 Series', '7 Series']
];
$descriptions = [
"Excellent condition, very well maintained.",
"Full option, armored, and ready for any terrain.",
"Fuel efficient, perfect for city driving.",
"Luxury interior, premium sound system, and smooth ride.",
"Recently imported, custom cleared, and plate registered.",
"Powerful engine, off-road capabilities, and spacious.",
"Very clean inside and out, low mileage.",
"Top of the line model with all modern features."
];
$insertCar = $pdo->prepare("INSERT INTO cars (user_id, brand, model, year, price, city, description, status, is_hot_deal) VALUES (?, ?, ?, ?, ?, ?, ?, 'approved', ?)");
$insertImage = $pdo->prepare("INSERT INTO car_images (car_id, image_path, is_main) VALUES (?, ?, 1)");
$carImages = [
'https://images.pexels.com/photos/170811/pexels-photo-170811.jpeg?auto=compress&cs=tinysrgb&w=600',
'https://images.pexels.com/photos/112460/pexels-photo-112460.jpeg?auto=compress&cs=tinysrgb&w=600',
'https://images.pexels.com/photos/3729464/pexels-photo-3729464.jpeg?auto=compress&cs=tinysrgb&w=600',
'https://images.pexels.com/photos/912413/pexels-photo-912413.jpeg?auto=compress&cs=tinysrgb&w=600',
'https://images.pexels.com/photos/116675/pexels-photo-116675.jpeg?auto=compress&cs=tinysrgb&w=600',
'https://images.pexels.com/photos/210019/pexels-photo-210019.jpeg?auto=compress&cs=tinysrgb&w=600',
'https://images.pexels.com/photos/337909/pexels-photo-337909.jpeg?auto=compress&cs=tinysrgb&w=600',
'https://images.pexels.com/photos/1149137/pexels-photo-1149137.jpeg?auto=compress&cs=tinysrgb&w=600'
];
for ($i = 0; $i < 20; $i++) {
$brand = array_rand($brands);
$model = $brands[$brand][array_rand($brands[$brand])];
$year = rand(2015, 2024);
$price = rand(5000, 150000);
$city = $afghanCities[array_rand($afghanCities)];
$desc = $descriptions[array_rand($descriptions)];
$isHot = (rand(1, 10) > 7) ? 1 : 0;
$insertCar->execute([$adminId, $brand, $model, $year, $price, $city, $desc, $isHot]);
$carId = $pdo->lastInsertId();
$imageUrl = $carImages[array_rand($carImages)];
$insertImage->execute([$carId, $imageUrl]);
}
echo "Successfully seeded 20 cars.";
} catch (PDOException $e) {
die("Database error: " . $e->getMessage());
}

96
db/setup.php Normal file
View File

@ -0,0 +1,96 @@
<?php
require_once __DIR__ . '/config.php';
try {
$pdo = db();
// Users Table
$pdo->exec("CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(100) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
role ENUM('guest', 'user', 'admin') DEFAULT 'user',
status ENUM('active', 'inactive') DEFAULT 'active',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;");
// Cars Table
$pdo->exec("CREATE TABLE IF NOT EXISTS cars (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
brand VARCHAR(50) NOT NULL,
model VARCHAR(50) NOT NULL,
year INT NOT NULL,
price DECIMAL(10, 2) NOT NULL,
city VARCHAR(50) NOT NULL,
description TEXT,
status ENUM('pending', 'approved', 'rejected', 'sold') DEFAULT 'pending',
is_hot_deal BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP NULL DEFAULT NULL,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;");
// Car Images Table
$pdo->exec("CREATE TABLE IF NOT EXISTS car_images (
id INT AUTO_INCREMENT PRIMARY KEY,
car_id INT NOT NULL,
image_path VARCHAR(255) NOT NULL,
is_main BOOLEAN DEFAULT FALSE,
FOREIGN KEY (car_id) REFERENCES cars(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;");
// Reviews Table
$pdo->exec("CREATE TABLE IF NOT EXISTS reviews (
id INT AUTO_INCREMENT PRIMARY KEY,
car_id INT NOT NULL,
user_id INT NOT NULL,
rating INT CHECK (rating >= 1 AND rating <= 5),
comment TEXT,
status ENUM('pending', 'approved') DEFAULT 'pending',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (car_id) REFERENCES cars(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;");
// Purchases (Simulation)
$pdo->exec("CREATE TABLE IF NOT EXISTS purchases (
id INT AUTO_INCREMENT PRIMARY KEY,
car_id INT NOT NULL,
user_id INT NOT NULL,
buyer_name VARCHAR(100),
buyer_email VARCHAR(100),
buyer_phone VARCHAR(20),
status ENUM('pending', 'completed', 'cancelled') DEFAULT 'pending',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (car_id) REFERENCES cars(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;");
// Contact Messages
$pdo->exec("CREATE TABLE IF NOT EXISTS contact_messages (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100),
email VARCHAR(100),
subject VARCHAR(200),
message TEXT,
status ENUM('unread', 'read', 'answered') DEFAULT 'unread',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;");
// Seed Admin User
$adminEmail = 'admin@gmail.com';
$stmt = $pdo->prepare("SELECT id FROM users WHERE email = ?");
$stmt->execute([$adminEmail]);
if (!$stmt->fetch()) {
$password = password_hash('12345678', PASSWORD_DEFAULT);
$pdo->prepare("INSERT INTO users (name, email, password, role) VALUES (?, ?, ?, ?)")
->execute(['Admin', $adminEmail, $password, 'admin']);
}
echo "Database setup successfully.";
} catch (PDOException $e) {
die("Database error: " . $e->getMessage());
}

110
edit_car.php Normal file
View File

@ -0,0 +1,110 @@
<?php
require_once __DIR__ . '/includes/header.php';
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit;
}
$pdo = db();
$id = $_GET['id'] ?? 0;
$userId = $_SESSION['user_id'];
// Check ownership
$stmt = $pdo->prepare("SELECT * FROM cars WHERE id = ? AND user_id = ? AND deleted_at IS NULL");
$stmt->execute([$id, $userId]);
$car = $stmt->fetch();
if (!$car) {
header('Location: dashboard.php');
exit;
}
$error = '';
$success = false;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$brand = $_POST['brand'] ?? '';
$model = $_POST['model'] ?? '';
$year = $_POST['year'] ?? '';
$price = $_POST['price'] ?? '';
$city = $_POST['city'] ?? '';
$description = $_POST['description'] ?? '';
try {
$stmt = $pdo->prepare("UPDATE cars SET brand = ?, model = ?, year = ?, price = ?, city = ?, description = ?, status = 'pending' WHERE id = ?");
$stmt->execute([$brand, $model, $year, $price, $city, $description, $id]);
$success = true;
} catch (Exception $e) {
$error = "Update failed: " . $e->getMessage();
}
}
$cities = ['Kabul', 'Herat', 'Mazar-i-Sharif', 'Kandahar', 'Jalalabad', 'Kunduz', 'Ghazni', 'Balkh'];
?>
<div class="container" style="max-width: 800px;">
<div class="box" style="padding: 4rem;">
<h1 style="margin-bottom: 1rem; font-size: 2.5rem; font-weight: 900;">Edit Listing</h1>
<p style="color: var(--text-secondary); margin-bottom: 3rem;">Update your vehicle details. Note: editing will reset the status to 'pending' for re-approval.</p>
<?php if ($success): ?>
<div class="glass" style="padding: 2rem; border-color: var(--success); background: rgba(46, 213, 115, 0.05); color: var(--success); margin-bottom: 3rem; text-align: center; border-radius: 16px;">
<h3 style="margin-bottom: 0.5rem;"> Changes Saved!</h3>
<p>Your listing has been updated and is now pending approval.</p>
<div style="margin-top: 1.5rem;">
<a href="dashboard.php" class="btn btn-primary btn-sm">Back to Dashboard</a>
</div>
</div>
<?php endif; ?>
<?php if ($error): ?>
<div class="alert alert-error" style="margin-bottom: 2rem;"><?= $error ?></div>
<?php endif; ?>
<form method="POST">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;">
<div class="form-group">
<label>Brand</label>
<input type="text" name="brand" class="form-control" value="<?= htmlspecialchars($car['brand']) ?>" required>
</div>
<div class="form-group">
<label>Model</label>
<input type="text" name="model" class="form-control" value="<?= htmlspecialchars($car['model']) ?>" required>
</div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;">
<div class="form-group">
<label>Year</label>
<input type="number" name="year" class="form-control" value="<?= htmlspecialchars($car['year']) ?>" required>
</div>
<div class="form-group">
<label>Price (USD)</label>
<input type="number" name="price" class="form-control" value="<?= htmlspecialchars($car['price']) ?>" required>
</div>
</div>
<div class="form-group">
<label>City</label>
<select name="city" class="form-control" required>
<?php foreach ($cities as $c): ?>
<option value="<?= $c ?>" <?= $car['city'] === $c ? 'selected' : '' ?>><?= $c ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label>Description</label>
<textarea name="description" class="form-control" rows="5" required><?= htmlspecialchars($car['description']) ?></textarea>
</div>
<div style="margin-top: 3rem; display: flex; gap: 1.5rem;">
<button type="submit" class="btn btn-primary" style="flex: 2; padding: 1.2rem;">Save Changes</button>
<a href="dashboard.php" class="btn btn-outline" style="flex: 1; text-align: center; padding: 1.2rem;">Cancel</a>
</div>
</form>
</div>
</div>
<?php require_once __DIR__ . '/includes/footer.php'; ?>

49
includes/footer.php Normal file
View File

@ -0,0 +1,49 @@
<footer>
<div class="footer-grid">
<div class="footer-col">
<a href="index.php" class="logo">AfgCars</a>
<p style="margin-top: 1.5rem; color: var(--text-secondary); font-size: 0.95rem; line-height: 1.8;">
The most premium and trusted car marketplace in Afghanistan. We bridge the gap between luxury and accessibility for every Afghan citizen.
</p>
<div style="display: flex; gap: 1rem; margin-top: 1.5rem;">
<span style="font-size: 1.2rem; cursor: pointer; opacity: 0.6;">𝕏</span>
<span style="font-size: 1.2rem; cursor: pointer; opacity: 0.6;">📘</span>
<span style="font-size: 1.2rem; cursor: pointer; opacity: 0.6;">📸</span>
</div>
</div>
<div class="footer-col">
<h4>Marketplace</h4>
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="cars.php">All Vehicles</a></li>
<li><a href="cars.php?hot_deal=1">Hot Deals</a></li>
<li><a href="register.php">Sell Your Car</a></li>
</ul>
</div>
<div class="footer-col">
<h4>Company</h4>
<ul>
<li><a href="about.php">About Us</a></li>
<li><a href="contact.php">Contact Us</a></li>
<li><a href="about.php#locations">Our Locations</a></li>
<li><a href="about.php#mission">Our Mission</a></li>
</ul>
</div>
<div class="footer-col">
<h4>Showrooms</h4>
<ul style="color: var(--text-secondary); font-size: 0.9rem;">
<li style="margin-bottom: 0.8rem;">📍 Kabul Main: Street 15, Wazir Akbar Khan</li>
<li style="margin-bottom: 0.8rem;">📍 Herat: Near Blue Mosque</li>
<li style="margin-bottom: 0.8rem;">📍 Mazar: Balkh Gate Road</li>
<li style="margin-bottom: 0.8rem;">📞 Support: +93 799 123 456</li>
</ul>
</div>
</div>
<div class="footer-bottom">
<p>&copy; <?= date('Y') ?> AfgCars Premium Marketplace. All rights reserved.</p>
<p style="margin-top: 1rem; opacity: 0.4; font-size: 0.75rem; letter-spacing: 1px;">UNIVERSITY FINAL-YEAR PROJECT DESIGNED FOR AFGHANISTAN 2026</p>
</div>
</footer>
<script src="assets/js/main.js"></script>
</body>
</html>

50
includes/header.php Normal file
View File

@ -0,0 +1,50 @@
<?php
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
require_once __DIR__ . '/../db/config.php';
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Premium Car Marketplace Afghanistan';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AfgCars | Premium Marketplace</title>
<meta name="description" content="<?= htmlspecialchars($projectDescription) ?>">
<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;500;600;700;800;900&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/style.css?v=<?= time() ?>">
<style>
.nav-actions {
display: flex;
align-items: center;
gap: 1rem;
}
</style>
</head>
<body>
<?php if (!str_contains($_SERVER['SCRIPT_NAME'], 'admin_dashboard.php')): ?>
<nav>
<a href="index.php" class="logo">AfgCars</a>
<ul class="nav-links">
<li><a href="index.php">Home</a></li>
<li><a href="cars.php">Marketplace</a></li>
<li><a href="about.php">About</a></li>
<li><a href="contact.php">Contact</a></li>
</ul>
<div class="nav-actions">
<?php if (isset($_SESSION['user_id'])): ?>
<?php if (($_SESSION['role'] ?? '') === 'admin'): ?>
<a href="admin_dashboard.php" class="btn-auth">Admin Panel</a>
<?php else: ?>
<a href="dashboard.php" class="btn-auth">My Account</a>
<?php endif; ?>
<a href="logout.php" class="btn-auth" style="border-color: rgba(255, 71, 87, 0.3); color: var(--danger);">Logout</a>
<?php else: ?>
<a href="login.php" class="btn-auth">Login / Register</a>
<?php endif; ?>
</div>
</nav>
<?php endif; ?>

266
index.php
View File

@ -1,150 +1,124 @@
<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
require_once __DIR__ . '/includes/header.php';
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
$pdo = db();
// Get hot deals
$hotDeals = $pdo->query("SELECT c.*, ci.image_path FROM cars c LEFT JOIN car_images ci ON c.id = ci.car_id AND ci.is_main = 1 WHERE c.is_hot_deal = 1 AND c.status = 'approved' LIMIT 6")->fetchAll();
$testimonials = [
[
'name' => 'Ahmad Wali',
'city' => 'Kabul',
'text' => 'Found my dream Land Cruiser here. The process was smooth and the seller was very professional. Highly recommended for premium cars in Afghanistan!',
'rating' => 5
],
[
'name' => 'Mariam Sadat',
'city' => 'Herat',
'text' => 'As a first-time car buyer, I felt very safe using AfgCars. The verified listings give me peace of mind. Excellent service!',
'rating' => 5
],
[
'name' => 'Zubair Khan',
'city' => 'Mazar-i-Sharif',
'text' => 'The best marketplace in the country. Clean interface and very easy to contact sellers. Sold my Corolla within 3 days!',
'rating' => 4
]
];
?>
<!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>
<section class="hero" style="background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.7)), url('https://images.pexels.com/photos/337909/pexels-photo-337909.jpeg?auto=compress&cs=tinysrgb&w=1920') center/cover no-repeat fixed;">
<div style="z-index: 2; position: relative;">
<h1>Find Your Premium Ride</h1>
<p>Exclusive luxury vehicles and reliable everyday cars in Afghanistan's most trusted marketplace.</p>
<div style="display: flex; gap: 1.5rem; justify-content: center;">
<a href="cars.php" class="btn btn-primary">View Marketplace</a>
<?php if (!isset($_SESSION['user_id'])): ?>
<a href="register.php" class="btn btn-outline">Start Selling</a>
<?php else: ?>
<a href="dashboard.php" class="btn btn-outline">My Account</a>
<?php endif; ?>
</div>
</div>
</main>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC)
</footer>
</body>
</html>
</section>
<div class="container">
<h2 class="section-title">Hot Deals</h2>
<div class="grid">
<?php foreach ($hotDeals as $car): ?>
<div class="car-card glass">
<div class="car-img-container" style="overflow: hidden; height: 240px; border-bottom: 1px solid var(--glass-border);">
<div class="car-img" style="background-image: url('<?= htmlspecialchars($car['image_path'] ?: 'assets/images/placeholder-car.jpg') ?>'); background-size: cover; background-position: center; height: 100%;"></div>
</div>
<div class="car-info">
<div class="car-meta">
<span>📅 <?= htmlspecialchars($car['year']) ?></span>
<span>📍 <?= htmlspecialchars($car['city']) ?></span>
</div>
<h3><?= htmlspecialchars($car['brand'] . ' ' . $car['model']) ?></h3>
<div class="car-price">$<?= number_format($car['price']) ?></div>
<a href="car_detail.php?id=<?= $car['id'] ?>" class="btn btn-outline" style="width: 100%; text-align: center;">View Details</a>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<section style="background: rgba(212, 175, 55, 0.03); padding: 8rem 0;">
<div class="container">
<h2 class="section-title">What Our Clients Say</h2>
<div class="grid">
<?php foreach ($testimonials as $t): ?>
<div class="box">
<div class="review-stars" style="color: var(--primary-color); margin-bottom: 1.5rem;">
<?php for($i=0; $i<$t['rating']; $i++) echo '★'; ?>
</div>
<p style="font-style: italic; color: var(--text-secondary); line-height: 1.8; margin-bottom: 2rem;">"<?= htmlspecialchars($t['text']) ?>"</p>
<div class="review-author" style="display: flex; align-items: center; gap: 1rem;">
<div style="width: 45px; height: 45px; background: var(--primary-color); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #000;">
<?= substr($t['name'], 0, 1) ?>
</div>
<div>
<h4 style="margin: 0; font-size: 1rem;"><?= htmlspecialchars($t['name']) ?></h4>
<p style="margin: 0; font-size: 0.8rem; color: var(--text-secondary);"><?= htmlspecialchars($t['city']) ?></p>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</section>
<div class="container">
<h2 class="section-title">Our Physical Showrooms</h2>
<div class="grid">
<div class="box" style="text-align: center;">
<div style="font-size: 3rem; margin-bottom: 1.5rem;">📍</div>
<h3>Kabul HQ</h3>
<p style="color: var(--text-secondary); margin-bottom: 1rem;">Wazir Akbar Khan, Street 15</p>
<p style="font-weight: 700; color: var(--primary-color); font-size: 1.1rem;">+93 700 123 456</p>
</div>
<div class="box" style="text-align: center;">
<div style="font-size: 3rem; margin-bottom: 1.5rem;">📍</div>
<h3>Herat Branch</h3>
<p style="color: var(--text-secondary); margin-bottom: 1rem;">Jada-e-Main, Near Blue Mosque</p>
<p style="font-weight: 700; color: var(--primary-color); font-size: 1.1rem;">+93 700 987 654</p>
</div>
<div class="box" style="text-align: center;">
<div style="font-size: 3rem; margin-bottom: 1.5rem;">📍</div>
<h3>Mazar-i-Sharif</h3>
<p style="color: var(--text-secondary); margin-bottom: 1rem;">Balkh Gate Road</p>
<p style="font-weight: 700; color: var(--primary-color); font-size: 1.1rem;">+93 700 456 789</p>
</div>
</div>
</div>
<div class="container" style="text-align: center; margin-bottom: 4rem;">
<div class="box" style="padding: 6rem 3rem; background: linear-gradient(135deg, rgba(212, 175, 55, 0.08), transparent);">
<h2 style="font-size: 3rem; margin-bottom: 1.5rem; font-weight: 900;">Ready to sell your car?</h2>
<p style="color: var(--text-secondary); margin-bottom: 3rem; max-width: 600px; margin-left: auto; margin-right: auto; font-size: 1.1rem;">Join thousands of Afghans who have successfully sold their vehicles through our platform. No hidden fees, just results.</p>
<a href="register.php" class="btn btn-primary" style="padding: 1.2rem 3rem;">Start Listing Now</a>
</div>
</div>
<?php require_once __DIR__ . '/includes/footer.php'; ?>

68
login.php Normal file
View File

@ -0,0 +1,68 @@
<?php
require_once __DIR__ . '/includes/header.php';
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$email = $_POST['email'] ?? '';
$password = $_POST['password'] ?? '';
$pdo = db();
$stmt = $pdo->prepare("SELECT * FROM users WHERE email = ? AND deleted_at IS NULL");
$stmt->execute([$email]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
if ($user['status'] === 'active') {
$_SESSION['user_id'] = $user['id'];
$_SESSION['user_name'] = $user['name'];
$_SESSION['user_email'] = $user['email'];
$_SESSION['role'] = $user['role'];
// Redirect based on role
if ($user['role'] === 'admin') {
header('Location: admin_dashboard.php');
} else {
header('Location: dashboard.php');
}
exit;
} else {
$error = "Your account is inactive. Please contact admin.";
}
} else {
$error = "Invalid email or password.";
}
}
?>
<div class="container" style="display: flex; justify-content: center; align-items: center; min-height: 70vh;">
<div class="box" style="width: 100%; max-width: 450px; padding: 3.5rem;">
<div style="text-align: center; margin-bottom: 2.5rem;">
<h2 style="font-size: 2.2rem; font-weight: 900; margin-bottom: 0.5rem;">Welcome Back</h2>
<p style="color: var(--text-secondary);">Sign in to your AfgCars account</p>
</div>
<?php if ($error): ?>
<div class="glass" style="padding: 1rem; border-color: rgba(255, 71, 87, 0.3); background: rgba(255, 71, 87, 0.05); color: var(--danger); margin-bottom: 1.5rem; border-radius: 12px; font-size: 0.9rem; font-weight: 600; text-align: center;">
<?= $error ?>
</div>
<?php endif; ?>
<form method="POST">
<div class="form-group">
<label style="font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-secondary); font-weight: 700;">Email Address</label>
<input type="email" name="email" class="form-control" required placeholder="admin@gmail.com" style="margin-top: 0.5rem;">
</div>
<div class="form-group">
<label style="font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-secondary); font-weight: 700;">Password</label>
<input type="password" name="password" class="form-control" required placeholder="••••••••" style="margin-top: 0.5rem;">
</div>
<button type="submit" class="btn btn-primary" style="width: 100%; margin-top: 1.5rem; padding: 1.1rem;">Sign In</button>
</form>
<p style="text-align: center; margin-top: 2.5rem; color: var(--text-secondary); font-size: 0.95rem;">
New to AfgCars? <a href="register.php" style="color: var(--primary-color); font-weight: 700; text-decoration: none;">Create an account</a>
</p>
</div>
</div>
<?php require_once __DIR__ . '/includes/footer.php'; ?>

5
logout.php Normal file
View File

@ -0,0 +1,5 @@
<?php
session_start();
session_destroy();
header('Location: index.php');
exit;

106
purchase.php Normal file
View File

@ -0,0 +1,106 @@
<?php
require_once __DIR__ . '/includes/header.php';
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit;
}
$pdo = db();
$id = $_GET['id'] ?? 0;
$stmt = $pdo->prepare("SELECT c.*, ci.image_path FROM cars c LEFT JOIN car_images ci ON c.id = ci.car_id AND ci.is_main = 1 WHERE c.id = ? AND c.status = 'approved'");
$stmt->execute([$id]);
$car = $stmt->fetch();
if (!$car) {
header('Location: cars.php');
exit;
}
$success = false;
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = $_POST['buyer_name'] ?? '';
$phone = $_POST['buyer_phone'] ?? '';
$email = $_SESSION['user_email'] ?? '';
$stmt = $pdo->prepare("INSERT INTO purchases (car_id, user_id, buyer_name, buyer_email, buyer_phone) VALUES (?, ?, ?, ?, ?)");
if ($stmt->execute([$id, $_SESSION['user_id'], $name, $email, $phone])) {
$success = true;
} else {
$error = "Failed to submit request. Please try again.";
}
}
?>
<div class="container" style="max-width: 1000px;">
<?php if ($success): ?>
<div class="glass" style="padding: 5rem; text-align: center; border-top: 4px solid var(--primary-color);">
<div style="font-size: 5rem; margin-bottom: 2rem;"></div>
<h1 style="color: var(--primary-color); font-size: 3rem; margin-bottom: 1.5rem; font-weight: 800;">Request Submitted!</h1>
<p style="margin-bottom: 3rem; font-size: 1.2rem; color: var(--text-secondary); max-width: 700px; margin-left: auto; margin-right: auto; line-height: 1.8;">
Your purchase request for the <strong><?= htmlspecialchars($car['brand'] . ' ' . $car['model']) ?></strong> has been sent to our verification team.
Our representative will contact you at <strong><?= htmlspecialchars($phone) ?></strong> within 24 hours to guide you through the offline bank transfer process.
</p>
<div style="display: flex; gap: 1.5rem; justify-content: center;">
<a href="cars.php" class="btn btn-primary">Back to Marketplace</a>
<a href="index.php" class="btn btn-outline">Home Page</a>
</div>
</div>
<?php else: ?>
<div style="display: grid; grid-template-columns: 1fr 1.5fr; gap: 3rem; align-items: start;">
<div class="glass" style="padding: 2rem; position: sticky; top: 120px;">
<h3 style="margin-bottom: 1.5rem; color: var(--primary-color);">Purchase Summary</h3>
<div style="width: 100%; height: 200px; background-image: url('<?= htmlspecialchars($car['image_path'] ?: 'assets/images/placeholder-car.jpg') ?>'); background-size: cover; background-position: center; border-radius: 12px; margin-bottom: 1.5rem;"></div>
<h2 style="font-size: 1.5rem; margin-bottom: 0.5rem;"><?= htmlspecialchars($car['brand'] . ' ' . $car['model']) ?></h2>
<p style="color: var(--text-secondary); margin-bottom: 1.5rem;"><?= $car['year'] ?> Model - <?= $car['city'] ?></p>
<div style="display: flex; justify-content: space-between; border-top: 1px solid var(--glass-border); padding-top: 1.5rem;">
<span style="font-weight: 600;">Total Amount</span>
<span style="font-weight: 800; color: var(--primary-color); font-size: 1.5rem;">$<?= number_format($car['price']) ?></span>
</div>
</div>
<div class="glass" style="padding: 4rem;">
<h1 style="margin-bottom: 1rem; font-size: 2.5rem; font-weight: 800;">Complete Your Request</h1>
<p style="color: var(--text-secondary); margin-bottom: 3rem; font-size: 1.1rem;">Please provide your contact details. This is an offline purchase simulation for the Afghan automotive market.</p>
<?php if ($error): ?>
<div class="alert alert-error" style="margin-bottom: 2rem;"><?= $error ?></div>
<?php endif; ?>
<form method="POST">
<div class="form-group">
<label>Your Full Name</label>
<input type="text" name="buyer_name" class="form-control" value="<?= htmlspecialchars($_SESSION['user_name']) ?>" required placeholder="Enter your full legal name">
</div>
<div class="form-group">
<label>Active Phone Number (For Verification)</label>
<input type="text" name="buyer_phone" class="form-control" required placeholder="+93 7xx xxx xxx">
</div>
<div style="margin: 3rem 0; padding: 2.5rem; background: rgba(212, 175, 55, 0.05); border-left: 5px solid var(--primary-color); border-radius: 16px;">
<h4 style="color: var(--primary-color); margin-bottom: 1rem; font-size: 1.2rem; display: flex; align-items: center; gap: 0.8rem;">
<span>🏦</span> Offline Payment Process
</h4>
<p style="font-size: 0.95rem; color: var(--text-secondary); line-height: 1.8;">
1. Submit this purchase request.<br>
2. Wait for admin approval (usually within 24 hours).<br>
3. Visit any <strong>Azizi Bank</strong> or <strong>New Kabul Bank</strong> branch.<br>
4. Deposit the total amount into the verified seller's account.<br>
5. Upload the bank receipt to complete the transaction.
</p>
</div>
<div style="display: flex; gap: 1.5rem; align-items: center;">
<button type="submit" class="btn btn-primary" style="flex: 2; padding: 1.2rem; font-size: 1.1rem;">Confirm & Submit Request</button>
<a href="car_detail.php?id=<?= $id ?>" class="btn btn-outline" style="flex: 1; text-align: center; padding: 1.2rem; font-size: 1.1rem;">Cancel</a>
</div>
</form>
</div>
</div>
<?php endif; ?>
</div>
<?php require_once __DIR__ . '/includes/footer.php'; ?>

68
register.php Normal file
View File

@ -0,0 +1,68 @@
<?php
require_once __DIR__ . '/includes/header.php';
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = $_POST['name'] ?? '';
$email = $_POST['email'] ?? '';
$password = $_POST['password'] ?? '';
$pdo = db();
// Check if user exists
$stmt = $pdo->prepare("SELECT id FROM users WHERE email = ?");
$stmt->execute([$email]);
if ($stmt->fetch()) {
$error = "Email already registered.";
} else {
$hashed = password_hash($password, PASSWORD_DEFAULT);
$stmt = $pdo->prepare("INSERT INTO users (name, email, password) VALUES (?, ?, ?)");
if ($stmt->execute([$name, $email, $hashed])) {
$_SESSION['user_id'] = $pdo->lastInsertId();
$_SESSION['user_name'] = $name;
$_SESSION['user_email'] = $email;
$_SESSION['role'] = 'user';
header('Location: dashboard.php');
exit;
} else {
$error = "Registration failed. Please try again.";
}
}
}
?>
<div class="container" style="display: flex; justify-content: center; align-items: center; min-height: 80vh;">
<div class="box" style="width: 100%; max-width: 500px; padding: 4rem;">
<div style="text-align: center; margin-bottom: 3rem;">
<h2 style="font-size: 2.2rem; font-weight: 900; margin-bottom: 0.5rem;">Join AfgCars</h2>
<p style="color: var(--text-secondary);">Create your premium account today</p>
</div>
<?php if ($error): ?>
<div class="glass" style="padding: 1rem; border-color: rgba(255, 71, 87, 0.3); background: rgba(255, 71, 87, 0.05); color: var(--danger); margin-bottom: 1.5rem; border-radius: 12px; font-size: 0.9rem; font-weight: 600; text-align: center;">
<?= $error ?>
</div>
<?php endif; ?>
<form method="POST">
<div class="form-group">
<label style="font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-secondary); font-weight: 700;">Full Name</label>
<input type="text" name="name" class="form-control" required placeholder="John Doe" style="margin-top: 0.5rem;">
</div>
<div class="form-group">
<label style="font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-secondary); font-weight: 700;">Email Address</label>
<input type="email" name="email" class="form-control" required placeholder="name@example.com" style="margin-top: 0.5rem;">
</div>
<div class="form-group">
<label style="font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-secondary); font-weight: 700;">Password</label>
<input type="password" name="password" class="form-control" required placeholder="••••••••" style="margin-top: 0.5rem;">
</div>
<button type="submit" class="btn btn-primary" style="width: 100%; margin-top: 1.5rem; padding: 1.1rem;">Create Account</button>
</form>
<p style="text-align: center; margin-top: 2.5rem; color: var(--text-secondary); font-size: 0.95rem;">
Already have an account? <a href="login.php" style="color: var(--primary-color); font-weight: 700; text-decoration: none;">Sign in</a>
</p>
</div>
</div>
<?php require_once __DIR__ . '/includes/footer.php'; ?>