diff --git a/App_LocalResources/ucViewOptions.ascx.resx b/App_LocalResources/ucViewOptions.ascx.resx index f3e54ac..5873c8c 100755 --- a/App_LocalResources/ucViewOptions.ascx.resx +++ b/App_LocalResources/ucViewOptions.ascx.resx @@ -1221,4 +1221,10 @@ Google reCaptcha Site Key, only needed when CaptchaType is set to reCaptcha. + + Allow Portal files? + + + Check to allow portal files to be associated with articles. + \ No newline at end of file diff --git a/Components/ArticleSettings.vb b/Components/ArticleSettings.vb index 86f90ce..e0ee676 100755 --- a/Components/ArticleSettings.vb +++ b/Components/ArticleSettings.vb @@ -355,6 +355,16 @@ Namespace Ventrian.NewsArticles End If End Get End Property + + Public ReadOnly Property EnablePortalFiles() As Boolean + Get + If (Settings.Contains(ArticleConstants.ENABLE_PORTAL_FILES_SETTING)) Then + Return Convert.ToBoolean(Settings(ArticleConstants.ENABLE_PORTAL_FILES_SETTING).ToString()) + Else + Return True + End If + End Get + End Property Public ReadOnly Property EnableActiveSocialFeed() As Boolean Get diff --git a/Components/Common/ArticleConstants.vb b/Components/Common/ArticleConstants.vb index 4fca1a6..14f3048 100755 --- a/Components/Common/ArticleConstants.vb +++ b/Components/Common/ArticleConstants.vb @@ -69,6 +69,7 @@ Namespace Ventrian.NewsArticles Public Const ENABLE_PORTAL_IMAGES_SETTING As String = "EnableImages" Public Const DEFAULT_IMAGES_FOLDER_SETTING As String = "DefaultImagesFolder" Public Const DEFAULT_FILES_FOLDER_SETTING As String = "DefaultFilesFolder" + Public Const ENABLE_PORTAL_FILES_SETTING As String = "EnablePortalFiles" Public Const IMAGE_RESIZE_SETTING As String = "ResizeImages" Public Const IMAGE_THUMBNAIL_SETTING As String = "ImageThumbnailType" Public Const IMAGE_MAX_WIDTH_SETTING As String = "ImageMaxWidth" diff --git a/Controls/Honeypot.ascx b/Controls/Honeypot.ascx deleted file mode 100644 index ac7a100..0000000 --- a/Controls/Honeypot.ascx +++ /dev/null @@ -1,7 +0,0 @@ -<%@ 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 deleted file mode 100644 index 0f455fa..0000000 --- a/Controls/Honeypot.ascx.designer.vb +++ /dev/null @@ -1,44 +0,0 @@ -'------------------------------------------------------------------------------ -' -' 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 deleted file mode 100644 index 67002f6..0000000 --- a/Controls/Honeypot.ascx.vb +++ /dev/null @@ -1,23 +0,0 @@ -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 d32cd9e..e107871 100755 --- a/Controls/PostComment.ascx +++ b/Controls/PostComment.ascx @@ -1,7 +1,5 @@ -<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="PostComment.ascx.vb" Inherits="Ventrian.NewsArticles.Controls.PostComment" %> +<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="PostComment.ascx.vb" Inherits="Ventrian.NewsArticles.Controls.PostComment" ClassName="NewsArticlesPostCommentControl" %> <%@ 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" %>

