<!--#include file ="include/config.asp"-->
<!--#include file ="include/conn.asp"-->
<%
dim AdsID,rs1,ObjUrl
AdsID=request("AdsID")
if AdsID<>"" then

set rs=conn.execute("select ObjUrl,ClickState,ClickCount,AdsState,ClickFiltrationIP,ClickTime from Ads Where AdsID="&AdsID)
if rs.eof then response.end
if rs("ClickState")=true then
  set rs1=conn.execute("select count(*) as count from AdsAccessLog where AdsID="&AdsID&" and OpType='click' group by AdsID")  
  if not rs1.eof then 
    if rs1(0)>rs("ClickState") then conn.execute("Update Ads Set AdsState=0 where AdsID="&AdsID)
  end if
  rs1.close
  set rs1=nothing
end if

ObjUrl=rs(0)


response.redirect ObjUrl
end if
call close_conn()
%>