<%Response.AddHeader "P3P", "CP=""CAO PSA OUR""" varnull=0 varnull2="" if request("bn")<>"" and session(CookieName & "BN")="" then session(CookieName & "BN")=request("bn") end if if request("af")<>"" then affusername=request("af") response.cookies(CookieName)=request("af") response.cookies(CookieName).expires=dateadd("yyyy",1,date()) session(CookieName)=request("af") elseif request.cookies(CookieName)<>"" then affusername=request.cookies(CookieName) elseif session(CookieName)<>"" then affusername=session(CookieName) else affusername="" end if ipaddress=request.servervariables("REMOTE_ADDR") PageNameURL=Request.ServerVariables("SCRIPT_NAME") referurl=Request.ServerVariables("HTTP_REFERER") hit=1 bn=request("bn") Set conn = Server.CreateObject("ADODB.Connection") Set rs = Server.CreateObject("ADODB.Recordset") Conn.Open dsn rs.open "SELECT AfUsername, status, activation from AF_Users WHERE AfUsername ='" & affusername & "'", conn,1,3 if not rs.eof then UserStatus=rs("status") if rs("activation")="1" then userok=true end if else UserStatus=0 end if rs.close if UserStatus=0 then rs.open "SELECT ConStatus, payperclick, EnableTiers, SmartClicks FROM AF_Constants where ConStatus = " & UserStatus & "", conn,1,3 else rs.open "SELECT ConStatus, ConstantsID, payperclick, EnableTiers, SmartClicks FROM AF_Constants where ConstantsID = " & UserStatus & "", conn,1,3 end if if not rs.eof then payperclick=rs("payperclick") EnableTiers=rs("EnableTiers") SmartClicks=rs("SmartClicks") end if rs.close if EnableTiers<>0 then session("aft")=affusername end if if affusername<>"" and userok=true then rs.open "SELECT SmartIP, SmartHits from AF_Hits WHERE SmartIP='" & ipaddress & "' and SmartHits <>'" & varnull2 & "'", conn,1,3 If rs.EOF Then 'no smart hits if bn>0 then sql = "INSERT into AF_Hits(AfUsername, SmartIP, SmartHits, hits, leads, salesnum, sales, earn, banners, referurl, date) Values('" & affusername & "', '" & ipaddress & "', '" & PageNameURL & "', '" & varnull & "', '" & varnull & "', '" & varnull & "', '" & varnull & "', '" & varnull & "', '" &bn & "', '" & referurl & "', '" & now() & "')" conn.execute(sql) end if rs.close else 'count smart hits i=0 Dim SmartClicksArray(100) do until rs.EOF i=i+1 SmartClicksArray(i)=rs("SmartHits") rs.MoveNext loop if i>=1 then for k=1 to i if SmartClicksArray(k)=PageNameURL then SmartPageExist=1 next end if 'response.write "
SmartPageExist:" & SmartPageExist if SmartPageExist<>1 then if i<(SmartClicks-1) then sql = "INSERT into AF_Hits(AfUsername, SmartIP, SmartHits, hits, leads, salesnum, sales, earn, date) Values('" & affusername & "', '" & ipaddress & "', '" & PageNameURL & "', '" & varnull & "', '" & varnull & "', '" & varnull & "', '" & varnull & "', '" & varnull & "', '" & now() & "')" conn.execute(sql) rs.close elseif i=(SmartClicks-1) then rs.close 'retrieve tha BannerID rs.open "SELECT SmartIP, banners, referurl from AF_Hits WHERE SmartIP ='" & ipaddress & "' and banners>0", conn,1,3 if not rs.EOF Then bn=rs("banners") referurl=rs("referurl") end if rs.close 'Insert Hit rs.open "SELECT ipaddress from AF_Hits WHERE ipaddress ='" & ipaddress & "'", conn,1,3 If rs.EOF Then sql = "INSERT into AF_Hits(AfUsername, ipaddress, SmartHits, hits, leads, salesnum, sales, earn, banners, referurl, date) Values('" & affusername & "', '" & ipaddress & "', '" & PageNameURL & "', '" & hit & "', '" & varnull & "', '" & varnull & "', '" & varnull & "', '" & payperclick & "', '" & bn & "', '" & referurl & "', '" & now() & "')" conn.execute(sql) rs.close rs.open "SELECT * from AF_Payments WHERE AfUsername ='" & affusername & "'", conn,1,3 if not rs.eof then hits=rs("hits")+1 earn=rs("earn")+payperclick SQL = "update AF_Payments Set hits = '"& hits &"', earn = '"& earn &"' Where AfUsername = '" & affusername & "'" Set RS = conn.Execute(SQL) else sql = "INSERT into AF_Payments(AfUsername, hits, leads, sales, numOfSales, earn, downlineEarn, amountPaid, Bonus) Values('" & affusername & "', '" & hit & "', '" & varnull & "', '" & varnull & "', '" & varnull & "', '" & payperclick & "', '" & varnull & "', '" & varnull & "', '" & varnull & "')" conn.execute(sql) rs.close end if end if end if end if end if end if set rs = nothing conn.close set conn = nothing %>