@@ -27,8 +25,20 @@ 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 0654a9f..9f3dbae 100755 --- a/Controls/PostComment.ascx.designer.vb +++ b/Controls/PostComment.ascx.designer.vb @@ -165,7 +165,34 @@ Namespace Ventrian.NewsArticles.Controls '''Auto-generated field. '''To modify move field declaration from designer file to code-behind file. ''' - Protected WithEvents ctlReCaptcha As Global.Ventrian.NewsArticles.Controls.ReCaptcha + Protected WithEvents ctlReCaptcha As Global.System.Web.UI.HtmlControls.HtmlGenericControl + + ''' + '''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 ''' '''ctlHoneypot control. @@ -174,7 +201,34 @@ Namespace Ventrian.NewsArticles.Controls '''Auto-generated field. '''To modify move field declaration from designer file to code-behind file. ''' - Protected WithEvents ctlHoneypot As Global.Ventrian.NewsArticles.Controls.Honeypot + Protected WithEvents ctlHoneypot As Global.System.Web.UI.HtmlControls.HtmlGenericControl + + ''' + '''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.WebControls.Label + + ''' + '''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 + + ''' + '''HoneypotValidator control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents HoneypotValidator As Global.System.Web.UI.WebControls.CustomValidator ''' '''btnAddComment control. diff --git a/Controls/PostComment.ascx.vb b/Controls/PostComment.ascx.vb index 6df9fe2..4474488 100755 --- a/Controls/PostComment.ascx.vb +++ b/Controls/PostComment.ascx.vb @@ -1,4 +1,7 @@ -Imports DotNetNuke.Common.Utilities +Imports System.IO +Imports System.Net +Imports System.Web.Script.Serialization +Imports DotNetNuke.Common.Utilities Imports DotNetNuke.Security Imports DotNetNuke.Services.Localization Imports DotNetNuke.Web.Client.ClientResourceManagement @@ -177,10 +180,12 @@ Namespace Ventrian.NewsArticles.Controls pUrl.Visible = Not Request.IsAuthenticated 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) + ctlReCaptcha.Visible = (ArticleSettings.CaptchaType = CaptchaType.ReCaptcha And Request.IsAuthenticated = False) if ctlReCaptcha.Visible Then ClientResourceManager.RegisterScript(Page, ResolveUrl("https://www.google.com/recaptcha/api.js")) + reCaptchaDiv.Controls.Clear() + reCaptchaDiv.Controls.Add(New LiteralControl($"
")) End If If (Request.IsAuthenticated = False) Then @@ -200,6 +205,11 @@ Namespace Ventrian.NewsArticles.Controls Return End If + If ArticleSettings.IsCommentsEnabled AndAlso ArticleSettings.CaptchaType = CaptchaType.ReCaptcha Then + SiteKey = ArticleSettings.ReCaptchaSiteKey + SecretKey = ArticleSettings.ReCaptchaSecretKey + End If + CheckSecurity() AssignLocalization() SetVisibility() @@ -210,11 +220,6 @@ 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 @@ -236,11 +241,11 @@ Namespace Ventrian.NewsArticles.Controls txtComment.Focus() Return End If - If (ctlReCaptcha.Visible AndAlso ctlReCaptcha.RecaptchaIsValid() = False) Then + If (ctlReCaptcha.Visible AndAlso RecaptchaIsValid() = False) Then txtComment.Focus() Return End If - If (ctlHoneypot.Visible AndAlso ctlHoneypot.IsValid() = False) Then + If (ctlHoneypot.Visible AndAlso HoneypotIsValid() = False) Then txtComment.Focus() Return End If @@ -530,7 +535,64 @@ Namespace Ventrian.NewsArticles.Controls End Sub #End Region + + 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 + + Protected Sub HoneypotValidator_OnServerValidate(source As Object, args As ServerValidateEventArgs) + args.IsValid = HoneyPotIsValid() + End Sub + + Public Function HoneyPotIsValid() As Boolean + Return txtConfirmEmail.Text = "" + 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/Controls/ReCaptcha.ascx b/Controls/ReCaptcha.ascx deleted file mode 100644 index 15ca25d..0000000 --- a/Controls/ReCaptcha.ascx +++ /dev/null @@ -1,9 +0,0 @@ -<%@ 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 deleted file mode 100644 index bdfc907..0000000 --- a/Controls/ReCaptcha.ascx.designer.vb +++ /dev/null @@ -1,44 +0,0 @@ -'------------------------------------------------------------------------------ -' -' 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 deleted file mode 100644 index 93cf810..0000000 --- a/Controls/ReCaptcha.ascx.vb +++ /dev/null @@ -1,65 +0,0 @@ -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/Controls/SWFUploader.ashx b/Controls/SWFUploader.ashx deleted file mode 100755 index 55489a2..0000000 --- a/Controls/SWFUploader.ashx +++ /dev/null @@ -1 +0,0 @@ -<%@ WebHandler Language="VB" CodeBehind="SWFUploader.ashx.vb" Class="Ventrian.NewsArticles.Controls.SWFUploader" %> diff --git a/Controls/SWFUploader.ashx.vb b/Controls/SWFUploader.ashx.vb deleted file mode 100755 index 30dfb36..0000000 --- a/Controls/SWFUploader.ashx.vb +++ /dev/null @@ -1,415 +0,0 @@ -Imports System.Web -Imports System.Web.Services - -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Entities.Modules -Imports DotNetNuke.Entities.Portals -Imports DotNetNuke.Entities.Users -Imports DotNetNuke.Security.Roles -Imports DotNetNuke.Services.FileSystem -Imports System.IO -Imports System.Drawing -Imports System.Drawing.Drawing2D -Imports System.Drawing.Imaging - -Namespace Ventrian.NewsArticles.Controls - - Public Class SWFUploader - Implements System.Web.IHttpHandler - -#Region " Private Members " - - Private _articleID As Integer = Null.NullInteger - Private _moduleID As Integer = Null.NullInteger - Private _tabID As Integer = Null.NullInteger - Private _tabModuleID As Integer = Null.NullInteger - Private _portalID As Integer = Null.NullInteger - Private _ticket As String = Null.NullString - Private _userID As Integer = Null.NullInteger - Private _imageGuid As String = Null.NullString - - Private _articleSettings As Ventrian.NewsArticles.ArticleSettings - Private _settings As Hashtable - Private _context As HttpContext - -#End Region - -#Region " Private Properties " - - Private ReadOnly Property ArticleSettings() As Ventrian.NewsArticles.ArticleSettings - Get - If _articleSettings Is Nothing Then - Dim objModuleController As New ModuleController - Dim objModule As ModuleInfo = objModuleController.GetModule(_moduleID, _tabID) - - _articleSettings = New Ventrian.NewsArticles.ArticleSettings(Settings, PortalController.GetCurrentPortalSettings(), objModule) - End If - Return _articleSettings - End Get - End Property - - Private ReadOnly Property Settings() As Hashtable - Get - If _settings Is Nothing Then - Dim objModuleController As New ModuleController - _settings = objModuleController.GetModuleSettings(_moduleID) - _settings = GetTabModuleSettings(_tabModuleID, _settings) - End If - Return _settings - End Get - End Property - -#End Region - -#Region " Private Methods " - - Private Sub AuthenticateUserFromTicket() - - If (_ticket <> "") Then - - Dim ticket As FormsAuthenticationTicket = FormsAuthentication.Decrypt(_ticket) - Dim fi As FormsIdentity = New FormsIdentity(ticket) - - Dim roles As String() = Nothing - HttpContext.Current.User = New System.Security.Principal.GenericPrincipal(fi, roles) - - Dim objUser As UserInfo = UserController.GetUserByName(_portalID, HttpContext.Current.User.Identity.Name) - - If Not (objUser Is Nothing) Then - _userID = objUser.UserID - HttpContext.Current.Items("UserInfo") = objUser - - Dim objRoleController As New RoleController - roles = objRoleController.GetRolesByUser(_userID, _portalID) - - Dim strPortalRoles As String = Join(roles, New Char() {";"c}) - _context.Items.Add("UserRoles", ";" + strPortalRoles + ";") - End If - - End If - - End Sub - - Private Function GetTabModuleSettings(ByVal TabModuleId As Integer, ByVal settings As Hashtable) As Hashtable - - Dim dr As IDataReader = DotNetNuke.Data.DataProvider.Instance().GetTabModuleSettings(TabModuleId) - - While dr.Read() - - If Not dr.IsDBNull(1) Then - settings(dr.GetString(0)) = dr.GetString(1) - Else - settings(dr.GetString(0)) = "" - End If - - End While - - dr.Close() - - Return settings - - End Function - - Private Sub ReadQueryString() - - If (_context.Request("ModuleID") <> "") Then - _moduleID = Convert.ToInt32(_context.Request("ModuleID")) - End If - - If (_context.Request("PortalID") <> "") Then - _portalID = Convert.ToInt32(_context.Request("PortalID")) - End If - - If (_context.Request("ArticleID") <> "") Then - _articleID = Convert.ToInt32(_context.Request("ArticleID")) - End If - - If (_context.Request("TabModuleID") <> "") Then - _tabModuleID = Convert.ToInt32(_context.Request("TabModuleID")) - End If - - If (_context.Request("TabID") <> "") Then - _tabID = Convert.ToInt32(_context.Request("TabID")) - End If - - If (_context.Request("Ticket") <> "") Then - _ticket = _context.Request("Ticket") - End If - - If (_articleID = Null.NullInteger) Then - If (_context.Request("ArticleGuid") <> "") Then - _imageGuid = _context.Request("ArticleGuid") - End If - End If - - End Sub - -#End Region - -#Region " Interface Methods " - - Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest - - _context = context - context.Response.ContentType = "text/plain" - - ReadQueryString() - AuthenticateUserFromTicket() - - If (_context.Request.IsAuthenticated = False) Then - _context.Response.Write("-2") - _context.Response.End() - End If - - Dim objImageController As New ImageController() - Dim objFile As HttpPostedFile = _context.Request.Files("Filedata") - - If Not (objFile Is Nothing) Then - - Dim objPortalController As New PortalController() - If (objPortalController.HasSpaceAvailable(_portalID, objFile.ContentLength) = False) Then - _context.Response.Write("-1") - _context.Response.End() - End If - - Dim username As String = _context.User.Identity.Name - - Dim objImage As New ImageInfo - - objImage.ArticleID = _articleID - If (_articleID = Null.NullInteger) Then - objImage.ImageGuid = _imageGuid - End If - objImage.FileName = objFile.FileName - - If (objFile.FileName.ToLower().EndsWith(".jpg")) Then - objImage.ContentType = "image/jpeg" - End If - - If (objFile.FileName.ToLower().EndsWith(".gif")) Then - objImage.ContentType = "image/gif" - End If - - If (objFile.FileName.ToLower().EndsWith(".png")) Then - objImage.ContentType = "image/png" - End If - - Dim maxWidth As Integer = ArticleSettings.MaxImageWidth - Dim maxHeight As Integer = ArticleSettings.MaxImageHeight - - Dim photo As Drawing.Image = Drawing.Image.FromStream(objFile.InputStream) - - objImage.Width = photo.Width - objImage.Height = photo.Height - - If (objImage.Width > maxWidth) Then - objImage.Width = maxWidth - objImage.Height = Convert.ToInt32(objImage.Height / (photo.Width / maxWidth)) - End If - - If (objImage.Height > maxHeight) Then - objImage.Height = maxHeight - objImage.Width = Convert.ToInt32(photo.Width / (photo.Height / maxHeight)) - End If - - objImage.SortOrder = 0 - - Dim imagesList As List(Of ImageInfo) = objImageController.GetImageList(_articleID, _imageGuid) - - If (imagesList.Count > 0) Then - objImage.SortOrder = CType(imagesList(imagesList.Count - 1), ImageInfo).SortOrder + 1 - End If - - Dim objPortalSettings As PortalSettings = PortalController.GetCurrentPortalSettings() - - Dim folder As String = "" - Dim folderID As Integer = Null.NullInteger - If (IsNumeric(context.Request.Form("FolderID"))) Then - folderID = Convert.ToInt32(context.Request.Form("FolderID")) - End If - - If (folderID <> Null.NullInteger) Then - Dim objFolderController As New FolderController - Dim objFolder As FolderInfo = objFolderController.GetFolderInfo(_portalID, folderID) - If (objFolder IsNot Nothing) Then - folder = objFolder.FolderPath - End If - End If - - objImage.Folder = folder - - Select Case objImage.ContentType.ToLower() - Case "image/jpeg" - objImage.Extension = "jpg" - Exit Select - Case "image/gif" - objImage.Extension = "gif" - Exit Select - Case "image/png" - objImage.Extension = "png" - Exit Select - End Select - - objImage.Title = objFile.FileName.Replace("." & objImage.Extension, "") - - Dim filePath As String = objPortalSettings.HomeDirectoryMapPath & folder.Replace("/", "\") - - If Not (Directory.Exists(filePath)) Then - Directory.CreateDirectory(filePath) - End If - - If (File.Exists(filePath & objImage.FileName)) Then - For i As Integer = 1 To 100 - If (File.Exists(filePath & i.ToString() & "_" & objImage.FileName) = False) Then - objImage.FileName = i.ToString() & "_" & objImage.FileName - Exit For - End If - Next - End If - - objImage.Size = objFile.ContentLength - If ((photo.Width < maxWidth And photo.Height < maxHeight) Or (ArticleSettings.ResizeImages = False)) Then - objFile.SaveAs(filePath & objImage.FileName) - Else - Dim bmp As New Bitmap(objImage.Width, objImage.Height) - Dim g As Graphics = Graphics.FromImage(DirectCast(bmp, Drawing.Image)) - - g.InterpolationMode = InterpolationMode.HighQualityBicubic - g.SmoothingMode = SmoothingMode.HighQuality - g.PixelOffsetMode = PixelOffsetMode.HighQuality - g.CompositingQuality = CompositingQuality.HighQuality - - g.DrawImage(photo, 0, 0, objImage.Width, objImage.Height) - - If (ArticleSettings.WatermarkEnabled And ArticleSettings.WatermarkText <> "") Then - Dim crSize As SizeF = New SizeF - Dim brushColor As Brush = Brushes.Yellow - Dim fnt As Font = New Font("Verdana", 11, FontStyle.Bold) - Dim strDirection As StringFormat = New StringFormat - - strDirection.Alignment = StringAlignment.Center - crSize = g.MeasureString(ArticleSettings.WatermarkText, fnt) - - Dim yPixelsFromBottom As Integer = Convert.ToInt32(Convert.ToDouble(objImage.Height) * 0.05) - Dim yPosFromBottom As Single = Convert.ToSingle((objImage.Height - yPixelsFromBottom) - (crSize.Height / 2)) - Dim xCenterOfImage As Single = Convert.ToSingle((objImage.Width / 2)) - - g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias - - Dim semiTransBrush2 As SolidBrush = New SolidBrush(Color.FromArgb(153, 0, 0, 0)) - g.DrawString(ArticleSettings.WatermarkText, fnt, semiTransBrush2, New PointF(xCenterOfImage + 1, yPosFromBottom + 1), strDirection) - - Dim semiTransBrush As SolidBrush = New SolidBrush(Color.FromArgb(153, 255, 255, 255)) - g.DrawString(ArticleSettings.WatermarkText, fnt, semiTransBrush, New PointF(xCenterOfImage, yPosFromBottom), strDirection) - End If - - If (ArticleSettings.WatermarkEnabled And ArticleSettings.WatermarkImage <> "") Then - Dim watermark As String = objPortalSettings.HomeDirectoryMapPath & ArticleSettings.WatermarkImage - If (File.Exists(watermark)) Then - Dim imgWatermark As Image = New Bitmap(watermark) - Dim wmWidth As Integer = imgWatermark.Width - Dim wmHeight As Integer = imgWatermark.Height - - Dim objImageAttributes As New ImageAttributes() - Dim objColorMap As New ColorMap() - objColorMap.OldColor = Color.FromArgb(255, 0, 255, 0) - objColorMap.NewColor = Color.FromArgb(0, 0, 0, 0) - Dim remapTable As ColorMap() = {objColorMap} - objImageAttributes.SetRemapTable(remapTable, ColorAdjustType.Bitmap) - - Dim colorMatrixElements As Single()() = {New Single() {1.0F, 0.0F, 0.0F, 0.0F, 0.0F}, New Single() {0.0F, 1.0F, 0.0F, 0.0F, 0.0F}, New Single() {0.0F, 0.0F, 1.0F, 0.0F, 0.0F}, New Single() {0.0F, 0.0F, 0.0F, 0.3F, 0.0F}, New Single() {0.0F, 0.0F, 0.0F, 0.0F, 1.0F}} - Dim wmColorMatrix As New ColorMatrix(colorMatrixElements) - objImageAttributes.SetColorMatrix(wmColorMatrix, ColorMatrixFlag.[Default], ColorAdjustType.Bitmap) - - Dim xPosOfWm As Integer = ((objImage.Width - wmWidth) - 10) - Dim yPosOfWm As Integer = 10 - - Select Case ArticleSettings.WatermarkPosition - Case WatermarkPosition.TopLeft - xPosOfWm = 10 - yPosOfWm = 10 - Exit Select - - Case WatermarkPosition.TopRight - xPosOfWm = ((objImage.Width - wmWidth) - 10) - yPosOfWm = 10 - Exit Select - - Case WatermarkPosition.BottomLeft - xPosOfWm = 10 - yPosOfWm = ((objImage.Height - wmHeight) - 10) - - Case WatermarkPosition.BottomRight - xPosOfWm = ((objImage.Width - wmWidth) - 10) - yPosOfWm = ((objImage.Height - wmHeight) - 10) - End Select - - g.DrawImage(imgWatermark, New Rectangle(xPosOfWm, yPosOfWm, wmWidth, wmHeight), 0, 0, wmWidth, wmHeight, _ - GraphicsUnit.Pixel, objImageAttributes) - imgWatermark.Dispose() - End If - End If - - photo.Dispose() - - Select Case objFile.ContentType.ToLower() - Case "image/jpeg" - Dim info As ImageCodecInfo() = ImageCodecInfo.GetImageEncoders() - Dim encoderParameters As New EncoderParameters(1) - encoderParameters.Param(0) = New EncoderParameter(Encoder.Quality, 100L) - bmp.Save(filePath & objImage.FileName, info(1), encoderParameters) - - Case "image/gif" - 'Dim quantizer As New ImageQuantization.OctreeQuantizer(255, 8) - 'Dim bmpQuantized As Bitmap = quantizer.Quantize(bmp) - 'bmpQuantized.Save(filePath & objPhoto.Filename, ImageFormat.Gif) - ' Not working in medium trust. - bmp.Save(filePath & objImage.FileName, ImageFormat.Gif) - - Case Else - 'Shouldn't get to here because of validators. - Dim info As ImageCodecInfo() = ImageCodecInfo.GetImageEncoders() - Dim encoderParameters As New EncoderParameters(1) - encoderParameters.Param(0) = New EncoderParameter(Encoder.Quality, 100L) - bmp.Save(filePath & objImage.FileName, info(1), encoderParameters) - End Select - - bmp.Dispose() - - If (File.Exists(filePath & objImage.FileName)) Then - Dim fi As New IO.FileInfo(filePath & objImage.FileName) - If (fi IsNot Nothing) Then - objImage.Size = Convert.ToInt32(fi.Length) - End If - End If - End If - - objImage.ImageID = objImageController.Add(objImage) - - If (_articleID <> Null.NullInteger) Then - Dim objArticleController As New ArticleController - Dim objArticle As ArticleInfo = objArticleController.GetArticle(_articleID) - If (objArticle IsNot Nothing) Then - objArticle.ImageCount = objArticle.ImageCount + 1 - objArticleController.UpdateArticle(objArticle) - End If - End If - - End If - - _context.Response.Write("0") - _context.Response.End() - - End Sub - - ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable - Get - Return False - End Get - End Property - -#End Region - - End Class - -End Namespace \ No newline at end of file diff --git a/Controls/SWFUploaderFiles.ashx b/Controls/SWFUploaderFiles.ashx deleted file mode 100755 index 962213f..0000000 --- a/Controls/SWFUploaderFiles.ashx +++ /dev/null @@ -1 +0,0 @@ -<%@ WebHandler Language="VB" CodeBehind="SWFUploaderFiles.ashx.vb" Class="Ventrian.NewsArticles.Controls.SWFUploaderFiles" %> diff --git a/Controls/SWFUploaderFiles.ashx.vb b/Controls/SWFUploaderFiles.ashx.vb deleted file mode 100755 index ddf5471..0000000 --- a/Controls/SWFUploaderFiles.ashx.vb +++ /dev/null @@ -1,201 +0,0 @@ -Imports System.Web -Imports System.Web.Services - -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Entities.Modules -Imports DotNetNuke.Entities.Portals -Imports DotNetNuke.Entities.Users -Imports DotNetNuke.Security.Roles -Imports DotNetNuke.Services.FileSystem -Imports System.IO -Imports System.Drawing -Imports System.Drawing.Drawing2D -Imports System.Drawing.Imaging - -Namespace Ventrian.NewsArticles.Controls - - Public Class SWFUploaderFiles - Implements System.Web.IHttpHandler - -#Region " Private Members " - - Private _articleID As Integer = Null.NullInteger - Private _moduleID As Integer = Null.NullInteger - Private _tabID As Integer = Null.NullInteger - Private _tabModuleID As Integer = Null.NullInteger - Private _portalID As Integer = Null.NullInteger - Private _ticket As String = Null.NullString - Private _userID As Integer = Null.NullInteger - Private _fileGuid As String = Null.NullString - - Private _articleSettings As Ventrian.NewsArticles.ArticleSettings - Private _settings As Hashtable - Private _context As HttpContext - -#End Region - -#Region " Private Properties " - - Private ReadOnly Property ArticleSettings() As Ventrian.NewsArticles.ArticleSettings - Get - If _articleSettings Is Nothing Then - Dim objModuleController As New ModuleController - Dim objModule As ModuleInfo = objModuleController.GetModule(_moduleID, _tabID) - - _articleSettings = New Ventrian.NewsArticles.ArticleSettings(Settings, PortalController.GetCurrentPortalSettings(), objModule) - End If - Return _articleSettings - End Get - End Property - - Private ReadOnly Property Settings() As Hashtable - Get - If _settings Is Nothing Then - Dim objModuleController As New ModuleController - _settings = objModuleController.GetModuleSettings(_moduleID) - _settings = GetTabModuleSettings(_tabModuleID, _settings) - End If - Return _settings - End Get - End Property - -#End Region - -#Region " Private Methods " - - Private Sub AuthenticateUserFromTicket() - - If (_ticket <> "") Then - - Dim ticket As FormsAuthenticationTicket = FormsAuthentication.Decrypt(_ticket) - Dim fi As FormsIdentity = New FormsIdentity(ticket) - - Dim roles As String() = Nothing - HttpContext.Current.User = New System.Security.Principal.GenericPrincipal(fi, roles) - - Dim objUser As UserInfo = UserController.GetUserByName(_portalID, HttpContext.Current.User.Identity.Name) - - If Not (objUser Is Nothing) Then - _userID = objUser.UserID - HttpContext.Current.Items("UserInfo") = objUser - - Dim objRoleController As New RoleController - roles = objRoleController.GetRolesByUser(_userID, _portalID) - - Dim strPortalRoles As String = Join(roles, New Char() {";"c}) - _context.Items.Add("UserRoles", ";" + strPortalRoles + ";") - End If - - End If - - End Sub - - Private Function GetTabModuleSettings(ByVal TabModuleId As Integer, ByVal settings As Hashtable) As Hashtable - - Dim dr As IDataReader = DotNetNuke.Data.DataProvider.Instance().GetTabModuleSettings(TabModuleId) - - While dr.Read() - - If Not dr.IsDBNull(1) Then - settings(dr.GetString(0)) = dr.GetString(1) - Else - settings(dr.GetString(0)) = "" - End If - - End While - - dr.Close() - - Return settings - - End Function - - Private Sub ReadQueryString() - - If (_context.Request("ModuleID") <> "") Then - _moduleID = Convert.ToInt32(_context.Request("ModuleID")) - End If - - If (_context.Request("PortalID") <> "") Then - _portalID = Convert.ToInt32(_context.Request("PortalID")) - End If - - If (_context.Request("ArticleID") <> "") Then - _articleID = Convert.ToInt32(_context.Request("ArticleID")) - End If - - If (_context.Request("TabModuleID") <> "") Then - _tabModuleID = Convert.ToInt32(_context.Request("TabModuleID")) - End If - - If (_context.Request("TabID") <> "") Then - _tabID = Convert.ToInt32(_context.Request("TabID")) - End If - - If (_context.Request("Ticket") <> "") Then - _ticket = _context.Request("Ticket") - End If - - If (_articleID = Null.NullInteger) Then - If (_context.Request("ArticleGuid") <> "") Then - _fileGuid = _context.Request("ArticleGuid") - End If - End If - - End Sub - -#End Region - -#Region " Interface Methods " - - Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest - - _context = context - context.Response.ContentType = "text/plain" - - ReadQueryString() - AuthenticateUserFromTicket() - - If (_context.Request.IsAuthenticated = False) Then - _context.Response.Write("-2") - _context.Response.End() - End If - - Dim objFileController As New FileController - - Dim objFilePosted As HttpPostedFile = _context.Request.Files("Filedata") - - If Not (objFilePosted Is Nothing) Then - - Dim objPortalController As New PortalController() - If (objPortalController.HasSpaceAvailable(_portalID, objFilePosted.ContentLength) = False) Then - _context.Response.Write("-1") - _context.Response.End() - End If - - Dim username As String = _context.User.Identity.Name - - If (_articleID <> Null.NullInteger) Then - FileProvider.Instance().AddFile(_articleID, _moduleID, objFilePosted) - Else - FileProvider.Instance().AddFile(_fileGuid, _moduleID, objFilePosted) - End If - - End If - - _context.Response.Write("0") - _context.Response.End() - - End Sub - - ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable - Get - Return False - End Get - End Property - -#End Region - - End Class - -End Namespace \ No newline at end of file diff --git a/Controls/UploadFiles.ascx.vb b/Controls/UploadFiles.ascx.vb index 855e451..cb52bea 100755 --- a/Controls/UploadFiles.ascx.vb +++ b/Controls/UploadFiles.ascx.vb @@ -102,6 +102,7 @@ Namespace Ventrian.NewsArticles.Controls Else folders.AddRange(FolderManager.Instance.GetFolders(ArticleModuleBase.PortalId, False)) End If + Logger.Debug($"UploadFiles.BindFiles starting to iterate {folders.Count} folders.") For Each folder As DotNetNuke.Services.FileSystem.FolderInfo In folders If Not folder.IsProtected Then Dim FolderItem As New ListItem() @@ -121,6 +122,7 @@ Namespace Ventrian.NewsArticles.Controls End If End If Next + Logger.Debug($"UploadFiles.BindFiles done iterating {folders.Count} folders.") If (drpUploadFilesFolder.Items.FindByValue(ArticleSettings.DefaultFilesFolder.ToString()) IsNot Nothing) Then drpUploadFilesFolder.SelectedValue = ArticleSettings.DefaultFilesFolder.ToString() @@ -214,6 +216,8 @@ Namespace Ventrian.NewsArticles.Controls ReadQueryString() SetLocalization() + trExisting.Visible = ArticleSettings.EnablePortalFiles + If (ArticleSettings.IsFilesEnabled = False) Then Me.Visible = False Return diff --git a/Controls/UploadImages.ascx.vb b/Controls/UploadImages.ascx.vb index b7f7cc0..bc03d7b 100755 --- a/Controls/UploadImages.ascx.vb +++ b/Controls/UploadImages.ascx.vb @@ -94,7 +94,6 @@ Namespace Ventrian.NewsArticles.Controls drpUploadImageFolder.Items.Clear() - Dim folders As New List(Of IFolderInfo)() If ArticleSettings.DefaultImagesFolder > 0 Then Dim defaultFolder as IFolderInfo = FolderManager.Instance.GetFolder(ArticleSettings.DefaultImagesFolder) @@ -103,6 +102,7 @@ Namespace Ventrian.NewsArticles.Controls Else folders.AddRange(FolderManager.Instance.GetFolders(ArticleModuleBase.PortalId, False)) End If + Logger.Debug($"UploadImages.BindFiles starting to iterate {folders.Count} folders.") For Each folder As DotNetNuke.Services.FileSystem.FolderInfo In folders If Not folder.IsProtected Then Dim FolderItem As New ListItem() @@ -122,6 +122,7 @@ Namespace Ventrian.NewsArticles.Controls End If End If Next + Logger.Debug($"UploadImages.BindFiles done iterating {folders.Count} folders.") If (drpUploadImageFolder.Items.FindByValue(ArticleSettings.DefaultImagesFolder.ToString()) IsNot Nothing) Then drpUploadImageFolder.SelectedValue = ArticleSettings.DefaultImagesFolder.ToString() @@ -583,7 +584,7 @@ Namespace Ventrian.NewsArticles.Controls End If objImage.FileName = CoreFileProvider.CleanFilename(objFile.FileName) - If (objFile.FileName.ToLower().EndsWith(".jpg")) Then + If (objFile.FileName.ToLower().EndsWith(".jpg") OrElse objFile.FileName.ToLower().EndsWith(".jpeg")) Then objImage.ContentType = "image/jpeg" End If diff --git a/Installs/NewsArticles.00.11.03.zip b/Installs/NewsArticles.00.11.03.zip new file mode 100644 index 0000000..b23b01a Binary files /dev/null and b/Installs/NewsArticles.00.11.03.zip differ diff --git a/NewsArticles.dnn b/NewsArticles.dnn index 84fc922..4c2af18 100755 --- a/NewsArticles.dnn +++ b/NewsArticles.dnn @@ -1,8 +1,12 @@ - + News Articles - Allows you to publish News Articles to your portal. + + 40FINGERS. + ]]> + Scott McCulloch Ventrian @@ -860,7 +864,7 @@ - + News Articles Latest Allows you to display a list of the latest articles. @@ -921,7 +925,7 @@ - + News Articles Comments Allows you to display a list of the latest comments. @@ -982,7 +986,7 @@ - + News Articles Archives Allows you to display a list of articles by month. @@ -1043,7 +1047,7 @@ - + News Articles Search Allows you to display a list of articles by month. diff --git a/README.md b/README.md index 68bfa74..3a883f5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # News-Articles +This module was originally created by Scott McCulloch of Ventrian. The module is now out in the open, and maintained mostly by Stefan Kamphuis, Timo Breumelhof and Peter Schotman of [40FINGERS](https://www.40fingers.net/). ## Installation diff --git a/Ventrian.NewsArticles.vbproj b/Ventrian.NewsArticles.vbproj index 90464d4..6b60119 100755 --- a/Ventrian.NewsArticles.vbproj +++ b/Ventrian.NewsArticles.vbproj @@ -176,20 +176,6 @@ - - Honeypot.ascx - - - Honeypot.ascx - ASPXCodeBehind - - - ReCaptcha.ascx - - - ReCaptcha.ascx - ASPXCodeBehind - @@ -700,8 +686,6 @@ Designer - - diff --git a/ViewArticle.ascx b/ViewArticle.ascx index bee8d82..dbc3773 100755 --- a/ViewArticle.ascx +++ b/ViewArticle.ascx @@ -7,9 +7,10 @@