/// <summary> /// The page_ load. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { if (this.User == null) { YafBuildLink.AccessDenied(); } if (!this.IsPostBack) { // get user data... MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.UserID); if (user == null) { YafBuildLink.AccessDenied( /*No such user exists*/); } string displayName = UserMembershipHelper.GetDisplayNameFromID(this.UserID); this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum)); this.PageLinks.AddLink(this.PageContext.BoardSettings.EnableDisplayName ? displayName : user.UserName, YafBuildLink.GetLink(ForumPages.profile, "u={0}", this.UserID)); this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty); // get full user data... var userData = new CombinedUserDataHelper(user, this.UserID); this.Img.Src = "http://opi.yahoo.com/online?u={0}&m=g&t=2".FormatWith(userData.Profile.YIM); this.Msg.NavigateUrl = "http://edit.yahoo.com/config/send_webmesg?.target={0}&.src=pg".FormatWith(userData.Profile.YIM); } }
/// <summary> /// The quick reply_ click. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void QuickReply_Click([NotNull] object sender, [NotNull] EventArgs e) { if (!this.PageContext.ForumReplyAccess || (this._topicFlags.IsLocked && !this.PageContext.ForumModeratorAccess)) { YafBuildLink.AccessDenied(); } if (this._quickReplyEditor.Text.Length <= 0) { this.PageContext.AddLoadMessage(this.GetText("EMPTY_MESSAGE"), MessageTypes.Warning); return; } // No need to check whitespace if they are actually posting something if (this.Get<YafBoardSettings>().MaxPostSize > 0 && this._quickReplyEditor.Text.Length >= this.Get<YafBoardSettings>().MaxPostSize) { this.PageContext.AddLoadMessage(this.GetText("ISEXCEEDED"), MessageTypes.Warning); return; } if (((this.PageContext.IsGuest && this.Get<YafBoardSettings>().EnableCaptchaForGuests) || (this.Get<YafBoardSettings>().EnableCaptchaForPost && !this.PageContext.IsCaptchaExcluded)) && !CaptchaHelper.IsValid(this.tbCaptcha.Text.Trim())) { this.PageContext.AddLoadMessage(this.GetText("BAD_CAPTCHA"), MessageTypes.Warning); return; } if (!(this.PageContext.IsAdmin || this.PageContext.ForumModeratorAccess) && this.Get<YafBoardSettings>().PostFloodDelay > 0) { if (YafContext.Current.Get<IYafSession>().LastPost > DateTime.UtcNow.AddSeconds(-this.Get<YafBoardSettings>().PostFloodDelay)) { this.PageContext.AddLoadMessage( this.GetTextFormatted( "wait", (YafContext.Current.Get<IYafSession>().LastPost - DateTime.UtcNow.AddSeconds(-this.Get<YafBoardSettings>().PostFloodDelay)).Seconds), MessageTypes.Warning); return; } } YafContext.Current.Get<IYafSession>().LastPost = DateTime.UtcNow; // post message... long messageId = 0; object replyTo = -1; string msg = this._quickReplyEditor.Text; long topicID = this.PageContext.PageTopicID; // SPAM Check // Check if Forum is Moderated DataRow forumInfo; bool isForumModerated = false; using (DataTable dt = LegacyDb.forum_list(this.PageContext.PageBoardID, this.PageContext.PageForumID)) { forumInfo = dt.Rows[0]; } if (forumInfo != null) { isForumModerated = this.CheckForumModerateStatus(forumInfo); } var spamApproved = true; var isPossibleSpamMessage = false; // Check for SPAM if (!this.PageContext.IsAdmin && !this.PageContext.ForumModeratorAccess && !this.Get<YafBoardSettings>().SpamServiceType.Equals(0)) { var spamChecker = new YafSpamCheck(); string spamResult; // Check content for spam if (spamChecker.CheckPostForSpam( this.PageContext.IsGuest ? "Guest" : this.PageContext.PageUserName, YafContext.Current.Get<HttpRequestBase>().GetUserRealIPAddress(), this._quickReplyEditor.Text, this.PageContext.IsGuest ? null : this.PageContext.User.Email, out spamResult)) { switch (this.Get<YafBoardSettings>().SpamMessageHandling) { case 0: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}" .FormatWith( this.PageContext.IsGuest ? "Guest" : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); break; case 1: spamApproved = false; isPossibleSpamMessage = true; this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, it was flagged as unapproved post" .FormatWith( this.PageContext.IsGuest ? "Guest" : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); break; case 2: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, post was rejected" .FormatWith( this.PageContext.IsGuest ? "Guest" : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); this.PageContext.AddLoadMessage(this.GetText("SPAM_MESSAGE"), MessageTypes.Error); return; case 3: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, user was deleted and bannded" .FormatWith( this.PageContext.IsGuest ? "Guest" : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); var userIp = new CombinedUserDataHelper( this.PageContext.CurrentUserData.Membership, this.PageContext.PageUserID).LastIP; UserMembershipHelper.DeleteAndBanUser( this.PageContext.PageUserID, this.PageContext.CurrentUserData.Membership, userIp); return; } } } // If Forum is Moderated if (isForumModerated) { spamApproved = false; } // Bypass Approval if Admin or Moderator if (this.PageContext.IsAdmin || this.PageContext.ForumModeratorAccess) { spamApproved = true; } var tFlags = new MessageFlags { IsHtml = this._quickReplyEditor.UsesHTML, IsBBCode = this._quickReplyEditor.UsesBBCode, IsApproved = spamApproved }; // Bypass Approval if Admin or Moderator. if ( !LegacyDb.message_save( topicID, this.PageContext.PageUserID, msg, null, this.Get<HttpRequestBase>().GetUserRealIPAddress(), null, replyTo, tFlags.BitValue, ref messageId)) { topicID = 0; } // Check to see if the user has enabled "auto watch topic" option in his/her profile. if (this.PageContext.CurrentUserData.AutoWatchTopics) { var watchTopicId = this.GetRepository<WatchTopic>().Check(this.PageContext.PageUserID, this.PageContext.PageTopicID); if (!watchTopicId.HasValue) { // subscribe to this topic this.GetRepository<WatchTopic>().Add(this.PageContext.PageUserID, this.PageContext.PageTopicID); } } bool bApproved = false; using (DataTable dt = LegacyDb.message_list(messageId)) { foreach (DataRow row in dt.Rows) { bApproved = ((int)row["Flags"] & 16) == 16; } } if (bApproved) { // send new post notification to users watching this topic/forum this.Get<ISendNotification>().ToWatchingUsers(messageId.ToType<int>()); if (Config.IsDotNetNuke && !this.PageContext.IsGuest) { this.Get<IActivityStream>() .AddReplyToStream( this.PageContext.PageForumID, this.PageContext.PageTopicID, messageId.ToType<int>(), this.PageContext.PageTopicName, msg); } // redirect to newly posted message YafBuildLink.Redirect(ForumPages.posts, "m={0}&#post{0}", messageId); } else { if (this.Get<YafBoardSettings>().EmailModeratorsOnModeratedPost) { // not approved, notifiy moderators this.Get<ISendNotification>() .ToModeratorsThatMessageNeedsApproval( this.PageContext.PageForumID, messageId.ToType<int>(), isPossibleSpamMessage); } string url = YafBuildLink.GetLink(ForumPages.topics, "f={0}", this.PageContext.PageForumID); if (Config.IsRainbow) { YafBuildLink.Redirect(ForumPages.info, "i=1"); } else { YafBuildLink.Redirect(ForumPages.info, "i=1&url={0}", this.Server.UrlEncode(url)); } } }
/// <summary> /// Gets the user info as JSON string for the hover cards /// </summary> /// <param name="context">The context.</param> private void GetUserInfo([NotNull] HttpContext context) { try { var userId = context.Request.QueryString.GetFirstOrDefault("userinfo").ToType<int>(); MembershipUser user = UserMembershipHelper.GetMembershipUserById(userId); if (user == null || user.ProviderUserKey.ToString() == "0") { context.Response.Write( "Error: Resource has been moved or is unavailable. Please contact the forum admin."); return; } // Check if user has access if (!this.Get<IPermissions>().Check(this.Get<YafBoardSettings>().ProfileViewPermissions)) { context.Response.Write(string.Empty); return; } var userData = new CombinedUserDataHelper(user, userId); context.Response.Clear(); context.Response.ContentType = "application/json"; context.Response.ContentEncoding = Encoding.UTF8; context.Response.Cache.SetCacheability(HttpCacheability.Public); context.Response.Cache.SetExpires( DateTime.UtcNow.AddMilliseconds(YafContext.Current.Get<YafBoardSettings>().OnlineStatusCacheTimeout)); context.Response.Cache.SetLastModified(DateTime.UtcNow); var avatarUrl = this.Get<IAvatars>().GetAvatarUrlForUser(userId); avatarUrl = avatarUrl.IsNotSet() ? "{0}images/noavatar.gif".FormatWith(YafForumInfo.ForumClientFileRoot) : avatarUrl; var activeUsers = this.Get<IDataCache>().GetOrSet( Constants.Cache.UsersOnlineStatus, () => this.Get<YafDbBroker>().GetActiveList( false, YafContext.Current.Get<YafBoardSettings>().ShowCrawlersInActiveList), TimeSpan.FromMilliseconds(YafContext.Current.Get<YafBoardSettings>().OnlineStatusCacheTimeout)); var userIsOnline = activeUsers.AsEnumerable().Any( x => x.Field<int>("UserId").Equals(userId) && !x.Field<bool>("IsHidden")); var userName = this.Get<YafBoardSettings>().EnableDisplayName ? userData.DisplayName : userData.UserName; userName = HttpUtility.HtmlEncode(userName); var location = userData.Profile.Country.IsSet() ? YafContext.Current.Get<IHaveLocalization>().GetText( "COUNTRY", userData.Profile.Country.Trim()) : userData.Profile.Location; if (userData.Profile.Region.IsSet() && userData.Profile.Country.IsSet()) { var tag = "RGN_{0}_{1}".FormatWith(userData.Profile.Country.Trim(), userData.Profile.Region); location += ", {0}".FormatWith(YafContext.Current.Get<IHaveLocalization>().GetText("REGION", tag)); } var forumUrl = HttpUtility.UrlDecode(context.Request.QueryString.GetFirstOrDefault("forumUrl")); if (Config.IsMojoPortal) { forumUrl = forumUrl + "&g={0}&u={1}".FormatWith(ForumPages.pmessage, userId); } else { forumUrl = forumUrl.Replace(".aspx", ".aspx?g={0}&u={1}".FormatWith(ForumPages.pmessage, userId)); } var pmButton = new ThemeButton { ID = "PM", CssClass = "yafcssimagebutton", TextLocalizedPage = "POSTS", TextLocalizedTag = "PM", ImageThemeTag = "PM", TitleLocalizedTag = "PM_TITLE", TitleLocalizedPage = "POSTS", NavigateUrl = Config.IsAnyPortal ? forumUrl : YafBuildLink.GetLinkNotEscaped(ForumPages.pmessage, true, "u={0}", userId).Replace( "resource.ashx", "default.aspx"), ParamTitle0 = userName, Visible = !userData.IsGuest && this.Get<YafBoardSettings>().AllowPrivateMessages && !userId.Equals(YafContext.Current.PageUserID) && !YafContext.Current.IsGuest }; var userInfo = new YafUserInfo { name = userName, realname = HttpUtility.HtmlEncode(userData.Profile.RealName), avatar = avatarUrl, /*profilelink = Config.IsAnyPortal ? userlinkUrl : YafBuildLink.GetLink(ForumPages.profile, true, "u={0}", userId).Replace( "resource.ashx", "default.aspx"),*/ interests = HttpUtility.HtmlEncode(userData.Profile.Interests), homepage = userData.Profile.Homepage, posts = "{0:N0}".FormatWith(userData.NumPosts), rank = userData.RankName, location = location, joined = this.Get<IDateTime>().FormatDateLong(userData.Joined), online = userIsOnline, actionButtons = pmButton.RenderToString() }; if (YafContext.Current.Get<YafBoardSettings>().EnableUserReputation) { userInfo.points = (userData.Points.ToType<int>() > 0 ? "+" : string.Empty) + userData.Points; } context.Response.Write(userInfo.ToJson()); HttpContext.Current.ApplicationInstance.CompleteRequest(); } catch (Exception x) { this.Get<ILogger>().Log(0, this, x, EventLogTypes.Information); context.Response.Write( "Error: Resource has been moved or is unavailable. Please contact the forum admin."); } }
/// <summary> /// The page_ load. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { if (this.User == null) { YafBuildLink.AccessDenied(); } if (!this.IsPostBack) { // get user data... MembershipUser userHe = UserMembershipHelper.GetMembershipUserById(this.UserID); string displayNameHe = UserMembershipHelper.GetDisplayNameFromID(this.UserID); this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum)); this.PageLinks.AddLink( this.PageContext.BoardSettings.EnableDisplayName ? displayNameHe : userHe.UserName, YafBuildLink.GetLink( ForumPages.profile, "u={0}&name={1}", this.UserID, this.PageContext.BoardSettings.EnableDisplayName ? displayNameHe : userHe.UserName)); this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty); if (this.UserID == this.PageContext.PageUserID) { this.NotifyLabel.Text = this.GetText("SERVERYOU"); } else { if (userHe == null) { YafBuildLink.AccessDenied( /*No such user exists*/); } // Data for current page user MembershipUser userMe = UserMembershipHelper.GetMembershipUserById(this.PageContext.PageUserID); // get full user data... var userDataHe = new CombinedUserDataHelper(userHe, this.UserID); var userDataMe = new CombinedUserDataHelper(userMe, this.PageContext.PageUserID); string serverHe = userDataHe.Profile.XMPP.Substring(userDataHe.Profile.XMPP.IndexOf("@") + 1).Trim(); string serverMe = userDataMe.Profile.XMPP.Substring(userDataMe.Profile.XMPP.IndexOf("@") + 1).Trim(); if (serverMe == serverHe) { this.NotifyLabel.Text = this.GetTextFormatted("SERVERSAME", userDataHe.Profile.XMPP); } else { this.NotifyLabel.Text = this.GetTextFormatted("SERVEROTHER", "http://" + serverHe); } } } }
/// <summary> /// The page_ load. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { if (this.User == null) { YafBuildLink.AccessDenied(); } if (!this.IsPostBack) { // get user data... MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.UserID); if (user == null) { YafBuildLink.AccessDenied( /*No such user exists*/); } string displayName = UserMembershipHelper.GetDisplayNameFromID(this.UserID); this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum)); this.PageLinks.AddLink( this.PageContext.BoardSettings.EnableDisplayName ? displayName : user.UserName, YafBuildLink.GetLink(ForumPages.profile, "u={0}", this.UserID)); this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty); // get full user data... var userData = new CombinedUserDataHelper(user, this.UserID); this.Msg.NavigateUrl = "aim:goim?screenname={0}&message=Hi.+Are+you+there?".FormatWith(userData.Profile.AIM); this.Buddy.NavigateUrl = "aim:addbuddy?screenname={0}".FormatWith(userData.Profile.AIM); } }
/// <summary> /// The update profile_ click. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected void UpdateProfile_Click([NotNull] object sender, [NotNull] EventArgs e) { if (this.HomePage.Text.IsSet()) { // add http:// by default if (!Regex.IsMatch(this.HomePage.Text.Trim(), @"^(http|https|ftp|ftps|git|svn|news)\://.*")) { this.HomePage.Text = "http://{0}".FormatWith(this.HomePage.Text.Trim()); } if (!ValidationHelper.IsValidURL(this.HomePage.Text)) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_HOME"), MessageTypes.Warning); return; } } if (this.Weblog.Text.IsSet() && !ValidationHelper.IsValidURL(this.Weblog.Text.Trim())) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_WEBLOG"), MessageTypes.Warning); return; } if (this.MSN.Text.IsSet() && !ValidationHelper.IsValidEmail(this.MSN.Text)) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_MSN"), MessageTypes.Warning); return; } if (this.Xmpp.Text.IsSet() && !ValidationHelper.IsValidXmpp(this.Xmpp.Text)) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_XMPP"), MessageTypes.Warning); return; } if (this.ICQ.Text.IsSet() && !(ValidationHelper.IsValidEmail(this.ICQ.Text) || ValidationHelper.IsNumeric(this.ICQ.Text))) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_ICQ"), MessageTypes.Warning); return; } if (this.Facebook.Text.IsSet() && !ValidationHelper.IsValidURL(this.Facebook.Text)) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_FACEBOOK"), MessageTypes.Warning); return; } if (this.Google.Text.IsSet() && !ValidationHelper.IsValidURL(this.Google.Text)) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_GOOGLE"), MessageTypes.Warning); return; } string displayName = null; if (this.Get<YafBoardSettings>().EnableDisplayName && this.Get<YafBoardSettings>().AllowDisplayNameModification) { // Check if name matches the required minimum length if (this.DisplayName.Text.Trim().Length < this.Get<YafBoardSettings>().DisplayNameMinLength) { this.PageContext.AddLoadMessage( this.GetTextFormatted("USERNAME_TOOLONG", this.Get<YafBoardSettings>().DisplayNameMinLength), MessageTypes.Warning); return; } // Check if name matches the required minimum length if (this.DisplayName.Text.Length > this.Get<YafBoardSettings>().UserNameMaxLength) { this.PageContext.AddLoadMessage( this.GetTextFormatted("USERNAME_TOOLONG", this.Get<YafBoardSettings>().UserNameMaxLength), MessageTypes.Warning); return; } if (this.DisplayName.Text.Trim() != this.UserData.DisplayName) { if (this.Get<IUserDisplayName>().GetId(this.DisplayName.Text.Trim()).HasValue) { this.PageContext.AddLoadMessage(this.GetText("REGISTER", "ALREADY_REGISTERED_DISPLAYNAME"), MessageTypes.Warning); return; } displayName = this.DisplayName.Text.Trim(); } } string userName = UserMembershipHelper.GetUserNameFromID(this.currentUserID); if (this.UpdateEmailFlag) { string newEmail = this.Email.Text.Trim(); if (!ValidationHelper.IsValidEmail(newEmail)) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_EMAIL"), MessageTypes.Warning); return; } string userNameFromEmail = this.Get<MembershipProvider>().GetUserNameByEmail(this.Email.Text.Trim()); if (userNameFromEmail.IsSet() && userNameFromEmail != userName) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_EMAIL"), MessageTypes.Warning); return; } if (this.Get<YafBoardSettings>().EmailVerification) { this.SendEmailVerification(newEmail); } else { // just update the e-mail... try { UserMembershipHelper.UpdateEmail(this.currentUserID, this.Email.Text.Trim()); } catch (ApplicationException) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "DUPLICATED_EMAIL"), MessageTypes.Warning); return; } } } if (this.Interests.Text.Trim().Length > 400) { this.PageContext.AddLoadMessage( this.GetTextFormatted("FIELD_TOOLONG", this.GetText("CP_EDITPROFILE", "INTERESTS"), 400), MessageTypes.Warning); return; } if (this.Occupation.Text.Trim().Length > 400) { this.PageContext.AddLoadMessage( this.GetTextFormatted("FIELD_TOOLONG", this.GetText("CP_EDITPROFILE", "OCCUPATION"), 400), MessageTypes.Warning); return; } this.UpdateUserProfile(userName); // vzrus: We should do it as we need to write null value to db, else it will be empty. // Localizer currently treats only nulls. object language = null; object culture = this.Culture.SelectedValue; object theme = this.Theme.SelectedValue; object editor = this.ForumEditor.SelectedValue; if (this.Theme.SelectedValue.IsNotSet()) { theme = null; } if (this.ForumEditor.SelectedValue.IsNotSet()) { editor = null; } if (this.Culture.SelectedValue.IsNotSet()) { culture = null; } else { foreach (DataRow row in StaticDataHelper.Cultures() .Rows.Cast<DataRow>() .Where(row => culture.ToString() == row["CultureTag"].ToString())) { language = row["CultureFile"].ToString(); } } // save remaining settings to the DB LegacyDb.user_save( this.currentUserID, this.PageContext.PageBoardID, null, displayName, null, this.TimeZones.SelectedValue.ToType<int>(), language, culture, theme, editor, this.UseMobileTheme.Checked, null, null, null, this.DSTUser.Checked, this.HideMe.Checked, null); // vzrus: If it's a guest edited by an admin registry value should be changed DataTable dt = LegacyDb.user_list(this.PageContext.PageBoardID, this.currentUserID, true, null, null, false); if (dt.Rows.Count > 0 && dt.Rows[0]["IsGuest"].ToType<bool>()) { LegacyDb.registry_save("timezone", this.TimeZones.SelectedValue, this.PageContext.PageBoardID); } // clear the cache for this user...) this.Get<IRaiseEvent>().Raise(new UpdateUserEvent(this.currentUserID)); YafContext.Current.Get<IDataCache>().Clear(); if (!this.adminEditMode) { YafBuildLink.Redirect(ForumPages.cp_profile); } else { this._userData = null; this.BindData(); } }
/// <summary> /// The current_ after init. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void Current_AfterInit([NotNull] object sender, [NotNull] EventArgs e) { YafContext.Current.Vars["IsMobile"] = false; // see if this is a mobile device... if (!UserAgentHelper.IsMobileDevice(this.HttpRequestBase.UserAgent) && !this.HttpRequestBase.Browser.IsMobileDevice) { // make sure to shut off mobile theme usage if the user agent is not mobile. if (this.YafSession.UseMobileTheme ?? false) { this.YafSession.UseMobileTheme = false; } return; } if (!YafContext.Current.IsGuest) { // return if the user has mobile themes shut off in their profile. var userData = new CombinedUserDataHelper(YafContext.Current.PageUserID); if (!userData.UseMobileTheme) { return; } } this.UpdateUseMobileThemeFromQueryString(); // use the mobile theme? var useMobileTheme = this.YafSession.UseMobileTheme ?? true; // get the current mobile theme... var mobileTheme = YafContext.Current.BoardSettings.MobileTheme; if (mobileTheme.IsSet()) { // create a new theme object... var theme = new YafTheme(mobileTheme); // make sure it's valid... if (YafTheme.IsValidTheme(theme.ThemeFile)) { YafContext.Current.Vars["IsMobile"] = true; // set new mobile theme... if (useMobileTheme) { YafContext.Current.Get <ThemeProvider>().Theme = theme; this.YafSession.UseMobileTheme = true; } return; } } // make sure to shut off mobile theme usage if there was no valid mobile theme found... if (this.YafSession.UseMobileTheme ?? false) { this.YafSession.UseMobileTheme = false; } }
/// <summary> /// The current_ after init. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void Current_AfterInit([NotNull] object sender, [NotNull] EventArgs e) { YafContext.Current.Vars["IsMobile"] = false; // see if this is a mobile device... if (!UserAgentHelper.IsMobileDevice(this.HttpRequestBase.UserAgent) && !this.HttpRequestBase.Browser.IsMobileDevice) { // make sure to shut off mobile theme usage if the user agent is not mobile. if (this.YafSession.UseMobileTheme ?? false) { this.YafSession.UseMobileTheme = false; } return; } if (!YafContext.Current.IsGuest) { // return if the user has mobile themes shut off in their profile. var userData = new CombinedUserDataHelper(YafContext.Current.PageUserID); if (!userData.UseMobileTheme) { return; } } this.UpdateUseMobileThemeFromQueryString(); // use the mobile theme? var useMobileTheme = this.YafSession.UseMobileTheme ?? true; // get the current mobile theme... var mobileTheme = YafContext.Current.BoardSettings.MobileTheme; if (mobileTheme.IsSet()) { // create a new theme object... var theme = new YafTheme(mobileTheme); // make sure it's valid... if (YafTheme.IsValidTheme(theme.ThemeFile)) { YafContext.Current.Vars["IsMobile"] = true; // set new mobile theme... if (useMobileTheme) { YafContext.Current.Get<ThemeProvider>().Theme = theme; this.YafSession.UseMobileTheme = true; } return; } } // make sure to shut off mobile theme usage if there was no valid mobile theme found... if (this.YafSession.UseMobileTheme ?? false) { this.YafSession.UseMobileTheme = false; } }
/// <summary> /// The save_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void Save_Click([NotNull] object sender, [NotNull] EventArgs e) { var body = this._sig.Text; // find forbidden BBcodes in signature var detectedBbCode = this.Get<IFormatMessage>().BBCodeForbiddenDetector(body, this._allowedBbcodes, ','); if (this._allowedBbcodes.IndexOf("ALL") < 0) { if (detectedBbCode.IsSet() && detectedBbCode != "ALL") { this.PageContext.AddLoadMessage( this.GetTextFormatted("SIGNATURE_BBCODE_WRONG", detectedBbCode)); return; } if (detectedBbCode.IsSet() && detectedBbCode == "ALL") { this.PageContext.AddLoadMessage(this.GetText("BBCODE_FORBIDDEN")); return; } } // find forbidden HTMLTags in signature if (!this.PageContext.IsAdmin && this._allowedHtml.IndexOf("ALL") < 0) { var detectedHtmlTag = this.Get<IFormatMessage>().CheckHtmlTags(body, this._allowedHtml, ','); if (detectedHtmlTag.IsSet() && detectedHtmlTag != "ALL") { this.PageContext.AddLoadMessage(detectedHtmlTag); return; } if (detectedHtmlTag.IsSet() && detectedHtmlTag == "ALL") { this.PageContext.AddLoadMessage(this.GetText("HTML_FORBIDDEN")); return; } } // body = this.Get<IFormatMessage>().RepairHtml(this,body,false); if (this._sig.Text.Length > 0) { if (this._sig.Text.Length <= this._allowedNumberOfCharacters) { var userData = new CombinedUserDataHelper(this.CurrentUserID); if (userData.NumPosts < this.Get<YafBoardSettings>().IgnoreSpamWordCheckPostCount) { // Check for spam string result; if (this.Get<ISpamWordCheck>().CheckForSpamWord(body, out result)) { var user = UserMembershipHelper.GetMembershipUserById(this.CurrentUserID); var userId = this.CurrentUserID; // Log and Send Message to Admins if (this.Get<YafBoardSettings>().BotHandlingOnRegister.Equals(1)) { this.Logger.Log( null, "Bot Detected", "Internal Spam Word Check detected a SPAM BOT: (user name : '{0}', user id : '{1}') after the user included a spam word in his/her signature: {2}" .FormatWith(user.UserName, this.CurrentUserID, result), EventLogTypes.SpamBotDetected); } else if (this.Get<YafBoardSettings>().BotHandlingOnRegister.Equals(2)) { this.Logger.Log( null, "Bot Detected", "Internal Spam Word Check detected a SPAM BOT: (user name : '{0}', user id : '{1}') after the user included a spam word in his/her signature: {2}, user was deleted and the name, email and IP Address are banned." .FormatWith(user.UserName, this.CurrentUserID, result), EventLogTypes.SpamBotDetected); // Kill user if (!this.InAdminPages) { var userIp = new CombinedUserDataHelper(user, userId).LastIP; UserMembershipHelper.DeleteAndBanUser(this.CurrentUserID, user, userIp); } } } } LegacyDb.user_savesignature(this.CurrentUserID, this.Get<IBadWordReplace>().Replace(body)); } else { this.PageContext.AddLoadMessage( this.GetTextFormatted("SIGNATURE_MAX", this._allowedNumberOfCharacters)); return; } } else { LegacyDb.user_savesignature(this.CurrentUserID, DBNull.Value); } // clear the cache for this user... this.Get<IRaiseEvent>().Raise(new UpdateUserEvent(this.CurrentUserID)); if (this.InAdminPages) { this.BindData(); } else { this.DoRedirect(); } }
/// <summary> /// The page_ load. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { if (this.User == null) { YafBuildLink.AccessDenied(); } if (!this.IsPostBack) { this.Send.Text = this.GetText("SEND"); this.From.Text = this.PageContext.User.UserName; this.Email.Text = this.PageContext.User.Email; // get user data... MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.UserID); if (user == null) { YafBuildLink.AccessDenied( /*No such user exists*/); } string displayName = UserMembershipHelper.GetDisplayNameFromID(this.UserID); this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum)); this.PageLinks.AddLink( this.PageContext.BoardSettings.EnableDisplayName ? displayName : user.UserName, YafBuildLink.GetLink( ForumPages.profile, "u={0}&name={1}", this.UserID, this.PageContext.BoardSettings.EnableDisplayName ? displayName : user.UserName)); this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty); // get full user data... var userData = new CombinedUserDataHelper(user, this.UserID); this.ViewState["to"] = userData.Profile.ICQ; this.Status.Src = "http://web.icq.com/whitepages/online?icq={0}&img=5".FormatWith(userData.Profile.ICQ); } }
/// <summary> /// The bind data. /// </summary> private void BindData() { MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.UserId); if (user == null || user.ProviderUserKey.ToString() == "0") { // No such user exists or this is an nntp user ("0") YafBuildLink.AccessDenied(); } var userData = new CombinedUserDataHelper(user, this.UserId); // populate user information controls... // Is BuddyList feature enabled? if (this.Get<YafBoardSettings>().EnableBuddyList) { this.SetupBuddyList(this.UserId, userData); } else { // BuddyList feature is disabled. don't show any link. this.lnkBuddy.Visible = false; this.ltrApproval.Visible = false; } // Is album feature enabled? if (this.Get<YafBoardSettings>().EnableAlbum) { this.AlbumList1.UserID = this.UserId; } else { this.AlbumList1.Dispose(); } var userNameOrDisplayName = this.Get<YafBoardSettings>().EnableDisplayName ? userData.DisplayName : userData.UserName; this.SetupUserProfileInfo(this.UserId, user, userData, userNameOrDisplayName); this.AddPageLinks(userNameOrDisplayName); this.SetupUserStatistics(userData); this.SetupUserLinks(userData, userNameOrDisplayName); this.SetupAvatar(this.UserId, userData); bool bFirst = true; const string StyledNick = @"<span class=""YafGroup_{0}"" style=""{1}"">{0}</span>"; string groupsText = null; foreach ( DataRow role in CommonDb.group_member(PageContext.PageModuleID, PageContext.PageBoardID, this.UserId).Rows) { // || role["IsUserGroup"].ToType<bool>() // CommonDb.eventlog_create(PageContext.PageModuleID,this.DataRow["UserId"], this, ">>>>>>>>>>userName ="******" group = " + role, EventLogTypes.Warning); if (role["Name"].ToString().IsNotSet() || role["Member"].ToType<int>() == 0 || role["IsHidden"].ToType<bool>()) { continue; } if (bFirst) { groupsText = this.Get<YafBoardSettings>().UseStyledNicks ? StyledNick.FormatWith( role["Name"].ToString(), this.TransformStyle.DecodeStyleByString(role["Style"].ToString(), true)) : role["Name"].ToString(); bFirst = false; } else { if (this.Get<YafBoardSettings>().UseStyledNicks) { groupsText = groupsText + (@", " + StyledNick).FormatWith( role["Name"], this.TransformStyle.DecodeStyleByString(role["Style"].ToString(), true)); } else { groupsText = groupsText + ", {0}".FormatWith(role["Name"]); } } } this.Groups.Text = groupsText; // this.Groups.DataSource = RoleMembershipHelper.GetRolesForUser(userData.UserName); // EmailRow.Visible = PageContext.IsAdmin; this.ModerateTab.Visible = this.PageContext.IsAdmin || this.PageContext.IsForumModerator; this.ModerateLi.Visible = this.PageContext.IsAdmin || this.PageContext.IsForumModerator; this.AdminUserButton.Visible = this.PageContext.IsAdmin; if (this.LastPosts.Visible) { this.LastPosts.DataSource = CommonDb.post_alluser( PageContext.PageModuleID, this.PageContext.PageBoardID, this.UserId, this.PageContext.PageUserID, 10).AsEnumerable(); this.SearchUser.NavigateUrl = YafBuildLink.GetLinkNotEscaped( ForumPages.search, "postedby={0}&u={1}", (this.Get<YafBoardSettings>().EnableDisplayName ? userData.DisplayName : userData.UserName), this.UserId); } this.DataBind(); }
/// <summary> /// Handles the PostReply click including: Replying, Editing and New post. /// </summary> /// <param name="sender"> /// The Sender Object. /// </param> /// <param name="e"> /// The Event Arguments. /// </param> protected void PostReply_Click([NotNull] object sender, [NotNull] EventArgs e) { if (!this.IsPostReplyVerified()) { return; } if (this.IsPostReplyDelay()) { return; } var isPossibleSpamMessage = false; // Check for SPAM if (!this.PageContext.IsAdmin && !this.PageContext.ForumModeratorAccess && !this.PageContext.BoardSettings.SpamServiceType.Equals(0)) { var spamChecker = new YafSpamCheck(); string spamResult; // Check content for spam if ( spamChecker.CheckPostForSpam( this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName, this.Get<HttpRequestBase>().GetUserRealIPAddress(), BBCodeHelper.StripBBCode( HtmlHelper.StripHtml(HtmlHelper.CleanHtmlString(this._forumEditor.Text))) .RemoveMultipleWhitespace(), this.PageContext.IsGuest ? null : this.PageContext.User.Email, out spamResult)) { switch (this.PageContext.BoardSettings.SpamMessageHandling) { case 0: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}".FormatWith( this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName), EventLogTypes.SpamMessageDetected); break; case 1: this.spamApproved = false; isPossibleSpamMessage = true; this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, it was flagged as unapproved post." .FormatWith( this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); break; case 2: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, post was rejected" .FormatWith( this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); this.PageContext.AddLoadMessage(this.GetText("SPAM_MESSAGE"), MessageTypes.danger); return; case 3: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, user was deleted and banned" .FormatWith( this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); var userIp = new CombinedUserDataHelper( this.PageContext.CurrentUserData.Membership, this.PageContext.PageUserID).LastIP; UserMembershipHelper.DeleteAndBanUser( this.PageContext.PageUserID, this.PageContext.CurrentUserData.Membership, userIp); return; } } } // Check posts for urls if the user has only x posts if (YafContext.Current.CurrentUserData.NumPosts <= YafContext.Current.Get<YafBoardSettings>().IgnoreSpamWordCheckPostCount && !this.PageContext.IsAdmin && !this.PageContext.ForumModeratorAccess) { var urlCount = UrlHelper.CountUrls(this._forumEditor.Text); if (urlCount > this.PageContext.BoardSettings.AllowedNumberOfUrls) { var spamResult = "The user posted {0} urls but allowed only {1}".FormatWith( urlCount, this.PageContext.BoardSettings.AllowedNumberOfUrls); switch (this.PageContext.BoardSettings.SpamMessageHandling) { case 0: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}".FormatWith( this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName), EventLogTypes.SpamMessageDetected); break; case 1: this.spamApproved = false; isPossibleSpamMessage = true; this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, it was flagged as unapproved post." .FormatWith( this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); break; case 2: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, post was rejected" .FormatWith( this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); this.PageContext.AddLoadMessage(this.GetText("SPAM_MESSAGE"), MessageTypes.danger); return; case 3: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, user was deleted and banned" .FormatWith( this.PageContext.IsGuest ? this.From.Text : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); var userIp = new CombinedUserDataHelper( this.PageContext.CurrentUserData.Membership, this.PageContext.PageUserID).LastIP; UserMembershipHelper.DeleteAndBanUser( this.PageContext.PageUserID, this.PageContext.CurrentUserData.Membership, userIp); return; } } } // update the last post time... this.Get<IYafSession>().LastPost = DateTime.UtcNow.AddSeconds(30); long messageId; long newTopic = 0; if (this.TopicID != null) { // Reply to topic messageId = this.PostReplyHandleReplyToTopic(this.spamApproved); newTopic = this.TopicID.ToType<long>(); } else if (this.EditMessageID != null) { // Edit existing post messageId = this.PostReplyHandleEditPost(); } else { // New post messageId = this.PostReplyHandleNewPost(out newTopic); } // Check if message is approved var isApproved = false; using (DataTable dt = LegacyDb.message_list(messageId)) { foreach (DataRow row in dt.Rows) { isApproved = row["Flags"].BinaryAnd(MessageFlags.Flags.IsApproved); } } // vzrus^ the poll access controls are enabled and this is a new topic - we add the variables var attachPollParameter = string.Empty; var retforum = string.Empty; if (this.PageContext.ForumPollAccess && this.PostOptions1.PollOptionVisible && newTopic > 0) { // new topic poll token attachPollParameter = "&t={0}".FormatWith(newTopic); // new return forum poll token retforum = "&f={0}".FormatWith(this.PageContext.PageForumID); } // Create notification emails if (isApproved) { this.Get<ISendNotification>().ToWatchingUsers(messageId.ToType<int>()); if (Config.IsDotNetNuke && this.EditMessageID == null && !this.PageContext.IsGuest) { if (this.TopicID != null) { this.Get<IActivityStream>() .AddReplyToStream( this.PageContext.PageForumID, newTopic, messageId.ToType<int>(), this.PageContext.PageTopicName, this._forumEditor.Text); } else { this.Get<IActivityStream>() .AddTopicToStream( this.PageContext.PageForumID, newTopic, messageId.ToType<int>(), this.TopicSubjectTextBox.Text, this._forumEditor.Text); } } if (attachPollParameter.IsNotSet() || (!this.PostOptions1.PollChecked)) { // regular redirect... YafBuildLink.Redirect(ForumPages.posts, "m={0}#post{0}", messageId); } else { // poll edit redirect... YafBuildLink.Redirect(ForumPages.polledit, "{0}", attachPollParameter); } } else { // Not Approved if (this.PageContext.BoardSettings.EmailModeratorsOnModeratedPost) { // not approved, notifiy moderators this.Get<ISendNotification>() .ToModeratorsThatMessageNeedsApproval( this.PageContext.PageForumID, messageId.ToType<int>(), isPossibleSpamMessage); } // 't' variable is required only for poll and this is a attach poll token for attachments page if (!this.PostOptions1.PollChecked) { attachPollParameter = string.Empty; } // Tell user that his message will have to be approved by a moderator var url = YafBuildLink.GetLink(ForumPages.topics, "f={0}", this.PageContext.PageForumID); if (this.PageContext.PageTopicID > 0) { url = YafBuildLink.GetLink(ForumPages.posts, "t={0}", this.PageContext.PageTopicID); } if (attachPollParameter.Length <= 0) { YafBuildLink.Redirect(ForumPages.info, "i=1&url={0}", this.Server.UrlEncode(url)); } else { YafBuildLink.Redirect(ForumPages.polledit, "&ra=1{0}{1}", attachPollParameter, retforum); } if (Config.IsRainbow) { YafBuildLink.Redirect(ForumPages.info, "i=1"); } } }
/// <summary> /// The update profile_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void UpdateProfile_Click([NotNull] object sender, [NotNull] EventArgs e) { if (this.HomePage.Text.IsSet()) { // add http:// by default if (!Regex.IsMatch(this.HomePage.Text.Trim(), @"^(http|https|ftp|ftps|git|svn|news)\://.*")) { this.HomePage.Text = "http://{0}".FormatWith(this.HomePage.Text.Trim()); } if (!ValidationHelper.IsValidURL(this.HomePage.Text)) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_HOME")); return; } } if (this.Weblog.Text.IsSet() && !ValidationHelper.IsValidURL(this.Weblog.Text.Trim())) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_WEBLOG")); return; } if (this.MSN.Text.IsSet() && !ValidationHelper.IsValidEmail(this.MSN.Text)) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_MSN")); return; } if (this.Xmpp.Text.IsSet() && !ValidationHelper.IsValidXmpp(this.Xmpp.Text)) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_XMPP")); return; } if (this.ICQ.Text.IsSet() && !(ValidationHelper.IsValidEmail(this.ICQ.Text) || ValidationHelper.IsNumeric(this.ICQ.Text))) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_ICQ")); return; } if (this.Facebook.Text.IsSet() && !ValidationHelper.IsNumeric(this.Facebook.Text)) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_FACEBOOK")); return; } string displayName = null; if (this.Get<YafBoardSettings>().EnableDisplayName && this.Get<YafBoardSettings>().AllowDisplayNameModification) { if (this.DisplayName.Text.Trim().Length < 2) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "INVALID_DISPLAYNAME")); return; } if (this.DisplayName.Text.Trim() != this.UserData.DisplayName) { if (this.Get<IUserDisplayName>().GetId(this.DisplayName.Text.Trim()).HasValue) { this.PageContext.AddLoadMessage( this.GetText("REGISTER", "ALREADY_REGISTERED_DISPLAYNAME")); return; } displayName = this.DisplayName.Text.Trim(); } } string userName = UserMembershipHelper.GetUserNameFromID(this._currentUserId); if (this.UpdateEmailFlag) { string newEmail = this.Email.Text.Trim(); if (!ValidationHelper.IsValidEmail(newEmail)) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_EMAIL")); return; } string userNameFromEmail = this.Get<MembershipProvider>().GetUserNameByEmail(this.Email.Text.Trim()); if (userNameFromEmail.IsSet() && userNameFromEmail != userName) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_EMAIL")); return; } if (this.Get<YafBoardSettings>().EmailVerification) { this.SendEmailVerification(newEmail); } else { // just update the e-mail... try { UserMembershipHelper.UpdateEmail(this._currentUserId, this.Email.Text.Trim()); } catch (ApplicationException) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "DUPLICATED_EMAIL")); return; } } } this.UpdateUserProfile(userName); // vzrus: We should do it as we need to write null value to db, else it will be empty. // Localizer currently treats only nulls. object languageFileName = null; object culture = this.Culture.SelectedValue; object theme = this.Theme.SelectedValue; object editor = this.ForumEditor.SelectedValue; if (string.IsNullOrEmpty(this.Theme.SelectedValue)) { theme = null; } if (string.IsNullOrEmpty(this.ForumEditor.SelectedValue)) { editor = null; } if (string.IsNullOrEmpty(this.Culture.SelectedValue)) { culture = null; } else { languageFileName = StaticDataHelper.Cultures().Where( ci => culture.ToString() == ci.IetfLanguageTag).FirstOrDefault().CultureFile; } // save remaining settings to the DB CommonDb.user_save( this.PageContext.PageModuleID, this._currentUserId, this.PageContext.PageBoardID, null, displayName, null, this.TimeZones.SelectedValue.ToType<int>(), languageFileName, culture, theme, this.SingleSignOn.Checked, editor, this.UseMobileTheme.Checked, null, null, null, this.DSTUser.Checked, this.HideMe.Checked, null, this.TopicsPerPageDDL.SelectedValue, this.PostsPerPageDDL.SelectedValue); // vzrus: If it's a guest edited by an admin registry value should be changed DataTable dt = CommonDb.user_list(PageContext.PageModuleID, this.PageContext.PageBoardID, this._currentUserId, true, null, null, false); if (dt.Rows.Count > 0 && dt.Rows[0]["IsGuest"].ToType<bool>()) { CommonDb.registry_save(PageContext.PageModuleID, "timezone", this.TimeZones.SelectedValue, 0); } // clear the cache for this user...) this.Get<IRaiseEvent>().Raise(new UpdateUserEvent(this._currentUserId)); YafContext.Current.Get<IDataCache>().Clear(); if (!this._adminEditMode) { YafBuildLink.Redirect(ForumPages.cp_profile); } else { this._userData = null; this.BindData(); } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { // init ids... this.PageContext.QueryIDs = new QueryStringIDHelper("u", true); // this needs to be done just once, not during postbacks if (this.IsPostBack) { return; } MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.CurrentUserID); var userData = new CombinedUserDataHelper(user, this.CurrentUserID.Value.ToType<int>()); this.ViewPostsLink.NavigateUrl = YafBuildLink.GetLinkNotEscaped( ForumPages.search, "postedby={0}", !userData.IsGuest ? (this.Get<YafBoardSettings>().EnableDisplayName ? userData.DisplayName : userData.UserName) : UserMembershipHelper.GuestUserName); this.Kill.Text = this.GetText("ADMIN_EDITUSER", "KILL_USER"); ControlHelper.AddOnClickConfirmDialog(this.Kill, this.GetText("ADMIN_EDITUSER", "KILL_USER_CONFIRM")); if (this.Get<YafBoardSettings>().StopForumSpamApiKey.IsSet()) { this.ReportUser.Visible = true; this.ReportUser.Text = this.GetText("ADMIN_EDITUSER", "REPORT_USER"); ControlHelper.AddOnClickConfirmDialog( this.ReportUser, this.GetText("ADMIN_EDITUSER", "REPORT_USER_CONFIRM")); } else { this.ReportUser.Visible = false; } // bind data this.BindData(); }
/// <summary> /// The page_ load. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { if (this.User == null) { YafBuildLink.AccessDenied(); } if (!this.IsPostBack) { // get user data... MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.UserID); if (user == null) { YafBuildLink.AccessDenied( /*No such user exists*/); } string displayName = UserMembershipHelper.GetDisplayNameFromID(this.UserID); this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum)); this.PageLinks.AddLink( this.PageContext.BoardSettings.EnableDisplayName ? displayName : user.UserName, YafBuildLink.GetLink( ForumPages.profile, "u={0}&name={1}", this.UserID, this.PageContext.BoardSettings.EnableDisplayName ? displayName : user.UserName)); this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty); // get full user data... var userData = new CombinedUserDataHelper(user, this.UserID); this.Msg.NavigateUrl = "msnim:chat?contact={0}".FormatWith(userData.Profile.MSN); // Msg.Attributes.Add( "onclick", "return skypeCheck();" ); this.Img.Src = "http://messenger.services.live.com/users/{0}/presenceimage".FormatWith(userData.Profile.MSN); } }
/// <summary> /// Gets the profile context. /// </summary> /// <param name="userId">The user identifier.</param> /// <returns></returns> public static ProfileModel GetProfileContext(int userId) { var userData = new CombinedUserDataHelper(userId).Profile; return new ProfileModel { UserId = userId, UserName = UserMembershipHelper.GetDisplayNameFromID(userId), Avatar = new YafAvatars(YafContext.Current.BoardSettings).GetAvatarUrlForUser(userId), AIM = userData.AIM, City = userData.City, Country = userData.Country, Facebook = userData.Facebook, FacebookId = userData.FacebookId, Homepage = userData.Homepage, MSN = userData.MSN, Twitter = userData.Twitter, TwitterId = userData.TwitterId, Interests = userData.Interests, Skype = userData.Skype, Occupation = userData.Occupation, UnreadMessages = Message.GetTotalUnreadInboxMessages(userId) }; }
/// <summary> /// The page_ load. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { // init ids... this.PageContext.QueryIDs = new QueryStringIDHelper("u", true); // this needs to be done just once, not during postbacks if (this.IsPostBack) { return; } MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.CurrentUserID); var userData = new CombinedUserDataHelper(user, (int)this.CurrentUserID.Value); this.ViewPostsLink.NavigateUrl = YafBuildLink.GetLinkNotEscaped( ForumPages.search, "postedby={0}&u={1}", !userData.IsGuest ? (this.Get<YafBoardSettings>().EnableDisplayName ? userData.DisplayName : userData.UserName) : (UserMembershipHelper.GuestUserName), userData.UserID); // bind data this.BindData(); }
/// <summary> /// The bind data. /// </summary> private void BindData() { MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.UserId); if (user == null || user.ProviderUserKey.ToString() == "0") { // No such user exists or this is an nntp user ("0") YafBuildLink.AccessDenied(); } var userData = new CombinedUserDataHelper(user, this.UserId); // populate user information controls... // Is BuddyList feature enabled? if (this.Get<YafBoardSettings>().EnableBuddyList) { this.SetupBuddyList(this.UserId, userData); } else { // BuddyList feature is disabled. don't show any link. this.BuddyLi.Visible = false; this.BuddyListTab.Visible = false; this.lnkBuddy.Visible = false; this.ltrApproval.Visible = false; } // Is album feature enabled? if (this.Get<YafBoardSettings>().EnableAlbum) { this.AlbumList1.UserID = this.UserId; } else { this.AlbumList1.Dispose(); } var userNameOrDisplayName = this.Get<YafBoardSettings>().EnableDisplayName ? userData.DisplayName : userData.UserName; this.SetupUserProfileInfo(this.UserId, user, userData, userNameOrDisplayName); this.AddPageLinks(userNameOrDisplayName); this.SetupUserStatistics(userData); this.SetupUserLinks(userData, userNameOrDisplayName); this.SetupAvatar(this.UserId, userData); this.Groups.DataSource = RoleMembershipHelper.GetRolesForUser(userData.UserName); // EmailRow.Visible = PageContext.IsAdmin; this.ModerateTab.Visible = this.PageContext.IsAdmin || this.PageContext.IsForumModerator; this.ModerateLi.Visible = this.PageContext.IsAdmin || this.PageContext.IsForumModerator; this.AdminUserButton.Visible = this.PageContext.IsAdmin; if (this.LastPosts.Visible) { this.LastPosts.DataSource = LegacyDb.post_alluser(this.PageContext.PageBoardID, this.UserId, this.PageContext.PageUserID, 10) .AsEnumerable(); this.SearchUser.NavigateUrl = YafBuildLink.GetLinkNotEscaped( ForumPages.search, "postedby={0}", this.Get<YafBoardSettings>().EnableDisplayName ? userData.DisplayName : userData.UserName); } this.DataBind(); }
/// <summary> /// The page_ load. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { if (this.User == null) { YafBuildLink.AccessDenied(); } if (!this.IsPostBack) { // get user data... MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.UserID); if (user == null) { YafBuildLink.AccessDenied( /*No such user exists*/); } string displayName = UserMembershipHelper.GetDisplayNameFromID(this.UserID); this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum)); this.PageLinks.AddLink( !string.IsNullOrEmpty(displayName) ? displayName : user.UserName, YafBuildLink.GetLink(ForumPages.profile, "u={0}", this.UserID)); this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty); // get full user data... var userData = new CombinedUserDataHelper(user, this.UserID); this.Msg.NavigateUrl = "skype:{0}?call".FormatWith(userData.Profile.Skype); this.Msg.Attributes.Add("onclick", "return skypeCheck();"); this.Img.Src = "http://mystatus.skype.com/bigclassic/{0}".FormatWith(userData.Profile.Skype); } }