SaaS Lottery WinGo - Same-Domain Fix
====================================

This build keeps every browser-side lottery request on the website's current
origin. On https://7lottrey.55ak.xyz the expected requests are:

  /api-live-v4/Lottery/GetGameList
  /api-live-v4/Lottery/GetGameInfo
  /api-live-v4/Lottery/GetUserInfo
  /api-live-v4/Lottery/GetBalance
  /draw-live-v4/WinGo/WinGo_30S.json
  /draw-live-v4/WinGo/WinGo_30S/GetHistoryIssuePage.json

The frontend no longer converts the site origin into api.55ak.xyz or
draw.55ak.xyz. It also ignores stale saved SaaS API hosts and uses the current
origin for both authenticated lottery API calls and public draw JSON.

Deployment
----------

1. Upload and extract the complete ZIP in the domain document root.
2. Preserve api-live-v4/.htaccess, draw-live-v4/.htaccess and
   assets/.htaccess (hidden files must be uploaded too).
3. Apache must have mod_rewrite enabled and AllowOverride permitted.
4. After upload, clear the site's/CDN's cached JS if applicable and open the
   page in an incognito window or perform a hard refresh.

Expected route mapping
----------------------

  /api-live-v4/Lottery/<Action>
    -> api-live-v4/Lottery/index.php?action=<Action>

  /draw-live-v4/<Lottery>/<GameCode>.json
    -> draw-live-v4/index.php?lottery=<Lottery>&gameCode=<GameCode>

  /draw-live-v4/<Lottery>/<GameCode>/GetHistoryIssuePage.json
    -> draw-live-v4/index.php?lottery=<Lottery>&gameCode=<GameCode>&history=1

Real draw and history sync
--------------------------

- WinGo, K3, 5D, TrxWinGo and MotoRace use the AR014 public draw feed
  (https://draw.ar-lottery01.com) as the authoritative source.
- Browser requests stay on this installation's own versioned API/draw paths; the
  PHP draw adapter fetches the public feed server-side.
- Current/previous periods and history results are not generated from the
  server clock or local random-result engine.
- Game history matches Lottery7: 10 records per page, 50 pages, 500 records.
- Local-random fallback is disabled while authoritative sync is enabled. A
  temporary upstream failure returns a service error instead of showing a
  different or fabricated period/result.
- Frontend and server both enforce 10 history rows and 50 pages.
- Manual/admin result overrides and local-random fallback are disabled.
- Versioned routes and module cache-busting prevent an older deployed response
  from being reused.

Deployment check
----------------

After extracting the complete ZIP and replacing existing files, open:

  https://YOUR-DOMAIN/real-sync-v4-check.php

Expected values include:

  build: 20260729-real-sync-v4-moto
  sameOriginApiRoute: /api-live-v4
  sameOriginDrawRoute: /draw-live-v4
  manualResultControl: false
  historyContract.rowsPerPage: 10
  historyContract.totalPage: 50
  historyContract.totalCount: 500

If the build value is missing, the complete V4 ZIP did not overwrite the old
deployment. Upload every folder from this package, especially assets,
api-live-v4, draw-live-v4, saas_lottery and codexhub.
