<% 'This file needs to be included on the page that you want to show the report. 'I recommend that you have a unique HTML page for each advertiser, and then on 'that page have code that looks like this: '<!--#include virtual="/report.asp"--> '<HTML> '<BODY> ' Your advertising report: ' <P> ' <% PrintReport 3 %> '</BODY> '</HTML> 'This assumes that this would be the HTML file for the Advertiser with 'the advertiserID of 3 sub PrintReport(adID) 'Don't change these... Const bannerID = 0 Const bannerCategory = 1 Const bannerWeight = 2 Const advertiserID = 3 Const IMGSRC = 4 Const Description = 5 Const RedirURL = 6 'Change this... Const path = "C:\InetPub\wwwroot\" Dim fs, banFile Set fs = Server.CreateObject("Scripting.FileSystemObject") Set banFile = fs.OpenTextFile(path & "Banners.txt",1) 'Read the file: Dim str str = banFile.ReadAll ' Close file banFile.Close 'Now, split the string into records Dim records records = split(str,"*") Dim banInfo(), tempArray ReDim banInfo(UBound(records),7) for i = LBound(records) to UBound(records) if right(records(i),1) = chr(10) then records(i) = left(records(i), len(records(i)) - 1) end if if left(records(i),1) = chr(10) then records(i) = right(records(i), len(records(i)) - 1) end if tempArray = split(records(i),chr(10)) banInfo(i,bannerID) = tempArray(0) banInfo(i,bannerCategory) = tempArray(1) banInfo(i,bannerWeight) = tempArray(2) banInfo(i,advertiserID) = tempArray(3) banInfo(i,IMGSRC) = tempArray(4) banInfo(i,Description) = tempArray(5) banInfo(i,RedirURL) = tempArray(6) next 'Now that we've got all of the information, let's 'get the banners for the given advertiser ID Dim IDs() Dim size size = 0 for i = LBound(records) to UBound(records) if CInt(banInfo(i,advertiserID)) = CInt(adID) then size = size + 1 Redim Preserve IDs(size) IDs(size-1) = i end if next Dim strClickPath, strClickThruPath Dim clicks, clickthrus, clicksTotal, clickthruTotal clicksTotal = 0 clickthrutotal = 0 Response.Write("<TABLE ALIGN=CENTER BORDER=1 CELLSPACING=1>") Response.Write("<TR><TH ALIGN=CENTER>Description</TH>") Response.Write("<TH ALIGN=CENTER>Impressions</TH>") Response.Write("<TH ALIGN=CENTER>Click Thrus</TH>") Response.Write("<TH ALIGN=CENTER>Click Thru %</TH></TR>" & vbCrLf) 'Now, IDs holds all of the banner IDs for the given advertiser for i = LBound(IDs) to UBound(IDs)-1 'For each ID, get the clicks and clickthroughs strClickPath = path & "clicks\" & banInfo(IDs(i),bannerID) & ".txt" strClickThruPath = path & "clickthrus\" & banInfo(IDs(i),bannerID) & ".txt" Response.Write("<!--" & strClickPath & " ??? " & strClickThruPath & "-->") if fs.FileExists(strClickPath) then Set banFile = fs.OpenTextFile(strClickPath,1) clicks = CInt(banFile.ReadLine) banFile.close else clicks = 0 end if if fs.FileExists(strClickThruPath) then Set banFile = fs.OpenTextFile(strClickThruPath,1) clickthrus = CInt(banFile.ReadLine) banFile.close else clickthrus = 0 end if clickstotal = clickstotal + CInt(clicks) ClickThruTotal = ClickThruTotal + CInt(clickThrus) Response.Write("<TR><TD ALIGN=LEFT>" & banInfo(IDs(i),Description) & "</TD>") Response.Write("<TD ALIGN=RIGHT>" & clicks & "</TD><TD ALIGN=RIGHT>" & clickthrus & "</TD>") Response.Write("<TD ALIGN=RIGHT>" & FormatPercent(clickthrus/clicks) & "</TD>") Response.Write("</TR>" & vbCrLf) next Response.Write("<TR><TD ALIGN=LEFT><B>Totals:</B></TD><TD ALIGN=RIGHT>") Response.Write(clicksTotal & "</TD><TD ALIGN=RIGHT>" & ClickThruTotal & "</TD>") Response.Write("<TD ALIGN=RIGHT>" & FormatPercent(ClickThruTotal / ClicksTotal) & "</TD></TR>" & vbCrLf) Response.Write("</TABLE>" & vbCrLf) 'Clean up Set banFile = Nothing Set fs = Nothing end sub %>