From 2fba686904e6f78ebab35df171c5757afeebf05d Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 24 May 2010 23:36:40 -0500 Subject: Burned slist, rewrote operservs XLine code --- src/modules/mysql/db_mysql_read.cpp | 57 +++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 24 deletions(-) (limited to 'src/modules/mysql/db_mysql_read.cpp') diff --git a/src/modules/mysql/db_mysql_read.cpp b/src/modules/mysql/db_mysql_read.cpp index 1b4ce33fa..3c5fb359a 100644 --- a/src/modules/mysql/db_mysql_read.cpp +++ b/src/modules/mysql/db_mysql_read.cpp @@ -620,42 +620,51 @@ static void LoadDatabase() query << "SELECT * FROM `anope_os_akills`"; qres = StoreQuery(query); - if (qres) + if (qres && SGLine) { for (size_t i = 0; i < qres.size(); ++i) { - Akill *ak = new Akill; - ak->user = sstrdup(qres[i]["user"].c_str()); - ak->host = sstrdup(qres[i]["host"].c_str()); - ak->by = sstrdup(qres[i]["xby"].c_str()); - ak->reason = sstrdup(qres[i]["reason"].c_str()); - ak->seton = atol(qres[i]["seton"].c_str()); - ak->expires = atol(qres[i]["expire"].c_str()); - slist_add(&akills, ak); + ci::string user = qres[i]["user"].c_str(); + ci::string host = qres[i]["host"].c_str(); + ci::string by = qres[i]["xby"].c_str(); + std::string reason = SQLAssign(qres[i]["reason"]); + time_t seton = atol(qres[i]["seton"].c_str()); + time_t expires = atol(qres[i]["expire"].c_str()); + + XLine *x = SGLine->Add(NULL, NULL, user + "@" + host, expires, reason); + if (x) + { + x->By = by; + x->Created = seton; + } } } - query << "SELECT * FROM `anope_os_sxlines`"; + query << "SELECT * FROM `anope_os_xlines`"; qres = StoreQuery(query); if (qres) { for (size_t i = 0; i < qres.size(); ++i) { - SXLine *sx = new SXLine; - sx->mask = sstrdup(qres[i]["mask"].c_str()); - sx->by = sstrdup(qres[i]["xby"].c_str()); - sx->reason = sstrdup(qres[i]["reason"].c_str()); - sx->seton = atol(qres[i]["seton"].c_str()); - sx->expires = atol(qres[i]["expires"].c_str()); - if (qres[i]["type"] == "SGLINE") - slist_add(&sglines, sx); - else if (qres[i]["type"] == "SQLINE") - slist_add(&sqlines, sx); - else if (qres[i]["type"] == "SZLINE") - slist_add(&szlines, sx); - else - delete sx; + ci::string mask = qres[i]["mask"].c_str(); + ci::string by = qres[i]["xby"].c_str(); + std::string reason = SQLAssign(qres[i]["reason"]); + time_t seton = atol(qres[i]["seton"].c_str()); + time_t expires = atol(qres[i]["expires"].c_str()); + + XLine *x = NULL; + if (qres[i]["type"] == "SNLINE" && SNLine) + x = SNLine->Add(NULL, NULL, mask, expires, reason); + else if (qres[i]["type"] == "SQLINE" && SQLine) + x = SQLine->Add(NULL, NULL, mask, expires, reason); + else if (qres[i]["type"] == "SZLINE" && SZLine) + x = SZLine->Add(NULL, NULL,mask, expires, reason); + if (x) + { + x->By = by; + x->Created = seton; + } } } } -- cgit