From a771ad3a6d06253269a7ddf2da2fe9eab71dd895 Mon Sep 17 00:00:00 2001 From: matthiasgrimm Date: Sun, 22 Jan 2006 13:53:27 +0100 Subject: MySQL backend code cleanup fix This patch make the MySQL backend work again after Andi's code cleanup ;-) darcs-hash:20060122125327-7ef76-5b7a46fa8bc49fc68a11a44fabddc9753e9a1dfb.gz --- conf/local.php.dist | 10 +++ conf/mysql.conf.php.example | 144 +++++++++++++++++++++++--------------------- inc/auth/mysql.class.php | 26 ++++---- 3 files changed, 99 insertions(+), 81 deletions(-) diff --git a/conf/local.php.dist b/conf/local.php.dist index bcbb19e63..53d7cc720 100644 --- a/conf/local.php.dist +++ b/conf/local.php.dist @@ -10,3 +10,13 @@ $conf['title'] = 'My Wiki'; //what to show in the title $conf['useacl'] = 1; //Use Access Control Lists to restrict access? $conf['superuser'] = 'joe'; + +/* The following options are usefull, if you use a MySQL + * database as autentication backend. Have a look into + * mysql.conf.php too and adjust the options to match + * your database installation. + */ +$conf['authtype'] = 'mysql'; +require_once ("mysql.conf.php"); + + diff --git a/conf/mysql.conf.php.example b/conf/mysql.conf.php.example index ffe35c466..fe0664903 100644 --- a/conf/mysql.conf.php.example +++ b/conf/mysql.conf.php.example @@ -1,24 +1,32 @@ + WHERE uid='%{uid}'"; + diff --git a/inc/auth/mysql.class.php b/inc/auth/mysql.class.php index 5017d5b83..41d45e940 100644 --- a/inc/auth/mysql.class.php +++ b/inc/auth/mysql.class.php @@ -351,17 +351,17 @@ class auth_mysql extends auth_basic { function _addUserToGroup($user, $group, $force=0) { $newgroup = 0; - if($this->_dbcon) { + if($this->dbcon) { $uid = $this->_getUserID($user); if ($uid) { $gid = $this->_getGroupID($group); if (!$gid) { if ($force) { // create missing groups - $sql = str_replace('%g',addslashes($group),$this->cnf['addGroup']); + $sql = str_replace('%{group}',addslashes($group),$this->cnf['addGroup']); $gid = $this->_modifyDB($sql); $newgroup = 1; // group newly created } - if (!$gid) return false; // group didm't exist and can't be created + if (!$gid) return false; // group didn't exist and can't be created } $sql = str_replace('%{uid}', addslashes($uid),$this->cnf['addUserGroup']); @@ -396,8 +396,8 @@ class auth_mysql extends auth_basic { function _getGroups($user) { $groups = array(); - if($this->_dbcon) { - $sql = str_replace('%u',addslashes($user),$this->cnf['getGroups']); + if($this->dbcon) { + $sql = str_replace('%{user}',addslashes($user),$this->cnf['getGroups']); $result = $this->_queryDB($sql); if(count($result)) { @@ -422,8 +422,8 @@ class auth_mysql extends auth_basic { * @author Matthias Grimm */ function _getUserID($user) { - if($this->_dbcon) { - $sql = str_replace('%u',addslashes($user),$this->cnf['getUserID']); + if($this->dbcon) { + $sql = str_replace('%{user}',addslashes($user),$this->cnf['getUserID']); $result = $this->_queryDB($sql); return $result === false ? false : $result[0]['id']; } @@ -449,7 +449,7 @@ class auth_mysql extends auth_basic { * @author Matthias Grimm */ function _addUser($user,$pwd,$name,$mail,$grps){ - if($this->_dbcon && is_array($grps)) { + if($this->dbcon && is_array($grps)) { $sql = str_replace('%{user}', addslashes($user),$this->cnf['addUser']); $sql = str_replace('%{pass}', addslashes($pwd),$sql); $sql = str_replace('%{name}', addslashes($name),$sql); @@ -470,8 +470,8 @@ class auth_mysql extends auth_basic { * is not a big issue so we ignore this problem here. */ $this->_delUser($user); - $text = str_replace('%u',addslashes($user),$this->cnf['joinGroupFailed']); - $text = str_replace('%g',addslashes($group),$text); + $text = str_replace('%{user}',addslashes($user),$this->cnf['joinGroupFailed']); + $text = str_replace('%{group}',addslashes($group),$text); msg($text, -1); } } @@ -492,7 +492,7 @@ class auth_mysql extends auth_basic { * @author Matthias Grimm */ function _delUser($user) { - if($this->_dbcon) { + if($this->dbcon) { $uid = $this->_getUserID($user); if ($uid) { $sql = str_replace('%{uid}',addslashes($uid),$this->cnf['delUser']); @@ -673,7 +673,7 @@ class auth_mysql extends auth_basic { if ($cnt++ != 0) $sql .= ", "; $sql .= "$table $mode"; } - $this->modifyDB($sql); + $this->_modifyDB($sql); return true; } } @@ -689,7 +689,7 @@ class auth_mysql extends auth_basic { */ function _unlockTables() { if ($this->dbcon) { - $this->modifyDB("UNLOCK TABLES"); + $this->_modifyDB("UNLOCK TABLES"); return true; } return false; -- cgit v1.2.3