diff --git a/Backend/Controllers/Admin/AdminLogin.php b/Backend/Controllers/Admin/AdminLogin.php index bf4e497..0a66c21 100644 --- a/Backend/Controllers/Admin/AdminLogin.php +++ b/Backend/Controllers/Admin/AdminLogin.php @@ -23,14 +23,16 @@ if(isset($_POST['aLogin'])){ }else{ session_destroy(); header('location: ../../../Frontend/index.html?login=failed?reason=password'); + exit(); } - - } - else{ + }else{ session_destroy(); header('location: ../../../Frontend/index.html?login=failed?reason=username'); + exit(); } - +}else{ + header("location: ../../../Frontend/index.html?error=NoLogin"); + exit(); } \ No newline at end of file diff --git a/Backend/Controllers/FileHandler/FileHandler.php b/Backend/Controllers/FileHandler/FileHandler.php index 8759e5e..4e3acd5 100644 --- a/Backend/Controllers/FileHandler/FileHandler.php +++ b/Backend/Controllers/FileHandler/FileHandler.php @@ -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; } \ No newline at end of file diff --git a/Backend/Controllers/FileHandler/updateFiles.php b/Backend/Controllers/FileHandler/updateFiles.php index 14f2af7..014a53a 100644 --- a/Backend/Controllers/FileHandler/updateFiles.php +++ b/Backend/Controllers/FileHandler/updateFiles.php @@ -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(); } \ No newline at end of file diff --git a/Backend/Controllers/FileHandler/upload.php b/Backend/Controllers/FileHandler/upload.php index b71b1ba..4a7d61d 100644 --- a/Backend/Controllers/FileHandler/upload.php +++ b/Backend/Controllers/FileHandler/upload.php @@ -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(); } \ No newline at end of file diff --git a/Backend/Controllers/GameJam/NewGameJam.php b/Backend/Controllers/GameJam/NewGameJam.php index d27babe..f4101dd 100644 --- a/Backend/Controllers/GameJam/NewGameJam.php +++ b/Backend/Controllers/GameJam/NewGameJam.php @@ -17,10 +17,18 @@ if(isAdmin()){ $gameJam->description = $_POST["description"]; if($gameJam->save()){ - + header("location: ../../../Frontend/Html/AdminPage.html?success=UploadedFile"); + exit(); } else{ - + header("location: ../../../Frontend/Html/AdminPage.html?error=FailToSaveGameJam"); + exit(); } + }else{ + header("location: ../../../Frontend/Html/AdminPage.html?error=FailedToMakeGameJam"); + exit(); } +}else{ + header("location: ../../../Frontend/index.html?error=NotAdmin"); + exit(); } \ No newline at end of file diff --git a/Backend/Controllers/GameJam/UpdateGameJam.php b/Backend/Controllers/GameJam/UpdateGameJam.php index 7b7d9e5..5c4aa23 100644 --- a/Backend/Controllers/GameJam/UpdateGameJam.php +++ b/Backend/Controllers/GameJam/UpdateGameJam.php @@ -22,9 +22,16 @@ if(isAdmin()){ $gameJam->description = $_POST['description']; if ($gameJam->save()) { - + header("location: ../../../Frontend/Html/AdminPage.html?success=UpdatedFile"); + exit(); } } + }else{ + header("location: ../../../Frontend/Html/AdminPage.html?error=FailedToUpdatedGameJam"); + exit(); } +}else{ + header("location: ../../../Frontend/index.html?error=NotAdmin"); + exit(); } diff --git a/Backend/Controllers/Group/Login.php b/Backend/Controllers/Group/Login.php index be2188f..292cdb6 100644 --- a/Backend/Controllers/Group/Login.php +++ b/Backend/Controllers/Group/Login.php @@ -1,6 +1,6 @@ password = password_hash($_POST['newPassword'], PASSWORD_DEFAULT); echo $password; if(!$password->save()){ - + header("location: ../../../Frontend/Html/AdminPage.html?error=FailedSaveResetPassword"); + exit(); } }else{ - + header("location: ../../../Frontend/Html/AdminPage.html?success=SavedResetPassword"); + exit(); } + }else{ + header("location: ../../../Frontend/Html/AdminPage.html?error=FailedToResetPassword"); + exit(); } +}else{ + header("location: ../../../Frontend/index.html?error=NotAdmin"); + exit(); } \ No newline at end of file diff --git a/Backend/Controllers/Group/SigningUp.php b/Backend/Controllers/Group/SigningUp.php index 7989c83..fbf1d66 100644 --- a/Backend/Controllers/Group/SigningUp.php +++ b/Backend/Controllers/Group/SigningUp.php @@ -43,8 +43,13 @@ if(isset($_POST['regGroup'])){ $_SESSION['groupName'] = $groupName; $_SESSION['token'] = $token; $_SESSION['success'] = "You are now logged in"; - header('location: ../../../Frontend/index.html'); + header("location: ../../../Frontend/index.html?success=GroupRegister"); + exit(); }else{ - + header("location: ../../../Frontend/index.html?error=CouldNotValidatePassword"); + exit(); } +}else{ + header("location: ../../../Frontend/index.html?error=FailedRegister"); + exit(); } diff --git a/Backend/Controllers/Group/UpdateGruop.php b/Backend/Controllers/Group/UpdateGruop.php index cba549f..e54ff05 100644 --- a/Backend/Controllers/Group/UpdateGruop.php +++ b/Backend/Controllers/Group/UpdateGruop.php @@ -11,8 +11,16 @@ if(isLogin()){ $group->group_amount = $_POST['groupAmount']; $group->game_jam_id = $_POST['gameJamId']; $group->save(); + header("location: ../../../Frontend/index.html?success=YouHaveUpdated"); + exit(); } + }else{ + header("location: ../../../Frontend/index.html?error=CouldNotUpdate"); + exit(); } +}else{ + header("location: ../../../Frontend/index.html?error=NotLogin"); + exit(); } diff --git a/Backend/Controllers/Group/UpdatePassword.php b/Backend/Controllers/Group/UpdatePassword.php index 2942ec7..b05709e 100644 --- a/Backend/Controllers/Group/UpdatePassword.php +++ b/Backend/Controllers/Group/UpdatePassword.php @@ -4,11 +4,20 @@ require_once "Group.php"; use Backend\Models\Password; if(isLogin()){ - if(isset($_POST['updatePassword'])) - $password = Password::firstWhere("group_id", groupViaToken($_SESSION["token"])->id); - if(passwordValidate($pass = $_POST['password'])){ - $password->password = password_hash($pass,PASSWORD_DEFAULT); - $password->save(); + if(isset($_POST['updatePassword'])){ + $password = Password::firstWhere("group_id", groupViaToken($_SESSION["token"])->id); + if(passwordValidate($pass = $_POST['password'])){ + $password->password = password_hash($pass,PASSWORD_DEFAULT); + $password->save(); + header("location: ../../../Frontend/index.html?success=PasswordUpdated"); + exit(); + } + }else{ + header("location: ../../../Frontend/index.html?error=CouldNotUpdated"); + exit(); } +}else{ + header("location: ../../../Frontend/index.html?error=NotLogin"); + exit(); } diff --git a/Backend/Controllers/Polls/1vote.php b/Backend/Controllers/Polls/1vote.php index 95a5173..85f00de 100644 --- a/Backend/Controllers/Polls/1vote.php +++ b/Backend/Controllers/Polls/1vote.php @@ -14,11 +14,17 @@ if(isset($_POST['1Vote'])){ $vote->points += 1; if(!empty($_POST['comment'])){ $vote->comment = $_POST['comment']; + }else{ + header("location: ../../../Frontend/index.html?error=EmptyField"); + exit(); } $vote->save(); + header("location: ../../../Frontend/index.html?success=YouHaveVoted"); + exit(); } - - +}else{ + header("location: ../../../Frontend/index.html?error=YouCantVoted"); + exit(); } @@ -27,4 +33,3 @@ if(isset($_POST['1Vote'])){ - diff --git a/Backend/Controllers/Polls/321vote.php b/Backend/Controllers/Polls/321vote.php index a28d0ec..2a5e9b2 100644 --- a/Backend/Controllers/Polls/321vote.php +++ b/Backend/Controllers/Polls/321vote.php @@ -32,6 +32,8 @@ if(isset($_POST['321Vote'])){ $vote->comment = $_POST['3pComment']; } $vote->save(); + header("location: ../../../Frontend/index.html?success=SavedVote"); + exit(); diff --git a/Backend/Controllers/keyWord/NewKeyWord.php b/Backend/Controllers/keyWord/NewKeyWord.php index 7f7fbbf..26164ea 100644 --- a/Backend/Controllers/keyWord/NewKeyWord.php +++ b/Backend/Controllers/keyWord/NewKeyWord.php @@ -25,15 +25,23 @@ if (isLogin()) { //Try to save it if(!$keyword->save()){ - header("location: ../../../Frontend/index.php?created=failed"); + header("location: ../../../Frontend/index.html?error=FailedToSave"); + exit(); }else{ - header("location:../../../Frontend/index.php?created=success"); + header("location: ../../../Frontend/index.html?success=KeyWordSaved"); + exit(); } + }else{ + header("location: ../../../Frontend/index.html?error=YouCantSubmitAnyMoreKeyWords"); + exit(); } - //TODO make toast feedback + }else{ + header("location: ../../../Frontend/index.html?error=CouldNotSubmitKeyWord"); + exit(); } }else{ - header("location: ../Frontend/index.php?login=notLoggein"); + header("location: ../../../Frontend/index.html?error=NotLogin"); + exit(); }