<!--#INCLUDE FILE="conn.asp" -->
<!--#include file="admin_Checkuser.asp"-->
<HTML><HEAD><title><%=StrVar(1)%>--管理页面</title>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<!--#include file="inc/admin_main.css"-->
</HEAD>
<BODY leftMargin=0 topMargin=0 marginwidth="0" marginheight="0">
<%
if  not sysadmin or session("adminlogin")<>"0K" Then
	Errmsg=Errmsg+"<br>"+"<li>本页面为管理员专用，请<a href=admin_index.asp target=_top>登陆</a>后进入。"
	Call Error("Information",ErrMsg)
Else
	Call main()
End if

Call endconnection()

Sub main()
%>
<table cellpadding=5 cellspacing=1 border=0 width=90% Class=TableBorder align=center>
  <tr>
	<th>欢迎<b><%=membername%></b>进入管理页面</th>
</tr>
</table>
<tr>
	<td width="100%" valign=top>
		<%
		if Request("action")="send" Then
			Call sendmsg()
		ElseIf Request("action")="delete" Then
			Call delmsg()
		Else
			Call msgform()
		End if
		%>
	</td>
</tr>
</table>
<%
End Sub


Sub msgform()
%>
<BR>
<form method="POST" action=admin_sms.asp>
<input type=hidden name=action value=send>
<table width="600" border="0" cellspacing="1" cellpadding="5"  align=center Class=TableBorder>
<!-- <tr> 
<th height="11" colspan="2" align=center><b>短消息发布与管理</b></font></th>
</tr>
 -->
 <tr> 
<th height="11" colspan="2" >短消息广播</font></th>
</tr>
<tr> 
<td width="30%" height="18" class=forumrow>&nbsp;&nbsp;发送对象</font></td>
<td width="70%" height="18" class=forumrow> 
	<Select name=stype size=1>
	<option value="1">所有学校管理员</option>
	<option value="2">所有校友录用户</option>
	<option value="3">当前在线用户</option>
	</Select>
</td>
</tr>
<tr> 
<td width="30%" height="18" class=forumrow>&nbsp;&nbsp;消息标题</font></td>
<td width="70%" height="18" class=forumrow> 
<input type="text" name="title" size="60" >
</td>
</tr>
<tr>
<td width="30%" height="18" class=forumrow>&nbsp;&nbsp;消息内容</font></td>
<td width="70%" height="18" class=forumrow> 
        <textarea name="content" cols=60 rows=6></textarea>
</td></tr>
<tr> 
<td height="18" colspan="2" align=right Class=forumrowhighlight> 
<input type="submit" name="Submit" value="发 送" class=button>&nbsp;&nbsp;<input type="reset" name="reset" value="重 写" class=button>
</td>
</tr>
</table>
</form>
<BR>
<table width="600" border="0" cellspacing="1" cellpadding="5"  align=center Class=TableBorder>
<tr> 
<th height="11">短消息管理</th>
</tr>
<tr> <form action="admin_sms.asp?action=delete" method=post>
<td height="40" class=forumrow><BR><BR>&nbsp;&nbsp;批量删除&nbsp;<Select name="delDate" size=1>
	<option value=7>一个星期前</option>
	<option value=30>一个月前</option>
	<option value=91>三个月前</option>
	<option value=182>半年前</option>
	<option value=365>一年前</option>
	<option value="all">所有信息</option>
	</Select>&nbsp;的短信息					  &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="isread" value="yes">包括未读信息
			<input type="submit" name="Submit" value="删除" class=button><br><BR></td></form>
</tr>
</table>
<BR>
<%
End Sub


Sub sendmsg()
	Dim rs,sql,sendsql
'on Error resume next
	if Request("title")="" Then
		Errmsg=Errmsg+"<br>"+"<li>请输入短信标题。"
		founderr=True
	Else
		title=trim(checkstr(Request("title")))
	End if

	if Request("content")="" Then
		Errmsg=Errmsg+"<br>"+"<li>请输入短信内容。"
		founderr=True
	Else
		content=rtrim(checkstr(Request("content")))
	End if

	if founderr=True Then 
	Call Error("Information",ErrMsg)
		Exit Sub
	End if


	if Request("stype")="1" Then
		sql = "Select distinct userid from joinclass where degree>6"
	ElseIf Request("stype")="2" Then
		sql = "Select userid from student"
	elseif Request("stype")="3" then
	sql = "Select userid from online"
	End if

	Set rs=conn.execute(sql)
	do until rs.EOF 
		sendsql="insert into message(incept,sender,title,content,sendtime,flag,issend,delS) values('"&rs(0)&"','"&StrVar(1)&"','"&title&"','"&content&"',getdate(),0,1,2)"
		conn.Execute(sendsql)
		rs.MoveNext 
	Loop
	rs.Close
	Call adminmsg("操作成功，短信已经发送！")

End Sub


Sub delmsg()

	if Request("isread")="yes" Then
	selflag=""
	Else
	selflag=" and flag=1"
	End if

	howlong=Request("delDate")
	if howlong="all" Then
	sql="delete from message where id>0 "&selflag
	Else
	sql="delete from message where datediff(day,sendtime,getdate())>"&cint(howlong)&" "&selflag
	End if 
	conn.Execute(sql)
		Call adminmsg("操作成功，短信成功删除！")

End Sub

Function Checkstr(str)
	str=replace(str,"'","''")
	Checkstr=str
End Function

%>
</BODY></HTML>



