知识库

FCKeditor 实战技巧(3)

4、文件管理功能、文件上传的权限问题

一直以后FCKeditor的文件管理部分的安全是个值得注意,但很多人没注意到的地方,虽然FCKeditor在各个Release版本中一直存在的一个功能就是对上传文件类型进行过滤,但是她没考虑过另一个问题:到底允许谁能上传?到底谁能浏览服务器文件?

之前刚开始用FCKeditor时,我就出现过这个问题,还好NetRube(FCKeditor中文化以及FCKeditor ASP版上传程序的作者)及时提醒了我,做法是去修改FCK上传程序,在里面进行权限判断,并且再在fckconfig.js里把相应的一些功能去掉。但随之FCK版本的不断升级,每升一次都要去改一次配置程序fckconfig.js,我发觉厌烦了,就没什么办法能更好的控制这种配置么?事实上,是有的。

在fckconfig.js里面,有关于是否打开上传和浏览服务器的设置,在创建FCKeditor时,通过程序来判断是否创建有上传浏览功能的编辑器。首先,我先在fckconfig.js里面把所有的上传和浏览设置全设为false,接着我使用的代码如下:

ASP版本:

xml 代码
 
  1.   
  2. <%    
  3. Dim oFCKeditor    
  4. Set oFCKeditor = New FCKeditor    
  5. with oFCKeditor    
  6. .BasePath = fckPath    
  7. .Config("ToolbarLocation") = "Out:fckToolBar"    
  8. if request.cookies(site_sn)("issuper")="yes" then    
  9. .Config("LinkBrowser") = "true"    
  10. .Config("ImageBrowser") = "true"    
  11. .Config("FlashBrowser") = "true"    
  12. .Config("LinkUpload") = "true"    
  13. .Config("ImageUpload") = "true"    
  14. .Config("FlashUpload") = "true"    
  15. end if    
  16. .ToolbarSet = "Basic"    
  17. .Width = "100%"    
  18. .Height = "200"    
  19. .Value = ""    
  20. .Create "jcontent"    
  21. %>    
  22.   
  23.    

 

Javascript 版本
 

xml 代码
 
  1.   
  2. var oFCKeditor = new FCKeditor( 'fbContent' ) ;   
  3. <%if power = powercode then%>  
  4. oFCKeditor.Config['LinkBrowser'] = true ;   
  5. oFCKeditor.Config['ImageBrowser'] = true ;   
  6. oFCKeditor.Config['FlashBrowser'] = true ;   
  7. oFCKeditor.Config['LinkUpload'] = true ;   
  8. oFCKeditor.Config['ImageUpload'] = true ;   
  9. oFCKeditor.Config['FlashUpload'] = true ;   
  10. <%end if%>  
  11. oFCKeditor.ToolbarSet = 'Basic' ;   
  12. oFCKeditor.Width = '100%' ;   
  13. oFCKeditor.Height = '200' ;   
  14. oFCKeditor.Value = '' ;   
  15. oFCKeditor.Create() ;   
  16.   

 

本文关键词 / FCKeditor
微信扫一扫
官方微博

点击拨打免费服务热线 4008203730

展开