X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fmain.inc;fp=includes%2Fmain.inc;h=38ceaa1df9730e4c5ba5b5200b2893e10cf36035;hb=7b8a565a1de2c6ed3c86133efb39e31b24c380a0;hp=11746a288b386bc254d0ea2b6ab4fdd6b436480e;hpb=19dce8c7be29e4cc8e7be92d044259348373d456;p=fa-stable.git diff --git a/includes/main.inc b/includes/main.inc index 11746a28..38ceaa1d 100644 --- a/includes/main.inc +++ b/includes/main.inc @@ -383,3 +383,23 @@ function clean_file_name($filename) { return preg_replace('/[^a-zA-Z0-9.\-_]/', '_', $filename); } +/* + Simple random password generator. +*/ +function generate_password() +{ + if (PHP_VERSION >= '5.3') + $bytes = openssl_random_pseudo_bytes(8, $cstrong); + else + $bytes = sprintf("08%x", mt_rand(0,0xffffffff)); + + return base64_encode($bytes); +} + +if (!function_exists('array_fill_keys')) // since 5.2 +{ + function array_fill_keys($keys, $value) + { + return array_combine($keys, array_fill(count($keys), $value)); + } +}