/// <summary> /// The bind data. /// </summary> private void BindData() { DataTable activeUsers = null; switch (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefaultAs <int>("v")) { case 0: // Show all users activeUsers = this.GetActiveUsersData( true, this.PageContext.BoardSettings.ShowGuestsInDetailedActiveList); if (activeUsers != null) { this.RemoveHiddenUsers(ref activeUsers); } break; case 1: // Show members activeUsers = this.GetActiveUsersData(false, false); if (activeUsers != null) { this.RemoveHiddenUsers(ref activeUsers); } break; case 2: // Show guests activeUsers = this.GetActiveUsersData(true, this.PageContext.BoardSettings.ShowCrawlersInActiveList); if (activeUsers != null) { this.RemoveAllButGuests(ref activeUsers); } break; case 3: // Show hidden if (this.PageContext.IsAdmin) { activeUsers = this.GetActiveUsersData(false, false); if (activeUsers != null) { this.RemoveAllButHiddenUsers(ref activeUsers); } } else { YafBuildLink.AccessDenied(); } break; default: YafBuildLink.AccessDenied(); break; } if (activeUsers == null || !activeUsers.HasRows()) { return; } YafContext.Current.PageElements.RegisterJsBlock( "UnverifiedUserstablesorterLoadJs", JavaScriptBlocks.LoadTableSorter( "#ActiveUsers", "sortList: [[0,0]]", "#ActiveUsersPager")); this.UserList.DataSource = activeUsers; this.DataBind(); }
/// <summary> /// The cancel_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void cancel_Click([NotNull] object sender, [NotNull] EventArgs e) { YafBuildLink.Redirect(ForumPages.admin_smilies); }
/// <summary> /// Handles the Click event of the Cancel 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 Cancel_Click([NotNull] object sender, [NotNull] EventArgs e) { YafBuildLink.Redirect(this.PageContext.CurrentForumPage.IsAdminPage ? ForumPages.admin_users : ForumPages.cp_profile); }
/// <summary> /// The render. /// </summary> /// <param name="writer"> /// The writer. /// </param> protected override void Render([NotNull] HtmlTextWriter writer) { // LoadList /*var navItemGeneralTopics = new YafHelpNavigation * { * HelpCategory = "GENERALTOPICS", * HelpPages = * new List<YafHelpNavigationPage> * { * new YafHelpNavigationPage { HelpPage = "FORUMS" }, * new YafHelpNavigationPage { HelpPage = "REGISTRATION" }, * new YafHelpNavigationPage { HelpPage = "SEARCHING" }, * new YafHelpNavigationPage { HelpPage = "ANOUNCE" }, * new YafHelpNavigationPage { HelpPage = "DISPLAY" }, * new YafHelpNavigationPage { HelpPage = "NEWPOSTS" }, * new YafHelpNavigationPage { HelpPage = "THREADOPT" }, * new YafHelpNavigationPage { HelpPage = "RECOVER" }, * new YafHelpNavigationPage { HelpPage = "MEMBERSLIST" }, * new YafHelpNavigationPage { HelpPage = "POPUPS" }, * new YafHelpNavigationPage { HelpPage = "PM" }, * new YafHelpNavigationPage { HelpPage = "RSS" } * } * }; * * this.helpNavList.Add(navItemGeneralTopics); * * var navItemProfileTopics = new YafHelpNavigation * { * HelpCategory = "PROFILETOPICS", * HelpPages = * new List<YafHelpNavigationPage> * { * new YafHelpNavigationPage { HelpPage = "MYSETTINGS" }, * new YafHelpNavigationPage { HelpPage = "MESSENGER" }, * new YafHelpNavigationPage { HelpPage = "PUBLICPROFILE" }, * new YafHelpNavigationPage { HelpPage = "EDITPROFILE" }, * new YafHelpNavigationPage { HelpPage = "THANKS" }, * new YafHelpNavigationPage { HelpPage = "BUDDIES" }, * new YafHelpNavigationPage { HelpPage = "MYALBUMS" }, * new YafHelpNavigationPage { HelpPage = "MYPICS" }, * new YafHelpNavigationPage { HelpPage = "MAILSETTINGS" }, * new YafHelpNavigationPage { HelpPage = "SUBSCRIPTIONS" } * } * }; * * this.helpNavList.Add(navItemProfileTopics); * * var navItemReadPostTopics = new YafHelpNavigation * { * HelpCategory = "READPOSTTOPICS", * HelpPages = * new List<YafHelpNavigationPage> * { * new YafHelpNavigationPage { HelpPage = "POSTING" }, * new YafHelpNavigationPage { HelpPage = "REPLYING" }, * new YafHelpNavigationPage { HelpPage = "EDITDELETE" }, * new YafHelpNavigationPage { HelpPage = "POLLS" }, * new YafHelpNavigationPage { HelpPage = "ATTACHMENTS" }, * new YafHelpNavigationPage { HelpPage = "SMILIES" }, * new YafHelpNavigationPage { HelpPage = "MODSADMINS" }, * } * }; * * this.helpNavList.Add(navItemReadPostTopics); * */ var serializer = new XmlSerializer(typeof(List <YafHelpNavigation>)); var xmlFilePath = HttpContext.Current.Server.MapPath( "{0}resources/{1}".FormatWith(YafForumInfo.ForumServerFileRoot, "HelpMenuList.xml")); if (File.Exists(xmlFilePath)) { var reader = new StreamReader(xmlFilePath); this.helpNavList = (List <YafHelpNavigation>)serializer.Deserialize(reader); reader.Close(); } var html = new StringBuilder(2000); string faqPage = "index"; if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("faq").IsSet()) { faqPage = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("faq"); } // Header html.Append(@"<table cellspacing=""0"" cellpadding=""0"" class=""content"" id=""yafhelpmenu"">"); html.Append(@"<tr><td class=""header1"">{0}</td></tr>".FormatWith(this.GetText("HELP_INDEX", "NAVIGATION"))); html.Append(@"<tr class=""header2""><td>{0}</td></tr>".FormatWith(this.GetText("HELP_INDEX", "INDEX"))); html.AppendFormat(@"<tr><td class=""post""><ul id=""yafhelpindex"">"); string selectedStyle = string.Empty; if (faqPage.Equals("index")) { selectedStyle = @"style=""color:red;"""; } html.AppendFormat( @"<li><a href=""{0}"" {2} title=""{1}"">{1}</a></li>", YafBuildLink.GetLink(ForumPages.help_index, "faq=index"), this.GetText("HELP_INDEX", "SEARCHHELP"), selectedStyle); html.AppendFormat(@"</ul></td></tr>"); foreach (var category in this.helpNavList) { html.AppendFormat( @"<tr class=""header2""><td>{0}</td></tr>", this.GetText("HELP_INDEX", category.HelpCategory)); html.AppendFormat(@"<tr><td class=""post""><ul id=""yafhelp{0}"">", category.HelpCategory.ToLower()); foreach (var helpPage in category.HelpPages) { selectedStyle = string.Empty; if (helpPage.HelpPage.ToLower().Equals(faqPage)) { selectedStyle = @"style=""color:red;"""; } if (helpPage.HelpPage.Equals("REGISTRATION")) { if (!this.Get <YafBoardSettings>().DisableRegistrations&& !Config.IsAnyPortal) { html.AppendFormat( @"<li><a href=""{0}"" {2} title=""{1}"">{1}</a></li>", YafBuildLink.GetLink(ForumPages.help_index, "faq={0}".FormatWith(helpPage.HelpPage.ToLower())), this.GetText("HELP_INDEX", "{0}TITLE".FormatWith(helpPage.HelpPage)), selectedStyle); } } else { html.AppendFormat( @"<li><a href=""{0}"" {2} title=""{1}"">{1}</a></li>", YafBuildLink.GetLink(ForumPages.help_index, "faq={0}".FormatWith(helpPage.HelpPage.ToLower())), this.GetText("HELP_INDEX", "{0}TITLE".FormatWith(helpPage.HelpPage)), selectedStyle); } } html.AppendFormat(@"</ul></td></tr>"); } html.Append(@"</table>"); writer.BeginRender(); // render the contents of the help menu.... writer.WriteLine(@"<div id=""{0}"">".FormatWith(this.ClientID)); writer.WriteLine(@"<table class=""adminContainer""><tr>"); writer.WriteLine(@"<td class=""adminMenu"" valign=""top"">"); writer.Write(html.ToString()); writer.WriteLine(@"</td>"); // contents of the help pages... writer.WriteLine(@"<td class=""helpContent"">"); this.RenderChildren(writer); writer.WriteLine(@"</td></tr></table>"); writer.WriteLine("</div>"); writer.EndRender(); }
/// <summary> /// Cancel Edit/Create and return Back to the Boards Listening /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void CancelClick([NotNull] object sender, [NotNull] EventArgs e) { YafBuildLink.Redirect(ForumPages.admin_boards); }
/// <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="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { if (this.IsPostBack) { return; } this.PageLinks.AddRoot(); this.PageLinks.AddLink( this.GetText("ADMIN_ADMIN", "Administration"), YafBuildLink.GetLink(ForumPages.admin_admin)); this.PageLinks.AddLink( this.GetText("ADMIN_BOARDS", "TITLE"), YafBuildLink.GetLink(ForumPages.admin_editboard)); this.PageLinks.AddLink(this.GetText("ADMIN_EDITBOARD", "TITLE"), string.Empty); this.Page.Header.Title = "{0} - {1} - {2}".FormatWith( this.GetText("ADMIN_ADMIN", "Administration"), this.GetText("ADMIN_BOARDS", "TITLE"), this.GetText("ADMIN_EDITBOARD", "TITLE")); this.Save.Text = this.GetText("SAVE"); this.Cancel.Text = this.GetText("CANCEL"); this.Culture.DataSource = StaticDataHelper.Cultures() .AsEnumerable() .OrderBy(x => x.Field <string>("CultureNativeName")) .CopyToDataTable(); this.Culture.DataValueField = "CultureTag"; this.Culture.DataTextField = "CultureNativeName"; this.BindData(); if (this.Culture.Items.Count > 0) { this.Culture.Items.FindByValue(this.Get <YafBoardSettings>().Culture).Selected = true; } if (this.BoardID != null) { this.CreateNewAdminHolder.Visible = false; using (DataTable dt = this.GetRepository <Board>().List(this.BoardID)) { DataRow row = dt.Rows[0]; this.Name.Text = (string)row["Name"]; this.AllowThreaded.Checked = Convert.ToBoolean(row["AllowThreaded"]); var membershipAppName = row["MembershipAppName"].ToString(); if (membershipAppName.IsSet()) { this.BoardMembershipAppName.Text = row["MembershipAppName"].ToString(); this.BoardMembershipAppName.Enabled = false; } else { this.BoardMembershipAppNameHolder.Visible = false; } } } else { this.UserName.Text = this.User.UserName; this.UserEmail.Text = this.User.Email; } if (Config.IsDotNetNuke) { this.CreateNewAdminHolder.Visible = false; } }
/// <summary> /// Binds the data. /// </summary> private void BindData() { using ( var dt = this.GetRepository <PMessage>().ListAsDataTable( Security.StringToLongOrRedirect(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("pm")))) { if (dt.HasRows()) { var row = dt.Rows[0]; // if the pm isn't from or two the current user--then it's access denied /*if (row["ToUserID"].ToType<int>() != this.PageContext.PageUserID * && row["FromUserID"].ToType<int>() != this.PageContext.PageUserID) * { * YafBuildLink.AccessDenied(); * }*/ // Check if Message is Reply if (!row["ReplyTo"].IsNullOrEmptyDBField()) { var replyTo = row["ReplyTo"].ToType <int>(); var message = new PMessage { ReplyTo = row["ReplyTo"].ToType <int>(), ID = row["PMessageID"].ToType <int>() }; dt.Merge(this.GetRepository <PMessage>().GetReplies(message, replyTo)); } var dataView = dt.DefaultView; dataView.Sort = "Created ASC"; this.SetMessageView( row["FromUserID"], row["ToUserID"], Convert.ToBoolean(row["IsInOutbox"]), Convert.ToBoolean(row["IsArchived"])); // get the return link to the pm listing if (this.IsOutbox) { this.PageLinks.AddLink( this.GetText("SENTITEMS"), YafBuildLink.GetLink(ForumPages.cp_pm, "v=out")); } else if (this.IsArchived) { this.PageLinks.AddLink( this.GetText("ARCHIVE"), YafBuildLink.GetLink(ForumPages.cp_pm, "v=arch")); } else { this.PageLinks.AddLink(this.GetText("INBOX"), YafBuildLink.GetLink(ForumPages.cp_pm)); } this.PageLinks.AddLink(row["Subject"].ToString()); this.Inbox.DataSource = dataView; } else { YafBuildLink.Redirect(ForumPages.cp_pm); } } this.DataBind(); if (this.IsOutbox) { return; } var userPmessageId = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefaultAs <int>("pm"); this.GetRepository <UserPMessage>().MarkAsRead(userPmessageId); this.Get <IDataCache>().Remove(Constants.Cache.ActiveUserLazyData.FormatWith(this.PageContext.PageUserID)); this.Get <IRaiseEvent>().Raise( new UpdateUserPrivateMessageEvent(this.PageContext.PageUserID, userPmessageId)); }
/// <summary> /// The new forum_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void NewForum_Click(object sender, EventArgs e) { YafBuildLink.Redirect(ForumPages.admin_editforum); }
/// <summary> /// The new category_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void NewCategory_Click(object sender, EventArgs e) { YafBuildLink.Redirect(ForumPages.admin_editcategory); }
/// <summary> /// Handles click on cancel button. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Cancel_Click([NotNull] object sender, [NotNull] EventArgs e) { // go back to roles administration YafBuildLink.Redirect(ForumPages.admin_groups); }
/// <summary> /// Try to Import from selected File /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Import_OnClick([NotNull] object sender, [NotNull] EventArgs e) { // import selected file (if it's the proper format)... if (!this.importFile.PostedFile.ContentType.StartsWith("text")) { this.PageContext.AddLoadMessage( this.GetText("ADMIN_REPLACEWORDS_IMPORT", "MSG_IMPORTED_FAILEDX").FormatWith( "Invalid upload format specified: " + this.importFile.PostedFile.ContentType)); return; } try { // import replace words... var dsReplaceWords = new DataSet(); dsReplaceWords.ReadXml(this.importFile.PostedFile.InputStream); if (dsReplaceWords.Tables["YafReplaceWords"] != null && dsReplaceWords.Tables["YafReplaceWords"].Columns["badword"] != null && dsReplaceWords.Tables["YafReplaceWords"].Columns["goodword"] != null) { int importedCount = 0; DataTable replaceWordsList = this.GetRepository <Replace_Words>().List(); // import any extensions that don't exist... foreach (DataRow row in dsReplaceWords.Tables["YafReplaceWords"].Rows.Cast <DataRow>().Where( row => replaceWordsList.Select( "badword = '{0}' AND goodword = '{1}'".FormatWith(row["badword"], row["goodword"])).Length == 0)) { // add this... this.GetRepository <Replace_Words>() .Save( replaceWordID: null, badWord: row["badword"].ToString(), goodWord: row["goodword"].ToString()); importedCount++; } this.PageContext.LoadMessage.AddSession( importedCount > 0 ? this.GetText("ADMIN_REPLACEWORDS_IMPORT", "MSG_IMPORTED").FormatWith(importedCount) : this.GetText("ADMIN_REPLACEWORDS_IMPORT", "MSG_NOTHING"), importedCount > 0 ? MessageTypes.Success : MessageTypes.Warning); YafBuildLink.Redirect(ForumPages.admin_replacewords); } else { this.PageContext.AddLoadMessage(this.GetText("ADMIN_REPLACEWORDS_IMPORT", "MSG_IMPORTED_FAILED")); } } catch (Exception x) { this.PageContext.AddLoadMessage( this.GetText("ADMIN_REPLACEWORDS_IMPORT", "MSG_IMPORTED_FAILEDX").FormatWith(x.Message)); } }
/// <summary> /// Handles click on save button. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Save_Click([NotNull] object sender, [NotNull] EventArgs e) { if (!ValidationHelper.IsValidInt(this.PMLimit.Text.Trim())) { this.PageContext.AddLoadMessage(this.GetText("ADMIN_EDITGROUP", "MSG_VALID_NUMBER")); return; } if (!ValidationHelper.IsValidInt(this.Priority.Text.Trim())) { this.PageContext.AddLoadMessage(this.GetText("ADMIN_EDITGROUP", "MSG_INTEGER")); return; } if (!ValidationHelper.IsValidInt(this.UsrAlbums.Text.Trim())) { this.PageContext.AddLoadMessage(this.GetText("ADMIN_EDITGROUP", "MSG_ALBUM_NUMBER")); return; } if (!ValidationHelper.IsValidInt(this.UsrSigChars.Text.Trim())) { this.PageContext.AddLoadMessage(this.GetText("ADMIN_EDITGROUP", "MSG_SIG_NUMBER")); return; } if (!ValidationHelper.IsValidInt(this.UsrAlbumImages.Text.Trim())) { this.PageContext.AddLoadMessage(this.GetText("ADMIN_EDITGROUP", "MSG_TOTAL_NUMBER")); return; } // Role long roleID = 0; // get role ID from page's parameter if (this.Request.QueryString.GetFirstOrDefault("i") != null) { roleID = long.Parse(this.Request.QueryString.GetFirstOrDefault("i")); } // get new and old name string roleName = this.Name.Text.Trim(); string oldRoleName = string.Empty; // if we are editing exising role, get it's original name if (roleID != 0) { // get the current role name in the DB using (DataTable dt = LegacyDb.group_list(YafContext.Current.PageBoardID, roleID)) { foreach (DataRow row in dt.Rows) { oldRoleName = row["Name"].ToString(); } } } // save role and get its ID if it's new (if it's old role, we get it anyway) roleID = LegacyDb.group_save( roleID, this.PageContext.PageBoardID, roleName, this.IsAdminX.Checked, this.IsGuestX.Checked, this.IsStartX.Checked, this.IsModeratorX.Checked, AccessMaskID.SelectedValue, this.PMLimit.Text.Trim(), this.StyleTextBox.Text.Trim(), this.Priority.Text.Trim(), this.Description.Text, this.UsrSigChars.Text, this.UsrSigBBCodes.Text, this.UsrSigHTMLTags.Text, this.UsrAlbums.Text.Trim(), this.UsrAlbumImages.Text.Trim()); // empty out access table this.GetRepository <ActiveAccess>().Reset(); // see if need to rename an existing role... if (oldRoleName.IsSet() && roleName != oldRoleName && RoleMembershipHelper.RoleExists(oldRoleName) && !RoleMembershipHelper.RoleExists(roleName) && !this.IsGuestX.Checked) { // transfer users in addition to changing the name of the role... var users = this.Get <RoleProvider>().GetUsersInRole(oldRoleName); // delete the old role... RoleMembershipHelper.DeleteRole(oldRoleName, false); // create new role... RoleMembershipHelper.CreateRole(roleName); if (users.Any()) { // put users into new role... this.Get <RoleProvider>().AddUsersToRoles(users, new[] { roleName }); } } else if (!RoleMembershipHelper.RoleExists(roleName) && !this.IsGuestX.Checked) { // if role doesn't exist in provider's data source, create it // simply create it RoleMembershipHelper.CreateRole(roleName); } // Access masks for a newly created or an existing role if (this.Request.QueryString.GetFirstOrDefault("i") != null) { // go trhough all forums for (int i = 0; i < this.AccessList.Items.Count; i++) { // get current repeater item RepeaterItem item = this.AccessList.Items[i]; // get forum ID int forumID = int.Parse(((Label)item.FindControl("ForumID")).Text); // save forum access maks for this role LegacyDb.forumaccess_save(forumID, roleID, ((DropDownList)item.FindControl("AccessmaskID")).SelectedValue); } YafBuildLink.Redirect(ForumPages.admin_groups); } // remove caching in case something got updated... this.Get <IDataCache>().Remove(Constants.Cache.ForumModerators); // Clearing cache with old permissions data... this.Get <IDataCache>().Remove(k => k.StartsWith(Constants.Cache.ActiveUserLazyData.FormatWith(String.Empty))); // Done, redirect to role editing page YafBuildLink.Redirect(ForumPages.admin_editgroup, "i={0}", roleID); }
/// <summary> /// The display post footer_ pre render. /// </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 DisplayPostFooter_PreRender([NotNull] object sender, [NotNull] EventArgs e) { // report posts if (this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().ReportPostPermissions) && !this.PostData.PostDeleted) { if (this.PageContext.IsGuest || (!this.PageContext.IsGuest && this.PageContext.User != null)) { this.ReportPost.Visible = true; this.ReportPost.NavigateUrl = YafBuildLink.GetLinkNotEscaped( ForumPages.reportpost, "m={0}", this.PostData.MessageId); } } string userName = this.Get <YafBoardSettings>().EnableDisplayName ? this.DataRow["DisplayName"].ToString() : this.DataRow["UserName"].ToString(); userName = this.Get <HttpServerUtilityBase>().HtmlEncode(userName); // albums link if (this.PostData.UserId != this.PageContext.PageUserID && !this.PostData.PostDeleted && this.PageContext.User != null && this.Get <YafBoardSettings>().EnableAlbum) { var numAlbums = this.Get <IDataCache>().GetOrSet <int?>( Constants.Cache.AlbumCountUser.FormatWith(this.PostData.UserId), () => { DataTable usrAlbumsData = LegacyDb.user_getalbumsdata( this.PostData.UserId, YafContext.Current.PageBoardID); return(usrAlbumsData.GetFirstRowColumnAsValue <int?>("NumAlbums", null)); }, TimeSpan.FromMinutes(5)); this.Albums.Visible = numAlbums.HasValue && numAlbums > 0; this.Albums.NavigateUrl = YafBuildLink.GetLinkNotEscaped( ForumPages.albums, "u={0}", this.PostData.UserId); this.Albums.ParamTitle0 = userName; } // private messages this.Pm.Visible = this.PostData.UserId != this.PageContext.PageUserID && !this.IsGuest && !this.PostData.PostDeleted && this.PageContext.User != null && this.Get <YafBoardSettings>().AllowPrivateMessages&& !this.PostData.IsSponserMessage; this.Pm.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.pmessage, "u={0}", this.PostData.UserId); this.Pm.ParamTitle0 = userName; // emailing this.Email.Visible = this.PostData.UserId != this.PageContext.PageUserID && !this.IsGuest && !this.PostData.PostDeleted && this.PageContext.User != null && this.Get <YafBoardSettings>().AllowEmailSending&& !this.PostData.IsSponserMessage; this.Email.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_email, "u={0}", this.PostData.UserId); this.Email.ParamTitle0 = userName; // home page this.Home.Visible = !this.PostData.PostDeleted && this.PostData.UserProfile.Homepage.IsSet(); this.SetupThemeButtonWithLink(this.Home, this.PostData.UserProfile.Homepage); this.Home.ParamTitle0 = userName; // blog page this.Blog.Visible = !this.PostData.PostDeleted && this.PostData.UserProfile.Blog.IsSet(); this.SetupThemeButtonWithLink(this.Blog, this.PostData.UserProfile.Blog); this.Blog.ParamTitle0 = userName; if (!this.PostData.PostDeleted && this.PageContext.User != null && (this.PostData.UserId != this.PageContext.PageUserID)) { // MSN this.Msn.Visible = this.PostData.UserProfile.MSN.IsSet(); this.Msn.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_msn, "u={0}", this.PostData.UserId); this.Msn.ParamTitle0 = userName; // Yahoo IM this.Yim.Visible = this.PostData.UserProfile.YIM.IsSet(); this.Yim.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_yim, "u={0}", this.PostData.UserId); this.Yim.ParamTitle0 = userName; // AOL IM this.Aim.Visible = this.PostData.UserProfile.AIM.IsSet(); this.Aim.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_aim, "u={0}", this.PostData.UserId); this.Aim.ParamTitle0 = userName; // ICQ this.Icq.Visible = this.PostData.UserProfile.ICQ.IsSet(); this.Icq.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_icq, "u={0}", this.PostData.UserId); this.Icq.ParamTitle0 = userName; // XMPP this.Xmpp.Visible = this.PostData.UserProfile.XMPP.IsSet(); this.Xmpp.NavigateUrl = YafBuildLink.GetLinkNotEscaped( ForumPages.im_xmpp, "u={0}", this.PostData.UserId); this.Xmpp.ParamTitle0 = userName; // Skype this.Skype.Visible = this.PostData.UserProfile.Skype.IsSet(); this.Skype.NavigateUrl = YafBuildLink.GetLinkNotEscaped( ForumPages.im_skype, "u={0}", this.PostData.UserId); this.Skype.ParamTitle0 = userName; } var loadHoverCardJs = false; // Facebook if (this.PostData.UserProfile.Facebook.IsSet()) { this.Facebook.Visible = this.PostData.UserProfile.Facebook.IsSet(); if (this.PostData.UserProfile.Facebook.IsSet()) { this.Facebook.NavigateUrl = ValidationHelper.IsNumeric(this.PostData.UserProfile.Facebook) ? "https://www.facebook.com/profile.php?id={0}".FormatWith( this.PostData.UserProfile.Facebook) : this.PostData.UserProfile.Facebook; } this.Facebook.ParamTitle0 = userName; if (this.Get <YafBoardSettings>().EnableUserInfoHoverCards) { this.Facebook.Attributes.Add("data-hovercard", this.PostData.UserProfile.Facebook); this.Facebook.CssClass += " Facebook-HoverCard"; loadHoverCardJs = true; } } // Twitter if (this.PostData.UserProfile.Twitter.IsSet()) { this.Twitter.Visible = this.PostData.UserProfile.Twitter.IsSet(); this.Twitter.NavigateUrl = "http://twitter.com/{0}".FormatWith(this.HtmlEncode(this.PostData.UserProfile.Twitter)); this.Twitter.ParamTitle0 = userName; if (this.Get <YafBoardSettings>().EnableUserInfoHoverCards&& Config.IsTwitterEnabled) { this.Twitter.Attributes.Add("data-hovercard", this.HtmlEncode(this.PostData.UserProfile.Twitter)); this.Twitter.CssClass += " Twitter-HoverCard"; loadHoverCardJs = true; } } // Google+ if (this.PostData.UserProfile.Google.IsSet()) { this.Google.Visible = this.PostData.UserProfile.Google.IsSet(); this.Google.NavigateUrl = this.PostData.UserProfile.Google; this.Google.ParamTitle0 = userName; } if (!loadHoverCardJs || !this.Get <YafBoardSettings>().EnableUserInfoHoverCards) { return; } var hoverCardLoadJs = new StringBuilder(); if (this.Facebook.Visible) { hoverCardLoadJs.Append( JavaScriptBlocks.HoverCardLoadJs( ".Facebook-HoverCard", "Facebook", this.GetText("DEFAULT", "LOADING_FB_HOVERCARD"), this.GetText("DEFAULT", "ERROR_FB_HOVERCARD"))); } if (this.Twitter.Visible && Config.IsTwitterEnabled) { hoverCardLoadJs.Append( JavaScriptBlocks.HoverCardLoadJs( ".Twitter-HoverCard", "Twitter", this.GetText("DEFAULT", "LOADING_TWIT_HOVERCARD"), this.GetText("DEFAULT", "ERROR_TWIT_HOVERCARD"), "{0}{1}resource.ashx?twitterinfo=".FormatWith( BaseUrlBuilder.BaseUrl.TrimEnd('/'), BaseUrlBuilder.AppPath))); } // Setup Hover Card JS YafContext.Current.PageElements.RegisterJsBlockStartup("hovercardjs", hoverCardLoadJs.ToString()); }
/// <summary> /// Load the Complete Help Pages From the language File. /// </summary> private void LoadHelpContent() { if (!this.helpContents.Count.Equals(0)) { return; } // vzrus tip: some features can be disabled and users shouldn't normally see them in help. // The list can include some limitations based on host settings when features are enabled. // tha_watcha: actually not really needed content describes that things can be disabled. var helpNavigation = new List <HelpMenu.YafHelpNavigation>(); var serializer = new XmlSerializer(typeof(List <HelpMenu.YafHelpNavigation>)); var xmlFilePath = HttpContext.Current.Server.MapPath( "{0}Resources/{1}".FormatWith(YafForumInfo.ForumServerFileRoot, "HelpMenuList.xml")); if (File.Exists(xmlFilePath)) { var reader = new StreamReader(xmlFilePath); helpNavigation = (List <HelpMenu.YafHelpNavigation>)serializer.Deserialize(reader); reader.Close(); } foreach (var helpPage in helpNavigation.SelectMany(category => category.HelpPages)) { string helpContent; switch (helpPage.HelpPage) { case "RECOVER": { helpContent = this.GetTextFormatted( "{0}CONTENT".FormatWith(helpPage.HelpPage), YafBuildLink.GetLink(ForumPages.recoverpassword)); } break; case "BBCODES": { helpContent = this.GetTextFormatted( "{0}CONTENT".FormatWith(helpPage.HelpPage), YafForumInfo.ForumBaseUrl); } break; case "POSTING": { helpContent = this.GetTextFormatted( "{0}CONTENT".FormatWith(helpPage.HelpPage), YafBuildLink.GetLink(ForumPages.help_index, "faq=bbcodes")); } break; default: { helpContent = this.GetText("{0}CONTENT".FormatWith(helpPage.HelpPage)); } break; } this.helpContents.Add( new YafHelpContent { HelpPage = helpPage.HelpPage, HelpTitle = this.GetText("{0}TITLE".FormatWith(helpPage.HelpPage)), HelpContent = helpContent }); } }
/// <summary> /// The init poll ui. /// </summary> /// <param name="pollID"> /// The poll ID. /// </param> private void InitPollUI(int?pollID) { // we should get the schema anyway this._choices = LegacyDb.poll_stats(pollID); this._choices.Columns.Add("ChoiceOrderID", typeof(int)); // First existing values alway 1! int existingRowsCount = 1; int allExistingRowsCount = this._choices.Rows.Count; // we edit existing poll if (this._choices.Rows.Count > 0) { if ((ObjectExtensions.ToType <int>(this._choices.Rows[0]["UserID"]) != this.PageContext.PageUserID) && (!this.PageContext.IsAdmin) && (!this.PageContext.ForumModeratorAccess)) { YafBuildLink.RedirectInfoPage(InfoMessage.Invalid); } this.IsBoundCheckBox.Checked = ObjectExtensions.ToType <bool>(this._choices.Rows[0]["IsBound"]); this.IsClosedBoundCheckBox.Checked = ObjectExtensions.ToType <bool>(this._choices.Rows[0]["IsClosedBound"]); this.AllowMultipleChoicesCheckBox.Checked = ObjectExtensions.ToType <bool>(this._choices.Rows[0]["AllowMultipleChoices"]); this.AllowSkipVoteCheckBox.Checked = ObjectExtensions.ToType <bool>(this._choices.Rows[0]["AllowSkipVote"]); this.ShowVotersCheckBox.Checked = ObjectExtensions.ToType <bool>(this._choices.Rows[0]["ShowVoters"]); this.Question.Text = this._choices.Rows[0]["Question"].ToString(); this.QuestionObjectPath.Text = this._choices.Rows[0]["QuestionObjectPath"].ToString(); if (this._choices.Rows[0]["Closes"] != DBNull.Value) { TimeSpan closing = (DateTime)this._choices.Rows[0]["Closes"] - DateTime.UtcNow; this.PollExpire.Text = ObjectExtensions.ToType <int>((closing.TotalDays + 1)).ToString(); } else { this.PollExpire.Text = null; } foreach (DataRow choiceRow in this._choices.Rows) { choiceRow["ChoiceOrderID"] = existingRowsCount; existingRowsCount++; } } else { // A new topic is created // below check currently if works for topics only, but will do as some things are not enabled if (!this.CanCreatePoll()) { YafBuildLink.RedirectInfoPage(InfoMessage.AccessDenied); } // Get isBound value using page variables. They are initialized here. int pgidt = 0; // If a topic poll is edited or new topic created if (this._topicId > 0 && this._topicInfo != null) { // topicid should not be null here if (!this._topicInfo["PollID"].IsNullOrEmptyDBField()) { pgidt = (int)this._topicInfo["PollID"]; DataTable pollGroupData = LegacyDb.pollgroup_stats(pgidt); this.IsBoundCheckBox.Checked = Convert.ToBoolean(pollGroupData.Rows[0]["IsBound"]); //// this.IsClosedBoundCheckBox.Checked = Convert.ToBoolean(DB.pollgroup_stats(pgidt).Rows[0]["IsClosedBound"]); } } else if (this._forumId > 0 && (!(this._topicId > 0) || (!(this._editTopicId > 0)))) { // forumid should not be null here pgidt = (int)LegacyDb.forum_list(this.PageContext.PageBoardID, this._forumId).Rows[0]["PollGroupID"]; } else if (this._categoryId > 0) { // categoryid should not be null here pgidt = this.GetRepository <Category>() .Listread(this.PageContext.PageUserID, this._categoryId) .GetFirstRowColumnAsValue <int>("PollGroupID", 0); } if (pgidt > 0) { if (LegacyDb.pollgroup_stats(pgidt).Rows[0]["IsBound"].ToType <int>() == 2) { this.IsBoundCheckBox.Checked = true; } if (LegacyDb.pollgroup_stats(pgidt).Rows[0]["IsClosedBound"].ToType <int>() == 4) { this.IsClosedBoundCheckBox.Checked = true; } } // clear the fields... this.PollExpire.Text = string.Empty; this.Question.Text = string.Empty; } // we add dummy rows to data table to fill in repeater empty fields int dummyRowsCount = this.Get <YafBoardSettings>().AllowedPollChoiceNumber - allExistingRowsCount - 1; for (int i = 0; i <= dummyRowsCount; i++) { DataRow drow = this._choices.NewRow(); drow["ChoiceOrderID"] = existingRowsCount + i; this._choices.Rows.Add(drow); } // Bind choices repeater this.ChoiceRepeater.DataSource = this._choices; this.ChoiceRepeater.DataBind(); this.ChoiceRepeater.Visible = true; // Show controls this.SavePoll.Visible = true; this.Cancel.Visible = true; this.PollRow1.Visible = true; this.PollRowExpire.Visible = true; this.IsClosedBound.Visible = this.IsBound.Visible = this.Get <YafBoardSettings>().AllowUsersHidePollResults || PageContext.IsAdmin || PageContext.IsForumModerator; this.tr_AllowMultipleChoices.Visible = this.Get <YafBoardSettings>().AllowMultipleChoices || PageContext.IsAdmin || PageContext.ForumModeratorAccess; this.tr_ShowVoters.Visible = true; this.tr_AllowSkipVote.Visible = false; }
/// <summary> /// Handles the CreatedUser event of the CreateUserWizard1 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 CreateUserWizard1_CreatedUser([NotNull] object sender, [NotNull] EventArgs e) { MembershipUser user = UserMembershipHelper.GetUser(this.CreateUserWizard1.UserName); // setup inital roles (if any) for this user RoleMembershipHelper.SetupUserRoles(YafContext.Current.PageBoardID, this.CreateUserWizard1.UserName); var displayName = user.UserName; if (this.Get <YafBoardSettings>().EnableDisplayName) { displayName = this.CreateUserStepContainer.FindControlAs <TextBox>("DisplayName").Text.Trim(); } // create the user in the YAF DB as well as sync roles... int?userID = RoleMembershipHelper.CreateForumUser(user, displayName, YafContext.Current.PageBoardID); // create empty profile just so they have one YafUserProfile userProfile = YafUserProfile.GetProfile(this.CreateUserWizard1.UserName); // setup their inital profile information userProfile.Save(); if (userID == null) { // something is seriously wrong here -- redirect to failure... YafBuildLink.RedirectInfoPage(InfoMessage.Failure); } if (this.IsPossibleSpamBot) { if (this.Get <YafBoardSettings>().BotHandlingOnRegister.Equals(1)) { this.Get <ISendNotification>().SendSpamBotNotificationToAdmins(user, userID.Value); } } else { // handle e-mail verification if needed if (this.Get <YafBoardSettings>().EmailVerification) { // get the user email var emailTextBox = (TextBox)this.CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email"); var email = emailTextBox.Text.Trim(); this.Get <ISendNotification>().SendVerificationEmail(user, email, userID); } else { // Send welcome mail/pm to user this.Get <ISendNotification>().SendUserWelcomeNotification(user, userID.Value); } if (this.Get <YafBoardSettings>().NotificationOnUserRegisterEmailList.IsSet()) { // send user register notification to the following admin users... this.Get <ISendNotification>().SendRegistrationNotificationEmail(user, userID.Value); } } }
/// <summary> /// The return to page. /// </summary> private void ReturnToPage() { if (this._topicUnapproved) { // Tell user that his message will have to be approved by a moderator string url = YafBuildLink.GetLink(ForumPages.topics, "f={0}", this._returnForum); if (Config.IsRainbow) { YafBuildLink.Redirect(ForumPages.info, "i=1"); } else { YafBuildLink.Redirect(ForumPages.info, "i=1&url={0}", this.Server.UrlEncode(url)); } } // YafBuildLink.Redirect(ForumPages.posts, "m={0}#{0}", this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("m")); string retliterals; int? retvalue; this.ParamsToSend(out retliterals, out retvalue); switch (retliterals) { case "t": YafBuildLink.Redirect(ForumPages.posts, "t={0}", retvalue); break; case "em": YafBuildLink.Redirect(ForumPages.postmessage, "m={0}", retvalue); break; case "f": YafBuildLink.Redirect(ForumPages.topics, "f={0}", retvalue); break; case "ef": YafBuildLink.Redirect(ForumPages.admin_editforum, "f={0}", retvalue); break; case "c": YafBuildLink.Redirect(ForumPages.forum, "c={0}", retvalue); break; case "ec": YafBuildLink.Redirect(ForumPages.admin_editcategory, "c={0}", retvalue); break; case "b": YafBuildLink.Redirect(ForumPages.forum); break; case "eb": YafBuildLink.Redirect(ForumPages.admin_editboard, "b={0}", retvalue); break; default: YafBuildLink.RedirectInfoPage(InfoMessage.Invalid); break; } }
/// <summary> /// Redirects to the Facebook login/register page. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The <see cref="EventArgs"/> instance containing the event data. /// </param> protected void FacebookRegisterClick(object sender, EventArgs e) { YafBuildLink.Redirect(ForumPages.login, "auth={0}", AuthService.facebook); }
/// <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="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { this.PollList.Visible = this.Get <YafBoardSettings>().BoardPollID > 0; this.PollList.PollGroupId = this.Get <YafBoardSettings>().BoardPollID; this.PollList.BoardId = this.PageContext.Settings.BoardID; // Since these controls have EnabledViewState=false, set their visibility on every page load so that this value is not lost on postback. // This is important for another reason: these are board settings; values in the view state should have no impact on whether these controls are shown or not. this.ShoutBox1.Visible = this.Get <YafBoardSettings>().ShowShoutbox && this.Get <IPermissions>() .Check(this.Get <YafBoardSettings>().ShoutboxViewPermissions); this.ForumStats.Visible = this.Get <YafBoardSettings>().ShowForumStatistics; this.ActiveDiscussions.Visible = this.Get <YafBoardSettings>().ShowActiveDiscussions; if (this.IsPostBack) { return; } /* * // vzrus: needs testing, potentially can cause problems * * // Jaben: I can't access MY OWN FORUM with this code. Commented out. Either it's an optional feature or will be completely removed. * // As far as I can see this is the worst kind of "feature": that no one asked for and solves a problem that no one had. * * //string ua = HttpContext.Current.Request.UserAgent; * * //if (!UserAgentHelper.IsSearchEngineSpider(ua) && (!UserAgentHelper.IsNotCheckedForCookiesAndJs(ua))) * //{ * // if (!HttpContext.Current.Request.Browser.Cookies) * // { * // YafBuildLink.RedirectInfoPage(InfoMessage.RequiresCookies); * // } * * // Version ecmaVersion = HttpContext.Current.Request.Browser.EcmaScriptVersion; * * // if (ecmaVersion != null) * // { * // try * // { * // string[] arrJsVer = Config.BrowserJSVersion.Split('.'); * * // if (!(ecmaVersion.Major >= arrJsVer[0].ToType<int>()) && !(ecmaVersion.Minor >= arrJsVer[1].ToType<int>())) * // { * // YafBuildLink.RedirectInfoPage(InfoMessage.EcmaScriptVersionUnsupported); * // } * // } * // catch (Exception) * // { * // } * // } * // else * // { * // YafBuildLink.RedirectInfoPage(InfoMessage.RequiresEcmaScript); * // } * //}*/ if (this.PageContext.Settings.LockedForum == 0) { this.PageLinks.AddLink(this.Get <YafBoardSettings>().Name, YafBuildLink.GetLink(ForumPages.forum)); if (this.PageContext.PageCategoryID != 0) { this.PageLinks.AddLink( this.PageContext.PageCategoryName, YafBuildLink.GetLink(ForumPages.forum, "c={0}", this.PageContext.PageCategoryID)); this.Welcome.Visible = false; } } }
/// <summary> /// Redirects to the Google login/register page. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The <see cref="EventArgs"/> instance containing the event data. /// </param> protected void GoogleRegisterClick(object sender, EventArgs e) { YafBuildLink.Redirect(ForumPages.login, "auth={0}", AuthService.google); }
private void CreateSmileys() { System.Text.StringBuilder html = new System.Text.StringBuilder(); html.AppendFormat("<tr class='post'>"); int rowcells = 0; for (int i = 0; i < _pagesize; i++) { if (i < _dtSmileys.Rows.Count) { DataRow row = _dtSmileys.Rows[i]; if (i % _perrow == 0 && i > 0 && i < _dtSmileys.Rows.Count) { html.Append("</tr><tr class='post'>\n"); rowcells = 0; } string evt = ""; if (_onclick.Length > 0) { string strCode = Convert.ToString(row["Code"]).ToLower(); strCode = strCode.Replace("&", "&"); strCode = strCode.Replace(">", ">"); strCode = strCode.Replace("<", "<"); strCode = strCode.Replace("\"", """); strCode = strCode.Replace("\\", "\\\\"); strCode = strCode.Replace("'", "\\'"); evt = String.Format("javascript:{0}('{1} ','{3}images/emoticons/{2}')", _onclick, strCode, row["Icon"], YafForumInfo.ForumRoot); } else { evt = "javascript:void()"; } html.AppendFormat("<td><a tabindex=\"999\" href=\"{2}\"><img src=\"{0}\" alt=\"{1}\" title=\"{1}\" /></a></td>\n", YafBuildLink.Smiley(( string )row ["Icon"]), row ["Emoticon"], evt); rowcells++; } } while (rowcells++ < _perrow) { html.AppendFormat("<td> </td>"); } html.AppendFormat("</tr>"); SmileyResults.Text = html.ToString(); }
/// <summary> /// Logins the click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The <see cref="EventArgs"/> instance containing the event data. /// </param> protected void LoginClick(object sender, EventArgs e) { YafBuildLink.Redirect(ForumPages.login); }
/// <summary> /// Saves the Updated Profile /// </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 UpdateProfileClick([NotNull] object sender, [NotNull] EventArgs e) { var userName = UserMembershipHelper.GetUserNameFromID(this.currentUserId); 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://{this.HomePage.Text.Trim()}"; } if (!ValidationHelper.IsValidURL(this.HomePage.Text)) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_HOME"), MessageTypes.warning); return; } if (this.UserData.NumPosts < this.Get <YafBoardSettings>().IgnoreSpamWordCheckPostCount) { // Check for spam if (this.Get <ISpamWordCheck>().CheckForSpamWord(this.HomePage.Text, out _)) { // 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 : '{userName}', user id : '{this.currentUserId}') after the user changed the profile Homepage url to: {this.HomePage.Text}", 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 : '{userName}', user id : '{this.currentUserId}') after the user changed the profile Homepage url to: {this.HomePage.Text}, user was deleted and the name, email and IP Address are banned.", EventLogTypes.SpamBotDetected); // Kill user if (!this.PageContext.CurrentForumPage.IsAdminPage) { var user = UserMembershipHelper.GetMembershipUserById(this.currentUserId); var userId = this.currentUserId; var userIp = new CombinedUserDataHelper(user, userId).LastIP; UserMembershipHelper.DeleteAndBanUser(this.currentUserId, user, userIp); } } } } } if (this.Weblog.Text.IsSet() && !ValidationHelper.IsValidURL(this.Weblog.Text.Trim())) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_WEBLOG"), 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; } 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(); } } 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); // save remaining settings to the DB this.GetRepository <User>().Save( this.currentUserId, this.PageContext.PageBoardID, null, displayName, null, this.UserData.TimeZoneInfo.Id, this.UserData.LanguageFile, this.UserData.CultureUser, this.UserData.ThemeFile, this.UserData.TextEditor, null, null, null, false, this.UserData.IsActiveExcluded, null); // clear the cache for this user...) this.Get <IRaiseEvent>().Raise(new UpdateUserEvent(this.currentUserId)); this.Get <IDataCache>().Clear(); if (!this.PageContext.CurrentForumPage.IsAdminPage) { YafBuildLink.Redirect(ForumPages.cp_profile); } else { this.userData = null; this.BindData(); } }
/// <summary> /// Handles the Bind event of the Files control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="DataListItemEventArgs"/> instance containing the event data.</param> public void Files_Bind([NotNull] object sender, [NotNull] DataListItemEventArgs e) { var directoryPath = Path.Combine(YafForumInfo.ForumClientFileRoot, YafBoardFolders.Current.Avatars); var fname = (Literal)e.Item.FindControl("fname"); if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { var finfo = new FileInfo( this.Server.MapPath(Convert.ToString(DataBinder.Eval(e.Item.DataItem, "name")))); if (this.CurrentDirectory.IsSet()) { directoryPath = this.CurrentDirectory; } string tmpExt = finfo.Extension.ToLower(); if (tmpExt == ".gif" || tmpExt == ".jpg" || tmpExt == ".jpeg" || tmpExt == ".png" || tmpExt == ".bmp") { string link; var encodedFileName = finfo.Name.Replace(".", "%2E"); if (this.returnUserID > 0) { link = YafBuildLink.GetLink( ForumPages.admin_edituser, "u={0}&av={1}", this.returnUserID, this.Server.UrlEncode("{0}/{1}".FormatWith(directoryPath, encodedFileName))); } else { link = YafBuildLink.GetLink( ForumPages.cp_editavatar, "av={0}", this.Server.UrlEncode("{0}/{1}".FormatWith(directoryPath, encodedFileName))); } fname.Text = @"<div style=""text-align:center""><a href=""{0}""><img src=""{1}"" alt=""{2}"" title=""{2}"" class=""borderless"" /></a><br /><small>{2}</small></div>{3}" .FormatWith( link, "{0}/{1}".FormatWith(directoryPath, finfo.Name), finfo.Name, Environment.NewLine); } } if (e.Item.ItemType != ListItemType.Header) { return; } // get the previous directory... string previousDirectory = Path.Combine(YafForumInfo.ForumClientFileRoot, YafBoardFolders.Current.Avatars); var up = e.Item.FindControl("up") as LinkButton; up.CommandArgument = previousDirectory; up.Text = @"<p style=""text-align:center""> <i class=""far fa-folder-open""style=""font-size:50px""></i><br /> <button type=""button"" class=""btn btn-primary btn-sm""><i class=""fas fa-arrow-left""></i> {0}</button></p>".FormatWith(this.GetText("UP")); up.ToolTip = this.GetText("UP_TITLE"); // Hide if Top Folder if (this.CurrentDirectory.Equals(previousDirectory)) { up.Visible = false; } }
/// <summary> /// Save Current board / Create new Board /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void SaveClick([NotNull] object sender, [NotNull] EventArgs e) { if (this.Name.Text.Trim().Length == 0) { this.PageContext.AddLoadMessage(this.GetText("ADMIN_EDITBOARD", "MSG_NAME_BOARD"), MessageTypes.warning); return; } if (this.BoardId == null && this.CreateAdminUser.Checked) { if (this.UserName.Text.Trim().Length == 0) { this.PageContext.AddLoadMessage( this.GetText("ADMIN_EDITBOARD", "MSG_NAME_ADMIN"), MessageTypes.warning); return; } if (this.UserEmail.Text.Trim().Length == 0) { this.PageContext.AddLoadMessage( this.GetText("ADMIN_EDITBOARD", "MSG_EMAIL_ADMIN"), MessageTypes.warning); return; } if (this.UserPass1.Text.Trim().Length == 0) { this.PageContext.AddLoadMessage( this.GetText("ADMIN_EDITBOARD", "MSG_PASS_ADMIN"), MessageTypes.warning); return; } if (this.UserPass1.Text != this.UserPass2.Text) { this.PageContext.AddLoadMessage( this.GetText("ADMIN_EDITBOARD", "MSG_PASS_MATCH"), MessageTypes.warning); return; } } if (this.BoardId != null) { var cult = StaticDataHelper.Cultures(); var langFile = "en-US"; foreach (var drow in cult.Rows.Cast <DataRow>() .Where(drow => drow["CultureTag"].ToString() == this.Culture.SelectedValue)) { langFile = drow["CultureFile"].ToString(); } // Save current board settings this.GetRepository <Board>().Save( this.BoardId ?? 0, this.Name.Text.Trim(), langFile, this.Culture.SelectedItem.Value, this.AllowThreaded.Checked); } else { // Create board // MEK says : Purposefully set MembershipAppName without including RolesAppName yet, as the current providers don't support different Appnames. if (this.CreateAdminUser.Checked) { this.CreateBoard( this.UserName.Text.Trim(), this.UserPass1.Text, this.UserEmail.Text.Trim(), this.UserPasswordQuestion.Text.Trim(), this.UserPasswordAnswer.Text.Trim(), this.Name.Text.Trim(), this.BoardMembershipAppName.Text.Trim(), this.BoardMembershipAppName.Text.Trim(), true); } else { // create admin user from logged in user... this.CreateBoard( null, null, null, null, null, this.Name.Text.Trim(), this.BoardMembershipAppName.Text.Trim(), this.BoardMembershipAppName.Text.Trim(), false); } } // Done this.PageContext.BoardSettings = null; YafBuildLink.Redirect(ForumPages.admin_boards); }
/// <summary> /// Returns to the Edit Avatar Page /// </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 BtnCancel_Click([NotNull] object sender, [NotNull] EventArgs e) { // Redirect to the edit avatar page YafBuildLink.Redirect(ForumPages.cp_editavatar); }
/// <summary> /// The import_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void import_Click([NotNull] object sender, [NotNull] EventArgs e) { if (long.Parse(this.File.SelectedValue) < 1) { this.PageContext.AddLoadMessage(this.GetText("ADMIN_SMILIES_IMPORT", "ERROR_SELECT_FILE")); return; } string fileName = this.Request.MapPath( "{0}{1}/{2}".FormatWith( YafForumInfo.ForumClientFileRoot, YafBoardFolders.Current.Emoticons, this.File.SelectedItem.Text)); string split = Regex.Escape("=+:"); using (var file = new StreamReader(fileName)) { int sortOrder = 1; // Delete existing smilies? if (this.DeleteExisting.Checked) { this.GetRepository <Smiley>().Delete(); } else { // Get max value of SortOrder using (DataView dv = this.GetRepository <Smiley>().ListUnique().DefaultView) { dv.Sort = "SortOrder desc"; if (dv.Count > 0) { DataRowView dr = dv[0]; if (dr != null) { object o = dr["SortOrder"]; if (int.TryParse(o.ToString(), out sortOrder)) { sortOrder++; } } } } } do { string line = file.ReadLine(); if (line == null) { break; } string[] lineSplit = Regex.Split(line, split, RegexOptions.None); if (lineSplit.Length != 3) { continue; } this.GetRepository <Smiley>().Save(null, lineSplit[2], lineSplit[0], lineSplit[1], (byte)sortOrder, 0); sortOrder++; }while (true); file.Close(); } YafBuildLink.Redirect(ForumPages.admin_smilies); }
/// <summary> /// Cancel Edit and Return Back To Access Mask List Page. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Cancel_Click([NotNull] object sender, [NotNull] EventArgs e) { // get back to access masks administration YafBuildLink.Redirect(ForumPages.admin_accessmasks); }
/// <summary> /// Saves the Updated Profile /// </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 UpdateProfile_Click([NotNull] object sender, [NotNull] EventArgs e) { var userName = UserMembershipHelper.GetUserNameFromID(this.currentUserId); 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.UserData.NumPosts < this.Get <YafBoardSettings>().IgnoreSpamWordCheckPostCount) { string result; // Check for spam if (this.Get <ISpamWordCheck>().CheckForSpamWord(this.HomePage.Text, out result)) { // 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 changed the profile Homepage url to: {2}" .FormatWith(userName, this.currentUserId, this.HomePage.Text), 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 changed the profile Homepage url to: {2}, user was deleted and the name, email and IP Address are banned." .FormatWith(userName, this.currentUserId, this.HomePage.Text), EventLogTypes.SpamBotDetected); // Kill user if (!this.PageContext.CurrentForumPage.IsAdminPage) { var user = UserMembershipHelper.GetMembershipUserById(this.currentUserId); var userId = this.currentUserId; var userIp = new CombinedUserDataHelper(user, userId).LastIP; UserMembershipHelper.DeleteAndBanUser(this.currentUserId, user, userIp); } } } } } 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(); } } if (this.UpdateEmailFlag) { var newEmail = this.Email.Text.Trim(); if (!ValidationHelper.IsValidEmail(newEmail)) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_EMAIL"), MessageTypes.warning); return; } var 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 (var 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 var dt = LegacyDb.user_list(this.PageContext.PageBoardID, this.currentUserId, true, null, null, false); if (dt.HasRows() && 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)); this.Get <IDataCache>().Clear(); if (!this.PageContext.CurrentForumPage.IsAdminPage) { YafBuildLink.Redirect(ForumPages.cp_profile); } else { this.userData = null; this.BindData(); } }
/// <summary> /// Handles the Click event of the Return 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 Return_Click([NotNull] object sender, [NotNull] EventArgs e) { YafBuildLink.Redirect(ForumPages.forum); }