<% @Language=VBScript %> <% '============================================================== ' 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_ user (used by the web server). shop_TempPath = Application("TempPath") '***** CONFIGURE IN CONTROL PANEL ***** ' Currency shop_DefCurName = Application("DefCurName") shop_SecCurName = Application("SecCurName") shop_SecCurConv = Application("SecCurConv") 'Others shop_CompanyName = Application("CompanyName") shop_Mail = Application("Mail") shop_Title = Application("Title") If Application("ShowTerms") = "1" Then shop_ShowTerms = True Else shop_ShowTerms = False End If If Application("StockControl") = "1" Then shop_StockControl = True Else shop_StockControl = False End If shop_DB = Application("DBSystem") shop_MailSystem = Application("MailSystem") shop_URL = Application("URL") 'Shop base URL. 'If the URL doesn't end with "/" add it: If RIGHT(shop_URL,1) <> "/" Then shop_URL = shop_URL & "/" 'Colour settings Dim CART_HEAD_BG, CART_HEAD_FONT, CART_BODY_BG, LMENU_BG, LMENU_FONT, LMENU_SUB_FONT, TMENU_BG Dim TMENU_FONT, SEC_BG, SEC_FONT, DETAILS_BG, DETAILS_HEAD_BG, DETAILS_HEAD_FONT CART_HEAD_BG = Application("CART_HEAD_BG") CART_HEAD_FONT = Application("CART_HEAD_FONT") CART_BODY_BG = Application("CART_BODY_BG") LMENU_BG = Application("LMENU_BG") LMENU_FONT = Application("LMENU_FONT") LMENU_SUB_FONT = Application("LMENU_SUB_FONT") TMENU_BG = Application("TMENU_BG") TMENU_FONT = Application("TMENU_FONT") SEC_BG = Application("SEC_BG") SEC_FONT = Application("SEC_FONT") DETAILS_BG = Application("DETAILS_BG") DETAILS_HEAD_BG = Application("DETAILS_HEAD_BG") DETAILS_HEAD_FONT = Application("DETAILS_HEAD_FONT") 'Tax Settings Dim Tax_Model, Tax_ShowVAT Tax_Model = Application("Tax_Model") 'EU, US or CAN supported Tax_ShowVAT = Application("Tax_ShowVAT") '1: Show VAT included. '======================================================================== ' DB Constant definitions (From adovbs.inc) ' Remove if including adovbs.inc '======================================================================== '---- CursorTypeEnum Values ---- Const adOpenForwardOnly = 0 Const adOpenKeyset = 1 Const adOpenDynamic = 2 Const adOpenStatic = 3 '---- LockTypeEnum Values ---- Const adLockReadOnly = 1 Const adLockPessimistic = 2 Const adLockOptimistic = 3 Const adLockBatchOptimistic = 4 '---- CursorLocationEnum Values ---- Const adUseServer = 2 Const adUseClient = 3 '---- Other ---- Const adExecuteNoRecords = &H00000080 %> <% Function GenerateUserId 'Generates a user Id that is not already in the database. Dim sUserId, IsValidNew IsValidNew = False sUserId = "" While NOT IsValidNew 'Generate a new Id (10 digits = 22,809,600,000,000 possible combinations Randomize sUserId = chr (int( 20 * Rnd +65 )) & _ chr (int( 20 * Rnd +65 )) & _ int ( 9 * Rnd + 1) & _ chr (int( 20 * Rnd +65 )) & _ chr (int( 20 * Rnd +65 )) & _ chr (int( 20 * Rnd +65 )) & _ int ( 9 * Rnd + 1) & _ chr (int( 20 * Rnd +65 )) & _ chr (int( 20 * Rnd +65 )) & _ chr (int( 20 * Rnd +65 )) 'Query how many times the UserId is in teh database (should be 0 or 1) sql = "SELECT COUNT(*) FROM Users Where UserId = '" & sUserId & "'" Set Rs = conn.Execute (sql) If NOT (rs.EOF and rs.BOF) Then If Rs(0) = 0 Then 'Does not exist IsValidNew = True Else 'Already exists! IsValidNew = False End If Else 'If if fails to perform the operation suppose it is correct 'this is to avoid an infinite loop IsValidNew = True End If 'Close an clean up recordset rs.Close set rs = nothing Wend GenerateUserId = sUserId End Function Function CheckEmailDB (sEmail) Dim sSQL, RsEmail, bResult bResult = False sSQL = "SELECT Mail From Users where Mail = '" & Trim(sEmail) & "'" Set RsEmail = Server.CreateObject("ADODB.Recordset") Set RsEmail = conn.execute(sSQL) If RsEmail.EOF AND RsEmail.BOF Then 'E-mail does not exist in the database bResult = False Else 'E-mail does already exist" bResult = True RsEmail.Close End If set RsEmail = nothing CheckEmailDB = bResult End Function Function CheckUserId (sUserId) 'Returns True if the User Id does not exist in the database 'Returns True if the User Id exists in the database Dim sSQL, RsUser, bResult bResult = False sSQL = "SELECT UserID From Users where UserID = '" & Trim(sUserId) & "'" Set RsUser = Server.CreateObject("ADODB.Recordset") Set RsUser = conn.execute(sSQL) If RsUser.EOF AND RsUser.BOF Then 'UserID does not exist in the database bResult = False Else 'UserID does already exist" bResult = True RsUser.Close End If set RsUser = nothing CheckUserId = bResult End Function Function CheckUserEmail (sEmail) 'Returns True if the User email does not exist in the database 'Returns True if the User email exists in the database Dim sSQL, RsUser, bResult bResult = False sSQL = "SELECT mail From Users where mail = '" & Trim(sEmail) & "'" Set RsUser = Server.CreateObject("ADODB.Recordset") Set RsUser = conn.execute(sSQL) If RsUser.EOF AND RsUser.BOF Then 'UserID does not exist in the database bResult = False Else 'UserID does already exist" bResult = True RsUser.Close End If set RsUser = nothing CheckUserEmail = bResult End Function 'Updates a cart with a new User Id Sub UpdateCartUserID (sUserID, sCartID) Dim Rs, sSQL sSQL = "UPDATE Carts SET UserID = '" & sUserID & "' WHERE CartID = '" & sCartID & "'" Set Rs = Server.CreateObject("ADODB.Recordset") set Rs = conn.execute(sSQL) set Rs = nothing End Sub 'Updates "My List" with a new User Id Sub UpdateMyListUserID (sOldUserID, sNewUserID) Dim Rs, sSQL sSQL = "UPDATE CommonList SET UserID = '" & sNewUserID & "' WHERE UserID = '" & sOldUserID & "'" Set Rs = Server.CreateObject("ADODB.Recordset") set Rs = conn.execute(sSQL) set Rs = nothing End Sub Sub ResetUser 'Reset User ID on Session and create a new one, reset user details as well. 'Write the new User ID to a cookie 'It also updates the cart items with the new UserID. Dim oUserID 'Old user ID Dim Rs oUserID = Session("UserID") 'Obtain User Id from the cookie Session("Logged") = False 'Log user out Session("UserID") = GenerateUserId 'Generate new User Id Session("Cookie")= 0 'This will force to write a cookie with the new id. 'Reset user information Session("Name") = Null Session("Surname") = Null Session("Mail") = Null Session("Country") = Null Session("UserDiscount") = 0 If Application("Tax_Model") = "EU" Then Session("TaxID") = Null On Error Resume Next 'Update the cart with the new UserID (in case the user had added something) Set Rs = Server.CreateObject("ADODB.Recordset") set Rs = conn.execute("UPDATE Carts SET UserID = '" & Session("UserID") & "' WHERE CartID = '" & Session("CartID") & "'") set Rs = nothing End Sub Sub WriteUserIdCookie (sUserId) 'Writes the UserID Cookie Response.Cookies("UserID") = sUserId 'Sets expiry date Response.Cookies("UserID").Expires = Date + 180 '6 months to expire (6*30 = 180 days) 'Example of fixed date: "1 Dec 1999" 'Saves the cookie state as "Written to client" Session("Cookie") = 1 End Sub Sub UpdateLastVisit (sUserId) ' Updates the LastVisit field in the database Dim Rs, sql, dtDate, strDateSep ' If NOT Session("DateUpdated") Then If shop_DB = "SQL" Then strDateSep = "'" 'MS SQL Server 'Get the date in an international format YYYY-MM-DD recognised by SQL Server dtDate = Year(Date) & "-" & Month(Date) & "-" & Day(Date) Else strDateSep = "#" '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) End If sql = "UPDATE Users SET LastVisit = " & strDateSep & dtdate & strDateSep & " WHERE UserID = '" & sUserId & "'" conn.execute sql 'Update this variable so we don't update the date again during this session Session("DateUpdated") = True ' End If End Sub Function CleanLoginPwd (sText) ' Cleans a text to be used as login or password to avoid SQL injection attacks. Dim sCleanText sCleanText = Replace(sText, "'", "") sCleanText = Replace(sCleanText, """", "") sCleanText = Replace(sCleanText, " ", "") sCleanText = Trim(sCleanText) CleanLoginPwd = sCleanText End Function %> <% '==================================================== ' CDO CONSTANTS ' Constants used by CDO Library on Win2K and XP '==================================================== Const cdoSendUsingPickup = 1 Const cdoSendUsingPort = 2 Const cdoAnonymous = 0 ' Use basic (clear-text) authentication. Const cdoBasic = 1 ' Use NTLM authentication Const cdoNTLM = 2 'NTLM %> <% '=========================================================== 'This library contains functions to send emails with CDONTS, 'JMAIL, ASPMAIL or CDOSYS (replaces CDONTS on Win XP) '=========================================================== Dim MAIL_SMTP_SERVER Dim MAIL_SMTP_USERNAME Dim MAIL_SMTP_PASSWORD MAIL_SMTP_SERVER = Application("SMTP_Server") MAIL_SMTP_USERNAME = Application("SMTP_Username") 'Only for CDOSYS MAIL_SMTP_PASSWORD = Application("SMTP_Password") 'Only for CDOSYS '===== CDONTS CONSTANTS =============================== 'Note on encoding: 'The default value for the EncodingMethod parameter can change if you set the MailFormat property. 'If MailFormat is set to CdoMailFormatText, the default value is CdoEncodingUUencode. 'If MailFormat is set to CdoMailFormatMime, the default value is CdoEncodingBase64. 'However, if you add an attachment encoded in base 64 format, the value of the MailFormat 'property is automatically set to CdoMailFormatMime. CONST CdoEncodingUUencode = 0 'The attachment is to be in UUEncode format (default). CONST CdoEncodingBase64 = 1 'The attachment is to be in Base64 format. CONST CdoMailFormatMime = 0 'The NewMail object is to be in MIME format. CONST CdoMailFormatText = 1 'The NewMail object is to be in uninterrupted plain text (default value). CONST CdoBodyFormatHTML = 0 'The Body property is to include Hypertext Markup Language (HTML). CONST CdoBodyFormatText = 1 'The Body property is to be exclusively in plain text (default value). CONST MailFormatText = 0 'Send the message in text format CONST MailFormatHtml = 1 'Send the message in HTML format (not all components support it) '===== END CONSTANTS ================================== '----------------------------------------------------------- ' isEmail ' The function isEmail validates e-mail address. Returns true ' if is valid according to the criteria applied. '----------------------------------------------------------- Function isEmail (sEmail) 'This function validates the email address format 'looking for "@" and at least one "." Dim iAtCount, iPerCount, iLenCount, cTemp iAtCount = 0 iPerCount = 0 isEmail = False iLenCount = len(sEmail) For i = 1 To iLenCount cTemp = mid(sEmail, i, 1) If cTemp = "@" Then iAtCount = iAtCount + 1 End If If cTemp = "." Then iPerCount = iPerCount + 1 End If Next If iAtCount = 1 And iPerCount > 0 Then isEmail = True End If End Function '----------------------------------------------------------- ' SendMail ' This function sends an email with CDONTS or calls another ' alternative function tailored to a specific component. ' Returns: ' 0: No error ' -1: Error Found (object not created) '----------------------------------------------------------- Function SendMail (strFrom, strTo, strCC, strSubject, strBody, strAttachPath, strAttachName) Dim MyCDO On Error Resume Next 'If shop is set to use JMail then call another function and carry over the result. Then exit. If UCase(shop_MailSystem) = "JMAIL" Then SendMail = SendJMail (strFrom, strTo, strCC, strSubject, strBody, strAttachPath, strAttachName) Exit Function ElseIf UCase(shop_MailSystem) = "ASPMAIL" Then SendMail = SendASPMail (strFrom, strTo, strCC, strSubject, strBody, strAttachPath, strAttachName) Exit Function ElseIf UCase(shop_MailSystem) = "CDOSYS" Then SendMail = SendCDOMail (strFrom, strTo, strCC, strSubject, strBody, strAttachPath, strAttachName) Exit Function End If 'Create mail object (CDONTS) Set MyCDO = Server.CreateObject("CDONTS.NewMail") If Err.Number <> 0 Then Response.Write "

Mail error: Could not create mail object. " & "
Err.Source=" & Err.Source& "
Err.Number=" & Err.Number & "
Err.Description=" & Err.Description & "
" SendMail = -1 Exit Function End If If IsObject (MyCDO) Then 'MyCDO.SetLocaleIDs(1027) 'Use to set the code page identifier to be used for this messaging user MyCDO.From = strFrom MyCDO.To = strTo If strCC <> "" Then MyCDO.CC = strCC End If MyCDO.Subject = strSubject 'If there is attachment file path then attach it to mail If strAttachPath <> "" Then If strAttachName <> "" Then MyCDO.AttachFile strAttachPath, strAttachName, CdoEncodingUUencode else MyCDO.AttachFile strAttachPath, , CdoEncodingUUencode End If End If MyCDO.BodyFormat = CdoBodyFormatText ' CdoBodyFormatText | CdoBodyFormatHTML MyCDO.MailFormat = CdoMailFormatMime ' CdoMailFormatMime | CdoMailFormatText MyCDO.Body = strBody 'Send MyCDO.Send Set MyCDO = nothing SendMail = 0 Else SendMail = -1 End If 'Reset error handling On Error Goto 0 End Function '----------------------------------------------------------- ' SendMailing ' This function sends a mailing with CDONTS or calls another ' alternative function tailored to a specific component. ' Not all mail components have been included with HTML mailing ' support (only CDOSYS). '----------------------------------------------------------- Sub SendMailing (rsEmail, strFrom, strSubject, strBody, nMailFormat) Dim MyCDO, strBody2 On Error Resume Next 'If shop is set to use JMail then call another sub and then exit. If UCASE(shop_MailSystem) = "JMAIL" Then Call SendJMailing (rsEmail, strFrom, strSubject, strBody, MailFormatText) Exit Sub ElseIf UCase(shop_MailSystem) = "ASPMAIL" Then Call SendASPMailing (rsEmail, strFrom, strSubject, strBody, MailFormatText) Exit Sub ElseIf UCase(shop_MailSystem) = "CDOSYS" Then Call SendCDOMailing (rsEmail, strFrom, strSubject, strBody, nMailFormat) Exit Sub End If strBody2 = strBody While NOT rsEmail.EOF strBody2 = strBody 'Create mail object (CDONTS) Set MyCDO = Server.CreateObject("CDONTS.NewMail") If Err.Number <> 0 Then Response.Write "
Mail error: Could not create mail object. " & "
Err.Source=" & Err.Source& "
Err.Number=" & Err.Number & "
Err.Description=" & Err.Description & "
" Exit Sub End If If IsObject (MyCDO) Then 'MyCDO.SetLocaleIDs(1027) 'Use to set the code page identifier to be used for this messaging user MyCDO.From = strFrom MyCDO.To = rsEmail("mail") MyCDO.Subject = strSubject Response.Write "
Sending mail: " & rsEmail("mail") 'If there is attachment file path then attach it to mail MyCDO.BodyFormat = 1 '0 = HTML, 1 = Plain Text MyCDO.MailFormat = 0 '0: MIME, 1: Plain text. 'Replace template variables For each cField in rsEmail.Fields strBody2 = Replace(strBody2, "#" & cField.Name &"#", cField.Value) Next MyCDO.Body = strBody2 'Send MyCDO.Send If Err.Number <> 0 Then Response.Write " -> Error sending mail" End if Set MyCDO = nothing End If rsEmail.MoveNext Wend 'Reset error handling On Error Goto 0 End Sub '=========================================================================================== ' CDOSYS functions '=========================================================================================== Function SendCDOMail (strFrom, strTo, strCC, strSubject, strBody, strAttachPath, strAttachName) Dim iMsg Dim iConf Dim Flds On Error Resume Next 'Create message and configuration objects set iMsg = CreateObject("CDO.Message") set iConf = CreateObject("CDO.Configuration") If Err.Number <> 0 Then Response.Write "
Mail error: Could not create CDO mail object. " & "
Err.Source=" & Err.Source& "
Err.Number=" & Err.Number & "
Err.Description=" & Err.Description & "
" SendCDOMail = -1 Exit Function End If Set Flds = iConf.Fields 'If there is SMTP authentication username then add this information If LEN(MAIL_SMTP_USERNAME) > 0 Then With Flds ' Specify the authentication mechanism to basic (clear-text) authentication. .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic ' The username for authenticating to an SMTP server .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = MAIL_SMTP_USERNAME ' The password used to authenticate to an SMTP server .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = MAIL_SMTP_PASSWORD End With End If ' set CDOSYS configuration details With Flds .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = MAIL_SMTP_SERVER .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10 ' The port on which the SMTP service specified by the smtpserver field is listening for connections (typically 25) '.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 'Use SSL for the connection (False or True) '.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False .Update End With ' apply the settings to the message With iMsg Set .Configuration = iConf .To = strTo .From = strFrom If strCC <> "" Then .CC = strCC End If .Subject = strSubject If strAttachPath <> "" Then .AddAttachment strAttachPath End If '.HTMLBody = strHTML .TextBody = strBody err.Clear 'Send message .Send If err.Number <> 0 Then 'Error Response.write "
Error sending message:
" & err.Description & "
" SendCDOMail = -1 Else 'Message sent succesfully! SendCDOMail = 0 End If End With ' cleanup of variables Set iMsg = Nothing Set iConf = Nothing Set Flds = Nothing End Function Sub SendCDOMailing (rsEmail, strFrom, strSubject, strBody, nMailFormat) Dim strBody2 Dim iMsg Dim iConf Dim Flds On Error Resume Next 'Create message and configuration objects set iMsg = CreateObject("CDO.Message") set iConf = CreateObject("CDO.Configuration") If Err.Number <> 0 Then Response.Write "
Mail error: Could not create CDO mail object. " & "
Err.Source=" & Err.Source & "
Err.Number=" & Err.Number & "
Err.Description=" & Err.Description & "
" 'SendCDOMailing = -1 'Exit Sub End If Set Flds = iConf.Fields 'If there is SMTP authentication username then add this information If LEN(MAIL_SMTP_USERNAME) > 0 Then With Flds ' Specify the authentication mechanism to basic (clear-text) authentication. .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic ' The username for authenticating to an SMTP server .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = MAIL_SMTP_USERNAME ' The password used to authenticate to an SMTP server .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = MAIL_SMTP_PASSWORD End With End If ' set CDOSYS configuration details With Flds .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = MAIL_SMTP_SERVER .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10 ' The port on which the SMTP service specified by the smtpserver field is listening for connections (typically 25) '.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 'Use SSL for the connection (False or True) '.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False .Update End With Set iMsg.Configuration = iConf 'Loop through all records: While NOT rsEmail.EOF 'Copy template into temporaty placeholder strBody2 = strBody 'Replace template variables For each cField in rsEmail.Fields strBody2 = Replace(strBody2, "#" & cField.Name &"#", cField.Value) Next With iMsg .To = rsEmail("mail") .From = shop_CompanyName & "<" & strFrom & ">" If strCC <> "" Then .CC = strCC End If .Subject = strSubject Response.Write "
Sending mail: " & rsEmail("mail") If nMailFormat = MailFormatText Then .TextBody = strBody2 ElseIf nMailFormat = MailFormatHtml Then .HTMLBody = strBody2 Else .TextBody = strBody2 End If err.Clear 'Send message .Send If err.Number <> 0 Then 'Error Response.write "
Error sending message:
" & err.Description & "
" SendCDOMailing = -1 Else 'Message sent succesfully! SendCDOMailing = 0 End If End With rsEmail.MoveNext Wend End Sub '=========================================================================================== ' End of CDOSYS functions '=========================================================================================== '=========================================================================================== ' JMail functions '=========================================================================================== Function SendJMail (strFrom, strTo, strCC, strSubject, strBody, strAttachPath, strAttachName) Dim objJMail On Error Resume Next ' Create the JMail message Object Set objJMail = Server.CreateObject("JMail.Message") If Err.Number <> 0 Then Response.Write "
Mail error: Could not create mail object. " & "
Err.Source=" & Err.Source& "
Err.Number=" & Err.Number & "
Err.Description=" & Err.Description & "
" Exit Function End If ' Set logging to true to ease any potential debugging ' And set silent to true as we wish to handle our errors ourself objJMail.Logging = True objJMail.silent = False If IsObject (objJMail) Then objJMail.From = strFrom objJMail.FromName = shop_CompanyName 'objJMail.AddRecipient "recipient@hisDomain.com", "His Name" objJMail.AddRecipient strTo If strCC <> "" Then objJMail.AddRecipientCC strCC End If objJMail.Subject = strSubject 'If there is attachment file path then attach it to mail If strAttachPath <> "" Then If strAttachName <> "" Then 'objJMail.AttachFile strAttachPath, strAttachName objJMail.AddAttachment(strAttachPath) else 'objJMail.AttachFile strAttachPath objJMail.AddAttachment(strAttachPath) End If End If objJMail.Body = strBody 'Send message If NOT objJMail.Send( MAIL_SMTP_SERVER ) then 'Error Response.write "
Error sending message:
" & objJMail.log & "
" SendJMail = -1 Else 'Message sent succesfully! SendJMail = 0 End If Set objJMail = nothing Else SendJMail = -1 End If End Function Sub SendJMailing (rsEmail, strFrom, strSubject, strBody) Dim objJMail, strBody2 On Error Resume Next strBody2 = strBody While NOT rsEmail.EOF strBody2 = strBody ' Create the JMail message Object Set objJMail = Server.CreateObject("JMail.Message") If Err.Number <> 0 Then Response.Write "Mail error: Could not create mail object. " & "Err.Number=" & Err.Number & ", Err.Description=" & Err.Description & ", Err.Source=" & Err.Source & "
" Exit Sub End If If IsObject (objJMail) Then objJMail.From = strFrom objJMail.FromName = shop_CompanyName objJMail.AddRecipient rsEmail("mail") objJMail.Subject = strSubject Response.Write "
Sending mail: " & rsEmail("mail") 'Replace template variables For each cField in rsEmail.Fields strBody2 = Replace(strBody2, "#" & cField.Name &"#", cField.Value) Next objJMail.Body = strBody2 'Send 'Configure your SMTP server: If NOT objJMail.Send(MAIL_SMTP_SERVER) then 'Error Response.Write "Error sending mail" Response.write "
Error sending message:
" & objJMail.log & "
" End If Set objJMail = nothing End If rsEmail.MoveNext Wend End Sub '=========================================================================================== ' End of JMail functions '=========================================================================================== '=========================================================================================== ' ASPMail functions (ASPMail documentation at http://www.serverobjects.com '=========================================================================================== Function SendASPMail (strFrom, strTo, strCC, strSubject, strBody, strAttachPath, strAttachName) Dim objASPMail On Error Resume Next ' Create the ASPMail message Object Set objASPMail = Server.CreateObject("SMTPsvg.Mailer") If Err.Number <> 0 Then Response.Write "
Mail error: Could not create mail object, check that ASPMail is installed. " & "
Err.Source=" & Err.Source& "
Err.Number=" & Err.Number & "
Err.Description=" & Err.Description & "
" Exit Function End If If IsObject (objASPMail) Then 'Configure your SMTP server: objASPMail.RemoteHost = MAIL_SMTP_SERVER objASPMail.FromName = shop_CompanyName objASPMail.FromAddress = strFrom 'objASPMail.AddRecipient "His Name", "recipient@hisDomain.com" objASPMail.AddRecipient "", strTo If strCC <> "" Then objASPMail.AddCC "", strCC End If objASPMail.Subject = strSubject 'If there is attachment file path then attach it to mail If strAttachPath <> "" Then If strAttachName <> "" Then objASPMail.AddAttachment(strAttachPath) else objASPMail.AddAttachment(strAttachPath) End If End If objASPMail.BodyText = strBody 'Send message 'Configure your SMTP server: If NOT objASPMail.SendMail then 'Error Response.write "
Error sending message.
" & objASPMail.Response & "
" SendASPMail = -1 Else 'Message sent succesfully! SendASPMail = 0 End If Set objASPMail = nothing Else SendASPMail = -1 End If 'Reset error handling On Error Goto 0 End Function Sub SendASPMailing (rsEmail, strFrom, strSubject, strBody) Dim objASPMail, strBody2 On Error Resume Next strBody2 = strBody While NOT rsEmail.EOF strBody2 = strBody 'Create the ASPMail message Object Set objASPMail = Server.CreateObject("SMTPsvg.Mailer") If Err.Number <> 0 Then Response.Write "
Mail error: Could not create mail object. " & "
Err.Source=" & Err.Source& "
Err.Number=" & Err.Number & "
Err.Description=" & Err.Description & "
" Exit Sub End If If IsObject (objASPMail) Then 'Configure your SMTP server: objASPMail.RemoteHost = MAIL_SMTP_SERVER 'objASPMail.FromName = shop_CompanyName objASPMail.FromAddress = strFrom objASPMail.AddRecipient rsEmail("Name") & " " & rsEmail("Surname"), rsEmail("mail") objASPMail.Subject = strSubject Response.Write "
Sending mail: " & rsEmail("mail") 'Replace template variables For each cField in rsEmail.Fields strBody2 = Replace(strBody2, "#" & cField.Name &"#", cField.Value) Next objASPMail.BodyText = strBody2 'Send If NOT objASPMail.SendMail then 'Error Response.Write " -> Error sending mail" Response.write "
Error sending message:
" & objASPMail.Response & "
" End If Set objASPMail = nothing End If rsEmail.MoveNext Wend End Sub '=========================================================================================== ' End of ASPMail functions '=========================================================================================== %> <% Sub SendWelcomeMail Dim errno, ShopPath, sMailBody, sMailSubject Dim FileObject, Instream On Error Resume Next 'Path where the root of the shop is ShopPath = Replace(Server.Mappath(Request.ServerVariables("PATH_INFO")),"newuser.asp","") 'Retrieve the mail body in file malbody.txt Set FileObject = Server.CreateObject("Scripting.FileSystemObject") Set Instream = FileObject.OpenTextFile (ShopPath & "welcomemailbody.txt", 1, FALSE, FALSE) sMailBody = Instream.ReadAll set Instream = nothing set FileObject = nothing If sMailBody <> "" Then 'Replace possible variables in the message subject 'sMailSubject = Replace(sMailSubject,"#field_name#",rs("field_name")) 'Order details sMailSubject = "Thank you for registering at #shop_Title#" sMailSubject = Replace(sMailSubject,"#shop_Title#",shop_Title) sMailSubject = Replace(sMailSubject,"#shop_CompanyName#",shop_CompanyName) 'Now replace possible variables in the message body 'sMailBody = Replace(sMailBody,"#field_name#",Request.Form("field_name")) 'Order details sMailBody = Replace(sMailBody,"#UserID#",fUserId) sMailBody = Replace(sMailBody,"#Name#",Request.Form("Name")) sMailBody = Replace(sMailBody,"#SurName#",Request.Form("SurName")) sMailBody = Replace(sMailBody,"#Mail#",Request.Form("mail")) sMailBody = Replace(sMailBody,"#Pwd#",Request.Form("Pwd")) 'Shop settings sMailBody = Replace(sMailBody,"#shop_CompanyName#",shop_CompanyName) sMailBody = Replace(sMailBody,"#shop_Mail#",shop_Mail) sMailBody = Replace(sMailBody,"#shop_Title#",shop_Title) 'You can add new fields here 'Response.Write "
" & sMailSubject & vbCrLf & sMailBody & "
" 'SendMail (strFrom, strTo, strCC, strSubject, strBody, strAttachPath, strAttachName) errNo = SendMail (Application("Mail"), Request.Form("mail"), null, sMailSubject, sMailBody, null, null) If errNo < 0 Then 'Do something if there was a problem sending the e-mail End If Else 'Alternative action if file couldn't be open. End If End Sub Dim strMsg 'Set this User Id as the default for this browser If Request("default")= "true" Then 'Write UserID cookie to user's browser Call WriteUserIdCookie (Session("UserID")) 'Generate message strMsg = Session("UserID") & " is now your default user.

" End If 'Reset this user If Request("resetuser") = "yes" Then Call ResetUser End If %> <%= shop_Title %> <% '====================================================================================== ' File: head.inc ' Description: This file produces the HTML for the definition of the top of all the ' shop pages. It also includes a call to the include file that creates ' the left hand side navigation bar leftinc.asp and until the creation of ' the cell that contains the main body of the pages. '====================================================================================== ' Initialise cat variable with the contents of Request("cat"). This holds current ' category/section Dim strNav If Request("cat") <> "" Then strNav = "cat=" & Request("cat") & "&path=" & Request("path") %>

 

<%= LogoURL %>

<% Dim strSQL If Session("logged") Then %>

Sorry, you are already logged in. To create a new account, please, log out first.
<% elseif Request.Form("AddUser") <> "" Then 'Validate data and create user Dim strError Dim fUserId, Pwd, Pwd2, Name, Surname, Address, CP, fCity, Province, Country, Phone, mail, mailme Dim fTaxID fUserID = ParseInj(Trim(Request.Form("UserId"))) 'If UserID is blank generate a new one If fUserId = "" Then fUserId = GenerateUserId fPwd = Trim(Request.Form("Pwd")) fPwd2 = Trim(Request.Form("Pwd2")) fName = Trim(Request.Form("Name")) fSurname = Trim(Request.Form("Surname")) fCompany = Trim(Request.Form("Company")) fAddress = Trim(Request.Form("Address")) fAddress2 = Trim(Request.Form("Address2")) fCity = Trim(Request.Form("City")) fCP = Trim(Request.Form("CP")) fCountry = Request.Form("Country") fPhone = Trim(Request.Form("Phone")) fmail = Trim(Request.Form("mail")) fmailme = Request.Form("mailme") fTaxID = Trim(Request.Form("TaxID")) If Request.Form("Province")(1) = "" OR Request.Form("Province")(1) = "-" Then If Request.Form("Province")(2) <> "" then fProvince = Trim(Request.Form("Province")(2)) else fProvince = Request.Form("Province")(1) End If else fProvince = Request.Form("Province")(1) End If 'If fUserId = "" Then strError = strError & "- User Id is missing.
" If NOT isEmail (fmail) OR fmail = "" Then strError = strError & "- Email address not valid.
" If fPwd = "" Then strError = strError & "- Password is missing.
" If fPwd <> fPwd2 Then strError = strError & "- The passwords don't match.
" If fName = "" Then strError = strError & "- Name is missing.
" If fSurname = "" Then strError = strError & "- Surname missing.
" If CheckUserEmail(fmail) Then strError = strError & "- Email already exists.
" If CheckUserId(fUserID) Then strError = strError & "- User Id already exists.
" If fCompany = "" Then fCompany = Null If fAddress = "" Then fAddress = Null If fAddress2 = "" Then fAddress2 = Null If fCity = "" Then fCity = Null If fCP = "" Then fCP = Null If fProvince = "" Then fProvince = Null If fPhone = "" Then fPhone = Null If fTaxID = "" Then fTaxID = Null Dim rsCheckUsr Set rsCheckUsr = Server.CreateObject("ADODB.Recordset") rsCheckUsr.Open "SELECT * FROM Users WHERE UserID ='" & fUserID & "'", Conn, adOpenStatic, adLockOptimistic If NOT (rsCheckUsr.EOF AND rsCheckUsr.BOF) Then strError = strError & "- The user Id already exists.
" If strError <> "" Then 'There was an error! %>
Sorry, the following errors were found:

<%= strError %>

Please, go back and correct your details.

<% else 'Validation correct rsCheckUsr.AddNew rsCheckUsr("UserID") = fUserID rsCheckUsr("Name") = fName rsCheckUsr("Surname") = fSurname rsCheckUsr("Pwd") = fPwd rsCheckUsr("Company") = fCompany rsCheckUsr("Address") = fAddress rsCheckUsr("Address2") = fAddress2 rsCheckUsr("City") = fCity rsCheckUsr("CP") = fCP rsCheckUsr("Province") = fProvince rsCheckUsr("Country") = fCountry rsCheckUsr("Phone") = fPhone rsCheckUsr("mail") = fmail If fmailme = "yes" Then rsCheckUsr("mailme") = 1 else rsCheckUsr("mailme") = 0 End If rsCheckUsr("Discount") = 0 rsCheckUsr("TaxID") = fTaxID rsCheckUsr.Update rsCheckUsr.Close 'Update user Id data for current session if the User ID is different (cart and my list) If fUserId <> Session("UserID") Then Call UpdateCartUserID (fUserID, Session("CartID")) Call UpdateMyListUserID (Session("UserID"), fUserID) End If Response.Write("

 

 

Thank you! Your new account has been created.

You can now log in My Account

") SendWelcomeMail End If set rsCheckUsr = nothing else 'Show Form %>
Please, fill in your details:

You can use your User ID to log in instead of your e-mail address. Leave the ID suggested if you plan to log in using your e-mail address (default).

<% If Application("Tax_Model") = "EU" Then %> <% End If %>
E-mail*:     (used to log in)
User ID*: "> (can be used instead of the e-mail to log in)
Password*:
Confirm password*:
First Name*:
Last Name*:
Company:
Address:
Postal Code/ZIP:  
Town/City:
Province/State:
If you are not in the US/Canada you can use this field instead:
Country*:
Phone:
VAT Number: (Companies only)

Log me in automatically next time I come back (read notes).
Yes, I accept receiving information of products or promotions. (We will not share your details with anybody else)

Notes:
1. You should not check the option to automatically remember your details if you are using a computer in a library, a cybercafe or any other public place.
2. Fields in bold and with * are required.

 
<% End If %>

Star Quest Publishing © 2003-2007       www.StarQuestPublishing.com       Email: info@StarQuestPublishing.com      
<% 'Close and destroy connection Call CloseCnx(conn) %>