Hezci samolepky
[mirrors/SokoMan.git] / lib / Sklad_Auth.class / mysql.php
CommitLineData
96fcd5f4
TM
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
28class Sklad_Auth extends Sklad_Auth_common {
29 function check_auth($user, $pass) {
30
31 $LMS_CONFIG = (array)parse_ini_file('/etc/lms/lms.ini', true);
32 define('BACKEND_AUTH_MYSQL_HOST', $LMS_CONFIG['database']['host']);
33 define('BACKEND_AUTH_MYSQL_USER', $LMS_CONFIG['database']['user']);
34 define('BACKEND_AUTH_MYSQL_PASS', $LMS_CONFIG['database']['password']);
35 define('BACKEND_AUTH_MYSQL_DB', $LMS_CONFIG['database']['database']);
36
37 $dblink = @mysql_connect(BACKEND_AUTH_MYSQL_HOST, BACKEND_AUTH_MYSQL_USER, BACKEND_AUTH_MYSQL_PASS);
38 mysql_select_db(BACKEND_AUTH_MYSQL_DB, $dblink);
39
40 mysql_query("SET NAMES utf8");
41
42 $lQ = mysql_query("SELECT id, name, passwd, hosts, lastlogindate, lastloginip FROM users WHERE login='".$user."' AND deleted=0");
43 $lA = mysql_fetch_array($lQ, MYSQL_ASSOC);
44 @mysql_close($dblink);
45
46 if(!is_array($lA)) return false;
47
48 if(crypt($pass, $lA['passwd']) != $lA['passwd']) return false;
49
50 $this->user['name'] = $lA['name'];
51 $this->user['id'] = $lA['id'];
52 $this->user['gid'] = 0; //TODO: rights
53 return true;
54
55 }
56}
This page took 0.397814 seconds and 4 git commands to generate.