Add files via upload

This commit is contained in:
gmanandmarbles 2023-08-09 16:47:52 -06:00 committed by GitHub
commit bd5f983f08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 1680 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

BIN
assets/icons/voxel/icon.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

16
config.php Normal file
View file

@ -0,0 +1,16 @@
<?php
/* Database credentials. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'web');
define('DB_PASSWORD', 'web');
define('DB_NAME', 'web');
/* Attempt to connect to MySQL database */
$link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
?>

37
delete_game.php Normal file
View file

@ -0,0 +1,37 @@
<?php
$host = 'localhost';
$username = 'web';
$password = 'web';
$dbname = 'web';
// Create connection
$conn = new mysqli($host, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Check if the ID parameter is set
if (isset($_GET['id'])) {
$id = $_GET['id'];
// Prepare and execute the delete statement
$stmt = $conn->prepare("DELETE FROM games_in_holding WHERE id = ?");
$stmt->bind_param("i", $id);
$stmt->execute();
// Check if any rows were affected
if ($stmt->affected_rows > 0) {
echo "Game deleted successfully.";
} else {
echo "Failed to delete game.";
}
// Close the statement
$stmt->close();
}
// Close the database connection
$conn->close();
?>

27
directory.sh Normal file
View file

@ -0,0 +1,27 @@
#!/bin/bash
grant_directory_access() {
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root."
return
fi
read -p "Enter the directory path: " directory
read -p "Enter the username: " username
# Check if the directory exists
if [ ! -d "$directory" ]; then
echo "Directory does not exist."
return
fi
# Grant full access to the directory for the specified user
if chown -R "$username:$username" "$directory" && chmod -R 700 "$directory"; then
echo "Access granted successfully."
else
echo "An error occurred."
fi
}
# Call the function
grant_directory_access

154
games.sql Normal file
View file

@ -0,0 +1,154 @@
-- phpMyAdmin SQL Dump
-- version 4.9.5deb2
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Generation Time: Aug 01, 2023 at 06:12 PM
-- Server version: 10.3.22-MariaDB-1ubuntu1
-- PHP Version: 7.4.3
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `web`
--
-- --------------------------------------------------------
--
-- Table structure for table `games_in_holding`
--
CREATE TABLE `games_in_holding` (
`id` int(11) NOT NULL,
`submitter` varchar(255) DEFAULT NULL,
`link_to_game` varchar(255) DEFAULT NULL,
`name_of_game` varchar(255) DEFAULT NULL,
`description` text DEFAULT NULL,
`tags` varchar(255) DEFAULT NULL,
`game_icon_url` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `games_in_holding`
--
INSERT INTO `games_in_holding` (`id`, `submitter`, `link_to_game`, `name_of_game`, `description`, `tags`, `game_icon_url`) VALUES
(6, 't', 't', 't', 't', 't', 't');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`username` varchar(50) NOT NULL,
`password` varchar(255) NOT NULL,
`created_at` datetime DEFAULT current_timestamp(),
`directory_created` tinyint(1) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `username`, `password`, `created_at`, `directory_created`) VALUES
(2, 'Griff', '$2y$10$ssk2xQ2PHC/4YFrSqjLRbO0WS0SNW.rQ2O.C/gHk1hWvhor4P7s0q', '2023-05-29 23:16:02', 0),
(3, 'test', '$2y$10$9hKSNMF0pkFkuDu9GTtJ0eCjY5JzNu/QI9Q3zzpmjk.BvUTLqsLfG', '2023-06-08 01:21:14', 0),
(4, 'test1', '$2y$10$tRtM.6y/KtDMilpC5n62De3j6INR9dEAmB7GsFdXySibUz/N0kp7q', '2023-06-08 01:25:12', 0),
(5, 'admin', '$2y$10$oZMyuHAReAxaW7OS1127yO5XyNV5qNcQOcSRTuaoJ0hn0F2.8RbKi', '2023-08-01 16:47:21', 0);
-- --------------------------------------------------------
--
-- Table structure for table `your_table_name`
--
CREATE TABLE `your_table_name` (
`ID` int(11) NOT NULL,
`Date_Added` date NOT NULL,
`Submitter` varchar(255) NOT NULL,
`link_to_game` varchar(255) NOT NULL,
`description` text NOT NULL,
`tags` varchar(255) DEFAULT NULL,
`thumbnail_url` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `your_table_name`
--
INSERT INTO `your_table_name` (`ID`, `Date_Added`, `Submitter`, `link_to_game`, `description`, `tags`, `thumbnail_url`) VALUES
(1, '2023-05-11', 'Hungry Giraffe Games', 'https://v6p9d9t4.ssl.hwcdn.net/html/6565980/polyrun/GameData/index.html', 'Polyrun', 'unity', 'https://img.itch.zone/aW1nLzEwMTQxOTgyLnBuZw==/315x250%23c/B5eZOp.png'),
(2, '2023-05-11', 'Hungry Giraffe Games', 'https://arcade.makecode.com/47432-80093-12157-98586', 'Climate Combat', 'makecode', 'assets/icons/climate-combat/icon.jpg'),
(3, '2023-05-11', 'Dolphin Coders', 'roblox://placeId=6375756571', 'Dolphin\'s DCO (Roblox)', 'roblox', 'https://tr.rbxcdn.com/465eb228ede4742b5de5ea307fd1fc61/150/150/Image/Png'),
(4, '2023-05-13', 'HungryGiraffeGames', 'https://v6p9d9t4.ssl.hwcdn.net/html/8057523/Build1.2/index.html', 'Mario Party - Black Belt Project', 'unity', 'https://img.itch.zone/aW1nLzEyMDg4Mzc4LnBuZw==/347x500/QoGP%2FP.png'),
(5, '2023-05-11', 'Zombie Island', 'https://gdp.code.ninja/Public/Play/WA4KYm8dPk', 'Zombie Island', 'gdp', 'assets/icons/zombie-island/icon.jpg'),
(6, '2023-05-15', 'Business Tycoon', 'https://scratch.mit.edu/projects/315791076/embed', 'Business Tycoon', 'scratch', 'assets/icons/business-tycoon/icon.jpg'),
(12, '2023-06-07', 'Voxel Game', 'assets/games/voxel/index.html', 'Voxel Game', 'web', 'assets/icons/voxel/icon.jpg'),
(13, '2023-06-07', 'Circle Game', 'assets/games/circle/index.html', 'Circle Game', 'web', 'assets/icons/circle/circle.jpg'),
(14, '2023-06-08', 'King of the hill - Roblox', 'roblox://placeId=5658651217', 'King of the hill - Roblox', 'roblox', 'https://tr.rbxcdn.com/bd1cd8c17127205364a4c04b8c563146/768/432/Image/Png'),
(15, '2023-06-08', 'Racing - Roblox', 'roblox://placeId=4382862134', 'Racing - Roblox', 'roblox', 'https://tr.rbxcdn.com/9eee16734b959911b128d9fc3fec9424/150/150/Image/Png'),
(16, '2023-06-08', 'Stranded - Roblox', 'roblox://placeId=5664506069', 'Stranded- Roblox', 'roblox', 'https://tr.rbxcdn.com/231cec87bdd28b8479f08ed3b7dd4199/768/432/Image/Png'),
(17, '2023-06-08', 'McDonalds Simulator - Roblox', 'roblox://placeId=6418182032', 'McDonalds Simulator - Roblox', 'roblox', 'https://t6.rbxcdn.com/df24feec0aae3d42d244d0fe6046d508');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `games_in_holding`
--
ALTER TABLE `games_in_holding`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `username` (`username`);
--
-- Indexes for table `your_table_name`
--
ALTER TABLE `your_table_name`
ADD PRIMARY KEY (`ID`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `games_in_holding`
--
ALTER TABLE `games_in_holding`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `your_table_name`
--
ALTER TABLE `your_table_name`
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

91
index.php Normal file
View file

@ -0,0 +1,91 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Game List</title>
<link rel="stylesheet" type="text/css" href="mystyle.css">
<style>
.game img {
max-width: 200px;
max-height: 200px;
object-fit: contain;
}
.top-bar {
background-color: #F47920;
padding: 10px;
color: white;
display: flex;
justify-content: space-between;
align-items: center;
}
.top-bar h1 {
margin: 0;
}
.top-bar a {
color: white;
text-decoration: none;
margin-left: 10px;
}
.top-bar .submit-button {
background-color: white;
color: #F47920;
border: none;
padding: 8px 16px;
border-radius: 4px;
font-weight: bold;
}
</style>
</head>
<body>
<div class="top-bar">
<h1>Game List</h1>
<div>
<a href="?type=unity">Unity Games</a>
<a href="?type=roblox">Roblox Games</a>
<a href="?type=gdp">GDP Games</a>
<a href="?type=makecode">Makecode Games</a>
<a href="?type=scratch">Scratch Games</a>
<a href="?type=web">Web Games</a>
</div>
<button class="submit-button" onclick="location.href='submissionform.html'">Submit Games</button>
<button class="submit-button" onclick="location.href='login.php'">Login</button>
</div>
<?php
$host = 'localhost';
$username = 'web';
$password = 'web';
$dbname = 'web';
$conn = mysqli_connect($host, $username, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$filter = isset($_GET['type']) ? $_GET['type'] : '';
$sql = "SELECT * FROM your_table_name";
if (!empty($filter)) {
$filter = mysqli_real_escape_string($conn, $filter);
$sql .= " WHERE tags LIKE '%$filter%'";
}
$sql .= " ORDER BY RAND()";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
echo "<div class='game-list'>";
while ($row = mysqli_fetch_assoc($result)) {
echo "<div class='game' onclick='location.href=\"play_game.php?id={$row['ID']}\"'>";
echo "<img src='{$row['thumbnail_url']}' alt='Game Thumbnail'>";
echo "<p>{$row['description']}</p>";
echo "</div>";
}
echo "</div>";
} else {
echo "No games found.";
}
?>
</body>
</html>

56
index2.php Normal file
View file

@ -0,0 +1,56 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Game List</title>
<link rel="stylesheet" type="text/css" href="mystyle.css">
<style>
/* Additional styles for game list page */
.game img {
max-width: 100%;
max-height: 100%;
object-fit: contain;
}
</style>
</head>
<body>
<h1>Game List</h1>
<?php
$host = 'localhost';
$username = 'web';
$password = 'web';
$dbname = 'web';
// Create connection
$conn = mysqli_connect($host, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// Retrieve games from table (ordered by DateAdded in descending order)
$sql = "SELECT * FROM your_table_name ORDER BY DateAdded DESC";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// Output games in a grid layout
echo "<div class='game-list'>";
while ($row = mysqli_fetch_assoc($result)) {
echo "<div class='game' onclick='location.href=\"play_game.php?id={$row['ID']}\"'>";
echo "<img src='{$row['thumbnail_url']}' alt='Game Thumbnail'>";
echo "<p>{$row['description']}</p>";
echo "</div>";
}
echo "</div>";
} else {
echo "No games found.";
}
// Close connection
mysqli_close($conn);
?>
</body>
</html>

131
login.php Normal file
View file

@ -0,0 +1,131 @@
<?php
// Initialize the session
session_start();
// Check if the user is already logged in, if yes then redirect him to welcome page
if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true){
header("location: welcome.php");
exit;
}
// Include config file
require_once "config.php";
// Define variables and initialize with empty values
$username = $password = "";
$username_err = $password_err = $login_err = "";
// Processing form data when form is submitted
if($_SERVER["REQUEST_METHOD"] == "POST"){
// Check if username is empty
if(empty(trim($_POST["username"]))){
$username_err = "Please enter username.";
} else{
$username = trim($_POST["username"]);
}
// Check if password is empty
if(empty(trim($_POST["password"]))){
$password_err = "Please enter your password.";
} else{
$password = trim($_POST["password"]);
}
// Validate credentials
if(empty($username_err) && empty($password_err)){
// Prepare a select statement
$sql = "SELECT id, username, password FROM users WHERE username = ?";
if($stmt = mysqli_prepare($link, $sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "s", $param_username);
// Set parameters
$param_username = $username;
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
// Store result
mysqli_stmt_store_result($stmt);
// Check if username exists, if yes then verify password
if(mysqli_stmt_num_rows($stmt) == 1){
// Bind result variables
mysqli_stmt_bind_result($stmt, $id, $username, $hashed_password);
if(mysqli_stmt_fetch($stmt)){
if(password_verify($password, $hashed_password)){
// Password is correct, so start a new session
session_start();
// Store data in session variables
$_SESSION["loggedin"] = true;
$_SESSION["id"] = $id;
$_SESSION["username"] = $username;
// Redirect user to welcome page
header("location: welcome.php");
} else{
// Password is not valid, display a generic error message
$login_err = "Invalid username or password.";
}
}
} else{
// Username doesn't exist, display a generic error message
$login_err = "Invalid username or password.";
}
} else{
echo "Oops! Something went wrong. Please try again later.";
}
// Close statement
mysqli_stmt_close($stmt);
}
}
// Close connection
mysqli_close($link);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login</title>
<link rel="stylesheet" href="mystyle.css">
<style>
body{ font: 14px sans-serif; }
.wrapper{ width: 360px; padding: 20px; }
</style>
</head>
<body>
<div class="wrapper">
<h2>Login</h2>
<p>Please fill in your credentials to login.</p>
<?php
if(!empty($login_err)){
echo '<div class="alert alert-danger">' . $login_err . '</div>';
}
?>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
<div class="form-group">
<label>Username</label>
<input type="text" name="username" class="form-control <?php echo (!empty($username_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $username; ?>">
<span class="invalid-feedback"><?php echo $username_err; ?></span>
</div>
<div class="form-group">
<label>Password</label>
<input type="password" name="password" class="form-control <?php echo (!empty($password_err)) ? 'is-invalid' : ''; ?>">
<span class="invalid-feedback"><?php echo $password_err; ?></span>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Login">
</div>
<p>Don't have an account? <a href="register.php">Sign up now</a>.</p>
</form>
</div>
</body>
</html>

14
logout.php Normal file
View file

@ -0,0 +1,14 @@
<?php
// Initialize the session
session_start();
// Unset all of the session variables
$_SESSION = array();
// Destroy the session.
session_destroy();
// Redirect to login page
header("location: login.php");
exit;
?>

366
mystyle.css Normal file
View file

@ -0,0 +1,366 @@
/* Game List Styles */
.game-list {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
grid-gap: 20px;
justify-items: center;
}
.game {
width: 100%;
background-color: #fff;
border-radius: 10px;
padding: 20px;
text-align: center;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}
.game img {
max-width: 100%;
max-height: 100%;
object-fit: contain;
border-radius: 10px;
}
.game p {
margin-top: 10px;
}
/* Top Bar Styles */
.top-bar {
background-color: #F47920;
padding: 10px;
color: white;
display: flex;
justify-content: space-between;
align-items: center;
}
.top-bar h1 {
margin: 0;
}
.top-bar a {
color: white;
text-decoration: none;
margin-left: 10px;
}
.submit-button {
background-color: white;
color: #F47920;
border: none;
padding: 8px 16px;
border-radius: 4px;
font-weight: bold;
}
/* Page Styles */
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
margin: 0;
padding: 0;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
h1 {
color: #F47920;
text-align: center;
}
.game-list {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 20px;
}
.game {
background-color: #fff;
border-radius: 10px;
padding: 20px;
text-align: center;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}
.game img {
max-width: 100%;
max-height: 100%;
object-fit: contain;
border-radius: 10px;
}
.game p {
margin-top: 10px;
}
/* Page Styles */
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
margin: 0;
padding: 0;
}
.container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}
h1 {
color: #F47920;
text-align: center;
}
form {
display: grid;
grid-gap: 2px;
}
label {
font-weight: bold;
}
input[type="text"],
textarea {
width: 100%;
padding: 2px;
border-radius: 4px;
border: 1px solid #ccc;
}
input[type="submit"] {
background-color: #F47920;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 4px;
font-weight: bold;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #E35D00;
}
/* Additional Styles for welcome.php */
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}
h1 {
color: #F47920;
text-align: center;
margin-top: 50px;
margin-bottom: 50px;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th,
td {
padding: 10px;
text-align: left;
border-bottom: 1px solid #ddd;
}
tr:last-child td {
border-bottom: none;
}
.approve-button {
background-color: #F47920;
color: #fff;
border: none;
padding: 8px 16px;
border-radius: 4px;
font-weight: bold;
cursor: pointer;
}
.approve-button:hover {
background-color: #E35D00;
}
/* Top Bar Styles */
.top-bar {
background-color: #F47920;
padding: 10px;
color: white;
display: flex;
justify-content: space-between;
align-items: center;
}
.top-bar h1 {
margin: 0;
}
.top-bar a {
color: white;
text-decoration: none;
margin-left: 10px;
}
.submit-button {
background-color: white;
color: #F47920;
border: none;
padding: 8px 16px;
border-radius: 4px;
font-weight: bold;
}
/* Additional Styles for welcome.php */
/* Top Bar Styles */
.top-bar {
background-color: #F47920;
padding: 10px;
color: white;
display: flex;
justify-content: space-between;
align-items: center;
}
.top-bar h1 {
margin: 0;
}
.top-bar a {
color: white;
text-decoration: none;
margin-left: 10px;
}
.submit-button {
background-color: white;
color: #F47920;
border: none;
padding: 8px 16px;
border-radius: 4px;
font-weight: bold;
}
/* Additional Styles for welcome.php */
/* Nav Bar Styles */
.nav-bar {
background-color: #F47920;
padding: 10px;
color: white;
display: flex;
justify-content: space-between;
align-items: center;
}
.nav-bar h1 {
margin: 0;
}
.nav-bar a {
color: white;
text-decoration: none;
margin-left: 10px;
}
.submit-button {
background-color: white;
color: #F47920;
border: none;
padding: 8px 16px;
border-radius: 4px;
font-weight: bold;
}
/* Additional Styles for welcome.php */
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}
h1 {
color: #F47920;
text-align: center;
margin-top: 50px;
margin-bottom: 50px;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th,
td {
padding: 10px;
text-align: left;
border-bottom: 1px solid #ddd;
}
tr:last-child td {
border-bottom: none;
}
.approve-button {
background-color: #F47920;
color: #fff;
border: none;
padding: 8px 16px;
border-radius: 4px;
font-weight: bold;
cursor: pointer;
}
.approve-button:hover {
background-color: #E35D00;
}
/* Additional Styles for welcome.php */
.navbar {
background-color: #F47920;
color: white;
}
.navbar ul {
list-style-type: none;
padding: 0;
margin: 0;
}
.navbar ul li {
display: inline-block;
margin-right: 10px;
}
.navbar ul li a {
color: white;
text-decoration: none;
padding: 10px;
}
.navbar ul li a {
color: #F47920; /* Replace with your desired color value */
text-decoration: none;
padding: 10px;
}

68
play_game.php Normal file
View file

@ -0,0 +1,68 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Play Game</title>
<link rel="stylesheet" href="mystyle.css">
<style>
/* Style the iframe container */
.iframe-container {
position: relative;
overflow: hidden;
width: 100%;
padding-top: 56.25%; /* Maintain a 16:9 aspect ratio (9 / 16 = 0.5625) */
}
/* Style the iframe */
.iframe-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: none;
}
</style>
<script>
function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.documentElement.scrollHeight + 'px';
}
</script>
</head>
<body>
<h1>Play Game</h1>
<?php
$host = '127.0.0.1';
$username = 'web';
$password = 'web';
$dbname = 'web';
// Get game ID from query parameter
$game_id = $_GET['id'];
// Create connection
$conn = mysqli_connect($host, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// Retrieve game from table
$sql = "SELECT * FROM your_table_name WHERE ID = $game_id";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// Output game information
$row = mysqli_fetch_assoc($result);
echo "<div class='iframe-container'><iframe src='{$row['link_to_game']}' onload='resizeIframe(this)'></iframe></div>";
} else {
echo "Game not found.";
}
// Close connection
mysqli_close($conn);
?>
</body>
</html>

