新浪博客HtmlEditor(OFFICE2007风格)在线编辑器
调用:
<input type="hidden" name="content" id="content">
<iframe src="Edit/editor.htm?id=content&ReadCookie=0" frameBorder="0" marginHeight="0" marginWidth="0" scrolling="No" width="700" height="460"></iframe>
注意:id为调用参数(小写),即隐藏的内容表单项id, ReadCookie设置是否读取上次未提交的数据,1为开启,0为关闭(注意大小写)。
在上次修复的基础上增加了一个附件上传功能,但还是有几个不理想的地方。
缺陷:
1缺乏安全判断(上一版也有这个问题)
2附件上传后,插入编辑器的样式很难看。
3缺清除格式功能
* 演示 下载
新浪博客HtmlEditor在线编辑器 已修BUG 使用方法
添加时- 程序代码:
<textarea name="content" id="content" style="display:none"></textarea><iframe src="Edit/editor.htm?id=content&ReadCookie=0" frameBorder="0" marginHeight="0" marginWidth="0" scrolling="No" width="621" height="459"></iframe>
编辑时- 程序代码:
<textarea name="content" id="content" style="display:none"><%=Server.HtmlEncode(rs("content"))%></textarea><iframe src="Edit/editor.htm?id=content&ReadCookie=0" frameBorder="0" marginHeight="0" marginWidth="0" scrolling="No" width="621" height="459"></iframe>
核心部分<%=Server.HtmlEncode(rs("content"))%>
Server.HtmlEncode()
请注意<iframe></iframe>中的文件路径
点击下载SinaEditor_ASP版
点击下载SinaEditor_PHP版
针对上传图片的改进,修改Edit/editor/目录下UpLoadClass.asp文件。
在65行附近找到
m_SavePath = "/UpLoadFile/"
替换如下的
程序代码
'm_SavePath = "/UpLoadFile/" ' 默认
'-------------------------------------
'以下是修改后按年月日分级目录存放
'例如/UpLoadFile/2008/8/28/ 可根据实际需求 设置存放目录级结构 一般用/UpLoadFile/2008/8/
'可根据实际需求 设置存放目录级结构
' 一般用二级 例如/UpLoadFile/2008/8/
' 海量级用三级 例如/UpLoadFile/2008/8/28/
m_SavePath0 = "/UpLoadFile/"
m_SavePath1 = year(now())&"/"
m_SavePath2 = month(now())&"/"
m_SavePath3 = day(now())&"/"
'生成目录开始
'主目录
Set fso = createObject("Scripting.FileSystemObject")
if not fso.folderexists(Server.MapPath(m_SavePath0)) then
fso.createFolder (Server.MapPath(m_SavePath0))
Set fout = fso.CreateTextFile(server.mappath(m_SavePath0&"default.html"))
fout.WriteLine "<meta http-equiv=Refresh content='1; URL=/'>您访问的页面不存在!"
end if
set fout=nothing
set fso=nothing
'年目录
Set fso = createObject("Scripting.FileSystemObject")
if not fso.folderexists(Server.MapPath(m_SavePath0&m_SavePath1)) then
fso.createFolder (Server.MapPath(m_SavePath0&m_SavePath1))
Set fout = fso.CreateTextFile(server.mappath(m_SavePath0&m_SavePath1&"default.html"))
fout.WriteLine "<meta http-equiv=Refresh content='1; URL=/'>您访问的页面不存在!"
end if
set fout=nothing
set fso=nothing
'月目录
Set fso = createObject("Scripting.FileSystemObject")
if not fso.folderexists(Server.MapPath(m_SavePath0&m_SavePath1&m_SavePath2)) then
fso.createFolder (Server.MapPath(m_SavePath0&m_SavePath1&m_SavePath2))
Set fout = fso.CreateTextFile(server.mappath(m_SavePath0&m_SavePath1&m_SavePath2&"default.html"))
fout.WriteLine "<meta http-equiv=Refresh content='1; URL=/'>您访问的页面不存在!"
end if
set fout=nothing
set fso=nothing
'生成目录结束
m_SavePath = m_SavePath0&m_SavePath1&m_SavePath2 '
'-------------------------------------