当前位置: 首页>>代码示例>>PHP>>正文


PHP Archive_Tar::createModify方法代码示例

本文整理汇总了PHP中Archive_Tar::createModify方法的典型用法代码示例。如果您正苦于以下问题:PHP Archive_Tar::createModify方法的具体用法?PHP Archive_Tar::createModify怎么用?PHP Archive_Tar::createModify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Archive_Tar的用法示例。


在下文中一共展示了Archive_Tar::createModify方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * Execute the action
  * 
  * @return mixed
  * @access public
  * @since 1/17/08
  */
 public function execute()
 {
     $harmoni = Harmoni::instance();
     $component = SiteDispatcher::getCurrentNode();
     $site = SiteDispatcher::getCurrentRootNode();
     $slotMgr = SlotManager::instance();
     $slot = $slotMgr->getSlotBySiteId($site->getId());
     $exportDir = DATAPORT_TMP_DIR . "/" . $slot->getShortname() . "-" . str_replace(':', '_', DateAndTime::now()->asString());
     mkdir($exportDir);
     try {
         // Do the export
         $visitor = new DomExportSiteVisitor($exportDir);
         $component->acceptVisitor($visitor);
         // Validate the result
         // 			printpre(htmlentities($visitor->doc->saveXMLWithWhitespace()));
         // 			$tmp = new Harmoni_DomDocument;
         // 			$tmp->loadXML($visitor->doc->saveXMLWithWhitespace());
         // 			$tmp->schemaValidateWithException(MYDIR."/doc/raw/dtds/segue2-site.xsd");
         $visitor->doc->schemaValidateWithException(MYDIR . "/doc/raw/dtds/segue2-site.xsd");
         // Write out the XML
         $visitor->doc->saveWithWhitespace($exportDir . "/site.xml");
         $archive = new Archive_Tar($exportDir . ".tar.gz");
         $archive->createModify($exportDir, '', DATAPORT_TMP_DIR);
         // Remove the directory
         $this->deleteRecursive($exportDir);
         header("Content-Type: application/x-gzip;");
         header('Content-Disposition: attachment; filename="' . basename($exportDir . ".tar.gz") . '"');
         print file_get_contents($exportDir . ".tar.gz");
         // Clean up the archive
         unlink($exportDir . ".tar.gz");
     } catch (PermissionDeniedException $e) {
         $this->deleteRecursive($exportDir);
         if (file_exists($exportDir . ".tar.gz")) {
             unlink($exportDir . ".tar.gz");
         }
         return new Block(_("You are not authorized to export this component."), ALERT_BLOCK);
     } catch (Exception $e) {
         $this->deleteRecursive($exportDir);
         if (file_exists($exportDir . ".tar.gz")) {
             unlink($exportDir . ".tar.gz");
         }
         throw $e;
     }
     error_reporting(0);
     exit;
 }
开发者ID:adamfranco,项目名称:segue,代码行数:53,代码来源:export.act.php

示例2: BagIt_compressBag

/**
 * This compresses the bag into a new file.
 *
 * @param string $dirname The directory to compress.
 * @param string $output  The output file.
 * @param string $method  Either 'tgz' or 'zip'. Default is 'tgz'.
 *
 * @return string The file name for the file.
 */
function BagIt_compressBag($dirname, $output, $method = 'tgz')
{
    $base = basename($dirname);
    $stripLen = strlen($dirname) - strlen($base);
    if ($method == 'zip') {
        $zip = new ZipArchive();
        $zip->open($output, ZIPARCHIVE::CREATE);
        foreach (rls($dirname) as $file) {
            $zip->addFile($file, substr($file, $stripLen));
        }
        $zip->close();
    } else {
        if ($method == 'tgz') {
            $tar = new Archive_Tar($output, 'gz');
            $tar->createModify($dirname, $base, $dirname);
        }
    }
}
开发者ID:AdrienneSerra,项目名称:Digitalsc,代码行数:27,代码来源:bagit_utils.php

示例3: pack_go

