diff --git a/.gitignore b/.gitignore index 913083b..af69409 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -Installs/NewsArticles.00.09.11/ -Installs/NewsArticles.00.10.00/ +InstallPackager/ diff --git a/App_LocalResources/ucViewOptions.ascx.resx b/App_LocalResources/ucViewOptions.ascx.resx index 72caad6..e28308a 100755 --- a/App_LocalResources/ucViewOptions.ascx.resx +++ b/App_LocalResources/ucViewOptions.ascx.resx @@ -112,10 +112,10 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Article Settings @@ -438,12 +438,6 @@ Comment Settings - - Check to use captcha validation on the post comment screen. - - - Use Captcha? - Check to require comments to be moderated before posting. @@ -1197,4 +1191,34 @@ Journal Group Posting + + Select the type of captcha to use on the post comment screen. + + + Captcha Type + + + Core DNN Captcha + + + Use a Honepot control + + + None + + + Google reCaptcha + + + reCaptcha Secret Key + + + reCaptcha Site Key + + + Google reCaptcha Secret Key, only needed when CaptchaType is set to reCaptcha. + + + Google reCaptcha Site Key, only needed when CaptchaType is set to reCaptcha. + \ No newline at end of file diff --git a/Components/ArticleSettings.vb b/Components/ArticleSettings.vb index 9ecf85f..86f90ce 100755 --- a/Components/ArticleSettings.vb +++ b/Components/ArticleSettings.vb @@ -57,10 +57,10 @@ Namespace Ventrian.NewsArticles Dim role As String For Each role In roles.Split(New Char() {";"c}) - If (role <> "" AndAlso Not role Is Nothing AndAlso _ - ((context.Request.IsAuthenticated = False And role = glbRoleUnauthUserName) Or _ - role = glbRoleAllUsersName Or _ - objUserInfo.IsInRole(role) = True _ + If (role <> "" AndAlso Not role Is Nothing AndAlso + ((context.Request.IsAuthenticated = False And role = glbRoleUnauthUserName) Or + role = glbRoleAllUsersName Or + objUserInfo.IsInRole(role) = True )) Then Return True End If @@ -939,12 +939,39 @@ Namespace Ventrian.NewsArticles End Get End Property - Public ReadOnly Property UseCaptcha() As Boolean + Public ReadOnly Property CaptchaType() As CaptchaType Get + Dim retval As CaptchaType = CaptchaType.None If (Settings.Contains(ArticleConstants.USE_CAPTCHA_SETTING)) Then - Return Convert.ToBoolean(Settings(ArticleConstants.USE_CAPTCHA_SETTING)) + 'there's an existing module setting, so make sure we don't change behavior for that + If Convert.ToBoolean(Settings(ArticleConstants.USE_CAPTCHA_SETTING).ToString()) Then + retval = CaptchaType.DnnCore + End If Else - Return False + If (Settings.Contains(ArticleConstants.CAPTCHATYPE_SETTING)) Then + retval = CType(System.Enum.Parse(GetType(CaptchaType), Settings(ArticleConstants.CAPTCHATYPE_SETTING)), CaptchaType) + End If + End If + Return retval + End Get + End Property + + Public ReadOnly Property ReCaptchaSiteKey() As String + Get + If Settings.ContainsKey(ArticleConstants.RECAPTCHA_SITEKEY_SETTING) Then + Return Settings(ArticleConstants.RECAPTCHA_SITEKEY_SETTING).ToString() + Else + Return "" + End If + End Get + End Property + + Public ReadOnly Property ReCaptchaSecretKey() As String + Get + If Settings.ContainsKey(ArticleConstants.RECAPTCHA_SECRETKEY_SETTING) Then + Return Settings(ArticleConstants.RECAPTCHA_SECRETKEY_SETTING).ToString() + Else + Return "" End If End Get End Property diff --git a/Components/CaptchaType.vb b/Components/CaptchaType.vb new file mode 100644 index 0000000..a5fbe13 --- /dev/null +++ b/Components/CaptchaType.vb @@ -0,0 +1,24 @@ +' +' News Articles for DotNetNuke - http://www.dotnetnuke.com +' Copyright (c) 2002-2007 +' by Ventrian ( sales@ventrian.com ) ( http://www.ventrian.com ) +' + +Imports System +Imports System.Configuration +Imports System.Data + +Imports DotNetNuke.Common.Utilities + +Namespace Ventrian.NewsArticles + + Public Enum CaptchaType + + None + DnnCore + ReCaptcha + Honeypot + + End Enum + +End Namespace diff --git a/Components/Common/ArticleConstants.vb b/Components/Common/ArticleConstants.vb index bfb22d3..4fca1a6 100755 --- a/Components/Common/ArticleConstants.vb +++ b/Components/Common/ArticleConstants.vb @@ -125,6 +125,9 @@ Namespace Ventrian.NewsArticles Public Const COMMENT_REQUIRE_NAME_SETTING As String = "CommentRequireName" Public Const COMMENT_REQUIRE_EMAIL_SETTING As String = "CommentRequireEmail" Public Const USE_CAPTCHA_SETTING As String = "UseCaptcha" + Public Const CAPTCHATYPE_SETTING As String = "CaptchaType" + Public Const RECAPTCHA_SITEKEY_SETTING As String = "reCaptchaSiteKey" + Public Const RECAPTCHA_SECRETKEY_SETTING As String = "reCaptchaSecretKey" Public Const NOTIFY_DEFAULT_SETTING As String = "NotifyDefault" Public Const COMMENT_SORT_DIRECTION_SETTING As String = "CommentSortDirection" Public Const COMMENT_AKISMET_SETTING As String = "CommentAkismet" diff --git a/Controls/Honeypot.ascx b/Controls/Honeypot.ascx new file mode 100644 index 0000000..ac7a100 --- /dev/null +++ b/Controls/Honeypot.ascx @@ -0,0 +1,7 @@ +<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="Honeypot.ascx.vb" Inherits="Ventrian.NewsArticles.Controls.Honeypot" %> +<%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %> +
+ + + +
diff --git a/Controls/Honeypot.ascx.designer.vb b/Controls/Honeypot.ascx.designer.vb new file mode 100644 index 0000000..0f455fa --- /dev/null +++ b/Controls/Honeypot.ascx.designer.vb @@ -0,0 +1,44 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Namespace Ventrian.NewsArticles.Controls + + Partial Public Class Honeypot + + ''' + '''ConfirmEmailLabel control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents ConfirmEmailLabel As Global.System.Web.UI.UserControl + + ''' + '''txtConfirmEmail control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents txtConfirmEmail As Global.System.Web.UI.WebControls.TextBox + + ''' + '''RecaptchaValidator control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents RecaptchaValidator As Global.System.Web.UI.WebControls.CustomValidator + End Class +End Namespace diff --git a/Controls/Honeypot.ascx.vb b/Controls/Honeypot.ascx.vb new file mode 100644 index 0000000..67002f6 --- /dev/null +++ b/Controls/Honeypot.ascx.vb @@ -0,0 +1,23 @@ +Imports System.IO +Imports System.Net +Imports System.Web.Script.Serialization +Imports DotNetNuke.Common.Utilities + +Namespace Ventrian.NewsArticles.Controls + Public Class Honeypot + Inherits System.Web.UI.UserControl + + Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load + + End Sub + + Protected Sub HoneypotValidator_OnServerValidate(source As Object, args As ServerValidateEventArgs) + args.IsValid = IsValid() + End Sub + + Public Function IsValid() As Boolean + Return txtConfirmEmail.Text = "" + End Function + End Class + +End Namespace \ No newline at end of file diff --git a/Controls/PostComment.ascx b/Controls/PostComment.ascx index 8ff659c..d32cd9e 100755 --- a/Controls/PostComment.ascx +++ b/Controls/PostComment.ascx @@ -1,5 +1,7 @@ <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="PostComment.ascx.vb" Inherits="Ventrian.NewsArticles.Controls.PostComment" %> <%@ Register TagPrefix="dnn" Assembly="DotNetNuke" Namespace="DotNetNuke.UI.WebControls"%> +<%@ Register TagPrefix="article" TagName="ReCaptcha" Src="ReCaptcha.ascx" %> +<%@ Register TagPrefix="article" TagName="Honeypot" Src="Honeypot.ascx" %>

@@ -25,6 +27,8 @@ controltovalidate="txtComment" errormessage="
Comment Is Required" display="Dynamic" SetFocusOnError="true" ValidationGroup="PostComment" />

+ +

diff --git a/Controls/PostComment.ascx.designer.vb b/Controls/PostComment.ascx.designer.vb index cd621de..0654a9f 100755 --- a/Controls/PostComment.ascx.designer.vb +++ b/Controls/PostComment.ascx.designer.vb @@ -11,9 +11,9 @@ Option Strict On Option Explicit On Namespace Ventrian.NewsArticles.Controls - + Partial Public Class PostComment - + ''' '''phCommentForm control. ''' @@ -22,7 +22,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents phCommentForm As Global.System.Web.UI.WebControls.PlaceHolder - + ''' '''pName control. ''' @@ -31,7 +31,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents pName As Global.System.Web.UI.HtmlControls.HtmlGenericControl - + ''' '''txtName control. ''' @@ -40,7 +40,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents txtName As Global.System.Web.UI.WebControls.TextBox - + ''' '''lblName control. ''' @@ -49,7 +49,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents lblName As Global.System.Web.UI.WebControls.Label - + ''' '''valName control. ''' @@ -58,7 +58,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents valName As Global.System.Web.UI.WebControls.RequiredFieldValidator - + ''' '''pEmail control. ''' @@ -67,7 +67,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents pEmail As Global.System.Web.UI.HtmlControls.HtmlGenericControl - + ''' '''txtEmail control. ''' @@ -76,7 +76,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents txtEmail As Global.System.Web.UI.WebControls.TextBox - + ''' '''lblEmail control. ''' @@ -85,7 +85,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents lblEmail As Global.System.Web.UI.WebControls.Label - + ''' '''valEmail control. ''' @@ -94,7 +94,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents valEmail As Global.System.Web.UI.WebControls.RequiredFieldValidator - + ''' '''valEmailIsValid control. ''' @@ -103,7 +103,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents valEmailIsValid As Global.System.Web.UI.WebControls.RegularExpressionValidator - + ''' '''pUrl control. ''' @@ -112,7 +112,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents pUrl As Global.System.Web.UI.HtmlControls.HtmlGenericControl - + ''' '''txtURL control. ''' @@ -121,7 +121,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents txtURL As Global.System.Web.UI.WebControls.TextBox - + ''' '''lblUrl control. ''' @@ -130,7 +130,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents lblUrl As Global.System.Web.UI.WebControls.Label - + ''' '''txtComment control. ''' @@ -139,7 +139,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents txtComment As Global.System.Web.UI.WebControls.TextBox - + ''' '''valComment control. ''' @@ -148,7 +148,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents valComment As Global.System.Web.UI.WebControls.RequiredFieldValidator - + ''' '''ctlCaptcha control. ''' @@ -157,7 +157,25 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents ctlCaptcha As Global.DotNetNuke.UI.WebControls.CaptchaControl - + + ''' + '''ctlReCaptcha control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents ctlReCaptcha As Global.Ventrian.NewsArticles.Controls.ReCaptcha + + ''' + '''ctlHoneypot control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents ctlHoneypot As Global.Ventrian.NewsArticles.Controls.Honeypot + ''' '''btnAddComment control. ''' @@ -166,7 +184,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents btnAddComment As Global.System.Web.UI.WebControls.Button - + ''' '''chkNotifyMe control. ''' @@ -175,7 +193,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents chkNotifyMe As Global.System.Web.UI.WebControls.CheckBox - + ''' '''phCommentPosted control. ''' @@ -184,7 +202,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents phCommentPosted As Global.System.Web.UI.WebControls.PlaceHolder - + ''' '''lblRequiresApproval control. ''' @@ -193,7 +211,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents lblRequiresApproval As Global.System.Web.UI.WebControls.Label - + ''' '''phCommentAnonymous control. ''' @@ -202,7 +220,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents phCommentAnonymous As Global.System.Web.UI.WebControls.PlaceHolder - + ''' '''lblRequiresAccess control. ''' diff --git a/Controls/PostComment.ascx.vb b/Controls/PostComment.ascx.vb index 1603f4d..6df9fe2 100755 --- a/Controls/PostComment.ascx.vb +++ b/Controls/PostComment.ascx.vb @@ -1,6 +1,7 @@ Imports DotNetNuke.Common.Utilities Imports DotNetNuke.Security Imports DotNetNuke.Services.Localization +Imports DotNetNuke.Web.Client.ClientResourceManagement Imports Joel.Net Imports Ventrian.NewsArticles.Components.Social @@ -174,7 +175,13 @@ Namespace Ventrian.NewsArticles.Controls pName.Visible = Not Request.IsAuthenticated pEmail.Visible = Not Request.IsAuthenticated pUrl.Visible = Not Request.IsAuthenticated - ctlCaptcha.Visible = (ArticleSettings.UseCaptcha And Request.IsAuthenticated = False) + + ctlCaptcha.Visible = (ArticleSettings.CaptchaType = CaptchaType.DnnCore And Request.IsAuthenticated = False) + ctlReCaptcha.Visible = (ArticleSettings.CaptchaType = CaptchaType.ReCaptcha And Request.IsAuthenticated = False) + ctlHoneypot.Visible = (ArticleSettings.CaptchaType = CaptchaType.Honeypot And Request.IsAuthenticated = False) + if ctlReCaptcha.Visible Then + ClientResourceManager.RegisterScript(Page, ResolveUrl("https://www.google.com/recaptcha/api.js")) + End If If (Request.IsAuthenticated = False) Then pUrl.Visible = Not ArticleSettings.IsCommentWebsiteHidden @@ -203,6 +210,11 @@ Namespace Ventrian.NewsArticles.Controls valComment.ValidationGroup = "PostComment-" & ArticleID.ToString() btnAddComment.ValidationGroup = "PostComment-" & ArticleID.ToString() + If ArticleSettings.IsCommentsEnabled AndAlso ArticleSettings.CaptchaType = CaptchaType.ReCaptcha Then + ctlReCaptcha.SiteKey = ArticleSettings.ReCaptchaSiteKey + ctlReCaptcha.SecretKey = ArticleSettings.ReCaptchaSecretKey + End If + If (Page.IsPostBack = False) Then GetCookie() End If @@ -220,11 +232,17 @@ Namespace Ventrian.NewsArticles.Controls Protected Sub btnAddComment_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnAddComment.Click If (Page.IsValid) Then - If (ArticleSettings.UseCaptcha And Request.IsAuthenticated = False) Then - If (ctlCaptcha.IsValid = False) Then - txtComment.Focus() - Return - End If + If (ctlCaptcha.Visible AndAlso ctlCaptcha.IsValid = False) Then + txtComment.Focus() + Return + End If + If (ctlReCaptcha.Visible AndAlso ctlReCaptcha.RecaptchaIsValid() = False) Then + txtComment.Focus() + Return + End If + If (ctlHoneypot.Visible AndAlso ctlHoneypot.IsValid() = False) Then + txtComment.Focus() + Return End If Dim objController As New ArticleController diff --git a/Controls/ReCaptcha.ascx b/Controls/ReCaptcha.ascx new file mode 100644 index 0000000..15ca25d --- /dev/null +++ b/Controls/ReCaptcha.ascx @@ -0,0 +1,9 @@ +<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ReCaptcha.ascx.vb" Inherits="Ventrian.NewsArticles.Controls.ReCaptcha" %> +<%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %> +
+
+ +
+ + +
diff --git a/Controls/ReCaptcha.ascx.designer.vb b/Controls/ReCaptcha.ascx.designer.vb new file mode 100644 index 0000000..bdfc907 --- /dev/null +++ b/Controls/ReCaptcha.ascx.designer.vb @@ -0,0 +1,44 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Namespace Ventrian.NewsArticles.Controls + + Partial Public Class ReCaptcha + + ''' + '''dummyTextBox control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents dummyTextBox As Global.System.Web.UI.WebControls.TextBox + + ''' + '''reCaptchaDiv control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents reCaptchaDiv As Global.System.Web.UI.WebControls.PlaceHolder + + ''' + '''RecaptchaValidator control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents RecaptchaValidator As Global.System.Web.UI.WebControls.CustomValidator + End Class +End Namespace diff --git a/Controls/ReCaptcha.ascx.vb b/Controls/ReCaptcha.ascx.vb new file mode 100644 index 0000000..93cf810 --- /dev/null +++ b/Controls/ReCaptcha.ascx.vb @@ -0,0 +1,65 @@ +Imports System.IO +Imports System.Net +Imports System.Web.Script.Serialization +Imports DotNetNuke.Common.Utilities + +Namespace Ventrian.NewsArticles.Controls + Public Class ReCaptcha + Inherits System.Web.UI.UserControl + + Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load + reCaptchaDiv.Controls.Clear() + reCaptchaDiv.Controls.Add(New LiteralControl($"
")) + End Sub + + public property SiteKey as String = "" + public property SecretKey as String = "" + + Protected Sub RecaptchaValidator_OnServerValidate(source As Object, args As ServerValidateEventArgs) + args.IsValid = RecaptchaIsValid() + End Sub + + Protected Function GetSiteKey() As String + return SiteKey + End Function + + Private _recaptchaisvalid As Boolean? = Nothing + Public Function RecaptchaIsValid() As Boolean + If _recaptchaisvalid.HasValue Then Return _recaptchaisvalid.Value + Dim Response As String = Request("g-recaptcha-response") + RecaptchaIsValid = False + Dim req As HttpWebRequest = CType(WebRequest.Create($"https://www.google.com/recaptcha/api/siteverify"), HttpWebRequest) + + Try + Dim postData = $"secret={SecretKey}&response={Response}" + Dim postEnc = Encoding.ASCII.GetBytes(postData) + req.Method = "POST" + req.ContentType = "application/x-www-form-urlencoded" + req.ContentLength = postEnc.Length + + Using stream = req.GetRequestStream() + stream.Write(postEnc, 0, postEnc.Length) + End Using + + Using wResponse As WebResponse = req.GetResponse() + + Using readStream As StreamReader = New StreamReader(wResponse.GetResponseStream()) + Dim jsonResponse As String = readStream.ReadToEnd() + Dim js As JavaScriptSerializer = New JavaScriptSerializer() + Dim data As RecaptchaResponse = js.Deserialize(Of RecaptchaResponse)(jsonResponse) + _recaptchaisvalid = Convert.ToBoolean(data.success) + End Using + End Using + + Catch ex As WebException + Throw ex + End Try + + Return _recaptchaisvalid.Value + End Function + End Class + public class RecaptchaResponse + public Property success As String + End Class + +End Namespace \ No newline at end of file diff --git a/Installs/NewsArticles.00.11.00.zip b/Installs/NewsArticles.00.11.00.zip new file mode 100644 index 0000000..9451ec8 Binary files /dev/null and b/Installs/NewsArticles.00.11.00.zip differ diff --git a/NewsArticles.dnn b/NewsArticles.dnn index baa6723..84fc922 100755 --- a/NewsArticles.dnn +++ b/NewsArticles.dnn @@ -1,6 +1,6 @@ - + News Articles Allows you to publish News Articles to your portal. @@ -860,7 +860,7 @@ - + News Articles Latest Allows you to display a list of the latest articles. @@ -921,7 +921,7 @@ - + News Articles Comments Allows you to display a list of the latest comments. @@ -982,7 +982,7 @@ - + News Articles Archives Allows you to display a list of articles by month. @@ -1043,7 +1043,7 @@ - + News Articles Search Allows you to display a list of articles by month. diff --git a/Ventrian.NewsArticles.vbproj b/Ventrian.NewsArticles.vbproj index 439ec85..224eaa4 100755 --- a/Ventrian.NewsArticles.vbproj +++ b/Ventrian.NewsArticles.vbproj @@ -152,6 +152,7 @@ + @@ -164,6 +165,20 @@ + + Honeypot.ascx + + + Honeypot.ascx + ASPXCodeBehind + + + ReCaptcha.ascx + + + ReCaptcha.ascx + ASPXCodeBehind + @@ -674,6 +689,8 @@ Designer + + diff --git a/ucViewOptions.ascx b/ucViewOptions.ascx index 9b7cd5f..be4eccc 100755 --- a/ucViewOptions.ascx +++ b/ucViewOptions.ascx @@ -197,9 +197,23 @@ - - + + + + + + + + + + + + + + + + diff --git a/ucViewOptions.ascx.designer.vb b/ucViewOptions.ascx.designer.vb index 4ab0bef..efc1c4f 100755 --- a/ucViewOptions.ascx.designer.vb +++ b/ucViewOptions.ascx.designer.vb @@ -681,22 +681,58 @@ Namespace Ventrian.NewsArticles Protected WithEvents chkEnableCommentModeration As Global.System.Web.UI.WebControls.CheckBox ''' - '''plUseCaptcha control. + '''plCaptchaType control. ''' ''' '''Auto-generated field. '''To modify move field declaration from designer file to code-behind file. ''' - Protected WithEvents plUseCaptcha As Global.System.Web.UI.UserControl + Protected WithEvents plCaptchaType As Global.System.Web.UI.UserControl ''' - '''chkUseCaptcha control. + '''drpCaptchaType control. ''' ''' '''Auto-generated field. '''To modify move field declaration from designer file to code-behind file. ''' - Protected WithEvents chkUseCaptcha As Global.System.Web.UI.WebControls.CheckBox + Protected WithEvents drpCaptchaType As Global.System.Web.UI.WebControls.DropDownList + + ''' + '''plReCaptchaSiteKey control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents plReCaptchaSiteKey As Global.System.Web.UI.UserControl + + ''' + '''txtReCaptchaSiteKey control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents txtReCaptchaSiteKey As Global.System.Web.UI.WebControls.TextBox + + ''' + '''plReCaptchaSecretKey control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents plReCaptchaSecretKey As Global.System.Web.UI.UserControl + + ''' + '''txtReCaptchaSecretKey control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents txtReCaptchaSecretKey As Global.System.Web.UI.WebControls.TextBox ''' '''plHideWebsite control. diff --git a/ucViewOptions.ascx.vb b/ucViewOptions.ascx.vb index 385bc54..8b69af9 100755 --- a/ucViewOptions.ascx.vb +++ b/ucViewOptions.ascx.vb @@ -26,7 +26,7 @@ Namespace Ventrian.NewsArticles Partial Public Class ucViewOptions Inherits NewsArticleModuleBase - + ''' '''ctlWatermarkImage control. ''' @@ -132,6 +132,17 @@ Namespace Ventrian.NewsArticles End Sub + Private Sub BindCaptchaTypes() + + For Each value As Integer In System.Enum.GetValues(GetType(CaptchaType)) + Dim li As New ListItem + li.Value = System.Enum.GetName(GetType(CaptchaType), value) + li.Text = Localization.GetString($"CaptchaType{System.Enum.GetName(GetType(CaptchaType), value)}", Me.LocalResourceFile) + drpCaptchaType.Items.Add(li) + Next + + End Sub + Private Sub BindRelatedTypes() For Each value As Integer In System.Enum.GetValues(GetType(RelatedType)) @@ -587,10 +598,26 @@ Namespace Ventrian.NewsArticles chkRequireEmail.Checked = True End If + Dim selectCaptchaType As CaptchaType = CaptchaType.None If (Settings.Contains(ArticleConstants.USE_CAPTCHA_SETTING)) Then - chkUseCaptcha.Checked = Convert.ToBoolean(Settings(ArticleConstants.USE_CAPTCHA_SETTING).ToString()) + 'there's an existing module setting, so make sure we don't change behavior for that + If Convert.ToBoolean(Settings(ArticleConstants.USE_CAPTCHA_SETTING).ToString()) Then + selectCaptchaType = CaptchaType.DnnCore + End If Else - chkUseCaptcha.Checked = False + If (Settings.Contains(ArticleConstants.CAPTCHATYPE_SETTING)) Then + selectCaptchaType = CType(System.Enum.Parse(GetType(CaptchaType), Settings(ArticleConstants.CAPTCHATYPE_SETTING)), CaptchaType) + End If + End If + Dim selectedItem As ListItem = drpCaptchaType.Items.FindByValue(selectCaptchaType.ToString()) + drpCaptchaType.SelectedIndex = drpCaptchaType.Items.IndexOf(selectedItem) + + If (Settings.Contains(ArticleConstants.RECAPTCHA_SITEKEY_SETTING)) Then + txtReCaptchaSiteKey.Text = Settings(ArticleConstants.RECAPTCHA_SITEKEY_SETTING).ToString() + End If + + If (Settings.Contains(ArticleConstants.RECAPTCHA_SECRETKEY_SETTING)) Then + txtReCaptchaSecretKey.Text = Settings(ArticleConstants.RECAPTCHA_SECRETKEY_SETTING).ToString() End If If (Settings.Contains(ArticleConstants.NOTIFY_DEFAULT_SETTING)) Then @@ -619,7 +646,13 @@ Namespace Ventrian.NewsArticles objModules.UpdateTabModuleSetting(TabModuleId, ArticleConstants.COMMENT_HIDE_WEBSITE_SETTING, chkHideWebsite.Checked.ToString()) objModules.UpdateTabModuleSetting(TabModuleId, ArticleConstants.COMMENT_REQUIRE_NAME_SETTING, chkRequireName.Checked.ToString()) objModules.UpdateTabModuleSetting(TabModuleId, ArticleConstants.COMMENT_REQUIRE_EMAIL_SETTING, chkRequireEmail.Checked.ToString()) - objModules.UpdateTabModuleSetting(TabModuleId, ArticleConstants.USE_CAPTCHA_SETTING, chkUseCaptcha.Checked.ToString()) + 'This is only for upgraded modules + If Settings.ContainsKey(ArticleConstants.USE_CAPTCHA_SETTING) Then + objModules.DeleteTabModuleSetting(TabModuleId, ArticleConstants.USE_CAPTCHA_SETTING) + End If + objModules.UpdateTabModuleSetting(TabModuleId, ArticleConstants.CAPTCHATYPE_SETTING, drpCaptchaType.SelectedValue) + objModules.UpdateTabModuleSetting(TabModuleId, ArticleConstants.RECAPTCHA_SITEKEY_SETTING, txtReCaptchaSiteKey.Text) + objModules.UpdateTabModuleSetting(TabModuleId, ArticleConstants.RECAPTCHA_SECRETKEY_SETTING, txtReCaptchaSecretKey.Text) objModules.UpdateTabModuleSetting(TabModuleId, ArticleConstants.NOTIFY_DEFAULT_SETTING, chkNotifyDefault.Checked.ToString()) objModules.UpdateTabModuleSetting(TabModuleId, ArticleConstants.COMMENT_SORT_DIRECTION_SETTING, drpSortDirectionComments.SelectedValue) objModules.UpdateModuleSetting(ModuleId, ArticleConstants.COMMENT_AKISMET_SETTING, txtAkismetKey.Text) @@ -1570,6 +1603,7 @@ Namespace Ventrian.NewsArticles BindCategorySortOrder() BindDisplayTypes() + BindCaptchaTypes() BindAuthorSelection() BindTextEditorMode() BindPageSize()