<!--#include file=conn.asp-->
<!--#include file=config.asp-->
<!--#include file=const.asp-->
<!--#include file=char.asp-->
<%
 '=========================================================
' File: userbook.asp
' Version:3.0
' Date: 2005-10-4
' Script Written by xmrxw
'=========================================================
' Copyright (C) 2004,2005 Xmrxw.Com All rights reserved.
' Web: http://www.xmrxw.com,http://www.xmzxw.com
' Email: info@mssky.com,super@mssky.com
' QQ：10689579　Msn：zdlmicr@hotmail.com
'=========================================================
dim ClassID
ClassID=checkStr(trim(request("ClassID")))
if ClassID="" or not isInteger(ClassID) then
	Errmsg=Errmsg+"<br>"+"<li>参数错误。"
	founderr=true
else
ClassID=Clng(ClassID)
end if
response.buffer=true
if ClassID=1 then
stats="约会留言"
elseif ClassID=2 then
stats="站内留言"
elseif ClassID=3 then
stats="速配留言"
elseif ClassID=4 then
stats="聚会留言"
end if

call nav()
if not founduser then
	Errmsg=Errmsg+"<br>"+"<li>您还没有登陆，请登陆后进行修改。"
	founderr=true
end if

if founderr then
	call head_var("","")
	call Mslove_error()
else
	call head_var(stats,"userbook.asp?ClassID="&ClassID&"")
call tumppages()'翻页处理
strFileName="userbook.asp?ClassID="&ClassID&""
Select Case Trim(Request("action"))
	Case "清空"
		Stats="清空留言"
		Call AllDeldata()
	Case "删除"
		Stats="删除留言"
		Call Deldata()
	Case "add"
		Call add()
	Case "saveadd"
		Stats="保存留言"
		Call saveadd()
	Case "view"
		Stats="查看留言"
		Call view()	
	case else
		call main()
End Select
if founderr then call Mslove_error()
end if
call activeonline()
call footer()

sub main()
%>
<table width="100%" align=center cellpadding=3 cellspacing=1 class=tableborder1>
  <form action="userbook.asp" method=POST name="theForm">
    <tr align="left"> 
      <th height="28" colspan="5" align="center"  class=tablebody1><%=stats%>列表</th>
    </tr>
    <tr align="center"> 
      <td width="7%" height="25"  class=tablebody2>状态 </td>
      <td width="56%"  class=tablebody2>主　题</td>
      <td width="13%"  class=tablebody2>发布者</td>
      <td width="17%"  class=tablebody2>时间</td>
      <td width="7%"  class=tablebody2>操作</td>
    </tr>
	<%dim NID,FlagR
	set rs=server.createobject("adodb.recordset")
  sql="select NID,Title,Addtime,Postname,Flag from Ms_Note where Username='"&trim(membername)&"' and TypeID="&ClassID&" order by addtime desc"
rs.Open sql,conn,1,1
if not (rs.eof and rs.bof) then
call rspages()
do while not rs.eof and page_count<Cint(MaxPerPage)
NID=rs("NID")
FlagR=rs("Flag")%>
    <tr align="center"> 
      <td align="center"  class=tablebody1><%if FlagR=1 then
	  response.Write("<font color=blue>已阅</font>")
	  else
	  response.Write("<font color=red>未阅</font>")
	  end if%></td>
      <td align="left"  class=tablebody1><a href=?action=view&Nid=<%=Nid%>&Classid=<%=Classid%> title=查看信息><%=rs("Title")%></a></td>
      <td align="center"  class=tablebody1><a href=dispuser.asp?username=<%=rs("Postname")%>><%=rs("Postname")%></a></td>
      <td align="center"  class=tablebody1><%=rs("Addtime")%></td>
      <td align="center"  class=tablebody1><input type=checkbox name=id value=<%=NID%>></td>
    </tr>
	  <%page_count=page_count+1
  rs.movenext
  loop
  else
  response.Write("<tr align=""center""> <td colspan=""5"" align=""left"" class=tablebody2>当前没有任何留言。</td></tr>")
  end if
    if totalrec>0 then
%>
    <tr align="center"> 
      <td colspan="5" align="left"  class=tablebody2><%call showpage(strFileName)%></td>
    </tr>
