public static string GenerateCaptcha(this HtmlHelper helper) { // Check the EnableCaptchaForComments setting if the captcha is enabled TemplateContentModel model = helper.ViewData.Model as TemplateContentModel; if (!model.Site.EnableCaptchaForComments) return string.Empty; // check if the keys are configured if (string.IsNullOrEmpty(model.Site.CaptchaPublicKey) || string.IsNullOrEmpty(model.Site.CaptchaPrivateKey)) return string.Empty; var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = "white", PublicKey = model.Site.CaptchaPublicKey, PrivateKey = model.Site.CaptchaPrivateKey }; var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderControl(htmlWriter); return string.Format("<div>{0}</div>", htmlWriter.InnerWriter.ToString()); }
public static IHtmlString GenerateCaptcha(this HtmlHelper helper, string id = "recaptcha", string theme = "blackglass") { var publicKey = ConfigurationManager.AppSettings["recaptcha.publicKey"]; var privateKey = ConfigurationManager.AppSettings["recaptcha.privateKey"]; if (String.IsNullOrEmpty(publicKey)) { throw new ConfigurationErrorsException("The key 'recaptcha.publicKey' must be defined in your config file"); } if (String.IsNullOrEmpty(privateKey)) { throw new ConfigurationErrorsException("The key 'recaptcha.privateKey' must be defined in your config file"); } var captchaControl = new Recaptcha.RecaptchaControl { ID = id, Theme = theme, PublicKey = publicKey, PrivateKey = privateKey }; var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderControl(htmlWriter); return(helper.Raw(htmlWriter.InnerWriter.ToString())); }
public static string GenerateCaptcha(this HtmlHelper helper, string id, string theme, string language, short?tabIndex) { if (string.IsNullOrEmpty(publicKey) || string.IsNullOrEmpty(privateKey)) { throw new ApplicationException("reCAPTCHA needs to be configured with a public & private key."); } var captchaControl = new Recaptcha.RecaptchaControl(); captchaControl.ID = id; captchaControl.Theme = theme; if (!string.IsNullOrEmpty(language)) { captchaControl.Language = language; } if (tabIndex.HasValue) { captchaControl.TabIndex = tabIndex.Value; } captchaControl.SiteKey = publicKey; captchaControl.SecretKey = privateKey; captchaControl.OverrideSecureMode = overrideSecureMode; var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderControl(htmlWriter); return(htmlWriter.InnerWriter.ToString()); }
public static IHtmlString GenerateCaptcha(this HtmlHelper helper, string id = "recaptcha", string theme = "blackglass") { var publicKey = ConfigurationManager.AppSettings["recaptcha.publicKey"]; var privateKey = ConfigurationManager.AppSettings["recaptcha.privateKey"]; if (String.IsNullOrEmpty(publicKey)) throw new ConfigurationErrorsException("The key 'recaptcha.publicKey' must be defined in your config file"); if (String.IsNullOrEmpty(privateKey)) throw new ConfigurationErrorsException("The key 'recaptcha.privateKey' must be defined in your config file"); var captchaControl = new Recaptcha.RecaptchaControl { ID = id, Theme = theme, PublicKey = publicKey, PrivateKey = privateKey }; var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderControl(htmlWriter); return helper.Raw(htmlWriter.InnerWriter.ToString()); }
public static Recaptcha.RecaptchaControl NewRecaptchControl() { Recaptcha.RecaptchaControl control = new Recaptcha.RecaptchaControl(); control.PrivateKey = AppSettings.RecaptchaPrivateKey; control.PublicKey = AppSettings.RecaptchaPublicKey; control.Theme = "clean"; return(control); }
public static Recaptcha.RecaptchaControl NewRecaptchControl() { Recaptcha.RecaptchaControl control = new Recaptcha.RecaptchaControl(); control.PrivateKey = AppSettings.RecaptchaPrivateKey; control.PublicKey = AppSettings.RecaptchaPublicKey; control.Theme = "clean"; return control; }
/// <summary> /// Write a Captcha out as part of a form on a page. /// </summary> public static void Render(TextWriter writer) { var captcha = new Recaptcha.RecaptchaControl(); captcha.OverrideSecureMode = true; captcha.Theme = "clean"; writer.Write(@"<div class=""captcha"">"); writer.Write(captcha.RenderControl()); writer.Write("</div>"); }
protected void uxRecaptcha_Init(object sender, EventArgs e) { Recaptcha.RecaptchaControl recaptcha = sender as Recaptcha.RecaptchaControl; if (recaptcha != null) { recaptcha.PublicKey = Settings.ReCaptchaPublicKey; recaptcha.PrivateKey = Settings.ReCaptchaPrivateKey; } lblCaptcha.Text = Sitecore.Modules.WeBlog.Globalization.Translator.Render("CAPTCHA"); }
/// <summary> /// Write a Captcha out as part of a form on a page. /// </summary> public static void Render(TextWriter writer) { var captcha = new Recaptcha.RecaptchaControl(); captcha.OverrideSecureMode = true; captcha.Theme = "clean"; writer.Write(@"<div class=""captcha"">"); writer.Write(captcha.RenderControl()); writer.Write("</div>"); }
public static string GenerateCaptcha(this HtmlHelper helper) { var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = "white", PublicKey = "key", PrivateKey = "key" }; var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderControl(htmlWriter); return htmlWriter.InnerWriter.ToString(); }
public static string GenerateCaptcha() { var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = "blackglass", PublicKey = "6LcPJMYSAAAAAOJpX1mzOgwRGYAL7MabbzGm4DZ9", PrivateKey = "6LcPJMYSAAAAAN5fSA_9ZaCZu7Yjqj1j9_kzSIri " }; var htmlWriter = new HtmlTextWriter( new StringWriter() ); captchaControl.RenderControl(htmlWriter); return htmlWriter.InnerWriter.ToString(); }
public static Recaptcha.RecaptchaControl NewRecaptchControl() { Recaptcha.RecaptchaControl control = new Recaptcha.RecaptchaControl(); control.PrivateKey = AppSettings.RecaptchaPrivateKey; control.PublicKey = AppSettings.RecaptchaPublicKey; control.Theme = "clean"; if (!Context.Request.IsSecureConnection) { var forwarded = Context.Request.Headers["X-Forwarded-Proto"]; control.OverrideSecureMode = forwarded != null && forwarded.StartsWith("https"); } return(control); }
public static string GenerateCaptcha( this HtmlHelper helper ) { var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = "clean", PublicKey = "6LcjU7oSAAAAAAc4zWAykYP1DuNCFknEb3jHxxpt", PrivateKey = "6LcjU7oSAAAAAJ1OFv9iogMBGPrH6q9VlZzamYM_" }; var htmlWriter = new HtmlTextWriter( new StringWriter() ); captchaControl.RenderControl( htmlWriter ); return htmlWriter.InnerWriter.ToString(); }
public static string GenerateCaptcha(this HtmlHelper helper) { var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = "white", PublicKey = "6LcjK8oSAAAAAAW92XPXyniHkitfgN5YR6EajTau", PrivateKey = "6LcjK8oSAAAAAFGassCSJXzZEtBR-_0rhk5jHUD2" }; var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderControl(htmlWriter); return htmlWriter.InnerWriter.ToString(); }
public static Recaptcha.RecaptchaControl NewRecaptchControl() { Recaptcha.RecaptchaControl control = new Recaptcha.RecaptchaControl(); control.PrivateKey = AppSettings.RecaptchaPrivateKey; control.PublicKey = AppSettings.RecaptchaPublicKey; control.Theme = "clean"; if (!Context.Request.IsSecureConnection) { var forwarded = Context.Request.Headers["X-Forwarded-Proto"]; control.OverrideSecureMode = forwarded != null && forwarded.StartsWith("https"); } return control; }
public static IHtmlString GenerateCaptcha( this HtmlHelper helper ) { var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = "white", PublicKey = "6LfjpuYSAAAAANd5R5xdCChdOF2-k2BrmihtltFD", PrivateKey = "6LfjpuYSAAAAALlkGasw_Sp37gdrLN4toyB-LmQO" }; var htmlWriter = new HtmlTextWriter( new StringWriter() ); captchaControl.RenderControl(htmlWriter); return new MvcHtmlString(htmlWriter.InnerWriter.ToString()); }
public static string GenerateCaptcha(this HtmlHelper helper) { var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = "clean", PublicKey = ConfigurationManager.AppSettings["RecaptchaPublicKey"], PrivateKey = ConfigurationManager.AppSettings["RecaptchaPrivateKey"] }; var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderControl(htmlWriter); return(htmlWriter.InnerWriter.ToString()); }
public static string GenerateCaptcha(this HtmlHelper helper) { var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = "blackglass", PublicKey = WebConfigurationManager.AppSettings["CaptchaPublicKey"], PrivateKey = WebConfigurationManager.AppSettings["CaptchaPrivateKey"] }; var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderControl(htmlWriter); return htmlWriter.InnerWriter.ToString(); }
public static IHtmlString GenerateCaptcha(this HtmlHelper helper) { var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = "white", PublicKey = "6LfjpuYSAAAAANd5R5xdCChdOF2-k2BrmihtltFD", PrivateKey = "6LfjpuYSAAAAALlkGasw_Sp37gdrLN4toyB-LmQO" }; var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderControl(htmlWriter); return(new MvcHtmlString(htmlWriter.InnerWriter.ToString())); }
public static MvcHtmlString GenerateCaptcha(this HtmlHelper helper) { var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = "clean", PublicKey = MvcApplication.CaptchaPublicKey, PrivateKey = MvcApplication.CaptchaPrivateKey, Language = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName }; var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderControl(htmlWriter); return(new MvcHtmlString(htmlWriter.InnerWriter.ToString())); }
public static string GenerateCaptcha(this HtmlHelper helper) { var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = "clean", PublicKey = "6Lc-KwYAAAAAAOroQBwfMBz1rHzwi1ZlKtsmKPuj", PrivateKey = "6Lc-KwYAAAAAANt8fE-8H3KtrFClNIz4f5FSqG4p" }; using (var htmlWriter = new HtmlTextWriter(new StringWriter(System.Globalization.CultureInfo.InvariantCulture))) { captchaControl.RenderControl(htmlWriter); return htmlWriter.InnerWriter.ToString(); } }
public static string GenerateCaptcha(this HtmlHelper helper) { var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = "blackglass", PublicKey = "6Lcx9xQTAAAAAC-Wiks3ZEVAlelIewCTzfPbPrRK", PrivateKey = "6Lcx9xQTAAAAANDEAaVhJO686nDs9WZfqI-fgoxp" }; var htmlWriter = new HtmlTextWriter( new StringWriter() ); captchaControl.RenderControl(htmlWriter); return htmlWriter.InnerWriter.ToString(); }
public static string GenerateCaptcha(this HtmlHelper helper) { var captchaSettings = EngineContext.Current.Resolve <CaptchaSettings>(); var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = "blackglass", PublicKey = captchaSettings.ReCaptchaPublicKey, PrivateKey = captchaSettings.ReCaptchaPrivateKey }; var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderControl(htmlWriter); return(htmlWriter.InnerWriter.ToString()); }
public static string GenerateCaptcha(this HtmlHelper helper) { var captchaSettings = EngineContext.Current.Resolve<CaptchaSettings>(); var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = "blackglass", PublicKey = captchaSettings.ReCaptchaPublicKey, PrivateKey = captchaSettings.ReCaptchaPrivateKey }; var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderControl(htmlWriter); return htmlWriter.InnerWriter.ToString(); }
public static string GenerateCaptcha(this HtmlHelper helper) { var captchaSettings = EngineContext.Current.Resolve<CaptchaSettings>(); var theme = !string.IsNullOrEmpty(captchaSettings.ReCaptchaTheme) ? captchaSettings.ReCaptchaTheme : "white"; var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = theme, PublicKey = captchaSettings.ReCaptchaPublicKey, PrivateKey = captchaSettings.ReCaptchaPrivateKey }; var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderControl(htmlWriter); return htmlWriter.InnerWriter.ToString(); }
public static string GenerateCaptcha(this HtmlHelper helper) { var captchaSettings = EngineContext.Current.Resolve <CaptchaSettings>(); var theme = !string.IsNullOrEmpty(captchaSettings.ReCaptchaTheme) ? captchaSettings.ReCaptchaTheme : "white"; var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = theme, PublicKey = captchaSettings.ReCaptchaPublicKey, PrivateKey = captchaSettings.ReCaptchaPrivateKey }; var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderControl(htmlWriter); return(htmlWriter.InnerWriter.ToString()); }
public static MvcHtmlString GenerateCaptcha(this HtmlHelper helper) { var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = "blackglass", PublicKey = "6LeAousSAAAAAMbaNyGD8d9jw7ideZey5vhBjHYu", PrivateKey = "6LeAousSAAAAADqiHv12jipV3AsBUrJ9DJuUaQId", }; captchaControl.OverrideSecureMode = true; var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderBeginTag(htmlWriter); captchaControl.RenderControl(htmlWriter); captchaControl.RenderEndTag(htmlWriter); return(MvcHtmlString.Create(htmlWriter.InnerWriter.ToString())); }
public static MvcHtmlString GenerateCaptcha(this HtmlHelper helper ) { var pubicKey = ConfigurationManager.AppSettings["RecaptchaPublic"]; var privateKey = ConfigurationManager.AppSettings["RecaptchaPrivate"]; var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = "clean", PublicKey = pubicKey, PrivateKey = privateKey }; var htmlWriter = new HtmlTextWriter( new StringWriter() ); captchaControl.RenderControl(htmlWriter); return new MvcHtmlString(htmlWriter.InnerWriter.ToString()); }
public static string GenerateCaptcha(this HtmlHelper helper) { var theme = "white"; var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = theme, //PublicKey = "6LdIPB4TAAAAAAPFVf_js9wSQ5mBVQ-n0RqdmUc7", //PrivateKey = "6LdIPB4TAAAAAJ3UVZFyyY9mI3DBELNFjw-ODTp7" PublicKey = "6LekyyATAAAAAHneVo8dcKkx4D7fff865X3bHNTg", PrivateKey = "6LekyyATAAAAAABSNFkB4B0gp0FE9d4JA2MtyQU7" }; var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderControl(htmlWriter); return htmlWriter.InnerWriter.ToString(); }
public static string GenerateCaptcha(this HtmlHelper helper) { var theme = "white"; var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", Theme = theme, //PublicKey = "6LdIPB4TAAAAAAPFVf_js9wSQ5mBVQ-n0RqdmUc7", //PrivateKey = "6LdIPB4TAAAAAJ3UVZFyyY9mI3DBELNFjw-ODTp7" PublicKey = "6LekyyATAAAAAHneVo8dcKkx4D7fff865X3bHNTg", PrivateKey = "6LekyyATAAAAAABSNFkB4B0gp0FE9d4JA2MtyQU7" }; var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderControl(htmlWriter); return(htmlWriter.InnerWriter.ToString()); }
public string GenerateCaptcha() { _captchaSettings = _orchardServices.WorkContext.CurrentSite.As <CaptchaSettingsPart>(); var CurrentCulture = _orchardServices.WorkContext.CurrentCulture; if (_captchaSettings == null) { return("CAPTCHA Part Record Was Not Found"); } var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", PublicKey = _captchaSettings.PublicKey, PrivateKey = _captchaSettings.PrivateKey, Theme = _captchaSettings.Theme, Language = CurrentCulture.Substring(0, 2) }; string captchaMarkup; if (captchaControl.Theme.ToLower() != "custom") { var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderControl(htmlWriter); captchaMarkup = htmlWriter.InnerWriter.ToString(); } else { if (_captchaSettings.CustomCaptchaMarkup != string.Empty) { captchaMarkup = _captchaSettings.CustomCaptchaMarkup; } else { captchaMarkup = "<script type=\"text/javascript\">var RecaptchaOptions = {theme: 'custom', custom_theme_widget: 'recaptcha_widget', lang: '" + CurrentCulture.Substring(0, 2) + "' };</script>"; captchaMarkup += "<div id=\"recaptcha_widget\" style=\"display:none\"><div id=\"recaptcha_image\"></div><div class=\"recaptcha_only_if_incorrect_sol\">" + T("Incorrect please try again") + "</div><span class=\"recaptcha_only_if_image\">" + T("Enter the words above") + "</span><span class=\"recaptcha_only_if_audio\">" + T("Enter the numbers you hear:") + "</span><input type=\"text\" id=\"recaptcha_response_field\" name=\"recaptcha_response_field\" /><div><a href=\"javascript:Recaptcha.reload()\">" + T("Get another CAPTCHA") + "</a></div><div class=\"recaptcha_only_if_image\"><a href=\"javascript:Recaptcha.switch_type('audio')\">" + @T("Get an audio CAPTCHA") + "</a></div><div class=\"recaptcha_only_if_audio\"><a href=\"javascript:Recaptcha.switch_type('image')\">" + @T("Get an image CAPTCHA") + "</a></div><div><a href=\"javascript:Recaptcha.showhelp()\">Help</a></div></div><script type=\"text/javascript\" src=\"http://www.google.com/recaptcha/api/challenge?k=" + captchaControl.PublicKey + "\"></script><noscript><iframe src=\"http://www.google.com/recaptcha/api/noscript?k=" + captchaControl.PublicKey + "\" height=\"300\" width=\"500\" frameborder=\"0\"></iframe><br><textarea name=\"recaptcha_challenge_field\" rows=\"3\" cols=\"40\"></textarea><input type=\"hidden\" name=\"recaptcha_response_field\" value=\"manual_challenge\"></noscript>"; } } return(captchaMarkup); }
public string GenerateCaptcha() { if (CaptchaPart == null) { return "CAPTCHA Part Record Was Not Found"; } var captchaControl = new Recaptcha.RecaptchaControl { ID = "recaptcha", PublicKey = CaptchaPart.PublicKey, PrivateKey = CaptchaPart.PrivateKey, Theme = CaptchaPart.Theme, Language = CurrentCulture.Substring(0, 2) }; string captchaMarkup; if (captchaControl.Theme.ToLower() != "custom") { var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderControl(htmlWriter); captchaMarkup = htmlWriter.InnerWriter.ToString(); } else { if (CaptchaPart.CustomCaptchaMarkup != string.Empty) { captchaMarkup = CaptchaPart.CustomCaptchaMarkup; } else { captchaMarkup = "<script type=\"text/javascript\">var RecaptchaOptions = {theme: 'custom', custom_theme_widget: 'recaptcha_widget', lang: '" + CurrentCulture.Substring(0, 2) + "' };</script>"; captchaMarkup += "<div id=\"recaptcha_widget\" style=\"display:none\"><div id=\"recaptcha_image\"></div><div class=\"recaptcha_only_if_incorrect_sol\">" + T("Incorrect please try again") + "</div><span class=\"recaptcha_only_if_image\">" + T("Enter the words above") + "</span><span class=\"recaptcha_only_if_audio\">" + T("Enter the numbers you hear:") + "</span><input type=\"text\" id=\"recaptcha_response_field\" name=\"recaptcha_response_field\" /><div><a href=\"javascript:Recaptcha.reload()\">" + T("Get another CAPTCHA") + "</a></div><div class=\"recaptcha_only_if_image\"><a href=\"javascript:Recaptcha.switch_type('audio')\">" + @T("Get an audio CAPTCHA") + "</a></div><div class=\"recaptcha_only_if_audio\"><a href=\"javascript:Recaptcha.switch_type('image')\">" + @T("Get an image CAPTCHA") + "</a></div><div><a href=\"javascript:Recaptcha.showhelp()\">Help</a></div></div><script type=\"text/javascript\" src=\"http://www.google.com/recaptcha/api/challenge?k=" + captchaControl.PublicKey + "\"></script><noscript><iframe src=\"http://www.google.com/recaptcha/api/noscript?k=" + captchaControl.PublicKey + "\" height=\"300\" width=\"500\" frameborder=\"0\"></iframe><br><textarea name=\"recaptcha_challenge_field\" rows=\"3\" cols=\"40\"></textarea><input type=\"hidden\" name=\"recaptcha_response_field\" value=\"manual_challenge\"></noscript>"; } } return captchaMarkup; }
public static string GenerateCaptcha(this HtmlHelper helper, string id, string theme, string language, short? tabIndex) { if (string.IsNullOrEmpty(publicKey) || string.IsNullOrEmpty(privateKey)) { throw new ApplicationException("reCAPTCHA needs to be configured with a public & private key."); } var captchaControl = new Recaptcha.RecaptchaControl(); captchaControl.ID = id; captchaControl.Theme = theme; if (!string.IsNullOrEmpty(language)) captchaControl.Language = language; if (tabIndex.HasValue) captchaControl.TabIndex = tabIndex.Value; captchaControl.PublicKey = publicKey; captchaControl.PrivateKey = privateKey; captchaControl.OverrideSecureMode = overrideSecureMode; var htmlWriter = new HtmlTextWriter(new StringWriter()); captchaControl.RenderControl(htmlWriter); return htmlWriter.InnerWriter.ToString(); }