function pack_go()
{
    global $list, $options;
    $arc_name = basename($_POST["arc_name"] . '.' . $_POST["arc_ext"]);
    $saveTo = ($options['download_dir_is_changeable'] ? stripslashes($_POST["saveTo"][$i]) : realpath($options['download_dir'])) . '/';
    $v_list = array();
    if (!$_POST["arc_name"] || !$_POST["arc_ext"]) {
        echo lang(196) . "<br /><br />";
    } elseif (file_exists($saveTo . $arc_name)) {
        printf(lang(179), $arc_name);
        echo "<br /><br />";
    } else {
        for ($i = 0; $i < count($_POST["files"]); $i++) {
            $file = $list[$_POST["files"][$i]];
            if (file_exists($file["name"])) {
                $v_list[] = $file["name"];
            } else {
                printf(lang(145), $file['name']);
                echo "<br /><br />";
            }
        }
        if (count($v_list) < 1) {
            echo lang(137) . "<br /><br />";
        } else {
            $arc_name = $saveTo . $arc_name;
            require_once CLASS_DIR . "tar.php";
            $tar = new Archive_Tar($arc_name);
            if ($tar->error != '') {
                echo $tar->error . "<br /><br />";
            } else {
                $remove_path = realpath($options['download_dir']) . '/';
                $tar->createModify($v_list, '', $remove_path);
                if (!file_exists($arc_name)) {
                    echo lang(197) . "<br /><br />";
                } else {
                    if (count($v_list = $tar->listContent()) > 0) {
                        for ($i = 0; $i < sizeof($v_list); $i++) {
                            printf(lang(198), $v_list[$i]['filename']);
                            echo " <br />";
                        }
                        printf(lang(199), $arc_name);
                        echo "<br />";
                        $stmp = strtolower($arc_name);
                        $arc_method = "Tar";
                        if (!$options['disable_archive_compression']) {
                            if (strrchr($stmp, "tar.gz") + 5 == strlen($stmp)) {
                                $arc_method = "Tar.gz";
                            } elseif (strrchr($stmp, "tar.bz2") + 6 == strlen($stmp)) {
                                $arc_method = "Tar.bz2";
                            }
                        }
                        unset($stmp);
                        $time = explode(" ", microtime());
                        $time = str_replace("0.", $time[1], $time[0]);
                        $list[$time] = array("name" => $arc_name, "size" => bytesToKbOrMbOrGb(filesize($arc_name)), "date" => $time, "link" => "", "comment" => "archive " . $arc_method);
                    } else {
                        echo lang(200) . "<br /><br />";
                    }
                    if (!updateListInFile($list)) {
                        echo lang(9) . '<br /><br />';
                    }
                }
            }
        }
    }
}
开发者ID:mewtutorial,项目名称:RapidTube,代码行数:66,代码来源:pack.php

示例4: submitExportLang

 public function submitExportLang()
 {
     global $currentIndex;
     $lang = strtolower(Tools::getValue('iso_code'));
     $theme = strval(Tools::getValue('theme'));
     if ($lang and $theme) {
         $items = array_flip(Language::getFilesList($lang, $theme, false, false, false, false, true));
         $gz = new Archive_Tar(_PS_TRANSLATIONS_DIR_ . '/export/' . $lang . '.gzip', true);
         if ($gz->createModify($items, NULL, _PS_ROOT_DIR_)) {
         }
         Tools::redirect('translations/export/' . $lang . '.gzip');
         $this->_errors[] = Tools::displayError('An error occurred while creating archive.');
     }
     $this->_errors[] = Tools::displayError('Please choose a language and theme.');
 }
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:15,代码来源:AdminTranslations.php

示例5: message

 function Create_Tar($which_exported, $add_dirs)
 {
     global $dataDir, $langmessage;
     if (!$this->NewFile($which_exported, 'tar')) {
         return;
     }
     $this->Init_Tar();
     //$tar_object = new Archive_Tar($this->archive_path,'gz'); //didn't always work when compressin
     $tar_object = new Archive_Tar($this->archive_path);
     //if( gpdebug ){
     //	$tar_object->setErrorHandling(PEAR_ERROR_PRINT);
     //}
     if (!$tar_object->createModify($add_dirs, 'gpexport', $dataDir)) {
         message($langmessage['OOPS'] . '(5)');
         unlink($this->archive_path);
         return false;
     }
     //add in array so addModify doesn't split the string into an array
     $temp = array();
     $temp[] = $this->export_ini_file;
     if (!$tar_object->addModify($temp, 'gpexport', $this->temp_dir)) {
         message($langmessage['OOPS'] . '(6)');
         unlink($this->archive_path);
         return false;
     }
     //compression
     $compression =& $_POST['compression'];
     if (!isset($this->avail_compress[$compression])) {
         return true;
     }
     $new_path = $this->archive_path . '.' . $compression;
     $new_name = $this->archive_name . '.' . $compression;
     switch ($compression) {
         case 'gz':
             //gz compress the tar
             $gz_handle = @gzopen($new_path, 'wb9');
             if (!$gz_handle) {
                 return true;
             }
             if (!@gzwrite($gz_handle, file_get_contents($this->archive_path))) {
                 return true;
             }
             @gzclose($gz_handle);
             break;
         case 'bz':
             //gz compress the tar
             $bz_handle = @bzopen($new_path, 'w');
             if (!$bz_handle) {
                 return true;
             }
             if (!@bzwrite($bz_handle, file_get_contents($this->archive_path))) {
                 return true;
             }
             @bzclose($bz_handle);
             break;
     }
     unlink($this->archive_path);
     $this->archive_path = $new_path;
     $this->archive_name = $new_name;
     return true;
 }
