1 // TODO: Fix this shit!
2 #include "../../../admin.h"
3 #include "../../../users.h"
5 #include "parser_getusers.h"
7 PARSER_GET_USERS::PARSER_GET_USERS(const ADMIN * ca, USERS * u)
9 result("<error message=\"Not implemented yet\"/>"),
15 PARSER_GET_USERS::~PARSER_GET_USERS()
19 bool PARSER_GET_USERS::StartTag(const char * name, const char ** attr)
21 std::string tag(name);
22 if (tag != "GetUsers") {
29 bool PARSER_GET_USERS::EndTag(const char * name)
31 std::string tag(name);
32 if (tag != "GetUsers") {
36 int handle = users->OpenSearch();
38 printfd(__FILE__, "PARSER_GET_USERS::EndTag() OpenSearch error\n");
39 users->CloseSearch(handle);
40 result = "<error message=\"Internal error (OpenSearch failed)\"/>";
44 std::stringstream answer;
46 answer << "<Users>\n";
51 if (users->SearchNext(handle, &ui)) {
55 answer << "\t<User>\n";
56 answer << "\t\t<login value=\"" << ui->GetLogin() << "\"/>\n";
57 if (currAdmin->GetPriv()->userConf || currAdmin->GetPriv()->userPasswd) {
58 answer << "\t\t<password value=\"" << ui->property.password.Get() << "\"/>\n";
60 answer << "\t\t<password value=\"++++++++\"/>\n";
62 answer << "\t\t<cash value=\"" << ui->property.cash.Get() << "\"/>\n";
63 answer << "\t\t<freemb value=\"" << ui->property.freeMb.Get() << "\"/>\n";
64 answer << "\t\t<credit value=\"" << ui->property.credit.Get() << "\"/>\n";
65 if (ui->property.nextTariff.Get() != "") {
66 answer << "\t\t<tariff value=\"" << ui->property.tariffName.Get()
67 << "/" << ui->property.nextTariff.Get() << "\"/>\n";
69 answer << "\t\t<tariff value=\"" << ui->property.tariffName.Get() << "\"/>\n";
73 Encode12str(encoded, ui->property.note.Get());
74 answer << "\t\t<note value=\"" << encoded << "\"/>\n";
75 Encode12str(encoded, ui->property.phone.Get());
76 answer << "\t\t<phone value=\"" << encoded << "\"/>\n";
77 Encode12str(encoded, ui->property.address.Get());
78 answer << "\t\t<address value=\"" << encoded << "\"/>\n";
79 Encode12str(encoded, ui->property.email.Get());
80 answer << "\t\t<email value=\"" << encoded << "\"/>\n";
81 Encode12str(encoded, ui->property.realName.Get());
82 answer << "\t\t<name value=\"" << encoded << "\"/>\n";
83 Encode12str(encoded, ui->property.group.Get());
84 answer << "\t\t<group value=\"" << encoded << "\"/>\n";
86 // TODO: Fix this shit!
88 Encode12str(encoded, ui->property.userdata0.Get()); answer << "\t\t<userdata0 value=\"" << encoded << "\"/>\n";
89 Encode12str(encoded, ui->property.userdata1.Get()); answer << "\t\t<userdata1 value=\"" << encoded << "\"/>\n";
90 Encode12str(encoded, ui->property.userdata2.Get()); answer << "\t\t<userdata2 value=\"" << encoded << "\"/>\n";
91 Encode12str(encoded, ui->property.userdata3.Get()); answer << "\t\t<userdata3 value=\"" << encoded << "\"/>\n";
92 Encode12str(encoded, ui->property.userdata4.Get()); answer << "\t\t<userdata4 value=\"" << encoded << "\"/>\n";
93 Encode12str(encoded, ui->property.userdata5.Get()); answer << "\t\t<userdata5 value=\"" << encoded << "\"/>\n";
94 Encode12str(encoded, ui->property.userdata6.Get()); answer << "\t\t<userdata6 value=\"" << encoded << "\"/>\n";
95 Encode12str(encoded, ui->property.userdata7.Get()); answer << "\t\t<userdata7 value=\"" << encoded << "\"/>\n";
96 Encode12str(encoded, ui->property.userdata8.Get()); answer << "\t\t<userdata8 value=\"" << encoded << "\"/>\n";
97 Encode12str(encoded, ui->property.userdata9.Get()); answer << "\t\t<userdata9 value=\"" << encoded << "\"/>\n";
100 answer << "\t\t<status value=\"" << ui->GetConnected() << "\"/>\n";
101 answer << "\t\t<aonline value=\"" << ui->property.alwaysOnline.Get() << "\"/>\n";
102 answer << "\t\t<currip value=\"" << inet_ntostring(ui->GetCurrIP()) << "\"/>\n";
103 answer << "\t\t<pingtime value=\"" << ui->GetPingTime() << "\"/>\n";
104 answer << "\t\t<ip value=\"" << ui->property.ips.Get() << "\"/>\n";
105 answer << "\t\t<lastcash value=\"" << ui->property.lastCashAdd.Get() << "\"/>\n";
106 answer << "\t\t<lasttimecash value=\"" << ui->property.lastCashAddTime.Get() << "\"/>\n";
107 answer << "\t\t<lastactivitytime value=\"" << ui->property.lastActivityTime.Get() << "\"/>\n";
108 answer << "\t\t<creditexpire value=\"" << ui->property.creditExpire.Get() << "\"/>\n";
109 answer << "\t\t<down value=\"" << ui->property.disabled.Get() << "\"/>\n";
110 answer << "\t\t<passive value=\"" << ui->property.passive.Get() << "\"/>\n";
111 answer << "\t\t<disabledetailstat value=\"" << ui->property.disabledDetailStat.Get() << "\"/>\n";
113 // TODO: Fix this shit!
115 answer << "\t\t<traff ";
116 DIR_TRAFF up(ui->property.up.Get());
117 DIR_TRAFF down(ui->property.down.Get());
118 for (int i = 0; i < DIR_NUM; ++i) {
119 answer << "MU" << i << "=\"" << up[i] << "\" ";
120 answer << "MD" << i << "=\"" << down[i] << "\" ";
125 answer << "\t</User>\n";
128 answer << "</Users>";
130 users->CloseSearch(handle);
132 result = answer.str();