Added routes
This commit is contained in:
parent
0d4f161a48
commit
a84c7a9258
|
@ -23,14 +23,16 @@ if(isset($_POST['aLogin'])){
|
||||||
}else{
|
}else{
|
||||||
session_destroy();
|
session_destroy();
|
||||||
header('location: ../../../Frontend/index.html?login=failed?reason=password');
|
header('location: ../../../Frontend/index.html?login=failed?reason=password');
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
}
|
|
||||||
else{
|
|
||||||
session_destroy();
|
session_destroy();
|
||||||
header('location: ../../../Frontend/index.html?login=failed?reason=username');
|
header('location: ../../../Frontend/index.html?login=failed?reason=username');
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
header("location: ../../../Frontend/index.html?error=NoLogin");
|
||||||
|
exit();
|
||||||
}
|
}
|
|
@ -22,6 +22,7 @@ function ZipFileHandler(string $gameFileName, string $gameFileTmp){
|
||||||
return $gameFileNewName;
|
return $gameFileNewName;
|
||||||
}else{
|
}else{
|
||||||
header("location: location: ../../../Frontend/index.html?error=Wrong%20File%20Type");
|
header("location: location: ../../../Frontend/index.html?error=Wrong%20File%20Type");
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +49,7 @@ function imagesFileHandler(string $thumbnailFileName, string $thumbnailFileTmp){
|
||||||
return $thumbnailFileNewName;
|
return $thumbnailFileNewName;
|
||||||
}else{
|
}else{
|
||||||
header("location: location: ../../../Frontend/index.html?error=Wrong%20File%20Type");
|
header("location: location: ../../../Frontend/index.html?error=Wrong%20File%20Type");
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
|
@ -37,7 +37,13 @@ if(isLogin()){
|
||||||
}
|
}
|
||||||
$gameData->is_web_Based = $isWebBased;
|
$gameData->is_web_Based = $isWebBased;
|
||||||
$gameData->save();
|
$gameData->save();
|
||||||
|
header("location: ../../../Frontend/index.html?success=UpdatedFiles");
|
||||||
|
exit();
|
||||||
|
}else{
|
||||||
|
header("location: ../../../Frontend/index.html?error=FailedUpload");
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
header("location: ../../../Frontend/index.html?error=NoLogin");
|
header("location: ../../../Frontend/index.html?error=NoLogin");
|
||||||
|
exit();
|
||||||
}
|
}
|
|
@ -3,9 +3,12 @@ require_once "../../../bootstrap.php";
|
||||||
require_once('../Group/Group.php');
|
require_once('../Group/Group.php');
|
||||||
require_once('FileHandler.php');
|
require_once('FileHandler.php');
|
||||||
use Backend\Models\GameData;
|
use Backend\Models\GameData;
|
||||||
|
use Backend\Models\GameJam;
|
||||||
|
|
||||||
use Backend\Models\Group;
|
use Backend\Models\Group;
|
||||||
|
|
||||||
|
date_default_timezone_set("Europe/Copenhagen");
|
||||||
|
|
||||||
$isImages = false;
|
$isImages = false;
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,40 +16,59 @@ if(isLogin()){
|
||||||
|
|
||||||
$group = groupViaToken($_SESSION['token']);
|
$group = groupViaToken($_SESSION['token']);
|
||||||
|
|
||||||
if(!isset($group->game_data_id)){
|
$gameJam = GameJam::find($group->game_jam_id);
|
||||||
if(isset($_POST['submitUpload'])){
|
$gameJamStartTime = strtotime($gameJam->start_time);
|
||||||
//Get the data from the user form
|
$gameJamEndTime = strtotime($gameJam->end_time);
|
||||||
$gameFile = $_FILES['gameFile'];
|
$date = date('Y/m/d H:i:s', time());
|
||||||
$desc = $_POST['description'];
|
|
||||||
$title = $_POST['gameTitle'];
|
|
||||||
$thumbnail = $_FILES['thumbnailFile'];
|
|
||||||
$isWebBased = isset( $_POST['isWebBased']);
|
|
||||||
|
|
||||||
$gameFileName = $_FILES['gameFile']['name'];//Game name
|
$currentTime = strtotime($date);
|
||||||
$gameFileTmp = $_FILES['gameFile']['tmp_name'];//Tmp location of the file
|
|
||||||
$gameFileError = $_FILES['gameFile']['error'];//File error
|
|
||||||
|
|
||||||
$thumbnailFileName = $_FILES['thumbnailFile']['name'];//Game name
|
if($gameJamStartTime <= $currentTime && $gameJamEndTime >= $currentTime){
|
||||||
$thumbnailFileTmp = $_FILES['thumbnailFile']['tmp_name'];//Tmp location of the file
|
if(!isset($group->game_data_id)){
|
||||||
$thumbnailFileError =$_FILES['thumbnailFile']['error'];//File error
|
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){
|
$gameFileName = $_FILES['gameFile']['name'];//Game name
|
||||||
$gameData = new GameData();
|
$gameFileTmp = $_FILES['gameFile']['tmp_name'];//Tmp location of the file
|
||||||
$gameData->game_name = $title;
|
$gameFileError = $_FILES['gameFile']['error'];//File error
|
||||||
$gameData->game_link = ZipFileHandler($gameFileName,$gameFileTmp);
|
|
||||||
$gameData->description = $desc;
|
$thumbnailFileName = $_FILES['thumbnailFile']['name'];//Game name
|
||||||
if(isset($thumbnail) && $thumbnailFileError === 0){
|
$thumbnailFileTmp = $_FILES['thumbnailFile']['tmp_name'];//Tmp location of the file
|
||||||
$gameData->img = imagesFileHandler($thumbnailFileName,$thumbnailFileTmp);
|
$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;
|
}else{
|
||||||
$gameData->save();
|
header("location: ../../../Frontend/group.php?error=UploadFail");
|
||||||
$group->gameData()->associate($gameData);
|
exit();
|
||||||
$group->save();
|
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
header("location: ../../../Frontend/group.php?error=TooManyUploads");
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
header("location: ../../../Frontend/index.html?error=TooManyUploads");
|
header("location: ../../../Frontend/group.php?error=GameJamHasNotBegun");
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
header("location: ../../../Frontend/index.html?error=NoLogin");
|
header("location: ../../../Main.php?error=NoLogin");
|
||||||
|
exit();
|
||||||
}
|
}
|
|
@ -17,10 +17,18 @@ if(isAdmin()){
|
||||||
$gameJam->description = $_POST["description"];
|
$gameJam->description = $_POST["description"];
|
||||||
|
|
||||||
if($gameJam->save()){
|
if($gameJam->save()){
|
||||||
|
header("location: ../../../Frontend/Html/AdminPage.html?success=UploadedFile");
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
else{
|
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();
|
||||||
}
|
}
|
|
@ -22,9 +22,16 @@ if(isAdmin()){
|
||||||
|
|
||||||
$gameJam->description = $_POST['description'];
|
$gameJam->description = $_POST['description'];
|
||||||
if ($gameJam->save()) {
|
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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once "../../../bootstrap.php";
|
require "../../../bootstrap.php";
|
||||||
|
|
||||||
use Backend\Models\Group;
|
use Backend\Models\Group;
|
||||||
use Backend\Models\Password;
|
use Backend\Models\Password;
|
||||||
|
@ -25,24 +25,26 @@ if(isset($_POST['login'])){
|
||||||
$_SESSION['groupName'] = $groupName;
|
$_SESSION['groupName'] = $groupName;
|
||||||
$_SESSION['token'] = $token;
|
$_SESSION['token'] = $token;
|
||||||
$_SESSION['success'] = "You are now logged in";
|
$_SESSION['success'] = "You are now logged in";
|
||||||
//header('location: ../../../Frontend/index.php?login=success');
|
header('location: ../../../Frontend/index.php?login=success');
|
||||||
echo "YES";
|
exit();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
session_destroy();
|
session_destroy();
|
||||||
header('location: ../../../Frontend/index.php?login=failed&?reason=token');
|
header('location: ../../../Frontend/index.php?login=failed&?reason=token');
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
session_destroy();
|
session_destroy();
|
||||||
header('location: ../../../Frontend/index.php?login=failed&?reason=password');
|
header('location: ../../../Frontend/index.php?login=failed&?reason=password');
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
session_destroy();
|
session_destroy();
|
||||||
header('location: ../../../Frontend/index.php?login=failed&?reason=group');
|
header('location: ../../../Frontend/index.php?login=failed&?reason=group');
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,19 @@ if(isAdmin()){
|
||||||
$password->password = password_hash($_POST['newPassword'], PASSWORD_DEFAULT);
|
$password->password = password_hash($_POST['newPassword'], PASSWORD_DEFAULT);
|
||||||
echo $password;
|
echo $password;
|
||||||
if(!$password->save()){
|
if(!$password->save()){
|
||||||
|
header("location: ../../../Frontend/Html/AdminPage.html?error=FailedSaveResetPassword");
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
}else{
|
}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();
|
||||||
}
|
}
|
|
@ -43,8 +43,13 @@ if(isset($_POST['regGroup'])){
|
||||||
$_SESSION['groupName'] = $groupName;
|
$_SESSION['groupName'] = $groupName;
|
||||||
$_SESSION['token'] = $token;
|
$_SESSION['token'] = $token;
|
||||||
$_SESSION['success'] = "You are now logged in";
|
$_SESSION['success'] = "You are now logged in";
|
||||||
header('location: ../../../Frontend/index.html');
|
header("location: ../../../Frontend/index.html?success=GroupRegister");
|
||||||
|
exit();
|
||||||
}else{
|
}else{
|
||||||
|
header("location: ../../../Frontend/index.html?error=CouldNotValidatePassword");
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
header("location: ../../../Frontend/index.html?error=FailedRegister");
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,16 @@ if(isLogin()){
|
||||||
$group->group_amount = $_POST['groupAmount'];
|
$group->group_amount = $_POST['groupAmount'];
|
||||||
$group->game_jam_id = $_POST['gameJamId'];
|
$group->game_jam_id = $_POST['gameJamId'];
|
||||||
$group->save();
|
$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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,20 @@ require_once "Group.php";
|
||||||
use Backend\Models\Password;
|
use Backend\Models\Password;
|
||||||
|
|
||||||
if(isLogin()){
|
if(isLogin()){
|
||||||
if(isset($_POST['updatePassword']))
|
if(isset($_POST['updatePassword'])){
|
||||||
$password = Password::firstWhere("group_id", groupViaToken($_SESSION["token"])->id);
|
$password = Password::firstWhere("group_id", groupViaToken($_SESSION["token"])->id);
|
||||||
if(passwordValidate($pass = $_POST['password'])){
|
if(passwordValidate($pass = $_POST['password'])){
|
||||||
$password->password = password_hash($pass,PASSWORD_DEFAULT);
|
$password->password = password_hash($pass,PASSWORD_DEFAULT);
|
||||||
$password->save();
|
$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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,17 @@ if(isset($_POST['1Vote'])){
|
||||||
$vote->points += 1;
|
$vote->points += 1;
|
||||||
if(!empty($_POST['comment'])){
|
if(!empty($_POST['comment'])){
|
||||||
$vote->comment = $_POST['comment'];
|
$vote->comment = $_POST['comment'];
|
||||||
|
}else{
|
||||||
|
header("location: ../../../Frontend/index.html?error=EmptyField");
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
$vote->save();
|
$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'])){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,8 @@ if(isset($_POST['321Vote'])){
|
||||||
$vote->comment = $_POST['3pComment'];
|
$vote->comment = $_POST['3pComment'];
|
||||||
}
|
}
|
||||||
$vote->save();
|
$vote->save();
|
||||||
|
header("location: ../../../Frontend/index.html?success=SavedVote");
|
||||||
|
exit();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,15 +25,23 @@ if (isLogin()) {
|
||||||
|
|
||||||
//Try to save it
|
//Try to save it
|
||||||
if(!$keyword->save()){
|
if(!$keyword->save()){
|
||||||
header("location: ../../../Frontend/index.php?created=failed");
|
header("location: ../../../Frontend/index.html?error=FailedToSave");
|
||||||
|
exit();
|
||||||
}else{
|
}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{
|
}else{
|
||||||
header("location: ../Frontend/index.php?login=notLoggein");
|
header("location: ../../../Frontend/index.html?error=NotLogin");
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue