fID = Request.Item("fID")
fURL = Request.Item("fURL")
fClick = cbool(Request.Item("fClick"))
fAdmin = cbool(Request.Item("fAdmin"))
fUser = Request.Item("fUser")
fpassword = Request.Item("fPassword")
fperpage= cint(Request.Item("fperpage"))
fcurrentpage = cint(Request.Item("fcurrentpage"))
if fcurrentpage = 0 then fcurrentpage = 1
if fperpage = 0 then fperpage = 10
fsortby = Request.Item("fsortby")
fordertype = Request.Item("fordertype")
if fordertype = "" then fordertype = "ASC"
if fsortby = "" then fsortby = "ID"
'on error resume next
Set ObjCon = Server.CreateObject("ADODB.Connection")
ObjCon.Open gblConnectString,,16
Set Objcmd = Server.CreateObject("ADODB.Command")
Objcmd.ActiveConnection = ObjCon
if fAdmin = True then
showstats fperpage, fcurrentpage, fsortby,fordertype
end if
if fClick = True and fAdmin = False then
AdClicked fID
elseif fClick = False And fAdmin = False then
Randomize
Rand = cint(int(cint(AdCount) * Rnd(47) + 1))
'Response.Write AdCount
LoadAd Rand
end if
Sub LoadAd(intID)
Objcmd.commandtext = "SELECT * FROM ADS WHERE ID=" & intID
set ObjRS = Objcmd.Execute
IF ObjRS.EOF Then Response.Write("ERROR: EOF") : Exit Sub
fID = intID
fURL = ObjRS("URL")
fURL = mid(fURL,10,len(fURL)-11)
fIMG = ObjRS("ImageURL")
fTrackURL = ObjRS("TrackURL")
fViews = ObjRS("Views")
fViews = fViews + 1
Objcmd.commandtext = "UPDATE ADS SET Views=" & fViews & " WHERE
ID=" & intID
set ObjRS = Objcmd.Execute
displayad fID,fIMG,fURL,fTrackURL
End Sub
Sub AdClicked(intID)
Objcmd.commandtext = "SELECT Clicks FROM ADS
WHERE ID=" & intID
set ObjRS = Objcmd.Execute
IF ObjRS.EOF Then Exit Sub
fID = intID
fClick = ObjRS("Clicks")
fClick = cint(fClick) + 1
Response.Write furl
Objcmd.commandtext = "UPDATE ADS SET Clicks=" & fClick & " WHERE
ID=" & intID
set ObjRS = Objcmd.Execute
Response.Redirect furl
End Sub
Sub ShowStats(iPerPage,iCurrentPage,strSortBy, strOrderType)
Dim TotalPages
TotalPages = cint(Round(AdCount / iPerPage ,0))
Objcmd.commandtext = "SELECT * FROM ADS ORDER BY " & strSortBy & " " & strOrderType
set ObjRS = Objcmd.Execute
'Response.Write iperpage & " " & icurrentpage
ObjRS.PageSize = iPerPage
'Response.Write TotalPages
'ObjRS.AbsolutePage = iCurrentPage
'Display PREV page link, if appropriate
If Not iCurrentPage = 1 Then
Response.Write "<div align=center><a href=ad.asp?fordertype=" & strOrdertype & "&fsortby=" & strsortby & "&fcurrentpage=" & iCurrentPage
- 1 & "&fAdmin=True&fperpage=10>Prev</a> | "
Else
Response.Write "<div align=center>Prev | "
End If
'Display NEXT page link, if appropriate
If cint(iCurrentPage) < TotalPages Then
Response.Write "<a href=ad.asp?fordertype=" & strOrdertype & "&fsortby=" & strsortby & "&fcurrentpage=" & iCurrentPage
+ 1 & "&fAdmin=True&fperpage=10>Next</a><br>" & vbcrlf & "</div>"
Else
Response.Write "Next<br>" & vbcrlf & "</div>"
End If
%>
Sub DisplayAd(intID,strImage,strURL,strTrack)
%><!--Start banner for ID <%=intID%> -->
<A href="/ads/ad.asp?fID=<%=intID%>&fURL=<%=server.URLEncode(strURL)%>&fClick=True" target="_AD"><%=strImage%><br><%=strTrack%>
<%
End Sub
Function ADCount()
Objcmd.commandtext = "SELECT Views FROM ADS"
set ObjRS = Objcmd.Execute
AdCount = 0
do while not ObjRS.EOF
AdCount = AdCount + 1
ObjRS.MoveNext
Loop
End Function
ObjCon.Close
set ObjRS = Nothing
Set ObjCon = Nothing
Set Objcmd = Nothing
%>