diff --git a/README.md b/README.md index 81d63b7..ab76a33 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,106 @@ - -# Game Library [![Badge License]][License] - -*A game library extension for* ***[EmulatorJS]*** +# RetroHub [![Badge_License]][License] +*Formerly EJS Library* +*A game library and rom management tool using ***[EmulatorJS]***
-This add - on site allows users of EmulatorJS to manage ROMs, including a built-in (albeit basic) data and image scraper.
+This site allows users to run and manage their ROMs, using EmulatorJS and the RetroAchievements website. -PSX has returned! -
+## Disclaimer +I will no longer be working on this project; this final update was purely me learning how to program better for my new project -## Installation +If you wish for functionality like this, but are unsure how to set it up yourself, check out ***[Temporus]***. -This is a drag and drop extension, with the
-exception that it requires something to host
-PHP files like XAMPP. After that, simply upload your roms.
-Bulk rom uploading has been added to make this easier. +## Features -I've taken out image scraping for now, I will try to add it in with more options etc with the rebuild.
-Instead, I've given cloud save options! +### Modern Game Library Interface -## BIOS setup +Grid and list views for your ROM collection +Search and filter by console type +Game cards with cover art and metadata -To add BIOs for the systems that require it, simply
-add the BIOs to a ZIP file and rename it to *console name*.zip.
-For example, the gba bios would be kept as /bios/gba.zip
- +### Powerful ROM Management + +Bulk upload capability for ROMs +Automatic console detection based on file extension +Support for various ROM formats including ZIP files + + +### RetroAchievements Integration + +Automatic game metadata and images from RetroAchievements +Game info including developer, publisher, release date +Cover art, screenshots, and title screens + + +### Profile System + +Netflix-style profile switching for family sharing +Custom avatars for each profile +Independent save states per profile + + +### Advanced Save State System + +Multiple save slots per game +Screenshot preview of each save state +Seamless saving/loading during gameplay + + +### BIOS Management + +Upload and manage BIOS files for various systems +Visual indication of installed BIOS files +System-specific BIOS requirements reference + + +### Cloud Save Support + +Server-side save state management +Persistent game progress across sessions +Backup protection for your progress + + + +### Installation + +Requires a PHP-enabled web server (XAMPP, WAMP, or similar) +Copy all files to your web server's document root +Ensure proper permissions for cache and save directories +Access the site via your web browser + +### RetroAchievements Setup +(This is for direct access. If using a Proxy, I have one set up already and linked in :) +Go to Settings → RetroAchievements +Enable RetroAchievements integration +Choose between direct API access (requires your own API key) or proxy mode +If using direct access, enter your RetroAchievements API key from your account's control panel +Save settings and enjoy enhanced game metadata and images + +### BIOS Requirements +Some systems require BIOS files to function correctly. Upload your BIOS files through the BIOS management page. Common requirements include: + +PlayStation: SCPH5500.bin, SCPH5501.bin, SCPH5502.bin +Game Boy Advance: gba_bios.bin +Nintendo DS: bios7.bin, bios9.bin, firmware.bin +Sega CD: bios_CD_U.bin, bios_CD_J.bin, bios_CD_E.bin + +### Support +This project is no longer actively maintained. For similar functionality with professional support, please visit Temporus. +License +RetroHub is released under the GPL license. + +### Credits + +EmulatorJS - Emulation core +RetroAchievements - Game metadata and images [Badge License]: https://img.shields.io/badge/license-GPL-blue [EmulatorJS]: https://github.com/EmulatorJS/emulatorjs +[Temporus]: https://temporus.one/ + [License]: # diff --git a/backend/raproxy.php b/backend/raproxy.php new file mode 100644 index 0000000..ae30a2b --- /dev/null +++ b/backend/raproxy.php @@ -0,0 +1,149 @@ + '** YOUR API KEY **', // Replace with your RetroAchievements API key + 'cache_dir' => 'cache/', // Directory to store cached responses + 'cache_expiration' => 604800, // Cache expiration time in seconds (7 days) + 'rate_limit' => 30, // Maximum requests per minute per IP + 'rate_limit_window' => 60 // Time window for rate limiting in seconds +]; + +// Create cache directory if it doesn't exist +if (!is_dir($config['cache_dir'])) { + mkdir($config['cache_dir'], 0755, true); +} + +// Basic rate limiting +$clientIP = $_SERVER['REMOTE_ADDR']; +$rateLimitFile = $config['cache_dir'] . 'rate_' . md5($clientIP) . '.json'; + +$rateData = [ + 'count' => 0, + 'timestamp' => time() +]; + +if (file_exists($rateLimitFile)) { + $rateData = json_decode(file_get_contents($rateLimitFile), true); + + // Reset counter if window has passed + if (time() - $rateData['timestamp'] > $config['rate_limit_window']) { + $rateData['count'] = 0; + $rateData['timestamp'] = time(); + } +} + +// Check if rate limit exceeded +if ($rateData['count'] >= $config['rate_limit']) { + header('HTTP/1.1 429 Too Many Requests'); + echo json_encode([ + 'error' => 'Rate limit exceeded. Please try again later.' + ]); + exit; +} + +// Process only POST requests +if ($_SERVER['REQUEST_METHOD'] !== 'POST') { + header('HTTP/1.1 405 Method Not Allowed'); + echo json_encode([ + 'error' => 'Only POST requests are allowed.' + ]); + exit; +} + +// Verify required parameters +if (!isset($_POST['endpoint']) || empty($_POST['endpoint'])) { + header('HTTP/1.1 400 Bad Request'); + echo json_encode([ + 'error' => 'Missing required parameter: endpoint' + ]); + exit; +} + +$endpoint = $_POST['endpoint']; +$params = isset($_POST['params']) ? $_POST['params'] : []; + +// Sanitize endpoint to prevent directory traversal +$endpoint = basename($endpoint); + +// Generate cache key based on request +$cacheKey = md5($endpoint . serialize($params)); +$cachePath = $config['cache_dir'] . $cacheKey . '.json'; + +// Check if cached response exists and is still valid +if (file_exists($cachePath) && (time() - filemtime($cachePath) < $config['cache_expiration'])) { + $cachedResponse = file_get_contents($cachePath); + + if ($cachedResponse) { + header('Content-Type: application/json'); + echo $cachedResponse; + exit; + } +} + +// Increment rate limit counter and save +$rateData['count']++; +file_put_contents($rateLimitFile, json_encode($rateData)); + +// Build API URL - Using the correct format: API_EndpointName.php +$baseUrl = 'https://retroachievements.org/API/'; +$url = $baseUrl . 'API_' . $endpoint . '.php'; + +// Add authentication to params +if (is_array($params)) { + $params['y'] = $config['api_key']; +} else { + $params = [ + 'y' => $config['api_key'] + ]; +} + +// Build full URL with parameters +$url .= '?' . http_build_query($params); + +// Make request to RetroAchievements API +$ch = curl_init(); +curl_setopt($ch, CURLOPT_URL, $url); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); +curl_setopt($ch, CURLOPT_USERAGENT, 'RetroHub-Proxy/1.0'); +curl_setopt($ch, CURLOPT_TIMEOUT, 15); + +$response = curl_exec($ch); +$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); +$error = curl_error($ch); + +curl_close($ch); + +// Return error if request failed +if ($httpCode !== 200 || empty($response)) { + header('HTTP/1.1 ' . ($httpCode ? $httpCode : 500) . ' Error'); + echo json_encode([ + 'error' => 'Error fetching data from RetroAchievements API', + 'http_code' => $httpCode, + 'curl_error' => $error, + 'url' => $url + ]); + exit; +} + +// Cache the response +file_put_contents($cachePath, $response); + +// Return the response +header('Content-Type: application/json'); +echo $response; \ No newline at end of file diff --git a/bios.php b/bios.php new file mode 100644 index 0000000..9bda09b --- /dev/null +++ b/bios.php @@ -0,0 +1,275 @@ + 0) { + $_SESSION['current_profile'] = $profiles[0]['id']; + } else { + // Create default profile if none exists + $defaultProfileId = createProfile("Player 1", "avatar1.png"); + $_SESSION['current_profile'] = $defaultProfileId; + } +} + +// Process BIOS file uploads +$uploadMessage = ''; +$uploadStatus = ''; + +if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['upload_type'])) { + if ($_POST['upload_type'] == 'bios' && isset($_FILES['bios_file'])) { + if ($_FILES['bios_file']['error'] == UPLOAD_ERR_OK) { + // Create the bios directory if it doesn't exist + if (!is_dir('bios')) { + mkdir('bios', 0755, true); + } + + $tmp_name = $_FILES['bios_file']['tmp_name']; + $name = basename($_FILES['bios_file']['name']); + $console = isset($_POST['console_type']) ? $_POST['console_type'] : pathinfo($name, PATHINFO_FILENAME); + + // If console type is specified, rename the file + if (isset($_POST['console_type']) && !empty($_POST['console_type'])) { + $ext = pathinfo($name, PATHINFO_EXTENSION); + $name = $console . '.' . $ext; + } + + // Move the uploaded file + if (move_uploaded_file($tmp_name, "bios/$name")) { + $uploadMessage = "BIOS file uploaded successfully!"; + $uploadStatus = 'success'; + } else { + $uploadMessage = "Error uploading BIOS file."; + $uploadStatus = 'error'; + } + } else { + $uploadMessage = "Error uploading BIOS file: " . $_FILES['bios_file']['error']; + $uploadStatus = 'error'; + } + } +} + +// Get current profile data +$currentProfile = getProfileById($_SESSION['current_profile']); +$allProfiles = getProfiles(); + +// Get list of BIOS files +$biosFiles = getBiosFiles(); +?> + + + + + + + RetroHub - BIOS Files + + + + +
+
+ +
+
+ +
+
+ + + +
+ + +
+ + +
+
+
+

