function mkArch($Folder1, $FolderToArch, $DestFile) { global $isWin, $Wrar; echo "{$Folder1}, {$FolderToArch}, {$DestFile}<br>"; # $newfile = new gzip_file($DestFile.".tgz"); $newfile = new tar_file($DestFile . ".tar"); $newfile->set_options(array('basedir' => $Folder1, 'overwrite' => 1)); $newfile->add_files($FolderToArch); $newfile->create_archive(); if (count($newfile->errors) > 0) { print "Errors occurred."; } }
function save_original($file_with_path, $in_test = false, $pack = false) { // globals var global $THIS_BASEPATH, $CURRENT_FOLDER; // just in case is not set.... if ($this->hack_path == "") { $this->hack_path = "{$THIS_BASEPATH}/hacks"; } if (!is_writable($this->hack_path)) { @chmod($this->hack_path, 0777); if (!is_writable($this->hack_path)) { $this->ftp_login_need = true; $new = true; foreach ($this->ftp_files_to_chmod as $ftcm) { if (in_array($this->hack_path, $ftcm)) { $new = false; } } if ($new) { $index = count($this->ftp_files_to_chmod); $this->ftp_files_to_chmod[$index]["file"] = $this->hack_path; $this->ftp_files_to_chmod[$index]["mode"] = "777"; } return false; } } if ($in_test) { return true; } if (!$pack) { $this->files_to_backup[] = $file_with_path; return true; } // no files to backup??? if (count($this->files_to_backup) == 0) { return true; } $archive = new tar_file($this->hack_path . "/backup-" . date("d-m-Y_H-i-s") . ".tar"); $archive->set_options(array("basedir" => "{$THIS_BASEPATH}")); foreach ($this->files_to_backup as $ftb) { $archive->add_files($ftb); } $archive->create_archive(); if (count($archive->errors) > 0) { $this->_err_message("Unable to write in {$this->hack_path}", "Folder", "Check chmod+chown for {$this->hack_path}"); return false; } return true; }