From f3f0262c480d7e509b008d37c90aed884532bba8 Mon Sep 17 00:00:00 2001 From: andi Date: Wed, 12 Jan 2005 21:24:54 +0100 Subject: Initial revision. darcs-hash:20050112202454-9977f-60936f24fe2092a30223627e0683de2df61d0c4a.gz --- inc/auth_mysql.php | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 inc/auth_mysql.php (limited to 'inc/auth_mysql.php') diff --git a/inc/auth_mysql.php b/inc/auth_mysql.php new file mode 100644 index 000000000..213c4a852 --- /dev/null +++ b/inc/auth_mysql.php @@ -0,0 +1,98 @@ + no need to ask for results + if ($result != 1) { + for($i=0; $i< mysql_num_rows($result); $i++) { + $temparray = mysql_fetch_assoc($result); + $resultarray[]=$temparray; + } + mysql_free_result ($result); + } + if (mysql_insert_id($link)) { + $resultarray = mysql_insert_id($link); //give back ID on insert + } + mysql_close ($link); + return $resultarray; +} + +/** + * required auth function + * + * Checks if a user with the given password exists + */ +function auth_checkPass($user,$pass){ + global $conf; + $cnf = $conf['auth']['mysql']; + + $sql = str_replace('%u',addslashes($user),$cnf['passcheck']); + $sql = str_replace('%p',addslashes($pass),$sql); + $result = auth_mysql_runsql($sql); + return(count($result)); +} + +/** + * Required auth function + * + * Returns info about the given user needs to contain + * at least these fields: + * + * name string full name of the user + * mail string email addres of the user + * grps array list of groups the user is in + * + */ +function auth_getUserData($user){ + global $conf; + $cnf = $conf['auth']['mysql']; + + $sql = str_replace('%u',addslashes($user),$cnf['userinfo']); + $result = auth_mysql_runsql($sql); + if(!count($result)) return false; + $info = $result[0]; + + $sql = str_replace('%u',addslashes($user),$cnf['groups']); + $result = auth_mysql_runsql($sql); + if(!count($result)) return false; + foreach($result as $row){ + $info['grps'][] = $row['group']; + } + + return $info; +} + +/** + * Required auth function + * + * Not implemented + */ +function auth_createUser($user,$name,$mail){ + msg("Sorry. Creating users is not supported by the MySQL backend, yet",-1); + return null; +} + +?> -- cgit v1.2.3