Added files

This commit is contained in:
neerholt 2021-03-10 14:16:08 +01:00
parent 29e9bf10f3
commit 246cfad08a
5 changed files with 76 additions and 1 deletions

View File

@ -0,0 +1,45 @@
<?php
require_once "../../../bootstrap.php";
require_once('../Group/Group.php');
require_once('FileHandler.php');
use Backend\Models\GameData;
session_start();
if(isset($_SESSION['token'])){
if(isset($_POST['submitUpdate'])){
$gameFile = $_FILES['gameFile'];
$desc = $_POST['description'];
$title = $_POST['gameTitle'];
$thumbnail = $_FILES['thumbnailFile'];
$isWebBased = isset( $_POST['isWebBased']);
$gameFileName = $_FILES['gameFile']['name'];//Game name
$gameFileTmp = $_FILES['gameFile']['tmp_name'];//Tmp location of the file
$gameFileError = $_FILES['gameFile']['error'];//File error
$thumbnailFileName = $_FILES['thumbnailFile']['name'];//Game name
$thumbnailFileTmp = $_FILES['thumbnailFile']['tmp_name'];//Tmp location of the file
$thumbnailFileError =$_FILES['thumbnailFile']['error'];//File error
//Get the group
$group = groupViaToken($_SESSION['token']);
//Get the game data, from the group
$gameData = GameData::find($group->game_data_id);
$gameData->game_name = $title;
if(isset($gameData) && $gameFileError === 0){
unlink("../../Games/".$gameData->game_link);
$gameData->game_link = ZipFileHandler($gameFileName,$gameFileTmp);
}
$gameData->description = $desc;
if(isset($thumbnail) && $thumbnailFileError === 0){
unlink("../../../Frontend/images/".$gameData->img);
$gameData->img = imagesFileHandler($thumbnailFileName,$thumbnailFileTmp);
}
$gameData->is_web_Based = $isWebBased;
$gameData->save();
}
}else{
header("location: ../Backend/Main.php?error=NoLogin");
}

View File

@ -0,0 +1 @@
<?php

View File

@ -8,7 +8,7 @@
<body>
<form action="../Backend/Controllers/keyWordsRemaining.php" method="POST">
<form action="../Backend/Controllers/keyWord/keyWordsRemaining.php" method="POST">
<input type="text" name="key_word" placeholder="key word">
<input type="submit" name="submitKeyWord" value="Submit">
</form>

View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<center>
<h1>Hvis det er noget du ikke vil ændre lad feltet forblive tomt</h1>
<form action="../Backend/Controllers/FileHandler/updateFiles.php" method="POST" id="updateGame" enctype="multipart/form-data">
<input type="text" name="gameTitle" placeholder="Updater Titlen på spillet"><br><br>
<input type="text" name="description" placeholder="Opdater beskrivelse"><br><br>
<label for="uploadGame">Opdater spil [.zip]</label>
<input type="file" name="gameFile" id="uploadGame" placeholder="Opdater dit spil"><br><br>
<label for="uploadthumbnail">Opdater thumbnail [GIF, JPEG, PNG, SVG]</label>
<input type="file" name="thumbnailFile" id="uploadthumbnail" placeholder="Opdater en thumbnail"><br><br>
<label for="web">Opdater om spillet er web based</label>
<input type="checkbox" id="web" name="isWebBased" value="1"><br><br>
<input type="submit" name="submitUpdate" value="Opdater">
</form>
</center>
</body>
</html>