getProfileByHardwareId($hwId); if ($profile === null || !$profile->complete()) { //unregistered gamestick if ($profile === null) { $profile = $profileDb->createProfile($hwId); } $data = [ 'sid' => $profile->sessionId, 'time' => (string) $nowMilli, 'body' => [ 'status' => 'CONNECTION_IN_PROGRESS', 'registrationCode' => ($GLOBALS['verificationCodePrefix'] ?? '') . $profile->verificationCode, ] ]; $json = json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); header('HTTP/1.0 200 OK'); header('Content-Type: application/json'); echo $json . "\n"; exit(0); } $data = [ 'sid' => $profile->sessionId, 'time' => (string) $nowMilli, 'lastaccessed' => $nowMilli, 'x-forwarded-for' => null, 'created' => $nowMilli, 'accessCount' => 1, 'addr' => '1.2.3.4', 'remoteaddr' => '1.2.3.4', 'body' => [ 'status' => 'CONNECTED', 'verificationCode' => 'd7d987', 'config' => [ 'apps' => 'PLACEHOLDER_APPS', 'global' => [ 'defaults' => [ 'images' => [], 'currency' => null, 'social' => [], ], 'uitranslation' => 'PLACEHOLDER_UITRANSLATION', 'newfeatured' => [ 'ages' => 'PLACEHOLDER_AGES', ], ], ] ] ]; $json = json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); $placeholderFiles = [ 'PLACEHOLDER_APPS' => $cacheDir . 'connect-apps.min.json', 'PLACEHOLDER_AGES' => $cacheDir . 'connect-featured-ages.min.json', 'PLACEHOLDER_UITRANSLATION' => $cacheDir . 'connect-uitranslation.min.json', ]; foreach ($placeholderFiles as $placeholder => $cacheFile) { //inject apps if (!file_exists($cacheFile)) { header('Content-Type: text/plain'); echo "Cache file missing: $cacheFile\n"; exit(1); } $json = str_replace( '"' . $placeholder . '"', trim(file_get_contents($cacheFile)), $json ); } sleep(2);//prevent error "Failed to duplicate connect data for console" header('HTTP/1.0 200 OK'); header('Content-Type: application/json'); echo $json . "\n"; ?>