<%
'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:
'
'
'
' Your advertising report:
'
' <% PrintReport 3 %>
'
'
'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("
")
Response.Write("Description ")
Response.Write("Impressions ")
Response.Write("Click Thrus ")
Response.Write("Click Thru % " & 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("")
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("" & banInfo(IDs(i),Description) & " ")
Response.Write("" & clicks & " " & clickthrus & " ")
Response.Write("" & FormatPercent(clickthrus/clicks) & " ")
Response.Write(" " & vbCrLf)
next
Response.Write("Totals: ")
Response.Write(clicksTotal & " " & ClickThruTotal & " ")
Response.Write("" & FormatPercent(ClickThruTotal / ClicksTotal) & " " & vbCrLf)
Response.Write("
" & vbCrLf)
'Clean up
Set banFile = Nothing
Set fs = Nothing
end sub
%>