emulatorjs-GameLibrary/upload.php
Ramaerel e274c3d76b Complete rebuild, part 1.
Rebuilt from the ground up. Removed the accounts system (Can bring it back if it's wanted), added data scraping, added BIOs support, added PSX
2023-07-03 11:11:38 +10:00

85 lines
3.1 KiB
PHP

<!DOCTYPE html>
<html>
<head>
<title>EmulatorJS Library - Upload</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<!-- Navbar -->
<nav>
<ul>
<li><a href="index.php">Arcade</a></li>
<li><a href="#">Upload</a></li>
</ul>
</nav>
<br />
<!-- Game Arcade -->
<div class="arcadelist">
<?php
include 'fnc.php';
$settings = parse_ini_file("./settings.ini");
//Write system extension arrays
// Nintendo
$snes = ["smc", "sfc", "fig", "swc", "bs", "st"];
$gba = ["gba"];
$gb = ["gb", "gbc", "dmg"];
$nes = ["fds", "nes", "unif", "unf"];
$vb = ["vb", "vboy"];
$nds = ["nds"];
$n64 = ["n64", "z64", "v64", "u1", "ndd"];
// Sega
$sms = ["sms"];
$smd = ["smd", "md"];
$gg = ["gg"];
//Upload functionality
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if($_FILES['rom-files']['error'][0] == UPLOAD_ERR_OK) {
foreach ($_FILES['rom-files']['tmp_name'] as $key => $tmp_name) {
$name = basename($_FILES['rom-files']['name'][$key]);
$ext = explode('.', $name);
$ext = end($ext);
if(!is_dir("roms")) {
mkdir("roms");
}
//Move File
move_uploaded_file($tmp_name, "roms/$name");
//Scrape File
if($settings["key"] !== "") {
if(scrape_data($name)) {
$data = parse_ini_file("./inis/$name.ini");
print("<p>Uploaded and scraped file: ".$data["name"]."</p><br /><img src='img/$name.png' />");
} else {
print("<p>File uploaded, scraping failed. Is cURL and CORs enabled?");
}
} else {
print("<p>File successfully uploaded. Scraping failed due to no key error.</p>");
}
}
}
}
?>
<form action="upload.php" method="post" enctype="multipart/form-data">
<label for="rom-files">Select a ROM file (Max 20):</label>
<br />
<input type="file" id="rom-files" name="rom-files[]" multiple>
<br />
<br />
<input type="submit" value="Upload">
</form>
</div>
</body>
</html>