<%@ Language = "VBScript" %> <% Response.Buffer = True %><%
' option explicit
'Declare the Variables. It is best way to delcare them on the top before using them.
dim method
dim view
dim colorway
dim taxonomy_id
dim id
dim affiliate_id
' Populate the Variables now.
if not isEmpty(Request.QueryString("m")) then
method = Request.QueryString("m")
else
method = "index"
end if
view = "default"
colorway = "royal"
taxonomy_id = "009180"
if not isEmpty(Request.QueryString("id")) then
id = Request.QueryString("id")
else
id = taxonomy_id
end if
id = join(split(id, " "), "-")
affiliate_id = "5236"
' Code
Function implode_with_key(assoc , inglue , outglue)
dim return
return = null
For Each tk in assoc
return = return & outglue & tk & inglue & assoc(tk)
Next
if return <> null then
implode_with_key = right(return, ( len(return) - len(outglue)))
else
implode_with_key = return
end if
End Function
'-------------------------------------------------------------------------------------------------------
Function parse_URL(strURL)
'Parse URL
Set objRegEx = New RegExp
objRegEx.pattern = "^([\w]*://)([\w\-\.:@]*)([\w\.\-/?=#&]*)"
objRegEx.Global = true
dim aryParsedURL(7)
If objRegEx.Test(strURL) Then
Set colMatches = objRegEx.Execute(strURL)
Set objMatch = colMatches(0)
'Scheme
If objMatch.SubMatches.Count > 0 Then
strProtocol = objMatch.SubMatches(0)
aryParsedURL(0) = split(strProtocol, "://")(0)
End if
'Host
If objMatch.SubMatches.Count > 1 Then
strHost = objMatch.SubMatches(1)
End if
'Path
If objMatch.SubMatches.Count > 2 Then
aryParsedURL(4) = objMatch.SubMatches(2)
End if
'Check if path contains the # sign
if InStr(aryParsedURL(4), "#") <> 0 then
path = split(aryParsedURL(4), "#")
aryParsedURL(4) = path(0)
aryParsedURL(7) = path(1) ' Store the Anchor
end if
'check if path contains ? Mark
if InStr(aryParsedURL(4), "?") <> 0 then
path = split(aryParsedURL(4), "?")
aryParsedURL(4) = path(0)
aryParsedURL(6) = path(1) ' Query String
end if
'Check if path contains the # sign
dim port, host, user, password
'Get the Port if specified
if InStr(strHost, "@") = 0 then
if InStr(strHost, ":") <> 0 then
strHost = split(strHost, ":")
aryParsedURL(1) = strHost(0)
aryParsedURL(5) = strHost(1)
else
aryParsedURL(1) = strHost
aryParsedURL(5) = 80
end if
else
strHost = split(strHost, "@")
aryParsedURL(2) = split(strHost(0),":")(0) ' Get the User Name
aryParsedURL(3) = split(strHost(0),":")(1) ' Get the Password
if InStr(strHost(1), ":") <> 0 then
aryHost = split(strHost(1), ":")
aryParsedURL(1) = aryHost(0) ' Get the Host
aryParsedURL(5) = aryHost(1) 'Get the Port #
else
aryParsedURL(1) = strHost(1)
aryParsedURL(5) = 80
end if
end if
parse_URL = aryParsedURL
Else
Response.Write( "Input is an invalid URL")
End if
End Function
'-------------------------------------------------------------------------------------------------------
Function getRemoteFile(url)
' get the host name and url path
parsedUrl = parse_url(url)
host = parsedUrl(1)
if not isEmpty(parsedUrl(4)) then
path = parsedUrl(4)
else
' the url is pointing to the host like http://www.mysite.com
path = "/"
end if
if not isEmpty(parsedUrl(6)) then
path = path & "?" & parsedUrl(6)
end if
if not isEmpty(parsedUrl(5)) then
port = parsedUrl(5)
else
' most sites use port 80
port = "80"
end if
' dim timeout
' timeout = 10
dim responseFromServer
responseFromServer = ""
' connect to the remote server
dim xmlHttp
' Internet Explorer
If isObject(Server.CreateObject("Msxml2.XMLHTTP")) then
set xmlHttp = Server.CreateObject("Msxml2.XMLHTTP")
ElseIf isObject(Server.CreateObject("Microsoft.XMLHTTP")) then
set xmlHttp = CreateObject("Microsoft.XMLHTTP")
End If
xmlHttp.open "GET",url,false
xmlHttp.setRequestHeader "Host", host & "\r\n"
xmlHttp.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3\r\n"
xmlHttp.setRequestHeader "Accept", "*/*\r\n"
xmlHttp.setRequestHeader "Accept-Language", "en-us,en;q=0.5\r\n"
xmlHttp.setRequestHeader "Accept-Charset:", "ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n"
xmlHttp.setRequestHeader "Keep-Alive", "300\r\n"
xmlHttp.setRequestHeader "Connection", "keep-alive\r\n"
xmlHttp.setRequestHeader "Referer", "http://" & host & "\r\n\r\n"
xmlHttp.send
responseFromServer = responseFromServer & xmlHttp.ResponseText
' strip the headers
dim pos
' pos = InStr(responseFromServer, "\r\n\r\n")
' responseFromServer = right(responseFromServer, pos + 4)
' return the file content
getRemoteFile = responseFromServer
End Function
'-------------------------------------------------------------------------------------------------------
' Output
Response.Write(getRemoteFile("http://services.bridaluxe.com/store/" & method & "/" & view & "/" & id & "/" & affiliate_id & "/" & taxonomy_id & "/" & colorway & "/" & implode_with_key(Request.QueryString, "/", "/")))
%>