Hey all

Long time no post ...

Great post by king.lui ! Thx, that helped a lot trying to setup the 3-step password recovery on a Joomla 1.0.15 Stable + CB 1.1... with some tweaks

For all of you running this setup ( Joomla 1.0.15 Stable / CB 1.1
without the captcha plugin), here is my changed code,
completely based on king.lui's code (and shamelessely stealing his instructions

):
1. First you need a new text-field in your #_comprofiler table with name cb_pwdresetuuid
2. You need text-entries in your language.php:
Code:
DEFINE('_RESETPASS_SUB','$_sitename :: Have you requested a new password?');
DEFINE('_RESETPASS_SENT','Check your email!');
DEFINE('_RESETPASS_ERR','Error! Please contact the support!');
DEFINE('_RESETPASS_MSG','The User account $checkusername has this e-mail associated with it.\n\n'[code][/code]
.'Have you requested a new password?\n\n'
.'If so click here:\n$mosConfig_live_site/index.php?option=com_comprofiler&task=sendNewPass&xid=$uuid \n\n'
.'If this was an error just ignore this email');
4. Comment out the username-field in comprofiler.html.php:
Code:
<? /* <tr>
<td>< ?php echo _PROMPT_UNAME; ? ></td>
<td><input type="text" name="checkusername" class="inputbox" size="40" maxlength="25" /></td>
</tr> */ ?>
5. You must replace your function sendNewPass in your comprofiler.php:
Code:
function sendNewPass( $option ) {
global $database, $Itemid, $ueConfig,$_PLUGINS;
global $mosConfig_live_site, $mosConfig_sitename;
global $mosConfig_mailfrom, $mosConfig_fromname;
$_live_site = $mosConfig_live_site;
$_sitename = "";
$uuid = trim( mosGetParam( $_GET, 'xid', "") );
if ($uuid) {
$sql = "SELECT users.username, users.email, users.id
FROM #__users AS users
Inner Join #__comprofiler AS cb ON cb.user_id = users.id
WHERE cb.cb_pwdresetuuid = '$uuid'";
$database->setQuery($sql);
$rows = $database->loadObjectList();
if(count($rows)) {
$userrow = $rows[0];
$checkusername=$userrow->username;
$user_id=$userrow->id;
$confirmEmail=$userrow->email;
$newpass = $newpass = cbMakeRandomString( 8, true );
$message = _NEWPASS_MSG;
eval ("\$message = \"$message\";");
$subject = _NEWPASS_SUB;
eval ("\$subject = \"$subject\";");
$_PLUGINS->loadPluginGroup('user');
$_PLUGINS->trigger( 'onBeforeNewPassword', array( $user_id, &$newpass, &$subject, &$message ));
if ($_PLUGINS->is_errors()) {
echo "<script type=\"text/javascript\">alert(\"".$_PLUGINS->getErrorMSG()."\"); window.history.go(-1); </script>\n";
exit();
}
$cbNotification = new cbNotification();
$res=$cbNotification->sendFromSystem($user_id,$subject,$message);
if ($res) {
$_PLUGINS->trigger( 'onNewPassword', array($user_id,$newpass));
$newpass = md5( $newpass );
$sql = "UPDATE #__users SET password='$newpass' WHERE id = " . (int) $user_id;
$database->setQuery( $sql );
if (!$database->query()) { die("SQL error" . $database->stderr(true)); }
$sql = "UPDATE #__comprofiler SET cb_pwdresetuuid='' WHERE user_id = " . (int) $user_id;
$database->setQuery( $sql );
if (!$database->query()) { die("SQL error" . $database->stderr(true)); }
echo '<div class="message">'._NEWPASS_SENT.'</div>';
} else {
echo '<div class="message">'._UE_NEWPASS_FAILED.'</div>';
}
}else{ // no count(rows)
mosRedirect(sefRelToAbs("index.php?option=$option&task=lostPassword"),_RESETPASS_ERR );
}
} else { // no uuid
// simple spoof check security
cbSpoofCheck();
$confirmEmail = trim( mosGetParam( $_POST, 'confirmEmail', '') );
$database->setQuery( "SELECT id FROM #__users WHERE email='$confirmEmail'");
$user_id = $database->loadResult();
$database->setQuery( "SELECT username FROM #__users WHERE email='$confirmEmail'");
$checkusername = $database->loadResult();
if (!$user_id || !$confirmEmail) {
mosRedirect(sefRelToAbs("index.php?option=$option&task=lostPassword"),_ERROR_PASS );
}
// generate uuid and save it into the db
$uuid = $user_id.uniqid("");
$sql="UPDATE #__comprofiler SET cb_pwdresetuuid='$uuid' WHERE user_id=".(int) $user_id;
$database->SetQuery($sql);
$database->query();
// email
$message = _RESETPASS_MSG;
eval ("\$message = \"$message\";");
$subject = _RESETPASS_SUB;
eval ("\$subject = \"$subject\";");
$_PLUGINS->loadPluginGroup('user');
$_PLUGINS->trigger( 'onBeforeNewPassword', array( $user_id, &$newpass, &$subject, &$message ));
if ($_PLUGINS->is_errors()) {
echo "<script type=\"text/javascript\">alert(\"".$_PLUGINS->getErrorMSG()."\"); window.history.go(-1); </script>\n";
exit();
}
$cbNotification = new cbNotification();
$res=$cbNotification->sendFromSystem($user_id,$subject,$message);
mosRedirect(sefRelToAbs("index.php?option=$option&task=done".($Itemid ? "&Itemid=".$Itemid : "")),_RESETPASS_SENT );
}
if (!$user_id || !$confirmEmail) {
mosRedirect(sefRelToAbs("index.php?option=$option&task=lostPassword"),_ERROR_PASS );
}
}
That's all. Good luck

And thanx again, king.lui, for the piece of code+instructions

Regards,