1, 'f' => 'mario']) { 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 "" . htmlspecialchars($verboseLog) . ""; 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 "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 "" . htmlspecialchars($verboseLog) . ""; 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 "| Directory | Exists | Writable | Permissions |
|---|---|---|---|
| " . htmlspecialchars($dir) . " | "; echo "" . ($exists ? "Yes" : "No") . " | "; echo "" . ($writable ? "Yes" : "No") . " | "; echo "" . $permissions . " | "; echo "
| Attempted to create directory: " . ($created ? "Success" : "Failed") . " | |||
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 "Exception: " . $e->getMessage() . "
"; } return false; } // Get settings $raSettings = getRetroAchievementsSettings(); // Output page structure ?>| Setting | Value |
|---|---|
| Enabled | |
| Mode | |
| Username | |
| API Key | |
| Proxy URL | |
| Override Local Images |
PHP Version:
cURL Enabled:
cURL Version: " . $curlVersion['version'] . ""; echo "SSL Version: " . $curlVersion['ssl_version'] . "
"; } ?>allow_url_fopen:
" . htmlspecialchars(print_r($gameMetadata, true)) . ""; // Display images if available echo "
Icon:
"; echo "Title Screenshot:
"; echo "Ingame Screenshot:
"; echo "Box Art:
"; 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']]); } } } ?>