source: branches/old/administrace/user.php

Last change on this file was 404, checked in by george, 16 years ago
  • Upraveno: Názvy databází MaNGOSu přesunuty do konfiguračního souboru a odkazované skripty upraveny k použití těchto proměnných.
File size: 1.2 KB
Line 
1<?php
2
3class User
4{
5 var $SessionTimeout = 30; // minutes
6
7 function Check()
8 {
9 if(!array_key_exists('Time', $_SESSION)) $_SESSION['Time'] = time();
10 if(!array_key_exists('UserId', $_SESSION)) $_SESSION['UserId'] = 0;
11
12 // Session time expiration
13 if($_SESSION['Time'] < (time() - 60 * $this->SessionTimeout))
14 {
15 $_SESSION['UserId'] = 0;
16 $_SESSION['UserName'] = '';
17 }
18 $_SESSION['Time'] = time();
19
20 return($_SESSION['UserId'] != 0);
21 }
22
23 function Login($Username, $Password)
24 {
25 global $Config;
26 global $Database;
27 $Database->select_db($Config['Mangos']['DatabaseRealmd']);
28 $DbResult = $Database->select('account', 'Id,username', '(gmlevel > 0) AND (username = "'.$Username.'") AND (sha_pass_hash = SHA1(CONCAT(UCASE("'.$Username.'"),":",UCASE("'.$Password.'"))))');
29 if($DbResult->num_rows > 0)
30 {
31 $User = $DbResult->fetch_array();
32 $_SESSION['UserId'] = $User['Id'];
33 $_SESSION['UserName'] = $User['username'];
34 echo('Byl jste přihlášen.<br>');
35 } else {
36 echo('Přístup nepovolen!<br>');
37 }
38 }
39
40 function Logout()
41 {
42 $_SESSION['UserId'] = 0;
43 echo('Byl jste odhlášen.<br>');
44 }
45}
46
47?>
Note: See TracBrowser for help on using the repository browser.