Location: PHPKode > projects > Filebased News Mangagement > filebased-news-mangagement/include/backup.inc.php
<?php

  /**
  * data.txt backup to html
  * 6-1-2000, urs_at_circle_dot_ch
  */
  function backup_news($datafile = "data/mynews.txt") {

      $outputfile      = "data/mynews.htm";

      $content = file($datafile);
      $size = count($content);

      for($i=0; $i<count($content); $i++) {
          $myLINES[$i] = explode("|",$content[$i]);
      }

      if (!$fp = @fopen($outputfile, "w+")) {
          echo ("Unable to write to outputfile");
      } else {
          fputs ( $fp, "<html><table width=450 border=0 cellpadding=2 cellspacing=0>\n" );
          // last in last out
          for($j=count($content); $j>0; $j-- ) {
              // date
              fputs ( $fp, "<tr><td>" . stripslashes($myLINES[$j][1] )) ;
              // author
              fputs ( $fp, (strlen($myLINES[$j][4]) ? " - " : "" ) . stripslashes($myLINES[$j][4] ) . "</td></tr>\n" );
              // title
              fputs ( $fp, "<tr><td><b>" . stripslashes($myLINES[$j][2] ) . "</b></td></tr>\n" );
              // message
              fputs ( $fp, "<tr><td>" . stripslashes($myLINES[$j][3] ) . "</td></tr>\n" );
              // horizontal line
              fputs ( $fp, "<tr><td><hr width=100% size=1></td></tr>\n" );
          }
      }
      fputs ( $fp, "</table></html>\n");
      fclose( $fp );

  }

?>
Return current item: Filebased News Mangagement