<% ' site Sophisticated Cart ' Developed by site Open Technologies LC ' Software License can be found at License.txt ' http://www.site.com ' Details: redirects to default index page inside the store %> <% ' site Sophisticated Cart ' site Open Technologies ' USA - 2005 ' Open Source License can be found at documentation/readme.txt ' http://www.site.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) pByPassShipping=getSettingKey("pByPassShipping") if pByPassShipping="0" then arrayShipment=split(pPlainString,"%%") pShipmentDesc =arrayShipment(0) pShipmentPrice =Cdbl(arrayShipment(1))+Cdbl(arrayShipment(2)) if pChangeDecimalPoint="-1" then pShipmentPrice=replace(pShipmentPrice,".",",") end if else pShipmentPrice =0 pShipmentDesc ="" end if end sub function getShipmentString(pShipmentIndex, pIdDbSession) dim rstemp3 pByPassShipping=getSettingKey("pByPassShipping") getShipmentString="" if pByPassShipping="0" then mySQL = "SELECT sessionData FROM dbSession WHERE idDbSession=" &pIdDbSession call getFromDatabase (mySql, rsTemp3, "getShipmentString") if not rstemp3.eof then pSessionData=rstemp3("sessionData") ' parse rows arrayRows=split(pSessionData,"||") ' retrieve index getShipmentString=arrayRows(pShipmentIndex) end if end if end function 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, "site_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 getStateName(pStateCode) dim rstempgSN mySQL="SELECT stateName FROM stateCodes WHERE stateCode='"&pStateCode&"'" call getFromDatabase(mySQL, rstempgSN, "getStateName()") if not rstempgSN.eof then getStateName=rstempgSN("stateName") else getStateName="-" end if end function function getCountryName(pCountryCode) dim rstempgSN mySQL="SELECT countryName FROM countryCodes WHERE countryCode='"&pCountryCode&"'" call getFromDatabase(mySQL, rstempgSN, "getCountryName()") if not rstempgSN.eof then getCountryName=rstempgSN("countryName") else getCountryName="-" end if end function function isDownloadFile(pFile) isDownloadFile=0 if instr(pFile,".zip")<>0 then isDownloadFile=-1 end if if instr(pFile,".exe")<>0 then isDownloadFile=-1 end if if instr(pFile,".mp3")<>0 then isDownloadFile=-1 end if end function %> <% call saveCookie() pIdAffiliate=request.querystring("idAffiliate") if isNumeric(pIdAffiliate) then response.redirect "Search/default.asp" else response.redirect "Search/default.asp" end if %>