Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (CurrentUserSession == null && Config.Users.RegistrationRequiredToBrowse)
                    Response.Redirect("LoginThroughFacebook.aspx?back_url=" + Server.UrlEncode(Request.Url.AbsoluteUri));

                if (Config.Users.CompletedProfileRequiredToBrowseSearch &&
                    CurrentUserSession != null && !CurrentUserSession.HasProfile)
                    Response.Redirect("ManageProfile.aspx?err=profnotcompl");
                
                loadPhotos = true;

                if (Request.Params["uid"] != null)
                {
                    try
                    {
                        User user = User.Load(Request.Params["uid"]);

                        if (user.Deleted)
                        {
                            if (user.DeleteReason == null || user.DeleteReason.Trim().Length == 0)
                                StatusPageMessage = "This user has been deleted!".Translate();
                            else
                                StatusPageMessage =
                                    String.Format(
                                        "This user has been deleted for the following reason:<br><br>{0}".Translate(),
                                        user.DeleteReason);
                            Response.Redirect("Home.aspx");
                        }

                        User = user;

                        #region Show/hide profile

                        if (CurrentUserSession == null)
                        {
                            if (!User.IsOptionEnabled(eUserOptions.VisitorsCanViewProfile))
                            {
                                if (User.IsOptionEnabled(eUserOptions.UsersCanViewProfile))
                                {
                                    StatusPageMessage = "This profile is visible for registered users only!".Translate();
                                    Response.Redirect("Home.aspx");
                                    return;
                                }
                                else if (User.IsOptionEnabled(eUserOptions.FriendsOfFriendsCanViewProfile))
                                {
                                    StatusPageMessage = "This profile is visible for friends of friends!".Translate();
                                    Response.Redirect("Home.aspx");
                                    return;
                                }
                                else
                                {
                                    StatusPageMessage = "This profile is visible for friends only!".Translate();
                                    Response.Redirect("Home.aspx");
                                    return;
                                }
                            }
                        }
                        else
                        {
                            if (User.Username != CurrentUserSession.Username
                                && !User.IsOptionEnabled(eUserOptions.VisitorsCanViewProfile)
                                && !User.IsOptionEnabled(eUserOptions.UsersCanViewProfile))
                            {
                                if (User.IsOptionEnabled(eUserOptions.FriendsOfFriendsCanViewProfile))
                                {
                                    if (!User.IsUserInFriendList(CurrentUserSession.Username))
                                    {
                                        bool areFriends = false;
                                        string[] friends = User.FetchMutuallyFriends(User.Username);
                                        foreach (string friend in friends)
                                        {
                                            if (User.IsUserInFriendList(friend, CurrentUserSession.Username))
                                            {
                                                areFriends = true;
                                                break;
                                            }
                                        }
                                        if (!areFriends)
                                        {
                                            StatusPageMessage = "This profile is visible for friends of friends!".Translate();
                                            Response.Redirect("Home.aspx");
                                            return;
                                        }
                                    }
                                }
                                else if (!User.IsUserInFriendList(CurrentUserSession.Username))
                                {
                                    StatusPageMessage = "This profile is visible for friends only!".Translate();
                                    Response.Redirect("Home.aspx");
                                    return;
                                }
                            }
                        }

                        #endregion

                        #region Show/hide photos

                        if (!Config.Photos.FreeMembersCanViewPhotosOfPaidMembers)
                        {
                            if (CurrentUserSession == null)
                            {
                                if (Classes.User.IsPaidMember(User.Username))
                                {
                                    StatusPageMessage = "Only paid members can view those photos".Translate();
                                    loadPhotos = false;
                                }
                            }
                            else if (!Classes.User.IsPaidMember(CurrentUserSession.Username)
                                        && Classes.User.IsPaidMember(User.Username))
                            {
                                StatusPageMessage = "Only paid members can view those photos".Translate();
                                loadPhotos = false;
                            }
                        }

                        if (CurrentUserSession == null)
                        {
                            if (!User.IsOptionEnabled(eUserOptions.VisitorsCanViewPhotos))
                            {
                                if (User.IsOptionEnabled(eUserOptions.UsersCanViewPhotos))
                                {
                                    StatusPageMessage = "This photos are visible for registered users only!".Translate();
                                    loadPhotos = false;
                                }
                                else if (User.IsOptionEnabled(eUserOptions.FriendsOfFriendsCanViewPhotos))
                                {
                                    StatusPageMessage = "This photos are visible for friends of friends!".Translate();
                                    loadPhotos = false;
                                }
                                else
                                {
                                    StatusPageMessage = "This photos are visible for friends only!".Translate();
                                    loadPhotos = false;
                                }
                            }
                        }
                        else
                        {
                            if (User.Username != CurrentUserSession.Username
                                && !User.IsOptionEnabled(eUserOptions.VisitorsCanViewPhotos)
                                && !User.IsOptionEnabled(eUserOptions.UsersCanViewPhotos))
                            {
                                if (User.IsOptionEnabled(eUserOptions.FriendsOfFriendsCanViewPhotos))
                                {
                                    if (!User.IsUserInFriendList(CurrentUserSession.Username))
                                    {
                                        bool areFriends = false;
                                        string[] friends = Classes.User.FetchMutuallyFriends(User.Username);
                                        foreach (string friend in friends)
                                        {
                                            if (Classes.User.IsUserInFriendList(friend, CurrentUserSession.Username))
                                            {
                                                areFriends = true;
                                                break;
                                            }
                                        }
                                        if (!areFriends)
                                        {
                                            StatusPageMessage = "This photos are visible for friends of friends!".Translate();
                                            loadPhotos = false;
                                        }
                                    }
                                }
                                else if (!User.IsUserInFriendList(CurrentUserSession.Username))
                                {
                                    StatusPageMessage = "This photos are visible for friends only!".Translate();
                                    loadPhotos = false;
                                }
                            }
                        }

                        #endregion

                        #region Save profile view

                        if (CurrentUserSession != null &&
                            !CurrentUserSession.IsOptionEnabled(eUserOptions.DisableProfileViews))
                        {
                            User.SaveProfileView(
                                CurrentUserSession.Username, User.Username);

                            User.AddScore(CurrentUserSession.Username,
                                          Config.UserScores.ViewingProfile, "ViewingProfile");
                            User.AddScore(User.Username,
                                          Config.UserScores.ViewedProfile, "ViewedProfile");

                            if (Config.Users.NewEventNotification && 
                                (User.IsOnline() || User.IsUsingNotifier(User.Username)))
                            {
                                var text = String.Format("User {0} is viewing your profile!".Translate(),
                                                         "<b>" + CurrentUserSession.Username + "</b>");
                                int imageID;
                                try
                                {
                                    imageID = CurrentUserSession.GetPrimaryPhoto().Id;
                                }
                                catch (NotFoundException)
                                {
                                    imageID = ImageHandler.GetPhotoIdByGender(CurrentUserSession.Gender);
                                }
                                var thumbnailUrl = ImageHandler.CreateImageUrl(imageID, 50, 50, false, true, true);
                                var notification = new GenericEventNotification
                                {
                                    Recipient = User.Username,
                                    Sender = CurrentUserSession.Username,
                                    Text = text,
                                    ThumbnailUrl = thumbnailUrl,
                                    RedirectUrl = UrlRewrite.CreateMobileShowUserUrl(CurrentUserSession.Username)
                                };
                                RealtimeNotification.SendNotification(notification);
                            }
                        }

                        #endregion

                        LoadStrings();
                        LoadProfile();
                    }
                    catch (ThreadAbortException)
                    {
                    }
                    catch (ArgumentException)
                    {
                        Response.Redirect("Home.aspx");
                    }
                    catch (NotFoundException)
                    {
                        Response.Redirect("Home.aspx");
                    }
                    catch (Exception err)
                    {
                        Global.Logger.LogError(err);
                        Response.Redirect("Home.aspx");
                    }
                }
                else
                {
                    Response.Redirect("Home.aspx");
                }
            }

            ScriptManager scriptManager = ScriptManager.GetCurrent(Page);
            if (scriptManager != null)
                scriptManager.Navigate += scriptManager_Navigate;
        }
