mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 01:09:21 +02:00
Optimize code (account number generation)
Thanks kamil-karkus for suggestion
This commit is contained in:
parent
0abb9384a6
commit
afea618867
@ -86,6 +86,9 @@ const TFS_03 = 4;
|
||||
const TFS_FIRST = TFS_02;
|
||||
const TFS_LAST = TFS_03;
|
||||
|
||||
// other definitions
|
||||
const ACCOUNT_NUMBER_LENGTH = 10;
|
||||
|
||||
session_save_path(SYSTEM . 'php_sessions');
|
||||
session_start();
|
||||
|
||||
|
@ -218,7 +218,7 @@ if($save)
|
||||
if (!config('account_login_by_email')) {
|
||||
$tmp_account = (USE_ACCOUNT_NAME ? $account_name : $account_id);
|
||||
}
|
||||
|
||||
|
||||
if($config['mail_enabled'] && $config['account_mail_verify'])
|
||||
{
|
||||
$hash = md5(generateRandomString(16, true, true) . $email);
|
||||
|
@ -14,15 +14,15 @@ require '../common.php';
|
||||
require SYSTEM . 'functions.php';
|
||||
require SYSTEM . 'init.php';
|
||||
|
||||
if(USE_ACCOUNT_NAME) {
|
||||
if (config('account_login_by_email') || USE_ACCOUNT_NAME) {
|
||||
return;
|
||||
}
|
||||
|
||||
$hasNumberColumn = $db->hasColumn('accounts', 'number');
|
||||
do {
|
||||
$length = 10;
|
||||
$min = (int)(1 . str_repeat(0, $length - 1));
|
||||
$max = (int)str_repeat(9, $length);
|
||||
$length = ACCOUNT_NUMBER_LENGTH;
|
||||
$min = 10 ** ($length - 1);
|
||||
$max = 10 ** $length - 1;
|
||||
|
||||
try {
|
||||
$number = random_int($min, $max);
|
||||
|
Loading…
x
Reference in New Issue
Block a user