102 |
//------------------------------------------------------------------------------ |
//------------------------------------------------------------------------------ |
103 |
//- Session setup: |
//- Session setup: |
104 |
|
|
105 |
if ($common['client']['session_enabled']) { |
if(!isset($common['client']['session_enabled'])) { |
106 |
|
|
107 |
// Neither proxies, nor the clients are allowed to cache session data: |
// Neither proxies, nor the clients are allowed to cache session data: |
108 |
session_cache_limiter('nocache'); |
session_cache_limiter('nocache'); |
125 |
'birthtime' => time(), |
'birthtime' => time(), |
126 |
'firstrequest' => 1, // Mark the very first page request. |
'firstrequest' => 1, // Mark the very first page request. |
127 |
|
|
128 |
// Empty user data sub array: |
// User data and authorisation: |
129 |
'userdata' => array( |
'user_auth' => array( |
130 |
'name' => '', |
'name' => '', |
131 |
'password' => '', |
'password' => '', |
132 |
'authorised' => false, |
'authorised' => false |
133 |
|
), |
134 |
|
|
135 |
|
// User preferences and preferred settings: |
136 |
|
'user_prefs' => array( |
137 |
|
'benchlist' => null, |
138 |
|
'debug' => null, |
139 |
|
'language_id' => null, |
140 |
|
'outputtype' => null |
141 |
), |
), |
142 |
|
|
143 |
// Content related additional data: |
// Content related additional data: |
176 |
} |
} |
177 |
|
|
178 |
//------------------------------------------------------------------------------ |
//------------------------------------------------------------------------------ |
|
//- 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']; |
|
|
|
|
|
//------------------------------------------------------------------------------ |
|
179 |
//- Functions: |
//- Functions: |
180 |
|
|
181 |
function common_checkauthorisation() { |
function common_authorise($username, $password) { |
182 |
|
|
183 |
global $common_sessiondata; |
global $common_sessiondata; |
184 |
|
|
|
$username = $common_sessiondata['userdata']['name']; |
|
|
$password = $common_sessiondata['userdata']['password']; |
|
|
|
|
185 |
if((strlen($username) < 2) || (strlen($password) < 2)) return false; |
if((strlen($username) < 2) || (strlen($password) < 2)) return false; |
186 |
|
|
187 |
$sql = "SELECT id, rights, logincount, lastlogin FROM users WHERE name='$username' AND password='$password';"; |
$sql = "SELECT id, rights, logincount, lastlogin FROM users WHERE name='$username' AND password='$password';"; |
194 |
|
|
195 |
// Congratulations - authorisation suxxessful! |
// Congratulations - authorisation suxxessful! |
196 |
|
|
197 |
|
$common_sessiondata['user_auth']['authorised'] = true; |
198 |
|
|
199 |
|
$common_sessiondata['user_auth']['name'] = $username; |
200 |
|
$common_sessiondata['user_auth']['password'] = $password; |
201 |
|
|
202 |
$logintime = time(); |
$logintime = time(); |
203 |
|
|
204 |
$userid = $row[0]; |
$userid = $row[0]; |
206 |
$logincount = $row[2] + 1; |
$logincount = $row[2] + 1; |
207 |
$lastlogin = $row[3]; |
$lastlogin = $row[3]; |
208 |
|
|
209 |
$common_sessiondata['userdata']['authorised'] = true; |
$common_sessiondata['user_auth']['id'] = $userid; |
210 |
|
$common_sessiondata['user_auth']['lastlogin'] = $lastlogin; |
211 |
$common_sessiondata['userdata']['id'] = $userid; |
$common_sessiondata['user_auth']['rights'] = $rights; |
|
$common_sessiondata['userdata']['lastlogin'] = $lastlogin; |
|
|
$common_sessiondata['userdata']['rights'] = $rights; |
|
212 |
|
|
213 |
// Break if the user already has authorised in this session: |
// Break if the user already has authorised in this session: |
214 |
if(isset($common_sessiondata['userdata']['logintime'])) return false; |
if(isset($common_sessiondata['user_auth']['logintime'])) return false; |
215 |
|
|
216 |
$common_sessiondata['userdata']['logincount'] = $logincount; |
$common_sessiondata['user_auth']['logincount'] = $logincount; |
217 |
$common_sessiondata['userdata']['logintime'] = $logintime; |
$common_sessiondata['user_auth']['logintime'] = $logintime; |
|
|
|
|
// print_r($common_sessiondata['userdata']); |
|
218 |
|
|
219 |
$sql = "UPDATE users SET logincount='$logincount', lastlogin=FROM_UNIXTIME('$logintime') WHERE id='$userid';"; |
$sql = "UPDATE users SET logincount='$logincount', lastlogin=FROM_UNIXTIME('$logintime') WHERE id='$userid';"; |
220 |
|
|
328 |
|
|
329 |
//---------------------------------------------------------- |
//---------------------------------------------------------- |
330 |
//- Utility functions: |
//- Utility functions: |
331 |
|
|
332 |
function common_get_baseurl() { |
function common_get_baseurl() { |
333 |
$baseurl = "http://" . $_SERVER['SERVER_NAME'] . "" . $_SERVER['SCRIPT_NAME'] . "/"; |
|
334 |
return $baseurl; |
global $common; |
335 |
|
|
336 |
|
return $common['site']['url']; |
337 |
|
|
338 |
} |
} |
339 |
|
|
340 |
//------------------------------------------------------------------------------ |
//------------------------------------------------------------------------------ |