From 492a50fb963e2138fef7fb53315e2883b9b27320 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sat, 17 Aug 2013 18:51:10 -0500 Subject: [PATCH] Well the process starts, that's a start --- api.js | 4 ++-- channel.js | 3 ++- database.js | 4 ++-- server.js | 8 ++++---- user.js | 5 ++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/api.js b/api.js index 96654562..58735f83 100644 --- a/api.js +++ b/api.js @@ -514,7 +514,7 @@ module.exports = function (Server) { return; } - db.listUserChannels(name, function (err, res) { + db.listUserChannels(name, function (err, dbres) { if(err) { res.jsonp({ success: false, @@ -525,7 +525,7 @@ module.exports = function (Server) { res.jsonp({ success: true, - channels: res + channels: dbres }); }); }); diff --git a/channel.js b/channel.js index ee9feab3..7bf92123 100644 --- a/channel.js +++ b/channel.js @@ -478,9 +478,10 @@ Channel.prototype.getIPRank = function (ip, callback) { if(ip2.indexOf(ip) == 0) { for(var i in self.ip_aliases[ip2]) names.push(self.ip_aliases[ip2][i]); + } } next(names); - } else{ + } else { self.server.db.listAliases(ip, function (err, names) { self.ip_alias[ip] = names; next(names); diff --git a/database.js b/database.js index 4186e056..2104dc1e 100644 --- a/database.js +++ b/database.js @@ -24,6 +24,7 @@ var Database = function (cfg) { this.pool.getConnection(function (err, conn) { if(err) { Logger.errlog.log("! DB connection failed"); + return; } conn.end(); }); @@ -45,7 +46,6 @@ Database.prototype.query = function (query, sub, callback) { self.pool.getConnection(function (err, conn) { if(err) { callback("Database failure", null); - conn.end(); } else { function cback(err, res) { if(err) { @@ -217,7 +217,7 @@ Database.prototype.init = function () { }); // Refresh global IP bans - self.getGlobalIPBans(); + self.listGlobalIPBans(); }; /* REGION global bans */ diff --git a/server.js b/server.js index 5cecd78a..2bc42bf1 100644 --- a/server.js +++ b/server.js @@ -89,6 +89,10 @@ var Server = { this.httpaccess.log([ipstr, req.method, url, status, req.headers["user-agent"]].join(" ")); }, init: function () { + // init database + var Database = require("./database"); + this.db = new Database(this.cfg); + this.db.init(); this.actionlog = require("./actionlog")(this); this.httpaccess = new Logger.Logger("httpaccess.log"); this.app = express(); @@ -202,10 +206,6 @@ var Server = { new User(socket, this); }.bind(this)); - // init database - var Database = require("./database"); - this.db = new Database(this.cfg); - this.db.init(); // init ACP this.acp = require("./acp")(this); diff --git a/user.js b/user.js index a078e2e7..1ef9130a 100644 --- a/user.js +++ b/user.js @@ -13,7 +13,6 @@ var Rank = require("./rank.js"); var Channel = require("./channel.js").Channel; var formatTime = require("./media.js").formatTime; var Logger = require("./logger.js"); -var self.server.actionlog = require("./actionlog"); // Represents a client connected via socket.io var User = function(socket, Server) { @@ -313,7 +312,7 @@ User.prototype.initCallbacks = function() { self.socket.emit("searchResults", { results: vids }); - } + }); } } }.bind(this)); @@ -600,7 +599,7 @@ User.prototype.login = function(name, pw, session) { self.channel.logger.log(self.ip + " signed in as " + name); self.channel.broadcastNewUser(self); } - } + }); } else { self.server.db.userLogin(name, pw, session, function (err, row) { if(err) {