# DexProtectX Commercial Bot — Setup Guide

## Folder Structure (php/)
```
php/
├── config.php          ← Main configuration (edit this first!)
├── db.php              ← Database auto-setup
├── points.php          ← Points logic (hold/deduct/refund)
├── fonts.php           ← Font management
├── bot.php             ← Telegram webhook (main entry)
├── worker.php          ← Background APK protection worker
├── heartbeat.php       ← Heartbeat pinger
├── owner_panel.php     ← Owner web dashboard
├── setup_webhook.php   ← One-time webhook register
└── .htaccess           ← Security rules
```

## Step 1 — Edit config.php
```php
define('OWNER_ID',   7554081592);        // Your Telegram numeric ID
define('BOT_TOKEN',  'YOUR_BOT_TOKEN');  // From @BotFather
define('DB_NAME',    'dexprotect_bot');  // Your MySQL DB name
define('DB_USER',    'root');            // MySQL username
define('DB_PASS',    '');                // MySQL password
```

## Step 2 — Create MySQL Database
Create a database named `dexprotect_bot` on your hosting.
Tables will be **auto-created** on first run!

## Step 3 — Upload to Server
Upload the entire `php/` folder to your hosting (e.g. public_html/php/)

## Step 4 — Register Webhook
Open in browser:
```
https://yourdomain.com/php/setup_webhook.php?url=https://yourdomain.com/php/bot.php
```

## Step 5 — Open Owner Panel
```
https://yourdomain.com/php/owner_panel.php
Password: slex@owner2024  (change in owner_panel.php line 9!)
```

---

## How the System Works

### Roles
| Role  | What they can do |
|-------|-----------------|
| Owner | Add admins, add points, see all stats, upload fonts |
| Admin | Use bot to protect APKs (costs 200 points each) |

### Points Flow
```
Owner adds points → Admin's balance increases
Admin sends APK  → 200 pts put ON HOLD (can't use held points!)
APK processing   → Points stay on hold
APK ready ✅     → Points DEDUCTED from balance
APK fails ❌     → Points REFUNDED back (hold released)
Timeout 30min ⏰  → Points AUTO-REFUNDED
```

### Bot Commands
**Admin Commands:**
- `/start` — Welcome + balance
- `/balance` — Points balance
- `/stats` — 24h protection stats
- `/history` — Last 10 jobs

**Owner Commands (in bot):**
- `/addadmin [telegram_id]` — Register new admin
- `/addpoints [id] [amount]` — Give points to admin
- `/listadmins` — List all admins
- `/listfonts` — List all fonts
- Send TTF/OTF file → Auto-uploads font

### Font System
- 10 fonts pre-loaded (Roboto, Open Sans, Montserrat, Lato, Poppins — Bold & Italic)
- Owner can upload custom fonts via bot OR owner panel
- Bot auto-detects font keywords in APK name and renames output accordingly

### Per APK Cost
- `200 points` per protection
- Points go on hold when job starts
- APK must be ready within **30 minutes** or auto-refund
