<% ' Last Updated 27th September 2006 ' Jonathan Maxwell Function RandomBanner(BannerArray) ' Creates banner for top of page Randomize dim RandomNumber dim BannerSrc, BannerLink, BannerAlt RandomNumber = int(rnd*Ubound(BannerArray))+1 BannerSrc = BannerArray(RandomNumber, 0) BannerLink = BannerArray(RandomNumber, 1) BannerAlt = BannerArray(RandomNumber, 2) RandomBanner = "" End Function Function FormatTextboxHTML(strString) ' Replaces spaces with HTML equivalents if isnull(strString) = false then strString = Replace(strString,vbcrlf & vbcrlf,"

") strString = Replace(strString,vbcrlf,"
") end if FormatTextboxHTML = strString End Function Function RandomPassword() ' Creates an 8 letter/number random string dim strPass, strPasswordTemp dim intUpper, intLower, intRand, intNum, i Randomize For i = 1 to 8 intNum = Int(10 * Rnd + 48) intUpper = Int(26 * Rnd + 65) intLower = Int(26 * Rnd + 97) intRand = Int(3 * Rnd + 1) Select Case intRand Case 1 strPass = Chr(intNum) Case 2 strPass = Chr(intUpper) Case 3 strPass = Chr(intLower) End Select strPasswordTemp = strPasswordTemp & strPass Next RandomPassword = LCASE(strPasswordTemp) End Function Function TitleCase(TitleString) 'Converts a string into Title Case 'Written by Tim Surtell and downloaded from www.surtell.com '(C) 2004 Tim Surtell dim TempString, NextCap, CurrentChar NextCap = True for CurrentChar = 1 to Len(TitleString) if NextCap = True then TempString = TempString & UCase(Mid(TitleString, CurrentChar, 1)) NextCap = False else TempString = TempString & Mid(TitleString, CurrentChar, 1) end if if InStr(" ({[""""", Mid(TitleString, CurrentChar, 1)) > 0 then NextCap = True end if next TitleCase = TempString End Function function FixEmail(strEmailAddress) ' Gets rid of non-email syntax strEmailAddress = fixQuotes(strEmailAddress) strEmailAddress=lcase(strEmailAddress) strEmailAddress=replace(strEmailAddress," ", "") strEmailAddress=replace(strEmailAddress,",", ".") if left(strEmailAddress,4) = "www." then strEmailAddress = mid(strEmailAddress,5,len(strEmailAddress)) FixEmail = strEmailAddress end function FUNCTION invalidEmail( email ) ' Is email valid? IF INSTR( email, "@" ) = 0 OR INSTR( email, "." ) = 0 THEN invalidEmail = TRUE ELSE invalidEmail = FALSE END IF END FUNCTION FUNCTION invalidUrl( url ) ' Is url valid? IF INSTR( url, "http://" ) = 0 OR INSTR( url, "." ) = 0 THEN invalidUrl = TRUE ELSE invalidUrl = FALSE END IF END FUNCTION FUNCTION SELECTED( firstVal, secondVal ) ' Adds a selected to a drop-down/listbox if selected IF cSTR( firstVal ) = cSTR( secondVal ) THEN SELECTED = " SELECTED " ELSE SELECTED = "" END IF END FUNCTION FUNCTION CHECKED( firstVal, secondVal ) ' Adds a tick/check to check box if selected IF cSTR( firstVal ) = cSTR( secondVal ) THEN CHECKED = " CHECKED " ELSE CHECKED = "" END IF END FUNCTION FUNCTION FixQuotes(theString) ' Replaces ' with '' dim strTemp if isnull(theString) = false then strTemp = Cstr(theString) strTemp = replace(strTemp,"'","''") FixQuotes = trim(strTemp) else FixQuotes = null end if END FUNCTION FUNCTION FixApostrophe(theString) ' Replaces ' with ascii code equivalent(?) dim strTemp if isnull(theString) = false then strTemp = Cstr(theString) strTemp = replace(strTemp,"'","'") strTemp = replace(strTemp,chr(34),""") strTemp = replace(strTemp,",",",") FixApostrophe = trim(strTemp) else FixApostrophe = null end if END FUNCTION Function GetUrl() ' Get current url GetUrl = request.servervariables("SCRIPT_NAME") & "?" & request.ServerVariables("QUERY_STRING") End Function Public Function CreateList(Data, RowDelimiter, ColDelimiter, ListType, ListName, FirstOption, Style, Extra) ' Create list from datasource dim strTempArray, strTempInnerArray, strTempValue, strTempText, strTempSelected dim strTempList dim i strTempArray = split(Data,RowDelimiter) for i = 0 to ubound(strTempArray) if trim(strTempArray(i)) <> "" then strTempInnerArray = split(strTempArray(i),ColDelimiter) strTempValue = trim(strTempInnerArray(0)) strTempText = trim(strTempInnerArray(1)) strTempSelected = trim(strTempInnerArray(2)) end if ' Create list items Select Case lcase(ListType) case "listbox", "dropdown" strTempList = strTempList & "" & vbcrlf case "checkbox" strTempList = strTempList & "" & strTempText & "" & vbcrlf case "textbox" strTempList = strTempList & "" & i+1 & "" & vbcrlf case "radiobutton" strTempList = strTempList & "" & strTempText & "" & vbcrlf case "hidden" strTempList = strTempList & "
" & vbcrlf case "list" strTempList = strTempList & "

  • " & strTempText & "
  • " & vbcrlf case "br" strTempList = strTempList & "" & strTempText & "
    " & vbcrlf case else strTempList = strTempList & "" & strTempText & "" & vbcrlf End Select next ' Finish List Select Case lcase(ListType) case "listbox" strTempList = "" case "dropdown" strTempList = "" case "list" strTempList = "" case "br" case else strTempList = "" & strTempList & "
    " End Select CreateList = strTempList End Function Sub PageMessage(Message, Style) ' Updates page message for e.g. success or failure of an insert response.Write "" & vbcrlf End Sub Function ReplaceKeyTags(Temp) ' Replaces {yyy} value with correct values Temp = replace(Temp,"{br}","
    ") Temp = replace(Temp,"{p}","

    ") Temp = replace(Temp,"{b}","") Temp = replace(Temp,"{/b}","") Temp = replace(Temp,"{\b}","<\b>") Temp = replace(Temp,"{i}","") Temp = replace(Temp,"{/i}","") Temp = replace(Temp,"{\i}","<\i>") ReplaceKeyTags = Temp End Function Function GetPageName() ' Gets current page name dim strTempURL strTempURL = request.ServerVariables("URL") strTempURL = strReverse(strTempURL) strTempURL = left(strTempURL,instr(strTempURL,"/")-1) strTempURL = strReverse(strTempURL) GetPageName = strTempURL End Function Function ScreenScrape(url) ' Gets a web page's contents Dim xml, strData if url = "" then exit function 'Next, create an instance of the MS XMLhttp component. 'old version, unstable server side performance so upgrade if you can ' *** OLD *** Set xml = Server.CreateObject("Microsoft.XMLHTTP") 'new version, better server side performance Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP") xml.Open "GET", url, true ' the True specifies an asynchronous request Call xml.Send() 'Turn off error handling On Error Resume Next 'Wait for up to 3 seconds if we've not gotten the data yet If xml.readyState <> 4 then xml.waitForResponse 3 End If 'Did an error occur? If so, use a default value for our data If Err.Number <> 0 then strData = "" Else If (xml.readyState <> 4) Or (xml.Status <> 200) Then 'Abort the XMLHttp request xml.Abort strData = "" Else strData = xml.ResponseText End If End If ScreenScrape = strData End Function Function CreateBar(BarWidth, TotalBarWidth) dim BarTable, Colour Colour = "green" ' Get correct colour depending on percent if CInt((100/TotalBarWidth)*BarWidth) >= 75 and CInt((100/TotalBarWidth)*BarWidth) <= 85 then Colour = "orange" elseif CInt((100/TotalBarWidth)*BarWidth) > 85 then Colour = "red" end if BarTable = "" & vbcrlf & _ "" & vbcrlf & _ " " & vbcrlf & _ " " & vbcrlf & _ " " & vbcrlf & _ " " & vbcrlf & _ "" & vbcrlf & _ "
    " CreateBar = BarTable End Function Function GetCurrencyName(Symbol,ISO) Select case lcase(Symbol) case "£", "£" if ISO then GetCurrencyName = "gbp" else GetCurrencyName = "British Pounds Sterling" end if case "$" if ISO then GetCurrencyName = "usd" else GetCurrencyName = "US Dollars" end if case "€", "€" if ISO then GetCurrencyName = "eur" else GetCurrencyName = "Euro" end if case else if ISO then GetCurrencyName = "eur" else GetCurrencyName = "British Pounds Sterling" end if End Select End Function Function ProductPageName(Product) ' Formats product name page.asp dim Temp Temp = Product if Product <> "" then Temp = lcase(Temp) Temp = replace(Temp," ","_") Temp = "_" & Temp end if ProductPageName = Temp End Function Function PageProductName(Page) ' Formats page.asp name to product dim Temp Temp = Page if Page <> "" then Temp = replace(Temp,"_"," ") Temp = replace(Temp,".asp","") Temp = TitleCase(Temp) end if PageProductName = Temp End Function Function AddressBreak(Address) ' Creates a break if address has details Dim TempAddress TempAddress = Address if TempAddress <> "" then TempAddress = TempAddress & "
    " end if AddressBreak = TempAddress End Function Function ClearHTMLTags(strHTML, intWorkFlow) ' Clears all HTML characters dim regEx, strTagLess strTagless = strHTML set regEx = New RegExp 'Creates a regexp object regEx.IgnoreCase = True regEx.Global = True 'Removes HTML characters if intWorkFlow <> 1 then regEx.Pattern = "<[^>]*>" strTagLess = regEx.Replace(strTagLess, "") end if 'Sources as HTML if intWorkFlow > 0 and intWorkFlow < 3 then regEx.Pattern = "[<]" 'matches a single < strTagLess = regEx.Replace(strTagLess, "<") regEx.Pattern = "[>]" 'matches a single > strTagLess = regEx.Replace(strTagLess, ">") end if 'Clean up set regEx = nothing ClearHTMLTags = strTagLess End Function %>