开发者ID:GedionChang,项目名称:gpEasy-CMS,代码行数:61,代码来源:admin_port.php

示例6: basename


//.........这里部分代码省略.........
         // bundles of packages
         $contents = $contents['bundledpackage'];
         if (!isset($contents[0])) {
             $contents = array($contents);
         }
         $packageDir = $where;
         foreach ($contents as $i => $package) {
             $fname = $package;
             $file = $pkgdir . DIRECTORY_SEPARATOR . $fname;
             if (!file_exists($file)) {
                 return $packager->raiseError("File does not exist: {$fname}");
             }
             $tfile = $packageDir . DIRECTORY_SEPARATOR . $fname;
             System::mkdir(array('-p', dirname($tfile)));
             copy($file, $tfile);
             $filelist[$i++] = $tfile;
             $packager->log(2, "Adding package {$fname}");
         }
     } else {
         // normal packages
         $contents = $contents['dir']['file'];
         if (!isset($contents[0])) {
             $contents = array($contents);
         }
         $packageDir = $where;
         foreach ($contents as $i => $file) {
             $fname = $file['attribs']['name'];
             $atts = $file['attribs'];
             $orig = $file;
             $file = $pkgdir . DIRECTORY_SEPARATOR . $fname;
             if (!file_exists($file)) {
                 return $packager->raiseError("File does not exist: {$fname}");
             }
             $origperms = fileperms($file);
             $tfile = $packageDir . DIRECTORY_SEPARATOR . $fname;
             unset($orig['attribs']);
             if (count($orig)) {
                 // file with tasks
                 // run any package-time tasks
                 $contents = file_get_contents($file);
                 foreach ($orig as $tag => $raw) {
                     $tag = str_replace(array($this->_packagefile->getTasksNs() . ':', '-'), array('', '_'), $tag);
                     $task = "PEAR_Task_{$tag}";
                     $task = new $task($this->_packagefile->_config, $this->_packagefile->_logger, PEAR_TASK_PACKAGE);
                     $task->init($raw, $atts, null);
                     $res = $task->startSession($this->_packagefile, $contents, $tfile);
                     if (!$res) {
                         continue;
                         // skip this task
                     }
                     if (PEAR::isError($res)) {
                         return $res;
                     }
                     $contents = $res;
                     // save changes
                     System::mkdir(array('-p', dirname($tfile)));
                     $wp = fopen($tfile, "wb");
                     fwrite($wp, $contents);
                     fclose($wp);
                 }
             }
             if (!file_exists($tfile)) {
                 System::mkdir(array('-p', dirname($tfile)));
                 copy($file, $tfile);
             }
             chmod($tfile, $origperms);
             $filelist[$i++] = $tfile;
             $this->_packagefile->setFileAttribute($fname, 'md5sum', md5_file($tfile), $i - 1);
             $packager->log(2, "Adding file {$fname}");
         }
     }
     // }}}
     $name = $pf1 !== null ? 'package2.xml' : 'package.xml';
     $packagexml = $this->toPackageFile($where, PEAR_VALIDATE_PACKAGING, $name);
     if ($packagexml) {
         $tar = new Archive_Tar($dest_package, $compress);
         $tar->setErrorHandling(PEAR_ERROR_RETURN);
         // XXX Don't print errors
         // ----- Creates with the package.xml file
         $ok = $tar->createModify(array($packagexml), '', $where);
         if (PEAR::isError($ok)) {
             return $packager->raiseError($ok);
         } elseif (!$ok) {
             return $packager->raiseError('PEAR_Packagefile_v2::toTgz(): adding ' . $name . ' failed');
         }
         // ----- Add the content of the package
         if (!$tar->addModify($filelist, $pkgver, $where)) {
             return $packager->raiseError('PEAR_Packagefile_v2::toTgz(): tarball creation failed');
         }
         // add the package.xml version 1.0
         if ($pf1 !== null) {
             $pfgen =& $pf1->getDefaultGenerator();
             $packagexml1 = $pfgen->toPackageFile($where, PEAR_VALIDATE_PACKAGING, 'package.xml', true);
             if (!$tar->addModify(array($packagexml1), '', $where)) {
                 return $packager->raiseError('PEAR_Packagefile_v2::toTgz(): adding package.xml failed');
             }
         }
         return $dest_package;
     }
 }
开发者ID:michabbb,项目名称:pear-core,代码行数:101,代码来源:v2.php

