Well the process starts, that's a start

This commit is contained in:
calzoneman 2013-08-17 18:51:10 -05:00
parent f4b32ad3ad
commit 492a50fb96
5 changed files with 12 additions and 12 deletions

4
api.js
View File

@ -514,7 +514,7 @@ module.exports = function (Server) {
return; return;
} }
db.listUserChannels(name, function (err, res) { db.listUserChannels(name, function (err, dbres) {
if(err) { if(err) {
res.jsonp({ res.jsonp({
success: false, success: false,
@ -525,7 +525,7 @@ module.exports = function (Server) {
res.jsonp({ res.jsonp({
success: true, success: true,
channels: res channels: dbres
}); });
}); });
}); });

View File

@ -479,6 +479,7 @@ Channel.prototype.getIPRank = function (ip, callback) {
for(var i in self.ip_aliases[ip2]) for(var i in self.ip_aliases[ip2])
names.push(self.ip_aliases[ip2][i]); names.push(self.ip_aliases[ip2][i]);
} }
}
next(names); next(names);
} else { } else {
self.server.db.listAliases(ip, function (err, names) { self.server.db.listAliases(ip, function (err, names) {

View File

@ -24,6 +24,7 @@ var Database = function (cfg) {
this.pool.getConnection(function (err, conn) { this.pool.getConnection(function (err, conn) {
if(err) { if(err) {
Logger.errlog.log("! DB connection failed"); Logger.errlog.log("! DB connection failed");
return;
} }
conn.end(); conn.end();
}); });
@ -45,7 +46,6 @@ Database.prototype.query = function (query, sub, callback) {
self.pool.getConnection(function (err, conn) { self.pool.getConnection(function (err, conn) {
if(err) { if(err) {
callback("Database failure", null); callback("Database failure", null);
conn.end();
} else { } else {
function cback(err, res) { function cback(err, res) {
if(err) { if(err) {
@ -217,7 +217,7 @@ Database.prototype.init = function () {
}); });
// Refresh global IP bans // Refresh global IP bans
self.getGlobalIPBans(); self.listGlobalIPBans();
}; };
/* REGION global bans */ /* REGION global bans */

View File

@ -89,6 +89,10 @@ var Server = {
this.httpaccess.log([ipstr, req.method, url, status, req.headers["user-agent"]].join(" ")); this.httpaccess.log([ipstr, req.method, url, status, req.headers["user-agent"]].join(" "));
}, },
init: function () { init: function () {
// init database
var Database = require("./database");
this.db = new Database(this.cfg);
this.db.init();
this.actionlog = require("./actionlog")(this); this.actionlog = require("./actionlog")(this);
this.httpaccess = new Logger.Logger("httpaccess.log"); this.httpaccess = new Logger.Logger("httpaccess.log");
this.app = express(); this.app = express();
@ -202,10 +206,6 @@ var Server = {
new User(socket, this); new User(socket, this);
}.bind(this)); }.bind(this));
// init database
var Database = require("./database");
this.db = new Database(this.cfg);
this.db.init();
// init ACP // init ACP
this.acp = require("./acp")(this); this.acp = require("./acp")(this);

View File

@ -13,7 +13,6 @@ var Rank = require("./rank.js");
var Channel = require("./channel.js").Channel; var Channel = require("./channel.js").Channel;
var formatTime = require("./media.js").formatTime; var formatTime = require("./media.js").formatTime;
var Logger = require("./logger.js"); var Logger = require("./logger.js");
var self.server.actionlog = require("./actionlog");
// Represents a client connected via socket.io // Represents a client connected via socket.io
var User = function(socket, Server) { var User = function(socket, Server) {
@ -313,7 +312,7 @@ User.prototype.initCallbacks = function() {
self.socket.emit("searchResults", { self.socket.emit("searchResults", {
results: vids results: vids
}); });
} });
} }
} }
}.bind(this)); }.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.logger.log(self.ip + " signed in as " + name);
self.channel.broadcastNewUser(self); self.channel.broadcastNewUser(self);
} }
} });
} else { } else {
self.server.db.userLogin(name, pw, session, function (err, row) { self.server.db.userLogin(name, pw, session, function (err, row) {
if(err) { if(err) {