156
register.php Normal file
View file

@ -0,0 +1,156 @@
<?php
// Include config file
require_once "config.php";
// Define variables and initialize with empty values
$username = $password = $confirm_password = "";
$username_err = $password_err = $confirm_password_err = "";
// Processing form data when form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Validate username
if (empty(trim($_POST["username"]))) {
$username_err = "Please enter a username.";
} elseif (!preg_match('/^[a-zA-Z0-9_]+$/', trim($_POST["username"]))) {
$username_err = "Username can only contain letters, numbers, and underscores.";
} else {
// Prepare a select statement
$sql = "SELECT id FROM users WHERE username = ?";
if ($stmt = mysqli_prepare($link, $sql)) {
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "s", $param_username);
// Set parameters
$param_username = trim($_POST["username"]);
// Attempt to execute the prepared statement
if (mysqli_stmt_execute($stmt)) {
/* store result */
mysqli_stmt_store_result($stmt);
if (mysqli_stmt_num_rows($stmt) == 1) {
$username_err = "This username is already taken.";
} else {
$username = trim($_POST["username"]);
}
} else {
echo "Oops! Something went wrong. Please try again later.";
}
// Close statement
mysqli_stmt_close($stmt);
}
}
// Validate password
if (empty(trim($_POST["password"]))) {
$password_err = "Please enter a password.";
} elseif (strlen(trim($_POST["password"])) < 6) {
$password_err = "Password must have at least 6 characters.";
} else {
$password = trim($_POST["password"]);
}
// Validate confirm password
if (empty(trim($_POST["confirm_password"]))) {
$confirm_password_err = "Please confirm password.";
} else {
$confirm_password = trim($_POST["confirm_password"]);
if (empty($password_err) && ($password != $confirm_password)) {
$confirm_password_err = "Password did not match.";
}
}
// Check input errors before inserting in database
if (empty($username_err) && empty($password_err) && empty($confirm_password_err)) {
// Prepare an insert statement
$sql = "INSERT INTO users (username, password) VALUES (?, ?)";
if ($stmt = mysqli_prepare($link, $sql)) {
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "ss", $param_username, $param_password);
// Set parameters
$param_username = $username;
$param_password = password_hash($password, PASSWORD_DEFAULT); // Creates a password hash
// Attempt to execute the prepared statement
if (mysqli_stmt_execute($stmt)) {
// Get the inserted user ID
$user_id = mysqli_insert_id($link);
// Create the directory
$directory = "users/" . $user_id;
if (!is_dir($directory)) {
mkdir($directory, 0777, true);
}
// Redirect to login page
header("location: login.php");
exit;
} else {
echo "Oops! Something went wrong. Please try again later.";
}
// Close statement
mysqli_stmt_close($stmt);
}
}
// Close connection
mysqli_close($link);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Sign Up</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
body {
font: 14px sans-serif;
}
.wrapper {
width: 360px;
padding: 20px;
}
</style>
</head>
<body>
<div class="wrapper">
<h2>Sign Up</h2>
<p>Please fill this form to create an account.</p>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
<div class="form-group">
<label>Username</label>
<input type="text" name="username" class="form-control <?php echo (!empty($username_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $username; ?>">
<span class="invalid-feedback"><?php echo $username_err; ?></span>
</div>
<div class="form-group">
<label>Password</label>
<input type="password" name="password" class="form-control <?php echo (!empty($password_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $password; ?>">
<span class="invalid-feedback"><?php echo $password_err; ?></span>
</div>
<div class="form-group">
<label>Confirm Password</label>
<input type="password" name="confirm_password" class="form-control <?php echo (!empty($confirm_password_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $confirm_password; ?>">
<span class="invalid-feedback"><?php echo $confirm_password_err; ?></span>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Submit">
<input type="reset" class="btn btn-secondary ml-2" value="Reset">
</div>
<p>Already have an account? <a href="login.php">Login here</a>.</p>
</form>
</div>
</body>
</html>

