本文整理汇总了PHP中Zip类的典型用法代码示例。如果您正苦于以下问题:PHP Zip类的具体用法?PHP Zip怎么用?PHP Zip使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zip类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: extract
public function extract($zip_file)
{
$posts = array();
if (!$zip_file) {
return $posts;
}
$z = new Zip();
$result = $z->Extract($zip_file, ".");
if (!$result) {
$posts;
}
foreach ($result as $key => $value) {
if (!self::is_file_with_extension($key, 'xliff')) {
continue;
}
$xliff = self::get_xliff($value);
$translation_item = self::get_translation_item($xliff->children());
if (!self::is_valid($translation_item)) {
continue;
}
$post = get_post($translation_item['id']);
if (!$post) {
continue;
}
if ($post->post_title != $translation_item['title']) {
$post->post_title = $translation_item['title'];
}
if ($post->post_content != $translation_item['content']) {
$post->post_content = $translation_item['content'];
}
array_push($posts, $post);
}
return $posts;
}
开发者ID:JonZiemlich,项目名称:wpml2mlp,代码行数:34,代码来源:Wpml2mlp_Xliff_Extractor.php
示例2: export
public static function export($idstr)
{
$idArr = is_array($idstr) ? $idstr : explode(",", $idstr);
if (1 < count($idArr)) {
$zip = new Zip();
$exportFileName = Ibos::lang("Form export file pack", "workflow.default", array("{date}" => date("Y-m-d")));
$zipFileName = FileUtil::getTempPath() . "/" . TIMESTAMP . ".zip";
foreach ($idArr as $id) {
$form = self::handleExportSingleForm($id);
$zip->addFile($form["content"], sprintf("%s.html", ConvertUtil::iIconv($form["title"], CHARSET, "gbk")));
}
$fp = fopen($zipFileName, "w");
if (@fwrite($fp, $zip->file()) !== false) {
header("Cache-control: private");
header("Content-type: application/octet-stream");
header("Accept-Ranges: bytes");
header("Content-Length: " . sprintf("%u", FileUtil::fileSize($zipFileName)));
header("Content-Disposition: attachment; filename=" . $exportFileName . ".zip");
readfile($zipFileName);
exit;
}
} else {
$id = implode(",", $idArr);
$form = self::handleExportSingleForm($id);
ob_end_clean();
header("Cache-control: private");
header("Content-type: text/plain");
header("Accept-Ranges: bytes");
header("Accept-Length: " . strlen($form["content"]));
header("Content-Disposition: attachment; filename=" . $form["title"] . ".html");
echo $form["content"];
}
}
开发者ID:AxelPanda,项目名称:ibos,代码行数:33,代码来源:WfFormUtil.php
示例3: index
public function index()
{
// Define directory separator
define(MYDS, '/');
if ($_POST['submit']) {
$yui = new Yui();
$yui->compressor_dir = '/assets' . DS . 'compressor' . DS;
$yui->params = array('nomunge' => $_POST['nomunge'], 'preserve-semi' => $_POST['preserve-semi'], 'disable-optimizations' => $_POST['disable-optimizations']);
$yui->execute(array_merge($_FILES, $_POST));
$this->vars['error'] = $yui->error;
$file_loc = $yui->compressed['dir'] . $yui->compressed['file'];
$filename = $yui->compressed['file'];
$filename_zip = current(explode('.', $yui->compressed['file'])) . '.zip';
$zip_file_with_path = $yui->compressed['dir'] . $filename_zip;
if ($_POST['zipped'] === "1") {
$zip = new Zip();
$zip->addFile($file_loc, $filename);
$zip->save($zip_file_with_path);
$this->vars['zipped_file'] = '<a href="' . $zip_file_with_path . '" target="_blank">' . $filename_zip . '</a>';
}
$this->vars['compressed_file'] = '<a href="' . $file_loc . '" target="_blank">' . $filename . '</a>';
}
$this->layout_vars['page_title'] = 'YUI Compression tool';
$this->display('home/index', $this->vars);
}
开发者ID:silentworks,项目名称:the-compressor,代码行数:25,代码来源:HomeController.php
示例4: upload
function upload($incVersion)
{
$vs = qg::remoteGet($this->name);
if (!is_dir(sysPATH . $this->name)) {
return false;
}
$v = explode('.', $vs['version']);
$v = @array((int) $v[0], (int) $v[1], (int) $v[2]);
foreach ($v as $i => $vp) {
if ($i >= $incVersion) {
$v[$i] = 0;
}
}
isset($v[$incVersion - 1]) && ++$v[$incVersion - 1];
$vs['version'] = implode('.', $v);
$tmpFile = appPATH . 'cache/tmp/module_export1.zip';
is_file($tmpFile) && unlink($tmpFile);
// zzz unlink???
ini_set('max_execution_time', '600');
$zip = new Zip();
$zip->open($tmpFile, Zip::CREATE);
$zip->addDir(sysPATH . $this->name, null, '/(\\.svn)|(zzz)/');
$zip->close();
$vs['size'] = filesize($tmpFile);
$this->local_version = $vs['version'];
@qg::Ftp()->mkdir('/module/' . $this->name . '/');
qg::Ftp()->put('/module/' . $this->name . '/' . $vs['version'] . '.zip', $tmpFile, FTP_BINARY);
qg::remoteSet($this->name, $vs);
return $vs['version'];
}
开发者ID:nuxodin,项目名称:shwups-cms-v4,代码行数:30,代码来源:module.class.php
示例5: compress
/**
* Compresses the directory with ZIP.
* @param string $fileName The file name of the ZIP archive.
* @param int $flags [optional] The mode to use to open the archive.
* @return mixed The ZIP archive or an error code on failure.
*/
public function compress($fileName, $flags = \ZipArchive::CREATE)
{
$zip = new Zip();
if (($res = $zip->open($fileName, $flags)) === true) {
$zip->addDir($this->path);
$zip->close();
return $zip;
}
return $res;
}
开发者ID:rolandrajko,项目名称:BREAD,代码行数:16,代码来源:Directory.php
示例6: run
function run($args)
{
if (empty($args[1])) {
echo $this->getHelp();
return;
}
$path = $args[0];
$version = $args[1];
echo "Preparing {$path} release.\n";
require dirname(__FILE__) . '/GenerateDocsCommand.php';
$docProcessor = new GenerateDocsCommand($this->getName(), $this->getCommandRunner());
$outFiles = $docProcessor->processDocuments($path);
// copy extension dir to temp
$extPath = Yii::getPathOfAlias('ext') . '/' . $path;
$copiedExtRoot = Yii::getPathOfAlias('application.runtime.extension');
echo "Removing {$copiedExtRoot}.\n";
if (file_exists($copiedExtRoot)) {
$this->recursiveDelete($copiedExtRoot);
}
$copiedExtPath = $copiedExtRoot . '/' . $path;
if (!file_exists($copiedExtPath)) {
mkdir($copiedExtPath, 0777, true);
}
echo "Copying extension files from {$extPath} to {$copiedExtPath}.\n";
CFileHelper::copyDirectory($extPath, $copiedExtPath, array('exclude' => array('.svn', 'readme_en.txt', 'readme_ru.txt')));
echo "Copying documentation to {$copiedExtPath}.\n";
foreach ($outFiles as $file) {
copy($file, $copiedExtPath . '/' . basename($file));
}
$pathExp = explode('/', $path);
$zipName = end($pathExp) . '_' . $version . '.zip';
$releasePath = Yii::getPathOfAlias('application.releases');
if (!file_exists($releasePath)) {
mkdir($releasePath, 0777, true);
}
$zipPath = "{$releasePath}/{$zipName}";
if (file_exists($zipPath)) {
unlink($zipPath);
}
//touch($zipPath);
echo "Creating Zip {$zipPath}.\n";
require dirname(__FILE__) . '/Zip.php';
$zip = new Zip();
if ($zip->open($zipPath, ZipArchive::OVERWRITE | ZipArchive::CREATE) !== TRUE) {
die("Failed to open Zip {$zipPath}.\n");
}
if (!$zip->addDir($copiedExtRoot)) {
die("Failed adding {$copiedExtRoot} to Zip.\n");
}
if ($zip->close()) {
echo "Done.\n";
} else {
die("Failed to write Zip {$zipPath}.\n");
}
}
开发者ID:sinelnikof,项目名称:yiiext,代码行数:55,代码来源:ReleaseCommand.php
示例7: download
static function download($name, $beta = false)
{
$vs = self::remoteGet($name, $beta);
self::ftp()->get(appPATH . 'cache/tmp/pri/remoteModule.zip', '/module/' . $name . '/' . $vs['version'] . '.zip', FTP_BINARY);
$zip = new Zip();
$go = $zip->open(appPATH . 'cache/tmp/pri/remoteModule.zip');
if (!$go) {
return;
}
rrmdir(sysPATH . $name);
$zip->extractTo(sysPATH);
$zip->close();
return $vs;
}
开发者ID:nuxodin,项目名称:shwups-cms-v4,代码行数:14,代码来源:qg.class_old.php
示例8: isPOMExists
/**
* Megnézi, hogy a paraméterben kapott zip file-ban létezik e a pom.xml file.
* @param string $pin_FileName A vizsgált zip file
* @return bool Létezik e a pom vagy sem
*/
public static function isPOMExists(string $pin_FileName) : bool
{
$obj_Zip = new Zip();
$obj_Zip->setZipFile($pin_FileName);
(array) ($loc_Zip = $obj_Zip->getZipFileContent());
(array) ($loc_Tmp = array());
foreach ($loc_Zip as $loc_File) {
$loc_Tmp = array_merge($loc_Tmp, explode('/', $loc_File));
}
if (in_array('pom.xml', $loc_Tmp)) {
return true;
}
return false;
}
开发者ID:szana8,项目名称:Szakdolgozat,代码行数:19,代码来源:addon.php
示例9: install
public function install($filename)
{
$src = ROOT . '/sys/tmp/' . $filename;
$dest = ROOT . '/sys/tmp/install_plugin/';
Zip::extractZip($src, $dest);
if (!file_exists($dest)) {
$this->errors = __('Some error occurred');
return false;
}
$tmp_plugin_path = glob($dest . '*', GLOB_ONLYDIR);
$tmp_plugin_path = $tmp_plugin_path[0];
$plugin_basename = substr(strrchr($tmp_plugin_path, '/'), 1);
$plugin_path = ROOT . '/sys/plugins/' . $plugin_basename;
copyr($dest, ROOT . '/sys/plugins/', 0755);
$this->files = getDirFiles($plugin_path);
if (file_exists($plugin_path . '/config.dat')) {
$config = json_decode(file_get_contents($plugin_path . '/config.dat'), true);
include_once $plugin_path . '/index.php';
$className = $config['className'];
$obj = new $className(null);
if (method_exists($obj, 'install')) {
$obj->install();
}
}
_unlink($src);
_unlink($dest);
return true;
}
开发者ID:VictorSproot,项目名称:AtomXCMS-2,代码行数:28,代码来源:plugins.class.php
示例10: action_zip
public function action_zip($articulo_id = null)
{
is_null($articulo_id) and Response::redirect('diagramador');
$articulos = Model_Articulo::find('all', array('related' => array('fotos', 'seccion'), 'where' => array(array('id', '=', $articulo_id))));
$files_to_zip = array();
$archivo_informacion = '';
foreach ($articulos as $articulo) {
$archivo_informacion .= "Nombre del Articulo: " . $articulo->nombre . "\n";
$archivo_informacion .= "Seccion del Articulo: " . $articulo->seccion->descripcion . "\n";
$archivo_informacion .= "Fecha del Articulo: " . date('Y-m-d H:i:s', $articulo->fecha_publicacion) . "\n";
$archivo_informacion .= "\n ==========================\n";
foreach ($articulo->fotos as $foto) {
if ($foto->estado == 1) {
array_push($files_to_zip, $foto->imagen);
$nombre_archivo = str_ireplace(".jpg", "-" . $articulo->pagina->descripcion . ".jpg", $foto->imagen);
$pieces = explode("/", $nombre_archivo);
$count_foto = count($pieces);
$nombre_archivo = $pieces[$count_foto - 1];
$archivo_informacion .= $nombre_archivo . "\n" . "Medida: " . $foto->dimension->descipcion . "\n" . "Pagina: " . $articulo->pagina->descripcion . "\n ==========================\n";
}
}
}
$time = time();
File::create(DOCROOT . "zip/", "info_{$articulo_id}_{$time}.txt", $archivo_informacion);
array_push($files_to_zip, "/gr/public/zip/info_{$articulo_id}_{$time}.txt");
Zip::create_zip($files_to_zip, $articulo_id, true, $time, $articulo->pagina->descripcion);
}
开发者ID:ronaldpatino,项目名称:fuelphp-auth,代码行数:27,代码来源:diagramador.php
示例11: download
/**
* Download zipfile.
*
* @param array $files
* @param string $filename
*
* @return string
*/
public function download($files, $filename)
{
// Get assets
$criteria = craft()->elements->getCriteria(ElementType::Asset);
$criteria->id = $files;
$criteria->limit = null;
$assets = $criteria->find();
// Set destination zip
$destZip = craft()->path->getTempPath() . $filename . '_' . time() . '.zip';
// Create the zipfile
IOHelper::createFile($destZip);
// Loop through assets
foreach ($assets as $asset) {
// Get asset source
$source = $asset->getSource();
// Get asset source type
$sourceType = $source->getSourceType();
// Get asset file
$file = $sourceType->getLocalCopy($asset);
// Add to zip
Zip::add($destZip, $file, dirname($file));
}
// Return zip destination
return $destZip;
}
开发者ID:brammittendorff,项目名称:zipassets,代码行数:33,代码来源:ZipAssetsService.php
示例12: getPluginInfo
/**
* @param mixed $plugin
* @throws \RuntimeException
* @return array
*/
public function getPluginInfo($plugin)
{
switch (true) {
case is_array($plugin):
$backend = new ArrayTestCase();
break;
case is_dir($plugin):
$backend = new Directory();
break;
case is_file($plugin):
$backend = new Zip();
break;
default:
throw new \RuntimeException("Could not automatically detect type of given plugin");
}
return $backend->getPluginInfo($plugin);
}
开发者ID:ingowalther,项目名称:plugin-info,代码行数:22,代码来源:AutoDetect.php
示例13: rebuildZipFile
public function rebuildZipFile($workshopId)
{
$documents = $this->getDocumentsForWorkshop($workshopId);
$config = Zend_Registry::get('config');
if (!is_readable($config->user->fileUploadPathWorkshop->val)) {
throw new Ot_Exception_Data('Target directory is not readable');
}
$zip = new Zip($config->user->fileUploadPathWorkshop->val . '/' . $workshopId . '/all_handouts.zip');
$filesToAdd = array();
foreach ($documents as $d) {
$target = $config->user->fileUploadPathWorkshop->val . '/' . $workshopId . '/' . $d['name'];
if (is_file($target)) {
$filesToAdd[] = $target;
} else {
throw new Ot_Exception_Data('File not found: ' . $target);
}
}
$zip->addFiles($filesToAdd);
$zip->createZipFile();
}
开发者ID:ncsuwebdev,项目名称:classmate,代码行数:20,代码来源:WorkshopDocument.php
示例14: create_zip_Zip
function create_zip_Zip($files = array(), $destination = '')
{
if (count($files)) {
//create the archive
if (file_exists($destination)) {
unlink($destination);
}
$zip = new Zip();
$zip->setZipFile($destination);
foreach ($files as $file) {
$zip->addFile(file_get_contents($file), str_replace('/', '', strrchr($file, '/')));
}
$zip->finalize();
$zip->setZipFile($destination);
//check to make sure the file exists
return (string) file_exists($destination);
} else {
return "No valid files found. Exiting<br/>";
}
}
开发者ID:StudentLifeMarketingAndDesign,项目名称:krui-wp,代码行数:20,代码来源:downml_settings_page.php
示例15: __construct
/**
* Create a Zip object and store the query results
*
* @param mysqli_result $QueryResult results from a query on the collector pages
* @param string $Title name of the collection that will be created
* @param string $AnnounceURL URL to add to the created torrents
*/
public function __construct(&$QueryResult, $Title)
{
G::$Cache->InternalCache = false;
// The internal cache is almost completely useless for this
Zip::unlimit();
// Need more memory and longer timeout
$this->QueryResult = $QueryResult;
$this->Title = $Title;
$this->User = G::$LoggedUser;
$this->AnnounceURL = ANNOUNCE_URL . '/' . G::$LoggedUser['torrent_pass'] . '/announce';
$this->Zip = new Zip(Misc::file_string($Title));
}
开发者ID:Kufirc,项目名称:Gazelle,代码行数:19,代码来源:torrentsdl.class.php
示例16: getArchive
/**
* Creates a new archive with the specified name and files
* @param string $name Path to the archive with name and extension
* @param array $files A numeric array of files
* @param string $replace
* @return int How many files has been successfully handled
*/
public function getArchive($name, array $files, $replace = ABSPATH)
{
set_time_limit(300);
if (!class_exists('Zip', false)) {
/** @var backupBup $backup */
$backup = $this->getModule();
$backup->loadLibrary('zip');
}
$zip = new Zip();
$zip->setZipFile($name);
foreach ($files as $file) {
$filename = str_replace($replace, '', $file);
if (file_exists($file) && is_readable($file) && (substr(basename($file), 0, 3) != 'pcl' && substr($file, -2) != 'gz')) {
$stream = @fopen($file, 'rb');
if ($stream) {
$zip->addLargeFile($stream, $filename);
}
}
}
$zip->finalize();
/* backward */
return rand(100, 1000);
}
开发者ID:VSVS,项目名称:vs_wp_4.0,代码行数:30,代码来源:filesystem.php
示例17: performAction
/**
* Performs the tool's action.
*
* @param array $params
* @return array
*/
public function performAction($params = array())
{
$file = craft()->db->backup();
if (IOHelper::fileExists($file) && isset($params['downloadBackup']) && (bool) $params['downloadBackup']) {
$destZip = craft()->path->getTempPath() . IOHelper::getFileName($file, false) . '.zip';
if (IOHelper::fileExists($destZip)) {
IOHelper::deleteFile($destZip, true);
}
IOHelper::createFile($destZip);
if (Zip::add($destZip, $file, craft()->path->getDbBackupPath())) {
return array('backupFile' => IOHelper::getFileName($destZip, false));
}
}
}
开发者ID:kentonquatman,项目名称:portfolio,代码行数:20,代码来源:DbBackupTool.php
示例18: performAction
/**
* @inheritDoc ITool::performAction()
*
* @param array $params
*
* @return array
*/
public function performAction($params = array())
{
// In addition to the default tables we want to ignore data in, we also don't care about data in the session
// table in this tools' case.
$file = craft()->db->backup(array('sessions'));
if (IOHelper::fileExists($file) && isset($params['downloadBackup']) && (bool) $params['downloadBackup']) {
$destZip = craft()->path->getTempPath() . IOHelper::getFileName($file, false) . '.zip';
if (IOHelper::fileExists($destZip)) {
IOHelper::deleteFile($destZip, true);
}
IOHelper::createFile($destZip);
if (Zip::add($destZip, $file, craft()->path->getDbBackupPath())) {
return array('backupFile' => IOHelper::getFileName($destZip, false));
}
}
}
开发者ID:kant312,项目名称:sop,代码行数:23,代码来源:DbBackupTool.php
示例19: PreProcess
public function PreProcess()
{
$v = Validator::Create();
$v->Register($this->source[Video_Source::FIELD_EMBED], Validator_Type::NOT_EMPTY, 'The Embed Code field is required');
$v->Register($this->source[Video_Source::FIELD_DURATION], Validator_Type::VALID_TIME, 'The Video Duration field must be in HH:MM:SS format');
$this->duration = Format::DurationToSeconds($this->source[Video_Source::FIELD_DURATION]);
$this->video_dir = new Video_Dir(null, 0700);
Request::FixFiles();
// No thumbnails uploaded
if (!isset($_FILES[Video_Source::FIELD_THUMBNAILS])) {
return;
}
// Process each uploaded file
foreach ($_FILES[Video_Source::FIELD_THUMBNAILS] as $upload) {
// No file uploaded in this field
if ($upload['error'] == UPLOAD_ERR_NO_FILE) {
continue;
}
// Check for other errors
if ($upload['error'] != UPLOAD_ERR_OK) {
throw new BaseException(Uploads::CodeToMessage($upload['error']));
}
switch (File::Type($upload['name'])) {
case File::TYPE_ZIP:
foreach (Zip::ExtractEntries($upload['tmp_name'], File::TYPE_JPEG) as $name => $data) {
$thumbs[] = $this->video_dir->AddTempFromVar($data, JPG_EXTENSION);
}
break;
case File::TYPE_JPEG:
$thumbs[] = $this->video_dir->AddTempFromFile($upload['tmp_name'], JPG_EXTENSION);
break;
}
}
// Resize (if possible) and move images to the correct directory
if (Video_Thumbnail::CanResize()) {
$this->thumbs = Video_Thumbnail::ResizeDirectory($this->video_dir->GetTempDir(), $this->video_dir->GetThumbsDir(), Config::Get('thumb_size'), Config::Get('thumb_quality'));
} else {
$this->thumbs = $this->video_dir->MoveFiles(Video_Dir::TEMP, Video_Dir::THUMBS, JPG_EXTENSION);
}
// Cleanup temp and processing dirs
$this->video_dir->ClearTemp();
$this->video_dir->ClearProcessing();
}
开发者ID:hackingman,项目名称:TubeX,代码行数:43,代码来源:Embed.php
示例20: export_and_download_layouts
function export_and_download_layouts()
{
if (isset($_POST['export_and_download'])) {
$nonce = $_POST["wp_nonce_export_layouts"];
if (WPDD_Utils::user_not_admin()) {
die(__("You don't have permission to perform this action!", 'ddl-layouts'));
}
if (wp_verify_nonce($nonce, 'wp_nonce_export_layouts')) {
$results = $this->export_for_download();
$sitename = sanitize_key(get_bloginfo('name'));
if (!empty($sitename)) {
$sitename .= '.';
}
require_once WPDDL_TOOLSET_COMMON_ABSPATH . '/Zip.php';
if (class_exists('Zip')) {
$dirname = $sitename . 'dd-layouts.' . date('Y-m-d');
$zipName = $dirname . '.zip';
$zip = new Zip();
$zip->addDirectory($dirname);
foreach ($results as $file_data) {
$zip->addFile($file_data['file_data'], $dirname . '/' . $file_data['file_name']);
}
$zip->sendZip($zipName);
}
}
die;
}
}
开发者ID:javierdlahoz,项目名称:paella-development,代码行数:28,代码来源:wpddl.theme-support.class.php
注:本文中的Zip类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论