diff --git a/dev_mvc/controller/MVCController.php b/dev_mvc/controller/MVCController.php index 9ba4db2..73ef8ea 100644 --- a/dev_mvc/controller/MVCController.php +++ b/dev_mvc/controller/MVCController.php @@ -12,28 +12,28 @@ class MVCController{ self::$mvcController = $this; //prepare current view and view model if(isset($_GET['p']) && $_GET['p'] != ''){ - $this->view = "./view/webcontent/content_".$_GET['p'].".php"; - $this->viewmodel = "./viewmodel/viewmodel_".$_GET['p'].".php"; + $this->view = ROOT_DIR."./view/webcontent/content_".$_GET['p'].".php"; + $this->viewmodel = ROOT_DIR."./viewmodel/viewmodel_".$_GET['p'].".php"; } else{ - $this->view = "./view/webcontent/content_home.php"; - $this->viewmodel = "./viewmodel/viewmodel_home.php"; + $this->view = ROOT_DIR."./view/webcontent/content_home.php"; + $this->viewmodel = ROOT_DIR."./viewmodel/viewmodel_home.php"; } //prepare current action model if(isset($_POST['action'])){ - $this->model = "./model/actions/model_".$_POST['action'].".php"; + $this->model = ROOT_DIR."./model/actions/model_".$_POST['action'].".php"; } else if(isset($_GET['action'])){ - $this->model = "./model/actions/model_".$_GET['action'].".php"; + $this->model = ROOT_DIR."./model/actions/model_".$_GET['action'].".php"; } else{ - $this->model = "./model/actions/model_empty.php"; + $this->model = ROOT_DIR."./model/actions/model_empty.php"; } if(isset($_POST['testaction'])){ - $this->testaction = "./model/testactions/TA_".$_POST['testaction'].".php"; + $this->testaction = ROOT_DIR."./model/testactions/TA_".$_POST['testaction'].".php"; } @@ -44,8 +44,8 @@ class MVCController{ } function overrideView($view_target):void { - $this->view = "./view/webcontent/content_".$view_target.".php"; - $this->viewmodel = "./viewmodel/viewmodel_".$view_target.".php"; + $this->view = ROOT_DIR."./view/webcontent/content_".$view_target.".php"; + $this->viewmodel = ROOT_DIR."./viewmodel/viewmodel_".$view_target.".php"; $this->viewOverridden = true; } function executeAction():void @@ -102,7 +102,7 @@ class MVCController{ include_once($this->view); } else{ - include_once("./view/webcontent/content_404.php"); + include_once(ROOT_DIR."./view/webcontent/content_404.php"); echo("view: ".$this->view." not found."); } } diff --git a/dev_mvc/controller/UserSession.php b/dev_mvc/controller/UserSession.php index 6d3de70..83e4633 100644 --- a/dev_mvc/controller/UserSession.php +++ b/dev_mvc/controller/UserSession.php @@ -1,5 +1,5 @@ prepare("SELECT * FROM thread WHERE ID = :id"); $query->bindParam(":id", $id); $query->execute(); - return $query->fetch(PDO::FETCH_BOTH); + $result = $query->fetch(PDO::FETCH_BOTH); + return new Thread($result['ID'], $result['users_ID'], $result['board_ID'], $result['title'], $result['text'], $result['date_created']); } static function getThreadsByBoard($boardID){ $con = self::connectToDB(); diff --git a/dev_mvc/controller/db/DBUser.php b/dev_mvc/controller/db/DBUser.php index 45ba636..e69cf4b 100644 --- a/dev_mvc/controller/db/DBUser.php +++ b/dev_mvc/controller/db/DBUser.php @@ -1,5 +1,5 @@ prepare("SELECT * FROM users WHERE email = :email"); + $query->bindParam(":email", $email); + $query->execute(); + $result = $query->fetch(PDO::FETCH_BOTH); + $user = new User($result['ID'], $result['username'], $result['email'], $result['password'], $result['reg_date'], $result['login_date'], $result['reg_ip'], $result['permissions'], $result['active']); + if($query->rowCount() == 1){ + //Email adres is niet in gebruik, return false + return $user; + } + else{ + //Email is al in gebruik of komt meer dan een keer voor. Beide gevallen zijn een probleem dus return true. + trigger_error("Multiple users for email $email returned by DB, value should be unique", E_USER_ERROR); + } + + } //Controleert of het email adres al in de database voorkomt. Returnt true indien wel. diff --git a/dev_mvc/index.php b/dev_mvc/index.php index 6b19552..685e204 100644 --- a/dev_mvc/index.php +++ b/dev_mvc/index.php @@ -1,4 +1,5 @@ executeModel(); if(!isset($_POST['testaction'])){ - include_once("./view/content_pagetemplate.php"); + include_once(ROOT_DIR."./view/content_pagetemplate.php"); } //require_once('aaaadea'); //http_response_code(200); diff --git a/dev_mvc/model/actions/model_create_reply.php b/dev_mvc/model/actions/model_create_reply.php index 4a44c17..0a3cd08 100644 --- a/dev_mvc/model/actions/model_create_reply.php +++ b/dev_mvc/model/actions/model_create_reply.php @@ -1,8 +1,8 @@ uid; diff --git a/dev_mvc/model/actions/model_create_thread.php b/dev_mvc/model/actions/model_create_thread.php index 36c2e23..24a04bc 100644 --- a/dev_mvc/model/actions/model_create_thread.php +++ b/dev_mvc/model/actions/model_create_thread.php @@ -1,8 +1,8 @@ uid; diff --git a/dev_mvc/model/actions/model_do_register.php b/dev_mvc/model/actions/model_do_register.php index 2883168..e086577 100644 --- a/dev_mvc/model/actions/model_do_register.php +++ b/dev_mvc/model/actions/model_do_register.php @@ -1,8 +1,8 @@ getId(),$verificationKey); $message = 'Please follow the link to verify your account: http://localhost/webforum_redux/hforumphp/dev_mvc/index.php?p=verify&key='.$verificationKey; $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . diff --git a/dev_mvc/model/actions/model_login.php b/dev_mvc/model/actions/model_login.php index 36fd985..d9b0023 100644 --- a/dev_mvc/model/actions/model_login.php +++ b/dev_mvc/model/actions/model_login.php @@ -1,12 +1,13 @@ owner = $owner; } + public function getId():int { return $this->id; } diff --git a/dev_mvc/model/forum/User.php b/dev_mvc/model/forum/User.php index 78e7f25..cb4f79b 100644 --- a/dev_mvc/model/forum/User.php +++ b/dev_mvc/model/forum/User.php @@ -10,7 +10,7 @@ class User { public $reg_ip; public $permissions; public $active; - function User($id, $username, $email, $password, $reg_date, $login_date, $reg_ip, $permissions, $active){ + function __construct($id, $username, $email, $password, $reg_date, $login_date, $reg_ip, $permissions, $active){ $this->id = $id; $this->username = $username; $this->email = $email; @@ -24,28 +24,28 @@ class User { /** * @return mixed */ - public function getId() { + public function getId():int { return $this->id; } /** * @return mixed */ - public function getUsername() { + public function getUsername():string { return $this->username; } /** * @return mixed */ - public function getEmail() { + public function getEmail():string { return $this->email; } /** * @return mixed */ - public function getPassword() { + public function getPassword():string { return $this->password; } diff --git a/dev_mvc/model/testactions/TA_GetUsers.php b/dev_mvc/model/testactions/TA_GetUsers.php deleted file mode 100644 index e69de29..0000000 diff --git a/dev_mvc/model/testactions/TA_TestDBUser.php b/dev_mvc/model/testactions/TA_TestDBUser.php index c43c209..a204ca2 100644 --- a/dev_mvc/model/testactions/TA_TestDBUser.php +++ b/dev_mvc/model/testactions/TA_TestDBUser.php @@ -1,4 +1,6 @@ getUsername()); + self::logMessage($user->getEmail()); + self::logMessage($user->getPassword()); } } diff --git a/dev_mvc/model/testactions/TestAction.php b/dev_mvc/model/testactions/TestAction.php index 33d2dbb..2f43a80 100644 --- a/dev_mvc/model/testactions/TestAction.php +++ b/dev_mvc/model/testactions/TestAction.php @@ -1,6 +1,6 @@ execute(); @@ -32,7 +32,7 @@ class TestAction{ echo("[".self::$log[$i]['status']."] ".self::$log[$i]['message']."\n"); if(self::$log[$i]['status'] == 'FAILURE'){ echo('