diff --git a/acp.js b/acp.js index 899a058a..e5993ab6 100644 --- a/acp.js +++ b/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); diff --git a/actionlog.js b/actionlog.js index e5c18df4..312a2f74 100644 --- a/actionlog.js +++ b/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"); diff --git a/api.js b/api.js index 03d8ed2c..3f9dfc25 100644 --- a/api.js +++ b/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); }, diff --git a/user.js b/user.js index 80d76f1c..d5637b67 100644 --- a/user.js +++ b/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, diff --git a/www/assets/css/ytsync.css b/www/assets/css/ytsync.css index c9f9025d..e493e2b3 100644 --- a/www/assets/css/ytsync.css +++ b/www/assets/css/ytsync.css @@ -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 */ diff --git a/www/assets/js/acp.js b/www/assets/js/acp.js index b8a70779..fe9595e7 100644 --- a/www/assets/js/acp.js +++ b/www/assets/js/acp.js @@ -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 = $("
").addClass("pagination") - .attr("id", "actionlog_pagination") - .insertAfter($("#actionlog table")); - var btns = $("