/// <summary> /// Creates the board in the database. /// </summary> /// <param name="boardName">Name of the board.</param> /// <param name="boardMembershipAppName">Name of the board membership application.</param> /// <param name="boardRolesAppName">Name of the board roles application.</param> /// <param name="langFile">The language file.</param> /// <param name="newAdmin">The new admin.</param> /// <returns></returns> private int DbCreateBoard( string boardName, string boardMembershipAppName, string boardRolesAppName, string langFile, SitecoreMembershipUser newAdmin) { int newBoardID = this.GetRepository<Board>() .Create( boardName, this.Culture.SelectedItem.Value, langFile, boardMembershipAppName, boardRolesAppName, newAdmin.UserName, newAdmin.Email, newAdmin.ProviderUserKey.ToString(), this.PageContext().IsHostAdmin, Config.CreateDistinctRoles && Config.IsAnyPortal ? "YAF " : string.Empty); return newBoardID; }
/// <summary> /// The page_ load. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { if (this.User == null) { YafBuildLink.AccessDenied(); } if (!this.IsPostBack) { // get user data... SitecoreMembershipUser user = new SitecoreMembershipUser(this.User); if (user == null) { YafBuildLink.AccessDenied( /*No such user exists*/); } string displayName = UserMembershipHelper.GetDisplayNameFromID(this.UserID); this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum)); this.PageLinks.AddLink( this.PageContext.BoardSettings.EnableDisplayName ? displayName : user.UserName, YafBuildLink.GetLink( ForumPages.profile, "u={0}&name={1}", this.UserID, this.PageContext.BoardSettings.EnableDisplayName ? displayName : user.UserName)); this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty); // get full user data... var userData = new CombinedUserDataHelper(user, this.UserID); this.Msg.NavigateUrl = "aim:goim?screenname={0}&message=Hi.+Are+you+there?".FormatWith(userData.Profile.AIM); this.Buddy.NavigateUrl = "aim:addbuddy?screenname={0}".FormatWith(userData.Profile.AIM); } }
/// <summary> /// Deletes and ban's the user. /// </summary> /// <param name="userID">The user id.</param> /// <param name="user">The MemberShip User.</param> /// <param name="userIpAddress">The user's IP address.</param> /// <returns> /// Returns if Deleting was successfully /// </returns> public static bool DeleteAndBanUser(int userID, SitecoreMembershipUser user, string userIpAddress) { // Ban IP ? if (YafContext.Current.Get<YafBoardSettings>().BanBotIpOnDetection) { YafContext.Current.GetRepository<BannedIP>() .Save( null, userIpAddress, "A spam Bot who was trying to register was banned by IP {0}".FormatWith(userIpAddress), userID); // Clear cache YafContext.Current.Get<IDataCache>().Remove(Constants.Cache.BannedIP); if (YafContext.Current.Get<YafBoardSettings>().LogBannedIP) { YafContext.Current.Get<ILogger>() .Log( userID, "IP BAN of Bot", "A spam Bot who was banned by IP {0}".FormatWith(userIpAddress), EventLogTypes.IpBanSet); } } // Ban Name ? YafContext.Current.GetRepository<BannedName>() .Save(null, user.UserName, "Name was reported by the automatic spam system."); // Ban User Email? YafContext.Current.GetRepository<BannedEmail>() .Save(null, user.Email, "Email was reported by the automatic spam system."); // Delete the images/albums both from database and physically. var uploadDir = HttpContext.Current.Server.MapPath( string.Concat(BaseUrlBuilder.ServerFileRoot, YafBoardFolders.Current.Uploads)); using (DataTable dt = LegacyDb.album_list(userID, null)) { foreach (DataRow dr in dt.Rows) { YafAlbum.Album_Image_Delete(uploadDir, dr["AlbumID"], userID, null); } } YafContext.Current.Get<MembershipProvider>().DeleteUser(user.UserName, true); LegacyDb.user_delete(userID); YafContext.Current.Get<ILogger>() .Log( YafContext.Current.PageUserID, "UserMembershipHelper.DeleteUser", "User {0} was deleted by the automatic spam check system.".FormatWith(user.UserName), EventLogTypes.UserDeleted); // clear the cache YafContext.Current.Get<IDataCache>().Remove(Constants.Cache.UsersOnlineStatus); YafContext.Current.Get<IDataCache>().Remove(Constants.Cache.BoardUserStats); YafContext.Current.Get<IDataCache>().Remove(Constants.Cache.UsersDisplayNameCollection); return true; }
/// <summary> /// Setups the user profile. /// </summary> /// <param name="user"> /// The user. /// </param> /// <param name="userId"> /// The user identifier. /// </param> private void SetupUserProfile(SitecoreMembershipUser user, int userId) { // this is the "Profile Information" step. Save the data to their profile (+ defaults). var timeZones = (DropDownList)this.CreateUserWizard1.FindWizardControlRecursive("TimeZones"); var country = (DropDownList)this.CreateUserWizard1.FindWizardControlRecursive("Country"); var locationTextBox = (TextBox)this.CreateUserWizard1.FindWizardControlRecursive("Location"); var homepageTextBox = (TextBox)this.CreateUserWizard1.FindWizardControlRecursive("Homepage"); var dstUser = (CheckBox)this.CreateUserWizard1.FindWizardControlRecursive("DSTUser"); // setup/save the profile YafUserProfile userProfile = YafUserProfile.GetProfile(this.CreateUserWizard1.UserName); if (country.SelectedValue != null) { userProfile.Country = country.SelectedValue; } string result; if (this.Get<ISpamWordCheck>().CheckForSpamWord(homepageTextBox.Text.Trim(), out result)) { this.IsPossibleSpamBotInternalCheck = true; var userIpAddress = this.Get<HttpRequestBase>().GetUserRealIPAddress(); if (this.Get<YafBoardSettings>().BotHandlingOnRegister.Equals(1)) { // Flag user as spam bot this.IsPossibleSpamBot = true; this.Get<ISendNotification>().SendSpamBotNotificationToAdmins(user, userId); } else if (this.Get<YafBoardSettings>().BotHandlingOnRegister.Equals(2)) { // Kill user UserMembershipHelper.DeleteAndBanUser(userId, user, userIpAddress); this.PageContext.AddLoadMessage(this.GetText("BOT_MESSAGE"), MessageTypes.Error); } this.Logger.Log( null, "Bot Detected", "Internal Spam Word Check detected a SPAM BOT: (user name : '{0}', email : '{1}', ip: '{2}') reason word: {3}" .FormatWith(user.UserName, this.CreateUserWizard1.Email, userIpAddress, homepageTextBox.Text.Trim()), EventLogTypes.SpamBotDetected); } if (!this.IsPossibleSpamBotInternalCheck) { userProfile.Location = locationTextBox.Text.Trim(); // add http:// by default if (!Regex.IsMatch(homepageTextBox.Text.Trim(), @"^(http|https|ftp|ftps|git|svn|news)\://.*")) { homepageTextBox.Text = "http://{0}".FormatWith(homepageTextBox.Text.Trim()); } if (ValidationHelper.IsValidURL(homepageTextBox.Text)) { userProfile.Homepage = homepageTextBox.Text.Trim(); } userProfile.Save(); // save the time zone... LegacyDb.user_save( userID: userId, boardID: this.PageContext.PageBoardID, userName: null, displayName: null, email: null, timeZone: timeZones.SelectedValue.ToType<int>(), languageFile: null, culture: null, themeFile: null, textEditor: null, useMobileTheme: null, approved: null, pmNotification: null, autoWatchTopics: null, dSTUser: dstUser.Checked, hideUser: null, notificationType: null); var autoWatchTopicsEnabled = this.Get<YafBoardSettings>().DefaultNotificationSetting == UserNotificationSetting.TopicsIPostToOrSubscribeTo; // save the settings... LegacyDb.user_savenotification( userId, true, autoWatchTopicsEnabled, this.Get<YafBoardSettings>().DefaultNotificationSetting, this.Get<YafBoardSettings>().DefaultSendDigestEmail); } }