Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Pessoal, boa tarde!
Num sistema de banners, tenho administração dos (inserção, exclusão e midificação dos banners) e administração de zonas, posições em que determinados banners são eibitos, tipo: banners de topo, banners da lateral, etc...
Aontece que eu quero exibir todos os banners cadastrados em determinadas zonas, porém o sistema chama apenas um de cada vez, e de forma randomica... Como eu faço pra mudar isso e exibir todos os registros de determinadas zonas?
Obs: As tags de inserção de banners e zonas dentro da página é chamada assim:
<% IdZona = 10 %>
<!--#include virtual="\sysbanner\Includes\MostraBanner.asp"-->
Abaixo segue o código que chama os banners "MostraBanner.asp"
Obrigado a quem tiver paciencia em me ajudar, abraço!
<!--#include file="../CfgAdmin.asp"-->
<!--#include file="DBDados.asp"-->
<!--#include file="Tempo.asp"-->
<%
Function printf(txt,str1,str2,str3)
cont = 0
I = 0
bak = split(txt,str1)
while instr(txt,str1)
txt = mid(txt,instr(txt,str1)+1,len(txt))
cont = 1 + cont
wend
cont = cont + 1
while I < cont
response.write str2 +bak(I)+str3+chr(13)+chr(10)
I= I +1
wend
end function
KRTZ = "Sim"
KRTB = "Sim"
JavaS =""
JavaS2 =""
if IdZona = "" then
IdZona = Request.QueryString("IdZona")
KRTZ = ""
end if
if BannerID = "" then
BannerID = Request.QueryString("BannerID")
KRTB = ""
end if
IF IdZona = "" then IdZona = 0 end if
JavaS3 = "<script language="+Chr(34)+"JavaScript"+Chr(34)+" type=text/JavaScript>"+Chr(10)
JavaS4 = "</script>"+chr(10)
if BannerID = "" thenIf not BuscaDB.eof then
BannerToShow = BuscaDB("BannerID")
OnShow = 0
' Se Não tiver registro no Sbanners ele adiciona
Set BuscaDD = Dados.Execute("SELECT * FROM SBanners WHERE IdZona="+Cstr(IDZona)+" AND IdHorario="+CStr(IDHorarioAtual))
If Not BuscaDD.eof then
LastID = BuscaDD("BannerToShow")
else
SQL = "Insert into SBanners (BannerToShow,IdHorario,IDZona) "
SQL = SQL + " values (0,"+CStr(IDHorarioAtual)+","+CStr(IDZona)+")"
Dados.execute(SQL)
end if
Set BuscaDD = nothing
' Se Não tiver registro no Sbanners ele adiciona
While Not BuscaDB.eof
If OnShow = 1 then
OnShow = 0
BannerToShow = BuscaDB("BannerId")
end if
If LastID = BuscaDB("BannerId") then
OnShow = 1
end if
BuscaDB.MoveNext
Wend
else
BannerToShow = 1
end if
else
BannerToShow=1
Set BuscaDB = Dados.Execute("SELECT * FROM Banners WHERE ID = "+CStr(BannerID))
if not BuscaDB.eof then
BannerToShow = BannerID
If (BuscaDB("Views") > BuscaDB("MaxViews")) and BuscaDB("MaxViews") <> 0 or (BuscaDB("Cliques") > BuscaDB("MaxCliques")) and BuscaDB("MaxCliques") <> 0 then
BannerToShow = 1
end if
end if
if not KRTB = "Sim" then
JavaS = "document.write (unescape('"
JaVaS2 = "'));"
JavaS3 = ""
JavaS4 =""
end if
end if'
'''''' Tabela Anos
SQL = "SELECT * FROM Anos WHERE Ano = "+CSTR(ano)+" AND BannerID = "+CSTR(BannerToShow)
Set BuscaDB = Dados2.execute(SQL)
if not BuscaDB.eof then
TheD = BuscaDB("Views")
TheD = TheD + 1
SQL = "UPDATE Anos SET Views = " & Cstr(TheD) & " WHERE BannerId = "+CStr(BannerToShow)+" AND Ano ="+CSTR(Ano)
Dados2.Execute(SQL)
else
SQL = "INSERT INTO Anos (BannerID,Ano,Views,Cliques) "
SQL = SQL + " values ("+Cstr(BannerToShow)+","+CStr(Ano)+",1,0)"
Dados2.execute(SQL)
SQL = "DELETE * FROM Meses WHERE BannerID="+CSTR(BannerToshow)
Dados2.execute(SQL)
end if'''''' Tabela Meses
SQL = "SELECT * FROM Meses WHERE Mes = "+CSTR(Mes)+" AND BannerID = "+CSTR(BannerToShow)
Set BuscaDB = Dados2.execute(SQL)
if not BuscaDB.eof then
TheD = BuscaDB("Views")
TheD = TheD + 1
SQL = "UPDATE Meses SET Views = " & Cstr(TheD) & " WHERE BannerId = "+CStr(BannerToShow)+" AND Mes ="+CSTR(Mes)
Dados2.Execute(SQL)
else
SQL = "INSERT INTO Meses (BannerID,Mes,Views,Cliques) "
SQL = SQL + " values ("+Cstr(BannerToShow)+","+CStr(Mes)+",1,0)"
Dados2.execute(SQL)
SQL = "DELETE * FROM Dias WHERE BannerID="+CSTR(BannerToshow)
Dados2.execute(SQL)
end if'''''' Tabela Dias
SQL = "SELECT * FROM Dias WHERE Dia = "+CSTR(Dia)+" AND BannerID = "+CSTR(BannerToShow)
Set BuscaDB = Dados2.execute(SQL)
if not BuscaDB.eof then
TheD = BuscaDB("Views")
TheD = TheD + 1
SQL = "UPDATE Dias SET Views = " & Cstr(TheD) & " WHERE BannerId = "+CStr(BannerToShow)+" AND Dia ="+CSTR(Dia)
Dados2.Execute(SQL)
else
SQL = "INSERT INTO Dias (BannerID,Dia,Views,Cliques) "
SQL = SQL + " values ("+Cstr(BannerToShow)+","+CStr(Dia)+",1,0)"
Dados2.execute(SQL)
SQL = "DELETE * FROM Horas WHERE BannerID="+CSTR(BannerToshow)
Dados2.execute(SQL)
end if'''''' Tabela Horas
SQL = "SELECT * FROM Horas WHERE Hora = "+CSTR(Hora)+" AND BannerID = "+CSTR(BannerToShow)
Set BuscaDB = Dados2.execute(SQL)
if not BuscaDB.eof then
TheD = BuscaDB("Views")
TheD = TheD + 1
SQL = "UPDATE Horas SET Views = " & Cstr(TheD) & " WHERE BannerId = "+CStr(BannerToShow)+" AND Hora ="+CSTR(Hora)
Dados2.Execute(SQL)
else
SQL = "INSERT INTO Horas (BannerID,Hora,Views,Cliques) "
SQL = SQL + " values ("+Cstr(BannerToShow)+","+CStr(Hora)+",1,0)"
Dados2.execute(SQL)
end if Set BuscaDB = Dados.Execute("SELECT * FROM Banners WHERE ID = "+CStr(BannerToShow))
NViews = BuscaDB("Views")
NViews = NViews + 1
SQL = "UPDATE Banners SET Views = '" & Cstr(NViews) & "' WHERE ID = "+CStr(BannerToShow)
Dados.Execute(SQL)
MaxViews = BuscaDB("MaxViews")
If (NViews >= MaxViews) and (MaxViews <> 0) then
SQL = "UPDATE Banners2Zonas SET DDD = 1 WHERE BannerId ="+CStr(BannerToShow)
Dados.Execute(SQL)
else
SQL = "UPDATE Banners SET Views = '" & Cstr(NViews) & "' WHERE ID = "+CStr(BannerToShow)
end if
Dados.Execute(SQL)
SQL = "UPDATE SBanners SET BannerToShow = " & Cstr(BannerToshow) & " , IdHorario = " & CStr(IdHorarioAtual) & ", IdZona = " & CStr(IDZona) & " WHERE IDZona = " & CStr(IDZona) & " AND IdHorario = " & CStr(IdHorarioAtual) & ""
Dados.Execute(SQL)
SID = BuscaDB("ID")
Link = BuscaDB("Link")
Src = BuscaDB("Src")
HTML = BuscaDB("HTML")
Formato = BuscaDB("Formato")
Width = BuscaDB("Width")
Height = BuscaDB("Height")
Target = BuscaDB("Target")
if target = 0 then
target = "_blank"
else
target = "_self"
end if
if len(JavaS4) > 0 then
HTML = TransStr(HTML,"%27","'")
src = TransStr(src,"%27","'")
Link = TransStr(link,"%27","'")
Query =Request.QueryString
If Query <> "" then
Query = "?" + Query
end if
Rfer = "http://"+Request.ServerVariables("SERVER_NAME")+Request.ServerVariables("SCRIPT_NAME")+Query
else
Rfer = Request.ServerVariables("HTTP_REFERER")
end if
Rfer = TransStr(Rfer,"://","|")
Rfer = TransStr (Rfer,"/","~")
Rfer = TransStr (Rfer,"&","$")
If Formato = 2 then
response.write JavaS3
SRC = TransStr(SRC,"://","|")
SRC = TransStr (SRC,"/","~")
SRC = TransStr (SRC,"&","$")
Link = TransStr(Link,"://","|")
Link = TransStr (Link,"/","~")
Link = TransStr (Link,"&","$")
response.write "<!--var var_url,var_largura,var_altura;"+Chr(10)
response.write "var_url = "+Chr(34)+SURL+"Includes/Pop.asp?ID="+Cstr(BannerToshow)+"&N="+BuscaDB("nome")+"&K=1&Src="+src+"&R="+Rfer+Chr(34)+";"+Chr(10)
response.write "var_largura = "+Cstr(Width)+";"+Chr(10)
response.write "var_altura = "+Cstr(Height)+";"+Chr(10)
response.write "var Abr = window.open(var_url,"+Chr(34)+"janela"+Chr(34)+","+Chr(34)+"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width="+Chr(34)+"+var_largura+"+Chr(34)+",height="+Chr(34)+"+var_altura+"+Chr(34)+",top=50,left=100"+Chr(34)+");"+Chr(10)
response.write " // -->"+Chr(10)
response.write JavaS4
end if ' Pop-up
If Formato = 1 then
response.write JavaS + "<a href="+Chr(34)+SURL+"Includes/Visitar.asp?ID="+Cstr(BannerToshow)+"&R="+Rfer+Chr(34)+" target="+Chr(34)+target+Chr(34)+"><img src="+Chr(34)+src+Chr(34)+" width="+Chr(34)+Cstr(Width)+Chr(34)+" height="+Chr(34)+CStr(Height)+Chr(34)+" border="+Chr(34)+"0"+Chr(34)+"></a>"+JavaS2+CHR(10)
end if'Imagem
If Formato = 0 then
response.write JavaS3
response.write "<!--"+Chr(10)
response.write "function Link (){"+chr(10)
response.write "var area = window.open ("+Chr(34)+SURL+"Includes/Visitar.asp?ID="+Cstr(BannerToshow)+"&R="+Rfer+Chr(34)+","+Chr(34)+target+Chr(34)+","+chr(10)
response.write Chr(34)+"toolbar=yes,scrollbars=yes,menubar=yes,location=yes,resizable=yes,status=yes"+Chr(34)+");"+Chr(10)
response.write "}"+Chr(10)
response.write " // -->"+Chr(10)
response.write JavaS4
response.write JavaS + "<object width="+Chr(34)+Cstr(Width)+Chr(34)+" height="+Chr(34)+Cstr(Height)+Chr(34)+">"+JavaS2+CHR(10)
response.write JavaS + "<param name=movie value="+Chr(34)+Src+Chr(34)+">"+JavaS2+CHR(10)
response.write JavaS + "<param name=wmode value=transparent>"+JavaS2+CHR(10)
response.write JavaS + "<embed src="+Chr(34)+Src+Chr(34)+" wmode=transparent menu=false width="+Chr(34)+Cstr(Width)+Chr(34)+" height="+Chr(34)+Cstr(Height)+Chr(34)+">"+JavaS2+CHR(10)
response.write JavaS + "</embed>"+JavaS2+CHR(10)
response.write JavaS + "</object>"+JavaS2+CHR(10)
end if ' flash
if Formato = 3 then
response.write JavaS3
response.write "<!--"+Chr(10)
response.write "function Link (){"+chr(10)
response.write "var area = window.open ("+Chr(34)+SURL+"Includes/Visitar.asp?ID="+Cstr(BannerToshow)+"&R="+Rfer+Chr(34)+","+Chr(34)+target+Chr(34)+","+chr(10)
response.write Chr(34)+"toolbar=yes,scrollbars=yes,menubar=yes,location=yes,resizable=yes,status=yes"+Chr(34)+");"+Chr(10)
response.write "}"+Chr(10)
response.write " // -->"+Chr(10)
response.write JavaS4
HTML = printf(HTML,chr(13)+chr(10),JavaS,JavaS2)
end if ' HTML
Set BuscaDB = nothing
Dados.close
' Thank's Mom
' Thank's Dad %>
Carregando comentários...