From 89dcca30211404d65c46c5b8d280edd8bd8e7547 Mon Sep 17 00:00:00 2001 From: Andreas Schaafsma Date: Fri, 17 May 2019 13:59:34 +0200 Subject: [PATCH] Database dingen gerenamed en opgeruimt --- dev_mvc/controller/Database.php | 68 ++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 5 deletions(-) diff --git a/dev_mvc/controller/Database.php b/dev_mvc/controller/Database.php index 1351f9a..273b52c 100644 --- a/dev_mvc/controller/Database.php +++ b/dev_mvc/controller/Database.php @@ -1,5 +1,6 @@ prepare("SELECT * FROM email_activation_keys WHERE activationkey = :activationKey"); + $query->bindParam(':activationKey', $activationKey, PDO::PARAM_STR, 256); + $query->execute(); + if($query->rowCount() == 0){ + //bestaat nog niet + return false; + } + else{ + //bestaat al + return true; + } + } + //Activeer gebruiker en verwijder activation key uit de activation key tabel + static function activateUser($activationKey){ + $con = Database::connectToDb(); + $query = $con->prepare("SELECT users_id FROM email_activation_keys WHERE activationKey = :activationKey"); + $query->bindParam('activationKey', $activationKey); + $query->execute(); + $result = -1; + if($query->rowCount() == 1){ + //login correct, return uid + $result = $query->fetch(PDO::FETCH_COLUMN); + } + else{ + //activation key komt niet voor in de db, return -1 + return -1; + } + $id = $result; + $query = null; + $query = $con->prepare("UPDATE users SET active = 1 WHERE id = :id and active = 0"); + $query->bindParam(':id',$id,PDO::PARAM_INT); + $query->execute(); + } + + /*** + * _____ ______ _____ _____ _____ ____ _ _ _______ ____ _ ________ _ _ _____ + * / ____| ____|/ ____/ ____|_ _/ __ \| \ | | |__ __/ __ \| |/ / ____| \ | |/ ____| + * | (___ | |__ | (___| (___ | || | | | \| | | | | | | | ' /| |__ | \| | (___ + * \___ \| __| \___ \\___ \ | || | | | . ` | | | | | | | < | __| | . ` |\___ \ + * ____) | |____ ____) |___) |_| || |__| | |\ | | | | |__| | . \| |____| |\ |____) | + * |_____/|______|_____/_____/|_____\____/|_| \_| |_| \____/|_|\_\______|_| \_|_____/ + * + ***/ + + static function isSessionTokenInUse($token){ //Init db connection $con = Database::connectToDB(); @@ -207,12 +268,9 @@ Class Database{ return $result; } else{ - //something went wrong, return -1 + //something went wrong, return an invalid date. return "2000-01-01 00:00:00"; } } - static function createThread(){ - - } } ?> \ No newline at end of file