<!-- #include file="include/config_forum.asp" -->
<% if not(isnumeric(forumid)) then call cookies_type("forum_id") %>
<!-- #include file="include/config_frm.asp" -->
<!-- #include file="include/config_upload.asp" -->
<!-- #include file="include/conn.asp" -->
<%
call forum_first()
call forum_word()
tit=forumname&"（发表小字报）"
call web_head(2,0,2,0,0)

if int(popedom_format(login_popedom,41)) then call close_conn():call cookies_type("locked")
'-----------------------------------center---------------------------------
response.write forum_top("发表小字报") & kong

if lx=0 then
%>
  <script language=javascript>
   history.back()
   alert("小字报已暂时被管理员关闭！")
  </script>
<%
else
dim pemoney,pe:pe=int(web_var(web_num,20))
sql="select emoney from user_data where username='"&login_username&"'"
set rs=conn.execute(sql)
if not(rs.eof and rs.bof) then
 pemoney=rs("emoney")
end if
rs.close:set rs=nothing
if pemoney<pe then
  response.write "<table border=0><tr><td align=center height=180>"
  response.write "<font class=red>您没有足够的 <b>"&m_unit&"</b> 发表小字报！</font><br><br>（每发表一次小字报需要 <b>"&pe&"</b> "&m_unit&"）<br><br><br><a href='user_emoney.asp'>去兑换 <b>"&m_unit&"</b></a><br><br><a href='javascript:history.back(1)'>返回上一页</a>"
  response.write "</td></tr></table>"
else
if trim(request.form("write"))="ok" then
  response.write "<table border=0><tr><td align=center height=200>"
  if post_chk()="no" then
    response.write web_var(web_error,1)
  else
    response.write write_chk()
  end if
  response.write "</td></tr></table>"
else
  response.write write_type()
end if
end if
end if

'---------------------------------center end-------------------------------
call web_end(0)

function write_type()
%>
<script language=javascript><!--
function check(write_frm)
{
  if(write_frm.topic.value=="" || write_frm.topic.value.length>50)
  {
   alert("你还没完全留下所需信息！\r\n\n小字报的 主题 是必须要的；\n且长度不能超过50个字符。");
   return false;
  }
  if(write_frm.jk_word.value=="" || write_frm.jk_word.value.length><%response.write word_size*1024%>)
  {
   alert("你还没完全留下所需信息！\r\n\n小字报的 内容 是必须要的；\n且大小不能超过<%response.write word_size%>KB。");
   return false;
  }
}
--></script>
<script language=javascript src='style/em_type.js'></script>
<script language=javascript src='style/form_ok.js'></script>
<%response.write forum_table1%>
<form name=write_frm action='xzb_write.asp?forum_id=<%response.write forumid%>' method=post onsubmit="frm_submitonce(this);">
<input type=hidden name=write value='ok'>
<input type=hidden name=upid value=''>


<tr height=30<%response.write forum_table3%>>
<td width='20%' align=center>用户信息：</td>
<td width='80%'>&nbsp;&nbsp;用户名：<input type=username name=username value='<%response.write login_username%>' size=18 maxlength=20>&nbsp;&nbsp;
密码：<input type=password name=password value='<%response.write login_password%>' size=18 maxlength=20>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font class=gray>[ <a href='user_main.asp?username=<%response.write server.htmlencode(login_username)%>'>用户中心</a> ]</font>&nbsp;&nbsp;&nbsp;&nbsp;
<font class=gray>[ <a href='login.asp?action=logout'>退出登陆</a> ]</font></td>
</tr>
<tr height=30<%response.write format_table(3,1)%>>
<td align=center>小字报主题：</td>
<td>
  <table border=0 cellspacing=0 cellpadding=0><tr>
  <td>&nbsp;&nbsp;<%call frm_topic("write_frm","topic")%></td>
  <td>&nbsp;<input type=text name=topic size=60 maxlength=50><%response.write redx%>长度不能超过50</td>
  </tr></table>
