git.stg.codes
/
stg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Hide assignement operator for USER_IMPL
[stg.git]
/
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 fefadd5cb803b4b734303fd78b9541fb705d7a80..859992e90eaf807b4a8b78a8edc2de245ab0fbaf 100644
(file)
--- a/
projects/stargazer/plugins/store/mysql/mysql_store.cpp
+++ b/
projects/stargazer/plugins/store/mysql/mysql_store.cpp
@@
-8,11
+8,12
@@
#include <mysql.h>
#include <errmsg.h>
#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 "mysql_store.h"
-#include "blowfish.h"
#define adm_enc_passwd "cjeifY8m3"
char qbuf[4096];
#define adm_enc_passwd "cjeifY8m3"
char qbuf[4096];
@@
-95,32
+96,13
@@
int GetULongLongInt(const string & str, uint64_t * val, uint64_t defaultVal)
return 0;
}
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.Get
Store
();
+return msc.Get
Plugin
();
}
//-----------------------------------------------------------------------------
MYSQL_STORE_SETTINGS::MYSQL_STORE_SETTINGS()
}
//-----------------------------------------------------------------------------
MYSQL_STORE_SETTINGS::MYSQL_STORE_SETTINGS()
@@
-153,13
+135,17
@@
return 0;
//-----------------------------------------------------------------------------
int MYSQL_STORE_SETTINGS::ParseSettings(const MODULE_SETTINGS & s)
{
//-----------------------------------------------------------------------------
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;
return -1;
-if (ParseParam(s.moduleParams, "rootdbpass", dbPass) < 0)
+if (ParseParam(s.moduleParams, "password", dbPass) < 0 &&
+ ParseParam(s.moduleParams, "rootdbpass", dbPass) < 0)
return -1;
return -1;
-if (ParseParam(s.moduleParams, "dbname", dbName) < 0)
+if (ParseParam(s.moduleParams, "database", dbName) < 0 &&
+ ParseParam(s.moduleParams, "dbname", dbName) < 0)
return -1;
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;
return -1;
return 0;
@@
-711,6
+697,13
@@
if (!(res=mysql_store_result(sock)))
return -1;
}
return -1;
}
+if (mysql_num_rows(res) != 1)
+{
+ errorStr = "User not found";
+ mysql_close(sock);
+ return -1;
+}
+
row = mysql_fetch_row(res);
string param;
row = mysql_fetch_row(res);
string param;
@@
-797,7
+790,7
@@
try
{
i = StrToIPS(ipStr);
}
{
i = StrToIPS(ipStr);
}
-catch (
string
s)
+catch (
const string &
s)
{
mysql_free_result(res);
errorStr = "User \'" + login + "\' data not read. Parameter IP address. " + s;
{
mysql_free_result(res);
errorStr = "User \'" + login + "\' data not read. Parameter IP address. " + s;
@@
-1262,6
+1255,10
@@
char password[ADM_PASSWD_LEN + 1];
char passwordE[2*ADM_PASSWD_LEN + 2];
BLOWFISH_CTX ctx;
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;
string p;
MYSQL_RES *res;
MYSQL_ROW row;
@@
-1862,8
+1859,8
@@
MYSQL_RES *res;
MYSQL_ROW row;
MYSQL * sock;
MYSQL_ROW row;
MYSQL * sock;
-sprintf(qbuf,"SELECT * FROM messages WHERE login='%s' AND id=%ll
d
LIMIT 1",
-
login.c_str(), id
);
+sprintf(qbuf,"SELECT * FROM messages WHERE login='%s' AND id=%ll
u
LIMIT 1",
+
login.c_str(), static_cast<unsigned long long>(id)
);
if(MysqlGetQuery(qbuf,sock))
{
if(MysqlGetQuery(qbuf,sock))
{