<!-- #include file="share.asp" -->
<%
dim bid
dim pt
dim uid
dim bdid
dim login
login=false
bdid=request("bdid")
if session("bluelogin")="yes" then   'check login already or not
	uid=session("blueuid")
	login=true
else
	response.redirect "error.asp?tp="&request("type")&"&bdid="&request("bdid")&"&rt="&request("rt")&"&bid="&request("bid")&"&emsg=登录吧，先！"
	response.end
	login=false
end if

if session("blueauthority")>=2 then
	response.redirect "error.asp?emsg=管理员账号不能使用这个功能。"
	response.end
end if

pt=request("type")
if not pt="re" then
	bid=""
else
	bid=request("bid")
end if
isok=request("isok")
if isok="ok" then    ' how to process the data
	if pt="re" then
		savereply     ' save data as a reply
	elseif pt="new" then
		savenew         ' save data as a new message
	end if
else
	showform
end if
%>
<%
sub savereply  '-----------f---save reply data
	rtitle=request.form("ptitle")
	rbody=request.form("pbody")
	icon=request.form("icon")
	sign=request.form("sign")
	rbody=replace(rbody,""&chr(13),"<BR>")
	rbody=replace(rbody,"  ","&nbsp; ")
	if sign="no" then
		addsign=false
	elseif sign="yes" then
		addsign=true
	else
		response.redirect "error.asp?emsg=error value of prmt-addsign!["&sign&"]"
		response.end
	end if
	'opendb
	sql="select * from reply"
	on error resume next
	set rs=server.createobject("adodb.recordset")
	rs.open sql, conn, 1,3
	rs.addnew
	rs("rtitle")=rtitle
	rs("rbody")=rbody
	rs("icon")=icon
	rs("uid")=uid
	rs("bid")=bid
	rs("addsign")=addsign
	rs.update
	rs.close
	checkerr
	' add reply mark in table book
	sql="select * from book where bid="&bid
	rs.open sql,conn, 1,3
	if rs.eof then
		response.redirect "error.asp?emsg=可能出现了严重的错误，联系管理员吧。"
		response.end
	else
		rs("btimemodify")=now
		rs("blastuser")=uid
		rs("addreply")=true
		rn=rs("rn")
		rs("rn")=rn+1
		rs.update
	end if
	rs.close
	checkerr
	set rs=nothing
	'closedb
	adduserpos
	'response.write addsign
	response.redirect "main.asp?bdid="&bdid
end sub
sub savenew    '-----------f---save new data
	btitle=request.form("ptitle")
	bbody=request.form("pbody")
	icon=request.form("icon")
	sign=request.form("sign")
	bdid=request.form("bdid")
	bbody=replace(bbody,""&chr(13),"<br>")
	bbody=replace(bbody,"  ","&nbsp; ")
	if sign="no" then
		addsign=false
	elseif sign="yes" then
		addsign=true
	else
		response.redirect "error.asp?emsg=error value of par-addsign!["&sign&"]"
		response.end
	end if
	sql="select * from book"
	'opendb
	on error resume next
	set rs=server.createobject("adodb.recordset")
	rs.open sql, conn ,1 ,3
	rs.addnew
		rs("uid")=uid
		rs("btitle")=btitle
		rs("bbody")=bbody
		rs("icon")=icon
		rs("addsign")=addsign
		rs("bdid")=bdid
		rs.update
	rs.close
	checkerr
	set rs=nothing
	'closedb
	adduserpos
	'response.write addsign
	response.redirect "main.asp?bdid="&bdid
