<% '------------------------------' ' BANNERMAN3 Redirector Script ' '------------------------------' ' DATABASE GARBAGE... Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open BM_CONNSTRING AD_ID = Request("id") ' now update the advertisement table sql = "update bm_ads set odo_click = odo_click + 1" & _ " where id = " & AD_ID Conn.Execute(sql) '******************************************** '* '* WRITE AN ENTRY TO THE MASTER LOG '* TheLogTime = date TheLogTime = DateAdd("h", datepart("h", now), TheLogTime) sql = "select hit_count from bm_masterlog where ad_id = " & AD_ID & " and " & _ "entry_type = 'W' and log_time = '" & TheLogTime & "'" Set RS2 = Conn.Execute(sql) if RS2.EOF then ' Make a new record for this hour RS2.Close Conn.Execute "insert bm_masterlog values (" & AD_ID & ", 'W', '" & TheLogTime & "', 1, 0)" else ' Increment the existing record hit_count = RS2("hit_count") RS2.Close Conn.Execute "update bm_masterlog set hit_count = hit_count + 1 where ad_id = " & _ AD_ID & " and entry_type = 'W' and log_time = '" & TheLogTime & "'" end if '* '* '******************************************** ' Now, see if we have met the clickthrough maximum if there is one, and if so, ' update the active flag. sql = "update bm_ads set live = 0 where id = " & AD_ID & " and clicks_max > " & _ "0 and clicks_max <= (select sum(hit_count) from bm_masterlog where ad_id = " & AD_ID & ")" Conn.Execute(sql) ' retrieve the destination from the database, and redirect, and we are outa here! sql = "select dest_url from bm_ads where id = " & AD_ID Set RS = Conn.Execute(sql) RedirectLoc = RS("dest_url") RS.Close Set RS = Nothing Conn.Close Set Conn = Nothing Response.Redirect RedirectLoc %>