<!-- #include file="inc.asp" -->
<!-- #include file="ydzq.asp" -->
<%call head()

dim path,tid,pathall
path=request.querystring("path")
tid=request.querystring("tid")
info=request.querystring("info")
if tid="" or IsNumeric(tid)=False then
 Call Error("<card title=""下载附件""><p>ID无效！")
  end if
if path="" then
 Call Error("<card title=""下载附件""><p>地址无效！")
  end if
  
Select Case info
	Case "ok"   
		Call downok()
	Case "mail"  
		Call mailok()
	Case else
		Call list()
end select 


Sub list

Call saycarda("下载附件")



 Response.Write "<a href='down.asp?info=ok&amp;tid="&tid&"&amp;saytk="&saytk&"&amp;sid="&sid&"&amp;path="&path&"'>直接下载</a>"
 Response.Write "|<a href='down.asp?info=mail&amp;tid="&tid&"&amp;saytk="&saytk&"&amp;sid="&sid&"&amp;path="&path&"'>发到邮箱</a>"
 Response.Write "<br/><a href='topic.asp?tid="&tid&"&amp;saytk="&saytk&"&amp;sid="&sid&"'>太黑了,我闪</a><br/>"
 
 response.write"注意:下载附件和发文件到自己的邮箱都要用到"&bbsmyjb&getcent&"<br/>"
response.write "您现在持有"&myjb&getcent&"<br/>"

end sub

sub downok()
if myjb>=abs(int(bbsmyjb)) then

conn.Execute("update Users set myjb=myjb-"&abs(int(bbsmyjb))&" Where id="&myid)

if Instr(path,"file/")>0 then
pathall="http://"&Request.ServerVariables("HTTP_HOST")&"/bbs/"&path
else
pathall="http://"&Request.ServerVariables("HTTP_HOST")&"/bbs/"&deCode_base64(path)
end if


Call cardz("正在下载文件中，请稍后",""&pathall&"")


response.write "正在下载文件中，请稍后..."
 Response.Write "<br/><a href='"&pathall&"'>手动直接下载</a><br/>"
 Response.Write "<a href='down.asp?tid="&tid&"&amp;saytk="&saytk&"&amp;sid="&sid&"&amp;path="&path&"'>返回上一级</a><br/>"
else
 Call Error("<card title=""下载附件""><p>您的"&getcent&"不足！下载附件需用"&bbsmyjb&getcent&"<br/>")
  end if
end sub

sub mailok
Call saycardd("发送附件到邮箱")

if myjb>=abs(int(bbsmyjb)) then

conn.Execute("update Users set myjb=myjb-"&abs(int(bbsmyjb))&" Where id="&myid)

dim path2
if Instr(path,"file/")>0 then
path2=path
else
path2=deCode_base64(path)
end if

dim emname,mail
  Call Error("此功能正在开发中...！")
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select ID,name,email from [users] where id="&myid,conn,1,1
	if CheckEmail(rs("email"))=False then
  Call Error("对不起，您的个人资料中还没有填写邮箱或者您的邮箱错误！")
end if
 emname=rs("name")
 mail=rs("email")
rs.close
set rs=nothing
Dim msg
Set msg = Server.CreateObject("JMail.Message")
msg.ContentType = "multipart/mixed"
msg.CharSet = "GB2312"
msg.FromName = "发送下载附件"				'发件者的签名
msg.From = ""&mail&""			'发件者邮箱
msg.ReplyTo = ""&mail&""			'指定回复邮箱
msg.Subject = "发送下载附件"				'邮件主题
msg.AddAttachment(Server.MapPath(path2))	'附件地址，必填
msg.Body =""
msg.Body =msg.Body &emname&"您好！您的文件已成功接收：" & vbCrLf
msg.Body =msg.Body &"来自"& waptitle&"发送附件系统"	'邮件正文
msg.AddRecipient mail, "来自"&waptitle&""		'收件人的邮箱、签名
msg.MailServerUserName = ""&waptitle&""	'自己邮箱的管理用户名
msg.MailServerPassword  = ""&waptitle&""	'自己邮箱密码
msg.Send("smtp.qq.com")				'发邮件服务器
msg.Close
Set msg = Nothing
response.Write "您的文件已成功发送到您的邮箱！<br/>"

else
 Call Error("<card title=""发送附件到邮箱""><p>您的"&getcent&"不足！发送附件到邮箱需用"&bbsmyjb&getcent&"<br/>")
  end if
end sub
Function CheckEmail(str)
		Dim re,a
		Set re = New RegExp
		re.IgnoreCase = True
		re.Global = True
		re.Pattern = "\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
		a = re.Test(str)
		If a then 
			CheckEmail = True
		Else
			CheckEmail = False
		End If	
	End Function
%>
<a href="topic.asp?tid=<%=tid%>&amp;sid=<%=sid%>&amp;saytk=<%=saytk%>">返回主帖</a>
<!--#include file="fanhui.asp"-->
<%call headsay()%>