class ADMINS {
public:
- virtual int Add(const std::string & login, const ADMIN & admin) = 0;
- virtual int Del(const std::string & login, const ADMIN & admin) = 0;
- virtual int Change(const ADMIN_CONF & ac, const ADMIN & admin) = 0;
+ virtual int Add(const std::string & login, const ADMIN * admin) = 0;
+ virtual int Del(const std::string & login, const ADMIN * admin) = 0;
+ virtual int Change(const ADMIN_CONF & ac, const ADMIN * admin) = 0;
virtual const ADMIN * GetSysAdmin() const = 0;
virtual const ADMIN * GetNoAdmin() const = 0;
virtual bool FindAdmin(const std::string & l, ADMIN ** admin) = 0;
virtual bool AdminExists(const std::string & login) const = 0;
virtual bool AdminCorrect(const std::string & login,
const std::string & password,
- ADMIN * admin) const = 0;
+ ADMIN ** admin) = 0;
virtual const std::string & GetStrError() const = 0;
virtual int OpenSearch() const = 0;
virtual const TARIFF * FindByName(const std::string & name) const = 0;
virtual const TARIFF * GetNoTariff() const = 0;
virtual int GetTariffsNum() const = 0;
- virtual int Del(const std::string & name, const ADMIN & admin) = 0;
- virtual int Add(const std::string & name, const ADMIN & admin) = 0;
- virtual int Chg(const TARIFF_DATA & td, const ADMIN & admin) = 0;
+ virtual int Del(const std::string & name, const ADMIN * admin) = 0;
+ virtual int Add(const std::string & name, const ADMIN * admin) = 0;
+ virtual int Chg(const TARIFF_DATA & td, const ADMIN * admin) = 0;
virtual void GetTariffsData(std::list<TARIFF_DATA> * tdl) = 0;
virtual void AddNotifierUserDel(NOTIFIER_BASE<USER_PTR> * notifier) = 0;
virtual void DelNotifierUserDel(NOTIFIER_BASE<USER_PTR> * notifier) = 0;
- virtual int Add(const std::string & login, const ADMIN & admin) = 0;
- virtual void Del(const std::string & login, const ADMIN & admin) = 0;
+ virtual int Add(const std::string & login, const ADMIN * admin) = 0;
+ virtual void Del(const std::string & login, const ADMIN * admin) = 0;
virtual int ReadUsers() = 0;
virtual int GetUserNum() const = 0;
ReadAdmins();
}
//-----------------------------------------------------------------------------
-int ADMINS_IMPL::Add(const string & login, const ADMIN & admin)
+int ADMINS_IMPL::Add(const string & login, const ADMIN * admin)
{
STG_LOCKER lock(&mutex, __FILE__, __LINE__);
-const PRIV * priv = admin.GetPriv();
+const PRIV * priv = admin->GetPriv();
if (!priv->adminChg)
{
- string s = admin.GetLogStr() + " Add administrator \'" + login + "\'. Access denied.";
+ string s = admin->GetLogStr() + " Add administrator \'" + login + "\'. Access denied.";
strError = "Access denied.";
WriteServLog(s.c_str());
return -1;
if (ai != data.end())
{
strError = "Administrator \'" + login + "\' cannot not be added. Administrator alredy exist.";
- WriteServLog("%s %s", admin.GetLogStr().c_str(), strError.c_str());
+ WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str());
return -1;
}
if (store->AddAdmin(login) == 0)
{
WriteServLog("%s Administrator \'%s\' added.",
- admin.GetLogStr().c_str(), login.c_str());
+ admin->GetLogStr().c_str(), login.c_str());
return 0;
}
strError = "Administrator \'" + login + "\' was not added. Error: " + store->GetStrError();
-WriteServLog("%s %s", admin.GetLogStr().c_str(), strError.c_str());
+WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str());
return -1;
}
//-----------------------------------------------------------------------------
-int ADMINS_IMPL::Del(const string & login, const ADMIN & admin)
+int ADMINS_IMPL::Del(const string & login, const ADMIN * admin)
{
STG_LOCKER lock(&mutex, __FILE__, __LINE__);
ADMIN_IMPL adm(0, login, "");
-const PRIV * priv = admin.GetPriv();
+const PRIV * priv = admin->GetPriv();
if (!priv->adminChg)
{
- string s = admin.GetLogStr() + " Delete administrator \'" + login + "\'. Access denied.";
+ string s = admin->GetLogStr() + " Delete administrator \'" + login + "\'. Access denied.";
strError = "Access denied.";
WriteServLog(s.c_str());
return -1;
if (ai == data.end())
{
strError = "Administrator \'" + login + "\' cannot be deleted. Administrator does not exist.";
- WriteServLog("%s %s", admin.GetLogStr().c_str(), strError.c_str());
+ WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str());
return -1;
}
if (store->DelAdmin(login) < 0)
{
strError = "Administrator \'" + login + "\' was not deleted. Error: " + store->GetStrError();
- WriteServLog("%s %s", admin.GetLogStr().c_str(), strError.c_str());
+ WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str());
return -1;
}
-WriteServLog("%s Administrator \'%s\' deleted.", admin.GetLogStr().c_str(), login.c_str());
+WriteServLog("%s Administrator \'%s\' deleted.", admin->GetLogStr().c_str(), login.c_str());
return 0;
}
//-----------------------------------------------------------------------------
-int ADMINS_IMPL::Change(const ADMIN_CONF & ac, const ADMIN & admin)
+int ADMINS_IMPL::Change(const ADMIN_CONF & ac, const ADMIN * admin)
{
STG_LOCKER lock(&mutex, __FILE__, __LINE__);
-const PRIV * priv = admin.GetPriv();
+const PRIV * priv = admin->GetPriv();
if (!priv->adminChg)
{
- string s = admin.GetLogStr() + " Change administrator \'" + ac.login + "\'. Access denied.";
+ string s = admin->GetLogStr() + " Change administrator \'" + ac.login + "\'. Access denied.";
strError = "Access denied.";
WriteServLog(s.c_str());
return -1;
if (ai == data.end())
{
strError = "Administrator \'" + ac.login + "\' cannot be changed " + ". Administrator does not exist.";
- WriteServLog("%s %s", admin.GetLogStr().c_str(), strError.c_str());
+ WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str());
return -1;
}
}
WriteServLog("%s Administrator \'%s\' changed.",
- admin.GetLogStr().c_str(), ac.login.c_str());
+ admin->GetLogStr().c_str(), ac.login.c_str());
return 0;
}
return false;
}
//-----------------------------------------------------------------------------
-bool ADMINS_IMPL::AdminCorrect(const string & login, const std::string & password, ADMIN * admin) const
+bool ADMINS_IMPL::AdminCorrect(const string & login, const std::string & password, ADMIN ** admin)
{
STG_LOCKER lock(&mutex, __FILE__, __LINE__);
if (data.empty())
}
ADMIN_IMPL adm(0, login, "");
-const_admin_iter ai(find(data.begin(), data.end(), adm));
+admin_iter ai(find(data.begin(), data.end(), adm));
if (ai == data.end())
{
return false;
}
-*admin = *ai;
+*admin = &(*ai);
return true;
}
ADMINS_IMPL(STORE * st);
virtual ~ADMINS_IMPL() {}
- int Add(const string & login, const ADMIN & admin);
- int Del(const string & login, const ADMIN & admin);
- int Change(const ADMIN_CONF & ac, const ADMIN & admin);
+ int Add(const string & login, const ADMIN * admin);
+ int Del(const string & login, const ADMIN * admin);
+ int Change(const ADMIN_CONF & ac, const ADMIN * admin);
void PrintAdmins() const;
const ADMIN * GetSysAdmin() const { return &stg; }
const ADMIN * GetNoAdmin() const { return &noAdmin; }
bool AdminExists(const std::string & login) const;
bool AdminCorrect(const std::string & login,
const std::string & password,
- ADMIN * admin) const;
+ ADMIN ** admin);
const std::string & GetStrError() const { return strError; }
int OpenSearch() const;
tariffs = new TARIFFS_IMPL(dataStore);
admins = new ADMINS_IMPL(dataStore);
-users = new USERS_IMPL(settings, dataStore, tariffs, *admins->GetSysAdmin());
+users = new USERS_IMPL(settings, dataStore, tariffs, admins->GetSysAdmin());
traffCnt = new TRAFFCOUNTER(users, tariffs, settings->GetRulesFileName());
traffCnt->SetMonitorDir(settings->GetMonitorDir());
USER_PTR u;
if (users->FindByName(login, &u))
{
- return users->Add(login, *currAdmin);
+ return users->Add(login, currAdmin);
}
return -1;
}
}
if (!ucr->ips.res_empty())
- if (!u->GetProperty().ips.Set(ucr->ips.const_data(), *currAdmin, login, store))
+ if (!u->GetProperty().ips.Set(ucr->ips.const_data(), currAdmin, login, store))
res = -1;
if (!ucr->address.res_empty())
- if (!u->GetProperty().address.Set(ucr->address.const_data(), *currAdmin, login, store))
+ if (!u->GetProperty().address.Set(ucr->address.const_data(), currAdmin, login, store))
res = -1;
if (!ucr->alwaysOnline.res_empty())
if (!u->GetProperty().alwaysOnline.Set(ucr->alwaysOnline.const_data(),
- *currAdmin, login, store))
+ currAdmin, login, store))
res = -1;
if (!ucr->creditExpire.res_empty())
if (!u->GetProperty().creditExpire.Set(ucr->creditExpire.const_data(),
- *currAdmin, login, store))
+ currAdmin, login, store))
res = -1;
if (!ucr->credit.res_empty())
- if (!u->GetProperty().credit.Set(ucr->credit.const_data(), *currAdmin, login, store))
+ if (!u->GetProperty().credit.Set(ucr->credit.const_data(), currAdmin, login, store))
res = -1;
if (!usr->freeMb.res_empty())
- if (!u->GetProperty().freeMb.Set(usr->freeMb.const_data(), *currAdmin, login, store))
+ if (!u->GetProperty().freeMb.Set(usr->freeMb.const_data(), currAdmin, login, store))
res = -1;
if (!ucr->disabled.res_empty())
- if (!u->GetProperty().disabled.Set(ucr->disabled.const_data(), *currAdmin, login, store))
+ if (!u->GetProperty().disabled.Set(ucr->disabled.const_data(), currAdmin, login, store))
res = -1;
if (!ucr->disabledDetailStat.res_empty())
- if (!u->GetProperty().disabledDetailStat.Set(ucr->disabledDetailStat.const_data(), *currAdmin, login, store))
+ if (!u->GetProperty().disabledDetailStat.Set(ucr->disabledDetailStat.const_data(), currAdmin, login, store))
res = -1;
if (!ucr->email.res_empty())
- if (!u->GetProperty().email.Set(ucr->email.const_data(), *currAdmin, login, store))
+ if (!u->GetProperty().email.Set(ucr->email.const_data(), currAdmin, login, store))
res = -1;
if (!ucr->group.res_empty())
- if (!u->GetProperty().group.Set(ucr->group.const_data(), *currAdmin, login, store))
+ if (!u->GetProperty().group.Set(ucr->group.const_data(), currAdmin, login, store))
res = -1;
if (!ucr->note.res_empty())
- if (!u->GetProperty().note.Set(ucr->note.const_data(), *currAdmin, login, store))
+ if (!u->GetProperty().note.Set(ucr->note.const_data(), currAdmin, login, store))
res = -1;
vector<USER_PROPERTY_LOGGED<string> *> userdata;
{
if (!ucr->userdata[i].res_empty())
{
- if(!userdata[i]->Set(ucr->userdata[i].const_data(), *currAdmin, login, store))
+ if(!userdata[i]->Set(ucr->userdata[i].const_data(), currAdmin, login, store))
res = -1;
}
}
if (!ucr->passive.res_empty())
- if (!u->GetProperty().passive.Set(ucr->passive.const_data(), *currAdmin, login, store))
+ if (!u->GetProperty().passive.Set(ucr->passive.const_data(), currAdmin, login, store))
res = -1;
if (!ucr->password.res_empty())
- if (!u->GetProperty().password.Set(ucr->password.const_data(), *currAdmin, login, store))
+ if (!u->GetProperty().password.Set(ucr->password.const_data(), currAdmin, login, store))
res = -1;
if (!ucr->phone.res_empty())
- if (!u->GetProperty().phone.Set(ucr->phone.const_data(), *currAdmin, login, store))
+ if (!u->GetProperty().phone.Set(ucr->phone.const_data(), currAdmin, login, store))
res = -1;
if (!ucr->realName.res_empty())
- if (!u->GetProperty().realName.Set(ucr->realName.const_data(), *currAdmin, login, store))
+ if (!u->GetProperty().realName.Set(ucr->realName.const_data(), currAdmin, login, store))
res = -1;
if (cashMustBeAdded)
{
if (!u->GetProperty().cash.Set(usr->cash.const_data() + u->GetProperty().cash,
- *currAdmin,
- login,
- store,
- cashMsg))
+ currAdmin,
+ login,
+ store,
+ cashMsg))
res = -1;
}
else
{
- if (!u->GetProperty().cash.Set(usr->cash.const_data(), *currAdmin, login, store, cashMsg))
+ if (!u->GetProperty().cash.Set(usr->cash.const_data(), currAdmin, login, store, cashMsg))
res = -1;
}
}
{
if (tariffs->FindByName(ucr->tariffName.const_data()))
{
- if (!u->GetProperty().tariffName.Set(ucr->tariffName.const_data(), *currAdmin, login, store))
+ if (!u->GetProperty().tariffName.Set(ucr->tariffName.const_data(), currAdmin, login, store))
res = -1;
u->ResetNextTariff();
}
{
if (tariffs->FindByName(ucr->nextTariff.const_data()))
{
- if (!u->GetProperty().nextTariff.Set(ucr->nextTariff.const_data(), *currAdmin, login, store))
+ if (!u->GetProperty().nextTariff.Set(ucr->nextTariff.const_data(), currAdmin, login, store))
res = -1;
}
else
}
if (upCount)
- if (!u->GetProperty().up.Set(up, *currAdmin, login, store))
+ if (!u->GetProperty().up.Set(up, currAdmin, login, store))
res = -1;
if (downCount)
- if (!u->GetProperty().down.Set(down, *currAdmin, login, store))
+ if (!u->GetProperty().down.Set(down, currAdmin, login, store))
res = -1;
/*if (!usr->down.res_empty())
{
- u->GetProperty().down.Set(usr->down.const_data(), *currAdmin, login, store);
+ u->GetProperty().down.Set(usr->down.const_data(), currAdmin, login, store);
}
if (!usr->up.res_empty())
{
- u->GetProperty().up.Set(usr->up.const_data(), *currAdmin, login, store);
+ u->GetProperty().up.Set(usr->up.const_data(), currAdmin, login, store);
}*/
u->WriteConf();
if (strcasecmp(el, "DelUser") == 0)
{
if (!res)
- users->Del(u->GetLogin(), *currAdmin);
+ users->Del(u->GetLogin(), currAdmin);
return 0;
}
//answerList->clear();
answerList->erase(answerList->begin(), answerList->end());
-if (admins->Del(adminToDel, *currAdmin) == 0)
+if (admins->Del(adminToDel, currAdmin) == 0)
{
answerList->push_back("<DelAdmin Result=\"Ok\"/>");
}
//answerList->clear();
answerList->erase(answerList->begin(), answerList->end());
-if (admins->Add(adminToAdd, *currAdmin) == 0)
+if (admins->Add(adminToAdd, currAdmin) == 0)
{
answerList->push_back("<AddAdmin Result=\"Ok\"/>");
}
conf.priv.tariffChg = (p & 0x3000) >> 0x0C; // 1000+2000
}
- if (admins->Change(conf, *currAdmin) != 0)
+ if (admins->Change(conf, currAdmin) != 0)
{
strprintf(&s, "<ChgAdmin Result = \"%s\"/>", admins->GetStrError().c_str());
answerList->push_back(s);
//answerList->clear();
answerList->erase(answerList->begin(), answerList->end());
-if (tariffs->Add(tariffToAdd, *currAdmin) == 0)
+if (tariffs->Add(tariffToAdd, currAdmin) == 0)
{
answerList->push_back("<AddTariff Result=\"Ok\"/>");
}
return;
}
-if (tariffs->Del(tariffToDel, *currAdmin) == 0)
+if (tariffs->Del(tariffToDel, currAdmin) == 0)
{
answerList->push_back("<DelTariff Result=\"Ok\"/>");
}
if (!td.tariffConf.name.data().empty())
{
TARIFF_DATA tariffData = td.GetData();
- if (tariffs->Chg(tariffData, *currAdmin) == 0)
+ if (tariffs->Chg(tariffData, currAdmin) == 0)
{
answerList->push_back("<SetTariff Result=\"ok\"/>");
return;
return NULL;
}
//-----------------------------------------------------------------------------
-int TARIFFS_IMPL::Chg(const TARIFF_DATA & td, const ADMIN & admin)
+int TARIFFS_IMPL::Chg(const TARIFF_DATA & td, const ADMIN * admin)
{
-const PRIV * priv = admin.GetPriv();
+const PRIV * priv = admin->GetPriv();
if (!priv->tariffChg)
{
- string s = admin.GetLogStr() + " Change tariff \'"
+ string s = admin->GetLogStr() + " Change tariff \'"
+ td.tariffConf.name + "\'. Access denied.";
strError = "Access denied.";
WriteServLog(s.c_str());
if (ti == tariffs.end())
{
strError = "Tariff \'" + td.tariffConf.name + "\' cannot be changed. Tariff does not exist.";
- WriteServLog("%s %s", admin.GetLogStr().c_str(), strError.c_str());
+ WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str());
return -1;
}
}
WriteServLog("%s Tariff \'%s\' changed.",
- admin.GetLogStr().c_str(), td.tariffConf.name.c_str());
+ admin->GetLogStr().c_str(), td.tariffConf.name.c_str());
return 0;
}
//-----------------------------------------------------------------------------
-int TARIFFS_IMPL::Del(const string & name, const ADMIN & admin)
+int TARIFFS_IMPL::Del(const string & name, const ADMIN * admin)
{
-const PRIV * priv = admin.GetPriv();
+const PRIV * priv = admin->GetPriv();
if (!priv->tariffChg)
{
- string s = admin.GetLogStr() + " Delete tariff \'"
+ string s = admin->GetLogStr() + " Delete tariff \'"
+ name + "\'. Access denied.";
strError = "Access denied.";
WriteServLog(s.c_str());
if (ti == tariffs.end())
{
strError = "Tariff \'" + name + "\' cannot be deleted. Tariff does not exist.";
- WriteServLog("%s %s", admin.GetLogStr().c_str(), strError.c_str());
+ WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str());
return -1;
}
tariffs.erase(ti);
WriteServLog("%s Tariff \'%s\' deleted.",
- admin.GetLogStr().c_str(),
+ admin->GetLogStr().c_str(),
name.c_str());
return 0;
}
//-----------------------------------------------------------------------------
-int TARIFFS_IMPL::Add(const string & name, const ADMIN & admin)
+int TARIFFS_IMPL::Add(const string & name, const ADMIN * admin)
{
-const PRIV * priv = admin.GetPriv();
+const PRIV * priv = admin->GetPriv();
if (!priv->tariffChg)
{
- string s = admin.GetLogStr() + " Add tariff \'"
+ string s = admin->GetLogStr() + " Add tariff \'"
+ name + "\'. Access denied.";
strError = "Access denied.";
WriteServLog(s.c_str());
if (ti != tariffs.end())
{
strError = "Tariff \'" + name + "\' cannot be added. Tariff alredy exist.";
- WriteServLog("%s %s", admin.GetLogStr().c_str(), strError.c_str());
+ WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str());
return -1;
}
}
WriteServLog("%s Tariff \'%s\' added.",
- admin.GetLogStr().c_str(), name.c_str());
+ admin->GetLogStr().c_str(), name.c_str());
return 0;
}
const TARIFF * FindByName(const std::string & name) const;
const TARIFF * GetNoTariff() const { return &noTariff; };
int GetTariffsNum() const;
- int Del(const std::string & name, const ADMIN & admin);
- int Add(const std::string & name, const ADMIN & admin);
- int Chg(const TARIFF_DATA & td, const ADMIN & admin);
+ int Del(const std::string & name, const ADMIN * admin);
+ int Add(const std::string & name, const ADMIN * admin);
+ int Chg(const TARIFF_DATA & td, const ADMIN * admin);
void GetTariffsData(std::list<TARIFF_DATA> * tdl);
USER_IMPL::USER_IMPL(const SETTINGS * s,
const STORE * st,
const TARIFFS * t,
- const ADMIN & a,
+ const ADMIN * a,
const USERS * u)
: users(u),
property(s),
USER_IMPL(const SETTINGS * settings,
const STORE * store,
const TARIFFS * tariffs,
- const ADMIN & sysAdmin,
+ const ADMIN * sysAdmin,
const USERS * u);
USER_IMPL(const USER_IMPL & u);
virtual ~USER_IMPL();
time_t pingTime;
- const ADMIN & sysAdmin;
+ const ADMIN * sysAdmin;
const STORE * store;
const TARIFFS * tariffs;
const varT & Get() const;
const string & GetName() const;
bool Set(const varT & val,
- const ADMIN & admin,
+ const ADMIN * admin,
const string & login,
const STORE * store,
const string & msg = "");
private:
void WriteAccessDenied(const string & login,
- const ADMIN & admin,
+ const ADMIN * admin,
const string & parameter);
void WriteSuccessChange(const string & login,
- const ADMIN & admin,
+ const ADMIN * admin,
const string & parameter,
const string & oldValue,
const string & newValue,
const string & paramName,
const string & oldValue,
const string & newValue,
- const ADMIN & admin);
+ const ADMIN * admin);
string name; // parameter name. needed for logging
bool isPassword; // is parameter password. when true, it will be logged as *******
//-------------------------------------------------------------------------
template <typename varT>
bool USER_PROPERTY_LOGGED<varT>::Set(const varT & val,
- const ADMIN & admin,
+ const ADMIN * admin,
const string & login,
const STORE * store,
const string & msg)
{
STG_LOCKER locker(&mutex, __FILE__, __LINE__);
-//cout << "USER_PROPERTY_LOGGED " << val << endl;
-//value = val;
-//modificationTime = stgTime;
-
-const PRIV * priv = admin.GetPriv();
-string adm_login = admin.GetLogin();
-string adm_ip = admin.GetIPStr();
+const PRIV * priv = admin->GetPriv();
+string adm_login = admin->GetLogin();
+string adm_ip = admin->GetIPStr();
if ((priv->userConf && !isStat) || (priv->userStat && isStat) || (priv->userPasswd && isPassword) || (priv->userCash && name == "cash"))
{
//-------------------------------------------------------------------------
template <typename varT>
void USER_PROPERTY_LOGGED<varT>::WriteAccessDenied(const string & login,
- const ADMIN & admin,
+ const ADMIN * admin,
const string & parameter)
{
stgLogger("%s Change user \'%s.\' Parameter \'%s\'. Access denied.",
- admin.GetLogStr().c_str(), login.c_str(), parameter.c_str());
+ admin->GetLogStr().c_str(), login.c_str(), parameter.c_str());
}
//-------------------------------------------------------------------------
template <typename varT>
void USER_PROPERTY_LOGGED<varT>::WriteSuccessChange(const string & login,
- const ADMIN & admin,
+ const ADMIN * admin,
const string & parameter,
const string & oldValue,
const string & newValue,
const STORE * store)
{
stgLogger("%s User \'%s\': \'%s\' parameter changed from \'%s\' to \'%s\'. %s",
- admin.GetLogStr().c_str(),
+ admin->GetLogStr().c_str(),
login.c_str(),
parameter.c_str(),
oldValue.c_str(),
newValue.c_str(),
msg.c_str());
-store->WriteUserChgLog(login, admin.GetLogin(), admin.GetIP(), parameter, oldValue, newValue, msg);
+store->WriteUserChgLog(login, admin->GetLogin(), admin->GetIP(), parameter, oldValue, newValue, msg);
}
//-------------------------------------------------------------------------
template <typename varT>
const string & paramName,
const string & oldValue,
const string & newValue,
- const ADMIN & admin)
+ const ADMIN * admin)
{
string str1;
if (access(str1.c_str(), X_OK) == 0)
{
- string str2("\"" + str1 + "\" \"" + login + "\" \"" + paramName + "\" \"" + oldValue + "\" \"" + newValue + "\" \"" + admin.GetLogin() + "\" \"" + admin.GetIPStr() + "\"");
+ string str2("\"" + str1 + "\" \"" + login + "\" \"" + paramName + "\" \"" + oldValue + "\" \"" + newValue + "\" \"" + admin->GetLogin() + "\" \"" + admin->GetIPStr() + "\"");
ScriptExec(str2);
}
else
//#define USERS_DEBUG 1
//-----------------------------------------------------------------------------
-USERS_IMPL::USERS_IMPL(SETTINGS * s, STORE * st, TARIFFS * t, const ADMIN & sa)
+USERS_IMPL::USERS_IMPL(SETTINGS * s, STORE * st, TARIFFS * t, const ADMIN * sa)
: users(),
usersToDelete(),
userIPNotifiersBefore(),
return false;
}
//-----------------------------------------------------------------------------
-int USERS_IMPL::Add(const string & login, const ADMIN & admin)
+int USERS_IMPL::Add(const string & login, const ADMIN * admin)
{
STG_LOCKER lock(&mutex, __FILE__, __LINE__);
-const PRIV * priv = admin.GetPriv();
+const PRIV * priv = admin->GetPriv();
if (!priv->userAddDel)
{
WriteServLog("%s tried to add user \'%s\'. Access denied.",
- admin.GetLogStr().c_str(), login.c_str());
- /*errorStr = "Admin \'" + admin.GetLogin() +
+ admin->GetLogStr().c_str(), login.c_str());
+ /*errorStr = "Admin \'" + admin->GetLogin() +
"\': tried to add user \'" + ud->login + "\'. Access denied.";*/
return -1;
}
{
//TODO
//WriteServLog("Admin \'%s\': tried to add user \'%s\'. Access denied.",
- // admin.GetLogin().c_str(), ud->login.c_str());
+ // admin->GetLogin().c_str(), ud->login.c_str());
return -1;
}
//////
u.WriteStat();
WriteServLog("%s User \'%s\' added.",
- admin.GetLogStr().c_str(), login.c_str());
+ admin->GetLogStr().c_str(), login.c_str());
u.OnAdd();
return 0;
}
//-----------------------------------------------------------------------------
-void USERS_IMPL::Del(const string & login, const ADMIN & admin)
+void USERS_IMPL::Del(const string & login, const ADMIN * admin)
{
-const PRIV * priv = admin.GetPriv();
+const PRIV * priv = admin->GetPriv();
user_iter u;
if (!priv->userAddDel)
{
WriteServLog("%s tried to remove user \'%s\'. Access denied.",
- admin.GetLogStr().c_str(), login.c_str());
+ admin->GetLogStr().c_str(), login.c_str());
return;
}
if (FindByNameNonLock(login, &u))
{
WriteServLog("%s tried to delete user \'%s\': not found.",
- admin.GetLogStr().c_str(),
+ admin->GetLogStr().c_str(),
login.c_str());
return;
}
DelUserFromIndexes(u);
WriteServLog("%s User \'%s\' deleted.",
- admin.GetLogStr().c_str(), login.c_str());
+ admin->GetLogStr().c_str(), login.c_str());
}
}
friend class PROPERTY_NOTIFER_IP_AFTER;
public:
- USERS_IMPL(SETTINGS * s, STORE * store, TARIFFS * tariffs, const ADMIN & sysAdmin);
+ USERS_IMPL(SETTINGS * s, STORE * store, TARIFFS * tariffs, const ADMIN * sysAdmin);
virtual ~USERS_IMPL();
int FindByName(const std::string & login, USER_PTR * user);
void AddNotifierUserDel(NOTIFIER_BASE<USER_PTR> *);
void DelNotifierUserDel(NOTIFIER_BASE<USER_PTR> *);
- int Add(const std::string & login, const ADMIN & admin);
- void Del(const std::string & login, const ADMIN & admin);
+ int Add(const std::string & login, const ADMIN * admin);
+ void Del(const std::string & login, const ADMIN * admin);
int ReadUsers();
int GetUserNum() const;
SETTINGS * settings;
TARIFFS * tariffs;
STORE * store;
- const ADMIN & sysAdmin;
+ const ADMIN * sysAdmin;
STG_LOGGER & WriteServLog;
bool nonstop;