% '============================================================== ' This file contains the database configuration. It also opens ' a connection object (Conn) using OpenCnx. ' The file also contains some common function. '============================================================== 'Global scope variables: Dim conn 'Connection object Dim dbPassword 'Database password '=========================================================== ' Sub: OpenCnx ' Desc: 'Opens connection conn if it is not already open. ' >>> Please, modify configuration with correct values <<< '=========================================================== Sub OpenCnx (ByRef conn) If NOT IsObject(conn) Then On Error Resume Next Dim ConnStr 'Connection string Dim dbPassword 'Database password Set conn = Server.CreateObject("ADODB.Connection") dbPassword = "QS2003p" ' <<<< Change any new Access database password here. '------------------------------------------------------- 'Pick ONE of the following configurations and comment the others 'For additional tech. info see ' - http://www.able-consulting.com/ADO_Conn.htm '------------------------------------------------------- '1. Configuration for System DSN 'ConnStr = "DSN=DSN_Name;uid=;pwd=" & dbPassword '2. Configuration for file DSN (DSN-Less) 'ConnStr = "DBQ=d:\inetpub\quadcomm.com\db\store.mdb;Driver={Microsoft Access Driver (*.mdb)};uid=;pwd=" & dbPassword '3. Configuration for OLEDB drivers (more efficient) 'a) Example of OLEDB connection with OLEDB 3.51 (if you have to use this one you may want to 'consider installing a newer version of MDAC 'ConnStr = "Provider=Microsoft.Jet.OLEDB.3.51; Data Source=C:\web\quadcomm\db\store.mdb; Jet OLEDB:Database Password=" & dbPassword 'b)Example of OLEDB connection on Windows 2000 server (version 4.0) 'ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\web\quadcomm\db\store.mdb; Jet OLEDB:Database Password=" & dbPassword ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Web\starquestpublishing\db\store2K.mdb; Jet OLEDB:Database Password=" & dbPassword 'c)Example of OLEDB connection on Windows 2000 server (version 4.0) and MS SQL Server 7.0/2000 'ConnStr = "Provider=SQLOLEDB; Data Source=(local); Initial Catalog=QShopDB; User ID=qshop_usr; Password=" & dbPassword 'ConnStr = "Provider=SQLOLEDB; Data Source=(local); Initial Catalog=Q-Shop; User ID=sa; Password=" '------------------------------------------------------- conn.open ConnStr 'Open connection object '------------------------------------------------------- 'When the site is working we recommend you to comment 'Option 1 and uncomment option 2 '------------------------------------------------------- If conn.errors.count > 0 then Dim counter For counter = 0 to conn.errors.count-1 If int(conn.errors(counter).number) <> 0 Then ' Option 1 response.write "Error # :" & conn.errors(counter).number & "
" response.write "Error desc. : " & conn.errors(counter).description & "
" If conn.errors(counter).number = -2147467259 Then response.write "Suggestion: Check the connection string ConnStr in conx.asp and make sure that only one option is not commented using '.
"
End If
set conn = nothing
Response.End
'Option 2
'Redirect user to an error page if there is a connetion error.
set conn = nothing
Response.Redirect("connerror.htm")
Response.End
End If
next
conn.errors.Clear
End If
'If you leave the following line commented, all errors will be by-passed unless there is
'a line like this somewhere in the code.
On Error Goto 0
End If
End Sub
'===========================================================
' Sub: CloseCnx
' Desc: Closes and destroys connection object "conn".
'===========================================================
Sub CloseCnx (ByRef conn)
If IsObject(conn) Then
conn.close
set conn = nothing
End If
End Sub
'========================================================================
' Basic Currency Functions
'===========================================================
' Function: FormatPrice
' Desc: Returns a price formatted including taxes when tax
' model is EU and Show_VAT is enabled.
'===========================================================
Function FormatPrice (ByVal nCost, ByVal nTax, ByVal nTaxable)
If IsNumeric(nCost) Then
If Tax_ShowVAT = 1 AND Tax_Model = "EU" AND nTaxable = 1 Then
FormatPrice = FormatNumber(nCost * (1+nTax/100.0),2)
Else
FormatPrice = FormatNumber(nCost,2)
End If
Else
FormatPrice = "Error!"
End If
End Function
'===========================================================
' Function: FormatDefCurr (num)
' Desc: Returns a price formatted as currency using the default
' currency settings.
'===========================================================
Function FormatDefCurr (num)
'Formats a number (num) as a currency figure with 2 decimal digits
If IsNumeric(num) Then
FormatDefCurr = Replace(shop_DefCurName,"#",FormatNumber(num,2))
Else
FormatDefCurr = "Error!"
End If
End Function
'===========================================================
' Function: FormatSecCurr (ByVal num)
' Desc: Returns a price converted and formatted as currency
' using the secondary currency settings.
'===========================================================
Function FormatSecCurr (ByVal num)
'Converts and formats a number (num) as a secondary currency figure with 2 decimal digits
If IsNumeric(num) Then
FormatSecCurr = Replace(shop_SecCurName,"#",FormatNumber (num / (CDbl(shop_SecCurConv)),2))
Else
FormatDefCurr = "Error!"
End If
End Function
'===========================================================
' Function not currently used
'===========================================================
'Function FormatDefCurrTax (ByVal nCost, ByVal nTaxRate)
' If IsNumeric(nCost) AND IsNumeric(nTaxRate) Then
' FormatDefCurrTax = FormatDefCurr(nCost*(1+ntaxrate/100.0))
' Else
' FormatDefCurrTax = "Error!"
' End If
'End Function
'===========================================================
' Function: GetDBCurrentDateTime
' Desc: Returns the current date and time in a format
' accepted by the current database (Access or SQL Server)
'===========================================================
Function GetDBCurrentDateTime
Dim strDateDelim, dtDate
If shop_DB = "SQL" Then
strDateDelim = "" 'MS SQL Server
dtDate = "GETDATE()"
Else
strDateDelim = "#" 'MS Access
'Use with Access: It must be in US format MM/DD/YY regardless of local settings.
dtDate = Month(Date) & "/" & Day(Date) & "/" & Year(Date) & " " & Time
End If
'Build and return final date/time
GetDBCurrentDateTime = strDateDelim & dtDate & strDateDelim
End Function
'===========================================================
' Function: ParseInj
' Desc: Parses a string for SQL injection attacks.
'===========================================================
Function ParseInj(strIn)
ParseInj = Replace(strIn, "'", "''")
End Function
'===========================================================
' Function: RemoveHTML
' Desc: Removes HTML tags from a string
'===========================================================
Function RemoveHTML(sText)
Dim RegEx
Set RegEx = New RegExp
RegEx.Pattern = "<[^>]*>"
RegEx.Global = True
RegEx.IgnoreCase = True
RemoveHTML = RegEx.Replace(sText, "")
End Function
'========================================
'Create connection object
Call OpenCnx (conn)
'========================================
%>
<%
'-----------------------------------------------------------
' Q-Shop Parameter/Settings definition
' Developed by QuadComm Inc. for use with Q-Shop
' © Copyright QuadComm, Inc. 2003. All rights reserved
'-----------------------------------------------------------
'========================================================================
' CONSTANTS HARDCODED
'========================================================================
'=========================================
'Collect Credit Card Details
'=========================================
Dim bCollectCCDetails 'Indicates whether credit card details fields should be shown
'If True CC fields are collected and saved to the database (True|False)
'Use True when processing credit cards manually
'Choose of the two options and comment the other one:
bCollectCCDetails = False 'Display CC details fields
'bCollectCCDetails = True 'Don't display CC details fields
'=========================================
'=========================================
'Paypal configuration
'=========================================
Dim bEnablePaypal 'When True a paypal option will be displayed (True|False). (default is False)
'Choose of the two options and comment the other one:
bEnablePaypal = True 'Enable Paypal
'bEnablePaypal = False 'Disable Paypal
'=========================================
'=========================================
'Cash on Delivery (COD) configuration
'=========================================
Dim bEnableCOD 'When True a COD option will be displayed (True|False). (default is True)
'Choose of the two options and comment the other one:
'bEnableCOD = True 'Enable COD
bEnableCOD = False 'Disable COD
'=========================================
'=========================================
'External payment gateway link configuration
'=========================================
Dim bExtGateway 'Indicates whether the credit card payment is processed in an external site
'If True the credit card options including details won't be shown. (True|False)
'Choose of the two options and comment the other one:
'bExtGateway = True 'Use external gateway
bExtGateway = False 'No external gateway
'=========================================
'=========================================
'CC extra fields configuration
'=========================================
Dim bShow_CCIssueNumber 'Display issue number field? (True|False)
bShow_CCIssueNumber = False
Dim bShow_CVV 'Display CVV number field? (True|False)
bShow_CVV = True
Dim bShow_L4SSN 'Display last 4 SNN digits field? (True|False)
bShow_L4SSN = False 'Used for Transact-Secure with Authorize.Net
'=========================================
'=========================================
'Order email confirmation
'=========================================
Dim bSendMailConf 'Defines whether a mail confirmation should be sent (True|False). Default to True
bSendMailConf = True 'Default True: Send email confirmation message.
'========================================================================
'Get secure URL details. If there is a secure URL get the non-secure as well.
'========================================================================
Dim strNonSecPath
Dim strSecPath
strSecPath = Application("SECUREURL")
If strSecPath <> "" Then strNonSecPath = Application("URL")
'Hardcode if necessary:
'strSecPath = "https://www.secure-us.net/quadcomm/demo/"
'strNonSecPath = "http://quadcomm.com/demo/"
'========================================================================
'========================================================================
' Logo file paths. If you need to have content other than images, you can
' hardcode the value here.
'========================================================================
Dim LogoURL, smLogoURL, LineLogoURL
'URL of the main logo. Double quote all quote characters
'LogoURL = ""
If Application("LogoURL") <> "" Then
LogoURL = "
"
Else
LogoURL = ""
End If
'URL of the small logo on the left-hand side bar. Double quote all quote characters
'smLogoURL = "
"
If Application("smLogoURL") <> "" Then
smLogoURL = "
"
Else
smLogoURL = ""
End If
'URL of the small logo displayed when a product has no picture (called in inc/line.asp). Double quote all quote characters. This could also be text or HTML code.
'LineLogoURL = "
"
If Application("NotAvailImg") <> "" Then
LineLogoURL = "
"
Else
LineLogoURL = "(No image)"
End If
'========================================================================
'========================================================================
Dim MaxItems 'Defines the maximum number of products per page when
'browsing products in the shop
'========================================================================
MaxItems = 20 'Maximum number of items displayed at once
'========================================================================
'Set browse layout types: S (single), M (multiple)
' Single: Each product has its own add to cart button
' Multiple: All products in a page share an add to cart button so that
' multiple products can be added to the cart at the same time.
'========================================================================
Dim sBrowseSearch 'Browse type for products page
Dim sBrowseOffer 'Browse type for Offers page
Dim sBrowseManu 'Browse type for Manufacturers page
Dim sBrowseFeat 'Browse type for Featured Products page
Dim sBrowseMyList 'Browse type for My List page
sBrowseSearch = "S" 'Browse search results
sBrowseOffer = "M" 'Browse offers page
sBrowseManu = "S" 'Browse by brands/manufacturer list page
sBrowseFeat = "M" 'Browse featured products
sBrowseMyList = "M" 'Browse type for My List page
'========================================================================
'========================================================================
' Related Products Parameters (used in details.asp)
'========================================================================
Dim RelProdsLayout 'Related Products Layout
Dim RelProdsTableColumns 'Number of related products per line when using "Thumbnail" layout
RelProdsLayout = "Thumbnail" '(Thumbnail|List)
RelProdsTableColumns = 3
'========================================================================
'========================================================================
' Email confirmation settings
'========================================================================
Dim sMailFormat 'Related Products Layout (TEXT|HTML)
sMailFormat = "TEXT" '(TEXT|HTML)
'sMailFormat = "HTML" '(TEXT|HTML)
'========================================================================
'========================================================================
' CONSTANTS LOADED DYNAMICALLY FROM DB, ETC.
'========================================================================
' You shouldn't edit the parameters below in normall circumstances
' unless you want to override the default way of loading them via the
' database and the control panel.
'========================================================================
'========================================================================
' Shop Settings definitions
'========================================================================
Dim shop_DefCurName, shop_SecCurName, shop_SecCurConv, shop_CompanyName, shop_Mail, shop_Title, shop_StockControl
Dim shop_DB, shop_MailSystem, shop_URL, shop_ShowTerms
Dim shop_TempPath
'Temporary folder (to write temporary files). This folder requires write permissions
'for the IUSR_
"
End If
WritePriceOptionsPrintable = strTemp
End Function
'=========================================================================
' Function: UnitPrs
' Returns units description. Currently only 1 is used
'=========================================================================
Function UnitPrs (cod)
if cod = 1 Then UnitPrs = "Unit/s"
if cod = 2 Then UnitPrs = "gr."
if cod = 3 Then UnitPrs = "Kg."
End Function
'=========================================================================
' Function: CutRFWord
' Trim and cut to nlength craracters max the Request.Form(name) passed.
'=========================================================================
Function CutRFWord (name, nlength)
Dim sTmp
sTmp = Left(Trim(Request.Form(name)),nlength)
If sTmp <> "" Then
CutRFWord = sTmp
Else
CutRFWord = Null
End If
End Function
'=========================================================================
' Function: ProdName
' Returns the name of a product with id cod
'=========================================================================
Function ProdName (cod)
Dim rs, sql
Set rs = Server.CreateObject("ADODB.Recordset")
sql= "SELECT Name FROM products WHERE ProdID = '" & cod & "'"
rs.Open sql,Conn, adOpenStatic, adLockOptimistic
If rs.EOF AND rs.BOF Then
ProdName = "Product deleted"
else
ProdName = rs("Name")
End If
rs.Close
set rs = nothing
End Function
'=========================================================================
' Function: DeleteCart
' Deletes cart with ID IDCart
'=========================================================================
Function DeleteCart (IDCart)
Dim rs, sql
sql= "DELETE FROM Carts WHERE CartID = '" & IDCart & "'"
set rs = Conn.Execute(sql)
set rs = nothing
End Function
'=========================================================================
' Function: CreateOrder
' Creates order from cart with ID = IDCart in the orders/orderlines tables
'Uses from form:
'TotalTax: Total taxes
'ShipCost: Shipping costr
'e-mail: Email address
'Password: Password
'Billing details
'Name: Customer's Name
'Surname: Customer's Surname
'Company: Customer's Company name
'Address: Customer's Address part 1
'Address2: Customer's Address part 2
'CP: Customer's Post Code/ZIP
'Town: Customer's City/Town
'Province: Customer's State or Province
'Country: Customer's Country
'Telephone: Customer's Telephone number
'mailme: Is customer subscribing to receive news and notifications? (True/False)
'rememberme:Does customer want to be logged in automatically next time? (True/False)
'Shipping/Recepient details
'DName: Ship to Name
'DAddress: Ship to Address part 1
'DAddress2: Ship to Address part 2
'DCompany: Ship to Company
'DCP: Ship to Post Code/ZIP
'DTown: Ship to City/Town
'DProvince: Ship to State or Province
'DTelephone:Ship to Telephone number
'DCountry: Ship to Country
'
'payment: Payment type (VISA,COD, etc)
'CCOwner Name on Credit Card
'CCNumber: Credit Card Number
'CCExpDateMonth: Credit Card Expiration date month
'CCExpDateYear: Credit Card Expiration date year
'CCIssueNumber: Credit Card Issue Number
'CCCVV: Credit Card verification number
'TaxId: Tax code (Tax ID) (eg VAT number)
'strUPS: String returned by UPS real time calculation module
'
'Comments: Customer order comments.
'Uses variables from prochkoutend.asp:
'PriceT: Products total cost
'Taxes: Order tax
'TotalTax: Tax rate
'ShipCost: Shipping cost applied
'PriceTG: Order total
'WeightT: Total products weight
'=========================================================================
Function CreateOrder (IDCart)
Dim rs, rsh, rsu, rsl, rsoid
Dim sql
Dim NewUSer
Dim OrderID
'Get cart
Set rs = Server.CreateObject("ADODB.Recordset")
sql= "SELECT Carts.*, Products.Name, PriceOptions.Description As PODescription " & _
"FROM (Carts INNER JOIN Products ON Carts.ProdID = Products.ProdID) " & _
"LEFT OUTER JOIN PriceOptions ON Carts.PriceOption = PriceOptions.id " & _
"WHERE CartID = '" & IDCart & "'"
rs.Open sql, Conn, adOpenStatic, adLockOptimistic
'Orders Headers DB: rsh
'Note: We query an impossible record to correct a possible
'wrong behaviour with Microsoft's DB drivers
Set rsh = Server.CreateObject("ADODB.Recordset")
rsh.Open "SELECT * from Orders WHERE (0 = 1)", Conn, adOpenKeySet, adLockOptimistic
'OrderLines DB: rsl
Set rsl = Server.CreateObject("ADODB.Recordset")
rsl.Open "SELECT * from Orderlines WHERE (0 = 1)", Conn, adOpenStatic, adLockOptimistic
'User Data: rsu
Set rsu = Server.CreateObject("ADODB.Recordset")
rsu.Open "SELECT * from Users WHERE UserID ='" & UserID & "'", Conn, adOpenStatic, adLockOptimistic
If rsu.EOF AND rsu.BOF Then
'If no data found create a new one
NewUSer = True
rsu.Close
rsu.Open "SELECT * from Users WHERE (1=0)", Conn, adOpenStatic, adLockOptimistic
Else
NewUser = False
End If
If NewUSer then rsu.AddNew
rsu("UserID") = UserID
If Request("Company") <> "" Then
rsu("Company") = CutRFWord("Company",50)
Else
rsu("Company") = Null
End If
rsu("Name") = CutRFWord("Name",50)
rsu("Surname") = CutRFWord("Surname",50)
rsu("Address") = CutRFWord("Address",100)
rsu("Address2") = CutRFWord("Address2",100)
rsu("CP") = CutRFWord("CP",10)
rsu("City") = CutRFWord("Town",50)
If Trim(Request.Form("Province")) <> "" Then rsu("Province") = CutRFWord("Province",50)
rsu("Country") = CutRFWord("Country",20)
If Trim(Request.Form("Telephone")) <> "" Then rsu("Phone") = CutRFWord("Telephone",50)
If Request.Form("e-mail") <> "" Then
rsu("mail") = CutRFWord("e-mail",100)
If Request.Form("mailme") = "yes" Then
rsu("mailme") = 1
else
rsu("mailme") = 0
End If
else
rsu("mailme") = 0
End If
If Request.Form("rememberme") = "yes" Then
rsu("rememberme") = 1
Else
rsu("rememberme") = 0
End If
rsu("Date") = Now
'If is a new user and has chosen a password (error if not) and is not logged (extra check) then
'use the suggested password
If NewUser AND (NOT Session("Logged")) AND Request.Form("Password") <> "" Then
rsu("pwd") = Request.Form("Password")
End If
' If IsNull(rsu("pwd")) AND Session("uPwd")<> "" Then rsu("pwd") = Session("uPwd")
rsu("LastVisit") = Date
Session("DateUpdated") = True
rsu.Update
rsu.Close
set rsu = nothing
rsh.AddNew
rsh("UserID") = UserID
rsh("CartID") = CartID
rsh("Date") = Now 'Formatdatetime(now(),2)
'Customer details
If Trim(Request.Form("Company")) <> "" Then rsh("Company") = CutRFWord("Company",100)
rsh("Name") = CutRFWord("Name",50)
rsh("Surname") = CutRFWord("Surname",50)
rsh("Address") = CutRFWord("Address",100)
rsh("Address2") = CutRFWord("Address2",100)
rsh("CP") = CutRFWord("CP",10)
rsh("City") = CutRFWord("Town",50)
if Request.Form("Province") <> "" Then rsh("Province") = CutRFWord("Province",50)
If Request.Form("Telephone") <> "" Then rsh("Phone") = CutRFWord("Telephone",50)
rsh("mail") = CutRFWord("e-mail",100)
rsh("Country") = CutRFWord("Country",20)
'Delivery Details
If Trim(Request.Form("DName")) <> "" Then rsh("DName") = CutRFWord("DName",100)
If Trim(Request.Form("DAddress")) <> "" Then rsh("DAddress") = CutRFWord("DAddress",100)
If Trim(Request.Form("DAddress2")) <> "" Then rsh("DAddress2") = CutRFWord("DAddress2",100)
If Trim(Request.Form("DCompany")) <> "" Then rsh("DCompany") = CutRFWord("DCompany",100)
If Trim(Request.Form("DCP")) <> "" Then rsh("DCP") = CutRFWord("DCP",10)
If Trim(Request.Form("DTown")) <> "" Then rsh("DCity") = CutRFWord("DTown",50)
If Trim(Request.Form("DProvince")) <> "" Then rsh("DProvince") = CutRFWord("DProvince",50)
If Trim(Request.Form("DTelephone")) <> "" Then rsh("DPhone") = CutRFWord("DTelephone",50)
If Trim(Request.Form("DCountry")) <> "" Then rsh("DCountry") = CutRFWord("DCountry",20)
'Costs
rsh("SubTotal") = CDbl(PriceT)
rsh("Taxes") = Taxes
rsh("TotalTax") = TotalTax
rsh("Delivery") = ShipCost
rsh("Total") = CDbl(PriceTG)
If CStr(WeightT) <> "" Then
rsh("Weight") = CDbl(WeightT)
else
rsh("Weight") = 0
End If
'Store user discount value.
rsh("UserDiscount") = nUrDiscountTotal
'====================================
' Order status and billing status
' Change the default values at the top
'====================================
' Set the status of new orders.
rsh("Status") = N_STATUS_NEWORDER
' Set the billing status of new orders.
rsh("BillingStatus") = N_BILLINGSTATUS_NEWORDER
'Payment method
rsh("PaymentMode") = CutRFWord("payment",50)
'Credit card details stored if there is an owner name (CCOwner).
If Request.Form("CCOwner") <> "" Then
rsh("CCOwner") = CutRFWord("CCOwner",100)
'Remove spaces and "-".
Dim sEncCCNumber
sEncCCNumber = Replace(Replace(CutRFWord("CCNumber",40)," ",""),"-","")
'Encrypt and encode into HEX string to be safely stored
sEncCCNumber = EncryptAndEncode(sEncCCNumber)
'rsh("CCNumber") = Replace(Replace(CutRFWord("CCNumber",40)," ",""),"-","")
rsh("CCNumber") = sEncCCNumber 'Store the encrypted and encoded in Hex string CC number
rsh("CCExpDate") = EncryptAndEncode(CutRFWord("CCExpDateMonth",2) & "/" & Right(Request.Form("CCExpDateYear"),2))
If Request.Form("CCIssueNumber") <> "" Then
rsh("CCIssueNumber") = CutRFWord("CCIssueNumber",10)
End If
'Get CVV number (from back of some cards). Cut to 7 characters.
If CutRFWord("CCCVV",7) <> "" Then
rsh("CCCVV") = CutRFWord("CCCVV",7)
End If
End If
'UPS returned values. Store here if adding another external company system.
If Request.Form("strUPS") <> "" Then
rsh("Shipping") = CutRFWord("strUPS",50)
End If
'VAT number used in European Union to allow tax exemption for companies
If Request.Form("TaxId") <> "" Then
rsh("TaxID") = CutRFWord("TaxId",100)
End If
'Transaction values return in real time payment processing like Authorize.Net.
If strTrans <> "" Then
rsh("TransactionData") = Left(strTrans,150)
End If
'User comments
If Trim(Request.Form("Comments")) <> "" Then rsh("Comments") = Request.Form("Comments")
'User IP address stored as security meassure.
rsh("RemoteIP") = LEFT(Request.ServerVariables("REMOTE_ADDR"),15)
'Save details
rsh.Update
'Obtain the order Id generated automatically by the database
OrderID = rsh("Id")
rsh.Close
set rsh = nothing
'If the Order id wasn't retrieved correctly, attempt to query the record using the combination
'of Cart Id and User Id. This code should not get to be executed in a normal installation!.
If CStr(orderID) = "" Then
set rsoid = conn.Execute ("SELECT Id FROM orders WHERE UserID = '" & UserID & "' AND CartId = '" & CartID & "' ORDER BY Id DESC")
If rsoid.EOF and rsoid.BOF Then
set rsoid = nothing
%>
Fatal Error occurred, please contact shop administrator. Your order ID could not be retrieved
[an error occurred while processing this directive]