Commit 962bdcf2 authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files

Added a function that returns a random string 16 characters long, which can

be used for sending email keys.
parent 29dc2659
......@@ -1002,4 +1002,24 @@ function format_date($date, $formatkey='strftimedatetime') {
return strftime(get_string($formatkey), $date);
}
/**
* Returns a random string suitable for registration/change password requests
*
* @return string
*/
function get_random_key() {
$pool = array_merge(
range('A', 'Z'),
range('a', 'z'),
range(0, 9)
);
shuffle($pool);
$result = '';
for ($i = 0; $i < 16; $i++) {
$result .= $pool[$i];
}
log_debug($result);
return $result;
}
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment