path.DIRECTORY_SEPARATOR.$file, 'a+'); $this->saveBackup($file); fputcsv($fp, $data, "\t"); } public function saveBackup($file){ // if dir doesn't exist, create it if (!is_dir($this->path.DIRECTORY_SEPARATOR."backup")) mkdir($this->path."backup", 0700); $oldfile = $this->path.$file; if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { // set new file location to copy to (backup) $newfile = $this->path."\\backup\\$file"; } else { $newfile = $this->path."backup/$file"; } if (!copy($oldfile, $newfile)) { echo "Failed to create backup of $file...\n"; } } public function saveTblEnries($filename) { $post = $_POST; if (!is_dir($this->path."tblEntries")) mkdir($this->path."tblEntries", 0700); // write for .tbl $str = '"'.$post['index'].'"'."\t".'"'.$post['index'].'"'.PHP_EOL; $file = $this->path."\\tblEntries\\$filename"; file_put_contents($file, $str, FILE_APPEND); } public function __construct() { $this->path = TXT_PATH; } } ?>