Browse Source

Invalid ip address -> '0.0.0.0'

Visman 4 years ago
parent
commit
164dbfe304
2 changed files with 2 additions and 8 deletions
  1. 1 1
      app/Models/Pages/Admin/Install.php
  2. 1 7
      app/Models/User/Current.php

+ 1 - 1
app/Models/Pages/Admin/Install.php

@@ -1057,7 +1057,7 @@ class Install extends Admin
         }
         }
         $this->c->DB->exec('UPDATE ::groups SET g_pm_limit=0 WHERE g_id=?i', [$this->c->GROUP_ADMIN]);
         $this->c->DB->exec('UPDATE ::groups SET g_pm_limit=0 WHERE g_id=?i', [$this->c->GROUP_ADMIN]);
 
 
-        $ip = \filter_var($_SERVER['REMOTE_ADDR'], \FILTER_VALIDATE_IP) ?: 'unknow';
+        $ip = \filter_var($_SERVER['REMOTE_ADDR'], \FILTER_VALIDATE_IP) ?: '0.0.0.0';
         $this->c->DB->exec('INSERT INTO ::users (group_id, username, password, signature) VALUES (?i, ?s, ?s, \'\')', [$this->c->GROUP_GUEST, __('Guest '), __('Guest ')]);
         $this->c->DB->exec('INSERT INTO ::users (group_id, username, password, signature) VALUES (?i, ?s, ?s, \'\')', [$this->c->GROUP_GUEST, __('Guest '), __('Guest ')]);
         $this->c->DB->exec('INSERT INTO ::users (group_id, username, password, email, email_normal, language, style, num_posts, last_post, registered, registration_ip, last_visit, signature, num_topics) VALUES (?i, ?s, ?s, ?s, ?s, ?s, ?s, 1, ?i, ?i, ?s, ?i, \'\', 1)', [$this->c->GROUP_ADMIN, $v->username, password_hash($v->password, \PASSWORD_DEFAULT), $v->email, $this->c->NormEmail->normalize($v->email), $v->defaultlang, $v->defaultstyle, $now, $now, $ip, $now]);
         $this->c->DB->exec('INSERT INTO ::users (group_id, username, password, email, email_normal, language, style, num_posts, last_post, registered, registration_ip, last_visit, signature, num_topics) VALUES (?i, ?s, ?s, ?s, ?s, ?s, ?s, 1, ?i, ?i, ?s, ?i, \'\', 1)', [$this->c->GROUP_ADMIN, $v->username, password_hash($v->password, \PASSWORD_DEFAULT), $v->email, $this->c->NormEmail->normalize($v->email), $v->defaultlang, $v->defaultstyle, $now, $now, $ip, $now]);
 
 

+ 1 - 7
app/Models/User/Current.php

@@ -109,13 +109,7 @@ class Current extends Action
      */
      */
     protected function getIp(): string
     protected function getIp(): string
     {
     {
-        $ip = \filter_var($_SERVER['REMOTE_ADDR'], \FILTER_VALIDATE_IP);
-
-        if (empty($ip)) {
-            throw new RuntimeException('Bad IP');
-        }
-
-        return $ip;
+        return \filter_var($_SERVER['REMOTE_ADDR'], \FILTER_VALIDATE_IP) ?: '0.0.0.0';
     }
     }
 
 
     /**
     /**