diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..abe5e15
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,24 @@
+{
+ // Use IntelliSense to learn about possible attributes.
+ // Hover to view descriptions of existing attributes.
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "Listen for XDebug",
+ "type": "php",
+ "request": "launch",
+ "port": 9000
+ },
+ {
+ "name": "Launch currently open script",
+ "type": "php",
+ "request": "launch",
+ "program": "${file}",
+ "cwd": "${fileDirname}",
+ "port": 9000
+ }
+ ],
+ "php.executablePath": "C:/xampp/php/php.exe",
+ "php.suggest.basic": "false"
+}
\ No newline at end of file
diff --git a/dev/app/HUtils.php b/dev/app/HUtils.php
new file mode 100644
index 0000000..b620cac
--- /dev/null
+++ b/dev/app/HUtils.php
@@ -0,0 +1,26 @@
+
\ No newline at end of file
diff --git a/dev/app/assets/AssetHandler.php b/dev/app/assets/AssetHandler.php
new file mode 100644
index 0000000..05dad34
--- /dev/null
+++ b/dev/app/assets/AssetHandler.php
@@ -0,0 +1,17 @@
+';
+ }
+ else{
+ echo 'prepare("SELECT * FROM users where email = :email");
+ //Bind parameters
+ $query->bindParam(':email', $email, PDO::PARAM_STR, 256);
+ //Voer de query uit
+ $query->execute();
+ //Check de hoeveelheid rijen die de database returnt.
+ if($query->rowCount() == 0){
+ //Email adres is niet in gebruik, return false
+ return false;
+ }
+ else{
+ //Email is al in gebruik of komt meer dan een keer voor. Beide gevallen zijn een probleem dus return true.
+ return true;
+ }
+ }
+ //Controleert of de gebruikersnaam al in de database voorkomt. Returnt true indien wel.
+ static function checkUsedUsername($username){
+ $con = Database::connectToDB();
+ //Bereid query voor
+ $query = $con->prepare("SELECT * FROM users where username = :username");
+ //Bind parameters
+ $query->bindParam(':username', $username, PDO::PARAM_STR, 256);
+ //Voer de query uit
+ $query->execute();
+ //Check de hoeveelheid rijen die de database returnt.
+ if($query->rowCount() == 0){
+ //Username adres is niet in gebruik, return false
+ return false;
+ }
+ else{
+ //Username is al in gebruik of komt meer dan een keer voor. Beide gevallen zijn een probleem dus return true.
+ return true;
+ }
+ }
+ //Registreert een gebruiker. Neemt als invoer email, wachtwoord, gebruikersnaam.
+ static function registerUser($email, $password, $username){
+ $ip = $_SERVER['REMOTE_ADDR'];
+ //Initit db connection
+ $con = Database::connectToDB();
+ //Bereid query voor
+ $query = $con->prepare("INSERT INTO users (username, email, password, reg_ip) VALUES (:username, :email, :password, :ip)");
+ //Bind parameters
+ $query->bindParam(':username', $username, PDO::PARAM_STR, 256);
+ $query->bindParam(':email', $email, PDO::PARAM_STR, 256);
+ $query->bindParam(':password', $password, PDO::PARAM_STR, 256);
+ $query->bindParam(':ip', $ip, PDO::PARAM_STR, 256);
+ //Voer query uit
+ $query->execute();
+ }
+ //Check of gegeven login info in de database voorkomt
+ static function isLoginValid($email, $password){
+ //Init db connection
+ $con = Database::connectToDB();
+ //Bereid query voor
+ $query = $con->prepare("SELECT * FROM users where email = :email AND password = :password");
+ //Bind params
+ $query->bindParam(':email', $email, PDO::PARAM_STR, 256);
+ $query->bindParam(':password', $password, PDO::PARAM_STR, 256);
+ //Voer query it
+ $query->execute();
+ //Check hoeveelheid teruggestuurde rijen
+ if($query->rowCount() == 1){
+ //login correct (komt voor in de db)
+ return true;
+ }
+ else{
+ //Incorrect
+ return false;
+ }
+ }
+ //Vraag gebruikers ID op doormiddel van email en pass
+ static function getUID($email, $password){
+ //Init db connection
+ $con = Database::connectToDB();
+ //Bereid query voor
+ $query = $con->prepare("SELECT id FROM users where email = :email AND password = :password");
+ //Bind params
+ $query->bindParam(':email', $email, PDO::PARAM_STR, 256);
+ $query->bindParam(':password', $password, PDO::PARAM_STR, 256);
+ //Voer query it
+ $query->execute();
+ //Check hoeveelheid teruggestuurde rijen
+ if($query->rowCount() == 1){
+ //login correct, return uid
+ $result = $query->fetch(PDO::FETCH_COLUMN);
+ return $result;
+ }
+ else{
+ //something went wrong, return -1
+ return -1;
+ }
+ }
+ static function getUsername($uid){
+ $con = Database::connectToDB();
+ $query = $con->prepare("SELECT username FROM users where id = :uid");
+ $query->bindParam(':uid', $uid, PDO::PARAM_STR, 256);
+ $query->execute();
+ if($query->rowCount() == 1){
+ //login correct, return uid
+ $result = $query->fetch(PDO::FETCH_COLUMN);
+ return $result;
+ }
+ else{
+ //something went wrong, return -1
+ return "dbfetcherror";
+ }
+ }
+ static function isSessionTokenInUse($token){
+ //Init db connection
+ $con = Database::connectToDB();
+ //Bereid query voor
+ $query = $con->prepare("SELECT * FROM usersessions where token = :token");
+ //Bind params
+ $query->bindParam(':token', $token, PDO::PARAM_STR, 256);
+ //Voer query it
+ $query->execute();
+ //Check hoeveelheid teruggestuurde rijen
+ if($query->rowCount() == 0){
+ return false;
+ }
+ else{
+ return true;
+ }
+ }
+ static function registerNewSession($uid, $token, $expires){
+ //Init db connection
+ $con = Database::connectToDB();
+ //Bereid query voor
+ $query = $con->prepare("INSERT INTO usersessions (uid, token, expires) VALUES (:uid, :token, :expires)");
+ //Bind params
+ $query->bindParam(':uid', $uid, PDO::PARAM_INT);
+ $query->bindParam(':token', $token, PDO::PARAM_STR, 256);
+ $query->bindParam(':expires', $expires, PDO::PARAM_STR);
+ //Voer query it
+ $query->execute();
+ }
+ static function isSessionValid($token, $uid){
+ //Init db connection
+ $con = Database::connectToDB();
+ //Bereid query voor
+ $query = $con->prepare("SELECT * FROM usersessions where token = :token AND uid = :uid AND expires > NOW()");
+ //Bind params
+ $query->bindParam(':token', $token, PDO::PARAM_STR, 256);
+ $query->bindParam(':uid', $uid, PDO::PARAM_STR, 256);
+ //Voer query it
+ $query->execute();
+ //Check hoeveelheid teruggestuurde rijen
+ if($query->rowCount() == 1){
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+ static function invalidateSession($token){
+ //Init db connection
+ $con = Database::connectToDB();
+ //Bereid query voor
+ $query = $con->prepare("DELETE FROM usersessions WHERE token = :token");
+ //Bind params
+ $query->bindParam(':token', $token, PDO::PARAM_STR, 256);
+ //Voer query it
+ $query->execute();
+ }
+ static function invalidateSessionByUID($uid){
+ //Init db connection
+ $con = Database::connectToDB();
+ //Bereid query voor
+ $query = $con->prepare("DELETE FROM usersessions WHERE uid = :uid");
+ //Bind params
+ $query->bindParam(':token', $uid, PDO::PARAM_INT);
+ //Voer query it
+ $query->execute();
+ }
+ static function deleteExpiredSessions(){
+ $con = Database::connectToDB();
+ //Bereid query voor
+ $query = $con->prepare("DELETE FROM usersessions WHERE expires < NOW()");
+ $query->execute();
+ }
+ static function getSessionExpiryDate($token){
+ $con = Database::connectToDB();
+ $query = $con->prepare("SELECT expires FROM usersessions where token = :token");
+ $query->bindParam(':token', $token, PDO::PARAM_STR, 256);
+ $query->execute();
+ if($query->rowCount() == 1){
+ //login correct, return uid
+ $result = $query->fetch(PDO::FETCH_COLUMN);
+ return $result;
+ }
+ else{
+ //something went wrong, return -1
+ return "2000-01-01 00:00:00";
+ }
+ }
+ static function createThread(){
+
+ }
+}
+?>
\ No newline at end of file
diff --git a/dev/app/login/UserSession.php b/dev/app/login/UserSession.php
new file mode 100644
index 0000000..c795add
--- /dev/null
+++ b/dev/app/login/UserSession.php
@@ -0,0 +1,92 @@
+username = $username;
+ $this->uid = $uid;
+ $this->token = $token;
+ $this->setExpiry();
+ //echo($username." ");
+ //echo($loginSessionToken);
+ $_SESSION['usersession'] = $this;
+ setcookie('usersession', $this->token);
+ setcookie('uid', $this->uid);
+ }
+ public function setSessionToken($token){
+ $this->token = $token;
+ }
+ public function getSessionToken(){
+ return $this->token;
+ }
+ public function getFormattedExpiry(){
+ return $this->expires->format('Y-m-d H:i:s');
+ }
+ public function setExpiry(){
+ $this->expires = new DateTime();
+ $this->expires->modify("+ 1 hour");
+ }
+ public static function generateToken(){
+ $chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ $token = "";
+ for ($i=0; $i < 32 ; $i++) {
+ $token .= $chars[rand(0, strlen($chars) - 1)];
+ }
+ return $token;
+ }
+ public static function isSessionValid(){
+ if(isset($_SESSION['usersession'])){
+ if(!UserSession::isSessionExpired($_SESSION['usersession'])){
+ //check if session also exists in database
+ return true;
+ }
+ }
+ else{
+ if(isset($_COOKIE['usersession'])){
+ $token = $_COOKIE['usersession'];
+ $uid = $_COOKIE['uid'];
+ if(Database::isSessionValid($token,$uid)){
+ $username = Database::getUsername($uid);
+ $session = new UserSession($username, $uid, $token);
+ $session->expires = new DateTime(Database::getSessionExpiryDate($token));
+ }
+ else{
+ return false;
+ }
+ if(!UserSession::isSessionExpired($session)){
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+ public static function getSession()
+ {
+ return $_SESSION['usersession'];
+ }
+ public static function isSessionExpired($session){
+ //session is expired
+ if(new DateTime() > $session->expires){
+ return true;
+ }
+ //session is not expired
+ else{
+ return false;
+ }
+ }
+ public static function isUserSignedIn(){
+ if(UserSession::isSessionValid()){
+ if(!UserSession::isSessionExpired(UserSession::getSession())){
+ if(Database::isSessionValid(UserSession::getSession()->token, UserSession::getSession()->uid)){
+ return true;
+ }
+ }
+ else{
+ return false;
+ }
+ }
+ }
+}
+?>
\ No newline at end of file
diff --git a/dev/app/login/attempt_login.php b/dev/app/login/attempt_login.php
new file mode 100644
index 0000000..cae9861
--- /dev/null
+++ b/dev/app/login/attempt_login.php
@@ -0,0 +1,46 @@
+getSessionToken();
+ echo " ";
+ echo $a->uid;
+ echo " ";
+ echo $a->username;
+ }
+ //clean up expired sessions from ANY users
+ Database::deleteExpiredSessions();
+ Database::registerNewSession($a->uid, $a->token, $a->getFormattedExpiry());
+ //logged in, time to continue with other stuff
+ }
+ else{
+ echo "uid returned -1 from db interface";
+ }
+ }
+ else{
+ echo("login invalid");
+ }
+ }
+}
+else{
+ //we're done, don't even need to log in, session already active
+ //echo($_SESSION['usersession']->uid);
+}
+?>
\ No newline at end of file
diff --git a/dev/app/login/attempt_logout.php b/dev/app/login/attempt_logout.php
new file mode 100644
index 0000000..456fc0f
--- /dev/null
+++ b/dev/app/login/attempt_logout.php
@@ -0,0 +1,12 @@
+token);
+ session_destroy();
+}
+
+
+
+
+
+?>
\ No newline at end of file
diff --git a/dev/app/login/destroy.php b/dev/app/login/destroy.php
new file mode 100644
index 0000000..ecf6762
--- /dev/null
+++ b/dev/app/login/destroy.php
@@ -0,0 +1,3 @@
+
\ No newline at end of file
diff --git a/dev/app/pagecontent/content_createthread.php b/dev/app/pagecontent/content_createthread.php
new file mode 100644
index 0000000..176c8a7
--- /dev/null
+++ b/dev/app/pagecontent/content_createthread.php
@@ -0,0 +1,6 @@
+
\ No newline at end of file
diff --git a/dev/app/pagecontent/content_header.php b/dev/app/pagecontent/content_header.php
new file mode 100644
index 0000000..1c07e88
--- /dev/null
+++ b/dev/app/pagecontent/content_header.php
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/dev/app/pagecontent/content_header_signedin.php b/dev/app/pagecontent/content_header_signedin.php
new file mode 100644
index 0000000..76343dd
--- /dev/null
+++ b/dev/app/pagecontent/content_header_signedin.php
@@ -0,0 +1,6 @@
+
+
\ No newline at end of file
diff --git a/dev/app/pagecontent/content_index.php b/dev/app/pagecontent/content_index.php
new file mode 100644
index 0000000..852160d
--- /dev/null
+++ b/dev/app/pagecontent/content_index.php
@@ -0,0 +1,3 @@
+
+
Welkom op hForumPHP. Log in of registreer om iets te doen.
+
\ No newline at end of file
diff --git a/dev/app/pagecontent/content_page.php b/dev/app/pagecontent/content_page.php
new file mode 100644
index 0000000..ed57278
--- /dev/null
+++ b/dev/app/pagecontent/content_page.php
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+ =$sSiteTitle?>
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dev/app/pagecontent/login/content_destroy.php b/dev/app/pagecontent/login/content_destroy.php
new file mode 100644
index 0000000..dc3cd8b
--- /dev/null
+++ b/dev/app/pagecontent/login/content_destroy.php
@@ -0,0 +1,3 @@
+
+
You're still signed in thanks to our cookies!
+
\ No newline at end of file
diff --git a/dev/app/pagecontent/login/content_login.php b/dev/app/pagecontent/login/content_login.php
new file mode 100644
index 0000000..dd07475
--- /dev/null
+++ b/dev/app/pagecontent/login/content_login.php
@@ -0,0 +1,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/dev/app/pagecontent/login/content_login_succesful.php b/dev/app/pagecontent/login/content_login_succesful.php
new file mode 100644
index 0000000..ea09f68
--- /dev/null
+++ b/dev/app/pagecontent/login/content_login_succesful.php
@@ -0,0 +1,8 @@
+
+
Login succesful :DDDDDDDD
+
+
\ No newline at end of file
diff --git a/dev/app/pagecontent/login/content_login_unsuccesful.php b/dev/app/pagecontent/login/content_login_unsuccesful.php
new file mode 100644
index 0000000..a9a1ae8
--- /dev/null
+++ b/dev/app/pagecontent/login/content_login_unsuccesful.php
@@ -0,0 +1,3 @@
+
+
UNEXPECTED LOGIN ERROR. OUR CODEMONKEYS DID SOMETHING VERY WRONG :(
+
\ No newline at end of file
diff --git a/dev/app/pagecontent/login/content_register.php b/dev/app/pagecontent/login/content_register.php
new file mode 100644
index 0000000..9bdc0ac
--- /dev/null
+++ b/dev/app/pagecontent/login/content_register.php
@@ -0,0 +1,9 @@
+
+
+
\ No newline at end of file
diff --git a/dev/app/registration/attempt_register.php b/dev/app/registration/attempt_register.php
new file mode 100644
index 0000000..1441324
--- /dev/null
+++ b/dev/app/registration/attempt_register.php
@@ -0,0 +1,19 @@
+
\ No newline at end of file
diff --git a/dev/css/main.css b/dev/css/main.css
new file mode 100644
index 0000000..e69de29
diff --git a/dev/img/logo.png b/dev/img/logo.png
new file mode 100644
index 0000000..5837651
Binary files /dev/null and b/dev/img/logo.png differ
diff --git a/dev/index.php b/dev/index.php
new file mode 100644
index 0000000..d2d3c64
--- /dev/null
+++ b/dev/index.php
@@ -0,0 +1,32 @@
+
\ No newline at end of file
diff --git a/dev_mvc/controller/AssetHandler.php b/dev_mvc/controller/AssetHandler.php
new file mode 100644
index 0000000..0718470
--- /dev/null
+++ b/dev_mvc/controller/AssetHandler.php
@@ -0,0 +1,12 @@
+';
+ }
+ else{
+ echo 'prepare("SELECT * FROM users where email = :email");
+ //Bind parameters
+ $query->bindParam(':email', $email, PDO::PARAM_STR, 256);
+ //Voer de query uit
+ $query->execute();
+ //Check de hoeveelheid rijen die de database returnt.
+ if($query->rowCount() == 0){
+ //Email adres is niet in gebruik, return false
+ return false;
+ }
+ else{
+ //Email is al in gebruik of komt meer dan een keer voor. Beide gevallen zijn een probleem dus return true.
+ return true;
+ }
+ }
+ //Controleert of de gebruikersnaam al in de database voorkomt. Returnt true indien wel.
+ static function checkUsedUsername($username){
+ $con = Database::connectToDB();
+ //Bereid query voor
+ $query = $con->prepare("SELECT * FROM users where username = :username");
+ //Bind parameters
+ $query->bindParam(':username', $username, PDO::PARAM_STR, 256);
+ //Voer de query uit
+ $query->execute();
+ //Check de hoeveelheid rijen die de database returnt.
+ if($query->rowCount() == 0){
+ //Username adres is niet in gebruik, return false
+ return false;
+ }
+ else{
+ //Username is al in gebruik of komt meer dan een keer voor. Beide gevallen zijn een probleem dus return true.
+ return true;
+ }
+ }
+ //Registreert een gebruiker. Neemt als invoer email, wachtwoord, gebruikersnaam.
+ static function registerUser($email, $password, $username){
+ $ip = $_SERVER['REMOTE_ADDR'];
+ //Initit db connection
+ $con = Database::connectToDB();
+ //Bereid query voor
+ $query = $con->prepare("INSERT INTO users (username, email, password, reg_ip) VALUES (:username, :email, :password, :ip)");
+ //Bind parameters
+ $query->bindParam(':username', $username, PDO::PARAM_STR, 256);
+ $query->bindParam(':email', $email, PDO::PARAM_STR, 256);
+ $query->bindParam(':password', $password, PDO::PARAM_STR, 256);
+ $query->bindParam(':ip', $ip, PDO::PARAM_STR, 256);
+ //Voer query uit
+ $query->execute();
+ }
+ //Check of gegeven login info in de database voorkomt
+ static function isLoginValid($email, $password){
+ //Init db connection
+ $con = Database::connectToDB();
+ //Bereid query voor
+ $query = $con->prepare("SELECT * FROM users where email = :email AND password = :password");
+ //Bind params
+ $query->bindParam(':email', $email, PDO::PARAM_STR, 256);
+ $query->bindParam(':password', $password, PDO::PARAM_STR, 256);
+ //Voer query it
+ $query->execute();
+ //Check hoeveelheid teruggestuurde rijen
+ if($query->rowCount() == 1){
+ //login correct (komt voor in de db)
+ return true;
+ }
+ else{
+ //Incorrect
+ return false;
+ }
+ }
+ //Vraag gebruikers ID op doormiddel van email en pass
+ static function getUID($email, $password){
+ //Init db connection
+ $con = Database::connectToDB();
+ //Bereid query voor
+ $query = $con->prepare("SELECT id FROM users where email = :email AND password = :password");
+ //Bind params
+ $query->bindParam(':email', $email, PDO::PARAM_STR, 256);
+ $query->bindParam(':password', $password, PDO::PARAM_STR, 256);
+ //Voer query it
+ $query->execute();
+ //Check hoeveelheid teruggestuurde rijen
+ if($query->rowCount() == 1){
+ //login correct, return uid
+ $result = $query->fetch(PDO::FETCH_COLUMN);
+ return $result;
+ }
+ else{
+ //something went wrong, return -1
+ return -1;
+ }
+ }
+ static function getUsername($uid){
+ $con = Database::connectToDB();
+ $query = $con->prepare("SELECT username FROM users where id = :uid");
+ $query->bindParam(':uid', $uid, PDO::PARAM_STR, 256);
+ $query->execute();
+ if($query->rowCount() == 1){
+ //login correct, return uid
+ $result = $query->fetch(PDO::FETCH_COLUMN);
+ return $result;
+ }
+ else{
+ //something went wrong, return -1
+ return "dbfetcherror";
+ }
+ }
+ static function isSessionTokenInUse($token){
+ //Init db connection
+ $con = Database::connectToDB();
+ //Bereid query voor
+ $query = $con->prepare("SELECT * FROM usersessions where token = :token");
+ //Bind params
+ $query->bindParam(':token', $token, PDO::PARAM_STR, 256);
+ //Voer query it
+ $query->execute();
+ //Check hoeveelheid teruggestuurde rijen
+ if($query->rowCount() == 0){
+ return false;
+ }
+ else{
+ return true;
+ }
+ }
+ static function registerNewSession($uid, $token, $expires){
+ //Init db connection
+ $con = Database::connectToDB();
+ //Bereid query voor
+ $query = $con->prepare("INSERT INTO usersessions (uid, token, expires) VALUES (:uid, :token, :expires)");
+ //Bind params
+ $query->bindParam(':uid', $uid, PDO::PARAM_INT);
+ $query->bindParam(':token', $token, PDO::PARAM_STR, 256);
+ $query->bindParam(':expires', $expires, PDO::PARAM_STR);
+ //Voer query it
+ $query->execute();
+ }
+ static function isSessionValid($token, $uid){
+ //Init db connection
+ $con = Database::connectToDB();
+ //Bereid query voor
+ $query = $con->prepare("SELECT * FROM usersessions where token = :token AND uid = :uid AND expires > NOW()");
+ //Bind params
+ $query->bindParam(':token', $token, PDO::PARAM_STR, 256);
+ $query->bindParam(':uid', $uid, PDO::PARAM_STR, 256);
+ //Voer query it
+ $query->execute();
+ //Check hoeveelheid teruggestuurde rijen
+ if($query->rowCount() == 1){
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+ static function invalidateSession($token){
+ //Init db connection
+ $con = Database::connectToDB();
+ //Bereid query voor
+ $query = $con->prepare("DELETE FROM usersessions WHERE token = :token");
+ //Bind params
+ $query->bindParam(':token', $token, PDO::PARAM_STR, 256);
+ //Voer query it
+ $query->execute();
+ }
+ static function invalidateSessionByUID($uid){
+ //Init db connection
+ $con = Database::connectToDB();
+ //Bereid query voor
+ $query = $con->prepare("DELETE FROM usersessions WHERE uid = :uid");
+ //Bind params
+ $query->bindParam(':token', $uid, PDO::PARAM_INT);
+ //Voer query it
+ $query->execute();
+ }
+ static function deleteExpiredSessions(){
+ $con = Database::connectToDB();
+ //Bereid query voor
+ $query = $con->prepare("DELETE FROM usersessions WHERE expires < NOW()");
+ $query->execute();
+ }
+ static function getSessionExpiryDate($token){
+ $con = Database::connectToDB();
+ $query = $con->prepare("SELECT expires FROM usersessions where token = :token");
+ $query->bindParam(':token', $token, PDO::PARAM_STR, 256);
+ $query->execute();
+ if($query->rowCount() == 1){
+ //login correct, return uid
+ $result = $query->fetch(PDO::FETCH_COLUMN);
+ return $result;
+ }
+ else{
+ //something went wrong, return -1
+ return "2000-01-01 00:00:00";
+ }
+ }
+ static function createThread(){
+
+ }
+}
+?>
\ No newline at end of file
diff --git a/dev_mvc/controller/HUtils.php b/dev_mvc/controller/HUtils.php
new file mode 100644
index 0000000..e44ae28
--- /dev/null
+++ b/dev_mvc/controller/HUtils.php
@@ -0,0 +1,36 @@
+
\ No newline at end of file
diff --git a/dev_mvc/controller/UserSession.php b/dev_mvc/controller/UserSession.php
new file mode 100644
index 0000000..7b76eeb
--- /dev/null
+++ b/dev_mvc/controller/UserSession.php
@@ -0,0 +1,96 @@
+username = $username;
+ $this->uid = $uid;
+ $this->token = $token;
+ $this->setExpiry();
+ //echo($username." ");
+ //echo($loginSessionToken);
+ $_SESSION['usersession'] = $this;
+ setcookie('usersession', $this->token);
+ setcookie('uid', $this->uid);
+ }
+ public function setSessionToken($token){
+ $this->token = $token;
+ }
+ public function getSessionToken(){
+ return $this->token;
+ }
+ public function getFormattedExpiry(){
+ return $this->expires->format('Y-m-d H:i:s');
+ }
+ public function setExpiry(){
+ $this->expires = new DateTime();
+ $this->expires->modify("+ 1 hour");
+ }
+ public static function generateToken(){
+ $chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ $token = "";
+ for ($i=0; $i < 32 ; $i++) {
+ $token .= $chars[rand(0, strlen($chars) - 1)];
+ }
+ return $token;
+ }
+ public static function isSessionValid(){
+ if(isset($_SESSION['usersession'])){
+ if(!Database::isSessionValid($_SESSION['usersession']->token, $_SESSION['usersession']->uid)){
+ include_once("./model/model_attempt_logout.php");
+ return false;
+ }
+ if(!UserSession::isSessionExpired($_SESSION['usersession'])){
+ //check if session also exists in database
+ return true;
+ }
+ }
+ else{
+ if(isset($_COOKIE['usersession'])){
+ $token = $_COOKIE['usersession'];
+ $uid = $_COOKIE['uid'];
+ if(Database::isSessionValid($token,$uid)){
+ $username = Database::getUsername($uid);
+ $session = new UserSession($username, $uid, $token);
+ $session->expires = new DateTime(Database::getSessionExpiryDate($token));
+ }
+ else{
+ return false;
+ }
+ if(!UserSession::isSessionExpired($session)){
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+ public static function getSession()
+ {
+ return $_SESSION['usersession'];
+ }
+ public static function isSessionExpired($session){
+ //session is expired
+ if(new DateTime() > $session->expires){
+ return true;
+ }
+ //session is not expired
+ else{
+ return false;
+ }
+ }
+ public static function isUserSignedIn(){
+ if(UserSession::isSessionValid()){
+ if(!UserSession::isSessionExpired(UserSession::getSession())){
+ if(Database::isSessionValid(UserSession::getSession()->token, UserSession::getSession()->uid)){
+ return true;
+ }
+ }
+ else{
+ return false;
+ }
+ }
+ }
+}
+?>
\ No newline at end of file
diff --git a/dev_mvc/index.php b/dev_mvc/index.php
new file mode 100644
index 0000000..f439505
--- /dev/null
+++ b/dev_mvc/index.php
@@ -0,0 +1,27 @@
+
\ No newline at end of file
diff --git a/dev_mvc/model/model_attempt_login.php b/dev_mvc/model/model_attempt_login.php
new file mode 100644
index 0000000..383faa1
--- /dev/null
+++ b/dev_mvc/model/model_attempt_login.php
@@ -0,0 +1,46 @@
+getSessionToken();
+ echo " ";
+ echo $a->uid;
+ echo " ";
+ echo $a->username;
+ }
+ //clean up expired sessions from ANY users
+ Database::deleteExpiredSessions();
+ Database::registerNewSession($a->uid, $a->token, $a->getFormattedExpiry());
+ //logged in, time to continue with other stuff
+ }
+ else{
+ echo "uid returned -1 from db interface";
+ }
+ }
+ else{
+ echo("login invalid");
+ }
+ }
+}
+else{
+ //we're done, don't even need to log in, session already active
+ //echo($_SESSION['usersession']->uid);
+}
+?>
\ No newline at end of file
diff --git a/dev_mvc/model/model_attempt_logout.php b/dev_mvc/model/model_attempt_logout.php
new file mode 100644
index 0000000..27dac87
--- /dev/null
+++ b/dev_mvc/model/model_attempt_logout.php
@@ -0,0 +1,12 @@
+token);
+ session_destroy();
+}
+
+
+
+
+
+?>
\ No newline at end of file
diff --git a/dev_mvc/model/model_attempt_register.php b/dev_mvc/model/model_attempt_register.php
new file mode 100644
index 0000000..dceb18a
--- /dev/null
+++ b/dev_mvc/model/model_attempt_register.php
@@ -0,0 +1,19 @@
+
\ No newline at end of file
diff --git a/dev_mvc/model/model_destroy.php b/dev_mvc/model/model_destroy.php
new file mode 100644
index 0000000..ecf6762
--- /dev/null
+++ b/dev_mvc/model/model_destroy.php
@@ -0,0 +1,3 @@
+
\ No newline at end of file
diff --git a/dev_mvc/view/css/main.css b/dev_mvc/view/css/main.css
new file mode 100644
index 0000000..2973018
--- /dev/null
+++ b/dev_mvc/view/css/main.css
@@ -0,0 +1,10 @@
+*{
+ font-family: Arial, Helvetica, sans-serif;
+}
+header{
+ background-color: bisque;
+}
+a{
+ margin-right: 10px;
+ text-decoration: none;
+}
\ No newline at end of file
diff --git a/dev_mvc/view/img/logo.png b/dev_mvc/view/img/logo.png
new file mode 100644
index 0000000..5837651
Binary files /dev/null and b/dev_mvc/view/img/logo.png differ
diff --git a/dev_mvc/view/js/checkform.js b/dev_mvc/view/js/checkform.js
new file mode 100644
index 0000000..02ad2eb
--- /dev/null
+++ b/dev_mvc/view/js/checkform.js
@@ -0,0 +1,51 @@
+var arrWarnings = [];
+var arrProblems = [];
+
+function checkInputs(){
+ var boolProblem = false;
+ document.getElementById("jsSignupAlert").innerHTML = "";
+ if(document.getElementById("name").value == ""){
+ arrWarnings[0] = "name field is empty ";
+ boolProblem = true
+ }
+ else{
+ arrWarnings[0] = "";
+ }
+ if(document.getElementById("email").value == ""){
+ arrWarnings[1] = "email field is empty ";
+ boolProblem = true
+ }
+ else{
+ arrWarnings[1] = ""
+ }
+ if(document.getElementById("pass").value == ""){
+ arrWarnings[2] = "pass field is empty ";
+ boolProblem = true
+ }
+ else{
+ arrWarnings[2] = ""
+ }1
+ if(document.getElementById("pass2").value == ""){
+ arrWarnings[3] = "pass verification field is empty ";
+ boolProblem = true
+ }
+ else{
+ arrWarnings[3] = ""
+ }
+ if(document.getElementById("pass").value == document.getElementById("pass2").value){
+ arrWarnings[4] = "";
+ }
+ else{
+ arrWarnings[4] = "pass verification field doesnt match";
+ boolProblem = true
+ }
+ for (var i = 0; i < arrWarnings.length; i++) {
+ document.getElementById("jsSignupAlert").innerHTML += arrWarnings[i];
+ }
+ if(boolProblem){
+ document.getElementById("submitButton").disabled = true;
+ }
+ else{
+ document.getElementById("submitButton").disabled = false;
+ }
+}
\ No newline at end of file
diff --git a/dev_mvc/view/pagecontent/content_404.php b/dev_mvc/view/pagecontent/content_404.php
new file mode 100644
index 0000000..ceb7af1
--- /dev/null
+++ b/dev_mvc/view/pagecontent/content_404.php
@@ -0,0 +1,3 @@
+
+
This page does not exist!
+
\ No newline at end of file
diff --git a/dev_mvc/view/pagecontent/content_attempt_login.php b/dev_mvc/view/pagecontent/content_attempt_login.php
new file mode 100644
index 0000000..0b12f34
--- /dev/null
+++ b/dev_mvc/view/pagecontent/content_attempt_login.php
@@ -0,0 +1,7 @@
+
\ No newline at end of file
diff --git a/dev_mvc/view/pagecontent/content_attempt_logout.php b/dev_mvc/view/pagecontent/content_attempt_logout.php
new file mode 100644
index 0000000..6a047ec
--- /dev/null
+++ b/dev_mvc/view/pagecontent/content_attempt_logout.php
@@ -0,0 +1,3 @@
+
+
You've been succesfully logged out
+
\ No newline at end of file
diff --git a/dev_mvc/view/pagecontent/content_attempt_register.php b/dev_mvc/view/pagecontent/content_attempt_register.php
new file mode 100644
index 0000000..f8b887e
--- /dev/null
+++ b/dev_mvc/view/pagecontent/content_attempt_register.php
@@ -0,0 +1,3 @@
+
+
Successfully registered!
+
\ No newline at end of file
diff --git a/dev_mvc/view/pagecontent/content_createthread.php b/dev_mvc/view/pagecontent/content_createthread.php
new file mode 100644
index 0000000..176c8a7
--- /dev/null
+++ b/dev_mvc/view/pagecontent/content_createthread.php
@@ -0,0 +1,6 @@
+
\ No newline at end of file
diff --git a/dev_mvc/view/pagecontent/content_destroy.php b/dev_mvc/view/pagecontent/content_destroy.php
new file mode 100644
index 0000000..dc3cd8b
--- /dev/null
+++ b/dev_mvc/view/pagecontent/content_destroy.php
@@ -0,0 +1,3 @@
+
+
You're still signed in thanks to our cookies!
+
\ No newline at end of file
diff --git a/dev_mvc/view/pagecontent/content_header.php b/dev_mvc/view/pagecontent/content_header.php
new file mode 100644
index 0000000..184e0d0
--- /dev/null
+++ b/dev_mvc/view/pagecontent/content_header.php
@@ -0,0 +1,7 @@
+
\ No newline at end of file
diff --git a/dev_mvc/view/pagecontent/content_index.php b/dev_mvc/view/pagecontent/content_index.php
new file mode 100644
index 0000000..852160d
--- /dev/null
+++ b/dev_mvc/view/pagecontent/content_index.php
@@ -0,0 +1,3 @@
+
+
Welkom op hForumPHP. Log in of registreer om iets te doen.
+
\ No newline at end of file
diff --git a/dev_mvc/view/pagecontent/content_login.php b/dev_mvc/view/pagecontent/content_login.php
new file mode 100644
index 0000000..dd07475
--- /dev/null
+++ b/dev_mvc/view/pagecontent/content_login.php
@@ -0,0 +1,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/dev_mvc/view/pagecontent/content_page.php b/dev_mvc/view/pagecontent/content_page.php
new file mode 100644
index 0000000..6482fbb
--- /dev/null
+++ b/dev_mvc/view/pagecontent/content_page.php
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+ =HUtils::getSiteTitle();?>
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dev_mvc/view/pagecontent/content_register.php b/dev_mvc/view/pagecontent/content_register.php
new file mode 100644
index 0000000..6f23196
--- /dev/null
+++ b/dev_mvc/view/pagecontent/content_register.php
@@ -0,0 +1,11 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/dev_mvc/view/pagecontent/header/content_header_signedin.php b/dev_mvc/view/pagecontent/header/content_header_signedin.php
new file mode 100644
index 0000000..0ba7d68
--- /dev/null
+++ b/dev_mvc/view/pagecontent/header/content_header_signedin.php
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/dev_mvc/view/pagecontent/header/content_header_signedout.php b/dev_mvc/view/pagecontent/header/content_header_signedout.php
new file mode 100644
index 0000000..02bda45
--- /dev/null
+++ b/dev_mvc/view/pagecontent/header/content_header_signedout.php
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/dev_mvc/view/pagecontent/login/content_login_succesful.php b/dev_mvc/view/pagecontent/login/content_login_succesful.php
new file mode 100644
index 0000000..f86a96c
--- /dev/null
+++ b/dev_mvc/view/pagecontent/login/content_login_succesful.php
@@ -0,0 +1,3 @@
+
+
Successfully logged in!
+
\ No newline at end of file
diff --git a/dev_mvc/view/pagecontent/login/content_login_unsuccesful.php b/dev_mvc/view/pagecontent/login/content_login_unsuccesful.php
new file mode 100644
index 0000000..a9a1ae8
--- /dev/null
+++ b/dev_mvc/view/pagecontent/login/content_login_unsuccesful.php
@@ -0,0 +1,3 @@
+
+
UNEXPECTED LOGIN ERROR. OUR CODEMONKEYS DID SOMETHING VERY WRONG :(
+
\ No newline at end of file
diff --git a/globalvars.php b/globalvars.php
new file mode 100644
index 0000000..95f8a62
--- /dev/null
+++ b/globalvars.php
@@ -0,0 +1,4 @@
+
\ No newline at end of file