From: Reini U. <ru...@us...> - 2004-03-10 14:12:54
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31942/lib Modified Files: WikiGroup.php Log Message: adodb WikiGroup fix Index: WikiGroup.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/WikiGroup.php,v retrieving revision 1.15 retrieving revision 1.16 diff -u -2 -b -p -d -r1.15 -r1.16 --- WikiGroup.php 9 Mar 2004 12:11:57 -0000 1.15 +++ WikiGroup.php 10 Mar 2004 13:54:54 -0000 1.16 @@ -194,9 +194,14 @@ class WikiGroup{ if ($dbi and !empty($GLOBALS['DBAuthParams']['pref_select'])) { //get prefs table - $sql = str_replace(' prefs ',' userid ',$GLOBALS['DBAuthParams']['pref_select']); - $sql = preg_replace('/WHERE.*/i','',$sql); + $sql = preg_replace('/SELECT .+ FROM/i','SELECT userid FROM',$GLOBALS['DBAuthParams']['pref_select']); + //don't strip WHERE, only the userid stuff. + $sql = preg_replace('/(WHERE.*?)\s+\w+\s*=\s*"\$userid"/i','\\1 AND 1',$sql); + $sql = str_replace('WHERE AND 1','',$sql); if ($GLOBALS['DBParams']['dbtype'] == 'ADODB') { $db_result = $dbi->Execute($sql); - $users = array_merge($users,$db_result->GetArray()); + foreach ($db_result->GetArray() as $u) { + $users = array_merge($users,array_values($u)); + } + //$users = array_merge($users,array_values($db_result->GetArray())); } elseif ($GLOBALS['DBParams']['dbtype'] == 'SQL') { $users = array_merge($users,$dbi->getCol($sql)); @@ -205,9 +210,15 @@ class WikiGroup{ /* WikiDB users from users: */ + // Fixme: don't strip WHERE, only the userid stuff. if ($dbi and !empty($GLOBALS['DBAuthParams']['auth_user_exists'])) { - $sql = preg_replace('/WHERE.*/i','',$GLOBALS['DBAuthParams']['auth_user_exists']); + //don't strip WHERE, only the userid stuff. + $sql = preg_replace('/(WHERE.*?)\s+\w+\s*=\s*"\$userid"/i','\\1 AND 1',$GLOBALS['DBAuthParams']['auth_user_exists']); + $sql = str_replace('WHERE AND 1','',$sql); + //$sql = preg_replace('/WHERE.*/i','',$GLOBALS['DBAuthParams']['auth_user_exists']); if ($GLOBALS['DBParams']['dbtype'] == 'ADODB') { $db_result = $dbi->Execute($sql); - $users = array_merge($users,$db_result->GetArray()); + foreach ($db_result->GetArray() as $u) { + $users = array_merge($users,array_values($u)); + } } elseif ($GLOBALS['DBParams']['dbtype'] == 'SQL') { $users = array_merge($users,$dbi->getCol($sql)); @@ -582,5 +593,5 @@ class GroupDb extends WikiGroup { } $dbh = _PassUser::getAuthDbh(); - $db_result = $dbh->execute($this->_user_groups,$username); + $db_result = $dbh->execute($this->_user_groups,array($username)); if ($db_result->numRows() > 0) { while (list($group) = $db_result->fetchRow()) { @@ -606,5 +617,5 @@ class GroupDb extends WikiGroup { $dbh = _PassUser::getAuthDbh(); - $db_result = $dbh->execute($this->_group_members,$group); + $db_result = $dbh->execute($this->_group_members,array($group)); if ($db_result->numRows() > 0) { while (list($userid) = $db_result->fetchRow()) { @@ -848,4 +859,7 @@ class GroupLdap extends WikiGroup { // $Log$ +// Revision 1.16 2004/03/10 13:54:54 rurban +// adodb WikiGroup fix +// // Revision 1.15 2004/03/09 12:11:57 rurban // prevent from undefined DBAuthParams warning |