Генерация случайного пароля через хэш случайной строки.

This commit is contained in:
Igor Barkov (iwork) 2020-09-30 16:20:55 +03:00
parent f18fab4cdf
commit 0917f9d07f

View File

@ -18,15 +18,13 @@ $in_haos = mysql_fetch_array(mysql_query("SELECT * FROM `cit_haos_status` WHERE
$owntravma = mysql_fetch_array(mysql_query("SELECT * FROM `effects` WHERE `owner` = " . $user['id'] . " AND (type=13 OR type=12 OR type=14) limit 1;"));
$wait_msg = "Ждем подтверждения от всей группы...";
function getPass($length = 6)
/** Генерация случайного пароля через хэш случайной строки.
*
* @return string
*/
function getPass():string
{
$chars = 'abcdefghijklmnopqrstyvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789';
$numChars = strlen($chars);
$string = '';
for ($i = 0; $i < $length; $i++) {
$string .= substr($chars, rand(1, $numChars) - 1, 1);
}
return $string;
return hash('crc32', mt_rand());
}
if (!$in_haos) {
@ -34,7 +32,7 @@ if (!$in_haos) {
$in_haos = mysql_fetch_array(mysql_query("SELECT * FROM `cit_haos_status` WHERE `id` = '{$user['id']}' LIMIT 1;"));
}
$pass_s = getPass(6);
$pass_s = getPass();
if ($_POST['pay']) {
if (!$_POST['pay_gr']) $_POST['pay_gr'] = 1;
@ -180,7 +178,7 @@ Template::header('Цитадель Хаоса');
} elseif ($in_haos['status'] == 0) {
$cit_haos_gr = mysql_num_rows(mysql_query("SELECT * FROM `cit_haos_var`;"));
if ($cit_haos_gr == 0) {
$pass_s = getPass(6);
$pass_s = getPass();
mysql_query("INSERT INTO `cit_haos_var`(`group`,`password`) values('1','{$pass_s}');");
$cit_haos_gr = mysql_num_rows(mysql_query("SELECT * FROM `cit_haos_var`;"));
}