Upload BIOS Files

+

Some systems require BIOS files to function correctly. Upload your BIOS files here.

+ +
+
+ + +
+ + +
+ +
+ +
+ +
+ + Select BIOS File +
+ No file selected +
+
+ + +
+
+ +
+

About BIOS Files

+

BIOS files are required for some systems to run correctly. They contain low-level system code that the emulator needs to properly emulate the original hardware.

+

For copyright reasons, BIOS files are not included with RetroHub and must be provided by you.

+

Once uploaded, BIOS files will be automatically detected and used by the emulator.

+
+
+ +
+

Installed BIOS Files

+ +
+
+ Console + Filename + Size + Uploaded + Actions +
+ + 0): ?> + +
+ + + + +
+ + + +
+
+ + +
+

No BIOS files installed yet.

+
+ +
+ +
+

Required BIOS Files by System

+
+
+
PlayStation (PSX)
+
scph5500.bin, scph5501.bin, scph5502.bin
+
+
+
Game Boy Advance
+
gba_bios.bin
+
+
+
Nintendo DS
+
bios7.bin, bios9.bin, firmware.bin
+
+
+
Sega CD
+
bios_CD_U.bin, bios_CD_J.bin, bios_CD_E.bin
+
+ +
+
+
+
+
+
+ + + + + +
+ + +