$Debug->set_flag('start user handling'); session_start(); //----------------------------------------------------------------------------------- ///////////////////////////////////////////////////////////////////////////////////// //-- Load user information ---------------------------------------------------------- // User info is broken up into many sections // Heavy - Things that the site never has to look at if the user isn't logged in (as opposed to things like the class, donor status, etc) // Light - Things that appear in format_user // Stats - Uploaded and downloaded - can be updated by a script if you want super speed // Session data - Information about the specific session // Enabled - if the user's enabled or not // Permissions if (isset($_COOKIE['session'])) { $LoginCookie=$Enc->decrypt($_COOKIE['session']); } if(isset($LoginCookie)) { list($SessionID, $LoggedUser['ID'])=explode("|~|",$Enc->decrypt($LoginCookie)); $LoggedUser['ID'] = (int)$LoggedUser['ID']; $UserID=$LoggedUser['ID']; //TODO: UserID should not be LoggedUser if (!$LoggedUser['ID'] || !$SessionID) { logout(); } $UserSessions = $Cache->get_value('users_sessions_'.$UserID); if(!is_array($UserSessions)) { $DB->query("SELECT SessionID, Browser,
//$Mobile = UserAgent::mobile($_SERVER['HTTP_USER_AGENT']); $Mobile = in_array($_SERVER['HTTP_HOST'], array('m.' . NONSSL_SITE_URL, 'm.' . NONSSL_SITE_URL)); $Debug->set_flag('start user handling'); // Get classes // TODO: Remove these globals, replace by calls into Users list($Classes, $ClassLevels) = Users::get_classes(); //-- Load user information // User info is broken up into many sections // Heavy - Things that the site never has to look at if the user isn't logged in (as opposed to things like the class, donor status, etc) // Light - Things that appear in format_user // Stats - Uploaded and downloaded - can be updated by a script if you want super speed // Session data - Information about the specific session // Enabled - if the user's enabled or not // Permissions if (isset($_COOKIE['session'])) { $LoginCookie = $Enc->decrypt($_COOKIE['session']); } if (isset($LoginCookie)) { list($SessionID, $LoggedUser['ID']) = explode('|~|', $Enc->decrypt($LoginCookie)); $LoggedUser['ID'] = (int) $LoggedUser['ID']; $UserID = $LoggedUser['ID']; //TODO: UserID should not be LoggedUser if (!$LoggedUser['ID'] || !$SessionID) { logout(); } $UserSessions = $Cache->get_value("users_sessions_{$UserID}"); if (!is_array($UserSessions)) { $DB->query("\n\t\t\tSELECT\n\t\t\t\tSessionID,\n\t\t\t\tBrowser,\n\t\t\t\tOperatingSystem,\n\t\t\t\tIP,\n\t\t\t\tLastUpdate\n\t\t\tFROM users_sessions\n\t\t\tWHERE UserID = '{$UserID}'\n\t\t\t\tAND Active = 1\n\t\t\tORDER BY LastUpdate DESC"); $UserSessions = $DB->to_array('SessionID', MYSQLI_ASSOC); $Cache->cache_value("users_sessions_{$UserID}", $UserSessions, 0); }
require 'config.php'; //The config contains all site wide configuration information as well as memcached rules require SERVER_ROOT . '/classes/debug.class.php'; require SERVER_ROOT . '/classes/cache.class.php'; //Require the caching class require SERVER_ROOT . '/classes/encrypt.class.php'; //Require the caching class $Debug = new DEBUG(); $Cache = new CACHE($MemcachedServers); //Load the caching class $Enc = new CRYPT(); //Load the encryption class $SSL = $_SERVER['SERVER_PORT'] === '443'; if (isset($_COOKIE['session'])) { $LoginCookie = $Enc->decrypt($_COOKIE['session']); } if (isset($LoginCookie)) { list($SessionID, $UserID) = explode("|~|", $Enc->decrypt($LoginCookie)); if (!$UserID || !$SessionID) { die('Not logged in!'); } if (!($Enabled = $Cache->get_value("enabled_{$UserID}"))) { require SERVER_ROOT . '/classes/mysql.class.php'; //Require the database wrapper $DB = new DB_MYSQL(); //Load the database wrapper $DB->query("\n\t\t\tSELECT Enabled\n\t\t\tFROM users_main\n\t\t\tWHERE ID = '{$UserID}'"); list($Enabled) = $DB->next_record(); $Cache->cache_value("enabled_{$UserID}", $Enabled, 0); }