broken email confirmation

broken email confirmation

by yoni a -
Number of replies: 0
Hello,
When a user signs up for the first time, a confirmation link is sent to his email address.
My problem is this:
The confirmation link that is sent doesn't work:

Example for the wrong link:

http://excelangcourses.com/moodle/login/confirm.php?data=HiZ2DizGDrtcxXQ=abcdef

Example for the correct link(how it should be):
http://excelangcourses.com/moodle/login/confirm.php?data=HiZ2DizGDrtcxXQ/abcdef

Pay attention to the "=" sign after the "secret" code("HiZ2DizGDrtcxXQ="), Instead it should be "/" sign.
After the "secret" code moodle adds a "=" sign, and replace the "/" sign.

The CODE:
---------------------------------------
file moodle\login\signup.php:

else if ($user = $mform_signup->get_data()) {
$user->confirmed = 0;
$user->lang = current_language();
$user->firstaccess = time();
$user->mnethostid = $CFG->mnet_localhost_id;
$user->secret = random_string(15); //The "secret" line.
$user->auth = $CFG->registerauth;

$authplugin->user_signup($user, true); // prints notice and link to login/index.php
exit; //never reached
}
------------------------------------------------------
file moodle\lib\moodlelib.php:

function random_string ($length=16) {
$pool = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$pool .= 'abcdefghijklmnopqrstuvwxyz';
$pool .= '0123456789';
$poollen = strlen($pool);
mt_srand ((double) microtime() * 1000000);
$string = '';
for ($i = 0; $i < $length; $i++) {
$string .= substr($pool, (mt_rand()%($poollen)), 1);
}
return $string;
}

----------------------------------

Please help me figure it out.
Thanks...
Average of ratings: -