diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.htaccess b/.htaccess index 5d497f7..d044b84 100755 --- a/.htaccess +++ b/.htaccess @@ -1 +1,2 @@ -Header set Access-Control-Allow-Origin: * +Header add Access-Control-Allow-Origin "*" +Header add Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT" \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore old mode 100644 new mode 100755 diff --git a/.idea/Game-Jaming.iml b/.idea/Game-Jaming.iml old mode 100644 new mode 100755 diff --git a/.idea/misc.xml b/.idea/misc.xml old mode 100644 new mode 100755 diff --git a/.idea/modules.xml b/.idea/modules.xml old mode 100644 new mode 100755 diff --git a/.idea/php.xml b/.idea/php.xml old mode 100644 new mode 100755 diff --git a/.idea/vcs.xml b/.idea/vcs.xml old mode 100644 new mode 100755 diff --git a/Backend/CheckSetup.php b/Backend/CheckSetup.php new file mode 100644 index 0000000..7d0b919 --- /dev/null +++ b/Backend/CheckSetup.php @@ -0,0 +1,11 @@ + false]); +}elseif(0 === filesize('../config/database.json')){ + echo json_encode(['data' => false]); +}else{ + echo json_encode(['data' => true]); +} diff --git a/Backend/Controllers/Admin/Admin.php b/Backend/Controllers/Admin/Admin.php index c394c4a..51232d5 100644 --- a/Backend/Controllers/Admin/Admin.php +++ b/Backend/Controllers/Admin/Admin.php @@ -8,3 +8,15 @@ function isAdmin(): bool return isset($_SESSION['admin']); } +/** + * @param string $userName + */ +function makeAdminLogin(string $userName) +{ + setcookie("userName", $userName, [ + 'expires' => 0, + 'samesite' => 'Strict', + 'path' => '/' + ]); +} + diff --git a/Backend/Controllers/Admin/AdminLogin.php b/Backend/Controllers/Admin/AdminLogin.php index d15b39f..f7ec881 100644 --- a/Backend/Controllers/Admin/AdminLogin.php +++ b/Backend/Controllers/Admin/AdminLogin.php @@ -20,16 +20,17 @@ if(isset($_POST['aLogin'])){ $_SESSION['admin'] = true; $_SESSION['success'] = "You are now logged in"; http_response_code(200); + makeAdminLogin($userName); }else{ session_destroy(); - echo "Fail to verify password"; http_response_code(401); + echo json_encode(["message" => "wrong password"]); } }else{ session_destroy(); - echo "No user"; http_response_code(401); + echo json_encode(["message" => "admin don't exist"]); } }else{ http_response_code(400); diff --git a/Backend/Controllers/Admin/AdminSignup.php b/Backend/Controllers/Admin/AdminSignup.php index e47089b..f63eab9 100644 --- a/Backend/Controllers/Admin/AdminSignup.php +++ b/Backend/Controllers/Admin/AdminSignup.php @@ -19,4 +19,5 @@ if (isAdmin()){ } }else{ http_response_code(401); + echo json_encode(["message" => "is not admin"]); } \ No newline at end of file diff --git a/Backend/Controllers/FileHandler/FileHandler.php b/Backend/Controllers/FileHandler/FileHandler.php index cbd439f..e31cb14 100644 --- a/Backend/Controllers/FileHandler/FileHandler.php +++ b/Backend/Controllers/FileHandler/FileHandler.php @@ -5,7 +5,8 @@ * @return string */ -function ZipFileHandler(string $gameFileName, string $gameFileTmp){ +function ZipFileHandler(string $gameFileName, string $gameFileTmp): string +{ $fileExtGame = explode('.', $gameFileName); $fileActualExtGame = strtolower(end($fileExtGame)); @@ -21,11 +22,10 @@ function ZipFileHandler(string $gameFileName, string $gameFileTmp){ rename($gameFileTmp,"../../Games/".$gameFileNewName); return $gameFileNewName; }else{ - echo "Wrong file type"; http_response_code(400); + echo json_encode(["message" => "Wrong file type gameFile"]); exit(); } -return NULL; } /** @@ -33,7 +33,8 @@ return NULL; * @param string $thumbnailFileTmp * @return string */ -function imagesFileHandler(string $thumbnailFileName, string $thumbnailFileTmp){ +function imagesFileHandler(string $thumbnailFileName, string $thumbnailFileTmp): string +{ $fileExtThumb = explode('.', $thumbnailFileName); $fileActualExtThumb = strtolower(end($fileExtThumb)); @@ -49,9 +50,8 @@ function imagesFileHandler(string $thumbnailFileName, string $thumbnailFileTmp){ rename($thumbnailFileTmp,"../../../Frontend/images/".$thumbnailFileNewName); return $thumbnailFileNewName; }else{ - echo "Wrong file type"; http_response_code(400); + echo json_encode(["message" => "Wrong file type thumbnailFile"]); exit(); } - return NULL; } \ No newline at end of file diff --git a/Backend/Controllers/FileHandler/GetGameData.php b/Backend/Controllers/FileHandler/GetGameData.php index 01445c6..b58f35c 100644 --- a/Backend/Controllers/FileHandler/GetGameData.php +++ b/Backend/Controllers/FileHandler/GetGameData.php @@ -17,4 +17,4 @@ if(isset($_GET['gameDataId'])){ header("Access-Control-Allow-Methods: GET"); header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept"); header('Content-Type: application/json;charset=UTF-8'); -echo $openGameDataStream->toJson(JSON_PRETTY_PRINT); \ No newline at end of file +echo json_encode(array('data' => $openGameDataStream->jsonSerialize())); \ No newline at end of file diff --git a/Backend/Controllers/FileHandler/updateFiles.php b/Backend/Controllers/FileHandler/updateFiles.php index 3a1e649..b903190 100644 --- a/Backend/Controllers/FileHandler/updateFiles.php +++ b/Backend/Controllers/FileHandler/updateFiles.php @@ -37,14 +37,15 @@ if(isLogin()){ } $gameData->is_web_Based = $isWebBased; if(!$gameData->save()){ - http_response_code(500); + http_response_code(500); }else{ - http_response_code(201); + http_response_code(201); } }else{ - http_response_code(400); + http_response_code(400); } }else{ - http_response_code(401); + http_response_code(401); + echo json_encode(["message" => "is not login"]); } \ No newline at end of file diff --git a/Backend/Controllers/FileHandler/upload.php b/Backend/Controllers/FileHandler/upload.php index cea1698..c6cad0c 100644 --- a/Backend/Controllers/FileHandler/upload.php +++ b/Backend/Controllers/FileHandler/upload.php @@ -58,18 +58,21 @@ if(isLogin()){ http_response_code(201); } + }else{ + http_response_code(500); } }else{ http_response_code(400); } }else{ - echo "Can only upload one file"; http_response_code(400); + echo json_encode(["message" => "Can only upload one file"]); } }else{ - echo "Can only upload when the game jam has started"; http_response_code(400); + echo json_encode(["message" => "Can only upload when the game jam has started"]); } }else{ http_response_code(401); + echo json_encode(["message" => "is not login"]); } \ No newline at end of file diff --git a/Backend/Controllers/GameJam/GetGameJam.php b/Backend/Controllers/GameJam/GetGameJam.php index e36a06a..6746672 100644 --- a/Backend/Controllers/GameJam/GetGameJam.php +++ b/Backend/Controllers/GameJam/GetGameJam.php @@ -15,6 +15,7 @@ if(isset($_GET['gameJamId'])){ } header('Content-Type: application/json;charset=UTF-8'); -echo $dbValue->toJson(JSON_PRETTY_PRINT); + +echo json_encode(array('data' => $dbValue->jsonSerialize())); //var_dump(headers_list()); \ No newline at end of file diff --git a/Backend/Controllers/GameJam/NewGameJam.php b/Backend/Controllers/GameJam/NewGameJam.php index f8bf5fb..f5bdfab 100644 --- a/Backend/Controllers/GameJam/NewGameJam.php +++ b/Backend/Controllers/GameJam/NewGameJam.php @@ -14,6 +14,9 @@ if(isAdmin()){ $gameJam->name = $_POST["gameJamName"]; $gameJam->start_time = $_POST["startDate"]."T".$_POST["startTime"]; $gameJam->end_time = $_POST["endDate"]."T".$_POST["endTime"]; + if (!empty($_POST['keyWord'])) { + $gameJam->key_word = $_POST['keyWord']; + } $gameJam->description = $_POST["description"]; if($gameJam->save()){ @@ -27,4 +30,5 @@ if(isAdmin()){ } }else{ http_response_code(401); + echo json_encode(["message" => "is not admin"]); } \ No newline at end of file diff --git a/Backend/Controllers/GameJam/UpdateGameJam.php b/Backend/Controllers/GameJam/UpdateGameJam.php index b63ec20..6fb62ce 100644 --- a/Backend/Controllers/GameJam/UpdateGameJam.php +++ b/Backend/Controllers/GameJam/UpdateGameJam.php @@ -26,10 +26,14 @@ if(isAdmin()){ }else{ http_response_code(500); } + }else{ + http_response_code(400); + echo json_encode(["message" => "game jam not found"]); } }else{ http_response_code(400); } }else{ http_response_code(401); + echo json_encode(["message" => "is not admin"]); } diff --git a/Backend/Controllers/Group/GetGroup.php b/Backend/Controllers/Group/GetGroup.php index 1b1203d..e4dee59 100644 --- a/Backend/Controllers/Group/GetGroup.php +++ b/Backend/Controllers/Group/GetGroup.php @@ -15,4 +15,4 @@ else{ header("Access-Control-Allow-Methods: GET"); header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept"); header('Content-Type: application/json;charset=UTF-8'); -echo $groups->toJson(JSON_PRETTY_PRINT); \ No newline at end of file +echo json_encode(array('data' => $groups->jsonSerialize())); \ No newline at end of file diff --git a/Backend/Controllers/Group/Group.php b/Backend/Controllers/Group/Group.php index da36077..2519cdf 100644 --- a/Backend/Controllers/Group/Group.php +++ b/Backend/Controllers/Group/Group.php @@ -5,6 +5,7 @@ use Backend\Models\Group; use Backend\Models\Password; session_start(); + /** * @param string $token * @return Group|null ; @@ -42,4 +43,15 @@ function passwordValidate(string $password1): bool return true; } else return false; +} + +function makeLogin(string $groupName, int $groupId) +{ + $cookieCon = array( + 'expires' => 0, + 'samesite' => 'Strict', + 'path' => '/' + ); + setcookie("groupName", $groupName, $cookieCon); + setcookie("groupId", $groupId, $cookieCon); } \ No newline at end of file diff --git a/Backend/Controllers/Group/Login.php b/Backend/Controllers/Group/Login.php index 3d18dc6..f78693d 100644 --- a/Backend/Controllers/Group/Login.php +++ b/Backend/Controllers/Group/Login.php @@ -1,13 +1,13 @@ id); $groupPassword->remember_token = $token; if($groupPassword->save()){ - $_SESSION['groupName'] = $groupName; $_SESSION['token'] = $token; $_SESSION['success'] = "You are now logged in"; + makeLogin($groupName,$group->id); //header('location: ../../../Frontend/index.php?login=success'); //exit(); http_response_code(200); @@ -37,12 +37,16 @@ if(isset($_POST['login'])){ }else{ session_destroy(); http_response_code(401); + echo json_encode(["message" => "Wrong password"]); } }else{ session_destroy(); - http_response_code(400); + http_response_code(401); + echo json_encode(["message" => "group was not found"]); } +}else{ + http_response_code(400); } diff --git a/Backend/Controllers/Group/Logout.php b/Backend/Controllers/Group/Logout.php index ac9b642..fa7cbb1 100644 --- a/Backend/Controllers/Group/Logout.php +++ b/Backend/Controllers/Group/Logout.php @@ -1,5 +1,16 @@ -1, + 'samesite' => 'Strict', + 'path' => '/' +); +setcookie("groupName", null, $cookieCon); +setcookie("groupId", null, $cookieCon); +setcookie("userName", null, $cookieCon); + +echo http_response_code(200); \ No newline at end of file diff --git a/Backend/Controllers/Group/ResetPassword.php b/Backend/Controllers/Group/ResetPassword.php index 4ad3cd7..3fa3e8e 100644 --- a/Backend/Controllers/Group/ResetPassword.php +++ b/Backend/Controllers/Group/ResetPassword.php @@ -18,6 +18,7 @@ if(isAdmin()){ } }else{ http_response_code(400); + echo json_encode(["message" => "group not found"]); } }else{ @@ -25,4 +26,5 @@ if(isAdmin()){ } }else{ http_response_code(401); + echo json_encode(["message" => "is not admin"]); } \ No newline at end of file diff --git a/Backend/Controllers/Group/SigningUp.php b/Backend/Controllers/Group/SigningUp.php index b3cd946..40101bc 100644 --- a/Backend/Controllers/Group/SigningUp.php +++ b/Backend/Controllers/Group/SigningUp.php @@ -24,8 +24,10 @@ if(isset($_POST['regGroup'])){ $group->group_amount = $_POST['groupAmount']; if(!$group->save()){ - return; + http_response_code(500); + exit(); } + $password = New Password(); $password->group()->associate($group); @@ -38,16 +40,19 @@ if(isset($_POST['regGroup'])){ if(!$password->save()){ http_response_code(500); - }else{ - http_response_code(201); + exit(); } $_SESSION['groupName'] = $groupName; $_SESSION['token'] = $token; $_SESSION['success'] = "You are now logged in"; + makeLogin($groupName,$group->id); + http_response_code(201); + echo json_encode(["message" => "you are login"]); }else{ http_response_code(400); + echo json_encode(["message" => "password not valid"]); } }else{ http_response_code(400); diff --git a/Backend/Controllers/Group/UpdateGruop.php b/Backend/Controllers/Group/UpdateGruop.php index b96c655..0c2dc5f 100644 --- a/Backend/Controllers/Group/UpdateGruop.php +++ b/Backend/Controllers/Group/UpdateGruop.php @@ -16,11 +16,16 @@ if(isLogin()){ http_response_code(201); } } + else{ + http_response_code(400); + echo json_encode(["message" => "group not found"]); + } }else{ http_response_code(400); } }else{ http_response_code(401); + echo json_encode(["message" => "is not login"]); } diff --git a/Backend/Controllers/Group/UpdatePassword.php b/Backend/Controllers/Group/UpdatePassword.php index 3bcd2a9..ea686f2 100644 --- a/Backend/Controllers/Group/UpdatePassword.php +++ b/Backend/Controllers/Group/UpdatePassword.php @@ -14,10 +14,15 @@ if(isLogin()){ http_response_code(201); } } + else{ + http_response_code(400); + echo json_encode(["message" => "password not valid"]); + } }else{ http_response_code(400); } }else{ http_response_code(401); + echo json_encode(["message" => "is not login"]); } diff --git a/Backend/Controllers/Polls/1vote.php b/Backend/Controllers/Polls/1vote.php index 04ff428..f718230 100644 --- a/Backend/Controllers/Polls/1vote.php +++ b/Backend/Controllers/Polls/1vote.php @@ -20,9 +20,13 @@ if(isset($_POST['1Vote'])){ }else{ http_response_code(201); } + } else{ + http_response_code(403); + echo json_encode(["message" => "you have already voted"]); } }else{ http_response_code(400); + echo json_encode(["message" => "you have already voted"]); } diff --git a/Backend/Controllers/Polls/GetVote.php b/Backend/Controllers/Polls/GetVote.php index e421407..f44593f 100644 --- a/Backend/Controllers/Polls/GetVote.php +++ b/Backend/Controllers/Polls/GetVote.php @@ -5,8 +5,9 @@ require_once "../Group/Group.php"; if(isLogin()){ header('Content-Type: application/json;charset=UTF-8'); - echo Vote::where('group_id',groupViaToken($_SESSION['token'])->id)->get()->toJson(JSON_PRETTY_PRINT); + echo json_encode(array('data' => Vote::where('group_id',groupViaToken($_SESSION['token'])->id)->get()->jsonSerialize())); }else{ http_response_code(401); + echo json_encode(["message" => "not login"]); } diff --git a/Backend/Controllers/Polls/GetWinner.php b/Backend/Controllers/Polls/GetWinner.php index 3613331..28f597d 100644 --- a/Backend/Controllers/Polls/GetWinner.php +++ b/Backend/Controllers/Polls/GetWinner.php @@ -5,30 +5,39 @@ use Backend\Models\Group; use Backend\Models\Vote; use \Illuminate\Support\Collection; -if(isAdmin() && isset($_GET['gameJamId'])){ - $groups = Group::where('game_jam_id',$_GET['gameJamId'])->get(); - $winningGroups = new Collection(); - $i = -1; - foreach ($groups as $group){ - $x = Vote::where('group_id', $group->id)->count(); - if($x>$i){ +if(isAdmin()){ + if(isset($_GET['gameJamId'])) { + $groups = Group::where('game_jam_id', $_GET['gameJamId'])->get(); + if($groups) { $winningGroups = new Collection(); - $winningGroups->push($group); + $i = -1; + foreach ($groups as $group) { + $x = Vote::where('group_id', $group->id)->count(); + if ($x > $i) { + $winningGroups = new Collection(); + $winningGroups->push($group); - $i = $x; + $i = $x; + } elseif ($i === $x) { + $winningGroups->push($group); + } + } + + header("Access-Control-Allow-Methods: GET"); + header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept"); + header('Content-Type: application/json;charset=UTF-8'); + echo json_encode(array('data' => $winningGroups->jsonSerialize())); } - elseif ($i === $x){ - $winningGroups->push($group); + else{ + http_response_code(400); + echo json_encode(["message" => "game jam not found"]); } + }else{ + http_response_code(400); } - header("Access-Control-Allow-Methods: GET"); - header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept"); - header('Content-Type: application/json;charset=UTF-8'); - echo $winningGroups->toJson(JSON_PRETTY_PRINT); - - }else{ http_response_code(401); + echo json_encode(["message" => "not admin"]); } diff --git a/Backend/Controllers/keyWord/GetKeyWinner.php b/Backend/Controllers/keyWord/GetKeyWinner.php index 0045d10..3290ed5 100644 --- a/Backend/Controllers/keyWord/GetKeyWinner.php +++ b/Backend/Controllers/keyWord/GetKeyWinner.php @@ -23,10 +23,11 @@ if (!isAdmin()){ header("Access-Control-Allow-Methods: GET"); header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept"); header('Content-Type: application/json;charset=UTF-8'); - echo $find_all_keywords->pluck("key_word")->toJson(JSON_PRETTY_PRINT); + echo json_encode(array('data' => $find_all_keywords->jsonSerialize())); }else{ http_response_code(400); } }else{ http_response_code(401); + echo json_encode(["message" => "is not admin"]); } \ No newline at end of file diff --git a/Backend/Controllers/keyWord/NewKeyWord.php b/Backend/Controllers/keyWord/NewKeyWord.php index 5049f3b..26aeb7f 100644 --- a/Backend/Controllers/keyWord/NewKeyWord.php +++ b/Backend/Controllers/keyWord/NewKeyWord.php @@ -30,8 +30,8 @@ if (isLogin()) { http_response_code(201); } }else{ - echo "limited upload reached"; http_response_code(400); + echo json_encode(["message" => "limited upload reached"]); } }else{ @@ -39,5 +39,6 @@ if (isLogin()) { } }else{ http_response_code(401); + echo json_encode(["message" => "not login"]); } diff --git a/Backend/setup.php b/Backend/setup.php new file mode 100644 index 0000000..289514a --- /dev/null +++ b/Backend/setup.php @@ -0,0 +1,111 @@ +connect_error) { + http_response_code(400); + echo json_encode(["message" => $conn->connect_error]); + exit(); + } + $sql = "CREATE DATABASE ".$DBName; + if ($conn->query($sql) === FALSE) { + http_response_code(400); + echo json_encode(["message" => $conn->error]); + exit(); + } + $conn->close(); + return array( + "driver" => "mysql", + "host" => $servername, + "database" => $DBName, + "username" => $username, + "password" => $password + ); +} + +/** + * @param string $DBName + * @return string[] + */ +function liteDB(string $DBName): array +{ + $DBName = $DBName.".sqlite"; + if(file_exists($DBName)){ + http_response_code(400); + echo json_encode(["message" => "database already exits"]); + exit(); + } + New SQLite3($DBName); + return array( + 'driver' => 'sqlite', + 'database' => realpath(dirname(__FILE__)."/".$DBName) + ); +} + +$conFilePath = '../config/database.json'; +if(!file_exists($conFilePath)){ + $confile = fopen($conFilePath, "w"); + fclose($confile); +} +if (0 !== filesize($conFilePath)){ + http_response_code(400); + echo json_encode(["message" => "already have database connection"]); + exit(); +} + + +if(isset($_POST["dbSetup"])){ + + switch($_POST["dbType"]){ + case "mysql": + $dbCon = myDB($_POST["dbServername"],$_POST["dbUsername"],$_POST["dbPassword"], $_POST["dbName"]); + break; + case "sqlite": + $dbCon = liteDB($_POST["dbName"]); + break; + default: + http_response_code(400); + echo json_encode(["message" => "database type is wrong"]); + exit(); + } + + file_put_contents($conFilePath, json_encode($dbCon)); + + require_once('../bootstrap.php'); + try{ + $capsule->Connection()->getPdo(); + } catch (\Exception $e) { + http_response_code(400); + file_put_contents($conFilePath, NULL); + echo json_encode(["message" => "Could not connect to the database. Please check your configuration. error:" . $e]); + exit(); + } + require_once ('Database/databaseMigration.php'); + AdminUser::firstOrCreate([ + 'user_name' => $_POST["AdminUsername"], 'password' => password_hash($_POST["AdminPassword"],PASSWORD_DEFAULT) + ]); + http_response_code(201); + +}else{ + http_response_code(400); +} + + + + + + diff --git a/Frontend/.vs/Frontend/config/applicationhost.config b/Frontend/.vs/Frontend/config/applicationhost.config new file mode 100644 index 0000000..f7beb9b --- /dev/null +++ b/Frontend/.vs/Frontend/config/applicationhost.config @@ -0,0 +1,1023 @@ + + + + + + + +
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Frontend/.vs/Frontend/v16/.suo b/Frontend/.vs/Frontend/v16/.suo new file mode 100644 index 0000000..e1a5ed4 Binary files /dev/null and b/Frontend/.vs/Frontend/v16/.suo differ diff --git a/Frontend/.vs/VSWorkspaceState.json b/Frontend/.vs/VSWorkspaceState.json new file mode 100644 index 0000000..6b61141 --- /dev/null +++ b/Frontend/.vs/VSWorkspaceState.json @@ -0,0 +1,6 @@ +{ + "ExpandedNodes": [ + "" + ], + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/Frontend/Html/AdminPage.html b/Frontend/Html/AdminPage.html index 3e3a9f2..3050e1b 100755 --- a/Frontend/Html/AdminPage.html +++ b/Frontend/Html/AdminPage.html @@ -1,4 +1,4 @@ - + @@ -27,20 +27,52 @@ - -
-
- - - -
- Admin panel -
+
+
+ + + +
+ Admin panel +
+
+ + +
+
+

Administration

+
Opret Game Jam
+
+
+ + +
+ + +
+ + +
+ + +
+ + +
+

Indsæt en beskrivelse af Gam jammet

+
+ + +
+ +
+ + diff --git a/Frontend/Html/FirstTimeSetup.html b/Frontend/Html/FirstTimeSetup.html new file mode 100644 index 0000000..e69de29 diff --git a/Frontend/Images/SetupFav.png b/Frontend/Images/SetupFav.png new file mode 100644 index 0000000..e2c7876 Binary files /dev/null and b/Frontend/Images/SetupFav.png differ diff --git a/Frontend/Index.html b/Frontend/Index.html index 40327e4..20eebea 100755 --- a/Frontend/Index.html +++ b/Frontend/Index.html @@ -83,9 +83,12 @@ - + Login +
@@ -618,19 +621,15 @@

Lodtrækning

-

+ +
+

+

- -
-

Administration

-

-
- - @@ -651,6 +650,7 @@ + diff --git a/Frontend/Javascript/AddEvent.js b/Frontend/Javascript/AddEvent.js new file mode 100644 index 0000000..0a3da48 --- /dev/null +++ b/Frontend/Javascript/AddEvent.js @@ -0,0 +1,17 @@ +// Admin add event +$("#indsend").click(function () { + let startDate = $("#startDate").val(); + let endDate = $("#endDate").val(); + let startTime = $("#startTime").val(); + let endTime = $("#endTime").val(); + console.log(`startDate ${startDate} \n + endDate ${endDate} \n + startTime ${startTime} \n + endTime ${endTime}`); +}) + +function addEvent() { + + +} + diff --git a/Frontend/Javascript/Lodtrækning.js b/Frontend/Javascript/Lodtrækning.js new file mode 100644 index 0000000..e69de29 diff --git a/Frontend/Javascript/LoginFunctionality.js b/Frontend/Javascript/LoginFunctionality.js index fa92610..5c19cfc 100755 --- a/Frontend/Javascript/LoginFunctionality.js +++ b/Frontend/Javascript/LoginFunctionality.js @@ -12,9 +12,15 @@ $(document).ready(function () { .then(function(res) { let resArr = res.data; - $.each(resArr, function(i, value) { - arr.push({id: value.id, Gamejam: value.name}); - }); + //console.log(res.data.data); + + for(let i = 0; i < res.data.data.length; i++) + { + arr.push({ + id: res.data.data[i].id, + Gamejam: res.data.data[i].name + }); + } $.each(arr, function(i, data) { if (i === 0) @@ -34,7 +40,7 @@ $(document).ready(function () { // Remove invalidInput if selected option has been changed $('#GameJamSelect').change(function() { selectedGameJam = $('#GameJamSelect').children("option:selected").val(); - + if (selectedGameJam >= 1) { $('#GameJamSelect').removeClass('invalidInput'); @@ -50,7 +56,7 @@ $(document).ready(function () { }) GetGroupNames().then(function(res) { - let resArr = res; + let resArr = res.data; let groupNameTaken = false; $('#RegisterBtn').click(function() { @@ -88,28 +94,33 @@ $(document).ready(function () { { $('#pass1').addClass('invalidInput'); e.preventDefault(); + return; } if($('#pass2').val().length === 0) { $('#pass2').addClass('invalidInput'); e.preventDefault(); + return; } if($('#username').val().length === 0) { $('#username').addClass('invalidInput'); e.preventDefault(); + return; } if($('#pass1').hasClass('invalidInput')) { e.preventDefault(); + return; } if($('#pass2').hasClass('invalidInput')) { e.preventDefault(); + return; } if(!$.isNumeric($('#NUDDisplay').text())) @@ -127,32 +138,28 @@ $(document).ready(function () { { $('#username').addClass('invalidInput'); e.preventDefault(); + return; } let URL = "/Backend/Controllers/Group/SigningUp.php"; - let formData = new FormData(this); - let name = $('#RegisterBtn').attr('name'); + + let form = $('#RegisterForm')[0]; + let formData = new FormData(form); + + let id = $('#RegisterBtn').attr('name'); let value = $('#RegisterBtn').val(); - formData.append(name, value); + formData.append(id, value); - $.ajax({ - url: URL, - type: 'POST', - data: formData, - mimeType:"multipart/form-data", - contentType: false, - cache: false, - processData:false, - success: function(data, textStatus, jqXHR) - { - console.log(data); - }, - error: function(jqXHR, textStatus, errorThrown) - { - console.log(textStatus); - } + axios.post(URL, formData, { + header: 'multipart/form-data' + }).then(res => { + console.log(res); + }).catch(error => { + console.log(error); }); + + e.preventDefault(); }); }); @@ -195,29 +202,28 @@ $(document).ready(function () { // Login start $('#LoginForm').submit(function(e) { let URL = "/Backend/Controllers/Group/Login.php"; - let formData = new FormData(this); - let name = $('#LoginBtn').attr('name'); + + let form = $('#LoginForm')[0]; + let formData = new FormData(form); + + let id = $('#LoginBtn').attr('name'); let value = $('#LoginBtn').val(); - formData.append(name, value); + formData.append(id, value); - $.ajax({ - url: URL, - type: 'POST', - data: formData, - mimeType:"multipart/form-data", - contentType: false, - cache: false, - processData:false, - success: function(data, textStatus, jqXHR) + + axios.post(URL, formData, { + header: 'multipart/form-data' + }).then(res => { + if (res.status === 200) { - console.log(data); - }, - error: function(jqXHR, textStatus, errorThrown) - { - console.log(`XHR: ${jqXHR} \n Status: ${textStatus} \n Error: ${errorThrown}`); - } + console.log('Logged in'); + } + }).catch(error => { + console.log(error); }); + + e.preventDefault(); }) // Login end }); \ No newline at end of file diff --git a/Frontend/Javascript/qweData.js b/Frontend/Javascript/qweData.js deleted file mode 100755 index 2770f4c..0000000 --- a/Frontend/Javascript/qweData.js +++ /dev/null @@ -1,19 +0,0 @@ -$(window).on("load", function(){ - dataFetch(); -}); - - -function dataFetch(){ - $.ajax({ - type: "GET", - url: "/Game-Jaming/Backend/controllers/GameJam/GetGameJam.php", - success: function(result){ - console.log(result[0].name); - } - }); -} - - - -//console.log(result.name); ?gameJamId=1 -//console.log(result[0].name); uden ?gameJamId=1 \ No newline at end of file diff --git a/Frontend/Styles/AdminPage.css b/Frontend/Styles/AdminPage.css index e4c881d..b81d1b2 100755 --- a/Frontend/Styles/AdminPage.css +++ b/Frontend/Styles/AdminPage.css @@ -1,3 +1,6 @@ +body{ + text-align: center; +} .HeaderPanel { position: fixed; overflow: hidden; @@ -23,4 +26,74 @@ .HeaderLeft { float: left; -} \ No newline at end of file +} + +/*Create game jam*/ + +#createGameJam{ + justify-content: center; + display: grid; +} +#createGameJam input{ + display: block; + position: center; + +} + +#startTime { + border-radius: 15px; + color: #474747; + background-color: rgba(255, 255, 255, .55); + border: double; + filter: invert(90%); +} + +#endTime { + border-radius: 15px; + color: #474747; + background-color: rgba(255, 255, 255, .55); + border: double; + filter: invert(90%); +} + +#startDate { + border-radius: 15px; + color: #474747; + background-color: rgba(255, 255, 255, .55); + border: double; + filter: invert(90%); +} + +#endDate { + border-radius: 15px; + color: #474747; + background-color: rgba(255, 255, 255, .55); + border: double; + filter: invert(90%); +} + +#nameOfGameJam { + background-color: rgb(18, 18, 18); + color: rgba(255, 255, 255, .55); + border-radius: 15px; + border: double; +} + + + +#description { + background-color: rgb(18, 18, 18); + color: rgba(255, 255, 255, .55); + border-radius: 15px; + border: double; + width:400px; + height:250px; +} + +#indsend { + border-radius: 15px; + color: rgba(255, 255, 255, .55); + background-color: rgb(18, 18, 18); + border: double; +} +/*Create Game Jam end*/ \ No newline at end of file diff --git a/Frontend/Styles/Index.css b/Frontend/Styles/Index.css index 6e8d81e..1992e49 100755 --- a/Frontend/Styles/Index.css +++ b/Frontend/Styles/Index.css @@ -352,6 +352,65 @@ a:hover { transform: translate(-50%, -50%); } +.box #NUDMinus { + color: rgba(255, 255, 255, .55); + background-color: transparent; + border: none; + float: left; +} + + .box #NUDMinus:focus { + box-shadow: none; +} + + .box #NUDMinus:focus-visible { + outline: none; +} + + .box #NUDDisplay { + color: rgba(255, 255, 255, .55); + background-color: transparent; + border: none; + cursor: text; + width: 65%; +} + + .box #NUDDisplay:focus { + box-shadow: none; +} + + .box #NUDDisplay:focus-visible { + outline: none; +} + + .box #NUDPlus { + color: rgba(255, 255, 255, .55); + background-color: transparent; + border: none; + float: right; +} + + .box #NUDPlus:focus { + box-shadow: none; +} + + .box #NUDPlus:focus-visible { + outline: none; +} + + .box #GameJamSelect:focus { + box-shadow: none; +} + + .box #GameJamSelect:hover { + color: rgba(255, 255, 255, .75); +} + + .box #GameJamSelect ul { + background-color: red; +} + + .box { background-color: rgb(18, 18, 18); } @@ -749,7 +808,7 @@ image_gruppenavn{ } .hasEvent { - background-color: red; + background-color: red;; } /*Kalender slut*/ diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/bootstrap.php b/bootstrap.php old mode 100644 new mode 100755 index 7d51cc9..1959089 --- a/bootstrap.php +++ b/bootstrap.php @@ -1,14 +1,8 @@ addConnection([ - "driver" => "mysql", - "host" => "localhost", - "port" => "3306", - "database" => "testdb", - "username" => "root", - "password" => "V#_xWL6_" -]); +$con = json_decode(file_get_contents('config/database.json', true), true); +$capsule->addConnection($con); $capsule->setAsGlobal(); $capsule->bootEloquent(); diff --git a/composer.json b/composer.json old mode 100644 new mode 100755 index 1083192..fd70852 --- a/composer.json +++ b/composer.json @@ -1,10 +1,15 @@ { "require": { - "illuminate/database": "^8.30" + "illuminate/database": "^8.30", + "ext-mysqli": "*", + "ext-sqlite3": "*", + "ext-fileinfo": "*" }, "autoload": { "classmap": [ "Backend/Models" ] - } + }, + "name": "sde_skp/game_jaming", + "description": "description" } diff --git a/composer.lock b/composer.lock old mode 100644 new mode 100755 index 0b2ef39..0f8f175 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f8dc5027639f0368374ccb33723ddcd2", + "content-hash": "f7278c3dc731961ed65f3f31bf2b49f0", "packages": [ { "name": "doctrine/inflector", @@ -103,16 +103,16 @@ }, { "name": "illuminate/collections", - "version": "v8.32.1", + "version": "v8.34.0", "source": { "type": "git", "url": "https://github.com/illuminate/collections.git", - "reference": "d7cc717a00064b40fa63a8ad522042005e1de1ed" + "reference": "e18d6e4cf03dd597bc3ecd86fefc2023d0c7a5e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/collections/zipball/d7cc717a00064b40fa63a8ad522042005e1de1ed", - "reference": "d7cc717a00064b40fa63a8ad522042005e1de1ed", + "url": "https://api.github.com/repos/illuminate/collections/zipball/e18d6e4cf03dd597bc3ecd86fefc2023d0c7a5e8", + "reference": "e18d6e4cf03dd597bc3ecd86fefc2023d0c7a5e8", "shasum": "" }, "require": { @@ -153,20 +153,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2021-03-08T17:22:22+00:00" + "time": "2021-03-19T00:05:33+00:00" }, { "name": "illuminate/container", - "version": "v8.32.1", + "version": "v8.34.0", "source": { "type": "git", "url": "https://github.com/illuminate/container.git", - "reference": "3d6ce613f455093fdf8bd3c81b30104aef0b11e0" + "reference": "0e38ee1632d470e56aece0079e6e22d13e6bea8e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/container/zipball/3d6ce613f455093fdf8bd3c81b30104aef0b11e0", - "reference": "3d6ce613f455093fdf8bd3c81b30104aef0b11e0", + "url": "https://api.github.com/repos/illuminate/container/zipball/0e38ee1632d470e56aece0079e6e22d13e6bea8e", + "reference": "0e38ee1632d470e56aece0079e6e22d13e6bea8e", "shasum": "" }, "require": { @@ -204,20 +204,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2021-02-12T21:15:27+00:00" + "time": "2021-03-16T19:42:20+00:00" }, { "name": "illuminate/contracts", - "version": "v8.32.1", + "version": "v8.34.0", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", - "reference": "9c7a9868d7485a82663d67109429094c8e4ed56d" + "reference": "121cea1d8b8772bc7fee99c71ecf0f57c1d77b3b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/contracts/zipball/9c7a9868d7485a82663d67109429094c8e4ed56d", - "reference": "9c7a9868d7485a82663d67109429094c8e4ed56d", + "url": "https://api.github.com/repos/illuminate/contracts/zipball/121cea1d8b8772bc7fee99c71ecf0f57c1d77b3b", + "reference": "121cea1d8b8772bc7fee99c71ecf0f57c1d77b3b", "shasum": "" }, "require": { @@ -252,20 +252,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2021-02-26T13:17:03+00:00" + "time": "2021-03-12T14:45:30+00:00" }, { "name": "illuminate/database", - "version": "v8.32.1", + "version": "v8.34.0", "source": { "type": "git", "url": "https://github.com/illuminate/database.git", - "reference": "f6a10cebd9bbd188ca66993168fb453439dbb50f" + "reference": "74a165fd07b36cc0ea3558fa391b762867af87e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/database/zipball/f6a10cebd9bbd188ca66993168fb453439dbb50f", - "reference": "f6a10cebd9bbd188ca66993168fb453439dbb50f", + "url": "https://api.github.com/repos/illuminate/database/zipball/74a165fd07b36cc0ea3558fa391b762867af87e8", + "reference": "74a165fd07b36cc0ea3558fa391b762867af87e8", "shasum": "" }, "require": { @@ -320,11 +320,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2021-03-09T14:06:15+00:00" + "time": "2021-03-23T15:12:51+00:00" }, { "name": "illuminate/macroable", - "version": "v8.32.1", + "version": "v8.34.0", "source": { "type": "git", "url": "https://github.com/illuminate/macroable.git", @@ -370,16 +370,16 @@ }, { "name": "illuminate/support", - "version": "v8.32.1", + "version": "v8.34.0", "source": { "type": "git", "url": "https://github.com/illuminate/support.git", - "reference": "2ef7ff288366a1ebe32f633196a1b90bd443acc3" + "reference": "b7b27e758b68aad44558c62e7374328835895386" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/support/zipball/2ef7ff288366a1ebe32f633196a1b90bd443acc3", - "reference": "2ef7ff288366a1ebe32f633196a1b90bd443acc3", + "url": "https://api.github.com/repos/illuminate/support/zipball/b7b27e758b68aad44558c62e7374328835895386", + "reference": "b7b27e758b68aad44558c62e7374328835895386", "shasum": "" }, "require": { @@ -434,7 +434,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2021-03-05T15:22:14+00:00" + "time": "2021-03-21T13:37:37+00:00" }, { "name": "nesbot/carbon", @@ -1625,7 +1625,11 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "ext-mysqli": "*", + "ext-sqlite3": "*", + "ext-fileinfo": "*" + }, "platform-dev": [], "plugin-api-version": "2.0.0" } diff --git a/config/database.json b/config/database.json new file mode 100644 index 0000000..e69de29