fixed some stuff

This commit is contained in:
neerholt 2021-03-11 13:20:10 +01:00
parent 0e343cb46e
commit 1d1606ff13
8 changed files with 72 additions and 9 deletions

View File

@ -32,7 +32,7 @@ function imagesFileHandler(string $thumbnailFileName, string $thumbnailFileTmp){
$fileExtThumb = explode('.', $thumbnailFileName); $fileExtThumb = explode('.', $thumbnailFileName);
$fileActualExtThumb = strtolower(end($fileExtThumb)); $fileActualExtThumb = strtolower(end($fileExtThumb));
$allowedFileTypeThumbnail = array('gif', 'jpeg', 'png', 'svg'); $allowedFileTypeThumbnail = array('gif', 'jpeg', 'png', 'svg', 'jpg', 'jfif', 'pjpeg', 'pjp', 'webp');
if(in_array($fileActualExtThumb,$allowedFileTypeThumbnail)){ if(in_array($fileActualExtThumb,$allowedFileTypeThumbnail)){
$thumbnailFileNewName = uniqid("", true). "." . $fileActualExtThumb; $thumbnailFileNewName = uniqid("", true). "." . $fileActualExtThumb;

View File

@ -0,0 +1,21 @@
<?php
require_once "../../../bootstrap.php";
use \Backend\Models\GameData;
use \Backend\Models\Group;
use \Backend\Models\GameJam;
if(isset($_GET['gameDataId'])){
$openGameDataStream = GameData::find($_GET['gameDataId']);
}elseif(isset($_GET['groupId'])){
$openGameDataStream = Group::find($_GET['groupId'])->GameData();
}elseif (isset($_GET['gameJamId'])){
$openGameDataStream = Group::where("game_jam_id",$_GET['gameJamId'])->GameData();/*->pluck("id")->toArray()*/;
}else{
$openGameDataStream = GameData::all();
}
header('Content-Type: application/json;charset=UTF-8');
echo $openGameDataStream ->toJson(JSON_PRETTY_PRINT);

View File

@ -1,6 +1,7 @@
<?php <?php
require "../../../bootstrap.php"; require "../../../bootstrap.php";
require_once "Group.php";
use Backend\Models\Group; use Backend\Models\Group;
use Backend\Models\Password; use Backend\Models\Password;
@ -45,5 +46,7 @@ if(isset($_POST['regGroup'])){
$_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'); header('location: ../../../Frontend/index.php');
}else{
echo "asdasd";
} }
} }

View File

@ -1 +1,22 @@
<?php <?php
require_once "../../../bootstrap.php";
require_once "../Admin/Admin.php";
use Backend\Models\Group;
use \Backend\Models\KeyWord;
use \Backend\Models\GameJam;
use \Illuminate\Support\Collection;
if (!isAdmin()){
if(isset($_POST['genKeyWord'])){
$gameJamId = $_POST['gameJamId'];
$game_jam = GameJam::find($gameJamId);
$all_group_in_game_jam_id = Group::where("game_jam_id", $game_jam->id)->pluck("id")->toArray();
$find_all_keywords = KeyWord::whereIn("group_id", $all_group_in_game_jam_id)->inRandomOrder()->get();
$game_jam->key_word = $find_all_keywords->first()->key_word;
$game_jam->save();
header('Content-Type: application/json;charset=UTF-8');
echo $find_all_keywords->pluck("key_word")->toJson(JSON_PRETTY_PRINT);
}
}

View File

@ -1,5 +1,6 @@
<?php <?php
require "../../bootstrap.php"; require "../../../bootstrap.php";
require_once "../Group/Group.php";
use Backend\Models\Group; use Backend\Models\Group;
use Backend\Models\KeyWord; use Backend\Models\KeyWord;
@ -8,10 +9,10 @@ session_start();
if (session_status() === PHP_SESSION_ACTIVE) { if (session_status() === PHP_SESSION_ACTIVE) {
if(isset($_POST['submitKeyWord'])){ if(isset($_POST['submitKeyWord'])){
//Find the group id //Find the group id
$group = Group::find($_SESSION['groupId']); $group = groupViaToken($_SESSION['token']);
//if statement to find out if the group have use all their keyWords //if statement to find out if the group have use all their keyWords
if(KeyWord::where('group_id', $group->id)->count()<$group->groupAmount){ if(KeyWord::where('group_id', $group->id)->count()<$group->group_amount){
//Make a new keyword[Only to be used if you need to make a new of something] //Make a new keyword[Only to be used if you need to make a new of something]
$keyword = new KeyWord(); $keyword = new KeyWord();
@ -24,9 +25,9 @@ if (session_status() === PHP_SESSION_ACTIVE) {
//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.php?created=failed");
}else{ }else{
header("location: ../Frontend/index.php?created=success"); header("location:../../../Frontend/index.php?created=success");
} }
} }

View File

@ -21,8 +21,9 @@ $gameJam = GameJam::firstOrCreate([
<input type="text" name="groupName" placeholder="Group name"> <input type="text" name="groupName" placeholder="Group name">
<input type="number" name="groupAmount" placeholder="Group Amount"> <input type="number" name="groupAmount" placeholder="Group Amount">
<input type="number" name="gameJamId" placeholder="Game Jam id"> <input type="number" name="gameJamId" placeholder="Game Jam id">
<input type="password" name="password" placeholder="password"> <input type="password" name="password1" placeholder="password">
<input type="submit" name="reg_group" value="Register"> <input type="password" name="password2" placeholder="password">
<input type="submit" name="regGroup" value="Register">
</form> </form>

View File

@ -0,0 +1,17 @@
<?php ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action="../Backend/Controllers/keyWord/genRandomKeyWinner.php" method="POST">
<input type="number" name="gameJamId" placeholder="Game Jam id">
<input type="submit" value="Gen" name="genKeyWord" id="pog" />
</form>
</body>
</html>

View File

@ -1,4 +1,3 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>