Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Oct 2004
    Location
    London E4 UK
    Posts
    320
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Importing/incorporating code from an external web page?

    Hello

    Basic php/html/mysql skills here

    I do code for a website, they have sold a page to an advertiser that needs to show material from a daily html newsletter, I initially said it would work on the basis that anyone doing a complex html newsletter daily would be able to also produce a block of code that could act as an include

    It now turns out that all the advertiser is able to provide is the html email itself.

    I'm still squinting at this project from a long way off but I'd be grateful for a rough idea of how this would be tackled.

    The html email has the usual 'email not displaying properly?' so there is a webpage for each newsletter, it uses relative links for the css and images

    Is it as simple as my webpage reading their code from their website, and then some manipulation to make their links absolute paths and top and tail out their headers and footer so it can appear within my headers and footers? That said how would I load up actual code from someone else's web page?

    Can anyone see problems ahead or suggest any handy dos and don'ts?

    Many thanks
    Tynan
    Last edited by Tynan; 03-17-2009 at 03:19 PM. Reason: awful thread title

  • #2
    Regular Coder
    Join Date
    Oct 2004
    Location
    London E4 UK
    Posts
    320
    Thanks
    0
    Thanked 0 Times in 0 Posts
    googled this, look ok?
    ................
    PHP Code:
    <?php
    $handle 
    fopen ("http://www.example.com/""rb");
    $contents "";
    do {
    $data fread($handle8192);
    if (
    strlen($data) == 0) {
    break;
    }
    $contents .= $data;
    } while(
    true);
    fclose ($handle);
    ?>
    I haven't tested those but from what I saw, $content will be the exact source of the index file in example.com (parts that is shown to the world of course - not the serverside scripts)

    so now we can look for some pattern in $content
    .............


  •  

    Posting Permissions

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