<!--#include virtual="/inc/conn.asp"-->
<%
id=trim(SafeRequest("id"))
cid=trim(SafeRequest("cid"))
act=trim(SafeRequest("act"))

if act="zishou" then

	ddku=getddku(id)
	
	conn.execute "update ddlasttime set ddtime='"&now()&"' where ddhao='"&SafeRequest("id")&"'"
	
	rs.open "select top 1 zishouzt,aydingdansum,aydingdanzt,ddchaoshi from "&ddku&" where aydingdansum='"&id&"'" ,conn,1,1	
	if not(rs.eof) then
		if cint(rs("aydingdanzt"))=1 then response.Write "ok"
		if cint(rs("zishouzt"))=1 then response.Write "err"
		if cint(rs("ddchaoshi"))=1 then response.Write "time"
	end if
	rs.close


else

		if id<>"" then
			
			if request.Cookies("timed")="" then
			response.Write "ok"
			response.End()
			end if
			
			ddku=getddku(id)
			
				if DateDiff("s",request.Cookies("timed"),now())>300 then
				response.Cookies("timed")=""
				response.Write "ok"
				response.End()
				else
					rs.open "select top 1 aydingdansum,aydingdanzt,dailikuo,aydingdanuser from "&ddku&" where aydingdansum='"&id&"' and aydingdanzt=1" ,conn,1,1	
					if not(rs.eof) then
					
						dailikuo=trim(rs("dailikuo"))'代理关系
						dailiku=""					'总代理卡密库 
						if dailikuo<>"" then
						dailistr=split(dailikuo,"|")
						dailiuserstr=split(dailistr(Ubound(dailistr)),",")
						dailiku=trim(dailiuserstr(5))
						end if
							
						yifenpei=getddokkami(trim(rs("aydingdansum")),rs("aydingdanuser"),dailiku)
						
						if ccur(yifenpei)>0 then
						response.Cookies("timed")=""
						response.Write "ok"
						end if


					response.End()
					end if
					rs.close
				end if
				
		end if
		
		
		if cid<>"" then
		
			cwku=getcwku(cid)
		
			'if request.Cookies("timed")="" then	response.Cookies("timed")=now()
			
			
			'	if DateDiff("s",request.Cookies("timed"),now())>15 then
			'	response.Cookies("timed")=""
			'	response.Write "ok"
			'	else
					rs.open "select top 1 aycailiushui,aycaiwuzt from "&cwku&" where aycailiushui='"&cid&"' and aycaiwuzt=1" ,conn,1,1	
					if not(rs.eof) then
			'		response.Cookies("timed")=""
					response.Write "ok"
					end if
					rs.close
			'	end if
				
		end if
	
end if
%>