</td>
</tr>
<tr height=35<%response.write format_table(3,1)%>>
<td align=center><%call frm_ubb_type()%></td>
<td><%call frm_ubb("write_frm","jk_word","&nbsp;&nbsp;")%></td>
</tr>
<tr align=center<%response.write forum_table3%>>
<td><table border=0><tr><td class=htd><font class=red>发表需</font> <b><%response.write pe%></b>&nbsp;<font class=blue><%response.write m_unit%></font><br><b>小字报内容：</b><br><%call frm_word_size("write_frm","jk_word",word_size,"内容")%><br><%response.write word_remark%><br>
</td></tr></table></td>
<td><table border=0><tr><td>
  <textarea name=jk_word rows=12 cols=93 title='按 Ctrl+Enter 可直接发送' onkeydown="javascript:frm_quicksubmit();"></textarea></td></tr></table></td>
</tr>
<tr height=30<%response.write forum_table3%>><td align=center>E M 贴图：</td><td>&nbsp;&nbsp;<script language=javascript>jk_em_type('s');</script></td></tr>
<tr<%response.write format_table(3,1)%>><td colspan=2 align=center width=777 height=60>&nbsp;&nbsp;<script language=javascript>jk_em_type('b');</script></td></tr>
<tr align=center height=30<%response.write forum_table3%>>
<td>发表小字报：</td>
<td><input type=submit name=wsubmit value='可以发表啦' onclick="return check(write_frm)">　&nbsp;<input type=button value='预览内容'>　&nbsp;<input type=reset value='清除重写'>　&nbsp;（按 Ctrl + Enter 可快速发表）</td></tr>
</form></table><br>
<%
end function

function write_chk()
  dim topic,word,founderr,rs,sql,now_tim,sort,xzb
  topic=code_form(trim(request.form("topic")))
  word=code_word(request.form("jk_word"))
  founderr=""
  if login_username="" or isnull(login_username) then
    founderr=founderr & "<br><li><font class=red_2>您还没有登陆本站！因此不能发表小字报。</font>"
  end if
  if topic="" or len(topic)>50 then
    founderr=founderr & "<br><li>小字报的 <font class=founderr>主题</font> 是必须要的；且长度不能超过50个字符！"
  end if
  if word="" or isnull(word) or len(word)>word_size*1024 then
    founderr=founderr & "<br><li>小字报的 <font class=founderr>内容</font> 是必须要的；且大小不能超过"&word_size&"KB！"
  end if
  
 if founderr="" then
   set rs=server.createobject("adodb.recordset")
      sql="select * from gongao "
      rs.open sql,conn,1,3
      rs.addnew
      rs("topic")=topic
      rs("username")=login_username
      rs("word")=word
      rs("forum_id")=forumid
      rs("tim")=now_time
      rs("count")=0
      rs.update
      rs.close:set rs=nothing
      sql="update user_data set emoney=emoney-"&pe&" where username='"&login_username&"'"
      conn.execute(sql)

    response.write VbCrLf & "<table border=0 width=300>" & _
        	   VbCrLf & "<tr><td align=center height=30><font class=red>小字报发表成功！谢谢您。</font></td></tr>" & _
        	   VbCrLf & "<tr><td height=30>您现在可以选择以下操作：</td></tr>" & _
        	   VbCrLf & "<tr><td>　　1、<a href='forum_list.asp?forum_id=" & forumid & "'>返回 <b>" & forumname & "</b></a></td></tr>" & _
        	   VbCrLf & "<tr><td>　　2、<a href='forum.asp'>返回论坛首页</a></td></tr>" & _
        	   VbCrLf & "<tr><td height=30>系统将在 " & web_var(web_num,5) & " 秒钟后自动返回 <b>" & forumname & "</b> 。</td></tr>" & _
		   VbCrLf & "</table><meta http-equiv='refresh' content='" & web_var(web_num,5) & "; url=forum_list.asp?forum_id=" & forumid & "'>"
  else
    response.write found_error(founderr,"350")
  end if
end function
%>