<% Response.Buffer = True Dim strPostXML, strToBasket, SafeKey, strLocalUrl, strTrolly SafeKey = Application("SafeKeyProd") StoreID = Application("StoreIDProd") Function CheckForFile(sFile) Dim Position 'Position = InStr(9, sFile, "/") 'Response.Write sFile 'Response.End On Error Resume Next CheckForFile = "/images/no_image.gif" If Len(sFile) > 0 Then Position = InStr(9, sFile, "/") sFile = MID(sFile, Position) GetFilePath = Server.MapPath(sFile) 'Response.Write GetFilePath 'Response.End Dim objFile Set objFile = Server.CreateObject("Scripting.FileSystemObject") If objFile.FileExists(GetFilePath)Then 'File Does Exist CheckForFile = sFile Else 'File Does NOT Exist CheckForFile = "/images/no_image.gif" End If Set objFile = Nothing Else CheckForFile = "/images/no_image.gif" End If End Function Function urlPrefix() If InStr(LCase(Request.ServerVariables("HTTP_HOST")), LCase("dev.")) > 0 Then urlPrefix = "http://dev." ElseIf InStr(LCase(Request.ServerVariables("HTTP_HOST")), LCase("stage.")) > 0 Then urlPrefix = "http://stage." Else urlPrefix = "https://" End if End Function Call urlPrefix '## -------------------------------------------------------------------------------------------------- If InStr(LCase(Request.ServerVariables("HTTP_HOST")), LCase(StoreURL)) > 0 Then strPostXML = urlPrefix() & "secure.safeshop.co.za/s2s/Product.asp" '## Testing strToBasket = urlPrefix() & "secure.safeshop.co.za/basket/basket_addItem.asp" '## Testing strLocalUrl = StoreURL strTrolly = urlPrefix() & "secure.safeshop.co.za/basket/index.asp" '## Testing strStoreSiteXML = urlPrefix() & "secure.safeshop.co.za/S2S/StoreSite.asp" '## Testing Else strPostXML = urlPrefix() & "secure.safeshop.co.za/S2S/Product.asp" '## Live strToBasket = urlPrefix() & "secure.safeshop.co.za/basket/basket_addItem.asp" '## Live strLocalUrl = replace(StoreURL, "//dev.", "") strTrolly = urlPrefix() & "secure.safeshop.co.za/basket/index.asp" '## Live strStoreSiteXML = urlPrefix() & "secure.safeshop.co.za/S2S/StoreSite.asp" '## Live End If '##------------------------------------------------------------------------------------------ '## Get a info across Http using XML object '##------------------------------------------------------------------------------------------ Function GetXMLHttp(ByVal HTTPLocation, Byval XMLData) Dim strErrorMsg Dim xmlhttp Dim strRemoteDataResult '## URLString is the URL that is to be requested '## FormInputArray are the names of the tags '## FormValueArray are the actual values of the corresponding tags '## Erorr checkking If InStr(HTTPLocation, "/") = 0 Then GetXMLHttp = "Error: Remote Address not supplied " Exit Function End If '## Set XML HTTP Object Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP") '## Initializes an MSXML2.ServerXMLHTTP objXMLHTTP.Open "POST", HTTPLocation, False '## Initializes XMLHTTP request, and specifies the method, URL, and authentication information for the request. objXMLHTTP.send XMLData '## Sends an HTTP request to the server and receives a response strRemoteDataResult = Trim(objXMLHTTP.responseText) '## Get response text and set to var If InStr(LCase(strRemoteDataResult), LCase("-2146697211")) Then '## Web Server is Down strErrorMsg = "Error: Web Server not responding." ElseIf InStr(LCase(strRemoteDataResult), LCase("HTTP 404")) Then '## The page cannot be found strErrorMsg = "Error: The page cannot be found." ElseIf InStr(LCase(strRemoteDataResult), LCase("80004005")) Then '## Server.CreateObject Failed strErrorMsg = "Error: " & strRemoteDataResult ElseIf InStr(LCase(strRemoteDataResult), LCase("Error:")) Then '## Error on web server strErrorMsg = "Error: " & strRemoteDataResult ElseIf LCase(strRemoteDataResult) = LCase("NoRecord") Then strErrorMsg = "Error: No New Record" ElseIf strRemoteDataResult = "" Then strErrorMsg = "Error: No New Record" End If If strErrorMsg <> "" Then GetXMLHttp = strErrorMsg Else GetXMLHttp = strRemoteDataResult End If Set objXMLHTTP = Nothing End Function Function DigestGenerate(SafeKey, StoreID, SKU) 'Set objMD5 = Server.CreateObject("MD5DLL.Crypt") 'DigestGenerate = objMD5.Encrypt(LCase(SafeKey & StoreID & SKU)) DigestGenerate = md5(LCase(SafeKey & StoreID & SKU)) ' tmpStr = "" ' For iCnt = 1 To Len(DigestGenerate) ' tmpStr = tmpStr & Right("0" & hex(asc(mid(DigestGenerate, iCnt, 1))), 2) ' Next End Function Function Encrypt (SafeKey, StoreID, SKU, URLPostTo) Encrypt = "SafeKey=" & StoreID & "&SKU=" & Server.URLEncode(SKU) Encrypt = URLPostTo &"?"& Encrypt & "&Digest=" & DigestGenerate(SafeKey, StoreID, SKU) End Function %>