1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

dynamic website to static..

Discussion in 'Programming' started by kalius, Feb 21, 2005.

  1. #1
    Here's the deal, I have a dynamic website that I want to convert to static. The website is database/php driven, I want to create a "snapshot" of the website at a given time and have that "snapshot" replace the website.
     
    kalius, Feb 21, 2005 IP
  2. honey

    honey Prominent Member

    Messages:
    15,555
    Likes Received:
    712
    Best Answers:
    0
    Trophy Points:
    325
    #2
    I can do that. PM me.
     
    honey, Feb 21, 2005 IP
  3. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If your goal is to reduce server load, just cache yoru php output. As you create your page with php, just keep adding it to a variable instead of echoing it. at the end of the page, you output it, and save it to a cache file, which will be checked before re-generating it.
    Pseudo code:
    
    <?php
        $me = $SERVER['PHP_SELF'];
        $me = str_replace( '/', '_', $me );
        if( file_exists( $my_cache_dir.'/'.$me.'.txt' ) ){
            echo file_get_contents( $my_cache_dir.'/'.$me.'.txt' );
        }else{
             // Create my whole page here and save it in a variable
             $output = '';
             $output .= 'Hello world.';
             ...
             echo $output;
             $f = fopen( $my_cache_dir.'/'.$me.'.txt', 'w' );
             fputs( $f, $output );
             fclose( $f );
        }
    ?>
    
    PHP:
    And whenever you need to re-generate the pages, just clear out $my_cache_dir
     
    exam, Feb 21, 2005 IP
  4. kalius

    kalius Peon

    Messages:
    599
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #4
    My goal is to create a dynamic website on my local computer, Grab a Snapshot and upload that snapshot.
     
    kalius, Feb 22, 2005 IP
  5. nullbit

    nullbit Peon

    Messages:
    489
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You probably want some sort of spidering program.

    Which OS are you using? Your options will vary depending on that.
     
    nullbit, Feb 22, 2005 IP
  6. kalius

    kalius Peon

    Messages:
    599
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I'm using windows, but you can list some linux tools too, I know how to get around it too.
     
    kalius, Feb 22, 2005 IP
  7. nullbit

    nullbit Peon

    Messages:
    489
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #7
    For linux:

    Wget can recurse through your site, and convert files to static HTML.

    Type "man wget" in linux for the manual page. Wget is included with pretty much every linux distro.

    For Windows:

    I'll edit this post with Windows suggestions if I can think of any.
     
    nullbit, Feb 22, 2005 IP
    J.D. likes this.
  8. kalius

    kalius Peon

    Messages:
    599
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thanks a lot, *hits head*, I forgot linux comes with everything but the kitchensink, time to remove the dust from the knoppix cd.

    also wget ( and other gnu stuff) for windows
    http://unxutils.sourceforge.net/
     
    kalius, Feb 22, 2005 IP
  9. justicewhite

    justicewhite Well-Known Member

    Messages:
    240
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    138
    #9
    wget rocks :cool:

    Thanks guys for this.
     
    justicewhite, Feb 22, 2005 IP