Browse Source

Bring the "IP check info" functionality to a working state

Visman 4 năm trước cách đây
mục cha
commit
13be9d5300

+ 2 - 8
app/Models/Pages/Auth.php

@@ -161,14 +161,8 @@ class Auth extends Page
             if (! \password_verify($password, $user->password)) {
                 $v->addError('Wrong user/pass');
             } else {
-                // перезаписываем ip админа и модератора - Visman
-                if (
-                    $user->isAdmMod
-                    && $this->c->config->o_check_ip
-                    && $user->registration_ip != $this->user->ip
-                ) {
-                    $user->registration_ip = $this->user->ip;
-                }
+                $this->c->users->updateLoginIpCache($user, true); // ????
+
                 // сбросить запрос на смену кодовой фразы
                 if (32 === \strlen($user->activate_string)) {
                     $user->activate_string = '';

+ 1 - 1
app/Models/Pages/Profile/Config.php

@@ -79,7 +79,7 @@ class Config extends Profile
                 $this->curUser->replAttrs($data, true);
 
                 if ($this->curUser->isModified('ip_check_type')) {
-//                    $this->c->users->updateLoginIpCache($this->curUser); // ????
+                    $this->c->users->updateLoginIpCache($this->curUser); // ????
                 }
 
                 $this->c->users->update($this->curUser);

+ 6 - 6
app/Models/User/Current.php

@@ -22,12 +22,12 @@ class Current extends Action
         if (! $user->isGuest) {
             if (! $cookie->verifyUser($user)) {
                 $user = $this->load(1);
-            } elseif (
-                '1' == $this->c->config->o_check_ip
-                && $user->isAdmMod
-                && $user->registration_ip !== $user->ip
-            ) {
-                $user = $this->load(1);
+            } elseif ($user->ip_check_type > 0) {
+                $hexIp = \bin2hex(\inet_pton($user->ip)); // ???? проверка на пустоту?
+
+                if (false === \strpos("|{$user->login_ip_cache}|", "|{$hexIp}|")) {
+                    $user = $this->load(1);
+                }
             }
         }
 

+ 1 - 1
app/Models/User/UpdateLoginIpCache.php

@@ -42,7 +42,7 @@ class UpdateLoginIpCache extends Action
         $hexIp = \bin2hex(\inet_pton($this->c->user->ip)); // ???? проверка на пустоту?
 
         if (1 === $user->ip_check_type) {
-            $ipStr = \str_replace("|{$hexIp}|", "|", "|{$user->login_ip_cache}|");
+            $ipStr = \trim(\str_replace("|{$hexIp}|", "|", "|{$user->login_ip_cache}|"), '|');
             $ipStr = \trim("{$hexIp}|{$ipStr}", '|');
 
             while (

+ 1 - 1
app/lang/en/profile.po

@@ -547,4 +547,4 @@ msgid "Strict check"
 msgstr "Strict"
 
 msgid "IP check info"
-msgstr "<b>Strict</b> - if your ip address has changed, you will be logout;<br><b>Not strict</b> - this board remembers 10-20 of your last ip addresses, if your current ip address is not in this list, you will be logout;<br><b>Off</b> - changing your ip address does not affect anything."
+msgstr "<b>Strict</b> - if your ip address has changed, you will be logout;<br><b>Not strict</b> - this board remembers 10-20 of your last ip addresses and if your current ip address is not in this list, you will be logout;<br><b>Off</b> - changing your ip address does not affect anything."

+ 1 - 1
app/lang/ru/profile.po

@@ -547,4 +547,4 @@ msgid "Strict check"
 msgstr "Строгая"
 
 msgid "IP check info"
-msgstr "<b>Строгая</b> - при каждой смене вашего ip адреса, вы будите разлогинены;<br><b>Не строгая</b> - форум помнит 10-20 ваших последних ip адресов, если ваш текущий ip адрес не попадает в этот список, вы будите разлогинены;<br><b>Отключена</b> - смена вашего ip адеса ни на что не влияет."
+msgstr "<b>Строгая</b> - при каждой смене вашего ip адреса, вы будите разлогинены;<br><b>Не строгая</b> - форум помнит 10-20 ваших последних ip адресов и если ваш текущий ip адрес не попадает в этот список, вы будите разлогинены;<br><b>Отключена</b> - смена вашего ip адеса ни на что не влияет."