<%@ Language=VBScript%>
<%
Response.Buffer=false
Response.Expires=0
%>
<!-- #include file="./dsnroot.asp" -->
<!-- #include file="./links.asp" -->
<%
set cn=Server.CreateObject("ADODB.Connection")
set rs=Server.CreateObject("ADODB.Recordset")
set rs1=Server.CreateObject("ADODB.Recordset")
cn.Open mycnstr
xx=1
menu="0000100"
id=Request.QueryString ("id")
writeok=Request.QueryString ("writeok")
classid=Request.QueryString ("classid")
if id="" then
	  id=0
   else
	id=cint(id)
	newtitle=now()&"回复"&id
end if
if writeok="" then
	  writeok=0
   else
	writeok=cint(writeok)
end if
if id=0 then
		titletxt="发表新话题"
	else
		sqltext="select title from bbs where id="&id&" and enable=1"
		rs.Open sqltext,cn,1,1
		if not rs.EOF then
			titletxt="回复话题：--"&trim(rs("title"))
		end if
		rs.Close 
end if			
if classid="" then
	  classid=0
   else
	classid=cint(classid)
end if	
if classid=0 then
	sqltext="select id from bbs_class where enable=1 order by pl"
	rs.Open sqltext,cn,1,1
	if not rs.EOF then
		classid=rs("id")
	end if
	rs.Close 
end if
if classid<>0 then
	sqltext="select title from bbs_class where id="&classid&" and enable=1"
	rs.Open sqltext,cn,1,1
	if not rs.EOF then
		class_titletxt=trim(rs("title"))
	else
		err=1	
	end if
	rs.Close 
else
	err=1	
end if
if err=1 then 
		Response.Write "该版面不存在！"
		Response.End 
end if			
sqltext="select top 1 body from classes where enable=1 and id=54" 
rs.Open sqltext,cn,1,1
if not rs.EOF then
		glstr1=trim(rs("body"))
end if      
rs.Close 
sqltext="select top 1 body from classes where enable=1 and id=55" 
rs.Open sqltext,cn,1,1
if not rs.EOF then
		glstr=trim(rs("body"))
end if      
rs.Close 
if flag=1 then
	if session("userflag")<>1 then
		err=9
		errtxt="本版面为内部员工交流区，您无权限进入"
	end if
end if
if Request.ServerVariables("REQUEST_METHOD")="POST" and err<>9 then
	newtitle=trim(Request.Form("titlename"))
	newcontent=trim(Request.Form("content"))
	newemote=Request.Form("emote")
	bbsflag=cint(Request.Form("bbsflag"))
	userflag=cint(Request.Form("userflag"))
	username=trim(Request.Form("username"))
	userpass=trim(Request.Form("userpass"))
	if session("username")="" then
	if checktxt(username,0,0,0)=1 then 
		err=2
		errtxt=errtxt&"会员名不能为空，不能发表"
	end if	
	if checktxt(username,2,0,0)=3 then 
		err=2
		errtxt=errtxt&"|您所填写的会员名中有非法字符，不能发表"
	end if    
	if checktxt(userpass,0,0,0)=1 then	
		err=2
		errtxt=errtxt&"|密码不能为空，不能发表"
	end if
	end if
	if checktxt(newtitle,0,0,0)=1 then	
		err=1
		errtxt=errtxt&"|标题不能为空，不能发表"
	end if
	if checktxt(newtitle,3,0,0)=4 then 
		err=1
		errtxt=errtxt&"|标题中有非法字符，请检查重试"
	end if
	if checktxt(newtitle,1,1,45)=2 then 
		err=1
		errtxt=errtxt&"|标题超过了系统允许的范围，请检查重试"
	end if	
	if checktxt(newcontent,0,0,0)=1 and id<>0 then 
		err=1
		errtxt=errtxt&"|回复话题时，内容不能为空"
	end if	

	if err=0 and session("username")="" then
		if userflag=0 then
				tabname="userbase"
		elseif userflag=1 then
				tabname="userls"	
		end if		
		sqltext="select * from "+tabname+" where enable=1 and username='"+username+"' and password='"+userpass+"'"
		rs.Open sqltext,cn,1,2
		if not rs.EOF then'
			session("username")=trim(rs("username"))
			session("userflag")=userflag
		    rs("logincount")=rs("logincount")+1
		    rs("loginlast")=now()
		    rs("loginlastip")=Request.ServerVariables("Remote_HOST")
			rs.Update 			
		else
			err=3
			errtxt=errtxt&"|用户名或者密码错误，不能发表"		
		end if
		rs.Close 
	end if
	if err=0 then
		if id<>0 then
			sqltext="select relcount,upupdate from bbs where enable=1 and id="&id
			rs.Open sqltext,cn,1,2
			if not rs.EOF then
				rs("relcount")=rs("relcount")+1
				rs("upupdate")=now()
				rs.Update 
			end if
			rs.Close 
		end if
		sqltext="select * from bbs"
		rs.Open sqltext,cn,1,2
		rs.AddNew 
		rs("title")=newtitle
		rs("userflag")=session("userflag")
		rs("username")=session("username")
		rs("face")=newemote
		rs("ipaddress")=Request.ServerVariables("Remote_HOST")
		rs("creatdate")=now()
		rs("qx")=bbsflag
		rs("pid")=id
		rs("classid")=classid
		rs("content")=Request.Form ("content")
		rs("upupdate")=now()
		rs.Update 
		rs.Close 
		Response.Redirect "forum_write.asp?writeok=1&classid="&classid
	end if
