Added routes
This commit is contained in:
@@ -22,6 +22,7 @@ function ZipFileHandler(string $gameFileName, string $gameFileTmp){
|
||||
return $gameFileNewName;
|
||||
}else{
|
||||
header("location: location: ../../../Frontend/index.html?error=Wrong%20File%20Type");
|
||||
exit();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -48,6 +49,7 @@ function imagesFileHandler(string $thumbnailFileName, string $thumbnailFileTmp){
|
||||
return $thumbnailFileNewName;
|
||||
}else{
|
||||
header("location: location: ../../../Frontend/index.html?error=Wrong%20File%20Type");
|
||||
exit();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -37,7 +37,13 @@ if(isLogin()){
|
||||
}
|
||||
$gameData->is_web_Based = $isWebBased;
|
||||
$gameData->save();
|
||||
header("location: ../../../Frontend/index.html?success=UpdatedFiles");
|
||||
exit();
|
||||
}else{
|
||||
header("location: ../../../Frontend/index.html?error=FailedUpload");
|
||||
exit();
|
||||
}
|
||||
}else{
|
||||
header("location: ../../../Frontend/index.html?error=NoLogin");
|
||||
exit();
|
||||
}
|
||||
@@ -3,9 +3,12 @@ require_once "../../../bootstrap.php";
|
||||
require_once('../Group/Group.php');
|
||||
require_once('FileHandler.php');
|
||||
use Backend\Models\GameData;
|
||||
use Backend\Models\GameJam;
|
||||
|
||||
use Backend\Models\Group;
|
||||
|
||||
date_default_timezone_set("Europe/Copenhagen");
|
||||
|
||||
$isImages = false;
|
||||
|
||||
|
||||
@@ -13,40 +16,59 @@ if(isLogin()){
|
||||
|
||||
$group = groupViaToken($_SESSION['token']);
|
||||
|
||||
if(!isset($group->game_data_id)){
|
||||
if(isset($_POST['submitUpload'])){
|
||||
//Get the data from the user form
|
||||
$gameFile = $_FILES['gameFile'];
|
||||
$desc = $_POST['description'];
|
||||
$title = $_POST['gameTitle'];
|
||||
$thumbnail = $_FILES['thumbnailFile'];
|
||||
$isWebBased = isset( $_POST['isWebBased']);
|
||||
$gameJam = GameJam::find($group->game_jam_id);
|
||||
$gameJamStartTime = strtotime($gameJam->start_time);
|
||||
$gameJamEndTime = strtotime($gameJam->end_time);
|
||||
$date = date('Y/m/d H:i:s', time());
|
||||
|
||||
$gameFileName = $_FILES['gameFile']['name'];//Game name
|
||||
$gameFileTmp = $_FILES['gameFile']['tmp_name'];//Tmp location of the file
|
||||
$gameFileError = $_FILES['gameFile']['error'];//File error
|
||||
$currentTime = strtotime($date);
|
||||
|
||||
$thumbnailFileName = $_FILES['thumbnailFile']['name'];//Game name
|
||||
$thumbnailFileTmp = $_FILES['thumbnailFile']['tmp_name'];//Tmp location of the file
|
||||
$thumbnailFileError =$_FILES['thumbnailFile']['error'];//File error
|
||||
if($gameJamStartTime <= $currentTime && $gameJamEndTime >= $currentTime){
|
||||
if(!isset($group->game_data_id)){
|
||||
if(isset($_POST['submitUpload'])){
|
||||
//Get the data from the user form
|
||||
$gameFile = $_FILES['gameFile'];
|
||||
$desc = $_POST['description'];
|
||||
$title = $_POST['gameTitle'];
|
||||
$thumbnail = $_FILES['thumbnailFile'];
|
||||
$isWebBased = isset( $_POST['isWebBased']);
|
||||
|
||||
if($gameFileError === 0){
|
||||
$gameData = new GameData();
|
||||
$gameData->game_name = $title;
|
||||
$gameData->game_link = ZipFileHandler($gameFileName,$gameFileTmp);
|
||||
$gameData->description = $desc;
|
||||
if(isset($thumbnail) && $thumbnailFileError === 0){
|
||||
$gameData->img = imagesFileHandler($thumbnailFileName,$thumbnailFileTmp);
|
||||
$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
|
||||
|
||||
if($gameFileError === 0){
|
||||
$gameData = new GameData();
|
||||
$gameData->game_name = $title;
|
||||
$gameData->game_link = ZipFileHandler($gameFileName,$gameFileTmp);
|
||||
$gameData->description = $desc;
|
||||
if(isset($thumbnail) && $thumbnailFileError === 0){
|
||||
$gameData->img = imagesFileHandler($thumbnailFileName,$thumbnailFileTmp);
|
||||
}
|
||||
$gameData->is_web_Based = $isWebBased;
|
||||
$gameData->save();
|
||||
$group->gameData()->associate($gameData);
|
||||
$group->save();
|
||||
header("location: ../../../Frontend/index.html?success=UploadedFile");
|
||||
exit();
|
||||
}
|
||||
$gameData->is_web_Based = $isWebBased;
|
||||
$gameData->save();
|
||||
$group->gameData()->associate($gameData);
|
||||
$group->save();
|
||||
}else{
|
||||
header("location: ../../../Frontend/group.php?error=UploadFail");
|
||||
exit();
|
||||
}
|
||||
}else{
|
||||
header("location: ../../../Frontend/group.php?error=TooManyUploads");
|
||||
exit();
|
||||
}
|
||||
}else{
|
||||
header("location: ../../../Frontend/index.html?error=TooManyUploads");
|
||||
header("location: ../../../Frontend/group.php?error=GameJamHasNotBegun");
|
||||
exit();
|
||||
}
|
||||
}else{
|
||||
header("location: ../../../Frontend/index.html?error=NoLogin");
|
||||
header("location: ../../../Main.php?error=NoLogin");
|
||||
exit();
|
||||
}
|
||||
Reference in New Issue
Block a user