source: trunk/admin/inc/ckeditor/filemanager/lib/class_zipFolder.php@ 430

Last change on this file since 430 was 239, checked in by luc, 9 years ago

Admin: correzione visulaizzazione immissione dati spoglio per Chrome e Safari - Aggiornamento dell'editor da FCKeditor a CKeditor , accessibili anche a Chrome e Safari.

  • Property svn:executable set to *
File size: 1.9 KB
Line 
1<?php
2
3/** This file is part of KCFinder project. The class are taken from
4 * http://www.php.net/manual/en/function.ziparchive-addemptydir.php
5 *
6 * @desc Directory to ZIP file archivator
7 * @package KCFinder
8 * @version 2.51
9 * @author Pavel Tzonkov <pavelc@users.sourceforge.net>
10 * @copyright 2010, 2011 KCFinder Project
11 * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
12 * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
13 * @link http://kcfinder.sunhater.com
14 */
15
16class zipFolder {
17 protected $zip;
18 protected $root;
19 protected $ignored;
20
21 function __construct($file, $folder, $ignored=null) {
22 $this->zip = new ZipArchive();
23
24 $this->ignored = is_array($ignored)
25 ? $ignored
26 : ($ignored ? array($ignored) : array());
27
28 if ($this->zip->open($file, ZIPARCHIVE::CREATE) !== TRUE)
29 throw new Exception("cannot open <$file>\n");
30
31 $folder = rtrim($folder, '/');
32
33 if (strstr($folder, '/')) {
34 $this->root = substr($folder, 0, strrpos($folder, '/') + 1);
35 $folder = substr($folder, strrpos($folder, '/') + 1);
36 }
37
38 $this->zip($folder);
39 $this->zip->close();
40 }
41
42 function zip($folder, $parent=null) {
43 $full_path = "{$this->root}$parent$folder";
44 $zip_path = "$parent$folder";
45 $this->zip->addEmptyDir($zip_path);
46 $dir = new DirectoryIterator($full_path);
47 foreach ($dir as $file)
48 if (!$file->isDot()) {
49 $filename = $file->getFilename();
50 if (!in_array($filename, $this->ignored)) {
51 if ($file->isDir())
52 $this->zip($filename, "$zip_path/");
53 else
54 $this->zip->addFile("$full_path/$filename", "$zip_path/$filename");
55 }
56 }
57 }
58}
59
60?>
Note: See TracBrowser for help on using the repository browser.