Hi,

I have written a script that uses fsockopen, fputs, and fgets to send http GET headers to a web site and receive the resulting content. Everything is working fine so far.

My problem: Lets say my script is named "test.php", and the full url of the script that I enter in my browser is "http://my.webserver.net/test.php". In the script, I establish a connection to some web server using fsockopen. I then use fputs to send HTTP GET headers to the web server, and fgets to receive the web server's response. This response includes headers & content, which I am seperating properly. I am then able to display this content within my web browser. However, the URL in my browser's address bar does not change from the original "http://my.webserver.net/test.php". In addition, some of the relative links on the content I retrieved from the other web server are broken, because they are now relative to MY webserver, not the server I retrieved the content from. Does anyone know of a way to remedy this problem?

My ultimate goal here is to implement a sort of "single signon". I've figured out basic authorization and form posts, but I can't go much further until I work out this problem. Any input is appreciated.

Thanks!

    Originally posted by nemonoman
    In the stream you fget() from www.myTargetWebsite.com, find the <head> tag

    Insert this code before it

    <BASE HREF='http://www.myTargetWebsite.com'>

    Keeps all refs relative to the returned html

    Hey, that works. Thanks a bunch! The address bar still shows the original url (of the script), however, but all the links now work. Know of a way to get the new url to show up (the url that i received the content from)? Thanks again!

      I believe that what you describing can't be done...but what I'm trying to figure out is: Whaaa??? You want to munge a page, display the munged content and change the URL of the page to the URL of the page you're displaying?? Isn't that what <a href=www.thePageIwantToDisplay.com>Show the page</a> Is all about?

        Originally posted by nemonoman
        I believe that what you describing can't be done...but what I'm trying to figure out is: Whaaa??? You want to munge a page, display the munged content and change the URL of the page to the URL of the page you're displaying?? Isn't that what <a href=www.thePageIwantToDisplay.com>Show the page</a> Is all about?

        You are correct. However, ultimately I hope to have a single-signon end product. So, simply providing a link will not work. I'm attempting to use fsockopen to send headers with login credentials to a web site that requires those credentials. This may not be the best method to use. I'm still experimenting with different solutions. Thanks for your help.

          Write a Reply...