}
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);
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++)
{
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;
}
//-----------------------------------------------------------------------------
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);
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)
mysql_close(sock);
return -1;
}
- stat->up[i] = traff;
+ stat->monthUp[i] = traff;
}//for
startPos += (2*DIR_NUM);
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;
}
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;
}