本文整理匯總了PHP中tar::saveTar方法的典型用法代碼示例。如果您正苦於以下問題:PHP tar::saveTar方法的具體用法?PHP tar::saveTar怎麽用?PHP tar::saveTar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tar
的用法示例。
在下文中一共展示了tar::saveTar方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: date
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY, without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
// //
// This product released under GNU General Public License v2 //
////////////////////////////////////////////////////////////////////////////////
if (!empty($_POST['backupit'])) {
if (!empty($_POST['gzip'])) {
$suffix = '.gz';
} else {
$suffix = '';
}
$bkupfilename = RCMS_ROOT_PATH . 'backups/backup_' . date('H-i-s_d.m.Y') . '.tar' . $suffix;
$backup = new tar();
$backup->isGzipped = !empty($_POST['gzip']);
$backup->filename = $bkupfilename;
$path = getcwd();
chdir(RCMS_ROOT_PATH);
$backup->addDirectory('config', true);
$backup->addDirectory('content', true);
chdir($path);
$backup->saveTar();
rcms_showAdminMessage(__('Backup complete') . ' (' . basename($bkupfilename) . ')');
}
// Interface generation
$frm = new InputForm('', 'post', __('Backup data'));
$frm->addbreak(__('Backup data'));
$frm->hidden('backupit', '1');
$frm->addrow(__('To backup all your data from directories "config" and "content" press "Create backup" button. Speed of backup creation depends on size of your site. In order to be more secure we do not provide any backups management from there. You must download or delete backups using FTP or another way to reach /backups/ folder, because HTTP access for it was forbidden.'));
$frm->addrow(__('Pack file with gzip (uncheck if you experience problems)'), $frm->checkbox('gzip', '1', '', true));
$frm->show();
示例2:
echo " There are no files described in this tar archive.<br>\n";
}
echo "<br>\n";
// Check if a file exists in the tar file
if ($tar->containsFile("fake.php")) {
echo "<b>This TAR Archive does contain a file called fake.php!</b><br>\n";
} else {
echo "<b>This TAR Archive does not contain any files called fake.php!</b><br>\n";
}
echo "<br>\n";
// Add a file to the archive
if ($tar->addFile("example.php")) {
echo "Added 'example.php' to archive!<br>\n";
} else {
echo "Could not add 'example.php' to archive!<br>\n";
}
echo "<br>\n";
// Save changes to a NEW tar file
if (!$tar->toTar("test.tgz", TRUE)) {
echo "Could not save Gzipped TAR Archive!<br>\n";
} else {
echo "New Gzipped TAR File generated successfully!<br>\n";
}
// Save changes to currently opened tar file using existing filename and gzip method
// already set when loading (main.tar, no gzip in this example)
if (!$tar->saveTar()) {
echo "Could not save TAR Archive!<br>\n";
} else {
echo "New Regular TAR File generated successfully!<br>\n";
}
echo "</font>";
示例3: logMerge
function logMerge($title, $t_d, $t_m, $t_y, $f_d = 1, $f_m = 1, $f_y = 1980)
{
$logs = rcms_scandir($this->logging);
$f = mktime(0, 0, 0, $f_m, $f_d, $f_y);
$t = mktime(0, 0, 0, $t_m, $t_d, $t_y);
$to_merge = array();
foreach ($logs as $log_entry) {
if (preg_match("/^(.*?)-(.*?)-(.*?)\\.log(|.gz)\$/i", $log_entry, $matches)) {
$c = mktime(0, 0, 0, $matches[2], $matches[3], $matches[1]);
if ($c >= $f && $c <= $t) {
$to_merge[] = $log_entry;
}
}
}
if (!empty($to_merge)) {
if ($this->logging_gz) {
$suffix = '.gz';
} else {
$suffix = '';
}
$merged_file = $this->logging . $title . '.tar' . $suffix;
$merged = new tar();
$merged->isGzipped = $this->logging_gz;
$merged->filename = $merged_file;
$path = getcwd();
chdir($this->logging);
foreach ($to_merge as $file) {
$merged->addFile($file, substr($file, -3) == '.gz');
}
chdir($path);
if ($merged->saveTar()) {
foreach ($to_merge as $file) {
rcms_delete_files($this->logging . $file);
}
}
}
return true;
}
示例4: tar
$tar->toTar("new.tar", FALSE);
// Normal TAR
// $tar->toFile("new.tgz",TRUE); // Gzipped TAR
unset($tar);
// Appending 2 tar files together, saving in gzipped format (Gzipping requires zlib)
$tar = new tar();
$tar->openTAR("my.tar", FALSE);
$tar->appendTar("another.tar", FALSE);
$tar->toTar("combined.tgz", TRUE);
unset($tar);
// Removing 2 files from the new.tar file created above
$tar = new tar();
$tar->openTar("new.tar", FALSE);
$tar->removeFile("example.php");
$tar->removeFile("example2.php");
$tar->saveTar();
// Saves to currently open TAR file (In this case, new.tar)
unset($tar);
// Check if a TAR file contains a specific file
$tar = new tar();
$tar->openTar("new.tar", FALSE);
if ($tar->containsFile("tar.class.php")) {
echo "This tar file contains a file named 'tar.class.php'!<br>\n";
} else {
echo "This tar file does NOT contain a file named 'tar.class.php'!<br>\n";
}
// There is no need to save our tar file since we did not edit it, so delete our tar class
unset($tar);
// Get information about a file in a TAR file
$tar = new tar();
$tar->openTar("new.tar");