dev-php74-utf8 #31

Merged
lopar merged 15 commits from dev-php74-utf8 into master 2023-01-11 13:52:04 +00:00
2 changed files with 12 additions and 23 deletions
Showing only changes of commit 2590d62f1f - Show all commits

View File

@ -97,11 +97,8 @@ class UserRegister
if ($isRegistered || $wasRegistered || $isRestricted) { if ($isRegistered || $wasRegistered || $isRestricted) {
$this->error = 'Логин ' . $login . ' уже занят, выберите другой.'; $this->error = 'Логин ' . $login . ' уже занят, выберите другой.';
} }
if (!$this->error) {
$this->login = $login; return !$this->error;
return true;
}
return false;
} }
public function hasGoodEmail(string $email): bool public function hasGoodEmail(string $email): bool
@ -118,11 +115,7 @@ class UserRegister
if (!in_array(explode('@', $email)[1], $allowedDomains)) { if (!in_array(explode('@', $email)[1], $allowedDomains)) {
$this->error = 'Данный почтовый сервис использовать нельзя.'; $this->error = 'Данный почтовый сервис использовать нельзя.';
} }
if (!$this->error) { return !$this->error;
$this->email = $email;
return true;
}
return false;
} }
public function hasGoodEmailCode(string $email, int $code): bool public function hasGoodEmailCode(string $email, int $code): bool
@ -144,25 +137,17 @@ class UserRegister
if (strlen($password1) < 8) { if (strlen($password1) < 8) {
$this->error = 'Пароль должен быть больше 8 символов'; $this->error = 'Пароль должен быть больше 8 символов';
} }
if (!$this->error) { return !$this->error;
$this->password = password_hash($password1, PASSWORD_DEFAULT);
return true;
}
return false;
} }
public function new($ref, $birthday, int $sex, int $class): string public function new(string $login, string $password, string $email, $ref, $birthday, int $sex, int $class): string
{ {
if (!$this->login || if (!$this->hasGoodLogin()) {
!$this->password ||
!$this->email ||
!in_array($sex, [10, 11]) ||
!in_array($class, range(1, 9))) {
return 0; return 0;
} }
$this->class = $class; $this->class = $class;
$ip = UserIp::get(); $ip = UserIp::get();
$sex = (int)$sex - 10; //На входе 10\11, а передать надо 0\1. $sex -= 10; //На входе 10\11, а передать надо 0\1.
Db::sql( Db::sql(
'insert into users 'insert into users
(`real`,login,host_reg,pass,ip,ipreg,room,timereg,mail,bithday,sex,fnq,molch2,level,clan_zv,money,online) (`real`,login,host_reg,pass,ip,ipreg,room,timereg,mail,bithday,sex,fnq,molch2,level,clan_zv,money,online)
@ -179,6 +164,7 @@ class UserRegister
] ]
); );
$uid = Db::lastInsertId(); $uid = Db::lastInsertId();
$this->login = $login;
$this->setCookies(); $this->setCookies();
$this->setStatsItemsEffects(); $this->setStatsItemsEffects();
User::setOnline($uid); User::setOnline($uid);
@ -190,7 +176,7 @@ class UserRegister
{ {
setcookie('login', 1, 1, '/', Config::get('host'), true); setcookie('login', 1, 1, '/', Config::get('host'), true);
setcookie('registrationModal', 1, 1, '/', Config::get('host'), true); setcookie('registrationModal', 1, 1, '/', Config::get('host'), true);
setrawcookie('login', $this->login, strtotime('+7 days'), '/', Config::get('host'), true); setcookie('login', $this->login, strtotime('+7 days'), '/', Config::get('host'), true);
setcookie('registrationModal', 'true', strtotime('+7 days'), '/', Config::get('host'), true); setcookie('registrationModal', 'true', strtotime('+7 days'), '/', Config::get('host'), true);
} }

View File

@ -89,6 +89,9 @@ if ($_SESSION['step'] === 8) { // Всех их соберём, вместе с
//Создаем персонажа //Создаем персонажа
$uid = $newUser->new( $uid = $newUser->new(
$_SESSION['login'],
$_SESSION['password'],
$_SESSION['email'],
$_SESSION['ref'], $_SESSION['ref'],
$_SESSION['birthday'], $_SESSION['birthday'],
$_SESSION['sex'], $_SESSION['sex'],