2 #include <sys/utsname.h>
4 #include <sys/socket.h>
5 #include <netinet/in.h>
12 #include "stg/version.h"
13 #include "stg/tariffs.h"
14 #include "stg/user_property.h"
15 #include "stg/settings.h"
18 #define UNAME_LEN (256)
19 //-----------------------------------------------------------------------------
21 //-----------------------------------------------------------------------------
22 int PARSER_GET_SERVER_INFO::ParseStart(void *, const char *el, const char **)
24 answerList->erase(answerList->begin(), answerList->end());
25 if (strcasecmp(el, "GetServerInfo") == 0)
31 //-----------------------------------------------------------------------------
32 int PARSER_GET_SERVER_INFO::ParseEnd(void *, const char *el)
34 if (strcasecmp(el, "GetServerInfo") == 0)
41 //-----------------------------------------------------------------------------
42 void PARSER_GET_SERVER_INFO::CreateAnswer()
44 char s[UNAME_LEN + 128];
51 strcat(un, utsn.sysname);
53 strcat(un, utsn.release);
55 strcat(un, utsn.machine);
57 strcat(un, utsn.nodename);
59 //answerList->clear();
60 answerList->erase(answerList->begin(), answerList->end());
61 answerList->push_back("<ServerInfo>");
63 sprintf(s, "<version value=\"%s\"/>", SERVER_VERSION);
64 answerList->push_back(s);
66 sprintf(s, "<tariff_num value=\"%llu\"/>", (unsigned long long)tariffs->Count());
67 answerList->push_back(s);
69 sprintf(s, "<tariff value=\"%d\"/>", 2);
70 answerList->push_back(s);
72 sprintf(s, "<users_num value=\"%llu\"/>", (unsigned long long)users->Count());
73 answerList->push_back(s);
75 sprintf(s, "<uname value=\"%s\"/>", un);
76 answerList->push_back(s);
78 sprintf(s, "<dir_num value=\"%d\"/>", DIR_NUM);
79 answerList->push_back(s);
81 sprintf(s, "<day_fee value=\"%d\"/>", settings->GetDayFee());
82 answerList->push_back(s);
84 for (int i = 0; i< DIR_NUM; i++)
87 Encode12str(dn2e, settings->GetDirName(i));
88 sprintf(s, "<dir_name_%d value=\"%s\"/>", i, dn2e.c_str());
89 answerList->push_back(s);
92 answerList->push_back("</ServerInfo>");
94 //-----------------------------------------------------------------------------
96 //-----------------------------------------------------------------------------
97 int PARSER_GET_USER::ParseStart(void *, const char *el, const char **attr)
99 if (strcasecmp(el, "GetUser") == 0)
101 if (attr[0] && attr[1])
106 login.erase(login.begin(), login.end());
113 //-----------------------------------------------------------------------------
114 int PARSER_GET_USER::ParseEnd(void *, const char *el)
116 if (strcasecmp(el, "GetUser") == 0)
123 //-----------------------------------------------------------------------------
124 void PARSER_GET_USER::CreateAnswer()
131 answerList->erase(answerList->begin(), answerList->end());
133 if (users->FindByName(login, &u))
135 s = "<user result=\"error\"/>";
136 answerList->push_back(s);
140 s = "<user result=\"ok\">";
141 answerList->push_back(s);
143 s = "<login value=\"" + u->GetLogin() + "\"/>";
144 answerList->push_back(s);
146 if (currAdmin->GetPriv()->userConf || currAdmin->GetPriv()->userPasswd)
147 s = "<password value=\"" + u->GetProperty().password.Get() + "\" />";
149 s = "<password value=\"++++++\"/>";
150 answerList->push_back(s);
152 strprintf(&s, "<cash value=\"%f\" />", u->GetProperty().cash.Get());
153 answerList->push_back(s);
155 strprintf(&s, "<freemb value=\"%f\" />", u->GetProperty().freeMb.Get());
156 answerList->push_back(s);
158 strprintf(&s, "<credit value=\"%f\" />", u->GetProperty().credit.Get());
159 answerList->push_back(s);
161 if (u->GetProperty().nextTariff.Get() != "")
163 strprintf(&s, "<tariff value=\"%s/%s\" />",
164 u->GetProperty().tariffName.Get().c_str(),
165 u->GetProperty().nextTariff.Get().c_str());
169 strprintf(&s, "<tariff value=\"%s\" />",
170 u->GetProperty().tariffName.Get().c_str());
173 answerList->push_back(s);
175 Encode12str(enc, u->GetProperty().note);
176 s = "<note value=\"" + enc + "\" />";
177 answerList->push_back(s);
179 Encode12str(enc, u->GetProperty().phone);
180 s = "<phone value=\"" + enc + "\" />";
181 answerList->push_back(s);
183 Encode12str(enc, u->GetProperty().address);
184 s = "<address value=\"" + enc + "\" />";
185 answerList->push_back(s);
187 Encode12str(enc, u->GetProperty().email);
188 s = "<email value=\"" + enc + "\" />";
189 answerList->push_back(s);
192 vector<USER_PROPERTY_LOGGED<string> *> userdata;
193 userdata.push_back(u->GetProperty().userdata0.GetPointer());
194 userdata.push_back(u->GetProperty().userdata1.GetPointer());
195 userdata.push_back(u->GetProperty().userdata2.GetPointer());
196 userdata.push_back(u->GetProperty().userdata3.GetPointer());
197 userdata.push_back(u->GetProperty().userdata4.GetPointer());
198 userdata.push_back(u->GetProperty().userdata5.GetPointer());
199 userdata.push_back(u->GetProperty().userdata6.GetPointer());
200 userdata.push_back(u->GetProperty().userdata7.GetPointer());
201 userdata.push_back(u->GetProperty().userdata8.GetPointer());
202 userdata.push_back(u->GetProperty().userdata9.GetPointer());
205 for (unsigned i = 0; i < userdata.size(); i++)
207 Encode12str(enc, userdata[i]->Get());
208 s = "<UserData" + x2str(i, tmpI) + " value=\"" + enc + "\" />";
209 answerList->push_back(s);
212 Encode12str(enc, u->GetProperty().realName);
213 s = "<name value=\"" + enc + "\" />";
214 answerList->push_back(s);
216 Encode12str(enc, u->GetProperty().group);
217 s = "<GROUP value=\"" + enc + "\" />";
218 answerList->push_back(s);
220 strprintf(&s, "<status value=\"%d\" />", u->GetConnected());
221 answerList->push_back(s);
223 strprintf(&s, "<aonline value=\"%d\" />", u->GetProperty().alwaysOnline.Get());
224 answerList->push_back(s);
226 strprintf(&s, "<currip value=\"%s\" />", inet_ntostring(u->GetCurrIP()).c_str());
227 answerList->push_back(s);
229 strprintf(&s, "<PingTime value=\"%lu\" />", u->GetPingTime());
230 answerList->push_back(s);
233 sstr << u->GetProperty().ips.Get();
234 strprintf(&s, "<ip value=\"%s\" />", sstr.str().c_str());
235 answerList->push_back(s);
238 ss = new char[DIR_NUM*25*4 + 50];
240 sprintf(ss, "<traff");
243 download = u->GetProperty().down.Get();
244 upload = u->GetProperty().up.Get();
246 for (int j = 0; j < DIR_NUM; j++)
250 sprintf(st, " MU%d=\"%s\"", j, s.c_str());
253 x2str(download[j], s);
254 sprintf(st, " MD%d=\"%s\"", j, s.c_str());
257 sprintf(st, " SU%d=\"0\"", j);
260 sprintf(st, " SD%d=\"0\"", j);
264 answerList->push_back(ss);
267 strprintf(&s, "<down value=\"%d\" />", u->GetProperty().disabled.Get());
268 answerList->push_back(s);
270 strprintf(&s, "<DisableDetailStat value=\"%d\" />", u->GetProperty().disabledDetailStat.Get());
271 answerList->push_back(s);
273 strprintf(&s, "<passive value=\"%d\" />", u->GetProperty().passive.Get());
274 answerList->push_back(s);
276 strprintf(&s, "<LastCash value=\"%f\" />", u->GetProperty().lastCashAdd.Get());
277 answerList->push_back(s);
279 strprintf(&s, "<LastTimeCash value=\"%ld\" />", u->GetProperty().lastCashAddTime.Get());
280 answerList->push_back(s);
282 strprintf(&s, "<LastActivityTime value=\"%ld\" />", u->GetProperty().lastActivityTime.Get());
283 answerList->push_back(s);
285 strprintf(&s, "<CreditExpire value=\"%ld\" />", u->GetProperty().creditExpire.Get());
286 answerList->push_back(s);
288 strprintf(&s, "</user>");
289 answerList->push_back(s);
291 //-----------------------------------------------------------------------------
293 //-----------------------------------------------------------------------------
294 int PARSER_GET_USERS::ParseStart(void *, const char *el, const char ** attr)
296 /*if (attr && *attr && *(attr+1))
298 printfd(__FILE__, "attr=%s %s\n", *attr, *(attr+1));
302 printfd(__FILE__, "attr = NULL\n");
305 lastUpdateFound = false;
306 if (strcasecmp(el, "GetUsers") == 0)
308 while (attr && *attr && *(attr+1))
310 if (strcasecmp(*attr, "LastUpdate") == 0)
312 if (str2x(*(attr+1), lastUserUpdateTime) == 0)
314 //printfd(__FILE__, "lastUserUpdateTime=%d\n", lastUserUpdateTime);
315 lastUpdateFound = true;
319 //printfd(__FILE__, "NO lastUserUpdateTime\n");
329 //-----------------------------------------------------------------------------
330 int PARSER_GET_USERS::ParseEnd(void *, const char *el)
332 if (strcasecmp(el, "GetUsers") == 0)
339 //-----------------------------------------------------------------------------
340 void PARSER_GET_USERS::CreateAnswer()
342 answerList->erase(answerList->begin(), answerList->end());
357 int h = users->OpenSearch();
360 printfd(__FILE__, "users->OpenSearch() error\n");
361 users->CloseSearch(h);
365 x2str(time(NULL), updateTime);
368 answerList->push_back("<Users LastUpdate=\"" + updateTime + "\">");
370 answerList->push_back("<Users>");
374 if (users->SearchNext(h, &u))
378 userStart = "<user login=\"" + u->GetLogin() + "\">";
381 if (u->GetProperty().password.ModificationTime() > lastUserUpdateTime)
383 if (currAdmin->GetPriv()->userConf || currAdmin->GetPriv()->userPasswd)
384 s = "<password value=\"" + u->GetProperty().password.Get() + "\" />";
386 s = "<password value=\"++++++\"/>";
391 if (u->GetProperty().cash.ModificationTime() > lastUserUpdateTime)
393 strprintf(&s, "<cash value=\"%f\" />", u->GetProperty().cash.Get());
395 //printfd(__FILE__, "cash value=\"%f\"\n", u->GetProperty().cash.Get());
399 if (u->GetProperty().freeMb.ModificationTime() > lastUserUpdateTime)
401 strprintf(&s, "<freemb value=\"%f\" />", u->GetProperty().freeMb.Get());
405 if (u->GetProperty().credit.ModificationTime() > lastUserUpdateTime)
407 strprintf(&s, "<credit value=\"%f\" />", u->GetProperty().credit.Get());
411 if (u->GetProperty().nextTariff.Get() != "")
413 if (u->GetProperty().tariffName.ModificationTime() > lastUserUpdateTime
414 || u->GetProperty().nextTariff.ModificationTime() > lastUserUpdateTime)
416 strprintf(&s, "<tariff value=\"%s/%s\" />",
417 u->GetProperty().tariffName.Get().c_str(),
418 u->GetProperty().nextTariff.Get().c_str());
424 if (u->GetProperty().tariffName.ModificationTime() > lastUserUpdateTime)
426 strprintf(&s, "<tariff value=\"%s\" />",
427 u->GetProperty().tariffName.Get().c_str());
432 if (u->GetProperty().note.ModificationTime() > lastUserUpdateTime)
434 Encode12str(enc, u->GetProperty().note);
435 strprintf(&s, "<note value=\"%s\" />", enc.c_str());
439 if (u->GetProperty().phone.ModificationTime() > lastUserUpdateTime)
441 Encode12str(enc, u->GetProperty().phone);
442 strprintf(&s, "<phone value=\"%s\" />", enc.c_str());
446 if (u->GetProperty().address.ModificationTime() > lastUserUpdateTime)
448 Encode12str(enc, u->GetProperty().address);
449 strprintf(&s, "<address value=\"%s\" />", enc.c_str());
453 if (u->GetProperty().email.ModificationTime() > lastUserUpdateTime)
455 Encode12str(enc, u->GetProperty().email);
456 strprintf(&s, "<email value=\"%s\" />", enc.c_str());
460 vector<USER_PROPERTY_LOGGED<string> *> userdata;
461 userdata.push_back(u->GetProperty().userdata0.GetPointer());
462 userdata.push_back(u->GetProperty().userdata1.GetPointer());
463 userdata.push_back(u->GetProperty().userdata2.GetPointer());
464 userdata.push_back(u->GetProperty().userdata3.GetPointer());
465 userdata.push_back(u->GetProperty().userdata4.GetPointer());
466 userdata.push_back(u->GetProperty().userdata5.GetPointer());
467 userdata.push_back(u->GetProperty().userdata6.GetPointer());
468 userdata.push_back(u->GetProperty().userdata7.GetPointer());
469 userdata.push_back(u->GetProperty().userdata8.GetPointer());
470 userdata.push_back(u->GetProperty().userdata9.GetPointer());
473 for (unsigned i = 0; i < userdata.size(); i++)
475 if (userdata[i]->ModificationTime() > lastUserUpdateTime)
477 Encode12str(enc, userdata[i]->Get());
478 s = "<UserData" + x2str(i, tmpI) + " value=\"" + enc + "\" />";
483 if (u->GetProperty().realName.ModificationTime() > lastUserUpdateTime)
485 Encode12str(enc, u->GetProperty().realName);
486 strprintf(&s, "<name value=\"%s\" />", enc.c_str());
490 if (u->GetProperty().group.ModificationTime() > lastUserUpdateTime)
492 Encode12str(enc, u->GetProperty().group);
493 strprintf(&s, "<GROUP value=\"%s\" />", enc.c_str());
497 if (u->GetProperty().alwaysOnline.ModificationTime() > lastUserUpdateTime)
499 strprintf(&s, "<aonline value=\"%d\" />", u->GetProperty().alwaysOnline.Get());
503 if (u->GetCurrIPModificationTime() > lastUserUpdateTime)
505 strprintf(&s, "<currip value=\"%s\" />", inet_ntostring(u->GetCurrIP()).c_str());
510 if (u->GetConnectedModificationTime() > lastUserUpdateTime)
512 strprintf(&s, "<status value=\"%d\" />", u->GetConnected());
516 if (u->GetPingTime() > lastUserUpdateTime)
518 strprintf(&s, "<PingTime value=\"%lu\" />", u->GetPingTime());
522 if (u->GetProperty().ips.ModificationTime() > lastUserUpdateTime)
525 sstr << u->GetProperty().ips.Get();
526 strprintf(&s, "<ip value=\"%s\" />", sstr.str().c_str());
531 traffStart = "<traff";
534 download = u->GetProperty().down.Get();
535 upload = u->GetProperty().up.Get();
538 if (u->GetProperty().up.ModificationTime() > lastUserUpdateTime)
540 for (int j = 0; j < DIR_NUM; j++)
544 sprintf(st, " MU%d=\"%s\" ", j, s.c_str());
549 if (u->GetProperty().down.ModificationTime() > lastUserUpdateTime)
551 for (int j = 0; j < DIR_NUM; j++)
553 x2str(download[j], s);
554 sprintf(st, " MD%d=\"%s\" ", j, s.c_str());
560 if (traffMiddle.length() > 0)
562 middle += traffStart;
563 middle += traffMiddle;
564 middle += traffFinish;
567 if (u->GetProperty().disabled.ModificationTime() > lastUserUpdateTime)
569 strprintf(&s, "<down value=\"%d\" />", u->GetProperty().disabled.Get());
573 if (u->GetProperty().disabledDetailStat.ModificationTime() > lastUserUpdateTime)
575 strprintf(&s, "<DisableDetailStat value=\"%d\" />", u->GetProperty().disabledDetailStat.Get());
579 //printfd(__FILE__, ">>>>> %s\n", s.c_str());
581 if (u->GetProperty().passive.ModificationTime() > lastUserUpdateTime)
583 strprintf(&s, "<passive value=\"%d\" />", u->GetProperty().passive.Get());
587 if (u->GetProperty().lastCashAdd.ModificationTime() > lastUserUpdateTime)
589 strprintf(&s, "<LastCash value=\"%f\" />", u->GetProperty().lastCashAdd.Get());
593 if (u->GetProperty().lastCashAddTime.ModificationTime() > lastUserUpdateTime)
595 strprintf(&s, "<LastTimeCash value=\"%ld\" />", u->GetProperty().lastCashAddTime.Get());
600 if (u->GetProperty().lastActivityTime.ModificationTime() > lastUserUpdateTime)
602 strprintf(&s, "<LastActivityTime value=\"%ld\" />", u->GetProperty().lastActivityTime.Get());
606 if (u->GetProperty().creditExpire.ModificationTime() > lastUserUpdateTime)
608 strprintf(&s, "<CreditExpire value=\"%ld\" />", u->GetProperty().creditExpire.Get());
613 userFinish = "</user>";
615 if (middle.length() > 0)
617 /*printfd(__FILE__, "login: %s\n", u->GetLogin().c_str());
618 printfd(__FILE__, "middle: %s\n", middle.c_str());*/
620 answerList->push_back(userStart);
621 answerList->push_back(middle);
622 answerList->push_back(userFinish);
626 users->CloseSearch(h);
628 //answerList->push_back("</Users>");
630 answerList->push_back("</Users>");
632 //-----------------------------------------------------------------------------
634 //-----------------------------------------------------------------------------
635 int PARSER_ADD_USER::ParseStart(void *, const char *el, const char **attr)
641 if (strcasecmp(el, "AddUser") == 0)
648 if (strcasecmp(el, "login") == 0)
656 //-----------------------------------------------------------------------------
657 int PARSER_ADD_USER::ParseEnd(void *, const char *el)
661 if (strcasecmp(el, "AddUser") == 0)
672 //-----------------------------------------------------------------------------
673 void PARSER_ADD_USER::Reset()
675 BASE_PARSER::Reset();
678 //-----------------------------------------------------------------------------
679 void PARSER_ADD_USER::CreateAnswer()
681 //answerList->clear();
682 answerList->erase(answerList->begin(), answerList->end());
684 if (CheckUserData() == 0)
686 answerList->push_back("<AddUser result=\"ok\"/>");
690 answerList->push_back("<AddUser result=\"error\" reason=\"Access denied\"/>");
693 //-----------------------------------------------------------------------------
694 int PARSER_ADD_USER::CheckUserData()
697 if (users->FindByName(login, &u))
699 return users->Add(login, currAdmin);
703 //-----------------------------------------------------------------------------
705 //-----------------------------------------------------------------------------
706 PARSER_CHG_USER::PARSER_CHG_USER()
714 cashMustBeAdded(false),
719 //-----------------------------------------------------------------------------
720 PARSER_CHG_USER::~PARSER_CHG_USER()
727 //-----------------------------------------------------------------------------
728 void PARSER_CHG_USER::Reset()
739 usr = new USER_STAT_RES;
740 ucr = new USER_CONF_RES;
742 upr = new RESETABLE<uint64_t>[DIR_NUM];
743 downr = new RESETABLE<uint64_t>[DIR_NUM];
745 //-----------------------------------------------------------------------------
746 string PARSER_CHG_USER::EncChar2String(const char * strEnc)
749 Decode21str(str, strEnc);
752 //-----------------------------------------------------------------------------
753 int PARSER_CHG_USER::ParseStart(void *, const char *el, const char **attr)
759 if (strcasecmp(el, "SetUser") == 0)
766 //printfd(__FILE__, "el=%s\n", el);
767 if (strcasecmp(el, "login") == 0)
773 if (strcasecmp(el, "ip") == 0)
777 ucr->ips = StrToIPS(attr[1]);
781 printfd(__FILE__, "StrToIPS Error!\n");
785 if (strcasecmp(el, "password") == 0)
787 ucr->password = attr[1];
791 if (strcasecmp(el, "address") == 0)
793 ucr->address = EncChar2String(attr[1]);
797 if (strcasecmp(el, "aonline") == 0)
799 ucr->alwaysOnline = (*(attr[1]) != '0');
803 if (strcasecmp(el, "cash") == 0)
805 if (attr[2] && (strcasecmp(attr[2], "msg") == 0))
807 cashMsg = EncChar2String(attr[3]);
811 if (strtodouble2(attr[1], cash) == 0)
814 if (strcasecmp(attr[0], "set") == 0)
815 cashMustBeAdded = false;
817 if (strcasecmp(attr[0], "add") == 0)
818 cashMustBeAdded = true;
823 if (strcasecmp(el, "CreditExpire") == 0)
825 long int creditExpire = 0;
826 if (str2x(attr[1], creditExpire) == 0)
827 ucr->creditExpire = (time_t)creditExpire;
832 if (strcasecmp(el, "credit") == 0)
835 if (strtodouble2(attr[1], credit) == 0)
836 ucr->credit = credit;
840 if (strcasecmp(el, "freemb") == 0)
843 if (strtodouble2(attr[1], freeMb) == 0)
844 usr->freeMb = freeMb;
848 if (strcasecmp(el, "down") == 0)
851 if (str2x(attr[1], down) == 0)
852 ucr->disabled = down;
856 if (strcasecmp(el, "DisableDetailStat") == 0)
858 int disabledDetailStat = 0;
859 if (str2x(attr[1], disabledDetailStat) == 0)
860 ucr->disabledDetailStat = disabledDetailStat;
864 if (strcasecmp(el, "email") == 0)
866 ucr->email = EncChar2String(attr[1]);
870 for (int i = 0; i < USERDATA_NUM; i++)
873 sprintf(name, "userdata%d", i);
874 if (strcasecmp(el, name) == 0)
876 ucr->userdata[i] = EncChar2String(attr[1]);
881 if (strcasecmp(el, "group") == 0)
883 ucr->group = EncChar2String(attr[1]);
887 if (strcasecmp(el, "note") == 0)
889 ucr->note = EncChar2String(attr[1]);
893 if (strcasecmp(el, "passive") == 0)
896 if (str2x(attr[1], passive) == 0)
897 ucr->passive = passive;
901 if (strcasecmp(el, "phone") == 0)
903 ucr->phone = EncChar2String(attr[1]);
907 if (strcasecmp(el, "Name") == 0)
909 ucr->realName = EncChar2String(attr[1]);
913 if (strcasecmp(el, "traff") == 0)
919 unsigned long long t = 0;
922 dir = attr[j][2] - '0';
924 if (strncasecmp(attr[j], "md", 2) == 0)
930 if (strncasecmp(attr[j], "mu", 2) == 0)
943 if (strcasecmp(el, "tariff") == 0)
945 if (strcasecmp(attr[0], "now") == 0)
946 ucr->tariffName = attr[1];
948 if (strcasecmp(attr[0], "delayed") == 0)
949 ucr->nextTariff = attr[1];
956 //-----------------------------------------------------------------------------
957 int PARSER_CHG_USER::ParseEnd(void *, const char *el)
961 if (strcasecmp(el, "SetUser") == 0)
973 //-----------------------------------------------------------------------------
974 void PARSER_CHG_USER::CreateAnswer()
976 //answerList->clear();
977 answerList->erase(answerList->begin(), answerList->end());
982 answerList->push_back("<SetUser result=\"ok\"/>");
985 answerList->push_back("<SetUser result=\"error\"/>");
988 answerList->push_back("<SetUser result=\"error\"/>");
991 answerList->push_back("<SetUser result=\"error\"/>");
996 //-----------------------------------------------------------------------------
997 int PARSER_CHG_USER::AplayChanges()
1002 if (users->FindByName(login, &u))
1008 if (!ucr->ips.res_empty())
1009 if (!u->GetProperty().ips.Set(ucr->ips.const_data(), currAdmin, login, store))
1012 if (!ucr->address.res_empty())
1013 if (!u->GetProperty().address.Set(ucr->address.const_data(), currAdmin, login, store))
1016 if (!ucr->alwaysOnline.res_empty())
1017 if (!u->GetProperty().alwaysOnline.Set(ucr->alwaysOnline.const_data(),
1018 currAdmin, login, store))
1021 if (!ucr->creditExpire.res_empty())
1022 if (!u->GetProperty().creditExpire.Set(ucr->creditExpire.const_data(),
1023 currAdmin, login, store))
1026 if (!ucr->credit.res_empty())
1027 if (!u->GetProperty().credit.Set(ucr->credit.const_data(), currAdmin, login, store))
1030 if (!usr->freeMb.res_empty())
1031 if (!u->GetProperty().freeMb.Set(usr->freeMb.const_data(), currAdmin, login, store))
1034 if (!ucr->disabled.res_empty())
1035 if (!u->GetProperty().disabled.Set(ucr->disabled.const_data(), currAdmin, login, store))
1038 if (!ucr->disabledDetailStat.res_empty())
1039 if (!u->GetProperty().disabledDetailStat.Set(ucr->disabledDetailStat.const_data(), currAdmin, login, store))
1042 if (!ucr->email.res_empty())
1043 if (!u->GetProperty().email.Set(ucr->email.const_data(), currAdmin, login, store))
1046 if (!ucr->group.res_empty())
1047 if (!u->GetProperty().group.Set(ucr->group.const_data(), currAdmin, login, store))
1050 if (!ucr->note.res_empty())
1051 if (!u->GetProperty().note.Set(ucr->note.const_data(), currAdmin, login, store))
1054 vector<USER_PROPERTY_LOGGED<string> *> userdata;
1055 userdata.push_back(u->GetProperty().userdata0.GetPointer());
1056 userdata.push_back(u->GetProperty().userdata1.GetPointer());
1057 userdata.push_back(u->GetProperty().userdata2.GetPointer());
1058 userdata.push_back(u->GetProperty().userdata3.GetPointer());
1059 userdata.push_back(u->GetProperty().userdata4.GetPointer());
1060 userdata.push_back(u->GetProperty().userdata5.GetPointer());
1061 userdata.push_back(u->GetProperty().userdata6.GetPointer());
1062 userdata.push_back(u->GetProperty().userdata7.GetPointer());
1063 userdata.push_back(u->GetProperty().userdata8.GetPointer());
1064 userdata.push_back(u->GetProperty().userdata9.GetPointer());
1066 for (int i = 0; i < (int)userdata.size(); i++)
1068 if (!ucr->userdata[i].res_empty())
1070 if(!userdata[i]->Set(ucr->userdata[i].const_data(), currAdmin, login, store))
1075 if (!ucr->passive.res_empty())
1076 if (!u->GetProperty().passive.Set(ucr->passive.const_data(), currAdmin, login, store))
1079 if (!ucr->password.res_empty())
1080 if (!u->GetProperty().password.Set(ucr->password.const_data(), currAdmin, login, store))
1083 if (!ucr->phone.res_empty())
1084 if (!u->GetProperty().phone.Set(ucr->phone.const_data(), currAdmin, login, store))
1087 if (!ucr->realName.res_empty())
1088 if (!u->GetProperty().realName.Set(ucr->realName.const_data(), currAdmin, login, store))
1092 if (!usr->cash.res_empty())
1094 //if (*currAdmin->GetPriv()->userCash)
1096 if (cashMustBeAdded)
1098 if (!u->GetProperty().cash.Set(usr->cash.const_data() + u->GetProperty().cash,
1107 if (!u->GetProperty().cash.Set(usr->cash.const_data(), currAdmin, login, store, cashMsg))
1114 if (!ucr->tariffName.res_empty())
1116 if (tariffs->FindByName(ucr->tariffName.const_data()))
1118 if (!u->GetProperty().tariffName.Set(ucr->tariffName.const_data(), currAdmin, login, store))
1120 u->ResetNextTariff();
1124 //WriteServLog("SetUser: Tariff %s not found", ud.conf.tariffName.c_str());
1129 if (!ucr->nextTariff.res_empty())
1131 if (tariffs->FindByName(ucr->nextTariff.const_data()))
1133 if (!u->GetProperty().nextTariff.Set(ucr->nextTariff.const_data(), currAdmin, login, store))
1138 //WriteServLog("SetUser: Tariff %s not found", ud.conf.tariffName.c_str());
1143 DIR_TRAFF up = u->GetProperty().up;
1144 DIR_TRAFF down = u->GetProperty().down;
1147 for (int i = 0; i < DIR_NUM; i++)
1149 if (!upr[i].res_empty())
1154 if (!downr[i].res_empty())
1162 if (!u->GetProperty().up.Set(up, currAdmin, login, store))
1166 if (!u->GetProperty().down.Set(down, currAdmin, login, store))
1169 /*if (!usr->down.res_empty())
1171 u->GetProperty().down.Set(usr->down.const_data(), currAdmin, login, store);
1173 if (!usr->up.res_empty())
1175 u->GetProperty().up.Set(usr->up.const_data(), currAdmin, login, store);
1183 //-----------------------------------------------------------------------------
1185 //-----------------------------------------------------------------------------
1186 int PARSER_SEND_MESSAGE::ParseStart(void *, const char *el, const char **attr)
1188 if (strcasecmp(el, "Message") == 0)
1190 for (int i = 0; i < 14; i++)
1192 if (attr[i] == NULL)
1194 result = res_params_error;
1196 printfd(__FILE__, "To few parameters\n");
1201 for (int i = 0; i < 14; i+=2)
1203 if (strcasecmp(attr[i], "login") == 0)
1205 ParseLogins(attr[i+1]);
1206 /*if (users->FindByName(login, &u))
1208 result = res_unknown;
1213 if (strcasecmp(attr[i], "MsgVer") == 0)
1215 str2x(attr[i+1], msg.header.ver);
1216 if (msg.header.ver != 1)
1217 result = res_params_error;
1220 if (strcasecmp(attr[i], "MsgType") == 0)
1222 str2x(attr[i+1], msg.header.type);
1223 if (msg.header.type != 1)
1224 result = res_params_error;
1227 if (strcasecmp(attr[i], "Repeat") == 0)
1229 str2x(attr[i+1], msg.header.repeat);
1230 if (msg.header.repeat < 0)
1231 result = res_params_error;
1234 if (strcasecmp(attr[i], "RepeatPeriod") == 0)
1236 str2x(attr[i+1], msg.header.repeatPeriod);
1239 if (strcasecmp(attr[i], "ShowTime") == 0)
1241 str2x(attr[i+1], msg.header.showTime);
1244 if (strcasecmp(attr[i], "Text") == 0)
1246 Decode21str(msg.text, attr[i+1]);
1254 //-----------------------------------------------------------------------------
1255 int PARSER_SEND_MESSAGE::ParseEnd(void *, const char *el)
1258 if (strcasecmp(el, "Message") == 0)
1260 result = res_unknown;
1261 for (unsigned i = 0; i < logins.size(); i++)
1263 if (users->FindByName(logins[i], &u))
1265 printfd(__FILE__, "User not found. %s\n", logins[i].c_str());
1268 msg.header.creationTime = stgTime;
1269 u->AddMessage(&msg);
1272 /*if (result == res_ok)
1274 if (strcmp(login, "*") == 0)
1278 printfd(__FILE__, "SendMsg text: %s\n", text);
1279 users->GetAllUsers(SendMessageAllUsers, &msg);
1283 u->AddMessage(pri, text);
1291 //-----------------------------------------------------------------------------
1292 int PARSER_SEND_MESSAGE::ParseLogins(const char * login)
1295 char * l = new char[strlen(login) + 1];
1301 logins.push_back(p);
1302 p = strtok(NULL, ":");
1308 //-----------------------------------------------------------------------------
1309 void PARSER_SEND_MESSAGE::CreateAnswer()
1311 //answerList->clear();
1312 answerList->erase(answerList->begin(), answerList->end());
1313 //answerList->push_back("<SendMessageResult value=\"ok\"/>");
1318 answerList->push_back("<SendMessageResult value=\"ok\"/>");
1320 case res_params_error:
1321 printfd(__FILE__, "res_params_error\n");
1322 answerList->push_back("<SendMessageResult value=\"Parameters error\"/>");
1325 printfd(__FILE__, "res_unknown\n");
1326 answerList->push_back("<SendMessageResult value=\"Unknown user\"/>");
1329 printfd(__FILE__, "res_default\n");
1333 //-----------------------------------------------------------------------------
1335 //-----------------------------------------------------------------------------
1336 int PARSER_DEL_USER::ParseStart(void *, const char *el, const char **attr)
1339 if (strcasecmp(el, "DelUser") == 0)
1341 if (attr[0] == NULL || attr[1] == NULL)
1343 //CreateAnswer("Parameters error!");
1348 if (users->FindByName(attr[1], &u))
1359 //-----------------------------------------------------------------------------
1360 int PARSER_DEL_USER::ParseEnd(void *, const char *el)
1362 if (strcasecmp(el, "DelUser") == 0)
1365 users->Del(u->GetLogin(), currAdmin);
1371 //-----------------------------------------------------------------------------
1372 void PARSER_DEL_USER::CreateAnswer()
1375 answerList->push_back("<DelUser value=\"error\" reason=\"User not found\"/>");
1377 answerList->push_back("<DelUser value=\"ok\"/>");
1379 //-----------------------------------------------------------------------------
1380 /*void PARSERDELUSER::CreateAnswer(char * mes)
1382 //answerList->clear();
1383 answerList->erase(answerList->begin(), answerList->end());
1386 sprintf(str, "<DelUser value=\"%s\"/>", mes);
1387 answerList->push_back(str);
1389 //-----------------------------------------------------------------------------
1391 // <checkuser login="vasya" password=\"123456\"/>
1392 //-----------------------------------------------------------------------------
1393 int PARSER_CHECK_USER::ParseStart(void *, const char *el, const char **attr)
1397 if (strcasecmp(el, "CheckUser") == 0)
1399 if (attr[0] == NULL || attr[1] == NULL
1400 || attr[2] == NULL || attr[3] == NULL)
1404 printfd(__FILE__, "PARSER_CHECK_USER - attr err\n");
1409 if (users->FindByName(attr[1], &user))
1413 printfd(__FILE__, "PARSER_CHECK_USER - login err\n");
1417 if (strcmp(user->GetProperty().password.Get().c_str(), attr[3]))
1421 printfd(__FILE__, "PARSER_CHECK_USER - passwd err\n");
1431 //-----------------------------------------------------------------------------
1432 int PARSER_CHECK_USER::ParseEnd(void *, const char *el)
1434 if (strcasecmp(el, "CheckUser") == 0)
1440 //-----------------------------------------------------------------------------
1441 void PARSER_CHECK_USER::CreateAnswer()
1444 answerList->push_back("<CheckUser value=\"Ok\"/>");
1446 answerList->push_back("<CheckUser value=\"Err\"/>");
1448 //-----------------------------------------------------------------------------
1449 //-----------------------------------------------------------------------------
1450 //-----------------------------------------------------------------------------