<!--#include file="../p_inc/Include_func.asp"-->
<!--#include file="../p_inc/openconn.asp"-->
<!--#include file="config.asp"-->
<!--#include file="upublic.asp"-->
<!--#include file="function_u.asp"-->
<%
Response.Buffer=True
response.contenttype="text/html;charset=gb2312"

oid=Request("id")
oid=Replace(oid,"'","")
oa=Request("a")
om_txt=left(Trim(Replace(Request("m_txt"),"'","")),50)

'每次提交的间隔
gb_jiange=request.cookies("Task_in")
IF gb_jiange="" Then gb_jiange=now()-1
temp_jg=Bint(DateDiff("s",gb_jiange,now()))
IF temp_jg<300 Then
	Response.Write "<script>alert('任务做累了，先休息一会儿哦!');window.opener=null;window.close();</script>"
	Response.End()
End IF

Set oRs_detail=Conn.Execute("Select * From qingtiandy_renwu Where id="&oid&" And m_statue=1")
IF oRs_detail.Eof Then
	Str= "<script>alert('任务不存在');window.opener=null;window.close();</script>"
Else
	zm_id=oRs_detail("id")
	zm_title=oRs_detail("m_title")
	zm_content=oRs_detail("m_content")
	zm_zhouqi=Bint(oRs_detail("m_zhouqi"))
	zm_yuanbao1=Bint(oRs_detail("m_yuanbao1"))
	zm_yuanbao2=Bint(oRs_detail("m_yuanbao2"))
	zm_numb=Bint(oRs_detail("m_numb"))					
	zm_pic=oRs_detail("m_pic")
	zm_pic=zm_pic
	zm_type2=oRs_detail("m_type2")
	IF zm_type2="0" Then
		zm_type2_txt="自动任务"
	Else
		zm_type2_txt="手动任务"
	End IF
	zm_wenzi=GetRp(oRs_detail("m_wenzi"))
	zm_url=GetRp(oRs_detail("m_url"))
	zm_starttime=ForMatDate(oRs_detail("m_starttime"),5)
	zm_endtime=ForMatDate(oRs_detail("m_endtime"),5)
	zm_youxiao=False
	IF DateDiff("s",zm_starttime,Now())>=0 Then '任务开始
		IF DateDiff("s",zm_endtime,Now())>=0 Then '任务结束
			zm_starttime_txt="任务已结束"
		Else
			zm_starttime_txt="任务进行中"
			zm_youxiao=True
		End IF
	Else
		zm_starttime_txt="任务未开始"
	End IF
	IF Clng(zm_zhouqi)<=1 Then
		zm_zhouqi_text="当天认证"
	Else
		zm_zhouqi_text=zm_zhouqi&"天"
	End IF
	IF zm_numb=0 Then
		zm_numb_text="无限制"
	Else
		zm_numb_text=zm_numb&"次"
	End IF
	IF zm_yuanbao2=0 Then
		zm_yuanbao1_text=zm_yuanbao1
	Else
		zm_yuanbao1_text=zm_yuanbao1&" +"&zm_yuanbao2
	End IF
	zEndTime_1=Bint(DateDiff("d",Now(),zm_endtime))
	IF zEndTime_1<=0 Then zEndTime_1=0	
	
	IF zm_wenzi="" Then zm_wenzi="请认真参与此任务，否则您有可能会拿不到奖励"
	
	IF Not zm_youxiao Then
		Str= "<script>alert('任务已结束');window.opener=null;window.close();</script>"
		Response.Write Str
		Response.End()
	End IF
	
	IF zm_numb=0 Then '可以无限制做
		IF zm_yuanbao2<>0 Then '点了任务就送积分
			Get_qingtiandy_jifen_ip Request.Cookies(G_u_Cookies)("soojs_id"),10,zm_yuanbao2	
			Get_cz zm_yuanbao2,2
		End IF
		IF zm_type2=0 Then '自动任务
			Response.cookies("Task_in")=now()
			Set oRs3=Server.CreateObject(G_RS)
			oRs3.open "Select * From qingtiandy_renwu_jilu Where 1<>1",Conn,1,3
			oRs3.AddNew
			oRs3("mid")=oid
			oRs3("uid")=Request.Cookies(G_u_Cookies)("soojs_id")
			oRs3("l_dingdanbianhao")=0
			oRs3("l_status")=0
			oRs3("l_date")=ForMatDate(now(),55)
			oRs3("l_txt")=""
			oRs3("l_numb")=zm_yuanbao1
			oRs3("l_title")=zm_title
			oRs3.Update
			oRs3.close
			Response.Write "<script>alert('"&zm_wenzi&"');window.location='"&zm_url&"'</script>"
		Else
			IF oa="1" Then '判断是否是小提示框进来的
				Response.cookies("Task_in")=now()
				IF om_txt=""  Then
					Str= "<script>alert('完成任务后，请按提示填写完信息，否则得不到奖励');window.opener=null;window.close();</script>"
					Response.Write Str
					Response.End()
				Else
					Set oRs3=Server.CreateObject(G_RS)
					oRs3.open "Select * From qingtiandy_renwu_jilu Where 1<>1",Conn,1,3
					oRs3.AddNew
					oRs3("mid")=oid
					oRs3("uid")=Request.Cookies(G_u_Cookies)("soojs_id")
					oRs3("l_dingdanbianhao")=0
					oRs3("l_status")=0
					oRs3("l_date")=ForMatDate(now(),55)
					oRs3("l_txt")=om_txt
					oRs3("l_numb")=zm_yuanbao1
					oRs3("l_title")=zm_title
					oRs3.Update
					oRs3.close
					Response.Write "<script>alert('提交成功，等待管理员的审核');window.location='"&zm_url&"'</script>"
				End IF
			Else
				Response.Write "<script>alert('"&zm_wenzi&"');window.location='"&zm_url&"'</script>"
			End IF	
		End IF
	Else
		IF zm_yuanbao2<>0 Then '点了任务就送积分
			Get_qingtiandy_jifen_ip Request.Cookies(G_u_Cookies)("soojs_id"),10,zm_yuanbao2	
			Get_cz zm_yuanbao2,2
		End IF
		IF zm_type2=0 Then '自动任务
			Response.cookies("Task_in")=now()
			tTotal=0
			Set oRst=Conn.Execute("Select Count(*) From qingtiandy_renwu_jilu Where uid="&Request.Cookies(G_u_Cookies)("soojs_id")&" And mid="&oid)
			IF Not oRst.Eof Then
				tTotal=Bint(oRst(0))	
			End IF
			oRst.close
			
			IF CLng(zm_numb)>Clng(tTotal) Then			
				Set oRs3=Server.CreateObject(G_RS)
				oRs3.open "Select * From qingtiandy_renwu_jilu Where 1<>1",Conn,1,3
				oRs3.AddNew
				oRs3("mid")=oid
				oRs3("uid")=Request.Cookies(G_u_Cookies)("soojs_id")
				oRs3("l_dingdanbianhao")=0
				oRs3("l_status")=0
				oRs3("l_date")=ForMatDate(now(),55)
				oRs3("l_txt")=""
				oRs3("l_numb")=zm_yuanbao1
				oRs3("l_title")=zm_title
				oRs3.Update
				oRs3.close
				Response.Write "<script>alert('"&zm_wenzi&"');window.location='"&zm_url&"'</script>"
			Else
				Str= "<script>alert('此任务最多只能做"&zm_numb&"次，您已经做完此任务了');window.opener=null;window.close();</script>"
				Response.Write Str
				Response.End()				
			End IF
		Else
			IF oa="1" Then '判断是否是小提示框进来的
				Response.cookies("Task_in")=now()
				IF om_txt=""  Then
					Str= "<script>alert('完成任务后，请按提示填写完信息，否则得不到奖励');window.opener=null;window.close();</script>"
					Response.Write Str
					Response.End()
				Else
					tTotal=0
					Set oRst=Conn.Execute("Select Count(*) From qingtiandy_renwu_jilu Where uid="&Request.Cookies(G_u_Cookies)("soojs_id")&" And mid="&oid)
					IF Not oRst.Eof Then
						tTotal=Bint(oRst(0))	
					End IF
					oRst.close
					
					IF CLng(zm_numb)>Clng(tTotal) Then			
						Set oRs3=Server.CreateObject(G_RS)
						oRs3.open "Select * From qingtiandy_renwu_jilu Where 1<>1",Conn,1,3
						oRs3.AddNew
						oRs3("mid")=oid
						oRs3("uid")=Request.Cookies(G_u_Cookies)("soojs_id")
						oRs3("l_dingdanbianhao")=0
						oRs3("l_status")=0
						oRs3("l_date")=ForMatDate(now(),55)
						oRs3("l_txt")=om_txt
						oRs3("l_numb")=zm_yuanbao1
						oRs3("l_title")=zm_title
						oRs3.Update
						oRs3.close
						Response.Write "<script>alert('提交成功，等待管理员的审核');window.location='"&zm_url&"'</script>"
					Else
						Str= "<script>alert('此任务最多只能做"&zm_numb&"次，您已经做完此任务了');window.opener=null;window.close();</script>"
						Response.Write Str
						Response.End()				
					End IF							
				End IF
			Else
				Response.Write "<script>alert('"&zm_wenzi&"');window.location='"&zm_url&"'</script>"
			End IF					
		End IF	
	End IF
End IF


%>