137
register.php.backup Normal file
View file

@ -0,0 +1,137 @@
<?php
// Include config file
require_once "config.php";
// Define variables and initialize with empty values
$username = $password = $confirm_password = "";
$username_err = $password_err = $confirm_password_err = "";
// Processing form data when form is submitted
if($_SERVER["REQUEST_METHOD"] == "POST"){
// Validate username
if(empty(trim($_POST["username"]))){
$username_err = "Please enter a username.";
} elseif(!preg_match('/^[a-zA-Z0-9_]+$/', trim($_POST["username"]))){
$username_err = "Username can only contain letters, numbers, and underscores.";
} else{
// Prepare a select statement
$sql = "SELECT id FROM users WHERE username = ?";
if($stmt = mysqli_prepare($link, $sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "s", $param_username);
// Set parameters
$param_username = trim($_POST["username"]);
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
/* store result */
mysqli_stmt_store_result($stmt);
if(mysqli_stmt_num_rows($stmt) == 1){
$username_err = "This username is already taken.";
} else{
$username = trim($_POST["username"]);
}
} else{
echo "Oops! Something went wrong. Please try again later.";
}
// Close statement
mysqli_stmt_close($stmt);
}
}
// Validate password
if(empty(trim($_POST["password"]))){
$password_err = "Please enter a password.";
} elseif(strlen(trim($_POST["password"])) < 6){
$password_err = "Password must have atleast 6 characters.";
} else{
$password = trim($_POST["password"]);
}
// Validate confirm password
if(empty(trim($_POST["confirm_password"]))){
$confirm_password_err = "Please confirm password.";
} else{
$confirm_password = trim($_POST["confirm_password"]);
if(empty($password_err) && ($password != $confirm_password)){
$confirm_password_err = "Password did not match.";
}
}
// Check input errors before inserting in database
if(empty($username_err) && empty($password_err) && empty($confirm_password_err)){
// Prepare an insert statement
$sql = "INSERT INTO users (username, password) VALUES (?, ?)";
if($stmt = mysqli_prepare($link, $sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "ss", $param_username, $param_password);
// Set parameters
$param_username = $username;
$param_password = password_hash($password, PASSWORD_DEFAULT); // Creates a password hash
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
// Redirect to login page
header("location: login.php");
} else{
echo "Oops! Something went wrong. Please try again later.";
}
// Close statement
mysqli_stmt_close($stmt);
}
}
// Close connection
mysqli_close($link);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Sign Up</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
body{ font: 14px sans-serif; }
.wrapper{ width: 360px; padding: 20px; }
</style>
</head>
<body>
<div class="wrapper">
<h2>Sign Up</h2>
<p>Please fill this form to create an account.</p>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
<div class="form-group">
<label>Username</label>
<input type="text" name="username" class="form-control <?php echo (!empty($username_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $username; ?>">
<span class="invalid-feedback"><?php echo $username_err; ?></span>
</div>
<div class="form-group">
<label>Password</label>
<input type="password" name="password" class="form-control <?php echo (!empty($password_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $password; ?>">
<span class="invalid-feedback"><?php echo $password_err; ?></span>
</div>
<div class="form-group">
<label>Confirm Password</label>
<input type="password" name="confirm_password" class="form-control <?php echo (!empty($confirm_password_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $confirm_password; ?>">
<span class="invalid-feedback"><?php echo $confirm_password_err; ?></span>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Submit">
<input type="reset" class="btn btn-secondary ml-2" value="Reset">
</div>
<p>Already have an account? <a href="login.php">Login here</a>.</p>
</form>
</div>
</body>
</html>