示例7: toTgz

 /**
  * @param PEAR_Packager
  * @param bool if true, a .tgz is written, otherwise a .tar is written
  * @param string|null directory in which to save the .tgz
  * @return string|PEAR_Error location of package or error object
  */
 function toTgz(&$packager, $compress = true, $where = null)
 {
     require_once 'Archive/Tar.php';
     if ($where === null) {
         if (!($where = System::mktemp(array('-d')))) {
             return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: mktemp failed');
         }
     } elseif (!@System::mkDir(array('-p', $where))) {
         return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: "' . $where . '" could' . ' not be created');
     }
     if (file_exists($where . DIRECTORY_SEPARATOR . 'package.xml') && !is_file($where . DIRECTORY_SEPARATOR . 'package.xml')) {
         return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: unable to save package.xml as' . ' "' . $where . DIRECTORY_SEPARATOR . 'package.xml"');
     }
     if (!$this->_packagefile->validate(PEAR_VALIDATE_PACKAGING)) {
         return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: invalid package file');
     }
     $pkginfo = $this->_packagefile->getArray();
     $ext = $compress ? '.tgz' : '.tar';
     $pkgver = $pkginfo['package'] . '-' . $pkginfo['version'];
     $dest_package = getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext;
     if (file_exists(getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext) && !is_file(getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext)) {
         return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: cannot create tgz file "' . getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext . '"');
     }
     if ($pkgfile = $this->_packagefile->getPackageFile()) {
         $pkgdir = dirname(realpath($pkgfile));
         $pkgfile = basename($pkgfile);
     } else {
         return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: package file object must ' . 'be created from a real file');
     }
     // {{{ Create the package file list
     $filelist = array();
     $i = 0;
     foreach ($this->_packagefile->getFilelist() as $fname => $atts) {
         $file = $pkgdir . DIRECTORY_SEPARATOR . $fname;
         if (!file_exists($file)) {
             return PEAR::raiseError("File does not exist: {$fname}");
         } else {
             $filelist[$i++] = $file;
             if (!isset($atts['md5sum'])) {
                 $this->_packagefile->setFileAttribute($fname, 'md5sum', md5_file($file));
             }
             $packager->log(2, "Adding file {$fname}");
         }
     }
     // }}}
     $packagexml = $this->toPackageFile($where, PEAR_VALIDATE_PACKAGING, 'package.xml', true);
     if ($packagexml) {
         $tar = new Archive_Tar($dest_package, $compress);
         $tar->setErrorHandling(PEAR_ERROR_RETURN);
         // XXX Don't print errors
         // ----- Creates with the package.xml file
         $ok = $tar->createModify(array($packagexml), '', $where);
         if (PEAR::isError($ok)) {
             return $ok;
         } elseif (!$ok) {
             return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: tarball creation failed');
         }
         // ----- Add the content of the package
         if (!$tar->addModify($filelist, $pkgver, $pkgdir)) {
             return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: tarball creation failed');
         }
         return $dest_package;
     }
 }
开发者ID:crazy-max,项目名称:neard-bin-php,代码行数:70,代码来源:v1.php

示例8: PhpCompress

 /**
  * Create archive using php function and return the path
  *
  * @param  string  $dir    target dir
  * @param  array   $files  files names list
  * @param  string  $name   archive name
  * @param  array   $arc    archiver options
  * @return string|bool
  */
 protected function PhpCompress($dir, $files, $name, $archiver)
 {
     @ini_set('memory_limit', '256M');
     $path = $this->_joinPath($dir, $name);
     //format the list
     $list = array();
     foreach ($files as $file) {
         $list[] = $this->_joinPath($dir, $file);
     }
     // create archive object
     switch ($archiver['ext']) {
         case 'zip':
             include 'pclzip.lib.php';
             $archive = new PclZip($path);
             if (!$archive->Create($list, '', $dir)) {
                 return $this->SetError('errArchive');
             }
             break;
         case 'tgz':
         case 'tbz':
         case 'tar':
             include 'Archive_Tar.php';
             $archive = new Archive_Tar($path);
             if (!$archive->createModify($list, '', $dir)) {
                 return $this->SetError('errArchive');
             }
             break;
     }
     return $path;
 }
开发者ID:RyeZhu,项目名称:gpFinder,代码行数:39,代码来源:FinderVolumeLocalFileSystem.class.php