Пример #2
0
 /// <summary>
 /// Checks is the recipient is online and sends the online event notification.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="recipient">The recipient.</param>
 /// <param name="text">The text.</param>
 /// <param name="thumbnailUrl">The thumbnail URL.</param>
 /// <param name="redirectUrl">The redirect URL.</param>
 public static void SendOnlineEventNotification(string sender, string recipient, string text, string thumbnailUrl, string redirectUrl)
 {
     if (IsOnline(recipient) || IsUsingNotifier(recipient))
     {
         var notification = new GenericEventNotification
         {
             Recipient = recipient,
             Sender = sender,
             Text = text,
             ThumbnailUrl = thumbnailUrl,
             RedirectUrl = redirectUrl
         };
         RealtimeNotification.SendNotification(notification);
     }
 }
Пример #3
0
        protected void lnkUpdateStatusText_Click(object sender, EventArgs e)
        {
            string status = String.Empty;

            status = txtStatusText.Text.Trim();

            if (status.Length > 0)
            {
                lblStatusText.Text = Server.HtmlEncode(status);
                CurrentUserSession.StatusText = status;
                CurrentUserSession.Update();

                #region Add FriendUpdatedStatus Event & realtime notifications

                Event newEvent = new Event(CurrentUserSession.Username) { Type = Event.eType.FriendUpdatedStatus };

                var friendUpdatedStatus = new FriendUpdatedStatus { Status = status };
                newEvent.DetailsXML = Misc.ToXml(friendUpdatedStatus);

                newEvent.Save();

                string[] usernames = Classes.User.FetchMutuallyFriends(CurrentUserSession.Username);

                foreach (string friendUsername in usernames)
                {
                    if (Config.Users.NewEventNotification &&
                        (Classes.User.IsOnline(friendUsername) || Classes.User.IsUsingNotifier(friendUsername)))
                    {
                        var text = String.Format("Your friend {0} has changed their status to \"{1}\"".Translate(),
                                                 "<b>" + CurrentUserSession.Username + "</b>", status);
                        var imageID = 0;
                        try
                        {
                            imageID = CurrentUserSession.GetPrimaryPhoto().Id;
                        }
                        catch (NotFoundException)
                        {
                            imageID = ImageHandler.GetPhotoIdByGender(CurrentUserSession.Gender);
                        }
                        var thumbnailUrl = ImageHandler.CreateImageUrl(imageID, 50, 50, false, true, true);
                        var notification = new GenericEventNotification
                        {
                            Recipient = friendUsername,
                            Sender = CurrentUserSession.Username,
                            Text = text,
                            ThumbnailUrl = thumbnailUrl,
                            RedirectUrl = UrlRewrite.CreateMobileShowUserUrl(CurrentUserSession.Username)
                        };
                        RealtimeNotification.SendNotification(notification);
                    }
                }

                #endregion
            }
            else
            {
                lblStatusText.Text = "Not set".Translate();
                CurrentUserSession.StatusText = null;
                CurrentUserSession.Update();
            }

            pnlEditStatusText.Visible = false;
            pnlViewStatusText.Visible = true;
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["uid"] == null)
                {
                    Response.Redirect("~/Home.aspx");
                    return;
                }

                if (Config.Misc.EnableMobileVersion && Misc.IsMobileBrowser())
                {
                    Response.Redirect(UrlRewrite.CreateMobileShowUserUrl(Request.Params["uid"]));
                    return;
                }

                if (CurrentUserSession == null && Config.Users.RegistrationRequiredToBrowse)
                {
                    Response.Redirect("Login.aspx?back_url=" + Server.UrlEncode(Request.Url.AbsoluteUri));
                    return;
                }

                if (Config.Users.CompletedProfileRequiredToBrowseSearch &&
                    CurrentUserSession != null && !CurrentUserSession.HasProfile && !CurrentUserSession.IsAdmin())
                {
                    Response.Redirect("Profile.aspx?err=profnotcompl");
                    return;
                }

                if (Config.Users.PhotoRequiredToBrowseSearch &&
                    CurrentUserSession != null && !CurrentUserSession.HasPhotos && !CurrentUserSession.IsAdmin())
                {
                    Response.Redirect("Profile.aspx?err=nophoto");
                    return;
                }

                LoadStrings();

                try
                {
                    User user = User.Load(Request.Params["uid"]);

                    if (user.Deleted)
                    {
                        if (user.DeleteReason == null || user.DeleteReason.Trim().Length == 0)
                            Page.StatusPageMessage = "This user has been deleted!".Translate();
                        else
                            Page.StatusPageMessage =
                                String.Format(
                                    "This user has been deleted for the following reason:<br><br>{0}".Translate(),
                                    user.DeleteReason);
                        Response.Redirect("ShowStatus.aspx");
                        return;
                    }

                    ViewedUser = user;

                    // Save profile view
                    if (Page is ShowUserPage && CurrentUserSession != null &&
                        !CurrentUserSession.IsOptionEnabled(eUserOptions.DisableProfileViews))
                    {
                        User.SaveProfileView(
                            CurrentUserSession.Username, ViewedUser.Username);

                        User.AddScore(CurrentUserSession.Username,
                                      Config.UserScores.ViewingProfile, "ViewingProfile");
                        User.AddScore(ViewedUser.Username,
                                      Config.UserScores.ViewedProfile, "ViewedProfile");

                        if (Config.Users.NewEventNotification && CurrentUserSession.Username != ViewedUser.Username
                            && (ViewedUser.IsOnline() || User.IsUsingNotifier(ViewedUser.Username)))
                        {
                            var text = String.Format("User {0} is viewing your profile!".Translate(),
                                                     "<b>" + CurrentUserSession.Username + "</b>");
                            int imageID;
                            try
                            {
                                imageID = CurrentUserSession.GetPrimaryPhoto().Id;
                            }
                            catch (NotFoundException)
                            {
                                imageID = ImageHandler.GetPhotoIdByGender(CurrentUserSession.Gender);
                            }
                            var thumbnailUrl = ImageHandler.CreateImageUrl(imageID, 50, 50, false, true, true);
                            var notification = new GenericEventNotification
                            {
                                Recipient = ViewedUser.Username,
                                Sender = CurrentUserSession.Username,
                                Text = text,
                                ThumbnailUrl = thumbnailUrl,
                                RedirectUrl = UrlRewrite.CreateShowUserUrl(CurrentUserSession.Username)
                            };
                            RealtimeNotification.SendNotification(notification);
                        }
                    }

                    #region show/hide IM link

                    string reason;
                    if (Config.Misc.EnableIntegratedIM &&
                        CurrentUserSession != null &&
                        !CurrentUserSession.StealthMode &&
                        ViewedUser.IsOnline() &&
                        CurrentUserSession.Username != ViewedUser.Username &&
                        User.CanSendMessage(CurrentUserSession, ViewedUser, out reason) &&
                        !Classes.User.IsUserBlocked(ViewedUser.Username, CurrentUserSession.Username))
                    {
                        pnlInstantMessenger.Visible = true;

                        var permissionCheckResult = CurrentUserSession.CanIM();

                        if (permissionCheckResult == PermissionCheckResult.No)
                            pnlInstantMessenger.Visible = false;
                        else
                        {
                            string root = HttpRuntime.AppDomainAppVirtualPath.TrimEnd('/');
                            var sectionUnlocked = UnlockedSection.IsSectionUnlocked(CurrentUserSession.Username, ViewedUser.Username, UnlockedSection.SectionType.IM, null);
                            if (permissionCheckResult == PermissionCheckResult.Yes || sectionUnlocked)
                            {
                                var timestamp = DateTime.Now.ToFileTimeUtc().ToString();
                                var hash = Misc.CalculateChatAuthHash(CurrentUserSession.Username, ViewedUser.Username, timestamp);
                                lnkInstantMessenger.HRef = "#";
                                lnkInstantMessenger.Attributes.Add("onclick",
                                                                   String.Format(
                                                                       "window.open('{0}/MessengerWindow.aspx?init=1&id={1}&target={2}&timestamp={3}&hash={4}', 'ajaxim_{1}_{2}', 'width=650,height=500,resizable=1,menubar=0,status=0,toolbar=0'); return false;",
                                                                       Config.Urls.ChatHome,
                                                                       CurrentUserSession.Username,
                                                                       ViewedUser.Username,
                                                                       timestamp,
                                                                       hash));
                                lnkInstantMessenger.Target = "AjaxIM_" + ViewedUser.Username;
                            }
                            else if (permissionCheckResult == PermissionCheckResult.YesWithCredits)
                            {
                                string url = String.Format(
                                    "if (confirm('{4}')) window.open('{0}/LaunchIM.aspx?targetUsername={1}', 'ajaxim_{2}_{3}', 'width=650,height=500,resizable=1,menubar=0,status=0,toolbar=0'); return false;",
                                    root, strTargetUserID,
                                    Regex.Replace(strUserID, @"[^A-Za-z0-9]", "_"),
                                    Regex.Replace(strTargetUserID, @"[^A-Za-z0-9]", "_"),
                                    String.Format(Lang.Trans("Opening the chat session will subtract {0} credits from your balance."), CurrentUserSession.BillingPlanOptions.CanIM.Credits /*Config.Credits.CreditsForIM*/));

                                lnkInstantMessenger.Attributes.Add("onclick", url);
                                lnkInstantMessenger.Attributes.Add("href", "");
                            }
                            else if (permissionCheckResult == PermissionCheckResult.YesButMoreCreditsNeeded ||
                                    permissionCheckResult == PermissionCheckResult.YesButPlanUpgradeNeeded)
                            {
                                lnkInstantMessenger.Visible = false;
                                lnkInstantMessengerPay.Visible = true;
                            }
                        }
                    }
                    else pnlInstantMessenger.Visible = false;

                    #endregion

                    #region set "allow/disallow user to view your private photos" links

                    if (Config.Photos.EnablePrivatePhotos &&
                        CurrentUserSession != null &&
                        CurrentUserSession.HasPrivatePhotos())
                    {
                        if (CurrentUserSession.HasUserAccessToPrivatePhotos(user.Username))
                            pnlGrantAccessToPrivatePhotos.Visible = false;
                        else
                            pnlDenyAccessToPrivatePhotos.Visible = false;
                    }
                    else
                    {
                        pnlGrantAccessToPrivatePhotos.Visible = false;
                        pnlDenyAccessToPrivatePhotos.Visible = false;
                    }

                    #endregion

                    #region set "allow/disallow user to view your private video" links

                    if (
                        CurrentUserSession != null &&
                        (CurrentUserSession.HasPrivateVideo()
                         || CurrentUserSession.HasPrivateVideoUpload()))
                    {
                        if (CurrentUserSession.HasUserAccessToPrivateVideo(user.Username))
                            pnlGrantAccessToPrivateVideo.Visible = false;
                        else
                            pnlDenyAccessToPrivateVideo.Visible = false;
                    }
                    else
                    {
                        pnlGrantAccessToPrivateVideo.Visible = false;
                        pnlDenyAccessToPrivateVideo.Visible = false;
                    }

                    #endregion

                    #region set "allow/disallow user to view your private audio" links

                    if (Config.Misc.EnableAudioUpload && CurrentUserSession != null &&
                        CurrentUserSession.HasPrivateAudio())
                    {
                        if (CurrentUserSession.HasUserAccessToPrivateAudio(user.Username))
                            pnlGrantAccessToPrivateAudio.Visible = false;
                        else
                            pnlDenyAccessToPrivateAudio.Visible = false;
                    }
                    else
                    {
                        pnlGrantAccessToPrivateAudio.Visible = false;
                        pnlDenyAccessToPrivateAudio.Visible = false;
                    }

                    #endregion

                    #region activate/deactivate RealPerson Verification links

                    if (Config.Users.EnableRealPersonVerificationFunctionality &&
                        CurrentUserSession != null)
                    {

                        using (var db = new Model.AspNetDatingDataContext())
                        {
                            var verifiedByThisUser =
                                db.VerifiedUsers.Any(u => u.vu_verifiedby == CurrentUserSession.Username
                                                               && u.vu_verifieduser == ViewedUser.Username);

                            if (verifiedByThisUser || CurrentUserSession.IsUserVerified(user.Username))
                                pnlCertifyUserIsGenuine.Visible = false;
                            else
                                pnlRemoveVerifiedUserStatus.Visible = false;
                        }
                    }
                    else
                    {
                        pnlCertifyUserIsGenuine.Visible = false;
                        pnlRemoveVerifiedUserStatus.Visible = false;
                    }

                    #endregion

                    #region Set "block/unlblock user" links

                    if (CurrentUserSession != null)
                    {
                        if (CurrentUserSession.IsUserBlocked(ViewedUser.Username))
                            pnlBlockUser.Visible = false;
                        else
                            pnlUnblockUser.Visible = false;
                    }
                    else
                    {
                        pnlBlockUser.Visible = false;
                        pnlUnblockUser.Visible = false;
                    }

                    #endregion

                    #region Enable/Disable ViewBlog

                    pnlBlog.Visible = Config.Misc.EnableBlogs && Blog.HasPosts(ViewedUser.Username);

                    #endregion

                    #region Enable/Disable ViewEvents

                    pnlViewEvents.Visible = Config.Users.EnableUserEventsPage;

                    #endregion

                    #region Add report abuse option

                    if (Config.AbuseReports.UserCanReportProfileAbuse
                        && (CurrentUserSession != null && (CurrentUserSession.BillingPlanOptions.UserCanReportAbuse.Value
                        || CurrentUserSession.Level != null && CurrentUserSession.Level.Restrictions.UserCanReportAbuse)))
                    {
                        pnlReportAbuseLink.Visible = true;
                    }

                    #endregion

                    #region Show blog if param is supplied

                    // Left for compatibility with old links to blog posts
                    if (Request.Params["bpid"] != null && !(Page is ShowUserBlog))
                    {
                        try
                        {
                            int blogPostId = Convert.ToInt32(Request.Params["bpid"]);
                            Response.Redirect(UrlRewrite.CreateShowUserBlogUrl(ViewedUser.Username,
                                blogPostId));
                            return;
                        }
                        catch (ArgumentException)
                        {
                        }
                    }

                    #endregion

                    #region Set meta tags

                    Parser parse = delegate(string text)
                                       {
                                           string result = text
                                               .Replace("%%USERNAME%%", user.Username)
                                               .Replace("%%AGE%%", user.Age.ToString())
                                               .Replace("%%GENDER%%", Lang.Trans(user.Gender.ToString()))
                                               .Replace("%%COUNTRY%%", user.Country)
                                               .Replace("%%STATE%%", user.State)
                                               .Replace("%%ZIP%%", user.ZipCode)
                                               .Replace("%%CITY%%", user.City);

                                           var regex = new Regex(@"%%Q_(\d+)%%");
                                           Match match = regex.Match(result);
                                           while (match.Success)
                                           {
                                               foreach (Capture capture in match.Groups[1].Captures)
                                               {
                                                   int questionId;
                                                   if (!int.TryParse(capture.Value, out questionId)) continue;
                                                   try
                                                   {
                                                       ProfileAnswer answer =
                                                           ProfileAnswer.Fetch(user.Username, questionId);
                                                       result =
                                                           result.Replace(String.Format("%%Q_{0}%%", questionId),
                                                                          Server.HtmlEncode(answer.Value));
                                                   }
                                                   catch (NotFoundException)
                                                   {
                                                       continue;
                                                   }
                                               }
                                               match = match.NextMatch();
                                           }

                                           return result;
                                       };

                    Page.Header.Title = parse(Config.SEO.ShowUserTitleTemplate);

                    var metaDesc = new HtmlMeta
                                       {
                                           ID = "Description",
                                           Name = "description",
                                           Content = parse(Config.SEO.ShowUserMetaDescriptionTemplate)
                                       };
                    Page.Header.Controls.Add(metaDesc);

                    var metaKeywords = new HtmlMeta
                                           {
                                               ID = "Keywords",
                                               Name = "keywords",
                                               Content = parse(Config.SEO.ShowUserMetaKeywordsTemplate)
                                           };
                    Page.Header.Controls.Add(metaKeywords);

                    #endregion

                }
                catch (ThreadAbortException)
                {
                }
                catch (ArgumentException)
                {
                    Response.Redirect("~/Home.aspx");
                }
                catch (NotFoundException)
                {
                    Response.Redirect("~/Home.aspx");
                }
                catch (Exception err)
                {
                    Global.Logger.LogError(err);
                    Response.Redirect("~/Home.aspx");
                }

                #region Show/Hide links

                if (CurrentUserSession != null)
                {
                    if (Config.Users.EnableFavorites)
                    {
                        if (CurrentUserSession.IsUserInFavouriteList(ViewedUser.Username))
                        {
                            pnlRemoveFromFavourites.Visible = true;
                            pnlAddToFavourites.Visible = false;
                        }
                        else
                        {
                            pnlRemoveFromFavourites.Visible = false;
                            pnlAddToFavourites.Visible = true;
                        }
                    }
                    else
                    {
                        pnlRemoveFromFavourites.Visible = false;
                        pnlAddToFavourites.Visible = false;
                    }

                    if (Config.Users.EnableFriends)
                    {
                        if (CurrentUserSession.IsUserInFriendList(ViewedUser.Username))
                        {
                            pnlRemoveFromFriends.Visible = true;
                            pnlAddToFriends.Visible = false;
                            pnlViewMutualFriends.Visible = false;
                        }
                        else
                        {
                            pnlRemoveFromFriends.Visible = false;
                            pnlAddToFriends.Visible = true;
                        }
                    }
                    else
                    {
                        pnlAddToFriends.Visible = false;
                        pnlRemoveFromFriends.Visible = false;
                        pnlViewMutualFriends.Visible = false;
                    }
                }
                else
                {
                    pnlRemoveFromFavourites.Visible = false;
                    pnlAddToFavourites.Visible = false;
                    pnlAddToFriends.Visible = false;
                    pnlRemoveFromFriends.Visible = false;
                    pnlViewMutualFriends.Visible = false;
                }

                if (Page is ShowUserPage && Config.ThirdPartyServices.UseBingTranslate)
                {
                    divTranslate.Visible = true;
                }

                #endregion

                if (Page is ShowUserPage)
                    Master.SetSelectedLink(lnkViewProfile.ClientID);
                else if (Page is ShowUserPhotos)
                    Master.SetSelectedLink(lnkViewPhotos.ClientID);
                else if (Page is ShowUserBlog)
                    Master.SetSelectedLink(lnkViewBlog.ClientID);
                else if (Page is ReportUserAbuse)
                    Master.SetSelectedLink(lnkReportAbuse.ClientID);
                else if (Page is ShowUserEvents)
                    Master.SetSelectedLink(lnkViewEvents.ClientID);

                SetSimilarProfilesProperties();
            }

            #region Apply profile skin

            if (ViewedUser.ProfileSkin != null || Request.Params["skin"] != null)
            {
                var cssSkinCommon = new HtmlLink();
                cssSkinCommon.Attributes.Add("rel", "stylesheet");
                cssSkinCommon.Attributes.Add("type", "text/css");
                cssSkinCommon.Href = "Skins/common.css";
                Page.Header.Controls.Add(cssSkinCommon);

                var cssSkin = new HtmlLink();
                cssSkin.Attributes.Add("rel", "stylesheet");
                cssSkin.Attributes.Add("type", "text/css");
                cssSkin.Href = Request.Params["skin"] ?? ViewedUser.ProfileSkin;
                Page.Header.Controls.Add(cssSkin);
            }

            #endregion

            PrepareLinks();
        }