Commit 5438bec5 authored by 邓军's avatar 邓军

添加log的IP 和userAgen

parent e192c05c
......@@ -49,13 +49,34 @@ router.get('/info/:fid/get', function(req, res, next) {
openId: '54c9e321d5037010b44d4b1f',
userId: '54c9e321d5037010b44d4b1f'
};*/
var ip = '';
var userAgent = '';
var getClientIP = function(req) {
var ipAddress;
var headers = req.headers;
var forwardedIpsStr = headers['x-real-ip'] || headers['x-forwarded-for'];
if (forwardedIpsStr) {
ipAddress = forwardedIpsStr;
} else {
ipAddress = null;
}
if (!ipAddress) {
ipAddress = req.connection.remoteAddress;
}
return ipAddress;
};
ip = getClientIP(req);
userAgent = req.headers['user-agent'];
var log = {
ent_code: req.session.user,
mid: req.session.openUser.mid,
forumInfo: fid,
open_id: req.session.mobileForumUser.openId,
user: req.session.mobileForumUser.userId,
type: 2
type: 2,
ip: ip,
userAgent: userAgent
};
httpService.createLog(log);
......@@ -213,7 +234,7 @@ router.get('/info/:fid/hotThreads', function(req, res, next) {
};
if (fid) {
async.waterfall([
function(callback) {
forumUserThreadControlService.getUserThreadControlById(user.getMobileUser(req), function(err, doc) {
......@@ -267,7 +288,7 @@ router.get('/info/:fid/photoThreads', function(req, res, next) {
};
if (fid) {
async.waterfall([
function(callback) {
forumUserThreadControlService.getUserThreadControlById(user.getMobileUser(req), function(err, doc) {
......@@ -320,7 +341,7 @@ router.get('/info/:fid/myThreads', function(req, res, next) {
};
if (fid) {
async.waterfall([
function(callback) {
forumUserThreadControlService.getUserThreadControlById(user.getMobileUser(req), function(err, doc) {
......@@ -381,7 +402,7 @@ router.get('/info/:fid/serachThreads', function(req, res, next) {
}
if (fid) {
async.waterfall([
function(callback) {
forumUserThreadControlService.getUserThreadControlById(user.getMobileUser(req), function(err, doc) {
......
......@@ -108,6 +108,26 @@ router.get('/thread/:tid/get', function(req, res, next) {
},
function(data, callback) {
forumThreadService.getThreadById(tid, function(err, thread) {
var ip = '';
var userAgent = '';
var getClientIP = function(req) {
var ipAddress;
var headers = req.headers;
var forwardedIpsStr = headers['x-real-ip'] || headers['x-forwarded-for'];
if (forwardedIpsStr) {
ipAddress = forwardedIpsStr;
} else {
ipAddress = null;
}
if (!ipAddress) {
ipAddress = req.connection.remoteAddress;
}
return ipAddress;
};
ip = getClientIP(req);
userAgent = req.headers['user-agent'];
var log = {
ent_code: req.session.user,
mid: req.session.openUser.mid,
......@@ -115,19 +135,21 @@ router.get('/thread/:tid/get', function(req, res, next) {
open_id: req.session.mobileForumUser.openId,
user: req.session.mobileForumUser.userId,
type: 3,
thread_type: 2
thread_type: 2,
ip:ip,
userAgent: userAgent
};
if (thread.type == 1) {
log.thread_type = 2;
log.thread_type = 2;
httpService.createLog(log);
}else if(thread.type==2&&thread.level==1){
log.thread_type = 1;
} else if (thread.type == 2 && thread.level == 1) {
log.thread_type = 1;
httpService.createLog(log);
}else if(thread.type==2&&thread.level==2){
log.thread_type = 4;
} else if (thread.type == 2 && thread.level == 2) {
log.thread_type = 4;
httpService.createLog(log);
}else if(thread.type==3){
log.thread_type = 3;
} else if (thread.type == 3) {
log.thread_type = 3;
httpService.createLog(log);
}
if (err) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment