# Deploying to telegram.aviobull.live

The project is portable — it uses relative paths and detects its own URL, so no code changes are needed. You only have to put the files in the right place and point the subdomain at the `public/` folder.

## Step 1 — Create the subdomain
cPanel → **Domains** (or **Subdomains**) → Create a new subdomain:
- Subdomain: `telegram`
- Domain: `aviobull.live`
- **Document Root:** set it to `telegram.aviobull.live/public`  ← important

cPanel usually suggests a document root like `/home/spacexpr/telegram.aviobull.live`. Change it (or note it) so the **public** folder is the web root. Two layouts work:

### Option A (recommended — source code outside the web root)
```
/home/spacexpr/telegram.aviobull.live/        ← upload the whole project here
    ├── public/      ← set this as the subdomain Document Root
    ├── src/
    ├── config/
    ├── database/
    ├── bin/
    └── storage/
```
Set the subdomain's Document Root to `/home/spacexpr/telegram.aviobull.live/public`.
Only `public/` is reachable from the web; `config/`, `src/`, etc. sit above it and are private. This is the safest.

### Option B (if cPanel won't let you set the root above the public files)
Put the **contents of `public/`** directly in the subdomain folder, and the rest in a sibling private folder. If you use this, open `public/webhook.php`, `cron.php`, `install.php`, and the `bin/*.php` files and change `dirname(__DIR__)` to point at wherever you placed `src/`, `config/`, etc. (Option A avoids this entirely — prefer it.)

## Step 2 — Upload
Upload and extract the ZIP so you get the structure in Option A. (cPanel → File Manager → Upload → Extract.)

## Step 3 — Run the web installer
Open **https://telegram.aviobull.live/install.php** and follow the 5 steps:
1. Bot token + database details (it tests the connection)
2. Create tables & seed data
3. Enter your Telegram ID (from @userinfobot) to become admin
4. Connect the bot to Telegram (sets the webhook to `https://telegram.aviobull.live/webhook.php?secret=...` automatically)
5. Done

## Step 4 — After install
- In the bot: **Admin → Settings** → set deposit addresses.
- Add the once-per-minute cron (cPanel → Cron Jobs):
  `/usr/local/bin/php /home/spacexpr/telegram.aviobull.live/bin/worker.php >> /home/spacexpr/telegram.aviobull.live/storage/logs/cron.log 2>&1`
  No cron? Use a free pinger to call `https://telegram.aviobull.live/cron.php?secret=<WEBHOOK_SECRET>` every minute.
- **Delete `public/install.php`** from the server.

## Security notes
- The included `public/.htaccess` only allows `webhook.php`, `cron.php`, and `install.php` to run; it blocks direct access to any other PHP in the web root.
- With Option A, your `config/config.php` (DB password, bot token) lives above the web root and is never served.
