From 8d996da0d967e517f4fa0437c60c5fe1fcfe37f0 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Mon, 23 Feb 2026 09:05:29 +0000 Subject: [PATCH] sad --- about.php | 73 +++++++ add_car.php | 115 ++++++++++ admin_cars.php | 116 ++++++++++ admin_dashboard.php | 156 ++++++++++++++ admin_messages.php | 86 ++++++++ admin_users.php | 94 ++++++++ assets/css/style.css | 500 +++++++++++++++++++++++++++++++++++++++++++ assets/js/main.js | 48 +---- car_detail.php | 144 +++++++++++++ cars.php | 99 +++++++++ contact.php | 107 +++++++++ dashboard.php | 112 ++++++++++ db/seed_cars.php | 77 +++++++ db/setup.php | 96 +++++++++ edit_car.php | 110 ++++++++++ includes/footer.php | 49 +++++ includes/header.php | 50 +++++ index.php | 266 +++++++++++------------ login.php | 68 ++++++ logout.php | 5 + purchase.php | 106 +++++++++ register.php | 68 ++++++ 22 files changed, 2362 insertions(+), 183 deletions(-) create mode 100644 about.php create mode 100644 add_car.php create mode 100644 admin_cars.php create mode 100644 admin_dashboard.php create mode 100644 admin_messages.php create mode 100644 admin_users.php create mode 100644 assets/css/style.css create mode 100644 car_detail.php create mode 100644 cars.php create mode 100644 contact.php create mode 100644 dashboard.php create mode 100644 db/seed_cars.php create mode 100644 db/setup.php create mode 100644 edit_car.php create mode 100644 includes/footer.php create mode 100644 includes/header.php create mode 100644 login.php create mode 100644 logout.php create mode 100644 purchase.php create mode 100644 register.php diff --git a/about.php b/about.php new file mode 100644 index 0000000..f9968ad --- /dev/null +++ b/about.php @@ -0,0 +1,73 @@ + + +
+

About AfgCars

+

Afghanistan's Premier Marketplace for Luxury & Reliable Vehicles.

+
+ +
+
+
+

Our Mission

+

+ 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. +

+

+ 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. +

+
+
+ Team +
+
+
+ +
+

Our Physical Locations

+
+
+

Kabul Main Showroom

+

Wazir Akbar Khan, Street 15

+

Kabul, Afghanistan

+

+93 700 123 456

+
+
+

Herat Branch

+

Jada-e-Main, Near Blue Mosque

+

Herat, Afghanistan

+

+93 700 987 654

+
+
+

Mazar-i-Sharif Office

+

Balkh Gate Road

+

Mazar-i-Sharif, Afghanistan

+

+93 700 456 789

+
+
+
+ +
+

Why trust us?

+
+
+

500+

+

Premium Cars Sold

+
+
+

24/7

+

Support Availability

+
+
+

100%

+

Verified Sellers

+
+
+

5

+

Major Cities

+
+
+
+ + diff --git a/add_car.php b/add_car.php new file mode 100644 index 0000000..4fe225a --- /dev/null +++ b/add_car.php @@ -0,0 +1,115 @@ +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']; +?> + +
+
+

List Your Vehicle

+

Provide details about your car. Our team will review and approve your listing within 24 hours.

+ + +
+

πŸŽ‰ Listing Submitted!

+

Your car has been sent for approval. You can track its status in your dashboard.

+
+ Go to Dashboard +
+
+ + + +
+ + +
+
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+ +
+ + + For this prototype, please provide a direct link to an image. +
+ +
+ + +
+ +
+ + Cancel +
+
+
+
+ + \ No newline at end of file diff --git a/admin_cars.php b/admin_cars.php new file mode 100644 index 0000000..877b0c5 --- /dev/null +++ b/admin_cars.php @@ -0,0 +1,116 @@ +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(); +?> + + + + + + Manage Cars | Admin + + + +
+ + +
+

