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');
echo $openGameDataStream ->toJson(JSON_PRETTY_PRINT);
echo $openGameDataStream->toJson(JSON_PRETTY_PRINT);

View File

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

View File

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

View File

@ -3,11 +3,11 @@ require_once "../../../bootstrap.php";
require_once "Group.php";
use Backend\Models\Password;
if(isset($_SESSION['token'])){
if(isLogin()){
if(isset($_POST['updatePassword']))
$password = Password::firstWhere("group_id", groupViaToken($_SESSION["token"])->id);
if(passwordValidate($pass = $_POST['password1'], $_POST['password2'])){
$password = password_hash($pass,PASSWORD_DEFAULT);
if(passwordValidate($pass = $_POST['password'])){
$password->password = password_hash($pass,PASSWORD_DEFAULT);
$password->save();
}

View File

@ -2,19 +2,22 @@
use Backend\Models\Group;
use Backend\Models\Vote;
require "../../../bootstrap.php";
require_once "../../../bootstrap.php";
require_once "Vote.php";
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->group()->associate(Group::find($_POST['groupId']));
$vote->points += 1;
if(!empty($_POST['comment'])){
$vote->comment = $_POST['comment'];
$vote->points += 1;
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'])){
require "VoteChecking.php";
require "Vote.php";
//give 1 point
$vote = new Vote();

View File

@ -5,6 +5,6 @@ require_once "../Group/Group.php";
if(isLogin()){
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";
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();
$winningGroup = array();
$winningGroups = new Collection();
$i = -1;
foreach ($groups as $group){
$x = Vote::where('group_id', $group->id)->count();
if($x>$i){
$winningGroup = array();
array_push($winningGroup,$group);
$winningGroups = new Collection();
$winningGroups->push($group);
$i = $x;
}
elseif ($i === $x){
array_push($winningGroup,$group);
$winningGroups->push($group);
}
}
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, "/");