--- nfo/site/htdocs/inc/common/common.php.inc 2004/09/01 08:58:40 1.7 +++ nfo/site/htdocs/inc/common/common.php.inc 2004/09/04 03:06:10 1.10 @@ -4,7 +4,7 @@ --- Setup and common functions include file. -------------------------------------------------------------------------------- --- rabit, 04:31 24.08.2004 ---- $Id: common.php.inc,v 1.7 2004/09/01 08:58:40 rabit Exp $ +--- $Id: common.php.inc,v 1.10 2004/09/04 03:06:10 rabit Exp $ ------------------------------------------------------------------------------*/ //------------------------------------------------------------------------------ @@ -102,11 +102,15 @@ //------------------------------------------------------------------------------ //- Session setup: -// Neither proxies, nor the clients are allowed to cache session data: -session_cache_limiter('nocache'); +if(!isset($common['client']['session_enabled'])) { -// This is neccessary to make the $_SESSION global available: -session_start(); + // Neither proxies, nor the clients are allowed to cache session data: + session_cache_limiter('nocache'); + + // This is neccessary to make the $_SESSION global available: + session_start(); + +} common_benchmark_addstep('common: session init'); @@ -121,11 +125,19 @@ 'birthtime' => time(), 'firstrequest' => 1, // Mark the very first page request. - // Empty user data sub array: - 'userdata' => array( + // User data and authorisation: + 'user_auth' => array( 'name' => '', 'password' => '', - 'authorised' => false, + 'authorised' => false + ), + + // User preferences and preferred settings: + 'user_prefs' => array( + 'benchlist' => null, + 'debug' => null, + 'language_id' => null, + 'outputtype' => null ), // Content related additional data: @@ -164,22 +176,12 @@ } //------------------------------------------------------------------------------ -//- URL parameter flags and variables: - -if(isset($_GET['devstate'])) $common_sessiondata['userdata']['devstate'] = $_GET['devstate']; - -if(isset($common_sessiondata['userdata']['devstate'])) $common['hostsetup']['devstate'] = $common_sessiondata['userdata']['devstate']; - -//------------------------------------------------------------------------------ //- Functions: -function common_checkauthorisation() { +function common_authorise($username, $password) { global $common_sessiondata; - $username = $common_sessiondata['userdata']['name']; - $password = $common_sessiondata['userdata']['password']; - if((strlen($username) < 2) || (strlen($password) < 2)) return false; $sql = "SELECT id, rights, logincount, lastlogin FROM users WHERE name='$username' AND password='$password';"; @@ -192,6 +194,11 @@ // Congratulations - authorisation suxxessful! + $common_sessiondata['user_auth']['authorised'] = true; + + $common_sessiondata['user_auth']['name'] = $username; + $common_sessiondata['user_auth']['password'] = $password; + $logintime = time(); $userid = $row[0]; @@ -199,19 +206,15 @@ $logincount = $row[2] + 1; $lastlogin = $row[3]; - $common_sessiondata['userdata']['authorised'] = true; - - $common_sessiondata['userdata']['id'] = $userid; - $common_sessiondata['userdata']['lastlogin'] = $lastlogin; - $common_sessiondata['userdata']['rights'] = $rights; + $common_sessiondata['user_auth']['id'] = $userid; + $common_sessiondata['user_auth']['lastlogin'] = $lastlogin; + $common_sessiondata['user_auth']['rights'] = $rights; // Break if the user already has authorised in this session: - if(isset($common_sessiondata['userdata']['logintime'])) return false; + if(isset($common_sessiondata['user_auth']['logintime'])) return false; - $common_sessiondata['userdata']['logincount'] = $logincount; - $common_sessiondata['userdata']['logintime'] = $logintime; - -// print_r($common_sessiondata['userdata']); + $common_sessiondata['user_auth']['logincount'] = $logincount; + $common_sessiondata['user_auth']['logintime'] = $logintime; $sql = "UPDATE users SET logincount='$logincount', lastlogin=FROM_UNIXTIME('$logintime') WHERE id='$userid';"; @@ -323,7 +326,16 @@ //---------------------------------------------------------- //- File functions: +//---------------------------------------------------------- +//- Utility functions: + +function common_get_baseurl() { + +global $common; + return $common['site']['url']; + +} //------------------------------------------------------------------------------