generate unpredictable unique session ids

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2021-10-02 12:38:17 +02:00
parent e73523531a
commit 7feddf0aec
7 changed files with 56 additions and 8 deletions

View File

@@ -82,10 +82,10 @@ class DbManager
// get all usernames from db-manager
$allsqlusers = $this->getManager()->getAllSqlUsers();
// generate random username
$username = $loginname . '-' . substr(md5(uniqid(microtime(), 1)), 20, 3);
$username = $loginname . '-' . substr(\Froxlor\Froxlor::genSessionId(), 20, 3);
// check whether it exists on the DBMS
while (in_array($username, $allsqlusers)) {
$username = $loginname . '-' . substr(md5(uniqid(microtime(), 1)), 20, 3);
$username = $loginname . '-' . substr(\Froxlor\Froxlor::genSessionId(), 20, 3);
}
} elseif (strtoupper(Settings::Get('customer.mysqlprefix')) == 'DBNAME') {
$username = $loginname;