#include <mysql.h>
#include <errmsg.h>
-#include "user_ips.h"
-#include "user_conf.h"
-#include "user_stat.h"
+#include "stg/user_ips.h"
+#include "stg/user_conf.h"
+#include "stg/user_stat.h"
+#include "stg/blowfish.h"
+#include "stg/plugin_creator.h"
#include "mysql_store.h"
-#include "blowfish.h"
#define adm_enc_passwd "cjeifY8m3"
char qbuf[4096];
return 0;
}
-class MYSQL_STORE_CREATOR
-{
-private:
- MYSQL_STORE * ms;
-
-public:
- MYSQL_STORE_CREATOR()
- : ms(new MYSQL_STORE())
- {
- };
- ~MYSQL_STORE_CREATOR()
- {
- delete ms;
- };
-
- MYSQL_STORE * GetStore()
- {
- return ms;
- };
-} msc;
+PLUGIN_CREATOR<MYSQL_STORE> msc;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-BASE_STORE * GetStore()
+STORE * GetStore()
{
-return msc.GetStore();
+return msc.GetPlugin();
}
//-----------------------------------------------------------------------------
MYSQL_STORE_SETTINGS::MYSQL_STORE_SETTINGS()
- : settings(NULL)
+ : settings(NULL),
+ errorStr(),
+ dbUser(),
+ dbPass(),
+ dbName(),
+ dbHost()
{
-}
-//-----------------------------------------------------------------------------
-MYSQL_STORE_SETTINGS::~MYSQL_STORE_SETTINGS()
-{
-
}
//-----------------------------------------------------------------------------
int MYSQL_STORE_SETTINGS::ParseParam(const vector<PARAM_VALUE> & moduleParams,
//-----------------------------------------------------------------------------
int MYSQL_STORE_SETTINGS::ParseSettings(const MODULE_SETTINGS & s)
{
-if (ParseParam(s.moduleParams, "dbuser", dbUser) < 0)
+if (ParseParam(s.moduleParams, "user", dbUser) < 0 &&
+ ParseParam(s.moduleParams, "dbuser", dbUser) < 0)
return -1;
-if (ParseParam(s.moduleParams, "rootdbpass", dbPass) < 0)
+if (ParseParam(s.moduleParams, "password", dbPass) < 0 &&
+ ParseParam(s.moduleParams, "rootdbpass", dbPass) < 0)
return -1;
-if (ParseParam(s.moduleParams, "dbname", dbName) < 0)
+if (ParseParam(s.moduleParams, "database", dbName) < 0 &&
+ ParseParam(s.moduleParams, "dbname", dbName) < 0)
return -1;
-if (ParseParam(s.moduleParams, "dbhost", dbHost) < 0)
+if (ParseParam(s.moduleParams, "server", dbHost) < 0 &&
+ ParseParam(s.moduleParams, "dbhost", dbHost) < 0)
return -1;
return 0;
}
//-----------------------------------------------------------------------------
-const string & MYSQL_STORE_SETTINGS::GetStrError() const
-{
-return errorStr;
-}
-//-----------------------------------------------------------------------------
-string MYSQL_STORE_SETTINGS::GetDBUser() const
-{
-return dbUser;
-}
-//-----------------------------------------------------------------------------
-string MYSQL_STORE_SETTINGS::GetDBPassword() const
-{
-return dbPass;
-}
-//-----------------------------------------------------------------------------
-string MYSQL_STORE_SETTINGS::GetDBHost() const
-{
-return dbHost;
-}
-//-----------------------------------------------------------------------------
-string MYSQL_STORE_SETTINGS::GetDBName() const
-{
-return dbName;
-}
-//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
MYSQL_STORE::MYSQL_STORE()
+ : errorStr(),
+ version("mysql_store v.0.67"),
+ storeSettings(),
+ settings()
{
-version = "mysql_store v.0.67";
};
//-----------------------------------------------------------------------------
-MYSQL_STORE::~MYSQL_STORE()
-{
-};
-//-----------------------------------------------------------------------------
-void MYSQL_STORE::SetSettings(const MODULE_SETTINGS & s)
-{
-settings = s;
-}
-//-----------------------------------------------------------------------------
int MYSQL_STORE::MysqlQuery(const char* sQuery,MYSQL * sock) const
{
int ret,i;
return ret;
}
//-----------------------------------------------------------------------------
-const string & MYSQL_STORE::GetStrError() const
-{
-return errorStr;
-}
-//-----------------------------------------------------------------------------
-const string & MYSQL_STORE::GetVersion() const
-{
-return version;
-}
-//-----------------------------------------------------------------------------
bool MYSQL_STORE::IsTablePresent(const string & str,MYSQL * sock)
{
MYSQL_RES* result;
{
i = StrToIPS(ipStr);
}
-catch (string s)
+catch (const string & s)
{
mysql_free_result(res);
errorStr = "User \'" + login + "\' data not read. Parameter IP address. " + s;
char passwordE[2*ADM_PASSWD_LEN + 2];
BLOWFISH_CTX ctx;
+memset(pass, 0, sizeof(pass));
+memset(password, 0, sizeof(password));
+memset(passwordE, 0, sizeof(passwordE));
+
string p;
MYSQL_RES *res;
MYSQL_ROW row;
MYSQL_ROW row;
MYSQL * sock;
-sprintf(qbuf,"SELECT * FROM messages WHERE login='%s' AND id=%lld LIMIT 1",
- login.c_str(), id);
+sprintf(qbuf,"SELECT * FROM messages WHERE login='%s' AND id=%llu LIMIT 1",
+ login.c_str(), static_cast<unsigned long long>(id));
if(MysqlGetQuery(qbuf,sock))
{