2022-08-25 11:23:36 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
2022-12-30 19:03:37 +00:00
|
|
|
|
use Core\Db;
|
|
|
|
|
|
2022-08-25 11:23:36 +00:00
|
|
|
|
class UserRegister
|
|
|
|
|
{
|
|
|
|
|
|
2022-12-30 19:03:37 +00:00
|
|
|
|
public function hasMixedLatCur(string $txt): bool
|
2022-08-25 11:23:36 +00:00
|
|
|
|
{
|
2022-12-30 19:03:37 +00:00
|
|
|
|
$en = preg_match("/^(([0-9A-z -])+)$/i", $txt);
|
|
|
|
|
$ru = preg_match("/^(([0-9<>-<2D> _-])+)$/i", $txt);
|
|
|
|
|
return ($ru && $en) || (!$ru && !$en);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function hasGoodLogin(string $login): string
|
|
|
|
|
{
|
|
|
|
|
$isRestricted = in_array(
|
|
|
|
|
$login,
|
|
|
|
|
[
|
|
|
|
|
'<27><><EFBFBD><EFBFBD><EFBFBD>', 'angel', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', 'administration', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',
|
|
|
|
|
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',
|
|
|
|
|
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',
|
|
|
|
|
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
$isRegistered = Db::getValue('select count(*) from users where login = ?', [$login]);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD>.
|
|
|
|
|
$wasRegistered = Db::getValue('select count(*) from lastnames where login = ?', [$login]);
|
|
|
|
|
|
|
|
|
|
$login = str_replace(' ', ' ', $login);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD> <20><> 4 <20><> 20 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (strlen($login) > 20) {
|
|
|
|
|
$error = '<27><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> 20 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.';
|
|
|
|
|
}
|
|
|
|
|
if (strlen($login) < 4) {
|
|
|
|
|
$error = '<27><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> 4 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.';
|
|
|
|
|
}
|
|
|
|
|
if ($this->hasMixedLatCur($login)) {
|
|
|
|
|
$error = '<27> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.';
|
2022-08-25 11:23:36 +00:00
|
|
|
|
}
|
2022-12-30 19:03:37 +00:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (substr_count($login, ' ') + substr_count($login, '-') + substr_count($login, '_') > 2) {
|
|
|
|
|
$error = '<27><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>).';
|
2022-08-25 11:23:36 +00:00
|
|
|
|
}
|
2022-12-30 19:03:37 +00:00
|
|
|
|
if (!empty($error)) {
|
|
|
|
|
$error .= '<br> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>, xalop. <br> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: )))), kol<6F>)=-/.';
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if ($isRegistered || $wasRegistered || $isRestricted) {
|
|
|
|
|
$error = '<27><><EFBFBD><EFBFBD><EFBFBD> ' . $login . ' <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $error ?? '';
|
2022-08-25 11:23:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-30 19:03:37 +00:00
|
|
|
|
public function hasGoodEmail(string $email): string
|
2022-08-25 11:23:36 +00:00
|
|
|
|
{
|
2022-12-30 19:03:37 +00:00
|
|
|
|
$isRegistered = Db::getValue('select count(*) from users where mail = ?', [$email]);
|
|
|
|
|
$isBlocked = Db::getValue('select count(*) from ban_email where email = ?', [$email]);
|
|
|
|
|
if (!filter_var($email, FILTER_VALIDATE_EMAIL) || $isRegistered) {
|
|
|
|
|
$error = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> email.';
|
|
|
|
|
}
|
|
|
|
|
if ($isBlocked) {
|
|
|
|
|
$error = '<27><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$allowedDomains = Db::getColumn('select email from trust_email');
|
|
|
|
|
$domain = explode('@', $email)[1];
|
|
|
|
|
|
|
|
|
|
if (!in_array($domain, $allowedDomains)) {
|
|
|
|
|
$error = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $error ?? '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function hasGoodEmailCode(string $email, int $code): string
|
|
|
|
|
{
|
|
|
|
|
$check = Db::getValue('select code from secure_code where email = ?', [$email]);
|
|
|
|
|
if ($code !== $check) {
|
|
|
|
|
return '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>.';
|
|
|
|
|
}
|
|
|
|
|
return '';
|
2022-08-25 11:23:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-30 19:03:37 +00:00
|
|
|
|
public function hasGoodPassword(string $password1, string $password2): string
|
|
|
|
|
{
|
|
|
|
|
if ($password1 !== $password2) {
|
|
|
|
|
$error = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|
|
|
|
}
|
|
|
|
|
if (strlen($password1 < 8)) {
|
|
|
|
|
$error = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 8 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|
|
|
|
$error .= '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ' . PassGen::new();
|
|
|
|
|
}
|
|
|
|
|
return $error ?? '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function new(string $login, string $password, string $email, $ref, $birthday, $sex): string
|
|
|
|
|
{
|
2023-01-06 14:57:25 +00:00
|
|
|
|
$password = password_hash($password, PASSWORD_DEFAULT);
|
|
|
|
|
$ip = UserIp::get();
|
|
|
|
|
$sex = (int)$sex - 10; //<2F><> <20><><EFBFBD><EFBFBD><EFBFBD> 10\11, <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> 0\1.
|
2022-12-30 19:03:37 +00:00
|
|
|
|
Db::sql(
|
2023-01-06 14:57:25 +00:00
|
|
|
|
'insert into users (users.real,login,host_reg,pass,ip,ipreg,room,timereg,mail,bithday,sex,fnq,molch2,level,hobby,clan_zv) values (1,?,?,?,?,?,9,unix_timestamp(),?,?,?,0,unix_timestamp() + 86400,8,\'\',0)',
|
2022-12-30 19:03:37 +00:00
|
|
|
|
[
|
|
|
|
|
$login,
|
2023-01-06 19:26:10 +00:00
|
|
|
|
$ref ?? '',
|
2023-01-06 14:57:25 +00:00
|
|
|
|
$password,
|
|
|
|
|
$ip,
|
|
|
|
|
$ip,
|
2022-12-30 19:03:37 +00:00
|
|
|
|
$email,
|
|
|
|
|
date('d.m.Y', strtotime($birthday)),
|
2023-01-06 14:57:25 +00:00
|
|
|
|
$sex,
|
2022-12-30 19:03:37 +00:00
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return Db::lastInsertId();
|
|
|
|
|
}
|
2022-08-25 11:23:36 +00:00
|
|
|
|
}
|