PluginProbe ʕ •ᴥ•ʔ
WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets / 3.9.4
WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets v3.9.4
3.9.5 3.9.6 4.0.0 4.0.1 4.1.0 trunk 2.12 2.13 2.14 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.5.7 3.5.8 3.5.9 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9 3.7.0 3.7.1 3.7.2 3.7.3 3.7.3-beta-1.0 3.7.4 3.7.4-beta-1.0 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4
wp-all-import / classes / zip.php
wp-all-import / classes Last commit date
XmlStreamReader 2 years ago partner-discount-sdk 1 year ago api.php 4 years ago arraytoxml.php 8 years ago chunk.php 1 year ago config.php 2 years ago download.php 13 years ago error.php 2 years ago handler.php 9 months ago helper.php 8 years ago input.php 7 years ago nested.php 4 years ago rapidaddon.php 9 months ago render.php 4 years ago session.php 9 months ago upload.php 9 months ago zip.php 10 years ago
zip.php
54 lines
1 <?php
2
3 if ( ! class_exists('PMXI_Zip')){
4
5 class PMXI_Zip
6 {
7 /**
8 * Add files and sub-directories in a folder to zip file.
9 * @param string $folder
10 * @param ZipArchive $zipFile
11 * @param int $exclusiveLength Number of text to be exclusived from the file path.
12 */
13 private static function folderToZip($folder, &$zipFile, $exclusiveLength) {
14 $handle = opendir($folder);
15 while (false !== $f = readdir($handle)) {
16 if ($f != '.' && $f != '..') {
17 $filePath = "$folder/$f";
18 // Remove prefix from file path before add to zip.
19 $localPath = substr($filePath, $exclusiveLength);
20 if (is_file($filePath)) {
21 $zipFile->addFile($filePath, $localPath);
22 } elseif (is_dir($filePath)) {
23 // Add sub-directory.
24 $zipFile->addEmptyDir($localPath);
25 self::folderToZip($filePath, $zipFile, $exclusiveLength);
26 }
27 }
28 }
29 closedir($handle);
30 }
31
32 /**
33 * Zip a folder (include itself).
34 * Usage:
35 * PMXI_Zip::zipDir('/path/to/sourceDir', '/path/to/out.zip');
36 *
37 * @param string $sourcePath Path of directory to be zip.
38 * @param string $outZipPath Path of output zip file.
39 */
40 public static function zipDir($sourcePath, $outZipPath)
41 {
42 $pathInfo = pathInfo($sourcePath);
43 $parentPath = $pathInfo['dirname'];
44 $dirName = $pathInfo['basename'];
45
46 $z = new ZipArchive();
47 $z->open($outZipPath, ZIPARCHIVE::CREATE);
48 $z->addEmptyDir($dirName);
49 self::folderToZip($sourcePath, $z, strlen("$parentPath/"));
50 $z->close();
51 }
52 }
53
54 }