mirror of
https://git.code.sf.net/p/seeddms/code
synced 2026-01-20 00:07:27 +00:00
add new function uniqidReal()
This commit is contained in:
parent
e202ff46b8
commit
757d950802
|
|
@ -695,7 +695,7 @@ function formatComment($an) { /* {{{ */
|
|||
* @param string $command The command to check
|
||||
* @return bool True if the command has been found ; otherwise, false.
|
||||
*/
|
||||
function commandExists ($command) {
|
||||
function commandExists ($command) { /* {{{ */
|
||||
$whereIsCommand = (PHP_OS == 'WINNT') ? 'where' : 'command -v';
|
||||
|
||||
$process = proc_open(
|
||||
|
|
@ -718,7 +718,7 @@ function commandExists ($command) {
|
|||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Send a file from disk to the browser
|
||||
|
|
@ -851,7 +851,7 @@ function seed_pass_verify($password, $hash) { /* {{{ */
|
|||
return (md5($password) == $hash) || password_verify($password, $hash);
|
||||
} /* }}} */
|
||||
|
||||
function resolveTask($task) {
|
||||
function resolveTask($task) { /* {{{ */
|
||||
global $dms, $user, $settings, $logger, $fulltextservice, $notifier, $conversionmgr;
|
||||
|
||||
if(is_object($task))
|
||||
|
|
@ -862,7 +862,7 @@ function resolveTask($task) {
|
|||
}
|
||||
}
|
||||
return $task;
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Return nonce for CSP
|
||||
|
|
@ -880,6 +880,23 @@ function createNonce() { /* {{{ */
|
|||
return base64_encode($bytes);
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Create a real uniqid for cryptographic purposes
|
||||
*
|
||||
* @ return string
|
||||
*/
|
||||
function uniqidReal($lenght = 13) {
|
||||
// uniqid gives 13 chars, but you could adjust it to your needs.
|
||||
if (function_exists("random_bytes")) {
|
||||
$bytes = random_bytes(ceil($lenght / 2));
|
||||
} elseif (function_exists("openssl_random_pseudo_bytes")) {
|
||||
$bytes = openssl_random_pseudo_bytes(ceil($lenght / 2));
|
||||
} else {
|
||||
throw new Exception("no cryptographically secure random function available");
|
||||
}
|
||||
return substr(bin2hex($bytes), 0, $lenght);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare function for sorting users by login
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user