Added routes

This commit is contained in:
neerholt 2021-03-17 09:43:09 +01:00
parent 0d4f161a48
commit a84c7a9258
14 changed files with 148 additions and 54 deletions

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -1,6 +1,6 @@
<?php
require_once "../../../bootstrap.php";
require "../../../bootstrap.php";
use Backend\Models\Group;
use Backend\Models\Password;
@ -25,24 +25,26 @@ if(isset($_POST['login'])){
$_SESSION['groupName'] = $groupName;
$_SESSION['token'] = $token;
$_SESSION['success'] = "You are now logged in";
//header('location: ../../../Frontend/index.php?login=success');
echo "YES";
header('location: ../../../Frontend/index.php?login=success');
exit();
}
else{
session_destroy();
header('location: ../../../Frontend/index.php?login=failed&?reason=token');
exit();
}
}else{
session_destroy();
header('location: ../../../Frontend/index.php?login=failed&?reason=password');
exit();
}
}
else{
session_destroy();
header('location: ../../../Frontend/index.php?login=failed&?reason=group');
exit();
}

View File

@ -12,11 +12,19 @@ if(isAdmin()){
$password->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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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'])){

View File

@ -32,6 +32,8 @@ if(isset($_POST['321Vote'])){
$vote->comment = $_POST['3pComment'];
}
$vote->save();
header("location: ../../../Frontend/index.html?success=SavedVote");
exit();

View File

@ -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();
}