From: Naffanya Date: Sat, 11 Jan 2014 21:45:42 +0000 (+0200) Subject: Correcting verification exist parameter X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/de673871df0a5f56ce8c8ee1c075eb405b019f70?hp=31b24cededa8b07468cb5e1c49b2a208fe19173e Correcting verification exist parameter --- diff --git a/include/stg/user_property.h b/include/stg/user_property.h index 7d68e734..7c0f4da1 100644 --- a/include/stg/user_property.h +++ b/include/stg/user_property.h @@ -138,7 +138,7 @@ public: void SetProperties(const USER_PROPERTIES & p) { stat = p.stat; conf = p.conf; } std::string GetPropertyValue(const std::string & name) const; - bool Exists(const std::string & name) const; + bool Exists(const std::string & name) const; USER_PROPERTY_LOGGED cash; USER_PROPERTY_LOGGED up; @@ -400,8 +400,7 @@ return it->second->ToString(); inline bool USER_PROPERTIES::Exists(const std::string & name) const { -if (properties.find(name)!=properties.end()) return true; -return false; +return properties.find(name) != properties.end(); } //------------------------------------------------------------------------- //------------------------------------------------------------------------- diff --git a/projects/stargazer/plugins/other/rscript/rscript.cpp b/projects/stargazer/plugins/other/rscript/rscript.cpp index 640fc95b..5c94606b 100644 --- a/projects/stargazer/plugins/other/rscript/rscript.cpp +++ b/projects/stargazer/plugins/other/rscript/rscript.cpp @@ -426,7 +426,6 @@ for(it = rsSettings.GetUserParams().begin(); it != rsSettings.GetUserParams().end(); ++it) { -// std::string parameter(GetUserParam(rsu.user, *it)); std::string parameter(rsu.user->GetParamValue(it->c_str())); if (params.length() + parameter.length() > RS_PARAMS_LEN - 1) break; diff --git a/projects/stargazer/user_impl.cpp b/projects/stargazer/user_impl.cpp index 51637a1b..63af98e1 100644 --- a/projects/stargazer/user_impl.cpp +++ b/projects/stargazer/user_impl.cpp @@ -1474,24 +1474,21 @@ while (it != messages.end()) //----------------------------------------------------------------------------- std::string USER_IMPL::GetParamValue(const std::string & name) const { -if (property.Exists(name)) - { if (name == "id") { std::ostringstream stream; stream << id; return stream.str(); } - if (name == "login") return login; - if (name == "ip") return currIP.ToString(); - if (name == "enabledDirs") return GetEnabledDirs(); - return property.GetPropertyValue(name); - } -else - { - WriteServLog("Error getting parametr value", name.c_str()); - return ""; - } + if (name == "login") return login; + if (name == "ip") 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 ""; + } } //----------------------------------------------------------------------------- //-----------------------------------------------------------------------------