本文整理汇总了PHP中tar::loadfromstring方法的典型用法代码示例。如果您正苦于以下问题:PHP tar::loadfromstring方法的具体用法?PHP tar::loadfromstring怎么用?PHP tar::loadfromstring使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tar
的用法示例。
在下文中一共展示了tar::loadfromstring方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processform
public function processform()
{
$plugin = tsourcefiles::i();
if (isset($_POST['download'])) {
set_time_limit(300);
$version = litepublisher::$options->version;
if (!(($s = http::get("http://litepublisher.googlecode.com/files/litepublisher.{$version}.tar.gz")) || ($s = http::get("http://litepublisher.com/download/litepublisher.{$version}.tar.gz")))) {
return 'Error download';
}
tbackuper::include_tar();
$tar = new tar();
$tar->loadfromstring($s);
if (!is_array($tar->files)) {
unset($tar);
return 'Invalid file archive';
}
tfiler::delete($plugin->root, true, false);
foreach ($tar->files as $item) {
$filename = $plugin->root . $item['name'];
$dir = dirname($filename);
if (!is_dir($dir)) {
$this->mkdir($dir);
}
file_put_contents($filename, $item['file']);
@chmod($filename, 0666);
}
unset($tar);
$plugin->reread();
} elseif (isset($_POST['reread'])) {
$plugin->reread();
} else {
$plugin->root = $_POST['root'];
$plugin->save();
}
}
示例2: unpack
public function unpack($content, $archtype)
{
$result = array();
if ($archtype == 'zip') {
$archtype = 'unzip';
}
$this->archtype = $archtype;
//$this->createarchive();
switch ($archtype) {
case 'tar':
self::include_tar();
$tar = new tar();
$tar->loadfromstring($content);
if (!is_array($tar->files)) {
unset($tar);
return $this->errorarch();
}
foreach ($tar->files as $item) {
$result[$item['name']] = $item['file'];
}
unset($tar);
break;
case 'unzip':
case 'zip':
self::include_unzip();
$unzip = new StrSimpleUnzip();
$unzip->ReadData($content);
foreach ($unzip->Entries as $item) {
$result[$item->Path . '/' . $item->Name] = $item->Data;
}
unset($unzip);
break;
default:
$this->unknown_archive();
}
return $result;
}
示例3: install
public static function install()
{
$dir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
//test write
if (!file_put_contents($dir . 'test.php', ' ')) {
die('Error write to test.php');
}
chmod($dir . 'test.php', 0666);
unlink($dir . 'test.php');
if ($version = self::getlatest()) {
if (($s = http::get("http://litepublisher.googlecode.com/files/litepublisher.{$version}.tar.gz")) || ($s = http::get("http://litepublisher.com/download/litepublisher.{$version}.tar.gz"))) {
$tar = new tar();
$tar->loadfromstring($s);
foreach ($tar->files as $file) {
$filename = $dir . str_replace('/', DIRECTORY_SEPARATOR, $file['name']);
if (!self::forcedir(dirname($filename))) {
die("error create folder " . dirname($filename));
}
if (false === @file_put_contents($filename, $file['file'])) {
die(sprintf('Error write file %s', $filename));
}
@chmod($filename, 0666);
}
return true;
}
}
die('Error download last release');
}