diff --git a/app/Forum/Post.php b/app/Forum/Post.php index 067b68a..82db2f8 100644 --- a/app/Forum/Post.php +++ b/app/Forum/Post.php @@ -190,6 +190,12 @@ class Post // Create a topic object $topic = new Topic($this->topic); + try { + $ip = Net::pton($this->ip); + } catch (NetAddressTypeException $e) { + $ip = Net::pton("::1"); + } + // Update the post DB::table('posts') ->where('post_id', $this->id) @@ -197,7 +203,7 @@ class Post 'topic_id' => $topic->id, 'forum_id' => $topic->forum, 'poster_id' => $this->poster->id, - 'poster_ip' => Net::pton($this->ip), + 'poster_ip' => $ip, 'post_time' => $this->time, 'post_subject' => $this->subject, 'post_text' => $this->text, diff --git a/app/User.php b/app/User.php index af2aac9..9688dd6 100644 --- a/app/User.php +++ b/app/User.php @@ -389,10 +389,16 @@ class User } catch (NetAddressTypeException $e) { $this->registerIp = $userRow->register_ip; + try { + $reg_ip = Net::pton($this->registerIp); + } catch (NetAddressTypeException $e) { + $reg_ip = Net::pton("::1"); + } + DB::table('users') ->where('user_id', $this->id) ->update([ - 'register_ip' => Net::pton($this->registerIp), + 'register_ip' => $reg_ip, ]); } @@ -401,10 +407,16 @@ class User } catch (NetAddressTypeException $e) { $this->lastIp = $userRow->last_ip; + try { + $last_ip = Net::pton($this->lastIp); + } catch (NetAddressTypeException $e) { + $last_ip = Net::pton("::1"); + } + DB::table('users') ->where('user_id', $this->id) ->update([ - 'last_ip' => Net::pton($this->lastIp), + 'last_ip' => $last_ip, ]); } }