═══════════════════════════════════════════════════════════════
 APISEVA v2.0 — Premium DarkXen Portal
 Installation & Upgrade Guide
═══════════════════════════════════════════════════════════════

📁 FILE STRUCTURE:
─────────────────────────────────────────────────────────────
/home/apisevax/public_html/
├── config/
│   ├── dbconfig.php          ← DB credentials (EDIT THIS)
│   └── config.php            ← Main config + all functions
├── includes/
│   ├── header.php            ← Common header (sidebar + topbar)
│   └── footer.php            ← Footer + JS
├── assets/
│   └── css/
│       └── darkxen.css       ← DarkXen 3D Glassmorphism theme
├── ajax/
│   ├── payment_ajax.php      ← TheMonkeyPay QR + wallet credit
│   └── profile_ajax.php      ← API key regenerate + profile update
├── API_Seva/
│   ├── index.php             ← Dashboard (role-based: Admin/Dist/User)
│   ├── addwallet.php         ← Wallet + QR recharge
│   ├── credentials.php       ← API key + IP whitelist
│   ├── transaction_record.php← Transactions (Success/Failed tabs)
│   ├── listofusers.php       ← Admin: Users list + Go-to-Login
│   ├── profile.php           ← Profile & settings
│   ├── system_update.php     ← Auto-update system
│   └── return_to_admin.php   ← Return from user impersonation
├── database/
│   └── migration_v2.sql      ← New tables SQL
├── login.php                 ← Login page (working backend)
└── logout.php                ← Logout

═══════════════════════════════════════════════════════════════
🔧 INSTALLATION STEPS (FRESH or UPGRADE):
═══════════════════════════════════════════════════════════════

STEP 1: BACKUP FIRST!
──────────────────────
- Download full backup of /public_html/ via cPanel
- Export database backup from phpMyAdmin

STEP 2: RUN SQL MIGRATION
──────────────────────────
- Open phpMyAdmin → database: apisevax_working
- Go to SQL tab
- Copy-paste contents of database/migration_v2.sql
- Click "Go"

STEP 3: UPLOAD FILES
────────────────────
Upload via cPanel File Manager or FTP:

- config/config.php      → /public_html/config/
- includes/header.php    → /public_html/includes/
- includes/footer.php    → /public_html/includes/
- assets/css/darkxen.css → /public_html/assets/css/
- ajax/payment_ajax.php  → /public_html/ajax/
- ajax/profile_ajax.php  → /public_html/ajax/
- API_Seva/*.php          → /public_html/API_Seva/
- login.php              → /public_html/
- logout.php             → /public_html/

⚠️ DO NOT overwrite config/dbconfig.php (keep your existing one)

STEP 4: VERIFY
───────────────
- Open: https://api.apiseva.xyz/login.php
- Login with admin credentials
- Check dashboard loads
- Check wallet QR works
- Check credentials page → regenerate works

═══════════════════════════════════════════════════════════════
✅ FEATURES INCLUDED:
═══════════════════════════════════════════════════════════════

1. Role-Based Dashboards (Admin / Distributor / User)
2. Live stats from database (hits today, revenue, balance)
3. TheMonkeyPay QR wallet recharge (auto-credit fix)
4. API Key regenerate (AJAX - no page hang)
5. IP Whitelist (working)
6. Transactions — Success/Failed separate tabs
7. Admin → Users list with "Go to Login" (impersonation)
8. Return to Admin button when impersonating
9. System Update (Admin uploads ZIP → users click update)
10. DarkXen 3D Glassmorphism premium design
11. Mobile responsive with hamburger sidebar toggle
12. SweetAlert2 notifications
13. Password change with bcrypt security
14. Profile update via AJAX

═══════════════════════════════════════════════════════════════
⚠️ IMPORTANT NOTES:
═══════════════════════════════════════════════════════════════

- Payment Gateway: pg.paymentgateway.co.in (Corex/Razorpay Space)
  Set in config.php lines 20-23:
  PG_API_BASE = https://merchant.razorpay.space/api/v1
  PG_USERNAME = 8298201899
  PG_API_KEY = 8ee985fc719e23b27d9d7aba1aebb0de19fc8e49edc20b3d
  
  ⚠️ IMPORTANT: After upload, go to pg.paymentgateway.co.in → 
  API Settings → Whitelisted IP → Add your APISEVA server IP
  Also set Webhook Callback URL to:
  https://api.apiseva.xyz/ajax/payment_callback.php

- Telegram Bot Token: Set in config.php line 26
  Currently empty — add your bot token

- SITE_URL: Set in config.php line 11
  Currently: https://api.apiseva.xyz
  Change to match your domain

- Existing files (providers.php, services.php, routing.php etc)
  are NOT overwritten — they continue to work as before
  This update only adds NEW premium pages

═══════════════════════════════════════════════════════════════
