本文整理汇总了PHP中create_zip函数的典型用法代码示例。如果您正苦于以下问题:PHP create_zip函数的具体用法?PHP create_zip怎么用?PHP create_zip使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_zip函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: zipNotDups
private function zipNotDups()
{
$aFiles = array();
$results = $this->getNotDups();
while ($row = mysql_fetch_assoc($results)) {
array_push($aFiles, $this->extractTo . $row['file_name']);
}
return create_zip($aFiles, $this->extractTo . $this->userId . '.zip', true, false);
}
示例2: shareOnMarket
public static function shareOnMarket(&$market)
{
$cibDir = dirname(__FILE__) . '/../../../../' . config::byKey('userScriptDir', 'script') . '/' . $market->getLogicalId();
if (!file_exists($cibDir)) {
throw new Exception('Impossible de trouver le script :' . $cibDir);
}
$tmp = dirname(__FILE__) . '/../../../../tmp/' . $market->getLogicalId() . '.zip';
if (!create_zip($cibDir, $tmp)) {
throw new Exception('Echec de création du zip. Répertoire source : ' . $cibDir . ' / Répertoire cible : ' . $tmp);
}
return $tmp;
}
示例3: shareOnMarket
public static function shareOnMarket(&$market)
{
$informations = explode('.', $market->getLogicalId());
$cibDir = realpath(dirname(__FILE__) . '/../template/' . $informations[0] . '/cmd.' . $informations[1] . '.' . $informations[2] . '.' . $informations[3] . '.html');
if (!file_exists($cibDir)) {
throw new Exception('Impossible de trouver le widget ' . $cibDir);
}
$tmp = dirname(__FILE__) . '/../../../../tmp/' . $market->getLogicalId() . '.zip';
if (!create_zip($cibDir, $tmp)) {
throw new Exception('Echec de création du zip. Répertoire source : ' . $cibDir . ' / Répertoire cible : ' . $tmp);
}
return $tmp;
}
示例4: create_zip
function create_zip($folder, $files, $destination, $msg = false, $zip = null)
{
if (!function_exists('zip_open')) {
MSGError("Zip file error -- zip not installed (" . getFunctionName() . ")");
LogError("Zip file error -- zip not installed (" . getFunctionName() . ")");
}
$ds = DIRECTORY_SEPARATOR;
if ($ds == "") {
$ds = "/";
}
$dest = null;
if ($zip == null) {
$zip = new ZipArchive();
if ($zip->open($destination, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) {
return -1;
}
$dest = $destination;
$destination = '.';
}
foreach ($files as $file) {
if ($msg) {
echo "Packing file " . $file . "\n";
}
if (($pos = strrpos($file, $ds)) !== false) {
$file = substr($file, $pos + 1);
}
if (is_dir($folder . $ds . $file) === true) {
$zip->addEmptyDir($file);
create_zip($folder . $ds . $file, glob($folder . $ds . $file . $ds . '*'), $file, $msg, $zip);
} else {
if (is_file($folder . $ds . $file) === true) {
$zip->addFile($folder . $ds . $file, $destination . $ds . $file);
}
}
}
if ($dest != null) {
$zip->close();
if (file_exists($dest)) {
return 1;
} else {
return 0;
}
} else {
return 1;
}
}
示例5: export_zip
function export_zip($tables, $output_file)
{
$output_folder = sys_get_temp_dir() . "/openbiblio_export";
if (!file_exists($output_folder)) {
mkdir($output_folder);
}
foreach ($tables as $table) {
create_csv($table, $output_folder);
}
$output_file = sys_get_temp_dir() . "/" . $output_file;
$files = scandir($output_folder);
if (create_zip($files, $output_folder, $output_file, true)) {
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename={$output_file}");
header("Content-Transfer-Encoding: binary");
readfile($output_file);
} else {
print "Cannot export a zipped file.";
}
}
示例6: header
{
header("Content-Disposition: attachment; filename=\"" . $fname . "\"");
header("Content-Description: File Transfer");
header("Content-Transfer-Encoding: binary");
}
// *** we need to "exit()" executed options *** //
// *** else we might output also the trailling content *** //
if (isset($_GET['cleancache'])) {
clean_cache();
echo "Done";
exit;
}
if (isset($_POST['createzip'])) {
$zpath = zip_path();
if (!file_exists($zpath) || !_CACHE) {
create_zip($zpath);
// If no cache we need to forward the temp zip path
// for the chained ajax request
if (!_CACHE) {
header('Content-Type: application/json');
echo json_encode(array('zip' => basename($zpath)));
}
}
exit;
}
if (isset($_GET['zip'])) {
if (_CACHE) {
$zpath = zip_path();
} else {
// use basename to avoid path injection
// Note: sys_get_temp_dir drops any trailling slash
示例7: array
<?php
include "incl/functions.php";
include "incl/config.php";
if ($do_file_download) {
//create zip file
$selected_file_paths = array();
foreach ($_REQUEST['selected_files'] as $selected_file) {
$selected_file_path = $save_dir . basename($selected_file);
if (is_readable($selected_file_path)) {
array_push($selected_file_paths, $selected_file_path);
}
}
$zipfile_path = $temp_dir . 'scanned_' . time() . '.zip';
if (sizeof($selected_file_paths) > 0) {
create_zip($selected_file_paths, $zipfile_path, true);
if (is_readable($zipfile_path)) {
//output path to created file
echo $zipfile_path;
}
}
}
/* creates a compressed zip file */
function create_zip($files = array(), $destination = '', $overwrite = false)
{
//if the zip file already exists and overwrite is false, return false
if (file_exists($destination) && !$overwrite) {
return false;
}
//vars
$valid_files = array();
示例8: set_download_headers
}
function set_download_headers($O)
{
header("Content-Disposition: attachment; filename=\"" . $O . "\"");
header("Content-Description: File Transfer");
header("Content-Transfer-Encoding: binary");
}
if (isset($_GET['cleancache'])) {
clean_cache();
echo "Done";
exit;
}
if (isset($_POST['createzip'])) {
$F = zip_path();
if (!file_exists($F) || !_CACHE) {
create_zip($F);
if (!_CACHE) {
header('Content-Type: application/json');
echo json_encode(array('zip' => basename($F)));
}
}
exit;
}
if (isset($_GET['zip'])) {
if (_CACHE) {
$F = zip_path();
} else {
$F = sys_get_temp_dir() . '/' . basename($_GET['zip']);
}
set_download_headers(GNAME . ".zip");
send_file($F, 'application/zip');
示例9: dirname
$ds = DIRECTORY_SEPARATOR;
//1
$storeFolder = '';
//2
if (!empty($_FILES)) {
$tempFile = $_FILES['file']['tmp_name'];
//3
$targetPath = dirname(__FILE__) . $ds . $storeFolder . $ds;
//4
$targetFile = $targetPath . $_FILES['file']['name'];
//5
$call_log_file = str_replace('-all', '', basename($targetFile));
$upload_file = $targetPath . $call_log_file;
move_uploaded_file($tempFile, $upload_file);
//6
$result = create_zip($upload_file, 'test.zip');
}
function create_zip($files = array(), $destination = '', $overwrite = false)
{
//if the zip file already exists and overwrite is false, return false
if (file_exists($destination) && !$overwrite) {
return false;
}
//vars
$valid_files = array();
//if files were passed in...
if (is_array($files)) {
//cycle through each file
foreach ($files as $file) {
//make sure the file exists
if (file_exists($file)) {
示例10: base64_encode
@file_put_contents($fname . ".tmp", base64_encode(serialize($data0)));
@rename($fname . ".tmp", $fname . ".dat");
$data0 = array();
if ($level > 0) {
list($score, $data0) = DBScoreSite($_SESSION["usertable"]["contestnumber"], $_SESSION["usertable"]["usersitenumber"], 1, -1);
}
$ct = DBGetActiveContest();
$localsite = $ct['contestlocalsite'];
$fname = $remotedir . $ds . "score_site" . $localsite . "_" . $localsite . "_x";
// . md5($_SERVER['HTTP_HOST']);
@file_put_contents($fname . ".tmp", base64_encode(serialize($data0)));
@rename($fname . ".tmp", $fname . ".dat");
scoretransfer($fname . ".dat", $localsite);
if (@create_zip($remotedir, glob($remotedir . '/*.dat'), $fname . ".tmp") != 1) {
LOGError("Cannot create score zip file");
if (@create_zip($remotedir, array(), $fname . ".tmp") == 1) {
@rename($fname . ".tmp", $destination);
}
} else {
@rename($fname . ".tmp", $destination);
}
@fclose($fp);
@unlink($destination . ".lck");
} else {
if (file_exists($destination . ".lck", 'x') && filemtime($destination . ".lck", 'x') < time() - 180) {
@unlink($destination . ".lck");
}
}
}
}
}
示例11: file
function file()
{
// dump out file
$data = implode("", $this->datasec);
$ctrldir = implode("", $this->ctrl_dir);
return $data . $ctrldir . $this->eof_ctrl_dir . pack("v", sizeof($this->ctrl_dir)) . pack("v", sizeof($this->ctrl_dir)) . pack("V", strlen($ctrldir)) . pack("V", strlen($data)) . "";
// .zip file comment length
}
}
include "plog-globals.php";
include "plog-load_config.php";
connect_db();
if (!isset($_REQUEST["checked"]) || !is_array($_REQUEST["checked"])) {
echo 'No pictures were selected.';
} else {
create_zip($_REQUEST["checked"], $_REQUEST["dl_type"]);
}
function create_zip($checked, $level)
{
global $zipfile;
$dir = "Plogger." . date("Y.m.d") . "/";
$zipfile = new zipfile();
// add the subdirectory ... important!
// $zipfile -> add_dir($dir);
add_photos($checked, $level, $dir, $zipfile);
// the next three lines force an immediate download of the zip file:
header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename=plog-package-" . date("Y.m.d") . ".zip");
echo $zipfile->file();
return;
}
示例12: rand
require 'includes/functions.php';
include 'includes/header.php';
if ($_GET['download']) {
// Zip File Name + Path Configuration
$imagePath = "bebo_downloads/";
$zipPath = "zips/";
$salt = rand(9000000000, 9999999999);
$zip_name = $zipPath . $salt . "_bebo_pictures.zip";
// Split out text input to seperate lines
$urlArray = explode("\n", $_POST['lines']);
$urlOutcome = checkURL($urlArray);
if ($urlOutcome == FALSE) {
// Pull images from POST into Array then generate zip file
$new_pics = savePics($urlArray, $imagePath);
$result = create_zip($new_pics, $zip_name);
// Display success / fail message
if ($result) {
echo "<h1>Success!</h1>\n\t\t\t\t\t<div class=\"descr\">Your file is ready to be downloaded!</div>\n\t\t\t\t\t<p>Go <a href=\"download_images.php?filename=" . $salt . "_bebo_pictures.zip\">here</a> to retrieve it.<br /><br /><b>Note:</b> Once you have downloaded your file, it will be removed from our server immediately for security reasons. If you need to download it again please repeat the process.</p>";
} else {
echo "Hmm, something didn't work quite right! Please report it to johnathan [at] weleasewodewick.com";
}
// Tidy up pictures
deletePics($new_pics);
} else {
echo "<h1>Error! :o(</h1>\n\t\t\t\t\t <div class=\"descr\">Problem with your URLs</div>\n\t\t\t\t\t <p>Oops ... one of your URL's doesn't look like a bebo.com address. Try copying and pasting from the Bebo App again. Or, if you think this is an error, email what you pasted to johnathan [at] weleasewodewick.com";
}
} else {
// display form to kick off the process
echo "<h1>Process your images</h1>\n\t\t\t\t<div class=\"descr\">Just paste the lines of URL's into the box below, and click submit!</div>\n\t\t\t\t\t<p><b>Note:</b> This script will connect to Bebo's servers and download all the images that you specify - if you put in dozens/hundreds of pictures, expect it to take a few minutes to complete. If the page/script gives you a timeout error, consider doing half, or even quarter of your list at a time</p>\n\t\t\t\t\t<p><font color=\"#FF0000\">300 lines of images generally = a 1-3 minute download time. Zip file size of 13-15MB. In our tests 300+ images equals timeouts.</font></p>\n\t\t\t\t<form action=\"get_images.php?download=yes\" method=\"post\">\n\t\t\t\t<textarea cols=\"65\" rows=\"8\" name=\"lines\"></textarea><br />\n\t\t\t\t<input type=\"submit\">\n\t\t\t";
}
示例13: ZipArchive
//make sure the file exists
if (file_exists($file)) {
$valid_files[] = $file;
}
}
}
//if we have good files...
if (count($valid_files)) {
//create the archive
$zip = new ZipArchive();
if ($zip->open($destination, $overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
return false;
}
//add the files
foreach ($valid_files as $file) {
$zip->addFile($file, $file);
}
//debug
//echo 'The zip archive contains ',$zip->numFiles,' files with a status of ',$zip->status;
//close the zip — done!
$zip->close();
//check to make sure the file exists
return file_exists($destination);
} else {
return false;
}
}
$files_to_zip = array('add_page_step2.php', 'save_page.php', 'add_page.php');
//if true, good; if false, zip creation failed
$result = create_zip($files_to_zip, 'my-archive.zip');
示例14: shareOnMarket
public static function shareOnMarket(&$market)
{
$informations = explode('.', $market->getLogicalId());
$tmp_dir = realpath(dirname(__FILE__) . '/../../../../tmp/') . '/' . $market->getLogicalId();
if (file_exists($tmp_dir)) {
if (!rrmdir($tmp_dir)) {
throw new Exception(__('Impossible de supprimer : ', __FILE__) . $tmp_dir . __('. Vérifiez les droits', __FILE__));
}
}
mkdir($tmp_dir);
if (!file_exists($tmp_dir) || !is_dir($tmp_dir)) {
throw new Exception(__('Impossible de creer : ', __FILE__) . $tmp_dir . __('. Vérifiez les droits', __FILE__));
}
$cibDirs = array();
$cibDirs[0] = realpath(dirname(__FILE__) . '/../template/' . $informations[0] . '/cmd.' . $informations[1] . '.' . $informations[2] . '.' . $informations[3] . '.html');
if (!file_exists($cibDirs[0])) {
throw new Exception(__('Impossible de trouver le widget ', __FILE__) . $cibDirs[0]);
}
if (!rcopy($cibDirs[0], $tmp_dir . '/cmd.' . $informations[1] . '.' . $informations[2] . '.' . $informations[3] . '.html', false, array(), true)) {
throw new Exception(__('Impossible de copier ', __FILE__) . $cibDirs[0] . ' => ' . $tmp_dir);
}
$cibDirs[1] = realpath(dirname(__FILE__) . '/../template/' . $informations[0]) . '/cmd.' . $informations[1] . '.' . $informations[2] . '.' . $informations[3];
if (file_exists($cibDirs[1])) {
mkdir($tmp_dir . '/cmd.' . $informations[1] . '.' . $informations[2] . '.' . $informations[3]);
if (!rcopy($cibDirs[1], $tmp_dir . '/cmd.' . $informations[1] . '.' . $informations[2] . '.' . $informations[3], false, array(), true)) {
throw new Exception(__('Impossible de copier ', __FILE__) . $cibDirs[1] . ' => ' . $tmp_dir);
}
}
$tmp = dirname(__FILE__) . '/../../../../tmp/' . $market->getLogicalId() . '.zip';
if (file_exists($tmp)) {
if (!unlink($tmp)) {
throw new Exception(__('Impossible de supprimer : ', __FILE__) . $tmp . __('. Vérifiez les droits', __FILE__));
}
}
if (!create_zip($tmp_dir, $tmp)) {
throw new Exception(__('Echec de création du zip. Répertoire source : ', __FILE__) . $tmp_dir . __(' / Répertoire cible : ', __FILE__) . $tmp);
}
return $tmp;
}
示例15: chdir
chdir("photos/{$folder_name}");
} catch (Exception $e) {
}
$photo_list = array();
$curl = new Curl();
# get photos
foreach ($_POST as $key => $value) {
$response = $curl->get($value);
# move file to correct directory
$destination = "{$key}.jpg";
$file = fopen($destination, "w+");
fputs($file, $response->body);
fclose($file);
# add to photo list array
$photo_list[] = $destination;
}
try {
$zipped = create_zip($photo_list, 'facebook.zip');
} catch (Exception $e) {
}
if ($zipped) {
# delete zipped files
foreach ($photo_list as $key => $value) {
unlink($value);
}
# on success redirect to index
header('Location: /index.php?err=2&user=' . $folder_name);
} else {
# on failure redirect to index with error
header('Location: /index.php?err=1');
}