Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
RundelhausCode 2021-03-09 13:30:06 +01:00
commit f8e947b2c0
1 changed files with 14 additions and 3 deletions

View File

@ -2,6 +2,8 @@
require_once "../../../bootstrap.php"; require_once "../../../bootstrap.php";
use Backend\Models\GameData; use Backend\Models\GameData;
$isImages = false;
if(isset($_POST['submitUpload'])){ if(isset($_POST['submitUpload'])){
//Get the data from the user form //Get the data from the user form
$gameFile = $_FILES['gameFile']; $gameFile = $_FILES['gameFile'];
@ -34,21 +36,30 @@ if(isset($_POST['submitUpload'])){
if(in_array($fileActualExtGame,$allowedFileTypeGame) || in_array($thumbnailFileName,$allowedFileTypeThumbnail)){ if(in_array($fileActualExtGame,$allowedFileTypeGame) || in_array($thumbnailFileName,$allowedFileTypeThumbnail)){
if($gameFileError === 0 || $thumbnailFileError === 0){ if($gameFileError === 0 || $thumbnailFileError === 0){
$gameFileNewName = uniqid("", true). "." . $fileActualExtGame; $gameFileNewName = uniqid("", true). "." . $fileActualExtGame;
if(!empty($thumbnailFileName)){
$thumbnailFileNewName = uniqid("", true). "." . $fileActualExtThumb; $thumbnailFileNewName = uniqid("", true). "." . $fileActualExtThumb;
$isImages = true;
}
if(empty($gameFileName)){ if(empty($gameFileName)){
header("location: ../../../Frontend/index.php?error=emptyFile"); header("location: ../../../Frontend/index.php?error=emptyFile");
exit(); exit();
}else{ }else{
$gameData = new GameData(); $gameData = new GameData();
$gameData->game_name = $title; $gameData->game_name = $title;
$gameData->game_link = $gameFileNewName; $gameData->game_link = $gameFileNewName;
$gameData->description = $desc; $gameData->description = $desc;
$gameData->img = $thumbnailFileNewName; if($isImages) $gameData->img = $thumbnailFileNewName;
$gameData->is_web_Based = $isWebBased; $gameData->is_web_Based = $isWebBased;
$gameData->save(); $gameData->save();
rename($gameFileTmp,"../../Games/".$gameFileNewName); rename($gameFileTmp,"../../Games/".$gameFileNewName);
rename($thumbnailFileTmp,"../../../Frontend/images/".$fileActualExtThumb); if($isImages){
rename($thumbnailFileTmp,"../../../Frontend/images/".$thumbnailFileNewName);
}
} }
}else{ }else{
echo "Der var en fejl med at uploade din file"; echo "Der var en fejl med at uploade din file";