<%end if%>
    <tr align="right"> 
      <td colspan="5"  class=tablebody1>跳转到：<select name=ClassID onchange='javascript:submit()'>
<option value=1 <%if ClassID=1 then%>selected<%end if%>>约会留言</option>
<option value=2 <%if ClassID=2 then%>selected<%end if%>>站内留言</option>
<option value=3 <%if ClassID=3 then%>selected<%end if%>>速配留言</option>
<option value=4 <%if ClassID=4 then%>selected<%end if%>>聚会留言</option>
</select>
        <input type=button name=action2 onclick="location.href='?action=add&ClassID=<%=ClassID%>'" value="添加留言">
        <input type=checkbox name=chkall value=on onclick="CheckAll(this.form)">
        选中所有显示记录 
        <input type=submit name=action onclick="{if(confirm('确定清空所有记录吗?')){this.document.theForm.submit();return true;}return false;}" value="清空"> 
        <input type=submit name=action onclick="{if(confirm('确定删除选定的记录吗?')){this.document.theForm.submit();return true;}return false;}" value="删除">
      </td>
    </tr>
  </form>
</table>
<%
end sub

sub AllDeldata()''清空
if not (master or standmaster or supermaster) and ClassID=0 then
Errmsg=Errmsg+"<li>"+"只有管理员可以管理网站公告。"
Founderr=true
exit sub
end if
conn.execute("delete from Ms_Note where TypeID="&ClassID&" and Username='"&trim(membername)&"'")
sucmsg=sucmsg+"<br>"+"<li>您已成功清空所有记录。"
	call Mslove_suc()
end sub

sub Deldata()
dim delid,FixID
delid=replace(request("id"),"'","")
delid=replace(delid,";","")
delid=replace(delid,"--","")
delid=replace(delid,")","")
fixid=replace(delid,",","")
fixid=Trim(replace(fixid," ",""))
If Not IsNumeric(fixid) Then
	Errmsg=Errmsg+"<br><li>错误的参数。"
	founderr=true
End If
if delid="" or isnull(delid) then
Errmsg=Errmsg+"<li>"+"错误的参数。"
Founderr=true
end if
if not (master or standmaster or supermaster) and ClassID=0 then
Errmsg=Errmsg+"<li>"+"只有管理员可以管理网站公告。"
Founderr=true
exit sub
end if
if founderr=true then exit sub
conn.execute("delete from Ms_Note where TypeID="&ClassID&" and Nid in("&delid&")")
sucmsg=sucmsg+"<br>"+"<li>您已成功删除所选定的记录。"
	call Mslove_suc()
end sub


sub add()''发送留言
if not (master or standmaster or supermaster) and ClassID=0 then
Errmsg=Errmsg+"<li>"+"只有管理员可以添加网站公告。"
Founderr=true
exit sub
end if
%>
<table width="100%" align=center cellpadding=3 cellspacing=1 class=tableborder1>
  <form action="?action=saveadd" method=POST name="theForm">
    <tr> 
      <th height="28" colspan="2" align="center"  class=tablebody1><%=stats%></th>
    </tr>
    <input name="ClassID" type="hidden" id="ClassID" value="<%=ClassID%>">
    <tr> 
      <td width="22%" height="5" align="right" class=tablebody1>发布者：</td>
      <td width="78%" class=tablebody1><input disabled value="<%=trim(membername)%>" name="Postname" size="20"> 
        <input type="hidden" value="<%=trim(membername)%>" name="Postname"> 
      </td>
    </tr>
    <tr>
      <td width="22%" height="6" align="right" class=tablebody1>接收人：</td>
      <td class=tablebody1><input name="Touser" type="text" id="Touser" value="<%=request("Touser")%>" size="20"></td>
    </tr>
    <tr> 
      <td width="22%" height="13" align="right" class=tablebody1>标　题：</td>
      <td class=tablebody1><input name="title" type="text" id="title"></td>
    </tr>
    <tr> 
      <td height="25" align="right" class=tablebody1>内　容：</td>
      <td height="25" class=tablebody1><textarea name="Content" cols="60" rows="5" id="IDContent"></textarea> 
        <a style=cursor:hand onclick="if (parseInt(IDContent.rows)-3>0)(IDContent.rows=parseInt(IDContent.rows)-3)"><img src="Skins/Default/minus.gif" unselectable="on" border='0'></a> 
        <a style=cursor:hand onclick="if (parseInt(IDContent.rows)+3>3)(IDContent.rows=parseInt(IDContent.rows)+3)"><img src="Skins/Default/plus.gif" unselectable="on" border='0'></a></td>
    </tr>
    <tr align="center"> 
      <td height="27" colspan="2" class=tablebody1> <input class=2 type=Submit value="保存" name=Submit> 
        &nbsp; <input class=2 type="reset" name="Clear" value="清除"></td>
    </tr>
  </form>