end if	

%>
<!-- #include file="./func.inc" -->
<!-- #include file="./begin.asp" -->
      <table width="778" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td width="170" bgcolor="#079C07" valign="top" align="center"> 
            <!-- #include file="./bbs_left.asp" -->
          </td>
          <td bgcolor="#FFFFEC" valign="top" align="center"> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td height="70">&nbsp;</td>
              </tr>
            </table>
            <table width="95%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td width="20" height="20"><img src="images/company/title_sign.gif" width="14" height="18"></td>
                <td class="font2"><font color="#996600"><b><%=class_titletxt%></b></font></td>
                
              </tr>
            </table>
            <table width="95%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#B78900">
              <tr> &nbsp; 
                <td class="font1" height="20">&nbsp;<img src="images/arrow_news.gif" width="12" height="12">&nbsp;<font color="#000000"><b><font color="#FFFFFF"><%=titletxt%></font></b></font></td>
                <td align=right><a href="forum.asp?classid=<%=classid%>" class="a02"><font color="#ffffff">[返回论坛]</font></a>&nbsp;</td>
              </tr>
            </table>
            <table width="95%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td>
                <%
     			if instr(errtxt,"|")>0 then
					dim errlist
					errlist=split(errtxt,"|")
					for i = 0 to ubound(errlist)
						if trim(errlist(i))<>"" then
				%>
						<table width="100%" bgcolor=FFFFec cellpadding="0" cellspacing="0">
						  <tr bgcolor="ffffec" height="25" class=font1>
							<td>&nbsp;&nbsp;<font face=webdings color="red">4</font>&nbsp;<font color="red"><%=trim(errlist(i))%></font></td>
						  </tr>	
						</table>	
				<%			
	       				end if
					next
				end if		
				%>	
			   </td>
              </tr>
            </table>
 <%if writeok<>1 and err<>9 then%>       
<TABLE WIDTH="95%" BORDER="0" CELLSPACING="0" CELLPADDING="0" ALIGN="CENTER">
	<form action="forum_write.asp?id=<%=id%>&classid=<%=classid%>" method=post name=form1 autocomplete = "off">
  <TR VALIGN="middle" class=font1> 
	<td height="10"></td>
  </tr>		
 <%
 if Session("username")="" then%>	
  
  <TR VALIGN="middle" class=font1> 
    <TD CLASS="font1" align=right height=20>会员号：</TD>
    <TD> 
      <input type="text" name="username" size="12" class=font1><font color=red>*</font>
      <input type="radio" name="userflag" value="0" checked>会员&nbsp;&nbsp;
      <input type="radio" name="userflag" value="1">内部员工&nbsp;
    </TD>
  </TR>
  <TR VALIGN="middle" class=font1> 
    <TD CLASS="font1" align=right height=20>密码：</TD>
    <TD> 
	  <input type="password" name="userpass" size="12" class=font1><font color=red>*</font><font color=ff0000><%=errtxt1%></font>
	  若还没不是会员。点击此处<a href="forum_center.asp?flag=1" class=font1 target=_top>注册会员</a>。
    </TD>
  </TR>
 <%else%> 
  <TR VALIGN="middle" class=font1> 
    <TD CLASS="font1" align=right height=20>会员号：</TD>
    <TD> 
      <font color="red"><%=Session("username")%></font>
    </TD>
  </TR>
 <%end if%> 
  <%if id=0 then%>
  <TR VALIGN="middle" width=60 class=font1> 
    <TD CLASS="font1" align=right height=20>主题：</TD>
    <TD> 
      <INPUT type="text" value="<%=newtitle%>" name="titlename" maxlength=60 size=56><font color=red>*</font>
    </TD>
  </TR>
  <%else%>
  <input name="titlename" value="<%=newtitle%>" type="hidden">
  <%end if%>
  <TR VALIGN="TOP" class=font1> 
    <TD CLASS="font1" align=right>表情：</TD>
    <TD> 
