mirror of
https://github.com/Ramaerel/emulatorjs-GameLibrary.git
synced 2026-02-06 10:56:54 +00:00
New update.
Complete overhaul of the site, have fun.
This commit is contained in:
parent
bf7ac980ed
commit
1cab90c12f
63
arcade.php
Normal file
63
arcade.php
Normal file
@ -0,0 +1,63 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>EJSLibrary</title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<?php include 'fnc.php'; ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="index.php">Index</a></li>
|
||||
|
||||
<?php
|
||||
if (isset($_COOKIE["user"])) {
|
||||
print("
|
||||
<li><a href='upload.php'>Upload ROMs</a></li>
|
||||
<li><a href='arcade.php'>Play Games</a></li>
|
||||
<li><a href='logout.php'>Log Out</a></li>
|
||||
");
|
||||
} else {
|
||||
print("
|
||||
<li><a href='register.php'>Register</a></li>
|
||||
<li><a href='login.php'>Login</a></li>
|
||||
");
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</nav>
|
||||
<br />
|
||||
<br />
|
||||
<div class="updates">
|
||||
<div class="grid-container">
|
||||
<?php
|
||||
// Get console type - Print console select if no console
|
||||
|
||||
if ((isset($_GET["console"])) and ($_GET["console"] !== "")) {
|
||||
buildRomList($_GET["console"]);
|
||||
|
||||
} else {
|
||||
echo('<a class="rounded-square" href="./arcade.php?console=nes">Nintendo Entertainment System</a>');
|
||||
echo('<a class="rounded-square" href="./arcade.php?console=snes">Super Nintendo</a>');
|
||||
echo('<a class="rounded-square" href="./arcade.php?console=n64">Nintendo 64</a>');
|
||||
|
||||
echo('<a class="rounded-square" href="./arcade.php?console=gb"> Gameboy (Color)</a>');
|
||||
echo('<a class="rounded-square" href="./arcade.php?console=gba">Gameboy Advance</a>');
|
||||
echo('<a class="rounded-square" href="./arcade.php?console=nds">Nintendo DS</a>');
|
||||
|
||||
echo('<a class="rounded-square" href="./arcade.php?console=vb">Nintendo Virtual Boy</a>');
|
||||
|
||||
echo('<a class="rounded-square" href="./arcade.php?console=segaMS">Sega Master System</a>');
|
||||
echo('<a class="rounded-square" href="./arcade.php?console=segaMD">Sega Mega Drive</a>');
|
||||
echo('<a class="rounded-square" href="./arcade.php?console=segaGG">Sega Game Gear</a>');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
17
fnc.php
Normal file
17
fnc.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
function buildRomList($console) {
|
||||
|
||||
//Read all files from the system ROM directory
|
||||
$dir = 'users/'.$_COOKIE["user"].'/roms/'.$console.'/';
|
||||
$files = scandir($dir);
|
||||
|
||||
foreach($files as $file) {
|
||||
if (!in_array($file, array('.', '..'))) {
|
||||
$file_url = 'play.php?system='.$console.'&rom=' . urlencode($file);
|
||||
echo('<a class="rounded-square" href="'.$file_url.'">'.$file.'</a>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
37
index.php
Normal file
37
index.php
Normal file
@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>EJSLibrary</title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="#">Index</a></li>
|
||||
|
||||
<?php
|
||||
if (isset($_COOKIE["user"])) {
|
||||
print("
|
||||
<li><a href='upload.php'>Upload ROMs</a></li>
|
||||
<li><a href='arcade.php'>Play Games</a></li>
|
||||
<li><a href='logout.php'>Log Out</a></li>
|
||||
");
|
||||
} else {
|
||||
print("
|
||||
<li><a href='register.php'>Register</a></li>
|
||||
<li><a href='login.php'>Login</a></li>
|
||||
");
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</nav>
|
||||
<br />
|
||||
<br />
|
||||
<div class="updates">
|
||||
<h1>I dunno. Put news or something here.</h1>
|
||||
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
69
login.php
Normal file
69
login.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
if (isset($_POST["un"])) {
|
||||
|
||||
if (!is_dir("./users/".$_POST["un"])) {
|
||||
$errors = "User does not exist";
|
||||
} else {
|
||||
$pass = file_get_contents("./users/".$_POST["un"]."/pw.d");
|
||||
if (md5($_POST["pw"]) == $pass) {
|
||||
setcookie("user", $_POST["un"], time() + (30 * 24 * 60 * 60));
|
||||
header("Location: index.php");
|
||||
exit();
|
||||
} else {
|
||||
$errors = "Incorrect Password";
|
||||
}
|
||||
}
|
||||
print($errors);
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>EJSLibrary - Login</title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="index.php">Index</a></li>
|
||||
|
||||
<?php
|
||||
if (isset($_COOKIE["user"])) {
|
||||
print("
|
||||
<li><a href='upload.php'>Upload ROMs</a></li>
|
||||
<li><a href='arcade.php'>Play Games</a></li>
|
||||
<li><a href='logout.php'>Log Out</a></li>
|
||||
");
|
||||
} else {
|
||||
print("
|
||||
<li><a href='register.php'>Register</a></li>
|
||||
<li><a href='#'>Login</a></li>
|
||||
");
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</nav>
|
||||
<br />
|
||||
<br />
|
||||
<div class="updates">
|
||||
<br />
|
||||
<form action="login.php" method="POST">
|
||||
|
||||
<label for="un">Username: </label>
|
||||
<input type="text" id="un" name="un" />
|
||||
<br />
|
||||
<br />
|
||||
<label for="pw">Password: </label>
|
||||
<input type="password" id="pw" name="pw" />
|
||||
<hr />
|
||||
<input type="submit" value="Login" class="submit" />
|
||||
|
||||
</form>
|
||||
|
||||
<br />
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
49
logout.php
Normal file
49
logout.php
Normal file
@ -0,0 +1,49 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>EJSLibrary - Logout</title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="index.php">Index</a></li>
|
||||
|
||||
<?php
|
||||
if (isset($_COOKIE["user"])) {
|
||||
print("
|
||||
<li><a href='upload.php'>Upload ROMs</a></li>
|
||||
<li><a href='arcade.php'>Play Games</a></li>
|
||||
<li><a href='#'>Log Out</a></li>
|
||||
");
|
||||
} else {
|
||||
print("
|
||||
<li><a href='register.php'>Register</a></li>
|
||||
<li><a href='login.php'>Login</a></li>
|
||||
");
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</nav>
|
||||
<br />
|
||||
<br />
|
||||
<div class="updates">
|
||||
<br />
|
||||
<?php
|
||||
if(isset($_COOKIE["user"])) {
|
||||
setcookie("user", "", time() - 3000);
|
||||
|
||||
} else {
|
||||
print("<p>You must be logged in to log out.</p>");
|
||||
}
|
||||
?>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
window.location.href = "index.php";
|
||||
}
|
||||
</script>
|
||||
<br />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
21
play.php
Normal file
21
play.php
Normal file
@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>EJSLibrary Arcade</title>
|
||||
|
||||
</head>
|
||||
|
||||
<body style="background-color:#333333">
|
||||
<div style='width:100vw;height:100vh;max-width:100%'>
|
||||
<div id='game'></div>
|
||||
</div>
|
||||
|
||||
<script type='text/javascript'>
|
||||
EJS_player = '#game';
|
||||
EJS_core = '<?php echo($_GET['system']); ?>';
|
||||
EJS_gameUrl = '/users/<?php echo($_COOKIE['user']); ?>/roms/<?php echo($_GET['system'] . "/" . $_GET['rom']); ?>';
|
||||
EJS_pathtodata = 'data/';
|
||||
</script>
|
||||
<script src='data/loader.js'></script>
|
||||
</body>
|
||||
</html>
|
||||
92
register.php
Normal file
92
register.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
if (isset($_POST["un"])) {
|
||||
if (!is_dir("./users")) {
|
||||
mkdir("./users");
|
||||
}
|
||||
if (is_dir("./users/".$_POST["un"])) {
|
||||
$errors = "User already exists";
|
||||
}
|
||||
|
||||
if (strtolower($_POST["test"]) !== "f") {
|
||||
$errors = "Bot test Wrong";
|
||||
}
|
||||
|
||||
if (isset($errors)) {
|
||||
print($errors);
|
||||
} else {
|
||||
mkdir("./users/".$_POST["un"]);
|
||||
mkdir("./users/".$_POST["un"]."/roms");
|
||||
mkdir("./users/".$_POST["un"]."/img");
|
||||
|
||||
//Make System Directories
|
||||
mkdir("./users/".$_POST["un"]."/snes");
|
||||
|
||||
|
||||
$pwd = fopen("./users/".$_POST["un"]."/pw.d", "w");
|
||||
fwrite($pwd, md5($_POST["pw"]));
|
||||
fclose($pwd);
|
||||
|
||||
setcookie("user", $_POST["un"], time() + (30 * 24 * 60 * 60));
|
||||
|
||||
header("Location: index.php");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>EJS Library - Register</title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="index.php">Index</a></li>
|
||||
|
||||
<?php
|
||||
if (isset($_COOKIE["user"])) {
|
||||
print("
|
||||
<li><a href='upload.php'>Upload ROMs</a></li>
|
||||
<li><a href='arcade.php'>Play Games</a></li>
|
||||
<li><a href='logout.php'>Log Out</a></li>
|
||||
");
|
||||
} else {
|
||||
print("
|
||||
<li><a href='#'>Register</a></li>
|
||||
<li><a href='login.php'>Login</a></li>
|
||||
");
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</nav>
|
||||
<br />
|
||||
<br />
|
||||
<div class="updates">
|
||||
<br />
|
||||
|
||||
<form action="register.php" method="POST">
|
||||
|
||||
<label for="un">Username: </label>
|
||||
<input type="text" id="un" name="un" />
|
||||
<br />
|
||||
<br />
|
||||
<label for="pw">Password: </label>
|
||||
<input type="password" id="pw" name="pw" />
|
||||
<br />
|
||||
<br />
|
||||
<label for="test">Bot Test: What is the the 6th letter of the English alphabet?</label>
|
||||
<br />
|
||||
<input type="text" id="test" name="test" />
|
||||
<hr />
|
||||
<input type="submit" value="Register" class="submit" />
|
||||
|
||||
</form>
|
||||
|
||||
<br />
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
63
style.css
Normal file
63
style.css
Normal file
@ -0,0 +1,63 @@
|
||||
body {
|
||||
background-color: #313131;
|
||||
}
|
||||
|
||||
nav {
|
||||
background-color: #5f5f5f;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
nav ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
}
|
||||
|
||||
nav a {
|
||||
display: block;
|
||||
padding: 1rem;
|
||||
text-decoration: none;
|
||||
color: #c5c5c5;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
nav a:hover {
|
||||
background-color: #868686;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
div.updates {
|
||||
background-color: #5f5f5f;
|
||||
width: 65%;
|
||||
height: 90%;
|
||||
text-align:center;
|
||||
margin:auto;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
input {
|
||||
border-radius: 5px;
|
||||
border-width: 0;
|
||||
background-color: #cecece;
|
||||
}
|
||||
|
||||
input:hover {
|
||||
background-color: #8d8d8d;
|
||||
}
|
||||
|
||||
a.rounded-square {
|
||||
display: inline-block;
|
||||
padding: 10px 20px;
|
||||
border-radius: 20px;
|
||||
background-color: #747474;
|
||||
color: #d3d3d3;
|
||||
text-decoration: none;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
a.rounded-square:hover {
|
||||
background-color: #7e7e7e;
|
||||
}
|
||||
152
upload.php
Normal file
152
upload.php
Normal file
@ -0,0 +1,152 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>EJS Library</title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
|
||||
<?php
|
||||
include 'fnc.php';
|
||||
|
||||
$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"];
|
||||
|
||||
$sms = ["sms"];
|
||||
$smd = ["smd", "md"];
|
||||
$gg = ["gg"];
|
||||
|
||||
?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="index.php">Index</a></li>
|
||||
|
||||
<?php
|
||||
if (isset($_COOKIE["user"])) {
|
||||
print("
|
||||
<li><a href='#'>Upload ROMs</a></li>
|
||||
<li><a href='arcade.php'>Play Games</a></li>
|
||||
<li><a href='logout.php'>Log Out</a></li>
|
||||
");
|
||||
} else {
|
||||
print("
|
||||
<li><a href='register.php'>Register</a></li>
|
||||
<li><a href='login.php'>Login</a></li>
|
||||
");
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</nav>
|
||||
<br />
|
||||
<br />
|
||||
<div class="updates">
|
||||
<h1>Upload ROM Files</h1>
|
||||
|
||||
<?php
|
||||
if(isset($_COOKIE["user"])) {
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
// Multiple file upload
|
||||
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 (in_array($ext, $snes)) {
|
||||
if(!is_dir("users/" . $_COOKIE["user"] . "/roms/snes")) {
|
||||
mkdir("users/" . $_COOKIE['user'] . "/roms/snes");
|
||||
}
|
||||
move_uploaded_file($tmp_name, "users/" . $_COOKIE["user"] . "/roms/snes/" . $name);
|
||||
echo("<p>SNES rom $name successfully uploaded.<br /></p>");
|
||||
|
||||
} else if (in_array($ext, $gba)) {
|
||||
if(!is_dir("users/" . $_COOKIE["user"] . "/roms/gba")) {
|
||||
mkdir("users/" . $_COOKIE['user'] . "/roms/gba");
|
||||
}
|
||||
move_uploaded_file($tmp_name, "users/" . $_COOKIE["user"] . "/roms/gba/" . $name);
|
||||
echo("<p>GBA rom $name successfully uploaded.<br /></p>");
|
||||
|
||||
} else if (in_array($ext, $gb)) {
|
||||
if(!is_dir("users/" . $_COOKIE["user"] . "/roms/gb")) {
|
||||
mkdir("users/" . $_COOKIE['user'] . "/roms/gb");
|
||||
}
|
||||
move_uploaded_file($tmp_name, "users/" . $_COOKIE["user"] . "/roms/gb/" . $name);
|
||||
echo("<p>GB rom $name successfully uploaded.<br /></p>");
|
||||
|
||||
} else if (in_array($ext, $nes)) {
|
||||
if(!is_dir("users/" . $_COOKIE["user"] . "/roms/nes")) {
|
||||
mkdir("users/" . $_COOKIE['user'] . "/roms/nes");
|
||||
}
|
||||
move_uploaded_file($tmp_name, "users/" . $_COOKIE["user"] . "/roms/nes/" . $name);
|
||||
echo("<p>NES rom $name successfully uploaded.<br /></p>");
|
||||
|
||||
} else if (in_array($ext, $vb)) {
|
||||
if(!is_dir("users/" . $_COOKIE["user"] . "/roms/vb")) {
|
||||
mkdir("users/" . $_COOKIE['user'] . "/roms/vb");
|
||||
}
|
||||
move_uploaded_file($tmp_name, "users/" . $_COOKIE["user"] . "/roms/vb/" . $name);
|
||||
echo("<p>VB rom $name successfully uploaded.<br /></p>");
|
||||
|
||||
} else if (in_array($ext, $nds)) {
|
||||
if(!is_dir("users/" . $_COOKIE["user"] . "/roms/nds")) {
|
||||
mkdir("users/" . $_COOKIE['user'] . "/roms/nds");
|
||||
}
|
||||
move_uploaded_file($tmp_name, "users/" . $_COOKIE["user"] . "/roms/nds/" . $name);
|
||||
echo("<p>NDS rom $name successfully uploaded.<br /></p>");
|
||||
|
||||
} else if (in_array($ext, $n64)) {
|
||||
if(!is_dir("users/" . $_COOKIE["user"] . "/roms/n64")) {
|
||||
mkdir("users/" . $_COOKIE['user'] . "/roms/n64");
|
||||
}
|
||||
move_uploaded_file($tmp_name, "users/" . $_COOKIE["user"] . "/roms/n64/" . $name);
|
||||
echo("<p>N64 rom $name successfully uploaded.<br /></p>");
|
||||
|
||||
} else if (in_array($ext, $sms)) {
|
||||
if(!is_dir("users/" . $_COOKIE["user"] . "/roms/segaMS")) {
|
||||
mkdir("users/" . $_COOKIE['user'] . "/roms/segaMS");
|
||||
}
|
||||
move_uploaded_file($tmp_name, "users/" . $_COOKIE["user"] . "/roms/segaMS/" . $name);
|
||||
echo("<p>SMS rom $name successfully uploaded.<br /></p>");
|
||||
|
||||
} else if (in_array($ext, $smd)) {
|
||||
if(!is_dir("users/" . $_COOKIE["user"] . "/roms/segaMD")) {
|
||||
mkdir("users/" . $_COOKIE['user'] . "/roms/segaMD");
|
||||
}
|
||||
move_uploaded_file($tmp_name, "users/" . $_COOKIE["user"] . "/roms/segaMD/" . $name);
|
||||
echo("<p>SMD rom $name successfully uploaded.<br /></p>");
|
||||
|
||||
} else if (in_array($ext, $gg)) {
|
||||
if(!is_dir("users/" . $_COOKIE["user"] . "/roms/segaGG")) {
|
||||
mkdir("users/" . $_COOKIE['user'] . "/roms/segaGG");
|
||||
}
|
||||
move_uploaded_file($tmp_name, "users/" . $_COOKIE["user"] . "/roms/segaGG/" . $name);
|
||||
echo("<p>SGG rom $name successfully uploaded.<br /></p>");
|
||||
|
||||
} else {
|
||||
print("<p>Error: Unsupported filetype!</p>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<form action="upload.php" method="post" enctype="multipart/form-data">
|
||||
<label for="rom-files">Select a ROM file:</label>
|
||||
<br />
|
||||
<input type="file" id="rom-files" name="rom-files[]" multiple>
|
||||
<br />
|
||||
<br />
|
||||
<input type="submit" value="Upload">
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue
Block a user