发帖页面代码如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<%
if session("username")="" then
response.Write("<table align=center valign=center>")
response.Write("<tr>")
response.Write("<td>")
response.Write("<a href=bbs.html>请登录后在访问此页</a>")
response.Write("</td>")
response.Write("</tr>")
response.End()
end if
dim id
id=trim(request.QueryString("id"))
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>发帖页面</title>
<script type="text/javascript">
_editor_url = "htmlarea/"; //htmlarea所在目录
_editor_lang = "zh-cn"; //语言
</script>
<script type="text/javascript" src="htmlarea/htmlarea.js"></script>
<script type="text/javascript">
var editor = null;
function initEditor() {
editor = new HTMLArea("content"); //这里的content为需要添加WYSIWYG效果的文本框的ID
// comment the following two lines to see how customization works
editor.generate();
return false;
var cfg = editor.config; // this is the default configuration
cfg.registerButton({
id : "my-hilite",
tooltip : "Highlight text",
image : "ed_custom.gif",
textMode : false,
action : function(editor) {
editor.surroundHTML("<span class=\"hilite\">", "</span>");
},
context : 'table'
});
cfg.toolbar.push(["linebreak", "my-hilite"]); // add the new button to the toolbar
// BEGIN: code that adds a custom button
// uncomment it to test
var cfg = editor.config; // this is the default configuration
/*
cfg.registerButton({
id : "my-hilite",
tooltip : "Highlight text",
image : "ed_custom.gif",
textMode : false,
action : function(editor) {
editor.surroundHTML("<span class=\"hilite\">", "</span>");
}
});
*/
function clickHandler(editor, buttonId) {
switch (buttonId) {
case "my-toc":
editor.insertHTML("<h1>Table Of Contents</h1>");
break;
case "my-date":
editor.insertHTML((new Date()).toString());
break;
case "my-bold":
editor.execCommand("bold");
editor.execCommand("italic");
break;
case "my-hilite":
editor.surroundHTML("<span class=\"hilite\">", "</span>");
break;
}
};
cfg.registerButton("my-toc", "Insert TOC", "ed_custom.gif", false, clickHandler);
cfg.registerButton("my-date", "Insert date/time", "ed_custom.gif", false, clickHandler);
cfg.registerButton("my-bold", "Toggle bold/italic", "ed_custom.gif", false, clickHandler);
cfg.registerButton("my-hilite", "Hilite selection", "ed_custom.gif", false, clickHandler);
cfg.registerButton("my-sample", "Class: sample", "ed_custom.gif", false,
function(editor) {
if (HTMLArea.is_ie) {
editor.insertHTML("<span class=\"sample\"> </span>");
var r = editor._doc.selection.createRange();
r.move("character", -2);
r.moveEnd("character", 2);
r.select();
} else { // Gecko/W3C compliant
var n = editor._doc.createElement("span");
n.className = "sample";
editor.insertNodeAtSelection(n);
var sel = editor._iframe.contentWindow.getSelection();
sel.removeAllRanges();
var r = editor._doc.createRange();
r.setStart(n, 0);
r.setEnd(n, 0);
sel.addRange(r);
}
}
);
/*
cfg.registerButton("my-hilite", "Highlight text", "ed_custom.gif", false,
function(editor) {
editor.surroundHTML('<span class="hilite">', '</span>');
}
);
*/
cfg.pageStyle = "body { background-color: #efd; } .hilite { background-color: yellow; } "+
".sample { color: green; font-family: monospace; }";
cfg.toolbar.push(["linebreak", "my-toc", "my-date", "my-bold", "my-hilite", "my-sample"]); // add the new button to the toolbar
// END: code that adds a custom button
editor.generate();
}
function insertHTML() {
var html = prompt("Enter some HTML code here");
if (html) {
editor.insertHTML(html);
}
}
function highlight() {
editor.surroundHTML('<span style="background-color: yellow">', '</span>');
}
</script>
</head>
<!--#include file="public/function.asp"-->
<body
onLoad="initEditor()">
<form name="form1" method="post" action="send_post_go.asp" enctype="multipart/form-data">
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0" background="images/wlaura_30.png">
<tr>
<td width="19%">发布新帖子</td>
<td colspan="2"><input name="id" type="hidden" id="id" value="<%=id%>"/></td>
</tr>
<tr>
<td><div align="right">标题:
<select name="select">
<option value="原创">原创</option>
<option value="讨论">讨论</option>
<option value="引用">引用</option>
</select>
</div></td>
<td colspan="2">
<div align="left">
<input name="title" type="text" id="title" size="30">
</div></td>
</tr>
<tr>
<td><div align="right">内容:</div></td>
<td width="65%"><textarea name="content" cols="35" rows="20" id="content"></textarea></td>
<td width="16%">注:发帖时请不要用红色字体,以免影响视力</td>
</tr>
<tr>
<td><div align="right">图像上传</div></td>
<td colspan="2"><input type="file" name="file1"> </td>
</tr>
<tr>
<td><div align="right">验证码:</div></td>
<td colspan="2"><input name="yzm" type="text" id="yzm" size="4">
<%=Rnkey(length)%></td></tr>
<tr>
<td>
<div align="right">
<input type="submit" name="Submit" value="发帖">
</div></td>
<td colspan="2">
<div align="left">
<input type="submit" name="Submit2" value="清空">
</div></td></tr>
</table>
</form>
</body>
</html>
执行页面代码如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<%
if session("username")="" then
response.end()
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head>
<!--#include file="public/function.asp"-->
<!--#include file="public/readconn.asp"-->
<body>
<!--#include file="public/writeconn.asp"-->
<%
dim id,Stitle,Scontent,yzm
id=request.form("id")
Stitle=CheckStr(request.form("title"))
Scontent=CheckStr(request.form("content"))
yzm=CheckStr(trim(request.Form("yzm")))
if yzm="" then
response.Write("<div><center>请输入验证码</center></div>")
response.end
end if
dim rs,sql
sql="insert into tbShowtopic(Stitle,Scontent,Sowner) values('"&Stitle&"','"&Scontent&"','"&trim(session("username"))&"')"
wconn.execute(sql)
sql="update tbUser set Post = Post+1 where UserName='"&trim(session("username"))&"'"
set rs=server.create
object("adodb.recordset")
wconn.execute(sql)
wconn.close
set wconn=nothing
%>
<%
response.Redirect("bbs.asp")
%>
</body>
</html>
问题出下图:
附件:
83691020076922603.jpg