2 error_reporting(E_ALL);
3 define ("BASE_PATH",".");
4 define ("FILES_DIR","logfiles");
8 private $basePath = BASE_PATH;
9 private $filesDir = FILES_DIR;
14 public function __construct($fileName) {
15 $this->fileName = $fileName;
16 $this->filePath = $this->basePath . DIRECTORY_SEPARATOR . $this->filesDir . DIRECTORY_SEPARATOR;
18 public function createFile($writeMode) {
19 if($this->fileHandle = fopen($this->filePath . $this->fileName, $writeMode)) {
25 public function closeFile(){
26 fclose($this->fileHandle);
29 public function writeToFile($dataToInsert) {
30 self::createFile('w');
31 if(fwrite($this->fileHandle , $dataToInsert)) {
37 public function appendToFile($dataToInsert){
38 self::createFile('a');
39 if(fwrite($this->fileHandle , $dataToInsert)) {
46 public function readFromFile($bytesToRead = 0){
47 self::createFile('r');
48 if($bytesToRead > 0) {
49 if($result = fread($this->fileHandle , $bytesToRead)) {
53 if($result = fread($this->fileHandle , filesize($this->filePath . $this->fileName))) {
66 $_POST["currentTest"] )
69 $file = new SevFile("log.txt");
70 $file->appendToFile( $_POST["currentTest"]."|". $obj["result"] ."|". $obj["actual"] ."|". $obj["expected"] ."|". $obj["message"] ."|". $obj["source"] ."\n" );
72 echo $_POST["currentTest"]."|". $obj["result"] ."|". $obj["actual"] ."|". $obj["expected"] ."|". $obj["message"] ."|". $obj["source"];
77 if( $_REQUEST["reset"] )
79 $file = new SevFile("log.txt");
80 $file->writeToFile("");