您目前尚未登陆,请选择【登陆】或【注册
首页->博客论坛->SpaceBuilder v1.0正式版源码>>BlogControls/Admin/UploadAttachment.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:SpaceBuilder v1.0正式版源码
当前文件:文件类型 SpaceBuiderV10Source/BlogControls/Admin/UploadAttachment.cs打开代码结构图
普通视图
		            
1//------------------------------------------------------------------------------ 2// <copyright company="Tunynet"> 3// Copyright (c) Tunynet Network Technology Co., Ltd. All rights reserved. 4// </copyright> 5//------------------------------------------------------------------------------ 6 7using System; 8using System.Collections.Generic; 9using System.Text; 10using SpaceBuilder.Blogs.Components; 11using SpaceBuilder.Posts.Components; 12using SpaceBuilder.Posts.Configuration; 13using SpaceBuilder.Blogs.Configuration; 14using SpaceBuilder.Components; 15using SpaceBuilder.Posts.Permissions; 16using System.Web; 17using SpaceBuilder.Controls; 18 19namespace SpaceBuilder.Blogs.Controls 20{ 21 public class UploadAttachment : SpaceBuilder.Controls.UploadAttachment 22 { 23 protected override void OnInit(EventArgs e) 24 { 25 base.OnInit(e); 26 this.Page.Response.Cache.SetCacheability(HttpCacheability.NoCache); 27 Authorize(); 28 } 29 30 protected virtual void Authorize() 31 { 32 if (!SBContext.Current.IsAuthenticated) 33 this.Page.Response.Redirect(UserUrls.Instance().Login()); 34 Permissions.AccessCheck(CurrentWeblog, Permission.Post, SBContext.Current.User); 35 } 36 37 protected override Section Section 38 { 39 get { return this.CurrentWeblog; } 40 } 41 42 private Weblog _currentWeblog = null; 43 public virtual Weblog CurrentWeblog 44 { 45 get 46 { 47 if ((_currentWeblog == null) || (!_currentWeblog.ApplicationKey.Equals(SBContext.Current.UserDomainName, StringComparison.CurrentCultureIgnoreCase))) 48 { 49 //ApplicationKey 与 UserDomainName 相同 50 _currentWeblog = Weblogs.GetWeblog(SBContext.Current.UserDomainName, true, true); 51 } 52 return _currentWeblog; 53 } 54 } 55 56 protected override bool IsFileValid(string filename, bool isRemote, int fileSizeBytes, ref string message) 57 { 58 AttachmentSettings fs = WeblogConfiguration.Instance().AttachmentSettings; 59 if (fs.ValidateExtensions && !SBContext.Current.User.IsBlogAdministrator) 60 { 61 if (!fs.ValidationRegex.IsMatch(filename)) 62 { 63 message = string.Format("只允许上传以下文件类型: {0}.", fs.Extensions.Replace(";", ",")); 64 return false; 65 } 66 else 67 return true; 68 } 69 else 70 return true; 71 } 72 73 74 } 75}
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:SpaceBuilder v1.0正式版源码