<% Set Conexao = Server.CreateObject("ADODB.Connection") Conexao.Open Application("StringConexaoADO") ban_codigo = request("ban_codigo") ban_link = request("ban_link") if (not isempty(ban_codigo)) or (not isempty(ban_link)) then if isempty(ban_codigo) then queryselbanner="SELECT ban_codigo FROM bannernet WHERE ban_link="&ban_link set selbanner = conexao.execute(queryselbanner) ban_codigo = selbanner("ban_codigo") end if queryupdbanner="UPDATE bannernet SET bannernet.ban_qtd_click = bannernet.ban_qtd_click+1 WHERE bannernet.ban_codigo="&ban_codigo set updbanner = Conexao.Execute(queryupdbanner) if isempty(ban_link) then queryselbanner="SELECT ban_link FROM bannernet WHERE ban_codigo = "&ban_codigo set selbanner = conexao.execute(queryselbanner) ban_link = selbanner("ban_link") end if response.redirect(ban_link) else %> <% Function ExecuteSelectCursor(ByVal querysel, ByVal cur) Dim rs Set rs = Server.CreateObject ("ADODB.Recordset") rs.Open querysel, Conexao, cur Set ExecuteSelectCursor = rs End Function Function ExecuteSelectCount(ByVal querysel, ByRef Count) Dim rs Set rs = ExecuteSelectCursor(querysel, 3) Count = rs.RecordCount Set ExecuteSelectCount = rs End Function Function Randomico(max) Dim MyValue Randomize MyValue = Int((max * Rnd) + 1) Randomico= MyValue End Function %> <% queryselbanner="SELECT bannernet.ban_codigo, bannernet.ban_figura, bannernet.ban_link, bannernet.ban_qtd_view, bannernet.ban_atual_view, bannernet.ban_data_vencimento, bannernet.ban_data_ini, bannernet.ban_qtd_click, bannernet.ban_pagina, bannernet.ban_ativo FROM bannernet WHERE (bannernet.ban_pagina='"&request.servervariables("PATH_INFO")&"' or bannernet.ban_pagina='/') AND bannernet.ban_ativo=True AND (bannernet.ban_qtd_view > bannernet.ban_atual_view OR bannernet.ban_data_vencimento >= Date())" set selbanner = ExecuteSelectCount(queryselbanner,contador) if not selbanner.eof then selbanner.movefirst if contador = 1 then if InStr(ucase(selbanner("ban_figura")),".GIF") = 0 then response.write(" ") response.write(" ") response.write(" ") response.write(" ") response.write(" ") response.write(" ") else response.write("") end if ban_codigo=selbanner("ban_codigo") end if if contador > 1 then numbanner = randomico(contador) x=1 while (not selbanner.eof) if numbanner=x then if InStr(ucase(selbanner("ban_figura")),".GIF") = 0 then response.write(" ") response.write(" ") response.write(" ") response.write(" ") response.write(" ") response.write(" ") else response.write("") end if ban_codigo=selbanner("ban_codigo") end if selbanner.movenext x=x+1 wend end if queryupdbanner="UPDATE bannernet SET bannernet.ban_atual_view = bannernet.ban_atual_view + 1 WHERE bannernet.ban_codigo="&ban_codigo set updbanner = Conexao.Execute(queryupdbanner) queryselbanner="SELECT bannernet.ban_codigo, bannernet.ban_figura, bannernet.ban_link, bannernet.ban_qtd_view, bannernet.ban_atual_view, bannernet.ban_data_vencimento, bannernet.ban_data_ini, bannernet.ban_qtd_click, bannernet.ban_pagina, bannernet.ban_ativo FROM bannernet WHERE bannernet.ban_codigo="&ban_codigo Set selbanner = Conexao.Execute(queryselbanner) if selbanner("ban_qtd_view")=selbanner("ban_atual_view") or selbanner("ban_data_vencimento") < Date() then queryupdbanner="UPDATE bannernet SET bannernet.ban_data_fim = Date() WHERE bannernet.ban_codigo="&ban_codigo set updbanner = Conexao.Execute(queryupdbanner) end if end if end if %>