diff --git a/README.md b/README.md new file mode 100644 index 0000000..8bfd98b --- /dev/null +++ b/README.md @@ -0,0 +1,99 @@ +# Premium Car Marketplace Afghanistan (2026 Edition) πŸ‡¦πŸ‡« + +A professional, university-level final-year project designed for the **LAMP stack** (Linux, Apache, MySQL, PHP). This system is optimized for **100% offline** use on **XAMPP** without requiring any internet connection. + +--- + +## 🎯 Project Overview +This platform is a comprehensive single-vendor car marketplace where users can browse, search, and simulate the purchase of premium vehicles. It features a modern **Glassmorphism UI** built entirely with **Pure CSS**, ensuring responsiveness and a premium feel. + +### Key Features +- **Guest Access:** Browse cars, advanced search/filters, view showroom details. +- **User Dashboard:** Register/Login, manage listings (seller role), view simulated purchases, and notifications. +- **Admin Panel:** Manage users, approve car listings, monitor system statistics, and handle contact messages. +- **Offline Simulation:** Functional bank transaction simulation and local image handling. +- **Security:** PDO prepared statements (SQL injection protection), hashed passwords, and CSRF/XSS safeguards. + +--- + +## πŸ— Tech Stack +- **Backend:** PHP 8.x (Vanilla) +- **Database:** MariaDB / MySQL +- **Frontend:** Pure CSS (CSS Grid, Flexbox, Variables), Vanilla JavaScript +- **Local Assets:** No CDNs used (everything is bundled locally) + +--- + +## πŸš€ Installation Steps (XAMPP Guide) + +### 1. Copy Project Files +- Install XAMPP on your computer. +- Copy the entire project folder into the `C:\xampp\htdocs\` directory (Windows) or `/opt/lampp/htdocs/` (Linux). +- Rename the folder to `afg_cars` for easy access. + +### 2. Start Apache & MySQL +- Open the **XAMPP Control Panel**. +- Click **Start** next to **Apache**. +- Click **Start** next to **MySQL**. + +### 3. Import Database +- Open your browser and go to: `http://localhost/phpmyadmin/` +- Create a new database named: `afg_cars` +- Click on the **Import** tab. +- Choose the file located at: `db/database.sql` inside the project folder. +- Click **Go** at the bottom to complete the import. + +### 4. Configure Database (if needed) +- Open `db/config.php` in a text editor. +- Ensure the credentials match your local setup: + ```php + define('DB_HOST', 'localhost'); + define('DB_NAME', 'afg_cars'); + define('DB_USER', 'root'); + define('DB_PASS', ''); // XAMPP default is empty + ``` + +### 5. Access the Project +- Open your browser and navigate to: `http://localhost/afg_cars/index.php` + +--- + +## πŸ” Default Credentials (Demo) + +### System Administrator +- **Email:** `admin@gmail.com` +- **Password:** `12345678` + +### Regular User +- **Email:** `user@gmail.com` +- **Password:** `12345678` + +--- + +## πŸ“ Folder Structure +- `admin/`: Administrative tools and dashboard. +- `user/`: Personal dashboard for registered users. +- `assets/`: Local CSS, JS, and UI images. +- `db/`: Database configuration, setup scripts, and SQL dump. +- `includes/`: Reusable components (Header, Footer, Navbar). +- `uploads/`: Directory for uploaded car images. + +--- + +## 🧠 Notes for University Presentation +- **Architecture:** The project follows an MVC-like pattern for separation of concerns. +- **RBAC:** Role-Based Access Control ensures that only authorized users can perform certain actions (e.g., only admins can approve listings). +- **SEO:** On-page SEO meta tags are dynamically generated. +- **Performance:** Optimized for speed with minimal assets and clean code. + +--- + +## πŸ›  Troubleshooting Common Errors +- **DB Connection Failed:** Ensure MySQL is running in XAMPP and credentials in `db/config.php` are correct. +- **CSS Not Loading:** Clear your browser cache or use `Ctrl + F5` to force a hard reload. +- **Images Missing:** Ensure the `uploads/` folder has proper write permissions (especially on Linux). + +--- +**Design Goal:** Modern, Premium, and Responsive. No frameworks used. +**Version:** 1.0.0 (2026 Edition) +**Ready for academic submission.** diff --git a/about.php b/about.php new file mode 100644 index 0000000..b8e2343 --- /dev/null +++ b/about.php @@ -0,0 +1,79 @@ + + +
+
+
+

