<!-- #include file="setup.asp" -->
<!--#include file="z_dgconn.asp"-->
<%

top
if Request.Cookies("username")="" then
error("<li>您还还未<a href=login.asp>登陆</a>社区")
end if

if instr(RcUsername," ")>0 then:error("<li>非法操作"):end if

sql="select * from [user] where username='"&Request.Cookies("username")&"'"
rs.Open sql,Conn,1,3

if Request.Cookies("userpass")<>rs("userpass") then
error2("密码错误！")
end if%>

<%
	dim isfull
	isfull=false		

%>
<% 
dim lincept,lcontent,lmedianame,lurl,dguser
'-------------
dguser=HTMLEncode(Request.Cookies("username"))
lincept=HTMLEncode(Request.Form("incept"))
lcontent=HTMLEncode(Request.Form("content"))
lmedianame=HTMLEncode(Request.Form("medianame"))
lurl=HTMLEncode(Request.Form("url"))

if lincept="" then 
	error("<li>请输入接收用户名")
	founderr=true
else
	if instr(lincept,"全体会员")>0 then
		lincept="全体会员"
		isfull=true
	else 	
		lincept=split(lincept,"|")
		if ubound(lincept)>=5 then
			error("<li>最多只能发送给5个用户")
			founderr=true
		end if
	end if	
end if
if lmedianame="" then 
	error("<li>请输入点播名称")
	founderr=true
end if
'if lurl="" or lurl="http://" then 
lur2=right(lurl,3)
if lur2<>"mp3" and lur2<>"mid" and lur2<>"wav" and lur2<>"wma" and lur2<>"swf" and lur2<>"mpg" and lur2<>".rm" and lur2<>".ra" and lur2<>"asf" then
	error("<li>请正确输入音乐地址")
	founderr=true
end if

if lcontent="" then 
	error("<li>请输入祝福语")	
	founderr=true
end if
if len(lmedianame)>50 then '--------------判断名字
	error("<li>点播名称不能多于50字")
	founderr=true	
end if
if len(lcontent)>200 then '--------------判断名字
	error("<li>祝福语不能多于200字")
	founderr=true	
end if
dim haverr 
    haverr=false
    call updata()
	call CloseDB()
'===================================
top
dim v1,v2
v1=Cstr(Request.ServerVariables("HTTP_REFERER"))
v2=Cstr(Request.ServerVariables("SERVER_NAME"))
if v1="" or isnull(v1) or mid(v1,8,len(v2))<>v2 then error("<li>非法操作")
sub updata()
	dim ii
	
	if isfull then
			set rs=server.createobject("adodb.recordset")
			sql="select * from media" 
			rs.open sql,connDG,3,2
			rs.addnew
			rs("sender")=dguser
			rs("incept")=lincept
			rs("sendtime")=now()
			rs("content")=lcontent
			rs("medianame")=lmedianame
			rs("url")=lurl
			rs.update
			rs.close
			set rs=nothing
			succtitle="点播成功"
            message=message&"<br><li><a href=z_dgwrite.asp>点播祝福已成功发出!你向论坛所有的会员发送了点播祝福!正在自动返回点播页............<li><a href=default.asp>返回论坛首页</a>"
            succeed(""&message&"<meta http-equiv=refresh content=3;url=z_dgwrite.asp>")

	
	else	
		for ii=0 to ubound(lincept)
			set rs=server.createobject("adodb.recordset")
			sql="select username from [user] where username='"&lincept(ii)&"'"
			rs.open sql,conn,1,1
			if rs.eof and rs.bof then
				error("<li>论坛没有<font color=red>["&lincept(ii)&"]</font>这个用户")
				haverr=true
			else
				rs.close
				sql="select * from [media]" 
				rs.open sql,connDG,3,2
				rs.addnew
				rs("sender")=dguser
				rs("incept")=lincept(ii)
				rs("sendtime")=now()
				rs("content")=lcontent
				rs("medianame")=lmedianame
				rs("url")=lurl
				'rs("yin")=lyin
				rs.update
				rs.close
				set rs=nothing
				'--------------------发送点播信息到网内短信
				dim sender,incept,content,lurl1
				lurl1=Request.Form("url")
				sender=Request.Cookies("username")
				content=""&[sender]&"点了一首 "&lmedianame&"给你！ 祝福语："&lcontent&""
				conn.execute("insert into message(author,incept,content) values ('"&sender&"','"&lincept(ii)&"','"&content&"')")
				conn.execute("update [user] set newmessage= +1 where username='"&lincept(ii)&"'")
				'--------------------发送点播信息到网内短信
				succtitle="点播成功"				
		message=message&"<br><li><a href=z_dgwrite.asp>你点播给<b>"&lincept(ii)&"</b>成功!系统已向<b>"&lincept(ii)&"</b>发出短消息通知!"
			end if	
         next		
                succeed(""&message&"<meta http-equiv=refresh content=3;url=z_dgwrite.asp>")		
	end if		
end sub
%>


<%
htmlend
%>