106
reset-password.php Normal file
View file

@ -0,0 +1,106 @@
<?php
// Initialize the session
session_start();
// Check if the user is logged in, otherwise redirect to login page
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
header("location: login.php");
exit;
}
// Include config file
require_once "config.php";
// Define variables and initialize with empty values
$new_password = $confirm_password = "";
$new_password_err = $confirm_password_err = "";
// Processing form data when form is submitted
if($_SERVER["REQUEST_METHOD"] == "POST"){
// Validate new password
if(empty(trim($_POST["new_password"]))){
$new_password_err = "Please enter the new password.";
} elseif(strlen(trim($_POST["new_password"])) < 6){
$new_password_err = "Password must have atleast 6 characters.";
} else{
$new_password = trim($_POST["new_password"]);
}
// Validate confirm password
if(empty(trim($_POST["confirm_password"]))){
$confirm_password_err = "Please confirm the password.";
} else{
$confirm_password = trim($_POST["confirm_password"]);
if(empty($new_password_err) && ($new_password != $confirm_password)){
$confirm_password_err = "Password did not match.";
}
}
// Check input errors before updating the database
if(empty($new_password_err) && empty($confirm_password_err)){
// Prepare an update statement
$sql = "UPDATE users SET password = ? WHERE id = ?";
if($stmt = mysqli_prepare($link, $sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "si", $param_password, $param_id);
// Set parameters
$param_password = password_hash($new_password, PASSWORD_DEFAULT);
$param_id = $_SESSION["id"];
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
// Password updated successfully. Destroy the session, and redirect to login page
session_destroy();
header("location: login.php");
exit();
} else{
echo "Oops! Something went wrong. Please try again later.";
}
// Close statement
mysqli_stmt_close($stmt);
}
}
// Close connection
mysqli_close($link);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Reset Password</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
body{ font: 14px sans-serif; }
.wrapper{ width: 360px; padding: 20px; }
</style>
</head>
<body>
<div class="wrapper">
<h2>Reset Password</h2>
<p>Please fill out this form to reset your password.</p>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
<div class="form-group">
<label>New Password</label>
<input type="password" name="new_password" class="form-control <?php echo (!empty($new_password_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $new_password; ?>">
<span class="invalid-feedback"><?php echo $new_password_err; ?></span>
</div>
<div class="form-group">
<label>Confirm Password</label>
<input type="password" name="confirm_password" class="form-control <?php echo (!empty($confirm_password_err)) ? 'is-invalid' : ''; ?>">
<span class="invalid-feedback"><?php echo $confirm_password_err; ?></span>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Submit">
<a class="btn btn-link ml-2" href="welcome.php">Cancel</a>
</div>
</form>
</div>
</body>
</html>

