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 answer = "<Error Result=\"Error. Access denied.\"/>";
41 int h = admins->OpenSearch();
43 while (admins->SearchNext(h, &ac) == 0)
45 unsigned int p = (ac.priv.userStat << 0) +
46 (ac.priv.userConf << 2) +
47 (ac.priv.userCash << 4) +
48 (ac.priv.userPasswd << 6) +
49 (ac.priv.userAddDel << 8) +
50 (ac.priv.adminChg << 10) +
51 (ac.priv.tariffChg << 12);
52 answer += "<admin login=\"" + ac.login + "\" priv=\"" + x2str(p) + "\"/>";
54 admins->CloseSearch(h);
55 answer += "</Admins>";
57 //-----------------------------------------------------------------------------
59 //-----------------------------------------------------------------------------
61 //-----------------------------------------------------------------------------
62 int PARSER_DEL_ADMIN::ParseStart(void *, const char *el, const char **attr)
65 if (strcasecmp(el, "DelAdmin") == 0)
72 //-----------------------------------------------------------------------------
73 int PARSER_DEL_ADMIN::ParseEnd(void *, const char *el)
75 if (strcasecmp(el, "DelAdmin") == 0)
82 //-----------------------------------------------------------------------------
83 void PARSER_DEL_ADMIN::CreateAnswer()
85 if (admins->Del(adminToDel, currAdmin) == 0)
86 answer = "<DelAdmin Result=\"Ok\"/>";
88 answer = "<DelAdmin Result=\"Error. " + admins->GetStrError() + "\"/>";
90 //-----------------------------------------------------------------------------
92 //-----------------------------------------------------------------------------
93 int PARSER_ADD_ADMIN::ParseStart(void *, const char *el, const char **attr)
95 if (strcasecmp(el, "AddAdmin") == 0)
102 //-----------------------------------------------------------------------------
103 int PARSER_ADD_ADMIN::ParseEnd(void *, const char *el)
105 if (strcasecmp(el, "AddAdmin") == 0)
112 //-----------------------------------------------------------------------------
113 void PARSER_ADD_ADMIN::CreateAnswer()
115 if (admins->Add(adminToAdd, currAdmin) == 0)
116 answer = "<AddAdmin Result=\"Ok\"/>";
118 answer = "<AddAdmin Result=\"Error. " + admins->GetStrError() + "\"/>";
120 //-----------------------------------------------------------------------------
121 //-----------------------------------------------------------------------------
123 //-----------------------------------------------------------------------------
124 int PARSER_CHG_ADMIN::ParseStart(void *, const char *el, const char **attr)
126 if (strcasecmp(el, "ChgAdmin") == 0)
128 for (int i = 0; i < 6; i+=2)
130 printfd(__FILE__, "PARSER_CHG_ADMIN::attr[%d] = %s\n", i, attr[i]);
134 if (strcasecmp(attr[i], "Login") == 0)
140 if (strcasecmp(attr[i], "Priv") == 0)
142 privAsString = attr[i + 1];
146 if (strcasecmp(attr[i], "Password") == 0)
148 password = attr[i + 1];
157 //-----------------------------------------------------------------------------
158 int PARSER_CHG_ADMIN::ParseEnd(void *, const char *el)
160 if (strcasecmp(el, "ChgAdmin") == 0)
167 //-----------------------------------------------------------------------------
168 void PARSER_CHG_ADMIN::CreateAnswer()
172 ADMIN * origAdmin = NULL;
174 if (admins->Find(login.data(), &origAdmin))
176 answer = "<ChgAdmin Result = \"Admin '" + login.data() + "' is not found.\"/>";
180 ADMIN_CONF conf(origAdmin->GetConf());
182 if (!password.empty())
183 conf.password = password.data();
185 if (!privAsString.empty())
188 if (str2x(privAsString.data().c_str(), p) < 0)
190 answer = "<ChgAdmin Result = \"Incorrect parameter Priv.\"/>";
194 conf.priv.FromInt(p);
197 if (admins->Change(conf, currAdmin) != 0)
198 answer = "<ChgAdmin Result = \"" + admins->GetStrError() + "\"/>";
200 answer = "<ChgAdmin Result = \"Ok\"/>";
203 answer = "<ChgAdmin Result = \"Incorrect parameter login.\"/>";