source: trunk/src/inc/FileHandler.class.php@ 7637

Last change on this file since 7637 was 7637, checked in by Pieter Naber, 15 years ago

Updated ErrorHandler to use our LogHandler. Updated LogHandler with an adjustable error level.

File size: 1.1 KB
RevLine 
[7620]1<?
2/*
3 * Project: NodeMap2.0
4 * File: FileHandler.class.php
5 * Purpose: Checking and reading node files from the server
6 */
7
8class FileHandler {
[7621]9 private $file;
10
11 /*
12 * Function: __construct (constructor)
13 * Parameters: string $filename
14 * Function: Handling with a node file
15 */
[7631]16 public function __construct($filename) {
[7621]17 try {
[7637]18 trigger_log(SYSLOG_DEBUG, 'Opening the file "' . $filename . '"', __FILE__, __LINE__);
[7631]19 $handle = fopen($filename, 'r');
[7637]20
21 trigger_log(SYSLOG_DEBUG, 'Reading from file "' . $filename . '"', __FILE__, __LINE__);
[7631]22 $this->file = '';
23 while (!feof($handle)) {
24 $this->file .= fread($handle, 8192);
25 }
[7637]26
27 trigger_log(SYSLOG_DEBUG, 'Closing file "' . $filename . '"', __FILE__, __LINE__);
[7631]28 fclose($handle);
[7637]29
30 trigger_log(SYSLOG_INFO, 'Reading from file "' . $filename . '" is done', __FILE__, __LINE__);
[7621]31 } catch (Exception $err) {
32 // TODO: Better error description
[7637]33 trigger_log(SYSLOG_ERR, 'Reading from file "' . $filename . '" failed', __FILE__, __LINE__);
[7621]34 }
[7631]35 }
[7622]36
[7631]37 public function getFile() {
38 return $this->file;
[7621]39 }
[7620]40}
Note: See TracBrowser for help on using the repository browser.