BETWIN - INSTALL GUIDE (cPanel)
================================
1. cPanel > MySQL Databases: create a database + user, add user to database (ALL PRIVILEGES).
2. cPanel > MultiPHP Manager: choose PHP 8.1 or newer for the domain.
3. File Manager > public_html (or the sub-domain / sub-folder root):
   upload and Extract, in this order:
     betwin-site.zip     (code + installer)  <- required
     betwin-media-1.zip  (game images)
     betwin-media-2.zip  (other images, music)
   All three extract into the same folder.
4. Open  https://YOUR-URL/install/   and fill: site URL, DB login, admin e-mail + password.
5. Open  https://YOUR-URL/dash/login  and log in with the admin e-mail.
6. Delete the install folder (button on the last installer page).
7. Admin panel: add game-provider and payment keys; import games.
Notes: DB schema was rebuilt from the code (original dump was not in the zips).
Maintenance scripts are in _tools/ (blocked from the web).

UPDATE FOR AN ALREADY-INSTALLED SITE (sub-folder fix, v2)
---------------------------------------------------------
1. Upload betwin-site.zip into the SAME folder and Extract (overwrite). Your .env and data are kept.
2. Open  https://YOUR-URL/install/  and click "Apply update".
   (If the page shows the normal install form instead, fill it in and tick
    "Use existing tables" - nothing is deleted.)
3. Open the site / admin panel with Ctrl+F5 (clear cache).
If a page is still blank: set APP_DEBUG=1 in .env, reload, and read php_errors.log
(or the error shown on screen) - then send it to me.

If the admin page is blank or the user panel shows red X errors: open /install/ and press 'Run diagnostics'.
Admin pages now print fatal errors on screen once you are logged in.

v3 NOTES
--------
* Admin crash "mysqli_stmt::get_result()": cPanel > Select PHP Version > Extensions: untick "mysqli", tick "nd_mysqli", Save.
* "Apply update" also imports ~1,950 games the first time (only if the games table is empty).
* Press Ctrl+F5 after updating (the app JS is cached by the browser).

v4 NOTES
--------
* After updating, test the site in a PRIVATE/incognito tab (or clear the site data once) so the browser does not use the old cached JS.
* Open  https://YOUR-URL/?debug=1  to see JS errors / failed API calls on screen.

v5 NOTES
--------
* The sub-folder (e.g. /m) is now detected from the real file location; APP_URL only needs the domain.
* Coupon creation SQL bug fixed (column/value count mismatch in the original code).

v6 NOTES
--------
* The frontend folder was renamed yq-br-prod -> app-v5 so browsers cannot reuse old cached JS.
  You may delete the old yq-br-prod folder from the server after updating.

v7 NOTES
--------
* After extracting, open /install/ and press "Apply update" (applies patch_002.sql: empty text columns instead of NULL).
* deposit_bkash.php / deposit_nagad.php / webhook.php were DISABLED (originals in /_disabled/): they used somebody
  else's payment account, gave "demo" users free balance and used tables that do not exist here.
  Connect your own gateway before enabling bKash/Nagad deposits.
* Import tools (fishImport.php, importGameJson.php, gamesAdd.php, ...) are active again but need an admin login.
* Several front-end endpoints (promotions, feedback, phone binding) have no server code in the package;
  they now answer with empty/"not available" results instead of errors.

v8 NOTES (bonus system)
-----------------------
* New admin pages (sidebar > TOOLS): "Assign Bonus" (12 bonus types, credits the balance, ledger in bonus_log)
  and "Bonus Campaigns" (campaign settings + automatic Daily Level Promo codes).
* Daily promo: add the cron line shown on the "Bonus Campaigns" page (cPanel > Cron Jobs). Codes are normal coupons,
  redeemed with the gift button; rules can be limited by VIP level.
* install/sql/patch_003_bonus_promo.sql creates: bonus_types, bonus_log, daily_promo_*, bonus_campaign_settings,
  agent_deposit_settings, vip_xp_settings, vip_xp_awards (+ cupom.vip_min/vip_max). Run "Apply update" once.
* Not wired to the player site yet: VIP XP awarding, campaign claims (daily/weekly/birthday...), agent deposit wallets.
