usr = $usr; $this->periodo = $periodo; if(trim($filename) == ""){ $this->file = sha1("file_".$usr.$periodo).".txt"; }else $this->file = $filename; if(preg_match('/\bapsa_pruebas\b/', $_SERVER['PHP_SELF']) ){ $ruta = "apsa_pruebas"; }else $ruta = "apsa"; $this->dir = $_SERVER['DOCUMENT_ROOT']."/".$ruta."/files/"; } function getFileName(){ return $this->file; } function cleanFile(){ $filename = $this->dir.$this->file; if (!file_exists($this->dir)){ mkdir($this->dir, 0755, true); } if (file_exists($this->dir)){ file_put_contents($filename, ""); } } function appendFile($row){ $filename = $this->dir.$this->file; if (!file_exists($this->dir)){ mkdir($this->dir, 0755, true); } if (file_exists($this->dir)){ $data = $row."\n"; file_put_contents($filename, $data, FILE_APPEND); } } function getFile(){ $filename = $this->dir.$this->file; if (file_exists($filename)){ return file ($filename , FILE_SKIP_EMPTY_LINES); }else{ return array(); } } }