⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uploadattachment.cs

📁 community server 源码
💻 CS
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using CommunityServer;
using CommunityServer.Components;
using CommunityServer.Controls;
using CommunityServer.Discussions.Components;

namespace CommunityServer.Discussions.Controls
{
	public class UploadAttachment : CommunityServer.Controls.UploadAttachment
	{
		private Section _section;
		protected override Section Section
		{
			get
			{
				if (_section == null)
					_section = Forums.GetForum(CSContext.Current.SectionID);

				return _section;
			}
		}

		protected override bool IsFileValid(string filename, bool isRemote, int contentLengthBytes, ref string message)
		{
			if (!CSContext.Current.User.IsForumAdministrator)
			{
				ForumAttachmentSettings fas = ForumConfiguration.Instance().AttachmentSettings;
				if (fas.ValidateExtensions)
				{
					if (!fas.ValidationRegex.IsMatch(filename))
					{
						message = string.Format(ResourceManager.GetString("UploadAttachment_InvalidFileExtension"), fas.Extensions.Replace(";", ","));
						return false;
					}
				}

				if (!isRemote && fas.MaxAttachmentSize > 0 && contentLengthBytes / 1024 > fas.MaxAttachmentSize)
				{
					message = string.Format(ResourceManager.GetString("UploadAttachment_TooLarge"), fas.MaxAttachmentSize.ToString());
					return false;
				}
			}

			return true;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -