本文整理汇总了PHP中zipfile::addfile方法的典型用法代码示例。如果您正苦于以下问题:PHP zipfile::addfile方法的具体用法?PHP zipfile::addfile怎么用?PHP zipfile::addfile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zipfile
的用法示例。
在下文中一共展示了zipfile::addfile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ft_zip_page
/**
* Implementation of hook_page.
* Zip current file/folder
*/
function ft_zip_page($act)
{
global $ft;
if ($act == 'zip') {
$_REQUEST['file'] = trim(ft_stripslashes($_REQUEST['file']));
// nom de fichier/repertoire
$zip = new zipfile();
if ($ft["plugins"]["zip"]["filebuffer"]) {
$zip->setOutFile($ft["plugins"]["zip"]["filebuffer"]);
}
$substr_base = strlen(ft_get_dir()) + 1;
foreach (ft_zip_getfiles(ft_get_dir() . '/' . $_REQUEST['file']) as $file) {
$filename = substr($file, $substr_base);
$filesize = filesize($file);
if ($filesize > 0) {
$fp = fopen($file, 'r');
$content = fread($fp, $filesize);
fclose($fp);
} else {
$content = '';
}
$zip->addfile($content, $filename);
}
if ($ft["plugins"]["zip"]["filebuffer"]) {
$zip->finish();
$filesize = filesize($ft["plugins"]["zip"]["filebuffer"]);
} else {
$archive = $zip->file();
$filesize = strlen($archive);
}
header('Content-Type: application/x-zip');
header('Content-Disposition: inline; filename="' . $_REQUEST['file'] . '.zip"');
header('Content-Length: ' . $filesize);
if ($ft["plugins"]["zip"]["filebuffer"]) {
readfile($ft["plugins"]["zip"]["filebuffer"]);
unlink($ft["plugins"]["zip"]["filebuffer"]);
} else {
echo $archive;
}
exit;
}
}
示例2: while
while ($row = mysql_fetch_assoc($result)) {
echo $row['Field'] . "; ";
$l++;
}
}
echo "\n";
$values = mysql_query('SELECT * FROM ' . $table . $clause_where);
while ($rowr = mysql_fetch_row($values)) {
for ($j = 0; $j < $l; $j++) {
$d = str_replace('"', '""', $rowr[$j]);
echo '"' . str_replace('
', '\\n', $d) . '";';
}
echo "\n";
}
$zip->addfile(utf8_decode(ob_get_contents()), $nom_fichier);
//on ajoute le fichier
ob_end_clean();
//on vide le cache
}
}
$archive = $zip->file();
// on associe l'archive
// on enregistre l'archive dans un fichier
$open = fopen('exports/' . $filename . '.zip', "wb");
fwrite($open, $archive);
fclose($open);
// code à insérer à la place des 3lignes ( fopen, fwrite, fclose )
header('Content-Type: application/x-zip');
//on détermine les en-tête
header('Content-Disposition: inline; filename=' . $filename . '.zip');
示例3: die
<?php
include "config.php";
if (isset($_REQUEST['p'])) {
$path = $_REQUEST['p'];
} else {
die("Unknown path!");
}
require_once 'zip.lib.php';
$zip = new zipfile();
$cmd = "/usr/bin/find files/{$path} -name \"*\" | grep -v svn | grep -v DS_Store";
exec($cmd, $files);
if (count($files) == 0) {
die("No files to download");
}
foreach ($files as $key => $filename) {
if (!is_dir($filename)) {
$fp = fopen($filename, 'r');
$content = fread($fp, filesize($filename));
fclose($fp);
$filename = str_replace("files/", "", $filename);
$zip->addfile($content, $filename);
}
}
$archive = $zip->file();
$archive_name = str_replace("//", "/", $path);
$archive_name = str_replace("/", "_", $archive_name);
header('Content-Type: application/x-zip');
header('Content-Disposition: inline; filename=' . $archive_name . '.zip');
echo $archive;
示例4: URLCrypt
if ($crypteretour == 'OUI') {
echo URLCrypt($bindRes[$i], $PublicKey) . 'PHP4WDSEP';
} else {
echo $bindRes[$i] . 'PHP4WDSEP';
}
}
}
if ($methode == 'zip') {
$value = $value . '--FINSQL--' . 'PHP4WDSEP';
} else {
echo '--FINSQL--' . 'PHP4WDSEP';
}
$func_close($session);
if ($methode == 'zip') {
$zip = new zipfile();
$zip->addfile($value, $filename);
$archive = $zip->file();
if ($crypteretour == 'OUI') {
$archive = URLCrypt($archive, $PublicKey);
}
// céation d'un fichier temporaire
$tmpfname = tempnam("/tmp", "arch_");
$handle = fopen($tmpfname, 'a');
fwrite($handle, $archive);
fclose($handle);
$fsize = filesize($tmpfname);
$bufsize = 20000;
header("HTTP/1.1 200 OK");
header("Content-Length: {$fsize}");
header("Content-Type: application/force-download");
header("Pragma: no-cache");
示例5: array
function Lib_zipDirectory($filename, $replace = 0, $extension = '.zip', $tab_files = array())
{
$filename_gz = '../../img_ftp/' . $filename . $extension;
Lib_myLog("Debut zipDirectory {$filename}");
if ($replace && file_exists($filename_gz)) {
unlink($filename_gz);
}
if (!empty($tab_files)) {
// création d'un objet 'zipfile'
$zip = new zipfile();
// Création du zip
foreach ($tab_files as $chemin_archive => $file) {
$fp = fopen('../../img_ftp/' . $file, 'r');
$content = fread($fp, filesize('../../img_ftp/' . $file));
fclose($fp);
// ajout du fichier dans l'objet 'zipfile'
$zip->addfile($content, $chemin_archive);
}
// production de l'archive' Zip
$archive = $zip->file();
$fp = fopen($filename_gz, "w");
fputs($fp, '../../img_ftp/' . $archive);
fclose($fp);
}
}