Files
tlw-database-tool/docs/tippligaforum.md
T

2.5 KiB

tippligaforum — MySQL & phpBB Integration

Database connector, config loader, website HTTP client, and forum post management.

Classes

TippligaSQLConnector

Singleton JDBC connector to the phpBB MySQL database (d0144ddb). Connects to production via credentials from environment variables, with a fallback to localhost.

All major queries in one class:

  • getTeams(), getMatches(), getMatchdays(), getLeague() — read domain objects
  • getUpdatedMatchdaysBasedOnMatches() — complex SQL that computes delivery deadlines from match times (uses DATEDIFF to split deadlines across days/weeks)
  • getNextWhatsAppReminders(hours) — multi-table query finding users with missing bets on upcoming matchdays, joins with reminder tracking to avoid duplicates
  • updatePost() / getPost() / getChecksumOfPost() — phpBB post CRUD
  • executeQuery() / executeUpdate() — raw SQL access
  • markWhatsAppReminderAsSent() — logs sent reminders

Post updates use the phpBB checksum mechanism: post_checksum = MD5 of XML-escaped post text.

TippligaConfigProvider

Reads JSON configuration from phpBB forum posts. Configs are stored as topics under the Admin → Tippliga-Config → <season> forum hierarchy.

  • getTippligaConfig(config) — fetches post, strips [code] BBCode wrapper, parses JSON
  • getChecksumOfConfigPost(configFile) — reads post checksum for integrity verification

TippligaWebsiteConnector

HTTP client that logs into the phpBB frontend + admin panel and submits match results. Used by TLWMatchesResultsUpdater.

Login flow:

  1. GET login page → extract creation_time, form_token, sid from hidden fields
  2. POST credentials → capture session cookies
  3. GET admin panel → extract admin credential token
  4. POST admin login with password_<credential> parameter

Result submission:

  1. GET results management page → extract CSRF tokens
  2. POST form with season, league, matchday, match scores (home, guest, overtime)

MatchesListCreator

Generates a JSON match list config from raw API-Football fixture data (read from S3). Creates SingleMatch config entries with matchday, matchtime, team names, and fixture IDs. Used by MatchesListForumUpdater to create fixture list forum posts.

MatchesListForumUpdater

For each league:

  1. Creates MatchesListCreator from S3 fixture data
  2. Formats as pretty-printed JSON
  3. Wraps in [code] BBCode
  4. Finds the correct forum post (under Admin → Tippliga-Config → <season> → Ligen → <country> <league>)
  5. Updates the post text via TippligaSQLConnector