<% zoneid=request("z") contentid=request("c") xlaparsing=request("xlaparsing") callingurl=Request.ServerVariables("HTTP_REFERER") if zoneprotection<>"any" and instr(1,callingurl,applicationurl,1)=0 and callingurl<>"" and xlaparsing="" then hasparameters=instr(callingurl,"?") if hasparameters>0 then callingurl=left(callingurl,hasparameters-1) specialurls=split(lcase(specialurls),";") for x=0 to ubound(specialurls) if instr(1,callingurl,specialurls(x),1)<>0 then takeaction=true exit for end if next if zoneprotection="restricted" and takeaction=false then doblock="1" if zoneprotection="banned" and takeaction=true then doblock="1" end if if not(isnumeric(zoneid)) and not(isnumeric(contentid)) or doblock="1" then response.end function closeconn() rs.close set rs=nothing conn.close set conn=nothing response.end end function set conn=server.createobject("ADODB.Connection") conn.open connection '/// prepare query if contentid="" then '//// Get zone details psql="select * from xlaACRzones where zonestatus=1 and zoneid=" & zoneid set rs=conn.execute(psql) if rs.eof then call closeconn() zonerotation=rs("zonerotation") rotationtime=rs("rotationtime") zonetimeframe=rs("zonetimeframe") if zonetimeframe="" then zonetimeframe="h" lastupdate=rs("lastupdate") & "" contentid=rs("lastcontentid") '/// Content has to be rotated ? /// getcontent=false if contentid=0 or lastupdate="" or not(isdate(lastupdate)) or rotationtime=0 then getcontent=true if not(getcontent) and isdate(lastupdate) then if datediff(zonetimeframe,cdate(lastupdate),now)>=rotationtime then getcontent=true 'if getdate(dateadd(zonetimeframe,-rotationtime,now))>lastupdate then getcontent=true end if if getcontent then '/// Select the proper content psql="SELECT xlaACRcontent.contentid FROM xlaACRcontent INNER JOIN xlaACRiContentZones ON xlaACRcontent.contentid = xlaACRiContentZones.contentid " psql=psql & " where contentstatus=1 and zoneid=" & zoneid & " and zoneid in (select zoneid from xlaACRzones where zonestatus=1) " psql=psql & " and (startdate<='" & todaydate & "' and (enddate>='" & todaydate & "' or enddate='-')) and (months='' or months like '%," & month(now) & ",%') and (days='' or days like '%," & day(now) & ",%') and (weekdays='' or weekdays like '%," & weekday(now) &",%')" psql=psql & " and (maxhits=0 or (hits0))" psql=psql & " order by internalhits asc,xlaACRcontent.contentid asc" set rs=conn.execute(psql) if rs.eof then call closeconn() results=rs.getrows rs.close set rs=nothing found=ubound(results,2)+1 contentid=results(0,0) '/// get random content ? if zonerotation=1 then Randomize Timer a = (Int(RND * found)) contentid=results(0,a) end if '/// Update this content & zone's internal hits conn.execute("update xlaACRiContentZones set internalhits=internalhits+1 where contentid=" & contentid & " and zoneid=" & zoneid) '/// Update zone last update conn.execute("update xlaACRzones set lastupdate='" & thistime & "', lastcontentid=" & contentid & " where zoneid=" & zoneid) end if end if '/// Update content hits /// conn.execute("update xlaACRcontent set hits=hits+1 where contentid=" & contentid) '/// Retrieve for the content psql="select autoformat,whicheditor,content from xlaACRcontent where contentid=" & contentid set rs=conn.execute(psql) if rs.eof then closeconn() content=rs("content") autoformat=rs("autoformat") whicheditor=rs("whicheditor") rs.close set rs=nothing conn.close set conn=nothing '//// Format Content ///' if whicheditor="1" and autoformat="" then content=replace(content,vbcrlf,"
") '/// Change Paths and relative links /// content=replace(content,"href=" & chr(34), "href=" & chr(34) & applicationurl & "r.asp?u=",1,-1,1) content=replace(content,"src=" & chr(34), "src=" & chr(34) & applicationurl & "r.asp?u=",1,-1,1) content=replace(content,applicationurl & "r.asp?u=http://","http://",1,-1,1) if xlaparsing<>"" then response.ContentType="text/html" response.buffer=true response.flush response.write "" response.write escape(content) response.write "" else response.ContentType="application/x-javascript" response.write "document.write(" & chr(34) & preparecontent(content) & chr(34) & ");" end if %>