# LiveScore Admin Panel — Setup Guide

Pure PHP, no composer required. Compatible with PHP 7.4+.

---

## 1. Upload the folder

Upload the entire `/admin/` folder to your web server alongside your existing project:

```
/                     ← your project root
├── api/
├── config/
├── core/
├── miniapp/
└── admin/            ← place this here
    ├── index.php     ← entry point
    ├── config.php    ← set your DB creds here
    ├── auth.php
    ├── includes/
    └── pages/
```

---

## 2. Configure the database

Edit `admin/config.php` and set your database credentials:

```php
define('DB_HOST', 'localhost');
define('DB_PORT', '3306');
define('DB_NAME', 'earnhuun_score');
define('DB_USER', 'your_db_user');     // ← your actual DB user
define('DB_PASS', 'your_db_password'); // ← your actual DB password
```

---

## 3. Access the panel

Visit: `https://yourdomain.com/admin/`

**Default admin credentials** (from your database):
- Email: `admin@livescore.com`
- Password: (set in `admin_users` table — hash: `$2y$10$M4hMo/lMtE...`)

> To set a new password, run this in phpMyAdmin or MySQL:
> ```sql
> UPDATE admin_users
> SET password_hash = '$2y$10$YOUR_BCRYPT_HASH'
> WHERE email = 'admin@livescore.com';
> ```
> Generate a bcrypt hash using: `echo password_hash('your_password', PASSWORD_BCRYPT);` in PHP.

---

## 4. Admin Panel Features

| Page          | What you can do |
|---------------|-----------------|
| Dashboard     | Overview stats, recent users, pending withdrawals, activity feed |
| Users         | Search/view users, grant/deduct points, set premium tier |
| Fixtures      | Filter by status/date/league, edit scores, add/delete match events |
| Leagues       | Full CRUD — add, edit, delete leagues |
| Teams         | Full CRUD — add, edit, delete teams |
| Quests        | Full CRUD — create quest definitions with rewards |
| Achievements  | Full CRUD — create achievement triggers |
| Predictions   | View all predictions, manually verify correct/incorrect |
| Payments      | View Telegram Stars payments + ad reward history |
| Withdrawals   | Approve (with TX hash), reject (auto-refund points), or mark complete |
| Notifications | View queue, retry failed, clear failed batch |
| Settings      | Edit all app settings inline, quick toggle for maintenance mode |
| Admin Logs    | Full audit trail of all admin actions |

---

## 5. Security Recommendations

- Restrict `/admin/` access by IP in your `.htaccess` or Nginx config
- Use HTTPS (SSL certificate) — required for session security
- Change the default admin password immediately
- The `includes/` and `pages/` subdirectories are protected from direct browser access

---

## 6. No dependencies needed

- ✅ Pure PHP (no Composer, no frameworks)
- ✅ Bootstrap 5 via CDN
- ✅ Bootstrap Icons via CDN  
- ✅ PDO MySQLi (built-in PHP extension)
- ✅ PHP sessions (built-in)
- ✅ CSRF protection built-in