</table>
<%end sub

sub saveadd()''保存留言
dim Title,Content,touser,postname
Title=checkStr(trim(request("Title")))
Content=checkStr(trim(request("Content")))
touser=checkStr(trim(request("touser")))
Postname=checkStr(trim(request("Postname")))
Classid=checkStr(trim(request("Classid")))
if Classid="" or not isnumeric(Classid) then
	errmsg=errmsg+"<br>"+"<li>参数错误。"
	founderr=true
end if
if not (master or standmaster or supermaster) and ClassID=0 then
Errmsg=Errmsg+"<li>"+"只有管理员可以添加网站公告。"
Founderr=true
exit sub
end if
if Title="" or strLength(request("Title"))>100 then
	errmsg=errmsg+"<br>"+"<li>标题不能为空长度不大于100个字符。"
	founderr=true
end if
if Content="" or strLength(request("Content"))>300 then
	errmsg=errmsg+"<br>"+"<li>内容不能为空长度不大于300个字符。"
	founderr=true
end if
if touser="" then
	errmsg=errmsg+"<br>"+"<li>接收信息用户名为空。"
	founderr=true
end if
if Postname="" or strLength(request("Postname"))>20 then
	errmsg=errmsg+"<br>"+"<li>接收对象用户名为空。"
	founderr=true
end if
if founderr=true then exit sub
conn.execute("Insert into Ms_Note (TypeID,Title,Content,Username,Postname,Flag,Addtime) VALUES ("&Classid&",'"&Title&"','"&Content&"','"&Touser&"','"&Postname&"',0,'"&now()&"')")
	sucmsg=sucmsg+"<br>"+"<li><b>您已经成功发送信息。"
		call Mslove_suc()
end sub

sub view()''查看留言
dim nid
Nid=checkStr(trim(request("Nid")))
if Nid="" or not isInteger(Nid) then
	Errmsg=Errmsg+"<br>"+"<li>参数错误。"
	founderr=true
else
Nid=Clng(Nid)
end if
if classid<>0 then
conn.execute("update Ms_Note set Flag=1 where Nid="&Nid&"")
end if
set rs=server.createobject("adodb.recordset")
if classid<>0 then
  sql="select Title,Content,Addtime,Postname from Ms_Note where Username='"&trim(MemberName)&"' and TypeID="&ClassID&" and Nid="&Nid&""
  else
  sql="select Title,Content,Addtime,Postname from Ms_Note where TypeID="&ClassID&" and Nid="&Nid&""
  end if
rs.Open sql,conn,1,1
if not (rs.eof and rs.bof) then%>
<table width="100%" align=center cellpadding=3 cellspacing=1 class=tableborder1>
  <tr align="left"> 
    <th width="100%" height="26" align="center"  class=tablebody1>&gt;&gt; <%=rs(0)%> &lt;&lt;</th>
  </tr>
  <tr align="center"> 
    <td class="tablebody1" style="LEFT: 0px; WIDTH: 100%; WORD-WRAP: break-word" vAlign="top" align="left"><blockquote><%=rs("Content")%></blockquote></td>
  </tr>
  <tr align="center"> 
    <td height="26" align="center" valign="top"  class=tablebody1><table cellSpacing="0" cellPadding="0" width="100%" border="0">
        <tr> 
          <td height="24" align="left">&nbsp;&nbsp;&nbsp;<b>发布人</b>： <a href=dispuser.asp?username=<%=rs("Postname")%>><%=rs("Postname")%></a></td>
          <td align="right"><b>发布时间</b>： <%=rs("addtime")%>&nbsp;&nbsp;</td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<%end if
rs.close
end sub%>
</body>
</html>