LogFile.class.php 680 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. class LogFile {
  3. public function append($filename, $message) {
  4. $fileHandle = null;
  5. if(!file_exists(LOG_PATH . $filename)) {
  6. $fileHandle = fopen(LOG_PATH . $filename, 'w');
  7. $message .= "\n";
  8. } else {
  9. $fileHandle = fopen(LOG_PATH . $filename, "a");
  10. $message .= "\n";
  11. }
  12. fwrite($fileHandle, $message);
  13. fclose($fileHandle);
  14. }
  15. public function outputHTML($filename) {
  16. $output = "";
  17. $fileHandle = fopen(LOG_PATH . $filename, "r");
  18. while(!feof($fileHandle)) {
  19. $line = fgets($fileHandle);
  20. if($line == "") {
  21. continue;
  22. }
  23. $output = "<tr><td>" . $line . "</td></tr>\n" . $output;
  24. }
  25. fclose($fileHandle);
  26. return $output;
  27. }
  28. }