/** * Save a backup of the file * */ function SaveBackup() { global $dataDir; $dir = $dataDir . '/data/_backup/pages/' . $this->gp_index; gpFiles::CheckDir($dir); $time = time(); if (isset($_REQUEST['revision']) && is_numeric($_REQUEST['revision'])) { $time = $_REQUEST['revision']; } $contents = gpFiles::GetRaw($this->file); //backup file name $len = strlen($contents); $backup_file = $dir . '/' . $time . '.' . $len; if (isset($this->file_stats['username']) && $this->file_stats['username']) { $backup_file .= '.' . $this->file_stats['username']; } //compress if (function_exists('gzencode') && function_exists('readgzfile')) { $backup_file .= '.gze'; $contents = gzencode($contents, 9); } gpFiles::Save($backup_file, $contents); $this->CleanBackupFolder(); }
/** * Save a backup of the file * */ public function SaveBackup() { global $dataDir; $dir = $dataDir . '/data/_backup/pages/' . $this->gp_index; if ($this->draft_exists) { $contents = gpFiles::GetRaw($this->draft_file); $time = $this->draft_stats['modified']; } else { $contents = gpFiles::GetRaw($this->file); $time = $this->file_stats['modified']; } //backup file name $len = strlen($contents); $backup_file = $dir . '/' . $time . '.' . $len; if (isset($this->file_stats['username']) && $this->file_stats['username']) { $backup_file .= '.' . $this->file_stats['username']; } //compress if (function_exists('gzencode') && function_exists('readgzfile')) { $backup_file .= '.gze'; $contents = gzencode($contents, 9); } if (!gpFiles::Save($backup_file, $contents)) { return false; } $this->CleanBackupFolder(); return true; }