<% ''''''''''' (C) Stefan Holmberg 1999 ''''''''''' Free to use if these sourcecode lines is not deleted ''''''''''' Contact me at webmaster@sqlexperts.com ''''''''''' http://www.sqlexperts.com ''''''''''' AdMentor homepage at http://www.create-a-webshop.com ''''''''''''''''Config - global variables Dim g_AdMentor_AdMentorRedirPath ' Dim g_AdMentor_Demo ' Dim g_Admentor_strConnect ' Connect string Dim g_AdMentor_MaxRecords Dim g_AdMentor_PathToAdServe ' HTTP path to adserve.asp and adclick.asp, like http://www.sqlexperts.com/ads Dim g_AdMentor_DatabaseType ' SQLServer or Access Dim strAdmentor_strAlreadyOnPage 'Internal - you should not set it yourself g_AdMentor_DatabaseType = "Access" 'g_AdMentor_DatabaseType = "SQLServer" g_AdMentor_PathToAdServe = "http://www.umanovaera.com/admentor/admentor/" If Right(g_AdMentor_PathToAdServe,1) <> "/" Then g_AdMentor_PathToAdServe = g_AdMentor_PathToAdServe & "/" End If ''''''''''''''''TODO: You might need to change g_Admentor_strConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="& Server.MapPath("/admentor/admentor/ad97.mdb") ''''''''''''''''Variables for optimizing g_AdMentor_MaxRecords = 50 'Set this to the maximum number of banners in a single farm ''''''''''''''''These variables you have to change g_AdMentor_AdMentorRedirPath = g_AdMentor_PathToAdServe & "admentorredir.asp" ' This should be the path to admentorredir.asp g_AdMentor_Demo = false ' If true then you can really update/add/delete stuff ''''''''''''''''Config - Maximin sizes etc Dim g_MaxLongInt, g_MaxEndDate g_MaxLongInt = 2147483647 ' Virtually forever, max for a long integer in Access g_MaxEndDate = "2020-01-01" ' This date means forever... %> <% '-------------------------------------------------------------------- ' Microsoft ADO ' ' (c) 1996 Microsoft Corporation. All Rights Reserved. ' ' ' ' ADO constants include file for VBScript ' '-------------------------------------------------------------------- '---- CursorTypeEnum Values ---- Const adOpenForwardOnly = 0 Const adOpenKeyset = 1 Const adOpenDynamic = 2 Const adOpenStatic = 3 '---- CursorOptionEnum Values ---- Const adHoldRecords = &H00000100 Const adMovePrevious = &H00000200 Const adAddNew = &H01000400 Const adDelete = &H01000800 Const adUpdate = &H01008000 Const adBookmark = &H00002000 Const adApproxPosition = &H00004000 Const adUpdateBatch = &H00010000 Const adResync = &H00020000 Const adNotify = &H00040000 '---- LockTypeEnum Values ---- Const adLockReadOnly = 1 Const adLockPessimistic = 2 Const adLockOptimistic = 3 Const adLockBatchOptimistic = 4 '---- ExecuteOptionEnum Values ---- Const adRunAsync = &H00000010 '---- ObjectStateEnum Values ---- Const adStateClosed = &H00000000 Const adStateOpen = &H00000001 Const adStateConnecting = &H00000002 Const adStateExecuting = &H00000004 '---- CursorLocationEnum Values ---- Const adUseServer = 2 Const adUseClient = 3 '---- DataTypeEnum Values ---- Const adEmpty = 0 Const adTinyInt = 16 Const adSmallInt = 2 Const adInteger = 3 Const adBigInt = 20 Const adUnsignedTinyInt = 17 Const adUnsignedSmallInt = 18 Const adUnsignedInt = 19 Const adUnsignedBigInt = 21 Const adSingle = 4 Const adDouble = 5 Const adCurrency = 6 Const adDecimal = 14 Const adNumeric = 131 Const adBoolean = 11 Const adError = 10 Const adUserDefined = 132 Const adVariant = 12 Const adIDispatch = 9 Const adIUnknown = 13 Const adGUID = 72 Const adDate = 7 Const adDBDate = 133 Const adDBTime = 134 Const adDBTimeStamp = 135 Const adBSTR = 8 Const adChar = 129 Const adVarChar = 200 Const adLongVarChar = 201 Const adWChar = 130 Const adVarWChar = 202 Const adLongVarWChar = 203 Const adBinary = 128 Const adVarBinary = 204 Const adLongVarBinary = 205 '---- FieldAttributeEnum Values ---- Const adFldMayDefer = &H00000002 Const adFldUpdatable = &H00000004 Const adFldUnknownUpdatable = &H00000008 Const adFldFixed = &H00000010 Const adFldIsNullable = &H00000020 Const adFldMayBeNull = &H00000040 Const adFldLong = &H00000080 Const adFldRowID = &H00000100 Const adFldRowVersion = &H00000200 Const adFldCacheDeferred = &H00001000 '---- EditModeEnum Values ---- Const adEditNone = &H0000 Const adEditInProgress = &H0001 Const adEditAdd = &H0002 Const adEditDelete = &H0004 '---- RecordStatusEnum Values ---- Const adRecOK = &H0000000 Const adRecNew = &H0000001 Const adRecModified = &H0000002 Const adRecDeleted = &H0000004 Const adRecUnmodified = &H0000008 Const adRecInvalid = &H0000010 Const adRecMultipleChanges = &H0000040 Const adRecPendingChanges = &H0000080 Const adRecCanceled = &H0000100 Const adRecCantRelease = &H0000400 Const adRecConcurrencyViolation = &H0000800 Const adRecIntegrityViolation = &H0001000 Const adRecMaxChangesExceeded = &H0002000 Const adRecObjectOpen = &H0004000 Const adRecOutOfMemory = &H0008000 Const adRecPermissionDenied = &H0010000 Const adRecSchemaViolation = &H0020000 Const adRecDBDeleted = &H0040000 '---- GetRowsOptionEnum Values ---- Const adGetRowsRest = -1 '---- PositionEnum Values ---- Const adPosUnknown = -1 Const adPosBOF = -2 Const adPosEOF = -3 '---- enum Values ---- Const adBookmarkCurrent = 0 Const adBookmarkFirst = 1 Const adBookmarkLast = 2 '---- MarshalOptionsEnum Values ---- Const adMarshalAll = 0 Const adMarshalModifiedOnly = 1 '---- AffectEnum Values ---- Const adAffectCurrent = 1 Const adAffectGroup = 2 Const adAffectAll = 3 '---- FilterGroupEnum Values ---- Const adFilterNone = 0 Const adFilterPendingRecords = 1 Const adFilterAffectedRecords = 2 Const adFilterFetchedRecords = 3 Const adFilterPredicate = 4 '---- SearchDirection Values ---- Const adSearchForward = 1 Const adSearchBackward = -1 '---- ConnectPromptEnum Values ---- Const adPromptAlways = 1 Const adPromptComplete = 2 Const adPromptCompleteRequired = 3 Const adPromptNever = 4 '---- ConnectModeEnum Values ---- Const adModeUnknown = 0 Const adModeRead = 1 Const adModeWrite = 2 Const adModeReadWrite = 3 Const adModeShareDenyRead = 4 Const adModeShareDenyWrite = 8 Const adModeShareExclusive = &Hc Const adModeShareDenyNone = &H10 '---- IsolationLevelEnum Values ---- Const adXactUnspecified = &Hffffffff Const adXactChaos = &H00000010 Const adXactReadUncommitted = &H00000100 Const adXactBrowse = &H00000100 Const adXactCursorStability = &H00001000 Const adXactReadCommitted = &H00001000 Const adXactRepeatableRead = &H00010000 Const adXactSerializable = &H00100000 Const adXactIsolated = &H00100000 '---- XactAttributeEnum Values ---- Const adXactCommitRetaining = &H00020000 Const adXactAbortRetaining = &H00040000 '---- PropertyAttributesEnum Values ---- Const adPropNotSupported = &H0000 Const adPropRequired = &H0001 Const adPropOptional = &H0002 Const adPropRead = &H0200 Const adPropWrite = &H0400 '---- ErrorValueEnum Values ---- Const adErrInvalidArgument = &Hbb9 Const adErrNoCurrentRecord = &Hbcd Const adErrIllegalOperation = &Hc93 Const adErrInTransaction = &Hcae Const adErrFeatureNotAvailable = &Hcb3 Const adErrItemNotFound = &Hcc1 Const adErrObjectInCollection = &Hd27 Const adErrObjectNotSet = &Hd5c Const adErrDataConversion = &Hd5d Const adErrObjectClosed = &He78 Const adErrObjectOpen = &He79 Const adErrProviderNotFound = &He7a Const adErrBoundToCommand = &He7b Const adErrInvalidParamInfo = &He7c Const adErrInvalidConnection = &He7d Const adErrStillExecuting = &He7f Const adErrStillConnecting = &He81 '---- ParameterAttributesEnum Values ---- Const adParamSigned = &H0010 Const adParamNullable = &H0040 Const adParamLong = &H0080 '---- ParameterDirectionEnum Values ---- Const adParamUnknown = &H0000 Const adParamInput = &H0001 Const adParamOutput = &H0002 Const adParamInputOutput = &H0003 Const adParamReturnValue = &H0004 '---- CommandTypeEnum Values ---- Const adCmdUnknown = &H0008 Const adCmdText = &H0001 Const adCmdTable = &H0002 Const adCmdStoredProc = &H0004 '---- SchemaEnum Values ---- Const adSchemaProviderSpecific = -1 Const adSchemaAsserts = 0 Const adSchemaCatalogs = 1 Const adSchemaCharacterSets = 2 Const adSchemaCollations = 3 Const adSchemaColumns = 4 Const adSchemaCheckConstraints = 5 Const adSchemaConstraintColumnUsage = 6 Const adSchemaConstraintTableUsage = 7 Const adSchemaKeyColumnUsage = 8 Const adSchemaReferentialContraints = 9 Const adSchemaTableConstraints = 10 Const adSchemaColumnsDomainUsage = 11 Const adSchemaIndexes = 12 Const adSchemaColumnPrivileges = 13 Const adSchemaTablePrivileges = 14 Const adSchemaUsagePrivileges = 15 Const adSchemaProcedures = 16 Const adSchemaSchemata = 17 Const adSchemaSQLLanguages = 18 Const adSchemaStatistics = 19 Const adSchemaTables = 20 Const adSchemaTranslations = 21 Const adSchemaProviderTypes = 22 Const adSchemaViews = 23 Const adSchemaViewColumnUsage = 24 Const adSchemaViewTableUsage = 25 Const adSchemaProcedureParameters = 26 Const adSchemaForeignKeys = 27 Const adSchemaPrimaryKeys = 28 Const adSchemaProcedureColumns = 29 %> <% ''''''''''' (C) Stefan Holmberg 1999 ''''''''''' Free to use if these sourcecode lines is not deleted ''''''''''' Contact me at webmaster@sqlexperts.com ''''''''''' http://www.sqlexperts.com ''''''''''' AdMentor homepage at http://www.create-a-webshop.com ' Version 1.11 contains contribution from Shawn Willmon - traceclicks code Function Internal_AdMentordb_GetDateFunction() If g_AdMentor_DatabaseType = "SQLServer" Then Internal_AdMentordb_GetDateFunction = "getdate()" Else Internal_AdMentordb_GetDateFunction = "date()" End If End Function Function Internal_AdMentordb_GetBoolValue( fTrue ) If g_AdMentor_DatabaseType = "SQLServer" Then If fTrue = True Then Internal_AdMentordb_GetBoolValue = "1" Else Internal_AdMentordb_GetBoolValue = "0" End If Else If fTrue = true Then Internal_AdMentordb_GetBoolValue = "true" Else Internal_AdMentordb_GetBoolValue = "false" End If End If End Function Function AdMentor_DBOpenConnection() Dim oConn Set oConn = Server.CreateObject("ADODB.Connection") oConn.Open g_AdMentor_strConnect Set AdMentor_DBOpenConnection = oConn End Function Function AdMentor_DBGetBannersInFarm( oConn, nBannerFarm ) Dim oRS Set oRS = CreateObject("ADODB.Recordset") oRS.CursorLocation = adUseClient oRS.MaxRecords = g_AdMentor_MaxRecords oRS.CacheSize = g_AdMentor_MaxRecords oRS.CursorType = adOpenForwardOnly oRS.Open "select bannerid, gifurl, weight, alttext, undertext, xsize, ysize from banner where farmid=" & nBannerFarm & " and weight > 0 and showcount < maximpressions AND clickcount+underclickcount < maxclicks AND validtodate >= " & Internal_AdMentordb_GetDateFunction() & " AND validfromdate <= " & Internal_AdMentordb_GetDateFunction(), oConn Set oRS.ActiveConnection = Nothing Set AdMentor_DBGetBannersInFarm = oRS End Function Sub AdMentor_DBAddShowCount( oConn, nBanner ) oConn.Execute "update banner set showcount=showcount+1 where bannerid=" & nBanner End Sub Sub AdMentor_DBUpdateClickCount( oConn, nBanner, fUnderText ) Dim sSQL Dim oRSTC If fUnderText = True Then sSQL = "update banner set underclickcount = underclickcount +1 where bannerid = " & nBanner Else sSQL = "update banner set clickcount = clickcount +1 where bannerid = " & nBanner End if oConn.Execute ( sSQL ) Set oRSTC = Server.CreateObject("ADODB.Recordset") Set oRSTC.ActiveConnection = oConn oRSTC.Open "select * from traceclicks where bannerid = -1 ", ,adOpenKeyset,adLockOptimistic oRSTC.AddNew() oRSTC("bannerid")=nBanner oRSTC("page")=Request.ServerVariables("HTTP_REFERER") oRSTC("dt") = now() oRSTC("ip")=Request.ServerVariables( "REMOTE_ADDR" ) oRSTC("undertext")=fUndertext oRSTC.Update oRSTC.Close Set oRSTC = Nothing End Sub Function AdMentor_DBGetUrl( oConn, nBanner, fUnderText ) Dim oRS Dim sSQL2 If fUnderText = True Then sSQL2 = "select underurl as url from banner where bannerid= " & nBanner Else sSQL2 = "select redirurl as url from banner where bannerid= " & nBanner End if Set oRS = oConn.Execute ( sSQL2 ) AdMentor_DBGetUrl = oRS("url").Value oRS.Close Set oRS = Nothing End Function Function AdSQL_AddAndWhere( strWhere, strWhat ) If strWhere = "" Then strWhere = " WHERE " Else strWhere = strWhere & " AND " End If strWhere = strWhere & " " & strWhat AdSQL_AddAndWhere = strWhere End Function Function AdMentor_DBGetAvailBanners( oConn, fASP, strZones, nFarm, nBannerId, fCanUseHTML ) Dim oRS Set oRS = CreateObject("ADODB.Recordset") oRS.CursorLocation = adUseClient oRS.MaxRecords = g_AdMentor_MaxRecords oRS.CacheSize = g_AdMentor_MaxRecords oRS.CursorType = adOpenStatic oRS.Open GetAdSQL(fASP, strZones, nFarm, nBannerId, fCanUseHTML ), oConn Set oRS.ActiveConnection = Nothing Set AdMentor_DBGetAvailBanners = oRS End Function Function AdMentor_GetHTMLCode( oConn, nBannerId ) Dim oRS Set oRS = CreateObject("ADODB.Recordset") oRS.CursorLocation = adUseClient oRS.MaxRecords = 1 oRS.CacheSize = 1 oRS.CursorType = adOpenForwardOnly oRS.Open "select htmlcode from banner where bannerid="&nBannerId, oConn AdMentor_GetHTMLCode = oRS("htmlcode").Value oRS.Close Set oRS = Nothing End Function Function GetAdSQL( fASP, sZone, nFarm, nBannerId, fCanUseHTML ) Dim strSQL Dim strWhere strSQL = "select distinct banner.bannerid, banner.gifurl, banner.weight " If fASP Then strSQL = strSQL & ", banner.AltText, banner.UnderText, banner.xsize, banner.ysize " End If If fCanUseHTML Then strSQL = strSQL & ",ishtml" End If If strAdmentor_strAlreadyOnPage <> "" Then strWhere = AdSQL_AddAndWhere( strWhere, "banner.bannerid not in ( " & strAdmentor_strAlreadyOnPage & ")" ) End If strSQL = strSQL & " from banner " If sZone <> "0" Then strSQL = strSQL & ",banzone " strWhere = AdSQL_AddAndWhere( strWhere, "banner.bannerid=banzone.bannerid" ) strWhere = AdSQL_AddAndWhere( strWhere, "banzone.zoneid in ( " & sZone & ")" ) End If If nBannerId <> "" Then strWhere = AdSQL_AddAndWhere( strWhere, "banner.bannerid=" & nBannerId ) Else If nFarm <> 0 Then strWhere = AdSQL_AddAndWhere( strWhere, "banner.farmid=" & nFarm ) End If strWhere = AdSQL_AddAndWhere( strWhere, "weight > 0 and showcount < maximpressions AND validtodate >= " & Internal_AdMentordb_GetDateFunction() & " AND validfromdate <= " & Internal_AdMentordb_GetDateFunction() ) If fCanUseHTML = True Then strWhere = AdSQL_AddAndWhere( strWhere, " ( ( clickcount+underclickcount < maxclicks ) OR ishtml=" & Internal_AdMentordb_GetBoolValue(true) & " )" ) Else strWhere = AdSQL_AddAndWhere( strWhere, "ishtml <> " & Internal_AdMentordb_GetBoolValue(true) ) End If End If strSQL = strSQL & strWhere ' If you want banners with no zoning to mean all zones then add these ' lines ' If sZone <> "0" Then ' strSQL = strSQL & "union select distinct banner.bannerid, banner.gifurl, banner.weight " ' If fASP Then ' strSQL = strSQL & ", banner.AltText, banner.UnderText, banner.xsize, banner.ysize " ' End If ' If fCanUseHTML Then ' strSQL = strSQL & ",ishtml" ' End If ' strSQL = strSQL & " from banner " ' strSQL = strSQL & " where bannerid not in (select bannerid from banzone)" ' If strAdmentor_strAlreadyOnPage <> "" Then ' strSQL = strSQL & " AND banner.bannerid not in ( " & strAdmentor_strAlreadyOnPage & ")" ' End If ' End If GetAdSQL = strSQL End Function %> <% ''''''''''' (C) Stefan Holmberg 1999 ''''''''''' Free to use if these sourcecode lines is not deleted ''''''''''' Contact me at webmaster@sqlexperts.com ''''''''''' http://www.sqlexperts.com ''''''''''' AdMentor homepage at http://www.create-a-webshop.com ''''''''''''''''The public functions 'This should be called from ASP pages on SAME server 'The QueryString parameter is just that - a querystring string 'where you specify zone etc the same way as when 'using NonSSI version Public Function AdMentor_GetAdASP( strQueryString ) Dim sArr, n Dim sArr2 'Setable parameters Dim sZones, nFarm, nBannerId sArr = Split( strQueryString, "&" ) For n=LBound(sArr) To UBound(sArr) sArr2 = Split( sArr(n), "=" ) Select Case sArr2(0) Case "Z" sZones = sArr2(1) Case "F" nFarm = sArr2(1) Case "B" nBannerId = sArr2(1) Case "N" nBannerOnPage = sArr2(1) End Select Next 'If we have selected a certain banner to run on this 'specific spot then just don't care about the rest... AdMentor_GetAdASP = AdMentor_GetAdEx( True, sZones, nFarm, nBannerId, nBannerOnPage, True ) End Function Public Function AdMentor_GetAdNonSSI() 'Setable parameters Dim sZones, nFarm, nBannerId, nBannerOnPage sZones = Request.QueryString("Z") nFarm = Request.QueryString("F") nBannerId = Request.QueryString("B") nBannerOnPage = Request.QueryString("N") AdMentor_GetAdNonSSI = AdMentor_GetAdEx( False, sZones, nFarm, nBannerId, nBannerOnPage, False ) End Function 'Private functions Private Function AdMentor_AddToUsedList( nBannerId ) If strAdmentor_strAlreadyOnPage <> "" Then strAdmentor_strAlreadyOnPage = strAdmentor_strAlreadyOnPage & "," End If strAdmentor_strAlreadyOnPage = strAdmentor_strAlreadyOnPage & CStr(nBannerId) End Function ' If ASP then it returns the HTML ' else it simply returns the bannerid ' fASP = true or false Private Function AdMentor_GetAdEx( fASP, strZone, nFarm, nBannerId, nBannerOnPage, fCanUseHTML ) Dim oConn Dim oRS Dim nSumWeight Dim nTempIndex Dim nWeight Dim nTempIndex2 Dim nBanner Dim nCurRow Dim nMax Set oConn = AdMentor_DBOpenConnection() If strZone = "" Then strZone = "0" End If If nFarm = "" Then nFarm = "0" End If ' Get Total Weight Set oRS = AdMentor_DBGetAvailBanners( oConn, fASP, strZone, nFarm, nBannerId, fCanUseHTML ) If oRS.EOF Then 'There is no banner in this banner farm 'TODO: RETURN DEFAULT BANNER!!!!! oRS.Close Set oRS = Nothing oConn.Close Set oConn = Nothing AdMentor_GetAd = "No banner in farm" Exit Function End If 'Now lets get the total weight nSumWeight = 0 While Not oRS.EOF nSumWeight = nSumWeight + oRS("weight").Value oRS.MoveNext Wend ' Lets get a random banner Randomize nBanner = Int((nSumWeight * Rnd) + 1) oRS.MoveFirst nCurVal = 0 While nCurVal + oRS("weight").Value < nBanner nCurVal = nCurVal + oRS("weight").Value oRS.MoveNext Wend nBanner = oRS("bannerid").Value AdMentor_AddToUsedList nBanner If Not fASP Then oRS.Close Set oRS = Nothing AdMentor_GetAdEx = nBanner & "---" & oRS("gifurl").Value AdMentor_DBAddShowCount oConn, nBanner oConn.Close Set oConn = Nothing Exit Function End If If fCanUseHTML And oRS("ishtml").Value = True Then Dim sHTMCode oRS.Close Set oRS = Nothing sHTMCode = AdMentor_GetHTMLCode( oConn, nBanner ) AdMentor_GetAdEx = FixupSpecialVariables(sHTMCode) AdMentor_DBAddShowCount oConn, nBanner oConn.Close Set oConn = Nothing Exit Function End If ' Now we have the banner id, lets create the actual HTML 'Move into temp variables only to make it more readable Dim sRedirUrl Dim sGifUrl Dim sAltText Dim sUnderText Dim sUnderUrl Dim sRet Dim nXSize Dim nYSize sRedirUrl = g_AdMentor_AdMentorRedirPath & "?id=" & nBanner & "&way=ban" If IsNull( oRS("gifurl").Value ) Then sGifUrl = "" Else sGifUrl = oRS("gifurl").Value End if If IsNull( oRS("AltText").Value ) Then sAltText = "" Else sAltText = oRS("AltText").Value End if If IsNull( oRS("UnderText").Value ) Then sUnderText = "" Else sUnderText = oRS("UnderText").Value End if sUnderUrl = g_AdMentor_AdMentorRedirPath & "?id=" & nBanner & "&way=txt" nXSize=oRS("xsize").Value nYSize=oRS("ysize").Value sRet = "
" & "" & "" If sUnderText <> "" Then sRet = sRet & "
" & sUnderText & "" Else ' End If sRet = sRet & "
" AdMentor_GetAdEx = sRet ' Lets update impression for it AdMentor_DBAddShowCount oConn, nBanner oRS.Close Set oRS = Nothing oConn.Close Set oConn = Nothing End Function Public Function AdMentor_ClickAd(nBannerId, sWay) Dim oConn Dim sSQL Dim sSQL2 Dim oRS Dim sRedir Dim fIsUnderText If sWay ="txt" Then fIsUnderText = true Else fIsUnderText = false ' Clicked on actual banner End If 'Pretty easy... Set oConn = AdMentor_DBOpenConnection() AdMentor_DBUpdateClickCount oConn, nBannerId, fIsUnderText sRedir = AdMentor_DBGetUrl( oConn, nBannerId, fIsUnderText ) oConn.Close Set oConn = Nothing AdMentor_ClickAd = sRedir End Function Private Function FixupSpecialVariables( sHTML ) 'Now check for ' 0 Then sLeftHTML = Left( sHTML, nIndStart -1 ) nIndEnd = InStr( nIndStart, sHTML, ">" ) sRightHTML = Mid( sHTML, nIndEnd + 1 ) sSubStr = Mid( sHTML, nIndStart, nIndEnd - nIndStart ) vData = Split( sSubStr, "-") If vData(1) = "LAST" Then nNumber = Session("AdMentor_RndNumber") Else nLow = CLng(vData(1)) nHigh = CLng(vData(2)) Randomize nNumber = CLng((nHigh * Rnd) + nLow) Session("AdMentor_RndNumber") = nNumber End If sHTML = sLeftHTML & CStr(nNumber) & sRightHTML End If If InStr( 1,CStr(sHTML), " 0 Then fCont = True Else fCont = False End If Wend FixupSpecialVariables = sHTML End Function Public Function GetAdminPagesBannerCode() 'Want to advertise on your admin pages? 'Then just change this function to what you want... 'What I do is just call AdMentorGetAd with a special banner id 'to get by Datais-banners showed ' Dim sRet ' sRet = AdMentor_GetAdASP("B=93") GetAdminPagesBannerCode = "" End Function %> <% Dim sId Dim sWay Dim sRedir sId = GetId() sWay = "ban" sRedir = AdMentor_ClickAd( sId, sWay ) Response.Redirect sRedir Function GetId() ' How to get id from clicked banner ' Oh, yes we stored it in session... Dim nBanNoOnPage If Request.QueryString("N") = "" Then nBanNoOnPage = 1 Else nBanNoOnPage = Request.QueryString("N") End If GetId = Session("AdMentor_BannerId" & nBanNoOnPage ) End Function %>