diff --git a/config/vhost/vhost.conf b/config/vhost/vhost.conf new file mode 100755 index 0000000..b82c1cc --- /dev/null +++ b/config/vhost/vhost.conf @@ -0,0 +1,91 @@ +docRoot $VH_ROOT/public_html +vhDomain $VH_NAME +vhAliases www.$VH_NAME +adminEmails admin@tomtomgames.com +enableGzip 1 +enableIpGeo 1 + +index { + useServer 0 + indexFiles index.php, index.html +} + +errorlog $VH_ROOT/logs/$VH_NAME.error_log { + useServer 0 + logLevel WARN + rollingSize 10M +} + +accesslog $VH_ROOT/logs/$VH_NAME.access_log { + useServer 0 + logFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" + logHeaders 5 + rollingSize 10M + keepDays 10 + compressArchive 1 +} + +scripthandler { + add lsapi:tomto8868 php +} + +extprocessor tomto8868 { + type lsapi + address UDS://tmp/lshttpd/tomto8868.sock + maxConns 10 + env LSAPI_CHILDREN=10 + initTimeout 600 + retryTimeout 0 + persistConn 1 + pcKeepAliveTimeout 1 + respBuffer 0 + autoStart 1 + path /usr/local/lsws/lsphp85/bin/lsphp + extUser tomto8868 + extGroup tomto8868 + memSoftLimit 1024M + memHardLimit 1024M + procSoftLimit 400 + procHardLimit 500 +} + +phpIniOverride { + +} + +module cache { + storagePath /usr/local/lsws/cachedata/$VH_NAME +} + +rewrite { + enable 1 + autoLoadHtaccess 1 +} + +context /.well-known/acme-challenge { + location /usr/local/lsws/Example/html/.well-known/acme-challenge + allowBrowse 1 + + rewrite { + enable 0 + } + addDefaultCharset off + + phpIniOverride { + + } +} + + +vhssl { + keyFile /etc/letsencrypt/live/tomtomgames.com/privkey.pem + certFile /etc/letsencrypt/live/tomtomgames.com/fullchain.pem + certChain 1 + sslProtocol 24 + enableECDHE 1 + renegProtection 1 + sslSessionCache 1 + enableSpdy 15 + enableStapling 1 + ocspRespMaxAge 86400 +} diff --git a/config/vhost/vhost.conf.txt b/config/vhost/vhost.conf.txt new file mode 100755 index 0000000..2c3f7e7 --- /dev/null +++ b/config/vhost/vhost.conf.txt @@ -0,0 +1,85 @@ +adminemails admin@tomtomgames.com +enablegzip 1 +vhaliases www.$VH_NAME +docroot $VH_ROOT/public_html +vhdomain $VH_NAME +enableipgeo 1 +phpinioverride + +scripthandler { + add lsapi:tomto8868 php +} + +extprocessor tomto8868 { + type lsapi + address UDS://tmp/lshttpd/tomto8868.sock + maxconns 10 + env LSAPI_CHILDREN=10 + inittimeout 600 + retrytimeout 0 + persistconn 1 + pckeepalivetimeout 1 + respbuffer 0 + autostart 1 + path /usr/local/lsws/lsphp85/bin/lsphp + extuser tomto8868 + extgroup tomto8868 + memsoftlimit 1024M + memhardlimit 1024M + procsoftlimit 400 + prochardlimit 500 +} + +errorlog $VH_ROOT/logs/$VH_NAME.error_log { + useserver 0 + loglevel WARN + rollingsize 10M +} + +vhssl { + keyfile /etc/letsencrypt/live/tomtomgames.com/privkey.pem + certfile /etc/letsencrypt/live/tomtomgames.com/fullchain.pem + certchain 1 + sslprotocol 24 + enableecdhe 1 + renegprotection 1 + sslsessioncache 1 + enablespdy 15 + enablestapling 1 + ocsprespmaxage 86400 +} + +index { + useserver 0 + indexfiles index.php, index.html +} + +accesslog $VH_ROOT/logs/$VH_NAME.access_log { + keepdays 10 + compressarchive 1 + logformat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" + logheaders 5 + rollingsize 10M + useserver 0 +} + +module cache { + param storagepath /usr/local/lsws/cachedata/$VH_NAME + unknownkeywords storagepath /usr/local/lsws/cachedata/$VH_NAME +} + +rewrite { + enable 1 + autoloadhtaccess 1 +} + +context /.well-known/acme-challenge { + adddefaultcharset off + phpinioverride + location /usr/local/lsws/Example/html/.well-known/acme-challenge + allowbrowse 1 + + rewrite { + enable 0 + } +} diff --git a/config/vhost/vhost.conf0 b/config/vhost/vhost.conf0 new file mode 100755 index 0000000..b82c1cc --- /dev/null +++ b/config/vhost/vhost.conf0 @@ -0,0 +1,91 @@ +docRoot $VH_ROOT/public_html +vhDomain $VH_NAME +vhAliases www.$VH_NAME +adminEmails admin@tomtomgames.com +enableGzip 1 +enableIpGeo 1 + +index { + useServer 0 + indexFiles index.php, index.html +} + +errorlog $VH_ROOT/logs/$VH_NAME.error_log { + useServer 0 + logLevel WARN + rollingSize 10M +} + +accesslog $VH_ROOT/logs/$VH_NAME.access_log { + useServer 0 + logFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" + logHeaders 5 + rollingSize 10M + keepDays 10 + compressArchive 1 +} + +scripthandler { + add lsapi:tomto8868 php +} + +extprocessor tomto8868 { + type lsapi + address UDS://tmp/lshttpd/tomto8868.sock + maxConns 10 + env LSAPI_CHILDREN=10 + initTimeout 600 + retryTimeout 0 + persistConn 1 + pcKeepAliveTimeout 1 + respBuffer 0 + autoStart 1 + path /usr/local/lsws/lsphp85/bin/lsphp + extUser tomto8868 + extGroup tomto8868 + memSoftLimit 1024M + memHardLimit 1024M + procSoftLimit 400 + procHardLimit 500 +} + +phpIniOverride { + +} + +module cache { + storagePath /usr/local/lsws/cachedata/$VH_NAME +} + +rewrite { + enable 1 + autoLoadHtaccess 1 +} + +context /.well-known/acme-challenge { + location /usr/local/lsws/Example/html/.well-known/acme-challenge + allowBrowse 1 + + rewrite { + enable 0 + } + addDefaultCharset off + + phpIniOverride { + + } +} + + +vhssl { + keyFile /etc/letsencrypt/live/tomtomgames.com/privkey.pem + certFile /etc/letsencrypt/live/tomtomgames.com/fullchain.pem + certChain 1 + sslProtocol 24 + enableECDHE 1 + renegProtection 1 + sslSessionCache 1 + enableSpdy 15 + enableStapling 1 + ocspRespMaxAge 86400 +} diff --git a/config/vhost/vhost.conf0,v b/config/vhost/vhost.conf0,v new file mode 100755 index 0000000..9b2b861 --- /dev/null +++ b/config/vhost/vhost.conf0,v @@ -0,0 +1,130 @@ +head 1.2; +access; +symbols; +locks + root:1.2; strict; +comment @# @; + + +1.2 +date 2026.05.16.13.11.17; author root; state Exp; +branches; +next 1.1; + +1.1 +date 2026.05.15.20.01.17; author root; state Exp; +branches; +next ; + + +desc +@/usr/local/lsws/conf/vhosts/tomtomgames.com/vhost.conf0 +@ + + +1.2 +log +@Update +@ +text +@docRoot $VH_ROOT/public_html +vhDomain $VH_NAME +vhAliases www.$VH_NAME +adminEmails admin@@tomtomgames.com +enableGzip 1 +enableIpGeo 1 + +index { + useServer 0 + indexFiles index.php, index.html +} + +errorlog $VH_ROOT/logs/$VH_NAME.error_log { + useServer 0 + logLevel WARN + rollingSize 10M +} + +accesslog $VH_ROOT/logs/$VH_NAME.access_log { + useServer 0 + logFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" + logHeaders 5 + rollingSize 10M + keepDays 10 + compressArchive 1 +} + +scripthandler { + add lsapi:tomto8868 php +} + +extprocessor tomto8868 { + type lsapi + address UDS://tmp/lshttpd/tomto8868.sock + maxConns 10 + env LSAPI_CHILDREN=10 + initTimeout 600 + retryTimeout 0 + persistConn 1 + pcKeepAliveTimeout 1 + respBuffer 0 + autoStart 1 + path /usr/local/lsws/lsphp85/bin/lsphp + extUser tomto8868 + extGroup tomto8868 + memSoftLimit 1024M + memHardLimit 1024M + procSoftLimit 400 + procHardLimit 500 +} + +phpIniOverride { + +} + +module cache { + storagePath /usr/local/lsws/cachedata/$VH_NAME +} + +rewrite { + enable 1 + autoLoadHtaccess 1 +} + +context /.well-known/acme-challenge { + location /usr/local/lsws/Example/html/.well-known/acme-challenge + allowBrowse 1 + + rewrite { + enable 0 + } + addDefaultCharset off + + phpIniOverride { + + } +} + + +vhssl { + keyFile /etc/letsencrypt/live/tomtomgames.com/privkey.pem + certFile /etc/letsencrypt/live/tomtomgames.com/fullchain.pem + certChain 1 + sslProtocol 24 + enableECDHE 1 + renegProtection 1 + sslSessionCache 1 + enableSpdy 15 + enableStapling 1 + ocspRespMaxAge 86400 +} +@ + + +1.1 +log +@Update +@ +text +@d79 13 +@ diff --git a/db/schema.sql b/db/schema.sql new file mode 100644 index 0000000..82cf691 --- /dev/null +++ b/db/schema.sql @@ -0,0 +1,429 @@ +/*M!999999\- enable the sandbox mode */ + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +DROP TABLE IF EXISTS `activity_log`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `activity_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) DEFAULT NULL, + `admin_id` int(11) DEFAULT NULL, + `action` varchar(80) NOT NULL, + `category` varchar(40) DEFAULT 'general', + `entity_type` varchar(40) DEFAULT NULL, + `entity_id` int(11) DEFAULT NULL, + `detail` text DEFAULT NULL, + `old_value` text DEFAULT NULL, + `new_value` text DEFAULT NULL, + `ip` varchar(45) DEFAULT NULL, + `user_agent` varchar(300) DEFAULT NULL, + `page` varchar(200) DEFAULT NULL, + `session_id` varchar(64) DEFAULT NULL, + `severity` enum('info','warning','critical') DEFAULT 'info', + `created_at` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `idx_created` (`created_at`), + KEY `idx_user` (`user_id`) +) ENGINE=InnoDB AUTO_INCREMENT=356 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `admin_payout_settings`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `admin_payout_settings` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `method_key` varchar(50) NOT NULL, + `label` varchar(100) NOT NULL, + `method_type` enum('manual','square_gift_card') DEFAULT 'manual', + `is_enabled` tinyint(1) DEFAULT 1, + `handle` varchar(200) DEFAULT NULL, + `instructions` text DEFAULT NULL, + `sort_order` int(11) DEFAULT 0, + PRIMARY KEY (`id`), + UNIQUE KEY `method_key` (`method_key`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `app_version`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `app_version` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `version` varchar(20) NOT NULL, + `notes` text DEFAULT NULL, + `created_at` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `broadcast_reads`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `broadcast_reads` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `broadcast_id` int(11) NOT NULL, + `user_id` int(11) NOT NULL, + `read_at` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + UNIQUE KEY `uq_br` (`broadcast_id`,`user_id`), + KEY `user_id` (`user_id`), + CONSTRAINT `broadcast_reads_ibfk_1` FOREIGN KEY (`broadcast_id`) REFERENCES `broadcasts` (`id`) ON DELETE CASCADE, + CONSTRAINT `broadcast_reads_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `broadcast_replies`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `broadcast_replies` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `broadcast_id` int(11) NOT NULL, + `user_id` int(11) NOT NULL, + `message` text NOT NULL, + `created_at` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `broadcast_id` (`broadcast_id`), + KEY `user_id` (`user_id`), + CONSTRAINT `broadcast_replies_ibfk_1` FOREIGN KEY (`broadcast_id`) REFERENCES `broadcasts` (`id`) ON DELETE CASCADE, + CONSTRAINT `broadcast_replies_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `broadcasts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `broadcasts` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `admin_id` int(11) NOT NULL, + `subject` varchar(200) NOT NULL, + `message` text NOT NULL, + `target` enum('all','verified','unverified','admins') DEFAULT 'all', + `sent_at` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `admin_id` (`admin_id`), + CONSTRAINT `broadcasts_ibfk_1` FOREIGN KEY (`admin_id`) REFERENCES `users` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `cashout_method_types`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `cashout_method_types` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `slug` varchar(50) NOT NULL, + `label` varchar(100) NOT NULL, + `icon` varchar(10) DEFAULT '?', + `description` varchar(200) DEFAULT NULL, + `is_active` tinyint(1) DEFAULT 1, + `sort_order` int(11) DEFAULT 0, + `created_at` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + UNIQUE KEY `slug` (`slug`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `cashout_requests`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `cashout_requests` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL, + `platform_id` varchar(50) NOT NULL, + `alias` varchar(100) NOT NULL, + `payout_method_type` varchar(50) DEFAULT NULL, + `payout_handle` varchar(200) DEFAULT NULL, + `tokens` decimal(10,2) NOT NULL, + `status` enum('pending','approved','sent','rejected','deleted') DEFAULT 'pending', + `admin_note` text DEFAULT NULL, + `sent_note` text DEFAULT NULL, + `created_at` datetime DEFAULT current_timestamp(), + `resolved_at` datetime DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `user_id` (`user_id`), + CONSTRAINT `cashout_requests_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `cashout_transactions`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `cashout_transactions` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `cashout_id` int(11) NOT NULL, + `admin_id` int(11) NOT NULL, + `payout_method` varchar(50) NOT NULL, + `payout_type` enum('manual','square_gift_card') DEFAULT 'manual', + `amount_cents` int(11) NOT NULL, + `square_txn_id` varchar(200) DEFAULT NULL, + `gift_card_gan` varchar(100) DEFAULT NULL, + `gift_card_balance` int(11) DEFAULT NULL, + `note` text DEFAULT NULL, + `status` enum('pending','completed','failed') DEFAULT 'pending', + `created_at` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `cashout_id` (`cashout_id`), + CONSTRAINT `cashout_transactions_ibfk_1` FOREIGN KEY (`cashout_id`) REFERENCES `cashout_requests` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `chat_messages`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `chat_messages` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL, + `sender` enum('user','admin') NOT NULL, + `message` text NOT NULL, + `is_read` tinyint(1) DEFAULT 0, + `created_at` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `user_id` (`user_id`), + CONSTRAINT `chat_messages_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `game_aliases`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `game_aliases` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL, + `platform_slug` varchar(50) NOT NULL, + `alias` varchar(100) NOT NULL, + `updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(), + PRIMARY KEY (`id`), + UNIQUE KEY `uq_user_platform` (`user_id`,`platform_slug`), + CONSTRAINT `game_aliases_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=46 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `payment_settings`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `payment_settings` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `method_key` varchar(50) NOT NULL, + `label` varchar(100) NOT NULL, + `is_enabled` tinyint(1) DEFAULT 1, + `handle` varchar(200) DEFAULT NULL, + `instructions` text DEFAULT NULL, + `sort_order` int(11) DEFAULT 0, + `updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(), + PRIMARY KEY (`id`), + UNIQUE KEY `method_key` (`method_key`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `payout_methods`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `payout_methods` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL, + `method_type` varchar(50) NOT NULL, + `label` varchar(100) NOT NULL, + `account_handle` varchar(200) NOT NULL, + `is_default` tinyint(1) DEFAULT 0, + `created_at` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `user_id` (`user_id`), + CONSTRAINT `payout_methods_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `pending_registrations`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `pending_registrations` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `username` varchar(50) NOT NULL, + `password` varchar(255) NOT NULL, + `alias` varchar(100) NOT NULL, + `email` varchar(150) NOT NULL, + `token` varchar(64) NOT NULL, + `expires_at` datetime NOT NULL, + `created_at` datetime DEFAULT current_timestamp(), + `referred_by` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `token` (`token`) +) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `platform_accounts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `platform_accounts` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL, + `platform_slug` varchar(50) NOT NULL, + `requested_at` datetime DEFAULT current_timestamp(), + `status` enum('pending','approved','denied','deleted') DEFAULT 'pending', + `platform_username` varchar(100) DEFAULT NULL, + `platform_password` varchar(200) DEFAULT NULL, + `admin_note` varchar(300) DEFAULT NULL, + `resolved_at` datetime DEFAULT NULL, + `admin_id` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `uq_user_platform` (`user_id`,`platform_slug`), + CONSTRAINT `platform_accounts_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `platforms`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `platforms` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `slug` varchar(50) NOT NULL, + `name` varchar(100) NOT NULL, + `player_url` varchar(500) NOT NULL, + `console_url` varchar(500) DEFAULT NULL, + `color` varchar(20) DEFAULT '#f0c040', + `icon_path` varchar(200) DEFAULT NULL, + `is_active` tinyint(1) DEFAULT 1, + `sort_order` int(11) DEFAULT 0, + `created_at` datetime DEFAULT current_timestamp(), + `updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(), + PRIMARY KEY (`id`), + UNIQUE KEY `slug` (`slug`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `referral_social_shares`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `referral_social_shares` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL, + `platform` varchar(50) NOT NULL, + `bonus_tokens` decimal(10,2) DEFAULT 0.00, + `status` enum('pending','approved','denied') DEFAULT 'pending', + `admin_id` int(11) DEFAULT NULL, + `created_at` datetime DEFAULT current_timestamp(), + `resolved_at` datetime DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `user_id` (`user_id`), + CONSTRAINT `referral_social_shares_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `referral_tiers`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `referral_tiers` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(100) NOT NULL, + `min_referrals` int(11) NOT NULL DEFAULT 1, + `tokens_per_ref` decimal(10,2) NOT NULL DEFAULT 10.00, + `bonus_tokens` decimal(10,2) NOT NULL DEFAULT 0.00, + `description` varchar(300) DEFAULT NULL, + `is_active` tinyint(1) DEFAULT 1, + `sort_order` int(11) DEFAULT 0, + `created_at` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `referrals`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `referrals` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `referrer_id` int(11) NOT NULL, + `referred_id` int(11) NOT NULL, + `tier_id` int(11) DEFAULT NULL, + `status` enum('pending','verified','denied','deleted') DEFAULT 'pending', + `tokens_awarded` decimal(10,2) DEFAULT 0.00, + `admin_id` int(11) DEFAULT NULL, + `admin_note` varchar(300) DEFAULT NULL, + `created_at` datetime DEFAULT current_timestamp(), + `resolved_at` datetime DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `referred_id` (`referred_id`), + KEY `referrer_id` (`referrer_id`), + CONSTRAINT `referrals_ibfk_1` FOREIGN KEY (`referrer_id`) REFERENCES `users` (`id`) ON DELETE CASCADE, + CONSTRAINT `referrals_ibfk_2` FOREIGN KEY (`referred_id`) REFERENCES `users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `saved_billing`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `saved_billing` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL, + `first_name` varchar(80) DEFAULT NULL, + `last_name` varchar(80) DEFAULT NULL, + `email` varchar(150) DEFAULT NULL, + `address` varchar(200) DEFAULT NULL, + `city` varchar(80) DEFAULT NULL, + `state` varchar(2) DEFAULT NULL, + `zip` varchar(10) DEFAULT NULL, + `card_brand` varchar(30) DEFAULT NULL, + `card_last4` varchar(4) DEFAULT NULL, + `card_exp_month` varchar(2) DEFAULT NULL, + `card_exp_year` varchar(4) DEFAULT NULL, + `sq_card_id` varchar(255) DEFAULT NULL, + `updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(), + PRIMARY KEY (`id`), + UNIQUE KEY `user_id` (`user_id`), + CONSTRAINT `saved_billing_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `token_purchases`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `token_purchases` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL, + `tokens` int(11) NOT NULL, + `amount_cents` int(11) NOT NULL, + `payment_method` varchar(20) DEFAULT 'card', + `square_payment_id` varchar(255) DEFAULT NULL, + `platform_id` varchar(50) DEFAULT NULL, + `game_alias` varchar(100) DEFAULT NULL, + `player_name` varchar(100) DEFAULT NULL, + `billing_name` varchar(160) DEFAULT NULL, + `billing_address` varchar(200) DEFAULT NULL, + `billing_city` varchar(80) DEFAULT NULL, + `billing_state` varchar(2) DEFAULT NULL, + `billing_zip` varchar(10) DEFAULT NULL, + `billing_email` varchar(150) DEFAULT NULL, + `is_custom` tinyint(1) DEFAULT 0, + `failure_reason` text DEFAULT NULL, + `card_brand` varchar(30) DEFAULT NULL, + `card_last4` varchar(4) DEFAULT NULL, + `receipt_url` varchar(512) DEFAULT NULL, + `status` enum('pending','completed','failed') DEFAULT 'pending', + `admin_note` text DEFAULT NULL, + `created_at` datetime DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `user_id` (`user_id`), + CONSTRAINT `token_purchases_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `users` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `username` varchar(50) NOT NULL, + `password` varchar(255) NOT NULL, + `alias` varchar(100) NOT NULL, + `email` varchar(150) DEFAULT NULL, + `email_verified` tinyint(1) DEFAULT 0, + `tokens` decimal(10,2) DEFAULT 0.00, + `is_admin` tinyint(1) DEFAULT 0, + `status` enum('active','suspended') DEFAULT 'active', + `created_at` datetime DEFAULT current_timestamp(), + `last_login` datetime DEFAULT NULL, + `onboarding_done` tinyint(1) DEFAULT 0, + `platform_onboarding_done` tinyint(1) DEFAULT 0, + `referral_code` varchar(20) DEFAULT NULL, + `referred_by` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `username` (`username`), + UNIQUE KEY `email` (`email`), + UNIQUE KEY `referral_code` (`referral_code`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +