From 3eeca9767bf85f3e75787862da2e66d0d851e49d Mon Sep 17 00:00:00 2001 From: flashwave Date: Wed, 22 Mar 2017 20:56:43 +0100 Subject: [PATCH] ip storage "fixes" --- app/Forum/Post.php | 8 +++++++- app/User.php | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) 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, ]); } }