55
scanandcreateusers.sh Normal file
View file

@ -0,0 +1,55 @@
#!/bin/bash
# MySQL database credentials
DB_HOST="localhost"
DB_USER="web"
DB_PASS="web"
DB_NAME="web"
# Directory where user directories will be created
BASE_DIR="users"
# Query to select new users
QUERY="SELECT id, username, created_at FROM users WHERE directory_created = 0"
# Execute the query
RESULT=$(mysql -u "$DB_USER" -p"$DB_PASS" -h "$DB_HOST" -D "$DB_NAME" -N -e "$QUERY")
# Loop through the result and create directories
while IFS=$'\t' read -r user_id username created_at; do
directory="$BASE_DIR/$user_id"
backup_directory="$directory/backup"
# Check if the directory already exists
if [ -d "$directory" ]; then
echo "Directory already exists for user: $username"
# Move existing files to backup directory
mkdir -p "$backup_directory"
mv "$directory"/* "$backup_directory"
echo "Existing files moved to backup directory for user: $username"
else
# Create the directory
mkdir -p "$directory"
if [ $? -eq 0 ]; then
echo "Directory created for user: $username"
else
echo "Failed to create directory for user: $username"
continue
fi
fi
# Calculate account age
current_date=$(date +%Y-%m-%d)
account_age=$(($(($(date -d "$current_date" +%s) - $(date -d "$created_at" +%s))) / 86400))
# Construct the JSON data
JSON_DATA=$(printf '{"id": "%s", "username": "%s", "dateCreated": "%s", "accountAge": "%d"}' "$user_id" "$username" "$created_at" "$account_age")
# Write JSON data to user.json file
echo "$JSON_DATA" >"$directory/user.json"
echo "User data backed up for user: $username"
# Update the directory_created flag in the database
mysql -u "$DB_USER" -p"$DB_PASS" -h "$DB_HOST" -D "$DB_NAME" -e "UPDATE users SET directory_created = 1 WHERE id = $user_id"
echo "Directory creation flag updated for user: $username"
done

32
submissionform.html Normal file
View file

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Game Submission Form</title>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
<body>
<h1>Game Submission Form</h1>
<form action="submit_game1.php" method="post">
<label for="submitter">Submitter:</label>
<input type="text" id="submitter" name="submitter" required><br><br>
<label for="link_to_game">Link to Game:</label>
<input type="text" id="link_to_game" name="link_to_game" required><br><br>
<label for="name_of_game">Name of Game:</label>
<input type="text" id="name_of_game" name="name_of_game" required><br><br>
<label for="description">Description:</label><br>
<textarea id="description" name="description" required></textarea><br><br>
<label for="tags">Tags:</label>
<input type="text" id="tags" name="tags"><br><br>
<label for="game_icon_url">Game Icon URL:</label>
<input type="text" id="game_icon_url" name="game_icon_url"><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>

78
submit.html Normal file
View file

@ -0,0 +1,78 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Submit Game</title>
<link rel="stylesheet" type="text/css" href="mystyle.css">
<style>
/* Additional styles for submission form */
.form-container {
max-width: 500px;
margin: 0 auto;
padding: 20px;
background-color: #FFF;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.form-container label {
display: block;
margin-bottom: 10px;
}
.form-container input[type="text"],
.form-container textarea,
.form-container select {
width: 100%;
padding: 10px;
border: 1px solid #CCC;
border-radius: 4px;
}
.form-container input[type="submit"] {
background-color: #F48024;
color: #FFF;
border: none;
padding: 10px 20px;
border-radius: 4px;
cursor: pointer;
}
.form-container input[type="submit"]:hover {
background-color: #E56B0A;
}
</style>
</head>
<body>
<div class="form-container">
<h1>Submit Game</h1>
<form action="submit_game.php" method="post">
<label for="title">Title:</label>
<input type="text" name="title" id="title" required>
<label for="description">Description:</label>
<textarea name="description" id="description" rows="4" required></textarea>
<label for="tags">Tags:</label>
<select name="tags" id="tags" required>
<option value="">Select Tag</option>
<option value="unity">Unity</option>
<option value="gdp">GDP</option>
<option value="makecode">Makecode</option>
<option value="roblox">Roblox</option>
<option value="scratch">Scratch</option>
<option value="web">Web</option>
</select>
<label for="thumbnail">Thumbnail URL:</label>
<input type="text" name="thumbnail" id="thumbnail">
<label for="game_url">Game URL:</label>
<input type="text" name="game_url" id="game_url" required>
<input type="submit" value="Submit">
</form>
</div>
</body>
</html>

