X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/ede91934442fd804d7b818971a44e3ad795cb01f..d9bd555be1eccc4f615de667e3ff07650ef0f987:/projects/stargazer/user_property.h?ds=sidebyside diff --git a/projects/stargazer/user_property.h b/projects/stargazer/user_property.h index 704f371e..41a0cfb5 100644 --- a/projects/stargazer/user_property.h +++ b/projects/stargazer/user_property.h @@ -70,24 +70,24 @@ public: bool isPassword, bool isStat, STG_LOGGER & logger, - const SETTINGS * s); + const std::string & sd); virtual ~USER_PROPERTY_LOGGED(); USER_PROPERTY_LOGGED * GetPointer() throw(); 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, @@ -98,14 +98,13 @@ private: const string & paramName, const string & oldValue, const string & newValue, - const ADMIN & admin); + const ADMIN * admin); - string name; // parameter name. needed for logging + STG_LOGGER & stgLogger; // server's logger bool isPassword; // is parameter password. when true, it will be logged as ******* bool isStat; // is parameter a stat data or conf data? - mutable pthread_mutex_t mutex; - STG_LOGGER & stgLogger; // server's logger - const SETTINGS * settings; + string name; // parameter name. needed for logging + const std::string scriptsDir; }; //----------------------------------------------------------------------------- class USER_PROPERTIES { @@ -122,7 +121,7 @@ private: USER_CONF conf; public: - USER_PROPERTIES(const SETTINGS * settings); + USER_PROPERTIES(const std::string & sd); USER_STAT & Stat() { return stat; } USER_CONF & Conf() { return conf; } @@ -283,17 +282,15 @@ USER_PROPERTY_LOGGED::USER_PROPERTY_LOGGED(varT& val, bool isPass, bool isSt, STG_LOGGER & logger, - const SETTINGS * s) + const std::string & sd) : USER_PROPERTY(val), - stgLogger(logger) + stgLogger(logger), + isPassword(isPass), + isStat(isSt), + name(n), + scriptsDir(sd) { -pthread_mutex_init(&mutex, NULL); -STG_LOCKER locker(&mutex, __FILE__, __LINE__); -isPassword = isPass; -isStat = isSt; -name = n; -settings = s; } //----------------------------------------------------------------------------- template @@ -321,20 +318,14 @@ return name; //------------------------------------------------------------------------- template bool USER_PROPERTY_LOGGED::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")) { @@ -370,16 +361,16 @@ return true; //------------------------------------------------------------------------- template void USER_PROPERTY_LOGGED::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 void USER_PROPERTY_LOGGED::WriteSuccessChange(const string & login, - const ADMIN & admin, + const ADMIN * admin, const string & parameter, const string & oldValue, const string & newValue, @@ -387,14 +378,14 @@ void USER_PROPERTY_LOGGED::WriteSuccessChange(const string & login, 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 @@ -402,15 +393,15 @@ void USER_PROPERTY_LOGGED::OnChange(const string & login, const string & paramName, const string & oldValue, const string & newValue, - const ADMIN & admin) + const ADMIN * admin) { string str1; -str1 = settings->GetConfDir() + "/OnChange"; +str1 = scriptsDir + "/OnChange"; 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 @@ -421,13 +412,6 @@ else //------------------------------------------------------------------------- //------------------------------------------------------------------------- //------------------------------------------------------------------------- -/*template -stringstream & operator<< (stringstream & s, const USER_PROPERTY & v) -{ -s << v.ConstData(); -return s; -}*/ -//----------------------------------------------------------------------------- template ostream & operator<< (ostream & stream, const USER_PROPERTY & value) {