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


PHP ZipArchive::addGlob方法代码示例

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


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

示例1: create_zip_package

function create_zip_package($dir, $destination)
{
    $zip = new ZipArchive();
    if ($zip->open($destination, ZipArchive::OVERWRITE) !== true) {
        echo 'Failed to create ' . $destination . ' with code ' . $ret;
        return false;
    } else {
        $zip->addGlob($dir . '/*.php', GLOB_BRACE, array('add_path' => '/' . basename($dir) . '/', 'remove_all_path' => true));
        $zip->addFile($dir . '/package-info.xml', 'package-info.xml');
        $zip->addFile($dir . '/agreement.txt', 'agreement.' . basename($dir) . '.txt');
        $zip->close();
        return true;
    }
}
开发者ID:ahrasis,项目名称:tools,代码行数:14,代码来源:pack_langs.php

示例2: downloadAction

 /**
  * Скачать архив с резервной копией
  *
  */
 public function downloadAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     if ($this->hasParam('dir')) {
         $dir = $this->getParam('dir');
         $zip = new ZipArchive();
         $ret = $zip->open($zipFile = TEMP_PATH . DS . $dir . '.zip', ZipArchive::OVERWRITE);
         if ($ret !== TRUE) {
             printf('Failed with code %d', $ret);
         } else {
             $options = array('add_path' => 'backup/', 'remove_all_path' => TRUE);
             $zip->addGlob(TEMP_PATH . DS . 'Backups/' . $dir . '/*.*', GLOB_BRACE, $options);
             $zip->close();
             header('Content-Type: ' . System_Mime_Type::mime($zipFile));
             header('Content-Length: ' . filesize($zipFile));
             header("Content-Disposition: attachment; filename=\"" . basename($zipFile) . "\";");
             header("Content-Transfer-Encoding: binary");
             ob_end_flush();
             readfile($zipFile);
             unlink($zipFile);
             exit;
         }
     }
 }
开发者ID:kytvi2p,项目名称:ZettaFramework,代码行数:29,代码来源:AdminController.php

示例3: makeComicBookFromDir

 public static function makeComicBookFromDir($dir, $extension = "cbr")
 {
     if (!is_dir($dir)) {
         return false;
     }
     $zipFile = $dir . "." . $extension;
     $zipArchive = new ZipArchive();
     if (!$zipArchive->open($zipFile, ZIPARCHIVE::OVERWRITE)) {
         die("Failed to create archive\n");
     }
     $zipArchive->addGlob($dir . "/*");
     if (!$zipArchive->status == ZIPARCHIVE::ER_OK) {
         echo "Failed to write files to zip\n";
     }
     $zipArchive->close();
     return true;
 }
开发者ID:eltonmoura,项目名称:sandbox,代码行数:17,代码来源:Util.class.php

示例4: printf

<?php

require "vendor/autoload.php";
\D2LView\StaticPages::generate(".", "phtml");
$zip = new \ZipArchive();
$ret = $zip->open('courseShell.zip', ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);
if ($ret !== TRUE) {
    printf('Failed with code %d', $ret);
} else {
    $zip->addGlob('*.{html,xml}', GLOB_BRACE);
    $zip->close();
}
开发者ID:rhildred,项目名称:d2lview,代码行数:12,代码来源:index.php

示例5: generarZip

 private function generarZip()
 {
     $zip = new ZipArchive();
     $ret = $zip->open($this->pathCirculares . "/circulares{$_SESSION['usuarioPortal']['Id']}.zip", ZipArchive::OVERWRITE);
     if ($ret !== TRUE) {
         printf('Erróneo con el código %d', $ret);
     } else {
         $options = array('add_path' => "/", 'remove_all_path' => TRUE);
         $ok = $zip->addGlob("{$this->pathCirculares}/{$_SESSION['usuarioPortal']['Id']}_*.rtf", GLOB_BRACE, $options);
         $zip->close();
         if ($ok) {
             // Borrar los archivos
             foreach (glob("{$this->pathCirculares}/{$_SESSION['usuarioPortal']['Id']}_*.rtf") as $nombreArchivo) {
                 @unlink($nombreArchivo);
             }
         }
     }
 }
