diff options
author | Malf Furious <m@lfurio.us> | 2016-02-07 14:01:22 -0500 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2016-02-07 14:01:22 -0500 |
commit | 72e37180b69db2c067b926b54c64e1989bef0be4 (patch) | |
tree | d5e76f4894d3822f1923464c641c63fa283bdd2b /app/class/framework.class.php | |
parent | 43ca317ea7d49396eb2958a38aed8b737ef4186b (diff) | |
parent | c5564a0a2ae183c533a38905eccdbf383030cd4c (diff) | |
download | scrott-72e37180b69db2c067b926b54c64e1989bef0be4.tar.gz scrott-72e37180b69db2c067b926b54c64e1989bef0be4.zip |
Merge branch 'auth' into dev
Diffstat (limited to '')
-rw-r--r-- | app/class/framework.class.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/app/class/framework.class.php b/app/class/framework.class.php index d1293de..74c4b14 100644 --- a/app/class/framework.class.php +++ b/app/class/framework.class.php @@ -4,7 +4,11 @@ is_file("scrott.conf.php") && require_once "scrott.conf.php"; +/* Init PHP session */ +session_start(); + require_once "class/mysql.class.php"; +require_once "class/user.class.php"; /* * Global functions / operations and access to contextual or session-based information @@ -48,6 +52,43 @@ abstract class Framework } /* + * Get a user object for the currently logged in user. Returns false if session is logged out. + */ + function getCurrentUser() + { + if (isset($_SESSION['userguid'])) + return new User($_SESSION['userguid']); + + return false; + } + + /* + * Get the IP address the client held when the current session began + */ + function getOriginIP() + { + return $_SESSION['userip']; + } + + /* + * Set the current logged in user + */ + function setCurrentUser($user = null) + { + if ($user != null && isset($user->guid)) + { + $_SESSION['userguid'] = $user->guid; + $_SESSION['userip'] = $_SERVER['REMOTE_ADDR']; + } + + else + { + unset($_SESSION['userguid']); + unset($_SESSION['userip']); + } + } + + /* * Get or create the app's database connection object (this is a singleton object and dependent on system-level config) */ static function getDbConnection() |