'GLOBAL UNLOCK OF ALL CHILKAT OBJECTS If NOT IsObject( oChilkatUnlockGlobal ) Then Set oChilkatUnlockGlobal = Server.CreateObject("Chilkat_9_5_0.Global") bSuccess = oChilkatUnlockGlobal.UnlockBundle("WBMRKC.CB1042021_qGkqkA756rn9") End If Randomize Function Authen() Authen = Authenticated() End Function Function Authenticated() Authenticated = CBool( Session("bAuthen") ) End Function Private Function Login( ByVal sEmail, ByVal sPassword ) If ( AdminSuper AND sPassword = True ) Then 'Address SuperAdmin Swap to any Specific User If Session("bAdminSuperUser") <> True Then Session("iAdminSuperUser") = iOwner End If Session("bAdminSuperUser") = True sPhone = "NOT Phone" 'Required to avoid validating an empty field Else Session("bAdminSuperUser") = False Session("iAdminSuperUser") = 0 iPhone = Numeric( sEmail ) If iPhone > 2002000000 Then sPhone = Phone( iPhone ) Else sPhone = "NOT Phone" 'Required to avoid validating an empty field End If End If Login = False sEmail = Clean( sEmail ) sKeyAccount = UCase( Left( AlphaNumeric( sEmail & Now ), 15 ) ) sSQL = "SELECT TOP 1 tblAccounts.* FROM tblAccounts WHERE bLive > 0 AND bDeleted = 0 AND ( '@' + sUserID = '" & sEmail & "' OR sEmail = '" & LCase( sEmail ) & "' OR sPhone = '" & sPhone & "' OR sKey = '" & sEmail & "')" Set rsLogin = CreateObject("ADODB.Recordset") rsLogin.CursorLocation = adUseClient rsLogin.Open sSQL, Connection, adOpenReadOnly, adLockReadOnly, adCmdText If rsLogin.EOF Then Login = "Passport | Account does not exist." Else If Session("bAdminSuperUser") <> True Then rsLogin.Filter = "sPassword = '" & Clean( sPassword ) & "'" End If If rsLogin.EOF Then Login = "Password is incorrect." Else Session("bAuthen") = True Session("iTypeAccount") = rsLogin("iTypeAccount") Session("iSubscriptionType") = rsLogin("iSubscriptionType") Session("sKey") = rsLogin("sKey") Session("sKeyAccount") = rsLogin("sKey") Session("sUserID") = rsLogin("sUserID") Session("sKeyPersonasAdministrative") = rsLogin("sKeyPersonasAdministrative") Session("bAdmin") = CBool( rsLogin("bAdmin") ) Session("bSuper") = CBool( rsLogin("bSuper") ) OR Session("bAdminSuperUser") Session("iSavvy") = rsLogin("iSavvy") Session("bAdminSavvy") = CBool( ( Session("bAdmin") AND Session("iSavvy") > 3 ) OR Session("bSuper") ) Session("iOwner") = rsLogin("ID") Session("sFacebookID") = rsLogin("sFacebookID") Session("sName") = rsLogin("sName") aNameFull = Split( Session("sName") & "", " ") Session("sNameFirst") = aNameFull( 0 ) Session("sEmail") = rsLogin("sEmail") Session("sPhone") = rsLogin("sPhone") Session("sPostal") = rsLogin("sPostal") Session("sAddress1") = rsLogin("sAddress1") Session("sAddress2") = rsLogin("sAddress2") Session("sCity") = rsLogin("sCity") Session("bMemberOPA") = rsLogin("bMemberOPA") Login = True If Session("bAdminSuperUser") <> True Then Call LoginLog() End If If Session("sURLRedirectAfterDetourComplete") = Empty Then Set oJSON = Server.CreateObject("Chilkat_9_5_0.JsonObject") bSuccess = oJSON.Load( rsLogin("jsonPreferences") ) If bSuccess Then Session("sURLAfterSignIn") = oJSON.StringOf("sURLAfterSignIn") End If Destroy oJSON Else Session("sURLAfterSignIn") = Session("sURLRedirectAfterDetourComplete") End If End If End If Destroy( rsLogin ) If AppVar("bSuspended") AND NOT AdminSuper Then Call Logout() Redirect("/") Quit End If End Function Private Function LoginLog() sSQL = "SELECT TOP 1 tblAccountsLog.* FROM tblAccountsLog WHERE tblAccountsLog.iOwner = " & iOwner & " AND tblAccountsLog.iSessionID = " & Numeric( Request.Cookies("Session.SessionID") ) Set rsLog = CreateObject("ADODB.Recordset") rsLog.CursorLocation = adUseClient rsLog.Open sSQL, Connection, adOpenStatic, adLockOptimistic, adCmdText If rsLog.EOF Then rsLog.AddNew rsLog("iSessionID") = Numeric( Session.SessionID ) End If rsLog("sIPAddress") = ServerVariable("REMOTE_ADDR") rsLog("iOwner") = iOwner rsLog("bAuthen") = 1 rsLog("sKeyPersona") = Session("sKeyPersona") rsLog("idPersona") = Session("idPersona") rsLog("dSessionEnd") = Now rsLog.Update Destroy( rsLog ) End Function Private Function Logout() Session("bAuthen") = 0 Session("bAdmin") = 0 Session("bSuper") = 0 Session("iSavvy") = 1 Session("iOwner") = 0 Session("iTypeAccount") = 0 Session("iLevel") = 0 Session("sKeyAccount") = Empty Session("sEmail") = Empty Session("sName") = Empty Session("sNameFirst") = Empty Session("bAdminSuperUser") = False Session("iAdminSuperUser") = 0 Call LogoutLog() End Function Private Function LogoutLog() 'This needs to be added to the Session.End event in the Global.asa sSQL = "SELECT TOP 1 tblAccountsLog.* FROM tblAccountsLog WHERE tblAccountsLog.iOwner = " & iOwner & " AND tblAccountsLog.iSessionID = " & Numeric( Request.Cookies("Session.SessionID") ) Set rsLog = CreateObject("ADODB.Recordset") rsLog.CursorLocation = adUseClient rsLog.Open sSQL, Connection, adOpenStatic, adLockOptimistic, adCmdText If NOT rsLog.EOF Then rsLog("dSessionEnd") = Now rsLog.Update End If Destroy( rsLog ) End Function Function LogContact( iTypeContact, sKeyAccountRecipient, sKeyAccountContact, sMessage, sIPData, sURLSentFrom ) LogContact = False sSQL = "SELECT tblContactRelations.* FROM tblContactRelations WHERE tblContactRelations.ID = -1" Set rsCMS = CreateObject("ADODB.Recordset") rsCMS.CursorLocation = adUseClient rsCMS.Open sSQL, Connection, adOpenStatic, adLockOptimistic, adCmdText If rsCMS.EOF Then rsCMS.AddNew rsCMS("sKey") = Key( 15 ) rsCMS("iTypeContact") = iTypeContact 'Sale Successful = 1, Lead/Message = 5 rsCMS("sKeyPersona") = sKeyAccountRecipient 'Website Persona or Recipient Person rsCMS("sKeyAccountContact") = AlphaNumeric( sKeyAccountContact ) 'Meaning the Sender rsCMS("sMessage") = Clean( sMessage ) rsCMS("sIPData") = sIPData 'JSONLocationGet( ServerVariable("REMOTE_ADDR") ) rsCMS("sURLSentFrom") = sURLSentFrom rsCMS.Update LogContact = True End If Destroy( rsCMS ) End Function Private Function AsideAd( sLayout ) If AppVar("bAdPublisher") Then If Session("sAreasOfLaw") = Empty Then Session("sAreasOfLaw") = " TERMINATOR,, " End If sTemp = " " & Replace( Replace( Replace( Session("sAreasOfLaw") & "", "TERMINATOR", ""), " ", ""), ",,,", ",") sTemp = Trim( Left( sTemp, Len( sTemp ) - 1 ) ) aTemp = Split( sTemp, ",") sTemp = Empty For iLoop = 0 To UBound( aTemp ) sTemp = sTemp & " CHARINDEX(' " & aTemp( iLoop ) & ",', tbl@Ads.sAreasOfLaw) > 0" If iLoop < UBound( aTemp ) Then sTemp = sTemp & " OR " End If Next 'THERE IS SOME FUCKING PROBLEM AMONG THE NEXT 5 LINES IN SOME NEW PERSONAS' sTemp = " ( " & sTemp & " ) " sSQL = "SELECT tbl@Ads.* FROM tbl@Ads WHERE tbl@Ads.sKeyBusiness = '" & Session("sKeyBusiness") & "' AND ( " & sTemp & " OR tbl@Ads.bGeneric <> 0 ) AND sCodeLanguage = '" & Session("sCodeLanguage") & "' AND tbl@Ads.bLive <> 0 AND tbl@Ads.bDeleted = 0 AND CONVERT( datetime, '" & Now & "' ) < tbl@Ads.dDateEnd ORDER BY NEWID()" Set rsAds = CreateObject("ADODB.Recordset") rsAds.CursorLocation = adUseClient rsAds.Open sSQL, Connection, adOpenStatic, adLockOptimistic, adCmdText If rsAds.EOF Then sHeading = "Advertise Here" sDescription = "Your advertisement could be here and viewed thousands of times per month." sURLPageLanding = "https://marketing.legal/contact" sThemeColor = "primary" Else rsAds.Filter = "bGeneric = 0" If rsAds.EOF Then rsAds.Filter = "" End If sKeyAd = rsAds("sKey") sHeading = rsAds("sHeading") sDescription = rsAds("sDescription") sURLPageLanding = rsAds("sURLPageLanding") sFileImage1 = rsAds("sFileImage1") & "" sThemeColor = rsAds("sThemeColor") & "" bUseScreenShot = rsAds("bUseLandingPageScreenShot") If IsBot() = False Then On Error Resume Next rsAds("iImpressions") = rsAds("iImpressions") + 1 rsAds.Update On Error Goto 0 End If End If Destroy( rsAds ) If InStr( sURLPageLanding, Session("sDomain") ) = 0 Then sTarget = "_blank" End If If Len( AlphaNumeric( sFileImage1 ) ) < 20 AND bUseScreenShot > 0 Then sStrUrlImage = "url=" & sURLPageLanding & "&width=1200&height=630&quality=100" sFileImage1 = "//api.urlbox.io/v1/F4UVscE5zgqc3BVd/" & UrlBoxEncode( sStrUrlImage ) & "/jpg?" & sStrUrlImage End If sURL = "/admin/advertisement-log.asp?sKeyAd=" & sKeyAd If sLayout = "vertical" Then sAd = "" sAd = sAd & "" sAd = sAd & "" End If If sLayout = "horizontal" Then sAd = "" sAd = sAd & "" sAd = sAd & "" End If End If AsideAd = sAd End Function Private Function BlogInfo( sHTML, sKeyPage ) sTemp = Empty If InStr( sHTML, "#TOKEN-sBlogInfo#") > 0 Then sSQL = "SELECT tblPageHTML.* FROM tblPageHTML WHERE sKey = '" & AlphaNumeric( sKeyPage ) & "'" Set rsBlog = CreateObject("ADODB.Recordset") rsBlog.CursorLocation = adUseClient rsBlog.Open sSQL, Connection, adOpenReadOnly, adLockReadOnly, adCmdText If rsBlog.EOF = False Then sTemp = "
" If Len( Alpha( rsBlog("sNameAuthor") ) ) > 3 Then sTemp = sTemp & "Author: " & rsBlog("sNameAuthor") & "
" End If sTemp = sTemp & "Date Posted: " & DateString( rsBlog("dAuthored"), False ) sTemp = sTemp & "

