Commit ed4a25d2 authored by Penny Leach's avatar Penny Leach
Browse files

Remove random_string() and replace all calls with get_random_key



These two functions are duplicates of functionality, get_random_key was
written first, and used more often, so makes more sense to keep.
Signed-off-by: default avatarPenny Leach <penny@mjollnir.org>
parent 6c60fe02
...@@ -246,7 +246,7 @@ function bulkimport_submit(Pieform $form, $values) { ...@@ -246,7 +246,7 @@ function bulkimport_submit(Pieform $form, $values) {
'username' => $username, 'username' => $username,
'firstname' => 'Imported', 'firstname' => 'Imported',
'lastname' => 'User', 'lastname' => 'User',
'password' => random_string(6), 'password' => get_random_key(6),
'passwordchange' => 1, 'passwordchange' => 1,
); );
......
...@@ -2283,18 +2283,6 @@ function cron_send_registration_data() { ...@@ -2283,18 +2283,6 @@ function cron_send_registration_data() {
} }
} }
function random_string($length=15) {
$pool = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$poollen = strlen($pool);
mt_srand ((double) microtime() * 1000000);
$string = '';
for ($i = 0; $i < $length; $i++) {
$string .= substr($pool, (mt_rand()%($poollen)), 1);
}
return $string;
}
function build_portfolio_search_html(&$data) { function build_portfolio_search_html(&$data) {
global $THEME; global $THEME;
$artefacttypes = get_records_assoc('artefact_installed_type'); $artefacttypes = get_records_assoc('artefact_installed_type');
......
...@@ -2629,9 +2629,9 @@ class View { ...@@ -2629,9 +2629,9 @@ class View {
$data = new StdClass; $data = new StdClass;
$data->view = $viewid; $data->view = $viewid;
$data->visible = (int) $visible; $data->visible = (int) $visible;
$data->token = random_string(20); $data->token = get_random_key(20);
while (record_exists('view_access_token', 'token', $data->token)) { while (record_exists('view_access_token', 'token', $data->token)) {
$data->token = random_string(20); $data->token = get_random_key(20);
} }
if (insert_record('view_access_token', $data)) { if (insert_record('view_access_token', $data)) {
return $data; return $data;
......
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