all controllers is aok

This commit is contained in:
RundelhausCode 2021-03-12 14:05:31 +01:00
parent c6e002d464
commit 91e4d3df00
10 changed files with 68 additions and 43 deletions

View File

@ -19,4 +19,4 @@ if(isset($_GET['gameDataId'])){
header('Content-Type: application/json;charset=UTF-8'); header('Content-Type: application/json;charset=UTF-8');
echo $openGameDataStream ->toJson(JSON_PRETTY_PRINT); echo $openGameDataStream->toJson(JSON_PRETTY_PRINT);

View File

@ -2,17 +2,21 @@
require_once "../../../bootstrap.php"; require_once "../../../bootstrap.php";
require_once "../Admin/Admin.php"; require_once "../Admin/Admin.php";
use Backend\Models\Group; use \Backend\Models\Password;
//session_start(); //session_start();
if(isAdmin()){ if(isAdmin()){
if(isset($_POST['restPassword'])){ if(isset($_POST['restPassword'])){
$group = Group::find($_POST['groupId']); $password = Password::firstWhere("group_id",$_POST['groupId']);
if($group){ if($password){
$group->password->password = password_hash($_POST['newPassword'], PASSWORD_DEFAULT); $password->password = password_hash($_POST['newPassword'], PASSWORD_DEFAULT);
if($group->save()){ echo $password;
if(!$password->save()){
} }
}else{
} }
} }
} }

View File

@ -1,24 +1,20 @@
<?php <?php
require "../../../bootstrap.php"; require "../../../bootstrap.php";
require_once "Group.php";
use Backend\Models\Group; use Backend\Models\Group;
session_start(); if(isLogin()){
if (isset($_POST['updateGroup'])) { if (isset($_POST['updateGroup'])) {
if($group = Group::find($_POST['groupId'])){ if($group = groupViaToken($_SESSION['token'])){
if ($group->password->remember_token === $_SESSION['token']){
$group->group_name = $_POST['groupName']; $group->group_name = $_POST['groupName'];
$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();
}
} }
} }
}

View File

@ -3,11 +3,11 @@ require_once "../../../bootstrap.php";
require_once "Group.php"; require_once "Group.php";
use Backend\Models\Password; use Backend\Models\Password;
if(isset($_SESSION['token'])){ 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['password1'], $_POST['password2'])){ if(passwordValidate($pass = $_POST['password'])){
$password = password_hash($pass,PASSWORD_DEFAULT); $password->password = password_hash($pass,PASSWORD_DEFAULT);
$password->save(); $password->save();
} }

View File

@ -2,19 +2,22 @@
use Backend\Models\Group; use Backend\Models\Group;
use Backend\Models\Vote; use Backend\Models\Vote;
require "../../../bootstrap.php"; require_once "../../../bootstrap.php";
require_once "Vote.php";
if(isset($_POST['1Vote'])){ if(isset($_POST['1Vote'])){
require "VoteChecking.php"; if(VoteCheck($_POST['groupId'])){
$vote = new Vote();
$vote->group()->associate(Group::find($_POST['groupId']));
$vote = new Vote(); $vote->points += 1;
$vote->group()->associate(Group::find($_POST['groupId'])); if(!empty($_POST['comment'])){
$vote->points += 1; $vote->comment = $_POST['comment'];
if(!empty($_POST['comment'])){ }
$vote->comment = $_POST['comment']; $vote->save();
} }
$vote->save();
} }

View File

@ -6,7 +6,7 @@ require "../../../bootstrap.php";
if(isset($_POST['321Vote'])){ if(isset($_POST['321Vote'])){
require "VoteChecking.php"; require "Vote.php";
//give 1 point //give 1 point
$vote = new Vote(); $vote = new Vote();

View File

@ -5,6 +5,6 @@ require_once "../Group/Group.php";
if(isLogin()){ if(isLogin()){
header('Content-Type: application/json;charset=UTF-8'); header('Content-Type: application/json;charset=UTF-8');
echo Vote::where('group_id',groupViaToken($_SESSION['token']))->get()->toJson(JSON_PRETTY_PRINT); echo Vote::where('group_id',groupViaToken($_SESSION['token'])->id)->get()->toJson(JSON_PRETTY_PRINT);
} }

View File

@ -3,23 +3,27 @@ require_once "../../../bootstrap.php";
require_once "../Admin/Admin.php"; require_once "../Admin/Admin.php";
use Backend\Models\Group; use Backend\Models\Group;
use Backend\Models\Vote; use Backend\Models\Vote;
use \Illuminate\Support\Collection;
if(isAdmin() && isset($_GET['gameJamId'])){ if(isAdmin() && isset($_GET['gameJamId'])){
$groups = Group::where('game_jam_id',$_GET['gameJamId'])->get(); $groups = Group::where('game_jam_id',$_GET['gameJamId'])->get();
$winningGroup = array(); $winningGroups = new Collection();
$i = -1; $i = -1;
foreach ($groups as $group){ foreach ($groups as $group){
$x = Vote::where('group_id', $group->id)->count(); $x = Vote::where('group_id', $group->id)->count();
if($x>$i){ if($x>$i){
$winningGroup = array(); $winningGroups = new Collection();
array_push($winningGroup,$group); $winningGroups->push($group);
$i = $x; $i = $x;
} }
elseif ($i === $x){ elseif ($i === $x){
array_push($winningGroup,$group); $winningGroups->push($group);
} }
} }
header('Content-Type: application/json;charset=UTF-8'); header('Content-Type: application/json;charset=UTF-8');
echo $winningGroup->toJson(JSON_PRETTY_PRINT); echo $winningGroups->toJson(JSON_PRETTY_PRINT);
} }

View File

@ -0,0 +1,28 @@
<?php
require "../../../bootstrap.php";
use \Backend\Models\Group;
/**
* @param string $voteId
* @return bool
*/
function VoteCheck(string $voteId): bool
{
$votes = array();
if(isset($_COOKIE["VotingReg"])) {
$votes = unserialize($_COOKIE["VotingReg"]);
foreach ($votes as $vote){
if($voteId === $vote) {
return false;
}
}
}
array_push($votes,$voteId);
setcookie("VotingReg", serialize($votes), time() + 86400, "/");
return true;
}

View File

@ -1,10 +0,0 @@
<?php
$votes = array();
if(isset($_COOKIE["votingReg"])) {
$votes = unserialize($_COOKIE["votingReg"]);
foreach ($votes as $vote){
if($_POST['gameJamId'] === $vote) return;
}
}
array_push($votes,$_POST['gameJamId']);
setcookie("VotingReg", serialize($votes), time() + 86400, "/");