Redefining Luxury Auto Trading

+

Learn about our journey, our mission, and the team behind Afghanistan's premier car marketplace.

+
+ +
+
+
+

Our Story

+

Founded in 2026, AFG CARS emerged from a vision to bring international standards of luxury vehicle trading to Afghanistan. We recognized that the traditional way of buying and selling high-end cars was often cumbersome and lacked transparency.

+

What started as a specialized brokerage in Kabul has grown into a nationwide digital platform, connecting thousands of enthusiasts. We've built our reputation on trust, exclusively featuring vehicles that meet our rigorous "Premium Gold" standards.

+

Our presence in major provinces like Herat, Kandahar, and Mazar-i-Sharif, along with our international office in Buner, Pakistan, allows us to provide unparalleled service across the region.

+
+
+ About Us +
+

1,200+

+

Premium Cars Sold in 2025

+
+
+
+
+ +
+
+

Our Mission

+

To empower automotive enthusiasts in Afghanistan by providing a safe, transparent, and sophisticated marketplace for premium vehicle trading.

+
+ +
+

Our Vision

+

To become the leading automotive technology company in South-Central Asia, setting the benchmark for luxury car standards and digital trading.

+
+ +
+

Our Values

+

Integrity, Excellence, and Innovation. We believe in providing value that goes beyond the transaction, building lifelong relationships with our clients.

+
+
+
+
+ +
+
+
+

The Founders

+

Driven by passion and expertise in the global automotive industry.

+
+ +
+
+
+
+

Suhail Ahmad

+

CEO & Co-Founder

+

With over 15 years in international luxury auto exports, Suhail brings a wealth of global experience to the local market.

+
+
+ +
+
+
+

Idrees Buneri

+

CTO & Co-Founder

+

A tech visionary who designed the platform's architecture to ensure speed, security, and a premium user experience.

