136 lines
6.7 KiB
PHP
136 lines
6.7 KiB
PHP
<?php
|
|
session_start();
|
|
require_once __DIR__ . '/db/config.php';
|
|
|
|
// Fetch Featured Cars
|
|
$cars = [];
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->query("SELECT * FROM cars ORDER BY created_at DESC LIMIT 4");
|
|
$cars = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
} catch (Exception $e) {
|
|
// Graceful fallback if DB fails (shouldn't happen given the setup step)
|
|
error_log($e->getMessage());
|
|
}
|
|
|
|
// Meta variables
|
|
$projectName = getenv('PROJECT_NAME') ?: 'Car Sells in Afghanistan';
|
|
$projectDesc = getenv('PROJECT_DESCRIPTION') ?: 'The best marketplace for buying and selling cars in Afghanistan.';
|
|
$projectImage = getenv('PROJECT_IMAGE_URL') ?: 'https://images.pexels.com/photos/120049/pexels-photo-120049.jpeg?auto=compress&cs=tinysrgb&w=1200';
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?php echo htmlspecialchars($projectName); ?></title>
|
|
<meta name="description" content="<?php echo htmlspecialchars($projectDesc); ?>">
|
|
|
|
<!-- Open Graph -->
|
|
<meta property="og:title" content="<?php echo htmlspecialchars($projectName); ?>">
|
|
<meta property="og:description" content="<?php echo htmlspecialchars($projectDesc); ?>">
|
|
<meta property="og:image" content="<?php echo htmlspecialchars($projectImage); ?>">
|
|
|
|
<!-- Bootstrap 5 -->
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<!-- Bootstrap Icons -->
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
|
|
<!-- Google Fonts: Inter -->
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
|
|
|
<!-- Custom CSS -->
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
</head>
|
|
<body>
|
|
|
|
<?php include 'partials/navbar.php'; ?>
|
|
|
|
<!-- Hero Section -->
|
|
<section class="hero-section text-center">
|
|
<div class="hero-bg-overlay"></div>
|
|
<div class="container hero-content">
|
|
<div class="row justify-content-center">
|
|
<div class="col-lg-8">
|
|
<h1 class="display-4 fw-bold mb-3">Find Your Dream Car</h1>
|
|
<p class="lead mb-5 text-light opacity-75">The most trusted marketplace for buying and selling cars in Afghanistan.</p>
|
|
|
|
<div class="search-card text-start">
|
|
<form action="#" method="GET" class="row g-3">
|
|
<div class="col-md-4">
|
|
<label class="form-label small text-muted">Make</label>
|
|
<select class="form-select border-0 bg-light">
|
|
<option selected>All Makes</option>
|
|
<option>Toyota</option>
|
|
<option>Mercedes</option>
|
|
<option>Honda</option>
|
|
</select>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<label class="form-label small text-muted">Model</label>
|
|
<select class="form-select border-0 bg-light">
|
|
<option selected>Any Model</option>
|
|
<option>Corolla</option>
|
|
<option>Camry</option>
|
|
<option>Land Cruiser</option>
|
|
</select>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<label class="form-label small text-muted d-block"> </label>
|
|
<button type="submit" class="btn btn-primary w-100">Search Cars</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<!-- Featured Cars -->
|
|
<section class="container mb-5">
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h2 class="section-title h3 mb-0">Featured Cars</h2>
|
|
<a href="#" class="text-decoration-none fw-semibold">View All <i class="bi bi-arrow-right"></i></a>
|
|
</div>
|
|
|
|
<div class="row g-4">
|
|
<?php if (!empty($cars)): ?>
|
|
<?php foreach ($cars as $car): ?>
|
|
<div class="col-md-6 col-lg-3">
|
|
<div class="car-card h-100">
|
|
<div class="position-relative">
|
|
<img src="<?php echo htmlspecialchars($car['image_url']); ?>" class="card-img-top car-img-top" alt="<?php echo htmlspecialchars($car['make'] . ' ' . $car['model']); ?>">
|
|
<span class="position-absolute top-0 end-0 m-3 badge bg-dark opacity-75"><?php echo $car['year']; ?></span>
|
|
</div>
|
|
<div class="car-card-body d-flex flex-column">
|
|
<h5 class="card-title fw-bold mb-1"><?php echo htmlspecialchars($car['make'] . ' ' . $car['model']); ?></h5>
|
|
<p class="text-muted small mb-3 text-truncate"><?php echo htmlspecialchars($car['description']); ?></p>
|
|
|
|
<div class="mt-auto">
|
|
<div class="d-flex justify-content-between mb-3">
|
|
<div class="spec-item"><i class="bi bi-speedometer2"></i> <?php echo number_format($car['mileage']); ?> km</div>
|
|
<div class="spec-item"><i class="bi bi-fuel-pump"></i> Petrol</div>
|
|
</div>
|
|
<div class="d-flex justify-content-between align-items-center">
|
|
<span class="price-tag">$<?php echo number_format($car['price']); ?></span>
|
|
<a href="#" class="btn btn-outline-secondary btn-sm rounded-pill">Details</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php else: ?>
|
|
<div class="col-12 text-center py-5">
|
|
<p class="text-muted">No cars available at the moment. Please check back later.</p>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</section>
|
|
|
|
<?php include 'partials/footer.php'; ?>
|
|
|
|
<!-- Scripts -->
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
|
</body>
|
|
</html>
|