mirror of https://github.com/calzoneman/sync.git
Merge branch 'dev' of github.com:calzoneman/sync into dev
This commit is contained in:
commit
e47c1abff7
6
acp.js
6
acp.js
|
@ -150,6 +150,12 @@ module.exports = function (Server) {
|
|||
}
|
||||
});
|
||||
|
||||
user.socket.on("acp-actionlog-list", function () {
|
||||
user.socket.emit("acp-actionlog-list",
|
||||
ActionLog.getLogTypes()
|
||||
);
|
||||
});
|
||||
|
||||
user.socket.on("acp-actionlog-clear", function(data) {
|
||||
ActionLog.clear(data);
|
||||
ActionLog.record(user.ip, user.name, "acp-actionlog-clear", data);
|
||||
|
|
32
actionlog.js
32
actionlog.js
|
@ -105,12 +105,42 @@ exports.tooManyRegistrations = function (ip) {
|
|||
return rows.length > 4;
|
||||
}
|
||||
|
||||
exports.readLog = function () {
|
||||
exports.getLogTypes = function () {
|
||||
var db = Database.getConnection();
|
||||
if(!db)
|
||||
return false;
|
||||
|
||||
var query = "SELECT DISTINCT action FROM actionlog";
|
||||
var result = db.querySync(query);
|
||||
if(!result) {
|
||||
Logger.errlog.log("! Failed to read action log");
|
||||
return [];
|
||||
}
|
||||
|
||||
result = result.fetchAllSync();
|
||||
var actions = [];
|
||||
for(var i in result)
|
||||
actions.push(result[i].action);
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
exports.readLog = function (actions) {
|
||||
var db = Database.getConnection();
|
||||
if(!db)
|
||||
return false;
|
||||
|
||||
var query = "SELECT * FROM actionlog";
|
||||
if(actions !== undefined) {
|
||||
var list = new Array(actions.length);
|
||||
for(var i in actions)
|
||||
list[i] = "?";
|
||||
list = list.join(",");
|
||||
query += Database.createQuery(
|
||||
" WHERE action IN ("+list+")",
|
||||
actions
|
||||
);
|
||||
}
|
||||
var result = db.querySync(query);
|
||||
if(!result) {
|
||||
Logger.errlog.log("! Failed to read action log");
|
||||
|
|
7
api.js
7
api.js
|
@ -189,7 +189,8 @@ module.exports = function (Server) {
|
|||
|
||||
var row = Auth.login(name, pw, session);
|
||||
if(row) {
|
||||
ActionLog.record(getIP(req), name, "login-success");
|
||||
if(row.global_rank >= 255)
|
||||
ActionLog.record(getIP(req), name, "login-success");
|
||||
this.sendJSON(res, {
|
||||
success: true,
|
||||
session: row.session_hash
|
||||
|
@ -510,13 +511,15 @@ module.exports = function (Server) {
|
|||
var name = params.name || "";
|
||||
var pw = params.pw || "";
|
||||
var session = params.session || "";
|
||||
var types = params.actions || "";
|
||||
var row = Auth.login(name, pw, session);
|
||||
if(!row || row.global_rank < 255) {
|
||||
res.send(403);
|
||||
return;
|
||||
}
|
||||
|
||||
var actions = ActionLog.readLog();
|
||||
var actiontypes = types.split(",");
|
||||
var actions = ActionLog.readLog(actiontypes);
|
||||
this.sendJSON(res, actions);
|
||||
},
|
||||
|
||||
|
|
3
user.js
3
user.js
|
@ -626,7 +626,8 @@ User.prototype.login = function(name, pw, session) {
|
|||
}
|
||||
}
|
||||
}
|
||||
ActionLog.record(this.ip, name, "login-success");
|
||||
if(this.global_rank >= 255)
|
||||
ActionLog.record(this.ip, name, "login-success");
|
||||
this.loggedIn = true;
|
||||
this.socket.emit("login", {
|
||||
success: true,
|
||||
|
|
|
@ -154,7 +154,12 @@ html, body {
|
|||
border-left: 0;
|
||||
}
|
||||
|
||||
#messagebuffer div, #messagebuffer code, #filteredit code {
|
||||
#channeldata td {
|
||||
max-width: 200px;
|
||||
}
|
||||
|
||||
#messagebuffer div, #messagebuffer code, #filteredit code,
|
||||
#channeldata td {
|
||||
white-space: pre-wrap; /* css-3 */
|
||||
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
|
||||
white-space: -pre-wrap; /* Opera 4-6 */
|
||||
|
|
|
@ -88,40 +88,10 @@ $("#listloaded_refresh").click(function() {
|
|||
socket.emit("acp-list-loaded");
|
||||
});
|
||||
menuHandler("#show_actionlog", "#actionlog");
|
||||
$("#show_actionlog").click(getActionLog);
|
||||
$("#actionlog_filter").click(function() {
|
||||
var tbl = $("#actionlog table");
|
||||
var actions = $(this).val();
|
||||
$("#actionlog tbody").remove();
|
||||
var entries = [];
|
||||
tbl.data("allentries").forEach(function(e) {
|
||||
if(actions.indexOf(e.action) == -1)
|
||||
return;
|
||||
entries.push(e);
|
||||
});
|
||||
$("#actionlog_pagination").remove();
|
||||
if(entries.length > 20) {
|
||||
var pag = $("<div/>").addClass("pagination")
|
||||
.attr("id", "actionlog_pagination")
|
||||
.insertAfter($("#actionlog table"));
|
||||
var btns = $("<ul/>").appendTo(pag);
|
||||
for(var i = 0; i < entries.length / 20; i++) {
|
||||
var li = $("<li/>").appendTo(btns);
|
||||
(function(i) {
|
||||
$("<a/>").attr("href", "javascript:void(0)")
|
||||
.text(i+1)
|
||||
.click(function() {
|
||||
loadPage(tbl, i);
|
||||
})
|
||||
.appendTo(li);
|
||||
})(i);
|
||||
}
|
||||
tbl.data("pagination", pag);
|
||||
}
|
||||
|
||||
$("#actionlog table").data("entries", entries);
|
||||
loadPage($("#actionlog table"), 0);
|
||||
$("#show_actionlog").click(function () {
|
||||
socket.emit("acp-actionlog-list");
|
||||
});
|
||||
$("#actionlog_filter").click(getActionLog);
|
||||
$("#actionlog_searchbtn").click(function() {
|
||||
var tbl = $("#actionlog table");
|
||||
$("#actionlog tbody").remove();
|
||||
|
@ -169,9 +139,11 @@ $("#actionlog_searchbtn").click(function() {
|
|||
});
|
||||
$("#actionlog_clear").click(function() {
|
||||
socket.emit("acp-actionlog-clear", $("#actionlog_filter").val());
|
||||
socket.emit("acp-actionlog-list");
|
||||
getActionLog();
|
||||
});
|
||||
$("#actionlog_refresh").click(function() {
|
||||
socket.emit("acp-actionlog-list");
|
||||
getActionLog();
|
||||
});
|
||||
$("#actionlog_ip").click(function() {
|
||||
|
@ -211,12 +183,31 @@ function getErrlog() {
|
|||
}
|
||||
$("#errlog").click(getErrlog);
|
||||
function getActionLog() {
|
||||
$.getJSON(WEB_URL+"/api/json/readactionlog?"+AUTH+"&callback=?").done(function(data) {
|
||||
var entries = data;
|
||||
var actions = [];
|
||||
var types = "&actions=" + $("#actionlog_filter").val().join(",");
|
||||
$.getJSON(WEB_URL+"/api/json/readactionlog?"+AUTH+types+"&callback=?").done(function(entries) {
|
||||
var tbl = $("#actionlog table");
|
||||
$("#actionlog tbody").remove();
|
||||
$("#actionlog_pagination").remove();
|
||||
if(entries.length > 20) {
|
||||
var pag = $("<div/>").addClass("pagination")
|
||||
.attr("id", "actionlog_pagination")
|
||||
.insertAfter($("#actionlog table"));
|
||||
var btns = $("<ul/>").appendTo(pag);
|
||||
for(var i = 0; i < entries.length / 20; i++) {
|
||||
var li = $("<li/>").appendTo(btns);
|
||||
(function(i) {
|
||||
$("<a/>").attr("href", "javascript:void(0)")
|
||||
.text(i+1)
|
||||
.click(function() {
|
||||
loadPage(tbl, i);
|
||||
})
|
||||
.appendTo(li);
|
||||
})(i);
|
||||
}
|
||||
tbl.data("pagination", pag);
|
||||
}
|
||||
|
||||
entries.forEach(function (e) {
|
||||
if(actions.indexOf(e.action) == -1)
|
||||
actions.push(e.action);
|
||||
e.time = parseInt(e.time);
|
||||
});
|
||||
var tbl = $("#actionlog table");
|
||||
|
@ -243,15 +234,7 @@ function getActionLog() {
|
|||
$("<td/>").text(e.args).appendTo(tr);
|
||||
$("<td/>").text(new Date(e.time).toString()).appendTo(tr);
|
||||
});
|
||||
$("#actionlog table").data("entries", entries);
|
||||
$("#actionlog_filter").html("");
|
||||
actions.sort(function(a, b) {
|
||||
return a == b ? 0 : (a < b ? -1 : 1);
|
||||
});
|
||||
actions.forEach(function(a) {
|
||||
$("<option/>").text(a).val(a).appendTo($("#actionlog_filter"));
|
||||
});
|
||||
tbl.find("tbody").remove();
|
||||
loadPage($("#actionlog table"), 0);
|
||||
});
|
||||
}
|
||||
function getChanlog() {
|
||||
|
@ -572,6 +555,16 @@ function setupCallbacks() {
|
|||
new Chart($("#stat_channels")[0].getContext("2d")).Line(chan_data);
|
||||
new Chart($("#stat_mem")[0].getContext("2d")).Line(mem_data);
|
||||
});
|
||||
|
||||
socket.on("acp-actionlog-list", function (alist) {
|
||||
$("#actionlog_filter").html("");
|
||||
alist.sort(function(a, b) {
|
||||
return a == b ? 0 : (a < b ? -1 : 1);
|
||||
});
|
||||
alist.forEach(function(a) {
|
||||
$("<option/>").text(a).val(a).appendTo($("#actionlog_filter"));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* cookie util */
|
||||
|
|
Loading…
Reference in New Issue