%
' Comersus 5.0x Sophisticated Cart
' Developed by Rodrigo S. Alhadeff for Comersus Open Technologies
' United States
' Open Source License can be found at License.txt
' http://www.comersus.com
' Details: list all the products added last 7 days
%>
Error processing SSI file
<%
On Error Resume Next
' Developed by Rodrigo S. Alhadeff for Comersus Open Technologies
' USA - 2003
' Open Source License can be found at documentation/readme.txt
' http://www.comersus.com
' Details: all session functions
%>
<%
' Comersus 5.0x Sophisticated Cart
' Developed by Rodrigo S. Alhadeff for Comersus Open Technologies
' USA - 2003
' Open Source License can be found at documentation/readme.txt
' http://www.comersus.com
' Details: date functions
%>
<%
function MediumDate (str)
Dim aDay, aMonth, aYear
aDay = Day(str)
aMonth = Monthname(Month(str),True)
aYear = Year(str)
MediumDate = aDay & "-" & aMonth & "-" & aYear
end Function
function formatDate(str)
if uCase(pDateFormat)="DD/MM/YY" then
formatDate=day(str)&"/"&month(str)&"/"&year(str)
else
formatDate=month(str)&"/"&day(str)&"/"&year(str)
end if
end function
%>
<%
' Comersus 5.0x Sophisticated Cart
' Developed by Rodrigo S. Alhadeff for Comersus Open Technologies
' USA - 2003
' Open Source License can be found at documentation/readme.txt
' http://www.comersus.com
' Details: miscellaneous functions
%>
<%
' discount code Generator (65^n)
function DiscountCodeGenerator(n)
dim s
randomize()
s="1234567890AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz"
do
a=""
for i = 1 to n
a = a + mid(s,cint(rnd()*len(s))+1,1)
next
' search if the code is being used
mySQL = "SELECT discountCode FROM discounts WHERE discountCode='" &a& "'"
call getFromDatabase (mySql, rsTemp3, "miscFunctions")
' eof implies that the code is available
loop until rstemp3.eof
DiscountCodeGenerator = cstr(a)
end function
' randomNumber function, generates a number between 1 and limit
function randomNumber(limit)
randomize
randomNumber=int(rnd*limit)+1
end function
' min value
function min(byval value1, byval value2)
if value1>value2 then
min = value2
else
min = value1
end if
end function
function getMax(arrProducts)
dim tempMax, k
tempMax=0
for k=0 to uBound(arrProducts)
if arrProducts(k,7)>tempMax then tempMax=arrProducts(k,7)
next
getMax=tempMax
end function
function getPopularity(currentPopularity, maxPopularity)
' to avoid errors
if maxPopularity=0 then maxPopularity=1
getPopularity=int(currentPopularity*4/maxPopularity)
end function
function removePrefix(input,prefix)
removePrefix=""
if input<>"" and prefix<>"" then
dim longPrefix
longPrefix =len(prefix)+1
removePrefix =mid(input,longPrefix)
end if
end function
function saveCookie()
response.cookies("test")="-1"
end function
function readCookie()
if request.cookies("test")<>"-1" then
readCookie=0
else
readCookie=-1
end if
end function
function writeLog(line, file)
set FSO = Server.CreateObject("scripting.FileSystemObject")
set myFile = fso.OpenTextFile(file, 8, true)
myFile.WriteLine(line)
myFile.Close
end function
sub parseShipmentMethod(pPlainString, pShipmentDesc, pShipmentPrice)
dim cutPoint, longpRealTimeShipment
cutPoint = instr(pPlainString, "|")
longpRealTimeShipment = len(pPlainString)
pShipmentPrice = left(pPlainString,cutPoint-1)
pShipmentDesc = right(pPlainString,longpRealTimeShipment-cutPoint)
if pChangeDecimalPoint="-1" then pShipmentPrice=replace(pShipmentPrice,".",",")
end sub
sub checkRentalAvailability(pIdProduct, pFrom, pUntil, pIsAvailable, pReason, pQuantity)
pQuantity =datediff("d",pFrom,pUntil)
if pQuantity<1 then
pReason="Rental interval is not correct. Please check date format."
pIsAvailable=0
end if
' get availability
mySQL="SELECT * FROM rentals WHERE idProduct="&pIdProduct
call getFromDatabase(mySQL, rstemp, "comersus_rentalListAvailability.asp")
do while not rstemp.eof
pLimitFF=datediff("d",pFrom,rstemp("fromDate"))
pLimitFU=datediff("d",pFrom,rstemp("untilDate"))
pLimitUF=datediff("d",pUntil,rstemp("fromDate"))
pLimitUU=datediff("d",pUntil,rstemp("untilDate"))
if pLimitFF<=0 and pLimitFU>=0 then
pReason="From date reserved"
pIsAvailable=0
end if
if pLimitUF<=0 and pLimitUU>=0 then
if pReason<>"" then pReason=pReason&" and "
pReason="End date reserved"
pIsAvailable=0
end if
rstemp.movenext
loop
end sub
%>
<%
function sessionInit()
' makes an init over all session variables used
if session("idCustomer")="" or isNull(session("idCustomer")) then
session("language") = pDefaultLanguage
session("idAffiliate") = Cint(1)
session("idCustomer") = Cint(0)
session("idCustomerType") = Cint(1)
session("cartItems") = Cint(0)
session("cartSubTotal") = CDbl(0)
session("idDbSession") = Cint(0)
session("idDbSessionCart") = Cint(0)
' now check if the client browser supports session variables
if session("idCustomer")<>0 then
response.redirect "comersus_message.asp?message="&Server.Urlencode(dictLanguage.Item(Session("language")&"_additem_1") )
end if
sessionInit=-1
else
sessionInit=0
end if
end function
function getSessionVariable(pSessionVariable, pDefault)
' try to get one session variable, if is empty, returns default value
if session(pSessionVariable)="" or isNull(session(pSessionVariable)) then
getSessionVariable=pDefault
else
getSessionVariable=session(pSessionVariable)
end if
end function
function checkSessionData()
pIdDbSession = getSessionVariable("idDbSession", 0)
if Cdbl(pIdDbSession)=0 then
' dbSession not defined
pRandomKey = randomNumber(99999999)
pDbSessionDate = formatDate(Date())
mySQL="INSERT INTO dbSession (randomKey, sessionType, dbSessionDate) VALUES (" &pRandomKey& ",'web','" &pDbSessionDate& "')"
call updateDatabase(mySQL, rsTemp, "sessionFunctions, checkSessionData")
' retrieve idDbSession
if lcase(pDatabase)="mysql" then
mySQL="SELECT idDbSession AS maxIdDbSession FROM dbSession WHERE idDbSession=last_insert_id()"
else
mySQL="SELECT MAX(idDbSession) AS maxIdDbSession FROM dbSession WHERE randomKey=" &pRandomKey& " AND dbSessionDate='" &pDbSessionDate& "'"
end if
call getFromDatabase(mySQL, rsTemp, "sessionFunctions, checkSessionData")
if rsTemp.eof then
' try again
mySQL="SELECT MAX(idDbSession) AS maxIdDbSession FROM dbSession WHERE randomKey=" &pRandomKey& " AND dbSessionDate='" &pDbSessionDate& "'"
call getFromDatabase(mySQL, rsTemp, "sessionFunctions, checkSessionData")
end if
pIdDbSession=rstemp("maxIdDbSession")
end if ' not NULL
' load in session
session("idDbSession")=pIdDbSession
checkSessionData = pIdDbSession
end function
function checkDbSessionCartOpen()
dim pIdDbSession2
' check if there is some cart open for current dbSession
pIdDbSession2=getSessionVariable("idDbSession", 0)
mySQL="SELECT idDbSessionCart FROM dbSessionCart WHERE idDbSession=" &pIdDbSession2& " AND cartOpen=-1 ORDER BY idDbSessionCart"
call getFromDatabase(mySQL, rsTemp, "sessionFunctions")
if rstemp.eof then
checkDbSessionCartOpen = 0
else
session("idDbSessionCart") = rstemp("idDbSessionCart")
checkDbSessionCartOpen = rstemp("idDbSessionCart")
end if
end function
function createNewDbSessionCart()
pIdDbSession=getSessionVariable("idDbSession", 0)
if pIdDbSession=0 then
response.redirect "comersus_supportError.asp?error="&Server.UrlEncode(" idDbSession was not defined while creating dbSessionCart. idDbSession:"&session("idDbSession")&" - Type:"&varType(session("idDbSession")))
end if
mySQL="INSERT INTO dbSessionCart (idDbSession, cartOpen) VALUES (" &pIdDbSession& ",-1)"
call updateDatabase(mySQL, rsTemp, "sessionFunctions, createNewDbSessionCart")
' retrieve idDbSession
mySQL="SELECT MAX(idDbSessionCart) AS maxIdDbSessionCart FROM dbSessionCart WHERE idDbSession=" &pIdDbSession
call getFromDatabase(mySQL, rsTemp, "sessionFunctions, createNewDbSessionCart")
pIdDbSessionCart=rstemp("maxIdDbSessionCart")
createNewDbSessionCart = pIdDbSessionCart
end function
function getSessionData(dictQueryString)
pIdDbSession = getSessionVariable("idDbSession", 0)
if pIdDbSession=0 then
response.redirect "comersus_supportError.asp?error="&Server.Urlencode("Error in sessionFunctions,idDbSession not defined in session")
end if
mySQL="SELECT sessionData FROM dbSession WHERE idDbSession=" &pIdDbSession
call getFromDatabase(mySQL, rstemp, "sessionFunctions")
if not rstemp.eof then
pSessionData = rstemp("sessionData")
else
pSessionData = ""
end if
if pSessionData="" or isNull(pSessionData) then
' clear sessionData
session("IdDbSession") =""
session("IdDbSessionCart") =""
' clear header cart vars
session("cartSubTotal") = Cdbl(0)
session("cartItems") = Cint(0)
response.redirect "comersus_message.asp?message="&Server.UrlEncode(dictLanguage.Item(Session("language")&"_getsessiondata_1"))
end if
' obtain fields from sessionData
dim arrayQueryString
' check if last char is &
if right(pSessionData,1)="&" then
pSessionData=left(pSessionData, len(pSessionData)-1)
end if
' insert into one dimensional array
arrayQueryString = split(pSessionData, "&")
' insert all values in one dictionary object passed as parameter
for f=0 to ubound(arrayQueryString)
' determine = position
pEqualPosition = instr(arrayQueryString(f),"=")
'response.write " Item : "&left(arrayQueryString(f),pEqualPosition-1)
'response.write " value : "& right(arrayQueryString(f),len(arrayQueryString(f))-pEqualPosition)
dictQueryString.Add left(arrayQueryString(f),pEqualPosition-1), right(arrayQueryString(f),len(arrayQueryString(f))-pEqualPosition)
next
end function
function sessionLost()
pIdDbSession = getSessionVariable("idDbSession", 0)
if pIdDbSession=0 then
sessionLost=-1
else
sessionLost=0
end if
end function
%>
<%
site = Request.ServerVariables("HTTP_REFERER")
if site <> "" AND left(site, 33) <> "https://www.theway.org.uk/comersus" Then
user_agent = request.servervariables("HTTP_USER_AGENT")
if instr(1, user_agent, "Mac") <> 0 then
%>
<%
end if
end if
%>
The Way Ignatian Book Service
<%if pHeaderKeywords<>"" then%>
<%else%>
<%end if%>
">
THE WAY
IGNATIAN BOOK SERVICE
<%
' Offer Box Display if logged in and some random conditions
if pCustomerName<>"" then
pBoxOpen=left(request.querystring("bop"),2)
%>
<%else%>
Coronavirus restrictions in the UK have been tightened, meaning that I cannot currently send books from the office. Orders of 2020 Ways and the January 2021 issue will be processed promptly.