diff options
author | McCabe Maxsted | 2011-06-10 17:31:48 -0700 |
---|---|---|
committer | McCabe Maxsted | 2011-06-10 17:31:48 -0700 |
commit | c303f6baa9106d7bb9373b119cba13d574d24d29 (patch) | |
tree | 2589b397d9741fe5a9c41b2b451d5390f1df58fb /linden/indra/newview/llpanelavatar.cpp | |
parent | Don't limit select distance when Disable Max Build Constraints is enabled (diff) | |
download | meta-impy-c303f6baa9106d7bb9373b119cba13d574d24d29.zip meta-impy-c303f6baa9106d7bb9373b119cba13d574d24d29.tar.gz meta-impy-c303f6baa9106d7bb9373b119cba13d574d24d29.tar.bz2 meta-impy-c303f6baa9106d7bb9373b119cba13d574d24d29.tar.xz |
Check for when a profile's born on date field gets sent invalid data
Diffstat (limited to 'linden/indra/newview/llpanelavatar.cpp')
-rw-r--r-- | linden/indra/newview/llpanelavatar.cpp | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/linden/indra/newview/llpanelavatar.cpp b/linden/indra/newview/llpanelavatar.cpp index 4f041f5..0a668ba 100644 --- a/linden/indra/newview/llpanelavatar.cpp +++ b/linden/indra/newview/llpanelavatar.cpp | |||
@@ -1953,29 +1953,37 @@ void LLPanelAvatar::processAvatarPropertiesReply(LLMessageSystem *msg, void**) | |||
1953 | self->mPanelSecondLife->childSetValue("acct", caption_text); | 1953 | self->mPanelSecondLife->childSetValue("acct", caption_text); |
1954 | 1954 | ||
1955 | //Chalice - Show avatar age in days. | 1955 | //Chalice - Show avatar age in days. |
1956 | S32 year; | 1956 | S32 year = 0; |
1957 | S32 month; | 1957 | S32 month = 0; |
1958 | S32 day; | 1958 | S32 day = 0; |
1959 | sscanf(born_on.c_str(), "%d/%d/%d", &month, &day, &year); | 1959 | sscanf(born_on.c_str(), "%d/%d/%d", &month, &day, &year); |
1960 | time_t now = time(NULL); | 1960 | if (year == 0 || month == 0 || day == 0) |
1961 | struct tm * timeinfo; | 1961 | { |
1962 | timeinfo = localtime(&now); | 1962 | // In case the string sent gets screwed up. It happens -- MC |
1963 | timeinfo->tm_mon = --month; | 1963 | born_on = self->mPanelSecondLife->getString("invalid"); |
1964 | timeinfo->tm_year = year - 1900; | 1964 | } |
1965 | timeinfo->tm_mday = day; | 1965 | else |
1966 | time_t birth = mktime(timeinfo); | 1966 | { |
1967 | 1967 | time_t now = time(NULL); | |
1968 | std::stringstream numberString; | 1968 | struct tm * timeinfo; |
1969 | S32 days = difftime(now, birth) / 86400; //(60*60*24) | 1969 | timeinfo = localtime(&now); |
1970 | if (days < 0) days = 0; // Happens for people on different timezones -- MC | 1970 | timeinfo->tm_mon = --month; |
1971 | numberString << days; | 1971 | timeinfo->tm_year = year - 1900; |
1972 | 1972 | timeinfo->tm_mday = day; | |
1973 | LLStringUtil::format_map_t targs; | 1973 | time_t birth = mktime(timeinfo); |
1974 | targs["[DAYS]"] = numberString.str(); | 1974 | |
1975 | std::string born_msg = self->mPanelSecondLife->getString("days_old_text"); | 1975 | std::stringstream numberString; |
1976 | LLStringUtil::format(born_msg, targs); | 1976 | S32 days = difftime(now, birth) / 86400; //(60*60*24) |
1977 | born_on += " "; | 1977 | if (days < 0) days = 0; // Happens for people on different timezones -- MC |
1978 | born_on += born_msg; | 1978 | numberString << days; |
1979 | |||
1980 | LLStringUtil::format_map_t targs; | ||
1981 | targs["[DAYS]"] = numberString.str(); | ||
1982 | std::string born_msg = self->mPanelSecondLife->getString("days_old_text"); | ||
1983 | LLStringUtil::format(born_msg, targs); | ||
1984 | born_on += " "; | ||
1985 | born_on += born_msg; | ||
1986 | } | ||
1979 | self->mPanelSecondLife->childSetValue("born", born_on); | 1987 | self->mPanelSecondLife->childSetValue("born", born_on); |
1980 | 1988 | ||
1981 | EOnlineStatus online_status = (online) ? ONLINE_STATUS_YES : ONLINE_STATUS_NO; | 1989 | EOnlineStatus online_status = (online) ? ONLINE_STATUS_YES : ONLINE_STATUS_NO; |