module.exports = function()
{
var config = require("./configure.js");
- var MySQLPool = new require("./mysql_pool.js");
- var pool = new MySQLPool({
- host : config.db_host,
- user : config.db_user,
- password : config.db_password,
- port : config.db_port,
- database : config.db_name,
- });
+ var IpBanModel = require("./init").GetIpBanColletion;
var collection = {};
this.IsBaned = function(ip){
return collection[ip] == "r";
var async = require("async");
async.waterfall([
function(next){
- pool.query("TRUNCATE TABLE ipbanlist",null,next);
+ IpBanModel.drop().done(next);
},
function(result,next){
var items = new Array();
collection[ip] = token[1];
items.push(new Array(ip,collection[ip]));
}
- pool.query("INSERT INTO ipbanlist VALUES ?",[items],next);
+ newIpBan = IpBanModel.build(items);
+ newIpBan.save().done(next);
},
],callfunc);
}
var async = require("async");
async.waterfall([
function(next){
- pool.query("SELECT * FROM ipbanlist",null,next);
+ IpBanModel.findAll().done(next);
},
function(result,next){
for(var i = 0; i < result.length; i++)