database And dertory update
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
require "../../../bootstrap.php";
|
||||
|
||||
use Backend\Models\Group;
|
||||
use Backend\Models\Password;
|
||||
|
||||
session_start();
|
||||
if(isset($_SESSION['Admin'])){
|
||||
if(isset($_POST['RestPassword'])){
|
||||
$group = Group::find($_POST['groupId']);
|
||||
if($group){
|
||||
$group->password->password = password_hash("Aa123456&", PASSWORD_DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Backend\Models\Group;
|
||||
use Backend\Models\Vote;
|
||||
require "../../../bootstrap.php";
|
||||
|
||||
|
||||
if(isset($_POST['1vote_for'])){
|
||||
require "VoteChecking.php";
|
||||
|
||||
$vote = new Vote();
|
||||
$vote->group()->associate(Group::find($_POST['groupId']));
|
||||
$vote->points += 1;
|
||||
if(!empty($_POST['comment'])){
|
||||
$vote->comment = $_POST['comment'];
|
||||
}
|
||||
$vote->save();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Backend\Models\Group;
|
||||
use Backend\Models\Vote;
|
||||
require "../../../bootstrap.php";
|
||||
|
||||
|
||||
if(isset($_POST['321vote_for'])){
|
||||
require "VoteChecking.php";
|
||||
|
||||
//give 1 point
|
||||
$vote = new Vote();
|
||||
$vote->group()->associate(Group::find($_POST['1pGroupId']));
|
||||
$vote->points += 1;
|
||||
if(!empty($_POST['1pComment'])){
|
||||
$vote->comment = $_POST['1pComment'];
|
||||
}
|
||||
$vote->save();
|
||||
//give 2 point
|
||||
$vote = new Vote();
|
||||
$vote->group()->associate(Group::find($_POST['2pGroupId']));
|
||||
$vote->points += 2;
|
||||
if(!empty($_POST['2pComment'])){
|
||||
$vote->comment = $_POST['2pComment'];
|
||||
}
|
||||
$vote->save();
|
||||
//give 3 point
|
||||
$vote = new Vote();
|
||||
$vote->group()->associate(Group::find($_POST['3pGroupId']));
|
||||
$vote->points += 3;
|
||||
if(!empty($_POST['3pComment'])){
|
||||
$vote->comment = $_POST['3pComment'];
|
||||
}
|
||||
$vote->save();
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
$votes = array();
|
||||
if(isset($_COOKIE["Voting_reg"])) {
|
||||
$votes = unserialize($_COOKIE["Voting_reg"]);
|
||||
foreach ($votes as $vote){
|
||||
if($_POST['gameJamId'] === $vote) return;
|
||||
}
|
||||
}
|
||||
array_push($votes,$_POST['gameJamId']);
|
||||
setcookie("Voting_reg", serialize($votes), time() + 86400, "/");
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
require "../../../bootstrap.php";
|
||||
|
||||
use Backend\Models\Group;
|
||||
use Backend\Models\Password;
|
||||
|
||||
//Start the php session
|
||||
session_start();
|
||||
|
||||
if(isset($_POST['login'])){
|
||||
|
||||
$groupName = $_POST["groupName"];
|
||||
$password = $_POST["password"];
|
||||
|
||||
$group = Group::firstWhere('groupName', $groupName );
|
||||
if($group){
|
||||
$hashedPassword = $group->password->password;
|
||||
if(password_verify($password, $hashedPassword )){
|
||||
$_SESSION['groupName'] = $groupName;
|
||||
$_SESSION['groupId'] = $group->id;
|
||||
$_SESSION['success'] = "You are now logged in";
|
||||
header('location: ../Frontend/index.php?login=success');
|
||||
}else{
|
||||
session_destroy();
|
||||
header('location: ../Frontend/index.php?login=failed?reason=password');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
session_destroy();
|
||||
header('location: ../Frontend/index.php?login=failed?reason=group');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
require "../../../bootstrap.php";
|
||||
|
||||
use Backend\Models\Group;
|
||||
use Backend\Models\Password;
|
||||
use Backend\Models\GameJam;
|
||||
|
||||
session_start();
|
||||
|
||||
$groupName = "";
|
||||
$errors = array();
|
||||
|
||||
if(isset($_POST['reg_group'])){
|
||||
|
||||
|
||||
|
||||
|
||||
$group = new Group();
|
||||
|
||||
$group->gameJam()->associate(GameJam::find($_POST['gameJamId']));
|
||||
|
||||
$group->groupName = $groupName = $_POST['groupName'];
|
||||
|
||||
$group->groupAmount = $_POST['groupAmount'];
|
||||
|
||||
if(!$group->save()){
|
||||
return;
|
||||
}
|
||||
$password = New Password();
|
||||
|
||||
$password->group()->associate($group);
|
||||
|
||||
$password->password = password_hash($_POST['password'] ,PASSWORD_DEFAULT);
|
||||
|
||||
if(!$password->save()){
|
||||
return;
|
||||
}
|
||||
|
||||
$_SESSION['groupName'] = $groupName;
|
||||
$_SESSION['groupId'] = $group->id;
|
||||
$_SESSION['success'] = "You are now logged in";
|
||||
header('location: index.php');
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
session_destroy();
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
require "../../bootstrap.php";
|
||||
use Backend\Models\Group;
|
||||
use Backend\Models\KeyWord;
|
||||
|
||||
session_start();
|
||||
|
||||
if (session_status() === PHP_SESSION_ACTIVE) {
|
||||
if(isset($_POST['submitKeyWord'])){
|
||||
//Find the group id
|
||||
$group = Group::find($_SESSION['groupId']);
|
||||
|
||||
//if statement to find out if the group have use all their keyWords
|
||||
if(KeyWord::where('group_id', $group->id)->count()<$group->groupAmount){
|
||||
|
||||
//Make a new keyword[Only to be used if you need to make a new of something]
|
||||
$keyword = new KeyWord();
|
||||
|
||||
//Take the keyWord the user typed and set it equal to the keyword valuable
|
||||
$keyword->keyWord = $_POST['key_word'];
|
||||
|
||||
//Make foreign key from the groups table to the keyWords table
|
||||
$keyword->group()->associate($group);
|
||||
|
||||
//Try to save it
|
||||
if(!$keyword->save()){
|
||||
header("location: ../Frontend/index.php?created=failed");
|
||||
}else{
|
||||
header("location: ../Frontend/index.php?created=success");
|
||||
}
|
||||
}
|
||||
|
||||
//TODO make toast feedback
|
||||
}
|
||||
}else{
|
||||
header("location: ../Frontend/index.php?login=notLoggein");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user