defaultPath = 'backup'.DIRECTORY_SEPARATOR; if(empty($fileName)) { $this->filePath = $this->getDefaultFilePath(); }else{ $folder = $this->getDefaultFolderPath(); $this->filePath = $folder.$fileName; } } private function getDefaultFolderPath() { require 'config.inc.php'; $rootPath = (strrpos($root_directory, DIRECTORY_SEPARATOR) !== false)? $root_directory. DIRECTORY_SEPARATOR:$root_directory; $rootPath = $this->fixPathSeparator($rootPath); return $rootPath.$this->defaultPath; } public function fixPathSeparator($path) { $start = 0; do { $done = false; $index = strpos($path, '/',$start); $start = $index + 1; if($index != false && $path[$index - 1] == '\\'.DIRECTORY_SEPARATOR) { continue; }else if($index != false){ $path[$index] = DIRECTORY_SEPARATOR; } }while($index != false); return $path; } public function getDefaultFilePath() { $folder = $this->getDefaultFolderPath(); return $folder.strtotime("now").'.sql'; } public function startBackup() { $this->file = fopen($this->filePath, 'w'); parent::startBackup(); } protected function writeLine($string) { fwrite($this->file,$string."\n"); } public function finishBackup() { parent::finishBackup(); fclose($this->file); } public function getFilePath() { return $this->filePath; } } ?>