<%@Language=VBscript%> <% Response.CacheControl = "no-cache" Response.AddHeader "Pragma", "no-cache" Response.Expires=-1500 Banner=64 URL="http://www.programmigratuiti.com/homebanner109" Img="http://www.programmigratuiti.com/homebanner109/hb109_12060.gif" if Request.QueryString("action")="go" then url = request.querystring("url") url = replace(url, "%26", "&", 1, -1, 1) bannerid = request.querystring("bannerid") sql="UPDATE rb_banner "&_ "SET "&_ "clickcount = clickcount + 1 "&_ "WHERE bannerid = "&bannerid OpenCN cn.execute(sql) CloseCN Response.Redirect(url) elseif Request.QueryString("action")="display" then id_set = request.querystring("id_set") OpenCN sql = "select bannerid, redirecturl, url_banner, peso, alttext from rb_banner "&_ "where id_set = "&id_Set&" and peso > 0 and showcount < maximpression and clickcount < maxclicks "&_ " and validodal <= date() and validofinoa >= date() and blocca = 0" rs.Open sql, Cn , adOpenKeyset numbanner = rs.recordcount if numbanner <> 0 then 'calcola peso totale nsommapeso = 0 While Not rs.EOF nsommapeso = nsommapeso + rs("peso").Value rs.MoveNext Wend Randomize nBanner = Int((nsommapeso * Rnd) + 1) 'Cerca in modo sequenziale il banner corrispondente al numero casuale rs.movefirst nCurVal = 0 While nCurVal + rs("peso") < nBanner nCurVal = nCurVal + rs("peso") rs.MoveNext Wend idBanner = rs("bannerid") URL=rs("redirecturl") url = replace(url, "&", "%26", 1, -1, 1) Img=rs("url_banner") alttext = rs("alttext") 'end if rs.Close 'aggiorna visualizzazioni banner selezionato sql="UPDATE rb_banner SET "&_ "showcount = showcount + 1 "&_ "WHERE bannerid = "&idbanner cn.execute(sql) 'aggiorna statistiche generali dataoggi = date() mese = datepart("m", dataoggi) giorno = datepart("d", dataoggi) sql="UPDATE rb_statistiche SET "&_ "impression = impression + 1 "&_ "WHERE id_set = "&id_set&" and giorno = "&giorno&_ " and mese = "&mese cn.execute(sql) CloseCN Response.write "" response.write "&alttext&" else rs.close CloseCN Response.write "Attenzione nessun banner disponibile!" end if end if %>