Results 1 to 7 of 7

Thread: Iframe SSI script II - External URL

  1. #1
    Join Date
    Jul 2008
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Iframe SSI script II - External URL

    1) Script Title: Iframe SSI script II

    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...iframessi2.htm

    3) Describe problem:

    I have recently added this invaluable script to my web site. I have however reached a point where i wish to incorporate an external web page.

    I am fully aware that the script does not support external web sites. However i have thought about URL masking or page re-direction.

    The 2 URL's in question are:

    Internal/hosted page (containing the iframe code) domain:
    http://idl.newport.ac.uk

    External domain: http://mycommunity.newport.ac.uk/cs/...s/Default.aspx

    1) The code currently on the host page looks like this (the url is linking to the external domain from the host page and will not work):

    Code:
    <iframe id="IDLBlog" src="http://mycommunity.newport.ac.uk/cs/blogs/idlnews/Default.aspx" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:100%; display:none"></iframe>
    2) I do have the power to mask this external URL to look like the same domain as the hosting page. So the code will now look like this:

    Code:
    <iframe id="IDLBlog" src="http://idl.newport.ac.uk/idlnews" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:100%; display:none"></iframe>
    Will masking the external url (1) disguise/hide (in the hosted page) the fact that it is hosted elsewhere? Will it work?

    Thanks in advance guys!

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    it really depends on how you're masking the external URL to appear as if it's local. About the only way I can think of is if you actually first fetch the contents of the external page using PHP (ie: via file_get_contents) or Curl, then including that local page using the script. That would be similar to creating an Ajax proxy to make a request on any external URL. Any type of "virtual" masking most likely will fail based on cross browser JavaScript security restrictions in modern browsers.

  3. The Following User Says Thank You to ddadmin For This Useful Post:

    egr103 (08-01-2008)

  4. #3
    Join Date
    Jul 2008
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    I will be masking it by making a dsn entry that will forward to the external domain.

    Will that work at all?

    Also, i'm afraid to say i'm quite useless when it comes to PHP as i have no experience of using it.

    From that then i'm guessing it is a lost cause?

  5. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    DNS redirect (A record) may work, though I'm not entirely sure. The browser may also check other credentials of the two servers to make sure they match (IP address for example).

    PHP's "file_get_contents" simply grabs the contents of any URL and outputs it as a string. The idea is to use that function to fetch and create a local copy of the external page on your server, then the Iframe SSI script would display that local copy of the file instead. You may create a blank php file (ie: external.php) containing:

    Code:
    <?php
    echo file_get_contents("http://othersite.com/test.htm");
    ?>
    Then have the Iframe SSI script show external.php. You should be able to get all the details on this function at php.net

  6. #5
    Join Date
    Jul 2008
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    This is excellent. It does the job and automatically adjusts to show all content, however...

    The external page i am calling in loses it's css styling elements.

    see this url:
    http://idl.newport.ac.uk/misc/idl-news-iframe.html

    But the page being called in looks like this:
    http://mycommunity.newport.ac.uk/cs/blogs/idlnews/

    SO the page content appears, but with no styling.

    Is there a way around this at all? For example, by echoing the CSS style sheet as well as the web page?

    I have also noticed that i cannot link to other pages that are on that external domain.

    I will need to link to various other pages in the domain...but this doesn't work with this method. Is there a way of viewing other pages in the external domain by modifying the php?
    Last edited by egr103; 08-01-2008 at 12:34 PM.

  7. #6
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Well, external CSS and JS files referenced on the external page can just be included within the output as is, without echoing their actual source code. So you may have something like:

    Code:
    <?php
    echo '<link rel="stylesheet" type="text/css" href="http://www.othersite.com/style.css" />';
    echo file_get_contents("http://othersite.com/test.htm");
    ?>

  8. The Following User Says Thank You to ddadmin For This Useful Post:

    egr103 (08-05-2008)

  9. #7
    Join Date
    Jul 2008
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Brilliant, thanks for your help on this.

    In my previous post i mentioned a problem with linking to different pages within the iframe. Obviously the current main page i am echo-ing (referenced in the PHP) will appear, but that page will have links to other pages within that external domain.

    Please see this link and then click any of the links in the white space (no styles applied to the text) - times new roman font. They are all blog posts.

    http://idl.newport.ac.uk/misc/idl-news-iframe.html

    You will notice that a server error occurs when you click on the links, how do i get these links to link to the proper pages and not return a error? Note: I do not have control over the other html pages so therefore cannot alter the source code of the html (i.e. the a href tags).

    If this cannot work then can you suggest any other methods that can get around this problem?

    Thanks again, ddadmin
    Last edited by egr103; 08-04-2008 at 12:20 PM. Reason: Please re-read post, i have altered it to get my point across better, thanks!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •