source.replace(pos, 1,1, chgsym);
return source;
}
source.replace(pos, 1,1, chgsym);
return source;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-int MYSQL_STORE_SETTINGS::ParseParam(const vector<PARAM_VALUE> & moduleParams,
- const string & name, string & result)
+int MYSQL_STORE_SETTINGS::ParseParam(const std::vector<PARAM_VALUE> & moduleParams,
+ const std::string & name, std::string & result)
pvi = find(moduleParams.begin(), moduleParams.end(), pv);
if (pvi == moduleParams.end())
{
pvi = find(moduleParams.begin(), moduleParams.end(), pv);
if (pvi == moduleParams.end())
{
//-----------------------------------------------------------------------------
int MYSQL_STORE::MysqlQuery(const char* sQuery,MYSQL * sock) const
{
//-----------------------------------------------------------------------------
int MYSQL_STORE::MysqlQuery(const char* sQuery,MYSQL * sock) const
{
if (!(sock = mysql_real_connect(&mysql,storeSettings.GetDBHost().c_str(),
storeSettings.GetDBUser().c_str(),storeSettings.GetDBPassword().c_str(),
0,0,NULL,0)))
if (!(sock = mysql_real_connect(&mysql,storeSettings.GetDBHost().c_str(),
storeSettings.GetDBUser().c_str(),storeSettings.GetDBPassword().c_str(),
0,0,NULL,0)))
}
//-----------------------------------------------------------------------------
int MYSQL_STORE::CheckAllTables(MYSQL * sock)
}
//-----------------------------------------------------------------------------
int MYSQL_STORE::CheckAllTables(MYSQL * sock)
if(!IsTablePresent("tariffs",sock))
{
res = "CREATE TABLE tariffs (name VARCHAR(40) DEFAULT '' PRIMARY KEY,";
if(!IsTablePresent("tariffs",sock))
{
res = "CREATE TABLE tariffs (name VARCHAR(40) DEFAULT '' PRIMARY KEY,";
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',"\
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;
+ }
-int MYSQL_STORE::GetAllParams(vector<string> * ParamList,
- const string & table, const string & name) const
+int MYSQL_STORE::GetAllParams(std::vector<std::string> * ParamList,
+ const std::string & table, const std::string & name) 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()))
query = "SELECT login, Password, Passive, Down, DisabledDetailStat, \
AlwaysOnline, Tariff, Address, Phone, Email, Note, \
query = "SELECT login, Password, Passive, Down, DisabledDetailStat, \
AlwaysOnline, Tariff, Address, Phone, Email, Note, \
strprintf(&res,"UPDATE users SET Password='%s', Passive=%d, Down=%d, DisabledDetailStat = %d, "\
"AlwaysOnline=%d, Tariff='%s', Address='%s', Phone='%s', Email='%s', "\
strprintf(&res,"UPDATE users SET Password='%s', Passive=%d, Down=%d, DisabledDetailStat = %d, "\
"AlwaysOnline=%d, Tariff='%s', Address='%s', Phone='%s', Email='%s', "\
strprintf(¶m, " CreditExpire=%d,", conf.creditExpire);
res += param;
strprintf(¶m, " CreditExpire=%d,", conf.creditExpire);
res += param;
- strprintf(¶m, " D%d=%lld,", i, stat.down[i]);
+ strprintf(¶m, " D%d=%lld,", i, stat.monthDown[i]);
- strprintf(¶m, " U%d=%lld,", i, stat.up[i]);
+ strprintf(¶m, " U%d=%lld,", i, stat.monthUp[i]);
strprintf(&res, "%s -- %s",LogDate(t), str.c_str());
strprintf(&res, "%s -- %s",LogDate(t), str.c_str());
strprintf(&send,"INSERT INTO logs_%02d_%4d SET login='%s', text='%s'",
lt->tm_mon+1, lt->tm_year+1900,
strprintf(&send,"INSERT INTO logs_%02d_%4d SET login='%s', text='%s'",
lt->tm_mon+1, lt->tm_year+1900,
-int MYSQL_STORE::WriteUserChgLog(const string & login,
- const string & admLogin,
+int MYSQL_STORE::WriteUserChgLog(const std::string & login,
+ const std::string & admLogin,
- const string & paramName,
- const string & oldValue,
- const string & newValue,
- const string & message) const
+ const std::string & paramName,
+ const std::string & oldValue,
+ const std::string & newValue,
+ const std::string & message) const
+ paramName + "\' parameter changed from \'" + oldValue +
"\' to \'" + newValue + "\'. " + message;
return WriteLogString(userLogMsg, login);
}
//-----------------------------------------------------------------------------
+ paramName + "\' parameter changed from \'" + oldValue +
"\' to \'" + newValue + "\'. " + message;
return WriteLogString(userLogMsg, login);
}
//-----------------------------------------------------------------------------
return WriteLogString(logStr, login);
}
//-----------------------------------------------------------------------------
return WriteLogString(logStr, login);
}
//-----------------------------------------------------------------------------
const DIR_TRAFF & up,
const DIR_TRAFF & down,
const DIR_TRAFF & sessionUp,
const DIR_TRAFF & sessionDown,
double cash,
const DIR_TRAFF & up,
const DIR_TRAFF & down,
const DIR_TRAFF & sessionUp,
const DIR_TRAFF & sessionDown,
double cash,
-string logStr = "Disconnect, ";
-stringstream sssu;
-stringstream sssd;
-stringstream ssmu;
-stringstream ssmd;
-stringstream sscash;
+std::string logStr = "Disconnect, ";
+std::ostringstream sssu;
+std::ostringstream sssd;
+std::ostringstream ssmu;
+std::ostringstream ssmd;
+std::ostringstream sscash;
}
//-----------------------------------------------------------------------------
int MYSQL_STORE::SaveMonthStat(const USER_STAT & stat, int month, int year,
}
//-----------------------------------------------------------------------------
int MYSQL_STORE::SaveMonthStat(const USER_STAT & stat, int month, int year,
strprintf(&res, "INSERT INTO stat SET login='%s', month=%d, year=%d,",
login.c_str(), month+1, year+1900);
for (int i = 0; i < DIR_NUM; i++)
{
strprintf(&res, "INSERT INTO stat SET login='%s', month=%d, year=%d,",
login.c_str(), month+1, year+1900);
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]);
- strprintf(¶m, " D%d=%lld,", i, stat.down[i]);
+ strprintf(¶m, " D%d=%lld,", i, stat.monthDown[i]);
strncpy(adminPass, ac.password.c_str(), ADM_PASSWD_LEN);
adminPass[ADM_PASSWD_LEN - 1] = 0;
for (int i = 0; i < ADM_PASSWD_LEN/8; i++)
{
strncpy(adminPass, ac.password.c_str(), ADM_PASSWD_LEN);
adminPass[ADM_PASSWD_LEN - 1] = 0;
for (int i = 0; i < ADM_PASSWD_LEN/8; i++)
{
{
char pass[ADM_PASSWD_LEN + 1];
char password[ADM_PASSWD_LEN + 1];
char passwordE[2*ADM_PASSWD_LEN + 2];
BLOWFISH_CTX ctx;
{
char pass[ADM_PASSWD_LEN + 1];
char password[ADM_PASSWD_LEN + 1];
char passwordE[2*ADM_PASSWD_LEN + 2];
BLOWFISH_CTX ctx;
for (int i = 0; i<DIR_NUM; i++)
{
strprintf(¶m, "Time%d", i);
for (int i = 0; i<DIR_NUM; i++)
{
strprintf(¶m, "Time%d", i);
td->dirPrice[i].priceNightB /= (1024*1024);
strprintf(¶m, "Threshold%d", i);
td->dirPrice[i].priceNightB /= (1024*1024);
strprintf(¶m, "Threshold%d", i);
strprintf(¶m, " Time%d", i);
strprintf(&s, "%0d:%0d-%0d:%0d",
strprintf(¶m, " Time%d", i);
strprintf(&s, "%0d:%0d-%0d:%0d",
-string res, stTime, endTime, tempStr;
+std::string res, stTime, endTime, tempStr;
sprintf(qbuf,"INSERT INTO messages SET login='%s', id=%lld",
login.c_str(),
sprintf(qbuf,"INSERT INTO messages SET login='%s', id=%lld",
login.c_str(),
return EditMessage(*msg, login);
}
//-----------------------------------------------------------------------------
return EditMessage(*msg, login);
}
//-----------------------------------------------------------------------------
strprintf(&res,"UPDATE messages SET type=%d, lastSendTime=%u, creationTime=%u, "\
"showTime=%u, stgRepeat=%d, repeatPeriod=%u, text='%s' "\
strprintf(&res,"UPDATE messages SET type=%d, lastSendTime=%u, creationTime=%u, "\
"showTime=%u, stgRepeat=%d, repeatPeriod=%u, text='%s' "\
msg.header.repeatPeriod,
(ReplaceStr(msg.text,badSyms,repSym)).c_str(),
login.c_str(),
msg.header.repeatPeriod,
(ReplaceStr(msg.text,badSyms,repSym)).c_str(),
login.c_str(),