示例9: UploadCompressed

 /**
  * Save a compressed copy of the uploaded file
  *
  */
 function UploadCompressed(&$from, &$fName, &$upload_moved)
 {
     global $config, $dataDir, $langmessage;
     //check file type
     $file_type = admin_uploaded::GetFileType($fName);
     if (isset($config['check_uploads']) && $config['check_uploads'] === false) {
         return true;
     }
     if (in_array($file_type, $this->AllowedExtensions)) {
         return true;
     }
     $upload_moved = true;
     @ini_set('memory_limit', '256M');
     includeFile('thirdparty/ArchiveTar/Tar.php');
     //first move the file to a temporary folder
     //some installations don't like working with files in the default tmp folder
     do {
         $this->temp_folder = $dataDir . '/data/_temp/' . rand(1000, 9000);
     } while (file_exists($this->temp_folder));
     gpFiles::CheckDir($this->temp_folder, false);
     $temp_file = $this->temp_folder . '/' . $fName;
     $this->temp_files[] = $temp_file;
     if (!move_uploaded_file($from, $temp_file)) {
         $this->errorMessages[] = sprintf($langmessage['UPLOAD_ERROR'] . ' (UC1)', $fName);
         return false;
     }
     //prepare file names that may be used
     //replace . with underscore for security
     $fName = str_replace('.', '_', $fName);
     $tar_name = $fName . '.tar';
     $tgz_name = $fName . '.tgz';
     $tbz_name = $fName . '.tar.bz';
     //create a .tar archive of the file in the same folder
     $tar_path = $temp_file . '.tar';
     $this->temp_files[] = $tar_path;
     $tar_object = new Archive_Tar($tar_path);
     $files = array($temp_file);
     if (!$tar_object->createModify($files, '', $this->temp_folder)) {
         $this->errorMessages[] = sprintf($langmessage['UPLOAD_ERROR'] . ' (CM1)', $fName);
         return false;
     }
     $fName = $tar_name;
     $from = $tar_path;
     //compress if available, try gz first
     if (function_exists('gzopen')) {
         $compress_path = $temp_file . '.tgz';
         $this->temp_files[] = $compress_path;
         //gz compress the tar
         $gz_handle = @gzopen($compress_path, 'wb9');
         if ($gz_handle) {
             if (@gzwrite($gz_handle, file_get_contents($tar_path))) {
                 @gzclose($gz_handle);
                 $fName = $tgz_name;
                 $from = $compress_path;
                 //return true;
             }
         }
     }
     //if gz isn't available or doesn't work, try bz
     if (function_exists('bzopen')) {
         $compress_path = $temp_file . '.tbz';
         $this->temp_files[] = $compress_path;
         //gz compress the tar
         $bz_handle = @bzopen($compress_path, 'w');
         if ($bz_handle) {
             if (@bzwrite($bz_handle, file_get_contents($tar_path))) {
                 @bzclose($bz_handle);
                 $fName = $tbz_name;
                 $from = $compress_path;
                 return true;
             }
         }
     }
     return true;
 }
开发者ID:rizub4u,项目名称:gpEasy-CMS,代码行数:79,代码来源:admin_uploaded.php