" End If Destroy( rsBlog ) End If BlogInfo = Replace( sHTML, "#TOKEN-sBlogInfo#", sTemp ) End Function Private Function SendTextMessage( iPhoneNumber, sMessageToSend ) iPhoneNumber = Numeric( Phone( iPhoneNumber ) ) Set oRest = Server.CreateObject("Chilkat_9_5_0.Rest") 'Establish connection to the AWS REST server, such as https://sns.us-west-2.amazonaws.com bTls = 1 iPort = 443 bAutoReconnect = 1 oSuccess = oRest.Connect("sns.us-west-2.amazonaws.com",iPort,bTls,bAutoReconnect) Set oAuthAws = Server.CreateObject("Chilkat_9_5_0.AuthAws") oAuthAws.AccessKey = "AKIAIS2G3MGFGFUDIM7A" oAuthAws.SecretKey = "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" 'The region should match our connection URL above. oAuthAws.Region = "us-west-2" oAuthAws.ServiceName = "sns" oSuccess = oRest.SetAuthAws( oAuthAws ) oSuccess = oRest.AddQueryParam("Action", "Publish") oSuccess = oRest.AddQueryParam("PhoneNumber", "+1" & iPhoneNumber ) oSuccess = oRest.AddQueryParam("Message", sMessageToSend ) oXML = oRest.FullRequestNoBody("GET","/") SendTextMessage = ( oRest.ResponseStatusCode = 200 ) Destroy( oSuccess ) Destroy( oAuthAws ) Destroy( oRest ) End Function Private Function TranslateLanguage( sStringToTranslate, sCodeLanguage ) sStringToTranslate = Replace( sStringToTranslate, "#TOKEN-", "#ZXCVB" ) 'STOP TOKEN FROM BEING TRANSLATED sStringToTranslate = Replace( sStringToTranslate, "#col-aside-", "#MNBVCX" ) sStringToTranslate = Replace( sStringToTranslate, "#aside-call-to-", "#QAZXSW" ) aTemp = Split( sStringToTranslate & " ", Chr( 60 ) & "!--TRANSLATION-->") 'Use Chr(60) instead of < due to some odd quirk sTranslated = "" For iLoop = 0 To UBound( aTemp ) sTranslated = sTranslated & TranslatedByAWS( aTemp( iLoop ), sCodeLanguage ) Next sTranslated = Replace( sTranslated, "#QAZXSW", "#aside-call-to-" ) sTranslated = Replace( sTranslated, "#aside-call-to-action #", "#aside-call-to-action#") sTranslated = Replace( sTranslated, "#MNBVCX", "#col-aside-" ) sTranslated = Replace( Replace( Replace( sTranslated, "#col-aside-children #", "#col-aside-children#"), "#col-aside-siblings #", "#col-aside-siblings#"), "#col-aside-cousins #", "#col-aside-cousins#") sTranslated = Replace( sTranslated, "#ZXCVB", "#TOKEN-" ) TranslateLanguage = FixBrokenTokens( sTranslated ) End Function Private Function TranslatedByAWS( sStringToTranslate, sCodeLanguage ) iCharacterLength = Len( sStringToTranslate ) 'BUILD SOMETHING TO LOG THIS AND MAKE IT ULTIMATELY BILLABLE TO THE CLIENT UPON A SUCCESSFUL TRANSLATION Set oRest = Server.CreateObject("Chilkat_9_5_0.Rest") Set oAuthAWS = Server.CreateObject("Chilkat_9_5_0.AuthAws") oAuthAWS.AccessKey = "AKIAIS2G3MGFGFUDIM7A" oAuthAWS.SecretKey = "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" oAuthAWS.Region = "us-west-2" oAuthAWS.ServiceName = "translate" bSuccess = oRest.SetAuthAws( oAuthAWS ) 'URL: https://translate.us-west-2.amazonaws.com/ OR ANOTHER SERVER bTls = 1 iPort = 443 bAutoReconnect = 1 bSuccess = oRest.Connect("translate.us-west-2.amazonaws.com", iPort, bTls, bAutoReconnect ) If ( bSuccess <> 1 ) Then bError = True End If 'Translate sStringToTranslate from English to sCodeLanguage Set oJSON = Server.CreateObject("Chilkat_9_5_0.JsonObject") bSuccess = oJSON.UpdateString("SourceLanguageCode", "en" ) bSuccess = oJSON.UpdateString("TargetLanguageCode", sCodeLanguage ) bSuccess = oJSON.UpdateString("Text", sStringToTranslate ) bSuccess = oRest.AddHeader("Content-Type","application/x-amz-json-1.1") bSuccess = oRest.AddHeader("X-Amz-Target","AWSShineFrontendService_20170701.TranslateText") Set sbRequestBody = Server.CreateObject("Chilkat_9_5_0.StringBuilder") bSuccess = oJSON.EmitSb( sbRequestBody ) Set sbResponseBody = Server.CreateObject("Chilkat_9_5_0.StringBuilder") bSuccess = oRest.FullRequestSb("POST","/", sbRequestBody, sbResponseBody ) If ( bSuccess <> 1 ) Then bError = True End If respStatusCode = oRest.ResponseStatusCode Set oJSONResponse = Server.CreateObject("Chilkat_9_5_0.JsonObject") bSuccess = oJSONResponse.LoadSb( sbResponseBody ) oJSONResponse.EmitCompact = 0 If bError Then TranslatedByAWS = sStringToTranslate 'Return the original data if there was a problem trying to translate. Else TranslatedByAWS = oJSONResponse.StringOf("TranslatedText") 'Return the translated data End If Destroy( oJSONResponse ) Destroy( sbResponseBody ) Destroy( sbRequestBody ) Destroy( oJSON ) Destroy( oAuthAWS ) Destroy( oRest ) End Function Private Function UrlBoxEncode( sStrToEncode ) sStrToEncode = Replace( Replace( Replace( Server.URLEncode( sStrToEncode ), "%2E", "."), "%3D", "="), "%26", "&" ) Set oChilkatCrypt2 = Server.CreateObject("Chilkat_9_5_0.Crypt2") oChilkatCrypt2.HashAlgorithm = "sha1" oChilkatCrypt2.EncodingMode = "hexlower" oChilkatCrypt2.KeyLength = 256 oChilkatCrypt2.SetHmacKeyEncoded "caf8b10dd473438196b514bbefac9ea6","ascii" UrlBoxEncode = Server.HTMLEncode( oChilkatCrypt2.HmacStringENC( sStrToEncode ) ) Destroy( oChilkatCrypt2 ) End Function Private Function AppVar( sName ) AppVar = Application( sName & Session("sKeyPersona") ) End Function Private Function AppVarGet( sName ) AppVarGet = AppVar( sName ) End Function Private Function AppVarSet( sName, sValue ) Application( sName & Session("sKeyPersona") ) = sValue End Function Private Function ArrayRandomize( aArrayRandom ) Dim iLoop, sTemp If UBound( aArrayRandom ) > 0 Then Randomize iUpper = UBound( aArrayRandom ) For iLoop = 0 To Int( iUpper / 2 ) + 1 iRnd = Int( Rnd * ( iUpper + 1 ) ) sTemp = aArrayRandom( iRnd ) aArrayRandom( iRnd ) = aArrayRandom( iLoop ) aArrayRandom( iLoop ) = sTemp Next End If ArrayRandomize = aArrayRandom End Function Private Function Aside( sKeyPersona, sKeyPage, sType ) Dim iLoop sType = Trim( LCase( sType ) ) 'Aside = sKeyPersona & "|" & sKeyPage 'sSQL = "SELECT tblPageHTML.* FROM tblPageHTML WHERE tblPageHTML.sKeyPersona = '" & sKeyPersona & "' AND tblPageHTML.sCodeLanguage = '" & Session("sCodeLanguage") & "' AND tblPageHTML.bLive <> 0 AND tblPageHTML.bDeleted = 0" sSQL = "SELECT tblPageHTML.* FROM tblPageHTML WHERE tblPageHTML.idPersona = " & Session("idPersona") & " AND tblPageHTML.sCodeLanguage = '" & Session("sCodeLanguage") & "' AND tblPageHTML.bLive <> 0 AND tblPageHTML.bDeleted = 0" Set rsPage = CreateObject("ADODB.Recordset") rsPage.CursorLocation = adUseClient rsPage.Open sSQL, Connection, adOpenReadOnly, adLockReadOnly, adCmdText rsPage.Filter = "sKey = '" & sKeyPage & "'" sPageAreasOfLaw = rsPage("sAreasOfLaw") iPageID = rsPage("ID") rsPage.Filter = "" sSQL = "SELECT tblNavigation.* FROM tblNavigation WHERE tblNavigation.idPersona = " & Session("idPersona") & " AND tblNavigation.sCodeLanguage = '" & Session("sCodeLanguage") & "' AND tblNavigation.sPath IS NOT NULL AND tblNavigation.bLive <> 0 AND tblNavigation.bDeleted = 0 ORDER BY NEWID()" Set rsNav = CreateObject("ADODB.Recordset") rsNav.CursorLocation = adUseClient rsNav.Open sSQL, Connection, adOpenReadOnly, adLockReadOnly, adCmdText rsNav.Filter = "iPageID=" & iPageID If sType = "children" Then ID = rsNav("ID") rsNav.Filter = "iPageID > 0 AND iParent=" & ID End If If sType = "siblings" Then iParent = rsNav("iParent") ID = rsNav("ID") rsNav.Filter = "iPageID > 0 AND iParent=" & iParent & " AND ID <> " & ID End If Aside = Aside & "
" Aside = Aside & " " Aside = Aside & "
" & AsidePromoConsultation() & AsideForm() & "
" Aside = Aside & AsideAd("vertical") Aside = Aside & "
" Destroy( rsNav ) Destroy( rsPage ) End Function Private Function AsideCourtHousesAndVenues( sPageAreasOfLaw ) If Numeric( AppVar("sCourtHouses") ) > 0 Then sSQL = "SELECT tbl@CourtHouses.* FROM tbl@CourtHouses WHERE bLive = 1 AND bDeleted = 0 ORDER BY sName" If Numeric( sPageAreasOfLaw ) > 0 Then aTemp = Split( sPageAreasOfLaw, "," ) sTemp = Empty For iLoop = 0 To UBound( aTemp ) If Numeric( aTemp( iLoop ) ) > 0 Then sTemp = sTemp & " tbl@CourtHouses.sAreasOfLaw LIKE '% " & aTemp( iLoop ) & ",%'" sTemp = sTemp & " OR " End If Next sTemp = Left( sTemp, Len( sTemp ) - 4 ) Else sTemp = "1=2" End If sSQL = Replace( sSQL, " WHERE ", " WHERE ( " & sTemp & " ) AND " ) sSQL = Replace( sSQL, " ", " ") 'Important Set rsCourtHouse = CreateObject("ADODB.Recordset") rsCourtHouse.CursorLocation = adUseClient rsCourtHouse.Open sSQL, Connection, adOpenReadOnly, adLockReadOnly, adCmdText If rsCourtHouse.EOF = False Then '' sVenues = "
" End If aCourtHouses = Split( AppVar("sCourtHouses") & "", "," ) Call ArrayRandomize( aCourtHouses ) For iLoop = 0 To UBound( aCourtHouses ) If Numeric( aCourtHouses( iLoop ) ) > 0 Then rsCourtHouse.Filter = "ID=" & aCourtHouses( iLoop ) If rsCourtHouse.EOF = False Then sTmpURL = IIf( Len( rsCourtHouse("sCity") ) > 3 ,Replace( rsCourtHouse("sCity") & ", Ontario", " ", "_"), "/cities") sVenues = sVenues & "

