X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/1347f3d1e04bedd1508589173f577673ee2c5554..67eb91cd2fafdf89ba670706e684ab0cd74ae513:/projects/stargazer/user_impl.cpp?ds=inline diff --git a/projects/stargazer/user_impl.cpp b/projects/stargazer/user_impl.cpp index ac8399ca..fff3f58d 100644 --- a/projects/stargazer/user_impl.cpp +++ b/projects/stargazer/user_impl.cpp @@ -588,6 +588,7 @@ if (!fakeConnect) } std::string scriptOnConnectParams; + strprintf(&scriptOnConnectParams, "%s \"%s\" \"%s\" \"%f\" \"%d\" \"%s\"", scriptOnConnect.c_str(), @@ -597,6 +598,13 @@ if (!fakeConnect) id, dirsStr); + std::vector::const_iterator it(settings->GetScriptParams().begin()); + while (it != settings->GetScriptParams().end()) + { + scriptOnConnectParams += " \"" + GetParamValue(it->c_str()) + "\""; + ++it; + } + ScriptExec(scriptOnConnectParams.c_str()); } else @@ -654,6 +662,13 @@ if (!fakeDisconnect) id, dirsStr); + std::vector::const_iterator it(settings->GetScriptParams().begin()); + while (it != settings->GetScriptParams().end()) + { + scriptOnDisonnectParams += " \"" + GetParamValue(it->c_str()) + "\""; + ++it; + } + ScriptExec(scriptOnDisonnectParams.c_str()); } else @@ -808,7 +823,7 @@ if (settings->GetShowFeeInCash() || tariff == NULL) return (cash - tariff->GetFee() >= -credit); } //----------------------------------------------------------------------------- -std::string USER_IMPL::GetEnabledDirs() +std::string USER_IMPL::GetEnabledDirs() const { //STG_LOCKER lock(&mutex, __FILE__, __LINE__); @@ -1457,6 +1472,26 @@ while (it != messages.end()) } } //----------------------------------------------------------------------------- +std::string USER_IMPL::GetParamValue(const std::string & name) const +{ + if (name == "id") + { + std::ostringstream stream; + stream << id; + return stream.str(); + } + if (name == "login") return login; + if (name == "currIP") return currIP.ToString(); + if (name == "enabledDirs") return GetEnabledDirs(); + if (property.Exists(name)) + return property.GetPropertyValue(name); + else + { + WriteServLog("User’s parameter '%s' does not exist.", name.c_str()); + return ""; + } +} +//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void CHG_PASSIVE_NOTIFIER::Notify(const int & oldPassive, const int & newPassive)