Manage Car Listings

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Car DetailsOwnerPriceStatusFeaturedActions
+
+
-
+
$ + + + + + + + + +
+ + Approve + + + Reject + + Delete +
+
+
+
+
+
+ + \ No newline at end of file diff --git a/admin_dashboard.php b/admin_dashboard.php new file mode 100644 index 0000000..1ebfa1d --- /dev/null +++ b/admin_dashboard.php @@ -0,0 +1,156 @@ +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(); + +?> + + + + + + Admin Dashboard | AfgCars + + + + +
+ + + + +
+
+
+

Dashboard Overview

+

Welcome back,

+
+
+ View Site +
+
+ + +
+
+ Total Listings + +
+
+ Pending Approval + +
+
+ Total Users + +
+
+ Purchases + +
+
+ +
+ +
+
+

Recent Car Listings

+ View All +
+
+ + + + + + + + + + + + + + + + + + + + + +
CarOwnerPriceStatusAction
+
+
+
$ + + + + View
+
+
+ + +
+

Recent Messages

+ +

No new messages.

+ +
+ +
+
+ + +
+

+ ... +

+
+ +
+ +
+
+
+
+ + \ No newline at end of file diff --git a/admin_messages.php b/admin_messages.php new file mode 100644 index 0000000..2cd0340 --- /dev/null +++ b/admin_messages.php @@ -0,0 +1,86 @@ +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(); +?> + + + + + + Manage Messages | Admin + + + +
+ + +
+

Customer Inquiries

+ +
+ +
+

No messages found.

+
+ + +
+
+
+

+

From: ()

+
+
+
+ +
+
+
+ +
+ +
+ + +
+
+
+ + \ No newline at end of file diff --git a/admin_users.php b/admin_users.php new file mode 100644 index 0000000..6cc5b31 --- /dev/null +++ b/admin_users.php @@ -0,0 +1,94 @@ +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(); +?> + + + + + + Manage Users | Admin + + + +
+ + +
+

User Management

+ +
+
+ + + + + + + + + + + + + + + + + + + + + +
User InfoRoleStatusJoinedActions
+
+
+
+
+ + Deactivate + + Activate + + Delete +
+
+
+
+
+
+ + \ No newline at end of file diff --git a/assets/css/style.css b/assets/css/style.css new file mode 100644 index 0000000..e4aef31 --- /dev/null +++ b/assets/css/style.css @@ -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; + } +} \ No newline at end of file diff --git a/assets/js/main.js b/assets/js/main.js index d349598..87bae7a 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -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'); - } + }); }); -}); +}); \ No newline at end of file diff --git a/car_detail.php b/car_detail.php new file mode 100644 index 0000000..206b3f6 --- /dev/null +++ b/car_detail.php @@ -0,0 +1,144 @@ +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 "

Car not found.

Back to Marketplace
"; + 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(); +?> + +
+
+
+
+ + 1): ?> +
+ +
+ +
+ + +
+

+ πŸ“œ Detailed Description +

+
+ +
+ +
+
+

Vehicle Condition

+

Excellent / Premium

+
+
+

Transmission

+

Automatic

+
+
+

Fuel Type

+

Petrol / Hybrid

+
+
+

Import Status

+

Custom Cleared

+
+
+
+
+ +
+
+
+ MODEL + πŸ“ , AFG +
+ +

+
$
+ +
+

+ πŸ‘€ Seller: +

+

+ πŸ†” Listing ID: #AFG- +

+
+ + + Initiate Purchase + Add to Favorites + +
+

Interested in this vehicle? Log in to contact the seller.

+ Login to Proceed +
+ + +
+

Share this listing:

+
+ πŸ“± + πŸ’¬ + πŸ“§ +
+
+
+
+
+ + +
+

Similar Premium Vehicles

+
+ +
+
+
+
+
+
+ πŸ“… + πŸ“ +
+

