/// <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(ForumPages.admin_bannedemail); }
/* Construction */ #region Methods /// <summary> /// The cancel_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Cancel_Click([NotNull] object sender, [NotNull] EventArgs e) { // get back to access admin list YafBuildLink.Redirect(ForumPages.admin_pageaccesslist); }
/// <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(page: ForumPages.login, format: "auth={0}", AuthService.google); }
/// <summary> /// Cancel import and Return to the Admin Users 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 Cancel_OnClick([NotNull] object sender, [NotNull] EventArgs e) { YafBuildLink.Redirect(ForumPages.admin_users); }
/// <summary> /// The password recovery 1_ verifying user. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void PasswordRecovery1_VerifyingUser([NotNull] object sender, [NotNull] LoginCancelEventArgs e) { MembershipUser user = null; if (this.PasswordRecovery1.UserName.Contains("@") && this.Get <MembershipProvider>().RequiresUniqueEmail) { // Email Login var username = this.Get <MembershipProvider>().GetUserNameByEmail(this.PasswordRecovery1.UserName); if (username != null) { user = this.Get <MembershipProvider>().GetUser(username, false); // update the username this.PasswordRecovery1.UserName = username; } } else { // Standard user name login if (this.Get <YafBoardSettings>().EnableDisplayName) { // Display name login var id = this.Get <IUserDisplayName>().GetId(this.PasswordRecovery1.UserName); if (id.HasValue) { // get the username associated with this id... var username = UserMembershipHelper.GetUserNameFromID(id.Value); // update the username this.PasswordRecovery1.UserName = username; } user = this.Get <MembershipProvider>().GetUser(this.PasswordRecovery1.UserName, false); } } if (user == null) { return; } // verify the user is approved, etc... if (user.IsApproved) { return; } if (this.Get <YafBoardSettings>().EmailVerification) { // get the hash from the db associated with this user... var checkTyped = this.GetRepository <CheckEmail>().ListTyped(user.Email).FirstOrDefault(); if (checkTyped != null) { // re-send verification email instead of lost password... var verifyEmail = new YafTemplateEmail("VERIFYEMAIL"); string subject = this.GetTextFormatted("VERIFICATION_EMAIL_SUBJECT", this.Get <YafBoardSettings>().Name); verifyEmail.TemplateParams["{link}"] = YafBuildLink.GetLinkNotEscaped(ForumPages.approve, true, "k={0}", checkTyped.Hash); verifyEmail.TemplateParams["{key}"] = checkTyped.Hash; verifyEmail.TemplateParams["{forumname}"] = this.Get <YafBoardSettings>().Name; verifyEmail.TemplateParams["{forumlink}"] = "{0}".FormatWith(YafForumInfo.ForumURL); verifyEmail.SendEmail(new MailAddress(user.Email, user.UserName), subject, true); this.PageContext.LoadMessage.AddSession( this.GetTextFormatted("ACCOUNT_NOT_APPROVED_VERIFICATION", user.Email), MessageTypes.Warning); } } else { // explain they are not approved yet... this.PageContext.LoadMessage.AddSession(this.GetText("ACCOUNT_NOT_APPROVED"), MessageTypes.Warning); } // just in case cancel the verification... e.Cancel = true; // nothing they can do here... redirect to login... YafBuildLink.Redirect(ForumPages.login); }
/// <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 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); }
/// <summary> /// Handles click on new medal button. /// </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 NewMedalClick([NotNull] object sender, [NotNull] EventArgs e) { // redirect to medal edit page YafBuildLink.Redirect(ForumPages.admin_editmedal); }
/// <summary> /// Handles click event of 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) { // redirect to forum moderation page YafBuildLink.Redirect(ForumPages.moderating, "f={0}", this.PageContext.PageForumID); }
/// <summary> /// The new rank_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void NewRank_Click([NotNull] object sender, [NotNull] EventArgs e) { YafBuildLink.Redirect(ForumPages.admin_editrank); }
/// <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 var 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> /// Show the Google Login/Register Form /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void GoogleFormClick(object sender, EventArgs e) { YafBuildLink.Redirect(ForumPages.login, "auth={0}", "google"); }
/// <summary> /// Show the Twitter Login/Register Form /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void TwitterFormClick(object sender, EventArgs e) { YafBuildLink.Redirect(ForumPages.login, "auth={0}", "twitter"); }
/// <summary> /// Show the Facebook Login/Register Form /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void FacebookFormClick(object sender, EventArgs e) { YafBuildLink.Redirect(ForumPages.login, "auth={0}", "facebook"); }
/// <summary> /// Redirect user back to his PM inbox /// </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(ForumPages.cp_pm); }
/// <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> /// Send Private Message /// </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 Save_Click([NotNull] object sender, [NotNull] EventArgs e) { var replyTo = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("p").IsSet() ? this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("p").ToType <int>() : -1; // recipient was set in dropdown if (this.ToList.Visible) { this.To.Text = this.ToList.SelectedItem.Text; } if (this.To.Text.Length <= 0) { // recipient is required field YafContext.Current.AddLoadMessage(this.GetText("need_to"), MessageTypes.warning); return; } // subject is required if (this.PmSubjectTextBox.Text.Trim().Length <= 0) { YafContext.Current.AddLoadMessage(this.GetText("need_subject"), MessageTypes.warning); return; } // message is required if (this._editor.Text.Trim().Length <= 0) { YafContext.Current.AddLoadMessage(this.GetText("need_message"), MessageTypes.warning); return; } if (this.ToList.SelectedItem != null && this.ToList.SelectedItem.Value == "0") { // administrator is sending PMs to all users var body = this._editor.Text; var messageFlags = new MessageFlags { IsHtml = this._editor.UsesHTML, IsBBCode = this._editor.UsesBBCode }; // test user's PM count if (!this.VerifyMessageAllowed(1, body)) { return; } LegacyDb.pmessage_save( YafContext.Current.PageUserID, 0, this.PmSubjectTextBox.Text, body, messageFlags.BitValue, replyTo); // redirect to outbox (sent items), not control panel YafBuildLink.Redirect(ForumPages.cp_pm, "v={0}", "out"); } else { // remove all abundant whitespaces and separators var rx = new Regex(@";(\s|;)*;"); this.To.Text = rx.Replace(this.To.Text, ";"); if (this.To.Text.StartsWith(";")) { this.To.Text = this.To.Text.Substring(1); } if (this.To.Text.EndsWith(";")) { this.To.Text = this.To.Text.Substring(0, this.To.Text.Length - 1); } rx = new Regex(@"\s*;\s*"); this.To.Text = rx.Replace(this.To.Text, ";"); // list of recipients var recipients = new List <string>(this.To.Text.Trim().Split(';')); if (recipients.Count > this.Get <YafBoardSettings>().PrivateMessageMaxRecipients && !YafContext.Current.IsAdmin && this.Get <YafBoardSettings>().PrivateMessageMaxRecipients != 0) { // to many recipients YafContext.Current.AddLoadMessage( this.GetTextFormatted( "TOO_MANY_RECIPIENTS", this.Get <YafBoardSettings>().PrivateMessageMaxRecipients), MessageTypes.warning); return; } if (!this.VerifyMessageAllowed(recipients.Count, this._editor.Text)) { return; } // list of recipient's ids var recipientIds = new List <int>(); // get recipients' IDs foreach (string recipient in recipients) { int?userId = this.Get <IUserDisplayName>().GetId(recipient); if (!userId.HasValue) { YafContext.Current.AddLoadMessage( this.GetTextFormatted("NO_SUCH_USER", recipient), MessageTypes.warning); return; } if (UserMembershipHelper.IsGuestUser(userId.Value)) { YafContext.Current.AddLoadMessage(this.GetText("NOT_GUEST"), MessageTypes.danger); return; } // get recipient's ID from the database if (!recipientIds.Contains(userId.Value)) { recipientIds.Add(userId.Value); } var receivingPMInfo = LegacyDb.user_pmcount(userId.Value).Rows[0]; // test receiving user's PM count if ((receivingPMInfo["NumberTotal"].ToType <int>() + 1 < receivingPMInfo["NumberAllowed"].ToType <int>()) || YafContext.Current.IsAdmin || (bool) Convert.ChangeType( UserMembershipHelper.GetUserRowForID(userId.Value, true)["IsAdmin"], typeof(bool))) { continue; } // recipient has full PM box YafContext.Current.AddLoadMessage( this.GetTextFormatted("RECIPIENTS_PMBOX_FULL", recipient), MessageTypes.danger); return; } // send PM to all recipients foreach (var userId in recipientIds) { string body = this._editor.Text; var messageFlags = new MessageFlags { IsHtml = this._editor.UsesHTML, IsBBCode = this._editor.UsesBBCode }; LegacyDb.pmessage_save( YafContext.Current.PageUserID, userId, this.PmSubjectTextBox.Text, body, messageFlags.BitValue, replyTo); // reset reciever's lazy data as he should be informed at once this.Get <IDataCache>().Remove(Constants.Cache.ActiveUserLazyData.FormatWith(userId)); if (this.Get <YafBoardSettings>().AllowPMEmailNotification) { this.Get <ISendNotification>() .ToPrivateMessageRecipient(userId, this.PmSubjectTextBox.Text.Trim()); } } // redirect to outbox (sent items), not control panel YafBuildLink.Redirect(ForumPages.cp_pm, "v={0}", "out"); } }
/// <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 var roleName = this.Name.Text.Trim(); var 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 (var dt = this.GetRepository <Group>().List(boardId: this.PageContext.PageBoardID)) { 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, this.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(s) this.GetRepository <Active>().DeleteAll(); this.GetRepository <ActiveAccess>().DeleteAll(); // 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 (var i = 0; i < this.AccessList.Items.Count; i++) { // get current repeater item var item = this.AccessList.Items[i]; // get forum ID var forumID = int.Parse(item.FindControlAs <Label>("ForumID").Text); // save forum access maks for this role LegacyDb.forumaccess_save( forumID, roleID, item.FindControlAs <DropDownList>("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))); // Clear Styling Caching this.Get <IDataCache>().Remove(Constants.Cache.GroupRankStyles); // Done, redirect to role editing page YafBuildLink.Redirect(ForumPages.admin_editgroup, "i={0}", roleID); }
/// <summary> /// Redirects to the Twitter 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 TwitterRegisterClick(object sender, EventArgs e) { YafBuildLink.Redirect(ForumPages.login, "auth={0}", AuthService.twitter); }
/// <summary> /// The add user_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void AddUser_Click([NotNull] object sender, [NotNull] EventArgs e) { YafBuildLink.Redirect(ForumPages.mod_forumuser, "f={0}", this.PageContext.PageForumID); }
/// <summary> /// The list_ item command. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterCommandEventArgs"/> instance containing the event data.</param> protected void List_ItemCommand([NotNull] object sender, [NotNull] RepeaterCommandEventArgs e) { switch (e.CommandName) { case "import": YafBuildLink.Redirect(ForumPages.admin_bannedip_import); break; case "add": YafBuildLink.Redirect(ForumPages.admin_bannedip_edit); break; case "edit": YafBuildLink.Redirect(ForumPages.admin_bannedip_edit, "i={0}", e.CommandArgument); break; case "export": { var bannedIps = this.GetRepository <BannedIP>().ListTyped(); this.Get <HttpResponseBase>().Clear(); this.Get <HttpResponseBase>().ClearContent(); this.Get <HttpResponseBase>().ClearHeaders(); this.Get <HttpResponseBase>().ContentType = "application/vnd.text"; this.Get <HttpResponseBase>() .AppendHeader("content-disposition", "attachment; filename=BannedIpsExport.txt"); var streamWriter = new StreamWriter(this.Get <HttpResponseBase>().OutputStream); foreach (var ip in bannedIps) { streamWriter.Write(ip.Mask); streamWriter.Write(streamWriter.NewLine); } streamWriter.Close(); this.Response.End(); } break; case "delete": { var ip = this.GetIPFromID(e.CommandArgument); this.GetRepository <BannedIP>().DeleteByID(e.CommandArgument.ToType <int>()); this.BindData(); this.PageContext.AddLoadMessage(this.GetText("ADMIN_BANNEDIP", "MSG_REMOVEBAN")); if (YafContext.Current.Get <YafBoardSettings>().LogBannedIP) { this.Get <ILogger>() .Log( this.PageContext.PageUserID, " YAF.Pages.Admin.bannedip", "IP or mask {0} was deleted by {1}.".FormatWith( ip, this.Get <YafBoardSettings>().EnableDisplayName ? this.PageContext.CurrentUserData.DisplayName : this.PageContext.CurrentUserData.UserName), EventLogTypes.IpBanLifted); } } break; } }
/// <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> /// Import the Users from the provided File /// </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 Import_OnClick([NotNull] object sender, [NotNull] EventArgs e) { try { int importedCount; // import selected file (if it's the proper format)... switch (this.importFile.PostedFile.ContentType) { case "text/xml": { importedCount = this.UsersImport(this.importFile.PostedFile.InputStream, true); } break; case "text/csv": { importedCount = this.UsersImport(this.importFile.PostedFile.InputStream, false); } break; case "text/comma-separated-values": { importedCount = this.UsersImport(this.importFile.PostedFile.InputStream, false); } break; case "application/csv": { importedCount = this.UsersImport(this.importFile.PostedFile.InputStream, false); } break; case "application/vnd.csv": { importedCount = this.UsersImport(this.importFile.PostedFile.InputStream, false); } break; case "application/vnd.ms-excel": { importedCount = this.UsersImport(this.importFile.PostedFile.InputStream, false); } break; default: { this.PageContext.AddLoadMessage( this.GetText("ADMIN_USERS_IMPORT", "IMPORT_FAILED_FORMAT"), MessageTypes.Error); return; } } this.PageContext.LoadMessage.AddSession( importedCount > 0 ? this.GetText("ADMIN_USERS_IMPORT", "IMPORT_SUCESS").FormatWith(importedCount) : this.GetText("ADMIN_USERS_IMPORT", "IMPORT_NOTHING"), importedCount > 0 ? MessageTypes.Success : MessageTypes.Information); YafBuildLink.Redirect(ForumPages.admin_users); } catch (Exception x) { this.PageContext.AddLoadMessage( this.GetText("ADMIN_USERS_IMPORT", "IMPORT_FAILED").FormatWith(x.Message), MessageTypes.Error); } }
/// <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> /// The submit button_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void SubmitButton_Click([NotNull] object sender, [NotNull] EventArgs e) { YafBuildLink.Redirect(ForumPages.login); }
/// <summary> /// Go Back to Albums Page /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// <exception cref="System.NotImplementedException"></exception> protected void Back_Click(object sender, EventArgs e) { YafBuildLink.Redirect( ForumPages.albums, "u={0}", this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("u")); }
/// <summary> /// Called when Password Recovery is Clicked /// </summary> /// <param name="sender"> /// standard event object sender /// </param> /// <param name="e"> /// event args /// </param> protected void PasswordRecovery_Click([NotNull] object sender, [NotNull] EventArgs e) { YafBuildLink.Redirect(page: ForumPages.recoverpassword); }
/// <summary> /// Saves the Host Settings /// </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 Save_Click([NotNull] object sender, [NotNull] EventArgs e) { // write all the settings back to the settings class // load Board Setting collection information... var settingCollection = new YafBoardSettingCollection(this.Get <YafBoardSettings>()); // handle checked fields... foreach (var name in settingCollection.SettingsBool.Keys) { var control = this.HostSettingsTabs.FindControlRecursive(name); if (control is CheckBox && settingCollection.SettingsBool[name].CanWrite) { settingCollection.SettingsBool[name].SetValue( this.Get <YafBoardSettings>(), ((CheckBox)control).Checked, null); } } // handle string fields... foreach (var name in settingCollection.SettingsString.Keys) { var control = this.HostSettingsTabs.FindControlRecursive(name); if (control is TextBox && settingCollection.SettingsString[name].CanWrite) { settingCollection.SettingsString[name].SetValue( this.Get <YafBoardSettings>(), ((TextBox)control).Text.Trim(), null); } else if (control is DropDownList && settingCollection.SettingsString[name].CanWrite) { settingCollection.SettingsString[name].SetValue( this.Get <YafBoardSettings>(), Convert.ToString(((DropDownList)control).SelectedItem.Value), null); } } // handle int fields... foreach (var name in settingCollection.SettingsInt.Keys) { var control = this.HostSettingsTabs.FindControlRecursive(name); if (control is TextBox && settingCollection.SettingsInt[name].CanWrite) { var value = ((TextBox)control).Text.Trim(); int i; if (value.IsNotSet()) { i = 0; } else { int.TryParse(value, out i); } settingCollection.SettingsInt[name].SetValue(this.Get <YafBoardSettings>(), i, null); } else if (control is DropDownList && settingCollection.SettingsInt[name].CanWrite) { settingCollection.SettingsInt[name].SetValue( this.Get <YafBoardSettings>(), ((DropDownList)control).SelectedItem.Value.ToType <int>(), null); } } // handle double fields... foreach (var name in settingCollection.SettingsDouble.Keys) { var control = this.HostSettingsTabs.FindControlRecursive(name); if (control is TextBox && settingCollection.SettingsDouble[name].CanWrite) { var value = ((TextBox)control).Text.Trim(); double i; if (value.IsNotSet()) { i = 0; } else { double.TryParse(value, out i); } settingCollection.SettingsDouble[name].SetValue(this.Get <YafBoardSettings>(), i, null); } else if (control is DropDownList && settingCollection.SettingsDouble[name].CanWrite) { settingCollection.SettingsDouble[name].SetValue( this.Get <YafBoardSettings>(), Convert.ToDouble(((DropDownList)control).SelectedItem.Value), null); } } // save the settings to the database ((YafLoadBoardSettings)this.Get <YafBoardSettings>()).SaveRegistry(); // reload all settings from the DB this.PageContext.BoardSettings = null; YafBuildLink.Redirect(ForumPages.admin_admin); }
/// <summary> /// The new server_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void NewServer_Click([NotNull] object sender, [NotNull] EventArgs e) { YafBuildLink.Redirect(ForumPages.admin_editnntpserver); }
/// <summary> /// Save the attached file both physically and in the db. /// </summary> /// <param name="file">the file.</param> /// <exception cref="Exception">Album Image File is too big</exception> private void SaveAttachment([NotNull] HtmlInputFile file) { if (file.PostedFile == null || file.PostedFile.FileName.Trim().Length == 0 || file.PostedFile.ContentLength == 0) { return; } string sUpDir = this.Get <HttpRequestBase>().MapPath( string.Concat(BaseUrlBuilder.ServerFileRoot, YafBoardFolders.Current.Uploads)); // check if Uploads folder exists if (!Directory.Exists(sUpDir)) { Directory.CreateDirectory(sUpDir); } string filename = file.PostedFile.FileName; int pos = filename.LastIndexOfAny(new[] { '/', '\\' }); if (pos >= 0) { filename = filename.Substring(pos + 1); } // filename can be only 255 characters long (due to table column) if (filename.Length > 255) { filename = filename.Substring(filename.Length - 255); } // verify the size of the attachment if (this.Get <YafBoardSettings>().AlbumImagesSizeMax > 0 && file.PostedFile.ContentLength > this.Get <YafBoardSettings>().AlbumImagesSizeMax) { throw new Exception(this.GetText("ERROR_TOOBIG")); } // vzrus: the checks here are useless but in a case... DataTable sigData = LegacyDb.user_getalbumsdata(this.PageContext.PageUserID, YafContext.Current.PageBoardID); var usrAlbumsAllowed = sigData.GetFirstRowColumnAsValue <int?>("UsrAlbums", null); var usrAlbumImagesAllowed = sigData.GetFirstRowColumnAsValue <int?>("UsrAlbumImages", null); // if (!usrAlbums.HasValue || usrAlbums <= 0) return; if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("a") == "new") { int[] alstats = LegacyDb.album_getstats(this.PageContext.PageUserID, null); // Albums count. If we reached limit then we exit. if (alstats[0] >= usrAlbumsAllowed) { this.PageContext.AddLoadMessage(this.GetTextFormatted("ALBUMS_COUNT_LIMIT", usrAlbumImagesAllowed)); return; } var newAlbumId = LegacyDb.album_save(null, this.PageContext.PageUserID, this.txtTitle.Text, null); file.PostedFile.SaveAs( "{0}/{1}.{2}.{3}.yafalbum".FormatWith(sUpDir, this.PageContext.PageUserID, newAlbumId.ToString(), filename)); LegacyDb.album_image_save(null, newAlbumId, null, filename, file.PostedFile.ContentLength, file.PostedFile.ContentType); // clear the cache for this user to update albums|images stats... this.Get <IRaiseEvent>().Raise(new UpdateUserEvent(this.PageContext.PageUserID)); YafBuildLink.Redirect(ForumPages.cp_editalbumimages, "a={0}", newAlbumId); } else { // vzrus: the checks here are useless but in a case... int[] alstats = LegacyDb.album_getstats( this.PageContext.PageUserID, this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("a")); /* * // Albums count. If we reached limit then we exit. * // Check it first as user could be in other group or prev YAF version was used; * if (DB.album_getstats(this.PageContext.PageUserID, null)[0] >= usrAlbums) * { * this.PageContext.AddLoadMessage(this.GetTextFormatted("ALBUMS_COUNT_LIMIT", usrAlbums)); * return; * }*/ // Images count. If we reached limit then we exit. if (alstats[1] >= usrAlbumImagesAllowed) { this.PageContext.AddLoadMessage(this.GetTextFormatted("IMAGES_COUNT_LIMIT", usrAlbumImagesAllowed)); return; } file.PostedFile.SaveAs( "{0}/{1}.{2}.{3}.yafalbum".FormatWith( sUpDir, this.PageContext.PageUserID, this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("a"), filename)); LegacyDb.album_image_save( null, this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("a"), null, filename, file.PostedFile.ContentLength, file.PostedFile.ContentType); } }