public function __construct() { include 'permission_levels.php'; $enabled_features = explode(',', strtoupper(ENABLED_FEATURES)); foreach ($PERM_LEVELS as $i => $detail) { list($define_symbol, $desc, $feature_code) = $detail; define('PERM_' . $define_symbol, $i); if (empty($feature_code) || in_array($feature_code, $enabled_features)) { $this->_permission_levels[$i] = $desc; } } if (!empty($_REQUEST['logout'])) { $this->_logOut(); } else { if (empty($_SESSION['user']) && !empty($_POST['username'])) { // process the login form if (array_get($_SESSION, 'login_key', NULL) != $_POST['login_key']) { $this->_error = 'Login Key Incorrect. Please try again.'; return; } $user_details = $this->_findUser($_POST['username'], $_POST['password']); if (is_null($user_details)) { $this->_error = 'Incorrect username or password'; } else { // Log the user in // Recreate session when logging in session_regenerate_id(); $_SESSION = array(); $_SESSION['user'] = $user_details; $_SESSION['login_time'] = time(); $_SESSION['last_activity_time'] = time(); include_once 'include/size_detector.class.php'; SizeDetector::processRequest(); } } } if (!empty($_SESSION['user'])) { if (defined('SESSION_TIMEOUT_MINS') && constant('SESSION_TIMEOUT_MINS')) { if ((time() - $_SESSION['last_activity_time']) / 60 > SESSION_TIMEOUT_MINS) { // They have been idle too long $this->_logOut(); } } if (defined('SESSION_MAXLENGTH_MINS') && constant('SESSION_MAXLENGTH_MINS')) { if ((time() - $_SESSION['login_time']) / 60 > SESSION_MAXLENGTH_MINS) { // They have been logged in too long $this->_logOut(); } } $_SESSION['last_activity_time'] = time(); $res = $GLOBALS['db']->query('SET @current_user_id = ' . (int) $_SESSION['user']['id']); if (PEAR::isError($res)) { trigger_error('Failed to set user id in database', E_USER_ERROR); } } }
<?php @session_start(); include 'size_detector.class.php'; SizeDetector::processRequest(); ?> <html> <head> <style>html,body { height: 100% }</style> </head> <body> <h1>Size Detector Test</h1> <pre style="border: 2px solid"> The server thinks the width is <?php echo SizeDetector::getWidth(); ?> and height is <?php echo SizeDetector::getHeight(); ?> </pre> <form method="post" style="border: 2px solid"> <?php SizeDetector::printFormFields(); ?> This is a form <input type="submit" /> </form> </body> </html>