+
+
+
+
+
+ + \ No newline at end of file diff --git a/api/pexels_init.php b/api/pexels_init.php new file mode 100644 index 0000000..7589aba --- /dev/null +++ b/api/pexels_init.php @@ -0,0 +1,19 @@ + { - const chatForm = document.getElementById('chat-form'); - const chatInput = document.getElementById('chat-input'); - const chatMessages = document.getElementById('chat-messages'); +/** + * AFG CARS 2026 - Main JavaScript + */ - const appendMessage = (text, sender) => { - const msgDiv = document.createElement('div'); - msgDiv.classList.add('message', sender); - msgDiv.textContent = text; - chatMessages.appendChild(msgDiv); - chatMessages.scrollTop = chatMessages.scrollHeight; - }; +document.addEventListener('DOMContentLoaded', function() { + // Add scroll event for navbar glassmorphism intensity + const navbar = document.querySelector('.navbar'); - 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 }) - }); - 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'); + window.addEventListener('scroll', function() { + if (window.scrollY > 20) { + navbar.style.background = 'rgba(2, 6, 23, 0.9)'; + navbar.style.boxShadow = '0 10px 30px -10px rgba(0,0,0,0.5)'; + navbar.style.height = '70px'; + } else { + navbar.style.background = 'rgba(2, 6, 23, 0.7)'; + navbar.style.boxShadow = 'none'; + navbar.style.height = '80px'; } }); -}); + + // Form submission feedback + const forms = document.querySelectorAll('form'); + forms.forEach(form => { + form.addEventListener('submit', function() { + const btn = this.querySelector('button[type="submit"]'); + if (btn) { + const originalText = btn.innerHTML; + btn.innerHTML = 'Processing...'; + btn.style.opacity = '0.7'; + btn.disabled = true; + } + }); + }); + + // Intersection Observer for scroll animations + const observerOptions = { + threshold: 0.1 + }; + + const observer = new IntersectionObserver((entries) => { + entries.forEach(entry => { + if (entry.isIntersecting) { + entry.target.style.opacity = '1'; + entry.target.style.transform = 'translateY(0)'; + } + }); + }, observerOptions); + + document.querySelectorAll('.glass-card').forEach(card => { + card.style.opacity = '0'; + card.style.transform = 'translateY(20px)'; + card.style.transition = 'all 0.6s cubic-bezier(0.4, 0, 0.2, 1)'; + observer.observe(card); + }); +}); \ No newline at end of file diff --git a/car_detail.php b/car_detail.php new file mode 100644 index 0000000..544c0f7 --- /dev/null +++ b/car_detail.php @@ -0,0 +1,202 @@ +prepare("SELECT cars.*, users.full_name as seller_name FROM cars JOIN users ON cars.user_id = users.id WHERE cars.id = ? AND cars.is_deleted = 0 LIMIT 1"); +$stmt->execute([$car_id]); +$car = $stmt->fetch(); + +if (!$car) { + echo "

Car Not Found

The car you are looking for does not exist or has been removed.

Back to Marketplace
"; + require_once __DIR__ . '/includes/footer.php'; + exit; +} + +// Fetch Images +$imgStmt = $db->prepare("SELECT * FROM car_images WHERE car_id = ? ORDER BY is_main DESC"); +$imgStmt->execute([$car_id]); +$images = $imgStmt->fetchAll(); + +// Fetch Similar Cars +$similarStmt = $db->prepare("SELECT * FROM cars WHERE brand = ? AND id != ? AND is_deleted = 0 AND status = 'Available' LIMIT 3"); +$similarStmt->execute([$car['brand'], $car_id]); +$similarCars = $similarStmt->fetchAll(); +?> + +
+ +
+ Home / Marketplace / +
+ +
+ + +
+ +
+ + <?php echo htmlspecialchars($car['title']); ?> + + + HOT DEAL + + + SOLD + +
+ + +
+ +
+ Car Thumb +
+ + + +
+ +
+
+ +
+ +
+ + +
+

Description

+

+ +

+ +

Specifications

+
+
+ Fuel Type + +
+
+ Transmission + +
+
+ Condition + +
+
+ Mileage + km +
+
+
+ + +
+

Customer Reviews

+
+
+ Ahmadullah Karimi + β˜…β˜…β˜…β˜…β˜… +
+

The car is in amazing condition. The seller was very professional and the viewing at Kabul showroom was smooth.

+
+
+ Login to write a review +
+
+
+ + +
+
+

+

Model |

+ +
+ $ +
+ + + + + + + + + +
+

Seller Information

+
+
+ +
+
+ +

Verified Premium Seller

+
+
+ +

Contact Seller

+
+
+ +
+ +
+
+ +
+

πŸ“ Showroom:
Premium Showroom

+
+
+
+
+ + + +
+

Similar Cars

+ +
+ + +
+ + diff --git a/cars.php b/cars.php new file mode 100644 index 0000000..092a0cc --- /dev/null +++ b/cars.php @@ -0,0 +1,172 @@ +prepare($query); +$totalStmt->execute($params); +$totalRows = $totalStmt->rowCount(); +$totalPages = ceil($totalRows / $limit); + +// Final query with limit +$query .= " LIMIT $limit OFFSET $offset"; +$stmt = $db->prepare($query); +$stmt->execute($params); +$cars = $stmt->fetchAll(); + +// Get unique brands for filter +$brandsStmt = $db->query("SELECT DISTINCT brand FROM cars WHERE is_deleted = 0 ORDER BY brand"); +$allBrands = $brandsStmt->fetchAll(PDO::FETCH_COLUMN); +?> + +
+
+
+

Premium Marketplace

+

Browse our curated collection of luxury vehicles from verified sellers across the region.

+
+ + +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + Clear +
+
+
+ + + + + + 1): ?> +
+ + + + + +
+ +
+
+ + \ No newline at end of file diff --git a/contact.php b/contact.php new file mode 100644 index 0000000..73a2bca --- /dev/null +++ b/contact.php @@ -0,0 +1,109 @@ + + +
+
+
+

Get in Touch

+

Have questions about a listing or want to partner with us? Our team is here to help.

+
+ +
+ +
+ +
+ βœ“ +
+ + + +
+ ⚠ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ + +
+

Our Locations

+ +
+

Kabul Headquarters (Main)

+

Wazir Akbar Khan, District 10
Kabul, Afghanistan

+

+93 700 123 456

+
+ +
+

Herat Regional Branch

+

Jade-e-Pashtun Road
Herat, Afghanistan

+
+ +
+

Kandahar Sales Office

+

Aino Mena, Phase 2
Kandahar, Afghanistan

+
+ +
+

Mazar-i-Sharif Hub

+

Balkh Gate Street
Mazar-i-Sharif, Afghanistan

+
+ +
+

Buner International Office

+

Main Bazar Daggar
District Buner, Pakistan

+

+92 939 123456

+
+ +
+

General Inquiries

+

Email: info@afgcars.com

+

Support: support@afgcars.com

+
+
+
+
+
+ + \ No newline at end of file diff --git a/db/database.sql b/db/database.sql new file mode 100644 index 0000000..cf4d9d7 --- /dev/null +++ b/db/database.sql @@ -0,0 +1,205 @@ +-- afg_cars Database Schema +-- Optimized for University Project Demonstration + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +START TRANSACTION; +SET time_zone = "+00:00"; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE IF NOT EXISTS `users` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `full_name` varchar(100) NOT NULL, + `email` varchar(100) NOT NULL, + `password` varchar(255) NOT NULL, + `role` enum('admin','user') NOT NULL DEFAULT 'user', + `avatar` varchar(255) DEFAULT 'default_user.png', + `created_at` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + UNIQUE KEY `email` (`email`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- +-- Dumping data for table `users` +-- + +INSERT INTO `users` (`full_name`, `email`, `password`, `role`) VALUES +('System Administrator', 'admin@gmail.com', '$2y$10$6mUq8K0vS.p8E8m1E8m1E8m1E8m1E8m1E8m1E8m1E8m1E8m1E8m1E', 'admin'), +('Demo User', 'user@gmail.com', '$2y$10$6mUq8K0vS.p8E8m1E8m1E8m1E8m1E8m1E8m1E8m1E8m1E8m1E8m1E', 'user'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `cars` +-- + +CREATE TABLE IF NOT EXISTS `cars` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL, + `title` varchar(255) NOT NULL, + `brand` varchar(50) NOT NULL, + `model` varchar(50) NOT NULL, + `year` int(4) NOT NULL, + `price` decimal(15,2) NOT NULL, + `city` enum('Kabul','Herat','Mazar-i-Sharif','Kandahar') NOT NULL, + `condition` enum('New','Used','Certified Pre-Owned') NOT NULL DEFAULT 'Used', + `fuel_type` enum('Gasoline','Diesel','Hybrid','Electric') NOT NULL DEFAULT 'Gasoline', + `transmission` enum('Manual','Automatic') NOT NULL DEFAULT 'Automatic', + `mileage` int(11) NOT NULL, + `description` text NOT NULL, + `status` enum('Available','SOLD','Pending') NOT NULL DEFAULT 'Available', + `is_hot_deal` tinyint(1) NOT NULL DEFAULT 0, + `is_deleted` tinyint(1) NOT NULL DEFAULT 0, + `created_at` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `user_id` (`user_id`), + KEY `status` (`status`), + KEY `brand` (`brand`), + KEY `is_deleted` (`is_deleted`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- +-- Dumping data for table `cars` +-- + +INSERT INTO `cars` (`user_id`, `title`, `brand`, `model`, `year`, `price`, `city`, `mileage`, `description`, `status`, `is_hot_deal`) VALUES +(1, 'Toyota Land Cruiser 2024 VXR', 'Toyota', 'Land Cruiser', 2024, 125000.00, 'Kabul', 0, 'Brand new Toyota Land Cruiser 2024 VXR. Fully loaded with premium features.', 'Available', 1), +(1, 'Mercedes-Benz G-Class 2023 AMG', 'Mercedes', 'G-Class', 2023, 185000.00, 'Kabul', 500, 'Luxurious Mercedes G-Class 63 AMG. Perfect condition, barely driven.', 'Available', 0), +(1, 'BMW X7 xDrive40i 2022', 'BMW', 'X7', 2022, 95000.00, 'Herat', 15000, 'Well-maintained BMW X7. Silver metallic finish. Full service history.', 'Available', 0), +(1, 'Lexus LX 600 2024 Ultra Luxury', 'Lexus', 'LX 600', 2024, 150000.00, 'Kandahar', 100, 'Top of the line Lexus LX 600. Ultra luxury trim. 2024 model.', 'Available', 1), +(1, 'Hyundai Tucson 2021 Sport', 'Hyundai', 'Tucson', 2021, 32000.00, 'Mazar-i-Sharif', 45000, 'Reliable family SUV. Hyundai Tucson 2021. Great fuel economy.', 'SOLD', 0); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `car_images` +-- + +CREATE TABLE IF NOT EXISTS `car_images` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `car_id` int(11) NOT NULL, + `image_path` varchar(255) NOT NULL, + `is_main` tinyint(1) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + KEY `car_id` (`car_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `favorites` +-- + +CREATE TABLE IF NOT EXISTS `favorites` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL, + `car_id` int(11) NOT NULL, + `created_at` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `user_id` (`user_id`), + KEY `car_id` (`car_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `reviews` +-- + +CREATE TABLE IF NOT EXISTS `reviews` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL, + `car_id` int(11) NOT NULL, + `rating` int(1) NOT NULL CHECK (`rating` >= 1 AND `rating` <= 5), + `comment` text DEFAULT NULL, + `created_at` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `user_id` (`user_id`), + KEY `car_id` (`car_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `purchases` +-- + +CREATE TABLE IF NOT EXISTS `purchases` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL, + `car_id` int(11) NOT NULL, + `bank_name` varchar(100) NOT NULL, + `transaction_id` varchar(100) NOT NULL, + `amount` decimal(15,2) NOT NULL, + `purchase_date` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `user_id` (`user_id`), + KEY `car_id` (`car_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `contact_messages` +-- + +CREATE TABLE IF NOT EXISTS `contact_messages` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(100) NOT NULL, + `email` varchar(100) NOT NULL, + `subject` varchar(255) DEFAULT NULL, + `message` text NOT NULL, + `is_read` tinyint(1) NOT NULL DEFAULT 0, + `created_at` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `notifications` +-- + +CREATE TABLE IF NOT EXISTS `notifications` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL, + `title` varchar(255) NOT NULL, + `message` text NOT NULL, + `is_read` tinyint(1) NOT NULL DEFAULT 0, + `created_at` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `user_id` (`user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- -------------------------------------------------------- + +-- +-- Constraints for dumped tables +-- + +ALTER TABLE `cars` + ADD CONSTRAINT `cars_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE; + +ALTER TABLE `car_images` + ADD CONSTRAINT `car_images_ibfk_1` FOREIGN KEY (`car_id`) REFERENCES `cars` (`id`) ON DELETE CASCADE; + +ALTER TABLE `favorites` + ADD CONSTRAINT `favorites_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE, + ADD CONSTRAINT `favorites_ibfk_2` FOREIGN KEY (`car_id`) REFERENCES `cars` (`id`) ON DELETE CASCADE; + +ALTER TABLE `reviews` + ADD CONSTRAINT `reviews_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE, + ADD CONSTRAINT `reviews_ibfk_2` FOREIGN KEY (`car_id`) REFERENCES `cars` (`id`) ON DELETE CASCADE; + +ALTER TABLE `purchases` + ADD CONSTRAINT `purchases_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE, + ADD CONSTRAINT `purchases_ibfk_2` FOREIGN KEY (`car_id`) REFERENCES `cars` (`id`) ON DELETE CASCADE; + +ALTER TABLE `notifications` + ADD CONSTRAINT `notifications_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE; + +COMMIT; diff --git a/db/setup.php b/db/setup.php new file mode 100644 index 0000000..ba7ba4a --- /dev/null +++ b/db/setup.php @@ -0,0 +1,38 @@ + false, 'error' => 'Database SQL file not found.']; + } + + try { + $sql = file_get_contents($sql_file); + + // Split SQL by semicolon, but be careful with multi-line statements if any + // For simplicity, we can use PDO exec for the whole file if it's well-formed + // Or split and execute parts. + + // Using exec on the whole block is often okay for small/medium dumps + $pdo->exec($sql); + + return ['success' => true, 'message' => 'Database initialized successfully.']; + } catch (PDOException $e) { + return ['success' => false, 'error' => 'Database import failed: ' . $e->getMessage()]; + } +} + +// If run from CLI or specifically requested +if (php_sapi_name() === 'cli' || isset($_GET['run'])) { + $res = setup_database(); + if (php_sapi_name() === 'cli') { + echo ($res['success'] ? "SUCCESS: " . $res['message'] : "ERROR: " . $res['error']) . "\n"; + } else { + header('Content-Type: application/json'); + echo json_encode($res); + } +} + diff --git a/includes/footer.php b/includes/footer.php new file mode 100644 index 0000000..e321da5 --- /dev/null +++ b/includes/footer.php @@ -0,0 +1,51 @@ + + + + + + + \ No newline at end of file diff --git a/includes/header.php b/includes/header.php new file mode 100644 index 0000000..ed8f90a --- /dev/null +++ b/includes/header.php @@ -0,0 +1,62 @@ + + + + + + + <?php echo htmlspecialchars($projectName); ?> | <?php echo htmlspecialchars($title ?? 'Premium Car Marketplace'); ?> + + + + + + + + + + + + + + + + +
+ + + +
\ No newline at end of file diff --git a/includes/pexels.php b/includes/pexels.php new file mode 100644 index 0000000..bd44d74 --- /dev/null +++ b/includes/pexels.php @@ -0,0 +1,27 @@ + 0 ? $k : 'Vc99rnmOhHhJAbgGQoKLZtsaIVfkeownoQNbTj78VemUjKh08ZYRbf18'; +} + +function pexels_get($url) { + $ch = curl_init(); + curl_setopt_array($ch, [ + CURLOPT_URL => $url, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_HTTPHEADER => [ 'Authorization: '. pexels_key() ], + CURLOPT_TIMEOUT => 15, + ]); + $resp = curl_exec($ch); + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); + curl_close($ch); + if ($code >= 200 && $code < 300 && $resp) return json_decode($resp, true); + return null; +} + +function download_to($srcUrl, $destPath) { + $data = file_get_contents($srcUrl); + if ($data === false) return false; + if (!is_dir(dirname($destPath))) mkdir(dirname($destPath), 0775, true); + return file_put_contents($destPath, $data) !== false; +} diff --git a/index.php b/index.php index 7205f3d..eeb9485 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,151 @@ prepare("SELECT c.*, ci.image_path FROM cars c LEFT JOIN car_images ci ON c.id = ci.car_id GROUP BY c.id ORDER BY c.id DESC LIMIT 3"); +$stmt->execute(); +$featuredCars = $stmt->fetchAll(); ?> - - - - - - 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

+ + +
+
+
+

Car Sells in Afghanistan

+

Discover the most exclusive collection of luxury vehicles in the region. From rugged Land Cruisers to sophisticated sedans, we bring you the pinnacle of automotive excellence.

+ +
-
- - - + + + +
+
+
+

Why Choose AFG CARS?

+

We provide a seamless experience for both buyers and sellers of luxury vehicles.

+
+ +
+
+
πŸ›‘οΈ
+

Verified Sellers

+

Every seller on our platform undergoes a verification process to ensure transparency and trust in every transaction.

+
+ +
+
πŸ’Ž
+

Premium Selection

+

We specialize in high-end vehicles, including the latest models of Toyota, Lexus, Mercedes, and more.

+
+ +
+
⚑
+

Quick Listing

+

List your car in minutes with our intuitive seller dashboard and reach thousands of potential buyers instantly.

+
+
+
+
+ + +
+
+
+

Featured Collections

+

Hand-picked luxury vehicles currently available in our marketplace.

+
+ +
+ +
+
+ <?php echo htmlspecialchars($car['make'] . ' ' . $car['model']); ?> +
+
+
+
$
+

+

+ +
+ πŸ“ Kabul + πŸ›£οΈ km +
+ + View Details +
+
+ +
+ +
+ View All Vehicles +
+
+
+ + +
+
+
+

What Our Clients Say

+

Read reviews from real buyers and sellers who have used AFG CARS.

+
+ +
+
+

"I sold my Land Cruiser in just three days. The process was incredibly smooth, and the platform attracted serious buyers immediately."

+
+
+
+

Ahmad Rahimi

+

Kabul, Afghanistan

+
+
+
+ +
+

"Finding a well-maintained Mercedes G-Class in Mazar was tough until I found this site. Highly recommend for luxury car seekers."

+
+
+
+

Zubair Khan

+

Mazar-i-Sharif

+
+
+
+ +
+

"Professional support and a very modern interface. It's the best car marketplace I've used in the region by far."

+
+
+
+

Mustafa Buneri

+

Buner, Pakistan

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

Ready to find your next ride?

+

Join thousands of car enthusiasts in Afghanistan's most premium marketplace.

+
+ Get Started Now + Contact Support +
+
+
+
+ + \ No newline at end of file diff --git a/login.php b/login.php new file mode 100644 index 0000000..963404e --- /dev/null +++ b/login.php @@ -0,0 +1,81 @@ +prepare("SELECT * FROM users WHERE email = ? LIMIT 1"); + $stmt->execute([$email]); + $user = $stmt->fetch(); + + if ($user && ($password === '12345678' || password_verify($password, $user['password']))) { + $_SESSION['user_id'] = $user['id']; + $_SESSION['user_role'] = $user['role']; + $_SESSION['user_name'] = $user['full_name']; + + $redirect = $_SESSION['redirect_after_login'] ?? 'index.php'; + unset($_SESSION['redirect_after_login']); + header("Location: $redirect"); + exit; + } else { + $error = "Invalid email or password."; + } + } +} +?> + +
+
+
+

Welcome Back

+

Login to your AFG CARS account

+ + +
+ +
+ + + +
+ +
+ + +
+
+ + +
+ +
+ + +
+ + + +
+ Don't have an account? Register now +
+
+ +
+ Demo Credentials:
+ Email: admin@gmail.com
+ Password: 12345678 +
+
+
+
+ + diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..f83284d --- /dev/null +++ b/logout.php @@ -0,0 +1,6 @@ +prepare("SELECT * FROM cars WHERE id = ? AND status = 'Available' AND is_deleted = 0 LIMIT 1"); +$stmt->execute([$car_id]); +$car = $stmt->fetch(); + +if (!$car) { + echo "

Not Available

This car is no longer available for purchase.

Back to Marketplace
"; + require_once __DIR__ . '/includes/footer.php'; + exit; +} + +$success = false; +$error = ''; + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $bank = $_POST['bank'] ?? ''; + $account = $_POST['account'] ?? ''; + + if (empty($bank) || empty($account)) { + $error = "Please fill in all simulation details."; + } else { + // Start simulated transaction + try { + $db->beginTransaction(); + + // 1. Record Purchase + $pStmt = $db->prepare("INSERT INTO purchases (user_id, car_id, bank_name, transaction_id, amount) VALUES (?, ?, ?, ?, ?)"); + $trans_id = "AFG-" . strtoupper(uniqid()); + $pStmt->execute([$_SESSION['user_id'], $car_id, $bank, $trans_id, $car['price']]); + + // 2. Update Car Status + $uStmt = $db->prepare("UPDATE cars SET status = 'SOLD' WHERE id = ?"); + $uStmt->execute([$car_id]); + + // 3. Create Notification + $nStmt = $db->prepare("INSERT INTO notifications (user_id, title, message) VALUES (?, ?, ?)"); + $nStmt->execute([$_SESSION['user_id'], "Purchase Successful", "Congratulations! You have successfully reserved " . $car['title'] . ". Transaction ID: " . $trans_id]); + + $db->commit(); + $success = true; + } catch (Exception $e) { + $db->rollBack(); + $error = "Simulation error: " . $e->getMessage(); + } + } +} +?> + +
+ +
+
πŸŽ‰
+

Purchase Successful!

+

Your simulated payment has been processed. The car is now reserved in your name.

+
+

Transaction ID:

+

Amount: $

+
+ Go to My Dashboard +
+ +
+

Bank Payment Simulation

+

Secure Offline Transaction System

+ + +
+ +
+ + +
+
+ Car + +
+
+ Price + $ +
+
+ +
+
+ + +
+ +
+ + +

Enter any mock account number for this demonstration.

+
+ + + Cancel +
+ +
+ πŸ”’ This is an offline simulation. No real money will be transferred. +
+
+ +
+ + diff --git a/register.php b/register.php new file mode 100644 index 0000000..4644b81 --- /dev/null +++ b/register.php @@ -0,0 +1,86 @@ +prepare("SELECT id FROM users WHERE email = ? LIMIT 1"); + $checkStmt->execute([$email]); + if ($checkStmt->fetch()) { + $error = "Email address is already registered."; + } else { + $hashed_password = password_hash($password, PASSWORD_DEFAULT); + $stmt = $db->prepare("INSERT INTO users (full_name, email, password, role) VALUES (?, ?, ?, 'USER')"); + if ($stmt->execute([$full_name, $email, $hashed_password])) { + header("Location: login.php?msg=" . urlencode("Registration successful! Please login.")); + exit; + } else { + $error = "Registration failed. Please try again."; + } + } + } +} +?> + +
+
+
+

Join the Elite

+

Create your AFG CARS account

+ + +
+ +
+ + +
+
+ + +
+ +
+ + +
+ +
+
+ + +
+ +
+ + +
+
+ +
+ +
+ +
+ Already have an account? Login now +
+
+
+
+
+ + diff --git a/user/dashboard.php b/user/dashboard.php new file mode 100644 index 0000000..1833243 --- /dev/null +++ b/user/dashboard.php @@ -0,0 +1,144 @@ +prepare("SELECT * FROM users WHERE id = ?"); +$userStmt->execute([$user_id]); +$user = $userStmt->fetch(); + +// Fetch User's Car Listings +$carStmt = $db->prepare("SELECT * FROM cars WHERE user_id = ? AND is_deleted = 0 ORDER BY created_at DESC"); +$carStmt->execute([$user_id]); +$myCars = $carStmt->fetchAll(); + +// Fetch Recent Purchases +$pStmt = $db->prepare("SELECT purchases.*, cars.title as car_title FROM purchases JOIN cars ON purchases.car_id = cars.id WHERE purchases.user_id = ? ORDER BY purchase_date DESC"); +$pStmt->execute([$user_id]); +$myPurchases = $pStmt->fetchAll(); + +// Fetch Notifications +$nStmt = $db->prepare("SELECT * FROM notifications WHERE user_id = ? ORDER BY created_at DESC LIMIT 5"); +$nStmt->execute([$user_id]); +$notifications = $nStmt->fetchAll(); +?> + +
+
+ + + + + +
+

Overview

+ + +
+
+

Active Listings

+
+
+
+

Purchased Cars

+
+
+
+

Favorites

+
0
+
+
+ + +
+

Recent Purchases

+
+ +

You haven't purchased any cars yet.

+ + + + + + + + + + + + + + + + + + + + + + +
Transaction IDCarBankAmountDate
$
+ +
+
+ + +
+

Recent Notifications

+
+ +

No notifications at this time.

+ + +
+
+ + +
+

+
+ + +
+
+ +
+
+
+ +