end sub
sub showform   '-----------f---show data table
%>
<html>
<!-- #include file="top.asp" -->
<head>
<title>3鸟设社[色彩连视版]媒体社区--发表文章</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="blue.css" type="text/css">
<style type="text/css">
<!--
.hand { cursor: hand }
-->
</style>
<script language="javascript">
function checkform(){
	if(signin.username.value==""){
		alert("请填写注册名！");
		signin.username.focus();
		return false;
	}else if(signin.password.value==""){
		alert("请填写密码！");
		signin.password.focus();
		return false;
	}else{
		signin.fromurl.value="index.asp";
		return true;
	}
	return false;
}
</script>
<script language="javascript">
function checksign(){
	if(newmsg.addsign.checked==true){
		newmsg.sign.value="yes";
	}else{
		newmsg.sign.value="no";
	}
	//alert(newmsg.sign.value);
}
// check form data format
function checkform(){
	var title=newmsg.ptitle.value;
	var message=newmsg.pbody.value;
	if(title==""){
		alert("请填写标题！");
		newmsg.ptitle.focus();
		return false;
	}else if(message==""){
		alert("sorry, 不能发空内容。");
		newmsg.pbody.focus();
		return false;
	}else{
		checksign();
		//alert("value is "+newmsg.sign.value);
		//alert("ok, submitting....");
		//alert("ok, submit!");
		return true;
	}
	return false;
}
// set icon;
function seticon(iname){
	var iconurl;
	iconurl='icon'+iname+'.gif';
	newmsg.icon.value=iconurl;
	document.showicon.src='icons/'+iconurl;
	//alert(iconurl);
}
function openeditor(){
	var bname;
	bname=navigator.appName;
	//alert(navigator.appVersion);
	if (bname!="Microsoft Internet Explorer"&&bname!="MSIE"){
	   alert("此功能只有IE用户才能使用！");
	   //alert(bname);
	}else{
	   newwin=window.open('editor/editor.html','','width=544,height=294');
	   newwin.focus();
	}
}
</script>
</head>
<body bgcolor=#ffffff leftmargin="0" topmargin="0">
<table width="758" height="621" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="20" height="11"></td>
    <td width="719" height="11"></td>
    <td width="21" height="11"></td>
  </tr>
  <tr> 
    <td width="25" height="455" background="images/bg.gif"></td>
    <td width="719" height="455" valign="top"><table width="720" height="598" border="0" cellspacing="0">
        <tr> 
          <td>&nbsp;</td>
        </tr>
        <tr> 
          <td><img src="images/post_title.gif" align="absmiddle"> <%
			if pt="re" then
			response.write("回复：")
			response.write(request("rt"))
			else
			response.write("写新贴。")
			end if
			%> </td>
        </tr>
        <tr> 
          <td><div align="center"> 
              <table border="0" cellspacing="0" cellpadding="0">
                <tr> 
                  <td width="80" align="right">select icon:</td>
                  <td width="370" valign="middle"> <table width="100%" border="0" cellspacing="0" cellpadding="0" height="50">
                      <tr> 
                        <td align="left" valign="middle"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr> 
                              <td width="7%" align="center" valign="middle"> <table width="100%" height="100%" cellpadding="0" cellspacing="1" border="0" bgcolor="#0099ff">
                                  <tr> 
                                    <td align="center" height="40" bgcolor="#ffffff"><img name="showicon" src="icons/icon01.gif" width="7" height="29"> 
                                      <input type="hidden" name="icon" value="icon01.gif"> 
                                    </td>
                                  </tr>
                                </table></td>
                              <td width="93%"> &nbsp;&nbsp;<img src="icons/icon01.gif" onclick="seticon('01');" width="7" height="29"> 
                                <img src="icons/icon02.gif" onclick="seticon('02');" width="11" height="28"> 
                                <img src="icons/icon03.gif" onclick="seticon('03');" width="6" height="28"> 
                                <img src="icons/icon04.gif" onclick="seticon('04');" width="8" height="26"> 
                                <img src="icons/icon05.gif" onclick="seticon('05');" width="7" height="29"> 
                                <img src="icons/icon06.gif" onclick="seticon('06');" width="8" height="29"> 
                                <img src="icons/icon07.gif" onclick="seticon('07');" width="9" height="29"> 
                                <img src="icons/icon08.gif" onclick="seticon('08');" width="6" height="29"> 
                                <img src="icons/icon09.gif" onclick="seticon('09');" width="10" height="26"> 
                                <img src="icons/icon10.gif" onclick="seticon('10');"> 
                                <img src="icons/icon11.gif" onclick="seticon('11');"> 
                                <img src="icons/icon12.gif" onclick="seticon('12');" width="8" height="31"> 
                                <img src="icons/icon13.gif" onclick="seticon('13');" width="17" height="28"> 
                                <img src="icons/icon14.gif" onclick="seticon('14');" width="9" height="28"> 
                                <img src="icons/icon15.gif" onclick="seticon('15');" width="9" height="30"> 
                                <img src="icons/icon16.gif" onclick="seticon('16');" width="8" height="28"> 
                                <img src="icons/icon17.gif" onclick="seticon('17');" width="7" height="29"> 
                                <img src="icons/icon18.gif" onclick="seticon('18');" width="7" height="22"> 
                                <img src="icons/icon19.gif" onclick="seticon('19');" width="8" height="22"> 
                                <img src="icons/icon20.gif" onclick="seticon('20');" width="7" height="22"> 
                                <img src="icons/icon21.gif" onclick="seticon('21');" width="8" height="29"> 
                                <img src="icons/icon22.gif" onclick="seticon('22');" width="8" height="28"> 
                                <img src="icons/icon23.gif" onclick="seticon('23');" width="7" height="27"> 
                                <img src="icons/icon24.gif" onclick="seticon('24');" width="8" height="30"> 
                                <img src="icons/icon25.gif" onclick="seticon('25');" width="9" height="29"> 
                                <img src="icons/icon26.gif" onclick="seticon('26');" width="7" height="29"> 
                                <img src="icons/icon27.gif" onclick="seticon('27');" width="9" height="30"> 
                              </td>
                            </tr>
                          </table></td>
                      </tr>
                    </table></td>
              </table>
              <table border="0" cellspacing="0" cellpadding="0" width="500">
                <tr> 
                  <td align="right" width="80">title:</td>
                  <td width="370"> <input type="text" name="ptitle" size="20" <% if pt="re" then %> value="re: <%=request("rt")%>" <% end if %>>
                    签名？ 
                    <input type="checkbox" name="addsign" value="no"> </td>
                </tr>
                <tr> 
                  <td align="right" width="80" valign="top">write here:</td>
                  <td width="370"> <textarea name="pbody" cols="45" rows="10"></textarea> 
                    <br> <a href="javascript:openeditor();">打开html编辑器</a> | <a href="#" onclick="window.open('em/em.htm','','left=100,top=100,width=450,height=450');"><img src="em/em16.gif" border="0">添加表情</a> 
                  </td>
                </tr>
                <tr> 
                  <td></td>
                  <td align="left"><br> <p> 
                      <input type="hidden" name="bid" value="<%=bid%>">
                      <input type="hidden" name="isok" value="ok">
                      <input type="hidden" name="sign">
                      <input type="hidden" name="type" value="<%=pt%>">
                      <input type="hidden" name="bdid" value="<%=bdid%>">
                      <input type="submit" name="submit" value="post">
                      &nbsp;&nbsp; 
                      <input type="button" name="cancel" value="back" onclick="window.location.replace('main.asp?bdid=<%=bdid%>');">
                  </td>
                </tr>
              </table>
            </div></td>
        </tr>
        <tr> 
          <td height="75">&nbsp;</td>
        </tr>
      </table></td>
    <td width="25" height="451" background="images/bg.gif"></td>
  </tr>
  <tr> 
    <td height="12" colspan="3"><div align="center"> 
        <table width="758" border="0" align="center" cellspacing="0">
          <tr> 
            <td height="35" colspan="2" background="images/footbg.gif"> <div align="center">3鸟设社[v1.2色彩连视]T恤论论坛 
                www.3niao.com</div></td>
          </tr>
          <tr> 
            <td width="392" background="http://www.3niao.com/v2/down1/images/footgb1.gif">&nbsp;</td>
            <td width="362"><div align="right"><img src="http://www.3niao.com/v2/down1/images/foot.jpg"></div></td>
          </tr>
        </table>
      </div></td>
  </tr>
</table>
  </center>
</div>

</body>

</html>
<% end sub %>
<% closedb %>