+
$
+ View Details +
+
+ +
+
+ +
+ + diff --git a/cars.php b/cars.php new file mode 100644 index 0000000..64d0490 --- /dev/null +++ b/cars.php @@ -0,0 +1,99 @@ +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']; +?> + +
+

Premium Marketplace

+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + βœ• +
+
+ +
+ +
+
πŸš—πŸ’¨
+

No vehicles found

+

We couldn't find any cars matching your current filters.

+ Clear all filters +
+ + +
+
+
+ +
Hot Deal
+ +
+
+
+ πŸ“… + πŸ“ +
+

+
$
+ View Details +
+
+ + +
+
+ + \ No newline at end of file diff --git a/contact.php b/contact.php new file mode 100644 index 0000000..a26a8f0 --- /dev/null +++ b/contact.php @@ -0,0 +1,107 @@ +prepare("INSERT INTO contact_messages (name, email, subject, message) VALUES (?, ?, ?, ?)"); + if ($stmt->execute([$name, $email, $subject, $message])) { + $success = true; + } +} +?> + +
+

Get in Touch

+

Have questions? Our team is here to help you find the perfect vehicle.

+
+ +
+
+
+
+

+ πŸ“ Visit Us +

+

+ Wazir Akbar Khan, District 10,
+ Kabul, Afghanistan +

+

+93 799 123 456

+
+ +
+

+ πŸ•’ Working Hours +

+
+ Sat - Wed: + 8:00 - 18:00 +
+
+ Thursday: + 8:00 - 13:00 +
+
+ +
+

+ βœ‰οΈ Support Email +

+

info@afgcars.af

+

support@afgcars.af

+
+
+ +
+

Send us a message

+ +
+ ✨ Message sent successfully! Our representative will contact you within 24 hours. +
+ + +
+
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+ +
+
+
+
+ +
+
+ +
+
+
πŸ“
+

Our Location

+

VISIT US IN KABUL

+ Open in Google Maps +
+
+
+ + \ No newline at end of file diff --git a/dashboard.php b/dashboard.php new file mode 100644 index 0000000..978a090 --- /dev/null +++ b/dashboard.php @@ -0,0 +1,112 @@ +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'; +?> + +
+
+
+

Welcome,

+

Manage your car listings and view your purchase history.

+
+ Sign Out +
+ +
+ +
+
+

My Listings

+ + List New Car +
+ + +
+

You haven't listed any cars yet.

+ Start Selling +
+ +
+ +
+
+

+ + + + $ +
+
+ View + Edit +
+
+ +
+ +
+ + +
+

Recent Activity

+
+

Purchase History

+ +

No purchases found.

+ +
+ +
+
+ + $ +
+
+ + Completed +
+
+ +
+ +
+
+
+
+ + \ No newline at end of file diff --git a/db/seed_cars.php b/db/seed_cars.php new file mode 100644 index 0000000..f90ef58 --- /dev/null +++ b/db/seed_cars.php @@ -0,0 +1,77 @@ +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()); +} diff --git a/db/setup.php b/db/setup.php new file mode 100644 index 0000000..4ad10cf --- /dev/null +++ b/db/setup.php @@ -0,0 +1,96 @@ +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()); +} diff --git a/edit_car.php b/edit_car.php new file mode 100644 index 0000000..b141657 --- /dev/null +++ b/edit_car.php @@ -0,0 +1,110 @@ +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']; +?> + +
+
+

Edit Listing

+

Update your vehicle details. Note: editing will reset the status to 'pending' for re-approval.

+ + +
+

✨ Changes Saved!

+

Your listing has been updated and is now pending approval.

