Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pisns-forum-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
scrmGroup
pisns-forum-api
Commits
5438bec5
Commit
5438bec5
authored
Apr 17, 2015
by
邓军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加log的IP 和userAgen
parent
e192c05c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
13 deletions
+56
-13
forumInfo.js
app/controllers/mobile/forumInfo.js
+26
-5
forumThread.js
app/controllers/mobile/forumThread.js
+30
-8
No files found.
app/controllers/mobile/forumInfo.js
View file @
5438bec5
...
...
@@ -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
)
{
...
...
app/controllers/mobile/forumThread.js
View file @
5438bec5
...
...
@@ -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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment