diff --git a/README.md b/README.md index fd75e90..7646447 100644 --- a/README.md +++ b/README.md @@ -1,95 +1,50 @@ -# AFG CARS - Premium Car Marketplace Afghanistan +# AFG CARS - Premium Car Marketplace Afghanistan (Offline Edition) -Welcome to **AFG CARS**, an enterprise-level automotive marketplace platform specifically designed for the Afghanistan market (2026 Edition). This application provides a seamless experience for buying, selling, and managing vehicle listings with a modern, high-end UI and robust administrative features. - ---- +AFG CARS is a modern, responsive web application for buying and selling cars in Afghanistan. This version is specially prepared to run **completely offline** on a local XAMPP environment. ## 🚀 Key Features +- **Offline Ready**: No internet connection required. All assets (Bootstrap, Icons) are stored locally. +- **Car Listings**: Browse verified car listings across major Afghan cities (Kabul, Herat, etc.). +- **User Authentication**: Secure Login and Registration system. +- **Admin Dashboard**: Comprehensive panel for managing inventory, approvals, users, and sales. +- **User Dashboard**: Manage your own listings and view purchase history. +- **Simulation Systems**: Simulated banking payment and local mail logging. -### 1. Advanced Marketplace -* **Verified Listings:** High-quality vehicle listings with detailed specifications. -* **Smart Search:** Filter by Brand, Model, Year, Location (Kabul, Herat, etc.), and Price range. -* **Badging System:** Visual indicators for "Hot Deals" and "SOLD" status. +## 💻 Installation (XAMPP) -### 2. Role-Based Access Control (RBAC) -* **Guests:** Browse cars, search the market, and view company information. -* **Registered Users:** List their own cars for sale, manage favorites, track purchases, and submit reviews. -* **Administrators:** Full control over listing approvals, user management, sales tracking, and system notifications. +1. **Move Project Folder**: + - Copy the `afg-cars` folder into your XAMPP's `htdocs` directory (usually `C:\xampp\htdocs\`). -### 3. User & Admin Dashboards -* **User Hub:** Track pending/approved listings, manage personal car ads, and view purchase history. -* **Admin Command Center:** Review user-submitted cars for approval, view total revenue, manage users, and receive real-time alerts. +2. **Start Services**: + - Open the XAMPP Control Panel. + - Start **Apache** and **MySQL**. -### 4. Enterprise-Grade Systems -* **Review & Rating System:** Users can rate vehicles and leave feedback for sold items. -* **Simulated Purchase System:** Integrated "Buy Now" flow featuring major Afghanistan banks (DAB, Azizi, AIB, etc.). -* **Contact & Mail Integration:** Functional contact forms using the platform's internal mail service. +3. **Database Setup (Automatic)**: + - Open your browser and go to: `http://localhost/afg-cars/db/setup.php` + - This script will automatically create the `afg_cars` database and all required tables. + - It will also insert a default admin account and sample listings. -### 5. Physical Presence -* Detailed information about physical showrooms in **Kabul, Herat, Mazar-i-Sharif, and Kandahar**. +4. **Database Setup (Manual - Optional)**: + - Go to `http://localhost/phpmyadmin/`. + - Create a database named `afg_cars`. + - Import the `db/database.sql` file. ---- - -## 🛠 Tech Stack - -* **Language:** PHP 8.x (Vanilla) -* **Database:** MariaDB / MySQL (via PDO) -* **Frontend:** Bootstrap 5, Inter Typography, Bi-Icons -* **Styling:** Custom CSS with modern glassmorphism and soft gradient effects -* **AI Integration:** Local AI Proxy for advanced processing -* **Mail Service:** PHPMailer-based `MailService` - ---- - -## ⚙️ Installation & How to Run - -### Prerequisites -* A web server (Apache/Nginx) with PHP 8.x support. -* MariaDB or MySQL database server. - -### Setup Steps -1. **Clone the Repository:** - Place the project files into your web server's document root (e.g., `/var/www/html` or `htdocs`). - -2. **Database Configuration:** - * Open `db/config.php` and update the `DB_HOST`, `DB_NAME`, `DB_USER`, and `DB_PASS` constants to match your local environment. - * Run the database initialization script by visiting `http://your-domain/db/setup.php` in your browser. This will create the necessary tables and seed the initial admin user. - * Alternatively, run `php db/run_migrations.php` from the terminal. - -3. **Environment Variables:** - Ensure your `.env` file (if applicable) contains the necessary mail and AI configuration as described in the system documentation. - -4. **Access the Site:** - Open your browser and navigate to the project root (e.g., `http://localhost`). - ---- - -## 🔐 Default Credentials (Enterprise Edition) - -| Role | Email | Password | -| :--- | :--- | :--- | -| **Admin** | `admin@gmail.com` | `12345678` | - ---- +## 🔐 Default Admin Credentials +- **Email**: `admin@gmail.com` +- **Password**: `12345678` ## 📁 Project Structure +- `admin/`: Admin-specific pages and dashboards. +- `assets/`: Local CSS, JS, and Bootstrap files. +- `db/`: Database configuration, setup script, and SQL schema. +- `includes/`: Reusable header and footer components. +- `mail/`: Offline mail simulation service. +- `user/`: User-specific dashboard and listing management. -* `index.php` - Enterprise landing page with "Hot Deals" and Hero section. -* `cars.php` - Marketplace search and listing page. -* `admin/` - Administrative dashboard and management scripts. -* `user/` - Registered user dashboard and car submission area. -* `db/` - Database configuration, setup scripts, and migrations. -* `includes/` - Reusable UI components (Header, Footer). -* `assets/` - CSS, JS, and image assets. -* `mail/` - Integrated mail service logic. +## 🛠 Troubleshooting +- **Database Connection Error**: Ensure MySQL is running in XAMPP. Check `db/config.php` if you have changed the default XAMPP MySQL credentials (default is `root` with no password). +- **Broken Layout**: Ensure the `assets/bootstrap/` folder contains the required CSS and JS files. +- **Page Not Found**: Ensure you are accessing the project via `http://localhost/afg-cars/`. ---- - -## 📄 License & Notes - -This project is built for the **Flatlogic LAMP VM**. -* **Reminder:** Always click **Save** in the Flatlogic editor to sync changes to the platform. -* **SEO:** Every page is optimized with unique meta titles and descriptions for maximum visibility. - ---- -*Last Updated: February 13, 2026* +## 🎓 University Project Note +This system is designed as a university final-year project to demonstrate full-stack web development capabilities using PHP, MySQL, and Bootstrap, with a focus on local enterprise deployment. \ No newline at end of file diff --git a/admin/add-car.php b/admin/add-car.php index 82359b5..fc97a58 100644 --- a/admin/add-car.php +++ b/admin/add-car.php @@ -3,31 +3,33 @@ session_start(); require_once __DIR__ . '/../db/config.php'; if (!isset($_SESSION['role']) || $_SESSION['role'] !== 'admin') { - header('Location: /login.php'); + header('Location: ' . APP_URL . 'login.php'); exit; } -$message = ''; -if ($_SERVER['REQUEST_METHOD'] === 'POST') { - $title = $_POST['title'] ?? ''; - $brand = $_POST['brand'] ?? ''; - $model = $_POST['model'] ?? ''; - $year = $_POST['year'] ?? ''; - $price = $_POST['price'] ?? ''; - $location = $_POST['location'] ?? ''; - $fuel_type = $_POST['fuel_type'] ?? ''; - $transmission = $_POST['transmission'] ?? ''; - $mileage = $_POST['mileage'] ?? ''; - $description = $_POST['description'] ?? ''; - $image_url = $_POST['image_url'] ?? ''; - $badge = $_POST['badge'] ?? NULL; +$pdo = db(); +$error = ''; +$success = ''; - $pdo = db(); - $stmt = $pdo->prepare("INSERT INTO cars (owner_id, title, brand, model, year, price, location, fuel_type, transmission, mileage, description, image_url, approval_status, badge) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'approved', ?)"); - if ($stmt->execute([$_SESSION['user_id'], $title, $brand, $model, $year, $price, $location, $fuel_type, $transmission, $mileage, $description, $image_url, $badge])) { - $message = "success"; - } else { - $message = "error"; +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $title = $_POST['title']; + $brand = $_POST['brand']; + $model = $_POST['model']; + $year = $_POST['year']; + $price = $_POST['price']; + $location = $_POST['location']; + $fuel = $_POST['fuel_type']; + $transmission = $_POST['transmission']; + $mileage = $_POST['mileage']; + $desc = $_POST['description']; + $image = $_POST['image']; // In a real app, handle file upload + + try { + $stmt = $pdo->prepare("INSERT INTO cars (title, brand, model, year, price, location, fuel_type, transmission, mileage, description, image, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'approved')"); + $stmt->execute([$title, $brand, $model, $year, $price, $location, $fuel, $transmission, $mileage, $desc, $image]); + $success = "Car added successfully!"; + } catch (PDOException $e) { + $error = "Error: " . $e->getMessage(); } } ?> @@ -36,105 +38,74 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
-Manage your enterprise car marketplace.
+Marketplace Administration (Offline Mode)
| Customer | Car | Amount | Bank |
|---|---|---|---|
| - | - | $ | -- |
| Customer | Car | Amount | Date |
|---|---|---|---|
| + | + | $ | ++ |