legohead6 Posted May 15, 2008 Share Posted May 15, 2008 Hi, i am just starting to learn about sockets, and have made a simple code, it works great and the google homepage loads, but no pictures are displayed(red x's) and the links arent displayed, the probelm is its trying to link to my website for the pics(EX pic is at google.com/pic.jpg, its trying to find it at example.com/pic.jpg) how could i fix this? i have to set the headers somehow im assuming, but dont know how! could someone please help me out, i am trying to learn sock stuff so please dont just give me a 1000line code without explaning it... <?php fsockopen ("www.google.com", 80); fwrite($connection, "GET / HTTP/1.1\r\nHOST: www.google.com\r\n\r\n"); while (!feof($connection)) { echo fread($connection,256); } fclose ($connection); ?> Quote Link to comment Share on other sites More sharing options...
awpti Posted May 15, 2008 Share Posted May 15, 2008 Because it's only getting the content you requested (index.html), the images are likely linked to relatively hence they won't show as they would be hunting on your server for the image location. You could pull the data down and parse it, but that would be a waste of time. This isn't what the socket functions are for, really. Something in-scope would be, say, connecting to a MUD and issuing commands via a web interface. Quote Link to comment Share on other sites More sharing options...
btherl Posted May 15, 2008 Share Posted May 15, 2008 When you display someone else's HTML code on your site, all the relative links will be relative to YOUR site. If all you want is a php web proxy, Yoctoproxy does a decent job of that. If you want to make your own proxy, then be warned that it's not easy You'll need to rewrite all those links like yoctoproxy does. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.