public int GetNewUsersCount(string username, string hash) { string encodedData = Convert.ToBase64String(Encoding.ASCII.GetBytes(username)); string hash2 = Misc.HMACSHA1ToHex(encodedData, Properties.Settings.Default.SecretGadgetKey); if (hash != hash2) return 0; NewUsersSearch nuSearch = new NewUsersSearch(); nuSearch.UsersSince = Classes.User.Load(username).PrevLogin; UserSearchResults nuResults = nuSearch.GetResultsFromCache(true); if (nuResults != null && nuResults.Usernames != null) return nuResults.Usernames.Length; else return 0; }
private void preparePage() { #region Show Profile Views if (Config.Users.EnableWhoViewedMyProfile) { lblProfileViews.Text = CurrentUserSession.ProfileViews.ToString(); if (CurrentUserSession.ProfileViews == 0) { lnkViewProfileViewers.Enabled = false; } liWhoViewedMyProfile.Visible = true; } else { liWhoViewedMyProfile.Visible = false; } #endregion #region Show Rating if (Config.Ratings.EnableProfileRatings) { pnlRating.Visible = true; try { UserRating userRating = UserRating.FetchRating(CurrentUserSession.Username); lblRating.Text = String.Format( Lang.Trans("{0} ({1} votes)"), userRating.AverageVote.ToString("0.00"), userRating.Votes); } catch (NotFoundException) { lblRating.Text = Lang.Trans("no rating"); } } else pnlRating.Visible = false; #endregion #region Show Votes if (Config.Ratings.EnableProfileVoting) { int score = UserVotes.FetchVotesScore(CurrentUserSession.Username); if (score > 0) { pnlVotes.Visible = true; lblVotes.Text = score.ToString(); } else { pnlVotes.Visible = false; } } else { pnlVotes.Visible = false; } #endregion #region Load New Users var nuSearch = new NewUsersSearch { PhotoReq = Config.Users.RequirePhotoToShowInNewUsers, ProfileReq = Config.Users.RequireProfileToShowInNewUsers, UsersSince = CurrentUserSession.PrevLogin }; UserSearchResults nuResults = nuSearch.GetResultsFromCache(true); if (nuResults == null) { pnlNewUsers.Visible = false; } else { lnkNewUsers.Text = nuResults.Usernames.Length == 1 ? Lang.Trans("There is one new user since your last visit!") : String.Format(Lang.Trans("There are <b>{0}</b> new users since your last visit!"), nuResults.Usernames.Length); pnlNewUsers.Visible = true; } #endregion #region Load Online Users var oSearch = new OnlineSearch(); UserSearchResults oResults = oSearch.GetResults(); if (oResults == null) { pnlUsersOnline.Visible = false; } else { lblUsersOnline.Text = oResults.Usernames.Length == 1 ? Lang.Trans("There is one online user!") : String.Format(Lang.Trans("There are <b>{0}</b> online users!"), oResults.Usernames.Length); pnlUsersOnline.Visible = true; } #endregion #region Show Unread Messages int unreadMsgCount = Message.SearchUnread(CurrentUserSession.Username).Length; if (unreadMsgCount > 0) { pnlNewMessages.Visible = true; if (unreadMsgCount == 1) { if (lblNewMessages != null) { lblNewMessages.Text = Lang.Trans("You have <b>1</b> unread message!"); lnkNewMessages.Text = Lang.Trans("View"); } else { lnkNewMessages.Text = Lang.Trans("You have <b>1</b> unread message!"); } } else { if (lblNewMessages != null) { lblNewMessages.Text = String.Format( Lang.Trans("You have <b>{0}</b> unread messages!"), unreadMsgCount); lnkNewMessages.Text = Lang.Trans("View"); } else { lnkNewMessages.Text = String.Format( Lang.Trans("You have <b>{0}</b> unread messages!"), unreadMsgCount); } } } else { pnlNewMessages.Visible = false; } #endregion #region Show Status text if (Config.Users.EnableUserStatusText) { pnlStatusText.Visible = !Config.Misc.SiteIsPaid || Classes.User.IsPaidMember(CurrentUserSession.Username); lblStatusText.Text = Server.HtmlEncode(CurrentUserSession.StatusText) ?? "Not set".Translate(); } #endregion }
private void preparePage() { string youHaveStrTrans = Lang.Trans("You have"); string thereAreTrans = Lang.Trans("There are"); #region Load Photo Photo primaryPhoto = null; bool hasPhoto = false; try { primaryPhoto = _currentUserSession.GetPrimaryPhoto(); hasPhoto = primaryPhoto != null && primaryPhoto.Approved ? true : false; } catch (NotFoundException) { } catch (Exception err) { if (Page is PageBase) ((PageBase)Page).Log(err); } #region Check _currentUserSession.Gender and set photoId int photoId = hasPhoto ? primaryPhoto.Id : ImageHandler.GetPhotoIdByGender(_currentUserSession.Gender); #endregion if (false) //Config.Photos.EnablePhotoStack) { imgPhoto.ImageUrl = ImageHandler.CreateImageStackUrl(_currentUserSession.Username, 200, 150); } else { if (!hasPhoto && _currentUserSession.FacebookID.HasValue && _currentUserSession.FacebookID.Value > 0) { imgPhoto.ImageUrl = ImageHandler.CreateFacebookImageUrl(_currentUserSession.FacebookID.Value, ImageHandler.eFacebookImageType.Normal); } else { imgPhoto.ImageUrl = ImageHandler.CreateImageUrl(photoId, 90, 90, photoId <= 0, true, true); } } #endregion #region Show Profile Views bool isShowProfileViews = Config.Users.EnableWhoViewedMyProfile && _currentUserSession.ProfileViews > 0; lblProfileViews.Text = isShowProfileViews ? _currentUserSession.ProfileViews.ToString() : ""; lnkViewProfileViewers.Visible = isShowProfileViews; liWhoViewedMyProfile.Visible = isShowProfileViews; #endregion #region Show Rating if (Config.Ratings.EnableProfileRatings) { pnlRating.Visible = true; try { UserRating userRating = UserRating.FetchRating(_currentUserSession.Username); lblRating.Text = String.Format( Lang.Trans("{0} ({1} votes)"), userRating.AverageVote.ToString("0.00"), userRating.Votes); } catch (NotFoundException) { lblRating.Text = Lang.Trans("no rating"); } } else pnlRating.Visible = false; #endregion #region Show Votes if (Config.Ratings.EnableProfileVoting) { int score = UserVotes.FetchVotesScore(_currentUserSession.Username); pnlVotes.Visible = (score > 0); lblVotes.Text = score.ToString(); } else { pnlVotes.Visible = false; } #endregion #region Load New Users var nuSearch = new NewUsersSearch { PhotoReq = Config.Users.RequirePhotoToShowInNewUsers, ProfileReq = Config.Users.RequireProfileToShowInNewUsers, UsersSince = _currentUserSession.PrevLogin, LoginCountThreshold = 1 }; UserSearchResults nuResults = nuSearch.GetResultsFromCache(true); pnlNewUsers.Visible = (nuResults != null); if (pnlNewUsers.Visible) { lnkNewUsers.Text = nuResults.Usernames.Length == 1 ? Lang.Trans("There is one new user since your last visit!") : thereAreTrans + AsBoldHtmlStr(nuResults.Usernames.Length) + Lang.Trans("new users since your last visit!"); } #endregion #region Load Online Users var oSearch = new OnlineSearch(); UserSearchResults oResults = oSearch.GetResults(); pnlUsersOnline.Visible = (oResults != null); if (pnlUsersOnline.Visible) { lblUsersOnline.Text = oResults.Usernames.Length == 1 ? Lang.Trans("There is one online registered user!") : thereAreTrans + AsBoldHtmlStr(oResults.Usernames.Length) + Lang.Trans("online registered users!"); } #endregion #region Show users broadcasting video if (Config.Misc.EnableProfileVideoBroadcast) { var vbSearch = new VideoBroadcastingSearch(); UserSearchResults vbResults = vbSearch.GetResults(); bool hasResults = (vbResults != null); pnlUsersBroadcasting.Visible = hasResults; if (hasResults) { lblUsersBroadcasting.Text = vbResults.Usernames.Length == 1 ? Lang.Trans("There is one user broadcasting video!") : thereAreTrans + AsBoldHtmlStr(vbResults.Usernames.Length)+ Lang.Trans("users broadcasting video!"); } } else { pnlUsersBroadcasting.Visible = false; } #endregion /* #region Load Blocked Users int blockedUsers = Classes.User.FetchBlockedUsers(_currentUserSession.Username).Count; bool hasBlockedUsers = blockedUsers != 0; pnlBlockedUsers.Visible = hasBlockedUsers; if (hasBlockedUsers) { lblBlockedUsers.Text = blockedUsers == 1 ? Lang.Trans("There is one blocked user!") : thereAreTrans + AsBoldHtmlStr(blockedUsers)+Lang.Trans("blocked users!"); } #endregion */ #region Show Unread Messages bool hasUnreadMsgs = Message.SearchUnread(_currentUserSession.Username) != null; pnlNewMessages.Visible = hasUnreadMsgs; if (hasUnreadMsgs) { int unreadMsgCount = Message.SearchUnread(_currentUserSession.Username).Length; lnkNewMessages.Text = Lang.Trans("View"); lblNewMessages.Text = unreadMsgCount == 1 ? Lang.Trans("You have <b>1</b> unread message!") : youHaveStrTrans + AsBoldHtmlStr(unreadMsgCount) + Lang.Trans("unread messages!"); } #endregion #region Show Relationship Requests if (Config.Users.EnableRelationshipStatus) { int relationshipRequests = Relationship.FetchRequests(_currentUserSession.Username).Length; bool hasRelReq = relationshipRequests > 0; pnlRelationshipRequests.Visible = hasRelReq; if (hasRelReq) { lnkRelationshipRequests.Text = Lang.Trans("View"); lblRelationshipRequests.Text = relationshipRequests == 1 ? Lang.Trans("You have <b>1</b> relationship request!") : youHaveStrTrans+ AsBoldHtmlStr(relationshipRequests)+ Lang.Trans("relationship requests!"); } } else pnlRelationshipRequests.Visible = false; #endregion #region Show Friend Requests int friendRequests = Classes.User.FetchOpenFriendshipRequestsToUsernme(_currentUserSession.Username).Length; if (friendRequests > 0) { pnlFriendsRequests.Visible = true; if (friendRequests == 1) { if (lblFriendsRequests != null) { lblFriendsRequests.Text = Lang.Trans("You have <b>1</b> friend request!"); lnkFriendsRequests.Text = Lang.Trans("View"); } else { lnkFriendsRequests.Text = Lang.Trans("You have <b>1</b> friend request!"); } } else { if (lblFriendsRequests != null) { lblFriendsRequests.Text = String.Format( Lang.Trans("You have <b>{0}</b> friend requests!"), friendRequests); lnkFriendsRequests.Text = Lang.Trans("View"); } else { lnkFriendsRequests.Text = String.Format( Lang.Trans("You have <b>{0}</b> friend requests!"), friendRequests); } } } else { pnlFriendsRequests.Visible = false; } #endregion #region Show contest rankings if (Config.Ratings.EnablePhotoContests) { PhotoContestEntry[] entries = PhotoContestEntry.Load(null, null, _currentUserSession.Username, null); if (entries != null && entries.Length > 0) { var dtRanks = new DataTable(); dtRanks.Columns.Add("Rank", typeof(int)); dtRanks.Columns.Add("ContestName", typeof(string)); foreach (PhotoContestEntry entry in entries) { int rank = PhotoContestEntry.FindRank(entry.ContestId, entry.Id); if (rank > 0) { PhotoContest contest = PhotoContest.Load(entry.ContestId); if (contest.DateEnds.HasValue && contest.DateEnds < DateTime.Now) continue; dtRanks.Rows.Add(new object[] { rank, contest.Name }); } } if (dtRanks.Rows.Count > 0) { rptContestsRanks.DataSource = dtRanks; rptContestsRanks.DataBind(); rptContestsRanks.Visible = true; } } } #endregion #region Show Pending Invitations if (Config.Groups.EnableGroups) { int pendingInvitations = Group.FetchPendingInvitations(_currentUserSession.Username); bool hasPendingInv = (pendingInvitations > 0); pnlPendingInvitations.Visible = hasPendingInv; if (hasPendingInv) { lnkPendingInvitations.Text = Lang.Trans("View"); lblPendingInvitatinos.Text = (pendingInvitations == 1) ? Lang.Trans("You have <b>1</b> pending invitation!") : youHaveStrTrans + String.Format(" <b>{0}</b> ", pendingInvitations)+Lang.Trans("pending invitations!"); } } #endregion #region Show group topic subscriptions if (Config.Groups.EnableGroups) { DataTable dtGroupTopicSubscriptions = new DataTable("GroupTopicSubscriptions"); dtGroupTopicSubscriptions.Columns.Add("GroupTopicID"); dtGroupTopicSubscriptions.Columns.Add("GroupTopicName"); dtGroupTopicSubscriptions.Columns.Add("GroupID"); dtGroupTopicSubscriptions.Columns.Add("GroupName"); GroupTopic[] groupTopics = GroupTopic.FetchUpdatedGroupTopicsUserHasSubscribedTo(_currentUserSession.Username); foreach (GroupTopic groupTopic in groupTopics) { Group group = Group.Fetch(groupTopic.GroupID); if (group != null) { dtGroupTopicSubscriptions.Rows.Add(new object[] { groupTopic.ID, groupTopic.Name, group.ID, group.Name }); } } rptGroupTopicSubscriptions.DataSource = dtGroupTopicSubscriptions; rptGroupTopicSubscriptions.DataBind(); rptGroupTopicSubscriptions.Visible = dtGroupTopicSubscriptions.Rows.Count > 0; } #endregion #region Show Status text if (Config.Users.EnableUserStatusText) { pnlStatusText.Visible = !Config.Misc.SiteIsPaid || Classes.User.IsPaidMember(_currentUserSession.Username); lblStatusText.Text = Server.HtmlEncode(_currentUserSession.StatusText) ?? "Not set".Translate(); } #endregion #region Notify Facebook for the changed status //long? facebookID = _currentUserSession.FacebookID; //if (Config.Misc.EnableFacebookIntegration && facebookID.HasValue && facebookID > 0) //{ // divFaceBookStatusUpdate.Visible = true; // pnlInviteFriendsFromFacebook.Visible = true; //} #endregion }