2 #include <sys/utsname.h>
4 #include <sys/socket.h>
5 #include <netinet/in.h>
15 #include "../../../settings.h"
16 #include "../../../user_property.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=\"%d\"/>", tariffs->GetTariffsNum());
67 answerList->push_back(s);
69 sprintf(s, "<tariff value=\"%d\"/>", 2);
70 answerList->push_back(s);
72 sprintf(s, "<users_num value=\"%d\"/>", users->GetUserNum());
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 PARSER_GET_USER::PARSER_GET_USER()
101 //-----------------------------------------------------------------------------
102 int PARSER_GET_USER::ParseStart(void *, const char *el, const char **attr)
104 if (strcasecmp(el, "GetUser") == 0)
106 if (attr[0] && attr[1])
111 login.erase(login.begin(), login.end());
118 //-----------------------------------------------------------------------------
119 int PARSER_GET_USER::ParseEnd(void *, const char *el)
121 if (strcasecmp(el, "GetUser") == 0)
128 //-----------------------------------------------------------------------------
129 void PARSER_GET_USER::CreateAnswer()
136 answerList->erase(answerList->begin(), answerList->end());
138 if (users->FindByName(login, &u))
140 s = "<user result=\"error\"/>";
141 answerList->push_back(s);
145 s = "<user result=\"ok\">";
146 answerList->push_back(s);
148 s = "<login value=\"" + u->GetLogin() + "\"/>";
149 answerList->push_back(s);
151 if (currAdmin->GetPriv()->userConf || currAdmin->GetPriv()->userPasswd)
152 s = "<password value=\"" + u->GetProperty().password.Get() + "\" />";
154 s = "<password value=\"++++++\"/>";
155 answerList->push_back(s);
157 strprintf(&s, "<cash value=\"%f\" />", u->GetProperty().cash.Get());
158 answerList->push_back(s);
160 strprintf(&s, "<freemb value=\"%f\" />", u->GetProperty().freeMb.Get());
161 answerList->push_back(s);
163 strprintf(&s, "<credit value=\"%f\" />", u->GetProperty().credit.Get());
164 answerList->push_back(s);
166 if (u->GetProperty().nextTariff.Get() != "")
168 strprintf(&s, "<tariff value=\"%s/%s\" />",
169 u->GetProperty().tariffName.Get().c_str(),
170 u->GetProperty().nextTariff.Get().c_str());
174 strprintf(&s, "<tariff value=\"%s\" />",
175 u->GetProperty().tariffName.Get().c_str());
178 answerList->push_back(s);
180 Encode12str(enc, u->GetProperty().note);
181 s = "<note value=\"" + enc + "\" />";
182 answerList->push_back(s);
184 Encode12str(enc, u->GetProperty().phone);
185 s = "<phone value=\"" + enc + "\" />";
186 answerList->push_back(s);
188 Encode12str(enc, u->GetProperty().address);
189 s = "<address value=\"" + enc + "\" />";
190 answerList->push_back(s);
192 Encode12str(enc, u->GetProperty().email);
193 s = "<email value=\"" + enc + "\" />";
194 answerList->push_back(s);
197 vector<USER_PROPERTY_LOGGED<string> *> userdata;
198 userdata.push_back(u->GetProperty().userdata0.GetPointer());
199 userdata.push_back(u->GetProperty().userdata1.GetPointer());
200 userdata.push_back(u->GetProperty().userdata2.GetPointer());
201 userdata.push_back(u->GetProperty().userdata3.GetPointer());
202 userdata.push_back(u->GetProperty().userdata4.GetPointer());
203 userdata.push_back(u->GetProperty().userdata5.GetPointer());
204 userdata.push_back(u->GetProperty().userdata6.GetPointer());
205 userdata.push_back(u->GetProperty().userdata7.GetPointer());
206 userdata.push_back(u->GetProperty().userdata8.GetPointer());
207 userdata.push_back(u->GetProperty().userdata9.GetPointer());
210 for (unsigned i = 0; i < userdata.size(); i++)
212 Encode12str(enc, userdata[i]->Get());
213 s = "<UserData" + x2str(i, tmpI) + " value=\"" + enc + "\" />";
214 answerList->push_back(s);
217 Encode12str(enc, u->GetProperty().realName);
218 s = "<name value=\"" + enc + "\" />";
219 answerList->push_back(s);
221 Encode12str(enc, u->GetProperty().group);
222 s = "<GROUP value=\"" + enc + "\" />";
223 answerList->push_back(s);
225 strprintf(&s, "<status value=\"%d\" />", u->GetConnected());
226 answerList->push_back(s);
228 strprintf(&s, "<aonline value=\"%d\" />", u->GetProperty().alwaysOnline.Get());
229 answerList->push_back(s);
231 strprintf(&s, "<currip value=\"%s\" />", inet_ntostring(u->GetCurrIP()).c_str());
232 answerList->push_back(s);
234 strprintf(&s, "<PingTime value=\"%lu\" />", u->GetPingTime());
235 answerList->push_back(s);
238 sstr << u->GetProperty().ips.Get();
239 strprintf(&s, "<ip value=\"%s\" />", sstr.str().c_str());
240 answerList->push_back(s);
243 ss = new char[DIR_NUM*25*4 + 50];
245 sprintf(ss, "<traff");
248 download = u->GetProperty().down.Get();
249 upload = u->GetProperty().up.Get();
251 for (int j = 0; j < DIR_NUM; j++)
255 sprintf(st, " MU%d=\"%s\"", j, s.c_str());
258 x2str(download[j], s);
259 sprintf(st, " MD%d=\"%s\"", j, s.c_str());
262 sprintf(st, " SU%d=\"0\"", j);
265 sprintf(st, " SD%d=\"0\"", j);
269 answerList->push_back(ss);
272 strprintf(&s, "<down value=\"%d\" />", u->GetProperty().disabled.Get());
273 answerList->push_back(s);
275 strprintf(&s, "<DisableDetailStat value=\"%d\" />", u->GetProperty().disabledDetailStat.Get());
276 answerList->push_back(s);
278 strprintf(&s, "<passive value=\"%d\" />", u->GetProperty().passive.Get());
279 answerList->push_back(s);
281 strprintf(&s, "<LastCash value=\"%f\" />", u->GetProperty().lastCashAdd.Get());
282 answerList->push_back(s);
284 strprintf(&s, "<LastTimeCash value=\"%ld\" />", u->GetProperty().lastCashAddTime.Get());
285 answerList->push_back(s);
287 strprintf(&s, "<LastActivityTime value=\"%ld\" />", u->GetProperty().lastActivityTime.Get());
288 answerList->push_back(s);
290 strprintf(&s, "<CreditExpire value=\"%ld\" />", u->GetProperty().creditExpire.Get());
291 answerList->push_back(s);
293 strprintf(&s, "</user>");
294 answerList->push_back(s);
296 //-----------------------------------------------------------------------------
298 //-----------------------------------------------------------------------------
299 PARSER_GET_USERS::PARSER_GET_USERS()
300 : lastUserUpdateTime(0),
301 lastUpdateFound(false)
304 //-----------------------------------------------------------------------------
305 int PARSER_GET_USERS::ParseStart(void *, const char *el, const char ** attr)
307 /*if (attr && *attr && *(attr+1))
309 printfd(__FILE__, "attr=%s %s\n", *attr, *(attr+1));
313 printfd(__FILE__, "attr = NULL\n");
316 lastUpdateFound = false;
317 if (strcasecmp(el, "GetUsers") == 0)
319 while (attr && *attr && *(attr+1))
321 if (strcasecmp(*attr, "LastUpdate") == 0)
323 if (str2x(*(attr+1), lastUserUpdateTime) == 0)
325 //printfd(__FILE__, "lastUserUpdateTime=%d\n", lastUserUpdateTime);
326 lastUpdateFound = true;
330 //printfd(__FILE__, "NO lastUserUpdateTime\n");
340 //-----------------------------------------------------------------------------
341 int PARSER_GET_USERS::ParseEnd(void *, const char *el)
343 if (strcasecmp(el, "GetUsers") == 0)
350 //-----------------------------------------------------------------------------
351 void PARSER_GET_USERS::CreateAnswer()
353 answerList->erase(answerList->begin(), answerList->end());
368 int h = users->OpenSearch();
371 printfd(__FILE__, "users->OpenSearch() error\n");
372 users->CloseSearch(h);
376 x2str(time(NULL), updateTime);
379 answerList->push_back("<Users LastUpdate=\"" + updateTime + "\">");
381 answerList->push_back("<Users>");
385 if (users->SearchNext(h, &u))
389 userStart = "<user login=\"" + u->GetLogin() + "\">";
392 if (u->GetProperty().password.ModificationTime() > lastUserUpdateTime)
394 if (currAdmin->GetPriv()->userConf || currAdmin->GetPriv()->userPasswd)
395 s = "<password value=\"" + u->GetProperty().password.Get() + "\" />";
397 s = "<password value=\"++++++\"/>";
402 if (u->GetProperty().cash.ModificationTime() > lastUserUpdateTime)
404 strprintf(&s, "<cash value=\"%f\" />", u->GetProperty().cash.Get());
406 //printfd(__FILE__, "cash value=\"%f\"\n", u->GetProperty().cash.Get());
410 if (u->GetProperty().freeMb.ModificationTime() > lastUserUpdateTime)
412 strprintf(&s, "<freemb value=\"%f\" />", u->GetProperty().freeMb.Get());
416 if (u->GetProperty().credit.ModificationTime() > lastUserUpdateTime)
418 strprintf(&s, "<credit value=\"%f\" />", u->GetProperty().credit.Get());
422 if (u->GetProperty().nextTariff.Get() != "")
424 if (u->GetProperty().tariffName.ModificationTime() > lastUserUpdateTime
425 || u->GetProperty().nextTariff.ModificationTime() > lastUserUpdateTime)
427 strprintf(&s, "<tariff value=\"%s/%s\" />",
428 u->GetProperty().tariffName.Get().c_str(),
429 u->GetProperty().nextTariff.Get().c_str());
435 if (u->GetProperty().tariffName.ModificationTime() > lastUserUpdateTime)
437 strprintf(&s, "<tariff value=\"%s\" />",
438 u->GetProperty().tariffName.Get().c_str());
443 if (u->GetProperty().note.ModificationTime() > lastUserUpdateTime)
445 Encode12str(enc, u->GetProperty().note);
446 strprintf(&s, "<note value=\"%s\" />", enc.c_str());
450 if (u->GetProperty().phone.ModificationTime() > lastUserUpdateTime)
452 Encode12str(enc, u->GetProperty().phone);
453 strprintf(&s, "<phone value=\"%s\" />", enc.c_str());
457 if (u->GetProperty().address.ModificationTime() > lastUserUpdateTime)
459 Encode12str(enc, u->GetProperty().address);
460 strprintf(&s, "<address value=\"%s\" />", enc.c_str());
464 if (u->GetProperty().email.ModificationTime() > lastUserUpdateTime)
466 Encode12str(enc, u->GetProperty().email);
467 strprintf(&s, "<email value=\"%s\" />", enc.c_str());
471 vector<USER_PROPERTY_LOGGED<string> *> userdata;
472 userdata.push_back(u->GetProperty().userdata0.GetPointer());
473 userdata.push_back(u->GetProperty().userdata1.GetPointer());
474 userdata.push_back(u->GetProperty().userdata2.GetPointer());
475 userdata.push_back(u->GetProperty().userdata3.GetPointer());
476 userdata.push_back(u->GetProperty().userdata4.GetPointer());
477 userdata.push_back(u->GetProperty().userdata5.GetPointer());
478 userdata.push_back(u->GetProperty().userdata6.GetPointer());
479 userdata.push_back(u->GetProperty().userdata7.GetPointer());
480 userdata.push_back(u->GetProperty().userdata8.GetPointer());
481 userdata.push_back(u->GetProperty().userdata9.GetPointer());
484 for (unsigned i = 0; i < userdata.size(); i++)
486 if (userdata[i]->ModificationTime() > lastUserUpdateTime)
488 Encode12str(enc, userdata[i]->Get());
489 s = "<UserData" + x2str(i, tmpI) + " value=\"" + enc + "\" />";
494 if (u->GetProperty().realName.ModificationTime() > lastUserUpdateTime)
496 Encode12str(enc, u->GetProperty().realName);
497 strprintf(&s, "<name value=\"%s\" />", enc.c_str());
501 if (u->GetProperty().group.ModificationTime() > lastUserUpdateTime)
503 Encode12str(enc, u->GetProperty().group);
504 strprintf(&s, "<GROUP value=\"%s\" />", enc.c_str());
508 if (u->GetProperty().alwaysOnline.ModificationTime() > lastUserUpdateTime)
510 strprintf(&s, "<aonline value=\"%d\" />", u->GetProperty().alwaysOnline.Get());
514 if (u->GetCurrIPModificationTime() > lastUserUpdateTime)
516 strprintf(&s, "<currip value=\"%s\" />", inet_ntostring(u->GetCurrIP()).c_str());
521 if (u->GetConnectedModificationTime() > lastUserUpdateTime)
523 strprintf(&s, "<status value=\"%d\" />", u->GetConnected());
527 if (u->GetPingTime() > lastUserUpdateTime)
529 strprintf(&s, "<PingTime value=\"%lu\" />", u->GetPingTime());
533 if (u->GetProperty().ips.ModificationTime() > lastUserUpdateTime)
536 sstr << u->GetProperty().ips.Get();
537 strprintf(&s, "<ip value=\"%s\" />", sstr.str().c_str());
542 traffStart = "<traff";
545 download = u->GetProperty().down.Get();
546 upload = u->GetProperty().up.Get();
549 if (u->GetProperty().up.ModificationTime() > lastUserUpdateTime)
551 for (int j = 0; j < DIR_NUM; j++)
555 sprintf(st, " MU%d=\"%s\" ", j, s.c_str());
560 if (u->GetProperty().down.ModificationTime() > lastUserUpdateTime)
562 for (int j = 0; j < DIR_NUM; j++)
564 x2str(download[j], s);
565 sprintf(st, " MD%d=\"%s\" ", j, s.c_str());
571 if (traffMiddle.length() > 0)
573 middle += traffStart;
574 middle += traffMiddle;
575 middle += traffFinish;
578 if (u->GetProperty().disabled.ModificationTime() > lastUserUpdateTime)
580 strprintf(&s, "<down value=\"%d\" />", u->GetProperty().disabled.Get());
584 if (u->GetProperty().disabledDetailStat.ModificationTime() > lastUserUpdateTime)
586 strprintf(&s, "<DisableDetailStat value=\"%d\" />", u->GetProperty().disabledDetailStat.Get());
590 //printfd(__FILE__, ">>>>> %s\n", s.c_str());
592 if (u->GetProperty().passive.ModificationTime() > lastUserUpdateTime)
594 strprintf(&s, "<passive value=\"%d\" />", u->GetProperty().passive.Get());
598 if (u->GetProperty().lastCashAdd.ModificationTime() > lastUserUpdateTime)
600 strprintf(&s, "<LastCash value=\"%f\" />", u->GetProperty().lastCashAdd.Get());
604 if (u->GetProperty().lastCashAddTime.ModificationTime() > lastUserUpdateTime)
606 strprintf(&s, "<LastTimeCash value=\"%ld\" />", u->GetProperty().lastCashAddTime.Get());
611 if (u->GetProperty().lastActivityTime.ModificationTime() > lastUserUpdateTime)
613 strprintf(&s, "<LastActivityTime value=\"%ld\" />", u->GetProperty().lastActivityTime.Get());
617 if (u->GetProperty().creditExpire.ModificationTime() > lastUserUpdateTime)
619 strprintf(&s, "<CreditExpire value=\"%ld\" />", u->GetProperty().creditExpire.Get());
624 userFinish = "</user>";
626 if (middle.length() > 0)
628 /*printfd(__FILE__, "login: %s\n", u->GetLogin().c_str());
629 printfd(__FILE__, "middle: %s\n", middle.c_str());*/
631 answerList->push_back(userStart);
632 answerList->push_back(middle);
633 answerList->push_back(userFinish);
637 users->CloseSearch(h);
639 //answerList->push_back("</Users>");
641 answerList->push_back("</Users>");
643 //-----------------------------------------------------------------------------
645 //-----------------------------------------------------------------------------
646 PARSER_ADD_USER::PARSER_ADD_USER()
650 //-----------------------------------------------------------------------------
651 int PARSER_ADD_USER::ParseStart(void *, const char *el, const char **attr)
657 if (strcasecmp(el, "AddUser") == 0)
664 if (strcasecmp(el, "login") == 0)
672 //-----------------------------------------------------------------------------
673 int PARSER_ADD_USER::ParseEnd(void *, const char *el)
677 if (strcasecmp(el, "AddUser") == 0)
688 //-----------------------------------------------------------------------------
689 void PARSER_ADD_USER::Reset()
691 BASE_PARSER::Reset();
694 //-----------------------------------------------------------------------------
695 void PARSER_ADD_USER::CreateAnswer()
697 //answerList->clear();
698 answerList->erase(answerList->begin(), answerList->end());
700 if (CheckUserData() == 0)
702 answerList->push_back("<AddUser result=\"ok\"/>");
706 answerList->push_back("<AddUser result=\"error\" reason=\"Access denied\"/>");
709 //-----------------------------------------------------------------------------
710 int PARSER_ADD_USER::CheckUserData()
713 if (users->FindByName(login, &u))
715 return users->Add(login, currAdmin);
719 //-----------------------------------------------------------------------------
721 //-----------------------------------------------------------------------------
722 PARSER_CHG_USER::PARSER_CHG_USER()
727 cashMustBeAdded(false),
732 //-----------------------------------------------------------------------------
733 PARSER_CHG_USER::~PARSER_CHG_USER()
740 //-----------------------------------------------------------------------------
741 void PARSER_CHG_USER::Reset()
752 usr = new USER_STAT_RES;
753 ucr = new USER_CONF_RES;
755 upr = new RESETABLE<uint64_t>[DIR_NUM];
756 downr = new RESETABLE<uint64_t>[DIR_NUM];
758 //-----------------------------------------------------------------------------
759 string PARSER_CHG_USER::EncChar2String(const char * strEnc)
762 Decode21str(str, strEnc);
765 //-----------------------------------------------------------------------------
766 int PARSER_CHG_USER::ParseStart(void *, const char *el, const char **attr)
772 if (strcasecmp(el, "SetUser") == 0)
779 //printfd(__FILE__, "el=%s\n", el);
780 if (strcasecmp(el, "login") == 0)
786 if (strcasecmp(el, "ip") == 0)
790 ucr->ips = StrToIPS(attr[1]);
794 printfd(__FILE__, "StrToIPS Error!\n");
798 if (strcasecmp(el, "password") == 0)
800 ucr->password = attr[1];
804 if (strcasecmp(el, "address") == 0)
806 ucr->address = EncChar2String(attr[1]);
810 if (strcasecmp(el, "aonline") == 0)
812 ucr->alwaysOnline = (*(attr[1]) != '0');
816 if (strcasecmp(el, "cash") == 0)
818 if (attr[2] && (strcasecmp(attr[2], "msg") == 0))
820 cashMsg = EncChar2String(attr[3]);
824 if (strtodouble2(attr[1], cash) == 0)
827 if (strcasecmp(attr[0], "set") == 0)
828 cashMustBeAdded = false;
830 if (strcasecmp(attr[0], "add") == 0)
831 cashMustBeAdded = true;
836 if (strcasecmp(el, "CreditExpire") == 0)
838 long int creditExpire = 0;
839 if (str2x(attr[1], creditExpire) == 0)
840 ucr->creditExpire = (time_t)creditExpire;
845 if (strcasecmp(el, "credit") == 0)
848 if (strtodouble2(attr[1], credit) == 0)
849 ucr->credit = credit;
853 if (strcasecmp(el, "freemb") == 0)
856 if (strtodouble2(attr[1], freeMb) == 0)
857 usr->freeMb = freeMb;
861 if (strcasecmp(el, "down") == 0)
864 if (str2x(attr[1], down) == 0)
865 ucr->disabled = down;
869 if (strcasecmp(el, "DisableDetailStat") == 0)
871 int disabledDetailStat = 0;
872 if (str2x(attr[1], disabledDetailStat) == 0)
873 ucr->disabledDetailStat = disabledDetailStat;
877 if (strcasecmp(el, "email") == 0)
879 ucr->email = EncChar2String(attr[1]);
883 for (int i = 0; i < USERDATA_NUM; i++)
886 sprintf(name, "userdata%d", i);
887 if (strcasecmp(el, name) == 0)
889 ucr->userdata[i] = EncChar2String(attr[1]);
894 if (strcasecmp(el, "group") == 0)
896 ucr->group = EncChar2String(attr[1]);
900 if (strcasecmp(el, "note") == 0)
902 ucr->note = EncChar2String(attr[1]);
906 if (strcasecmp(el, "passive") == 0)
909 if (str2x(attr[1], passive) == 0)
910 ucr->passive = passive;
914 if (strcasecmp(el, "phone") == 0)
916 ucr->phone = EncChar2String(attr[1]);
920 if (strcasecmp(el, "Name") == 0)
922 ucr->realName = EncChar2String(attr[1]);
926 if (strcasecmp(el, "traff") == 0)
932 unsigned long long t = 0;
935 dir = attr[j][2] - '0';
937 if (strncasecmp(attr[j], "md", 2) == 0)
943 if (strncasecmp(attr[j], "mu", 2) == 0)
956 if (strcasecmp(el, "tariff") == 0)
958 if (strcasecmp(attr[0], "now") == 0)
959 ucr->tariffName = attr[1];
961 if (strcasecmp(attr[0], "delayed") == 0)
962 ucr->nextTariff = attr[1];
969 //-----------------------------------------------------------------------------
970 int PARSER_CHG_USER::ParseEnd(void *, const char *el)
974 if (strcasecmp(el, "SetUser") == 0)
986 //-----------------------------------------------------------------------------
987 void PARSER_CHG_USER::CreateAnswer()
989 //answerList->clear();
990 answerList->erase(answerList->begin(), answerList->end());
995 answerList->push_back("<SetUser result=\"ok\"/>");
998 answerList->push_back("<SetUser result=\"error\"/>");
1001 answerList->push_back("<SetUser result=\"error\"/>");
1004 answerList->push_back("<SetUser result=\"error\"/>");
1009 //-----------------------------------------------------------------------------
1010 int PARSER_CHG_USER::AplayChanges()
1015 if (users->FindByName(login, &u))
1021 if (!ucr->ips.res_empty())
1022 if (!u->GetProperty().ips.Set(ucr->ips.const_data(), currAdmin, login, store))
1025 if (!ucr->address.res_empty())
1026 if (!u->GetProperty().address.Set(ucr->address.const_data(), currAdmin, login, store))
1029 if (!ucr->alwaysOnline.res_empty())
1030 if (!u->GetProperty().alwaysOnline.Set(ucr->alwaysOnline.const_data(),
1031 currAdmin, login, store))
1034 if (!ucr->creditExpire.res_empty())
1035 if (!u->GetProperty().creditExpire.Set(ucr->creditExpire.const_data(),
1036 currAdmin, login, store))
1039 if (!ucr->credit.res_empty())
1040 if (!u->GetProperty().credit.Set(ucr->credit.const_data(), currAdmin, login, store))
1043 if (!usr->freeMb.res_empty())
1044 if (!u->GetProperty().freeMb.Set(usr->freeMb.const_data(), currAdmin, login, store))
1047 if (!ucr->disabled.res_empty())
1048 if (!u->GetProperty().disabled.Set(ucr->disabled.const_data(), currAdmin, login, store))
1051 if (!ucr->disabledDetailStat.res_empty())
1052 if (!u->GetProperty().disabledDetailStat.Set(ucr->disabledDetailStat.const_data(), currAdmin, login, store))
1055 if (!ucr->email.res_empty())
1056 if (!u->GetProperty().email.Set(ucr->email.const_data(), currAdmin, login, store))
1059 if (!ucr->group.res_empty())
1060 if (!u->GetProperty().group.Set(ucr->group.const_data(), currAdmin, login, store))
1063 if (!ucr->note.res_empty())
1064 if (!u->GetProperty().note.Set(ucr->note.const_data(), currAdmin, login, store))
1067 vector<USER_PROPERTY_LOGGED<string> *> userdata;
1068 userdata.push_back(u->GetProperty().userdata0.GetPointer());
1069 userdata.push_back(u->GetProperty().userdata1.GetPointer());
1070 userdata.push_back(u->GetProperty().userdata2.GetPointer());
1071 userdata.push_back(u->GetProperty().userdata3.GetPointer());
1072 userdata.push_back(u->GetProperty().userdata4.GetPointer());
1073 userdata.push_back(u->GetProperty().userdata5.GetPointer());
1074 userdata.push_back(u->GetProperty().userdata6.GetPointer());
1075 userdata.push_back(u->GetProperty().userdata7.GetPointer());
1076 userdata.push_back(u->GetProperty().userdata8.GetPointer());
1077 userdata.push_back(u->GetProperty().userdata9.GetPointer());
1079 for (int i = 0; i < (int)userdata.size(); i++)
1081 if (!ucr->userdata[i].res_empty())
1083 if(!userdata[i]->Set(ucr->userdata[i].const_data(), currAdmin, login, store))
1088 if (!ucr->passive.res_empty())
1089 if (!u->GetProperty().passive.Set(ucr->passive.const_data(), currAdmin, login, store))
1092 if (!ucr->password.res_empty())
1093 if (!u->GetProperty().password.Set(ucr->password.const_data(), currAdmin, login, store))
1096 if (!ucr->phone.res_empty())
1097 if (!u->GetProperty().phone.Set(ucr->phone.const_data(), currAdmin, login, store))
1100 if (!ucr->realName.res_empty())
1101 if (!u->GetProperty().realName.Set(ucr->realName.const_data(), currAdmin, login, store))
1105 if (!usr->cash.res_empty())
1107 //if (*currAdmin->GetPriv()->userCash)
1109 if (cashMustBeAdded)
1111 if (!u->GetProperty().cash.Set(usr->cash.const_data() + u->GetProperty().cash,
1120 if (!u->GetProperty().cash.Set(usr->cash.const_data(), currAdmin, login, store, cashMsg))
1127 if (!ucr->tariffName.res_empty())
1129 if (tariffs->FindByName(ucr->tariffName.const_data()))
1131 if (!u->GetProperty().tariffName.Set(ucr->tariffName.const_data(), currAdmin, login, store))
1133 u->ResetNextTariff();
1137 //WriteServLog("SetUser: Tariff %s not found", ud.conf.tariffName.c_str());
1142 if (!ucr->nextTariff.res_empty())
1144 if (tariffs->FindByName(ucr->nextTariff.const_data()))
1146 if (!u->GetProperty().nextTariff.Set(ucr->nextTariff.const_data(), currAdmin, login, store))
1151 //WriteServLog("SetUser: Tariff %s not found", ud.conf.tariffName.c_str());
1156 DIR_TRAFF up = u->GetProperty().up;
1157 DIR_TRAFF down = u->GetProperty().down;
1160 for (int i = 0; i < DIR_NUM; i++)
1162 if (!upr[i].res_empty())
1167 if (!downr[i].res_empty())
1175 if (!u->GetProperty().up.Set(up, currAdmin, login, store))
1179 if (!u->GetProperty().down.Set(down, currAdmin, login, store))
1182 /*if (!usr->down.res_empty())
1184 u->GetProperty().down.Set(usr->down.const_data(), currAdmin, login, store);
1186 if (!usr->up.res_empty())
1188 u->GetProperty().up.Set(usr->up.const_data(), currAdmin, login, store);
1196 //-----------------------------------------------------------------------------
1198 //-----------------------------------------------------------------------------
1199 int PARSER_SEND_MESSAGE::ParseStart(void *, const char *el, const char **attr)
1201 if (strcasecmp(el, "Message") == 0)
1203 for (int i = 0; i < 14; i++)
1205 if (attr[i] == NULL)
1207 result = res_params_error;
1209 printfd(__FILE__, "To few parameters\n");
1214 for (int i = 0; i < 14; i+=2)
1216 if (strcasecmp(attr[i], "login") == 0)
1218 ParseLogins(attr[i+1]);
1219 /*if (users->FindByName(login, &u))
1221 result = res_unknown;
1226 if (strcasecmp(attr[i], "MsgVer") == 0)
1228 str2x(attr[i+1], msg.header.ver);
1229 if (msg.header.ver != 1)
1230 result = res_params_error;
1233 if (strcasecmp(attr[i], "MsgType") == 0)
1235 str2x(attr[i+1], msg.header.type);
1236 if (msg.header.type != 1)
1237 result = res_params_error;
1240 if (strcasecmp(attr[i], "Repeat") == 0)
1242 str2x(attr[i+1], msg.header.repeat);
1243 if (msg.header.repeat < 0)
1244 result = res_params_error;
1247 if (strcasecmp(attr[i], "RepeatPeriod") == 0)
1249 str2x(attr[i+1], msg.header.repeatPeriod);
1252 if (strcasecmp(attr[i], "ShowTime") == 0)
1254 str2x(attr[i+1], msg.header.showTime);
1257 if (strcasecmp(attr[i], "Text") == 0)
1259 Decode21str(msg.text, attr[i+1]);
1267 //-----------------------------------------------------------------------------
1268 int PARSER_SEND_MESSAGE::ParseEnd(void *, const char *el)
1271 if (strcasecmp(el, "Message") == 0)
1273 result = res_unknown;
1274 for (unsigned i = 0; i < logins.size(); i++)
1276 if (users->FindByName(logins[i], &u))
1278 printfd(__FILE__, "User not found. %s\n", logins[i].c_str());
1281 msg.header.creationTime = stgTime;
1282 u->AddMessage(&msg);
1285 /*if (result == res_ok)
1287 if (strcmp(login, "*") == 0)
1291 printfd(__FILE__, "SendMsg text: %s\n", text);
1292 users->GetAllUsers(SendMessageAllUsers, &msg);
1296 u->AddMessage(pri, text);
1304 //-----------------------------------------------------------------------------
1305 int PARSER_SEND_MESSAGE::ParseLogins(const char * login)
1308 char * l = new char[strlen(login) + 1];
1314 logins.push_back(p);
1315 p = strtok(NULL, ":");
1321 //-----------------------------------------------------------------------------
1322 void PARSER_SEND_MESSAGE::CreateAnswer()
1324 //answerList->clear();
1325 answerList->erase(answerList->begin(), answerList->end());
1326 //answerList->push_back("<SendMessageResult value=\"ok\"/>");
1331 answerList->push_back("<SendMessageResult value=\"ok\"/>");
1333 case res_params_error:
1334 printfd(__FILE__, "res_params_error\n");
1335 answerList->push_back("<SendMessageResult value=\"Parameters error\"/>");
1338 printfd(__FILE__, "res_unknown\n");
1339 answerList->push_back("<SendMessageResult value=\"Unknown user\"/>");
1342 printfd(__FILE__, "res_default\n");
1346 //-----------------------------------------------------------------------------
1348 //-----------------------------------------------------------------------------
1349 int PARSER_DEL_USER::ParseStart(void *, const char *el, const char **attr)
1352 if (strcasecmp(el, "DelUser") == 0)
1354 if (attr[0] == NULL || attr[1] == NULL)
1356 //CreateAnswer("Parameters error!");
1361 if (users->FindByName(attr[1], &u))
1372 //-----------------------------------------------------------------------------
1373 int PARSER_DEL_USER::ParseEnd(void *, const char *el)
1375 if (strcasecmp(el, "DelUser") == 0)
1378 users->Del(u->GetLogin(), currAdmin);
1384 //-----------------------------------------------------------------------------
1385 void PARSER_DEL_USER::CreateAnswer()
1388 answerList->push_back("<DelUser value=\"error\" reason=\"User not found\"/>");
1390 answerList->push_back("<DelUser value=\"ok\"/>");
1392 //-----------------------------------------------------------------------------
1393 /*void PARSERDELUSER::CreateAnswer(char * mes)
1395 //answerList->clear();
1396 answerList->erase(answerList->begin(), answerList->end());
1399 sprintf(str, "<DelUser value=\"%s\"/>", mes);
1400 answerList->push_back(str);
1402 //-----------------------------------------------------------------------------
1404 // <checkuser login="vasya" password=\"123456\"/>
1405 //-----------------------------------------------------------------------------
1406 int PARSER_CHECK_USER::ParseStart(void *, const char *el, const char **attr)
1410 if (strcasecmp(el, "CheckUser") == 0)
1412 if (attr[0] == NULL || attr[1] == NULL
1413 || attr[2] == NULL || attr[3] == NULL)
1417 printfd(__FILE__, "PARSER_CHECK_USER - attr err\n");
1422 if (users->FindByName(attr[1], &user))
1426 printfd(__FILE__, "PARSER_CHECK_USER - login err\n");
1430 if (strcmp(user->GetProperty().password.Get().c_str(), attr[3]))
1434 printfd(__FILE__, "PARSER_CHECK_USER - passwd err\n");
1444 //-----------------------------------------------------------------------------
1445 int PARSER_CHECK_USER::ParseEnd(void *, const char *el)
1447 if (strcasecmp(el, "CheckUser") == 0)
1453 //-----------------------------------------------------------------------------
1454 void PARSER_CHECK_USER::CreateAnswer()
1457 answerList->push_back("<CheckUser value=\"Ok\"/>");
1459 answerList->push_back("<CheckUser value=\"Err\"/>");
1461 //-----------------------------------------------------------------------------
1462 //-----------------------------------------------------------------------------
1463 //-----------------------------------------------------------------------------