git.stg.codes
/
stg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Optional authorization.
[stg.git]
/
projects
/
stargazer
/
plugins
/
configuration
/
sgconfig
/
parser_users.cpp
diff --git
a/projects/stargazer/plugins/configuration/sgconfig/parser_users.cpp
b/projects/stargazer/plugins/configuration/sgconfig/parser_users.cpp
index c9a2e3d38fac40a5eb3aaf38250073a5eafd7d22..2e9d70872a82e3a7ac1ff92236c36c306060d582 100644
(file)
--- a/
projects/stargazer/plugins/configuration/sgconfig/parser_users.cpp
+++ b/
projects/stargazer/plugins/configuration/sgconfig/parser_users.cpp
@@
-26,7
+26,6
@@
#include "stg/user_property.h"
#include "stg/user_conf.h"
#include "stg/user_stat.h"
#include "stg/user_property.h"
#include "stg/user_conf.h"
#include "stg/user_stat.h"
-#include "stg/common.h"
#include <cstdio>
#include <cassert>
#include <cstdio>
#include <cassert>
@@
-53,9
+52,9
@@
std::string UserToXML(const USER & user, bool loginInStart, bool showPass, time_
std::string answer;
if (loginInStart)
std::string answer;
if (loginInStart)
- answer += "<User result=\"ok\">";
+ answer += "<User
login=\"" + user.GetLogin() + "\"
result=\"ok\">";
else
else
- answer += "<User result=\"ok\"
login=\"" + user.GetLogin() + "\"
>";
+ answer += "<User result=\"ok\">";
answer += "<Login value=\"" + user.GetLogin() + "\"/>";
answer += "<Login value=\"" + user.GetLogin() + "\"/>";
@@
-127,8
+126,8
@@
std::string UserToXML(const USER & user, bool loginInStart, bool showPass, time_
answer += "<IP value=\"" + user.GetProperty().ips.Get().GetIpStr() + "\"/>";
answer += "<Traff";
answer += "<IP value=\"" + user.GetProperty().ips.Get().GetIpStr() + "\"/>";
answer += "<Traff";
- const DIR_TRAFF & upload(user.GetProperty().
down
.Get());
- const DIR_TRAFF & download(user.GetProperty().
up
.Get());
+ const DIR_TRAFF & upload(user.GetProperty().
up
.Get());
+ const DIR_TRAFF & download(user.GetProperty().
down
.Get());
if (user.GetProperty().up.ModificationTime() > lastTime)
for (size_t j = 0; j < DIR_NUM; j++)
answer += " MU" + x2str(j) + "=\"" + x2str(upload[j]) + "\"";
if (user.GetProperty().up.ModificationTime() > lastTime)
for (size_t j = 0; j < DIR_NUM; j++)
answer += " MU" + x2str(j) + "=\"" + x2str(upload[j]) + "\"";
@@
-177,7
+176,10
@@
std::string UserToXML(const USER & user, bool loginInStart, bool showPass, time_
int GET_USERS::Start(void *, const char * el, const char ** attr)
{
if (strcasecmp(el, m_tag.c_str()) != 0)
int GET_USERS::Start(void *, const char * el, const char ** attr)
{
if (strcasecmp(el, m_tag.c_str()) != 0)
+ {
+ printfd(__FILE__, "Got wrong tag: '%s' instead of '%s'\n", el, m_tag.c_str());
return -1;
return -1;
+ }
while (attr && *attr && *(attr + 1))
{
while (attr && *attr && *(attr + 1))
{
@@
-195,9
+197,9
@@
void GET_USERS::CreateAnswer()
assert(h);
if (m_lastUserUpdateTime > 0)
assert(h);
if (m_lastUserUpdateTime > 0)
- m_answer = "<
" + m_tag + "
LastUpdate=\"" + x2str(time(NULL)) + "\">";
+ m_answer = "<
Users
LastUpdate=\"" + x2str(time(NULL)) + "\">";
else
else
- m_answer =
GetOpenTag()
;
+ m_answer =
"<Users>"
;
USER_PTR u;
USER_PTR u;
@@
-206,7
+208,7
@@
void GET_USERS::CreateAnswer()
m_users.CloseSearch(h);
m_users.CloseSearch(h);
- m_answer +=
GetCloseTag()
;
+ m_answer +=
"</Users>"
;
}
int GET_USER::Start(void *, const char * el, const char ** attr)
}
int GET_USER::Start(void *, const char * el, const char ** attr)
@@
-226,7
+228,7
@@
void GET_USER::CreateAnswer()
CONST_USER_PTR u;
if (m_users.FindByName(m_login, &u))
CONST_USER_PTR u;
if (m_users.FindByName(m_login, &u))
- m_answer = "<
" + m_tag + "
result=\"error\" reason=\"User not found.\"/>";
+ m_answer = "<
User
result=\"error\" reason=\"User not found.\"/>";
else
m_answer = UserToXML(*u, false, m_currAdmin.GetPriv()->userConf || m_currAdmin.GetPriv()->userPasswd);
}
else
m_answer = UserToXML(*u, false, m_currAdmin.GetPriv()->userConf || m_currAdmin.GetPriv()->userPasswd);
}
@@
-572,8
+574,8
@@
int CHG_USER::ApplyChanges()
if (!u->GetProperty().realName.Set(m_ucr.realName.const_data(), &m_currAdmin, m_login, &m_store))
return -1;
if (!u->GetProperty().realName.Set(m_ucr.realName.const_data(), &m_currAdmin, m_login, &m_store))
return -1;
-
if (!m_usr.cash.empty())
if (!m_usr.cash.empty())
+ {
if (m_cashMustBeAdded)
{
if (!u->GetProperty().cash.Set(m_usr.cash.const_data() + u->GetProperty().cash,
if (m_cashMustBeAdded)
{
if (!u->GetProperty().cash.Set(m_usr.cash.const_data() + u->GetProperty().cash,
@@
-582,11
+584,13
@@
int CHG_USER::ApplyChanges()
&m_store,
m_cashMsg))
return -1;
&m_store,
m_cashMsg))
return -1;
- else
- if (!u->GetProperty().cash.Set(m_usr.cash.const_data(), &m_currAdmin, m_login, &m_store, m_cashMsg))
- return -1;
}
}
-
+ else
+ {
+ if (!u->GetProperty().cash.Set(m_usr.cash.const_data(), &m_currAdmin, m_login, &m_store, m_cashMsg))
+ return -1;
+ }
+ }
if (!m_ucr.tariffName.empty())
{
if (!m_ucr.tariffName.empty())
{