示例10: switch

             switch ($_POST['compression_type']) {
                 case 'zip':
                     if (get_extension($name) != $_POST['compression_type']) {
                         $name .= '.' . $_POST['compression_type'];
                     }
                     require $GO_CONFIG->class_path . 'pclzip.class.inc';
                     $zip = new PclZip($path . $GO_CONFIG->slash . $name);
                     $zip->create($_POST['archive_files'], PCLZIP_OPT_REMOVE_PATH, $path);
                     break;
                 default:
                     if (get_extension($name) != $_POST['compression_type']) {
                         $name .= '.tar.' . $_POST['compression_type'];
                     }
                     require $GO_CONFIG->class_path . 'pearTar.class.inc';
                     $tar = new Archive_Tar($path . $GO_CONFIG->slash . $name, $_POST['compression_type']);
                     if (!$tar->createModify($_POST['archive_files'], '', $path . $GO_CONFIG->slash)) {
                         $feedback = '<p class="Error">' . $fb_failed_to_create . '</p>';
                         $task = 'create_archive';
                     }
                     break;
             }
         }
     }
     break;
 case 'extract':
     if (isset($_POST['files'])) {
         require $GO_CONFIG->class_path . 'pearTar.class.inc';
         require $GO_CONFIG->class_path . 'pclzip.class.inc';
         while ($file = array_shift($_POST['files'])) {
             if (strtolower(get_extension($file)) == 'zip') {
                 $zip = new PclZip($file);
开发者ID:BackupTheBerlios,项目名称:hpt-obm-svn,代码行数:31,代码来源:index.php

示例11: fwrite

        // avoid timeouts
        if (!($index++ % 50)) {
            Safe::set_time_limit(30);
            SQL::ping();
        }
    }
    // save the zipfile
    if ($handle = Safe::fopen($context['path_to_root'] . $file_name . '.zip', 'wb')) {
        fwrite($handle, $zipfile->get());
        fclose($handle);
        $context['text'] .= BR . Skin::build_link($file_name . '.zip', $file_name . '.zip', 'basic');
    }
    // start the tar file
    include_once '../included/tar.php';
    $tarfile = new Archive_Tar($context['path_to_root'] . $file_name . '.tgz');
    // extend the tar file as well
    if ($tarfile->createModify($all_files, '', $file_path)) {
        $context['text'] .= BR . Skin::build_link($file_name . '.tgz', $file_name . '.tgz', 'basic');
    }
    $context['text'] .= "</p>\n";
    // display the execution time
    $time = round(get_micro_time() - $context['start_time'], 2);
    $context['text'] .= '<p>' . sprintf(i18n::s('Script terminated in %.2f seconds.'), $time) . '</p>';
    // forward to the index page
    $menu = array('scripts/' => i18n::s('Server software'));
    $context['text'] .= Skin::build_list($menu, 'menu_bar');
    // remember the built
    Logger::remember('scripts/build.php: ' . i18n::c('The reference store has been rebuilt'));
}
// render the skin
render_skin();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:build.php

示例12: writePackage


//.........这里部分代码省略.........
         if ($row_authorStmt['primary_contact'] == 1) {
             // primary_contact
             $authors .= ', "cre"';
             $contMail = "";
             if ($row_authorStmt['email'] != NULL && strlen($row_authorStmt['email']) > 0) {
                 $contMail = " <" . $row_authorStmt['email'] . ">";
             }
             $pd->set("Maintainer", $row_authorStmt['first_name'] . " " . $row_authorStmt['last_name'] . $contMail);
         }
         $authors .= '))';
     }
     $authors .= ')';
     $pd->set("Authors@R", $authors);
     $temp = explode('-', $pd->get("Date"));
     $pkgName_and_ver = $this->rpositorydao->getNameNew($article_id, $pkgName);
     $pkgName = $pkgName_and_ver[0] . "_" . $pkgName_and_ver[1];
     #$pkgName = $pkgName. $versnumb['major'] .  '.' $versnumb['minor'];
     unset($temp);
     $pd->set("Package", $pkgName_and_ver[0]);
     // path to write the package to
     $archive = array();
     $archive['name'] = sys_get_temp_dir() . '/' . $pkgName;
     $archive['targz'] = sys_get_temp_dir() . '/' . $pkgName . '.tar';
     $archive['zip'] = sys_get_temp_dir() . '/' . $pkgName . '.zip';
     error_log('OJS - OJSPackager: welchen Wert hat $archive: ' . $archive);
     $pd->set("Version", $pkgName_and_ver[1]);
     $pd->set("License", "CC BY-NC (http://creativecommons.org/licenses/by-nc/3.0/de/)");
     // create a directory under the system temp dir for and copy the article and its supplementary files to there
     $tempDirRoot = $this->tmpDir();
     error_log("name and version" . json_encode($pkgName_and_ver));
     $tempDir = $tempDirRoot . "/" . $pkgName . "_" . $pkgName_and_ver[1];
     mkdir($tempDir);
     error_log("OJSPackager Tmpdir" . $tempDir);
     //$pdfile = $pdfile;
     //error_log("OJS - Rpository: ". $pdfile);
     rename($pd->toTempFile(), $tempDir . '/' . 'DESCRIPTION');
     $pw = new Archive_Tar($archive['targz'], 'gz');
     //$pw = new PharData($archive['targz']);
     $pharData = new PharData($archive['zip']);
     $result_fileStmt = $this->rpositorydao->getFileStatement($article_id);
     $submissionPreprintName = '';
     $suppCount = 0;
     foreach ($result_fileStmt as $row_fileStmt) {
         if ($row_fileStmt['type'] == 'supp') {
             $suppCount++;
         }
     }
     foreach ($result_fileStmt as $row_fileStmt) {
         $name = $row_fileStmt['file_name'];
         $origName = $row_fileStmt['original_file_name'];
         $type = $row_fileStmt['type'];
         if ($type == 'supp') {
             if ($suppCount != 1 || !$this->unpacker->canHandle($suppPath . $name)) {
                 if (!is_dir($tempDir . '/' . 'inst')) {
                     mkdir($tempDir . '/' . 'inst', 0777, TRUE);
                 }
                 if (!copy($suppPath . $name, trim($tempDir) . '/' . 'inst' . '/' . $origName)) {
                     error_log('OJS - rpository: error copying file: ' . $suppPath . $name . ' to: ' . trim($tempDir . '/' . 'inst' . '/' . $origName));
                 }
             } elseif ($this->unpacker->canHandle($suppPath . $name)) {
                 if (!is_dir($tempDir . '/' . 'inst')) {
                     mkdir($tempDir . '/' . 'inst', 0777, TRUE);
                 }
                 $unpackDir = $this->tmpDir();
                 $this->unpacker->unpackInto($suppPath . $name, $unpackDir);
                 $contentDir = get_content_dir($unpackDir);
                 move_dir_contents($contentDir, $tempDir . '/' . 'inst');
                 $this->deleteDirectory($unpackDir);
             }
         } elseif ($type == 'submission/original') {
             // TODO: pdf name wird nicht ermittelt // verzeichnisstruktur weicht von java version ab
             $submissionPreprintName = $origName;
             if (!is_dir($tempDir . '/' . 'inst' . '/' . 'preprint')) {
                 mkdir($tempDir . '/' . 'inst' . '/' . 'preprint', 0777, TRUE);
             }
             copy($this->filesPath . "/" . $article_id . "/submission/original/" . $name, trim($tempDir) . '/' . 'inst' . '/' . 'preprint' . '/' . $submissionPreprintName);
         } elseif ($type == 'public') {
             $submissionPreprintName = $origName;
             if (!is_dir($tempDir . '/' . 'inst' . '/' . 'preprint')) {
                 mkdir($tempDir . '/' . 'inst' . '/' . 'preprint', 0777, TRUE);
             }
             copy($preprPath . $name, trim($tempDir) . '/' . 'inst' . '/' . 'preprint' . '/' . $submissionPreprintName);
         }
     }
     error_log('OJS - OJSPackager: der Wert von $tempDir ' . $tempDir . ' und von pkgName ' . $pkgName);
     //PhardataDirectory
     $pharData->buildFromDirectory($tempDir);
     //$archive['zip']=$pharData->buildFromDirectory($tempDir);
     // create the archive with the temp directory we created above
     //$pw->buildFromDirectory($tempDir);
     //$pw->compress(Phar::GZ);
     if (!$pw->createModify($tempDir, "{$pkgName}" . '/', $tempDir)) {
         error_log("OJS - rpository: error writing archive");
     }
     // delete temp directory
     $this->deleteDirectory($tempDirRoot);
     // return the name of created archive
     error_log('OJS - OJSPackager: Ein Archive wurde erfolgreich zustande gebracht! mit dem archive ' . $archive);
     return $archive;
 }
