This commit is contained in:
Andreas Schaafsma 2019-04-24 11:06:08 +02:00
parent 57691246ed
commit 0ab34603d0
15 changed files with 140 additions and 20 deletions

View File

@ -0,0 +1,13 @@
<?php
class ActionHandler
{
static function doAction(){
$action = '';
if(isset($_GET['action'])){
if(!$action == ''){
include_once("./model/actions/model_".$action."php");
}
}
}
}
?>

View File

@ -1,5 +1,7 @@
<?php
Class HUtils{
const FETCHGET = 0;
const FETCHPOST = 1;
static function issetPost($arr_postvars){
for ($i=0; $i <sizeof($arr_postvars) ; $i++)
{
@ -22,10 +24,18 @@ Class HUtils{
return new DateTime($date);
}
static function getPage(){
static function getPage($fetchmethod){
$p = "";
if(isset($_GET['p'])){
$p = $_GET['p'];
if($fetchmethod == HUtils::FETCHGET){
if(isset($_GET['p'])){
$p = $_GET['p'];
}
}
else if($fetchmethod == HUtils::FETCHPOST){
if(isset($_POST['p']))
{
$p = $_POST['p'];
}
}
return $p;
}

View File

@ -0,0 +1,38 @@
<?php
class Reply{
public $id;
public $user;
public $thread;
public $text;
function Reply($id, $user, $thread, $text){
$this->id = $id;
$this->user = $user;
$this->thread = $thread;
$this->text = $text;
}
public function getId(){
return $this->id;
}
public function setId($id){
$this->id = $id;
}
public function getUser(){
return $this->user;
}
public function setUser($user){
$this->user = $user;
}
public function getThread(){
return $this->thread;
}
public function setThread($thread){
$this->thread = $thread;
}
public function getText(){
return $this->text;
}
public function setText($text){
$this->text = $text;
}
}
?>

View File

@ -0,0 +1,18 @@
<?php
class Thread{
static $threadArray = [];
public $id;
public $titel;
public $text;
public $user;
public $board;
public function Thread($id, $titel, $text, $user){
$this->id = $id;
$this->titel = $titel;
$this->text = $text;
$this->user = $user;
array_push(Thread::$threadArray, $this);
}
}
?>

View File

@ -0,0 +1,33 @@
<?php
class User{
static $userArray = [];
public $id;
public $username;
public $email;
public function User($id, $username, $email, $password){
$this->id = $id;
$this->username = $username;
$this->email = $email;
$this->password = $password;
array_push(User::$userArray, $this);
}
public function getId(){
return $this->id;
}
public function setId($id){
$this->id = $id;
}
public function getUsername(){
return $this->username;
}
public function setUsername($username){
$this->username = $username;
}
public function getEmail(){
return $this->email;
}
public function setEmail($email){
$this->email = $email;
}
}
?>

View File

@ -14,7 +14,7 @@ include_once("./controller/UserSession.php");
include_once("./controller/HUtils.php");
session_start();
//Store de geselecteerde pagina in variabele $page
$page=HUtils::getPage();
$page=HUtils::getPage(HUtils::FETCHPOST);
//Model side operaties die afgerond moeten worden voor de paginacontent in wordt geladen
$path = "./model/model_".$page.".php";
if($page != ""){

View File

@ -4,9 +4,4 @@ if(UserSession::isSessionValid()){
Database::invalidateSession(UserSession::getSession()->token);
session_destroy();
}
?>

View File

@ -2,7 +2,7 @@
//Include classes
include_once("./controller/Database.php");
include_once("./controller/HUtils.php");
if(HUtils::issetPost(['email', 'pass', 'name'])){
if(HUtils::issetPost(['email', 'pass', 'pass2', 'name'])){
if($_POST['pass'] == $_POST['pass2']){
//Check of email aanwezig is in de database
if(!Database::checkUsedEmail($_POST['email']) && !Database::checkUsedUsername($_POST['name'])){

View File

@ -1,10 +1,4 @@
*{
font-family: Arial, Helvetica, sans-serif;
}
header{
background-color: bisque;
}
a{
margin-right: 10px;
text-decoration: none;
}

View File

@ -1,7 +1,8 @@
<article>
<form action="?p=attempt_login" method="post">
<form action="" method="post">
E-mail: <input type="text" name="email"><br>
Password: <input type="password" name="password"><br>
<input type="hidden" name="p" value="do_login" />
<input type="submit">
</form>
</article>

View File

@ -18,10 +18,9 @@
<main>
<?php
//Store de geselecteerde pagina in variabele $page
$page=HUtils::getPage();
$page=HUtils::getPage(HUtils::FETCHGET);
//Laad de juiste view
$path = "./view/pagecontent/content_".$page.".php";
if($page != ""){
if(file_exists($path)){
include_once($path);

View File

@ -5,6 +5,7 @@
E-mail: <input type="text" name="email" id="email" onkeyup="checkInputs()"><br>
Password: <input type="password" name="pass" id="pass" onkeyup="checkInputs()"><br>
Verify Password: <input type="password" name="pass2" id="pass2" onkeyup="checkInputs()"><br>
<input type="hidden" name="p" value="do_register" />
<input type="submit" id="submitButton" disabled>
</form>
<div id="jsSignupAlert"></div>

View File

@ -0,0 +1,10 @@
<?php
if(UserSession::isUserSignedIn()){
echo "LIST OF BOARDS LMAO";
}
else{
echo "You must be signed in to view this page.";
}
?>

View File

@ -0,0 +1,8 @@
<div>
<form action="" method="post">
E-mail: <input type="text" name="email">
Password: <input type="password" name="password">
<input type="hidden" name="p" value="do_login"/>
<input type="submit">
</form>
</div>