Commit | Line | Data |
---|---|---|
5704f294 MK |
1 | <?php |
2 | /* | |
3 | * SkladovySystem - Storage management system compatible with LMS | |
4 | * Copyright (C) 2011 Thomas Mudrunka | |
5 | * | |
6 | * This program is free software: you can redistribute it and/or modify | |
7 | * it under the terms of the GNU Affero General Public License as | |
8 | * published by the Free Software Foundation, either version 3 of the | |
9 | * License, or (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU Affero General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU Affero General Public License | |
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | */ | |
19 | ||
20 | /** | |
21 | * Trida zajistuje autorizaci vuci LMS | |
22 | * | |
23 | * @package Sklad_Auth | |
24 | * @author Tomas Mudrunka | |
25 | * @author Martin Krusinsky | |
26 | */ | |
27 | class Sklad_Auth extends Sklad_Auth_common { | |
28 | function check_auth($user, $pass) { | |
29 | ||
30 | $LMS_CONFIG = (array)parse_ini_file('/etc/lms/lms.ini', true); | |
31 | ||
32 | $dblink = @mysql_connect($LMS_CONFIG['database']['host'], $LMS_CONFIG['database']['user'], $LMS_CONFIG['database']['password']); | |
33 | mysql_select_db($LMS_CONFIG['database']['database'], $dblink); | |
34 | ||
35 | mysql_query("SET NAMES utf8"); | |
36 | ||
37 | $lQ = mysql_query("SELECT id, name, passwd, hosts, lastlogindate, lastloginip FROM users WHERE login='".$user."' AND deleted=0"); | |
38 | $lA = mysql_fetch_array($lQ, MYSQL_ASSOC); | |
39 | @mysql_close($dblink); | |
40 | ||
41 | if(!is_array($lA)) return false; | |
42 | ||
43 | if(crypt($pass, $lA['passwd']) != $lA['passwd']) return false; | |
44 | ||
45 | $this->user['name'] = $lA['name']; | |
46 | $this->user['id'] = $lA['id']; | |
47 | $this->user['gid'] = 0; //TODO: rights | |
48 | return true; | |
49 | ||
50 | } | |
51 | } |