40
submit_game.php Normal file
View file

@ -0,0 +1,40 @@
<?php
$host = 'localhost';
$username = 'web';
$password = 'web';
$dbname = 'web';
// Create connection
$conn = new mysqli($host, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($_SERVER["REQUEST_METHOD"] === "POST") {
$title = $_POST['title'];
$description = $_POST['description'];
$tags = $_POST['tags'];
$thumbnail = $_POST['thumbnail'];
$gameUrl = $_POST['game_url'];
// Prepare and execute the SQL query
$sql = "INSERT INTO your_table_name (Submitter, link_to_game, description, tags, thumbnail_url, Date_Added) VALUES (?, ?, ?, ?, ?, NOW())";
$stmt = $conn->prepare($sql);
$stmt->bind_param("sssss", $title, $gameUrl, $description, $tags, $thumbnail);
if ($stmt->execute()) {
$lastInsertId = $stmt->insert_id;
echo "Game submitted successfully! The game ID is: " . $lastInsertId;
} else {
echo "Failed to submit game. Error: " . $stmt->error;
}
// Close statement
$stmt->close();
}
// Close connection
$conn->close();
?>

43
submit_game1.php Normal file
View file

@ -0,0 +1,43 @@
<?php
$host = 'localhost';
$username = 'web';
$password = 'web';
$dbname = 'web';
// Create connection
$conn = new mysqli($host, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$submitter = $_POST["submitter"];
$link_to_game = $_POST["link_to_game"];
$name_of_game = $_POST["name_of_game"];
$description = $_POST["description"];
$tags = $_POST["tags"];
$game_icon_url = $_POST["game_icon_url"];
// Prepare the SQL statement
$sql = "INSERT INTO games_in_holding (submitter, link_to_game, name_of_game, description, tags, game_icon_url) VALUES (?, ?, ?, ?, ?, ?)";
// Prepare and bind the parameters
$stmt = $conn->prepare($sql);
$stmt->bind_param("ssssss", $submitter, $link_to_game, $name_of_game, $description, $tags, $game_icon_url);
// Execute the statement
if ($stmt->execute()) {
echo "Game submitted successfully.";
} else {
echo "Error submitting the game.";
}
// Close the statement
$stmt->close();
}
// Close the database connection
$conn->close();
?>

73
welcome.php Normal file
View file

@ -0,0 +1,73 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Welcome</title>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
<body>
<header class="navbar">
<div class="container">
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="submit.html">Submit</a></li>
<li><a href="reset-password.php">Reset Password</a></li>
<li><a href="logout.php" class="active">Logout</a></li>
</ul>
</div>
</header>
<div class="container">
<h1 class="my-5">Hi, <b><?php echo htmlspecialchars($_SESSION["username"]); ?></b>. Welcome to our site.</h1>
<table>
<thead>
<tr>
<th>Submitter</th>
<th>Link to Game</th>
<th>Name of Game</th>
<th>Description</th>
<th>Tags</th>
<th>Game Icon URL</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$host = 'localhost';
$username = 'web';
$password = 'web';
$dbname = 'web';
$conn = mysqli_connect($host, $username, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT * FROM games_in_holding";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td>" . $row['submitter'] . "</td>";
echo "<td>" . $row['link_to_game'] . "</td>";
echo "<td>" . $row['name_of_game'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "<td>" . $row['tags'] . "</td>";
echo "<td>" . $row['game_icon_url'] . "</td>";
var_dump($row['ID']); // Add this line
echo "<td><a href=\"delete_game.php?id=" . $row['ID'] . "\">Delete</a></td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan=\"7\">No games found.</td></tr>";
}
mysqli_close($conn);
?>
</tbody>
</table>
</div>
</body>
</html>