开发者ID:albatronic,项目名称:agentescloud,代码行数:18,代码来源:Circulares.class.php

示例6: json_encode

 along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
error_reporting(E_ERROR);
require '../init.php';
$data['error'] = "error";
$data['message'] = "Unknown error";
try {
    if (!$authAdmin) {
        throw new Exception("Access denied. Please login as an Admin to continue.");
    }
    $dump = new DumpSQL();
    $sqlFile = $dump->getDumpFile();
    $zipFile = "data/backup_" . BASE . "_" . date('Y-m-d') . ".zip";
    $options = array('remove_all_path' => true, 'add_path' => 'screens/');
    $zip = new ZipArchive();
    $zip->open(INSTALL_PATH . $zipFile, ZipArchive::CREATE | ZipArchive::OVERWRITE);
    $zip->addFile(INSTALL_PATH . $sqlFile, basename($sqlFile));
    $zip->addGlob(DATA_PATH . '*', null, $options);
    $zip->close();
    unlink(INSTALL_PATH . $sqlFile);
    $data['error'] = 'OK';
    $data['message'] = $LANG['Backup_OK'];
    $data['dumpfile'] = $zipFile;
} catch (Exception $e) {
    $data['message'] = $e->getMessage();
}
header('HTTP/1.1 200 OK');
header('Content-type: application/json; charset=UTF-8');
echo ")]}',\n";
// Pour sécu anti injection JSONP
echo json_encode($data, JSON_UNESCAPED_UNICODE);
开发者ID:polosson,项目名称:bughunter,代码行数:31,代码来源:backup.php

