% '**************************************************************************************** '** Copyright Notice '** '** Web Wiz Forums(TM) '** http://www.webwizforums.com '** '** Copyright (C)2001-2008 Web Wiz(TM). All Rights Reserved. '** '** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS UNDER LICENSE FROM 'WEB WIZ'. '** '** IF YOU DO NOT AGREE TO THE LICENSE AGREEMENT THEN 'WEB WIZ' IS UNWILLING TO LICENSE '** THE SOFTWARE TO YOU, AND YOU SHOULD DESTROY ALL COPIES YOU HOLD OF 'WEB WIZ' SOFTWARE '** AND DERIVATIVE WORKS IMMEDIATELY. '** '** If you have not received a copy of the license with this work then a copy of the latest '** license contract can be found at:- '** '** http://www.webwizguide.com/license '** '** For more information about this software and for licensing information please contact '** 'Web Wiz' at the address and website below:- '** '** Web Wiz, Unit 10E, Dawkins Road Industrial Estate, Poole, Dorset, BH15 4JD, England '** http://www.webwizguide.com '** '** Removal or modification of this copyright notice will violate the license contract. '** '**************************************************************************************** '*************************** SOFTWARE AND CODE MODIFICATIONS **************************** '** '** MODIFICATION OF THE FREE EDITIONS OF THIS SOFTWARE IS A VIOLATION OF THE LICENSE '** AGREEMENT AND IS STRICTLY PROHIBITED '** '** If you wish to modify any part of this software a license must be purchased '** '**************************************************************************************** '****************************************** '*** Create Usercode ***** '****************************************** Private Function userCode(ByVal strUsername) Dim strUserCode 'Randomise the system timer Randomize Timer 'Calculate a code for the user strUserCode = strUsername & hexValue(10) 'Make the usercode SQL safe strUserCode = formatSQLInput(strUserCode) 'Replace double quote with single in this intance strUserCode = Replace(strUserCode, "''", "'", 1, -1, 1) 'Remove ; from the usercode as this can course issues with the session tracking system (; is used as a seporator in teh session tracking system) strUserCode = Replace(strUserCode, ";", "", 1, -1, 1) 'Return the function userCode = strUserCode End Function '********************************************* '*** Browser Detection for Degradablity **** '********************************************* 'Ths function allows us to quickly detect the browser version so that some items can be disabled in browsers which have buggy support Private Function browserDetect() Dim strUserAgent 'Holds info on the users browser 'Get the users HTTP user agent (web browser) strUserAgent = Request.ServerVariables("HTTP_USER_AGENT") 'MSIE If InStr(1, strUserAgent, "MSIE", 1) AND InStr(1, strUserAgent, "Opera", 1) = 0 Then 'Check that we are dealing with a numeric number If isNumeric(Trim(Mid(strUserAgent, CInt(inStr(1, strUserAgent, "MSIE", 1)+5), 1))) Then 'MSIE 6 or below If CInt(Trim(Mid(strUserAgent, CInt(inStr(1, strUserAgent, "MSIE", 1)+5), 1))) <= 6 Then browserDetect = "MSIE6-" Else browserDetect = "MSIE" End If Else browserDetect = "MSIE" End If 'Gekco ElseIf inStr(1, strUserAgent, "Gecko", 1) Then browserDetect = "Gecko" 'Opera ElseIf inStr(1, strUserAgent, "Opera", 1) Then browserDetect = "opera" 'Others Else browserDetect = "na" End If End Function '****************************************** '*** Random Hex Generator **** '****************************************** Private Function hexValue(ByVal intHexLength) Dim intLoopCounter Dim strHexValue 'Randomise the system timer Randomize Timer() 'Generate a hex value For intLoopCounter = 1 to intHexLength 'Genreate a radom decimal value form 0 to 15 intHexLength = CInt(Rnd * 1000) Mod 16 'Turn the number into a hex value Select Case intHexLength Case 1 strHexValue = "1" Case 2 strHexValue = "2" Case 3 strHexValue = "3" Case 4 strHexValue = "4" Case 5 strHexValue = "5" Case 6 strHexValue = "6" Case 7 strHexValue = "7" Case 8 strHexValue = "8" Case 9 strHexValue = "9" Case 10 strHexValue = "A" Case 11 strHexValue = "B" Case 12 strHexValue = "C" Case 13 strHexValue = "D" Case 14 strHexValue = "E" Case 15 strHexValue = "F" Case Else strHexValue = "Z" End Select 'Place the hex value into the return string hexValue = hexValue & strHexValue Next End Function '******************************************** '*** Rich Text Compatible Browser type ***** '******************************************** Private Function RTEenabled() Dim strUserAgent 'Holds info on the users browser 'Get the users HTTP user agent (web browser) strUserAgent = Request.ServerVariables("HTTP_USER_AGENT") '************************************* '***** Windows Internet Explorer ***** '************************************* 'See if the user agent is IE on Winows and not Opera trying to look like IE If InStr(1, strUserAgent, "MSIE", 1) > 0 AND InStr(1, strUserAgent, "Win", 1) > 0 AND InStr(1, strUserAgent, "Opera", 1) = 0 Then 'Now we know this is Windows IE we need to see if the version number is 5.5 If Trim(Mid(strUserAgent, inStr(1, strUserAgent, "MSIE", 1)+5, 3)) = "5.5" OR Trim(Mid(strUserAgent, inStr(1, strUserAgent, "MSIE", 1)+5, 3)) = "5,5" Then RTEenabled = "winIE" 'Now we know this is Windows IE we need to see if the version number is 6+ (error handling to make sure number is numeric) ElseIf isNumeric(Trim(Mid(strUserAgent, CInt(inStr(1, strUserAgent, "MSIE", 1)+5), 1))) Then 'Now check the version number is 6 or above If CInt(Trim(Mid(strUserAgent, CInt(inStr(1, strUserAgent, "MSIE", 1)+5), 1))) >= 6 Then RTEenabled = "winIE" 'Else IE is below 5 Else RTEenabled = "false" End If 'Else the IE version is below 5 so return na Else RTEenabled = "false" End If '**************************** '***** Mozilla Firebird ***** '**************************** 'See if this is a version of Mozilla Firebird that supports Rich Text Editing under it's Midas API ElseIf inStr(1, strUserAgent, "Firebird", 1) Then 'Now we know this is Mozilla Firebird we need to see if the version 0.6.1 or above; relase date is above 2003/07/28 If CLng(Trim(Mid(strUserAgent, CInt(inStr(1, strUserAgent, "Gecko/", 1)+6), 8))) >= 20030728 Then RTEenabled = "Gecko" 'Else the Mozilla Firebird version is below 1.5 so return false Else RTEenabled = "false" End If '********************************************** '***** Mozilla Firefox/Seamonkey/Netscape ***** '********************************************** 'See if this is a version of Mozilla/Netscape that supports Rich Text Editing under it's Midas API ElseIf inStr(1, strUserAgent, "Gecko", 1) > 0 AND inStr(1, strUserAgent, "Firebird", 1) = 0 AND isNumeric(Trim(Mid(strUserAgent, CInt(inStr(1, strUserAgent, "Gecko/", 1)+6), 8))) Then 'Now we know this is Mozilla/Netscape we need to see if the version number is above 1.3 or above; relase date is above 2003/03/12 If CLng(Trim(Mid(strUserAgent, CInt(inStr(1, strUserAgent, "Gecko/", 1)+6), 8))) => 20030312 Then RTEenabled = "Gecko" 'Else the Mozilla version is below 1.3 or below 7.1 of Netscape so return false Else RTEenabled = "false" End If '********************************************** '***** Opera 9 ***** '********************************************** 'See if this is Opera that supports Rich Text Opera 9) ElseIf inStr(1, strUserAgent, "Opera", 1) Then 'now we need to see what version of Opera we are using If isNumeric(Trim(Mid(strUserAgent, CInt(inStr(1, strUserAgent, "Opera/", 1)+6), 1))) Then If CLng(Trim(Mid(strUserAgent, CInt(inStr(1, strUserAgent, "Opera/", 1)+6), 1))) => 9 Then RTEenabled = "opera" 'Else the Opera version is below 9 so return false Else RTEenabled = "false" End If 'Else the Opera version is below 9 so return false Else RTEenabled = "false" End If '****************************** '***** Apple Safari ***** '****************************** 'See if this is Safari that supports Rich Text (Safari 3.1 and above) ElseIf inStr(1, strUserAgent, "Safari", 1) Then 'Javascript is not supported on the iPhone and iPod If inStr(1, strUserAgent, "iPhone", 1) OR inStr(1, strUserAgent, "iPod", 1) Then RTEenabled = "false" 'See what everion we are using of Safari ElseIf isNumeric(Trim(Mid(strUserAgent, CInt(inStr(1, strUserAgent, "Safari/", 1)+7), 3))) Then 'If the version number is 523 or above it is fully RTE enabled If CLng(Trim(Mid(strUserAgent, CInt(inStr(1, strUserAgent, "Safari/", 1)+7), 3))) => 523 Then 'Safari works idenetically to Gekco so idenetify as Gecko RTEenabled = "Gecko" 'Else the the version is older and not fully RTE enabled Else RTEenabled = "false" End If 'Else the Safari version is below 3.0.4 so return false Else RTEenabled = "false" End If '*********************************** '***** Non RTE Enabled Browser ***** '*********************************** 'Else this is a browser that does not support Rich Text Editing Else 'RTEenabled - false RTEenabled = "false" End If End Function '****************************************** '*** Get Web Browser Details ***** '****************************************** Private Function BrowserType() Dim strUserAgent 'Holds info on the users browser and os Dim strBrowserUserType 'Holds the users browser type 'Get the users HTTP user agent (web browser) strUserAgent = Request.ServerVariables("HTTP_USER_AGENT") 'Get the uesrs web browser 'Opera If InStr(1, strUserAgent, "Opera 5", 1) Then strBrowserUserType = "Opera 5" ElseIf InStr(1, strUserAgent, "Opera 6", 1) Then strBrowserUserType = "Opera 6" ElseIf InStr(1, strUserAgent, "Opera 7", 1) Then strBrowserUserType = "Opera 7" ElseIf InStr(1, strUserAgent, "Opera 8", 1) Then strBrowserUserType = "Opera 8" ElseIf InStr(1, strUserAgent, "Opera 9", 1) Then strBrowserUserType = "Opera 9" ElseIf InStr(1, strUserAgent, "Opera 10", 1) Then strBrowserUserType = "Opera 10" ElseIf InStr(1, strUserAgent, "Opera", 1) Then strBrowserUserType = "Opera" 'AOL ElseIf inStr(1, strUserAgent, "AOL", 1) Then strBrowserUserType = "AOL" 'Konqueror ElseIf inStr(1, strUserAgent, "Konqueror", 1) Then strBrowserUserType = "Konqueror" 'EudoraWeb ElseIf inStr(1, strUserAgent, "EudoraWeb", 1) Then strBrowserUserType = "EudoraWeb" 'Dreamcast ElseIf inStr(1, strUserAgent, "Dreamcast", 1) Then strBrowserUserType = "Dreamcast" 'Google Chrome ElseIf inStr(1, strUserAgent, "Chrome", 1) Then strBrowserUserType = "Google Chrome" 'Safari ElseIf inStr(1, strUserAgent, "Safari", 1) AND inStr(1, strUserAgent, "Version/1", 1) Then strBrowserUserType = "Safari 1" ElseIf inStr(1, strUserAgent, "Safari", 1) AND inStr(1, strUserAgent, "Version/2", 1) Then strBrowserUserType = "Safari 2" ElseIf inStr(1, strUserAgent, "Safari", 1) AND inStr(1, strUserAgent, "Version/3", 1) Then strBrowserUserType = "Safari 3" ElseIf inStr(1, strUserAgent, "Safari", 1) AND inStr(1, strUserAgent, "Version/4", 1) Then strBrowserUserType = "Safari 4" ElseIf inStr(1, strUserAgent, "Safari", 1) Then strBrowserUserType = "Safari" 'Lynx ElseIf inStr(1, strUserAgent, "Lynx", 1) Then strBrowserUserType = "Lynx" 'ICE ElseIf inStr(1, strUserAgent, "ICE", 1) Then strBrowserUserType = "ICE" 'iCab ElseIf inStr(1, strUserAgent, "iCab", 1) Then strBrowserUserType = "iCab" 'HotJava ElseIf inStr(1, strUserAgent, "Sun", 1) AND inStr(1, strUserAgent, "Mozilla/3", 1) Then strBrowserUserType = "HotJava" 'Galeon ElseIf inStr(1, strUserAgent, "Galeon", 1) Then strBrowserUserType = "Galeon" 'Epiphany ElseIf inStr(1, strUserAgent, "Epiphany", 1) Then strBrowserUserType = "Epiphany" 'DocZilla ElseIf inStr(1, strUserAgent, "DocZilla", 1) Then strBrowserUserType = "DocZilla" 'Camino ElseIf inStr(1, strUserAgent, "Chimera", 1) OR inStr(1, strUserAgent, "Camino", 1) Then strBrowserUserType = "Camino" 'Dillo ElseIf inStr(1, strUserAgent, "Dillo", 1) Then strBrowserUserType = "Dillo" 'amaya ElseIf inStr(1, strUserAgent, "amaya", 1) Then strBrowserUserType = "Amaya" 'NetCaptor ElseIf inStr(1, strUserAgent, "NetCaptor", 1) Then strBrowserUserType = "NetCaptor" 'Twiceler ElseIf inStr(1, strUserAgent, "Twiceler", 1) Then strBrowserUserType = "Twiceler" 'LookSmart search engine robot ElseIf inStr(1, strUserAgent, "ZyBorg", 1) Then strBrowserUserType = "LookSmart" 'Googlebot search engine robot ElseIf inStr(1, strUserAgent, "Googlebot", 1) Then strBrowserUserType = "Google" 'Google/AdSense search engine robot ElseIf inStr(1, strUserAgent, "Mediapartners-Google", 1) Then strBrowserUserType = "Google/AdSense" 'MSN search engine robot ElseIf inStr(1, strUserAgent, "msnbot", 1) Then strBrowserUserType = "MSN" 'inktomi search engine robot ElseIf inStr(1, strUserAgent, "slurp", 1) Then strBrowserUserType = "Yahoo" 'AltaVista search engine robot ElseIf inStr(1, strUserAgent, "Scooter", 1) Then strBrowserUserType = "AltaVista" 'DMOZ search engine robot ElseIf inStr(1, strUserAgent, "Robozilla", 1) Then strBrowserUserType = "DMOZ" 'Ask Jeeves search engine robot ElseIf inStr(1, strUserAgent, "Ask Jeeves", 1) OR inStr(1, strUserAgent, "Ask+Jeeves", 1) Then strBrowserUserType = "Ask Jeeves" 'Lycos search engine robot ElseIf inStr(1, strUserAgent, "lycos", 1) Then strBrowserUserType = "Lycos" 'Excite search engine robot ElseIf inStr(1, strUserAgent, "ArchitextSpider", 1) Then strBrowserUserType = "Excite" 'Northernlight search engine robot ElseIf inStr(1, strUserAgent, "Gulliver", 1) Then strBrowserUserType = "Northernlight" 'AllTheWeb search engine robot ElseIf inStr(1, strUserAgent, "crawler@fast", 1) Then strBrowserUserType = "AllTheWeb" 'Turnitin search engine robot ElseIf inStr(1, strUserAgent, "TurnitinBot", 1) Then strBrowserUserType = "Turnitin" 'InternetSeer search engine robot ElseIf inStr(1, strUserAgent, "internetseer", 1) Then strBrowserUserType = "InternetSeer" 'NameProtect Inc. search engine robot ElseIf inStr(1, strUserAgent, "nameprotect", 1) Then strBrowserUserType = "NameProtect" 'PhpDig search engine robot ElseIf inStr(1, strUserAgent, "PhpDig", 1) Then strBrowserUserType = "PhpDig" 'Rambler search engine robot ElseIf inStr(1, strUserAgent, "StackRambler", 1) Then strBrowserUserType = "Rambler" 'UbiCrawler search engine robot ElseIf inStr(1, strUserAgent, "UbiCrawler", 1) Then strBrowserUserType = "UbiCrawler" 'entireweb search engine robot ElseIf inStr(1, strUserAgent, "Speedy+Spider", 1) Then strBrowserUserType = "entireweb" 'Alexa.com search engine robot ElseIf inStr(1, strUserAgent, "ia_archiver", 1) Then strBrowserUserType = "Alexa" 'Arianna/Libero search engine robot ElseIf inStr(1, strUserAgent, "arianna.libero.it", 1) Then strBrowserUserType = "Arianna/Libero" 'y2bot/1.0 (+http://bot.y2crack4.com) search engine robot ElseIf inStr(1, strUserAgent, "y2bot", 1) Then strBrowserUserType = "y2bot" 'Amazon robot checking their affiliate sites ElseIf inStr(1, strUserAgent, "aranhabot", 1) Then strBrowserUserType = "Amazon.com" 'Internet Explorer ElseIf inStr(1, strUserAgent, "MSIE 9", 1) Then strBrowserUserType = "IE 9" ElseIf inStr(1, strUserAgent, "MSIE 8", 1) Then strBrowserUserType = "IE 8" ElseIf inStr(1, strUserAgent, "MSIE 7", 1) Then strBrowserUserType = "IE 7" ElseIf inStr(1, strUserAgent, "MSIE 6", 1) Then strBrowserUserType = "IE 6" ElseIf inStr(1, strUserAgent, "MSIE 5", 1) Then strBrowserUserType = "IE 5" ElseIf inStr(1, strUserAgent, "MSIE 4", 1) Then strBrowserUserType = "IE 4" ElseIf inStr(1, strUserAgent, "MSIE", 1) Then strBrowserUserType = "IE" 'Pocket Internet Explorer ElseIf inStr(1, strUserAgent, "MSPIE", 1) Then strBrowserUserType = "Pocket IE" 'Firefox ElseIf inStr(1, strUserAgent, "Firefox/1", 1) Then strBrowserUserType = "Firefox 1" ElseIf inStr(1, strUserAgent, "Firefox/2", 1) Then strBrowserUserType = "Firefox 2" ElseIf inStr(1, strUserAgent, "Firefox/3", 1) Then strBrowserUserType = "Firefox 3" ElseIf inStr(1, strUserAgent, "Firefox/4", 1) Then strBrowserUserType = "Firefox 4" ElseIf inStr(1, strUserAgent, "Firefox/5", 1) Then strBrowserUserType = "Firefox 5" ElseIf inStr(1, strUserAgent, "Firefox", 1) Then strBrowserUserType = "Firefox" 'Netscape ElseIf inStr(1, strUserAgent, "Netscape/9", 1) Then strBrowserUserType = "Netscape 9" ElseIf inStr(1, strUserAgent, "Netscape/8", 1) Then strBrowserUserType = "Netscape 8" ElseIf inStr(1, strUserAgent, "Netscape/7", 1) Then strBrowserUserType = "Netscape 7" ElseIf inStr(1, strUserAgent, "Netscape6", 1) Then strBrowserUserType = "Netscape 6" ElseIf inStr(1, strUserAgent, "Mozilla/4", 1) Then strBrowserUserType = "Netscape 4" 'Mozilla ElseIf inStr(1, strUserAgent, "Gecko", 1) AND inStr(1, strUserAgent, "rv:2", 1) Then strBrowserUserType = "Mozilla 2" ElseIf inStr(1, strUserAgent, "Gecko", 1) AND inStr(1, strUserAgent, "rv:1", 1) Then strBrowserUserType = "Mozilla 1" ElseIf inStr(1, strUserAgent, "Gecko", 1) AND inStr(1, strUserAgent, "rv:0", 1) Then strBrowserUserType = "Mozilla" 'Else unknown or robot Else strBrowserUserType = "Unknown" End If 'Return function BrowserType = strBrowserUserType End Function '****************************************** '*** Get OS Type ***** '****************************************** Private Function OSType () Dim strUserAgent 'Holds info on the users browser and os Dim strOS 'Holds the users OS 'Get the users HTTP user agent (web browser) strUserAgent = Request.ServerVariables("HTTP_USER_AGENT") 'Get users OS 'Windows If inStr(1, strUserAgent, "Windows 2003", 1) Or inStr(1, strUserAgent, "NT 5.2", 1) Then strOS = "Windows 2003" ElseIf inStr(1, strUserAgent, "Windows 2008", 1) Then strOS = "Windows 2008" 'Windows Vista and Windows Server 2008 both identify as the same OS! ElseIf inStr(1, strUserAgent, "Windows Vista", 1) Or inStr(1, strUserAgent, "NT 6.0", 1) Then strOS = "Windows Vista/2008" ElseIf inStr(1, strUserAgent, "Windows XP", 1) Or inStr(1, strUserAgent, "NT 5.1", 1) Then strOS = "Windows XP" ElseIf inStr(1, strUserAgent, "NT 5.01", 1) Then strOS = "Windows 2000 SP1" ElseIf inStr(1, strUserAgent, "Windows 2000", 1) Or inStr(1, strUserAgent, "NT 5", 1) Then strOS = "Windows 2000" ElseIf inStr(1, strUserAgent, "Windows NT", 1) Or inStr(1, strUserAgent, "WinNT", 1) Then strOS = "Windows NT 4" ElseIf inStr(1, strUserAgent, "Windows 95", 1) Or inStr(1, strUserAgent, "Win95", 1) Then strOS = "Windows 95" ElseIf inStr(1, strUserAgent, "Windows ME", 1) Or inStr(1, strUserAgent, "Win 9x 4.90", 1) Then strOS = "Windows ME" ElseIf inStr(1, strUserAgent, "Windows 98", 1) Or inStr(1, strUserAgent, "Win98", 1) Then strOS = "Windows 98" ElseIf Instr(1, strUserAgent, "Windows CE", 1) Then strOS = "Windows CE" 'PalmOS ElseIf inStr(1, strUserAgent, "PalmOS", 1) Then strOS = "Palm OS" 'PalmPilot ElseIf inStr(1, strUserAgent, "Elaine", 1) Then strOS = "PalmPilot" 'Nokia ElseIf inStr(1, strUserAgent, "Nokia", 1) Then strOS = "Nokia" 'Ubuntu ElseIf inStr(1, strUserAgent, "Ubuntu", 1) Then strOS = "Ubuntu" 'Linux ElseIf inStr(1, strUserAgent, "Linux", 1) Then strOS = "Linux" 'Amiga ElseIf inStr(1, strUserAgent, "Amiga", 1) Then strOS = "Amiga" 'Solaris ElseIf inStr(1, strUserAgent, "Solaris", 1) Then strOS = "Solaris" 'SunOS ElseIf inStr(1, strUserAgent, "SunOS", 1) Then strOS = "Sun OS" 'BSD ElseIf inStr(1, strUserAgent, "BSD", 1) or inStr(1, strUserAgent, "FreeBSD", 1) Then strOS = "Free BSD" 'Unix ElseIf inStr(1, strUserAgent, "Unix", 1) OR inStr(1, strUserAgent, "X11", 1) Then strOS = "Unix" 'AOL webTV ElseIf inStr(1, strUserAgent, "AOLTV", 1) OR inStr(1, strUserAgent, "AOL_TV", 1) Then strOS = "AOL TV" ElseIf inStr(1, strUserAgent, "WebTV", 1) Then strOS = "Web TV" 'iPhone ElseIf inStr(1, strUserAgent, "iPhone", 1) Then strOS = "iPhone" 'iPod ElseIf inStr(1, strUserAgent, "iPod", 1) Then strOS = "iPod" 'Machintosh ElseIf inStr(1, strUserAgent, "Mac OS X", 1) Then strOS = "Mac OS X" ElseIf inStr(1, strUserAgent, "Mac_PowerPC", 1) or Instr(1, strUserAgent, "PPC", 1) Then strOS = "Mac PowerPC" ElseIf inStr(1, strUserAgent, "Mac", 1) or inStr(1, strUserAgent, "apple", 1) Then strOS = "Macintosh" 'OS/2 ElseIf inStr(1, strUserAgent, "OS/2", 1) Then strOS = "OS/2" 'Search Robot ElseIf inStr(1, strUserAgent, "Googlebot", 1) OR inStr(1, strUserAgent, "Mediapartners-Google", 1) OR inStr(1, strUserAgent, "ZyBorg", 1) OR inStr(1, strUserAgent, "slurp", 1) OR inStr(1, strUserAgent, "Scooter", 1) OR inStr(1, strUserAgent, "Robozilla", 1) OR inStr(1, strUserAgent, "Jeeves", 1) OR inStr(1, strUserAgent, "lycos", 1) OR inStr(1, strUserAgent, "ArchitextSpider", 1) OR inStr(1, strUserAgent, "Gulliver", 1) OR inStr(1, strUserAgent, "crawler@fast", 1) OR inStr(1, strUserAgent, "TurnitinBot", 1) OR inStr(1, strUserAgent, "internetseer", 1) OR inStr(1, strUserAgent, "nameprotect", 1) OR inStr(1, strUserAgent, "PhpDig", 1) OR inStr(1, strUserAgent, "StackRambler", 1) OR inStr(1, strUserAgent, "UbiCrawler", 1) OR inStr(1, strUserAgent, "Spider", 1) OR inStr(1, strUserAgent, "ia_archiver", 1) OR inStr(1, strUserAgent, "msnbot", 1) OR inStr(1, strUserAgent, "arianna.libero.it", 1) OR inStr(1, strUserAgent, "y2bot", 1) OR inStr(1, strUserAgent, "Twiceler", 1) Then strOS = "Search Robot" Else strOS = "Unknown" End If 'Return function OSType = strOS End Function '****************************************** '*** DB Topic/Post Count Update ***** '****************************************** Private Function updateForumStats(ByVal intForumID) Dim rsStats 'Database recordset Dim lngNumberOfTopics 'Holds the number of topics Dim lngNumberOfPosts 'Holds the number of posts Dim lngLastPostAuthorID 'Holds the last post author ID Dim dtmLastPostPostDate 'Holds the last post date Dim strDate 'Holds the date for SQL Server Dim lngLastTopicID 'Holds the last topic ID 'Intilaise variables lngNumberOfTopics = 0 lngNumberOfPosts = 0 lngLastPostAuthorID = 1 dtmLastPostPostDate = 0 lngLastTopicID = 0 'Intialise the ADO recordset object Set rsStats = Server.CreateObject("ADODB.Recordset") With rsStats 'Get the number of Topics 'Initalise the strSQL variable with an SQL statement to query the database to count the number of topics in the forums strSQL = "SELECT Count(" & strDbTable & "Topic.Forum_ID) AS Topic_Count " & _ "From " & strDbTable & "Topic " & strDBNoLock & " " & _ "WHERE " & strDbTable & "Topic.Forum_ID = " & intForumID & " " & _ "AND " & strDbTable & "Topic.Hide = " & strDBFalse & ";" 'Query the database .Open strSQL, adoCon 'Read in the number of Topics If NOT .EOF Then lngNumberOfTopics = CLng(.Fields("Topic_Count")) 'Close the rs .Close 'Get the number of Posts 'Initalise the strSQL variable with an SQL statement to query the database to count the number of posts in the forums strSQL = "SELECT Count(" & strDbTable & "Thread.Thread_ID) AS Thread_Count " & _ "FROM " & strDbTable & "Topic" & strDBNoLock & ", " & strDbTable & "Thread" & strDBNoLock & " " & _ "WHERE " & strDbTable & "Topic.Topic_ID = " & strDbTable & "Thread.Topic_ID " & _ "AND " & strDbTable & "Topic.Forum_ID = " & intForumID & " " & _ "AND " & strDbTable & "Thread.Hide = " & strDBFalse & ";" 'Query the database .Open strSQL, adoCon 'Get the thread count If NOT .EOF Then lngNumberOfPosts = CLng(.Fields("Thread_Count")) 'Reset server variables .Close 'Get the last post author ID and post date strSQL = "SELECT" & strDBTop1 & " " & strDbTable & "Topic.Topic_ID, " & strDbTable & "Thread.Author_ID, " & strDbTable & "Thread.Message_date " & _ "FROM " & strDbTable & "Topic" & strDBNoLock & ", " & strDbTable & "Thread" & strDBNoLock & " " & _ "WHERE " & strDbTable & "Topic.Topic_ID = " & strDbTable & "Thread.Topic_ID " & _ "AND " & strDbTable & "Topic.Forum_ID = " & intForumID & " " & _ "AND " & strDbTable & "Topic.Hide = " & strDBFalse & " " & _ "AND " & strDbTable & "Thread.Hide = " & strDBFalse & " " & _ "ORDER BY " & strDbTable & "Thread.Message_date DESC" & strDBLimit1 & ";" 'Query the database .Open strSQL, adoCon 'Get the thread count If NOT .EOF Then lngLastTopicID = CLng(.Fields("Topic_ID")) lngLastPostAuthorID = CLng(.Fields("Author_ID")) dtmLastPostPostDate = CDate(.Fields("Message_date")) End If 'Reset server variables .Close 'Get the date of last post in correct format strDate = internationalDateTime(dtmLastPostPostDate) 'Remove '-' from SQL Server date for backward compatibility with SQL 2000 If strDatabaseType = "SQLServer" Then strDate = Replace(strDate, "-", "", 1, -1, 1) 'Place the date in SQL safe # or ' If strDatabaseType = "Access" Then strDate = "#" & strDate & "#" Else strDate = "'" & strDate & "'" End If 'Update the database with the new forum statistics strSQL = "UPDATE " & strDbTable & "Forum" & strRowLock & " " & _ "SET " & strDbTable & "Forum.No_of_topics = " & lngNumberOfTopics & ", " & _ strDbTable & "Forum.No_of_posts = " & lngNumberOfPosts & ", " & _ strDbTable & "Forum.Last_post_author_ID = " & lngLastPostAuthorID & ", " & _ strDbTable & "Forum.Last_post_date = " & strDate & ", " & _ strDbTable & "Forum.Last_topic_ID = " & lngLastTopicID & " " & _ "WHERE " & strDbTable & "Forum.Forum_ID = " & intForumID & ";" 'Write the updated date of last post to the database adoCon.Execute(strSQL) End With 'Clean up Set rsStats = Nothing End Function '******************************************** '*** DB Topic Reply Details Update ***** '******************************************** Private Function updateTopicStats(ByVal lngTopicID) Dim intReplyCount Dim lngStartPostID Dim lngLastPostID 'Get the start and last post ID's from the database strSQL = "SELECT " & strDbTable & "Thread.Thread_ID " & _ "FROM " & strDbTable & "Thread" & strDBNoLock & " " & _ "WHERE " & strDbTable & "Thread.Topic_ID = " & lngTopicID & " " & _ "AND " & strDbTable & "Thread.Hide = " & strDBFalse & " " & _ "ORDER BY " & strDbTable & "Thread.Thread_ID ASC;" 'Set the cursor type property of the record set to Dynamic so we navigate through the recordset rsCommon.CursorType = 2 'Set set the lock type of the recordset to adLockReadOnly rsCommon.LockType = 1 'Query the database rsCommon.Open strSQL, adoCon 'If there are posts left in the database for this topic get some details for them If NOT rsCommon.EOF Then 'Get the post ID of the first post lngStartPostID = CLng(rsCommon("Thread_ID")) 'Move to the last message in the topic to get the details of the last post rsCommon.MoveLast 'Get the post ID of the last post lngLastPostID = CLng(rsCommon("Thread_ID")) End If 'Close the recordset rsCommon.Close 'Count the number of replies strSQL = "SELECT Count(" & strDbTable & "Thread.Topic_ID) AS ReplyCount " & _ "From " & strDbTable & "Thread" & strDBNoLock & " " & _ "WHERE " & strDbTable & "Thread.Hide = " & strDBFalse & " " & _ "AND " & strDbTable & "Thread.Topic_ID = " & lngTopicID & ";" 'Set the cursor type to static rsCommon.CursorType = 3 'Set set the lock type of the recordset to adLockReadOnly rsCommon.LockType = 1 'Query the database rsCommon.Open strSQL, adoCon 'Read in the thread count If NOT rsCommon.EOF Then If CLng(rsCommon("ReplyCount")) > 0 Then intReplyCount = CLng(rsCommon("ReplyCount")) - 1 Else intReplyCount = 0 End If 'Close rs rsCommon.Close 'Initalise the SQL string with an SQL update command to update the no. of replies and last author strSQL = "UPDATE " & strDbTable & "Topic " & strRowLock & " " & _ "SET " & strDbTable & "Topic.Start_Thread_ID = " & lngStartPostID & ", " & _ strDbTable & "Topic.Last_Thread_ID = " & lngLastPostID & ", " & _ strDbTable & "Topic.No_of_replies = " & intReplyCount & " " & _ "WHERE " & strDbTable & "Topic.Topic_ID = " & lngTopicID & ";" 'Set error trapping On Error Resume Next 'Write the updated date of last post to the database If lngStartPostID <> "" Then adoCon.Execute(strSQL) 'If an error has occurred write an error to the page If Err.Number <> 0 Then Call errorMsg("An error has occurred while writing to the database.", "updateTopicStats()_update_reply_count", "functions_common.asp") 'Disable error trapping On Error goto 0 End Function '****************************************** '*** Forum Permissions ***** '****************************************** Public Function forumPermissions(ByVal intForumID, ByVal intGroupID) 'Declare variables Dim rsPermissions 'Holds the permissions recordset Dim intCurrentPerRecord 'Holds the current record position Dim intPermssionRec 'Holds the permission record to check 'Initilise variables blnRead = False blnPost = False blnReply = False blnEdit = False blnDelete = False blnPriority = False blnPollCreate = False blnVote = False blnModerator = False blnCheckFirst = False blnEvents = False 'If the permissions array is not yet filled run the following (should only run once per page to increase performance) All forums read into the array If IsArray(saryPermissions) = false Then 'Intialise the ADO recordset object Set rsPermissions = Server.CreateObject("ADODB.Recordset") 'Get the users group permissions from the db if there are any 'Initalise the strSQL variable with an SQL statement to query the database strSQL = "SELECT " & strDbTable & "Permissions.Group_ID, " & strDbTable & "Permissions.Author_ID, " & strDbTable & "Permissions.Forum_ID, " & strDbTable & "Permissions.View_Forum, " & strDbTable & "Permissions.Post, " & strDbTable & "Permissions.Reply_posts, " & strDbTable & "Permissions.Edit_posts, " & strDbTable & "Permissions.Delete_posts, " & strDbTable & "Permissions.Priority_posts, " & strDbTable & "Permissions.Poll_create, " & strDbTable & "Permissions.Vote, " & strDbTable & "Permissions.Moderate, " & strDbTable & "Permissions.Display_post, " & strDbTable & "Permissions.Calendar_event " & _ "FROM " & strDbTable & "Permissions" & strDBNoLock & " " & _ "WHERE " & strDbTable & "Permissions.Group_ID = " & intGroupID & " OR " & strDbTable & "Permissions.Author_ID = " & lngLoggedInUserID & " " & _ "ORDER BY " & strDbTable & "Permissions.Author_ID DESC;" 'Query the database rsPermissions.Open strSQL, adoCon 'Raed the recordset into an array for better performance If NOT rsPermissions.EOF Then saryPermissions = rsPermissions.GetRows() 'Clean up rsPermissions.Close Set rsPermissions = Nothing End If 'Read in the permissions for the group the member is part of if there are any If IsArray(saryPermissions) Then 'Intilise variable intPermssionRec = -1 'Loop through the records to see if there is one for this forum For intCurrentPerRecord = 0 to UBound(saryPermissions,2) 'See if this record is for this forum If CInt(saryPermissions(2,intCurrentPerRecord)) = intForumID Then 'Get the record number and exit loop intPermssionRec = intCurrentPerRecord Exit For End If Next 'If a record is found read in the details If intPermssionRec => 0 Then blnRead = CBool(saryPermissions(3,intPermssionRec)) blnPost = CBool(saryPermissions(4,intPermssionRec)) blnReply = CBool(saryPermissions(5,intPermssionRec)) blnEdit = CBool(saryPermissions(6,intPermssionRec)) blnDelete = CBool(saryPermissions(7,intPermssionRec)) blnPriority = CBool(saryPermissions(8,intPermssionRec)) blnPollCreate = CBool(saryPermissions(9,intPermssionRec)) blnVote = CBool(saryPermissions(10,intPermssionRec)) blnModerator = CBool(saryPermissions(11,intPermssionRec)) blnCheckFirst = CBool(saryPermissions(12,intPermssionRec)) blnEvents = CBool(saryPermissions(13,intPermssionRec)) End If End If End Function '****************************************** '*** Is Moderator ***** '****************************************** 'Although the above permissions function can work out if the user is a moderator sometimes we only need to know if the user is a moderator or not Private Function isModerator(ByVal intForumID, ByVal intGroupID) 'Declare variables Dim rsPermissions 'Holds the permissions recordset Dim blnModerator 'Set to true if the user is a moderator 'Initilise vairiables blnModerator = False 'Intialise the ADO recordset object Set rsPermissions = Server.CreateObject("ADODB.Recordset") 'Get the users group permissions from the db if there are any 'Initalise the strSQL variable with an SQL statement to query the database to count the number of topics in the forums strSQL = "SELECT " & strDbTable & "Permissions.Moderate " & _ "FROM " & strDbTable & "Permissions" & strDBNoLock & " " & _ "WHERE (" & strDbTable & "Permissions.Group_ID = " & intGroupID & " OR " & strDbTable & "Permissions.Author_ID = " & lngLoggedInUserID & ") AND " & strDbTable & "Permissions.Forum_ID = " & intForumID & " " & _ "ORDER BY " & strDbTable & "Permissions.Author_ID DESC;" 'Query the database rsPermissions.Open strSQL, adoCon 'If there is a result returned by the db set it to the blnModerator variable If NOT rsPermissions.EOF Then blnModerator = CBool(rsPermissions("Moderate")) 'Clean up rsPermissions.Close Set rsPermissions = Nothing 'Return the function isModerator = blnModerator End Function '****************************************** '**** Banned IP's ***** '****************************************** Private Function bannedIP() 'Declare variables Dim rsIPAddr Dim strCheckIPAddress Dim strUserIPAddress Dim blnIPMatched Dim strTmpUserIPAddress Dim saryDbIPRange Dim intIPLoop 'Intilise variable blnIPMatched = False intIPLoop = 0 'Exit if in demo mode If blnDemoMode Then Exit Function 'Get the users IP strUserIPAddress = getIP() 'Intialise the ADO recordset object Set rsIPAddr = Server.CreateObject("ADODB.Recordset") 'Get any banned IP address from the database 'Initalise the strSQL variable with an SQL statement to query the database to count the number of topics in the forums strSQL = "SELECT " & strDbTable & "BanList.IP " & _ "FROM " & strDbTable & "BanList" & strDBNoLock & " " & _ "WHERE " & strDbTable & "BanList.IP Is Not Null;" 'Query the database rsIPAddr.Open strSQL, adoCon 'If results are returned check 'em out If NOT rsIPAddr.EOF Then 'Place the recordset into array saryDbIPRange = rsIPAddr.GetRows() 'Loop round to show all the categories and forums Do While intIPLoop =< Ubound(saryDbIPRange, 2) 'Get the IP address to check from the recordset strCheckIPAddress = saryDbIPRange(0, intIPLoop) 'See if we need to check the IP range or just one IP address 'If the last character is a * then this is a wildcard range to be checked If Right(strCheckIPAddress, 1) = "*" Then 'Remove the wildcard charcter form the IP strCheckIPAddress = Replace(strCheckIPAddress, "*", "", 1, -1, 1) 'Trim the users IP to the same length as the IP range to check strTmpUserIPAddress = Mid(strUserIPAddress, 1, Len(strCheckIPAddress)) 'See if whats left of the IP matches If strCheckIPAddress = strTmpUserIPAddress Then blnIPMatched = True 'Else check the IP address matches Else 'Else check to see if the IP address match If strCheckIPAddress = strUserIPAddress Then blnIPMatched = True End If 'Move to the next record intIPLoop = intIPLoop + 1 Loop End If 'Clean up rsIPAddr.Close Set rsIPAddr = Nothing 'Return the function bannedIP = blnIPMatched End Function '****************************************** '*** Check submission ID *** '****************************************** Private Function checkFormID(strFormID) 'Check to see if the form ID's match if they don't send the user away If strFormID <> getSessionItem("formID") Then 'Clean up before redirecting Call saveSessionItem("formID", "") Call closeDatabase() 'Redirect to insufficient permissions page Response.Redirect("insufficient_permission.asp?M=sID" & strQsSID3) End If End Function '****************************************** '*** Get users IP address *** '****************************************** Private Function getIP() Dim strIPAddr 'If they are not going through a proxy get the IP address If Request.ServerVariables("HTTP_X_FORWARDED_FOR") = "" OR InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), "unknown") > 0 Then strIPAddr = Request.ServerVariables("REMOTE_ADDR") 'If they are going through multiple proxy servers only get the fisrt IP address in the list (,) ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",") > 0 Then strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",")-1) 'If they are going through multiple proxy servers only get the fisrt IP address in the list (;) ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";") > 0 Then strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";")-1) 'Get the browsers IP address not the proxy servers IP Else strIPAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR") End If 'Remove all tags in IP string strIPAddr = removeAllTags(strIPAddr) 'Place the IP address back into the returning function getIP = Trim(Mid(strIPAddr, 1, 30)) End Function '************************************************** '*** Web Wiz Forums About for debugging *** '************************************************** '***** START WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ****** Private Sub about() 'Reset server objects Call closeDatabase() Dim strFreeEdition Dim strBranding Dim strPaging If blnACode Then strFreeEdition = "Yes" Else strFreeEdition = "No" If blnLCode Then strBranding = "Yes" Else strBranding = "No" If blnSqlSvrAdvPaging Then strPaging = "Yes" Else strPaging = "No" Response.Write("" & _ vbCrLf & "
" & _ vbCrLf & "*********************************************************" & _ vbCrLf & _ vbCrLf & "Software: Web Wiz Forums(TM)" & _ vbCrLf & "Version: " & strVersion & _ vbCrLf & _ vbCrLf & "Installation ID: " & strInstallID & _ vbCrLf & "Free Edition: " & strFreeEdition & _ vbCrLf & "Web Wiz Branding: " & strBranding & _ vbCrLf & _ vbCrLf & "Database: " & strDatabaseType & _ vbCrLf & "Database Paging: " & strPaging & _ vbCrLf & _ vbCrLf & "Author: Web Wiz." & _ vbCrLf & "Address: Unit 10E, Dawkins Road Ind Est, Poole, Dorset, UK" & _ vbCrLf & "Info: http://www.webwizforums.com" & _ vbCrLf & "Copyright: (C)2001-2008 Web Wiz. All rights reserved" & _ vbCrLf & _ vbCrLf & "This Software is protected by copyright and other intellectual property laws and treaties." & _ vbCrLf & _ vbCrLf & "*********************************************************" & _ vbCrLf & "") Response.Flush Response.End End Sub '***** END WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ****** '****************************************** '*** Count Unread Private Msg's **** '****************************************** 'Function to count and update the number of private messages Private Function updateUnreadPM(ByVal lngMemID) Dim intRecievedPMs 'Initlise the sql statement strSQL = "SELECT Count(" & strDbTable & "PMMessage.PM_ID) AS CountOfPM FROM " & strDbTable & "PMMessage " & _ "WHERE " & strDbTable & "PMMessage.Read_Post = " & strDBFalse & " " & _ "AND " & strDbTable & "PMMessage.Author_ID = " & lngMemID & ";" 'Query the database rsCommon.Open strSQL, adoCon 'Get the number of new pm's this user has intRecievedPMs = CInt(rsCommon("CountOfPM")) 'Update the number of unread PM's the user has intNoOfPms = CInt(rsCommon("CountOfPM")) 'Close the recordset rsCommon.Close 'Update database strSQL = "UPDATE " & strDbTable & "Author " & strRowLock & " " & _ "SET " & strDbTable & "Author.No_of_PM = " & intRecievedPMs & " " & _ "WHERE " & strDbTable & "Author.Author_ID=" & lngMemID & ";" 'Write the updated no. of PM's to the database adoCon.Execute(strSQL) End Function '****************************************** '*** Unsafe character Strip **** '****************************************** 'Function to strip non alphanumeric characters email addresses Private Function characterStrip(ByVal strTextInput) 'Dimension variable Dim intLoopCounter 'Holds the loop counter 'Loop through the ASCII characters For intLoopCounter = 0 to 31 strTextInput = Replace(strTextInput, CHR(intLoopCounter), "", 1, -1, 0) Next 'Loop through the ASCII characters For intLoopCounter = 33 to 37 strTextInput = Replace(strTextInput, CHR(intLoopCounter), "", 1, -1, 0) Next 'Loop through the ASCII characters For intLoopCounter = 39 to 44 strTextInput = Replace(strTextInput, CHR(intLoopCounter), "", 1, -1, 0) Next 'Loop through the ASCII characters For intLoopCounter = 58 to 65 strTextInput = Replace(strTextInput, CHR(intLoopCounter), "", 1, -1, 0) Next 'Loop through the ASCII characters numeric characters For intLoopCounter = 91 to 94 strTextInput = Replace(strTextInput, CHR(intLoopCounter), "", 1, -1, 0) Next 'Loop through the extended ASCII characters For intLoopCounter = 123 to 125 strTextInput = Replace(strTextInput, CHR(intLoopCounter), "", 1, -1, 0) Next 'Loop through the extended ASCII characters For intLoopCounter = 127 to 255 strTextInput = Replace(strTextInput, CHR(intLoopCounter), "", 1, -1, 0) Next 'Strip individul ASCII characters left out from above strTextInput = Replace(strTextInput, CHR(59), "", 1, -1, 0) strTextInput = Replace(strTextInput, CHR(60), "", 1, -1, 0) strTextInput = Replace(strTextInput, CHR(62), "", 1, -1, 0) strTextInput = Replace(strTextInput, CHR(96), "", 1, -1, 0) 'Return the string characterStrip = strTextInput End Function '********************************************** '*** Format ISO International Date/Time **** '********************************************** 'Function to format the present date and time into international formats to prevent systems crashes on foriegn servers Private Function internationalDateTime(dtmDate) Dim strYear Dim strMonth Dim strDay Dim strHour Dim strMinute Dim strSecound strYear = Year(dtmDate) strMonth = Month(dtmDate) strDay = Day(dtmDate) strHour = Hour(dtmDate) strMinute = Minute(dtmDate) strSecound = Second(dtmDate) 'Place 0 infront of minutes under 10 If strMonth < 10 then strMonth = "0" & strMonth If strDay < 10 then strDay = "0" & strDay If strHour < 10 then strHour = "0" & strHour If strMinute < 10 then strMinute = "0" & strMinute If strSecound < 10 then strSecound = "0" & strSecound 'This function returns the ISO internation date and time formats:- yyyy-mm-dd hh:mm:ss 'Dashes prevent systems that use periods etc. from crashing internationalDateTime = strYear & "-" & strMonth & "-" & strDay & " " & strHour & ":" & strMinute& ":" & strSecound End Function '******************************************* '*** Error Message **** '******************************************* 'Function to to dsiplay server error message Private Function errorMsg(strErrorText, strErrCode, strFileName) Response.Write("