file = $file; } function open($mode) { $this->id = @fopen($this->file, $mode); if (!$this->id) { trigger_error('Could not open '.$this->file.' in mode '.$mode.'.'); } return $this->id; } function close() { fclose($this->id); } function read($bytes = 1024) { return fgets($this->id, $bytes); } function write($data) { fwrite($this->id, $data); } function exists() { return file_exists($this->file); } function eof() { return feof($this->id); } function time() { return ($this->exists() ? filemtime($this->file) : false); } function write_once($data) { if (!$this->open('w')) { return false; } $this->write($data); $this->close(); return true; } function read_all() { $buffer = ''; while (!$this->eof()) { $buffer .= $this->read(); } return $buffer; } function read_once() { if (!$this->open('r')) { return false; } $buffer = $this->read_all(); $this->close(); return $buffer; } function is_uptodate($time) { return $this->time() >= $time; } } ?>