X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/0c80dbc4ce66a278eb5235420d34a469323efc6b..258b7ce79dba0c01b378e73bd6b8ee9fb1ae695d:/projects/stargazer/plugins/store/mysql/mysql_store.cpp diff --git a/projects/stargazer/plugins/store/mysql/mysql_store.cpp b/projects/stargazer/plugins/store/mysql/mysql_store.cpp index 11c2def3..995ed538 100644 --- a/projects/stargazer/plugins/store/mysql/mysql_store.cpp +++ b/projects/stargazer/plugins/store/mysql/mysql_store.cpp @@ -243,7 +243,7 @@ else } if (!ret) { - WriteServLog("MYSQL_STORE: Current DB schema version: %d", schemaVersion); + logger("MYSQL_STORE: Current DB schema version: %d", schemaVersion); MakeUpdates(sock); } mysql_close(sock); @@ -500,8 +500,13 @@ if(!IsTablePresent("users",sock)) res = "INSERT INTO users SET login='test',Address='',AlwaysOnline=0,"\ "Credit=0.0,CreditExpire=0,Down=0,Email='',DisabledDetailStat=0,"\ "StgGroup='',IP='192.168.1.1',Note='',Passive=0,Password='123456',"\ - "Phone='', RealName='',Tariff='tariff',TariffChange='',Userdata0='',"\ - "Userdata1='',"; + "Phone='', RealName='',Tariff='tariff',TariffChange='',NAS='',"; + + for (int i = 0; i < USERDATA_NUM; i++) + { + strprintf(¶m, " Userdata%d='',", i); + res += param; + } for (int i = 0; i < DIR_NUM; i++) { @@ -600,7 +605,7 @@ if (schemaVersion < 1) return -1; } schemaVersion = 1; - WriteServLog("MYSQL_STORE: Updated DB schema to version %d", schemaVersion); + logger("MYSQL_STORE: Updated DB schema to version %d", schemaVersion); } return 0; } @@ -676,9 +681,12 @@ return 0; //----------------------------------------------------------------------------- int MYSQL_STORE::AddUser(const std::string & login) const { -sprintf(qbuf,"INSERT INTO users SET login='%s'", login.c_str()); - -if(MysqlSetQuery(qbuf)) +std::string query = "INSERT INTO users SET login='" + login + "',Note='',NAS=''"; + +for (int i = 0; i < USERDATA_NUM; i++) + query += ",Userdata" + x2str(i) + "=''"; + +if(MysqlSetQuery(query.c_str())) { errorStr = "Couldn't add user:\n"; //errorStr += mysql_error(sock); @@ -903,7 +911,7 @@ for (int i = 0; i < DIR_NUM; i++) mysql_close(sock); return -1; } - stat->down[i] = traff; + stat->monthDown[i] = traff; sprintf(s, "U%d", i); if (GetULongLongInt(row[startPos+i*2+1], &traff, 0) != 0) @@ -913,7 +921,7 @@ for (int i = 0; i < DIR_NUM; i++) mysql_close(sock); return -1; } - stat->up[i] = traff; + stat->monthUp[i] = traff; }//for startPos += (2*DIR_NUM); @@ -1033,10 +1041,10 @@ res = "UPDATE users SET"; for (int i = 0; i < DIR_NUM; i++) { - strprintf(¶m, " D%d=%lld,", i, stat.down[i]); + strprintf(¶m, " D%d=%lld,", i, stat.monthDown[i]); res += param; - strprintf(¶m, " U%d=%lld,", i, stat.up[i]); + strprintf(¶m, " U%d=%lld,", i, stat.monthUp[i]); res += param; } @@ -1196,10 +1204,10 @@ strprintf(&res, "INSERT INTO stat SET login='%s', month=%d, year=%d,", for (int i = 0; i < DIR_NUM; i++) { - strprintf(¶m, " U%d=%lld,", i, stat.up[i]); + strprintf(¶m, " U%d=%lld,", i, stat.monthUp[i]); res += param; - strprintf(¶m, " D%d=%lld,", i, stat.down[i]); + strprintf(¶m, " D%d=%lld,", i, stat.monthDown[i]); res += param; }