X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/9c457d9aee148741ea438b05d3ce8177ca90055e..25d817aaf266fdf5300ca0b662426caaed4e924e:/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 94503c78..e9f529c6 100644 --- a/projects/stargazer/plugins/store/mysql/mysql_store.cpp +++ b/projects/stargazer/plugins/store/mysql/mysql_store.cpp @@ -118,7 +118,7 @@ public: //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -BASE_STORE * GetStore() +STORE * GetStore() { return msc.GetStore(); } @@ -711,6 +711,13 @@ if (!(res=mysql_store_result(sock))) return -1; } +if (mysql_num_rows(res) != 1) +{ + errorStr = "User not found"; + mysql_close(sock); + return -1; +} + row = mysql_fetch_row(res); string param; @@ -797,7 +804,7 @@ try { i = StrToIPS(ipStr); } -catch (string s) +catch (const string & s) { mysql_free_result(res); errorStr = "User \'" + login + "\' data not read. Parameter IP address. " + s; @@ -1689,7 +1696,7 @@ if(MysqlSetQuery(res.c_str())) return 0; } //----------------------------------------------------------------------------- -int MYSQL_STORE::WriteDetailedStat(const map * statTree, +int MYSQL_STORE::WriteDetailedStat(const map & statTree, time_t lastStat, const string & login) const { @@ -1774,11 +1781,10 @@ strprintf(&res,"INSERT INTO detailstat_%02d_%4d SET login='%s',"\ endTime.c_str() ); -int retRes; map::const_iterator stIter; -stIter = statTree->begin(); +stIter = statTree.begin(); -while (stIter != statTree->end()) +while (stIter != statTree.end()) { strprintf(&tempStr,"IP='%s', dir=%d, down=%lld, up=%lld, cash=%f", inet_ntostring(stIter->first.ip).c_str(), @@ -1788,7 +1794,7 @@ while (stIter != statTree->end()) stIter->second.cash ); - if( (retRes = MysqlQuery((res+tempStr).c_str(),sock)) ) + if( MysqlQuery((res+tempStr).c_str(),sock) ) { errorStr = "Couldn't insert data in WriteDetailedStat:\n"; errorStr += mysql_error(sock);