protected void LoginUser_Authenticate(object sender, AuthenticateEventArgs e) { string loginUsername = LoginUser.UserName; string loginPassword = LoginUser.Password; CaptchaControl CAPTCHA = LoginUser.FindControl("CAPTCHA") as CaptchaControl; // first check the Captcha to insure it is valid. if (!CAPTCHA.UserValidated && tries >= 3) { //CAPTCHA invalid LoginUser.FailureText = "The code you entered did not match up with the image provided; please try again with this new image."; tries++; e.Authenticated = false; } // next check the userid and password else if (Membership.ValidateUser(loginUsername, loginPassword)) { //Only set e.Authenticated to True if ALL checks pass e.Authenticated = true; tries = 0; } // else tell user to try again else { tries++; e.Authenticated = false; LoginUser.FailureText = "Your username and/or password are invalid."; } }
/// <summary> /// Adds the captcha if necessary. /// </summary> /// <param name="captcha">The captcha.</param> /// <param name="invisibleCaptchaValidator">The invisible captcha validator.</param> /// <param name="btnIndex">Index of the BTN.</param> protected void AddCaptchaIfNecessary(ref CaptchaControl captcha, ref InvisibleCaptcha invisibleCaptchaValidator, int btnIndex) { if (Config.CurrentBlog.CaptchaEnabled) { captcha = new CaptchaControl { ID = "captcha" }; Control preExisting = ControlHelper.FindControlRecursively(this, "captcha"); if (preExisting == null) // && !Config.CurrentBlog.FeedbackSpamServiceEnabled) Experimental code for improved UI. Will put back in later. - Phil Haack 10/09/2006 { Controls.AddAt(btnIndex, captcha); } } else { RemoveCaptcha(); } if (Config.Settings.InvisibleCaptchaEnabled) { invisibleCaptchaValidator = new InvisibleCaptcha { ErrorMessage = "Please enter the answer to the supplied question." }; Controls.AddAt(btnIndex, invisibleCaptchaValidator); } }
public async Task <ActionResult> RegisterCustomer(CustomerRegisterViewModel model) { if (ModelState.IsValid) { bool ajaxValidationResult = CaptchaControl.AjaxValidate (model.CaptchaId, model.CaptchaInput, model.InstanceId); if (ajaxValidationResult) { try { // Set customer details Customer customer = new Customer() { CompanyName = model.CompanyName }; var user = new PaskolUser { RegisteredDate = DateTime.Now, UserName = model.Name, Email = model.Email, Customer = customer, UserType = UserType.Customer, Status = UserStatus.Active }; // Create user var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { // assign user to role var roleResoult = await UserManager.AddToRoleAsync(user.Id, UserType.Customer.ToString()); // Sign in await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // email to customer EmailService.RegisterCustomer(model.Email, model.Name, model.Password); return(Json(new { suceeded = true, UserName = model.Name })); } AddErrors(result); } catch (Exception ex) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "ארעה שגיאה אנא פנה לתמיכה")); } } else { // handle not valid captcha _errors.Add(new KeyValuePair <string, string>("Captcha", "")); } } return(Json(new { suceeded = false, errors = _errors })); }
/// <summary> /// Returns true if entered data is valid. /// </summary> public override bool IsValid() { bool isValid = CaptchaControl.IsValid(); if (!isValid) { ValidationError = GetString("SecurityCode.ValidationError"); } return(isValid); }
private void PopulateControls() { if (siteSettings == null) { return; } if (siteSettings.DisableDbAuth) { this.Visible = false; return; } LoginCtrl.SetRedirectUrl = SetRedirectUrl; lblUserID = (SiteLabel)this.LoginCtrl.FindControl("lblUserID"); lblEmail = (SiteLabel)this.LoginCtrl.FindControl("lblEmail"); txtUserName = (TextBox)this.LoginCtrl.FindControl("UserName"); txtPassword = (TextBox)this.LoginCtrl.FindControl("Password"); chkRememberMe = (CheckBox)this.LoginCtrl.FindControl("RememberMe"); btnLogin = (mojoButton)this.LoginCtrl.FindControl("Login"); lnkRecovery = (HyperLink)this.LoginCtrl.FindControl("lnkPasswordRecovery"); lnkExtraLink = (HyperLink)this.LoginCtrl.FindControl("lnkRegisterExtraLink"); if (WebConfigSettings.DisableAutoCompleteOnLogin) { txtUserName.AutoCompleteType = AutoCompleteType.Disabled; txtPassword.AutoCompleteType = AutoCompleteType.Disabled; } divCaptcha = (Panel)LoginCtrl.FindControl("divCaptcha"); captcha = (CaptchaControl)LoginCtrl.FindControl("captcha"); if (!siteSettings.RequireCaptchaOnLogin) { if (divCaptcha != null) { divCaptcha.Visible = false; } if (captcha != null) { captcha.Captcha.Enabled = false; } } else { captcha.ProviderName = siteSettings.CaptchaProvider; captcha.RecaptchaPrivateKey = siteSettings.RecaptchaPrivateKey; captcha.RecaptchaPublicKey = siteSettings.RecaptchaPublicKey; } if ((siteSettings.UseEmailForLogin) && (!siteSettings.UseLdapAuth)) { if (!WebConfigSettings.AllowLoginWithUsernameWhenSiteSettingIsUseEmailForLogin) { EmailValidator regexEmail = new EmailValidator(); regexEmail.ControlToValidate = txtUserName.ID; regexEmail.ErrorMessage = Resource.LoginFailedInvalidEmailFormatMessage; this.LoginCtrl.Controls.Add(regexEmail); } } if (siteSettings.UseEmailForLogin && !siteSettings.UseLdapAuth) { this.lblUserID.Visible = false; } else { this.lblEmail.Visible = false; } if (SetFocus) { txtUserName.Focus(); } lnkRecovery.Visible = ((siteSettings.AllowPasswordRetrieval || siteSettings.AllowPasswordReset) && (!siteSettings.UseLdapAuth || (siteSettings.UseLdapAuth && siteSettings.AllowDbFallbackWithLdap))); lnkRecovery.NavigateUrl = this.LoginCtrl.PasswordRecoveryUrl; lnkRecovery.Text = this.LoginCtrl.PasswordRecoveryText; lnkExtraLink.NavigateUrl = siteRoot + "/Secure/Register.aspx"; lnkExtraLink.Text = Resource.RegisterLink; lnkExtraLink.Visible = siteSettings.AllowNewRegistration; string returnUrlParam = Page.Request.Params.Get("returnurl"); if (!String.IsNullOrEmpty(returnUrlParam)) { //string redirectUrl = returnUrlParam; lnkExtraLink.NavigateUrl += "?returnurl=" + SecurityHelper.RemoveMarkup(returnUrlParam); } chkRememberMe.Visible = siteSettings.AllowPersistentLogin; chkRememberMe.Text = this.LoginCtrl.RememberMeText; if (WebConfigSettings.ForcePersistentAuthCheckboxChecked) { chkRememberMe.Checked = true; chkRememberMe.Visible = false; } btnLogin.Text = this.LoginCtrl.LoginButtonText; //SiteUtils.SetButtonAccessKey(btnLogin, AccessKeys.LoginAccessKey); }
public async Task <ActionResult> RegisterArtist(ArtistRegisterViewModel model) { if (ModelState.IsValid) { bool ajaxValidationResult = CaptchaControl.AjaxValidate (model.CaptchaId, model.CaptchaInput, model.InstanceId); if (ajaxValidationResult) { try { Artist artist = new Artist() { ContactManName = model.ContactManName, ContactManPhone = model.ContactManPhone, ParticipateInAuction = true }; var user = new PaskolUser { RegisteredDate = DateTime.Now, UserName = model.Name, Email = model.Email, Artist = artist, UserType = UserType.Artist, Status = UserStatus.WaitingNewArtist }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { // assign user artist to role var roleResoult = await UserManager.AddToRoleAsync(user.Id, UserType.Artist.ToString()); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // Add to confirmation waiting _conSrv.Add(new Confirmation() { ConfirmType = ConfirmType.NewArtist, DateUpdate = DateTime.Now, EntityId = user.Id, Name = user.UserName }); // email to artist EmailService.RegisterArtist(model.Email, model.Name, model.Password); await _pdfService.ArtistPermissionAgreementAsync(DateTime.Now, user.UserName, user.Email, user.Id, WebConf.FSBaseRoute); return(Json(new { suceeded = true, UserName = model.Name })); } AddErrors(result); } catch (Exception ex) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "ארעה שגיאה אנא פנה לתמיכה")); } } else { // handle not valid captcha _errors.Add(new KeyValuePair <string, string>("Captcha", "")); } } return(Json(new { suceeded = false, errors = _errors })); }
void SiteLogin_LoggingIn(object sender, LoginCancelEventArgs e) { if (siteSettings.RequireCaptchaOnLogin) { CaptchaControl captcha = (CaptchaControl)this.FindControl("captcha"); if (captcha != null) { // if (!captcha.Captcha.IsValid) if (!captcha.IsValid) { e.Cancel = true; return; } } } SiteUser siteUser = new SiteUser(siteSettings, this.UserName); if (siteUser.UserId > -1) { if (siteSettings.UseSecureRegistration && siteUser.RegisterConfirmGuid != Guid.Empty) { //this.FailureText = Resource.LoginUnconfirmedEmailMessage; Label lblFailure = (Label)this.FindControl("FailureText"); if (lblFailure != null) { lblFailure.Visible = true; lblFailure.Text = Resource.LoginUnconfirmedEmailMessage; } // send email with confirmation link that will approve profile Notification.SendRegistrationConfirmationLink( SiteUtils.GetSmtpSettings(), ResourceHelper.GetMessageTemplate("RegisterConfirmEmailMessage.config"), siteSettings.DefaultEmailFromAddress, siteSettings.DefaultFromEmailAlias, siteUser.Email, siteSettings.SiteName, WebUtils.GetSiteRoot() + "/ConfirmRegistration.aspx?ticket=" + siteUser.RegisterConfirmGuid.ToString()); // user has not confirmed e.Cancel = true; return; } if (siteUser.IsDeleted) { //this.FailureText = Resource.LoginAccountLockedMessage; Label lblFailure = (Label)this.FindControl("FailureText"); if (lblFailure != null) { lblFailure.Visible = true; lblFailure.Text = ResourceHelper.GetMessageTemplate("LoginFailedMessage.config"); } e.Cancel = true; return; } if (siteUser.IsLockedOut) { //this.FailureText = Resource.LoginAccountLockedMessage; Label lblFailure = (Label)this.FindControl("FailureText"); if (lblFailure != null) { lblFailure.Visible = true; lblFailure.Text = Resource.LoginAccountLockedMessage; } e.Cancel = true; return; } if ((siteSettings.RequireApprovalBeforeLogin) && (!siteUser.ApprovedForLogin)) { //this.FailureText = Resource.LoginAccountLockedMessage; Label lblFailure = (Label)this.FindControl("FailureText"); if (lblFailure != null) { lblFailure.Visible = true; lblFailure.Text = Resource.LoginNotApprovedMessage; } e.Cancel = true; return; } if (siteSettings.MaxInvalidPasswordAttempts > 0) { if (siteUser.FailedPasswordAttemptCount >= siteSettings.MaxInvalidPasswordAttempts) { if (siteUser.FailedPasswordAttemptWindowStart.AddMinutes(siteSettings.PasswordAttemptWindowMinutes) > DateTime.UtcNow) { //this.FailureText = Resource.LoginAccountLockedMessage; Label lblFailure = (Label)this.FindControl("FailureText"); if (lblFailure != null) { lblFailure.Visible = true; lblFailure.Text = Resource.AccountLockedTemporarilyDueToPasswordFailures; } e.Cancel = true; return; } } } } }
void BuildEditForm() { var fieldSettingsTable = FieldSettingsController.GetFieldSettingsTable(ModuleId); var editForm = new List <FormColumnInfo>(); FormColumnInfo currentField; var security = new ModuleSecurity(ModuleContext); _editControls = new EditControls(ModuleContext); foreach (DataRow dr in Data.Tables[DataSetTableName.Fields].Rows) { var fieldTitle = dr[FieldsTableColumn.Title].AsString(); var dataTypeName = dr[FieldsTableColumn.Type].AsString(); var dataType = DataType.ByName(dataTypeName); var isColumnEditable = Convert.ToBoolean((!dataType.SupportsHideOnEdit || Convert.ToBoolean(dr[FieldsTableColumn.ShowOnEdit])) && (!Convert.ToBoolean(dr[FieldsTableColumn.IsPrivate]) || security.IsAllowedToEditAllColumns())); //If Column is hidden, the Fieldtype falls back to "String" as the related EditControl works perfect even if it is not visibile //EditControls of other user defined datatypes may use core controls (e.g. UrlControl or RTE) which are not rock solid regarding viewstate. if (!isColumnEditable && dataType.IsUserDefinedField) { dataTypeName = "String"; } currentField = new FormColumnInfo { IsUserDefinedField = dataType.IsUserDefinedField }; if (dataType.IsSeparator) { var fieldId = (int)dr[FieldsTableColumn.Id]; currentField.IsCollapsible = Data.Tables[DataSetTableName.FieldSettings].GetFieldSetting("IsCollapsible", fieldId).AsBoolean(); currentField.IsSeparator = true; if (dr[FieldsTableColumn.Visible].AsBoolean()) { currentField.Title = fieldTitle; } currentField.Visible = isColumnEditable; } else { currentField.Help = dr[FieldsTableColumn.HelpText].AsString(); currentField.Title = dr[FieldsTableColumn.Title].AsString(); currentField.Required = Convert.ToBoolean(dr[FieldsTableColumn.Required].AsBoolean() && dataType.IsUserDefinedField); //advanced Settings: Dynamic control currentField.EditControl = _editControls.Add(dr[FieldsTableColumn.Title].AsString(), dataTypeName, Convert.ToInt32(dr[FieldsTableColumn.Id]), dr[FieldsTableColumn.HelpText].AsString(), dr[FieldsTableColumn.Default].AsString(), dr[FieldsTableColumn.Required].AsBoolean(), dr[FieldsTableColumn.ValidationRule].AsString(), dr[FieldsTableColumn.ValidationMessage].AsString(), dr[FieldsTableColumn.EditStyle].AsString(), dr[FieldsTableColumn.InputSettings].AsString(), dr[FieldsTableColumn.OutputSettings].AsString(), dr[FieldsTableColumn.NormalizeFlag].AsBoolean(), dr[FieldsTableColumn.MultipleValues].AsBoolean(), fieldSettingsTable, this); currentField.Visible = isColumnEditable; } editForm.Add(currentField); } if (CaptchaNeeded()) { if (!Settings.PreferReCaptcha) { // use DnnCaptcha _ctlCaptcha = new CaptchaControl { ID = "Captcha", CaptchaWidth = Unit.Pixel(130), CaptchaHeight = Unit.Pixel(40), ToolTip = Localization.GetString("CaptchaToolTip", LocalResourceFile), ErrorMessage = Localization.GetString("CaptchaError", LocalResourceFile) }; currentField = new FormColumnInfo { Title = Localization.GetString("Captcha", LocalResourceFile), EditControl = _ctlCaptcha, Visible = true, IsUserDefinedField = false }; editForm.Add(currentField); } } var enableFormTemplate = Settings.EnableFormTemplate; var formTemplate = Settings.FormTemplate; if (enableFormTemplate && !string.IsNullOrEmpty(formTemplate)) { BuildTemplateForm(editForm, formTemplate); } else { BuildCssForm(editForm); } //Change captions of buttons in Form mode if (IsNewRow && Settings.ListOrForm.Contains("Form")) { cmdUpdate.Attributes["resourcekey"] = "cmdSend.Text"; } }
private void CreateSurveyItems(List <SurveysInfo> surveys) { foreach (SurveysInfo survey in surveys) { List <SurveyOptionsInfo> surveyOptions = SurveyOptionsController.GetAll(survey.SurveyID); switch (survey.OptionType) { case QuestionType.RadioButtons: SurveyRadioButtons surveyRadioButtons = (SurveyRadioButtons)LoadControl(string.Format("{0}Controls/SurveyRadioButtons.ascx", ControlPath)); surveyRadioButtons.ID = string.Format("SurveyRadiobutton_{0}", survey.SurveyID); surveyRadioButtons.Label = survey.Question; surveyRadioButtons.RepeatDirection = survey.RepeatDirection; surveyRadioButtons.RepeatColumns = (((survey.RepeatColumns == null) || (survey.RepeatColumns <= 1)) ? 1 : survey.RepeatColumns.Value); surveyRadioButtons.EditUrl = EditUrl("SurveyID", survey.SurveyID.ToString()); surveyRadioButtons.IsEditable = IsEditable; surveyRadioButtons.ErrorMessage = string.Format(Localization.GetString("RadioButtonRequired.ErrorMessage", LocalResourceFile), survey.Question); surveyRadioButtons.ValidationGroup = string.Format("Survey_{0}_ValidationGroup", ModuleId); surveyRadioButtons.DataSource = surveyOptions; surveyRadioButtons.DataTextField = "OptionName"; surveyRadioButtons.DataValueField = "SurveyOptionID"; surveyRadioButtons.DataBind(); SurveyPlaceHolder.Controls.Add(surveyRadioButtons); break; case QuestionType.CheckBoxes: SurveyCheckBoxes surveyCheckBoxes = (SurveyCheckBoxes)LoadControl(string.Format("{0}Controls/SurveyCheckBoxes.ascx", ControlPath)); surveyCheckBoxes.ID = string.Format("SurveyCheckbox_{0}", survey.SurveyID); surveyCheckBoxes.Label = survey.Question; surveyCheckBoxes.RepeatDirection = survey.RepeatDirection; surveyCheckBoxes.RepeatColumns = (((survey.RepeatColumns == null) || (survey.RepeatColumns <= 1)) ? 1 : survey.RepeatColumns.Value); surveyCheckBoxes.EditUrl = EditUrl("SurveyID", survey.SurveyID.ToString()); surveyCheckBoxes.IsEditable = IsEditable; surveyCheckBoxes.ErrorMessage = string.Format(Localization.GetString("CheckBoxRequired.ErrorMessage", LocalResourceFile), survey.Question); surveyCheckBoxes.ValidationGroup = string.Format("Survey_{0}_ValidationGroup", ModuleId); surveyCheckBoxes.DataSource = surveyOptions; surveyCheckBoxes.DataTextField = "OptionName"; surveyCheckBoxes.DataValueField = "SurveyOptionID"; surveyCheckBoxes.DataBind(); SurveyPlaceHolder.Controls.Add(surveyCheckBoxes); break; case QuestionType.Text: SurveyText surveyTextBox = (SurveyText)LoadControl(string.Format("{0}Controls/SurveyText.ascx", ControlPath)); surveyTextBox.ID = string.Format("SurveyTextBox_{0}", survey.SurveyID); surveyTextBox.Label = survey.Question; surveyTextBox.NumberOfRows = (((survey.NumberOfRows.HasValue) && (survey.NumberOfRows.Value > 1)) ? survey.NumberOfRows.Value : 1); surveyTextBox.EditUrl = EditUrl("SurveyID", survey.SurveyID.ToString()); surveyTextBox.IsEditable = IsEditable; surveyTextBox.ErrorMessage = string.Format(Localization.GetString("TextBoxRequired.ErrorMessage", LocalResourceFile), survey.Question); surveyTextBox.ValidationGroup = string.Format("Survey_{0}_ValidationGroup", ModuleId); surveyTextBox.SurveyOptionID = surveyOptions[0].SurveyOptionID; SurveyPlaceHolder.Controls.Add(surveyTextBox); break; default: break; } } if (PrivacyConfirmation) { // This is DNN 9.2.2 code... string privacyUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "Privacy"); string termsUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "Terms"); // For DNN 9.3.0 use this code then... //string privacyUrl = (PortalSettings.PrivacyTabId == Null.NullInteger ? Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "Privacy") : Globals.NavigateURL(PortalSettings.PrivacyTabId)); //string termsUrl = (PortalSettings.TermsTabId == Null.NullInteger ? Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "Terms") : Globals.NavigateURL(PortalSettings.TermsTabId)); PrivacyConfirmationCheckBox privacyConfirmation = (PrivacyConfirmationCheckBox)LoadControl(string.Format("{0}Controls/PrivacyConfirmationCheckBox.ascx", ControlPath)); privacyConfirmation.ID = string.Format("PrivacyConfirmationCheckBox_{0}", ModuleId); privacyConfirmation.Label = string.Format(Localization.GetString("PrivacyConfirmation.Text", LocalResourceFile), privacyUrl, termsUrl); privacyConfirmation.ErrorMessage = Localization.GetString("PrivacyConfirmation.ErrorMessage", LocalResourceFile); privacyConfirmation.ValidationGroup = string.Format("Survey_{0}_ValidationGroup", ModuleId); SurveyPlaceHolder.Controls.Add(privacyConfirmation); } if ((UseCaptcha == UseCaptcha.Always) || ((UseCaptcha == UseCaptcha.UnauthorizedUsersOnly) && (UserId < 1))) { CaptchaControl captcha = new CaptchaControl(); captcha.ID = string.Format("Captcha_{0}", ModuleId); captcha.Text = Localization.GetString("Captcha.Text", LocalResourceFile); captcha.CaptchaLength = 8; captcha.ErrorMessage = Localization.GetString("Captcha.ErrorMessage", LocalResourceFile); captcha.CaptchaChars = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789"; captcha.ErrorStyle.CssClass = "dnnFormMessage dnnFormError"; SurveyPlaceHolder.Controls.Add(captcha); } }
protected void SubmitSurveyButton_Click(object sender, EventArgs e) { // First, check CAPTCHA CaptchaControl captcha = (CaptchaControl)FindControl(string.Format("Captcha_{0}", ModuleId)); if (((captcha != null) && (captcha.IsValid)) || (captcha == null)) { // Then validate page... Page.Validate(string.Format("Survey_{0}_ValidationGroup", ModuleId)); if (Page.IsValid) { if (ContactByFaxOnlyCheckBox.Checked) { // if someone activates this checkbox send him home :-) Response.Redirect("http://localhost/"); } List <SurveysInfo> surveys = SurveysController.GetAll(ModuleId); List <SurveyResultsInfo> surveyResults = new List <SurveyResultsInfo>(); Guid resultUserID = Guid.NewGuid(); foreach (SurveysInfo survey in surveys) { SurveyResultsInfo surveyResult; switch (survey.OptionType) { case QuestionType.RadioButtons: SurveyRadioButtons surveyRadioButtons = (SurveyRadioButtons)FindControl(string.Format("SurveyRadiobutton_{0}", survey.SurveyID)); surveyResult = new SurveyResultsInfo(); surveyResult.SurveyOptionID = Convert.ToInt32(surveyRadioButtons.SelectedValue); surveyResult.UserID = (UserId < 1 ? (int?)null : UserId); surveyResult.IPAddress = Request.ServerVariables["REMOTE_ADDR"]; surveyResult.IsCorrect = SurveyOptionsController.GetAll(survey.SurveyID).Find(x => x.SurveyOptionID == surveyResult.SurveyOptionID).IsCorrect; surveyResult.ResultUserID = resultUserID; surveyResults.Add(surveyResult); break; case QuestionType.CheckBoxes: SurveyCheckBoxes surveyCheckBoxes = (SurveyCheckBoxes)FindControl(string.Format("SurveyCheckbox_{0}", survey.SurveyID)); foreach (int surveyOptionID in surveyCheckBoxes.SelectedItems) { surveyResult = new SurveyResultsInfo(); surveyResult.SurveyOptionID = surveyOptionID; surveyResult.UserID = (UserId < 1 ? (int?)null : UserId); surveyResult.IPAddress = Request.ServerVariables["REMOTE_ADDR"]; surveyResult.IsCorrect = SurveyOptionsController.GetAll(survey.SurveyID).Find(x => x.SurveyOptionID == surveyResult.SurveyOptionID).IsCorrect; surveyResult.ResultUserID = resultUserID; surveyResults.Add(surveyResult); } break; case QuestionType.Text: SurveyText surveyTextBox = (SurveyText)FindControl(string.Format("SurveyTextBox_{0}", survey.SurveyID)); surveyResult = new SurveyResultsInfo(); surveyResult.SurveyOptionID = surveyTextBox.SurveyOptionID; surveyResult.UserID = (UserId < 1 ? (int?)null : UserId); surveyResult.IPAddress = Request.ServerVariables["REMOTE_ADDR"]; surveyResult.TextAnswer = PortalSecurity.InputFilter(surveyTextBox.Text, PortalSecurity.FilterFlag.MultiLine | PortalSecurity.FilterFlag.NoAngleBrackets | PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoSQL); surveyResult.IsCorrect = true; surveyResult.ResultUserID = resultUserID; surveyResults.Add(surveyResult); break; default: break; } } if (PortalSecurity.IsInRole("Administrators")) { // This is just to force the SQL Script SurveyResults_Add to add the result if the user is an administrator SurveyResultsController.Add(surveyResults, false); } else { SurveyResultsController.Add(surveyResults, AuthorizedUsersOnly); } HttpCookie cookie = new HttpCookie(_cookie); cookie.Value = "True"; cookie.Expires = (SurveyClosingDate == DateTime.MinValue ? DateTime.MaxValue : SurveyClosingDate.AddDays(1)); Response.AppendCookie(cookie); SubmitSurveyButton.Visible = false; if (SurveyType == SurveyType.Survey) { SurveyPlaceHolder.Visible = false; if (HasViewResultsPermission) { Response.Redirect(EditUrl("SurveyResults"), false); } else { SurveyMessageLabel.Text = Localization.GetString("HasVoted.Text", LocalResourceFile); SurveyMessageLabel.CssClass = "dnnFormMessage dnnFormSuccess"; SurveyMessageLabel.Visible = true; } } else { SurveyMessageLabel.Text = Localization.GetString("QuizResults.Text", LocalResourceFile); SurveyMessageLabel.CssClass = "dnnFormMessage dnnFormSuccess"; SurveyMessageLabel.Visible = true; SurveyPlaceHolder.Controls.Clear(); DisplayQuizResults(surveys, surveyResults); } } } }
protected void Page_Load(object sender, EventArgs e) { CaptchaControl CAPTCHA = LoginUser.FindControl("CAPTCHA") as CaptchaControl; CAPTCHA.Visible = tries >= 3; }
//protected override object SaveViewState() //{ // object baseState = base.SaveViewState(); // object[] allStates = new object[3]; // allStates[0] = baseState; // allStates[1] = CaptchaHelper.EncryptString(_code, Password); // allStates[2] = this.ImageUrl; // return allStates; //} //protected override void LoadViewState(object savedState) //{ // if (savedState != null) // { // object[] myState = (object[])savedState; // if (myState[0] != null) // base.LoadViewState(myState[0]); // if (myState[1] != null) // _code = CaptchaHelper.DecryptString((string)myState[1], Password); // if (myState[2] != null) // ImageUrl = (string)myState[2]; // } //} public static CaptchaControl CreateControl(bool ignoreCase, CharSets charSets, int charCount, int width, int height, string guid) { CaptchaControl control = new CaptchaControl(ignoreCase, charSets, charCount, width, height, guid); return(control); }