Query Password in Joomla 1.5 using PHP

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
User avatar
jcracknell
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Sat Feb 11, 2006 11:41 am
Location: Suffolk, UK

Query Password in Joomla 1.5 using PHP

Post by jcracknell » Thu Sep 06, 2007 8:38 pm

Hi

I have a PHP script which I am using at work for logging student attainment.  The Intranet we use is Joomla currently Joomla 1.0.13 and I hope to move it to Joomla 1.5 RC2.

I'd like the script to call up the usernames and passwords in the Joomla tables for added security.  How do I do this when it runs independently of Joomla?  Additionally with the mda5 password being stored with a salt for added security in 1.0.13 and 1.5 what do I need to do?

cheers

J.

User avatar
ianmac
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 237
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: Query Password in Joomla 1.5 using PHP

Post by ianmac » Fri Sep 07, 2007 3:03 pm

There are a few ways to do this.

The first option would be to develop an XML-RPC plugin that would allow external scripts to contact your Joomla! site to authenticate.  You would then also have to figure out the logic of a RPC client in your external scripts.

The second option would be to query the database directly.  Basically, when a user in an external script tries to authenticate, you take their username and retrieve the password entry that is stored in the database for that user.

Then, you take the password entry and extract the salt from it.  The password is stored in the format : md5Hash:salt.  So, you do:
list( $pass, $salt ) = explode( ":", $storedPassword );

Then you authenticate using:
$authenticated = ($pass == md5( $passwordFromForm . $salt ));

Ian
Help test my Component XML Generator Tool!
http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,1997/Itemid,35/
All feedback appreciated!


Post Reply