本文整理汇总了PHP中tar::toTar方法的典型用法代码示例。如果您正苦于以下问题:PHP tar::toTar方法的具体用法?PHP tar::toTar怎么用?PHP tar::toTar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tar
的用法示例。
在下文中一共展示了tar::toTar方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
function main()
{
$tar = new tar();
$tar->addFile('./test.pdf');
$tar->toTar('./test_create.tar', false);
$tar1 = new tar();
$opened = $tar1->openTAR('./test_create.tar');
if ($opened) {
$soubor = $tar1->getFile('./test.pdf');
echo $soubor["file"];
} else {
echo "FAILED TO OPEN ARCHIVE";
}
}
示例2: MakeWikiZip
function MakeWikiZip($pExportFile)
{
global $gBitUser, $gBitSystem;
include_once UTIL_PKG_PATH . "tar.class.php";
$tar = new tar();
$query = "SELECT wp.`page_id` from `" . BIT_DB_PREFIX . "wiki_pages` wp INNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON (lc.`content_id` = wp.`content_id`) \n\t\t\t\t ORDER BY lc." . $this->mDb->convertSortmode("title_asc");
$result = $this->mDb->query($query, array());
while ($res = $result->fetchRow()) {
$page_id = $res["page_id"];
$content = $this->export_wiki_page($page_id, 0);
$tar->addData($page_id, $content, $gBitSystem->getUTCTime());
}
$tar->toTar($pExportFile, FALSE);
return '';
}
示例3: MakeWikiZip
function MakeWikiZip()
{
global $tikidomain;
$zipname = 'wikidb.zip';
include_once 'lib/tar.class.php';
$tar = new tar();
$query = 'select `pageName` from `tiki_pages` order by ' . $this->convertSortMode('pageName_asc');
$result = $this->query($query, array());
while ($res = $result->fetchRow()) {
$page = $res['pageName'];
$content = $this->export_wiki_page($page, 0);
$tar->addData($page, $content, $this->now);
}
$dump = 'dump';
if ($tikidomain) {
$dump .= "/{$tikidomain}";
}
$tar->toTar("{$dump}/export.tar", FALSE);
return '';
}
示例4: MakeWikiZip
function MakeWikiZip()
{
global $tikidomain;
$zipname = "wikidb.zip";
include_once "lib/tar.class.php";
$tar = new tar();
$query = "select `pageName` from `tiki_pages` order by " . $this->convert_sortmode("pageName_asc");
$result = $this->query($query, array());
while ($res = $result->fetchRow()) {
$page = $res["pageName"];
$content = $this->export_wiki_page($page, 0);
$tar->addData($page, $content, date("U"));
}
$dump = "dump";
if ($tikidomain) {
$dump .= "/{$tikidomain}";
}
$tar->toTar("{$dump}/export.tar", FALSE);
return '';
}
示例5: tar
function s_export_structure($structure_id)
{
global $exportlib, $tikidomain;
global $dbTiki;
include_once 'lib/wiki/exportlib.php';
include_once 'lib/tar.class.php';
$page_info = $this->s_get_structure_info($structure_id);
$page_name = $page_info['pageName'];
$zipname = $page_name . '.zip';
$tar = new tar();
$pages = $this->s_get_structure_pages($page_info['page_ref_id']);
foreach ($pages as $page) {
$data = $exportlib->export_wiki_page($page['pageName'], 0);
$tar->addData($page['pageName'], $data, $this->now);
}
$dump = 'dump';
if ($tikidomain) {
$dump .= "/{$tikidomain}";
}
$tar->toTar("{$dump}/{$page_name}.tar", FALSE);
header("location: {$dump}/{$page_name}.tar");
return '';
}
示例6: package
/**
* @param $mods_path
* @param $info_file
* @return bool|string
*/
function package($mods_path, $info_file)
{
$oldir = getcwd();
if (chdir($mods_path) === FALSE) {
$err = sprintf(tra("Can't chdir to '%s'"), $mods_path);
return $err;
}
include_once $oldir . '/lib/tar.class.php';
$info_file = 'Packages/' . $this->type . '-' . $this->name . '.info.txt';
$err = $this->readinfo($info_file);
if ($err !== FALSE) {
chdir($oldir);
return $err;
}
if (is_file("Dist/" . $this->type . '-' . $this->name . '-' . $this->revision . '.tgz')) {
unlink("Dist/" . $this->type . '-' . $this->name . '-' . $this->revision . '.tgz');
}
$tar = new tar();
$tar->addFile($info_file);
if (is_array($this->files)) {
foreach ($this->files as $f) {
$tar->addFile($f[0]);
}
}
$filename = 'Dist/' . $this->type . '-' . $this->name . '-' . $this->revision . '.tgz';
$tar->toTar($filename, 1);
if (!function_exists('md5_file')) {
$this->md5 = md5(implode('', file($filename)));
} else {
$this->md5 = md5_file($filename);
}
chmod($filename, 0644);
// needed on some servers
chdir($oldir);
return $err;
}
示例7: dump
function dump()
{
global $tikidomain, $prefs;
$parserlib = TikiLib::lib('parser');
$dump_path = "dump";
if ($tikidomain) {
$dump_path .= "/{$tikidomain}";
}
@unlink("{$dump_path}/new.tar");
$tar = new tar();
$tar->addFile('styles/' . $prefs['style']);
// Foreach page
$query = "select * from `tiki_pages`";
$result = $this->query($query, array());
while ($res = $result->fetchRow()) {
$pageName = $res["pageName"] . '.html';
$dat = $parserlib->parse_data($res["data"]);
// Now change index.php?page=foo to foo.html
// and index.php to HomePage.html
$dat = preg_replace("/tiki-index.php\\?page=([^\\'\"\$]+)/", "\$1.html", $dat);
$dat = preg_replace("/tiki-editpage.php\\?page=([^\\'\"\$]+)/", "", $dat);
//preg_match_all("/tiki-index.php\?page=([^ ]+)/",$dat,$cosas);
//print_r($cosas);
$data = "<html><head><title>" . $res["pageName"] . "</title><link rel='StyleSheet' href='styles/" . $prefs['style'] . "' type='text/css'></head><body><a class='wiki' href='" . $prefs['wikiHomePage'] . ".html'>home</a><br /><h1>" . $res["pageName"] . "</h1><div class='wikitext'>" . $dat . '</div></body></html>';
$tar->addData($pageName, $data, $res["lastModif"]);
}
$tar->toTar("{$dump_path}/new.tar", FALSE);
unset($tar);
$logslib = TikiLib::lib('logs');
$logslib->add_log('dump', 'dump created');
}
示例8: dump
function dump()
{
global $tikidomain, $wikiHomePage, $style;
$dump_path = "dump";
if ($tikidomain) {
$dump_path .= "/{$tikidomain}";
}
@unlink("{$dump_path}/new.tar");
$tar = new tar();
$tar->addFile("styles/{$style}");
// Foreach page
$query = "select * from `tiki_pages`";
$result = $this->query($query, array());
while ($res = $result->fetchRow()) {
$pageName = $res["pageName"] . '.html';
$dat = $this->parse_data($res["data"]);
// Now change index.php?page=foo to foo.html
// and index.php to HomePage.html
$dat = preg_replace("/tiki-index.php\\?page=([^\\'\"\$]+)/", "\$1.html", $dat);
$dat = preg_replace("/tiki-editpage.php\\?page=([^\\'\"\$]+)/", "", $dat);
//preg_match_all("/tiki-index.php\?page=([^ ]+)/",$dat,$cosas);
//print_r($cosas);
$data = "<html><head><title>" . $res["pageName"] . "</title><link rel='StyleSheet' href='styles/{$style}' type='text/css'></head><body><a class='wiki' href='{$wikiHomePage}.html'>home</a><br /><h1>" . $res["pageName"] . "</h1><div class='wikitext'>" . $dat . '</div></body></html>';
$tar->addData($pageName, $data, $res["lastModif"]);
}
$tar->toTar("{$dump_path}/new.tar", FALSE);
unset($tar);
$action = "dump created";
$t = date("U");
$query = "insert into `tiki_actionlog`(`action`,`pageName`,`lastModif`,`user`,`ip`,`comment`) values(?,?,?,?,?,?)";
$result = $this->query($query, array($action, $wikiHomePage, $t, 'admin', $_SERVER["REMOTE_ADDR"], ''));
}
示例9: copyqimage
echo $row[0] . ',' . $row[1] . "\n";
if ($GLOBALS['filehandertypecfiles'] == 's3') {
copyqimage($row[1], realpath("../assessment/qimages") . DIRECTORY_SEPARATOR . $row[1]);
}
$imgfiles[] = realpath("../assessment/qimages") . DIRECTORY_SEPARATOR . $row[1];
}
}
}
// need to work on
include "../includes/tar.class.php";
if (file_exists("../course/files/qimages.tar.gz")) {
unlink("../course/files/qimages.tar.gz");
}
$tar = new tar();
$tar->addFiles($imgfiles);
$tar->toTar("../course/files/qimages.tar.gz", TRUE);
exit;
} else {
//STEP 1 DATA MANIPULATION
if ($isadmin || $isgrpadmin || $isadminpage) {
$curBreadcrumb = "<div class=breadcrumb>{$breadcrumbbase} <a href=\"admin.php\">Admin</a> > Export libraries</div>\n";
} else {
$curBreadcrumb = "<div class=breadcrumb>{$breadcrumbbase} <a href=\"../course/course.php?cid={$cid}\">{$coursename}</a> > Export Libraries</div>\n";
}
}
}
/******* begin html output ********/
require "../header.php";
if ($overwriteBody == 1) {
echo $body;
} else {
示例10:
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>";
示例11: tar
// Include TAR Class
include "tar.class.php";
// Creating a NEW Tar file
$tar = new tar();
$tar->addFile("exmaple.php");
$tar->addFile("example2.php");
$tar->addFile("tar.class.php");
$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 {
示例12: package
function package($path, $type, $package)
{
$oldir = getcwd();
chdir($path);
include_once $oldir . '/lib/tar.class.php';
$file = 'Packages/' . $type . '-' . $package . '.info.txt';
$info = $this->readconf($file);
if (is_file("Dist/" . $type . '-' . $package . '-' . $info['revision'][0] . '.tgz')) {
unlink("Dist/" . $type . '-' . $package . '-' . $info['revision'][0] . '.tgz');
}
$tar = new tar();
$tar->addFile($file);
if (isset($info['files']) and count($info['files'])) {
foreach ($info['files'] as $f) {
$tar->addFile($f[0]);
}
}
$filename = 'Dist/' . $type . '-' . $package . '-' . $info['revision'][0] . '.tgz';
$tar->toTar($filename, 1);
if (!function_exists('md5_file')) {
$md5 = md5(implode('', file($filename)));
} else {
$md5 = md5_file($filename);
}
chdir($oldir);
return $md5;
}