6 //-----------------------------------------------------------------------------
8 //-----------------------------------------------------------------------------
9 int PARSER_GET_ADMINS::ParseStart(void *, const char *el, const char **)
11 if (strcasecmp(el, "GetAdmins") == 0)
17 //-----------------------------------------------------------------------------
18 int PARSER_GET_ADMINS::ParseEnd(void *, const char *el)
20 if (strcasecmp(el, "GetAdmins") == 0)
27 //-----------------------------------------------------------------------------
28 void PARSER_GET_ADMINS::CreateAnswer()
30 const PRIV * priv = currAdmin->GetPriv();
33 //answerList->clear();
34 answerList->erase(answerList->begin(), answerList->end());
36 answerList->push_back("<Error Result=\"Error. Access denied.\"/>");
41 //answerList->clear();
42 answerList->erase(answerList->begin(), answerList->end());
44 answerList->push_back("<Admins>");
46 int h = admins->OpenSearch();
48 while (admins->SearchNext(h, &ac) == 0)
50 //memcpy(&p, &ac.priv, sizeof(unsigned int));
51 unsigned int p = (ac.priv.userStat << 0) +
52 (ac.priv.userConf << 2) +
53 (ac.priv.userCash << 4) +
54 (ac.priv.userPasswd << 6) +
55 (ac.priv.userAddDel << 8) +
56 (ac.priv.adminChg << 10) +
57 (ac.priv.tariffChg << 12);
58 strprintf(&s, "<admin login=\"%s\" priv=\"%d\"/>", ac.login.c_str(), p);
59 answerList->push_back(s);
61 admins->CloseSearch(h);
62 answerList->push_back("</Admins>");
64 //-----------------------------------------------------------------------------
66 //-----------------------------------------------------------------------------
68 //-----------------------------------------------------------------------------
69 int PARSER_DEL_ADMIN::ParseStart(void *, const char *el, const char **attr)
72 if (strcasecmp(el, "DelAdmin") == 0)
79 //-----------------------------------------------------------------------------
80 int PARSER_DEL_ADMIN::ParseEnd(void *, const char *el)
82 if (strcasecmp(el, "DelAdmin") == 0)
89 //-----------------------------------------------------------------------------
90 void PARSER_DEL_ADMIN::CreateAnswer()
92 //answerList->clear();
93 answerList->erase(answerList->begin(), answerList->end());
95 if (admins->Del(adminToDel, currAdmin) == 0)
97 answerList->push_back("<DelAdmin Result=\"Ok\"/>");
102 strprintf(&s, "<DelAdmin Result=\"Error. %s\"/>", admins->GetStrError().c_str());
103 answerList->push_back(s);
106 //-----------------------------------------------------------------------------
108 //-----------------------------------------------------------------------------
109 int PARSER_ADD_ADMIN::ParseStart(void *, const char *el, const char **attr)
111 if (strcasecmp(el, "AddAdmin") == 0)
113 adminToAdd = attr[1];
118 //-----------------------------------------------------------------------------
119 int PARSER_ADD_ADMIN::ParseEnd(void *, const char *el)
121 //answerList->clear();
122 answerList->erase(answerList->begin(), answerList->end());
124 if (strcasecmp(el, "AddAdmin") == 0)
131 //-----------------------------------------------------------------------------
132 void PARSER_ADD_ADMIN::CreateAnswer()
134 //answerList->clear();
135 answerList->erase(answerList->begin(), answerList->end());
137 if (admins->Add(adminToAdd, currAdmin) == 0)
139 answerList->push_back("<AddAdmin Result=\"Ok\"/>");
144 strprintf(&s, "<AddAdmin Result=\"Error. %s\"/>", admins->GetStrError().c_str());
145 answerList->push_back(s);
148 //-----------------------------------------------------------------------------
149 //-----------------------------------------------------------------------------
151 //-----------------------------------------------------------------------------
152 int PARSER_CHG_ADMIN::ParseStart(void *, const char *el, const char **attr)
154 if (strcasecmp(el, "ChgAdmin") == 0)
156 for (int i = 0; i < 6; i+=2)
158 printfd(__FILE__, "PARSER_CHG_ADMIN::attr[%d] = %s\n", i, attr[i]);
162 if (strcasecmp(attr[i], "Login") == 0)
168 if (strcasecmp(attr[i], "Priv") == 0)
170 privAsString = attr[i + 1];
174 if (strcasecmp(attr[i], "Password") == 0)
176 password = attr[i + 1];
185 //-----------------------------------------------------------------------------
186 int PARSER_CHG_ADMIN::ParseEnd(void *, const char *el)
188 if (strcasecmp(el, "ChgAdmin") == 0)
195 //-----------------------------------------------------------------------------
196 void PARSER_CHG_ADMIN::CreateAnswer()
198 answerList->erase(answerList->begin(), answerList->end());
203 ADMIN * origAdmin = NULL;
205 if (admins->Find(login.data(), &origAdmin))
207 answerList->push_back(std::string("<ChgAdmin Result = \"Admin '") + login.data() + "' is not found.\"/>");
211 ADMIN_CONF conf(origAdmin->GetConf());
213 if (!password.empty())
214 conf.password = password.data();
216 if (!privAsString.empty())
219 if (str2x(privAsString.data().c_str(), p) < 0)
221 answerList->push_back("<ChgAdmin Result = \"Incorrect parameter Priv.\"/>");
225 conf.priv.FromInt(p);
228 if (admins->Change(conf, currAdmin) != 0)
231 strprintf(&s, "<ChgAdmin Result = \"%s\"/>", admins->GetStrError().c_str());
232 answerList->push_back(s);
236 answerList->push_back("<ChgAdmin Result = \"Ok\"/>");
241 answerList->push_back("<ChgAdmin Result = \"Incorrect parameter login.\"/>");
244 //-----------------------------------------------------------------------------*/