[pLog-svn] r5868 - in plog/branches/lifetype-1.2: class/dao/userdata config
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Thu Aug 23 14:08:53 EDT 2007
Author: oscar
Date: 2007-08-23 14:08:52 -0400 (Thu, 23 Aug 2007)
New Revision: 5868
Modified:
plog/branches/lifetype-1.2/class/dao/userdata/joomlauserdataprovider.class.php
plog/branches/lifetype-1.2/config/userdata.properties.php
Log:
Fix for issue http://bugs.lifetype.net/view.php?id=1376 -- Joomla user data provider not working for Joomla >= 1.0.13 due to changes in the authentication mechanism.
Modified: plog/branches/lifetype-1.2/class/dao/userdata/joomlauserdataprovider.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/dao/userdata/joomlauserdataprovider.class.php 2007-08-23 01:15:23 UTC (rev 5867)
+++ plog/branches/lifetype-1.2/class/dao/userdata/joomlauserdataprovider.class.php 2007-08-23 18:08:52 UTC (rev 5868)
@@ -45,7 +45,7 @@
//phpbb2_users table is created upon installation, we can use it for joomla too
//but better parameterize its name
$this->_joomlaauxtable="joomla_users";
-
+
$this->_dbc =& Db::getNewDb( $host, $user, $pass, $db );
//Oddly, there have been problems in reading Joomla! db in utf-8
@@ -67,15 +67,31 @@
*/
function authenticateUser( $user, $pass )
{
- $query = "SELECT * FROM ".$this->_joomladbprefix."users".
+ $providerConfig = $this->getProviderConfiguration();
+ if( $providerConfig->getValue( "useNewJoomlaAuth" )) {
+ $query = "SELECT * FROM ".$this->_joomladbprefix."users".
" WHERE username = '".$user."'".
+ " AND block=".JOOMLA_USER_IS_ACTIVE;
+ $result = $this->_dbc->Execute( $query );
+ if( !$result ) {
+ return false; // no such user
+ }
+ $row = $result->FetchRow();
+ list($hash, $salt) = explode(':', $row['password']);
+ $cryptpass = md5($pass.$salt);
+ if ($hash != $cryptpass) {
+ return false; // password don;t match
+ }
+ }
+ else {
+ $query = "SELECT * FROM ".$this->_joomladbprefix."users".
+ " WHERE username = '".$user."'".
" AND password = '".md5($pass)."'".
" AND block=".JOOMLA_USER_IS_ACTIVE;
-
- $result = $this->_dbc->Execute( $query );
-
- if( !$result ){
- return false;
+ $result = $this->_dbc->Execute( $query );
+ if( !$result ){
+ return false;
+ }
}
$ret = ($result->RecordCount() == 1);
@@ -98,16 +114,34 @@
function getUserInfo( $user, $pass )
{
//Query Joomla db
- $query = "SELECT * FROM ".$this->_joomladbprefix."users".
+ $providerConfig = $this->getProviderConfiguration();
+ if( $providerConfig->getValue( "useNewJoomlaAuth" )) {
+ $query = "SELECT * FROM ".$this->_joomladbprefix."users".
" WHERE username = '".$user."'".
- " AND password = '".md5($pass)."';".
-
- $result = $this->_dbc->Execute( $query );
-
- if( !$result )
- return false;
-
- $row = $result->FetchRow();
+ " AND block=".JOOMLA_USER_IS_ACTIVE;
+ $result = $this->_dbc->Execute( $query );
+ if( !$result ) {
+ return false; // no such user
+ }
+ $row = $result->FetchRow();
+ list($hash, $salt) = explode(':', $row['password']);
+ $cryptpass = md5($pass.$salt);
+ if ($hash != $cryptpass) {
+ return false; // password don;t match
+ }
+ }
+ else {
+ $query = "SELECT * FROM ".$this->_joomladbprefix."users".
+ " WHERE username = '".$user."'".
+ " AND password = '".md5($pass)."'".
+ " AND block=".JOOMLA_USER_IS_ACTIVE;
+ $result = $this->_dbc->Execute( $query );
+ if( !$result ) {
+ return false;
+ }
+ $row = $result->FetchRow();
+ }
+
$result->Close();
$userid=$row["id"];
Modified: plog/branches/lifetype-1.2/config/userdata.properties.php
===================================================================
--- plog/branches/lifetype-1.2/config/userdata.properties.php 2007-08-23 01:15:23 UTC (rev 5867)
+++ plog/branches/lifetype-1.2/config/userdata.properties.php 2007-08-23 18:08:52 UTC (rev 5868)
@@ -6,7 +6,7 @@
####
#
-# Default user data provider, plog's own one
+# Default user data provider, LifeType's own one
#
$config = Array(
"provider" => "LifeTypeUserDataProvider",
@@ -109,6 +109,7 @@
"user" => "joomla_db_user",
"password" => "joomla_db_pass",
"prefix" => "jos_",
+ "useNewJoomlaAuth" => true, // This is needed for Joomla 1.0.13 and higher
// This string gets appended to the username and results
// in "Username's Weblog"
More information about the pLog-svn
mailing list