#TOKEN-sNameShort# attends:
" sVenues = sVenues & "" & rsCourtHouse("sName") & "
" sVenues = sVenues & "(" & rsCourtHouse("sNameShort") & ")
" sVenues = sVenues & "" & rsCourtHouse("sAddress1") & "
" sVenues = sVenues & "" & rsCourtHouse("sCity") & ", Ontario,  " & rsCourtHouse("sPostal") & "
" If Numeric( rsCourtHouse("sPhone1") ) > 0 Then '' sVenues = sVenues & "P: " & rsCourtHouse("sPhone1") & "
" End If If Numeric( rsCourtHouse("sPhone2") ) > 0 Then '' sVenues = sVenues & "P: " & rsCourtHouse("sPhone2") & "
" End If If Numeric( rsCourtHouse("sPhoneFax") ) > 0 Then '' sVenues = sVenues & "F: " & rsCourtHouse("sPhoneFax") & "
" End If sVenues = sVenues & "


" End If End If If iLoop > 3 Then Exit For End If Next AsideCourtHousesAndVenues = sVenues If AppVar("bShowTestimonials") Then AsideCourtHousesAndVenues = AsideCourtHousesAndVenues & "
#TOKEN-htmlTestimonials-1#" End If Destroy( rsCourtHouse ) End If End Function Private Function AsideForm() 'AT SOME TIME, CONSOLIDATE THE 2 (FORM-CONTACT) FORMS AND HANDLE THEM IN A THANK YOU PAGE WITH ERROR CHECKING Set oFS = Server.CreateObject("Scripting.FileSystemObject") Set oTextFile = oFS.OpenTextFile( MapPath("/form-contact-aside.asp"), 1, False ) AsideForm = oTextFile.ReadAll Destroy( oTextFile ) Destroy( oFS ) End Function Private Function AsideCallToAction() If AppVar("iTypeFirm") > 0 AND AppVar("iTypeFirm") < 4 Then aTemp1 = Split("Have Legal Questions and Need Answers?~|~Have Legal Issues and Need Help?~|~Do You Need to Address a Legal Matter?", "~|~") sTemp1 = aTemp1( RandomInteger( 0, UBound( aTemp1 ) ) ) aTemp2 = Split("Avoid Delays.~|~Protect Your Legal Rights.~|~Address Your Legal Rights Today!~|~Discuss Your Legal Matter!~|~Get Legal Help Now.", "~|~") sTemp2 = aTemp2( RandomInteger( 0, UBound( aTemp2 ) ) ) aTemp3 = Split("Contact #TOKEN-sNameShort#~|~Call #TOKEN-sPhone1#~|~Contact #TOKEN-sNameShort#
#TOKEN-sPhone1#", "~|~") sTemp3 = aTemp3( RandomInteger( 0, UBound( aTemp3 ) ) ) aTemp4 = Split("Discuss Your Legal Rights Today!~|~Get Started Today!~|~Don't Delay, Start Today!","~|~") sTemp4 = aTemp4( RandomInteger( 0, UBound( aTemp4 ) ) ) sTemp = "" Else sTemp = "" End If AsideCallToAction = sTemp End Function Private Function AsidePromoConsultation() If AppVar("iOfferFreeConsultation") > 0 Then sTemp = "
Get a FREE " & ReplaceTokens("#TOKEN-sOfferFreeConsultationValue#") & " HOUR CONSULTATION
" AsidePromoConsultation = sTemp End If End Function Private Function ConstrainDataToByte( iValue ) 'See color functions ConstrainDataToByte = iValue If iValue < 0 Then ConstrainDataToByte = 0 End If If iValue > 255 Then ConstrainDataToByte = 255 End If End Function Private Function ColorDarken( sColor, iPercent ) 'Make iPercent < 1.0 to darken. If Len( AlphaNumeric( sColor ) ) = 6 Then sHex = Replace( Trim( sColor ), "#", "" ) iR = ConstrainDataToByte( Int( ( CInt("&H" & Left( sHex, 2 ) ) * iPercent ) + .5 ) ) iG = ConstrainDataToByte( Int( ( CInt("&H" & Mid ( sHex, 3, 2 ) ) * iPercent ) + .5 ) ) iB = ConstrainDataToByte( Int( ( CInt("&H" & Mid ( sHex, 5, 2 ) ) * iPercent ) + .5 ) ) ColorDarken = UCase( "#" & Right( "0" & Hex( iR ), 2 ) & Right( "0" & Hex( iG ), 2 ) & Right( "0" & Hex( iB ), 2 ) ) End If End Function Private Function ColorLighten( sColor, iPercent ) 'Make iPercent > 1.0 to lighten. ColorLighten = ColorDarken( sColor, iPercent ) End Function Private Function ColorRGBA( sColor, iAlpha ) sHex = Replace( Trim( sColor ), "#", "" ) iR = CInt("&H" & Left( sHex, 2 ) ) iG = CInt("&H" & Mid ( sHex, 3, 2 ) ) iB = CInt("&H" & Mid ( sHex, 5, 2 ) ) ColorRGBA = "rgba(" & iR & "," & iG & "," & iB & "," & iAlpha & ")" End Function Private Function ColorInvert( sColor ) If Len( AlphaNumeric( sColor ) ) = 6 Then sHex = AlphaNumeric( sColor ) iR = 255 - CInt("&H" & Left( sHex, 2 ) ) iG = 255 - CInt("&H" & Mid ( sHex, 3, 2 ) ) iB = 255 - CInt("&H" & Mid ( sHex, 5, 2 ) ) ColorInvert = UCase( "#" & Right( "0" & Hex( iR ), 2 ) & Right( "0" & Hex( iG ), 2 ) & Right( "0" & Hex( iB ), 2 ) ) End If End Function Private Function CBit( bBoolean ) If bBoolean OR Numeric( bBoolean ) <> 0 OR UCase( Trim( bBoolean ) ) = "TRUE" Then CBit = 1 Else CBit = 0 End If End Function Private Function AccountExists( aArray ) 'aArray SHOULD BE: sName,sEmail,sPhone,sPostal,sUserID,sLicenceNumber,sKey; FUNCTION RETURNS VALUE OF 1 IF PROBABLE TO 80% OR MORE, AND RETURNS ID OF ACCOUNT IF CERTAIN. AccountExists = 0 If IsArray( aArray ) Then For iLoop = 0 To UBound( aArray ) 'Parse out the array into its respective variables, then deal with the issue at hand Select Case iLoop Case 0 sName = Clean( aArray( iLoop ) ) Case 1 sEmail = Clean( aArray( iLoop ) ) Case 2 sPhone = Phone( Numeric( aArray( iLoop ) ) ) Case 3 sPostal = Clean( aArray( iLoop ) ) Case 4 sUserID = Replace( Clean( aArray( iLoop ) ), "@", "") Case 5 sLicenceNumber = Clean( aArray( iLoop ) ) Case 6 sKey = AlphaNumeric( aArray( iLoop ) ) End Select Next aName = Split( Replace( sName, "-", " " ) ) 'ASSISTS TO ENSURE THAT A HYPHENATED NAME IS BREAKABLE INTO SUB-PIECES sTemp = " tblAccounts.sEmail = '" & sEmail & "'" 'DO THIS FIRST AND ALWAYS, SO THE SQL STRING CAN BEGIN WITHOUT ANY BOOLEAN LOGIC For iLoop = 0 To UBound( aName ) sTemp = sTemp & " OR tblAccounts.sName LIKE '%" & aName( iLoop ) & "%'" Next If Numeric( sPhone ) > 2012010000 Then sTemp = sTemp & " OR sPhone = '" & sPhone & "'" End If If sUserID <> Empty Then sTemp = sTemp & " OR sUserID = '" & sUserID & "'" End If If sLicenceNumber <> Empty Then sTemp = sTemp & " OR sLicenceNumber = '" & sLicenceNumber & "'" End If If Len( sKey ) = 15 Then sTemp = sTemp & " OR sKey = '" & sKey & "'" End If sSQL = "SELECT tblAccounts.ID, tblAccounts.sKey, tblAccounts.sName, tblAccounts.sEmail, tblAccounts.sPhone, tblAccounts.sPostal, tblAccounts.sUserID, tblAccounts.sLicenceNumber FROM tblAccounts WHERE " & sTemp Set rs = CreateObject("ADODB.Recordset") rs.CursorLocation = adUseClient rs.Open sSQL, Connection, adOpenReadOnly, adLockReadOnly, adCmdText iExistsProbable = 0 'PERCENTAGE OF PROBABILITY idAccountLikely = 0 If NOT rs.EOF Then rs.Filter = "sEmail = '" & sEmail & "'" If NOT rs.EOF AND sEmail <> Empty Then idAccountLikely = rs("ID") iExistsProbable = 100 End If rs.Filter = "sUserID = '" & sUserID & "'" If NOT rs.EOF AND sUserID <> Empty AND sEmail = Empty Then idAccountLikely = rs("ID") iExistsProbable = 100 End If rs.Filter = "sKey = '" & sKey & "'" If NOT rs.EOF AND sKey <> Empty AND sEmail = Empty AND sUserID = Empty Then idAccountLikely = rs("ID") iExistsProbable = 100 End If rs.Filter = "" Do Until rs.EOF OR iExistsProbable > 79 iTempProbable = 0 idAccountLikely = 0 If IsArray( aName ) Then For iLoop = 0 To UBound( aName ) If InStr( 1, rs("sName"), Trim( aName( iLoop ) ), 1 ) > 0 AND Len( Trim( aName( iLoop ) ) ) > 1 Then iTempProbable = iTempProbable + 27 End If Next End If If Numeric( sPhone ) > 2012010000 AND InStr( rs("sPhone"), sPhone ) > 0 Then iTempProbable = iTempProbable + 50 End If If Len( sPostal ) > 3 AND AlphaNumeric( rs("sPostal") ) = AlphaNumeric( sPostal ) Then iTempProbable = iTempProbable + 27 End If If Len( sLicenceNumber ) > 3 AND InStr( 1, rs("sLicenceNumber"), sLicenceNumber, 1 ) > 0 Then iTempProbable = iTempProbable + 50 End If If iExistsProbable & iTempProbable > 79 Then idAccountLikely = rs("ID") iExistsProbable = iExistsProbable & iTempProbable Exit Do End If rs.MoveNext Loop End If If idAccountLikely > 0 Then AccountExists = idAccountLikely Else If iExistsProbable > 79 Then AccountExists = 1 End If End If End If Destroy( rs ) End Function 'ADDED 2022-01-02 - REPLACES OLD AND ALSO NOW ACCOMMODATES sPhone AS AN ACCOUNT CREATION COMPONENT IN OUR CHANGING WORLD :) Private Function AccountUserNewCreate( sName, sEmail, sPhone, sPassword, sKeyPersonaCreated, bLive, iCreator ) 'If bLive is received as an Array, then the [1] element sets bAddUserViaStealth; [2] element if present sets account type; bAccountCreatorIsDeleted = CBool( Numeric( Fetch("tblAccounts","bDeleted","ID=" & iCreator ) ) ) sName = Clean( sName ) sUserID = RegularExpression( "" & Replace( sName, " ", "."), "[^0-9a-zA-Z.-]", "" ) bUserIDExists = Numeric( AccountUserIDExists( sUserID ) ) > 0 If bUserIDExists Then sUserID = Left( Right( Key( 15 ), 5 ) & "-" & sUserID, 60 ) End If If IsAllLCase( sName ) OR IsAllUCase( sName ) Then sName = PCase( sName ) End If bAccountNameIsAcceptable = Len( Alpha( sName ) ) > 4 AND InStr( AlphaSpace( sName ), " " ) > 1 sEmail = LCase( Clean( sEmail ) ) bIsEmail = IsEmail( sEmail ) sPhone = Phone( Numeric( sPhone ) ) bIsPhone = Numeric( sPhone ) > 2002000000 AND Numeric( sPhone ) < 10000000000 sPassword = Left( sPassword, 30 ) If Trim( sPassword ) = Empty Then 'WE ARE PRESUMABLY WITHIN AN AUTOMATED PROCESS, SO AUTO-GENERATE A PASSWORD sPassword = "a" & Key( 11 ) End If bAccountPasswordIsAcceptable = ( sPassword = Clean( sPassword ) ) AND Len( Clean( sPassword ) ) > 7 bAccountPasswordIsAcceptable = bAccountPasswordIsAcceptable AND ( Len( Alpha( sPassword ) ) > 0 AND ( Numeric( sPassword ) > 0 OR InStr( sPassword, "0") > 0 ) ) If NOT bAccountCreatorIsDeleted AND bAccountNameIsAcceptable AND ( bIsEmail OR bIsPhone ) AND bAccountPasswordIsAcceptable Then sSQL = "SELECT TOP 1 tblAccounts.* FROM tblAccounts WHERE tblAccounts.sEmail = '" & sEmail & "'" Set rsNew = CreateObject("ADODB.Recordset") rsNew.CursorLocation = adUseClient rsNew.Open sSQL, Connection, adOpenStatic, adLockOptimistic, adCmdText If rsNew.EOF Then rsNew.AddNew sKeyAccountUserNew = Key( 15 ) rsNew("sKey") = sKeyAccountUserNew rsNew("iTypeAccount") = 1 'USER / PERSON rsNew("sName") = sName rsNew("sUserID") = sUserID rsNew("sUserIDLCase") = LCase( sUserID ) If bIsEmail Then rsNew("sEmail") = sEmail End If If bIsPhone Then rsNew("sPhone") = sPhone End If rsNew("sPassword") = sPassword If Len( AlphaNumeric( sKeyPersonaCreated ) ) <> 15 Then sKeyPersonaCreated = Session("sKeyPersona") End If rsNew("sKeyPersonaCreated") = sKeyPersonaCreated If NOT IsArray( bLive ) Then rsNew("bLive") = CBit( bLive ) rsNew("bAddedViaStealth") = 0 bAddUserViaStealth = False Else rsNew("bLive") = CBit( bLive( 0 ) ) rsNew("bAddedViaStealth") = CBit( bLive( 1 ) ) bAddUserViaStealth = CBit( bLive( 1 ) ) If UBound( bLive ) > 1 Then rsNew("iTypeAccount") = Numeric( bLive( 2 ) ) End If End If If Len( AlphaNumeric( Request("sLicenceNumber") ) ) > 5 AND InStr( UCase( Alpha( Request("sLicenceNumber") ) ), "P") = 0 Then rsNew("iTypeAccount") = 2 'LAWYER / ATTORNEY End If If UCase( Alpha( Request("sLicenceNumber") ) ) = "P" Then rsNew("iTypeAccount") = 3 'PARALEGAL End If rsNew("iCreator") = Numeric( iCreator ) rsNew("iOwner") = iOwner rsNew.Update bAccountUserNewSuccess = True Call AccountUserProfileNewCreate( sKeyAccountUserNew ) 'CREATE THE FUNDAMENTAL PROFILE RECORD TO SATISFY ANY JOINS THAT MIGHT RELY ON ITS EXISTENCE - NEED TO CREATE ALL RETROACTIVES!!! If bAddUserViaStealth <> True Then Call AccountUserNewWelcome( sName, sEmail, sKeyAccountUserNew ) 'Add phone notification ASAP End If Else fsErrors = fsErrors & "An account/passport for the person appears to already exist.
" End If Destroy( rsNew ) Else fsErrors = fsErrors & "Something happened.  An account could not be created.
" End If If bAccountUserNewSuccess Then AccountUserNewCreate = sKeyAccountUserNew Else AccountUserNewCreate = fsErrors End If End Function 'ADDED 2022-01-02 Private Function AccountUserProfileNewCreate( sKeyAccount ) idAccount = Fetch("tblAccounts","ID","sKey='" & AlphaNumeric( sKeyAccount ) & "'" ) bAccountExists = CBool( CBit( idAccount ) ) If bAccountExists Then sSQL = "SELECT TOP 1 tblAccountsProfiles.* FROM tblAccountsProfiles WHERE sKeyAccount = '" & AlphaNumeric( sKeyAccount ) & "'" Set rsProfile = CreateObject("ADODB.Recordset") rsProfile.CursorLocation = adUseClient rsProfile.Open sSQL, Connection, adOpenStatic, adLockOptimistic, adCmdText If rsProfile.EOF Then sKeyProfile = Key( 15 ) rsProfile.AddNew rsProfile("sKey") = sKeyProfile rsProfile("idAccount") = idAccount rsProfile("sKeyAccount") = sKeyAccount rsProfile("iCreator") = iOwner rsProfile("iOwner") = iOwner If AlphaNumeric( Request("sLicenceNumber") ) <> Empty Then jsonLicence = "{'sLicenceType':'Type','sLicenceNumber':'" & AlphaNumeric( Request("sLicenceNumber") ) & "':'','iYearLicenced':0}" If Len( AlphaNumeric( Request("sLicenceNumber") ) ) > 5 AND InStr( UCase( Alpha( Request("sLicenceNumber") ) ), "P") = 0 Then jsonLicence = Replace( jsonLicence, "'Type'", "'L1'" ) End If If UCase( Alpha( Request("sLicenceNumber") ) ) = "P" Then jsonLicence = Replace( jsonLicence, "'Type'", "'P1'" ) End If rsProfile("jsonLicence") = Replace( jsonLicence, "'", Chr( 34 ) ) End If rsProfile.Update bAccountUserNewProfileSuccess = True Else sErrors = sErrors & "Something happened.  An account could not be created.
" End If Destroy( rsProfile ) End If End Function 'ADDED 2023-09-17 Private Function AccountUserIDExists( sUserID ) AccountUserIDExists = Fetch("tblAccounts","ID","LOWER( sUserID ) = LOWER('" & sUserID & "')") ' "sUserID='" & sUserID & "' OR sUserIDLCase ='" & LCase( sUserID ) & "'") End Function Private Function AccountUpdateAddress( sKeyAccount, sAddress1, sAddress2, sAddressSuite, sCity, iCity, iProv, sPostal, iCountry, bOverWrite ) 'OVERWRITE PROTECTION NOT YET IMPLEMENTED sSQL = "SELECT TOP 1 tblAccounts.* FROM tblAccounts WHERE sKey = '" & AlphaNumeric( sKeyAccount ) & "'" Set rsAddress = CreateObject("ADODB.Recordset") rsAddress.CursorLocation = adUseClient rsAddress.Open sSQL, Connection, adOpenStatic, adLockOptimistic, adCmdText bAccountExists = NOT rsAddress.EOF If bAccountExists Then rsAddress("sAddress1") = Clean( sAddress1 ) rsAddress("sAddress2") = Clean( sAddress2 ) rsAddress("sAddressSuite") = UCase( AlphaNumeric( sAddressSuite ) ) rsAddress("sCity") = Clean( sCity ) '' rsAddress("iCity") = Numeric( iCity ) rsAddress("iProv") = Numeric( iProv ) rsAddress("sPostal") = AlphaNumericSpace( sPostal ) rsAddress("iCountry") = 1 rsAddress("iOwner") = iOwner rsAddress.Update bAccountUpdateAddressSuccess = True Else sErrors = sErrors & "The requisite account does not exist.
" End If Destroy( rsAddress ) End Function 'ADDED 2021-12-14 Private Function AccountUserNewWelcome( sName, sEmail, sKeyAccount ) sKeyVerification = Key( 20 ) If iOwner > 0 AND Session("sKeyAccount") <> sKeyAccount Then 'It is someone inviting someone to join. sMessageWelcome = Scrape("/emails/user-welcome-invite.txt") sMessageSubject = Session("sName") & " Invites You to Join the Success.Legal Network" sNameUserInvited = sName sName = Fetch("tblAccounts","sName","sKey = '" & Session("sKeyAccount") & "'") Else sMessageWelcome = Scrape("/emails/user-welcome.txt") sMessageSubject = "From the " & AppVar("sNameShort") & " Website " End If sMessageWelcome = Replace( sMessageWelcome, "#TOKEN-sDomain#", Session("sDomain") ) sMessageWelcome = Replace( sMessageWelcome, "#TOKEN-sNameUser#", sName ) sMessageWelcome = Replace( sMessageWelcome, "#TOKEN-sEmailUser#", sEmail ) sMessageWelcome = Replace( sMessageWelcome, "#TOKEN-sEmailUserInvited#", sEmail ) sMessageWelcome = Replace( sMessageWelcome, "#TOKEN-sNameUserInvited#", sNameUserInvited ) 'ADDED 2022-01-22 sMessageWelcome = Replace( sMessageWelcome, "#TOKEN-sKeyAccount#", sKeyAccount ) sMessageWelcome = Replace( sMessageWelcome, "#TOKEN-sKeyVerification#", sKeyVerification ) sSQL = "SELECT TOP 1 tblAccounts.sKeyVerification, tblAccounts.dEmailVerifySought, tblAccounts.dModified FROM tblAccounts WHERE tblAccounts.sKey = '" & sKeyAccount & "'" Set rsAccount = CreateObject("ADODB.Recordset") rsAccount.CursorLocation = adUseClient rsAccount.Open sSQL, Connection, adOpenStatic, adLockOptimistic, adCmdText If rsAccount.EOF Then Write "Something went wrong." Else If IsNull( rsAccount("dEmailVerifySought") ) Then rsAccount("sKeyVerification") = sKeyVerification rsAccount("dEmailVerifySought") = Now rsAccount("dModified") = Now rsAccount.Update Call Email( sEmail, "sent.from.marketing.legal@gmail.com", sMessageSubject, sMessageWelcome ) End If End If Destroy( rsAccount ) End Function Function Admin() Admin = CBool( Session("bAdmin") ) End Function Function AdminSavvy() AdminSavvy = CBool( Session("bAdminSavvy") ) End Function Function AdminSuper() AdminSuper = CBool( Session("bSuper") ) End Function Function SuperAdmin() SuperAdmin = CBool( Session("bSuper") ) End Function Private Function AjaxPager( oObject, sURL, iPageSize, iPages, iPage ) iPage = Numeric( iPage ) If iPage < 1 Then iPage = 1 End If iTemp = iPage - 4 If iTemp + 8 > iPages Then iTemp = iPages - 8 End If If iTemp < 1 Then iTemp = 1 End If For iLoop = 0 To 8 sLink = Replace( Replace( Replace( sURL, "&iPage=" & iPage, Empty ), "iPage=" & iPage, Empty ), "?", "?iPage=" ) If InStr( sLink, "?" ) = 0 Then sLink = sLink & "?iPage=" End If If iPage <> iLoop + iTemp Then sClass = "btn" Else sClass = "btn-primary active" End If sLink = Replace( Replace( sLink, "?iPage=", "?iPage=" & iLoop + iTemp & "&" ), "&&", "&" ) If Right( sLink, 1 ) = "&" Then sLink = Left( sLink, Len( sLink ) -1 ) End If sTemp = sTemp & "" & Right("0" & iLoop + iTemp, 2 ) & " " If iLoop + iTemp >= iPages Then Exit For End If Next sTemp = " " & sTemp sTemp = sTemp & " " AjaxPager = "