guitardave78
Programmer
For various reasons I am writing a Web based proxy (You knowthe idea, bypass firewall etc)
There are no dubious reasons, we are just having firewall issues at work and I am unable to test work!!
So far I can get to the pages and replace all the hrefs in a page with the new proxy href and querystring.
What I need to be able to do is check for relative images, stylesheets and javascript sources and replace them with the full url of the site.
Any ideas how I can do this? The code I have so far is
}...the bane of my life!
There are no dubious reasons, we are just having firewall issues at work and I am unable to test work!!
So far I can get to the pages and replace all the hrefs in a page with the new proxy href and querystring.
What I need to be able to do is check for relative images, stylesheets and javascript sources and replace them with the full url of the site.
Any ideas how I can do this? The code I have so far is
Code:
<%
function getPage(url)
on error resume next
dim xmlDoc,getPage,f
set xmlDoc = server.createObject("MSXML2.ServerXMLHTTP")
xmlDoc.Open "GET", url, false
'xmlDoc.setRequestHeader "Cache-Control","no-cache"
xmlDoc.Send
getPage = xmlDoc.responseTex
getPage = replace(getPage,"href=""","href=""[URL unfurl="true"]http://www.YOURDOMAIN.co.uk/proxy/?q=")[/URL]
getPage = replace(getPage,"href='","href='[URL unfurl="true"]http://www.YOURDOMAIN.co.uk/proxy/?q=")[/URL]
f = "<style>body{padding-top:0px;margin-top:0px;}</style><form method='get'><input type='text' name='q' id='q' value='"&url&"' size='70'> <input type='submit' value='Go' ></form>"
if instr(getPage,"</head>") > 0 then
getPage = replace(getPage,"</head>","</head>"&vbcrlf & f)
else
getPage = f & getPage
end if
'xmlDoc.close
xmlDoc = nothing
if err.number < 0 then
response.write(err.description)
end if
end function
dim q
q = request.querystring("q")
if q <> "" then
if left(q,7) <> "[URL unfurl="true"]http://"[/URL] then q = "[URL unfurl="true"]http://"[/URL] & q
response.write("")
response.write(getPage(q))
else
response.write(getPage("[URL unfurl="true"]http://www.yahoo.com"))[/URL]
end if
%>
}...the bane of my life!