Генерация случайного пароля через хэш случайной строки.
This commit is contained in:
parent
f18fab4cdf
commit
0917f9d07f
18
c_haos.php
18
c_haos.php
@ -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;"));
|
$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 = "Ждем подтверждения от всей группы...";
|
$wait_msg = "Ждем подтверждения от всей группы...";
|
||||||
|
|
||||||
function getPass($length = 6)
|
/** Генерация случайного пароля через хэш случайной строки.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function getPass():string
|
||||||
{
|
{
|
||||||
$chars = 'abcdefghijklmnopqrstyvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789';
|
return hash('crc32', mt_rand());
|
||||||
$numChars = strlen($chars);
|
|
||||||
$string = '';
|
|
||||||
for ($i = 0; $i < $length; $i++) {
|
|
||||||
$string .= substr($chars, rand(1, $numChars) - 1, 1);
|
|
||||||
}
|
|
||||||
return $string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$in_haos) {
|
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;"));
|
$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']) {
|
||||||
if (!$_POST['pay_gr']) $_POST['pay_gr'] = 1;
|
if (!$_POST['pay_gr']) $_POST['pay_gr'] = 1;
|
||||||
@ -180,7 +178,7 @@ Template::header('Цитадель Хаоса');
|
|||||||
} elseif ($in_haos['status'] == 0) {
|
} elseif ($in_haos['status'] == 0) {
|
||||||
$cit_haos_gr = mysql_num_rows(mysql_query("SELECT * FROM `cit_haos_var`;"));
|
$cit_haos_gr = mysql_num_rows(mysql_query("SELECT * FROM `cit_haos_var`;"));
|
||||||
if ($cit_haos_gr == 0) {
|
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}');");
|
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`;"));
|
$cit_haos_gr = mysql_num_rows(mysql_query("SELECT * FROM `cit_haos_var`;"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user