當前位置: 首頁>>代碼示例>>PHP>>正文


PHP tar::loadfromstring方法代碼示例

本文整理匯總了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();
     }
 }
開發者ID:laiello,項目名稱:litepublisher,代碼行數:35,代碼來源:admin.sourcefiles.class.php

示例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;
 }
開發者ID:laiello,項目名稱:litepublisher,代碼行數:37,代碼來源:backuper.class.php

示例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');
 }
開發者ID:laiello,項目名稱:litepublisher,代碼行數:28,代碼來源:reinstall.php


注:本文中的tar::loadfromstring方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。