%@ Language=VBScript %>
<% Option Explicit %>
<%
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString="DRIVER={Microsoft Access Driver (*.mdb)};" & "DBQ=" & Server.MapPath("includes/database/db_Welding_Supplies.mdb")
objConn.Open
%>
<%
'--------------------------------------------------------------------
' Microsoft ADO
'
' Copyright (c) 1996-1998 Microsoft Corporation.
'
'
'
' 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
Const adFind = &H00080000
Const adSeek = &H00400000
Const adIndex = &H00800000
'---- LockTypeEnum Values ----
Const adLockReadOnly = 1
Const adLockPessimistic = 2
Const adLockOptimistic = 3
Const adLockBatchOptimistic = 4
'---- ExecuteOptionEnum Values ----
Const adAsyncExecute = &H00000010
Const adAsyncFetch = &H00000020
Const adAsyncFetchNonBlocking = &H00000040
Const adExecuteNoRecords = &H00000080
Const adExecuteStream = &H00000400
'---- ConnectOptionEnum Values ----
Const adAsyncConnect = &H00000010
'---- ObjectStateEnum Values ----
Const adStateClosed = &H00000000
Const adStateOpen = &H00000001
Const adStateConnecting = &H00000002
Const adStateExecuting = &H00000004
Const adStateFetching = &H00000008
'---- 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
Const adChapter = 136
Const adFileTime = 64
Const adPropVariant = 138
Const adVarNumeric = 139
Const adArray = &H2000
'---- 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
Const adFldIsChapter = &H00002000
Const adFldNegativeScale = &H00004000
Const adFldKeyColumn = &H00008000
Const adFldIsRowURL = &H00010000
Const adFldIsDefaultStream = &H00020000
Const adFldIsCollection = &H00040000
'---- 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
'---- BookmarkEnum 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 adAffectAllChapters = 4
'---- ResyncEnum Values ----
Const adResyncUnderlyingValues = 1
Const adResyncAllValues = 2
'---- CompareEnum Values ----
Const adCompareLessThan = 0
Const adCompareEqual = 1
Const adCompareGreaterThan = 2
Const adCompareNotEqual = 3
Const adCompareNotComparable = 4
'---- FilterGroupEnum Values ----
Const adFilterNone = 0
Const adFilterPendingRecords = 1
Const adFilterAffectedRecords = 2
Const adFilterFetchedRecords = 3
Const adFilterConflictingRecords = 5
'---- SearchDirectionEnum Values ----
Const adSearchForward = 1
Const adSearchBackward = -1
'---- PersistFormatEnum Values ----
Const adPersistADTG = 0
Const adPersistXML = 1
'---- StringFormatEnum Values ----
Const adClipString = 2
'---- 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
Const adModeRecursive = &H400000
'---- RecordCreateOptionsEnum Values ----
Const adCreateCollection = &H00002000
Const adCreateStructDoc = &H80000000
Const adCreateNonCollection = &H00000000
Const adOpenIfExists = &H02000000
Const adCreateOverwrite = &H04000000
Const adFailIfNotExists = -1
'---- RecordOpenOptionsEnum Values ----
Const adOpenRecordUnspecified = -1
Const adOpenOutput = &H00800000
Const adOpenAsync = &H00001000
Const adDelayFetchStream = &H00004000
Const adDelayFetchFields = &H00008000
Const adOpenExecuteCommand = &H00010000
'---- 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 adErrProviderFailed = &Hbb8
Const adErrInvalidArgument = &Hbb9
Const adErrOpeningFile = &Hbba
Const adErrReadFile = &Hbbb
Const adErrWriteFile = &Hbbc
Const adErrNoCurrentRecord = &Hbcd
Const adErrIllegalOperation = &Hc93
Const adErrCantChangeProvider = &Hc94
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 adErrNotReentrant = &He7e
Const adErrStillExecuting = &He7f
Const adErrOperationCancelled = &He80
Const adErrStillConnecting = &He81
Const adErrInvalidTransaction = &He82
Const adErrUnsafeOperation = &He84
Const adwrnSecurityDialog = &He85
Const adwrnSecurityDialogHeader = &He86
Const adErrIntegrityViolation = &He87
Const adErrPermissionDenied = &He88
Const adErrDataOverflow = &He89
Const adErrSchemaViolation = &He8a
Const adErrSignMismatch = &He8b
Const adErrCantConvertvalue = &He8c
Const adErrCantCreate = &He8d
Const adErrColumnNotOnThisRow = &He8e
Const adErrURLIntegrViolSetColumns = &He8f
Const adErrURLDoesNotExist = &He8f
Const adErrTreePermissionDenied = &He90
Const adErrInvalidURL = &He91
Const adErrResourceLocked = &He92
Const adErrResourceExists = &He93
Const adErrCannotComplete = &He94
Const adErrVolumeNotFound = &He95
Const adErrOutOfSpace = &He96
Const adErrResourceOutOfScope = &He97
Const adErrUnavailable = &He98
Const adErrURLNamedRowDoesNotExist = &He99
Const adErrDelResOutOfScope = &He9a
Const adErrPropInvalidColumn = &He9b
Const adErrPropInvalidOption = &He9c
Const adErrPropInvalidValue = &He9d
Const adErrPropConflicting = &He9e
Const adErrPropNotAllSettable = &He9f
Const adErrPropNotSet = &Hea0
Const adErrPropNotSettable = &Hea1
Const adErrPropNotSupported = &Hea2
Const adErrCatalogNotSet = &Hea3
Const adErrCantChangeConnection = &Hea4
Const adErrFieldsUpdateFailed = &Hea5
Const adErrDenyNotSupported = &Hea6
Const adErrDenyTypeNotSupported = &Hea7
Const adErrProviderNotSpecified = &Hea9
'---- 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
Const adCmdFile = &H0100
Const adCmdTableDirect = &H0200
'---- EventStatusEnum Values ----
Const adStatusOK = &H0000001
Const adStatusErrorsOccurred = &H0000002
Const adStatusCantDeny = &H0000003
Const adStatusCancel = &H0000004
Const adStatusUnwantedEvent = &H0000005
'---- EventReasonEnum Values ----
Const adRsnAddNew = 1
Const adRsnDelete = 2
Const adRsnUpdate = 3
Const adRsnUndoUpdate = 4
Const adRsnUndoAddNew = 5
Const adRsnUndoDelete = 6
Const adRsnRequery = 7
Const adRsnResynch = 8
Const adRsnClose = 9
Const adRsnMove = 10
Const adRsnFirstChange = 11
Const adRsnMoveFirst = 12
Const adRsnMoveNext = 13
Const adRsnMovePrevious = 14
Const adRsnMoveLast = 15
'---- 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 adSchemaReferentialConstraints = 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
Const adSchemaDBInfoKeywords = 30
Const adSchemaDBInfoLiterals = 31
Const adSchemaCubes = 32
Const adSchemaDimensions = 33
Const adSchemaHierarchies = 34
Const adSchemaLevels = 35
Const adSchemaMeasures = 36
Const adSchemaProperties = 37
Const adSchemaMembers = 38
Const adSchemaTrustees = 39
Const adSchemaFunctions = 40
Const adSchemaActions = 41
Const adSchemaCommands = 42
Const adSchemaSets = 43
'---- FieldStatusEnum Values ----
Const adFieldOK = 0
Const adFieldCantConvertValue = 2
Const adFieldIsNull = 3
Const adFieldTruncated = 4
Const adFieldSignMismatch = 5
Const adFieldDataOverflow = 6
Const adFieldCantCreate = 7
Const adFieldUnavailable = 8
Const adFieldPermissionDenied = 9
Const adFieldIntegrityViolation = 10
Const adFieldSchemaViolation = 11
Const adFieldBadStatus = 12
Const adFieldDefault = 13
Const adFieldIgnore = 15
Const adFieldDoesNotExist = 16
Const adFieldInvalidURL = 17
Const adFieldResourceLocked = 18
Const adFieldResourceExists = 19
Const adFieldCannotComplete = 20
Const adFieldVolumeNotFound = 21
Const adFieldOutOfSpace = 22
Const adFieldCannotDeleteSource = 23
Const adFieldReadOnly = 24
Const adFieldResourceOutOfScope = 25
Const adFieldAlreadyExists = 26
Const adFieldPendingInsert = &H10000
Const adFieldPendingDelete = &H20000
Const adFieldPendingChange = &H40000
Const adFieldPendingUnknown = &H80000
Const adFieldPendingUnknownDelete = &H100000
'---- SeekEnum Values ----
Const adSeekFirstEQ = &H1
Const adSeekLastEQ = &H2
Const adSeekAfterEQ = &H4
Const adSeekAfter = &H8
Const adSeekBeforeEQ = &H10
Const adSeekBefore = &H20
'---- ADCPROP_UPDATECRITERIA_ENUM Values ----
Const adCriteriaKey = 0
Const adCriteriaAllCols = 1
Const adCriteriaUpdCols = 2
Const adCriteriaTimeStamp = 3
'---- ADCPROP_ASYNCTHREADPRIORITY_ENUM Values ----
Const adPriorityLowest = 1
Const adPriorityBelowNormal = 2
Const adPriorityNormal = 3
Const adPriorityAboveNormal = 4
Const adPriorityHighest = 5
'---- ADCPROP_AUTORECALC_ENUM Values ----
Const adRecalcUpFront = 0
Const adRecalcAlways = 1
'---- ADCPROP_UPDATERESYNC_ENUM Values ----
'---- ADCPROP_UPDATERESYNC_ENUM Values ----
'---- MoveRecordOptionsEnum Values ----
Const adMoveUnspecified = -1
Const adMoveOverWrite = 1
Const adMoveDontUpdateLinks = 2
Const adMoveAllowEmulation = 4
'---- CopyRecordOptionsEnum Values ----
Const adCopyUnspecified = -1
Const adCopyOverWrite = 1
Const adCopyAllowEmulation = 4
Const adCopyNonRecursive = 2
'---- StreamTypeEnum Values ----
Const adTypeBinary = 1
Const adTypeText = 2
'---- LineSeparatorEnum Values ----
Const adLF = 10
Const adCR = 13
Const adCRLF = -1
'---- StreamOpenOptionsEnum Values ----
Const adOpenStreamUnspecified = -1
Const adOpenStreamAsync = 1
Const adOpenStreamFromRecord = 4
'---- StreamWriteEnum Values ----
Const adWriteChar = 0
Const adWriteLine = 1
'---- SaveOptionsEnum Values ----
Const adSaveCreateNotExist = 1
Const adSaveCreateOverWrite = 2
'---- FieldEnum Values ----
Const adDefaultStream = -1
Const adRecordURL = -2
'---- StreamReadEnum Values ----
Const adReadAll = -1
Const adReadLine = -2
'---- RecordTypeEnum Values ----
Const adSimpleRecord = 0
Const adCollectionRecord = 1
Const adStructDoc = 2
%>
<%
'' Dim Domain_Name, theURL, QUERY_STRING, HTTP_PATH
' Domain_Name = lcase(request.ServerVariables("HTTP_HOST"))
' if domain_name <> "www.tbws.co.uk" and domain_name <> "www2.securesiteserver.co.uk" Then
' HTTP_PATH = request.ServerVariables("PATH_INFO")
' If Left(HTTP_PATH, 8) = "/default" Then
' HTTP_PATH = ""
' End If
' QUERY_STRING = request.ServerVariables("QUERY_STRING")
' theURL = "http://www.tbws.co.uk" & HTTP_PATH
' if len(QUERY_STRING) > 0 Then
' theURL = theURL & "?" & QUERY_STRING
' end if
' Response.Clear
' Response.Status = "301 Moved Permanently"
' Response.AddHeader "Location", theURL
' Response.Flush
' Response.End
' end if
'
'Function to replace spaces with underscores to create folder names
Function funCreateFolderName(funCategory)
funCategory = trim(lCase(funCategory))
funCategory = Replace(funCategory, " ", "_")
funCreateFolderName = funCategory
End Function
'sub to build the category arr if it dose not exist
Sub subCreateCategoryApp
Dim objCategory, strCatSQL
Set objCategory = Server.CreateObject("ADODB.Recordset")
strCatSQL = "SELECT CategoryLink, CategoryLinkDisplay, ParentCategory FROM tblProductCategory WHERE ParentCategory = 0 OR ParentCategory is null ORDER BY CategoryLink"
objCategory.Open strCatSQL, objConn, , adlockOptimistic
Dim arrProductCategories
If Not objCategory.EOF Then
arrProductCategories = objCategory.GetRows()
Application.Lock
Application("appProductCategories") = arrProductCategories
Application.UnLock
Else
Application.Lock
Application("appProductCategories") = " "
Application.UnLock
End If
objCategory.Close
Set objCategory = Nothing
End Sub
'Function to check login
Function funCheckLogin
Dim bolCheck
bolCheck = False
If Session("LoggedIn") = "yes" Then
bolCheck = True
End IF
funCheckLogin = bolCheck
End Function
'validate email addresss
Function funValidateEmail(strEmail)
Dim bolCheck, iATPosition, iEmailLength, iAfterAT, iFullStop
'find out the length
iEmailLength = Len(strEmail)
'set all charactres to lowercase
strEmail = Lcase(strEmail)
'check to see that there is an @ after the the first character
iATPosition = InStr("1", strEmail, "@", 1)
'if place found is greater than 1, it must be ok as the must have a character befor it
If iATPosition > 1 Then
bolCheck = True
'find out the length after the @
iAfterAT = iEmailLength - iATPosition
If iAfterAT > 4 Then
bolCheck = True
'find position of full stop after the @
iFullStop = InStr("" & iATPosition & "", strEmail, ".", 1)
'check to see that ther is a characher b4 the full stop and at least 2 afterwards
If iFullStop > 1 and iFullStop <= iEmailLength - 2 then
bolCheck = True
Else
bolCheck = False
End If
Else
bolCheck = False
End IF
Else
bolCheck = False
End If
'set the function true or false
funValidateEmail = bolCheck
End Function
'Function to validate password
Function funValidatePassword(strPassword)
Dim bolCheck
If Len(strPassword) < 4 Or len(strPassword) > 8 then
bolCheck = False
Else
bolCheck = True
End If
FunValidatePassword = bolCheck
End Function
FUNCTION funCleanCCNum( ccnumber )
Dim i
FOR i = 1 TO LEN( ccnumber )
IF isNumeric( MID( ccnumber, i, 1 ) ) THEN
funCleanCCNum = funCleanCCNum & MID( ccnumber, i, 1 )
END IF
NEXT
END FUNCTION
FUNCTION funvalidCCNumber( ccnumber )
ccnumber = funCleanCCNum( ccnumber )
IF ccnumber = "" THEN
funvalidCCNumber = FALSE
ELSE
isEven = False
digits = ""
for i = Len( ccnumber ) To 1 Step -1
if isEven Then
digits = digits & CINT( MID( ccnumber, i, 1) ) * 2
Else
digits = digits & CINT( MID( ccnumber, i, 1) )
End If
isEven = (Not isEven)
Next
checkSum = 0
For i = 1 To Len( digits) Step 1
checkSum = checkSum + CINT( MID( digits, i, 1 ) )
Next
funvalidCCNumber = ( ( checkSum Mod 10) = 0 )
END IF
End Function
'Function to calculate shipping costs
Function funCalculateShipping(strUsersCountry, arrCartArray)
Dim iShipping
If strUsersCountry = "UNITED KINGDOM" OR strUsersCountry = "IRELAND" OR strUsersCountry = "IRELAND - DUBLIN" Then
iShipping = 0
For iLoop = 0 to UBound(arrCartArray)
If arrCartArray(CartShippingValue, iLoop) <> "" Then
iShipping = iShipping + (arrCartArray(CartShippingValue, iLoop) * arrCartArray(CartQuantity, iLoop))
End If
Next
Else
iShipping = 0
End If
funCalculateShipping = FormatCurrency(iShipping)
End Function
'Functionton to calculate the basket sub total
Function funCartSubTotal(strUsersCountry, arrCartArray)
Dim iCartSubTotal, iShipping
iShipping = Cdbl(funCalculateShipping(strUsersCountry, arrCartArray))
iCartSubTotal = 0
For iLoop = 0 to UBound(arrCartArray)
If arrCartArray(CartProductID, iLoop) <> "" Then
iCartSubTotal = iCartSubTotal + (arrCartArray(CartProductPrice, iLoop) * arrCartArray(CartQuantity, iLoop))
End If
Next
If IsNumeric(iShipping) then
iCartSubTotal = iCartSubTotal + iShipping
End If
funCartSubTotal = FormatCurrency(iCartSubTotal)
End Function
'Function to calculate the basket VAT
Function funCalculateVAT(strUsersCountry, arrCartArray)
'Request the users location
Dim iVAT, iSubTotal
iSubTotal = Cdbl(funCartSubTotal(strUsersCountry, arrCartArray))
If strUsersCountry = "UNITED KINGDOM" OR strUsersCountry = "IRELAND" OR strUsersCountry = "IRELAND - DUBLIN" Then
iVAT = FormatCurrency((iSubTotal / 100) * 15)
Else
iVAT = 0
End If
funCalculateVAT = FormatCurrency(iVAT)
End Function
'Function to calculate the cart total
Function funCartTotal(strUsersCountry, arrCartArray)
Dim iCartTotal, iSubTotal, iVat
iSubTotal = Cdbl(funCartSubTotal(strUsersCountry, arrCartArray))
iVat = Cdbl(funCalculateVAT(strUsersCountry, arrCartArray))
iCartTotal = iSubTotal '+ iVat
funCartTotal = FormatCurrency(iCartTotal)
End Function
'Sub to send out new mail
Sub subSendNewMail(strMailFrom, strMailTo, strMailSubject, strMailMessage)
Dim objNewMail
Set objNewMail = Server.CreateObject("CDONTS.NewMail")
objNewMail.From = strMailFrom
objNewMail.To = strMailTo
objNewMail.Subject = strMailSubject
objNewMail.Body = strMailMessage
objNewMail.Send
Set objNewMail = Nothing
End Sub
'Function to dipaly the product status
Function funOrderStatus(iValue)
Dim strOrderStatus
Select Case iValue
Case 1
strOrderStatus = "New Order"
Case 2
strOrderStatus = "Pending"
Case 3
strOrderStatus = "Complete"
End Select
funOrderStatus = strOrderStatus
End Function
'Function to trim a telephone number
Function funTrimTelephone(strTelNumber)
Dim strNumber
strNumber = strTelNumber
strNumber = Replace(strNumber, " ", "")
funTrimTelephone = strNumber
End Function
'Sub to check admi login
Sub subCheckAdminLogin
If Session("AdminLoggedIn") <> "YES" and Request.Cookies ("loggedIN") <> "yes" Then
Response.Redirect("login.asp")
End IF
End Sub
'Function to check if the shopping cart is empty
Function funCheckCartEmpty
'Set constant values for the index of the array
Const CartProductID = 0
Const CartProductTitle = 1
Const CartProductPrice = 2
Const CartShippingValue = 3
Const CartQuantity = 4
dim bolCheck, iLoop, arrCart
bolCheck = False
If IsArray(Session("sesCart")) Then
arrCart = Session("sesCart")
For iLoop = 0 to UBound(arrCart)
If arrCart(0, iLoop) <> "" AND arrCart(1, iLoop) <> "" AND arrCart(2, iLoop) <> "" AND arrCart(2, iLoop) <> "" AND arrCart(4, iLoop) <> "" Then
bolCheck = True
End If
Next
End If
funCheckCartEmpty = bolCheck
End Function
'sunb to take the session values and send them to the secure page
Sub subPostCart
'Set constant values for the index of the array
Const CartProductID = 0
Const CartProductTitle = 1
Const CartProductPrice = 2
Const CartShippingValue = 3
Const CartQuantity = 4
Const CartProductCode = 5
Dim iPostLoop
Response.Write "" & vbCrLf
Response.Write "" & vbCrLf
Response.Write "" & vbCrLf
arrPostCart = arrCart
For iPostLoop = 0 to UBound(arrPostCart)
If arrPostCart(CartProductID, iPostLoop) <> "" Then
Response.Write "" & vbCrLf
Response.Write "" & vbCrLf
Response.Write "" & vbCrLf
Response.Write "" & vbCrLf
Response.Write "" & vbCrLf
Response.Write "" & vbCrLf
End If
Next
End Sub
'Sub to mretrieve from posted from non secure page and add setails to array and create new session
Sub subRetreiveSecureCart
Const CartProductID = 0
Const CartProductTitle = 1
Const CartProductPrice = 2
Const CartShippingValue = 3
Const CartQuantity = 4
Const CartProductCode = 5
If Request("tfTransferCart") = "yes" Then
Session("sesCart") = ""
Dim iPostLoop, arrPostCart(6, 20)
For iPostLoop = 0 to 20
If Request("CartProductID" & iPostLoop) <> "" Then
arrPostCart(0, iPostLoop) = Request("CartProductID" & iPostLoop)
arrPostCart(1, iPostLoop) = Request("CartProductTitle" & iPostLoop)
arrPostCart(2, iPostLoop) = Request("CartProductPrice" & iPostLoop)
arrPostCart(3, iPostLoop) = Request("CartShippingValue" & iPostLoop)
arrPostCart(4, iPostLoop) = Request("CartQuantity" & iPostLoop)
arrPostCart(5, iPostLoop) = Request("CartProductCode" & iPostLoop)
End If
Next
Session("sesCart") = arrPostCart
Session("LoggedIn") = "yes"
Session("UserEmail") = Request("tfSecureEmail")
Session("Password") = Request("tfSecurePassword")
End If
End SUb
'Function to diaplay price plus VAT
Function funDisplayVAT(strValue)
'Request the users location
Dim iVAT
iVAT = FormatCurrency((strValue / 100) * 15)
strValue = strValue + iVAT
funDisplayVAT = FormatCurrency(strValue)
End Function
'display free shipping
Sub subDisplayShipping(iShipping)
If iShipping = 0 Then
Response.Write ""
End If
End Sub
'display free shipping
Sub subDisplayShipping2(iShipping)
If iShipping = 0 Then
Response.Write ""
End If
End Sub
'Sub to write keywords in meta tags
Function funWriteKeyWords(arrLinks)
Dim iLoop, strkeywords
If isArray(arrLinks) Then
For iLoop = 0 to UBound(arrLinks, 2)
strKeywords = strKeywords & arrLinks(0, iLoop) & ", "
Next
End If
funWriteKeyWords = strKeywords
End Function
'function to replace line breaks in the admin update
Function funAddLineBreak(strText)
strText = replace(strText,vbCrLF," ")
funAddLineBreak = strText
End Function
'sub to build the category arr for the drop down menue
Sub subCreateCategoryDropApp
Dim objCategory, strCatSQL
Set objCategory = Server.CreateObject("ADODB.Recordset")
strCatSQL = "SELECT CategoryLink, CategoryLinkDisplay FROM tblProductCategory ORDER BY CategoryLink"
objCategory.Open strCatSQL, objConn, , adlockOptimistic
Dim arrProductCategories
If Not objCategory.EOF Then
arrProductCategories = objCategory.GetRows()
Application.Lock
Application("appProductCategoriesDrop") = arrProductCategories
Application.UnLock
Else
Application.Lock
Application("appProductCategoriesDrop") = " "
Application.UnLock
End If
objCategory.Close
Set objCategory = Nothing
End Sub
Function funInsertBreak(strText)
If Instr(UCASE(strText), " ") = 0 AND Instr(UCASE(strText), "
") = 0 AND Instr(UCASE(strText), "
") = 0 Then
strText = Replace(strText, vbCrLf, " ")
End If
funInsertBreak = strText
End Function
'function to create a page name
Function funCreatePageName(strTitle)
Dim iUBound, iLBound, iRange, strCode, strNewID
Randomize()
strCode = "LC"
iUBound = 9999
iLBound = 1000
iRange = iUBound - iLBound
strNewID = iRange * Rnd()
strNewID = Clng(strNewID + iLBound)
Dim arrNewName, strNewName
arrNewName = split(strTitle, " ")
strNewName = arrNewName(0) & " " & strNewID
funCreatePageName = strNewName
End Function
sub destroyAll
'If it's a recordset and open, close it
if TypeName(objRS) = "Recordset" then
if objRS.state <> adStateClosed then
objRS.close
end if
end if
'If it's a connection and open, close it
if TypeName(objConn) = "Connection" then
if objConn.state <> adStateClosed then
objConn.close
end if
end if
set objRS = nothing 'Dereference Recordset
set objConn = nothing 'Dereference Connection
end sub
%>
<%
Dim iCategoryID
iCategoryID = 211
%>
<%
Dim strSQL, objRS
Dim strProductCategoryID, fCategoryIDID, strProductCategory, strProductCategoryLink, strCategoryLinkDisplay, strCatLongDescription, strProductImage, strCatMetaDescription, strCatMetaKeywords
'Open the rs and retrieve the category
strSQL = "SELECT * FROM tblProductCategory WHERE CategoryID = " & iCategoryID & " OR ParentCategory = " & iCategoryID & ""
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, objConn, , adLockReadOnly
'retreive the values of the category
Dim arrCategorys
If Not objRS.EOF Then
arrCategorys = objRS.GetRows()
End If
objRS.Close
'loop through the array to set the current category
Dim iLoop2, ParentCategoryID, strCatShortDescription
For iLoop2 = 0 to UBound(arrCategorys, 2)
If arrCategorys(0, iLoop2) = iCategoryID then
ParentCategoryID = arrCategorys(1, iLoop2)
strProductCategory = arrCategorys(2, iLoop2)
strProductCategoryLink = arrCategorys(3, iLoop2)
strCategoryLinkDisplay = arrCategorys(4, iLoop2)
strCatLongDescription = arrCategorys(5, iLoop2)
strCatLongDescription = arrCategorys(6, iLoop2)
strProductImage = arrCategorys(7, iLoop2)
strMetaDescription = arrCategorys(8, iLoop2)
strMetaKeywords = arrCategorys(9, iLoop2)
End If
Next
''If the there is a parent category, then extract the link
' Dim strParentCategory, strParentCategoryLink
'If ParentCategoryID <> "" and ParentCategoryID <> 0 Then
' strSQL = "SELECT CategoryID, CategoryName, CategoryLink FROM tblProductCategory WHERE CategoryID = " & ParentCategoryID & ""
' objRS.Open strSQL, objConn, , adlockOptimistic
'If Not objRS.EOF Then
' strParentCategory = objRS("CategoryName")
' strParentCategoryLink = objRS("CategoryLink")
' End If
' objRS.Close
' End IF
'set the navigation links
' Dim strTopLink
' If strParentCategory <> "" Then
' strTopLink = "" & strParentCategory & " > " & strProductCategory
' Else
'strTopLink = strProductCategory
' End If
'open up the product recordset
strSQL = "SELECT ProductID, fCategoryID, ProductTitle, ProductShortDescription, ProductLongDescription, ProductLInk, RecommendedPrice, ProductPrice, ThumbImage, fShippingID, ShippingID, ShippingCost, ProductStatus FROM tblProducts, tblShippingCodes WHERE fCategoryID = " & iCategoryID & " AND ProductStatus = 'ON' AND ShippingID = fShippingID ORDER BY ProductPrice"
Set objRS = Server.CreateObject("ADODB.Recordset")
'set cursor location so we can page through resulults
objRS.CursorLocation = adUseClient
objRS.PageSize = 20
'open the rs
objRS.Open strSQL, objConn, , adLockReadOnly
'set thye current page of records
Dim iCurrentPage
iCurrentPage = Request("qPageNumber")
If iCurrentPage = "" Then
iCurrentPage = 1
End If
If Not objRS.EOF Then
objRS.AbsolutePage = iCurrentPage
End If
'populate array with the products for the navigation
Dim objProductList, strProductSQL
strProductSQL = "SELECT ProductLInk, ProductLInkDisplay, fCategoryID, ProductStatus, ProductLongDescription, ProductPrice FROM tblProducts WHERE fCategoryID = " & CInt(iCategoryID) & " AND ProductStatus = 'ON' AND ProductLongDescription <> '????' ORDER BY ProductPrice "
Set objProductList = Server.CreateObject("ADODB.Recordset")
objProductList.Open strProductSQL, objConn, , adLockReadOnly
'Mumber of records to diaplay
Dim iCount, arrProdList
If Not objProductList.EOF Then
arrProdList = objProductList.GetRows()
End IF
objProductList.Close
Set objProductList = Nothing
'set var for meta tgas
Dim strMetaDescription, strMetaKeywords
dim iLoop
%>
<%=strProductCategory%>
[an error occurred while processing this directive]
<%
If Not isArray(Application("appProductCategories")) Then
subCreateCategoryApp
End If
%>
IN THE STORE...
<%
Dim strNavLink
If IsArray(Application("appProductCategories")) Then
For iLoop = 0 to UBound(Application("appProductCategories"), 2)
If IsNUll(Application("appProductCategories") (1, iLoop)) Then
strNavLink = Application("appProductCategories") (0, iLoop)
Else
strNavLink = Application("appProductCategories") (1, iLoop)
End If
%>
<%'#################################################### NEW MAIN CELL ########################################################%>
<%=strProductCategory%>
<%
'if there is a category description then display
If strCatLongDescription <> "" AND iCurrentPage = 1 Then
'if there is an image, then diaply it
If strProductImage = "yes" AND iCurrentPage = 1 Then
Response.write ""
End If
'write the description
Response.write "
"
'end of display category description cell
End IF
'if there is a sub category then display
If UBound(arrCategorys, 2) > 0 Then
For iLoop2 = 0 to UBound(arrCategorys, 2)
If arrCategorys(1, iLoop2) = iCategoryID Then
%>
<%
'if there is an image for the sub category, then diaply it
If arrCategorys(7, iLoop2) = "yes" Then
Response.write Space(7) & ""
End If
'dispaly the sub category title
Response.write Space(7) & "" & arrCategorys(4, iLoop2) & ""
'if there is a sub category short description, then diaply it
If arrCategorys(5, iLoop2) <> "" Then
Response.write Space(10) & " " & Replace(arrCategorys(5, iLoop2), vbCrLf, " ")
End If
%>
<%
'end of siaply sub cat cell
End If
Next
End If
'display the products, 10 per page
If Not objRS.EOF Then
'set the row count
Dim iRowCount, iRecordNumber
'set the rrecord number
iRecordNumber = Cint((objRS.AbsolutePage - 1) & 1)
'set the row count
iRowCount = 1
Do while Not objRS.EOF and iRowCount < objRS.PageSize + 1
%>
<%=iRecordNumber%>.
<%
'if there is a long description, then diaplay link
If objRS("ProductLongDescription") <> "????" Then
%>
.asp" class="prod"><%=objRS("ProductTitle")%>
<%
Else
%>
<%=objRS("ProductTitle")%>.
<%
'end if long description links
End If
'display the short description
response.Write(" ")
response.write funInsertBreak(objRS("ProductShortDescription"))
%>
<%
'If there is a recommended price, display it
If objRS("RecommendedPrice") <> "" AND objRS("RecommendedPrice") <> 0 Then
%>
LIST:
<%=FormatCurrency(objRS("RecommendedPrice"))%>
<%
'end display recommended price
End If
'display the price if it not 0
If objRS("ProductPrice") <> 0 Then
%>
<%
objRS.MoveNext
iRowCount = iRowCount + 1
iRecordNumber = iRecordNumber + 1
Loop
End If
'if there is more than 1 page, then display the links
If objRS.PageCount > 1 Then
%>
<%
'if the page count is greater than the 1, then create the next page
If CInt(iCurrentPage) > 1 Then
Dim iPreviousPage
iPreviousPage = iCurrentPage - 1
%>
">
<%
End If
%>
<%
'if the page count is greater than the 1, then create the next page
If objRS.PageCount > Cint(iCurrentPage) and CInt(iCurrentPage) < objRS.PageCount Then
Dim iNextPage
iNextPage = iCurrentPage + 1
%>
">
<%
End If
%>
<%
'end diaplay page count links
End IF
'close the connection
objRS.Close
Set objRS = Nothing
%>
<%'#################################################### END NEW MAIN CELL ########################################################%>
Croquet Online, Unit 1,The Vennland Centre, Vennland Way, Minehead, Somerset, TA24 5DX Telephone 01643 703447 Fax: 01643 706734