1, 'f' => 'mario']) { echo "

Testing Proxy Connection

"; echo "

Proxy URL: " . htmlspecialchars($proxyUrl) . "

"; try { // Build request data $data = [ 'endpoint' => $testEndpoint, 'params' => $params ]; // Make request to proxy $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $proxyUrl); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($curl, CURLOPT_USERAGENT, 'RetroHub/1.0'); curl_setopt($curl, CURLOPT_TIMEOUT, 30); curl_setopt($curl, CURLOPT_VERBOSE, true); // Create a stream for curl to write verbose information to $verbose = fopen('php://temp', 'w+'); curl_setopt($curl, CURLOPT_STDERR, $verbose); $response = curl_exec($curl); $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); $error = curl_error($curl); // Get verbose information rewind($verbose); $verboseLog = stream_get_contents($verbose); curl_close($curl); // Display results echo "

HTTP Status Code: " . $httpCode . "

"; if ($error) { echo "

Error: " . htmlspecialchars($error) . "

"; } echo "

Curl Verbose Log:

"; echo "
" . htmlspecialchars($verboseLog) . "
"; echo "

Response:

"; if ($response === false) { echo "

No response received

"; return false; } else { // Attempt to parse JSON $parsedResponse = json_decode($response, true); if ($parsedResponse === null && json_last_error() !== JSON_ERROR_NONE) { echo "

Invalid JSON response. JSON error: " . json_last_error_msg() . "

"; echo "
" . htmlspecialchars(substr($response, 0, 1000)) . "...
"; } else { echo "
" . htmlspecialchars(print_r($parsedResponse, true)) . "
"; return $parsedResponse; } } } catch (Exception $e) { echo "

Exception: " . $e->getMessage() . "

"; } return false; } // Function to test direct connection function testDirectConnection($username, $apiKey, $testEndpoint = 'API_GetGameList', $params = ['i' => 1, 'f' => 'mario']) { echo "

Testing Direct Connection

"; echo "

Username: " . htmlspecialchars($username) . "

"; echo "

API Key: " . (empty($apiKey) ? "Not provided" : "Provided (hidden)") . "

"; try { // Add authentication to params $params['z'] = $username; $params['y'] = $apiKey; // Build URL $url = 'https://retroachievements.org/API/' . $testEndpoint . '?' . http_build_query($params); echo "

Request URL: " . htmlspecialchars($url) . "

"; // Make request $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_USERAGENT, 'RetroHub/1.0'); curl_setopt($curl, CURLOPT_TIMEOUT, 30); curl_setopt($curl, CURLOPT_VERBOSE, true); // Create a stream for curl to write verbose information to $verbose = fopen('php://temp', 'w+'); curl_setopt($curl, CURLOPT_STDERR, $verbose); $response = curl_exec($curl); $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); $error = curl_error($curl); // Get verbose information rewind($verbose); $verboseLog = stream_get_contents($verbose); curl_close($curl); // Display results echo "

HTTP Status Code: " . $httpCode . "

"; if ($error) { echo "

Error: " . htmlspecialchars($error) . "

"; } echo "

Curl Verbose Log:

"; echo "
" . htmlspecialchars($verboseLog) . "
"; echo "

Response:

"; if ($response === false) { echo "

No response received

"; return false; } else { // Attempt to parse JSON $parsedResponse = json_decode($response, true); if ($parsedResponse === null && json_last_error() !== JSON_ERROR_NONE) { echo "

Invalid JSON response. JSON error: " . json_last_error_msg() . "

"; echo "
" . htmlspecialchars(substr($response, 0, 1000)) . "...
"; } else { echo "
" . htmlspecialchars(print_r($parsedResponse, true)) . "
"; return $parsedResponse; } } } catch (Exception $e) { echo "

Exception: " . $e->getMessage() . "

"; } return false; } // Function to check file permissions function checkFilePermissions() { echo "

File Permission Check

"; $directories = [ RA_CACHE_DIR, RA_ICONS_CACHE_DIR, RA_SCREENSHOTS_CACHE_DIR, 'config/' ]; echo ""; echo ""; foreach ($directories as $dir) { $exists = is_dir($dir); $writable = $exists && is_writable($dir); $permissions = $exists ? substr(sprintf('%o', fileperms($dir)), -4) : 'N/A'; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; // Try to create directory if it doesn't exist if (!$exists) { $created = mkdir($dir, 0755, true); echo ""; } } echo "
DirectoryExistsWritablePermissions
" . htmlspecialchars($dir) . "" . ($exists ? "Yes" : "No") . "" . ($writable ? "Yes" : "No") . "" . $permissions . "
Attempted to create directory: " . ($created ? "Success" : "Failed") . "
"; } // Function to test image download function testImageDownload($url, $destination) { echo "

Testing Image Download

"; echo "

Source URL: " . htmlspecialchars($url) . "

"; echo "

Destination: " . htmlspecialchars($destination) . "

"; try { // Handle full URLs or relative URLs if (strpos($url, 'http') !== 0) { $url = 'https://retroachievements.org' . $url; echo "

Converted to full URL: " . htmlspecialchars($url) . "

"; } // Download image $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_USERAGENT, 'RetroHub/1.0'); curl_setopt($curl, CURLOPT_TIMEOUT, 30); $image = curl_exec($curl); $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); $contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE); $error = curl_error($curl); curl_close($curl); // Display results echo "

HTTP Status Code: " . $httpCode . "

"; echo "

Content Type: " . htmlspecialchars($contentType) . "

"; echo "

Content Size: " . strlen($image) . " bytes

"; if ($error) { echo "

Error: " . htmlspecialchars($error) . "

"; return false; } if ($httpCode !== 200) { echo "

Failed to download image (HTTP " . $httpCode . ")

"; return false; } // Ensure directory exists $dir = dirname($destination); if (!is_dir($dir)) { $created = mkdir($dir, 0755, true); echo "

Created directory " . htmlspecialchars($dir) . ": " . ($created ? "Success" : "Failed") . "

"; if (!$created) { echo "

Error: Could not create directory for image

"; return false; } } // Save image $saved = file_put_contents($destination, $image); if ($saved === false) { echo "

Error: Could not save image to " . htmlspecialchars($destination) . "

"; return false; } echo "

Image saved successfully (" . $saved . " bytes)

"; // Display the image echo "

Downloaded Image:

"; $base64 = base64_encode($image); echo ""; return true; } catch (Exception $e) { echo "

Exception: " . $e->getMessage() . "

"; } return false; } // Get settings $raSettings = getRetroAchievementsSettings(); // Output page structure ?> RetroAchievements Debug Tool

RetroAchievements Debug Tool

Current Configuration

SettingValue
Enabled
Mode
Username
API Key
Proxy URL
Override Local Images

System Information

PHP Version:

cURL Enabled:

cURL Version: " . $curlVersion['version'] . "

"; echo "

SSL Version: " . $curlVersion['ssl_version'] . "

"; } ?>

allow_url_fopen:

File System Checks

API Connection Tests

Game Search Test

Searching for: " . htmlspecialchars($_POST['game_title']) . " on " . htmlspecialchars($_POST['console']) . ""; // Get game metadata $gameMetadata = getGameMetadata($_POST['game_title'], $_POST['console']); if ($gameMetadata) { echo "

Game Metadata Found:

"; echo "
" . htmlspecialchars(print_r($gameMetadata, true)) . "
"; // Display images if available echo "

Images:

"; echo "
"; if (isset($gameMetadata['icon']) && $gameMetadata['icon']) { echo "
"; echo "

Icon:

"; echo "Game Icon"; echo "
"; } if (isset($gameMetadata['screenshot_title']) && $gameMetadata['screenshot_title']) { echo "
"; echo "

Title Screenshot:

"; echo "Title Screenshot"; echo "
"; } if (isset($gameMetadata['screenshot_ingame']) && $gameMetadata['screenshot_ingame']) { echo "
"; echo "

Ingame Screenshot:

"; echo "Ingame Screenshot"; echo "
"; } if (isset($gameMetadata['screenshot_boxart']) && $gameMetadata['screenshot_boxart']) { echo "
"; echo "

Box Art:

"; echo "Box Art"; echo "
"; } echo "
"; } else { echo "

No metadata found. Let's see if we can get the raw API response:

"; // Try to get the raw data if ($raSettings['mode'] === 'proxy') { $consoleId = $RA_CONSOLE_IDS[$_POST['console']]; testProxyConnection($raSettings['proxy_url'], 'API_GetGameList', ['i' => $consoleId, 'f' => $_POST['game_title']]); } else { $consoleId = $RA_CONSOLE_IDS[$_POST['console']]; testDirectConnection($raSettings['username'], $raSettings['api_key'], 'API_GetGameList', ['i' => $consoleId, 'f' => $_POST['game_title']]); } } } ?>

Clear Cache

Cleared $deletedFiles out of $totalFiles cache files.

"; } ?>