// TODO: Fix this shit!
#include "../../../admin.h"
#include "../../../users.h"
#include "parser_getuser.h"
PARSER_GET_USER::PARSER_GET_USER(const ADMIN * ca, const USERS * u)
: PARSER(),
result(""),
currAdmin(ca),
users(u)
{
}
PARSER_GET_USER::~PARSER_GET_USER()
{
}
bool PARSER_GET_USER::StartTag(const char * name, const char ** attr)
{
std::string tag(name);
if (tag != "GetUser") {
return false;
}
if (attr[0] == NULL || attr[1] == NULL) {
return false;
}
login = attr[1];
return true;
}
bool PARSER_GET_USER::EndTag(const char * name)
{
std::string tag(name);
if (tag != "GetUser") {
return false;
}
if (login == "") {
result = "";
return false;
}
user_iter ui;
if (users->FindByName(login, &ui)) {
result ="";
return false;
}
std::stringstream answer;
answer << "\n";
answer << "\tGetLogin() << "\"/>\n";
if (currAdmin->GetPriv()->userConf || currAdmin->GetPriv()->userPasswd) {
answer << "\tproperty.password.Get() << "\"/>\n";
} else {
answer << "\t\n";
}
answer << "\tproperty.cash.Get() << "\"/>\n";
answer << "\tproperty.freeMb.Get() << "\"/>\n";
answer << "\tproperty.credit.Get() << "\"/>\n";
if (ui->property.nextTariff.Get() != "") {
answer << "\tproperty.tariffName.Get()
<< "/" << ui->property.nextTariff.Get() << "\"/>\n";
} else {
answer << "\tproperty.tariffName.Get() << "\"/>\n";
}
std::string encoded;
Encode12str(encoded, ui->property.note.Get());
answer << "\t\n";
Encode12str(encoded, ui->property.phone.Get());
answer << "\t\n";
Encode12str(encoded, ui->property.address.Get());
answer << "\t\n";
Encode12str(encoded, ui->property.email.Get());
answer << "\t\n";
Encode12str(encoded, ui->property.realName.Get());
answer << "\t\n";
Encode12str(encoded, ui->property.group.Get());
answer << "\t\n";
// TODO: Fix this shit!
//
Encode12str(encoded, ui->property.userdata0.Get()); answer << "\t\n";
Encode12str(encoded, ui->property.userdata1.Get()); answer << "\t\n";
Encode12str(encoded, ui->property.userdata2.Get()); answer << "\t\n";
Encode12str(encoded, ui->property.userdata3.Get()); answer << "\t\n";
Encode12str(encoded, ui->property.userdata4.Get()); answer << "\t\n";
Encode12str(encoded, ui->property.userdata5.Get()); answer << "\t\n";
Encode12str(encoded, ui->property.userdata6.Get()); answer << "\t\n";
Encode12str(encoded, ui->property.userdata7.Get()); answer << "\t\n";
Encode12str(encoded, ui->property.userdata8.Get()); answer << "\t\n";
Encode12str(encoded, ui->property.userdata9.Get()); answer << "\t\n";
//
answer << "\tGetConnected() << "\"/>\n";
answer << "\tproperty.alwaysOnline.Get() << "\"/>\n";
answer << "\tGetCurrIP()) << "\"/>\n";
answer << "\tGetPingTime() << "\"/>\n";
answer << "\tproperty.ips.Get() << "\"/>\n";
answer << "\tproperty.lastCashAdd.Get() << "\"/>\n";
answer << "\tproperty.lastCashAddTime.Get() << "\"/>\n";
answer << "\tproperty.lastActivityTime.Get() << "\"/>\n";
answer << "\tproperty.creditExpire.Get() << "\"/>\n";
answer << "\tproperty.down.Get() << "\"/>\n";
answer << "\tproperty.passive.Get() << "\"/>\n";
answer << "\tproperty.disabledDetailStat.Get() << "\"/>\n";
// TODO: Fix this shit!
//
answer << "\tproperty.up.Get());
DIR_TRAFF down(ui->property.down.Get());
for (int i = 0; i < DIR_NUM; ++i) {
answer << "MU" << i << "=\"" << up[i] << "\" ";
answer << "MD" << i << "=\"" << down[i] << "\" ";
}
answer << "/>\n";
//
answer << "";
result = answer.str();
return true;
}