示例7: elseif

} elseif ($action === 'download_attachments') {
    try {
        // Get the year
        $year = date('Y', strtotime($listPeriode[$id_periode - 1]['date_debut']));
        // Create the zip
        $zipFilename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'afup_justificatifs-' . $year . '.zip';
        $zip = new ZipArchive();
        $ret = $zip->open($zipFilename, ZipArchive::CREATE);
        if ($ret !== true) {
            throw new RuntimeException("Impossible to open the Zip archive.");
        } else {
            for ($month = 1; $month <= 12; $month++) {
                $searchDir = sprintf('%d%02d', $year, $month);
                $zipDir = sprintf('%d%02d', $year, $month);
                $options = ['add_path' => 'afup_justificatifs-' . $year . '/' . $zipDir . '/', 'remove_all_path' => true];
                $zip->addGlob(AFUP_CHEMIN_RACINE . '/uploads/' . $searchDir . '/*.*', 0, $options);
            }
            $zip->close();
            // Download it
            header('Content-Type: application/zip');
            header("Content-Transfer-Encoding: Binary");
            header("Content-disposition: attachment; filename=\"" . basename($zipFilename) . "\"");
            readfile($zipFilename);
            unlink($zipFilename);
            exit;
        }
    } catch (Exception $e) {
        header('HTTP/1.1 400 Bad Request');
        header('X-Info: ' . $e->getMessage());
        exit;
    }
开发者ID:fferriere,项目名称:web,代码行数:31,代码来源:compta_banque.php

示例8: createModArchive

 private function createModArchive()
 {
     $zip = new ZipArchive();
     $filename = self::PACKAGE . '-' . self::VERSION . '.zip';
     if ($zip->open($this->getBuildDir() . DIRECTORY_SEPARATOR . $filename, ZipArchive::CREATE) !== true) {
         throw new RuntimeException('Zip create error');
     }
     $zip->addGlob('*.php');
     $zip->addGlob('*.xml');
     $zip->addGlob('*.txt');
     $zip->addGlob('languages/*.xml');
     $zip->addGlob('upgrades/*.*');
     $zip->deleteName('RoboFile.php');
     //self
     $zip->close();
     $this->say("Created zip {$filename}");
 }
开发者ID:VladCleantalk,项目名称:smf-antispam,代码行数:17,代码来源:RoboFile.php

示例9: generateAttachmentDownload

 function generateAttachmentDownload()
 {
     $file_path = getcwd() . '/output_files_work/';
     array_map('unlink', glob($file_path . "*"));
     $zipFileName = getcwd() . '/output_files/hy_image_2016.zip';
     //cleanup
     array_map('unlink', glob($file_path . "*"));
     array_map('unlink', glob(getcwd() . '/output_files/*'));
     $tables = ["articles", "q2", "q3", "q4", "q5", "q6", "q7", "q8", "q9"];
     $this->setReportFilter();
     for ($i = 0; $i < count($tables); $i++) {
         array_map('unlink', glob($file_path . "*"));
         //extract attachment out from DB
         $query = "select attachment_type, attachment, attachment_name from " . $tables[$i] . " where attachment is not null";
         if (trim($this->report_filter) != '') {
             $query = $query . " AND " . $this->report_filter;
         }
         $result = $this->runQuery($query);
         foreach ($result as $row) {
             file_put_contents($file_path . $row['attachment_name'], $row['attachment']);
         }
         //create zip file
         $zip = new ZipArchive();
         if ($zip->open($zipFileName, ZipArchive::CREATE) !== TRUE) {
             exit("cannot open <{$zipFileName}>\n");
         }
         $options = array('add_path' => $i + 1 . '/', 'remove_all_path' => TRUE);
         $zip->addGlob($file_path . "/*", GLOB_BRACE, $options);
         $zip->close();
     }
     if (file_exists($zipFileName)) {
         //send zip file to browser
         $download_file_name = "hy_" . $_POST['wuzhong'] . ".zip";
         header("Content-Type: application/zip");
         header("Content-Disposition: attachment; filename={$download_file_name}");
         header("Content-Length: " . filesize($zipFileName));
         readfile($zipFileName);
     } else {
         $this->f3->set('message', "没有找到附加文件");
         $this->f3->set('report_filter', $_POST['wuzhong']);
         $this->f3->set('view', 'report/report.html');
         $this->f3->set('showMenu', false);
         echo Template::instance()->render('layout.htm');
         //		echo Template::instance()->render('report.html');
         echo $this->generatePageBody();
     }
 }
开发者ID:srccn,项目名称:hy,代码行数:47,代码来源:ReportController.php

示例10: zipFolderContent

function zipFolderContent($folder, $fileName)
{
    $zip = new ZipArchive();
    $zipFile = $folder . '/' . $fileName . '.zip';
    if ($zip->open($zipFile, ZipArchive::CREATE) !== TRUE) {
        die('cannot open ' . $fileName);
    }
    $options = array('add_path' => $fileName . '/', 'remove_all_path' => TRUE);
    $zip->addGlob($folder . '/*', 0, $options);
    $zip->close();
}
开发者ID:hbeyer,项目名称:liddel-tool,代码行数:11,代码来源:select.php

示例11: ZipArchive

<?php

$zipFile = new ZipArchive();
$zipFile->open("./binaries.zip", ZipArchive::CREATE);
$directories = ["../imagick/images/spiderGif/*.png"];
foreach ($directories as $directory) {
    $zipFile->addGlob($directory);
}
$zipFile->close();
开发者ID:sdmmember,项目名称:Imagick-demos,代码行数:9,代码来源:makeZipFile.php

示例12: fopen

$rows = $db->query("SELECT * FROM backup where type like '27' and userid = " . $userid);
while ($row = $rows->fetchArray()) {
    $source = $row['image'];
    $refid = $row['refid'];
    //$source = "https://myapps.gia.edu/ReportCheckPortal/downloadReport.do?reportNo=1152872617&weight=1.35";
    $ch = curl_init($source);
    $destination = "./saved/" . $username . "." . $refid . ".jpg";
    $file = fopen($destination, "w+");
    curl_setopt($ch, CURLOPT_FILE, $file);
    curl_setopt($ch, CURLOPT_TIMEOUT, 20);
    //curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($Channel, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    //curl_setopt($ch, CURLOPT_SSLVERSION,3);
    $data = curl_exec($ch);
    $error = curl_error($ch);
    curl_close($ch);
    fclose($File);
    print $refid . "<br>";
}
$zipFile = "./" . $userid . ".zip";
$zipArchive = new ZipArchive();
if (!$zipArchive->open($zipFile, ZIPARCHIVE::OVERWRITE)) {
    die("Failed to create archive\n");
}
$zipArchive->addGlob("./saved/" . $userid . "*.jpg");
if (!$zipArchive->status == ZIPARCHIVE::ER_OK) {
    echo "Failed to write files to zip\n";
}
$zipArchive->close();
开发者ID:unofficial-anomo-api,项目名称:open,代码行数:31,代码来源:filesave.php

示例13: buildZipFile

 /**
  * Baut die ZIP-Datei auf.
  */
 private function buildZipFile()
 {
     $this->changePermissions();
     shell_exec('cd "' . $this->sProjectPath . '" && sudo make singlehtml');
     $zip = new ZipArchive();
     if ($zip->open('' . $this->sProjectPath . '/html.zip', ZipArchive::OVERWRITE)) {
         $zip->addFile('' . $this->sProjectPath . '/build/singlehtml/index.html', "index.html");
         $zip->addFile('' . $this->sProjectPath . '/build/singlehtml/objects.inv', "objects.inv");
         $zip->addGlob('' . $this->sProjectPath . '/build/singlehtml/_static/*', GLOB_ERR, array('add_path' => '_static/', 'remove_all_path' => TRUE));
         $zip->close();
     } else {
         die("zip erstellung ");
     }
 }
开发者ID:JanUrb,项目名称:Web-SystemeFL-WP,代码行数:17,代码来源:SphinxDocument.php

示例14: addFiles

 /**
  * Add files
  *
  * @param    string       $subfolder  The subfolder
  * @param    \ZipArchive  $zip        The zip object
  * @param    string       $path       Optional path
  *
  * @return  void
  */
 private function addFiles($subfolder, $zip, $path = null)
 {
     if (!$path) {
         $path = $this->current;
     }
     if ($subfolder->isFile()) {
         // Set all separators to forward slashes for comparison
         $usefolder = str_replace('\\', '/', $subfolder->getPath());
         // Drop the folder part as we don't want them added to archive
         $addpath = str_ireplace($path, '', $usefolder);
         // Remove preceding slash
         $findfirst = strpos($addpath, '/');
         if ($findfirst == 0 && $findfirst !== false) {
             $addpath = substr($addpath, 1);
         }
         if (strlen($addpath) > 0 || empty($addpath)) {
             $addpath .= '/';
         }
         $options = array('add_path' => $addpath, 'remove_all_path' => true);
         $zip->addGlob($usefolder . '/*.*', GLOB_BRACE, $options);
     }
 }
开发者ID:yvesh,项目名称:jbuild,代码行数:31,代码来源:Package.php

示例15: dirname

<?php

$dirname = dirname(__FILE__) . '/';
include $dirname . 'utils.inc';
$file = $dirname . '__tmp_oo_addglob.zip';
copy($dirname . 'test.zip', $file);
touch($dirname . 'foo.txt');
touch($dirname . 'bar.baz');
$zip = new ZipArchive();
if (!$zip->open($file)) {
    exit('failed');
}
$options = array('add_path' => 'baz/', 'remove_all_path' => TRUE);
if (!$zip->addGlob($dirname . '*.{txt,baz}', GLOB_BRACE, $options)) {
    echo "failed1\n";
}
if ($zip->status == ZIPARCHIVE::ER_OK) {
    dump_entries_name($zip);
    $zip->close();
} else {
    echo "failed2\n";
}
开发者ID:gleamingthecube,项目名称:php,代码行数:22,代码来源:ext_zip_tests_oo_addglob.php


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