From: Thomas Mudrunka Date: Tue, 13 Dec 2011 13:52:25 +0000 (+0100) Subject: Priprava pro vseobecny MySQL autorizacni backend X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=96fcd5f46822256e90d215118c31a388be4e33a2;p=mirrors%2FSokoMan.git Priprava pro vseobecny MySQL autorizacni backend --- diff --git a/lib/Sklad_Auth.class/mysql.php b/lib/Sklad_Auth.class/mysql.php new file mode 100755 index 0000000..fc5ec5c --- /dev/null +++ b/lib/Sklad_Auth.class/mysql.php @@ -0,0 +1,56 @@ +. +*/ + +/** +* Trida zajistuje autorizaci vuci LMS +* +* @package Sklad_Auth +* @author Tomas Mudrunka +* @author Martin Krusinsky +*/ + +class Sklad_Auth extends Sklad_Auth_common { + function check_auth($user, $pass) { + + $LMS_CONFIG = (array)parse_ini_file('/etc/lms/lms.ini', true); + define('BACKEND_AUTH_MYSQL_HOST', $LMS_CONFIG['database']['host']); + define('BACKEND_AUTH_MYSQL_USER', $LMS_CONFIG['database']['user']); + define('BACKEND_AUTH_MYSQL_PASS', $LMS_CONFIG['database']['password']); + define('BACKEND_AUTH_MYSQL_DB', $LMS_CONFIG['database']['database']); + + $dblink = @mysql_connect(BACKEND_AUTH_MYSQL_HOST, BACKEND_AUTH_MYSQL_USER, BACKEND_AUTH_MYSQL_PASS); + mysql_select_db(BACKEND_AUTH_MYSQL_DB, $dblink); + + mysql_query("SET NAMES utf8"); + + $lQ = mysql_query("SELECT id, name, passwd, hosts, lastlogindate, lastloginip FROM users WHERE login='".$user."' AND deleted=0"); + $lA = mysql_fetch_array($lQ, MYSQL_ASSOC); + @mysql_close($dblink); + + if(!is_array($lA)) return false; + + if(crypt($pass, $lA['passwd']) != $lA['passwd']) return false; + + $this->user['name'] = $lA['name']; + $this->user['id'] = $lA['id']; + $this->user['gid'] = 0; //TODO: rights + return true; + + } +}