ip storage "fixes"

This commit is contained in:
flash 2017-03-22 20:56:43 +01:00
parent 3413efd825
commit 3eeca9767b
2 changed files with 21 additions and 3 deletions

View file

@ -190,6 +190,12 @@ class Post
// Create a topic object // Create a topic object
$topic = new Topic($this->topic); $topic = new Topic($this->topic);
try {
$ip = Net::pton($this->ip);
} catch (NetAddressTypeException $e) {
$ip = Net::pton("::1");
}
// Update the post // Update the post
DB::table('posts') DB::table('posts')
->where('post_id', $this->id) ->where('post_id', $this->id)
@ -197,7 +203,7 @@ class Post
'topic_id' => $topic->id, 'topic_id' => $topic->id,
'forum_id' => $topic->forum, 'forum_id' => $topic->forum,
'poster_id' => $this->poster->id, 'poster_id' => $this->poster->id,
'poster_ip' => Net::pton($this->ip), 'poster_ip' => $ip,
'post_time' => $this->time, 'post_time' => $this->time,
'post_subject' => $this->subject, 'post_subject' => $this->subject,
'post_text' => $this->text, 'post_text' => $this->text,

View file

@ -389,10 +389,16 @@ class User
} catch (NetAddressTypeException $e) { } catch (NetAddressTypeException $e) {
$this->registerIp = $userRow->register_ip; $this->registerIp = $userRow->register_ip;
try {
$reg_ip = Net::pton($this->registerIp);
} catch (NetAddressTypeException $e) {
$reg_ip = Net::pton("::1");
}
DB::table('users') DB::table('users')
->where('user_id', $this->id) ->where('user_id', $this->id)
->update([ ->update([
'register_ip' => Net::pton($this->registerIp), 'register_ip' => $reg_ip,
]); ]);
} }
@ -401,10 +407,16 @@ class User
} catch (NetAddressTypeException $e) { } catch (NetAddressTypeException $e) {
$this->lastIp = $userRow->last_ip; $this->lastIp = $userRow->last_ip;
try {
$last_ip = Net::pton($this->lastIp);
} catch (NetAddressTypeException $e) {
$last_ip = Net::pton("::1");
}
DB::table('users') DB::table('users')
->where('user_id', $this->id) ->where('user_id', $this->id)
->update([ ->update([
'last_ip' => Net::pton($this->lastIp), 'last_ip' => $last_ip,
]); ]);
} }
} }