开发者ID:ingmarschuster,项目名称:MindResearchRepository,代码行数:101,代码来源:OJSPackager.php

示例13: package

 function package($pkgfile = null, $compress = true)
 {
     // {{{ validate supplied package.xml file
     if (empty($pkgfile)) {
         $pkgfile = 'package.xml';
     }
     // $this->pkginfo gets populated inside
     $pkginfo = $this->infoFromDescriptionFile($pkgfile);
     if (PEAR::isError($pkginfo)) {
         return $this->raiseError($pkginfo);
     }
     $pkgdir = dirname(realpath($pkgfile));
     $pkgfile = basename($pkgfile);
     $errors = $warnings = array();
     $this->validatePackageInfo($pkginfo, $errors, $warnings, $pkgdir);
     foreach ($warnings as $w) {
         $this->log(1, "Warning: {$w}");
     }
     foreach ($errors as $e) {
         $this->log(0, "Error: {$e}");
     }
     if (sizeof($errors) > 0) {
         return $this->raiseError('Errors in package');
     }
     // }}}
     $pkgver = $pkginfo['package'] . '-' . $pkginfo['version'];
     // {{{ Create the package file list
     $filelist = array();
     $i = 0;
     foreach ($pkginfo['filelist'] as $fname => $atts) {
         $file = $pkgdir . DIRECTORY_SEPARATOR . $fname;
         if (!file_exists($file)) {
             return $this->raiseError("File does not exist: {$fname}");
         } else {
             $filelist[$i++] = $file;
             if (empty($pkginfo['filelist'][$fname]['md5sum'])) {
                 $md5sum = md5_file($file);
                 $pkginfo['filelist'][$fname]['md5sum'] = $md5sum;
             }
             $this->log(2, "Adding file {$fname}");
         }
     }
     // }}}
     // {{{ regenerate package.xml
     $new_xml = $this->xmlFromInfo($pkginfo);
     if (PEAR::isError($new_xml)) {
         return $this->raiseError($new_xml);
     }
     if (!($tmpdir = System::mktemp(array('-d')))) {
         return $this->raiseError("PEAR_Packager: mktemp failed");
     }
     $newpkgfile = $tmpdir . DIRECTORY_SEPARATOR . 'package.xml';
     $np = @fopen($newpkgfile, 'wb');
     if (!$np) {
         return $this->raiseError("PEAR_Packager: unable to rewrite {$pkgfile} as {$newpkgfile}");
     }
     fwrite($np, $new_xml);
     fclose($np);
     // }}}
     // {{{ TAR the Package -------------------------------------------
     $ext = $compress ? '.tgz' : '.tar';
     $dest_package = getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext;
     $tar = new Archive_Tar($dest_package, $compress);
     $tar->setErrorHandling(PEAR_ERROR_RETURN);
     // XXX Don't print errors
     // ----- Creates with the package.xml file
     $ok = $tar->createModify(array($newpkgfile), '', $tmpdir);
     if (PEAR::isError($ok)) {
         return $this->raiseError($ok);
     } elseif (!$ok) {
         return $this->raiseError('PEAR_Packager: tarball creation failed');
     }
     // ----- Add the content of the package
     if (!$tar->addModify($filelist, $pkgver, $pkgdir)) {
         return $this->raiseError('PEAR_Packager: tarball creation failed');
     }
     $this->log(1, "Package {$dest_package} done");
     if (file_exists("{$pkgdir}/CVS/Root")) {
         $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $pkginfo['version']);
         $cvstag = "RELEASE_{$cvsversion}";
         $this->log(1, "Tag the released code with `pear cvstag {$pkgfile}'");
         $this->log(1, "(or set the CVS tag {$cvstag} by hand)");
     }
     // }}}
     return $dest_package;
 }
