Joomla Forum

Joomla Hacks => Joomla-SMF 2.0.x => Topic started by: Stef on March 12, 2008, 01:31:20 PM



Title: [solve] Password issue when ask for a new password
Post by: Stef on March 12, 2008, 01:31:20 PM
(J1.0.15, CB 1.1, SMF 1.1.4 and JSMF 2.0.2.1 may work with other version)

Problem : SQL error on line 1194 when users ask for new password because they forget it.

Solution : There is a syntax error (no declare and id membber field) in function updatePass in admin.smf.class.php

Find (line 1176) :
Code:
    function updatePass($id, $pass)
    {
        global $database;

        $username = $this->getUsername($id);
        if (empty($username)) {

            //what to do?
            //TODO empty username
            return false;
        }
        $smf_id = $this->getSMFid(null, $username);
        if (empty($smf_id)) {

            //what to do?
            //TODO empty uid
            return false;
        }
        $query =
            "UPDATE {$jsmfConfig->smf_prefix}members " .
            "SET passwd = '".sha1(strtolower($username).$pass)."' " .
            "WHERE id= '$smf_id' ";
        unset($username, $pass, $smf_id);
        $database->setQuery($query);
        unset($query);
        if (!$database->query()) {
            $this->err = $database->getErrorMsg().' ~~~ FROM::'.__FILE__.' || '.__FUNCTION__.' || '.__LINE__;
            return false;
        }
        return true;
    }

Replace by :
Code:
    function updatePass($id, $pass)
    {
        global $database;
        global $jsmfConfig;

        $username = $this->getUsername($id);
        if (empty($username)) {

            //what to do?
            //TODO empty username
            return false;
        }
        $smf_id = $this->getSMFid(null, $username);
        if (empty($smf_id)) {

            //what to do?
            //TODO empty uid
            return false;
        }
        $query =
            "UPDATE {$jsmfConfig->smf_prefix}members " .
            "SET passwd = '".sha1(strtolower($username).$pass)."' " .
            "WHERE ID_MEMBER = '$smf_id' ";
        unset($username, $pass, $smf_id);
        $database->setQuery($query);
        unset($query);
        if (!$database->query()) {
            $this->err = $database->getErrorMsg().' ~~~ FROM::'.__FILE__.' || '.__FUNCTION__.' || '.__LINE__;
            return false;
        }
        return true;
    }

For those don't like programming I join the class to this post
1-download
2-rename admin.smf.class.txt to admin.smf.class.php
3-FTP it to directory : /www/administrator/components/com_smf/


Title: Re: [solve] Password issue when ask for a new password
Post by: opheliagrimm on March 27, 2008, 11:04:53 PM
excellent work stef, did this the trick.

A little worried at how "abandoned" this bridge is feeling right now.


Joomla Forum | Powered by SMF 1.1 RC1.
© 2001-2005, Lewis Media. All Rights Reserved.
Joomla Bridge by JoomlaHacks.com