display ips to admins/users on profile

This commit is contained in:
Baris Soner Usakli
2014-02-25 17:34:42 -05:00
parent de3bc84fde
commit 1ba3acfd03
4 changed files with 24 additions and 3 deletions

View File

@@ -65,6 +65,7 @@
"in": "in",
"recentposts": "Recent Posts",
"recentips": "Recently Logged In IPs",
"online": "Online",
"away": "Away",

View File

@@ -108,6 +108,18 @@
</div>
</div>
<!-- IF ips.length -->
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">[[global:recentips]]</h3>
</div>
<div class="panel-body">
<!-- BEGIN ips -->
{ips.ip}
<!-- END ips -->
</div>
</div>
<!-- ENDIF ips.length -->
</div>

View File

@@ -593,7 +593,7 @@ var fs = require('fs'),
user.getFollowStats(uid, next);
},
ips: function(next) {
user.getIPs(uid, next);
user.getIPs(uid, 4, next);
}
}, function(err, results) {
if(err || !results.userData) {

View File

@@ -968,8 +968,16 @@ var bcrypt = require('bcryptjs'),
db.sortedSetAdd('uid:' + uid + ':ip', +new Date(), ip || 'Unknown');
};
User.getIPs = function(uid, callback) {
db.getSortedSetRevRange('uid:' + uid + ':ip', 0, 5, callback);
User.getIPs = function(uid, end, callback) {
db.getSortedSetRevRange('uid:' + uid + ':ip', 0, end, function(err, ips) {
if(err) {
return callback(err);
}
callback(null, ips.map(function(ip) {
return {ip:ip};
}));
});
};
User.email = {