开发者ID:radicaldesigns,项目名称:amp,代码行数:86,代码来源:Packager.php

示例14: pack_go

function pack_go()
{
    global $list, $options, $L;
    $arc_name = basename($_POST["arc_name"] . '.' . $_POST["arc_ext"]);
    $saveTo = ($options['download_dir_is_changeable'] ? stripslashes($_POST["saveTo"][$i]) : realpath($options['download_dir'])) . '/';
    $v_list = array();
    if (!$_POST["arc_name"] || !$_POST["arc_ext"]) {
        echo $L->say['enter_arc_name'] . "<br /><br />";
    } elseif (file_exists($saveTo . $arc_name)) {
        echo $L->sprintf($L->say['err_output_file_exist'], $arc_name) . "<br /><br />";
    } else {
        for ($i = 0; $i < count($_POST["files"]); $i++) {
            $file = $list[$_POST["files"][$i]];
            if (file_exists($file["name"])) {
                $v_list[] = $file["name"];
            } else {
                echo $L->sprintf($L->say['not_found'], $file['name']) . "<br /><br />";
            }
        }
        if (count($v_list) < 1) {
            echo "<b class=\"r\">" . $L->say['error_occur'] . "</b><br /><br />";
        } else {
            $arc_name = $saveTo . $arc_name;
            require_once CLASS_DIR . "tar.php";
            $tar = new Archive_Tar($arc_name);
            if ($tar->error != '') {
                echo $tar->error . "<br /><br />";
            } else {
                $remove_path = realpath($options['download_dir']) . '/';
                $tar->createModify($v_list, '', $remove_path);
                if (!file_exists($arc_name)) {
                    echo "<b class=\"r\">" . $L->say['_error'] . "</b> " . $L->say['arcv_not_created'] . "<br /><br />";
                } else {
                    if (count($v_list = $tar->listContent()) > 0) {
                        for ($i = 0; $i < sizeof($v_list); $i++) {
                            echo $L->sprintf($L->say['was_pack'], $v_list[$i]['filename']) . " <br />";
                        }
                        echo $L->sprintf($L->say['pack_in_arcv'], $arc_name) . "<br />";
                        $stmp = strtolower($arc_name);
                        $arc_method = "Tar";
                        if (!$options['disable_to']['act_archive_compression']) {
                            if (strrchr($stmp, "tar.gz") + 5 == strlen($stmp)) {
                                $arc_method = "Tar.gz";
                            } elseif (strrchr($stmp, "tar.bz2") + 6 == strlen($stmp)) {
                                $arc_method = "Tar.bz2";
                            }
                        }
                        unset($stmp);
                        $time = explode(" ", microtime());
                        $time = str_replace("0.", $time[1], $time[0]);
                        $list[$time] = array("name" => $arc_name, "size" => bytesToKbOrMbOrGb(filesize($arc_name)), "date" => $time, "link" => "", "comment" => "archive " . $arc_method);
                    } else {
                        echo "<b class=\"r\">" . $L->say['_error'] . "</b> " . $L->say['arcv_empty'] . "<br /><br />";
                    }
                    if (!updateListInFile($list)) {
                        echo $L->say['couldnt_upd'] . '<br /><br />';
                    }
                }
            }
        }
    }
}
开发者ID:laiello,项目名称:rapidleech36b,代码行数:62,代码来源:pack.php

示例15: submitExportLang

 public function submitExportLang()
 {
     if ($this->lang_selected->iso_code && $this->theme_selected) {
         $this->exportTabs();
         $items = array_flip(Language::getFilesList($this->lang_selected->iso_code, $this->theme_selected, false, false, false, false, true));
         $file_name = _PS_TRANSLATIONS_DIR_ . '/export/' . $this->lang_selected->iso_code . '.gzip';
         $gz = new \Archive_Tar($file_name, true);
         if ($gz->createModify($items, null, _PS_ROOT_DIR_)) {
             ob_start();
             header('Pragma: public');
             header('Expires: 0');
             header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
             header('Cache-Control: public');
             header('Content-Description: File Transfer');
             header('Content-type: application/octet-stream');
             header('Content-Disposition: attachment; filename="' . $this->lang_selected->iso_code . '.gzip' . '"');
             header('Content-Transfer-Encoding: binary');
             ob_end_flush();
             readfile($file_name);
             @unlink($file_name);
             exit;
         }
         $this->errors[] = $this->trans('An error occurred while creating archive.', array(), 'Admin.International.Notification');
     }
     $this->errors[] = $this->trans('Please select a language and a theme.', array(), 'Admin.International.Notification');
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:26,代码来源:AdminTranslationsController.php


注:本文中的Archive_Tar::createModify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。