diff options
| author | root | 2014-09-25 10:26:56 +0200 |
|---|---|---|
| committer | root | 2014-09-25 10:26:56 +0200 |
| commit | 2036626b560f22efd59673187a2de3b1319fcf8a (patch) | |
| tree | 5180be078e3758b6fe3c37834cf6074c148394d1 /bootstrap/class/user.php | |
| parent | 7ea240aef9b75758d05cb5212ef7c99b47b4180b (diff) | |
| download | jungegemeinde-2036626b560f22efd59673187a2de3b1319fcf8a.tar.gz | |
version 4.0
Diffstat (limited to 'bootstrap/class/user.php')
| -rw-r--r-- | bootstrap/class/user.php | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/bootstrap/class/user.php b/bootstrap/class/user.php index edbcaa6..969d734 100644 --- a/bootstrap/class/user.php +++ b/bootstrap/class/user.php @@ -9,8 +9,6 @@ class jg { private $query = false; public function __construct($name = null){ - if ( is_null($name) ) - return; $this->username = $name; @@ -24,10 +22,10 @@ class jg { # get's everything from the database private function _setQuery(){ - global $vfsdb; + global $db; - $sql = $vfsdv->prepare("SELECT * FROM " . DBPREFIX . "user WHERE name=%s;", $this->username); - $db_db = $vfsdb->doQuery($sql); + $sql = $db->prepare("SELECT * FROM " . DBPREFIX . "user WHERE name=%s;", $this->username); + $db_db = $db->doQuery($sql); if ( is_bool($db_db) ) $this->query = false; else @@ -54,7 +52,10 @@ class jg { } public function getEmail(){ - return $this->query['email']; + if ( $this->query['email'] == "null" ) + return ""; + else + return $this->query['email']; } public function getRegister(){ @@ -88,9 +89,11 @@ class jg { # set login to true $this->login = true; + $this->username=$user; + # start a session if needed if ( session_status() != PHP_SESSION_ACTIVE ) { - session_name(VFS_SESSION); + session_name(SESSION); session_start(); } @@ -99,6 +102,7 @@ class jg { # assign userid to the session variable $_SESSION["userid"] = $this->getUserId(); + $_SESSION["username"] = $this->username; return true; } @@ -120,21 +124,15 @@ class jg { } public function register($name, $password, $email){ - global $vfsdb; + global $db; - $password = $password . PEPPER; - $hash = password_hash($password, PASSWORD_DEFAULT); + $hash = password_hash($password . PEPPER, PASSWORD_DEFAULT); - $sql = $vfsdb->prepare(" - INSERT INTO " . DBPREFIX . "user VALUES ( - NULL, - name = %s, - password = %s, - email = %s, - register = %d - );", $name, $hash, $email, time() ); + $sql = $db->prepare(" + INSERT INTO " . DBPREFIX . "user (id, name, password, email, register) VALUES (NULL, %s, %s, %s, %d);", $name, $hash, $email, time() + ); - if ( ! $vfsdb->doQuery($sql) ) + if ( ! $db->doQuery($sql) ) return false; # the user is successfull registered, thus already logged in @@ -144,7 +142,7 @@ class jg { $this->_setPepper(); $this->_setQuery(); - $this->login($password); + $this->login($name, $password); return true; } |