+
+ Back to Dashboard +
+
+ + + +
+ + +
+
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+ +
+ + +
+ +
+ + Cancel +
+
+
+
+ + \ No newline at end of file diff --git a/includes/footer.php b/includes/footer.php new file mode 100644 index 0000000..c051a5f --- /dev/null +++ b/includes/footer.php @@ -0,0 +1,49 @@ + + + + \ No newline at end of file diff --git a/includes/header.php b/includes/header.php new file mode 100644 index 0000000..cbb4cb0 --- /dev/null +++ b/includes/header.php @@ -0,0 +1,50 @@ + + + + + + + AfgCars | Premium Marketplace + + + + + + + + + + + \ No newline at end of file diff --git a/index.php b/index.php index 7205f3d..d2a751a 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,124 @@ 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 + ] +]; ?> - - - - - - New Style - - - - - - - - - - - - - - - - - - - - - -
-
-

Analyzing your requirements and generating your website…

-
- Loading… -
-

AI is collecting your requirements and applying the first changes.

-

This page will update automatically as the plan is implemented.

-

Runtime: PHP β€” UTC

+ +
+
+

Find Your Premium Ride

+

Exclusive luxury vehicles and reliable everyday cars in Afghanistan's most trusted marketplace.

+
-
- - - + + +
+

Hot Deals

+
+ +
+
+
+
+
+
+ πŸ“… + πŸ“ +
+

+
$
+ View Details +
+
+ +
+
+ +
+
+

What Our Clients Say

+
+ +
+
+ +
+

""

+
+
+ +
+
+

+

+
+
+
+ +
+
+
+ +
+

Our Physical Showrooms

+
+
+
πŸ“
+

Kabul HQ

+

Wazir Akbar Khan, Street 15

+

+93 700 123 456

+
+
+
πŸ“
+

Herat Branch

+

Jada-e-Main, Near Blue Mosque

+

+93 700 987 654

+
+
+
πŸ“
+

Mazar-i-Sharif

+

Balkh Gate Road

+

+93 700 456 789

+
+
+
+ +
+
+

Ready to sell your car?

+

Join thousands of Afghans who have successfully sold their vehicles through our platform. No hidden fees, just results.

+ Start Listing Now +
+
+ + \ No newline at end of file diff --git a/login.php b/login.php new file mode 100644 index 0000000..ad36adf --- /dev/null +++ b/login.php @@ -0,0 +1,68 @@ +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."; + } +} +?> + +
+
+
+

Welcome Back

+

Sign in to your AfgCars account

+
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+ +
+ +

+ New to AfgCars? Create an account +

+
+
+ + \ No newline at end of file diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..85facf7 --- /dev/null +++ b/logout.php @@ -0,0 +1,5 @@ +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."; + } +} +?> + +
+ +
+
βœ…
+

Request Submitted!

+

+ Your purchase request for the has been sent to our verification team. + Our representative will contact you at within 24 hours to guide you through the offline bank transfer process. +

+
+ Back to Marketplace + Home Page +
+
+ +
+
+

Purchase Summary

+
+

+

Model -

+
+ Total Amount + $ +
+
+ +
+

Complete Your Request

+

Please provide your contact details. This is an offline purchase simulation for the Afghan automotive market.

+ + +
+ + +
+
+ + +
+
+ + +
+ +
+

+ 🏦 Offline Payment Process +

+

+ 1. Submit this purchase request.
+ 2. Wait for admin approval (usually within 24 hours).
+ 3. Visit any Azizi Bank or New Kabul Bank branch.
+ 4. Deposit the total amount into the verified seller's account.
+ 5. Upload the bank receipt to complete the transaction. +

+
+ +
+ + Cancel +
+
+
+
+ +
+ + \ No newline at end of file diff --git a/register.php b/register.php new file mode 100644 index 0000000..46f9bed --- /dev/null +++ b/register.php @@ -0,0 +1,68 @@ +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."; + } + } +} +?> + +
+
+
+

Join AfgCars

+

Create your premium account today

+
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ +

+ Already have an account? Sign in +

+
+
+ + \ No newline at end of file