<table width="95%" border="0" cellspacing="2" cellpadding="0">
  <tr>
    <td ><input checked name="emote" type="radio" value="25"></td>
    <td><img src="bbs/mood25.gif" width="20" height="20" alt border="0"></td>
    <td ><input  name="emote" type="radio" value="12"></td>
    <td><img src="bbs/mood12.gif" width="20" height="20" alt border="0"></td>	
    <td ><input  name="emote" type="radio" value="13"></td>
    <td><img src="bbs/mood13.gif" width="20" height="20" alt border="0"></td>	
    <td ><input  name="emote" type="radio" value="14"></td>
    <td><img src="bbs/mood14.gif" width="20" height="20" alt border="0"></td>	
    <td ><input name="emote" type="radio" value="15"></td>
    <td><img src="bbs/mood15.gif" width="20" height="20" alt border="0"></td>	
    <td ><input name="emote" type="radio" value="16"></td>
    <td><img src="bbs/mood16.gif" width="20" height="20" alt border="0"></td>	
    <td ><input  name="emote" type="radio" value="17"></td>
    <td><img src="bbs/mood17.gif" width="20" height="20" alt border="0"></td>	
    <td width="100%" >&nbsp;</td>			
  </tr>
  <tr>
    <td ><input  name="emote" type="radio" value="18"></td>
    <td><img src="bbs/mood18.gif" width="20" height="20" alt border="0"></td>
    <td ><input  name="emote" type="radio" value="19"></td>
    <td><img src="bbs/mood19.gif" width="20" height="20" alt border="0"></td>
    <td ><input  name="emote" type="radio" value="20"></td>
    <td><img src="bbs/mood20.gif" width="20" height="20" alt border="0"></td>	
    <td ><input  name="emote" type="radio" value="21"></td>
    <td><img src="bbs/mood21.gif" width="20" height="20" alt border="0"></td>	
    <td ><input  name="emote" type="radio" value="22"></td>
    <td><img src="bbs/mood22.gif" width="20" height="20" alt border="0"></td>	
    <td ><input  name="emote" type="radio" value="23"></td>
    <td><img src="bbs/mood23.gif" width="20" height="20" alt border="0"></td>	
    <td ><input  name="emote" type="radio" value="24"></td>
    <td><img src="bbs/mood24.gif" width="20" height="20" alt border="0"></td>	
    <td width="95%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT TYPE="submit" NAME="Submit" VALUE="提交" STYLE="background-color:d3d3d3; width: 75px; height:20px"></td>
  </tr>  
</table>
    </TD>
  </TR>
  <TR class=font1> 
    <TD CLASS="font1" align=right>内容：</TD>
    <TD> 
      <TEXTAREA rows=15 cols=70 name=content style="font-family:宋体"></TEXTAREA>
    </TD>
  </TR>
  <tr><td height="10"></td><td height="10"></td></tr>
</table>
<table width="95%">
  <TR VALIGN="TOP"> 
    <TD class="font1"> 
	    <center><b>发表话题时您必须遵守以下条款</b></center><br>
					·尊重网上道德，遵守《全国人大常委会关于维护互联网安全的决定》和《互联网电子公告服务管理规定》及中华人民共和国其他各项有关法律法规。<br> 
					·严禁发表危害国家安全、破坏民族团结、破坏国家宗教政策、破坏社会稳定、侮辱、诽谤、教唆、淫秽等内容的作品 <br>
					·承担一切因您的行为而直接或间接导致的民事或刑事法律责任 <br>
					·本贴提交者发言纯属个人意见，与本网站立场无关。 <br>
	      
    </TD>
  </TR>
  </form>
</table> 
<%else%>    
<table width="95%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
	<td><br><br>
	  <font face=webdings color=fe8c14>4</font>&nbsp;操作成功     <a href="./forum.asp?classid=<%=classid%>" class=a02 target=_top><font color="#ff6600">返回论坛</font>
	</td>
  </tr>
</table>
<%end if%>                        
            <table width="95%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td>&nbsp;</td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td width="170" bgcolor="#079C07" valign="top" align="center">&nbsp;</td>
          <td bgcolor="#FFFFEC" valign="top" align="center">
            <table width="95%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td colspan="2">&nbsp;</td>
              </tr>
              <tr> 
                <td background="images/company/point_line.gif" height="1" colspan="2"></td>
              </tr>
              <tr> 
                <td height="36" align="right"><img src="images/company/icon_top.gif" width="14" height="14"></td>
                <td height="36" width="30" align="center"><a href="#" class="a02">向上</a></td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
<!-- #include file="./end.asp" -->