From ef3b6a24507411bac9ac87cf365a15d479c45f60 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 5 Dec 2014 13:07:13 -0500 Subject: [PATCH] closes #2498 --- src/posts/create.js | 5 +++++ src/socket.io/index.js | 2 +- src/topics/create.js | 2 +- src/views/admin/settings/post.tpl | 5 +++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/posts/create.js b/src/posts/create.js index 99c50ea813..d9040e443e 100644 --- a/src/posts/create.js +++ b/src/posts/create.js @@ -2,6 +2,7 @@ var async = require('async'), + meta = require('../meta'), db = require('../database'), plugins = require('../plugins'), user = require('../user'), @@ -46,6 +47,10 @@ module.exports = function(Posts) { postData.toPid = data.toPid; } + if (data.ip && parseInt(meta.config.trackIpPerPost, 10) === 1) { + postData.ip = data.ip; + } + plugins.fireHook('filter:post.save', postData, next); }, function(postData, next) { diff --git a/src/socket.io/index.js b/src/socket.io/index.js index a0e0c1a150..0a49982d3f 100644 --- a/src/socket.io/index.js +++ b/src/socket.io/index.js @@ -250,7 +250,7 @@ Sockets.reqFromSocket = function(socket) { referer = headers.referer || ''; return { - ip: socket.ip, + ip: headers['x-forwarded-for'] || socket.ip, host: host, protocol: socket.request.connection.encrypted ? 'https' : 'http', secure: !!socket.request.connection.encrypted, diff --git a/src/topics/create.js b/src/topics/create.js index d1b2428e0c..76d905a1f0 100644 --- a/src/topics/create.js +++ b/src/topics/create.js @@ -226,7 +226,7 @@ module.exports = function(Topics) { checkContentLength(content, next); }, function(next) { - posts.create({uid: uid, tid: tid, content: content, toPid: toPid}, next); + posts.create({uid: uid, tid: tid, content: content, toPid: toPid, ip: data.req.ip}, next); }, function(data, next) { postData = data; diff --git a/src/views/admin/settings/post.tpl b/src/views/admin/settings/post.tpl index 2af1117c10..122b2cdf0c 100644 --- a/src/views/admin/settings/post.tpl +++ b/src/views/admin/settings/post.tpl @@ -41,6 +41,11 @@ +
+ +