Version Description
- Increased upload limit of files from 150MB to 500MB
- Use ZipArchive with fallback to PclZip (a few users notified us that they dont have ZipArchive enabled on their servers)
- Use PDO with fallback to mysql (a few users notified us that they dont have PDO enabled on their servers, mysql is deprecated as of PHP v5.5 but we are supporting PHP v5.2.17).
- Support for PHP v5.2.17 and WordPress v3.3 and above.
- Fix a bug during export that causes plugins to not be exported on some hosts (the problem that you are experiencing).
Download this release
Release Info
Developer | yani.iliev |
Plugin | All-in-One WP Migration |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.1.0 to 1.2.0
- all-in-one-wp-migration.php +1 -1
- constants.php +15 -2
- lib/controller/class-ai1wm-export-controller.php +4 -1
- lib/controller/class-ai1wm-main-controller.php +9 -3
- lib/model/class-ai1wm-export.php +82 -28
- lib/model/class-ai1wm-import.php +58 -18
- lib/vendor/mysqldump-factory/mysqldump-factory/LICENSE +20 -0
- lib/vendor/mysqldump-factory/mysqldump-factory/README.md +34 -0
- lib/vendor/mysqldump-factory/mysqldump-factory/bump_version.sh +63 -0
- lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpFactory.php +69 -0
- lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpInterface.php +196 -0
- lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpPDO.php +497 -0
- lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpSQL.php +490 -0
- lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlFileAdapter.php +74 -0
- lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlQueryAdapter.php +109 -0
- lib/vendor/mysqldump-php/mysqldump.php +0 -603
- lib/vendor/zip-factory/zip-factory/LICENSE +20 -0
- lib/vendor/zip-factory/zip-factory/README.md +31 -0
- lib/vendor/zip-factory/zip-factory/bump-version.sh +63 -0
- lib/vendor/zip-factory/zip-factory/lib/ArchiverInterface.php +117 -0
- lib/vendor/zip-factory/zip-factory/lib/ArchiverPclZip.php +191 -0
- lib/vendor/zip-factory/zip-factory/lib/ArchiverZipArchive.php +214 -0
- lib/vendor/zip-factory/zip-factory/lib/ZipFactory.php +69 -0
- lib/vendor/zip-factory/zip-factory/lib/vendor/pclzip-2-8-2/gnu-lgpl.txt +504 -0
- lib/vendor/zip-factory/zip-factory/lib/vendor/pclzip-2-8-2/pclzip.lib.php +5690 -0
- lib/vendor/zip-factory/zip-factory/lib/vendor/pclzip-2-8-2/readme.txt +421 -0
- lib/vendor/zipper/zipper.lib.php +0 -62
- lib/view/assets/css/export.min.css +1 -1
- lib/view/assets/css/import.min.css +1 -1
- lib/view/assets/javascript/import.min.js +1 -1
- lib/view/export/index.php +5 -8
- loader.php +49 -55
- readme.txt +35 -2
all-in-one-wp-migration.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Description: Migration tool for all your blog data
|
6 |
* Author: ServMask
|
7 |
* Author URI: http://servmask.com/
|
8 |
-
* Version: 1.
|
9 |
*
|
10 |
* Copyright (C) 2013 ServMask LLC
|
11 |
*
|
5 |
* Description: Migration tool for all your blog data
|
6 |
* Author: ServMask
|
7 |
* Author URI: http://servmask.com/
|
8 |
+
* Version: 1.2.0
|
9 |
*
|
10 |
* Copyright (C) 2013 ServMask LLC
|
11 |
*
|
constants.php
CHANGED
@@ -56,9 +56,9 @@ define( 'BANDAR_TEMPLATES_PATH', AI1WM_LIB_PATH . DIRECTORY_SEPARATOR . 'view' )
|
|
56 |
// ==================
|
57 |
define( 'AI1WM_EXCEPTION_PATH', AI1WM_LIB_PATH . DIRECTORY_SEPARATOR . 'exception' );
|
58 |
|
59 |
-
//
|
60 |
// = Vendor Path =
|
61 |
-
//
|
62 |
define( 'AI1WM_VENDOR_PATH', AI1WM_LIB_PATH . DIRECTORY_SEPARATOR . 'vendor' );
|
63 |
|
64 |
// ==============
|
@@ -70,3 +70,16 @@ define( 'AI1WM_URL', plugins_url( '', __FILE__ ) );
|
|
70 |
// = ServMask Feedback Url =
|
71 |
// ==============
|
72 |
define( 'AI1WM_FEEDBACK_URL', 'https://servmask.com/ai1wm/feedback/create' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
// ==================
|
57 |
define( 'AI1WM_EXCEPTION_PATH', AI1WM_LIB_PATH . DIRECTORY_SEPARATOR . 'exception' );
|
58 |
|
59 |
+
// ===============
|
60 |
// = Vendor Path =
|
61 |
+
// ===============
|
62 |
define( 'AI1WM_VENDOR_PATH', AI1WM_LIB_PATH . DIRECTORY_SEPARATOR . 'vendor' );
|
63 |
|
64 |
// ==============
|
70 |
// = ServMask Feedback Url =
|
71 |
// ==============
|
72 |
define( 'AI1WM_FEEDBACK_URL', 'https://servmask.com/ai1wm/feedback/create' );
|
73 |
+
|
74 |
+
// ===========================
|
75 |
+
// = WP_CONTENT_DIR Constant =
|
76 |
+
// ===========================
|
77 |
+
if ( ! defined( 'WP_CONTENT_DIR' ) )
|
78 |
+
define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
|
79 |
+
|
80 |
+
// ==========================
|
81 |
+
// = WP_PLUGIN_DIR Constant =
|
82 |
+
// ==========================
|
83 |
+
if ( ! defined( 'WP_PLUGIN_DIR' ) )
|
84 |
+
define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
|
85 |
+
|
lib/controller/class-ai1wm-export-controller.php
CHANGED
@@ -20,7 +20,10 @@ class Ai1wm_Export_Controller
|
|
20 |
{
|
21 |
public static function index() {
|
22 |
$model = new Ai1wm_Export;
|
23 |
-
Ai1wm_Template::render( 'export/index'
|
|
|
|
|
|
|
24 |
}
|
25 |
|
26 |
public static function export() {
|
20 |
{
|
21 |
public static function index() {
|
22 |
$model = new Ai1wm_Export;
|
23 |
+
Ai1wm_Template::render( 'export/index', array(
|
24 |
+
'list_plugins' => get_plugins(),
|
25 |
+
)
|
26 |
+
);
|
27 |
}
|
28 |
|
29 |
public static function export() {
|
lib/controller/class-ai1wm-main-controller.php
CHANGED
@@ -65,7 +65,7 @@ class Ai1wm_Main_Controller
|
|
65 |
add_action( 'wp_ajax_upload_file', 'Ai1wm_Import_Controller::upload_file' );
|
66 |
|
67 |
// Enable or disable maintenance mode
|
68 |
-
if ( get_option(
|
69 |
add_action( 'get_header', array( $this, 'activate_maintenance_mode' ) );
|
70 |
}
|
71 |
|
@@ -112,7 +112,7 @@ class Ai1wm_Main_Controller
|
|
112 |
|
113 |
// Set Message
|
114 |
$message = null;
|
115 |
-
if ( isset( $_POST['
|
116 |
$message = trim( $_POST['message'] );
|
117 |
}
|
118 |
|
@@ -130,15 +130,21 @@ class Ai1wm_Main_Controller
|
|
130 |
} else if ( ! $terms ) {
|
131 |
$errors[] = 'Please accept feedback term conditions.';
|
132 |
} else {
|
133 |
-
wp_remote_post(
|
134 |
AI1WM_FEEDBACK_URL,
|
135 |
array(
|
136 |
'body' => array(
|
137 |
'email' => $email,
|
138 |
'message' => $message,
|
|
|
139 |
),
|
140 |
)
|
141 |
);
|
|
|
|
|
|
|
|
|
|
|
142 |
}
|
143 |
|
144 |
echo json_encode( array( 'errors' => $errors ) );
|
65 |
add_action( 'wp_ajax_upload_file', 'Ai1wm_Import_Controller::upload_file' );
|
66 |
|
67 |
// Enable or disable maintenance mode
|
68 |
+
if ( get_option( Ai1wm_Import::MAINTENANCE_MODE ) ) {
|
69 |
add_action( 'get_header', array( $this, 'activate_maintenance_mode' ) );
|
70 |
}
|
71 |
|
112 |
|
113 |
// Set Message
|
114 |
$message = null;
|
115 |
+
if ( isset( $_POST['message'] ) ) {
|
116 |
$message = trim( $_POST['message'] );
|
117 |
}
|
118 |
|
130 |
} else if ( ! $terms ) {
|
131 |
$errors[] = 'Please accept feedback term conditions.';
|
132 |
} else {
|
133 |
+
$response = wp_remote_post(
|
134 |
AI1WM_FEEDBACK_URL,
|
135 |
array(
|
136 |
'body' => array(
|
137 |
'email' => $email,
|
138 |
'message' => $message,
|
139 |
+
'export_last_options' => get_option( Ai1wm_Export::EXPORT_LAST_OPTIONS ),
|
140 |
),
|
141 |
)
|
142 |
);
|
143 |
+
|
144 |
+
if ( is_wp_error( $response ) ) {
|
145 |
+
$errors[] = 'Something went wrong: ' .
|
146 |
+
$response->get_error_message();
|
147 |
+
}
|
148 |
}
|
149 |
|
150 |
echo json_encode( array( 'errors' => $errors ) );
|
lib/model/class-ai1wm-export.php
CHANGED
@@ -18,20 +18,24 @@
|
|
18 |
|
19 |
class Ai1wm_Export
|
20 |
{
|
21 |
-
const EXPORT_ARCHIVE_NAME
|
22 |
-
|
23 |
const EXPORT_DATABASE_NAME = 'database.sql';
|
24 |
-
|
25 |
-
const
|
26 |
-
|
27 |
-
const
|
28 |
-
|
29 |
-
const EXPORT_THEMES_NAME = 'themes';
|
30 |
|
31 |
protected $connection = null;
|
32 |
|
33 |
public function __construct() {
|
34 |
-
$this->connection =
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
}
|
36 |
|
37 |
/**
|
@@ -42,7 +46,11 @@ class Ai1wm_Export
|
|
42 |
* @return string Absolute file path
|
43 |
*/
|
44 |
public function export( $output_file, array $options = array() ) {
|
45 |
-
|
|
|
|
|
|
|
|
|
46 |
|
47 |
// Should we export database?
|
48 |
if ( ! isset( $options['export-database' ] ) ) {
|
@@ -69,6 +77,14 @@ class Ai1wm_Export
|
|
69 |
);
|
70 |
}
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
// Add package
|
73 |
$archive->addFromString(
|
74 |
self::EXPORT_PACKAGE_NAME,
|
@@ -88,17 +104,23 @@ class Ai1wm_Export
|
|
88 |
public function prepare_database( $output_file, array $options = array() ) {
|
89 |
global $wpdb;
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
'
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
$clauses = array();
|
104 |
|
@@ -125,9 +147,16 @@ class Ai1wm_Export
|
|
125 |
|
126 |
$output_meta = stream_get_meta_data( $output_file );
|
127 |
|
128 |
-
//
|
129 |
-
$this->connection
|
130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
|
132 |
// Replace Old/New Values
|
133 |
if (
|
@@ -158,7 +187,20 @@ class Ai1wm_Export
|
|
158 |
// Replace serialized string values
|
159 |
$data = preg_replace(
|
160 |
'!s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");!e',
|
161 |
-
"'s:'.strlen(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
$data
|
163 |
);
|
164 |
if ( $data ) {
|
@@ -169,7 +211,6 @@ class Ai1wm_Export
|
|
169 |
}
|
170 |
}
|
171 |
|
172 |
-
|
173 |
return $output_meta['uri'];
|
174 |
}
|
175 |
|
@@ -179,7 +220,7 @@ class Ai1wm_Export
|
|
179 |
* @param [type] $value [description]
|
180 |
* @return [type] [description]
|
181 |
*/
|
182 |
-
public function unescape_mysql( $value ) {
|
183 |
return str_replace(
|
184 |
array( '\\\\', '\\0', "\\n", "\\r", '\Z', "\'", '\"', ),
|
185 |
array( '\\', '\0', "\n", "\r", "\x1a", "'", '"', ),
|
@@ -193,7 +234,7 @@ class Ai1wm_Export
|
|
193 |
* @param [type] $value [description]
|
194 |
* @return [type] [description]
|
195 |
*/
|
196 |
-
public function unescape_quotes( $value ) {
|
197 |
return str_replace( '\"', '"', $value );
|
198 |
}
|
199 |
|
@@ -225,6 +266,19 @@ class Ai1wm_Export
|
|
225 |
}
|
226 |
}
|
227 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
/**
|
229 |
* Export package json file which includes information about installed plugins and etc.
|
230 |
*
|
18 |
|
19 |
class Ai1wm_Export
|
20 |
{
|
21 |
+
const EXPORT_ARCHIVE_NAME = 'dump';
|
|
|
22 |
const EXPORT_DATABASE_NAME = 'database.sql';
|
23 |
+
const EXPORT_PACKAGE_NAME = 'package.json';
|
24 |
+
const EXPORT_MEDIA_NAME = 'media';
|
25 |
+
const EXPORT_PLUGINS_NAME = 'plugins';
|
26 |
+
const EXPORT_THEMES_NAME = 'themes';
|
27 |
+
const EXPORT_LAST_OPTIONS = 'ai1wm_export_last_options';
|
|
|
28 |
|
29 |
protected $connection = null;
|
30 |
|
31 |
public function __construct() {
|
32 |
+
$this->connection = MysqlDumpFactory::makeMysqlDump(
|
33 |
+
DB_HOST,
|
34 |
+
DB_USER,
|
35 |
+
DB_PASSWORD,
|
36 |
+
DB_NAME,
|
37 |
+
class_exists( 'PDO' )
|
38 |
+
);
|
39 |
}
|
40 |
|
41 |
/**
|
46 |
* @return string Absolute file path
|
47 |
*/
|
48 |
public function export( $output_file, array $options = array() ) {
|
49 |
+
// Export last options
|
50 |
+
update_option( self::EXPORT_LAST_OPTIONS, json_encode( $options ) );
|
51 |
+
|
52 |
+
// Make archive
|
53 |
+
$archive = ZipFactory::makeZipArchiver( $output_file, ! class_exists( 'ZipArchive' ) );
|
54 |
|
55 |
// Should we export database?
|
56 |
if ( ! isset( $options['export-database' ] ) ) {
|
77 |
);
|
78 |
}
|
79 |
|
80 |
+
// Should we export plugins?
|
81 |
+
if ( ! isset( $options['export-plugins'] ) ) {
|
82 |
+
$archive->addDir(
|
83 |
+
$this->prepare_plugins( $options ),
|
84 |
+
self::EXPORT_PLUGINS_NAME
|
85 |
+
);
|
86 |
+
}
|
87 |
+
|
88 |
// Add package
|
89 |
$archive->addFromString(
|
90 |
self::EXPORT_PACKAGE_NAME,
|
104 |
public function prepare_database( $output_file, array $options = array() ) {
|
105 |
global $wpdb;
|
106 |
|
107 |
+
// Set include tables
|
108 |
+
$includeTables = array();
|
109 |
+
if ( isset( $options['include-tables'] ) ) {
|
110 |
+
$includeTables = $options['include-tables'];
|
111 |
+
}
|
112 |
+
|
113 |
+
// Set exclude tables
|
114 |
+
$excludeTables = array();
|
115 |
+
if ( isset( $options['exclude-tables' ] ) ) {
|
116 |
+
$excludeTables = $options['exclude-tables'];
|
117 |
+
}
|
118 |
+
|
119 |
+
// Set no table data
|
120 |
+
$noTableData = false;
|
121 |
+
if ( isset( $options['no-table-data'] ) ) {
|
122 |
+
$noTableData = true;
|
123 |
+
}
|
124 |
|
125 |
$clauses = array();
|
126 |
|
147 |
|
148 |
$output_meta = stream_get_meta_data( $output_file );
|
149 |
|
150 |
+
// Set dump options
|
151 |
+
$this->connection
|
152 |
+
->setFileName( $output_meta['uri'] )
|
153 |
+
->setIncludeTables( $includeTables )
|
154 |
+
->setExcludeTables( $excludeTables )
|
155 |
+
->setNoTableData( $noTableData )
|
156 |
+
->setQueryClauses( $clauses );
|
157 |
+
|
158 |
+
// Make dump
|
159 |
+
$this->connection->dump();
|
160 |
|
161 |
// Replace Old/New Values
|
162 |
if (
|
187 |
// Replace serialized string values
|
188 |
$data = preg_replace(
|
189 |
'!s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");!e',
|
190 |
+
"'s:'.strlen( Ai1wm_Export::unescape_mysql( '$3' ) ).':\"'. Ai1wm_Export::unescape_quotes( '$3' ) .'\";'",
|
191 |
+
$data
|
192 |
+
);
|
193 |
+
if ( $data ) {
|
194 |
+
ftruncate( $output_file, 0 );
|
195 |
+
rewind( $output_file );
|
196 |
+
fwrite( $output_file, $data );
|
197 |
+
}
|
198 |
+
} else {
|
199 |
+
$data = stream_get_contents( $output_file );
|
200 |
+
// Replace serialized string values
|
201 |
+
$data = preg_replace(
|
202 |
+
'!s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");!e',
|
203 |
+
"'s:'.strlen( Ai1wm_Export::unescape_mysql( '$3' ) ).':\"'. Ai1wm_Export::unescape_quotes( '$3' ) .'\";'",
|
204 |
$data
|
205 |
);
|
206 |
if ( $data ) {
|
211 |
}
|
212 |
}
|
213 |
|
|
|
214 |
return $output_meta['uri'];
|
215 |
}
|
216 |
|
220 |
* @param [type] $value [description]
|
221 |
* @return [type] [description]
|
222 |
*/
|
223 |
+
public static function unescape_mysql( $value ) {
|
224 |
return str_replace(
|
225 |
array( '\\\\', '\\0', "\\n", "\\r", '\Z', "\'", '\"', ),
|
226 |
array( '\\', '\0', "\n", "\r", "\x1a", "'", '"', ),
|
234 |
* @param [type] $value [description]
|
235 |
* @return [type] [description]
|
236 |
*/
|
237 |
+
public static function unescape_quotes( $value ) {
|
238 |
return str_replace( '\"', '"', $value );
|
239 |
}
|
240 |
|
266 |
}
|
267 |
}
|
268 |
|
269 |
+
/**
|
270 |
+
* Export plugins root directory
|
271 |
+
*
|
272 |
+
* @param array $options Export settings
|
273 |
+
* @return string Plugins root directory
|
274 |
+
*/
|
275 |
+
public function prepare_plugins( array $options = array() ) {
|
276 |
+
if ( ! isset( $options['export-plugins'] ) ) {
|
277 |
+
|
278 |
+
return WP_PLUGIN_DIR;
|
279 |
+
}
|
280 |
+
}
|
281 |
+
|
282 |
/**
|
283 |
* Export package json file which includes information about installed plugins and etc.
|
284 |
*
|
lib/model/class-ai1wm-import.php
CHANGED
@@ -18,14 +18,19 @@
|
|
18 |
|
19 |
class Ai1wm_Import
|
20 |
{
|
21 |
-
const MAX_FILE_SIZE
|
22 |
-
|
23 |
-
const MAX_CHUNK_SIZE = '1MB';
|
24 |
-
|
25 |
const MAX_CHUNK_RETRIES = 10;
|
|
|
26 |
|
27 |
public function __construct() {
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
|
31 |
/**
|
@@ -40,11 +45,11 @@ class Ai1wm_Import
|
|
40 |
|
41 |
if ( empty( $input_file['error'] ) ) {
|
42 |
// Partial file path
|
43 |
-
$
|
44 |
-
|
45 |
|
46 |
// Open partial file
|
47 |
-
$out = fopen( $
|
48 |
if ( $out ) {
|
49 |
// Read binary input stream and append it to temp file
|
50 |
$in = fopen( $input_file['tmp_name'], 'rb' );
|
@@ -72,7 +77,7 @@ class Ai1wm_Import
|
|
72 |
}
|
73 |
|
74 |
// Extract archive to a temporary directory
|
75 |
-
$archive =
|
76 |
$archive->extractTo( $extract_to );
|
77 |
$archive->close();
|
78 |
|
@@ -106,7 +111,7 @@ class Ai1wm_Import
|
|
106 |
$this->connection->truncateDatabase();
|
107 |
|
108 |
// Import database
|
109 |
-
$this->connection->
|
110 |
}
|
111 |
|
112 |
// Check if media files are present
|
@@ -146,6 +151,24 @@ class Ai1wm_Import
|
|
146 |
$this->copy_dir( $extract_to . Ai1wm_Export::EXPORT_THEMES_NAME, $themes_basedir );
|
147 |
}
|
148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
if ( file_exists( $extract_to . Ai1wm_Export::EXPORT_PACKAGE_NAME ) ) {
|
150 |
|
151 |
// Install selected plugins
|
@@ -159,7 +182,7 @@ class Ai1wm_Import
|
|
159 |
$this->connection->truncateDatabase();
|
160 |
|
161 |
// Import "OLD" database
|
162 |
-
$this->connection->
|
163 |
}
|
164 |
|
165 |
if ( file_exists( $extract_to . Ai1wm_Export::EXPORT_MEDIA_NAME ) ) {
|
@@ -177,6 +200,14 @@ class Ai1wm_Import
|
|
177 |
// Import "OLD" themes files
|
178 |
$this->copy_dir( $backup_themes_to, $themes_basedir );
|
179 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
}
|
181 |
|
182 |
// Disable maintenance mode
|
@@ -194,13 +225,13 @@ class Ai1wm_Import
|
|
194 |
|
195 |
|
196 |
/**
|
197 |
-
* Enable or disable
|
198 |
*
|
199 |
* @param boolean $enabled Enable or disable maintenance mode
|
200 |
* @return boolean True if option value has changed, false if not or if update failed
|
201 |
*/
|
202 |
public function maintenance_mode( $enabled = true ) {
|
203 |
-
return update_option(
|
204 |
}
|
205 |
|
206 |
/**
|
@@ -211,12 +242,18 @@ class Ai1wm_Import
|
|
211 |
* @return void
|
212 |
*/
|
213 |
public function copy_dir( $from, $to ) {
|
|
|
|
|
|
|
214 |
$iterator = new RecursiveIteratorIterator(
|
215 |
-
new RecursiveDirectoryIterator( $from
|
216 |
RecursiveIteratorIterator::SELF_FIRST
|
217 |
);
|
218 |
|
219 |
foreach ( $iterator as $item ) {
|
|
|
|
|
|
|
220 |
if ( $item->isDir() ) {
|
221 |
mkdir( $to . $iterator->getSubPathName() );
|
222 |
} else {
|
@@ -232,14 +269,18 @@ class Ai1wm_Import
|
|
232 |
* @return void
|
233 |
*/
|
234 |
public function truncate_dir( $dir ) {
|
|
|
235 |
$iterator = new RecursiveIteratorIterator(
|
236 |
-
new RecursiveDirectoryIterator( $dir
|
237 |
RecursiveIteratorIterator::CHILD_FIRST
|
238 |
);
|
239 |
|
240 |
foreach ( $iterator as $item ) {
|
|
|
|
|
|
|
241 |
if ( $item->isDir() ) {
|
242 |
-
rmdir
|
243 |
} else {
|
244 |
unlink( $dir . $iterator->getSubPathName() );
|
245 |
}
|
@@ -253,7 +294,7 @@ class Ai1wm_Import
|
|
253 |
* @return void
|
254 |
*/
|
255 |
public function install_plugins( $path ) {
|
256 |
-
$file
|
257 |
$package = json_decode( $file, true );
|
258 |
|
259 |
// For Plugins API
|
@@ -300,7 +341,6 @@ class Ai1wm_Import
|
|
300 |
*/
|
301 |
public function is_valid( $path ) {
|
302 |
$required_objects = array(
|
303 |
-
Ai1wm_Export::EXPORT_DATABASE_NAME,
|
304 |
Ai1wm_Export::EXPORT_PACKAGE_NAME,
|
305 |
);
|
306 |
|
18 |
|
19 |
class Ai1wm_Import
|
20 |
{
|
21 |
+
const MAX_FILE_SIZE = '512MB';
|
22 |
+
const MAX_CHUNK_SIZE = '1MB';
|
|
|
|
|
23 |
const MAX_CHUNK_RETRIES = 10;
|
24 |
+
const MAINTENANCE_MODE = 'ai1wm_maintenance_mode';
|
25 |
|
26 |
public function __construct() {
|
27 |
+
$this->connection = MysqlDumpFactory::makeMysqlDump(
|
28 |
+
DB_HOST,
|
29 |
+
DB_USER,
|
30 |
+
DB_PASSWORD,
|
31 |
+
DB_NAME,
|
32 |
+
class_exists( 'PDO' )
|
33 |
+
);
|
34 |
}
|
35 |
|
36 |
/**
|
45 |
|
46 |
if ( empty( $input_file['error'] ) ) {
|
47 |
// Partial file path
|
48 |
+
$upload_file = sys_get_temp_dir() . DIRECTORY_SEPARATOR
|
49 |
+
. $options['name'];
|
50 |
|
51 |
// Open partial file
|
52 |
+
$out = fopen( $upload_file, $options['chunk'] == 0 ? 'wb' : 'ab' );
|
53 |
if ( $out ) {
|
54 |
// Read binary input stream and append it to temp file
|
55 |
$in = fopen( $input_file['tmp_name'], 'rb' );
|
77 |
}
|
78 |
|
79 |
// Extract archive to a temporary directory
|
80 |
+
$archive = ZipFactory::makeZipArchiver( $upload_file, ! class_exists( 'ZipArchive' ) );
|
81 |
$archive->extractTo( $extract_to );
|
82 |
$archive->close();
|
83 |
|
111 |
$this->connection->truncateDatabase();
|
112 |
|
113 |
// Import database
|
114 |
+
$this->connection->import( $extract_to . Ai1wm_Export::EXPORT_DATABASE_NAME );
|
115 |
}
|
116 |
|
117 |
// Check if media files are present
|
151 |
$this->copy_dir( $extract_to . Ai1wm_Export::EXPORT_THEMES_NAME, $themes_basedir );
|
152 |
}
|
153 |
|
154 |
+
if ( file_exists( $extract_to . Ai1wm_Export::EXPORT_PLUGINS_NAME ) ) {
|
155 |
+
// Backup plugin files
|
156 |
+
$backup_plugins_to = sys_get_temp_dir() . DIRECTORY_SEPARATOR
|
157 |
+
. uniqid()
|
158 |
+
. DIRECTORY_SEPARATOR;
|
159 |
+
if ( ! is_dir( $backup_plugins_to ) ) {
|
160 |
+
mkdir( $backup_plugins_to );
|
161 |
+
}
|
162 |
+
|
163 |
+
$this->copy_dir( WP_PLUGIN_DIR, $backup_plugins_to );
|
164 |
+
|
165 |
+
// Truncate plugin files
|
166 |
+
$this->truncate_dir( WP_PLUGIN_DIR );
|
167 |
+
|
168 |
+
// Import plugin files
|
169 |
+
$this->copy_dir( $extract_to . Ai1wm_Export::EXPORT_PLUGINS_NAME, WP_PLUGIN_DIR );
|
170 |
+
}
|
171 |
+
|
172 |
if ( file_exists( $extract_to . Ai1wm_Export::EXPORT_PACKAGE_NAME ) ) {
|
173 |
|
174 |
// Install selected plugins
|
182 |
$this->connection->truncateDatabase();
|
183 |
|
184 |
// Import "OLD" database
|
185 |
+
$this->connection->import( $database_file );
|
186 |
}
|
187 |
|
188 |
if ( file_exists( $extract_to . Ai1wm_Export::EXPORT_MEDIA_NAME ) ) {
|
200 |
// Import "OLD" themes files
|
201 |
$this->copy_dir( $backup_themes_to, $themes_basedir );
|
202 |
}
|
203 |
+
|
204 |
+
if ( file_exists( $extract_to . Ai1wm_Export::EXPORT_PLUGINS_NAME ) ) {
|
205 |
+
// Truncate plugin files
|
206 |
+
$this->truncate_dir( WP_PLUGIN_DIR );
|
207 |
+
|
208 |
+
// Import "OLD" plugin files
|
209 |
+
$this->copy_dir( $backup_plugins_to, WP_PLUGIN_DIR );
|
210 |
+
}
|
211 |
}
|
212 |
|
213 |
// Disable maintenance mode
|
225 |
|
226 |
|
227 |
/**
|
228 |
+
* Enable or disable WordPress maintenance mode
|
229 |
*
|
230 |
* @param boolean $enabled Enable or disable maintenance mode
|
231 |
* @return boolean True if option value has changed, false if not or if update failed
|
232 |
*/
|
233 |
public function maintenance_mode( $enabled = true ) {
|
234 |
+
return update_option( self::MAINTENANCE_MODE, $enabled );
|
235 |
}
|
236 |
|
237 |
/**
|
242 |
* @return void
|
243 |
*/
|
244 |
public function copy_dir( $from, $to ) {
|
245 |
+
$from = trailingslashit( $from );
|
246 |
+
$to = trailingslashit( $to );
|
247 |
+
|
248 |
$iterator = new RecursiveIteratorIterator(
|
249 |
+
$rdi = new RecursiveDirectoryIterator( $from ),
|
250 |
RecursiveIteratorIterator::SELF_FIRST
|
251 |
);
|
252 |
|
253 |
foreach ( $iterator as $item ) {
|
254 |
+
// Skip dots
|
255 |
+
if ( $iterator->isDot() ) continue;
|
256 |
+
|
257 |
if ( $item->isDir() ) {
|
258 |
mkdir( $to . $iterator->getSubPathName() );
|
259 |
} else {
|
269 |
* @return void
|
270 |
*/
|
271 |
public function truncate_dir( $dir ) {
|
272 |
+
$dir = trailingslashit( $dir );
|
273 |
$iterator = new RecursiveIteratorIterator(
|
274 |
+
$rdi = new RecursiveDirectoryIterator( $dir ),
|
275 |
RecursiveIteratorIterator::CHILD_FIRST
|
276 |
);
|
277 |
|
278 |
foreach ( $iterator as $item ) {
|
279 |
+
// Skip dots
|
280 |
+
if ( $iterator->isDot() ) continue;
|
281 |
+
|
282 |
if ( $item->isDir() ) {
|
283 |
+
rmdir( $dir . $iterator->getSubPathName() );
|
284 |
} else {
|
285 |
unlink( $dir . $iterator->getSubPathName() );
|
286 |
}
|
294 |
* @return void
|
295 |
*/
|
296 |
public function install_plugins( $path ) {
|
297 |
+
$file = file_get_contents( $path );
|
298 |
$package = json_decode( $file, true );
|
299 |
|
300 |
// For Plugins API
|
341 |
*/
|
342 |
public function is_valid( $path ) {
|
343 |
$required_objects = array(
|
|
|
344 |
Ai1wm_Export::EXPORT_PACKAGE_NAME,
|
345 |
);
|
346 |
|
lib/vendor/mysqldump-factory/mysqldump-factory/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
The MIT License (MIT)
|
2 |
+
|
3 |
+
Copyright (c) 2013 Yani Iliev, Bobby Angelov
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6 |
+
this software and associated documentation files (the "Software"), to deal in
|
7 |
+
the Software without restriction, including without limitation the rights to
|
8 |
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9 |
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10 |
+
subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17 |
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18 |
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19 |
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20 |
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
lib/vendor/mysqldump-factory/mysqldump-factory/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# MySQL Dump Factory
|
2 |
+
|
3 |
+
[![Build Status](https://travis-ci.org/yani-/mysqldump-factory.png?branch=master)](https://travis-ci.org/yani-/mysqldump-factory)
|
4 |
+
[![Latest Stable Version](https://poser.pugx.org/mysqldump-factory/mysqldump-factory/v/stable.png)](https://packagist.org/packages/mysqldump-factory/mysqldump-factory)
|
5 |
+
[![Total Downloads](https://poser.pugx.org/mysqldump-factory/mysqldump-factory/downloads.png)](https://packagist.org/packages/mysqldump-factory/mysqldump-factory)
|
6 |
+
|
7 |
+
MySQL Dump Factory class that creates either mysql or PDO classes
|
8 |
+
|
9 |
+
### Requirements
|
10 |
+
PHP v5.2 and up. Tested on PHP v5.2.17, v5.3, v5.4, v5.5
|
11 |
+
|
12 |
+
### Usage
|
13 |
+
```php
|
14 |
+
require_once 'lib/MysqlDumpFactory.php';
|
15 |
+
$mc = MysqlDumpFactory::makeMysqlDump('dbhost', 'dbuser', 'dbpass', 'dbname',class_exists('PDO'));
|
16 |
+
```
|
17 |
+
|
18 |
+
### Tests
|
19 |
+
Coverage reports are stored inside the coverage folder.
|
20 |
+
```bash
|
21 |
+
phpunit
|
22 |
+
```
|
23 |
+
|
24 |
+
### Contributing
|
25 |
+
For code guidelines refer to `.editorconfig`. This project is following PEAR code standard - http://pear.php.net/manual/en/standards.php
|
26 |
+
The project is following Vincent Driessen's branching model aka git flow - http://nvie.com/git-model/
|
27 |
+
Make sure to submit your pull requests against the **develop** branch
|
28 |
+
|
29 |
+
### License
|
30 |
+
MIT
|
31 |
+
|
32 |
+
### Authors
|
33 |
+
* Yani Iliev
|
34 |
+
* Bobby Angelov
|
lib/vendor/mysqldump-factory/mysqldump-factory/bump_version.sh
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
if [ -z "$1" ]; then
|
4 |
+
echo -e "\033[0;31mUsage:\033[0m $0 (major|minor|patch)\033[0m"
|
5 |
+
echo -e "\033[4;32mCurrent version\033[0m:\033[0m \033[33m`git describe master`\033[0m"
|
6 |
+
exit -1
|
7 |
+
fi
|
8 |
+
|
9 |
+
# increment version depending on passed parameter
|
10 |
+
case "$1" in
|
11 |
+
major)
|
12 |
+
currentVersion=`git describe master`
|
13 |
+
bumpedVersion=`echo $currentVersion | ( IFS=".$IFS" ; read a b c && echo $((a + 1)).0.0 )`
|
14 |
+
;;
|
15 |
+
minor)
|
16 |
+
currentVersion=`git describe master`
|
17 |
+
bumpedVersion=`echo $currentVersion | ( IFS=".$IFS" ; read a b c && echo $a.$((b + 1)).0 )`
|
18 |
+
;;
|
19 |
+
patch)
|
20 |
+
currentVersion=`git describe master`
|
21 |
+
bumpedVersion=`echo $currentVersion | ( IFS=".$IFS" ; read a b c && echo $a.$b.$((c + 1)) )`
|
22 |
+
;;
|
23 |
+
*)
|
24 |
+
echo -e "\033[0;31mUsage:\033[0m $0 (major|minor|patch)\033[0m"
|
25 |
+
echo -e "\033[4;32mCurrent version\033[0m:\033[0m \033[33m`git describe master`\033[0m"
|
26 |
+
exit -1
|
27 |
+
esac
|
28 |
+
|
29 |
+
# let's start a new release
|
30 |
+
git flow release start $bumpedVersion
|
31 |
+
|
32 |
+
# bump version in all files
|
33 |
+
for file in `find . -path ./coverage -prune -o -path ./.git -prune -o -type f`
|
34 |
+
do
|
35 |
+
filename=$(basename "$file")
|
36 |
+
ext="${filename##*.}"
|
37 |
+
if [ $ext != "png" -a $ext != "jpg" -a $ext != "jpeg" -a $ext != "gif" ]; then
|
38 |
+
if [ $ext != "DS_Store" -a $ext != "ttf" -a $ext != "node_modules" -a $ext != "git" ]; then
|
39 |
+
sed -i '' "s/GIT: $currentVersion/GIT: $bumpedVersion/g" $file
|
40 |
+
fi
|
41 |
+
fi
|
42 |
+
done
|
43 |
+
|
44 |
+
# bump version in package.json
|
45 |
+
sed -i '' "s/\"version\": \"$currentVersion\"/\"version\": \"$bumpedVersion\"/g" package.json
|
46 |
+
|
47 |
+
# add changed files to git
|
48 |
+
git add . && git commit -m "Bumped version from $currentVersion to $bumpedVersion"
|
49 |
+
|
50 |
+
# finish the release
|
51 |
+
git flow release finish -F -m "$bumpedVersion" $bumpedVersion
|
52 |
+
|
53 |
+
# publish develop branch
|
54 |
+
git checkout develop && git push origin develop
|
55 |
+
|
56 |
+
# publish master
|
57 |
+
git checkout master && git push origin master
|
58 |
+
|
59 |
+
# publish tags
|
60 |
+
git push origin --tags
|
61 |
+
|
62 |
+
# Announce the result
|
63 |
+
echo -e "\033[4;32mSuccessfully released\033[0m:\033[0m \033[33m$bumpedVersion\033[0m"
|
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpFactory.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Factory class main file
|
6 |
+
*
|
7 |
+
* PHP version 5
|
8 |
+
*
|
9 |
+
* LICENSE: Permission is hereby granted, free of charge, to any person obtaining
|
10 |
+
* a copy of this software and associated documentation files (the "Software"), to
|
11 |
+
* deal in the Software without restriction, including without limitation the rights
|
12 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
13 |
+
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
14 |
+
* subject to the following conditions:
|
15 |
+
*
|
16 |
+
* The above copyright notice and this permission notice shall be included in all
|
17 |
+
* copies or substantial portions of the Software.
|
18 |
+
*
|
19 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
21 |
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
22 |
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
23 |
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
24 |
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25 |
+
*
|
26 |
+
* @category Databases
|
27 |
+
* @package MysqlDumpFactory
|
28 |
+
* @author Yani Iliev <yani@iliev.me>
|
29 |
+
* @author Bobby Angelov <bobby@servmask.com>
|
30 |
+
* @copyright 2014 Yani Iliev, Bobby Angelov
|
31 |
+
* @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
|
32 |
+
* @version GIT: 1.0.4
|
33 |
+
* @link https://github.com/yani-/mysqldump-factory/
|
34 |
+
*/
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Factory Main class
|
38 |
+
*
|
39 |
+
* @category Databases
|
40 |
+
* @package MysqlDumpFactory
|
41 |
+
* @author Yani Iliev <yani@iliev.me>
|
42 |
+
* @author Bobby Angelov <bobby@servmask.com>
|
43 |
+
* @copyright 2014 Yani Iliev, Bobby Angelov
|
44 |
+
* @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
|
45 |
+
* @version GIT: 1.0.4
|
46 |
+
* @link https://github.com/yani-/mysqldump-factory/
|
47 |
+
*/
|
48 |
+
class MysqlDumpFactory
|
49 |
+
{
|
50 |
+
public static function makeMysqlDump($hostname = 'localhost', $username = '', $password = '', $database = '', $pdo = false)
|
51 |
+
{
|
52 |
+
// is PDO class available?
|
53 |
+
if ($pdo) {
|
54 |
+
require_once
|
55 |
+
dirname(__FILE__) .
|
56 |
+
DIRECTORY_SEPARATOR .
|
57 |
+
'MysqlDumpPDO.php';
|
58 |
+
|
59 |
+
return new MysqlDumpPDO($hostname, $username, $password, $database);
|
60 |
+
} else {
|
61 |
+
require_once
|
62 |
+
dirname(__FILE__) .
|
63 |
+
DIRECTORY_SEPARATOR .
|
64 |
+
'MysqlDumpSQL.php';
|
65 |
+
|
66 |
+
return new MysqlDumpSQL($hostname, $username, $password, $database);
|
67 |
+
}
|
68 |
+
}
|
69 |
+
}
|
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpInterface.php
ADDED
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* MysqlDump interface
|
6 |
+
*
|
7 |
+
* PHP version 5
|
8 |
+
*
|
9 |
+
* LICENSE: Permission is hereby granted, free of charge, to any person obtaining
|
10 |
+
* a copy of this software and associated documentation files (the "Software"), to
|
11 |
+
* deal in the Software without restriction, including without limitation the rights
|
12 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
13 |
+
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
14 |
+
* subject to the following conditions:
|
15 |
+
*
|
16 |
+
* The above copyright notice and this permission notice shall be included in all
|
17 |
+
* copies or substantial portions of the Software.
|
18 |
+
*
|
19 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
21 |
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
22 |
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
23 |
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
24 |
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25 |
+
*
|
26 |
+
* @category Databases
|
27 |
+
* @package MysqlDumpFactory
|
28 |
+
* @author Yani Iliev <yani@iliev.me>
|
29 |
+
* @author Bobby Angelov <bobby@servmask.com>
|
30 |
+
* @copyright 2014 Yani Iliev, Bobby Angelov
|
31 |
+
* @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
|
32 |
+
* @version GIT: 1.0.4
|
33 |
+
* @link https://github.com/yani-/mysqldump-factory/
|
34 |
+
*/
|
35 |
+
|
36 |
+
/**
|
37 |
+
* MysqlDump interface
|
38 |
+
*
|
39 |
+
* @category Databases
|
40 |
+
* @package MysqlDumpFactory
|
41 |
+
* @author Yani Iliev <yani@iliev.me>
|
42 |
+
* @author Bobby Angelov <bobby@servmask.com>
|
43 |
+
* @copyright 2014 Yani Iliev, Bobby Angelov
|
44 |
+
* @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
|
45 |
+
* @version GIT: 1.0.4
|
46 |
+
* @link https://github.com/yani-/mysqldump-factory/
|
47 |
+
*/
|
48 |
+
interface MysqlDumpInterface
|
49 |
+
{
|
50 |
+
const MAXLINESIZE = 1000000;
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Define MySQL credentials for the current connection
|
54 |
+
*
|
55 |
+
* @param string $hostname MySQL Hostname
|
56 |
+
* @param string $username MySQL Username
|
57 |
+
* @param string $password MySQL Password
|
58 |
+
* @param string $database MySQL Database
|
59 |
+
* @return void
|
60 |
+
*/
|
61 |
+
public function __construct($hostname = 'localhost', $username = '', $password = '', $database = '');
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Dump database into a file
|
65 |
+
*
|
66 |
+
* @return void
|
67 |
+
*/
|
68 |
+
public function dump();
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Set output file name
|
72 |
+
*
|
73 |
+
* @param string $fileName Name of the output file
|
74 |
+
* @return string
|
75 |
+
*/
|
76 |
+
public function setFileName($fileName);
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Get output file name
|
80 |
+
*
|
81 |
+
* @return string
|
82 |
+
*/
|
83 |
+
public function getFileName();
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Set query clauses
|
87 |
+
*
|
88 |
+
* @param array $clauses List of SQL query clauses
|
89 |
+
* @return array
|
90 |
+
*/
|
91 |
+
public function setQueryClauses($clauses);
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Get query clauses
|
95 |
+
*
|
96 |
+
* @return array
|
97 |
+
*/
|
98 |
+
public function getQueryClauses();
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Set include tables
|
102 |
+
*
|
103 |
+
* @param array $tables List of tables
|
104 |
+
* @return array
|
105 |
+
*/
|
106 |
+
public function setIncludeTables($tables);
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Get include tables
|
110 |
+
*
|
111 |
+
* @return array
|
112 |
+
*/
|
113 |
+
public function getIncludeTables();
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Set exclude tables
|
117 |
+
*
|
118 |
+
* @param array $tables List of tables
|
119 |
+
* @return array
|
120 |
+
*/
|
121 |
+
public function setExcludeTables($tables);
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Get exclude tables
|
125 |
+
*
|
126 |
+
* @return array
|
127 |
+
*/
|
128 |
+
public function getExcludeTables();
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Set no table data flag
|
132 |
+
*
|
133 |
+
* @param bool $flag Do not export table data
|
134 |
+
* @return bool
|
135 |
+
*/
|
136 |
+
public function setNoTableData($flag);
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Get no table data flag
|
140 |
+
*
|
141 |
+
* @return bool
|
142 |
+
*/
|
143 |
+
public function getNoTableData();
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Set add drop table flag
|
147 |
+
*
|
148 |
+
* @param bool $flag Add drop table SQL clause
|
149 |
+
* @return bool
|
150 |
+
*/
|
151 |
+
public function setAddDropTable($flag);
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Get add drop table flag
|
155 |
+
*
|
156 |
+
* @return bool
|
157 |
+
*/
|
158 |
+
public function getAddDropTable();
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Set extended insert flag
|
162 |
+
*
|
163 |
+
* @param bool $flag Add extended insert SQL clause
|
164 |
+
* @return bool
|
165 |
+
*/
|
166 |
+
public function setExtendedInsert($flag);
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Get extended insert flag
|
170 |
+
*
|
171 |
+
* @return bool
|
172 |
+
*/
|
173 |
+
public function getExtendedInsert();
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Truncate database
|
177 |
+
*
|
178 |
+
* @return void
|
179 |
+
*/
|
180 |
+
public function truncateDatabase();
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Import database from file
|
184 |
+
*
|
185 |
+
* @param string $fileName Name of file
|
186 |
+
* @return bool
|
187 |
+
*/
|
188 |
+
public function import($fileName);
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Get list of tables
|
192 |
+
*
|
193 |
+
* @return array
|
194 |
+
*/
|
195 |
+
public function listTables();
|
196 |
+
}
|
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpPDO.php
ADDED
@@ -0,0 +1,497 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* MysqlDumpPDO class
|
6 |
+
*
|
7 |
+
* PHP version 5
|
8 |
+
*
|
9 |
+
* LICENSE: Permission is hereby granted, free of charge, to any person obtaining
|
10 |
+
* a copy of this software and associated documentation files (the "Software"), to
|
11 |
+
* deal in the Software without restriction, including without limitation the rights
|
12 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
13 |
+
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
14 |
+
* subject to the following conditions:
|
15 |
+
*
|
16 |
+
* The above copyright notice and this permission notice shall be included in all
|
17 |
+
* copies or substantial portions of the Software.
|
18 |
+
*
|
19 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
21 |
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
22 |
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
23 |
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
24 |
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25 |
+
*
|
26 |
+
* @category Databases
|
27 |
+
* @package MysqlDumpFactory
|
28 |
+
* @author Yani Iliev <yani@iliev.me>
|
29 |
+
* @author Bobby Angelov <bobby@servmask.com>
|
30 |
+
* @copyright 2014 Yani Iliev, Bobby Angelov
|
31 |
+
* @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
|
32 |
+
* @version GIT: 1.0.4
|
33 |
+
* @link https://github.com/yani-/mysqldump-factory/
|
34 |
+
*/
|
35 |
+
|
36 |
+
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'MysqlDumpInterface.php';
|
37 |
+
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'MysqlQueryAdapter.php';
|
38 |
+
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'MysqlFileAdapter.php';
|
39 |
+
|
40 |
+
/**
|
41 |
+
* MysqlDumpPDO class
|
42 |
+
*
|
43 |
+
* @category Databases
|
44 |
+
* @package MysqlDumpFactory
|
45 |
+
* @author Yani Iliev <yani@iliev.me>
|
46 |
+
* @author Bobby Angelov <bobby@servmask.com>
|
47 |
+
* @copyright 2014 Yani Iliev, Bobby Angelov
|
48 |
+
* @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
|
49 |
+
* @version GIT: 1.0.4
|
50 |
+
* @link https://github.com/yani-/mysqldump-factory/
|
51 |
+
*/
|
52 |
+
class MysqlDumpPDO implements MysqlDumpInterface
|
53 |
+
{
|
54 |
+
protected $hostname = null;
|
55 |
+
|
56 |
+
protected $username = null;
|
57 |
+
|
58 |
+
protected $password = null;
|
59 |
+
|
60 |
+
protected $database = null;
|
61 |
+
|
62 |
+
protected $fileName = 'dump.sql';
|
63 |
+
|
64 |
+
protected $fileAdapter = null;
|
65 |
+
|
66 |
+
protected $queryAdapter = null;
|
67 |
+
|
68 |
+
protected $connection = null;
|
69 |
+
|
70 |
+
protected $queryClauses = array();
|
71 |
+
|
72 |
+
protected $includeTables = array();
|
73 |
+
|
74 |
+
protected $excludeTables = array();
|
75 |
+
|
76 |
+
protected $noTableData = false;
|
77 |
+
|
78 |
+
protected $addDropTable = false;
|
79 |
+
|
80 |
+
protected $extendedInsert = true;
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Define MySQL credentials for the current connection
|
84 |
+
*
|
85 |
+
* @param string $hostname MySQL Hostname
|
86 |
+
* @param string $username MySQL Username
|
87 |
+
* @param string $password MySQL Password
|
88 |
+
* @param string $database MySQL Database
|
89 |
+
* @return void
|
90 |
+
*/
|
91 |
+
public function __construct($hostname = 'localhost', $username = '', $password = '', $database = '')
|
92 |
+
{
|
93 |
+
// Set MySQL credentials
|
94 |
+
$this->hostname = $hostname;
|
95 |
+
$this->username = $username;
|
96 |
+
$this->password = $password;
|
97 |
+
$this->database = $database;
|
98 |
+
|
99 |
+
// Set Query Adapter
|
100 |
+
$this->queryAdapter = new MysqlQueryAdapter('mysql');
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Dump database into a file
|
105 |
+
*
|
106 |
+
* @return void
|
107 |
+
*/
|
108 |
+
public function dump()
|
109 |
+
{
|
110 |
+
// Set File Adapter
|
111 |
+
$this->fileAdapter = new MysqlFileAdapter();
|
112 |
+
|
113 |
+
// Set output file
|
114 |
+
$this->fileAdapter->open($this->getFileName());
|
115 |
+
|
116 |
+
// Write Headers Formating dump file
|
117 |
+
$this->fileAdapter->write($this->getHeader());
|
118 |
+
|
119 |
+
// Listing all tables from database
|
120 |
+
$tables = array();
|
121 |
+
foreach ($this->listTables() as $table) {
|
122 |
+
if (count($this->getIncludeTables()) === 0 || in_array($table, $this->getIncludeTables())) {
|
123 |
+
$tables[] = $table;
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
// Export Tables
|
128 |
+
foreach ($tables as $table) {
|
129 |
+
if (in_array($table, $this->getExcludeTables())) {
|
130 |
+
continue;
|
131 |
+
}
|
132 |
+
|
133 |
+
$isTable = $this->getTableStructure($table);
|
134 |
+
if (true === $isTable) {
|
135 |
+
$this->listValues($table);
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Set output file name
|
142 |
+
*
|
143 |
+
* @param string $fileName Name of the output file
|
144 |
+
* @return string
|
145 |
+
*/
|
146 |
+
public function setFileName($fileName)
|
147 |
+
{
|
148 |
+
$this->fileName = $fileName;
|
149 |
+
|
150 |
+
return $this;
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Get output file name
|
155 |
+
*
|
156 |
+
* @return string
|
157 |
+
*/
|
158 |
+
public function getFileName()
|
159 |
+
{
|
160 |
+
return $this->fileName;
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Set query clauses
|
165 |
+
*
|
166 |
+
* @param array $clauses List of SQL query clauses
|
167 |
+
* @return array
|
168 |
+
*/
|
169 |
+
public function setQueryClauses($clauses)
|
170 |
+
{
|
171 |
+
$this->queryClauses = $clauses;
|
172 |
+
|
173 |
+
return $this;
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Get query clauses
|
178 |
+
*
|
179 |
+
* @return array
|
180 |
+
*/
|
181 |
+
public function getQueryClauses()
|
182 |
+
{
|
183 |
+
return $this->queryClauses;
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Set include tables
|
188 |
+
*
|
189 |
+
* @param array $tables List of tables
|
190 |
+
* @return array
|
191 |
+
*/
|
192 |
+
public function setIncludeTables($tables)
|
193 |
+
{
|
194 |
+
$this->includeTables = $tables;
|
195 |
+
|
196 |
+
return $this;
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Get include tables
|
201 |
+
*
|
202 |
+
* @return array
|
203 |
+
*/
|
204 |
+
public function getIncludeTables()
|
205 |
+
{
|
206 |
+
return $this->includeTables;
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Set exclude tables
|
211 |
+
*
|
212 |
+
* @param array $tables List of tables
|
213 |
+
* @return array
|
214 |
+
*/
|
215 |
+
public function setExcludeTables($tables)
|
216 |
+
{
|
217 |
+
$this->excludeTables = $tables;
|
218 |
+
|
219 |
+
return $this;
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Get exclude tables
|
224 |
+
*
|
225 |
+
* @return array
|
226 |
+
*/
|
227 |
+
public function getExcludeTables()
|
228 |
+
{
|
229 |
+
return $this->excludeTables;
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Set no table data flag
|
234 |
+
*
|
235 |
+
* @param bool $flag Do not export table data
|
236 |
+
* @return bool
|
237 |
+
*/
|
238 |
+
public function setNoTableData($flag)
|
239 |
+
{
|
240 |
+
$this->noTableData = $flag;
|
241 |
+
|
242 |
+
return $this;
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Get no table data flag
|
247 |
+
*
|
248 |
+
* @return bool
|
249 |
+
*/
|
250 |
+
public function getNoTableData()
|
251 |
+
{
|
252 |
+
return $this->noTableData;
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Set add drop table flag
|
257 |
+
*
|
258 |
+
* @param bool $flag Add drop table SQL clause
|
259 |
+
* @return bool
|
260 |
+
*/
|
261 |
+
public function setAddDropTable($flag)
|
262 |
+
{
|
263 |
+
$this->addDropTable = $flag;
|
264 |
+
|
265 |
+
return $this;
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Get add drop table flag
|
270 |
+
*
|
271 |
+
* @return bool
|
272 |
+
*/
|
273 |
+
public function getAddDropTable()
|
274 |
+
{
|
275 |
+
return $this->addDropTable;
|
276 |
+
}
|
277 |
+
|
278 |
+
/**
|
279 |
+
* Set extended insert flag
|
280 |
+
*
|
281 |
+
* @param bool $flag Add extended insert SQL clause
|
282 |
+
* @return bool
|
283 |
+
*/
|
284 |
+
public function setExtendedInsert($flag)
|
285 |
+
{
|
286 |
+
$this->extendedInsert = $flag;
|
287 |
+
|
288 |
+
return $this;
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* Get extended insert flag
|
293 |
+
*
|
294 |
+
* @return bool
|
295 |
+
*/
|
296 |
+
public function getExtendedInsert()
|
297 |
+
{
|
298 |
+
return $this->extendedInsert;
|
299 |
+
}
|
300 |
+
|
301 |
+
/**
|
302 |
+
* Truncate database
|
303 |
+
*
|
304 |
+
* @return void
|
305 |
+
*/
|
306 |
+
public function truncateDatabase()
|
307 |
+
{
|
308 |
+
$query = $this->queryAdapter->show_tables($this->database);
|
309 |
+
foreach ($this->getConnection()->query($query) as $row) {
|
310 |
+
// Drop table
|
311 |
+
$delete = $this->queryAdapter->drop_table($row['table_name']);
|
312 |
+
$this->getConnection()->query($delete);
|
313 |
+
}
|
314 |
+
}
|
315 |
+
|
316 |
+
/**
|
317 |
+
* Import database from file
|
318 |
+
*
|
319 |
+
* @param string $fileName Name of file
|
320 |
+
* @return bool
|
321 |
+
*/
|
322 |
+
public function import($fileName)
|
323 |
+
{
|
324 |
+
$fileHandler = fopen($fileName, 'r');
|
325 |
+
if ($fileHandler) {
|
326 |
+
$query = null;
|
327 |
+
|
328 |
+
// Read database file line by line
|
329 |
+
while (($line = fgets($fileHandler)) !== false) {
|
330 |
+
$query .= $line;
|
331 |
+
if (preg_match('/;\s*$/', $line)) {
|
332 |
+
try {
|
333 |
+
// Run SQL query
|
334 |
+
$result = $this->getConnection()->query($query);
|
335 |
+
if ($result) {
|
336 |
+
$query = null;
|
337 |
+
}
|
338 |
+
} catch (PDOException $e) {
|
339 |
+
continue;
|
340 |
+
}
|
341 |
+
}
|
342 |
+
}
|
343 |
+
|
344 |
+
return true;
|
345 |
+
}
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Get list of tables
|
350 |
+
*
|
351 |
+
* @return array
|
352 |
+
*/
|
353 |
+
public function listTables()
|
354 |
+
{
|
355 |
+
$tables = array();
|
356 |
+
|
357 |
+
$query = $this->queryAdapter->show_tables($this->database);
|
358 |
+
foreach ($this->getConnection()->query($query) as $row) {
|
359 |
+
$tables[] = $row['table_name'];
|
360 |
+
}
|
361 |
+
|
362 |
+
return $tables;
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Create MySQL connection (lazy loading)
|
367 |
+
*
|
368 |
+
* @return mixed
|
369 |
+
*/
|
370 |
+
public function getConnection()
|
371 |
+
{
|
372 |
+
if ($this->connection === null) {
|
373 |
+
try {
|
374 |
+
// Make connection
|
375 |
+
$this->connection = new PDO(
|
376 |
+
sprintf('mysql:host=%s;dbname=%s', $this->hostname, $this->database),
|
377 |
+
$this->username,
|
378 |
+
$this->password,
|
379 |
+
array(
|
380 |
+
PDO::ATTR_PERSISTENT => true,
|
381 |
+
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
382 |
+
)
|
383 |
+
);
|
384 |
+
|
385 |
+
// Set additional connection attributes
|
386 |
+
$this->connection->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_NATURAL);
|
387 |
+
|
388 |
+
// Set default encoding
|
389 |
+
$query = $this->queryAdapter->set_names( 'utf8' );
|
390 |
+
$this->connection->exec($query);
|
391 |
+
} catch (PDOException $e) {
|
392 |
+
throw new Exception('Unable to connect to MySQL database server: ' . $e->getMessage());
|
393 |
+
}
|
394 |
+
}
|
395 |
+
|
396 |
+
return $this->connection;
|
397 |
+
}
|
398 |
+
|
399 |
+
/**
|
400 |
+
* Returns header for dump file
|
401 |
+
*
|
402 |
+
* @return string
|
403 |
+
*/
|
404 |
+
protected function getHeader()
|
405 |
+
{
|
406 |
+
// Some info about software, source and time
|
407 |
+
$header = "-- All In One WP Migration SQL Dump\n" .
|
408 |
+
"-- http://servmask.com/\n" .
|
409 |
+
"--\n" .
|
410 |
+
"-- Host: {$this->hostname}\n" .
|
411 |
+
"-- Generation Time: " . date('r') . "\n\n" .
|
412 |
+
"--\n" .
|
413 |
+
"-- Database: `{$this->database}`\n" .
|
414 |
+
"--\n\n";
|
415 |
+
|
416 |
+
return $header;
|
417 |
+
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
* Table structure extractor
|
421 |
+
*
|
422 |
+
* @param string $tableName Name of table to export
|
423 |
+
* @return bool
|
424 |
+
*/
|
425 |
+
protected function getTableStructure($tableName)
|
426 |
+
{
|
427 |
+
$query = $this->queryAdapter->show_create_table($tableName);
|
428 |
+
foreach ($this->getConnection()->query($query) as $row) {
|
429 |
+
if (isset($row['Create Table'])) {
|
430 |
+
$this->fileAdapter->write("-- " .
|
431 |
+
"--------------------------------------------------------" .
|
432 |
+
"\n\n" .
|
433 |
+
"--\n" .
|
434 |
+
"-- Table structure for table `$tableName`\n--\n\n");
|
435 |
+
|
436 |
+
if ($this->getAddDropTable()) {
|
437 |
+
$this->fileAdapter->write("DROP TABLE IF EXISTS `$tableName`;\n\n");
|
438 |
+
}
|
439 |
+
|
440 |
+
$this->fileAdapter->write($row['Create Table'] . ";\n\n");
|
441 |
+
|
442 |
+
return true;
|
443 |
+
}
|
444 |
+
}
|
445 |
+
}
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Table rows extractor
|
449 |
+
*
|
450 |
+
* @param string $tableName Name of table to export
|
451 |
+
* @return void
|
452 |
+
*/
|
453 |
+
protected function listValues($tableName)
|
454 |
+
{
|
455 |
+
$this->fileAdapter->write(
|
456 |
+
"--\n" .
|
457 |
+
"-- Dumping data for table `$tableName`\n" .
|
458 |
+
"--\n\n"
|
459 |
+
);
|
460 |
+
|
461 |
+
$insertFirst = true;
|
462 |
+
$lineSize = 0;
|
463 |
+
$query = "SELECT * FROM `$tableName` ";
|
464 |
+
|
465 |
+
// Apply additional query clauses
|
466 |
+
if ($this->getNoTableData()) {
|
467 |
+
$clauses = $this->getQueryClauses();
|
468 |
+
if (isset($clauses[$tableName]) && ($queryClause = $clauses[$tableName])) {
|
469 |
+
$query .= $queryClause;
|
470 |
+
}
|
471 |
+
}
|
472 |
+
|
473 |
+
// Generate insert statements
|
474 |
+
foreach ($this->getConnection()->query($query, PDO::FETCH_NUM) as $row) {
|
475 |
+
$items = array();
|
476 |
+
foreach ($row as $value) {
|
477 |
+
$items[] = is_null($value) ? 'NULL' : $this->getConnection()->quote($value);;
|
478 |
+
}
|
479 |
+
|
480 |
+
if ($insertFirst || !$this->getExtendedInsert()) {
|
481 |
+
$lineSize += $this->fileAdapter->write("INSERT INTO `$tableName` VALUES (" . implode(',', $items) . ')');
|
482 |
+
$insertFirst = false;
|
483 |
+
} else {
|
484 |
+
$lineSize += $this->fileAdapter->write(',(' . implode(',', $items) . ')');
|
485 |
+
}
|
486 |
+
|
487 |
+
if (($lineSize > MysqlDumpInterface::MAXLINESIZE) || !$this->getExtendedInsert()) {
|
488 |
+
$insertFirst = true;
|
489 |
+
$lineSize = $this->fileAdapter->write(";\n");
|
490 |
+
}
|
491 |
+
}
|
492 |
+
|
493 |
+
if (!$insertFirst) {
|
494 |
+
$this->fileAdapter->write(";\n");
|
495 |
+
}
|
496 |
+
}
|
497 |
+
}
|
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpSQL.php
ADDED
@@ -0,0 +1,490 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* MysqlDumpSQL class
|
6 |
+
*
|
7 |
+
* PHP version 5
|
8 |
+
*
|
9 |
+
* LICENSE: Permission is hereby granted, free of charge, to any person obtaining
|
10 |
+
* a copy of this software and associated documentation files (the "Software"), to
|
11 |
+
* deal in the Software without restriction, including without limitation the rights
|
12 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
13 |
+
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
14 |
+
* subject to the following conditions:
|
15 |
+
*
|
16 |
+
* The above copyright notice and this permission notice shall be included in all
|
17 |
+
* copies or substantial portions of the Software.
|
18 |
+
*
|
19 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
21 |
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
22 |
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
23 |
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
24 |
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25 |
+
*
|
26 |
+
* @category Databases
|
27 |
+
* @package MysqlDumpFactory
|
28 |
+
* @author Yani Iliev <yani@iliev.me>
|
29 |
+
* @author Bobby Angelov <bobby@servmask.com>
|
30 |
+
* @copyright 2014 Yani Iliev, Bobby Angelov
|
31 |
+
* @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
|
32 |
+
* @version GIT: 1.0.4
|
33 |
+
* @link https://github.com/yani-/mysqldump-factory/
|
34 |
+
*/
|
35 |
+
|
36 |
+
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'MysqlDumpInterface.php';
|
37 |
+
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'MysqlQueryAdapter.php';
|
38 |
+
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'MysqlFileAdapter.php';
|
39 |
+
|
40 |
+
/**
|
41 |
+
* MysqlDumpSQL class
|
42 |
+
*
|
43 |
+
* @category Databases
|
44 |
+
* @package MysqlDumpFactory
|
45 |
+
* @author Yani Iliev <yani@iliev.me>
|
46 |
+
* @author Bobby Angelov <bobby@servmask.com>
|
47 |
+
* @copyright 2014 Yani Iliev, Bobby Angelov
|
48 |
+
* @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
|
49 |
+
* @version GIT: 1.0.4
|
50 |
+
* @link https://github.com/yani-/mysqldump-factory/
|
51 |
+
*/
|
52 |
+
class MysqlDumpSQL implements MysqlDumpInterface
|
53 |
+
{
|
54 |
+
protected $hostname = null;
|
55 |
+
|
56 |
+
protected $username = null;
|
57 |
+
|
58 |
+
protected $password = null;
|
59 |
+
|
60 |
+
protected $database = null;
|
61 |
+
|
62 |
+
protected $fileName = 'dump.sql';
|
63 |
+
|
64 |
+
protected $fileAdapter = null;
|
65 |
+
|
66 |
+
protected $queryAdapter = null;
|
67 |
+
|
68 |
+
protected $connection = null;
|
69 |
+
|
70 |
+
protected $queryClauses = array();
|
71 |
+
|
72 |
+
protected $includeTables = array();
|
73 |
+
|
74 |
+
protected $excludeTables = array();
|
75 |
+
|
76 |
+
protected $noTableData = false;
|
77 |
+
|
78 |
+
protected $addDropTable = false;
|
79 |
+
|
80 |
+
protected $extendedInsert = true;
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Define MySQL credentials for the current connection
|
84 |
+
*
|
85 |
+
* @param string $hostname MySQL Hostname
|
86 |
+
* @param string $username MySQL Username
|
87 |
+
* @param string $password MySQL Password
|
88 |
+
* @param string $database MySQL Database
|
89 |
+
* @return void
|
90 |
+
*/
|
91 |
+
public function __construct($hostname = 'localhost', $username = '', $password = '', $database = '')
|
92 |
+
{
|
93 |
+
// Set MySQL credentials
|
94 |
+
$this->hostname = $hostname;
|
95 |
+
$this->username = $username;
|
96 |
+
$this->password = $password;
|
97 |
+
$this->database = $database;
|
98 |
+
|
99 |
+
// Set Query Adapter
|
100 |
+
$this->queryAdapter = new MysqlQueryAdapter('mysql');
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Dump database into a file
|
105 |
+
*
|
106 |
+
* @return void
|
107 |
+
*/
|
108 |
+
public function dump()
|
109 |
+
{
|
110 |
+
// Set File Adapter
|
111 |
+
$this->fileAdapter = new MysqlFileAdapter();
|
112 |
+
|
113 |
+
// Set output file
|
114 |
+
$this->fileAdapter->open($this->getFileName());
|
115 |
+
|
116 |
+
// Write Headers Formating dump file
|
117 |
+
$this->fileAdapter->write($this->getHeader());
|
118 |
+
|
119 |
+
// Listing all tables from database
|
120 |
+
$tables = array();
|
121 |
+
foreach ($this->listTables() as $table) {
|
122 |
+
if (count($this->getIncludeTables()) === 0 || in_array($table, $this->getIncludeTables())) {
|
123 |
+
$tables[] = $table;
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
// Export Tables
|
128 |
+
foreach ($tables as $table) {
|
129 |
+
if (in_array($table, $this->getExcludeTables())) {
|
130 |
+
continue;
|
131 |
+
}
|
132 |
+
|
133 |
+
$isTable = $this->getTableStructure($table);
|
134 |
+
if (true === $isTable) {
|
135 |
+
$this->listValues($table);
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Set output file name
|
142 |
+
*
|
143 |
+
* @param string $fileName Name of the output file
|
144 |
+
* @return string
|
145 |
+
*/
|
146 |
+
public function setFileName($fileName)
|
147 |
+
{
|
148 |
+
$this->fileName = $fileName;
|
149 |
+
|
150 |
+
return $this;
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Get output file name
|
155 |
+
*
|
156 |
+
* @return string
|
157 |
+
*/
|
158 |
+
public function getFileName()
|
159 |
+
{
|
160 |
+
return $this->fileName;
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Set query clauses
|
165 |
+
*
|
166 |
+
* @param array $clauses List of SQL query clauses
|
167 |
+
* @return array
|
168 |
+
*/
|
169 |
+
public function setQueryClauses($clauses)
|
170 |
+
{
|
171 |
+
$this->queryClauses = $clauses;
|
172 |
+
|
173 |
+
return $this;
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Get query clauses
|
178 |
+
*
|
179 |
+
* @return array
|
180 |
+
*/
|
181 |
+
public function getQueryClauses()
|
182 |
+
{
|
183 |
+
return $this->queryClauses;
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Set include tables
|
188 |
+
*
|
189 |
+
* @param array $tables List of tables
|
190 |
+
* @return array
|
191 |
+
*/
|
192 |
+
public function setIncludeTables($tables)
|
193 |
+
{
|
194 |
+
$this->includeTables = $tables;
|
195 |
+
|
196 |
+
return $this;
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Get include tables
|
201 |
+
*
|
202 |
+
* @return array
|
203 |
+
*/
|
204 |
+
public function getIncludeTables()
|
205 |
+
{
|
206 |
+
return $this->includeTables;
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Set exclude tables
|
211 |
+
*
|
212 |
+
* @param array $tables List of tables
|
213 |
+
* @return array
|
214 |
+
*/
|
215 |
+
public function setExcludeTables($tables)
|
216 |
+
{
|
217 |
+
$this->excludeTables = $tables;
|
218 |
+
|
219 |
+
return $this;
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Get exclude tables
|
224 |
+
*
|
225 |
+
* @return array
|
226 |
+
*/
|
227 |
+
public function getExcludeTables()
|
228 |
+
{
|
229 |
+
return $this->excludeTables;
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Set no table data flag
|
234 |
+
*
|
235 |
+
* @param bool $flag Do not export table data
|
236 |
+
* @return bool
|
237 |
+
*/
|
238 |
+
public function setNoTableData($flag)
|
239 |
+
{
|
240 |
+
$this->noTableData = $flag;
|
241 |
+
|
242 |
+
return $this;
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Get no table data flag
|
247 |
+
*
|
248 |
+
* @return bool
|
249 |
+
*/
|
250 |
+
public function getNoTableData()
|
251 |
+
{
|
252 |
+
return $this->noTableData;
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Set add drop table flag
|
257 |
+
*
|
258 |
+
* @param bool $flag Add drop table SQL clause
|
259 |
+
* @return bool
|
260 |
+
*/
|
261 |
+
public function setAddDropTable($flag)
|
262 |
+
{
|
263 |
+
$this->addDropTable = $flag;
|
264 |
+
|
265 |
+
return $this;
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Get add drop table flag
|
270 |
+
*
|
271 |
+
* @return bool
|
272 |
+
*/
|
273 |
+
public function getAddDropTable()
|
274 |
+
{
|
275 |
+
return $this->addDropTable;
|
276 |
+
}
|
277 |
+
|
278 |
+
/**
|
279 |
+
* Set extended insert flag
|
280 |
+
*
|
281 |
+
* @param bool $flag Add extended insert SQL clause
|
282 |
+
* @return bool
|
283 |
+
*/
|
284 |
+
public function setExtendedInsert($flag)
|
285 |
+
{
|
286 |
+
$this->extendedInsert = $flag;
|
287 |
+
|
288 |
+
return $this;
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* Get extended insert flag
|
293 |
+
*
|
294 |
+
* @return bool
|
295 |
+
*/
|
296 |
+
public function getExtendedInsert()
|
297 |
+
{
|
298 |
+
return $this->extendedInsert;
|
299 |
+
}
|
300 |
+
|
301 |
+
/**
|
302 |
+
* Truncate database
|
303 |
+
*
|
304 |
+
* @return void
|
305 |
+
*/
|
306 |
+
public function truncateDatabase()
|
307 |
+
{
|
308 |
+
$query = $this->queryAdapter->show_tables($this->database);
|
309 |
+
$result = mysql_query($query, $this->getConnection());
|
310 |
+
while ($row = mysql_fetch_assoc($result)) {
|
311 |
+
// Drop table
|
312 |
+
$delete = $this->queryAdapter->drop_table($row['table_name']);
|
313 |
+
mysql_query($delete, $this->getConnection());
|
314 |
+
}
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
* Import database from file
|
319 |
+
*
|
320 |
+
* @param string $fileName Name of file
|
321 |
+
* @return bool
|
322 |
+
*/
|
323 |
+
public function import($fileName)
|
324 |
+
{
|
325 |
+
$fileHandler = fopen($fileName, 'r');
|
326 |
+
if ($fileHandler) {
|
327 |
+
$query = null;
|
328 |
+
|
329 |
+
// Read database file line by line
|
330 |
+
while (($line = fgets($fileHandler)) !== false) {
|
331 |
+
$query .= $line;
|
332 |
+
if (preg_match('/;\s*$/', $line)) {
|
333 |
+
// Run SQL query
|
334 |
+
$result = mysql_query($query, $this->getConnection());
|
335 |
+
if ($result) {
|
336 |
+
$query = null;
|
337 |
+
}
|
338 |
+
}
|
339 |
+
}
|
340 |
+
|
341 |
+
return true;
|
342 |
+
}
|
343 |
+
}
|
344 |
+
|
345 |
+
/**
|
346 |
+
* Get list of tables
|
347 |
+
*
|
348 |
+
* @return array
|
349 |
+
*/
|
350 |
+
public function listTables()
|
351 |
+
{
|
352 |
+
$tables = array();
|
353 |
+
|
354 |
+
$query = $this->queryAdapter->show_tables($this->database);
|
355 |
+
$result = mysql_query($query, $this->getConnection());
|
356 |
+
while ($row = mysql_fetch_assoc($result)) {
|
357 |
+
$tables[] = $row['table_name'];
|
358 |
+
}
|
359 |
+
|
360 |
+
return $tables;
|
361 |
+
}
|
362 |
+
|
363 |
+
/**
|
364 |
+
* Create MySQL connection (lazy loading)
|
365 |
+
*
|
366 |
+
* @return mixed
|
367 |
+
*/
|
368 |
+
protected function getConnection()
|
369 |
+
{
|
370 |
+
if ($this->connection === null) {
|
371 |
+
// Make connection
|
372 |
+
$this->connection = mysql_pconnect($this->hostname, $this->username, $this->password);
|
373 |
+
|
374 |
+
// Select database and set default encoding
|
375 |
+
if ($this->connection) {
|
376 |
+
if (mysql_select_db($this->database, $this->connection)) {
|
377 |
+
$query = $this->queryAdapter->set_names( 'utf8' );
|
378 |
+
mysql_query($query, $this->connection);
|
379 |
+
} else {
|
380 |
+
throw new Exception('Could not select MySQL database: ' . mysql_error($this->connection));
|
381 |
+
}
|
382 |
+
} else {
|
383 |
+
throw new Exception('Unable to connect to MySQL database server: ' . mysql_error($this->connection));
|
384 |
+
}
|
385 |
+
}
|
386 |
+
|
387 |
+
return $this->connection;
|
388 |
+
}
|
389 |
+
|
390 |
+
/**
|
391 |
+
* Returns header for dump file
|
392 |
+
*
|
393 |
+
* @return string
|
394 |
+
*/
|
395 |
+
protected function getHeader()
|
396 |
+
{
|
397 |
+
// Some info about software, source and time
|
398 |
+
$header = "-- All In One WP Migration SQL Dump\n" .
|
399 |
+
"-- http://servmask.com/\n" .
|
400 |
+
"--\n" .
|
401 |
+
"-- Host: {$this->hostname}\n" .
|
402 |
+
"-- Generation Time: " . date('r') . "\n\n" .
|
403 |
+
"--\n" .
|
404 |
+
"-- Database: `{$this->database}`\n" .
|
405 |
+
"--\n\n";
|
406 |
+
|
407 |
+
return $header;
|
408 |
+
}
|
409 |
+
|
410 |
+
/**
|
411 |
+
* Table structure extractor
|
412 |
+
*
|
413 |
+
* @param string $tableName Name of table to export
|
414 |
+
* @return bool
|
415 |
+
*/
|
416 |
+
protected function getTableStructure($tableName)
|
417 |
+
{
|
418 |
+
$query = $this->queryAdapter->show_create_table($tableName);
|
419 |
+
$result = mysql_query($query, $this->getConnection());
|
420 |
+
while ($row = mysql_fetch_assoc($result)) {
|
421 |
+
if (isset($row['Create Table'])) {
|
422 |
+
$this->fileAdapter->write("-- " .
|
423 |
+
"--------------------------------------------------------" .
|
424 |
+
"\n\n" .
|
425 |
+
"--\n" .
|
426 |
+
"-- Table structure for table `$tableName`\n--\n\n");
|
427 |
+
|
428 |
+
if ($this->getAddDropTable()) {
|
429 |
+
$this->fileAdapter->write("DROP TABLE IF EXISTS `$tableName`;\n\n");
|
430 |
+
}
|
431 |
+
|
432 |
+
$this->fileAdapter->write($row['Create Table'] . ";\n\n");
|
433 |
+
|
434 |
+
return true;
|
435 |
+
}
|
436 |
+
}
|
437 |
+
}
|
438 |
+
|
439 |
+
/**
|
440 |
+
* Table rows extractor
|
441 |
+
*
|
442 |
+
* @param string $tableName Name of table to export
|
443 |
+
* @return void
|
444 |
+
*/
|
445 |
+
protected function listValues($tableName)
|
446 |
+
{
|
447 |
+
$this->fileAdapter->write(
|
448 |
+
"--\n" .
|
449 |
+
"-- Dumping data for table `$tableName`\n" .
|
450 |
+
"--\n\n"
|
451 |
+
);
|
452 |
+
|
453 |
+
$insertFirst = true;
|
454 |
+
$lineSize = 0;
|
455 |
+
$query = "SELECT * FROM `$tableName` ";
|
456 |
+
|
457 |
+
// Apply additional query clauses
|
458 |
+
if ($this->getNoTableData()) {
|
459 |
+
$clauses = $this->getQueryClauses();
|
460 |
+
if (isset($clauses[$tableName]) && ($queryClause = $clauses[$tableName])) {
|
461 |
+
$query .= $queryClause;
|
462 |
+
}
|
463 |
+
}
|
464 |
+
|
465 |
+
// Generate insert statements
|
466 |
+
$result = mysql_query($query, $this->getConnection());
|
467 |
+
while ($row = mysql_fetch_row($result)) {
|
468 |
+
$items = array();
|
469 |
+
foreach ($row as $value) {
|
470 |
+
$items[] = is_null($value) ? 'NULL' : "'" . mysql_real_escape_string($value) . "'";
|
471 |
+
}
|
472 |
+
|
473 |
+
if ($insertFirst || !$this->getExtendedInsert()) {
|
474 |
+
$lineSize += $this->fileAdapter->write("INSERT INTO `$tableName` VALUES (" . implode(',', $items) . ')');
|
475 |
+
$insertFirst = false;
|
476 |
+
} else {
|
477 |
+
$lineSize += $this->fileAdapter->write(',(' . implode(',', $items) . ')');
|
478 |
+
}
|
479 |
+
|
480 |
+
if (($lineSize > MysqlDumpInterface::MAXLINESIZE) || !$this->getExtendedInsert()) {
|
481 |
+
$insertFirst = true;
|
482 |
+
$lineSize = $this->fileAdapter->write(";\n");
|
483 |
+
}
|
484 |
+
}
|
485 |
+
|
486 |
+
if (!$insertFirst) {
|
487 |
+
$this->fileAdapter->write(";\n");
|
488 |
+
}
|
489 |
+
}
|
490 |
+
}
|
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlFileAdapter.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* MysqlFileAdapter class
|
6 |
+
*
|
7 |
+
* PHP version 5
|
8 |
+
*
|
9 |
+
* LICENSE: Permission is hereby granted, free of charge, to any person obtaining
|
10 |
+
* a copy of this software and associated documentation files (the "Software"), to
|
11 |
+
* deal in the Software without restriction, including without limitation the rights
|
12 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
13 |
+
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
14 |
+
* subject to the following conditions:
|
15 |
+
*
|
16 |
+
* The above copyright notice and this permission notice shall be included in all
|
17 |
+
* copies or substantial portions of the Software.
|
18 |
+
*
|
19 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
21 |
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
22 |
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
23 |
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
24 |
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25 |
+
*
|
26 |
+
* @category Databases
|
27 |
+
* @package MysqlDumpFactory
|
28 |
+
* @author Yani Iliev <yani@iliev.me>
|
29 |
+
* @author Bobby Angelov <bobby@servmask.com>
|
30 |
+
* @copyright 2014 Yani Iliev, Bobby Angelov
|
31 |
+
* @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
|
32 |
+
* @version GIT: 1.0.4
|
33 |
+
* @link https://github.com/yani-/mysqldump-factory/
|
34 |
+
*/
|
35 |
+
|
36 |
+
/**
|
37 |
+
* MysqlFileAdapter class
|
38 |
+
*
|
39 |
+
* @category Databases
|
40 |
+
* @package MysqlDumpFactory
|
41 |
+
* @author Yani Iliev <yani@iliev.me>
|
42 |
+
* @author Bobby Angelov <bobby@servmask.com>
|
43 |
+
* @copyright 2014 Yani Iliev, Bobby Angelov
|
44 |
+
* @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
|
45 |
+
* @version GIT: 1.0.4
|
46 |
+
* @link https://github.com/yani-/mysqldump-factory/
|
47 |
+
*/
|
48 |
+
class MysqlFileAdapter
|
49 |
+
{
|
50 |
+
protected $fileHandler = null;
|
51 |
+
|
52 |
+
public function open($fileName)
|
53 |
+
{
|
54 |
+
$this->fileHandler = fopen($fileName, 'wb');
|
55 |
+
if (false === $this->fileHandler) {
|
56 |
+
throw new Exception('Output file is not writable', 2);
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
public function write($str)
|
61 |
+
{
|
62 |
+
$bytesWritten = 0;
|
63 |
+
if (false === ($bytesWritten = fwrite($this->fileHandler, $str))) {
|
64 |
+
throw new Exception('Writting to file failed! Probably, there is no more free space left?', 4);
|
65 |
+
}
|
66 |
+
|
67 |
+
return $bytesWritten;
|
68 |
+
}
|
69 |
+
|
70 |
+
public function close()
|
71 |
+
{
|
72 |
+
return fclose($this->fileHandler);
|
73 |
+
}
|
74 |
+
}
|
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlQueryAdapter.php
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* MysqlQueryAdapter class
|
6 |
+
*
|
7 |
+
* PHP version 5
|
8 |
+
*
|
9 |
+
* LICENSE: Permission is hereby granted, free of charge, to any person obtaining
|
10 |
+
* a copy of this software and associated documentation files (the "Software"), to
|
11 |
+
* deal in the Software without restriction, including without limitation the rights
|
12 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
13 |
+
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
14 |
+
* subject to the following conditions:
|
15 |
+
*
|
16 |
+
* The above copyright notice and this permission notice shall be included in all
|
17 |
+
* copies or substantial portions of the Software.
|
18 |
+
*
|
19 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
21 |
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
22 |
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
23 |
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
24 |
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25 |
+
*
|
26 |
+
* @category Databases
|
27 |
+
* @package MysqlDumpFactory
|
28 |
+
* @author Yani Iliev <yani@iliev.me>
|
29 |
+
* @author Bobby Angelov <bobby@servmask.com>
|
30 |
+
* @copyright 2014 Yani Iliev, Bobby Angelov
|
31 |
+
* @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
|
32 |
+
* @version GIT: 1.0.4
|
33 |
+
* @link https://github.com/yani-/mysqldump-factory/
|
34 |
+
*/
|
35 |
+
|
36 |
+
/**
|
37 |
+
* MysqlQueryAdapter class
|
38 |
+
*
|
39 |
+
* @category Databases
|
40 |
+
* @package MysqlDumpFactory
|
41 |
+
* @author Yani Iliev <yani@iliev.me>
|
42 |
+
* @author Bobby Angelov <bobby@servmask.com>
|
43 |
+
* @copyright 2014 Yani Iliev, Bobby Angelov
|
44 |
+
* @license https://raw.github.com/yani-/mysqldump-factory/master/LICENSE The MIT License (MIT)
|
45 |
+
* @version GIT: 1.0.4
|
46 |
+
* @link https://github.com/yani-/mysqldump-factory/
|
47 |
+
*/
|
48 |
+
class MysqlQueryAdapter
|
49 |
+
{
|
50 |
+
public function __construct($type)
|
51 |
+
{
|
52 |
+
$this->type = $type;
|
53 |
+
}
|
54 |
+
|
55 |
+
public function set_names($encoding = 'utf8')
|
56 |
+
{
|
57 |
+
return "SET NAMES '$encoding'";
|
58 |
+
}
|
59 |
+
|
60 |
+
public function show_create_table($tableName)
|
61 |
+
{
|
62 |
+
return "SHOW CREATE TABLE `$tableName`";
|
63 |
+
}
|
64 |
+
|
65 |
+
public function drop_table($tableName)
|
66 |
+
{
|
67 |
+
return "DROP TABLE IF EXISTS `$tableName`";
|
68 |
+
}
|
69 |
+
|
70 |
+
public function show_tables($databaseName)
|
71 |
+
{
|
72 |
+
return "SELECT TABLE_NAME AS table_name FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA = '$databaseName'";
|
73 |
+
}
|
74 |
+
|
75 |
+
public function show_views($databaseName)
|
76 |
+
{
|
77 |
+
return "SELECT VIEW_NAME AS view_name FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'VIEW' AND TABLE_SCHEMA='$databaseName'";
|
78 |
+
}
|
79 |
+
|
80 |
+
public function start_transaction()
|
81 |
+
{
|
82 |
+
return "SET GLOBAL TRANSACTION ISOLATION LEVEL REPEATABLE READ; START TRANSACTION";
|
83 |
+
}
|
84 |
+
|
85 |
+
public function commit_transaction()
|
86 |
+
{
|
87 |
+
return "SET GLOBAL TRANSACTION ISOLATION LEVEL REPEATABLE READ; START TRANSACTION";
|
88 |
+
}
|
89 |
+
|
90 |
+
public function lock_table($tableName)
|
91 |
+
{
|
92 |
+
return "LOCK TABLES `$tableName` READ LOCAL";
|
93 |
+
}
|
94 |
+
|
95 |
+
public function unlock_tables()
|
96 |
+
{
|
97 |
+
return "UNLOCK TABLES";
|
98 |
+
}
|
99 |
+
|
100 |
+
public function start_add_lock_table($tableName)
|
101 |
+
{
|
102 |
+
return "LOCK TABLES `$tableName` WRITE;\n";
|
103 |
+
}
|
104 |
+
|
105 |
+
public function end_add_lock_tables()
|
106 |
+
{
|
107 |
+
return "UNLOCK TABLES;\n";
|
108 |
+
}
|
109 |
+
}
|
lib/vendor/mysqldump-php/mysqldump.php
DELETED
@@ -1,603 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Mysqldump
|
4 |
-
{
|
5 |
-
const MAXLINESIZE = 1000000;
|
6 |
-
|
7 |
-
// This can be set both on constructor or manually
|
8 |
-
public $host;
|
9 |
-
public $user;
|
10 |
-
public $pass;
|
11 |
-
public $db;
|
12 |
-
public $fileName = 'dump.sql';
|
13 |
-
|
14 |
-
// Internal stuff
|
15 |
-
private $settings = array();
|
16 |
-
private $tables = array();
|
17 |
-
private $views = array();
|
18 |
-
private $dbHandler;
|
19 |
-
private $defaultSettings = array(
|
20 |
-
'include-tables' => array(),
|
21 |
-
'exclude-tables' => array(),
|
22 |
-
'compress' => CompressMethod::NONE,
|
23 |
-
'no-data' => false,
|
24 |
-
'add-drop-table' => false,
|
25 |
-
'single-transaction' => true,
|
26 |
-
'lock-tables' => false,
|
27 |
-
'add-locks' => true,
|
28 |
-
'extended-insert' => true
|
29 |
-
);
|
30 |
-
private $compressManager;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Constructor of Mysqldump. Note that in the case of an SQLite database connection, the filename must be in the $db parameter.
|
34 |
-
*
|
35 |
-
* @param string $db Database name
|
36 |
-
* @param string $user SQL account username
|
37 |
-
* @param string $pass SQL account password
|
38 |
-
* @param string $host SQL server to connect to
|
39 |
-
* @return null
|
40 |
-
*/
|
41 |
-
public function __construct($db = '', $user = '', $pass = '', $host = 'localhost', $type="mysql", $settings = null, $pdo_options = array(PDO::ATTR_PERSISTENT => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION))
|
42 |
-
{
|
43 |
-
$this->db = $db;
|
44 |
-
$this->user = $user;
|
45 |
-
$this->pass = $pass;
|
46 |
-
$this->host = $host;
|
47 |
-
$this->type = strtolower($type);
|
48 |
-
$this->pdo_options = $pdo_options;
|
49 |
-
$this->set($settings);
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* jquery style extend, merges arrays (without errors if the passed
|
54 |
-
* values are not arrays)
|
55 |
-
*
|
56 |
-
* @param array $args default settings
|
57 |
-
* @param array $extended user settings
|
58 |
-
*
|
59 |
-
* @return array $extended merged user settings with default settings
|
60 |
-
*/
|
61 |
-
public function extend()
|
62 |
-
{
|
63 |
-
$args = func_get_args();
|
64 |
-
$extended = array();
|
65 |
-
if (is_array($args) && count($args) > 0) {
|
66 |
-
foreach ($args as $array) {
|
67 |
-
if (is_array($array)) {
|
68 |
-
$extended = array_merge($extended, $array);
|
69 |
-
}
|
70 |
-
}
|
71 |
-
}
|
72 |
-
|
73 |
-
return $extended;
|
74 |
-
}
|
75 |
-
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Set new settings
|
79 |
-
*
|
80 |
-
* @return void
|
81 |
-
*/
|
82 |
-
public function set($settings)
|
83 |
-
{
|
84 |
-
$this->settings = $this->extend($this->defaultSettings, $settings);
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Connect with PDO
|
89 |
-
*
|
90 |
-
* @return bool
|
91 |
-
*/
|
92 |
-
private function connect()
|
93 |
-
{
|
94 |
-
// Connecting with PDO
|
95 |
-
try {
|
96 |
-
switch ($this->type){
|
97 |
-
case 'sqlite':
|
98 |
-
$this->dbHandler = new PDO("sqlite:" . $this->db, null, null, $this->pdo_options);
|
99 |
-
break;
|
100 |
-
|
101 |
-
case 'mysql': case 'pgsql': case 'dblib':
|
102 |
-
$this->dbHandler = new PDO($this->type . ":host=" . $this->host.";dbname=" . $this->db, $this->user, $this->pass, $this->pdo_options);
|
103 |
-
// Fix for always-unicode output
|
104 |
-
$this->dbHandler->exec("SET NAMES utf8");
|
105 |
-
break;
|
106 |
-
|
107 |
-
default:
|
108 |
-
throw new \Exception("Unsupported database type: " . $this->type, 3);
|
109 |
-
}
|
110 |
-
} catch (PDOException $e) {
|
111 |
-
throw new \Exception("Connection to " . $this->type . " failed with message: " .
|
112 |
-
$e->getMessage(), 3);
|
113 |
-
}
|
114 |
-
|
115 |
-
$this->dbHandler->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_NATURAL);
|
116 |
-
$this->adapter = new TypeAdapter($this->type);
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Main call
|
121 |
-
*
|
122 |
-
* @param string $filename Name of file to write sql dump to
|
123 |
-
* @param array $clauses Query parameters
|
124 |
-
* @return bool
|
125 |
-
*/
|
126 |
-
public function start($filename = '', $clauses = array())
|
127 |
-
{
|
128 |
-
// Output file can be redefined here
|
129 |
-
if ( !empty($filename) ) {
|
130 |
-
$this->fileName = $filename;
|
131 |
-
}
|
132 |
-
|
133 |
-
// We must set a name to continue
|
134 |
-
if ( empty($this->fileName) ) {
|
135 |
-
throw new \Exception("Output file name is not set", 1);
|
136 |
-
}
|
137 |
-
|
138 |
-
// Connect to database
|
139 |
-
$this->connect();
|
140 |
-
|
141 |
-
// Create a new compressManager to manage compressed output
|
142 |
-
$this->compressManager = CompressManagerFactory::create($this->settings['compress']);
|
143 |
-
|
144 |
-
if (! $this->compressManager->open($this->fileName)) {
|
145 |
-
throw new \Exception("Output file is not writable", 2);
|
146 |
-
}
|
147 |
-
|
148 |
-
// Formating dump file
|
149 |
-
$this->compressManager->write($this->getHeader());
|
150 |
-
|
151 |
-
// Listing all tables from database
|
152 |
-
$this->tables = array();
|
153 |
-
foreach ($this->dbHandler->query($this->adapter->show_tables($this->db)) as $row) {
|
154 |
-
if (empty($this->settings['include-tables']) || (! empty($this->settings['include-tables']) && in_array(current($row), $this->settings['include-tables'], true))) {
|
155 |
-
array_push($this->tables, current($row));
|
156 |
-
}
|
157 |
-
}
|
158 |
-
|
159 |
-
// Exporting tables one by one
|
160 |
-
foreach ($this->tables as $table) {
|
161 |
-
if (in_array($table, $this->settings['exclude-tables'], true)) {
|
162 |
-
continue;
|
163 |
-
}
|
164 |
-
|
165 |
-
$is_table = $this->getTableStructure($table);
|
166 |
-
if (true === $is_table) {
|
167 |
-
if (false === $this->settings['no-data']) {
|
168 |
-
$this->listValues($table, $clauses);
|
169 |
-
} else if (isset($clauses[$table])) {
|
170 |
-
$this->listValues($table, $clauses);
|
171 |
-
}
|
172 |
-
}
|
173 |
-
}
|
174 |
-
|
175 |
-
// Exporting views one by one
|
176 |
-
foreach ($this->views as $view) {
|
177 |
-
$this->compressManager->write($view);
|
178 |
-
}
|
179 |
-
|
180 |
-
//$this->compressManager->close();
|
181 |
-
}
|
182 |
-
|
183 |
-
/**
|
184 |
-
* Get current file name
|
185 |
-
*
|
186 |
-
* @return string
|
187 |
-
*/
|
188 |
-
public function getFileName()
|
189 |
-
{
|
190 |
-
return $this->fileName;
|
191 |
-
}
|
192 |
-
|
193 |
-
/**
|
194 |
-
* Truncate database
|
195 |
-
*
|
196 |
-
* @return void
|
197 |
-
*/
|
198 |
-
public function truncateDatabase()
|
199 |
-
{
|
200 |
-
// Connect to database
|
201 |
-
$this->connect();
|
202 |
-
|
203 |
-
foreach ($this->dbHandler->query($this->adapter->show_tables($this->db)) as $row) {
|
204 |
-
// Drop table
|
205 |
-
$this->dbHandler->query($this->adapter->drop_table($row['tbl_name']));
|
206 |
-
}
|
207 |
-
}
|
208 |
-
|
209 |
-
/**
|
210 |
-
* Import database from file
|
211 |
-
*
|
212 |
-
* @return void
|
213 |
-
*/
|
214 |
-
public function importFromFile($file)
|
215 |
-
{
|
216 |
-
if (!is_resource($file)) {
|
217 |
-
$file = fopen($file, 'r');
|
218 |
-
}
|
219 |
-
|
220 |
-
// Read database file
|
221 |
-
$sql = stream_get_contents($file);
|
222 |
-
|
223 |
-
return $this->dbHandler->query($sql);
|
224 |
-
}
|
225 |
-
|
226 |
-
/**
|
227 |
-
* Returns list of tables
|
228 |
-
*
|
229 |
-
* @return array
|
230 |
-
*/
|
231 |
-
public function listTables()
|
232 |
-
{
|
233 |
-
// Connect to database
|
234 |
-
$this->connect();
|
235 |
-
|
236 |
-
$result = array();
|
237 |
-
foreach ($this->dbHandler->query($this->adapter->show_tables($this->db)) as $row) {
|
238 |
-
$result[] = $row['tbl_name'];
|
239 |
-
}
|
240 |
-
|
241 |
-
return $result;
|
242 |
-
}
|
243 |
-
|
244 |
-
/**
|
245 |
-
* Returns header for dump file
|
246 |
-
*
|
247 |
-
* @return null
|
248 |
-
*/
|
249 |
-
private function getHeader()
|
250 |
-
{
|
251 |
-
// Some info about software, source and time
|
252 |
-
$header = "-- All In One WP Migration SQL Dump\n" .
|
253 |
-
"-- http://servmask.com/\n" .
|
254 |
-
"--\n" .
|
255 |
-
"-- Host: {$this->host}\n" .
|
256 |
-
"-- Generation Time: " . date('r') . "\n\n" .
|
257 |
-
"--\n" .
|
258 |
-
"-- Database: `{$this->db}`\n" .
|
259 |
-
"--\n\n";
|
260 |
-
|
261 |
-
return $header;
|
262 |
-
}
|
263 |
-
|
264 |
-
/**
|
265 |
-
* Table structure extractor
|
266 |
-
*
|
267 |
-
* @param string $tablename Name of table to export
|
268 |
-
* @return null
|
269 |
-
*/
|
270 |
-
private function getTableStructure($tablename)
|
271 |
-
{
|
272 |
-
$stmt = $this->adapter->show_create_table($tablename);
|
273 |
-
foreach ($this->dbHandler->query($stmt) as $r) {
|
274 |
-
if (isset($r['Create Table'])) {
|
275 |
-
$this->compressManager->write("-- " .
|
276 |
-
"--------------------------------------------------------" .
|
277 |
-
"\n\n" .
|
278 |
-
"--\n" .
|
279 |
-
"-- Table structure for table `$tablename`\n--\n\n");
|
280 |
-
|
281 |
-
if ($this->settings['add-drop-table']) {
|
282 |
-
$this->compressManager->write("DROP TABLE IF EXISTS `$tablename`;\n\n");
|
283 |
-
}
|
284 |
-
|
285 |
-
$this->compressManager->write($r['Create Table'] . ";\n\n");
|
286 |
-
|
287 |
-
return true;
|
288 |
-
}
|
289 |
-
if ( isset($r['Create View']) ) {
|
290 |
-
$view = "-- " .
|
291 |
-
"--------------------------------------------------------" .
|
292 |
-
"\n\n";
|
293 |
-
$view .= "--\n-- Table structure for view `$tablename`\n--\n\n";
|
294 |
-
$view .= $r['Create View'] . ";\n\n";
|
295 |
-
$this->views[] = $view;
|
296 |
-
|
297 |
-
return false;
|
298 |
-
}
|
299 |
-
}
|
300 |
-
}
|
301 |
-
|
302 |
-
/**
|
303 |
-
* Table rows extractor
|
304 |
-
*
|
305 |
-
* @param string $tablename Name of table to export
|
306 |
-
* @param array $clauses Query parameters
|
307 |
-
* @return null
|
308 |
-
*/
|
309 |
-
private function listValues($tablename, $clauses = array())
|
310 |
-
{
|
311 |
-
$this->compressManager->write(
|
312 |
-
"--\n" .
|
313 |
-
"-- Dumping data for table `$tablename`\n" .
|
314 |
-
"--\n\n"
|
315 |
-
);
|
316 |
-
|
317 |
-
if ($this->settings['single-transaction']) {
|
318 |
-
$this->dbHandler->exec($this->adapter->start_transaction());
|
319 |
-
}
|
320 |
-
|
321 |
-
if ($this->settings['lock-tables']) {
|
322 |
-
$lockstmt = $this->adapter->lock_table($tablename);
|
323 |
-
if(strlen($lockstmt)){
|
324 |
-
$this->dbHandler->exec($lockstmt);
|
325 |
-
}
|
326 |
-
}
|
327 |
-
|
328 |
-
if ( $this->settings['add-locks'] ) {
|
329 |
-
$this->compressManager->write($this->adapter->start_add_lock_table($tablename));
|
330 |
-
}
|
331 |
-
|
332 |
-
$onlyOnce = true; $lineSize = 0;
|
333 |
-
$stmt = "SELECT * FROM `$tablename` ";
|
334 |
-
|
335 |
-
// Add query parameters
|
336 |
-
if (isset($clauses[$tablename]) && ($clause_query = $clauses[$tablename])) {
|
337 |
-
$stmt .= $clause_query;
|
338 |
-
}
|
339 |
-
|
340 |
-
foreach ($this->dbHandler->query($stmt, PDO::FETCH_NUM) as $r) {
|
341 |
-
$vals = array();
|
342 |
-
foreach ($r as $val) {
|
343 |
-
$vals[] = is_null($val) ? "NULL" :
|
344 |
-
$this->dbHandler->quote($val);
|
345 |
-
}
|
346 |
-
if ($onlyOnce || !$this->settings['extended-insert'] ) {
|
347 |
-
$lineSize += $this->compressManager->write("INSERT INTO `$tablename` VALUES (" . implode(",", $vals) . ")");
|
348 |
-
$onlyOnce = false;
|
349 |
-
} else {
|
350 |
-
$lineSize += $this->compressManager->write(",(" . implode(",", $vals) . ")");
|
351 |
-
}
|
352 |
-
if ( ($lineSize > Mysqldump::MAXLINESIZE) ||
|
353 |
-
!$this->settings['extended-insert'] ) {
|
354 |
-
$onlyOnce = true;
|
355 |
-
$lineSize = $this->compressManager->write(";\n");
|
356 |
-
}
|
357 |
-
}
|
358 |
-
|
359 |
-
if (! $onlyOnce) {
|
360 |
-
$this->compressManager->write(";\n");
|
361 |
-
}
|
362 |
-
|
363 |
-
if ($this->settings['add-locks']) {
|
364 |
-
$this->compressManager->write($this->adapter->end_add_lock_table($tablename));
|
365 |
-
}
|
366 |
-
|
367 |
-
if ($this->settings['single-transaction']) {
|
368 |
-
$this->dbHandler->exec($this->adapter->commit_transaction());
|
369 |
-
}
|
370 |
-
|
371 |
-
if ($this->settings['lock-tables']) {
|
372 |
-
$lockstmt = $this->adapter->unlock_table($tablename);
|
373 |
-
if(strlen($lockstmt)){
|
374 |
-
$this->dbHandler->exec($lockstmt);
|
375 |
-
}
|
376 |
-
}
|
377 |
-
}
|
378 |
-
}
|
379 |
-
|
380 |
-
/**
|
381 |
-
* Enum with all available compression methods
|
382 |
-
*
|
383 |
-
*/
|
384 |
-
abstract class CompressMethod
|
385 |
-
{
|
386 |
-
const NONE = 0;
|
387 |
-
const GZIP = 1;
|
388 |
-
const BZIP2 = 2;
|
389 |
-
|
390 |
-
public static $enums = array(
|
391 |
-
"None",
|
392 |
-
"Gzip",
|
393 |
-
"Bzip2"
|
394 |
-
);
|
395 |
-
|
396 |
-
public static function isValid($c)
|
397 |
-
{
|
398 |
-
return in_array($c, self::$enums);
|
399 |
-
}
|
400 |
-
}
|
401 |
-
|
402 |
-
abstract class CompressManagerFactory
|
403 |
-
{
|
404 |
-
private $fileHandle = null;
|
405 |
-
|
406 |
-
public static function create($c)
|
407 |
-
{
|
408 |
-
$c = ucfirst(strtolower($c));
|
409 |
-
if (! CompressMethod::isValid($c)) {
|
410 |
-
throw new \Exception("Compression method is invalid", 1);
|
411 |
-
}
|
412 |
-
|
413 |
-
$method = "Compress" . $c;
|
414 |
-
|
415 |
-
return new $method();
|
416 |
-
}
|
417 |
-
}
|
418 |
-
|
419 |
-
class CompressBzip2 extends CompressManagerFactory
|
420 |
-
{
|
421 |
-
public function __construct()
|
422 |
-
{
|
423 |
-
if (! function_exists("bzopen")) {
|
424 |
-
throw new \Exception("Compression is enabled, but bzip2 lib is not installed or configured properly", 1);
|
425 |
-
}
|
426 |
-
}
|
427 |
-
|
428 |
-
public function open($filename)
|
429 |
-
{
|
430 |
-
$this->fileHandler = bzopen($filename, "w");
|
431 |
-
if (false === $this->fileHandler) {
|
432 |
-
return false;
|
433 |
-
}
|
434 |
-
|
435 |
-
return true;
|
436 |
-
}
|
437 |
-
|
438 |
-
public function write($str)
|
439 |
-
{
|
440 |
-
$bytesWritten = 0;
|
441 |
-
if (false === ($bytesWritten = bzwrite($this->fileHandler, $str))) {
|
442 |
-
throw new \Exception("Writting to file failed! Probably, there is no more free space left?", 4);
|
443 |
-
}
|
444 |
-
|
445 |
-
return $bytesWritten;
|
446 |
-
}
|
447 |
-
|
448 |
-
public function close()
|
449 |
-
{
|
450 |
-
return bzclose($this->fileHandler);
|
451 |
-
}
|
452 |
-
}
|
453 |
-
|
454 |
-
class CompressGzip extends CompressManagerFactory
|
455 |
-
{
|
456 |
-
public function __construct()
|
457 |
-
{
|
458 |
-
if (! function_exists("gzopen") ) {
|
459 |
-
throw new \Exception("Compression is enabled, but gzip lib is not installed or configured properly", 1);
|
460 |
-
}
|
461 |
-
}
|
462 |
-
|
463 |
-
public function open($filename)
|
464 |
-
{
|
465 |
-
$this->fileHandler = gzopen($filename, "wb");
|
466 |
-
if (false === $this->fileHandler) {
|
467 |
-
return false;
|
468 |
-
}
|
469 |
-
|
470 |
-
return true;
|
471 |
-
}
|
472 |
-
|
473 |
-
public function write($str)
|
474 |
-
{
|
475 |
-
$bytesWritten = 0;
|
476 |
-
if (false === ($bytesWritten = gzwrite($this->fileHandler, $str))) {
|
477 |
-
throw new \Exception("Writting to file failed! Probably, there is no more free space left?", 4);
|
478 |
-
}
|
479 |
-
|
480 |
-
return $bytesWritten;
|
481 |
-
}
|
482 |
-
|
483 |
-
public function close()
|
484 |
-
{
|
485 |
-
return gzclose($this->fileHandler);
|
486 |
-
}
|
487 |
-
}
|
488 |
-
|
489 |
-
class CompressNone extends CompressManagerFactory
|
490 |
-
{
|
491 |
-
public function open($filename)
|
492 |
-
{
|
493 |
-
$this->fileHandler = fopen($filename, "wb");
|
494 |
-
if (false === $this->fileHandler) {
|
495 |
-
return false;
|
496 |
-
}
|
497 |
-
|
498 |
-
return true;
|
499 |
-
}
|
500 |
-
|
501 |
-
public function write($str)
|
502 |
-
{
|
503 |
-
$bytesWritten = 0;
|
504 |
-
if (false === ($bytesWritten = fwrite($this->fileHandler, $str))) {
|
505 |
-
throw new \Exception("Writting to file failed! Probably, there is no more free space left?", 4);
|
506 |
-
}
|
507 |
-
|
508 |
-
return $bytesWritten;
|
509 |
-
}
|
510 |
-
|
511 |
-
public function close()
|
512 |
-
{
|
513 |
-
return fclose($this->fileHandler);
|
514 |
-
}
|
515 |
-
}
|
516 |
-
|
517 |
-
class TypeAdapter
|
518 |
-
{
|
519 |
-
public function __construct($type){
|
520 |
-
$this->type = $type;
|
521 |
-
}
|
522 |
-
|
523 |
-
public function show_create_table($tablename){
|
524 |
-
switch($this->type){
|
525 |
-
case 'sqlite':
|
526 |
-
return "select tbl_name as 'Table', sql as 'Create Table' from sqlite_master where type='table' and tbl_name='$tablename'";
|
527 |
-
default:
|
528 |
-
return "SHOW CREATE TABLE `$tablename`";
|
529 |
-
}
|
530 |
-
}
|
531 |
-
|
532 |
-
public function drop_table($tablename){
|
533 |
-
switch($this->type){
|
534 |
-
case 'sqlite':
|
535 |
-
return "drop table if exists '$tablename'";
|
536 |
-
default:
|
537 |
-
return "DROP TABLE IF EXISTS `$tablename`";
|
538 |
-
}
|
539 |
-
}
|
540 |
-
|
541 |
-
public function show_tables($dbName){
|
542 |
-
switch($this->type){
|
543 |
-
case 'sqlite':
|
544 |
-
return "SELECT tbl_name FROM sqlite_master where type='table'";
|
545 |
-
default:
|
546 |
-
return "SELECT TABLE_NAME AS tbl_name FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' AND TABLE_SCHEMA='$dbName'";
|
547 |
-
}
|
548 |
-
}
|
549 |
-
|
550 |
-
public function start_transaction(){
|
551 |
-
switch($this->type){
|
552 |
-
case 'sqlite':
|
553 |
-
return "BEGIN EXCLUSIVE";
|
554 |
-
default:
|
555 |
-
return "SET GLOBAL TRANSACTION ISOLATION LEVEL REPEATABLE READ; START TRANSACTION";
|
556 |
-
}
|
557 |
-
}
|
558 |
-
|
559 |
-
public function commit_transaction(){
|
560 |
-
switch($this->type){
|
561 |
-
case 'sqlite':
|
562 |
-
return "COMMIT";
|
563 |
-
default:
|
564 |
-
return "SET GLOBAL TRANSACTION ISOLATION LEVEL REPEATABLE READ; START TRANSACTION";
|
565 |
-
}
|
566 |
-
}
|
567 |
-
|
568 |
-
public function lock_table($tablename){
|
569 |
-
switch($this->type){
|
570 |
-
case 'sqlite':
|
571 |
-
return "";
|
572 |
-
default:
|
573 |
-
return "LOCK TABLES `$tablename` READ LOCAL";
|
574 |
-
}
|
575 |
-
}
|
576 |
-
|
577 |
-
public function unlock_table($tablename){
|
578 |
-
switch($this->type){
|
579 |
-
case 'sqlite':
|
580 |
-
return "";
|
581 |
-
default:
|
582 |
-
return "UNLOCK TABLES";
|
583 |
-
}
|
584 |
-
}
|
585 |
-
|
586 |
-
public function start_add_lock_table($tablename){
|
587 |
-
switch($this->type){
|
588 |
-
case 'sqlite':
|
589 |
-
return "\n";
|
590 |
-
default:
|
591 |
-
return "LOCK TABLES `$tablename` WRITE;\n";
|
592 |
-
}
|
593 |
-
}
|
594 |
-
|
595 |
-
public function end_add_lock_table($tablename){
|
596 |
-
switch($this->type){
|
597 |
-
case 'sqlite':
|
598 |
-
return "\n";
|
599 |
-
default:
|
600 |
-
return "UNLOCK TABLES;\n";
|
601 |
-
}
|
602 |
-
}
|
603 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/vendor/zip-factory/zip-factory/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
The MIT License (MIT)
|
2 |
+
|
3 |
+
Copyright (c) 2013 Yani Iliev
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6 |
+
this software and associated documentation files (the "Software"), to deal in
|
7 |
+
the Software without restriction, including without limitation the rights to
|
8 |
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9 |
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10 |
+
subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17 |
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18 |
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19 |
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20 |
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
lib/vendor/zip-factory/zip-factory/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Zip Factory
|
2 |
+
|
3 |
+
[![Build Status](https://travis-ci.org/yani-/zip-factory.png)](https://travis-ci.org/yani-/zip-factory)
|
4 |
+
[![Latest Stable Version](https://poser.pugx.org/zip-factory/zip-factory/v/stable.png)](https://packagist.org/packages/zip-factory/zip-factory)
|
5 |
+
[![Total Downloads](https://poser.pugx.org/zip-factory/zip-factory/downloads.png)](https://packagist.org/packages/zip-factory/zip-factory)
|
6 |
+
|
7 |
+
Factory class that creates either ZipArchive or PclZip
|
8 |
+
|
9 |
+
### Requirements
|
10 |
+
PHP v5.2 and up. Tested on PHP v5.2.17, v5.3, v5.4, v5.5
|
11 |
+
|
12 |
+
### Usage
|
13 |
+
```php
|
14 |
+
```
|
15 |
+
|
16 |
+
### Tests
|
17 |
+
Coverage reports are stored inside the coverage folder.
|
18 |
+
```bash
|
19 |
+
phpunit
|
20 |
+
```
|
21 |
+
|
22 |
+
### Contributing
|
23 |
+
For code guidelines refer to `.editorconfig`. This project is following PEAR code standard - http://pear.php.net/manual/en/standards.php
|
24 |
+
The project is following Vincent Driessen's branching model aka git flow - http://nvie.com/git-model/
|
25 |
+
Make sure to submit your pull requests against the **develop** branch
|
26 |
+
|
27 |
+
### License
|
28 |
+
MIT
|
29 |
+
|
30 |
+
### Authors
|
31 |
+
* Yani Iliev
|
lib/vendor/zip-factory/zip-factory/bump-version.sh
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
if [ -z "$1" ]; then
|
4 |
+
echo -e "\033[0;31mUsage:\033[0m $0 (major|minor|patch)\033[0m"
|
5 |
+
echo -e "\033[4;32mCurrent version\033[0m:\033[0m \033[33m`git describe master`\033[0m"
|
6 |
+
exit -1
|
7 |
+
fi
|
8 |
+
|
9 |
+
# increment version depending on passed parameter
|
10 |
+
case "$1" in
|
11 |
+
major)
|
12 |
+
currentVersion=`git describe master`
|
13 |
+
bumpedVersion=`echo $currentVersion | ( IFS=".$IFS" ; read a b c && echo $((a + 1)).0.0 )`
|
14 |
+
;;
|
15 |
+
minor)
|
16 |
+
currentVersion=`git describe master`
|
17 |
+
bumpedVersion=`echo $currentVersion | ( IFS=".$IFS" ; read a b c && echo $a.$((b + 1)).0 )`
|
18 |
+
;;
|
19 |
+
patch)
|
20 |
+
currentVersion=`git describe master`
|
21 |
+
bumpedVersion=`echo $currentVersion | ( IFS=".$IFS" ; read a b c && echo $a.$b.$((c + 1)) )`
|
22 |
+
;;
|
23 |
+
*)
|
24 |
+
echo -e "\033[0;31mUsage:\033[0m $0 (major|minor|patch)\033[0m"
|
25 |
+
echo -e "\033[4;32mCurrent version\033[0m:\033[0m \033[33m`git describe master`\033[0m"
|
26 |
+
exit -1
|
27 |
+
esac
|
28 |
+
|
29 |
+
# let's start a new release
|
30 |
+
git flow release start $bumpedVersion
|
31 |
+
|
32 |
+
# bump version in all files
|
33 |
+
for file in `find . -path ./coverage -prune -o -path ./.git -prune -o -type f`
|
34 |
+
do
|
35 |
+
filename=$(basename "$file")
|
36 |
+
ext="${filename##*.}"
|
37 |
+
if [ $ext != "png" -a $ext != "jpg" -a $ext != "jpeg" -a $ext != "gif" ]; then
|
38 |
+
if [ $ext != "DS_Store" -a $ext != "ttf" -a $ext != "node_modules" -a $ext != "git" ]; then
|
39 |
+
sed -i '' "s/GIT: $currentVersion/GIT: $bumpedVersion/g" $file
|
40 |
+
fi
|
41 |
+
fi
|
42 |
+
done
|
43 |
+
|
44 |
+
# bump version in package.json
|
45 |
+
sed -i '' "s/\"version\": \"$currentVersion\"/\"version\": \"$bumpedVersion\"/g" package.json
|
46 |
+
|
47 |
+
# add changed files to git
|
48 |
+
git add . && git commit -m "Bumped version from $currentVersion to $bumpedVersion"
|
49 |
+
|
50 |
+
# finish the release
|
51 |
+
git flow release finish -F -m "$bumpedVersion" $bumpedVersion
|
52 |
+
|
53 |
+
# publish develop branch
|
54 |
+
git checkout develop && git push origin develop
|
55 |
+
|
56 |
+
# publish master
|
57 |
+
git checkout master && git push origin master
|
58 |
+
|
59 |
+
# publish tags
|
60 |
+
git push origin --tags
|
61 |
+
|
62 |
+
# Announce the result
|
63 |
+
echo -e "\033[4;32mSuccessfully released\033[0m:\033[0m \033[33m$bumpedVersion\033[0m"
|
lib/vendor/zip-factory/zip-factory/lib/ArchiverInterface.php
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Archiver interface file
|
6 |
+
*
|
7 |
+
* PHP version 5
|
8 |
+
*
|
9 |
+
* LICENSE: Permission is hereby granted, free of charge, to any person obtaining
|
10 |
+
* a copy of this software and associated documentation files (the "Software"), to
|
11 |
+
* deal in the Software without restriction, including without limitation the rights
|
12 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
13 |
+
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
14 |
+
* subject to the following conditions:
|
15 |
+
*
|
16 |
+
* The above copyright notice and this permission notice shall be included in all
|
17 |
+
* copies or substantial portions of the Software.
|
18 |
+
*
|
19 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
21 |
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
22 |
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
23 |
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
24 |
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25 |
+
*
|
26 |
+
* @category Utilities
|
27 |
+
* @package ZipFactory
|
28 |
+
* @author Yani Iliev <yani@iliev.me>
|
29 |
+
* @copyright 2014 Yani Iliev
|
30 |
+
* @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
|
31 |
+
* @version GIT: 1.0.0
|
32 |
+
* @link https://github.com/yani-/zip-factory/
|
33 |
+
*/
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Archiver Interface
|
37 |
+
*
|
38 |
+
* @category Tests
|
39 |
+
* @package ZipFactory
|
40 |
+
* @author Yani Iliev <yani@iliev.me>
|
41 |
+
* @copyright 2014 Yani Iliev
|
42 |
+
* @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
|
43 |
+
* @link https://github.com/yani-/zip-factory/
|
44 |
+
*/
|
45 |
+
interface ArchiverInterface
|
46 |
+
{
|
47 |
+
/**
|
48 |
+
* [__construct description]
|
49 |
+
*
|
50 |
+
* @param [type] $file [description]
|
51 |
+
*
|
52 |
+
* @return [type] [description]
|
53 |
+
*/
|
54 |
+
public function __construct($file);
|
55 |
+
|
56 |
+
/**
|
57 |
+
* [addFile description]
|
58 |
+
*
|
59 |
+
* @param [type] $filepath [description]
|
60 |
+
* @param [type] $entryname [description]
|
61 |
+
* @param [type] $start [description]
|
62 |
+
* @param [type] $length [description]
|
63 |
+
*
|
64 |
+
* @return null [description]
|
65 |
+
*/
|
66 |
+
public function addFile(
|
67 |
+
$filepath,
|
68 |
+
$entryname = null,
|
69 |
+
$start = null,
|
70 |
+
$length = null
|
71 |
+
);
|
72 |
+
|
73 |
+
/**
|
74 |
+
* [addDir description]
|
75 |
+
*
|
76 |
+
* @param [type] $path [description]
|
77 |
+
* @param [type] $parent_dir [description]
|
78 |
+
* @param array $include [description]
|
79 |
+
*
|
80 |
+
* @return null [description]
|
81 |
+
*/
|
82 |
+
public function addDir($path, $parent_dir = null, $include = array());
|
83 |
+
|
84 |
+
/**
|
85 |
+
* [addFromString description]
|
86 |
+
*
|
87 |
+
* @param [type] $name [description]
|
88 |
+
* @param [type] $content [description]
|
89 |
+
*
|
90 |
+
* @return null [description]
|
91 |
+
*/
|
92 |
+
public function addFromString($name, $content);
|
93 |
+
|
94 |
+
/**
|
95 |
+
* [getArchive description]
|
96 |
+
*
|
97 |
+
* @return [type] [description]
|
98 |
+
*/
|
99 |
+
public function getArchive();
|
100 |
+
|
101 |
+
/**
|
102 |
+
* [extractTo description]
|
103 |
+
*
|
104 |
+
* @param string $pathto Path to extract to
|
105 |
+
* @param mixed $files Optional files parameter
|
106 |
+
*
|
107 |
+
* @return [type] [description]
|
108 |
+
*/
|
109 |
+
public function extractTo($pathto, $files = null);
|
110 |
+
|
111 |
+
/**
|
112 |
+
* [close description]
|
113 |
+
*
|
114 |
+
* @return [type] [description]
|
115 |
+
*/
|
116 |
+
public function close();
|
117 |
+
}
|
lib/vendor/zip-factory/zip-factory/lib/ArchiverPclZip.php
ADDED
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* ArchiverPclZip class file
|
6 |
+
*
|
7 |
+
* PHP version 5
|
8 |
+
*
|
9 |
+
* LICENSE: Permission is hereby granted, free of charge, to any person obtaining
|
10 |
+
* a copy of this software and associated documentation files (the "Software"), to
|
11 |
+
* deal in the Software without restriction, including without limitation the rights
|
12 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
13 |
+
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
14 |
+
* subject to the following conditions:
|
15 |
+
*
|
16 |
+
* The above copyright notice and this permission notice shall be included in all
|
17 |
+
* copies or substantial portions of the Software.
|
18 |
+
*
|
19 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
21 |
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
22 |
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
23 |
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
24 |
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25 |
+
*
|
26 |
+
* @category Utilities
|
27 |
+
* @package ZipFactory
|
28 |
+
* @author Yani Iliev <yani@iliev.me>
|
29 |
+
* @copyright 2014 Yani Iliev
|
30 |
+
* @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
|
31 |
+
* @version GIT: 1.0.0
|
32 |
+
* @link https://github.com/yani-/zip-factory/
|
33 |
+
*/
|
34 |
+
|
35 |
+
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ArchiverInterface.php';
|
36 |
+
|
37 |
+
if (function_exists('gzopen')) {
|
38 |
+
|
39 |
+
if (!class_exists('PclZip')) {
|
40 |
+
include_once dirname(__FILE__) .
|
41 |
+
DIRECTORY_SEPARATOR .
|
42 |
+
'vendor' .
|
43 |
+
DIRECTORY_SEPARATOR .
|
44 |
+
'pclzip-2-8-2' .
|
45 |
+
DIRECTORY_SEPARATOR .
|
46 |
+
'pclzip.lib.php';
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* ArchiverPclZip class
|
51 |
+
*
|
52 |
+
* @category Tests
|
53 |
+
* @package ZipFactory
|
54 |
+
* @author Yani Iliev <yani@iliev.me>
|
55 |
+
* @copyright 2014 Yani Iliev
|
56 |
+
* @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
|
57 |
+
* @link https://github.com/yani-/zip-factory/
|
58 |
+
*/
|
59 |
+
class ArchiverPclZip implements ArchiverInterface
|
60 |
+
{
|
61 |
+
/**
|
62 |
+
* [$archive description]
|
63 |
+
* @var [type]
|
64 |
+
*/
|
65 |
+
protected $archive = null;
|
66 |
+
|
67 |
+
/**
|
68 |
+
* [$archive description]
|
69 |
+
* @var [type]
|
70 |
+
*/
|
71 |
+
protected $pclzip = null;
|
72 |
+
|
73 |
+
/**
|
74 |
+
* [__construct description]
|
75 |
+
*
|
76 |
+
* @param [type] $file [description]
|
77 |
+
*
|
78 |
+
* @return [type] [description]
|
79 |
+
*/
|
80 |
+
public function __construct($file)
|
81 |
+
{
|
82 |
+
if (is_resource($file)) {
|
83 |
+
$meta = stream_get_meta_data($file);
|
84 |
+
$this->archive = $meta['uri'];
|
85 |
+
$this->pclzip = new PclZip($this->archive);
|
86 |
+
} else {
|
87 |
+
$this->archive = $file;
|
88 |
+
$this->pclzip = new PclZip($this->archive);
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* [addFile description]
|
94 |
+
*
|
95 |
+
* @param [type] $filepath [description]
|
96 |
+
* @param [type] $entryname [description]
|
97 |
+
* @param [type] $start [description]
|
98 |
+
* @param [type] $length [description]
|
99 |
+
*
|
100 |
+
* @return null
|
101 |
+
*/
|
102 |
+
public function addFile(
|
103 |
+
$filepath,
|
104 |
+
$entryname = null,
|
105 |
+
$start = null,
|
106 |
+
$length = null
|
107 |
+
) {
|
108 |
+
$this->pclzip->add(
|
109 |
+
array(
|
110 |
+
array(
|
111 |
+
PCLZIP_ATT_FILE_NAME => $entryname,
|
112 |
+
PCLZIP_ATT_FILE_CONTENT => file_get_contents($filepath)
|
113 |
+
)
|
114 |
+
)
|
115 |
+
);
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* [addDir description]
|
120 |
+
*
|
121 |
+
* @param [type] $path [description]
|
122 |
+
* @param [type] $name [description]
|
123 |
+
* @param array $include [description]
|
124 |
+
*
|
125 |
+
* @return null
|
126 |
+
*/
|
127 |
+
public function addDir($path, $name = null, $include = array())
|
128 |
+
{
|
129 |
+
$this->pclzip->add(
|
130 |
+
$path,
|
131 |
+
PCLZIP_OPT_REMOVE_PATH,
|
132 |
+
$path,
|
133 |
+
PCLZIP_OPT_ADD_PATH,
|
134 |
+
$name
|
135 |
+
);
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* [addFromString description]
|
140 |
+
*
|
141 |
+
* @param [type] $name [description]
|
142 |
+
* @param [type] $content [description]
|
143 |
+
*
|
144 |
+
* @return null [description]
|
145 |
+
*/
|
146 |
+
public function addFromString($name, $content)
|
147 |
+
{
|
148 |
+
$this->pclzip->add(
|
149 |
+
array(
|
150 |
+
array(
|
151 |
+
PCLZIP_ATT_FILE_NAME => $name,
|
152 |
+
PCLZIP_ATT_FILE_CONTENT => $content
|
153 |
+
)
|
154 |
+
)
|
155 |
+
);
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* [getArchive description]
|
160 |
+
*
|
161 |
+
* @return [type] [description]
|
162 |
+
*/
|
163 |
+
public function getArchive()
|
164 |
+
{
|
165 |
+
return $this->archive;
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* [extractTo description]
|
170 |
+
*
|
171 |
+
* @param string $pathto Path to extract to
|
172 |
+
* @param mixed $files Optional files parameter
|
173 |
+
*
|
174 |
+
* @return [type] [description]
|
175 |
+
*/
|
176 |
+
public function extractTo($pathto, $files = null)
|
177 |
+
{
|
178 |
+
$this->pclzip->extract(PCLZIP_OPT_PATH, $pathto);
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* [close description]
|
183 |
+
*
|
184 |
+
* @return [type] [description]
|
185 |
+
*/
|
186 |
+
public function close()
|
187 |
+
{
|
188 |
+
// empty function - not needed for pclzip
|
189 |
+
}
|
190 |
+
}
|
191 |
+
}
|
lib/vendor/zip-factory/zip-factory/lib/ArchiverZipArchive.php
ADDED
@@ -0,0 +1,214 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* ArchiverZipArchive class file
|
6 |
+
*
|
7 |
+
* PHP version 5
|
8 |
+
*
|
9 |
+
* LICENSE: Permission is hereby granted, free of charge, to any person obtaining
|
10 |
+
* a copy of this software and associated documentation files (the "Software"), to
|
11 |
+
* deal in the Software without restriction, including without limitation the rights
|
12 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
13 |
+
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
14 |
+
* subject to the following conditions:
|
15 |
+
*
|
16 |
+
* The above copyright notice and this permission notice shall be included in all
|
17 |
+
* copies or substantial portions of the Software.
|
18 |
+
*
|
19 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
21 |
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
22 |
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
23 |
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
24 |
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25 |
+
*
|
26 |
+
* @category Utilities
|
27 |
+
* @package ZipFactory
|
28 |
+
* @author Yani Iliev <yani@iliev.me>
|
29 |
+
* @copyright 2014 Yani Iliev
|
30 |
+
* @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
|
31 |
+
* @version GIT: 1.0.0
|
32 |
+
* @link https://github.com/yani-/zip-factory/
|
33 |
+
*/
|
34 |
+
|
35 |
+
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ArchiverInterface.php';
|
36 |
+
|
37 |
+
if (class_exists('ZipArchive')) {
|
38 |
+
/**
|
39 |
+
* ArchiverZipArchive class
|
40 |
+
*
|
41 |
+
* @category Tests
|
42 |
+
* @package ZipFactory
|
43 |
+
* @author Yani Iliev <yani@iliev.me>
|
44 |
+
* @copyright 2014 Yani Iliev
|
45 |
+
* @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
|
46 |
+
* @link https://github.com/yani-/zip-factory/
|
47 |
+
*/
|
48 |
+
class ArchiverZipArchive extends ZipArchive implements ArchiverInterface
|
49 |
+
{
|
50 |
+
/**
|
51 |
+
* [$archive description]
|
52 |
+
* @var [type]
|
53 |
+
*/
|
54 |
+
protected $archive = null;
|
55 |
+
|
56 |
+
/**
|
57 |
+
* [$root_dir description]
|
58 |
+
* @var [type]
|
59 |
+
*/
|
60 |
+
protected $root_dir = null;
|
61 |
+
|
62 |
+
/**
|
63 |
+
* [__construct description]
|
64 |
+
*
|
65 |
+
* @param [type] $file [description]
|
66 |
+
*
|
67 |
+
* @return [type] [description]
|
68 |
+
*/
|
69 |
+
public function __construct($file)
|
70 |
+
{
|
71 |
+
if (is_resource($file)) {
|
72 |
+
$meta = stream_get_meta_data($file);
|
73 |
+
$this->archive = $meta['uri'];
|
74 |
+
} else {
|
75 |
+
$this->archive = $file;
|
76 |
+
}
|
77 |
+
|
78 |
+
// Open Archive File
|
79 |
+
if (!($this->open($this->archive) === true)) {
|
80 |
+
throw new RuntimeException('Archive file cound not be created.');
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* [addFile description]
|
86 |
+
*
|
87 |
+
* @param [type] $filepath [description]
|
88 |
+
* @param [type] $entryname [description]
|
89 |
+
* @param [type] $start [description]
|
90 |
+
* @param [type] $length [description]
|
91 |
+
*
|
92 |
+
* @return null [description]
|
93 |
+
*/
|
94 |
+
public function addFile(
|
95 |
+
$filepath,
|
96 |
+
$entryname = null,
|
97 |
+
$start = null,
|
98 |
+
$length = null
|
99 |
+
) {
|
100 |
+
parent::addFile($filepath, $entryname, $start, $length);
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* [addDir description]
|
105 |
+
*
|
106 |
+
* @param [type] $path [description]
|
107 |
+
* @param [type] $parent_dir [description]
|
108 |
+
* @param array $include [description]
|
109 |
+
*
|
110 |
+
* @return null [description]
|
111 |
+
*/
|
112 |
+
public function addDir($path, $parent_dir = null, $include = array())
|
113 |
+
{
|
114 |
+
// Use Recursive functions
|
115 |
+
$iterator = new RecursiveIteratorIterator(
|
116 |
+
new RecursiveDirectoryIterator($path),
|
117 |
+
RecursiveIteratorIterator::SELF_FIRST
|
118 |
+
);
|
119 |
+
|
120 |
+
// Prepare File Filter Pattern
|
121 |
+
$file_pattern = null;
|
122 |
+
if (is_array($include)) {
|
123 |
+
$filters = array();
|
124 |
+
foreach ($include as $file) {
|
125 |
+
$filters[] = str_replace(
|
126 |
+
'\.\*', '.*',
|
127 |
+
preg_quote($file, '/')
|
128 |
+
);
|
129 |
+
}
|
130 |
+
|
131 |
+
$file_pattern = implode('|', $filters);
|
132 |
+
}
|
133 |
+
|
134 |
+
foreach ($iterator as $item) {
|
135 |
+
// Skip dots
|
136 |
+
if ($iterator->isDot()) {
|
137 |
+
continue;
|
138 |
+
}
|
139 |
+
|
140 |
+
// Validate file pattern
|
141 |
+
if ($file_pattern) {
|
142 |
+
if (!preg_match(
|
143 |
+
'/^(' . $file_pattern . ')$/',
|
144 |
+
$iterator->getSubPathName()
|
145 |
+
)) {
|
146 |
+
continue;
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
// Add to archive
|
151 |
+
if ($item->isDir()) {
|
152 |
+
$this->addEmptyDir(
|
153 |
+
$parent_dir .
|
154 |
+
DIRECTORY_SEPARATOR .
|
155 |
+
$iterator->getSubPathName()
|
156 |
+
);
|
157 |
+
} else {
|
158 |
+
$this->addFile(
|
159 |
+
$item->getPathname(),
|
160 |
+
$parent_dir .
|
161 |
+
DIRECTORY_SEPARATOR .
|
162 |
+
$iterator->getSubPathName()
|
163 |
+
);
|
164 |
+
}
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* [addFromString description]
|
170 |
+
*
|
171 |
+
* @param [type] $name [description]
|
172 |
+
* @param [type] $content [description]
|
173 |
+
*
|
174 |
+
* @return null [description]
|
175 |
+
*/
|
176 |
+
public function addFromString($name, $content)
|
177 |
+
{
|
178 |
+
parent::addFromString($name, $content);
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* [getArchive description]
|
183 |
+
*
|
184 |
+
* @return [type] [description]
|
185 |
+
*/
|
186 |
+
public function getArchive()
|
187 |
+
{
|
188 |
+
return $this->archive;
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* [extractTo description]
|
193 |
+
*
|
194 |
+
* @param string $pathto Path to extract to
|
195 |
+
* @param mixed $files Optional files parameter
|
196 |
+
*
|
197 |
+
* @return [type] [description]
|
198 |
+
*/
|
199 |
+
public function extractTo($pathto, $files = null)
|
200 |
+
{
|
201 |
+
parent::extractTo($pathto);
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* [close description]
|
206 |
+
*
|
207 |
+
* @return [type] [description]
|
208 |
+
*/
|
209 |
+
public function close()
|
210 |
+
{
|
211 |
+
parent::close();
|
212 |
+
}
|
213 |
+
}
|
214 |
+
}
|
lib/vendor/zip-factory/zip-factory/lib/ZipFactory.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Zip Factory main file
|
6 |
+
*
|
7 |
+
* PHP version 5
|
8 |
+
*
|
9 |
+
* LICENSE: Permission is hereby granted, free of charge, to any person obtaining
|
10 |
+
* a copy of this software and associated documentation files (the "Software"), to
|
11 |
+
* deal in the Software without restriction, including without limitation the rights
|
12 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
13 |
+
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
14 |
+
* subject to the following conditions:
|
15 |
+
*
|
16 |
+
* The above copyright notice and this permission notice shall be included in all
|
17 |
+
* copies or substantial portions of the Software.
|
18 |
+
*
|
19 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
21 |
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
22 |
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
23 |
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
24 |
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25 |
+
*
|
26 |
+
* @category Utilities
|
27 |
+
* @package ZipFactory
|
28 |
+
* @author Yani Iliev <yani@iliev.me>
|
29 |
+
* @copyright 2014 Yani Iliev
|
30 |
+
* @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
|
31 |
+
* @version GIT: 1.0.0
|
32 |
+
* @link https://github.com/yani-/zip-factory/
|
33 |
+
*/
|
34 |
+
|
35 |
+
/**
|
36 |
+
* ZipFactory class
|
37 |
+
*
|
38 |
+
* @category Tests
|
39 |
+
* @package ZipFactory
|
40 |
+
* @author Yani Iliev <yani@iliev.me>
|
41 |
+
* @copyright 2014 Yani Iliev
|
42 |
+
* @license https://raw.github.com/yani-/zip-factory/master/LICENSE The MIT License (MIT)
|
43 |
+
* @link https://github.com/yani-/zip-factory/
|
44 |
+
*/
|
45 |
+
class ZipFactory
|
46 |
+
{
|
47 |
+
/**
|
48 |
+
* [makeZip description]
|
49 |
+
*
|
50 |
+
* @param [type] $file [description]
|
51 |
+
* @param [type] $pclZip [description]
|
52 |
+
*
|
53 |
+
* @return [type] [description]
|
54 |
+
*/
|
55 |
+
public static function makeZipArchiver($file, $pclZip = false)
|
56 |
+
{
|
57 |
+
if ($pclZip) {
|
58 |
+
include_once dirname(__FILE__) .
|
59 |
+
DIRECTORY_SEPARATOR .
|
60 |
+
'ArchiverPclZip.php';
|
61 |
+
return new ArchiverPclZip($file);
|
62 |
+
} else {
|
63 |
+
include_once dirname(__FILE__) .
|
64 |
+
DIRECTORY_SEPARATOR .
|
65 |
+
'ArchiverZipArchive.php';
|
66 |
+
return new ArchiverZipArchive($file);
|
67 |
+
}
|
68 |
+
}
|
69 |
+
}
|
lib/vendor/zip-factory/zip-factory/lib/vendor/pclzip-2-8-2/gnu-lgpl.txt
ADDED
@@ -0,0 +1,504 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2 |
+
Version 2.1, February 1999
|
3 |
+
|
4 |
+
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
5 |
+
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
6 |
+
Everyone is permitted to copy and distribute verbatim copies
|
7 |
+
of this license document, but changing it is not allowed.
|
8 |
+
|
9 |
+
[This is the first released version of the Lesser GPL. It also counts
|
10 |
+
as the successor of the GNU Library Public License, version 2, hence
|
11 |
+
the version number 2.1.]
|
12 |
+
|
13 |
+
Preamble
|
14 |
+
|
15 |
+
The licenses for most software are designed to take away your
|
16 |
+
freedom to share and change it. By contrast, the GNU General Public
|
17 |
+
Licenses are intended to guarantee your freedom to share and change
|
18 |
+
free software--to make sure the software is free for all its users.
|
19 |
+
|
20 |
+
This license, the Lesser General Public License, applies to some
|
21 |
+
specially designated software packages--typically libraries--of the
|
22 |
+
Free Software Foundation and other authors who decide to use it. You
|
23 |
+
can use it too, but we suggest you first think carefully about whether
|
24 |
+
this license or the ordinary General Public License is the better
|
25 |
+
strategy to use in any particular case, based on the explanations below.
|
26 |
+
|
27 |
+
When we speak of free software, we are referring to freedom of use,
|
28 |
+
not price. Our General Public Licenses are designed to make sure that
|
29 |
+
you have the freedom to distribute copies of free software (and charge
|
30 |
+
for this service if you wish); that you receive source code or can get
|
31 |
+
it if you want it; that you can change the software and use pieces of
|
32 |
+
it in new free programs; and that you are informed that you can do
|
33 |
+
these things.
|
34 |
+
|
35 |
+
To protect your rights, we need to make restrictions that forbid
|
36 |
+
distributors to deny you these rights or to ask you to surrender these
|
37 |
+
rights. These restrictions translate to certain responsibilities for
|
38 |
+
you if you distribute copies of the library or if you modify it.
|
39 |
+
|
40 |
+
For example, if you distribute copies of the library, whether gratis
|
41 |
+
or for a fee, you must give the recipients all the rights that we gave
|
42 |
+
you. You must make sure that they, too, receive or can get the source
|
43 |
+
code. If you link other code with the library, you must provide
|
44 |
+
complete object files to the recipients, so that they can relink them
|
45 |
+
with the library after making changes to the library and recompiling
|
46 |
+
it. And you must show them these terms so they know their rights.
|
47 |
+
|
48 |
+
We protect your rights with a two-step method: (1) we copyright the
|
49 |
+
library, and (2) we offer you this license, which gives you legal
|
50 |
+
permission to copy, distribute and/or modify the library.
|
51 |
+
|
52 |
+
To protect each distributor, we want to make it very clear that
|
53 |
+
there is no warranty for the free library. Also, if the library is
|
54 |
+
modified by someone else and passed on, the recipients should know
|
55 |
+
that what they have is not the original version, so that the original
|
56 |
+
author's reputation will not be affected by problems that might be
|
57 |
+
introduced by others.
|
58 |
+
|
59 |
+
Finally, software patents pose a constant threat to the existence of
|
60 |
+
any free program. We wish to make sure that a company cannot
|
61 |
+
effectively restrict the users of a free program by obtaining a
|
62 |
+
restrictive license from a patent holder. Therefore, we insist that
|
63 |
+
any patent license obtained for a version of the library must be
|
64 |
+
consistent with the full freedom of use specified in this license.
|
65 |
+
|
66 |
+
Most GNU software, including some libraries, is covered by the
|
67 |
+
ordinary GNU General Public License. This license, the GNU Lesser
|
68 |
+
General Public License, applies to certain designated libraries, and
|
69 |
+
is quite different from the ordinary General Public License. We use
|
70 |
+
this license for certain libraries in order to permit linking those
|
71 |
+
libraries into non-free programs.
|
72 |
+
|
73 |
+
When a program is linked with a library, whether statically or using
|
74 |
+
a shared library, the combination of the two is legally speaking a
|
75 |
+
combined work, a derivative of the original library. The ordinary
|
76 |
+
General Public License therefore permits such linking only if the
|
77 |
+
entire combination fits its criteria of freedom. The Lesser General
|
78 |
+
Public License permits more lax criteria for linking other code with
|
79 |
+
the library.
|
80 |
+
|
81 |
+
We call this license the "Lesser" General Public License because it
|
82 |
+
does Less to protect the user's freedom than the ordinary General
|
83 |
+
Public License. It also provides other free software developers Less
|
84 |
+
of an advantage over competing non-free programs. These disadvantages
|
85 |
+
are the reason we use the ordinary General Public License for many
|
86 |
+
libraries. However, the Lesser license provides advantages in certain
|
87 |
+
special circumstances.
|
88 |
+
|
89 |
+
For example, on rare occasions, there may be a special need to
|
90 |
+
encourage the widest possible use of a certain library, so that it becomes
|
91 |
+
a de-facto standard. To achieve this, non-free programs must be
|
92 |
+
allowed to use the library. A more frequent case is that a free
|
93 |
+
library does the same job as widely used non-free libraries. In this
|
94 |
+
case, there is little to gain by limiting the free library to free
|
95 |
+
software only, so we use the Lesser General Public License.
|
96 |
+
|
97 |
+
In other cases, permission to use a particular library in non-free
|
98 |
+
programs enables a greater number of people to use a large body of
|
99 |
+
free software. For example, permission to use the GNU C Library in
|
100 |
+
non-free programs enables many more people to use the whole GNU
|
101 |
+
operating system, as well as its variant, the GNU/Linux operating
|
102 |
+
system.
|
103 |
+
|
104 |
+
Although the Lesser General Public License is Less protective of the
|
105 |
+
users' freedom, it does ensure that the user of a program that is
|
106 |
+
linked with the Library has the freedom and the wherewithal to run
|
107 |
+
that program using a modified version of the Library.
|
108 |
+
|
109 |
+
The precise terms and conditions for copying, distribution and
|
110 |
+
modification follow. Pay close attention to the difference between a
|
111 |
+
"work based on the library" and a "work that uses the library". The
|
112 |
+
former contains code derived from the library, whereas the latter must
|
113 |
+
be combined with the library in order to run.
|
114 |
+
|
115 |
+
GNU LESSER GENERAL PUBLIC LICENSE
|
116 |
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
117 |
+
|
118 |
+
0. This License Agreement applies to any software library or other
|
119 |
+
program which contains a notice placed by the copyright holder or
|
120 |
+
other authorized party saying it may be distributed under the terms of
|
121 |
+
this Lesser General Public License (also called "this License").
|
122 |
+
Each licensee is addressed as "you".
|
123 |
+
|
124 |
+
A "library" means a collection of software functions and/or data
|
125 |
+
prepared so as to be conveniently linked with application programs
|
126 |
+
(which use some of those functions and data) to form executables.
|
127 |
+
|
128 |
+
The "Library", below, refers to any such software library or work
|
129 |
+
which has been distributed under these terms. A "work based on the
|
130 |
+
Library" means either the Library or any derivative work under
|
131 |
+
copyright law: that is to say, a work containing the Library or a
|
132 |
+
portion of it, either verbatim or with modifications and/or translated
|
133 |
+
straightforwardly into another language. (Hereinafter, translation is
|
134 |
+
included without limitation in the term "modification".)
|
135 |
+
|
136 |
+
"Source code" for a work means the preferred form of the work for
|
137 |
+
making modifications to it. For a library, complete source code means
|
138 |
+
all the source code for all modules it contains, plus any associated
|
139 |
+
interface definition files, plus the scripts used to control compilation
|
140 |
+
and installation of the library.
|
141 |
+
|
142 |
+
Activities other than copying, distribution and modification are not
|
143 |
+
covered by this License; they are outside its scope. The act of
|
144 |
+
running a program using the Library is not restricted, and output from
|
145 |
+
such a program is covered only if its contents constitute a work based
|
146 |
+
on the Library (independent of the use of the Library in a tool for
|
147 |
+
writing it). Whether that is true depends on what the Library does
|
148 |
+
and what the program that uses the Library does.
|
149 |
+
|
150 |
+
1. You may copy and distribute verbatim copies of the Library's
|
151 |
+
complete source code as you receive it, in any medium, provided that
|
152 |
+
you conspicuously and appropriately publish on each copy an
|
153 |
+
appropriate copyright notice and disclaimer of warranty; keep intact
|
154 |
+
all the notices that refer to this License and to the absence of any
|
155 |
+
warranty; and distribute a copy of this License along with the
|
156 |
+
Library.
|
157 |
+
|
158 |
+
You may charge a fee for the physical act of transferring a copy,
|
159 |
+
and you may at your option offer warranty protection in exchange for a
|
160 |
+
fee.
|
161 |
+
|
162 |
+
2. You may modify your copy or copies of the Library or any portion
|
163 |
+
of it, thus forming a work based on the Library, and copy and
|
164 |
+
distribute such modifications or work under the terms of Section 1
|
165 |
+
above, provided that you also meet all of these conditions:
|
166 |
+
|
167 |
+
a) The modified work must itself be a software library.
|
168 |
+
|
169 |
+
b) You must cause the files modified to carry prominent notices
|
170 |
+
stating that you changed the files and the date of any change.
|
171 |
+
|
172 |
+
c) You must cause the whole of the work to be licensed at no
|
173 |
+
charge to all third parties under the terms of this License.
|
174 |
+
|
175 |
+
d) If a facility in the modified Library refers to a function or a
|
176 |
+
table of data to be supplied by an application program that uses
|
177 |
+
the facility, other than as an argument passed when the facility
|
178 |
+
is invoked, then you must make a good faith effort to ensure that,
|
179 |
+
in the event an application does not supply such function or
|
180 |
+
table, the facility still operates, and performs whatever part of
|
181 |
+
its purpose remains meaningful.
|
182 |
+
|
183 |
+
(For example, a function in a library to compute square roots has
|
184 |
+
a purpose that is entirely well-defined independent of the
|
185 |
+
application. Therefore, Subsection 2d requires that any
|
186 |
+
application-supplied function or table used by this function must
|
187 |
+
be optional: if the application does not supply it, the square
|
188 |
+
root function must still compute square roots.)
|
189 |
+
|
190 |
+
These requirements apply to the modified work as a whole. If
|
191 |
+
identifiable sections of that work are not derived from the Library,
|
192 |
+
and can be reasonably considered independent and separate works in
|
193 |
+
themselves, then this License, and its terms, do not apply to those
|
194 |
+
sections when you distribute them as separate works. But when you
|
195 |
+
distribute the same sections as part of a whole which is a work based
|
196 |
+
on the Library, the distribution of the whole must be on the terms of
|
197 |
+
this License, whose permissions for other licensees extend to the
|
198 |
+
entire whole, and thus to each and every part regardless of who wrote
|
199 |
+
it.
|
200 |
+
|
201 |
+
Thus, it is not the intent of this section to claim rights or contest
|
202 |
+
your rights to work written entirely by you; rather, the intent is to
|
203 |
+
exercise the right to control the distribution of derivative or
|
204 |
+
collective works based on the Library.
|
205 |
+
|
206 |
+
In addition, mere aggregation of another work not based on the Library
|
207 |
+
with the Library (or with a work based on the Library) on a volume of
|
208 |
+
a storage or distribution medium does not bring the other work under
|
209 |
+
the scope of this License.
|
210 |
+
|
211 |
+
3. You may opt to apply the terms of the ordinary GNU General Public
|
212 |
+
License instead of this License to a given copy of the Library. To do
|
213 |
+
this, you must alter all the notices that refer to this License, so
|
214 |
+
that they refer to the ordinary GNU General Public License, version 2,
|
215 |
+
instead of to this License. (If a newer version than version 2 of the
|
216 |
+
ordinary GNU General Public License has appeared, then you can specify
|
217 |
+
that version instead if you wish.) Do not make any other change in
|
218 |
+
these notices.
|
219 |
+
|
220 |
+
Once this change is made in a given copy, it is irreversible for
|
221 |
+
that copy, so the ordinary GNU General Public License applies to all
|
222 |
+
subsequent copies and derivative works made from that copy.
|
223 |
+
|
224 |
+
This option is useful when you wish to copy part of the code of
|
225 |
+
the Library into a program that is not a library.
|
226 |
+
|
227 |
+
4. You may copy and distribute the Library (or a portion or
|
228 |
+
derivative of it, under Section 2) in object code or executable form
|
229 |
+
under the terms of Sections 1 and 2 above provided that you accompany
|
230 |
+
it with the complete corresponding machine-readable source code, which
|
231 |
+
must be distributed under the terms of Sections 1 and 2 above on a
|
232 |
+
medium customarily used for software interchange.
|
233 |
+
|
234 |
+
If distribution of object code is made by offering access to copy
|
235 |
+
from a designated place, then offering equivalent access to copy the
|
236 |
+
source code from the same place satisfies the requirement to
|
237 |
+
distribute the source code, even though third parties are not
|
238 |
+
compelled to copy the source along with the object code.
|
239 |
+
|
240 |
+
5. A program that contains no derivative of any portion of the
|
241 |
+
Library, but is designed to work with the Library by being compiled or
|
242 |
+
linked with it, is called a "work that uses the Library". Such a
|
243 |
+
work, in isolation, is not a derivative work of the Library, and
|
244 |
+
therefore falls outside the scope of this License.
|
245 |
+
|
246 |
+
However, linking a "work that uses the Library" with the Library
|
247 |
+
creates an executable that is a derivative of the Library (because it
|
248 |
+
contains portions of the Library), rather than a "work that uses the
|
249 |
+
library". The executable is therefore covered by this License.
|
250 |
+
Section 6 states terms for distribution of such executables.
|
251 |
+
|
252 |
+
When a "work that uses the Library" uses material from a header file
|
253 |
+
that is part of the Library, the object code for the work may be a
|
254 |
+
derivative work of the Library even though the source code is not.
|
255 |
+
Whether this is true is especially significant if the work can be
|
256 |
+
linked without the Library, or if the work is itself a library. The
|
257 |
+
threshold for this to be true is not precisely defined by law.
|
258 |
+
|
259 |
+
If such an object file uses only numerical parameters, data
|
260 |
+
structure layouts and accessors, and small macros and small inline
|
261 |
+
functions (ten lines or less in length), then the use of the object
|
262 |
+
file is unrestricted, regardless of whether it is legally a derivative
|
263 |
+
work. (Executables containing this object code plus portions of the
|
264 |
+
Library will still fall under Section 6.)
|
265 |
+
|
266 |
+
Otherwise, if the work is a derivative of the Library, you may
|
267 |
+
distribute the object code for the work under the terms of Section 6.
|
268 |
+
Any executables containing that work also fall under Section 6,
|
269 |
+
whether or not they are linked directly with the Library itself.
|
270 |
+
|
271 |
+
6. As an exception to the Sections above, you may also combine or
|
272 |
+
link a "work that uses the Library" with the Library to produce a
|
273 |
+
work containing portions of the Library, and distribute that work
|
274 |
+
under terms of your choice, provided that the terms permit
|
275 |
+
modification of the work for the customer's own use and reverse
|
276 |
+
engineering for debugging such modifications.
|
277 |
+
|
278 |
+
You must give prominent notice with each copy of the work that the
|
279 |
+
Library is used in it and that the Library and its use are covered by
|
280 |
+
this License. You must supply a copy of this License. If the work
|
281 |
+
during execution displays copyright notices, you must include the
|
282 |
+
copyright notice for the Library among them, as well as a reference
|
283 |
+
directing the user to the copy of this License. Also, you must do one
|
284 |
+
of these things:
|
285 |
+
|
286 |
+
a) Accompany the work with the complete corresponding
|
287 |
+
machine-readable source code for the Library including whatever
|
288 |
+
changes were used in the work (which must be distributed under
|
289 |
+
Sections 1 and 2 above); and, if the work is an executable linked
|
290 |
+
with the Library, with the complete machine-readable "work that
|
291 |
+
uses the Library", as object code and/or source code, so that the
|
292 |
+
user can modify the Library and then relink to produce a modified
|
293 |
+
executable containing the modified Library. (It is understood
|
294 |
+
that the user who changes the contents of definitions files in the
|
295 |
+
Library will not necessarily be able to recompile the application
|
296 |
+
to use the modified definitions.)
|
297 |
+
|
298 |
+
b) Use a suitable shared library mechanism for linking with the
|
299 |
+
Library. A suitable mechanism is one that (1) uses at run time a
|
300 |
+
copy of the library already present on the user's computer system,
|
301 |
+
rather than copying library functions into the executable, and (2)
|
302 |
+
will operate properly with a modified version of the library, if
|
303 |
+
the user installs one, as long as the modified version is
|
304 |
+
interface-compatible with the version that the work was made with.
|
305 |
+
|
306 |
+
c) Accompany the work with a written offer, valid for at
|
307 |
+
least three years, to give the same user the materials
|
308 |
+
specified in Subsection 6a, above, for a charge no more
|
309 |
+
than the cost of performing this distribution.
|
310 |
+
|
311 |
+
d) If distribution of the work is made by offering access to copy
|
312 |
+
from a designated place, offer equivalent access to copy the above
|
313 |
+
specified materials from the same place.
|
314 |
+
|
315 |
+
e) Verify that the user has already received a copy of these
|
316 |
+
materials or that you have already sent this user a copy.
|
317 |
+
|
318 |
+
For an executable, the required form of the "work that uses the
|
319 |
+
Library" must include any data and utility programs needed for
|
320 |
+
reproducing the executable from it. However, as a special exception,
|
321 |
+
the materials to be distributed need not include anything that is
|
322 |
+
normally distributed (in either source or binary form) with the major
|
323 |
+
components (compiler, kernel, and so on) of the operating system on
|
324 |
+
which the executable runs, unless that component itself accompanies
|
325 |
+
the executable.
|
326 |
+
|
327 |
+
It may happen that this requirement contradicts the license
|
328 |
+
restrictions of other proprietary libraries that do not normally
|
329 |
+
accompany the operating system. Such a contradiction means you cannot
|
330 |
+
use both them and the Library together in an executable that you
|
331 |
+
distribute.
|
332 |
+
|
333 |
+
7. You may place library facilities that are a work based on the
|
334 |
+
Library side-by-side in a single library together with other library
|
335 |
+
facilities not covered by this License, and distribute such a combined
|
336 |
+
library, provided that the separate distribution of the work based on
|
337 |
+
the Library and of the other library facilities is otherwise
|
338 |
+
permitted, and provided that you do these two things:
|
339 |
+
|
340 |
+
a) Accompany the combined library with a copy of the same work
|
341 |
+
based on the Library, uncombined with any other library
|
342 |
+
facilities. This must be distributed under the terms of the
|
343 |
+
Sections above.
|
344 |
+
|
345 |
+
b) Give prominent notice with the combined library of the fact
|
346 |
+
that part of it is a work based on the Library, and explaining
|
347 |
+
where to find the accompanying uncombined form of the same work.
|
348 |
+
|
349 |
+
8. You may not copy, modify, sublicense, link with, or distribute
|
350 |
+
the Library except as expressly provided under this License. Any
|
351 |
+
attempt otherwise to copy, modify, sublicense, link with, or
|
352 |
+
distribute the Library is void, and will automatically terminate your
|
353 |
+
rights under this License. However, parties who have received copies,
|
354 |
+
or rights, from you under this License will not have their licenses
|
355 |
+
terminated so long as such parties remain in full compliance.
|
356 |
+
|
357 |
+
9. You are not required to accept this License, since you have not
|
358 |
+
signed it. However, nothing else grants you permission to modify or
|
359 |
+
distribute the Library or its derivative works. These actions are
|
360 |
+
prohibited by law if you do not accept this License. Therefore, by
|
361 |
+
modifying or distributing the Library (or any work based on the
|
362 |
+
Library), you indicate your acceptance of this License to do so, and
|
363 |
+
all its terms and conditions for copying, distributing or modifying
|
364 |
+
the Library or works based on it.
|
365 |
+
|
366 |
+
10. Each time you redistribute the Library (or any work based on the
|
367 |
+
Library), the recipient automatically receives a license from the
|
368 |
+
original licensor to copy, distribute, link with or modify the Library
|
369 |
+
subject to these terms and conditions. You may not impose any further
|
370 |
+
restrictions on the recipients' exercise of the rights granted herein.
|
371 |
+
You are not responsible for enforcing compliance by third parties with
|
372 |
+
this License.
|
373 |
+
|
374 |
+
11. If, as a consequence of a court judgment or allegation of patent
|
375 |
+
infringement or for any other reason (not limited to patent issues),
|
376 |
+
conditions are imposed on you (whether by court order, agreement or
|
377 |
+
otherwise) that contradict the conditions of this License, they do not
|
378 |
+
excuse you from the conditions of this License. If you cannot
|
379 |
+
distribute so as to satisfy simultaneously your obligations under this
|
380 |
+
License and any other pertinent obligations, then as a consequence you
|
381 |
+
may not distribute the Library at all. For example, if a patent
|
382 |
+
license would not permit royalty-free redistribution of the Library by
|
383 |
+
all those who receive copies directly or indirectly through you, then
|
384 |
+
the only way you could satisfy both it and this License would be to
|
385 |
+
refrain entirely from distribution of the Library.
|
386 |
+
|
387 |
+
If any portion of this section is held invalid or unenforceable under any
|
388 |
+
particular circumstance, the balance of the section is intended to apply,
|
389 |
+
and the section as a whole is intended to apply in other circumstances.
|
390 |
+
|
391 |
+
It is not the purpose of this section to induce you to infringe any
|
392 |
+
patents or other property right claims or to contest validity of any
|
393 |
+
such claims; this section has the sole purpose of protecting the
|
394 |
+
integrity of the free software distribution system which is
|
395 |
+
implemented by public license practices. Many people have made
|
396 |
+
generous contributions to the wide range of software distributed
|
397 |
+
through that system in reliance on consistent application of that
|
398 |
+
system; it is up to the author/donor to decide if he or she is willing
|
399 |
+
to distribute software through any other system and a licensee cannot
|
400 |
+
impose that choice.
|
401 |
+
|
402 |
+
This section is intended to make thoroughly clear what is believed to
|
403 |
+
be a consequence of the rest of this License.
|
404 |
+
|
405 |
+
12. If the distribution and/or use of the Library is restricted in
|
406 |
+
certain countries either by patents or by copyrighted interfaces, the
|
407 |
+
original copyright holder who places the Library under this License may add
|
408 |
+
an explicit geographical distribution limitation excluding those countries,
|
409 |
+
so that distribution is permitted only in or among countries not thus
|
410 |
+
excluded. In such case, this License incorporates the limitation as if
|
411 |
+
written in the body of this License.
|
412 |
+
|
413 |
+
13. The Free Software Foundation may publish revised and/or new
|
414 |
+
versions of the Lesser General Public License from time to time.
|
415 |
+
Such new versions will be similar in spirit to the present version,
|
416 |
+
but may differ in detail to address new problems or concerns.
|
417 |
+
|
418 |
+
Each version is given a distinguishing version number. If the Library
|
419 |
+
specifies a version number of this License which applies to it and
|
420 |
+
"any later version", you have the option of following the terms and
|
421 |
+
conditions either of that version or of any later version published by
|
422 |
+
the Free Software Foundation. If the Library does not specify a
|
423 |
+
license version number, you may choose any version ever published by
|
424 |
+
the Free Software Foundation.
|
425 |
+
|
426 |
+
14. If you wish to incorporate parts of the Library into other free
|
427 |
+
programs whose distribution conditions are incompatible with these,
|
428 |
+
write to the author to ask for permission. For software which is
|
429 |
+
copyrighted by the Free Software Foundation, write to the Free
|
430 |
+
Software Foundation; we sometimes make exceptions for this. Our
|
431 |
+
decision will be guided by the two goals of preserving the free status
|
432 |
+
of all derivatives of our free software and of promoting the sharing
|
433 |
+
and reuse of software generally.
|
434 |
+
|
435 |
+
NO WARRANTY
|
436 |
+
|
437 |
+
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
438 |
+
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
439 |
+
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
440 |
+
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
441 |
+
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
442 |
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
443 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
444 |
+
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
445 |
+
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
446 |
+
|
447 |
+
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
448 |
+
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
449 |
+
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
450 |
+
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
451 |
+
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
452 |
+
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
453 |
+
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
454 |
+
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
455 |
+
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
456 |
+
DAMAGES.
|
457 |
+
|
458 |
+
END OF TERMS AND CONDITIONS
|
459 |
+
|
460 |
+
How to Apply These Terms to Your New Libraries
|
461 |
+
|
462 |
+
If you develop a new library, and you want it to be of the greatest
|
463 |
+
possible use to the public, we recommend making it free software that
|
464 |
+
everyone can redistribute and change. You can do so by permitting
|
465 |
+
redistribution under these terms (or, alternatively, under the terms of the
|
466 |
+
ordinary General Public License).
|
467 |
+
|
468 |
+
To apply these terms, attach the following notices to the library. It is
|
469 |
+
safest to attach them to the start of each source file to most effectively
|
470 |
+
convey the exclusion of warranty; and each file should have at least the
|
471 |
+
"copyright" line and a pointer to where the full notice is found.
|
472 |
+
|
473 |
+
<one line to give the library's name and a brief idea of what it does.>
|
474 |
+
Copyright (C) <year> <name of author>
|
475 |
+
|
476 |
+
This library is free software; you can redistribute it and/or
|
477 |
+
modify it under the terms of the GNU Lesser General Public
|
478 |
+
License as published by the Free Software Foundation; either
|
479 |
+
version 2.1 of the License, or (at your option) any later version.
|
480 |
+
|
481 |
+
This library is distributed in the hope that it will be useful,
|
482 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
483 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
484 |
+
Lesser General Public License for more details.
|
485 |
+
|
486 |
+
You should have received a copy of the GNU Lesser General Public
|
487 |
+
License along with this library; if not, write to the Free Software
|
488 |
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
489 |
+
|
490 |
+
Also add information on how to contact you by electronic and paper mail.
|
491 |
+
|
492 |
+
You should also get your employer (if you work as a programmer) or your
|
493 |
+
school, if any, to sign a "copyright disclaimer" for the library, if
|
494 |
+
necessary. Here is a sample; alter the names:
|
495 |
+
|
496 |
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
497 |
+
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
498 |
+
|
499 |
+
<signature of Ty Coon>, 1 April 1990
|
500 |
+
Ty Coon, President of Vice
|
501 |
+
|
502 |
+
That's all there is to it!
|
503 |
+
|
504 |
+
|
lib/vendor/zip-factory/zip-factory/lib/vendor/pclzip-2-8-2/pclzip.lib.php
ADDED
@@ -0,0 +1,5690 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// --------------------------------------------------------------------------------
|
3 |
+
// PhpConcept Library - Zip Module 2.8.2
|
4 |
+
// --------------------------------------------------------------------------------
|
5 |
+
// License GNU/LGPL - Vincent Blavet - August 2009
|
6 |
+
// http://www.phpconcept.net
|
7 |
+
// --------------------------------------------------------------------------------
|
8 |
+
//
|
9 |
+
// Presentation :
|
10 |
+
// PclZip is a PHP library that manage ZIP archives.
|
11 |
+
// So far tests show that archives generated by PclZip are readable by
|
12 |
+
// WinZip application and other tools.
|
13 |
+
//
|
14 |
+
// Description :
|
15 |
+
// See readme.txt and http://www.phpconcept.net
|
16 |
+
//
|
17 |
+
// Warning :
|
18 |
+
// This library and the associated files are non commercial, non professional
|
19 |
+
// work.
|
20 |
+
// It should not have unexpected results. However if any damage is caused by
|
21 |
+
// this software the author can not be responsible.
|
22 |
+
// The use of this software is at the risk of the user.
|
23 |
+
//
|
24 |
+
// --------------------------------------------------------------------------------
|
25 |
+
// $Id: pclzip.lib.php,v 1.60 2009/09/30 21:01:04 vblavet Exp $
|
26 |
+
// --------------------------------------------------------------------------------
|
27 |
+
|
28 |
+
// ----- Constants
|
29 |
+
if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
|
30 |
+
define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
|
31 |
+
}
|
32 |
+
|
33 |
+
// ----- File list separator
|
34 |
+
// In version 1.x of PclZip, the separator for file list is a space
|
35 |
+
// (which is not a very smart choice, specifically for windows paths !).
|
36 |
+
// A better separator should be a comma (,). This constant gives you the
|
37 |
+
// abilty to change that.
|
38 |
+
// However notice that changing this value, may have impact on existing
|
39 |
+
// scripts, using space separated filenames.
|
40 |
+
// Recommanded values for compatibility with older versions :
|
41 |
+
//define( 'PCLZIP_SEPARATOR', ' ' );
|
42 |
+
// Recommanded values for smart separation of filenames.
|
43 |
+
if (!defined('PCLZIP_SEPARATOR')) {
|
44 |
+
define( 'PCLZIP_SEPARATOR', ',' );
|
45 |
+
}
|
46 |
+
|
47 |
+
// ----- Error configuration
|
48 |
+
// 0 : PclZip Class integrated error handling
|
49 |
+
// 1 : PclError external library error handling. By enabling this
|
50 |
+
// you must ensure that you have included PclError library.
|
51 |
+
// [2,...] : reserved for futur use
|
52 |
+
if (!defined('PCLZIP_ERROR_EXTERNAL')) {
|
53 |
+
define( 'PCLZIP_ERROR_EXTERNAL', 0 );
|
54 |
+
}
|
55 |
+
|
56 |
+
// ----- Optional static temporary directory
|
57 |
+
// By default temporary files are generated in the script current
|
58 |
+
// path.
|
59 |
+
// If defined :
|
60 |
+
// - MUST BE terminated by a '/'.
|
61 |
+
// - MUST be a valid, already created directory
|
62 |
+
// Samples :
|
63 |
+
// define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
|
64 |
+
// define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
|
65 |
+
if (!defined('PCLZIP_TEMPORARY_DIR')) {
|
66 |
+
define( 'PCLZIP_TEMPORARY_DIR', '' );
|
67 |
+
}
|
68 |
+
|
69 |
+
// ----- Optional threshold ratio for use of temporary files
|
70 |
+
// Pclzip sense the size of the file to add/extract and decide to
|
71 |
+
// use or not temporary file. The algorythm is looking for
|
72 |
+
// memory_limit of PHP and apply a ratio.
|
73 |
+
// threshold = memory_limit * ratio.
|
74 |
+
// Recommended values are under 0.5. Default 0.47.
|
75 |
+
// Samples :
|
76 |
+
// define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 );
|
77 |
+
if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
|
78 |
+
define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 );
|
79 |
+
}
|
80 |
+
|
81 |
+
// --------------------------------------------------------------------------------
|
82 |
+
// ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED *****
|
83 |
+
// --------------------------------------------------------------------------------
|
84 |
+
|
85 |
+
// ----- Global variables
|
86 |
+
$g_pclzip_version = "2.8.2";
|
87 |
+
|
88 |
+
// ----- Error codes
|
89 |
+
// -1 : Unable to open file in binary write mode
|
90 |
+
// -2 : Unable to open file in binary read mode
|
91 |
+
// -3 : Invalid parameters
|
92 |
+
// -4 : File does not exist
|
93 |
+
// -5 : Filename is too long (max. 255)
|
94 |
+
// -6 : Not a valid zip file
|
95 |
+
// -7 : Invalid extracted file size
|
96 |
+
// -8 : Unable to create directory
|
97 |
+
// -9 : Invalid archive extension
|
98 |
+
// -10 : Invalid archive format
|
99 |
+
// -11 : Unable to delete file (unlink)
|
100 |
+
// -12 : Unable to rename file (rename)
|
101 |
+
// -13 : Invalid header checksum
|
102 |
+
// -14 : Invalid archive size
|
103 |
+
define( 'PCLZIP_ERR_USER_ABORTED', 2 );
|
104 |
+
define( 'PCLZIP_ERR_NO_ERROR', 0 );
|
105 |
+
define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );
|
106 |
+
define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 );
|
107 |
+
define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 );
|
108 |
+
define( 'PCLZIP_ERR_MISSING_FILE', -4 );
|
109 |
+
define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 );
|
110 |
+
define( 'PCLZIP_ERR_INVALID_ZIP', -6 );
|
111 |
+
define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );
|
112 |
+
define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 );
|
113 |
+
define( 'PCLZIP_ERR_BAD_EXTENSION', -9 );
|
114 |
+
define( 'PCLZIP_ERR_BAD_FORMAT', -10 );
|
115 |
+
define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 );
|
116 |
+
define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 );
|
117 |
+
define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 );
|
118 |
+
define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );
|
119 |
+
define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );
|
120 |
+
define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );
|
121 |
+
define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 );
|
122 |
+
define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 );
|
123 |
+
define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 );
|
124 |
+
define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 );
|
125 |
+
define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 );
|
126 |
+
|
127 |
+
// ----- Options values
|
128 |
+
define( 'PCLZIP_OPT_PATH', 77001 );
|
129 |
+
define( 'PCLZIP_OPT_ADD_PATH', 77002 );
|
130 |
+
define( 'PCLZIP_OPT_REMOVE_PATH', 77003 );
|
131 |
+
define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );
|
132 |
+
define( 'PCLZIP_OPT_SET_CHMOD', 77005 );
|
133 |
+
define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );
|
134 |
+
define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 );
|
135 |
+
define( 'PCLZIP_OPT_BY_NAME', 77008 );
|
136 |
+
define( 'PCLZIP_OPT_BY_INDEX', 77009 );
|
137 |
+
define( 'PCLZIP_OPT_BY_EREG', 77010 );
|
138 |
+
define( 'PCLZIP_OPT_BY_PREG', 77011 );
|
139 |
+
define( 'PCLZIP_OPT_COMMENT', 77012 );
|
140 |
+
define( 'PCLZIP_OPT_ADD_COMMENT', 77013 );
|
141 |
+
define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 );
|
142 |
+
define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 );
|
143 |
+
define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 );
|
144 |
+
define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 );
|
145 |
+
// Having big trouble with crypt. Need to multiply 2 long int
|
146 |
+
// which is not correctly supported by PHP ...
|
147 |
+
//define( 'PCLZIP_OPT_CRYPT', 77018 );
|
148 |
+
define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 );
|
149 |
+
define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 );
|
150 |
+
define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias
|
151 |
+
define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 );
|
152 |
+
define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias
|
153 |
+
define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 );
|
154 |
+
define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias
|
155 |
+
|
156 |
+
// ----- File description attributes
|
157 |
+
define( 'PCLZIP_ATT_FILE_NAME', 79001 );
|
158 |
+
define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 );
|
159 |
+
define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 );
|
160 |
+
define( 'PCLZIP_ATT_FILE_MTIME', 79004 );
|
161 |
+
define( 'PCLZIP_ATT_FILE_CONTENT', 79005 );
|
162 |
+
define( 'PCLZIP_ATT_FILE_COMMENT', 79006 );
|
163 |
+
|
164 |
+
// ----- Call backs values
|
165 |
+
define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );
|
166 |
+
define( 'PCLZIP_CB_POST_EXTRACT', 78002 );
|
167 |
+
define( 'PCLZIP_CB_PRE_ADD', 78003 );
|
168 |
+
define( 'PCLZIP_CB_POST_ADD', 78004 );
|
169 |
+
/* For futur use
|
170 |
+
define( 'PCLZIP_CB_PRE_LIST', 78005 );
|
171 |
+
define( 'PCLZIP_CB_POST_LIST', 78006 );
|
172 |
+
define( 'PCLZIP_CB_PRE_DELETE', 78007 );
|
173 |
+
define( 'PCLZIP_CB_POST_DELETE', 78008 );
|
174 |
+
*/
|
175 |
+
|
176 |
+
// --------------------------------------------------------------------------------
|
177 |
+
// Class : PclZip
|
178 |
+
// Description :
|
179 |
+
// PclZip is the class that represent a Zip archive.
|
180 |
+
// The public methods allow the manipulation of the archive.
|
181 |
+
// Attributes :
|
182 |
+
// Attributes must not be accessed directly.
|
183 |
+
// Methods :
|
184 |
+
// PclZip() : Object creator
|
185 |
+
// create() : Creates the Zip archive
|
186 |
+
// listContent() : List the content of the Zip archive
|
187 |
+
// extract() : Extract the content of the archive
|
188 |
+
// properties() : List the properties of the archive
|
189 |
+
// --------------------------------------------------------------------------------
|
190 |
+
class PclZip
|
191 |
+
{
|
192 |
+
// ----- Filename of the zip file
|
193 |
+
var $zipname = '';
|
194 |
+
|
195 |
+
// ----- File descriptor of the zip file
|
196 |
+
var $zip_fd = 0;
|
197 |
+
|
198 |
+
// ----- Internal error handling
|
199 |
+
var $error_code = 1;
|
200 |
+
var $error_string = '';
|
201 |
+
|
202 |
+
// ----- Current status of the magic_quotes_runtime
|
203 |
+
// This value store the php configuration for magic_quotes
|
204 |
+
// The class can then disable the magic_quotes and reset it after
|
205 |
+
var $magic_quotes_status;
|
206 |
+
|
207 |
+
// --------------------------------------------------------------------------------
|
208 |
+
// Function : PclZip()
|
209 |
+
// Description :
|
210 |
+
// Creates a PclZip object and set the name of the associated Zip archive
|
211 |
+
// filename.
|
212 |
+
// Note that no real action is taken, if the archive does not exist it is not
|
213 |
+
// created. Use create() for that.
|
214 |
+
// --------------------------------------------------------------------------------
|
215 |
+
function PclZip($p_zipname)
|
216 |
+
{
|
217 |
+
|
218 |
+
// ----- Tests the zlib
|
219 |
+
if (!function_exists('gzopen'))
|
220 |
+
{
|
221 |
+
die('Abort '.basename(__FILE__).' : Missing zlib extensions');
|
222 |
+
}
|
223 |
+
|
224 |
+
// ----- Set the attributes
|
225 |
+
$this->zipname = $p_zipname;
|
226 |
+
$this->zip_fd = 0;
|
227 |
+
$this->magic_quotes_status = -1;
|
228 |
+
|
229 |
+
// ----- Return
|
230 |
+
return;
|
231 |
+
}
|
232 |
+
// --------------------------------------------------------------------------------
|
233 |
+
|
234 |
+
// --------------------------------------------------------------------------------
|
235 |
+
// Function :
|
236 |
+
// create($p_filelist, $p_add_dir="", $p_remove_dir="")
|
237 |
+
// create($p_filelist, $p_option, $p_option_value, ...)
|
238 |
+
// Description :
|
239 |
+
// This method supports two different synopsis. The first one is historical.
|
240 |
+
// This method creates a Zip Archive. The Zip file is created in the
|
241 |
+
// filesystem. The files and directories indicated in $p_filelist
|
242 |
+
// are added in the archive. See the parameters description for the
|
243 |
+
// supported format of $p_filelist.
|
244 |
+
// When a directory is in the list, the directory and its content is added
|
245 |
+
// in the archive.
|
246 |
+
// In this synopsis, the function takes an optional variable list of
|
247 |
+
// options. See bellow the supported options.
|
248 |
+
// Parameters :
|
249 |
+
// $p_filelist : An array containing file or directory names, or
|
250 |
+
// a string containing one filename or one directory name, or
|
251 |
+
// a string containing a list of filenames and/or directory
|
252 |
+
// names separated by spaces.
|
253 |
+
// $p_add_dir : A path to add before the real path of the archived file,
|
254 |
+
// in order to have it memorized in the archive.
|
255 |
+
// $p_remove_dir : A path to remove from the real path of the file to archive,
|
256 |
+
// in order to have a shorter path memorized in the archive.
|
257 |
+
// When $p_add_dir and $p_remove_dir are set, $p_remove_dir
|
258 |
+
// is removed first, before $p_add_dir is added.
|
259 |
+
// Options :
|
260 |
+
// PCLZIP_OPT_ADD_PATH :
|
261 |
+
// PCLZIP_OPT_REMOVE_PATH :
|
262 |
+
// PCLZIP_OPT_REMOVE_ALL_PATH :
|
263 |
+
// PCLZIP_OPT_COMMENT :
|
264 |
+
// PCLZIP_CB_PRE_ADD :
|
265 |
+
// PCLZIP_CB_POST_ADD :
|
266 |
+
// Return Values :
|
267 |
+
// 0 on failure,
|
268 |
+
// The list of the added files, with a status of the add action.
|
269 |
+
// (see PclZip::listContent() for list entry format)
|
270 |
+
// --------------------------------------------------------------------------------
|
271 |
+
function create($p_filelist)
|
272 |
+
{
|
273 |
+
$v_result=1;
|
274 |
+
|
275 |
+
// ----- Reset the error handler
|
276 |
+
$this->privErrorReset();
|
277 |
+
|
278 |
+
// ----- Set default values
|
279 |
+
$v_options = array();
|
280 |
+
$v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
|
281 |
+
|
282 |
+
// ----- Look for variable options arguments
|
283 |
+
$v_size = func_num_args();
|
284 |
+
|
285 |
+
// ----- Look for arguments
|
286 |
+
if ($v_size > 1) {
|
287 |
+
// ----- Get the arguments
|
288 |
+
$v_arg_list = func_get_args();
|
289 |
+
|
290 |
+
// ----- Remove from the options list the first argument
|
291 |
+
array_shift($v_arg_list);
|
292 |
+
$v_size--;
|
293 |
+
|
294 |
+
// ----- Look for first arg
|
295 |
+
if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
|
296 |
+
|
297 |
+
// ----- Parse the options
|
298 |
+
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
|
299 |
+
array (PCLZIP_OPT_REMOVE_PATH => 'optional',
|
300 |
+
PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
|
301 |
+
PCLZIP_OPT_ADD_PATH => 'optional',
|
302 |
+
PCLZIP_CB_PRE_ADD => 'optional',
|
303 |
+
PCLZIP_CB_POST_ADD => 'optional',
|
304 |
+
PCLZIP_OPT_NO_COMPRESSION => 'optional',
|
305 |
+
PCLZIP_OPT_COMMENT => 'optional',
|
306 |
+
PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
|
307 |
+
PCLZIP_OPT_TEMP_FILE_ON => 'optional',
|
308 |
+
PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
|
309 |
+
//, PCLZIP_OPT_CRYPT => 'optional'
|
310 |
+
));
|
311 |
+
if ($v_result != 1) {
|
312 |
+
return 0;
|
313 |
+
}
|
314 |
+
}
|
315 |
+
|
316 |
+
// ----- Look for 2 args
|
317 |
+
// Here we need to support the first historic synopsis of the
|
318 |
+
// method.
|
319 |
+
else {
|
320 |
+
|
321 |
+
// ----- Get the first argument
|
322 |
+
$v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
|
323 |
+
|
324 |
+
// ----- Look for the optional second argument
|
325 |
+
if ($v_size == 2) {
|
326 |
+
$v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
|
327 |
+
}
|
328 |
+
else if ($v_size > 2) {
|
329 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
|
330 |
+
"Invalid number / type of arguments");
|
331 |
+
return 0;
|
332 |
+
}
|
333 |
+
}
|
334 |
+
}
|
335 |
+
|
336 |
+
// ----- Look for default option values
|
337 |
+
$this->privOptionDefaultThreshold($v_options);
|
338 |
+
|
339 |
+
// ----- Init
|
340 |
+
$v_string_list = array();
|
341 |
+
$v_att_list = array();
|
342 |
+
$v_filedescr_list = array();
|
343 |
+
$p_result_list = array();
|
344 |
+
|
345 |
+
// ----- Look if the $p_filelist is really an array
|
346 |
+
if (is_array($p_filelist)) {
|
347 |
+
|
348 |
+
// ----- Look if the first element is also an array
|
349 |
+
// This will mean that this is a file description entry
|
350 |
+
if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
|
351 |
+
$v_att_list = $p_filelist;
|
352 |
+
}
|
353 |
+
|
354 |
+
// ----- The list is a list of string names
|
355 |
+
else {
|
356 |
+
$v_string_list = $p_filelist;
|
357 |
+
}
|
358 |
+
}
|
359 |
+
|
360 |
+
// ----- Look if the $p_filelist is a string
|
361 |
+
else if (is_string($p_filelist)) {
|
362 |
+
// ----- Create a list from the string
|
363 |
+
$v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
|
364 |
+
}
|
365 |
+
|
366 |
+
// ----- Invalid variable type for $p_filelist
|
367 |
+
else {
|
368 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
|
369 |
+
return 0;
|
370 |
+
}
|
371 |
+
|
372 |
+
// ----- Reformat the string list
|
373 |
+
if (sizeof($v_string_list) != 0) {
|
374 |
+
foreach ($v_string_list as $v_string) {
|
375 |
+
if ($v_string != '') {
|
376 |
+
$v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
|
377 |
+
}
|
378 |
+
else {
|
379 |
+
}
|
380 |
+
}
|
381 |
+
}
|
382 |
+
|
383 |
+
// ----- For each file in the list check the attributes
|
384 |
+
$v_supported_attributes
|
385 |
+
= array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
|
386 |
+
,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
|
387 |
+
,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
|
388 |
+
,PCLZIP_ATT_FILE_MTIME => 'optional'
|
389 |
+
,PCLZIP_ATT_FILE_CONTENT => 'optional'
|
390 |
+
,PCLZIP_ATT_FILE_COMMENT => 'optional'
|
391 |
+
);
|
392 |
+
foreach ($v_att_list as $v_entry) {
|
393 |
+
$v_result = $this->privFileDescrParseAtt($v_entry,
|
394 |
+
$v_filedescr_list[],
|
395 |
+
$v_options,
|
396 |
+
$v_supported_attributes);
|
397 |
+
if ($v_result != 1) {
|
398 |
+
return 0;
|
399 |
+
}
|
400 |
+
}
|
401 |
+
|
402 |
+
// ----- Expand the filelist (expand directories)
|
403 |
+
$v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
|
404 |
+
if ($v_result != 1) {
|
405 |
+
return 0;
|
406 |
+
}
|
407 |
+
|
408 |
+
// ----- Call the create fct
|
409 |
+
$v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options);
|
410 |
+
if ($v_result != 1) {
|
411 |
+
return 0;
|
412 |
+
}
|
413 |
+
|
414 |
+
// ----- Return
|
415 |
+
return $p_result_list;
|
416 |
+
}
|
417 |
+
// --------------------------------------------------------------------------------
|
418 |
+
|
419 |
+
// --------------------------------------------------------------------------------
|
420 |
+
// Function :
|
421 |
+
// add($p_filelist, $p_add_dir="", $p_remove_dir="")
|
422 |
+
// add($p_filelist, $p_option, $p_option_value, ...)
|
423 |
+
// Description :
|
424 |
+
// This method supports two synopsis. The first one is historical.
|
425 |
+
// This methods add the list of files in an existing archive.
|
426 |
+
// If a file with the same name already exists, it is added at the end of the
|
427 |
+
// archive, the first one is still present.
|
428 |
+
// If the archive does not exist, it is created.
|
429 |
+
// Parameters :
|
430 |
+
// $p_filelist : An array containing file or directory names, or
|
431 |
+
// a string containing one filename or one directory name, or
|
432 |
+
// a string containing a list of filenames and/or directory
|
433 |
+
// names separated by spaces.
|
434 |
+
// $p_add_dir : A path to add before the real path of the archived file,
|
435 |
+
// in order to have it memorized in the archive.
|
436 |
+
// $p_remove_dir : A path to remove from the real path of the file to archive,
|
437 |
+
// in order to have a shorter path memorized in the archive.
|
438 |
+
// When $p_add_dir and $p_remove_dir are set, $p_remove_dir
|
439 |
+
// is removed first, before $p_add_dir is added.
|
440 |
+
// Options :
|
441 |
+
// PCLZIP_OPT_ADD_PATH :
|
442 |
+
// PCLZIP_OPT_REMOVE_PATH :
|
443 |
+
// PCLZIP_OPT_REMOVE_ALL_PATH :
|
444 |
+
// PCLZIP_OPT_COMMENT :
|
445 |
+
// PCLZIP_OPT_ADD_COMMENT :
|
446 |
+
// PCLZIP_OPT_PREPEND_COMMENT :
|
447 |
+
// PCLZIP_CB_PRE_ADD :
|
448 |
+
// PCLZIP_CB_POST_ADD :
|
449 |
+
// Return Values :
|
450 |
+
// 0 on failure,
|
451 |
+
// The list of the added files, with a status of the add action.
|
452 |
+
// (see PclZip::listContent() for list entry format)
|
453 |
+
// --------------------------------------------------------------------------------
|
454 |
+
function add($p_filelist)
|
455 |
+
{
|
456 |
+
$v_result=1;
|
457 |
+
|
458 |
+
// ----- Reset the error handler
|
459 |
+
$this->privErrorReset();
|
460 |
+
|
461 |
+
// ----- Set default values
|
462 |
+
$v_options = array();
|
463 |
+
$v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
|
464 |
+
|
465 |
+
// ----- Look for variable options arguments
|
466 |
+
$v_size = func_num_args();
|
467 |
+
|
468 |
+
// ----- Look for arguments
|
469 |
+
if ($v_size > 1) {
|
470 |
+
// ----- Get the arguments
|
471 |
+
$v_arg_list = func_get_args();
|
472 |
+
|
473 |
+
// ----- Remove form the options list the first argument
|
474 |
+
array_shift($v_arg_list);
|
475 |
+
$v_size--;
|
476 |
+
|
477 |
+
// ----- Look for first arg
|
478 |
+
if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
|
479 |
+
|
480 |
+
// ----- Parse the options
|
481 |
+
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
|
482 |
+
array (PCLZIP_OPT_REMOVE_PATH => 'optional',
|
483 |
+
PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
|
484 |
+
PCLZIP_OPT_ADD_PATH => 'optional',
|
485 |
+
PCLZIP_CB_PRE_ADD => 'optional',
|
486 |
+
PCLZIP_CB_POST_ADD => 'optional',
|
487 |
+
PCLZIP_OPT_NO_COMPRESSION => 'optional',
|
488 |
+
PCLZIP_OPT_COMMENT => 'optional',
|
489 |
+
PCLZIP_OPT_ADD_COMMENT => 'optional',
|
490 |
+
PCLZIP_OPT_PREPEND_COMMENT => 'optional',
|
491 |
+
PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
|
492 |
+
PCLZIP_OPT_TEMP_FILE_ON => 'optional',
|
493 |
+
PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
|
494 |
+
//, PCLZIP_OPT_CRYPT => 'optional'
|
495 |
+
));
|
496 |
+
if ($v_result != 1) {
|
497 |
+
return 0;
|
498 |
+
}
|
499 |
+
}
|
500 |
+
|
501 |
+
// ----- Look for 2 args
|
502 |
+
// Here we need to support the first historic synopsis of the
|
503 |
+
// method.
|
504 |
+
else {
|
505 |
+
|
506 |
+
// ----- Get the first argument
|
507 |
+
$v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
|
508 |
+
|
509 |
+
// ----- Look for the optional second argument
|
510 |
+
if ($v_size == 2) {
|
511 |
+
$v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
|
512 |
+
}
|
513 |
+
else if ($v_size > 2) {
|
514 |
+
// ----- Error log
|
515 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
|
516 |
+
|
517 |
+
// ----- Return
|
518 |
+
return 0;
|
519 |
+
}
|
520 |
+
}
|
521 |
+
}
|
522 |
+
|
523 |
+
// ----- Look for default option values
|
524 |
+
$this->privOptionDefaultThreshold($v_options);
|
525 |
+
|
526 |
+
// ----- Init
|
527 |
+
$v_string_list = array();
|
528 |
+
$v_att_list = array();
|
529 |
+
$v_filedescr_list = array();
|
530 |
+
$p_result_list = array();
|
531 |
+
|
532 |
+
// ----- Look if the $p_filelist is really an array
|
533 |
+
if (is_array($p_filelist)) {
|
534 |
+
|
535 |
+
// ----- Look if the first element is also an array
|
536 |
+
// This will mean that this is a file description entry
|
537 |
+
if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
|
538 |
+
$v_att_list = $p_filelist;
|
539 |
+
}
|
540 |
+
|
541 |
+
// ----- The list is a list of string names
|
542 |
+
else {
|
543 |
+
$v_string_list = $p_filelist;
|
544 |
+
}
|
545 |
+
}
|
546 |
+
|
547 |
+
// ----- Look if the $p_filelist is a string
|
548 |
+
else if (is_string($p_filelist)) {
|
549 |
+
// ----- Create a list from the string
|
550 |
+
$v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
|
551 |
+
}
|
552 |
+
|
553 |
+
// ----- Invalid variable type for $p_filelist
|
554 |
+
else {
|
555 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
|
556 |
+
return 0;
|
557 |
+
}
|
558 |
+
|
559 |
+
// ----- Reformat the string list
|
560 |
+
if (sizeof($v_string_list) != 0) {
|
561 |
+
foreach ($v_string_list as $v_string) {
|
562 |
+
$v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
|
563 |
+
}
|
564 |
+
}
|
565 |
+
|
566 |
+
// ----- For each file in the list check the attributes
|
567 |
+
$v_supported_attributes
|
568 |
+
= array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
|
569 |
+
,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
|
570 |
+
,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
|
571 |
+
,PCLZIP_ATT_FILE_MTIME => 'optional'
|
572 |
+
,PCLZIP_ATT_FILE_CONTENT => 'optional'
|
573 |
+
,PCLZIP_ATT_FILE_COMMENT => 'optional'
|
574 |
+
);
|
575 |
+
foreach ($v_att_list as $v_entry) {
|
576 |
+
$v_result = $this->privFileDescrParseAtt($v_entry,
|
577 |
+
$v_filedescr_list[],
|
578 |
+
$v_options,
|
579 |
+
$v_supported_attributes);
|
580 |
+
if ($v_result != 1) {
|
581 |
+
return 0;
|
582 |
+
}
|
583 |
+
}
|
584 |
+
|
585 |
+
// ----- Expand the filelist (expand directories)
|
586 |
+
$v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
|
587 |
+
if ($v_result != 1) {
|
588 |
+
return 0;
|
589 |
+
}
|
590 |
+
|
591 |
+
// ----- Call the create fct
|
592 |
+
$v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
|
593 |
+
if ($v_result != 1) {
|
594 |
+
return 0;
|
595 |
+
}
|
596 |
+
|
597 |
+
// ----- Return
|
598 |
+
return $p_result_list;
|
599 |
+
}
|
600 |
+
// --------------------------------------------------------------------------------
|
601 |
+
|
602 |
+
// --------------------------------------------------------------------------------
|
603 |
+
// Function : listContent()
|
604 |
+
// Description :
|
605 |
+
// This public method, gives the list of the files and directories, with their
|
606 |
+
// properties.
|
607 |
+
// The properties of each entries in the list are (used also in other functions) :
|
608 |
+
// filename : Name of the file. For a create or add action it is the filename
|
609 |
+
// given by the user. For an extract function it is the filename
|
610 |
+
// of the extracted file.
|
611 |
+
// stored_filename : Name of the file / directory stored in the archive.
|
612 |
+
// size : Size of the stored file.
|
613 |
+
// compressed_size : Size of the file's data compressed in the archive
|
614 |
+
// (without the headers overhead)
|
615 |
+
// mtime : Last known modification date of the file (UNIX timestamp)
|
616 |
+
// comment : Comment associated with the file
|
617 |
+
// folder : true | false
|
618 |
+
// index : index of the file in the archive
|
619 |
+
// status : status of the action (depending of the action) :
|
620 |
+
// Values are :
|
621 |
+
// ok : OK !
|
622 |
+
// filtered : the file / dir is not extracted (filtered by user)
|
623 |
+
// already_a_directory : the file can not be extracted because a
|
624 |
+
// directory with the same name already exists
|
625 |
+
// write_protected : the file can not be extracted because a file
|
626 |
+
// with the same name already exists and is
|
627 |
+
// write protected
|
628 |
+
// newer_exist : the file was not extracted because a newer file exists
|
629 |
+
// path_creation_fail : the file is not extracted because the folder
|
630 |
+
// does not exist and can not be created
|
631 |
+
// write_error : the file was not extracted because there was a
|
632 |
+
// error while writing the file
|
633 |
+
// read_error : the file was not extracted because there was a error
|
634 |
+
// while reading the file
|
635 |
+
// invalid_header : the file was not extracted because of an archive
|
636 |
+
// format error (bad file header)
|
637 |
+
// Note that each time a method can continue operating when there
|
638 |
+
// is an action error on a file, the error is only logged in the file status.
|
639 |
+
// Return Values :
|
640 |
+
// 0 on an unrecoverable failure,
|
641 |
+
// The list of the files in the archive.
|
642 |
+
// --------------------------------------------------------------------------------
|
643 |
+
function listContent()
|
644 |
+
{
|
645 |
+
$v_result=1;
|
646 |
+
|
647 |
+
// ----- Reset the error handler
|
648 |
+
$this->privErrorReset();
|
649 |
+
|
650 |
+
// ----- Check archive
|
651 |
+
if (!$this->privCheckFormat()) {
|
652 |
+
return(0);
|
653 |
+
}
|
654 |
+
|
655 |
+
// ----- Call the extracting fct
|
656 |
+
$p_list = array();
|
657 |
+
if (($v_result = $this->privList($p_list)) != 1)
|
658 |
+
{
|
659 |
+
unset($p_list);
|
660 |
+
return(0);
|
661 |
+
}
|
662 |
+
|
663 |
+
// ----- Return
|
664 |
+
return $p_list;
|
665 |
+
}
|
666 |
+
// --------------------------------------------------------------------------------
|
667 |
+
|
668 |
+
// --------------------------------------------------------------------------------
|
669 |
+
// Function :
|
670 |
+
// extract($p_path="./", $p_remove_path="")
|
671 |
+
// extract([$p_option, $p_option_value, ...])
|
672 |
+
// Description :
|
673 |
+
// This method supports two synopsis. The first one is historical.
|
674 |
+
// This method extract all the files / directories from the archive to the
|
675 |
+
// folder indicated in $p_path.
|
676 |
+
// If you want to ignore the 'root' part of path of the memorized files
|
677 |
+
// you can indicate this in the optional $p_remove_path parameter.
|
678 |
+
// By default, if a newer file with the same name already exists, the
|
679 |
+
// file is not extracted.
|
680 |
+
//
|
681 |
+
// If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
|
682 |
+
// are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
|
683 |
+
// at the end of the path value of PCLZIP_OPT_PATH.
|
684 |
+
// Parameters :
|
685 |
+
// $p_path : Path where the files and directories are to be extracted
|
686 |
+
// $p_remove_path : First part ('root' part) of the memorized path
|
687 |
+
// (if any similar) to remove while extracting.
|
688 |
+
// Options :
|
689 |
+
// PCLZIP_OPT_PATH :
|
690 |
+
// PCLZIP_OPT_ADD_PATH :
|
691 |
+
// PCLZIP_OPT_REMOVE_PATH :
|
692 |
+
// PCLZIP_OPT_REMOVE_ALL_PATH :
|
693 |
+
// PCLZIP_CB_PRE_EXTRACT :
|
694 |
+
// PCLZIP_CB_POST_EXTRACT :
|
695 |
+
// Return Values :
|
696 |
+
// 0 or a negative value on failure,
|
697 |
+
// The list of the extracted files, with a status of the action.
|
698 |
+
// (see PclZip::listContent() for list entry format)
|
699 |
+
// --------------------------------------------------------------------------------
|
700 |
+
function extract()
|
701 |
+
{
|
702 |
+
$v_result=1;
|
703 |
+
|
704 |
+
// ----- Reset the error handler
|
705 |
+
$this->privErrorReset();
|
706 |
+
|
707 |
+
// ----- Check archive
|
708 |
+
if (!$this->privCheckFormat()) {
|
709 |
+
return(0);
|
710 |
+
}
|
711 |
+
|
712 |
+
// ----- Set default values
|
713 |
+
$v_options = array();
|
714 |
+
// $v_path = "./";
|
715 |
+
$v_path = '';
|
716 |
+
$v_remove_path = "";
|
717 |
+
$v_remove_all_path = false;
|
718 |
+
|
719 |
+
// ----- Look for variable options arguments
|
720 |
+
$v_size = func_num_args();
|
721 |
+
|
722 |
+
// ----- Default values for option
|
723 |
+
$v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
|
724 |
+
|
725 |
+
// ----- Look for arguments
|
726 |
+
if ($v_size > 0) {
|
727 |
+
// ----- Get the arguments
|
728 |
+
$v_arg_list = func_get_args();
|
729 |
+
|
730 |
+
// ----- Look for first arg
|
731 |
+
if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
|
732 |
+
|
733 |
+
// ----- Parse the options
|
734 |
+
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
|
735 |
+
array (PCLZIP_OPT_PATH => 'optional',
|
736 |
+
PCLZIP_OPT_REMOVE_PATH => 'optional',
|
737 |
+
PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
|
738 |
+
PCLZIP_OPT_ADD_PATH => 'optional',
|
739 |
+
PCLZIP_CB_PRE_EXTRACT => 'optional',
|
740 |
+
PCLZIP_CB_POST_EXTRACT => 'optional',
|
741 |
+
PCLZIP_OPT_SET_CHMOD => 'optional',
|
742 |
+
PCLZIP_OPT_BY_NAME => 'optional',
|
743 |
+
PCLZIP_OPT_BY_EREG => 'optional',
|
744 |
+
PCLZIP_OPT_BY_PREG => 'optional',
|
745 |
+
PCLZIP_OPT_BY_INDEX => 'optional',
|
746 |
+
PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
|
747 |
+
PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional',
|
748 |
+
PCLZIP_OPT_REPLACE_NEWER => 'optional'
|
749 |
+
,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
|
750 |
+
,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
|
751 |
+
PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
|
752 |
+
PCLZIP_OPT_TEMP_FILE_ON => 'optional',
|
753 |
+
PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
|
754 |
+
));
|
755 |
+
if ($v_result != 1) {
|
756 |
+
return 0;
|
757 |
+
}
|
758 |
+
|
759 |
+
// ----- Set the arguments
|
760 |
+
if (isset($v_options[PCLZIP_OPT_PATH])) {
|
761 |
+
$v_path = $v_options[PCLZIP_OPT_PATH];
|
762 |
+
}
|
763 |
+
if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
|
764 |
+
$v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
|
765 |
+
}
|
766 |
+
if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
|
767 |
+
$v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
|
768 |
+
}
|
769 |
+
if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
|
770 |
+
// ----- Check for '/' in last path char
|
771 |
+
if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
|
772 |
+
$v_path .= '/';
|
773 |
+
}
|
774 |
+
$v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
|
775 |
+
}
|
776 |
+
}
|
777 |
+
|
778 |
+
// ----- Look for 2 args
|
779 |
+
// Here we need to support the first historic synopsis of the
|
780 |
+
// method.
|
781 |
+
else {
|
782 |
+
|
783 |
+
// ----- Get the first argument
|
784 |
+
$v_path = $v_arg_list[0];
|
785 |
+
|
786 |
+
// ----- Look for the optional second argument
|
787 |
+
if ($v_size == 2) {
|
788 |
+
$v_remove_path = $v_arg_list[1];
|
789 |
+
}
|
790 |
+
else if ($v_size > 2) {
|
791 |
+
// ----- Error log
|
792 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
|
793 |
+
|
794 |
+
// ----- Return
|
795 |
+
return 0;
|
796 |
+
}
|
797 |
+
}
|
798 |
+
}
|
799 |
+
|
800 |
+
// ----- Look for default option values
|
801 |
+
$this->privOptionDefaultThreshold($v_options);
|
802 |
+
|
803 |
+
// ----- Trace
|
804 |
+
|
805 |
+
// ----- Call the extracting fct
|
806 |
+
$p_list = array();
|
807 |
+
$v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path,
|
808 |
+
$v_remove_all_path, $v_options);
|
809 |
+
if ($v_result < 1) {
|
810 |
+
unset($p_list);
|
811 |
+
return(0);
|
812 |
+
}
|
813 |
+
|
814 |
+
// ----- Return
|
815 |
+
return $p_list;
|
816 |
+
}
|
817 |
+
// --------------------------------------------------------------------------------
|
818 |
+
|
819 |
+
|
820 |
+
// --------------------------------------------------------------------------------
|
821 |
+
// Function :
|
822 |
+
// extractByIndex($p_index, $p_path="./", $p_remove_path="")
|
823 |
+
// extractByIndex($p_index, [$p_option, $p_option_value, ...])
|
824 |
+
// Description :
|
825 |
+
// This method supports two synopsis. The first one is historical.
|
826 |
+
// This method is doing a partial extract of the archive.
|
827 |
+
// The extracted files or folders are identified by their index in the
|
828 |
+
// archive (from 0 to n).
|
829 |
+
// Note that if the index identify a folder, only the folder entry is
|
830 |
+
// extracted, not all the files included in the archive.
|
831 |
+
// Parameters :
|
832 |
+
// $p_index : A single index (integer) or a string of indexes of files to
|
833 |
+
// extract. The form of the string is "0,4-6,8-12" with only numbers
|
834 |
+
// and '-' for range or ',' to separate ranges. No spaces or ';'
|
835 |
+
// are allowed.
|
836 |
+
// $p_path : Path where the files and directories are to be extracted
|
837 |
+
// $p_remove_path : First part ('root' part) of the memorized path
|
838 |
+
// (if any similar) to remove while extracting.
|
839 |
+
// Options :
|
840 |
+
// PCLZIP_OPT_PATH :
|
841 |
+
// PCLZIP_OPT_ADD_PATH :
|
842 |
+
// PCLZIP_OPT_REMOVE_PATH :
|
843 |
+
// PCLZIP_OPT_REMOVE_ALL_PATH :
|
844 |
+
// PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and
|
845 |
+
// not as files.
|
846 |
+
// The resulting content is in a new field 'content' in the file
|
847 |
+
// structure.
|
848 |
+
// This option must be used alone (any other options are ignored).
|
849 |
+
// PCLZIP_CB_PRE_EXTRACT :
|
850 |
+
// PCLZIP_CB_POST_EXTRACT :
|
851 |
+
// Return Values :
|
852 |
+
// 0 on failure,
|
853 |
+
// The list of the extracted files, with a status of the action.
|
854 |
+
// (see PclZip::listContent() for list entry format)
|
855 |
+
// --------------------------------------------------------------------------------
|
856 |
+
//function extractByIndex($p_index, options...)
|
857 |
+
function extractByIndex($p_index)
|
858 |
+
{
|
859 |
+
$v_result=1;
|
860 |
+
|
861 |
+
// ----- Reset the error handler
|
862 |
+
$this->privErrorReset();
|
863 |
+
|
864 |
+
// ----- Check archive
|
865 |
+
if (!$this->privCheckFormat()) {
|
866 |
+
return(0);
|
867 |
+
}
|
868 |
+
|
869 |
+
// ----- Set default values
|
870 |
+
$v_options = array();
|
871 |
+
// $v_path = "./";
|
872 |
+
$v_path = '';
|
873 |
+
$v_remove_path = "";
|
874 |
+
$v_remove_all_path = false;
|
875 |
+
|
876 |
+
// ----- Look for variable options arguments
|
877 |
+
$v_size = func_num_args();
|
878 |
+
|
879 |
+
// ----- Default values for option
|
880 |
+
$v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
|
881 |
+
|
882 |
+
// ----- Look for arguments
|
883 |
+
if ($v_size > 1) {
|
884 |
+
// ----- Get the arguments
|
885 |
+
$v_arg_list = func_get_args();
|
886 |
+
|
887 |
+
// ----- Remove form the options list the first argument
|
888 |
+
array_shift($v_arg_list);
|
889 |
+
$v_size--;
|
890 |
+
|
891 |
+
// ----- Look for first arg
|
892 |
+
if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
|
893 |
+
|
894 |
+
// ----- Parse the options
|
895 |
+
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
|
896 |
+
array (PCLZIP_OPT_PATH => 'optional',
|
897 |
+
PCLZIP_OPT_REMOVE_PATH => 'optional',
|
898 |
+
PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
|
899 |
+
PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
|
900 |
+
PCLZIP_OPT_ADD_PATH => 'optional',
|
901 |
+
PCLZIP_CB_PRE_EXTRACT => 'optional',
|
902 |
+
PCLZIP_CB_POST_EXTRACT => 'optional',
|
903 |
+
PCLZIP_OPT_SET_CHMOD => 'optional',
|
904 |
+
PCLZIP_OPT_REPLACE_NEWER => 'optional'
|
905 |
+
,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
|
906 |
+
,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
|
907 |
+
PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
|
908 |
+
PCLZIP_OPT_TEMP_FILE_ON => 'optional',
|
909 |
+
PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
|
910 |
+
));
|
911 |
+
if ($v_result != 1) {
|
912 |
+
return 0;
|
913 |
+
}
|
914 |
+
|
915 |
+
// ----- Set the arguments
|
916 |
+
if (isset($v_options[PCLZIP_OPT_PATH])) {
|
917 |
+
$v_path = $v_options[PCLZIP_OPT_PATH];
|
918 |
+
}
|
919 |
+
if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
|
920 |
+
$v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
|
921 |
+
}
|
922 |
+
if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
|
923 |
+
$v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
|
924 |
+
}
|
925 |
+
if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
|
926 |
+
// ----- Check for '/' in last path char
|
927 |
+
if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
|
928 |
+
$v_path .= '/';
|
929 |
+
}
|
930 |
+
$v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
|
931 |
+
}
|
932 |
+
if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
|
933 |
+
$v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
|
934 |
+
}
|
935 |
+
else {
|
936 |
+
}
|
937 |
+
}
|
938 |
+
|
939 |
+
// ----- Look for 2 args
|
940 |
+
// Here we need to support the first historic synopsis of the
|
941 |
+
// method.
|
942 |
+
else {
|
943 |
+
|
944 |
+
// ----- Get the first argument
|
945 |
+
$v_path = $v_arg_list[0];
|
946 |
+
|
947 |
+
// ----- Look for the optional second argument
|
948 |
+
if ($v_size == 2) {
|
949 |
+
$v_remove_path = $v_arg_list[1];
|
950 |
+
}
|
951 |
+
else if ($v_size > 2) {
|
952 |
+
// ----- Error log
|
953 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
|
954 |
+
|
955 |
+
// ----- Return
|
956 |
+
return 0;
|
957 |
+
}
|
958 |
+
}
|
959 |
+
}
|
960 |
+
|
961 |
+
// ----- Trace
|
962 |
+
|
963 |
+
// ----- Trick
|
964 |
+
// Here I want to reuse extractByRule(), so I need to parse the $p_index
|
965 |
+
// with privParseOptions()
|
966 |
+
$v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
|
967 |
+
$v_options_trick = array();
|
968 |
+
$v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
|
969 |
+
array (PCLZIP_OPT_BY_INDEX => 'optional' ));
|
970 |
+
if ($v_result != 1) {
|
971 |
+
return 0;
|
972 |
+
}
|
973 |
+
$v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
|
974 |
+
|
975 |
+
// ----- Look for default option values
|
976 |
+
$this->privOptionDefaultThreshold($v_options);
|
977 |
+
|
978 |
+
// ----- Call the extracting fct
|
979 |
+
if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
|
980 |
+
return(0);
|
981 |
+
}
|
982 |
+
|
983 |
+
// ----- Return
|
984 |
+
return $p_list;
|
985 |
+
}
|
986 |
+
// --------------------------------------------------------------------------------
|
987 |
+
|
988 |
+
// --------------------------------------------------------------------------------
|
989 |
+
// Function :
|
990 |
+
// delete([$p_option, $p_option_value, ...])
|
991 |
+
// Description :
|
992 |
+
// This method removes files from the archive.
|
993 |
+
// If no parameters are given, then all the archive is emptied.
|
994 |
+
// Parameters :
|
995 |
+
// None or optional arguments.
|
996 |
+
// Options :
|
997 |
+
// PCLZIP_OPT_BY_INDEX :
|
998 |
+
// PCLZIP_OPT_BY_NAME :
|
999 |
+
// PCLZIP_OPT_BY_EREG :
|
1000 |
+
// PCLZIP_OPT_BY_PREG :
|
1001 |
+
// Return Values :
|
1002 |
+
// 0 on failure,
|
1003 |
+
// The list of the files which are still present in the archive.
|
1004 |
+
// (see PclZip::listContent() for list entry format)
|
1005 |
+
// --------------------------------------------------------------------------------
|
1006 |
+
function delete()
|
1007 |
+
{
|
1008 |
+
$v_result=1;
|
1009 |
+
|
1010 |
+
// ----- Reset the error handler
|
1011 |
+
$this->privErrorReset();
|
1012 |
+
|
1013 |
+
// ----- Check archive
|
1014 |
+
if (!$this->privCheckFormat()) {
|
1015 |
+
return(0);
|
1016 |
+
}
|
1017 |
+
|
1018 |
+
// ----- Set default values
|
1019 |
+
$v_options = array();
|
1020 |
+
|
1021 |
+
// ----- Look for variable options arguments
|
1022 |
+
$v_size = func_num_args();
|
1023 |
+
|
1024 |
+
// ----- Look for arguments
|
1025 |
+
if ($v_size > 0) {
|
1026 |
+
// ----- Get the arguments
|
1027 |
+
$v_arg_list = func_get_args();
|
1028 |
+
|
1029 |
+
// ----- Parse the options
|
1030 |
+
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
|
1031 |
+
array (PCLZIP_OPT_BY_NAME => 'optional',
|
1032 |
+
PCLZIP_OPT_BY_EREG => 'optional',
|
1033 |
+
PCLZIP_OPT_BY_PREG => 'optional',
|
1034 |
+
PCLZIP_OPT_BY_INDEX => 'optional' ));
|
1035 |
+
if ($v_result != 1) {
|
1036 |
+
return 0;
|
1037 |
+
}
|
1038 |
+
}
|
1039 |
+
|
1040 |
+
// ----- Magic quotes trick
|
1041 |
+
$this->privDisableMagicQuotes();
|
1042 |
+
|
1043 |
+
// ----- Call the delete fct
|
1044 |
+
$v_list = array();
|
1045 |
+
if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
|
1046 |
+
$this->privSwapBackMagicQuotes();
|
1047 |
+
unset($v_list);
|
1048 |
+
return(0);
|
1049 |
+
}
|
1050 |
+
|
1051 |
+
// ----- Magic quotes trick
|
1052 |
+
$this->privSwapBackMagicQuotes();
|
1053 |
+
|
1054 |
+
// ----- Return
|
1055 |
+
return $v_list;
|
1056 |
+
}
|
1057 |
+
// --------------------------------------------------------------------------------
|
1058 |
+
|
1059 |
+
// --------------------------------------------------------------------------------
|
1060 |
+
// Function : deleteByIndex()
|
1061 |
+
// Description :
|
1062 |
+
// ***** Deprecated *****
|
1063 |
+
// delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered.
|
1064 |
+
// --------------------------------------------------------------------------------
|
1065 |
+
function deleteByIndex($p_index)
|
1066 |
+
{
|
1067 |
+
|
1068 |
+
$p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
|
1069 |
+
|
1070 |
+
// ----- Return
|
1071 |
+
return $p_list;
|
1072 |
+
}
|
1073 |
+
// --------------------------------------------------------------------------------
|
1074 |
+
|
1075 |
+
// --------------------------------------------------------------------------------
|
1076 |
+
// Function : properties()
|
1077 |
+
// Description :
|
1078 |
+
// This method gives the properties of the archive.
|
1079 |
+
// The properties are :
|
1080 |
+
// nb : Number of files in the archive
|
1081 |
+
// comment : Comment associated with the archive file
|
1082 |
+
// status : not_exist, ok
|
1083 |
+
// Parameters :
|
1084 |
+
// None
|
1085 |
+
// Return Values :
|
1086 |
+
// 0 on failure,
|
1087 |
+
// An array with the archive properties.
|
1088 |
+
// --------------------------------------------------------------------------------
|
1089 |
+
function properties()
|
1090 |
+
{
|
1091 |
+
|
1092 |
+
// ----- Reset the error handler
|
1093 |
+
$this->privErrorReset();
|
1094 |
+
|
1095 |
+
// ----- Magic quotes trick
|
1096 |
+
$this->privDisableMagicQuotes();
|
1097 |
+
|
1098 |
+
// ----- Check archive
|
1099 |
+
if (!$this->privCheckFormat()) {
|
1100 |
+
$this->privSwapBackMagicQuotes();
|
1101 |
+
return(0);
|
1102 |
+
}
|
1103 |
+
|
1104 |
+
// ----- Default properties
|
1105 |
+
$v_prop = array();
|
1106 |
+
$v_prop['comment'] = '';
|
1107 |
+
$v_prop['nb'] = 0;
|
1108 |
+
$v_prop['status'] = 'not_exist';
|
1109 |
+
|
1110 |
+
// ----- Look if file exists
|
1111 |
+
if (@is_file($this->zipname))
|
1112 |
+
{
|
1113 |
+
// ----- Open the zip file
|
1114 |
+
if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
|
1115 |
+
{
|
1116 |
+
$this->privSwapBackMagicQuotes();
|
1117 |
+
|
1118 |
+
// ----- Error log
|
1119 |
+
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
|
1120 |
+
|
1121 |
+
// ----- Return
|
1122 |
+
return 0;
|
1123 |
+
}
|
1124 |
+
|
1125 |
+
// ----- Read the central directory informations
|
1126 |
+
$v_central_dir = array();
|
1127 |
+
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
|
1128 |
+
{
|
1129 |
+
$this->privSwapBackMagicQuotes();
|
1130 |
+
return 0;
|
1131 |
+
}
|
1132 |
+
|
1133 |
+
// ----- Close the zip file
|
1134 |
+
$this->privCloseFd();
|
1135 |
+
|
1136 |
+
// ----- Set the user attributes
|
1137 |
+
$v_prop['comment'] = $v_central_dir['comment'];
|
1138 |
+
$v_prop['nb'] = $v_central_dir['entries'];
|
1139 |
+
$v_prop['status'] = 'ok';
|
1140 |
+
}
|
1141 |
+
|
1142 |
+
// ----- Magic quotes trick
|
1143 |
+
$this->privSwapBackMagicQuotes();
|
1144 |
+
|
1145 |
+
// ----- Return
|
1146 |
+
return $v_prop;
|
1147 |
+
}
|
1148 |
+
// --------------------------------------------------------------------------------
|
1149 |
+
|
1150 |
+
// --------------------------------------------------------------------------------
|
1151 |
+
// Function : duplicate()
|
1152 |
+
// Description :
|
1153 |
+
// This method creates an archive by copying the content of an other one. If
|
1154 |
+
// the archive already exist, it is replaced by the new one without any warning.
|
1155 |
+
// Parameters :
|
1156 |
+
// $p_archive : The filename of a valid archive, or
|
1157 |
+
// a valid PclZip object.
|
1158 |
+
// Return Values :
|
1159 |
+
// 1 on success.
|
1160 |
+
// 0 or a negative value on error (error code).
|
1161 |
+
// --------------------------------------------------------------------------------
|
1162 |
+
function duplicate($p_archive)
|
1163 |
+
{
|
1164 |
+
$v_result = 1;
|
1165 |
+
|
1166 |
+
// ----- Reset the error handler
|
1167 |
+
$this->privErrorReset();
|
1168 |
+
|
1169 |
+
// ----- Look if the $p_archive is a PclZip object
|
1170 |
+
if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
|
1171 |
+
{
|
1172 |
+
|
1173 |
+
// ----- Duplicate the archive
|
1174 |
+
$v_result = $this->privDuplicate($p_archive->zipname);
|
1175 |
+
}
|
1176 |
+
|
1177 |
+
// ----- Look if the $p_archive is a string (so a filename)
|
1178 |
+
else if (is_string($p_archive))
|
1179 |
+
{
|
1180 |
+
|
1181 |
+
// ----- Check that $p_archive is a valid zip file
|
1182 |
+
// TBC : Should also check the archive format
|
1183 |
+
if (!is_file($p_archive)) {
|
1184 |
+
// ----- Error log
|
1185 |
+
PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
|
1186 |
+
$v_result = PCLZIP_ERR_MISSING_FILE;
|
1187 |
+
}
|
1188 |
+
else {
|
1189 |
+
// ----- Duplicate the archive
|
1190 |
+
$v_result = $this->privDuplicate($p_archive);
|
1191 |
+
}
|
1192 |
+
}
|
1193 |
+
|
1194 |
+
// ----- Invalid variable
|
1195 |
+
else
|
1196 |
+
{
|
1197 |
+
// ----- Error log
|
1198 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
|
1199 |
+
$v_result = PCLZIP_ERR_INVALID_PARAMETER;
|
1200 |
+
}
|
1201 |
+
|
1202 |
+
// ----- Return
|
1203 |
+
return $v_result;
|
1204 |
+
}
|
1205 |
+
// --------------------------------------------------------------------------------
|
1206 |
+
|
1207 |
+
// --------------------------------------------------------------------------------
|
1208 |
+
// Function : merge()
|
1209 |
+
// Description :
|
1210 |
+
// This method merge the $p_archive_to_add archive at the end of the current
|
1211 |
+
// one ($this).
|
1212 |
+
// If the archive ($this) does not exist, the merge becomes a duplicate.
|
1213 |
+
// If the $p_archive_to_add archive does not exist, the merge is a success.
|
1214 |
+
// Parameters :
|
1215 |
+
// $p_archive_to_add : It can be directly the filename of a valid zip archive,
|
1216 |
+
// or a PclZip object archive.
|
1217 |
+
// Return Values :
|
1218 |
+
// 1 on success,
|
1219 |
+
// 0 or negative values on error (see below).
|
1220 |
+
// --------------------------------------------------------------------------------
|
1221 |
+
function merge($p_archive_to_add)
|
1222 |
+
{
|
1223 |
+
$v_result = 1;
|
1224 |
+
|
1225 |
+
// ----- Reset the error handler
|
1226 |
+
$this->privErrorReset();
|
1227 |
+
|
1228 |
+
// ----- Check archive
|
1229 |
+
if (!$this->privCheckFormat()) {
|
1230 |
+
return(0);
|
1231 |
+
}
|
1232 |
+
|
1233 |
+
// ----- Look if the $p_archive_to_add is a PclZip object
|
1234 |
+
if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
|
1235 |
+
{
|
1236 |
+
|
1237 |
+
// ----- Merge the archive
|
1238 |
+
$v_result = $this->privMerge($p_archive_to_add);
|
1239 |
+
}
|
1240 |
+
|
1241 |
+
// ----- Look if the $p_archive_to_add is a string (so a filename)
|
1242 |
+
else if (is_string($p_archive_to_add))
|
1243 |
+
{
|
1244 |
+
|
1245 |
+
// ----- Create a temporary archive
|
1246 |
+
$v_object_archive = new PclZip($p_archive_to_add);
|
1247 |
+
|
1248 |
+
// ----- Merge the archive
|
1249 |
+
$v_result = $this->privMerge($v_object_archive);
|
1250 |
+
}
|
1251 |
+
|
1252 |
+
// ----- Invalid variable
|
1253 |
+
else
|
1254 |
+
{
|
1255 |
+
// ----- Error log
|
1256 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
|
1257 |
+
$v_result = PCLZIP_ERR_INVALID_PARAMETER;
|
1258 |
+
}
|
1259 |
+
|
1260 |
+
// ----- Return
|
1261 |
+
return $v_result;
|
1262 |
+
}
|
1263 |
+
// --------------------------------------------------------------------------------
|
1264 |
+
|
1265 |
+
|
1266 |
+
|
1267 |
+
// --------------------------------------------------------------------------------
|
1268 |
+
// Function : errorCode()
|
1269 |
+
// Description :
|
1270 |
+
// Parameters :
|
1271 |
+
// --------------------------------------------------------------------------------
|
1272 |
+
function errorCode()
|
1273 |
+
{
|
1274 |
+
if (PCLZIP_ERROR_EXTERNAL == 1) {
|
1275 |
+
return(PclErrorCode());
|
1276 |
+
}
|
1277 |
+
else {
|
1278 |
+
return($this->error_code);
|
1279 |
+
}
|
1280 |
+
}
|
1281 |
+
// --------------------------------------------------------------------------------
|
1282 |
+
|
1283 |
+
// --------------------------------------------------------------------------------
|
1284 |
+
// Function : errorName()
|
1285 |
+
// Description :
|
1286 |
+
// Parameters :
|
1287 |
+
// --------------------------------------------------------------------------------
|
1288 |
+
function errorName($p_with_code=false)
|
1289 |
+
{
|
1290 |
+
$v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
|
1291 |
+
PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
|
1292 |
+
PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
|
1293 |
+
PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
|
1294 |
+
PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',
|
1295 |
+
PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',
|
1296 |
+
PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',
|
1297 |
+
PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',
|
1298 |
+
PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',
|
1299 |
+
PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',
|
1300 |
+
PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',
|
1301 |
+
PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',
|
1302 |
+
PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',
|
1303 |
+
PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',
|
1304 |
+
PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
|
1305 |
+
PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',
|
1306 |
+
PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE',
|
1307 |
+
PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION',
|
1308 |
+
PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION'
|
1309 |
+
,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE'
|
1310 |
+
,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION'
|
1311 |
+
);
|
1312 |
+
|
1313 |
+
if (isset($v_name[$this->error_code])) {
|
1314 |
+
$v_value = $v_name[$this->error_code];
|
1315 |
+
}
|
1316 |
+
else {
|
1317 |
+
$v_value = 'NoName';
|
1318 |
+
}
|
1319 |
+
|
1320 |
+
if ($p_with_code) {
|
1321 |
+
return($v_value.' ('.$this->error_code.')');
|
1322 |
+
}
|
1323 |
+
else {
|
1324 |
+
return($v_value);
|
1325 |
+
}
|
1326 |
+
}
|
1327 |
+
// --------------------------------------------------------------------------------
|
1328 |
+
|
1329 |
+
// --------------------------------------------------------------------------------
|
1330 |
+
// Function : errorInfo()
|
1331 |
+
// Description :
|
1332 |
+
// Parameters :
|
1333 |
+
// --------------------------------------------------------------------------------
|
1334 |
+
function errorInfo($p_full=false)
|
1335 |
+
{
|
1336 |
+
if (PCLZIP_ERROR_EXTERNAL == 1) {
|
1337 |
+
return(PclErrorString());
|
1338 |
+
}
|
1339 |
+
else {
|
1340 |
+
if ($p_full) {
|
1341 |
+
return($this->errorName(true)." : ".$this->error_string);
|
1342 |
+
}
|
1343 |
+
else {
|
1344 |
+
return($this->error_string." [code ".$this->error_code."]");
|
1345 |
+
}
|
1346 |
+
}
|
1347 |
+
}
|
1348 |
+
// --------------------------------------------------------------------------------
|
1349 |
+
|
1350 |
+
|
1351 |
+
// --------------------------------------------------------------------------------
|
1352 |
+
// ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS *****
|
1353 |
+
// ***** *****
|
1354 |
+
// ***** THESES FUNCTIONS MUST NOT BE USED DIRECTLY *****
|
1355 |
+
// --------------------------------------------------------------------------------
|
1356 |
+
|
1357 |
+
|
1358 |
+
|
1359 |
+
// --------------------------------------------------------------------------------
|
1360 |
+
// Function : privCheckFormat()
|
1361 |
+
// Description :
|
1362 |
+
// This method check that the archive exists and is a valid zip archive.
|
1363 |
+
// Several level of check exists. (futur)
|
1364 |
+
// Parameters :
|
1365 |
+
// $p_level : Level of check. Default 0.
|
1366 |
+
// 0 : Check the first bytes (magic codes) (default value))
|
1367 |
+
// 1 : 0 + Check the central directory (futur)
|
1368 |
+
// 2 : 1 + Check each file header (futur)
|
1369 |
+
// Return Values :
|
1370 |
+
// true on success,
|
1371 |
+
// false on error, the error code is set.
|
1372 |
+
// --------------------------------------------------------------------------------
|
1373 |
+
function privCheckFormat($p_level=0)
|
1374 |
+
{
|
1375 |
+
$v_result = true;
|
1376 |
+
|
1377 |
+
// ----- Reset the file system cache
|
1378 |
+
clearstatcache();
|
1379 |
+
|
1380 |
+
// ----- Reset the error handler
|
1381 |
+
$this->privErrorReset();
|
1382 |
+
|
1383 |
+
// ----- Look if the file exits
|
1384 |
+
if (!is_file($this->zipname)) {
|
1385 |
+
// ----- Error log
|
1386 |
+
PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
|
1387 |
+
return(false);
|
1388 |
+
}
|
1389 |
+
|
1390 |
+
// ----- Check that the file is readeable
|
1391 |
+
if (!is_readable($this->zipname)) {
|
1392 |
+
// ----- Error log
|
1393 |
+
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
|
1394 |
+
return(false);
|
1395 |
+
}
|
1396 |
+
|
1397 |
+
// ----- Check the magic code
|
1398 |
+
// TBC
|
1399 |
+
|
1400 |
+
// ----- Check the central header
|
1401 |
+
// TBC
|
1402 |
+
|
1403 |
+
// ----- Check each file header
|
1404 |
+
// TBC
|
1405 |
+
|
1406 |
+
// ----- Return
|
1407 |
+
return $v_result;
|
1408 |
+
}
|
1409 |
+
// --------------------------------------------------------------------------------
|
1410 |
+
|
1411 |
+
// --------------------------------------------------------------------------------
|
1412 |
+
// Function : privParseOptions()
|
1413 |
+
// Description :
|
1414 |
+
// This internal methods reads the variable list of arguments ($p_options_list,
|
1415 |
+
// $p_size) and generate an array with the options and values ($v_result_list).
|
1416 |
+
// $v_requested_options contains the options that can be present and those that
|
1417 |
+
// must be present.
|
1418 |
+
// $v_requested_options is an array, with the option value as key, and 'optional',
|
1419 |
+
// or 'mandatory' as value.
|
1420 |
+
// Parameters :
|
1421 |
+
// See above.
|
1422 |
+
// Return Values :
|
1423 |
+
// 1 on success.
|
1424 |
+
// 0 on failure.
|
1425 |
+
// --------------------------------------------------------------------------------
|
1426 |
+
function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
|
1427 |
+
{
|
1428 |
+
$v_result=1;
|
1429 |
+
|
1430 |
+
// ----- Read the options
|
1431 |
+
$i=0;
|
1432 |
+
while ($i<$p_size) {
|
1433 |
+
|
1434 |
+
// ----- Check if the option is supported
|
1435 |
+
if (!isset($v_requested_options[$p_options_list[$i]])) {
|
1436 |
+
// ----- Error log
|
1437 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
|
1438 |
+
|
1439 |
+
// ----- Return
|
1440 |
+
return PclZip::errorCode();
|
1441 |
+
}
|
1442 |
+
|
1443 |
+
// ----- Look for next option
|
1444 |
+
switch ($p_options_list[$i]) {
|
1445 |
+
// ----- Look for options that request a path value
|
1446 |
+
case PCLZIP_OPT_PATH :
|
1447 |
+
case PCLZIP_OPT_REMOVE_PATH :
|
1448 |
+
case PCLZIP_OPT_ADD_PATH :
|
1449 |
+
// ----- Check the number of parameters
|
1450 |
+
if (($i+1) >= $p_size) {
|
1451 |
+
// ----- Error log
|
1452 |
+
PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
|
1453 |
+
|
1454 |
+
// ----- Return
|
1455 |
+
return PclZip::errorCode();
|
1456 |
+
}
|
1457 |
+
|
1458 |
+
// ----- Get the value
|
1459 |
+
$v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
|
1460 |
+
$i++;
|
1461 |
+
break;
|
1462 |
+
|
1463 |
+
case PCLZIP_OPT_TEMP_FILE_THRESHOLD :
|
1464 |
+
// ----- Check the number of parameters
|
1465 |
+
if (($i+1) >= $p_size) {
|
1466 |
+
PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
|
1467 |
+
return PclZip::errorCode();
|
1468 |
+
}
|
1469 |
+
|
1470 |
+
// ----- Check for incompatible options
|
1471 |
+
if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
|
1472 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
|
1473 |
+
return PclZip::errorCode();
|
1474 |
+
}
|
1475 |
+
|
1476 |
+
// ----- Check the value
|
1477 |
+
$v_value = $p_options_list[$i+1];
|
1478 |
+
if ((!is_integer($v_value)) || ($v_value<0)) {
|
1479 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'");
|
1480 |
+
return PclZip::errorCode();
|
1481 |
+
}
|
1482 |
+
|
1483 |
+
// ----- Get the value (and convert it in bytes)
|
1484 |
+
$v_result_list[$p_options_list[$i]] = $v_value*1048576;
|
1485 |
+
$i++;
|
1486 |
+
break;
|
1487 |
+
|
1488 |
+
case PCLZIP_OPT_TEMP_FILE_ON :
|
1489 |
+
// ----- Check for incompatible options
|
1490 |
+
if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
|
1491 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
|
1492 |
+
return PclZip::errorCode();
|
1493 |
+
}
|
1494 |
+
|
1495 |
+
$v_result_list[$p_options_list[$i]] = true;
|
1496 |
+
break;
|
1497 |
+
|
1498 |
+
case PCLZIP_OPT_TEMP_FILE_OFF :
|
1499 |
+
// ----- Check for incompatible options
|
1500 |
+
if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) {
|
1501 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'");
|
1502 |
+
return PclZip::errorCode();
|
1503 |
+
}
|
1504 |
+
// ----- Check for incompatible options
|
1505 |
+
if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
|
1506 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
|
1507 |
+
return PclZip::errorCode();
|
1508 |
+
}
|
1509 |
+
|
1510 |
+
$v_result_list[$p_options_list[$i]] = true;
|
1511 |
+
break;
|
1512 |
+
|
1513 |
+
case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
|
1514 |
+
// ----- Check the number of parameters
|
1515 |
+
if (($i+1) >= $p_size) {
|
1516 |
+
// ----- Error log
|
1517 |
+
PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
|
1518 |
+
|
1519 |
+
// ----- Return
|
1520 |
+
return PclZip::errorCode();
|
1521 |
+
}
|
1522 |
+
|
1523 |
+
// ----- Get the value
|
1524 |
+
if ( is_string($p_options_list[$i+1])
|
1525 |
+
&& ($p_options_list[$i+1] != '')) {
|
1526 |
+
$v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
|
1527 |
+
$i++;
|
1528 |
+
}
|
1529 |
+
else {
|
1530 |
+
}
|
1531 |
+
break;
|
1532 |
+
|
1533 |
+
// ----- Look for options that request an array of string for value
|
1534 |
+
case PCLZIP_OPT_BY_NAME :
|
1535 |
+
// ----- Check the number of parameters
|
1536 |
+
if (($i+1) >= $p_size) {
|
1537 |
+
// ----- Error log
|
1538 |
+
PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
|
1539 |
+
|
1540 |
+
// ----- Return
|
1541 |
+
return PclZip::errorCode();
|
1542 |
+
}
|
1543 |
+
|
1544 |
+
// ----- Get the value
|
1545 |
+
if (is_string($p_options_list[$i+1])) {
|
1546 |
+
$v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
|
1547 |
+
}
|
1548 |
+
else if (is_array($p_options_list[$i+1])) {
|
1549 |
+
$v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
|
1550 |
+
}
|
1551 |
+
else {
|
1552 |
+
// ----- Error log
|
1553 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
|
1554 |
+
|
1555 |
+
// ----- Return
|
1556 |
+
return PclZip::errorCode();
|
1557 |
+
}
|
1558 |
+
$i++;
|
1559 |
+
break;
|
1560 |
+
|
1561 |
+
// ----- Look for options that request an EREG or PREG expression
|
1562 |
+
case PCLZIP_OPT_BY_EREG :
|
1563 |
+
// ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG
|
1564 |
+
// to PCLZIP_OPT_BY_PREG
|
1565 |
+
$p_options_list[$i] = PCLZIP_OPT_BY_PREG;
|
1566 |
+
case PCLZIP_OPT_BY_PREG :
|
1567 |
+
//case PCLZIP_OPT_CRYPT :
|
1568 |
+
// ----- Check the number of parameters
|
1569 |
+
if (($i+1) >= $p_size) {
|
1570 |
+
// ----- Error log
|
1571 |
+
PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
|
1572 |
+
|
1573 |
+
// ----- Return
|
1574 |
+
return PclZip::errorCode();
|
1575 |
+
}
|
1576 |
+
|
1577 |
+
// ----- Get the value
|
1578 |
+
if (is_string($p_options_list[$i+1])) {
|
1579 |
+
$v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
|
1580 |
+
}
|
1581 |
+
else {
|
1582 |
+
// ----- Error log
|
1583 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
|
1584 |
+
|
1585 |
+
// ----- Return
|
1586 |
+
return PclZip::errorCode();
|
1587 |
+
}
|
1588 |
+
$i++;
|
1589 |
+
break;
|
1590 |
+
|
1591 |
+
// ----- Look for options that takes a string
|
1592 |
+
case PCLZIP_OPT_COMMENT :
|
1593 |
+
case PCLZIP_OPT_ADD_COMMENT :
|
1594 |
+
case PCLZIP_OPT_PREPEND_COMMENT :
|
1595 |
+
// ----- Check the number of parameters
|
1596 |
+
if (($i+1) >= $p_size) {
|
1597 |
+
// ----- Error log
|
1598 |
+
PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE,
|
1599 |
+
"Missing parameter value for option '"
|
1600 |
+
.PclZipUtilOptionText($p_options_list[$i])
|
1601 |
+
."'");
|
1602 |
+
|
1603 |
+
// ----- Return
|
1604 |
+
return PclZip::errorCode();
|
1605 |
+
}
|
1606 |
+
|
1607 |
+
// ----- Get the value
|
1608 |
+
if (is_string($p_options_list[$i+1])) {
|
1609 |
+
$v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
|
1610 |
+
}
|
1611 |
+
else {
|
1612 |
+
// ----- Error log
|
1613 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE,
|
1614 |
+
"Wrong parameter value for option '"
|
1615 |
+
.PclZipUtilOptionText($p_options_list[$i])
|
1616 |
+
."'");
|
1617 |
+
|
1618 |
+
// ----- Return
|
1619 |
+
return PclZip::errorCode();
|
1620 |
+
}
|
1621 |
+
$i++;
|
1622 |
+
break;
|
1623 |
+
|
1624 |
+
// ----- Look for options that request an array of index
|
1625 |
+
case PCLZIP_OPT_BY_INDEX :
|
1626 |
+
// ----- Check the number of parameters
|
1627 |
+
if (($i+1) >= $p_size) {
|
1628 |
+
// ----- Error log
|
1629 |
+
PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
|
1630 |
+
|
1631 |
+
// ----- Return
|
1632 |
+
return PclZip::errorCode();
|
1633 |
+
}
|
1634 |
+
|
1635 |
+
// ----- Get the value
|
1636 |
+
$v_work_list = array();
|
1637 |
+
if (is_string($p_options_list[$i+1])) {
|
1638 |
+
|
1639 |
+
// ----- Remove spaces
|
1640 |
+
$p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
|
1641 |
+
|
1642 |
+
// ----- Parse items
|
1643 |
+
$v_work_list = explode(",", $p_options_list[$i+1]);
|
1644 |
+
}
|
1645 |
+
else if (is_integer($p_options_list[$i+1])) {
|
1646 |
+
$v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
|
1647 |
+
}
|
1648 |
+
else if (is_array($p_options_list[$i+1])) {
|
1649 |
+
$v_work_list = $p_options_list[$i+1];
|
1650 |
+
}
|
1651 |
+
else {
|
1652 |
+
// ----- Error log
|
1653 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
|
1654 |
+
|
1655 |
+
// ----- Return
|
1656 |
+
return PclZip::errorCode();
|
1657 |
+
}
|
1658 |
+
|
1659 |
+
// ----- Reduce the index list
|
1660 |
+
// each index item in the list must be a couple with a start and
|
1661 |
+
// an end value : [0,3], [5-5], [8-10], ...
|
1662 |
+
// ----- Check the format of each item
|
1663 |
+
$v_sort_flag=false;
|
1664 |
+
$v_sort_value=0;
|
1665 |
+
for ($j=0; $j<sizeof($v_work_list); $j++) {
|
1666 |
+
// ----- Explode the item
|
1667 |
+
$v_item_list = explode("-", $v_work_list[$j]);
|
1668 |
+
$v_size_item_list = sizeof($v_item_list);
|
1669 |
+
|
1670 |
+
// ----- TBC : Here we might check that each item is a
|
1671 |
+
// real integer ...
|
1672 |
+
|
1673 |
+
// ----- Look for single value
|
1674 |
+
if ($v_size_item_list == 1) {
|
1675 |
+
// ----- Set the option value
|
1676 |
+
$v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
|
1677 |
+
$v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];
|
1678 |
+
}
|
1679 |
+
elseif ($v_size_item_list == 2) {
|
1680 |
+
// ----- Set the option value
|
1681 |
+
$v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
|
1682 |
+
$v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];
|
1683 |
+
}
|
1684 |
+
else {
|
1685 |
+
// ----- Error log
|
1686 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
|
1687 |
+
|
1688 |
+
// ----- Return
|
1689 |
+
return PclZip::errorCode();
|
1690 |
+
}
|
1691 |
+
|
1692 |
+
|
1693 |
+
// ----- Look for list sort
|
1694 |
+
if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
|
1695 |
+
$v_sort_flag=true;
|
1696 |
+
|
1697 |
+
// ----- TBC : An automatic sort should be writen ...
|
1698 |
+
// ----- Error log
|
1699 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
|
1700 |
+
|
1701 |
+
// ----- Return
|
1702 |
+
return PclZip::errorCode();
|
1703 |
+
}
|
1704 |
+
$v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
|
1705 |
+
}
|
1706 |
+
|
1707 |
+
// ----- Sort the items
|
1708 |
+
if ($v_sort_flag) {
|
1709 |
+
// TBC : To Be Completed
|
1710 |
+
}
|
1711 |
+
|
1712 |
+
// ----- Next option
|
1713 |
+
$i++;
|
1714 |
+
break;
|
1715 |
+
|
1716 |
+
// ----- Look for options that request no value
|
1717 |
+
case PCLZIP_OPT_REMOVE_ALL_PATH :
|
1718 |
+
case PCLZIP_OPT_EXTRACT_AS_STRING :
|
1719 |
+
case PCLZIP_OPT_NO_COMPRESSION :
|
1720 |
+
case PCLZIP_OPT_EXTRACT_IN_OUTPUT :
|
1721 |
+
case PCLZIP_OPT_REPLACE_NEWER :
|
1722 |
+
case PCLZIP_OPT_STOP_ON_ERROR :
|
1723 |
+
$v_result_list[$p_options_list[$i]] = true;
|
1724 |
+
break;
|
1725 |
+
|
1726 |
+
// ----- Look for options that request an octal value
|
1727 |
+
case PCLZIP_OPT_SET_CHMOD :
|
1728 |
+
// ----- Check the number of parameters
|
1729 |
+
if (($i+1) >= $p_size) {
|
1730 |
+
// ----- Error log
|
1731 |
+
PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
|
1732 |
+
|
1733 |
+
// ----- Return
|
1734 |
+
return PclZip::errorCode();
|
1735 |
+
}
|
1736 |
+
|
1737 |
+
// ----- Get the value
|
1738 |
+
$v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
|
1739 |
+
$i++;
|
1740 |
+
break;
|
1741 |
+
|
1742 |
+
// ----- Look for options that request a call-back
|
1743 |
+
case PCLZIP_CB_PRE_EXTRACT :
|
1744 |
+
case PCLZIP_CB_POST_EXTRACT :
|
1745 |
+
case PCLZIP_CB_PRE_ADD :
|
1746 |
+
case PCLZIP_CB_POST_ADD :
|
1747 |
+
/* for futur use
|
1748 |
+
case PCLZIP_CB_PRE_DELETE :
|
1749 |
+
case PCLZIP_CB_POST_DELETE :
|
1750 |
+
case PCLZIP_CB_PRE_LIST :
|
1751 |
+
case PCLZIP_CB_POST_LIST :
|
1752 |
+
*/
|
1753 |
+
// ----- Check the number of parameters
|
1754 |
+
if (($i+1) >= $p_size) {
|
1755 |
+
// ----- Error log
|
1756 |
+
PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
|
1757 |
+
|
1758 |
+
// ----- Return
|
1759 |
+
return PclZip::errorCode();
|
1760 |
+
}
|
1761 |
+
|
1762 |
+
// ----- Get the value
|
1763 |
+
$v_function_name = $p_options_list[$i+1];
|
1764 |
+
|
1765 |
+
// ----- Check that the value is a valid existing function
|
1766 |
+
if (!function_exists($v_function_name)) {
|
1767 |
+
// ----- Error log
|
1768 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
|
1769 |
+
|
1770 |
+
// ----- Return
|
1771 |
+
return PclZip::errorCode();
|
1772 |
+
}
|
1773 |
+
|
1774 |
+
// ----- Set the attribute
|
1775 |
+
$v_result_list[$p_options_list[$i]] = $v_function_name;
|
1776 |
+
$i++;
|
1777 |
+
break;
|
1778 |
+
|
1779 |
+
default :
|
1780 |
+
// ----- Error log
|
1781 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
|
1782 |
+
"Unknown parameter '"
|
1783 |
+
.$p_options_list[$i]."'");
|
1784 |
+
|
1785 |
+
// ----- Return
|
1786 |
+
return PclZip::errorCode();
|
1787 |
+
}
|
1788 |
+
|
1789 |
+
// ----- Next options
|
1790 |
+
$i++;
|
1791 |
+
}
|
1792 |
+
|
1793 |
+
// ----- Look for mandatory options
|
1794 |
+
if ($v_requested_options !== false) {
|
1795 |
+
for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
|
1796 |
+
// ----- Look for mandatory option
|
1797 |
+
if ($v_requested_options[$key] == 'mandatory') {
|
1798 |
+
// ----- Look if present
|
1799 |
+
if (!isset($v_result_list[$key])) {
|
1800 |
+
// ----- Error log
|
1801 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
|
1802 |
+
|
1803 |
+
// ----- Return
|
1804 |
+
return PclZip::errorCode();
|
1805 |
+
}
|
1806 |
+
}
|
1807 |
+
}
|
1808 |
+
}
|
1809 |
+
|
1810 |
+
// ----- Look for default values
|
1811 |
+
if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
|
1812 |
+
|
1813 |
+
}
|
1814 |
+
|
1815 |
+
// ----- Return
|
1816 |
+
return $v_result;
|
1817 |
+
}
|
1818 |
+
// --------------------------------------------------------------------------------
|
1819 |
+
|
1820 |
+
// --------------------------------------------------------------------------------
|
1821 |
+
// Function : privOptionDefaultThreshold()
|
1822 |
+
// Description :
|
1823 |
+
// Parameters :
|
1824 |
+
// Return Values :
|
1825 |
+
// --------------------------------------------------------------------------------
|
1826 |
+
function privOptionDefaultThreshold(&$p_options)
|
1827 |
+
{
|
1828 |
+
$v_result=1;
|
1829 |
+
|
1830 |
+
if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
|
1831 |
+
|| isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
|
1832 |
+
return $v_result;
|
1833 |
+
}
|
1834 |
+
|
1835 |
+
// ----- Get 'memory_limit' configuration value
|
1836 |
+
$v_memory_limit = ini_get('memory_limit');
|
1837 |
+
$v_memory_limit = trim($v_memory_limit);
|
1838 |
+
$last = strtolower(substr($v_memory_limit, -1));
|
1839 |
+
|
1840 |
+
if($last == 'g')
|
1841 |
+
//$v_memory_limit = $v_memory_limit*1024*1024*1024;
|
1842 |
+
$v_memory_limit = $v_memory_limit*1073741824;
|
1843 |
+
if($last == 'm')
|
1844 |
+
//$v_memory_limit = $v_memory_limit*1024*1024;
|
1845 |
+
$v_memory_limit = $v_memory_limit*1048576;
|
1846 |
+
if($last == 'k')
|
1847 |
+
$v_memory_limit = $v_memory_limit*1024;
|
1848 |
+
|
1849 |
+
$p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
|
1850 |
+
|
1851 |
+
|
1852 |
+
// ----- Sanity check : No threshold if value lower than 1M
|
1853 |
+
if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
|
1854 |
+
unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
|
1855 |
+
}
|
1856 |
+
|
1857 |
+
// ----- Return
|
1858 |
+
return $v_result;
|
1859 |
+
}
|
1860 |
+
// --------------------------------------------------------------------------------
|
1861 |
+
|
1862 |
+
// --------------------------------------------------------------------------------
|
1863 |
+
// Function : privFileDescrParseAtt()
|
1864 |
+
// Description :
|
1865 |
+
// Parameters :
|
1866 |
+
// Return Values :
|
1867 |
+
// 1 on success.
|
1868 |
+
// 0 on failure.
|
1869 |
+
// --------------------------------------------------------------------------------
|
1870 |
+
function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
|
1871 |
+
{
|
1872 |
+
$v_result=1;
|
1873 |
+
|
1874 |
+
// ----- For each file in the list check the attributes
|
1875 |
+
foreach ($p_file_list as $v_key => $v_value) {
|
1876 |
+
|
1877 |
+
// ----- Check if the option is supported
|
1878 |
+
if (!isset($v_requested_options[$v_key])) {
|
1879 |
+
// ----- Error log
|
1880 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
|
1881 |
+
|
1882 |
+
// ----- Return
|
1883 |
+
return PclZip::errorCode();
|
1884 |
+
}
|
1885 |
+
|
1886 |
+
// ----- Look for attribute
|
1887 |
+
switch ($v_key) {
|
1888 |
+
case PCLZIP_ATT_FILE_NAME :
|
1889 |
+
if (!is_string($v_value)) {
|
1890 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
|
1891 |
+
return PclZip::errorCode();
|
1892 |
+
}
|
1893 |
+
|
1894 |
+
$p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
|
1895 |
+
|
1896 |
+
if ($p_filedescr['filename'] == '') {
|
1897 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'");
|
1898 |
+
return PclZip::errorCode();
|
1899 |
+
}
|
1900 |
+
|
1901 |
+
break;
|
1902 |
+
|
1903 |
+
case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
|
1904 |
+
if (!is_string($v_value)) {
|
1905 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
|
1906 |
+
return PclZip::errorCode();
|
1907 |
+
}
|
1908 |
+
|
1909 |
+
$p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
|
1910 |
+
|
1911 |
+
if ($p_filedescr['new_short_name'] == '') {
|
1912 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'");
|
1913 |
+
return PclZip::errorCode();
|
1914 |
+
}
|
1915 |
+
break;
|
1916 |
+
|
1917 |
+
case PCLZIP_ATT_FILE_NEW_FULL_NAME :
|
1918 |
+
if (!is_string($v_value)) {
|
1919 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
|
1920 |
+
return PclZip::errorCode();
|
1921 |
+
}
|
1922 |
+
|
1923 |
+
$p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
|
1924 |
+
|
1925 |
+
if ($p_filedescr['new_full_name'] == '') {
|
1926 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'");
|
1927 |
+
return PclZip::errorCode();
|
1928 |
+
}
|
1929 |
+
break;
|
1930 |
+
|
1931 |
+
// ----- Look for options that takes a string
|
1932 |
+
case PCLZIP_ATT_FILE_COMMENT :
|
1933 |
+
if (!is_string($v_value)) {
|
1934 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
|
1935 |
+
return PclZip::errorCode();
|
1936 |
+
}
|
1937 |
+
|
1938 |
+
$p_filedescr['comment'] = $v_value;
|
1939 |
+
break;
|
1940 |
+
|
1941 |
+
case PCLZIP_ATT_FILE_MTIME :
|
1942 |
+
if (!is_integer($v_value)) {
|
1943 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'");
|
1944 |
+
return PclZip::errorCode();
|
1945 |
+
}
|
1946 |
+
|
1947 |
+
$p_filedescr['mtime'] = $v_value;
|
1948 |
+
break;
|
1949 |
+
|
1950 |
+
case PCLZIP_ATT_FILE_CONTENT :
|
1951 |
+
$p_filedescr['content'] = $v_value;
|
1952 |
+
break;
|
1953 |
+
|
1954 |
+
default :
|
1955 |
+
// ----- Error log
|
1956 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
|
1957 |
+
"Unknown parameter '".$v_key."'");
|
1958 |
+
|
1959 |
+
// ----- Return
|
1960 |
+
return PclZip::errorCode();
|
1961 |
+
}
|
1962 |
+
|
1963 |
+
// ----- Look for mandatory options
|
1964 |
+
if ($v_requested_options !== false) {
|
1965 |
+
for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
|
1966 |
+
// ----- Look for mandatory option
|
1967 |
+
if ($v_requested_options[$key] == 'mandatory') {
|
1968 |
+
// ----- Look if present
|
1969 |
+
if (!isset($p_file_list[$key])) {
|
1970 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
|
1971 |
+
return PclZip::errorCode();
|
1972 |
+
}
|
1973 |
+
}
|
1974 |
+
}
|
1975 |
+
}
|
1976 |
+
|
1977 |
+
// end foreach
|
1978 |
+
}
|
1979 |
+
|
1980 |
+
// ----- Return
|
1981 |
+
return $v_result;
|
1982 |
+
}
|
1983 |
+
// --------------------------------------------------------------------------------
|
1984 |
+
|
1985 |
+
// --------------------------------------------------------------------------------
|
1986 |
+
// Function : privFileDescrExpand()
|
1987 |
+
// Description :
|
1988 |
+
// This method look for each item of the list to see if its a file, a folder
|
1989 |
+
// or a string to be added as file. For any other type of files (link, other)
|
1990 |
+
// just ignore the item.
|
1991 |
+
// Then prepare the information that will be stored for that file.
|
1992 |
+
// When its a folder, expand the folder with all the files that are in that
|
1993 |
+
// folder (recursively).
|
1994 |
+
// Parameters :
|
1995 |
+
// Return Values :
|
1996 |
+
// 1 on success.
|
1997 |
+
// 0 on failure.
|
1998 |
+
// --------------------------------------------------------------------------------
|
1999 |
+
function privFileDescrExpand(&$p_filedescr_list, &$p_options)
|
2000 |
+
{
|
2001 |
+
$v_result=1;
|
2002 |
+
|
2003 |
+
// ----- Create a result list
|
2004 |
+
$v_result_list = array();
|
2005 |
+
|
2006 |
+
// ----- Look each entry
|
2007 |
+
for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
|
2008 |
+
|
2009 |
+
// ----- Get filedescr
|
2010 |
+
$v_descr = $p_filedescr_list[$i];
|
2011 |
+
|
2012 |
+
// ----- Reduce the filename
|
2013 |
+
$v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false);
|
2014 |
+
$v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
|
2015 |
+
|
2016 |
+
// ----- Look for real file or folder
|
2017 |
+
if (file_exists($v_descr['filename'])) {
|
2018 |
+
if (@is_file($v_descr['filename'])) {
|
2019 |
+
$v_descr['type'] = 'file';
|
2020 |
+
}
|
2021 |
+
else if (@is_dir($v_descr['filename'])) {
|
2022 |
+
$v_descr['type'] = 'folder';
|
2023 |
+
}
|
2024 |
+
else if (@is_link($v_descr['filename'])) {
|
2025 |
+
// skip
|
2026 |
+
continue;
|
2027 |
+
}
|
2028 |
+
else {
|
2029 |
+
// skip
|
2030 |
+
continue;
|
2031 |
+
}
|
2032 |
+
}
|
2033 |
+
|
2034 |
+
// ----- Look for string added as file
|
2035 |
+
else if (isset($v_descr['content'])) {
|
2036 |
+
$v_descr['type'] = 'virtual_file';
|
2037 |
+
}
|
2038 |
+
|
2039 |
+
// ----- Missing file
|
2040 |
+
else {
|
2041 |
+
// ----- Error log
|
2042 |
+
PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
|
2043 |
+
|
2044 |
+
// ----- Return
|
2045 |
+
return PclZip::errorCode();
|
2046 |
+
}
|
2047 |
+
|
2048 |
+
// ----- Calculate the stored filename
|
2049 |
+
$this->privCalculateStoredFilename($v_descr, $p_options);
|
2050 |
+
|
2051 |
+
// ----- Add the descriptor in result list
|
2052 |
+
$v_result_list[sizeof($v_result_list)] = $v_descr;
|
2053 |
+
|
2054 |
+
// ----- Look for folder
|
2055 |
+
if ($v_descr['type'] == 'folder') {
|
2056 |
+
// ----- List of items in folder
|
2057 |
+
$v_dirlist_descr = array();
|
2058 |
+
$v_dirlist_nb = 0;
|
2059 |
+
if ($v_folder_handler = @opendir($v_descr['filename'])) {
|
2060 |
+
while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
|
2061 |
+
|
2062 |
+
// ----- Skip '.' and '..'
|
2063 |
+
if (($v_item_handler == '.') || ($v_item_handler == '..')) {
|
2064 |
+
continue;
|
2065 |
+
}
|
2066 |
+
|
2067 |
+
// ----- Compose the full filename
|
2068 |
+
$v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler;
|
2069 |
+
|
2070 |
+
// ----- Look for different stored filename
|
2071 |
+
// Because the name of the folder was changed, the name of the
|
2072 |
+
// files/sub-folders also change
|
2073 |
+
if (($v_descr['stored_filename'] != $v_descr['filename'])
|
2074 |
+
&& (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
|
2075 |
+
if ($v_descr['stored_filename'] != '') {
|
2076 |
+
$v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
|
2077 |
+
}
|
2078 |
+
else {
|
2079 |
+
$v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
|
2080 |
+
}
|
2081 |
+
}
|
2082 |
+
|
2083 |
+
$v_dirlist_nb++;
|
2084 |
+
}
|
2085 |
+
|
2086 |
+
@closedir($v_folder_handler);
|
2087 |
+
}
|
2088 |
+
else {
|
2089 |
+
// TBC : unable to open folder in read mode
|
2090 |
+
}
|
2091 |
+
|
2092 |
+
// ----- Expand each element of the list
|
2093 |
+
if ($v_dirlist_nb != 0) {
|
2094 |
+
// ----- Expand
|
2095 |
+
if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
|
2096 |
+
return $v_result;
|
2097 |
+
}
|
2098 |
+
|
2099 |
+
// ----- Concat the resulting list
|
2100 |
+
$v_result_list = array_merge($v_result_list, $v_dirlist_descr);
|
2101 |
+
}
|
2102 |
+
else {
|
2103 |
+
}
|
2104 |
+
|
2105 |
+
// ----- Free local array
|
2106 |
+
unset($v_dirlist_descr);
|
2107 |
+
}
|
2108 |
+
}
|
2109 |
+
|
2110 |
+
// ----- Get the result list
|
2111 |
+
$p_filedescr_list = $v_result_list;
|
2112 |
+
|
2113 |
+
// ----- Return
|
2114 |
+
return $v_result;
|
2115 |
+
}
|
2116 |
+
// --------------------------------------------------------------------------------
|
2117 |
+
|
2118 |
+
// --------------------------------------------------------------------------------
|
2119 |
+
// Function : privCreate()
|
2120 |
+
// Description :
|
2121 |
+
// Parameters :
|
2122 |
+
// Return Values :
|
2123 |
+
// --------------------------------------------------------------------------------
|
2124 |
+
function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
|
2125 |
+
{
|
2126 |
+
$v_result=1;
|
2127 |
+
$v_list_detail = array();
|
2128 |
+
|
2129 |
+
// ----- Magic quotes trick
|
2130 |
+
$this->privDisableMagicQuotes();
|
2131 |
+
|
2132 |
+
// ----- Open the file in write mode
|
2133 |
+
if (($v_result = $this->privOpenFd('wb')) != 1)
|
2134 |
+
{
|
2135 |
+
// ----- Return
|
2136 |
+
return $v_result;
|
2137 |
+
}
|
2138 |
+
|
2139 |
+
// ----- Add the list of files
|
2140 |
+
$v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options);
|
2141 |
+
|
2142 |
+
// ----- Close
|
2143 |
+
$this->privCloseFd();
|
2144 |
+
|
2145 |
+
// ----- Magic quotes trick
|
2146 |
+
$this->privSwapBackMagicQuotes();
|
2147 |
+
|
2148 |
+
// ----- Return
|
2149 |
+
return $v_result;
|
2150 |
+
}
|
2151 |
+
// --------------------------------------------------------------------------------
|
2152 |
+
|
2153 |
+
// --------------------------------------------------------------------------------
|
2154 |
+
// Function : privAdd()
|
2155 |
+
// Description :
|
2156 |
+
// Parameters :
|
2157 |
+
// Return Values :
|
2158 |
+
// --------------------------------------------------------------------------------
|
2159 |
+
function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
|
2160 |
+
{
|
2161 |
+
$v_result=1;
|
2162 |
+
$v_list_detail = array();
|
2163 |
+
|
2164 |
+
// ----- Look if the archive exists or is empty
|
2165 |
+
if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
|
2166 |
+
{
|
2167 |
+
|
2168 |
+
// ----- Do a create
|
2169 |
+
$v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
|
2170 |
+
|
2171 |
+
// ----- Return
|
2172 |
+
return $v_result;
|
2173 |
+
}
|
2174 |
+
// ----- Magic quotes trick
|
2175 |
+
$this->privDisableMagicQuotes();
|
2176 |
+
|
2177 |
+
// ----- Open the zip file
|
2178 |
+
if (($v_result=$this->privOpenFd('rb')) != 1)
|
2179 |
+
{
|
2180 |
+
// ----- Magic quotes trick
|
2181 |
+
$this->privSwapBackMagicQuotes();
|
2182 |
+
|
2183 |
+
// ----- Return
|
2184 |
+
return $v_result;
|
2185 |
+
}
|
2186 |
+
|
2187 |
+
// ----- Read the central directory informations
|
2188 |
+
$v_central_dir = array();
|
2189 |
+
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
|
2190 |
+
{
|
2191 |
+
$this->privCloseFd();
|
2192 |
+
$this->privSwapBackMagicQuotes();
|
2193 |
+
return $v_result;
|
2194 |
+
}
|
2195 |
+
|
2196 |
+
// ----- Go to beginning of File
|
2197 |
+
@rewind($this->zip_fd);
|
2198 |
+
|
2199 |
+
// ----- Creates a temporay file
|
2200 |
+
$v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
|
2201 |
+
|
2202 |
+
// ----- Open the temporary file in write mode
|
2203 |
+
if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
|
2204 |
+
{
|
2205 |
+
$this->privCloseFd();
|
2206 |
+
$this->privSwapBackMagicQuotes();
|
2207 |
+
|
2208 |
+
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
|
2209 |
+
|
2210 |
+
// ----- Return
|
2211 |
+
return PclZip::errorCode();
|
2212 |
+
}
|
2213 |
+
|
2214 |
+
// ----- Copy the files from the archive to the temporary file
|
2215 |
+
// TBC : Here I should better append the file and go back to erase the central dir
|
2216 |
+
$v_size = $v_central_dir['offset'];
|
2217 |
+
while ($v_size != 0)
|
2218 |
+
{
|
2219 |
+
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
|
2220 |
+
$v_buffer = fread($this->zip_fd, $v_read_size);
|
2221 |
+
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
|
2222 |
+
$v_size -= $v_read_size;
|
2223 |
+
}
|
2224 |
+
|
2225 |
+
// ----- Swap the file descriptor
|
2226 |
+
// Here is a trick : I swap the temporary fd with the zip fd, in order to use
|
2227 |
+
// the following methods on the temporary fil and not the real archive
|
2228 |
+
$v_swap = $this->zip_fd;
|
2229 |
+
$this->zip_fd = $v_zip_temp_fd;
|
2230 |
+
$v_zip_temp_fd = $v_swap;
|
2231 |
+
|
2232 |
+
// ----- Add the files
|
2233 |
+
$v_header_list = array();
|
2234 |
+
if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
|
2235 |
+
{
|
2236 |
+
fclose($v_zip_temp_fd);
|
2237 |
+
$this->privCloseFd();
|
2238 |
+
@unlink($v_zip_temp_name);
|
2239 |
+
$this->privSwapBackMagicQuotes();
|
2240 |
+
|
2241 |
+
// ----- Return
|
2242 |
+
return $v_result;
|
2243 |
+
}
|
2244 |
+
|
2245 |
+
// ----- Store the offset of the central dir
|
2246 |
+
$v_offset = @ftell($this->zip_fd);
|
2247 |
+
|
2248 |
+
// ----- Copy the block of file headers from the old archive
|
2249 |
+
$v_size = $v_central_dir['size'];
|
2250 |
+
while ($v_size != 0)
|
2251 |
+
{
|
2252 |
+
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
|
2253 |
+
$v_buffer = @fread($v_zip_temp_fd, $v_read_size);
|
2254 |
+
@fwrite($this->zip_fd, $v_buffer, $v_read_size);
|
2255 |
+
$v_size -= $v_read_size;
|
2256 |
+
}
|
2257 |
+
|
2258 |
+
// ----- Create the Central Dir files header
|
2259 |
+
for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
|
2260 |
+
{
|
2261 |
+
// ----- Create the file header
|
2262 |
+
if ($v_header_list[$i]['status'] == 'ok') {
|
2263 |
+
if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
|
2264 |
+
fclose($v_zip_temp_fd);
|
2265 |
+
$this->privCloseFd();
|
2266 |
+
@unlink($v_zip_temp_name);
|
2267 |
+
$this->privSwapBackMagicQuotes();
|
2268 |
+
|
2269 |
+
// ----- Return
|
2270 |
+
return $v_result;
|
2271 |
+
}
|
2272 |
+
$v_count++;
|
2273 |
+
}
|
2274 |
+
|
2275 |
+
// ----- Transform the header to a 'usable' info
|
2276 |
+
$this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
|
2277 |
+
}
|
2278 |
+
|
2279 |
+
// ----- Zip file comment
|
2280 |
+
$v_comment = $v_central_dir['comment'];
|
2281 |
+
if (isset($p_options[PCLZIP_OPT_COMMENT])) {
|
2282 |
+
$v_comment = $p_options[PCLZIP_OPT_COMMENT];
|
2283 |
+
}
|
2284 |
+
if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
|
2285 |
+
$v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT];
|
2286 |
+
}
|
2287 |
+
if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
|
2288 |
+
$v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
|
2289 |
+
}
|
2290 |
+
|
2291 |
+
// ----- Calculate the size of the central header
|
2292 |
+
$v_size = @ftell($this->zip_fd)-$v_offset;
|
2293 |
+
|
2294 |
+
// ----- Create the central dir footer
|
2295 |
+
if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
|
2296 |
+
{
|
2297 |
+
// ----- Reset the file list
|
2298 |
+
unset($v_header_list);
|
2299 |
+
$this->privSwapBackMagicQuotes();
|
2300 |
+
|
2301 |
+
// ----- Return
|
2302 |
+
return $v_result;
|
2303 |
+
}
|
2304 |
+
|
2305 |
+
// ----- Swap back the file descriptor
|
2306 |
+
$v_swap = $this->zip_fd;
|
2307 |
+
$this->zip_fd = $v_zip_temp_fd;
|
2308 |
+
$v_zip_temp_fd = $v_swap;
|
2309 |
+
|
2310 |
+
// ----- Close
|
2311 |
+
$this->privCloseFd();
|
2312 |
+
|
2313 |
+
// ----- Close the temporary file
|
2314 |
+
@fclose($v_zip_temp_fd);
|
2315 |
+
|
2316 |
+
// ----- Magic quotes trick
|
2317 |
+
$this->privSwapBackMagicQuotes();
|
2318 |
+
|
2319 |
+
// ----- Delete the zip file
|
2320 |
+
// TBC : I should test the result ...
|
2321 |
+
@unlink($this->zipname);
|
2322 |
+
|
2323 |
+
// ----- Rename the temporary file
|
2324 |
+
// TBC : I should test the result ...
|
2325 |
+
//@rename($v_zip_temp_name, $this->zipname);
|
2326 |
+
PclZipUtilRename($v_zip_temp_name, $this->zipname);
|
2327 |
+
|
2328 |
+
// ----- Return
|
2329 |
+
return $v_result;
|
2330 |
+
}
|
2331 |
+
// --------------------------------------------------------------------------------
|
2332 |
+
|
2333 |
+
// --------------------------------------------------------------------------------
|
2334 |
+
// Function : privOpenFd()
|
2335 |
+
// Description :
|
2336 |
+
// Parameters :
|
2337 |
+
// --------------------------------------------------------------------------------
|
2338 |
+
function privOpenFd($p_mode)
|
2339 |
+
{
|
2340 |
+
$v_result=1;
|
2341 |
+
|
2342 |
+
// ----- Look if already open
|
2343 |
+
if ($this->zip_fd != 0)
|
2344 |
+
{
|
2345 |
+
// ----- Error log
|
2346 |
+
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
|
2347 |
+
|
2348 |
+
// ----- Return
|
2349 |
+
return PclZip::errorCode();
|
2350 |
+
}
|
2351 |
+
|
2352 |
+
// ----- Open the zip file
|
2353 |
+
if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
|
2354 |
+
{
|
2355 |
+
// ----- Error log
|
2356 |
+
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
|
2357 |
+
|
2358 |
+
// ----- Return
|
2359 |
+
return PclZip::errorCode();
|
2360 |
+
}
|
2361 |
+
|
2362 |
+
// ----- Return
|
2363 |
+
return $v_result;
|
2364 |
+
}
|
2365 |
+
// --------------------------------------------------------------------------------
|
2366 |
+
|
2367 |
+
// --------------------------------------------------------------------------------
|
2368 |
+
// Function : privCloseFd()
|
2369 |
+
// Description :
|
2370 |
+
// Parameters :
|
2371 |
+
// --------------------------------------------------------------------------------
|
2372 |
+
function privCloseFd()
|
2373 |
+
{
|
2374 |
+
$v_result=1;
|
2375 |
+
|
2376 |
+
if ($this->zip_fd != 0)
|
2377 |
+
@fclose($this->zip_fd);
|
2378 |
+
$this->zip_fd = 0;
|
2379 |
+
|
2380 |
+
// ----- Return
|
2381 |
+
return $v_result;
|
2382 |
+
}
|
2383 |
+
// --------------------------------------------------------------------------------
|
2384 |
+
|
2385 |
+
// --------------------------------------------------------------------------------
|
2386 |
+
// Function : privAddList()
|
2387 |
+
// Description :
|
2388 |
+
// $p_add_dir and $p_remove_dir will give the ability to memorize a path which is
|
2389 |
+
// different from the real path of the file. This is usefull if you want to have PclTar
|
2390 |
+
// running in any directory, and memorize relative path from an other directory.
|
2391 |
+
// Parameters :
|
2392 |
+
// $p_list : An array containing the file or directory names to add in the tar
|
2393 |
+
// $p_result_list : list of added files with their properties (specially the status field)
|
2394 |
+
// $p_add_dir : Path to add in the filename path archived
|
2395 |
+
// $p_remove_dir : Path to remove in the filename path archived
|
2396 |
+
// Return Values :
|
2397 |
+
// --------------------------------------------------------------------------------
|
2398 |
+
// function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
|
2399 |
+
function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
|
2400 |
+
{
|
2401 |
+
$v_result=1;
|
2402 |
+
|
2403 |
+
// ----- Add the files
|
2404 |
+
$v_header_list = array();
|
2405 |
+
if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
|
2406 |
+
{
|
2407 |
+
// ----- Return
|
2408 |
+
return $v_result;
|
2409 |
+
}
|
2410 |
+
|
2411 |
+
// ----- Store the offset of the central dir
|
2412 |
+
$v_offset = @ftell($this->zip_fd);
|
2413 |
+
|
2414 |
+
// ----- Create the Central Dir files header
|
2415 |
+
for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
|
2416 |
+
{
|
2417 |
+
// ----- Create the file header
|
2418 |
+
if ($v_header_list[$i]['status'] == 'ok') {
|
2419 |
+
if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
|
2420 |
+
// ----- Return
|
2421 |
+
return $v_result;
|
2422 |
+
}
|
2423 |
+
$v_count++;
|
2424 |
+
}
|
2425 |
+
|
2426 |
+
// ----- Transform the header to a 'usable' info
|
2427 |
+
$this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
|
2428 |
+
}
|
2429 |
+
|
2430 |
+
// ----- Zip file comment
|
2431 |
+
$v_comment = '';
|
2432 |
+
if (isset($p_options[PCLZIP_OPT_COMMENT])) {
|
2433 |
+
$v_comment = $p_options[PCLZIP_OPT_COMMENT];
|
2434 |
+
}
|
2435 |
+
|
2436 |
+
// ----- Calculate the size of the central header
|
2437 |
+
$v_size = @ftell($this->zip_fd)-$v_offset;
|
2438 |
+
|
2439 |
+
// ----- Create the central dir footer
|
2440 |
+
if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
|
2441 |
+
{
|
2442 |
+
// ----- Reset the file list
|
2443 |
+
unset($v_header_list);
|
2444 |
+
|
2445 |
+
// ----- Return
|
2446 |
+
return $v_result;
|
2447 |
+
}
|
2448 |
+
|
2449 |
+
// ----- Return
|
2450 |
+
return $v_result;
|
2451 |
+
}
|
2452 |
+
// --------------------------------------------------------------------------------
|
2453 |
+
|
2454 |
+
// --------------------------------------------------------------------------------
|
2455 |
+
// Function : privAddFileList()
|
2456 |
+
// Description :
|
2457 |
+
// Parameters :
|
2458 |
+
// $p_filedescr_list : An array containing the file description
|
2459 |
+
// or directory names to add in the zip
|
2460 |
+
// $p_result_list : list of added files with their properties (specially the status field)
|
2461 |
+
// Return Values :
|
2462 |
+
// --------------------------------------------------------------------------------
|
2463 |
+
function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
|
2464 |
+
{
|
2465 |
+
$v_result=1;
|
2466 |
+
$v_header = array();
|
2467 |
+
|
2468 |
+
// ----- Recuperate the current number of elt in list
|
2469 |
+
$v_nb = sizeof($p_result_list);
|
2470 |
+
|
2471 |
+
// ----- Loop on the files
|
2472 |
+
for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
|
2473 |
+
// ----- Format the filename
|
2474 |
+
$p_filedescr_list[$j]['filename']
|
2475 |
+
= PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
|
2476 |
+
|
2477 |
+
|
2478 |
+
// ----- Skip empty file names
|
2479 |
+
// TBC : Can this be possible ? not checked in DescrParseAtt ?
|
2480 |
+
if ($p_filedescr_list[$j]['filename'] == "") {
|
2481 |
+
continue;
|
2482 |
+
}
|
2483 |
+
|
2484 |
+
// ----- Check the filename
|
2485 |
+
if ( ($p_filedescr_list[$j]['type'] != 'virtual_file')
|
2486 |
+
&& (!file_exists($p_filedescr_list[$j]['filename']))) {
|
2487 |
+
PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
|
2488 |
+
return PclZip::errorCode();
|
2489 |
+
}
|
2490 |
+
|
2491 |
+
// ----- Look if it is a file or a dir with no all path remove option
|
2492 |
+
// or a dir with all its path removed
|
2493 |
+
// if ( (is_file($p_filedescr_list[$j]['filename']))
|
2494 |
+
// || ( is_dir($p_filedescr_list[$j]['filename'])
|
2495 |
+
if ( ($p_filedescr_list[$j]['type'] == 'file')
|
2496 |
+
|| ($p_filedescr_list[$j]['type'] == 'virtual_file')
|
2497 |
+
|| ( ($p_filedescr_list[$j]['type'] == 'folder')
|
2498 |
+
&& ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
|
2499 |
+
|| !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
|
2500 |
+
) {
|
2501 |
+
|
2502 |
+
// ----- Add the file
|
2503 |
+
$v_result = $this->privAddFile($p_filedescr_list[$j], $v_header,
|
2504 |
+
$p_options);
|
2505 |
+
if ($v_result != 1) {
|
2506 |
+
return $v_result;
|
2507 |
+
}
|
2508 |
+
|
2509 |
+
// ----- Store the file infos
|
2510 |
+
$p_result_list[$v_nb++] = $v_header;
|
2511 |
+
}
|
2512 |
+
}
|
2513 |
+
|
2514 |
+
// ----- Return
|
2515 |
+
return $v_result;
|
2516 |
+
}
|
2517 |
+
// --------------------------------------------------------------------------------
|
2518 |
+
|
2519 |
+
// --------------------------------------------------------------------------------
|
2520 |
+
// Function : privAddFile()
|
2521 |
+
// Description :
|
2522 |
+
// Parameters :
|
2523 |
+
// Return Values :
|
2524 |
+
// --------------------------------------------------------------------------------
|
2525 |
+
function privAddFile($p_filedescr, &$p_header, &$p_options)
|
2526 |
+
{
|
2527 |
+
$v_result=1;
|
2528 |
+
|
2529 |
+
// ----- Working variable
|
2530 |
+
$p_filename = $p_filedescr['filename'];
|
2531 |
+
|
2532 |
+
// TBC : Already done in the fileAtt check ... ?
|
2533 |
+
if ($p_filename == "") {
|
2534 |
+
// ----- Error log
|
2535 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
|
2536 |
+
|
2537 |
+
// ----- Return
|
2538 |
+
return PclZip::errorCode();
|
2539 |
+
}
|
2540 |
+
|
2541 |
+
// ----- Look for a stored different filename
|
2542 |
+
/* TBC : Removed
|
2543 |
+
if (isset($p_filedescr['stored_filename'])) {
|
2544 |
+
$v_stored_filename = $p_filedescr['stored_filename'];
|
2545 |
+
}
|
2546 |
+
else {
|
2547 |
+
$v_stored_filename = $p_filedescr['stored_filename'];
|
2548 |
+
}
|
2549 |
+
*/
|
2550 |
+
|
2551 |
+
// ----- Set the file properties
|
2552 |
+
clearstatcache();
|
2553 |
+
$p_header['version'] = 20;
|
2554 |
+
$p_header['version_extracted'] = 10;
|
2555 |
+
$p_header['flag'] = 0;
|
2556 |
+
$p_header['compression'] = 0;
|
2557 |
+
$p_header['crc'] = 0;
|
2558 |
+
$p_header['compressed_size'] = 0;
|
2559 |
+
$p_header['filename_len'] = strlen($p_filename);
|
2560 |
+
$p_header['extra_len'] = 0;
|
2561 |
+
$p_header['disk'] = 0;
|
2562 |
+
$p_header['internal'] = 0;
|
2563 |
+
$p_header['offset'] = 0;
|
2564 |
+
$p_header['filename'] = $p_filename;
|
2565 |
+
// TBC : Removed $p_header['stored_filename'] = $v_stored_filename;
|
2566 |
+
$p_header['stored_filename'] = $p_filedescr['stored_filename'];
|
2567 |
+
$p_header['extra'] = '';
|
2568 |
+
$p_header['status'] = 'ok';
|
2569 |
+
$p_header['index'] = -1;
|
2570 |
+
|
2571 |
+
// ----- Look for regular file
|
2572 |
+
if ($p_filedescr['type']=='file') {
|
2573 |
+
$p_header['external'] = 0x00000000;
|
2574 |
+
$p_header['size'] = filesize($p_filename);
|
2575 |
+
}
|
2576 |
+
|
2577 |
+
// ----- Look for regular folder
|
2578 |
+
else if ($p_filedescr['type']=='folder') {
|
2579 |
+
$p_header['external'] = 0x00000010;
|
2580 |
+
$p_header['mtime'] = filemtime($p_filename);
|
2581 |
+
$p_header['size'] = filesize($p_filename);
|
2582 |
+
}
|
2583 |
+
|
2584 |
+
// ----- Look for virtual file
|
2585 |
+
else if ($p_filedescr['type'] == 'virtual_file') {
|
2586 |
+
$p_header['external'] = 0x00000000;
|
2587 |
+
$p_header['size'] = strlen($p_filedescr['content']);
|
2588 |
+
}
|
2589 |
+
|
2590 |
+
|
2591 |
+
// ----- Look for filetime
|
2592 |
+
if (isset($p_filedescr['mtime'])) {
|
2593 |
+
$p_header['mtime'] = $p_filedescr['mtime'];
|
2594 |
+
}
|
2595 |
+
else if ($p_filedescr['type'] == 'virtual_file') {
|
2596 |
+
$p_header['mtime'] = time();
|
2597 |
+
}
|
2598 |
+
else {
|
2599 |
+
$p_header['mtime'] = filemtime($p_filename);
|
2600 |
+
}
|
2601 |
+
|
2602 |
+
// ------ Look for file comment
|
2603 |
+
if (isset($p_filedescr['comment'])) {
|
2604 |
+
$p_header['comment_len'] = strlen($p_filedescr['comment']);
|
2605 |
+
$p_header['comment'] = $p_filedescr['comment'];
|
2606 |
+
}
|
2607 |
+
else {
|
2608 |
+
$p_header['comment_len'] = 0;
|
2609 |
+
$p_header['comment'] = '';
|
2610 |
+
}
|
2611 |
+
|
2612 |
+
// ----- Look for pre-add callback
|
2613 |
+
if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
|
2614 |
+
|
2615 |
+
// ----- Generate a local information
|
2616 |
+
$v_local_header = array();
|
2617 |
+
$this->privConvertHeader2FileInfo($p_header, $v_local_header);
|
2618 |
+
|
2619 |
+
// ----- Call the callback
|
2620 |
+
// Here I do not use call_user_func() because I need to send a reference to the
|
2621 |
+
// header.
|
2622 |
+
// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);');
|
2623 |
+
$v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header);
|
2624 |
+
if ($v_result == 0) {
|
2625 |
+
// ----- Change the file status
|
2626 |
+
$p_header['status'] = "skipped";
|
2627 |
+
$v_result = 1;
|
2628 |
+
}
|
2629 |
+
|
2630 |
+
// ----- Update the informations
|
2631 |
+
// Only some fields can be modified
|
2632 |
+
if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
|
2633 |
+
$p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
|
2634 |
+
}
|
2635 |
+
}
|
2636 |
+
|
2637 |
+
// ----- Look for empty stored filename
|
2638 |
+
if ($p_header['stored_filename'] == "") {
|
2639 |
+
$p_header['status'] = "filtered";
|
2640 |
+
}
|
2641 |
+
|
2642 |
+
// ----- Check the path length
|
2643 |
+
if (strlen($p_header['stored_filename']) > 0xFF) {
|
2644 |
+
$p_header['status'] = 'filename_too_long';
|
2645 |
+
}
|
2646 |
+
|
2647 |
+
// ----- Look if no error, or file not skipped
|
2648 |
+
if ($p_header['status'] == 'ok') {
|
2649 |
+
|
2650 |
+
// ----- Look for a file
|
2651 |
+
if ($p_filedescr['type'] == 'file') {
|
2652 |
+
// ----- Look for using temporary file to zip
|
2653 |
+
if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
|
2654 |
+
&& (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
|
2655 |
+
|| (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
|
2656 |
+
&& ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
|
2657 |
+
$v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
|
2658 |
+
if ($v_result < PCLZIP_ERR_NO_ERROR) {
|
2659 |
+
return $v_result;
|
2660 |
+
}
|
2661 |
+
}
|
2662 |
+
|
2663 |
+
// ----- Use "in memory" zip algo
|
2664 |
+
else {
|
2665 |
+
|
2666 |
+
// ----- Open the source file
|
2667 |
+
if (($v_file = @fopen($p_filename, "rb")) == 0) {
|
2668 |
+
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
|
2669 |
+
return PclZip::errorCode();
|
2670 |
+
}
|
2671 |
+
|
2672 |
+
// ----- Read the file content
|
2673 |
+
$v_content = @fread($v_file, $p_header['size']);
|
2674 |
+
|
2675 |
+
// ----- Close the file
|
2676 |
+
@fclose($v_file);
|
2677 |
+
|
2678 |
+
// ----- Calculate the CRC
|
2679 |
+
$p_header['crc'] = @crc32($v_content);
|
2680 |
+
|
2681 |
+
// ----- Look for no compression
|
2682 |
+
if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
|
2683 |
+
// ----- Set header parameters
|
2684 |
+
$p_header['compressed_size'] = $p_header['size'];
|
2685 |
+
$p_header['compression'] = 0;
|
2686 |
+
}
|
2687 |
+
|
2688 |
+
// ----- Look for normal compression
|
2689 |
+
else {
|
2690 |
+
// ----- Compress the content
|
2691 |
+
$v_content = @gzdeflate($v_content);
|
2692 |
+
|
2693 |
+
// ----- Set header parameters
|
2694 |
+
$p_header['compressed_size'] = strlen($v_content);
|
2695 |
+
$p_header['compression'] = 8;
|
2696 |
+
}
|
2697 |
+
|
2698 |
+
// ----- Call the header generation
|
2699 |
+
if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
|
2700 |
+
@fclose($v_file);
|
2701 |
+
return $v_result;
|
2702 |
+
}
|
2703 |
+
|
2704 |
+
// ----- Write the compressed (or not) content
|
2705 |
+
@fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
|
2706 |
+
|
2707 |
+
}
|
2708 |
+
|
2709 |
+
}
|
2710 |
+
|
2711 |
+
// ----- Look for a virtual file (a file from string)
|
2712 |
+
else if ($p_filedescr['type'] == 'virtual_file') {
|
2713 |
+
|
2714 |
+
$v_content = $p_filedescr['content'];
|
2715 |
+
|
2716 |
+
// ----- Calculate the CRC
|
2717 |
+
$p_header['crc'] = @crc32($v_content);
|
2718 |
+
|
2719 |
+
// ----- Look for no compression
|
2720 |
+
if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
|
2721 |
+
// ----- Set header parameters
|
2722 |
+
$p_header['compressed_size'] = $p_header['size'];
|
2723 |
+
$p_header['compression'] = 0;
|
2724 |
+
}
|
2725 |
+
|
2726 |
+
// ----- Look for normal compression
|
2727 |
+
else {
|
2728 |
+
// ----- Compress the content
|
2729 |
+
$v_content = @gzdeflate($v_content);
|
2730 |
+
|
2731 |
+
// ----- Set header parameters
|
2732 |
+
$p_header['compressed_size'] = strlen($v_content);
|
2733 |
+
$p_header['compression'] = 8;
|
2734 |
+
}
|
2735 |
+
|
2736 |
+
// ----- Call the header generation
|
2737 |
+
if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
|
2738 |
+
@fclose($v_file);
|
2739 |
+
return $v_result;
|
2740 |
+
}
|
2741 |
+
|
2742 |
+
// ----- Write the compressed (or not) content
|
2743 |
+
@fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
|
2744 |
+
}
|
2745 |
+
|
2746 |
+
// ----- Look for a directory
|
2747 |
+
else if ($p_filedescr['type'] == 'folder') {
|
2748 |
+
// ----- Look for directory last '/'
|
2749 |
+
if (@substr($p_header['stored_filename'], -1) != '/') {
|
2750 |
+
$p_header['stored_filename'] .= '/';
|
2751 |
+
}
|
2752 |
+
|
2753 |
+
// ----- Set the file properties
|
2754 |
+
$p_header['size'] = 0;
|
2755 |
+
//$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked
|
2756 |
+
$p_header['external'] = 0x00000010; // Value for a folder : to be checked
|
2757 |
+
|
2758 |
+
// ----- Call the header generation
|
2759 |
+
if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
|
2760 |
+
{
|
2761 |
+
return $v_result;
|
2762 |
+
}
|
2763 |
+
}
|
2764 |
+
}
|
2765 |
+
|
2766 |
+
// ----- Look for post-add callback
|
2767 |
+
if (isset($p_options[PCLZIP_CB_POST_ADD])) {
|
2768 |
+
|
2769 |
+
// ----- Generate a local information
|
2770 |
+
$v_local_header = array();
|
2771 |
+
$this->privConvertHeader2FileInfo($p_header, $v_local_header);
|
2772 |
+
|
2773 |
+
// ----- Call the callback
|
2774 |
+
// Here I do not use call_user_func() because I need to send a reference to the
|
2775 |
+
// header.
|
2776 |
+
// eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);');
|
2777 |
+
$v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header);
|
2778 |
+
if ($v_result == 0) {
|
2779 |
+
// ----- Ignored
|
2780 |
+
$v_result = 1;
|
2781 |
+
}
|
2782 |
+
|
2783 |
+
// ----- Update the informations
|
2784 |
+
// Nothing can be modified
|
2785 |
+
}
|
2786 |
+
|
2787 |
+
// ----- Return
|
2788 |
+
return $v_result;
|
2789 |
+
}
|
2790 |
+
// --------------------------------------------------------------------------------
|
2791 |
+
|
2792 |
+
// --------------------------------------------------------------------------------
|
2793 |
+
// Function : privAddFileUsingTempFile()
|
2794 |
+
// Description :
|
2795 |
+
// Parameters :
|
2796 |
+
// Return Values :
|
2797 |
+
// --------------------------------------------------------------------------------
|
2798 |
+
function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
|
2799 |
+
{
|
2800 |
+
$v_result=PCLZIP_ERR_NO_ERROR;
|
2801 |
+
|
2802 |
+
// ----- Working variable
|
2803 |
+
$p_filename = $p_filedescr['filename'];
|
2804 |
+
|
2805 |
+
|
2806 |
+
// ----- Open the source file
|
2807 |
+
if (($v_file = @fopen($p_filename, "rb")) == 0) {
|
2808 |
+
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
|
2809 |
+
return PclZip::errorCode();
|
2810 |
+
}
|
2811 |
+
|
2812 |
+
// ----- Creates a compressed temporary file
|
2813 |
+
$v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
|
2814 |
+
if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
|
2815 |
+
fclose($v_file);
|
2816 |
+
PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
|
2817 |
+
return PclZip::errorCode();
|
2818 |
+
}
|
2819 |
+
|
2820 |
+
// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
|
2821 |
+
$v_size = filesize($p_filename);
|
2822 |
+
while ($v_size != 0) {
|
2823 |
+
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
|
2824 |
+
$v_buffer = @fread($v_file, $v_read_size);
|
2825 |
+
//$v_binary_data = pack('a'.$v_read_size, $v_buffer);
|
2826 |
+
@gzputs($v_file_compressed, $v_buffer, $v_read_size);
|
2827 |
+
$v_size -= $v_read_size;
|
2828 |
+
}
|
2829 |
+
|
2830 |
+
// ----- Close the file
|
2831 |
+
@fclose($v_file);
|
2832 |
+
@gzclose($v_file_compressed);
|
2833 |
+
|
2834 |
+
// ----- Check the minimum file size
|
2835 |
+
if (filesize($v_gzip_temp_name) < 18) {
|
2836 |
+
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
|
2837 |
+
return PclZip::errorCode();
|
2838 |
+
}
|
2839 |
+
|
2840 |
+
// ----- Extract the compressed attributes
|
2841 |
+
if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
|
2842 |
+
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
|
2843 |
+
return PclZip::errorCode();
|
2844 |
+
}
|
2845 |
+
|
2846 |
+
// ----- Read the gzip file header
|
2847 |
+
$v_binary_data = @fread($v_file_compressed, 10);
|
2848 |
+
$v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);
|
2849 |
+
|
2850 |
+
// ----- Check some parameters
|
2851 |
+
$v_data_header['os'] = bin2hex($v_data_header['os']);
|
2852 |
+
|
2853 |
+
// ----- Read the gzip file footer
|
2854 |
+
@fseek($v_file_compressed, filesize($v_gzip_temp_name)-8);
|
2855 |
+
$v_binary_data = @fread($v_file_compressed, 8);
|
2856 |
+
$v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
|
2857 |
+
|
2858 |
+
// ----- Set the attributes
|
2859 |
+
$p_header['compression'] = ord($v_data_header['cm']);
|
2860 |
+
//$p_header['mtime'] = $v_data_header['mtime'];
|
2861 |
+
$p_header['crc'] = $v_data_footer['crc'];
|
2862 |
+
$p_header['compressed_size'] = filesize($v_gzip_temp_name)-18;
|
2863 |
+
|
2864 |
+
// ----- Close the file
|
2865 |
+
@fclose($v_file_compressed);
|
2866 |
+
|
2867 |
+
// ----- Call the header generation
|
2868 |
+
if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
|
2869 |
+
return $v_result;
|
2870 |
+
}
|
2871 |
+
|
2872 |
+
// ----- Add the compressed data
|
2873 |
+
if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
|
2874 |
+
{
|
2875 |
+
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
|
2876 |
+
return PclZip::errorCode();
|
2877 |
+
}
|
2878 |
+
|
2879 |
+
// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
|
2880 |
+
fseek($v_file_compressed, 10);
|
2881 |
+
$v_size = $p_header['compressed_size'];
|
2882 |
+
while ($v_size != 0)
|
2883 |
+
{
|
2884 |
+
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
|
2885 |
+
$v_buffer = @fread($v_file_compressed, $v_read_size);
|
2886 |
+
//$v_binary_data = pack('a'.$v_read_size, $v_buffer);
|
2887 |
+
@fwrite($this->zip_fd, $v_buffer, $v_read_size);
|
2888 |
+
$v_size -= $v_read_size;
|
2889 |
+
}
|
2890 |
+
|
2891 |
+
// ----- Close the file
|
2892 |
+
@fclose($v_file_compressed);
|
2893 |
+
|
2894 |
+
// ----- Unlink the temporary file
|
2895 |
+
@unlink($v_gzip_temp_name);
|
2896 |
+
|
2897 |
+
// ----- Return
|
2898 |
+
return $v_result;
|
2899 |
+
}
|
2900 |
+
// --------------------------------------------------------------------------------
|
2901 |
+
|
2902 |
+
// --------------------------------------------------------------------------------
|
2903 |
+
// Function : privCalculateStoredFilename()
|
2904 |
+
// Description :
|
2905 |
+
// Based on file descriptor properties and global options, this method
|
2906 |
+
// calculate the filename that will be stored in the archive.
|
2907 |
+
// Parameters :
|
2908 |
+
// Return Values :
|
2909 |
+
// --------------------------------------------------------------------------------
|
2910 |
+
function privCalculateStoredFilename(&$p_filedescr, &$p_options)
|
2911 |
+
{
|
2912 |
+
$v_result=1;
|
2913 |
+
|
2914 |
+
// ----- Working variables
|
2915 |
+
$p_filename = $p_filedescr['filename'];
|
2916 |
+
if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
|
2917 |
+
$p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
|
2918 |
+
}
|
2919 |
+
else {
|
2920 |
+
$p_add_dir = '';
|
2921 |
+
}
|
2922 |
+
if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
|
2923 |
+
$p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
|
2924 |
+
}
|
2925 |
+
else {
|
2926 |
+
$p_remove_dir = '';
|
2927 |
+
}
|
2928 |
+
if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
|
2929 |
+
$p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
|
2930 |
+
}
|
2931 |
+
else {
|
2932 |
+
$p_remove_all_dir = 0;
|
2933 |
+
}
|
2934 |
+
|
2935 |
+
|
2936 |
+
// ----- Look for full name change
|
2937 |
+
if (isset($p_filedescr['new_full_name'])) {
|
2938 |
+
// ----- Remove drive letter if any
|
2939 |
+
$v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
|
2940 |
+
}
|
2941 |
+
|
2942 |
+
// ----- Look for path and/or short name change
|
2943 |
+
else {
|
2944 |
+
|
2945 |
+
// ----- Look for short name change
|
2946 |
+
// Its when we cahnge just the filename but not the path
|
2947 |
+
if (isset($p_filedescr['new_short_name'])) {
|
2948 |
+
$v_path_info = pathinfo($p_filename);
|
2949 |
+
$v_dir = '';
|
2950 |
+
if ($v_path_info['dirname'] != '') {
|
2951 |
+
$v_dir = $v_path_info['dirname'].'/';
|
2952 |
+
}
|
2953 |
+
$v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
|
2954 |
+
}
|
2955 |
+
else {
|
2956 |
+
// ----- Calculate the stored filename
|
2957 |
+
$v_stored_filename = $p_filename;
|
2958 |
+
}
|
2959 |
+
|
2960 |
+
// ----- Look for all path to remove
|
2961 |
+
if ($p_remove_all_dir) {
|
2962 |
+
$v_stored_filename = basename($p_filename);
|
2963 |
+
}
|
2964 |
+
// ----- Look for partial path remove
|
2965 |
+
else if ($p_remove_dir != "") {
|
2966 |
+
if (substr($p_remove_dir, -1) != '/')
|
2967 |
+
$p_remove_dir .= "/";
|
2968 |
+
|
2969 |
+
if ( (substr($p_filename, 0, 2) == "./")
|
2970 |
+
|| (substr($p_remove_dir, 0, 2) == "./")) {
|
2971 |
+
|
2972 |
+
if ( (substr($p_filename, 0, 2) == "./")
|
2973 |
+
&& (substr($p_remove_dir, 0, 2) != "./")) {
|
2974 |
+
$p_remove_dir = "./".$p_remove_dir;
|
2975 |
+
}
|
2976 |
+
if ( (substr($p_filename, 0, 2) != "./")
|
2977 |
+
&& (substr($p_remove_dir, 0, 2) == "./")) {
|
2978 |
+
$p_remove_dir = substr($p_remove_dir, 2);
|
2979 |
+
}
|
2980 |
+
}
|
2981 |
+
|
2982 |
+
$v_compare = PclZipUtilPathInclusion($p_remove_dir,
|
2983 |
+
$v_stored_filename);
|
2984 |
+
if ($v_compare > 0) {
|
2985 |
+
if ($v_compare == 2) {
|
2986 |
+
$v_stored_filename = "";
|
2987 |
+
}
|
2988 |
+
else {
|
2989 |
+
$v_stored_filename = substr($v_stored_filename,
|
2990 |
+
strlen($p_remove_dir));
|
2991 |
+
}
|
2992 |
+
}
|
2993 |
+
}
|
2994 |
+
|
2995 |
+
// ----- Remove drive letter if any
|
2996 |
+
$v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename);
|
2997 |
+
|
2998 |
+
// ----- Look for path to add
|
2999 |
+
if ($p_add_dir != "") {
|
3000 |
+
if (substr($p_add_dir, -1) == "/")
|
3001 |
+
$v_stored_filename = $p_add_dir.$v_stored_filename;
|
3002 |
+
else
|
3003 |
+
$v_stored_filename = $p_add_dir."/".$v_stored_filename;
|
3004 |
+
}
|
3005 |
+
}
|
3006 |
+
|
3007 |
+
// ----- Filename (reduce the path of stored name)
|
3008 |
+
$v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
|
3009 |
+
$p_filedescr['stored_filename'] = $v_stored_filename;
|
3010 |
+
|
3011 |
+
// ----- Return
|
3012 |
+
return $v_result;
|
3013 |
+
}
|
3014 |
+
// --------------------------------------------------------------------------------
|
3015 |
+
|
3016 |
+
// --------------------------------------------------------------------------------
|
3017 |
+
// Function : privWriteFileHeader()
|
3018 |
+
// Description :
|
3019 |
+
// Parameters :
|
3020 |
+
// Return Values :
|
3021 |
+
// --------------------------------------------------------------------------------
|
3022 |
+
function privWriteFileHeader(&$p_header)
|
3023 |
+
{
|
3024 |
+
$v_result=1;
|
3025 |
+
|
3026 |
+
// ----- Store the offset position of the file
|
3027 |
+
$p_header['offset'] = ftell($this->zip_fd);
|
3028 |
+
|
3029 |
+
// ----- Transform UNIX mtime to DOS format mdate/mtime
|
3030 |
+
$v_date = getdate($p_header['mtime']);
|
3031 |
+
$v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
|
3032 |
+
$v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
|
3033 |
+
|
3034 |
+
// ----- Packed data
|
3035 |
+
$v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
|
3036 |
+
$p_header['version_extracted'], $p_header['flag'],
|
3037 |
+
$p_header['compression'], $v_mtime, $v_mdate,
|
3038 |
+
$p_header['crc'], $p_header['compressed_size'],
|
3039 |
+
$p_header['size'],
|
3040 |
+
strlen($p_header['stored_filename']),
|
3041 |
+
$p_header['extra_len']);
|
3042 |
+
|
3043 |
+
// ----- Write the first 148 bytes of the header in the archive
|
3044 |
+
fputs($this->zip_fd, $v_binary_data, 30);
|
3045 |
+
|
3046 |
+
// ----- Write the variable fields
|
3047 |
+
if (strlen($p_header['stored_filename']) != 0)
|
3048 |
+
{
|
3049 |
+
fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
|
3050 |
+
}
|
3051 |
+
if ($p_header['extra_len'] != 0)
|
3052 |
+
{
|
3053 |
+
fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
|
3054 |
+
}
|
3055 |
+
|
3056 |
+
// ----- Return
|
3057 |
+
return $v_result;
|
3058 |
+
}
|
3059 |
+
// --------------------------------------------------------------------------------
|
3060 |
+
|
3061 |
+
// --------------------------------------------------------------------------------
|
3062 |
+
// Function : privWriteCentralFileHeader()
|
3063 |
+
// Description :
|
3064 |
+
// Parameters :
|
3065 |
+
// Return Values :
|
3066 |
+
// --------------------------------------------------------------------------------
|
3067 |
+
function privWriteCentralFileHeader(&$p_header)
|
3068 |
+
{
|
3069 |
+
$v_result=1;
|
3070 |
+
|
3071 |
+
// TBC
|
3072 |
+
//for(reset($p_header); $key = key($p_header); next($p_header)) {
|
3073 |
+
//}
|
3074 |
+
|
3075 |
+
// ----- Transform UNIX mtime to DOS format mdate/mtime
|
3076 |
+
$v_date = getdate($p_header['mtime']);
|
3077 |
+
$v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
|
3078 |
+
$v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
|
3079 |
+
|
3080 |
+
|
3081 |
+
// ----- Packed data
|
3082 |
+
$v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
|
3083 |
+
$p_header['version'], $p_header['version_extracted'],
|
3084 |
+
$p_header['flag'], $p_header['compression'],
|
3085 |
+
$v_mtime, $v_mdate, $p_header['crc'],
|
3086 |
+
$p_header['compressed_size'], $p_header['size'],
|
3087 |
+
strlen($p_header['stored_filename']),
|
3088 |
+
$p_header['extra_len'], $p_header['comment_len'],
|
3089 |
+
$p_header['disk'], $p_header['internal'],
|
3090 |
+
$p_header['external'], $p_header['offset']);
|
3091 |
+
|
3092 |
+
// ----- Write the 42 bytes of the header in the zip file
|
3093 |
+
fputs($this->zip_fd, $v_binary_data, 46);
|
3094 |
+
|
3095 |
+
// ----- Write the variable fields
|
3096 |
+
if (strlen($p_header['stored_filename']) != 0)
|
3097 |
+
{
|
3098 |
+
fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
|
3099 |
+
}
|
3100 |
+
if ($p_header['extra_len'] != 0)
|
3101 |
+
{
|
3102 |
+
fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
|
3103 |
+
}
|
3104 |
+
if ($p_header['comment_len'] != 0)
|
3105 |
+
{
|
3106 |
+
fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
|
3107 |
+
}
|
3108 |
+
|
3109 |
+
// ----- Return
|
3110 |
+
return $v_result;
|
3111 |
+
}
|
3112 |
+
// --------------------------------------------------------------------------------
|
3113 |
+
|
3114 |
+
// --------------------------------------------------------------------------------
|
3115 |
+
// Function : privWriteCentralHeader()
|
3116 |
+
// Description :
|
3117 |
+
// Parameters :
|
3118 |
+
// Return Values :
|
3119 |
+
// --------------------------------------------------------------------------------
|
3120 |
+
function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
|
3121 |
+
{
|
3122 |
+
$v_result=1;
|
3123 |
+
|
3124 |
+
// ----- Packed data
|
3125 |
+
$v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
|
3126 |
+
$p_nb_entries, $p_size,
|
3127 |
+
$p_offset, strlen($p_comment));
|
3128 |
+
|
3129 |
+
// ----- Write the 22 bytes of the header in the zip file
|
3130 |
+
fputs($this->zip_fd, $v_binary_data, 22);
|
3131 |
+
|
3132 |
+
// ----- Write the variable fields
|
3133 |
+
if (strlen($p_comment) != 0)
|
3134 |
+
{
|
3135 |
+
fputs($this->zip_fd, $p_comment, strlen($p_comment));
|
3136 |
+
}
|
3137 |
+
|
3138 |
+
// ----- Return
|
3139 |
+
return $v_result;
|
3140 |
+
}
|
3141 |
+
// --------------------------------------------------------------------------------
|
3142 |
+
|
3143 |
+
// --------------------------------------------------------------------------------
|
3144 |
+
// Function : privList()
|
3145 |
+
// Description :
|
3146 |
+
// Parameters :
|
3147 |
+
// Return Values :
|
3148 |
+
// --------------------------------------------------------------------------------
|
3149 |
+
function privList(&$p_list)
|
3150 |
+
{
|
3151 |
+
$v_result=1;
|
3152 |
+
|
3153 |
+
// ----- Magic quotes trick
|
3154 |
+
$this->privDisableMagicQuotes();
|
3155 |
+
|
3156 |
+
// ----- Open the zip file
|
3157 |
+
if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
|
3158 |
+
{
|
3159 |
+
// ----- Magic quotes trick
|
3160 |
+
$this->privSwapBackMagicQuotes();
|
3161 |
+
|
3162 |
+
// ----- Error log
|
3163 |
+
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
|
3164 |
+
|
3165 |
+
// ----- Return
|
3166 |
+
return PclZip::errorCode();
|
3167 |
+
}
|
3168 |
+
|
3169 |
+
// ----- Read the central directory informations
|
3170 |
+
$v_central_dir = array();
|
3171 |
+
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
|
3172 |
+
{
|
3173 |
+
$this->privSwapBackMagicQuotes();
|
3174 |
+
return $v_result;
|
3175 |
+
}
|
3176 |
+
|
3177 |
+
// ----- Go to beginning of Central Dir
|
3178 |
+
@rewind($this->zip_fd);
|
3179 |
+
if (@fseek($this->zip_fd, $v_central_dir['offset']))
|
3180 |
+
{
|
3181 |
+
$this->privSwapBackMagicQuotes();
|
3182 |
+
|
3183 |
+
// ----- Error log
|
3184 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
|
3185 |
+
|
3186 |
+
// ----- Return
|
3187 |
+
return PclZip::errorCode();
|
3188 |
+
}
|
3189 |
+
|
3190 |
+
// ----- Read each entry
|
3191 |
+
for ($i=0; $i<$v_central_dir['entries']; $i++)
|
3192 |
+
{
|
3193 |
+
// ----- Read the file header
|
3194 |
+
if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
|
3195 |
+
{
|
3196 |
+
$this->privSwapBackMagicQuotes();
|
3197 |
+
return $v_result;
|
3198 |
+
}
|
3199 |
+
$v_header['index'] = $i;
|
3200 |
+
|
3201 |
+
// ----- Get the only interesting attributes
|
3202 |
+
$this->privConvertHeader2FileInfo($v_header, $p_list[$i]);
|
3203 |
+
unset($v_header);
|
3204 |
+
}
|
3205 |
+
|
3206 |
+
// ----- Close the zip file
|
3207 |
+
$this->privCloseFd();
|
3208 |
+
|
3209 |
+
// ----- Magic quotes trick
|
3210 |
+
$this->privSwapBackMagicQuotes();
|
3211 |
+
|
3212 |
+
// ----- Return
|
3213 |
+
return $v_result;
|
3214 |
+
}
|
3215 |
+
// --------------------------------------------------------------------------------
|
3216 |
+
|
3217 |
+
// --------------------------------------------------------------------------------
|
3218 |
+
// Function : privConvertHeader2FileInfo()
|
3219 |
+
// Description :
|
3220 |
+
// This function takes the file informations from the central directory
|
3221 |
+
// entries and extract the interesting parameters that will be given back.
|
3222 |
+
// The resulting file infos are set in the array $p_info
|
3223 |
+
// $p_info['filename'] : Filename with full path. Given by user (add),
|
3224 |
+
// extracted in the filesystem (extract).
|
3225 |
+
// $p_info['stored_filename'] : Stored filename in the archive.
|
3226 |
+
// $p_info['size'] = Size of the file.
|
3227 |
+
// $p_info['compressed_size'] = Compressed size of the file.
|
3228 |
+
// $p_info['mtime'] = Last modification date of the file.
|
3229 |
+
// $p_info['comment'] = Comment associated with the file.
|
3230 |
+
// $p_info['folder'] = true/false : indicates if the entry is a folder or not.
|
3231 |
+
// $p_info['status'] = status of the action on the file.
|
3232 |
+
// $p_info['crc'] = CRC of the file content.
|
3233 |
+
// Parameters :
|
3234 |
+
// Return Values :
|
3235 |
+
// --------------------------------------------------------------------------------
|
3236 |
+
function privConvertHeader2FileInfo($p_header, &$p_info)
|
3237 |
+
{
|
3238 |
+
$v_result=1;
|
3239 |
+
|
3240 |
+
// ----- Get the interesting attributes
|
3241 |
+
$v_temp_path = PclZipUtilPathReduction($p_header['filename']);
|
3242 |
+
$p_info['filename'] = $v_temp_path;
|
3243 |
+
$v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']);
|
3244 |
+
$p_info['stored_filename'] = $v_temp_path;
|
3245 |
+
$p_info['size'] = $p_header['size'];
|
3246 |
+
$p_info['compressed_size'] = $p_header['compressed_size'];
|
3247 |
+
$p_info['mtime'] = $p_header['mtime'];
|
3248 |
+
$p_info['comment'] = $p_header['comment'];
|
3249 |
+
$p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
|
3250 |
+
$p_info['index'] = $p_header['index'];
|
3251 |
+
$p_info['status'] = $p_header['status'];
|
3252 |
+
$p_info['crc'] = $p_header['crc'];
|
3253 |
+
|
3254 |
+
// ----- Return
|
3255 |
+
return $v_result;
|
3256 |
+
}
|
3257 |
+
// --------------------------------------------------------------------------------
|
3258 |
+
|
3259 |
+
// --------------------------------------------------------------------------------
|
3260 |
+
// Function : privExtractByRule()
|
3261 |
+
// Description :
|
3262 |
+
// Extract a file or directory depending of rules (by index, by name, ...)
|
3263 |
+
// Parameters :
|
3264 |
+
// $p_file_list : An array where will be placed the properties of each
|
3265 |
+
// extracted file
|
3266 |
+
// $p_path : Path to add while writing the extracted files
|
3267 |
+
// $p_remove_path : Path to remove (from the file memorized path) while writing the
|
3268 |
+
// extracted files. If the path does not match the file path,
|
3269 |
+
// the file is extracted with its memorized path.
|
3270 |
+
// $p_remove_path does not apply to 'list' mode.
|
3271 |
+
// $p_path and $p_remove_path are commulative.
|
3272 |
+
// Return Values :
|
3273 |
+
// 1 on success,0 or less on error (see error code list)
|
3274 |
+
// --------------------------------------------------------------------------------
|
3275 |
+
function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
|
3276 |
+
{
|
3277 |
+
$v_result=1;
|
3278 |
+
|
3279 |
+
// ----- Magic quotes trick
|
3280 |
+
$this->privDisableMagicQuotes();
|
3281 |
+
|
3282 |
+
// ----- Check the path
|
3283 |
+
if ( ($p_path == "")
|
3284 |
+
|| ( (substr($p_path, 0, 1) != "/")
|
3285 |
+
&& (substr($p_path, 0, 3) != "../")
|
3286 |
+
&& (substr($p_path,1,2)!=":/")))
|
3287 |
+
$p_path = "./".$p_path;
|
3288 |
+
|
3289 |
+
// ----- Reduce the path last (and duplicated) '/'
|
3290 |
+
if (($p_path != "./") && ($p_path != "/"))
|
3291 |
+
{
|
3292 |
+
// ----- Look for the path end '/'
|
3293 |
+
while (substr($p_path, -1) == "/")
|
3294 |
+
{
|
3295 |
+
$p_path = substr($p_path, 0, strlen($p_path)-1);
|
3296 |
+
}
|
3297 |
+
}
|
3298 |
+
|
3299 |
+
// ----- Look for path to remove format (should end by /)
|
3300 |
+
if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))
|
3301 |
+
{
|
3302 |
+
$p_remove_path .= '/';
|
3303 |
+
}
|
3304 |
+
$p_remove_path_size = strlen($p_remove_path);
|
3305 |
+
|
3306 |
+
// ----- Open the zip file
|
3307 |
+
if (($v_result = $this->privOpenFd('rb')) != 1)
|
3308 |
+
{
|
3309 |
+
$this->privSwapBackMagicQuotes();
|
3310 |
+
return $v_result;
|
3311 |
+
}
|
3312 |
+
|
3313 |
+
// ----- Read the central directory informations
|
3314 |
+
$v_central_dir = array();
|
3315 |
+
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
|
3316 |
+
{
|
3317 |
+
// ----- Close the zip file
|
3318 |
+
$this->privCloseFd();
|
3319 |
+
$this->privSwapBackMagicQuotes();
|
3320 |
+
|
3321 |
+
return $v_result;
|
3322 |
+
}
|
3323 |
+
|
3324 |
+
// ----- Start at beginning of Central Dir
|
3325 |
+
$v_pos_entry = $v_central_dir['offset'];
|
3326 |
+
|
3327 |
+
// ----- Read each entry
|
3328 |
+
$j_start = 0;
|
3329 |
+
for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
|
3330 |
+
{
|
3331 |
+
|
3332 |
+
// ----- Read next Central dir entry
|
3333 |
+
@rewind($this->zip_fd);
|
3334 |
+
if (@fseek($this->zip_fd, $v_pos_entry))
|
3335 |
+
{
|
3336 |
+
// ----- Close the zip file
|
3337 |
+
$this->privCloseFd();
|
3338 |
+
$this->privSwapBackMagicQuotes();
|
3339 |
+
|
3340 |
+
// ----- Error log
|
3341 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
|
3342 |
+
|
3343 |
+
// ----- Return
|
3344 |
+
return PclZip::errorCode();
|
3345 |
+
}
|
3346 |
+
|
3347 |
+
// ----- Read the file header
|
3348 |
+
$v_header = array();
|
3349 |
+
if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
|
3350 |
+
{
|
3351 |
+
// ----- Close the zip file
|
3352 |
+
$this->privCloseFd();
|
3353 |
+
$this->privSwapBackMagicQuotes();
|
3354 |
+
|
3355 |
+
return $v_result;
|
3356 |
+
}
|
3357 |
+
|
3358 |
+
// ----- Store the index
|
3359 |
+
$v_header['index'] = $i;
|
3360 |
+
|
3361 |
+
// ----- Store the file position
|
3362 |
+
$v_pos_entry = ftell($this->zip_fd);
|
3363 |
+
|
3364 |
+
// ----- Look for the specific extract rules
|
3365 |
+
$v_extract = false;
|
3366 |
+
|
3367 |
+
// ----- Look for extract by name rule
|
3368 |
+
if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
|
3369 |
+
&& ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
|
3370 |
+
|
3371 |
+
// ----- Look if the filename is in the list
|
3372 |
+
for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
|
3373 |
+
|
3374 |
+
// ----- Look for a directory
|
3375 |
+
if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
|
3376 |
+
|
3377 |
+
// ----- Look if the directory is in the filename path
|
3378 |
+
if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
|
3379 |
+
&& (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
|
3380 |
+
$v_extract = true;
|
3381 |
+
}
|
3382 |
+
}
|
3383 |
+
// ----- Look for a filename
|
3384 |
+
elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
|
3385 |
+
$v_extract = true;
|
3386 |
+
}
|
3387 |
+
}
|
3388 |
+
}
|
3389 |
+
|
3390 |
+
// ----- Look for extract by ereg rule
|
3391 |
+
// ereg() is deprecated with PHP 5.3
|
3392 |
+
/*
|
3393 |
+
else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
|
3394 |
+
&& ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
|
3395 |
+
|
3396 |
+
if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
|
3397 |
+
$v_extract = true;
|
3398 |
+
}
|
3399 |
+
}
|
3400 |
+
*/
|
3401 |
+
|
3402 |
+
// ----- Look for extract by preg rule
|
3403 |
+
else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
|
3404 |
+
&& ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
|
3405 |
+
|
3406 |
+
if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
|
3407 |
+
$v_extract = true;
|
3408 |
+
}
|
3409 |
+
}
|
3410 |
+
|
3411 |
+
// ----- Look for extract by index rule
|
3412 |
+
else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
|
3413 |
+
&& ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
|
3414 |
+
|
3415 |
+
// ----- Look if the index is in the list
|
3416 |
+
for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
|
3417 |
+
|
3418 |
+
if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
|
3419 |
+
$v_extract = true;
|
3420 |
+
}
|
3421 |
+
if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
|
3422 |
+
$j_start = $j+1;
|
3423 |
+
}
|
3424 |
+
|
3425 |
+
if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
|
3426 |
+
break;
|
3427 |
+
}
|
3428 |
+
}
|
3429 |
+
}
|
3430 |
+
|
3431 |
+
// ----- Look for no rule, which means extract all the archive
|
3432 |
+
else {
|
3433 |
+
$v_extract = true;
|
3434 |
+
}
|
3435 |
+
|
3436 |
+
// ----- Check compression method
|
3437 |
+
if ( ($v_extract)
|
3438 |
+
&& ( ($v_header['compression'] != 8)
|
3439 |
+
&& ($v_header['compression'] != 0))) {
|
3440 |
+
$v_header['status'] = 'unsupported_compression';
|
3441 |
+
|
3442 |
+
// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
|
3443 |
+
if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
|
3444 |
+
&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
3445 |
+
|
3446 |
+
$this->privSwapBackMagicQuotes();
|
3447 |
+
|
3448 |
+
PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
|
3449 |
+
"Filename '".$v_header['stored_filename']."' is "
|
3450 |
+
."compressed by an unsupported compression "
|
3451 |
+
."method (".$v_header['compression'].") ");
|
3452 |
+
|
3453 |
+
return PclZip::errorCode();
|
3454 |
+
}
|
3455 |
+
}
|
3456 |
+
|
3457 |
+
// ----- Check encrypted files
|
3458 |
+
if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
|
3459 |
+
$v_header['status'] = 'unsupported_encryption';
|
3460 |
+
|
3461 |
+
// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
|
3462 |
+
if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
|
3463 |
+
&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
3464 |
+
|
3465 |
+
$this->privSwapBackMagicQuotes();
|
3466 |
+
|
3467 |
+
PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
|
3468 |
+
"Unsupported encryption for "
|
3469 |
+
." filename '".$v_header['stored_filename']
|
3470 |
+
."'");
|
3471 |
+
|
3472 |
+
return PclZip::errorCode();
|
3473 |
+
}
|
3474 |
+
}
|
3475 |
+
|
3476 |
+
// ----- Look for real extraction
|
3477 |
+
if (($v_extract) && ($v_header['status'] != 'ok')) {
|
3478 |
+
$v_result = $this->privConvertHeader2FileInfo($v_header,
|
3479 |
+
$p_file_list[$v_nb_extracted++]);
|
3480 |
+
if ($v_result != 1) {
|
3481 |
+
$this->privCloseFd();
|
3482 |
+
$this->privSwapBackMagicQuotes();
|
3483 |
+
return $v_result;
|
3484 |
+
}
|
3485 |
+
|
3486 |
+
$v_extract = false;
|
3487 |
+
}
|
3488 |
+
|
3489 |
+
// ----- Look for real extraction
|
3490 |
+
if ($v_extract)
|
3491 |
+
{
|
3492 |
+
|
3493 |
+
// ----- Go to the file position
|
3494 |
+
@rewind($this->zip_fd);
|
3495 |
+
if (@fseek($this->zip_fd, $v_header['offset']))
|
3496 |
+
{
|
3497 |
+
// ----- Close the zip file
|
3498 |
+
$this->privCloseFd();
|
3499 |
+
|
3500 |
+
$this->privSwapBackMagicQuotes();
|
3501 |
+
|
3502 |
+
// ----- Error log
|
3503 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
|
3504 |
+
|
3505 |
+
// ----- Return
|
3506 |
+
return PclZip::errorCode();
|
3507 |
+
}
|
3508 |
+
|
3509 |
+
// ----- Look for extraction as string
|
3510 |
+
if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
|
3511 |
+
|
3512 |
+
$v_string = '';
|
3513 |
+
|
3514 |
+
// ----- Extracting the file
|
3515 |
+
$v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options);
|
3516 |
+
if ($v_result1 < 1) {
|
3517 |
+
$this->privCloseFd();
|
3518 |
+
$this->privSwapBackMagicQuotes();
|
3519 |
+
return $v_result1;
|
3520 |
+
}
|
3521 |
+
|
3522 |
+
// ----- Get the only interesting attributes
|
3523 |
+
if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
|
3524 |
+
{
|
3525 |
+
// ----- Close the zip file
|
3526 |
+
$this->privCloseFd();
|
3527 |
+
$this->privSwapBackMagicQuotes();
|
3528 |
+
|
3529 |
+
return $v_result;
|
3530 |
+
}
|
3531 |
+
|
3532 |
+
// ----- Set the file content
|
3533 |
+
$p_file_list[$v_nb_extracted]['content'] = $v_string;
|
3534 |
+
|
3535 |
+
// ----- Next extracted file
|
3536 |
+
$v_nb_extracted++;
|
3537 |
+
|
3538 |
+
// ----- Look for user callback abort
|
3539 |
+
if ($v_result1 == 2) {
|
3540 |
+
break;
|
3541 |
+
}
|
3542 |
+
}
|
3543 |
+
// ----- Look for extraction in standard output
|
3544 |
+
elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
|
3545 |
+
&& ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
|
3546 |
+
// ----- Extracting the file in standard output
|
3547 |
+
$v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
|
3548 |
+
if ($v_result1 < 1) {
|
3549 |
+
$this->privCloseFd();
|
3550 |
+
$this->privSwapBackMagicQuotes();
|
3551 |
+
return $v_result1;
|
3552 |
+
}
|
3553 |
+
|
3554 |
+
// ----- Get the only interesting attributes
|
3555 |
+
if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
|
3556 |
+
$this->privCloseFd();
|
3557 |
+
$this->privSwapBackMagicQuotes();
|
3558 |
+
return $v_result;
|
3559 |
+
}
|
3560 |
+
|
3561 |
+
// ----- Look for user callback abort
|
3562 |
+
if ($v_result1 == 2) {
|
3563 |
+
break;
|
3564 |
+
}
|
3565 |
+
}
|
3566 |
+
// ----- Look for normal extraction
|
3567 |
+
else {
|
3568 |
+
// ----- Extracting the file
|
3569 |
+
$v_result1 = $this->privExtractFile($v_header,
|
3570 |
+
$p_path, $p_remove_path,
|
3571 |
+
$p_remove_all_path,
|
3572 |
+
$p_options);
|
3573 |
+
if ($v_result1 < 1) {
|
3574 |
+
$this->privCloseFd();
|
3575 |
+
$this->privSwapBackMagicQuotes();
|
3576 |
+
return $v_result1;
|
3577 |
+
}
|
3578 |
+
|
3579 |
+
// ----- Get the only interesting attributes
|
3580 |
+
if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
|
3581 |
+
{
|
3582 |
+
// ----- Close the zip file
|
3583 |
+
$this->privCloseFd();
|
3584 |
+
$this->privSwapBackMagicQuotes();
|
3585 |
+
|
3586 |
+
return $v_result;
|
3587 |
+
}
|
3588 |
+
|
3589 |
+
// ----- Look for user callback abort
|
3590 |
+
if ($v_result1 == 2) {
|
3591 |
+
break;
|
3592 |
+
}
|
3593 |
+
}
|
3594 |
+
}
|
3595 |
+
}
|
3596 |
+
|
3597 |
+
// ----- Close the zip file
|
3598 |
+
$this->privCloseFd();
|
3599 |
+
$this->privSwapBackMagicQuotes();
|
3600 |
+
|
3601 |
+
// ----- Return
|
3602 |
+
return $v_result;
|
3603 |
+
}
|
3604 |
+
// --------------------------------------------------------------------------------
|
3605 |
+
|
3606 |
+
// --------------------------------------------------------------------------------
|
3607 |
+
// Function : privExtractFile()
|
3608 |
+
// Description :
|
3609 |
+
// Parameters :
|
3610 |
+
// Return Values :
|
3611 |
+
//
|
3612 |
+
// 1 : ... ?
|
3613 |
+
// PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback
|
3614 |
+
// --------------------------------------------------------------------------------
|
3615 |
+
function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
|
3616 |
+
{
|
3617 |
+
$v_result=1;
|
3618 |
+
|
3619 |
+
// ----- Read the file header
|
3620 |
+
if (($v_result = $this->privReadFileHeader($v_header)) != 1)
|
3621 |
+
{
|
3622 |
+
// ----- Return
|
3623 |
+
return $v_result;
|
3624 |
+
}
|
3625 |
+
|
3626 |
+
|
3627 |
+
// ----- Check that the file header is coherent with $p_entry info
|
3628 |
+
if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
|
3629 |
+
// TBC
|
3630 |
+
}
|
3631 |
+
|
3632 |
+
// ----- Look for all path to remove
|
3633 |
+
if ($p_remove_all_path == true) {
|
3634 |
+
// ----- Look for folder entry that not need to be extracted
|
3635 |
+
if (($p_entry['external']&0x00000010)==0x00000010) {
|
3636 |
+
|
3637 |
+
$p_entry['status'] = "filtered";
|
3638 |
+
|
3639 |
+
return $v_result;
|
3640 |
+
}
|
3641 |
+
|
3642 |
+
// ----- Get the basename of the path
|
3643 |
+
$p_entry['filename'] = basename($p_entry['filename']);
|
3644 |
+
}
|
3645 |
+
|
3646 |
+
// ----- Look for path to remove
|
3647 |
+
else if ($p_remove_path != "")
|
3648 |
+
{
|
3649 |
+
if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
|
3650 |
+
{
|
3651 |
+
|
3652 |
+
// ----- Change the file status
|
3653 |
+
$p_entry['status'] = "filtered";
|
3654 |
+
|
3655 |
+
// ----- Return
|
3656 |
+
return $v_result;
|
3657 |
+
}
|
3658 |
+
|
3659 |
+
$p_remove_path_size = strlen($p_remove_path);
|
3660 |
+
if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
|
3661 |
+
{
|
3662 |
+
|
3663 |
+
// ----- Remove the path
|
3664 |
+
$p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
|
3665 |
+
|
3666 |
+
}
|
3667 |
+
}
|
3668 |
+
|
3669 |
+
// ----- Add the path
|
3670 |
+
if ($p_path != '') {
|
3671 |
+
$p_entry['filename'] = $p_path."/".$p_entry['filename'];
|
3672 |
+
}
|
3673 |
+
|
3674 |
+
// ----- Check a base_dir_restriction
|
3675 |
+
if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
|
3676 |
+
$v_inclusion
|
3677 |
+
= PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
|
3678 |
+
$p_entry['filename']);
|
3679 |
+
if ($v_inclusion == 0) {
|
3680 |
+
|
3681 |
+
PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
|
3682 |
+
"Filename '".$p_entry['filename']."' is "
|
3683 |
+
."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
|
3684 |
+
|
3685 |
+
return PclZip::errorCode();
|
3686 |
+
}
|
3687 |
+
}
|
3688 |
+
|
3689 |
+
// ----- Look for pre-extract callback
|
3690 |
+
if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
|
3691 |
+
|
3692 |
+
// ----- Generate a local information
|
3693 |
+
$v_local_header = array();
|
3694 |
+
$this->privConvertHeader2FileInfo($p_entry, $v_local_header);
|
3695 |
+
|
3696 |
+
// ----- Call the callback
|
3697 |
+
// Here I do not use call_user_func() because I need to send a reference to the
|
3698 |
+
// header.
|
3699 |
+
// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
|
3700 |
+
$v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
|
3701 |
+
if ($v_result == 0) {
|
3702 |
+
// ----- Change the file status
|
3703 |
+
$p_entry['status'] = "skipped";
|
3704 |
+
$v_result = 1;
|
3705 |
+
}
|
3706 |
+
|
3707 |
+
// ----- Look for abort result
|
3708 |
+
if ($v_result == 2) {
|
3709 |
+
// ----- This status is internal and will be changed in 'skipped'
|
3710 |
+
$p_entry['status'] = "aborted";
|
3711 |
+
$v_result = PCLZIP_ERR_USER_ABORTED;
|
3712 |
+
}
|
3713 |
+
|
3714 |
+
// ----- Update the informations
|
3715 |
+
// Only some fields can be modified
|
3716 |
+
$p_entry['filename'] = $v_local_header['filename'];
|
3717 |
+
}
|
3718 |
+
|
3719 |
+
|
3720 |
+
// ----- Look if extraction should be done
|
3721 |
+
if ($p_entry['status'] == 'ok') {
|
3722 |
+
|
3723 |
+
// ----- Look for specific actions while the file exist
|
3724 |
+
if (file_exists($p_entry['filename']))
|
3725 |
+
{
|
3726 |
+
|
3727 |
+
// ----- Look if file is a directory
|
3728 |
+
if (is_dir($p_entry['filename']))
|
3729 |
+
{
|
3730 |
+
|
3731 |
+
// ----- Change the file status
|
3732 |
+
$p_entry['status'] = "already_a_directory";
|
3733 |
+
|
3734 |
+
// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
|
3735 |
+
// For historical reason first PclZip implementation does not stop
|
3736 |
+
// when this kind of error occurs.
|
3737 |
+
if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
|
3738 |
+
&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
3739 |
+
|
3740 |
+
PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
|
3741 |
+
"Filename '".$p_entry['filename']."' is "
|
3742 |
+
."already used by an existing directory");
|
3743 |
+
|
3744 |
+
return PclZip::errorCode();
|
3745 |
+
}
|
3746 |
+
}
|
3747 |
+
// ----- Look if file is write protected
|
3748 |
+
else if (!is_writeable($p_entry['filename']))
|
3749 |
+
{
|
3750 |
+
|
3751 |
+
// ----- Change the file status
|
3752 |
+
$p_entry['status'] = "write_protected";
|
3753 |
+
|
3754 |
+
// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
|
3755 |
+
// For historical reason first PclZip implementation does not stop
|
3756 |
+
// when this kind of error occurs.
|
3757 |
+
if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
|
3758 |
+
&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
3759 |
+
|
3760 |
+
PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
|
3761 |
+
"Filename '".$p_entry['filename']."' exists "
|
3762 |
+
."and is write protected");
|
3763 |
+
|
3764 |
+
return PclZip::errorCode();
|
3765 |
+
}
|
3766 |
+
}
|
3767 |
+
|
3768 |
+
// ----- Look if the extracted file is older
|
3769 |
+
else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
|
3770 |
+
{
|
3771 |
+
// ----- Change the file status
|
3772 |
+
if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
|
3773 |
+
&& ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
|
3774 |
+
}
|
3775 |
+
else {
|
3776 |
+
$p_entry['status'] = "newer_exist";
|
3777 |
+
|
3778 |
+
// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
|
3779 |
+
// For historical reason first PclZip implementation does not stop
|
3780 |
+
// when this kind of error occurs.
|
3781 |
+
if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
|
3782 |
+
&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
|
3783 |
+
|
3784 |
+
PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
|
3785 |
+
"Newer version of '".$p_entry['filename']."' exists "
|
3786 |
+
."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
|
3787 |
+
|
3788 |
+
return PclZip::errorCode();
|
3789 |
+
}
|
3790 |
+
}
|
3791 |
+
}
|
3792 |
+
else {
|
3793 |
+
}
|
3794 |
+
}
|
3795 |
+
|
3796 |
+
// ----- Check the directory availability and create it if necessary
|
3797 |
+
else {
|
3798 |
+
if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
|
3799 |
+
$v_dir_to_check = $p_entry['filename'];
|
3800 |
+
else if (!strstr($p_entry['filename'], "/"))
|
3801 |
+
$v_dir_to_check = "";
|
3802 |
+
else
|
3803 |
+
$v_dir_to_check = dirname($p_entry['filename']);
|
3804 |
+
|
3805 |
+
if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
|
3806 |
+
|
3807 |
+
// ----- Change the file status
|
3808 |
+
$p_entry['status'] = "path_creation_fail";
|
3809 |
+
|
3810 |
+
// ----- Return
|
3811 |
+
//return $v_result;
|
3812 |
+
$v_result = 1;
|
3813 |
+
}
|
3814 |
+
}
|
3815 |
+
}
|
3816 |
+
|
3817 |
+
// ----- Look if extraction should be done
|
3818 |
+
if ($p_entry['status'] == 'ok') {
|
3819 |
+
|
3820 |
+
// ----- Do the extraction (if not a folder)
|
3821 |
+
if (!(($p_entry['external']&0x00000010)==0x00000010))
|
3822 |
+
{
|
3823 |
+
// ----- Look for not compressed file
|
3824 |
+
if ($p_entry['compression'] == 0) {
|
3825 |
+
|
3826 |
+
// ----- Opening destination file
|
3827 |
+
if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
|
3828 |
+
{
|
3829 |
+
|
3830 |
+
// ----- Change the file status
|
3831 |
+
$p_entry['status'] = "write_error";
|
3832 |
+
|
3833 |
+
// ----- Return
|
3834 |
+
return $v_result;
|
3835 |
+
}
|
3836 |
+
|
3837 |
+
|
3838 |
+
// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
|
3839 |
+
$v_size = $p_entry['compressed_size'];
|
3840 |
+
while ($v_size != 0)
|
3841 |
+
{
|
3842 |
+
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
|
3843 |
+
$v_buffer = @fread($this->zip_fd, $v_read_size);
|
3844 |
+
/* Try to speed up the code
|
3845 |
+
$v_binary_data = pack('a'.$v_read_size, $v_buffer);
|
3846 |
+
@fwrite($v_dest_file, $v_binary_data, $v_read_size);
|
3847 |
+
*/
|
3848 |
+
@fwrite($v_dest_file, $v_buffer, $v_read_size);
|
3849 |
+
$v_size -= $v_read_size;
|
3850 |
+
}
|
3851 |
+
|
3852 |
+
// ----- Closing the destination file
|
3853 |
+
fclose($v_dest_file);
|
3854 |
+
|
3855 |
+
// ----- Change the file mtime
|
3856 |
+
touch($p_entry['filename'], $p_entry['mtime']);
|
3857 |
+
|
3858 |
+
|
3859 |
+
}
|
3860 |
+
else {
|
3861 |
+
// ----- TBC
|
3862 |
+
// Need to be finished
|
3863 |
+
if (($p_entry['flag'] & 1) == 1) {
|
3864 |
+
PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
|
3865 |
+
return PclZip::errorCode();
|
3866 |
+
}
|
3867 |
+
|
3868 |
+
|
3869 |
+
// ----- Look for using temporary file to unzip
|
3870 |
+
if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
|
3871 |
+
&& (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
|
3872 |
+
|| (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
|
3873 |
+
&& ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
|
3874 |
+
$v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
|
3875 |
+
if ($v_result < PCLZIP_ERR_NO_ERROR) {
|
3876 |
+
return $v_result;
|
3877 |
+
}
|
3878 |
+
}
|
3879 |
+
|
3880 |
+
// ----- Look for extract in memory
|
3881 |
+
else {
|
3882 |
+
|
3883 |
+
|
3884 |
+
// ----- Read the compressed file in a buffer (one shot)
|
3885 |
+
$v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
|
3886 |
+
|
3887 |
+
// ----- Decompress the file
|
3888 |
+
$v_file_content = @gzinflate($v_buffer);
|
3889 |
+
unset($v_buffer);
|
3890 |
+
if ($v_file_content === FALSE) {
|
3891 |
+
|
3892 |
+
// ----- Change the file status
|
3893 |
+
// TBC
|
3894 |
+
$p_entry['status'] = "error";
|
3895 |
+
|
3896 |
+
return $v_result;
|
3897 |
+
}
|
3898 |
+
|
3899 |
+
// ----- Opening destination file
|
3900 |
+
if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
|
3901 |
+
|
3902 |
+
// ----- Change the file status
|
3903 |
+
$p_entry['status'] = "write_error";
|
3904 |
+
|
3905 |
+
return $v_result;
|
3906 |
+
}
|
3907 |
+
|
3908 |
+
// ----- Write the uncompressed data
|
3909 |
+
@fwrite($v_dest_file, $v_file_content, $p_entry['size']);
|
3910 |
+
unset($v_file_content);
|
3911 |
+
|
3912 |
+
// ----- Closing the destination file
|
3913 |
+
@fclose($v_dest_file);
|
3914 |
+
|
3915 |
+
}
|
3916 |
+
|
3917 |
+
// ----- Change the file mtime
|
3918 |
+
@touch($p_entry['filename'], $p_entry['mtime']);
|
3919 |
+
}
|
3920 |
+
|
3921 |
+
// ----- Look for chmod option
|
3922 |
+
if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
|
3923 |
+
|
3924 |
+
// ----- Change the mode of the file
|
3925 |
+
@chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
|
3926 |
+
}
|
3927 |
+
|
3928 |
+
}
|
3929 |
+
}
|
3930 |
+
|
3931 |
+
// ----- Change abort status
|
3932 |
+
if ($p_entry['status'] == "aborted") {
|
3933 |
+
$p_entry['status'] = "skipped";
|
3934 |
+
}
|
3935 |
+
|
3936 |
+
// ----- Look for post-extract callback
|
3937 |
+
elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
|
3938 |
+
|
3939 |
+
// ----- Generate a local information
|
3940 |
+
$v_local_header = array();
|
3941 |
+
$this->privConvertHeader2FileInfo($p_entry, $v_local_header);
|
3942 |
+
|
3943 |
+
// ----- Call the callback
|
3944 |
+
// Here I do not use call_user_func() because I need to send a reference to the
|
3945 |
+
// header.
|
3946 |
+
// eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
|
3947 |
+
$v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
|
3948 |
+
|
3949 |
+
// ----- Look for abort result
|
3950 |
+
if ($v_result == 2) {
|
3951 |
+
$v_result = PCLZIP_ERR_USER_ABORTED;
|
3952 |
+
}
|
3953 |
+
}
|
3954 |
+
|
3955 |
+
// ----- Return
|
3956 |
+
return $v_result;
|
3957 |
+
}
|
3958 |
+
// --------------------------------------------------------------------------------
|
3959 |
+
|
3960 |
+
// --------------------------------------------------------------------------------
|
3961 |
+
// Function : privExtractFileUsingTempFile()
|
3962 |
+
// Description :
|
3963 |
+
// Parameters :
|
3964 |
+
// Return Values :
|
3965 |
+
// --------------------------------------------------------------------------------
|
3966 |
+
function privExtractFileUsingTempFile(&$p_entry, &$p_options)
|
3967 |
+
{
|
3968 |
+
$v_result=1;
|
3969 |
+
|
3970 |
+
// ----- Creates a temporary file
|
3971 |
+
$v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
|
3972 |
+
if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
|
3973 |
+
fclose($v_file);
|
3974 |
+
PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
|
3975 |
+
return PclZip::errorCode();
|
3976 |
+
}
|
3977 |
+
|
3978 |
+
|
3979 |
+
// ----- Write gz file format header
|
3980 |
+
$v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
|
3981 |
+
@fwrite($v_dest_file, $v_binary_data, 10);
|
3982 |
+
|
3983 |
+
// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
|
3984 |
+
$v_size = $p_entry['compressed_size'];
|
3985 |
+
while ($v_size != 0)
|
3986 |
+
{
|
3987 |
+
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
|
3988 |
+
$v_buffer = @fread($this->zip_fd, $v_read_size);
|
3989 |
+
//$v_binary_data = pack('a'.$v_read_size, $v_buffer);
|
3990 |
+
@fwrite($v_dest_file, $v_buffer, $v_read_size);
|
3991 |
+
$v_size -= $v_read_size;
|
3992 |
+
}
|
3993 |
+
|
3994 |
+
// ----- Write gz file format footer
|
3995 |
+
$v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']);
|
3996 |
+
@fwrite($v_dest_file, $v_binary_data, 8);
|
3997 |
+
|
3998 |
+
// ----- Close the temporary file
|
3999 |
+
@fclose($v_dest_file);
|
4000 |
+
|
4001 |
+
// ----- Opening destination file
|
4002 |
+
if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
|
4003 |
+
$p_entry['status'] = "write_error";
|
4004 |
+
return $v_result;
|
4005 |
+
}
|
4006 |
+
|
4007 |
+
// ----- Open the temporary gz file
|
4008 |
+
if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
|
4009 |
+
@fclose($v_dest_file);
|
4010 |
+
$p_entry['status'] = "read_error";
|
4011 |
+
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
|
4012 |
+
return PclZip::errorCode();
|
4013 |
+
}
|
4014 |
+
|
4015 |
+
|
4016 |
+
// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
|
4017 |
+
$v_size = $p_entry['size'];
|
4018 |
+
while ($v_size != 0) {
|
4019 |
+
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
|
4020 |
+
$v_buffer = @gzread($v_src_file, $v_read_size);
|
4021 |
+
//$v_binary_data = pack('a'.$v_read_size, $v_buffer);
|
4022 |
+
@fwrite($v_dest_file, $v_buffer, $v_read_size);
|
4023 |
+
$v_size -= $v_read_size;
|
4024 |
+
}
|
4025 |
+
@fclose($v_dest_file);
|
4026 |
+
@gzclose($v_src_file);
|
4027 |
+
|
4028 |
+
// ----- Delete the temporary file
|
4029 |
+
@unlink($v_gzip_temp_name);
|
4030 |
+
|
4031 |
+
// ----- Return
|
4032 |
+
return $v_result;
|
4033 |
+
}
|
4034 |
+
// --------------------------------------------------------------------------------
|
4035 |
+
|
4036 |
+
// --------------------------------------------------------------------------------
|
4037 |
+
// Function : privExtractFileInOutput()
|
4038 |
+
// Description :
|
4039 |
+
// Parameters :
|
4040 |
+
// Return Values :
|
4041 |
+
// --------------------------------------------------------------------------------
|
4042 |
+
function privExtractFileInOutput(&$p_entry, &$p_options)
|
4043 |
+
{
|
4044 |
+
$v_result=1;
|
4045 |
+
|
4046 |
+
// ----- Read the file header
|
4047 |
+
if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
|
4048 |
+
return $v_result;
|
4049 |
+
}
|
4050 |
+
|
4051 |
+
|
4052 |
+
// ----- Check that the file header is coherent with $p_entry info
|
4053 |
+
if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
|
4054 |
+
// TBC
|
4055 |
+
}
|
4056 |
+
|
4057 |
+
// ----- Look for pre-extract callback
|
4058 |
+
if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
|
4059 |
+
|
4060 |
+
// ----- Generate a local information
|
4061 |
+
$v_local_header = array();
|
4062 |
+
$this->privConvertHeader2FileInfo($p_entry, $v_local_header);
|
4063 |
+
|
4064 |
+
// ----- Call the callback
|
4065 |
+
// Here I do not use call_user_func() because I need to send a reference to the
|
4066 |
+
// header.
|
4067 |
+
// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
|
4068 |
+
$v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
|
4069 |
+
if ($v_result == 0) {
|
4070 |
+
// ----- Change the file status
|
4071 |
+
$p_entry['status'] = "skipped";
|
4072 |
+
$v_result = 1;
|
4073 |
+
}
|
4074 |
+
|
4075 |
+
// ----- Look for abort result
|
4076 |
+
if ($v_result == 2) {
|
4077 |
+
// ----- This status is internal and will be changed in 'skipped'
|
4078 |
+
$p_entry['status'] = "aborted";
|
4079 |
+
$v_result = PCLZIP_ERR_USER_ABORTED;
|
4080 |
+
}
|
4081 |
+
|
4082 |
+
// ----- Update the informations
|
4083 |
+
// Only some fields can be modified
|
4084 |
+
$p_entry['filename'] = $v_local_header['filename'];
|
4085 |
+
}
|
4086 |
+
|
4087 |
+
// ----- Trace
|
4088 |
+
|
4089 |
+
// ----- Look if extraction should be done
|
4090 |
+
if ($p_entry['status'] == 'ok') {
|
4091 |
+
|
4092 |
+
// ----- Do the extraction (if not a folder)
|
4093 |
+
if (!(($p_entry['external']&0x00000010)==0x00000010)) {
|
4094 |
+
// ----- Look for not compressed file
|
4095 |
+
if ($p_entry['compressed_size'] == $p_entry['size']) {
|
4096 |
+
|
4097 |
+
// ----- Read the file in a buffer (one shot)
|
4098 |
+
$v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
|
4099 |
+
|
4100 |
+
// ----- Send the file to the output
|
4101 |
+
echo $v_buffer;
|
4102 |
+
unset($v_buffer);
|
4103 |
+
}
|
4104 |
+
else {
|
4105 |
+
|
4106 |
+
// ----- Read the compressed file in a buffer (one shot)
|
4107 |
+
$v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
|
4108 |
+
|
4109 |
+
// ----- Decompress the file
|
4110 |
+
$v_file_content = gzinflate($v_buffer);
|
4111 |
+
unset($v_buffer);
|
4112 |
+
|
4113 |
+
// ----- Send the file to the output
|
4114 |
+
echo $v_file_content;
|
4115 |
+
unset($v_file_content);
|
4116 |
+
}
|
4117 |
+
}
|
4118 |
+
}
|
4119 |
+
|
4120 |
+
// ----- Change abort status
|
4121 |
+
if ($p_entry['status'] == "aborted") {
|
4122 |
+
$p_entry['status'] = "skipped";
|
4123 |
+
}
|
4124 |
+
|
4125 |
+
// ----- Look for post-extract callback
|
4126 |
+
elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
|
4127 |
+
|
4128 |
+
// ----- Generate a local information
|
4129 |
+
$v_local_header = array();
|
4130 |
+
$this->privConvertHeader2FileInfo($p_entry, $v_local_header);
|
4131 |
+
|
4132 |
+
// ----- Call the callback
|
4133 |
+
// Here I do not use call_user_func() because I need to send a reference to the
|
4134 |
+
// header.
|
4135 |
+
// eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
|
4136 |
+
$v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
|
4137 |
+
|
4138 |
+
// ----- Look for abort result
|
4139 |
+
if ($v_result == 2) {
|
4140 |
+
$v_result = PCLZIP_ERR_USER_ABORTED;
|
4141 |
+
}
|
4142 |
+
}
|
4143 |
+
|
4144 |
+
return $v_result;
|
4145 |
+
}
|
4146 |
+
// --------------------------------------------------------------------------------
|
4147 |
+
|
4148 |
+
// --------------------------------------------------------------------------------
|
4149 |
+
// Function : privExtractFileAsString()
|
4150 |
+
// Description :
|
4151 |
+
// Parameters :
|
4152 |
+
// Return Values :
|
4153 |
+
// --------------------------------------------------------------------------------
|
4154 |
+
function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
|
4155 |
+
{
|
4156 |
+
$v_result=1;
|
4157 |
+
|
4158 |
+
// ----- Read the file header
|
4159 |
+
$v_header = array();
|
4160 |
+
if (($v_result = $this->privReadFileHeader($v_header)) != 1)
|
4161 |
+
{
|
4162 |
+
// ----- Return
|
4163 |
+
return $v_result;
|
4164 |
+
}
|
4165 |
+
|
4166 |
+
|
4167 |
+
// ----- Check that the file header is coherent with $p_entry info
|
4168 |
+
if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
|
4169 |
+
// TBC
|
4170 |
+
}
|
4171 |
+
|
4172 |
+
// ----- Look for pre-extract callback
|
4173 |
+
if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
|
4174 |
+
|
4175 |
+
// ----- Generate a local information
|
4176 |
+
$v_local_header = array();
|
4177 |
+
$this->privConvertHeader2FileInfo($p_entry, $v_local_header);
|
4178 |
+
|
4179 |
+
// ----- Call the callback
|
4180 |
+
// Here I do not use call_user_func() because I need to send a reference to the
|
4181 |
+
// header.
|
4182 |
+
// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
|
4183 |
+
$v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
|
4184 |
+
if ($v_result == 0) {
|
4185 |
+
// ----- Change the file status
|
4186 |
+
$p_entry['status'] = "skipped";
|
4187 |
+
$v_result = 1;
|
4188 |
+
}
|
4189 |
+
|
4190 |
+
// ----- Look for abort result
|
4191 |
+
if ($v_result == 2) {
|
4192 |
+
// ----- This status is internal and will be changed in 'skipped'
|
4193 |
+
$p_entry['status'] = "aborted";
|
4194 |
+
$v_result = PCLZIP_ERR_USER_ABORTED;
|
4195 |
+
}
|
4196 |
+
|
4197 |
+
// ----- Update the informations
|
4198 |
+
// Only some fields can be modified
|
4199 |
+
$p_entry['filename'] = $v_local_header['filename'];
|
4200 |
+
}
|
4201 |
+
|
4202 |
+
|
4203 |
+
// ----- Look if extraction should be done
|
4204 |
+
if ($p_entry['status'] == 'ok') {
|
4205 |
+
|
4206 |
+
// ----- Do the extraction (if not a folder)
|
4207 |
+
if (!(($p_entry['external']&0x00000010)==0x00000010)) {
|
4208 |
+
// ----- Look for not compressed file
|
4209 |
+
// if ($p_entry['compressed_size'] == $p_entry['size'])
|
4210 |
+
if ($p_entry['compression'] == 0) {
|
4211 |
+
|
4212 |
+
// ----- Reading the file
|
4213 |
+
$p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
|
4214 |
+
}
|
4215 |
+
else {
|
4216 |
+
|
4217 |
+
// ----- Reading the file
|
4218 |
+
$v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
|
4219 |
+
|
4220 |
+
// ----- Decompress the file
|
4221 |
+
if (($p_string = @gzinflate($v_data)) === FALSE) {
|
4222 |
+
// TBC
|
4223 |
+
}
|
4224 |
+
}
|
4225 |
+
|
4226 |
+
// ----- Trace
|
4227 |
+
}
|
4228 |
+
else {
|
4229 |
+
// TBC : error : can not extract a folder in a string
|
4230 |
+
}
|
4231 |
+
|
4232 |
+
}
|
4233 |
+
|
4234 |
+
// ----- Change abort status
|
4235 |
+
if ($p_entry['status'] == "aborted") {
|
4236 |
+
$p_entry['status'] = "skipped";
|
4237 |
+
}
|
4238 |
+
|
4239 |
+
// ----- Look for post-extract callback
|
4240 |
+
elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
|
4241 |
+
|
4242 |
+
// ----- Generate a local information
|
4243 |
+
$v_local_header = array();
|
4244 |
+
$this->privConvertHeader2FileInfo($p_entry, $v_local_header);
|
4245 |
+
|
4246 |
+
// ----- Swap the content to header
|
4247 |
+
$v_local_header['content'] = $p_string;
|
4248 |
+
$p_string = '';
|
4249 |
+
|
4250 |
+
// ----- Call the callback
|
4251 |
+
// Here I do not use call_user_func() because I need to send a reference to the
|
4252 |
+
// header.
|
4253 |
+
// eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
|
4254 |
+
$v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
|
4255 |
+
|
4256 |
+
// ----- Swap back the content to header
|
4257 |
+
$p_string = $v_local_header['content'];
|
4258 |
+
unset($v_local_header['content']);
|
4259 |
+
|
4260 |
+
// ----- Look for abort result
|
4261 |
+
if ($v_result == 2) {
|
4262 |
+
$v_result = PCLZIP_ERR_USER_ABORTED;
|
4263 |
+
}
|
4264 |
+
}
|
4265 |
+
|
4266 |
+
// ----- Return
|
4267 |
+
return $v_result;
|
4268 |
+
}
|
4269 |
+
// --------------------------------------------------------------------------------
|
4270 |
+
|
4271 |
+
// --------------------------------------------------------------------------------
|
4272 |
+
// Function : privReadFileHeader()
|
4273 |
+
// Description :
|
4274 |
+
// Parameters :
|
4275 |
+
// Return Values :
|
4276 |
+
// --------------------------------------------------------------------------------
|
4277 |
+
function privReadFileHeader(&$p_header)
|
4278 |
+
{
|
4279 |
+
$v_result=1;
|
4280 |
+
|
4281 |
+
// ----- Read the 4 bytes signature
|
4282 |
+
$v_binary_data = @fread($this->zip_fd, 4);
|
4283 |
+
$v_data = unpack('Vid', $v_binary_data);
|
4284 |
+
|
4285 |
+
// ----- Check signature
|
4286 |
+
if ($v_data['id'] != 0x04034b50)
|
4287 |
+
{
|
4288 |
+
|
4289 |
+
// ----- Error log
|
4290 |
+
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
|
4291 |
+
|
4292 |
+
// ----- Return
|
4293 |
+
return PclZip::errorCode();
|
4294 |
+
}
|
4295 |
+
|
4296 |
+
// ----- Read the first 42 bytes of the header
|
4297 |
+
$v_binary_data = fread($this->zip_fd, 26);
|
4298 |
+
|
4299 |
+
// ----- Look for invalid block size
|
4300 |
+
if (strlen($v_binary_data) != 26)
|
4301 |
+
{
|
4302 |
+
$p_header['filename'] = "";
|
4303 |
+
$p_header['status'] = "invalid_header";
|
4304 |
+
|
4305 |
+
// ----- Error log
|
4306 |
+
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
|
4307 |
+
|
4308 |
+
// ----- Return
|
4309 |
+
return PclZip::errorCode();
|
4310 |
+
}
|
4311 |
+
|
4312 |
+
// ----- Extract the values
|
4313 |
+
$v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
|
4314 |
+
|
4315 |
+
// ----- Get filename
|
4316 |
+
$p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
|
4317 |
+
|
4318 |
+
// ----- Get extra_fields
|
4319 |
+
if ($v_data['extra_len'] != 0) {
|
4320 |
+
$p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
|
4321 |
+
}
|
4322 |
+
else {
|
4323 |
+
$p_header['extra'] = '';
|
4324 |
+
}
|
4325 |
+
|
4326 |
+
// ----- Extract properties
|
4327 |
+
$p_header['version_extracted'] = $v_data['version'];
|
4328 |
+
$p_header['compression'] = $v_data['compression'];
|
4329 |
+
$p_header['size'] = $v_data['size'];
|
4330 |
+
$p_header['compressed_size'] = $v_data['compressed_size'];
|
4331 |
+
$p_header['crc'] = $v_data['crc'];
|
4332 |
+
$p_header['flag'] = $v_data['flag'];
|
4333 |
+
$p_header['filename_len'] = $v_data['filename_len'];
|
4334 |
+
|
4335 |
+
// ----- Recuperate date in UNIX format
|
4336 |
+
$p_header['mdate'] = $v_data['mdate'];
|
4337 |
+
$p_header['mtime'] = $v_data['mtime'];
|
4338 |
+
if ($p_header['mdate'] && $p_header['mtime'])
|
4339 |
+
{
|
4340 |
+
// ----- Extract time
|
4341 |
+
$v_hour = ($p_header['mtime'] & 0xF800) >> 11;
|
4342 |
+
$v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
|
4343 |
+
$v_seconde = ($p_header['mtime'] & 0x001F)*2;
|
4344 |
+
|
4345 |
+
// ----- Extract date
|
4346 |
+
$v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
|
4347 |
+
$v_month = ($p_header['mdate'] & 0x01E0) >> 5;
|
4348 |
+
$v_day = $p_header['mdate'] & 0x001F;
|
4349 |
+
|
4350 |
+
// ----- Get UNIX date format
|
4351 |
+
$p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
|
4352 |
+
|
4353 |
+
}
|
4354 |
+
else
|
4355 |
+
{
|
4356 |
+
$p_header['mtime'] = time();
|
4357 |
+
}
|
4358 |
+
|
4359 |
+
// TBC
|
4360 |
+
//for(reset($v_data); $key = key($v_data); next($v_data)) {
|
4361 |
+
//}
|
4362 |
+
|
4363 |
+
// ----- Set the stored filename
|
4364 |
+
$p_header['stored_filename'] = $p_header['filename'];
|
4365 |
+
|
4366 |
+
// ----- Set the status field
|
4367 |
+
$p_header['status'] = "ok";
|
4368 |
+
|
4369 |
+
// ----- Return
|
4370 |
+
return $v_result;
|
4371 |
+
}
|
4372 |
+
// --------------------------------------------------------------------------------
|
4373 |
+
|
4374 |
+
// --------------------------------------------------------------------------------
|
4375 |
+
// Function : privReadCentralFileHeader()
|
4376 |
+
// Description :
|
4377 |
+
// Parameters :
|
4378 |
+
// Return Values :
|
4379 |
+
// --------------------------------------------------------------------------------
|
4380 |
+
function privReadCentralFileHeader(&$p_header)
|
4381 |
+
{
|
4382 |
+
$v_result=1;
|
4383 |
+
|
4384 |
+
// ----- Read the 4 bytes signature
|
4385 |
+
$v_binary_data = @fread($this->zip_fd, 4);
|
4386 |
+
$v_data = unpack('Vid', $v_binary_data);
|
4387 |
+
|
4388 |
+
// ----- Check signature
|
4389 |
+
if ($v_data['id'] != 0x02014b50)
|
4390 |
+
{
|
4391 |
+
|
4392 |
+
// ----- Error log
|
4393 |
+
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
|
4394 |
+
|
4395 |
+
// ----- Return
|
4396 |
+
return PclZip::errorCode();
|
4397 |
+
}
|
4398 |
+
|
4399 |
+
// ----- Read the first 42 bytes of the header
|
4400 |
+
$v_binary_data = fread($this->zip_fd, 42);
|
4401 |
+
|
4402 |
+
// ----- Look for invalid block size
|
4403 |
+
if (strlen($v_binary_data) != 42)
|
4404 |
+
{
|
4405 |
+
$p_header['filename'] = "";
|
4406 |
+
$p_header['status'] = "invalid_header";
|
4407 |
+
|
4408 |
+
// ----- Error log
|
4409 |
+
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
|
4410 |
+
|
4411 |
+
// ----- Return
|
4412 |
+
return PclZip::errorCode();
|
4413 |
+
}
|
4414 |
+
|
4415 |
+
// ----- Extract the values
|
4416 |
+
$p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
|
4417 |
+
|
4418 |
+
// ----- Get filename
|
4419 |
+
if ($p_header['filename_len'] != 0)
|
4420 |
+
$p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
|
4421 |
+
else
|
4422 |
+
$p_header['filename'] = '';
|
4423 |
+
|
4424 |
+
// ----- Get extra
|
4425 |
+
if ($p_header['extra_len'] != 0)
|
4426 |
+
$p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
|
4427 |
+
else
|
4428 |
+
$p_header['extra'] = '';
|
4429 |
+
|
4430 |
+
// ----- Get comment
|
4431 |
+
if ($p_header['comment_len'] != 0)
|
4432 |
+
$p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
|
4433 |
+
else
|
4434 |
+
$p_header['comment'] = '';
|
4435 |
+
|
4436 |
+
// ----- Extract properties
|
4437 |
+
|
4438 |
+
// ----- Recuperate date in UNIX format
|
4439 |
+
//if ($p_header['mdate'] && $p_header['mtime'])
|
4440 |
+
// TBC : bug : this was ignoring time with 0/0/0
|
4441 |
+
if (1)
|
4442 |
+
{
|
4443 |
+
// ----- Extract time
|
4444 |
+
$v_hour = ($p_header['mtime'] & 0xF800) >> 11;
|
4445 |
+
$v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
|
4446 |
+
$v_seconde = ($p_header['mtime'] & 0x001F)*2;
|
4447 |
+
|
4448 |
+
// ----- Extract date
|
4449 |
+
$v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
|
4450 |
+
$v_month = ($p_header['mdate'] & 0x01E0) >> 5;
|
4451 |
+
$v_day = $p_header['mdate'] & 0x001F;
|
4452 |
+
|
4453 |
+
// ----- Get UNIX date format
|
4454 |
+
$p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
|
4455 |
+
|
4456 |
+
}
|
4457 |
+
else
|
4458 |
+
{
|
4459 |
+
$p_header['mtime'] = time();
|
4460 |
+
}
|
4461 |
+
|
4462 |
+
// ----- Set the stored filename
|
4463 |
+
$p_header['stored_filename'] = $p_header['filename'];
|
4464 |
+
|
4465 |
+
// ----- Set default status to ok
|
4466 |
+
$p_header['status'] = 'ok';
|
4467 |
+
|
4468 |
+
// ----- Look if it is a directory
|
4469 |
+
if (substr($p_header['filename'], -1) == '/') {
|
4470 |
+
//$p_header['external'] = 0x41FF0010;
|
4471 |
+
$p_header['external'] = 0x00000010;
|
4472 |
+
}
|
4473 |
+
|
4474 |
+
|
4475 |
+
// ----- Return
|
4476 |
+
return $v_result;
|
4477 |
+
}
|
4478 |
+
// --------------------------------------------------------------------------------
|
4479 |
+
|
4480 |
+
// --------------------------------------------------------------------------------
|
4481 |
+
// Function : privCheckFileHeaders()
|
4482 |
+
// Description :
|
4483 |
+
// Parameters :
|
4484 |
+
// Return Values :
|
4485 |
+
// 1 on success,
|
4486 |
+
// 0 on error;
|
4487 |
+
// --------------------------------------------------------------------------------
|
4488 |
+
function privCheckFileHeaders(&$p_local_header, &$p_central_header)
|
4489 |
+
{
|
4490 |
+
$v_result=1;
|
4491 |
+
|
4492 |
+
// ----- Check the static values
|
4493 |
+
// TBC
|
4494 |
+
if ($p_local_header['filename'] != $p_central_header['filename']) {
|
4495 |
+
}
|
4496 |
+
if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) {
|
4497 |
+
}
|
4498 |
+
if ($p_local_header['flag'] != $p_central_header['flag']) {
|
4499 |
+
}
|
4500 |
+
if ($p_local_header['compression'] != $p_central_header['compression']) {
|
4501 |
+
}
|
4502 |
+
if ($p_local_header['mtime'] != $p_central_header['mtime']) {
|
4503 |
+
}
|
4504 |
+
if ($p_local_header['filename_len'] != $p_central_header['filename_len']) {
|
4505 |
+
}
|
4506 |
+
|
4507 |
+
// ----- Look for flag bit 3
|
4508 |
+
if (($p_local_header['flag'] & 8) == 8) {
|
4509 |
+
$p_local_header['size'] = $p_central_header['size'];
|
4510 |
+
$p_local_header['compressed_size'] = $p_central_header['compressed_size'];
|
4511 |
+
$p_local_header['crc'] = $p_central_header['crc'];
|
4512 |
+
}
|
4513 |
+
|
4514 |
+
// ----- Return
|
4515 |
+
return $v_result;
|
4516 |
+
}
|
4517 |
+
// --------------------------------------------------------------------------------
|
4518 |
+
|
4519 |
+
// --------------------------------------------------------------------------------
|
4520 |
+
// Function : privReadEndCentralDir()
|
4521 |
+
// Description :
|
4522 |
+
// Parameters :
|
4523 |
+
// Return Values :
|
4524 |
+
// --------------------------------------------------------------------------------
|
4525 |
+
function privReadEndCentralDir(&$p_central_dir)
|
4526 |
+
{
|
4527 |
+
$v_result=1;
|
4528 |
+
|
4529 |
+
// ----- Go to the end of the zip file
|
4530 |
+
$v_size = filesize($this->zipname);
|
4531 |
+
@fseek($this->zip_fd, $v_size);
|
4532 |
+
if (@ftell($this->zip_fd) != $v_size)
|
4533 |
+
{
|
4534 |
+
// ----- Error log
|
4535 |
+
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
|
4536 |
+
|
4537 |
+
// ----- Return
|
4538 |
+
return PclZip::errorCode();
|
4539 |
+
}
|
4540 |
+
|
4541 |
+
// ----- First try : look if this is an archive with no commentaries (most of the time)
|
4542 |
+
// in this case the end of central dir is at 22 bytes of the file end
|
4543 |
+
$v_found = 0;
|
4544 |
+
if ($v_size > 26) {
|
4545 |
+
@fseek($this->zip_fd, $v_size-22);
|
4546 |
+
if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
|
4547 |
+
{
|
4548 |
+
// ----- Error log
|
4549 |
+
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
|
4550 |
+
|
4551 |
+
// ----- Return
|
4552 |
+
return PclZip::errorCode();
|
4553 |
+
}
|
4554 |
+
|
4555 |
+
// ----- Read for bytes
|
4556 |
+
$v_binary_data = @fread($this->zip_fd, 4);
|
4557 |
+
$v_data = @unpack('Vid', $v_binary_data);
|
4558 |
+
|
4559 |
+
// ----- Check signature
|
4560 |
+
if ($v_data['id'] == 0x06054b50) {
|
4561 |
+
$v_found = 1;
|
4562 |
+
}
|
4563 |
+
|
4564 |
+
$v_pos = ftell($this->zip_fd);
|
4565 |
+
}
|
4566 |
+
|
4567 |
+
// ----- Go back to the maximum possible size of the Central Dir End Record
|
4568 |
+
if (!$v_found) {
|
4569 |
+
$v_maximum_size = 65557; // 0xFFFF + 22;
|
4570 |
+
if ($v_maximum_size > $v_size)
|
4571 |
+
$v_maximum_size = $v_size;
|
4572 |
+
@fseek($this->zip_fd, $v_size-$v_maximum_size);
|
4573 |
+
if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
|
4574 |
+
{
|
4575 |
+
// ----- Error log
|
4576 |
+
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
|
4577 |
+
|
4578 |
+
// ----- Return
|
4579 |
+
return PclZip::errorCode();
|
4580 |
+
}
|
4581 |
+
|
4582 |
+
// ----- Read byte per byte in order to find the signature
|
4583 |
+
$v_pos = ftell($this->zip_fd);
|
4584 |
+
$v_bytes = 0x00000000;
|
4585 |
+
while ($v_pos < $v_size)
|
4586 |
+
{
|
4587 |
+
// ----- Read a byte
|
4588 |
+
$v_byte = @fread($this->zip_fd, 1);
|
4589 |
+
|
4590 |
+
// ----- Add the byte
|
4591 |
+
//$v_bytes = ($v_bytes << 8) | Ord($v_byte);
|
4592 |
+
// Note we mask the old value down such that once shifted we can never end up with more than a 32bit number
|
4593 |
+
// Otherwise on systems where we have 64bit integers the check below for the magic number will fail.
|
4594 |
+
$v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
|
4595 |
+
|
4596 |
+
// ----- Compare the bytes
|
4597 |
+
if ($v_bytes == 0x504b0506)
|
4598 |
+
{
|
4599 |
+
$v_pos++;
|
4600 |
+
break;
|
4601 |
+
}
|
4602 |
+
|
4603 |
+
$v_pos++;
|
4604 |
+
}
|
4605 |
+
|
4606 |
+
// ----- Look if not found end of central dir
|
4607 |
+
if ($v_pos == $v_size)
|
4608 |
+
{
|
4609 |
+
|
4610 |
+
// ----- Error log
|
4611 |
+
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
|
4612 |
+
|
4613 |
+
// ----- Return
|
4614 |
+
return PclZip::errorCode();
|
4615 |
+
}
|
4616 |
+
}
|
4617 |
+
|
4618 |
+
// ----- Read the first 18 bytes of the header
|
4619 |
+
$v_binary_data = fread($this->zip_fd, 18);
|
4620 |
+
|
4621 |
+
// ----- Look for invalid block size
|
4622 |
+
if (strlen($v_binary_data) != 18)
|
4623 |
+
{
|
4624 |
+
|
4625 |
+
// ----- Error log
|
4626 |
+
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
|
4627 |
+
|
4628 |
+
// ----- Return
|
4629 |
+
return PclZip::errorCode();
|
4630 |
+
}
|
4631 |
+
|
4632 |
+
// ----- Extract the values
|
4633 |
+
$v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
|
4634 |
+
|
4635 |
+
// ----- Check the global size
|
4636 |
+
if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
|
4637 |
+
|
4638 |
+
// ----- Removed in release 2.2 see readme file
|
4639 |
+
// The check of the file size is a little too strict.
|
4640 |
+
// Some bugs where found when a zip is encrypted/decrypted with 'crypt'.
|
4641 |
+
// While decrypted, zip has training 0 bytes
|
4642 |
+
if (0) {
|
4643 |
+
// ----- Error log
|
4644 |
+
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT,
|
4645 |
+
'The central dir is not at the end of the archive.'
|
4646 |
+
.' Some trailing bytes exists after the archive.');
|
4647 |
+
|
4648 |
+
// ----- Return
|
4649 |
+
return PclZip::errorCode();
|
4650 |
+
}
|
4651 |
+
}
|
4652 |
+
|
4653 |
+
// ----- Get comment
|
4654 |
+
if ($v_data['comment_size'] != 0) {
|
4655 |
+
$p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
|
4656 |
+
}
|
4657 |
+
else
|
4658 |
+
$p_central_dir['comment'] = '';
|
4659 |
+
|
4660 |
+
$p_central_dir['entries'] = $v_data['entries'];
|
4661 |
+
$p_central_dir['disk_entries'] = $v_data['disk_entries'];
|
4662 |
+
$p_central_dir['offset'] = $v_data['offset'];
|
4663 |
+
$p_central_dir['size'] = $v_data['size'];
|
4664 |
+
$p_central_dir['disk'] = $v_data['disk'];
|
4665 |
+
$p_central_dir['disk_start'] = $v_data['disk_start'];
|
4666 |
+
|
4667 |
+
// TBC
|
4668 |
+
//for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
|
4669 |
+
//}
|
4670 |
+
|
4671 |
+
// ----- Return
|
4672 |
+
return $v_result;
|
4673 |
+
}
|
4674 |
+
// --------------------------------------------------------------------------------
|
4675 |
+
|
4676 |
+
// --------------------------------------------------------------------------------
|
4677 |
+
// Function : privDeleteByRule()
|
4678 |
+
// Description :
|
4679 |
+
// Parameters :
|
4680 |
+
// Return Values :
|
4681 |
+
// --------------------------------------------------------------------------------
|
4682 |
+
function privDeleteByRule(&$p_result_list, &$p_options)
|
4683 |
+
{
|
4684 |
+
$v_result=1;
|
4685 |
+
$v_list_detail = array();
|
4686 |
+
|
4687 |
+
// ----- Open the zip file
|
4688 |
+
if (($v_result=$this->privOpenFd('rb')) != 1)
|
4689 |
+
{
|
4690 |
+
// ----- Return
|
4691 |
+
return $v_result;
|
4692 |
+
}
|
4693 |
+
|
4694 |
+
// ----- Read the central directory informations
|
4695 |
+
$v_central_dir = array();
|
4696 |
+
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
|
4697 |
+
{
|
4698 |
+
$this->privCloseFd();
|
4699 |
+
return $v_result;
|
4700 |
+
}
|
4701 |
+
|
4702 |
+
// ----- Go to beginning of File
|
4703 |
+
@rewind($this->zip_fd);
|
4704 |
+
|
4705 |
+
// ----- Scan all the files
|
4706 |
+
// ----- Start at beginning of Central Dir
|
4707 |
+
$v_pos_entry = $v_central_dir['offset'];
|
4708 |
+
@rewind($this->zip_fd);
|
4709 |
+
if (@fseek($this->zip_fd, $v_pos_entry))
|
4710 |
+
{
|
4711 |
+
// ----- Close the zip file
|
4712 |
+
$this->privCloseFd();
|
4713 |
+
|
4714 |
+
// ----- Error log
|
4715 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
|
4716 |
+
|
4717 |
+
// ----- Return
|
4718 |
+
return PclZip::errorCode();
|
4719 |
+
}
|
4720 |
+
|
4721 |
+
// ----- Read each entry
|
4722 |
+
$v_header_list = array();
|
4723 |
+
$j_start = 0;
|
4724 |
+
for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
|
4725 |
+
{
|
4726 |
+
|
4727 |
+
// ----- Read the file header
|
4728 |
+
$v_header_list[$v_nb_extracted] = array();
|
4729 |
+
if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)
|
4730 |
+
{
|
4731 |
+
// ----- Close the zip file
|
4732 |
+
$this->privCloseFd();
|
4733 |
+
|
4734 |
+
return $v_result;
|
4735 |
+
}
|
4736 |
+
|
4737 |
+
|
4738 |
+
// ----- Store the index
|
4739 |
+
$v_header_list[$v_nb_extracted]['index'] = $i;
|
4740 |
+
|
4741 |
+
// ----- Look for the specific extract rules
|
4742 |
+
$v_found = false;
|
4743 |
+
|
4744 |
+
// ----- Look for extract by name rule
|
4745 |
+
if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
|
4746 |
+
&& ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
|
4747 |
+
|
4748 |
+
// ----- Look if the filename is in the list
|
4749 |
+
for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
|
4750 |
+
|
4751 |
+
// ----- Look for a directory
|
4752 |
+
if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
|
4753 |
+
|
4754 |
+
// ----- Look if the directory is in the filename path
|
4755 |
+
if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
|
4756 |
+
&& (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
|
4757 |
+
$v_found = true;
|
4758 |
+
}
|
4759 |
+
elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
|
4760 |
+
&& ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
|
4761 |
+
$v_found = true;
|
4762 |
+
}
|
4763 |
+
}
|
4764 |
+
// ----- Look for a filename
|
4765 |
+
elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
|
4766 |
+
$v_found = true;
|
4767 |
+
}
|
4768 |
+
}
|
4769 |
+
}
|
4770 |
+
|
4771 |
+
// ----- Look for extract by ereg rule
|
4772 |
+
// ereg() is deprecated with PHP 5.3
|
4773 |
+
/*
|
4774 |
+
else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
|
4775 |
+
&& ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
|
4776 |
+
|
4777 |
+
if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
|
4778 |
+
$v_found = true;
|
4779 |
+
}
|
4780 |
+
}
|
4781 |
+
*/
|
4782 |
+
|
4783 |
+
// ----- Look for extract by preg rule
|
4784 |
+
else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
|
4785 |
+
&& ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
|
4786 |
+
|
4787 |
+
if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
|
4788 |
+
$v_found = true;
|
4789 |
+
}
|
4790 |
+
}
|
4791 |
+
|
4792 |
+
// ----- Look for extract by index rule
|
4793 |
+
else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
|
4794 |
+
&& ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
|
4795 |
+
|
4796 |
+
// ----- Look if the index is in the list
|
4797 |
+
for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
|
4798 |
+
|
4799 |
+
if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
|
4800 |
+
$v_found = true;
|
4801 |
+
}
|
4802 |
+
if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
|
4803 |
+
$j_start = $j+1;
|
4804 |
+
}
|
4805 |
+
|
4806 |
+
if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
|
4807 |
+
break;
|
4808 |
+
}
|
4809 |
+
}
|
4810 |
+
}
|
4811 |
+
else {
|
4812 |
+
$v_found = true;
|
4813 |
+
}
|
4814 |
+
|
4815 |
+
// ----- Look for deletion
|
4816 |
+
if ($v_found)
|
4817 |
+
{
|
4818 |
+
unset($v_header_list[$v_nb_extracted]);
|
4819 |
+
}
|
4820 |
+
else
|
4821 |
+
{
|
4822 |
+
$v_nb_extracted++;
|
4823 |
+
}
|
4824 |
+
}
|
4825 |
+
|
4826 |
+
// ----- Look if something need to be deleted
|
4827 |
+
if ($v_nb_extracted > 0) {
|
4828 |
+
|
4829 |
+
// ----- Creates a temporay file
|
4830 |
+
$v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
|
4831 |
+
|
4832 |
+
// ----- Creates a temporary zip archive
|
4833 |
+
$v_temp_zip = new PclZip($v_zip_temp_name);
|
4834 |
+
|
4835 |
+
// ----- Open the temporary zip file in write mode
|
4836 |
+
if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
|
4837 |
+
$this->privCloseFd();
|
4838 |
+
|
4839 |
+
// ----- Return
|
4840 |
+
return $v_result;
|
4841 |
+
}
|
4842 |
+
|
4843 |
+
// ----- Look which file need to be kept
|
4844 |
+
for ($i=0; $i<sizeof($v_header_list); $i++) {
|
4845 |
+
|
4846 |
+
// ----- Calculate the position of the header
|
4847 |
+
@rewind($this->zip_fd);
|
4848 |
+
if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) {
|
4849 |
+
// ----- Close the zip file
|
4850 |
+
$this->privCloseFd();
|
4851 |
+
$v_temp_zip->privCloseFd();
|
4852 |
+
@unlink($v_zip_temp_name);
|
4853 |
+
|
4854 |
+
// ----- Error log
|
4855 |
+
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
|
4856 |
+
|
4857 |
+
// ----- Return
|
4858 |
+
return PclZip::errorCode();
|
4859 |
+
}
|
4860 |
+
|
4861 |
+
// ----- Read the file header
|
4862 |
+
$v_local_header = array();
|
4863 |
+
if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) {
|
4864 |
+
// ----- Close the zip file
|
4865 |
+
$this->privCloseFd();
|
4866 |
+
$v_temp_zip->privCloseFd();
|
4867 |
+
@unlink($v_zip_temp_name);
|
4868 |
+
|
4869 |
+
// ----- Return
|
4870 |
+
return $v_result;
|
4871 |
+
}
|
4872 |
+
|
4873 |
+
// ----- Check that local file header is same as central file header
|
4874 |
+
if ($this->privCheckFileHeaders($v_local_header,
|
4875 |
+
$v_header_list[$i]) != 1) {
|
4876 |
+
// TBC
|
4877 |
+
}
|
4878 |
+
unset($v_local_header);
|
4879 |
+
|
4880 |
+
// ----- Write the file header
|
4881 |
+
if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) {
|
4882 |
+
// ----- Close the zip file
|
4883 |
+
$this->privCloseFd();
|
4884 |
+
$v_temp_zip->privCloseFd();
|
4885 |
+
@unlink($v_zip_temp_name);
|
4886 |
+
|
4887 |
+
// ----- Return
|
4888 |
+
return $v_result;
|
4889 |
+
}
|
4890 |
+
|
4891 |
+
// ----- Read/write the data block
|
4892 |
+
if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
|
4893 |
+
// ----- Close the zip file
|
4894 |
+
$this->privCloseFd();
|
4895 |
+
$v_temp_zip->privCloseFd();
|
4896 |
+
@unlink($v_zip_temp_name);
|
4897 |
+
|
4898 |
+
// ----- Return
|
4899 |
+
return $v_result;
|
4900 |
+
}
|
4901 |
+
}
|
4902 |
+
|
4903 |
+
// ----- Store the offset of the central dir
|
4904 |
+
$v_offset = @ftell($v_temp_zip->zip_fd);
|
4905 |
+
|
4906 |
+
// ----- Re-Create the Central Dir files header
|
4907 |
+
for ($i=0; $i<sizeof($v_header_list); $i++) {
|
4908 |
+
// ----- Create the file header
|
4909 |
+
if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
|
4910 |
+
$v_temp_zip->privCloseFd();
|
4911 |
+
$this->privCloseFd();
|
4912 |
+
@unlink($v_zip_temp_name);
|
4913 |
+
|
4914 |
+
// ----- Return
|
4915 |
+
return $v_result;
|
4916 |
+
}
|
4917 |
+
|
4918 |
+
// ----- Transform the header to a 'usable' info
|
4919 |
+
$v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
|
4920 |
+
}
|
4921 |
+
|
4922 |
+
|
4923 |
+
// ----- Zip file comment
|
4924 |
+
$v_comment = '';
|
4925 |
+
if (isset($p_options[PCLZIP_OPT_COMMENT])) {
|
4926 |
+
$v_comment = $p_options[PCLZIP_OPT_COMMENT];
|
4927 |
+
}
|
4928 |
+
|
4929 |
+
// ----- Calculate the size of the central header
|
4930 |
+
$v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
|
4931 |
+
|
4932 |
+
// ----- Create the central dir footer
|
4933 |
+
if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
|
4934 |
+
// ----- Reset the file list
|
4935 |
+
unset($v_header_list);
|
4936 |
+
$v_temp_zip->privCloseFd();
|
4937 |
+
$this->privCloseFd();
|
4938 |
+
@unlink($v_zip_temp_name);
|
4939 |
+
|
4940 |
+
// ----- Return
|
4941 |
+
return $v_result;
|
4942 |
+
}
|
4943 |
+
|
4944 |
+
// ----- Close
|
4945 |
+
$v_temp_zip->privCloseFd();
|
4946 |
+
$this->privCloseFd();
|
4947 |
+
|
4948 |
+
// ----- Delete the zip file
|
4949 |
+
// TBC : I should test the result ...
|
4950 |
+
@unlink($this->zipname);
|
4951 |
+
|
4952 |
+
// ----- Rename the temporary file
|
4953 |
+
// TBC : I should test the result ...
|
4954 |
+
//@rename($v_zip_temp_name, $this->zipname);
|
4955 |
+
PclZipUtilRename($v_zip_temp_name, $this->zipname);
|
4956 |
+
|
4957 |
+
// ----- Destroy the temporary archive
|
4958 |
+
unset($v_temp_zip);
|
4959 |
+
}
|
4960 |
+
|
4961 |
+
// ----- Remove every files : reset the file
|
4962 |
+
else if ($v_central_dir['entries'] != 0) {
|
4963 |
+
$this->privCloseFd();
|
4964 |
+
|
4965 |
+
if (($v_result = $this->privOpenFd('wb')) != 1) {
|
4966 |
+
return $v_result;
|
4967 |
+
}
|
4968 |
+
|
4969 |
+
if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
|
4970 |
+
return $v_result;
|
4971 |
+
}
|
4972 |
+
|
4973 |
+
$this->privCloseFd();
|
4974 |
+
}
|
4975 |
+
|
4976 |
+
// ----- Return
|
4977 |
+
return $v_result;
|
4978 |
+
}
|
4979 |
+
// --------------------------------------------------------------------------------
|
4980 |
+
|
4981 |
+
// --------------------------------------------------------------------------------
|
4982 |
+
// Function : privDirCheck()
|
4983 |
+
// Description :
|
4984 |
+
// Check if a directory exists, if not it creates it and all the parents directory
|
4985 |
+
// which may be useful.
|
4986 |
+
// Parameters :
|
4987 |
+
// $p_dir : Directory path to check.
|
4988 |
+
// Return Values :
|
4989 |
+
// 1 : OK
|
4990 |
+
// -1 : Unable to create directory
|
4991 |
+
// --------------------------------------------------------------------------------
|
4992 |
+
function privDirCheck($p_dir, $p_is_dir=false)
|
4993 |
+
{
|
4994 |
+
$v_result = 1;
|
4995 |
+
|
4996 |
+
|
4997 |
+
// ----- Remove the final '/'
|
4998 |
+
if (($p_is_dir) && (substr($p_dir, -1)=='/'))
|
4999 |
+
{
|
5000 |
+
$p_dir = substr($p_dir, 0, strlen($p_dir)-1);
|
5001 |
+
}
|
5002 |
+
|
5003 |
+
// ----- Check the directory availability
|
5004 |
+
if ((is_dir($p_dir)) || ($p_dir == ""))
|
5005 |
+
{
|
5006 |
+
return 1;
|
5007 |
+
}
|
5008 |
+
|
5009 |
+
// ----- Extract parent directory
|
5010 |
+
$p_parent_dir = dirname($p_dir);
|
5011 |
+
|
5012 |
+
// ----- Just a check
|
5013 |
+
if ($p_parent_dir != $p_dir)
|
5014 |
+
{
|
5015 |
+
// ----- Look for parent directory
|
5016 |
+
if ($p_parent_dir != "")
|
5017 |
+
{
|
5018 |
+
if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
|
5019 |
+
{
|
5020 |
+
return $v_result;
|
5021 |
+
}
|
5022 |
+
}
|
5023 |
+
}
|
5024 |
+
|
5025 |
+
// ----- Create the directory
|
5026 |
+
if (!@mkdir($p_dir, 0777))
|
5027 |
+
{
|
5028 |
+
// ----- Error log
|
5029 |
+
PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
|
5030 |
+
|
5031 |
+
// ----- Return
|
5032 |
+
return PclZip::errorCode();
|
5033 |
+
}
|
5034 |
+
|
5035 |
+
// ----- Return
|
5036 |
+
return $v_result;
|
5037 |
+
}
|
5038 |
+
// --------------------------------------------------------------------------------
|
5039 |
+
|
5040 |
+
// --------------------------------------------------------------------------------
|
5041 |
+
// Function : privMerge()
|
5042 |
+
// Description :
|
5043 |
+
// If $p_archive_to_add does not exist, the function exit with a success result.
|
5044 |
+
// Parameters :
|
5045 |
+
// Return Values :
|
5046 |
+
// --------------------------------------------------------------------------------
|
5047 |
+
function privMerge(&$p_archive_to_add)
|
5048 |
+
{
|
5049 |
+
$v_result=1;
|
5050 |
+
|
5051 |
+
// ----- Look if the archive_to_add exists
|
5052 |
+
if (!is_file($p_archive_to_add->zipname))
|
5053 |
+
{
|
5054 |
+
|
5055 |
+
// ----- Nothing to merge, so merge is a success
|
5056 |
+
$v_result = 1;
|
5057 |
+
|
5058 |
+
// ----- Return
|
5059 |
+
return $v_result;
|
5060 |
+
}
|
5061 |
+
|
5062 |
+
// ----- Look if the archive exists
|
5063 |
+
if (!is_file($this->zipname))
|
5064 |
+
{
|
5065 |
+
|
5066 |
+
// ----- Do a duplicate
|
5067 |
+
$v_result = $this->privDuplicate($p_archive_to_add->zipname);
|
5068 |
+
|
5069 |
+
// ----- Return
|
5070 |
+
return $v_result;
|
5071 |
+
}
|
5072 |
+
|
5073 |
+
// ----- Open the zip file
|
5074 |
+
if (($v_result=$this->privOpenFd('rb')) != 1)
|
5075 |
+
{
|
5076 |
+
// ----- Return
|
5077 |
+
return $v_result;
|
5078 |
+
}
|
5079 |
+
|
5080 |
+
// ----- Read the central directory informations
|
5081 |
+
$v_central_dir = array();
|
5082 |
+
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
|
5083 |
+
{
|
5084 |
+
$this->privCloseFd();
|
5085 |
+
return $v_result;
|
5086 |
+
}
|
5087 |
+
|
5088 |
+
// ----- Go to beginning of File
|
5089 |
+
@rewind($this->zip_fd);
|
5090 |
+
|
5091 |
+
// ----- Open the archive_to_add file
|
5092 |
+
if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
|
5093 |
+
{
|
5094 |
+
$this->privCloseFd();
|
5095 |
+
|
5096 |
+
// ----- Return
|
5097 |
+
return $v_result;
|
5098 |
+
}
|
5099 |
+
|
5100 |
+
// ----- Read the central directory informations
|
5101 |
+
$v_central_dir_to_add = array();
|
5102 |
+
if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)
|
5103 |
+
{
|
5104 |
+
$this->privCloseFd();
|
5105 |
+
$p_archive_to_add->privCloseFd();
|
5106 |
+
|
5107 |
+
return $v_result;
|
5108 |
+
}
|
5109 |
+
|
5110 |
+
// ----- Go to beginning of File
|
5111 |
+
@rewind($p_archive_to_add->zip_fd);
|
5112 |
+
|
5113 |
+
// ----- Creates a temporay file
|
5114 |
+
$v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
|
5115 |
+
|
5116 |
+
// ----- Open the temporary file in write mode
|
5117 |
+
if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
|
5118 |
+
{
|
5119 |
+
$this->privCloseFd();
|
5120 |
+
$p_archive_to_add->privCloseFd();
|
5121 |
+
|
5122 |
+
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
|
5123 |
+
|
5124 |
+
// ----- Return
|
5125 |
+
return PclZip::errorCode();
|
5126 |
+
}
|
5127 |
+
|
5128 |
+
// ----- Copy the files from the archive to the temporary file
|
5129 |
+
// TBC : Here I should better append the file and go back to erase the central dir
|
5130 |
+
$v_size = $v_central_dir['offset'];
|
5131 |
+
while ($v_size != 0)
|
5132 |
+
{
|
5133 |
+
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
|
5134 |
+
$v_buffer = fread($this->zip_fd, $v_read_size);
|
5135 |
+
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
|
5136 |
+
$v_size -= $v_read_size;
|
5137 |
+
}
|
5138 |
+
|
5139 |
+
// ----- Copy the files from the archive_to_add into the temporary file
|
5140 |
+
$v_size = $v_central_dir_to_add['offset'];
|
5141 |
+
while ($v_size != 0)
|
5142 |
+
{
|
5143 |
+
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
|
5144 |
+
$v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
|
5145 |
+
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
|
5146 |
+
$v_size -= $v_read_size;
|
5147 |
+
}
|
5148 |
+
|
5149 |
+
// ----- Store the offset of the central dir
|
5150 |
+
$v_offset = @ftell($v_zip_temp_fd);
|
5151 |
+
|
5152 |
+
// ----- Copy the block of file headers from the old archive
|
5153 |
+
$v_size = $v_central_dir['size'];
|
5154 |
+
while ($v_size != 0)
|
5155 |
+
{
|
5156 |
+
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
|
5157 |
+
$v_buffer = @fread($this->zip_fd, $v_read_size);
|
5158 |
+
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
|
5159 |
+
$v_size -= $v_read_size;
|
5160 |
+
}
|
5161 |
+
|
5162 |
+
// ----- Copy the block of file headers from the archive_to_add
|
5163 |
+
$v_size = $v_central_dir_to_add['size'];
|
5164 |
+
while ($v_size != 0)
|
5165 |
+
{
|
5166 |
+
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
|
5167 |
+
$v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
|
5168 |
+
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
|
5169 |
+
$v_size -= $v_read_size;
|
5170 |
+
}
|
5171 |
+
|
5172 |
+
// ----- Merge the file comments
|
5173 |
+
$v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment'];
|
5174 |
+
|
5175 |
+
// ----- Calculate the size of the (new) central header
|
5176 |
+
$v_size = @ftell($v_zip_temp_fd)-$v_offset;
|
5177 |
+
|
5178 |
+
// ----- Swap the file descriptor
|
5179 |
+
// Here is a trick : I swap the temporary fd with the zip fd, in order to use
|
5180 |
+
// the following methods on the temporary fil and not the real archive fd
|
5181 |
+
$v_swap = $this->zip_fd;
|
5182 |
+
$this->zip_fd = $v_zip_temp_fd;
|
5183 |
+
$v_zip_temp_fd = $v_swap;
|
5184 |
+
|
5185 |
+
// ----- Create the central dir footer
|
5186 |
+
if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
|
5187 |
+
{
|
5188 |
+
$this->privCloseFd();
|
5189 |
+
$p_archive_to_add->privCloseFd();
|
5190 |
+
@fclose($v_zip_temp_fd);
|
5191 |
+
$this->zip_fd = null;
|
5192 |
+
|
5193 |
+
// ----- Reset the file list
|
5194 |
+
unset($v_header_list);
|
5195 |
+
|
5196 |
+
// ----- Return
|
5197 |
+
return $v_result;
|
5198 |
+
}
|
5199 |
+
|
5200 |
+
// ----- Swap back the file descriptor
|
5201 |
+
$v_swap = $this->zip_fd;
|
5202 |
+
$this->zip_fd = $v_zip_temp_fd;
|
5203 |
+
$v_zip_temp_fd = $v_swap;
|
5204 |
+
|
5205 |
+
// ----- Close
|
5206 |
+
$this->privCloseFd();
|
5207 |
+
$p_archive_to_add->privCloseFd();
|
5208 |
+
|
5209 |
+
// ----- Close the temporary file
|
5210 |
+
@fclose($v_zip_temp_fd);
|
5211 |
+
|
5212 |
+
// ----- Delete the zip file
|
5213 |
+
// TBC : I should test the result ...
|
5214 |
+
@unlink($this->zipname);
|
5215 |
+
|
5216 |
+
// ----- Rename the temporary file
|
5217 |
+
// TBC : I should test the result ...
|
5218 |
+
//@rename($v_zip_temp_name, $this->zipname);
|
5219 |
+
PclZipUtilRename($v_zip_temp_name, $this->zipname);
|
5220 |
+
|
5221 |
+
// ----- Return
|
5222 |
+
return $v_result;
|
5223 |
+
}
|
5224 |
+
// --------------------------------------------------------------------------------
|
5225 |
+
|
5226 |
+
// --------------------------------------------------------------------------------
|
5227 |
+
// Function : privDuplicate()
|
5228 |
+
// Description :
|
5229 |
+
// Parameters :
|
5230 |
+
// Return Values :
|
5231 |
+
// --------------------------------------------------------------------------------
|
5232 |
+
function privDuplicate($p_archive_filename)
|
5233 |
+
{
|
5234 |
+
$v_result=1;
|
5235 |
+
|
5236 |
+
// ----- Look if the $p_archive_filename exists
|
5237 |
+
if (!is_file($p_archive_filename))
|
5238 |
+
{
|
5239 |
+
|
5240 |
+
// ----- Nothing to duplicate, so duplicate is a success.
|
5241 |
+
$v_result = 1;
|
5242 |
+
|
5243 |
+
// ----- Return
|
5244 |
+
return $v_result;
|
5245 |
+
}
|
5246 |
+
|
5247 |
+
// ----- Open the zip file
|
5248 |
+
if (($v_result=$this->privOpenFd('wb')) != 1)
|
5249 |
+
{
|
5250 |
+
// ----- Return
|
5251 |
+
return $v_result;
|
5252 |
+
}
|
5253 |
+
|
5254 |
+
// ----- Open the temporary file in write mode
|
5255 |
+
if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
|
5256 |
+
{
|
5257 |
+
$this->privCloseFd();
|
5258 |
+
|
5259 |
+
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
|
5260 |
+
|
5261 |
+
// ----- Return
|
5262 |
+
return PclZip::errorCode();
|
5263 |
+
}
|
5264 |
+
|
5265 |
+
// ----- Copy the files from the archive to the temporary file
|
5266 |
+
// TBC : Here I should better append the file and go back to erase the central dir
|
5267 |
+
$v_size = filesize($p_archive_filename);
|
5268 |
+
while ($v_size != 0)
|
5269 |
+
{
|
5270 |
+
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
|
5271 |
+
$v_buffer = fread($v_zip_temp_fd, $v_read_size);
|
5272 |
+
@fwrite($this->zip_fd, $v_buffer, $v_read_size);
|
5273 |
+
$v_size -= $v_read_size;
|
5274 |
+
}
|
5275 |
+
|
5276 |
+
// ----- Close
|
5277 |
+
$this->privCloseFd();
|
5278 |
+
|
5279 |
+
// ----- Close the temporary file
|
5280 |
+
@fclose($v_zip_temp_fd);
|
5281 |
+
|
5282 |
+
// ----- Return
|
5283 |
+
return $v_result;
|
5284 |
+
}
|
5285 |
+
// --------------------------------------------------------------------------------
|
5286 |
+
|
5287 |
+
// --------------------------------------------------------------------------------
|
5288 |
+
// Function : privErrorLog()
|
5289 |
+
// Description :
|
5290 |
+
// Parameters :
|
5291 |
+
// --------------------------------------------------------------------------------
|
5292 |
+
function privErrorLog($p_error_code=0, $p_error_string='')
|
5293 |
+
{
|
5294 |
+
if (PCLZIP_ERROR_EXTERNAL == 1) {
|
5295 |
+
PclError($p_error_code, $p_error_string);
|
5296 |
+
}
|
5297 |
+
else {
|
5298 |
+
$this->error_code = $p_error_code;
|
5299 |
+
$this->error_string = $p_error_string;
|
5300 |
+
}
|
5301 |
+
}
|
5302 |
+
// --------------------------------------------------------------------------------
|
5303 |
+
|
5304 |
+
// --------------------------------------------------------------------------------
|
5305 |
+
// Function : privErrorReset()
|
5306 |
+
// Description :
|
5307 |
+
// Parameters :
|
5308 |
+
// --------------------------------------------------------------------------------
|
5309 |
+
function privErrorReset()
|
5310 |
+
{
|
5311 |
+
if (PCLZIP_ERROR_EXTERNAL == 1) {
|
5312 |
+
PclErrorReset();
|
5313 |
+
}
|
5314 |
+
else {
|
5315 |
+
$this->error_code = 0;
|
5316 |
+
$this->error_string = '';
|
5317 |
+
}
|
5318 |
+
}
|
5319 |
+
// --------------------------------------------------------------------------------
|
5320 |
+
|
5321 |
+
// --------------------------------------------------------------------------------
|
5322 |
+
// Function : privDisableMagicQuotes()
|
5323 |
+
// Description :
|
5324 |
+
// Parameters :
|
5325 |
+
// Return Values :
|
5326 |
+
// --------------------------------------------------------------------------------
|
5327 |
+
function privDisableMagicQuotes()
|
5328 |
+
{
|
5329 |
+
$v_result=1;
|
5330 |
+
|
5331 |
+
// ----- Look if function exists
|
5332 |
+
if ( (!function_exists("get_magic_quotes_runtime"))
|
5333 |
+
|| (!function_exists("set_magic_quotes_runtime"))) {
|
5334 |
+
return $v_result;
|
5335 |
+
}
|
5336 |
+
|
5337 |
+
// ----- Look if already done
|
5338 |
+
if ($this->magic_quotes_status != -1) {
|
5339 |
+
return $v_result;
|
5340 |
+
}
|
5341 |
+
|
5342 |
+
// ----- Get and memorize the magic_quote value
|
5343 |
+
$this->magic_quotes_status = @get_magic_quotes_runtime();
|
5344 |
+
|
5345 |
+
// ----- Disable magic_quotes
|
5346 |
+
if ($this->magic_quotes_status == 1) {
|
5347 |
+
@set_magic_quotes_runtime(0);
|
5348 |
+
}
|
5349 |
+
|
5350 |
+
// ----- Return
|
5351 |
+
return $v_result;
|
5352 |
+
}
|
5353 |
+
// --------------------------------------------------------------------------------
|
5354 |
+
|
5355 |
+
// --------------------------------------------------------------------------------
|
5356 |
+
// Function : privSwapBackMagicQuotes()
|
5357 |
+
// Description :
|
5358 |
+
// Parameters :
|
5359 |
+
// Return Values :
|
5360 |
+
// --------------------------------------------------------------------------------
|
5361 |
+
function privSwapBackMagicQuotes()
|
5362 |
+
{
|
5363 |
+
$v_result=1;
|
5364 |
+
|
5365 |
+
// ----- Look if function exists
|
5366 |
+
if ( (!function_exists("get_magic_quotes_runtime"))
|
5367 |
+
|| (!function_exists("set_magic_quotes_runtime"))) {
|
5368 |
+
return $v_result;
|
5369 |
+
}
|
5370 |
+
|
5371 |
+
// ----- Look if something to do
|
5372 |
+
if ($this->magic_quotes_status != -1) {
|
5373 |
+
return $v_result;
|
5374 |
+
}
|
5375 |
+
|
5376 |
+
// ----- Swap back magic_quotes
|
5377 |
+
if ($this->magic_quotes_status == 1) {
|
5378 |
+
@set_magic_quotes_runtime($this->magic_quotes_status);
|
5379 |
+
}
|
5380 |
+
|
5381 |
+
// ----- Return
|
5382 |
+
return $v_result;
|
5383 |
+
}
|
5384 |
+
// --------------------------------------------------------------------------------
|
5385 |
+
|
5386 |
+
}
|
5387 |
+
// End of class
|
5388 |
+
// --------------------------------------------------------------------------------
|
5389 |
+
|
5390 |
+
// --------------------------------------------------------------------------------
|
5391 |
+
// Function : PclZipUtilPathReduction()
|
5392 |
+
// Description :
|
5393 |
+
// Parameters :
|
5394 |
+
// Return Values :
|
5395 |
+
// --------------------------------------------------------------------------------
|
5396 |
+
function PclZipUtilPathReduction($p_dir)
|
5397 |
+
{
|
5398 |
+
$v_result = "";
|
5399 |
+
|
5400 |
+
// ----- Look for not empty path
|
5401 |
+
if ($p_dir != "") {
|
5402 |
+
// ----- Explode path by directory names
|
5403 |
+
$v_list = explode("/", $p_dir);
|
5404 |
+
|
5405 |
+
// ----- Study directories from last to first
|
5406 |
+
$v_skip = 0;
|
5407 |
+
for ($i=sizeof($v_list)-1; $i>=0; $i--) {
|
5408 |
+
// ----- Look for current path
|
5409 |
+
if ($v_list[$i] == ".") {
|
5410 |
+
// ----- Ignore this directory
|
5411 |
+
// Should be the first $i=0, but no check is done
|
5412 |
+
}
|
5413 |
+
else if ($v_list[$i] == "..") {
|
5414 |
+
$v_skip++;
|
5415 |
+
}
|
5416 |
+
else if ($v_list[$i] == "") {
|
5417 |
+
// ----- First '/' i.e. root slash
|
5418 |
+
if ($i == 0) {
|
5419 |
+
$v_result = "/".$v_result;
|
5420 |
+
if ($v_skip > 0) {
|
5421 |
+
// ----- It is an invalid path, so the path is not modified
|
5422 |
+
// TBC
|
5423 |
+
$v_result = $p_dir;
|
5424 |
+
$v_skip = 0;
|
5425 |
+
}
|
5426 |
+
}
|
5427 |
+
// ----- Last '/' i.e. indicates a directory
|
5428 |
+
else if ($i == (sizeof($v_list)-1)) {
|
5429 |
+
$v_result = $v_list[$i];
|
5430 |
+
}
|
5431 |
+
// ----- Double '/' inside the path
|
5432 |
+
else {
|
5433 |
+
// ----- Ignore only the double '//' in path,
|
5434 |
+
// but not the first and last '/'
|
5435 |
+
}
|
5436 |
+
}
|
5437 |
+
else {
|
5438 |
+
// ----- Look for item to skip
|
5439 |
+
if ($v_skip > 0) {
|
5440 |
+
$v_skip--;
|
5441 |
+
}
|
5442 |
+
else {
|
5443 |
+
$v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
|
5444 |
+
}
|
5445 |
+
}
|
5446 |
+
}
|
5447 |
+
|
5448 |
+
// ----- Look for skip
|
5449 |
+
if ($v_skip > 0) {
|
5450 |
+
while ($v_skip > 0) {
|
5451 |
+
$v_result = '../'.$v_result;
|
5452 |
+
$v_skip--;
|
5453 |
+
}
|
5454 |
+
}
|
5455 |
+
}
|
5456 |
+
|
5457 |
+
// ----- Return
|
5458 |
+
return $v_result;
|
5459 |
+
}
|
5460 |
+
// --------------------------------------------------------------------------------
|
5461 |
+
|
5462 |
+
// --------------------------------------------------------------------------------
|
5463 |
+
// Function : PclZipUtilPathInclusion()
|
5464 |
+
// Description :
|
5465 |
+
// This function indicates if the path $p_path is under the $p_dir tree. Or,
|
5466 |
+
// said in an other way, if the file or sub-dir $p_path is inside the dir
|
5467 |
+
// $p_dir.
|
5468 |
+
// The function indicates also if the path is exactly the same as the dir.
|
5469 |
+
// This function supports path with duplicated '/' like '//', but does not
|
5470 |
+
// support '.' or '..' statements.
|
5471 |
+
// Parameters :
|
5472 |
+
// Return Values :
|
5473 |
+
// 0 if $p_path is not inside directory $p_dir
|
5474 |
+
// 1 if $p_path is inside directory $p_dir
|
5475 |
+
// 2 if $p_path is exactly the same as $p_dir
|
5476 |
+
// --------------------------------------------------------------------------------
|
5477 |
+
function PclZipUtilPathInclusion($p_dir, $p_path)
|
5478 |
+
{
|
5479 |
+
$v_result = 1;
|
5480 |
+
|
5481 |
+
// ----- Look for path beginning by ./
|
5482 |
+
if ( ($p_dir == '.')
|
5483 |
+
|| ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
|
5484 |
+
$p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
|
5485 |
+
}
|
5486 |
+
if ( ($p_path == '.')
|
5487 |
+
|| ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
|
5488 |
+
$p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
|
5489 |
+
}
|
5490 |
+
|
5491 |
+
// ----- Explode dir and path by directory separator
|
5492 |
+
$v_list_dir = explode("/", $p_dir);
|
5493 |
+
$v_list_dir_size = sizeof($v_list_dir);
|
5494 |
+
$v_list_path = explode("/", $p_path);
|
5495 |
+
$v_list_path_size = sizeof($v_list_path);
|
5496 |
+
|
5497 |
+
// ----- Study directories paths
|
5498 |
+
$i = 0;
|
5499 |
+
$j = 0;
|
5500 |
+
while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
|
5501 |
+
|
5502 |
+
// ----- Look for empty dir (path reduction)
|
5503 |
+
if ($v_list_dir[$i] == '') {
|
5504 |
+
$i++;
|
5505 |
+
continue;
|
5506 |
+
}
|
5507 |
+
if ($v_list_path[$j] == '') {
|
5508 |
+
$j++;
|
5509 |
+
continue;
|
5510 |
+
}
|
5511 |
+
|
5512 |
+
// ----- Compare the items
|
5513 |
+
if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) {
|
5514 |
+
$v_result = 0;
|
5515 |
+
}
|
5516 |
+
|
5517 |
+
// ----- Next items
|
5518 |
+
$i++;
|
5519 |
+
$j++;
|
5520 |
+
}
|
5521 |
+
|
5522 |
+
// ----- Look if everything seems to be the same
|
5523 |
+
if ($v_result) {
|
5524 |
+
// ----- Skip all the empty items
|
5525 |
+
while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
|
5526 |
+
while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
|
5527 |
+
|
5528 |
+
if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
|
5529 |
+
// ----- There are exactly the same
|
5530 |
+
$v_result = 2;
|
5531 |
+
}
|
5532 |
+
else if ($i < $v_list_dir_size) {
|
5533 |
+
// ----- The path is shorter than the dir
|
5534 |
+
$v_result = 0;
|
5535 |
+
}
|
5536 |
+
}
|
5537 |
+
|
5538 |
+
// ----- Return
|
5539 |
+
return $v_result;
|
5540 |
+
}
|
5541 |
+
// --------------------------------------------------------------------------------
|
5542 |
+
|
5543 |
+
// --------------------------------------------------------------------------------
|
5544 |
+
// Function : PclZipUtilCopyBlock()
|
5545 |
+
// Description :
|
5546 |
+
// Parameters :
|
5547 |
+
// $p_mode : read/write compression mode
|
5548 |
+
// 0 : src & dest normal
|
5549 |
+
// 1 : src gzip, dest normal
|
5550 |
+
// 2 : src normal, dest gzip
|
5551 |
+
// 3 : src & dest gzip
|
5552 |
+
// Return Values :
|
5553 |
+
// --------------------------------------------------------------------------------
|
5554 |
+
function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
|
5555 |
+
{
|
5556 |
+
$v_result = 1;
|
5557 |
+
|
5558 |
+
if ($p_mode==0)
|
5559 |
+
{
|
5560 |
+
while ($p_size != 0)
|
5561 |
+
{
|
5562 |
+
$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
|
5563 |
+
$v_buffer = @fread($p_src, $v_read_size);
|
5564 |
+
@fwrite($p_dest, $v_buffer, $v_read_size);
|
5565 |
+
$p_size -= $v_read_size;
|
5566 |
+
}
|
5567 |
+
}
|
5568 |
+
else if ($p_mode==1)
|
5569 |
+
{
|
5570 |
+
while ($p_size != 0)
|
5571 |
+
{
|
5572 |
+
$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
|
5573 |
+
$v_buffer = @gzread($p_src, $v_read_size);
|
5574 |
+
@fwrite($p_dest, $v_buffer, $v_read_size);
|
5575 |
+
$p_size -= $v_read_size;
|
5576 |
+
}
|
5577 |
+
}
|
5578 |
+
else if ($p_mode==2)
|
5579 |
+
{
|
5580 |
+
while ($p_size != 0)
|
5581 |
+
{
|
5582 |
+
$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
|
5583 |
+
$v_buffer = @fread($p_src, $v_read_size);
|
5584 |
+
@gzwrite($p_dest, $v_buffer, $v_read_size);
|
5585 |
+
$p_size -= $v_read_size;
|
5586 |
+
}
|
5587 |
+
}
|
5588 |
+
else if ($p_mode==3)
|
5589 |
+
{
|
5590 |
+
while ($p_size != 0)
|
5591 |
+
{
|
5592 |
+
$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
|
5593 |
+
$v_buffer = @gzread($p_src, $v_read_size);
|
5594 |
+
@gzwrite($p_dest, $v_buffer, $v_read_size);
|
5595 |
+
$p_size -= $v_read_size;
|
5596 |
+
}
|
5597 |
+
}
|
5598 |
+
|
5599 |
+
// ----- Return
|
5600 |
+
return $v_result;
|
5601 |
+
}
|
5602 |
+
// --------------------------------------------------------------------------------
|
5603 |
+
|
5604 |
+
// --------------------------------------------------------------------------------
|
5605 |
+
// Function : PclZipUtilRename()
|
5606 |
+
// Description :
|
5607 |
+
// This function tries to do a simple rename() function. If it fails, it
|
5608 |
+
// tries to copy the $p_src file in a new $p_dest file and then unlink the
|
5609 |
+
// first one.
|
5610 |
+
// Parameters :
|
5611 |
+
// $p_src : Old filename
|
5612 |
+
// $p_dest : New filename
|
5613 |
+
// Return Values :
|
5614 |
+
// 1 on success, 0 on failure.
|
5615 |
+
// --------------------------------------------------------------------------------
|
5616 |
+
function PclZipUtilRename($p_src, $p_dest)
|
5617 |
+
{
|
5618 |
+
$v_result = 1;
|
5619 |
+
|
5620 |
+
// ----- Try to rename the files
|
5621 |
+
if (!@rename($p_src, $p_dest)) {
|
5622 |
+
|
5623 |
+
// ----- Try to copy & unlink the src
|
5624 |
+
if (!@copy($p_src, $p_dest)) {
|
5625 |
+
$v_result = 0;
|
5626 |
+
}
|
5627 |
+
else if (!@unlink($p_src)) {
|
5628 |
+
$v_result = 0;
|
5629 |
+
}
|
5630 |
+
}
|
5631 |
+
|
5632 |
+
// ----- Return
|
5633 |
+
return $v_result;
|
5634 |
+
}
|
5635 |
+
// --------------------------------------------------------------------------------
|
5636 |
+
|
5637 |
+
// --------------------------------------------------------------------------------
|
5638 |
+
// Function : PclZipUtilOptionText()
|
5639 |
+
// Description :
|
5640 |
+
// Translate option value in text. Mainly for debug purpose.
|
5641 |
+
// Parameters :
|
5642 |
+
// $p_option : the option value.
|
5643 |
+
// Return Values :
|
5644 |
+
// The option text value.
|
5645 |
+
// --------------------------------------------------------------------------------
|
5646 |
+
function PclZipUtilOptionText($p_option)
|
5647 |
+
{
|
5648 |
+
|
5649 |
+
$v_list = get_defined_constants();
|
5650 |
+
for (reset($v_list); $v_key = key($v_list); next($v_list)) {
|
5651 |
+
$v_prefix = substr($v_key, 0, 10);
|
5652 |
+
if (( ($v_prefix == 'PCLZIP_OPT')
|
5653 |
+
|| ($v_prefix == 'PCLZIP_CB_')
|
5654 |
+
|| ($v_prefix == 'PCLZIP_ATT'))
|
5655 |
+
&& ($v_list[$v_key] == $p_option)) {
|
5656 |
+
return $v_key;
|
5657 |
+
}
|
5658 |
+
}
|
5659 |
+
|
5660 |
+
$v_result = 'Unknown';
|
5661 |
+
|
5662 |
+
return $v_result;
|
5663 |
+
}
|
5664 |
+
// --------------------------------------------------------------------------------
|
5665 |
+
|
5666 |
+
// --------------------------------------------------------------------------------
|
5667 |
+
// Function : PclZipUtilTranslateWinPath()
|
5668 |
+
// Description :
|
5669 |
+
// Translate windows path by replacing '\' by '/' and optionally removing
|
5670 |
+
// drive letter.
|
5671 |
+
// Parameters :
|
5672 |
+
// $p_path : path to translate.
|
5673 |
+
// $p_remove_disk_letter : true | false
|
5674 |
+
// Return Values :
|
5675 |
+
// The path translated.
|
5676 |
+
// --------------------------------------------------------------------------------
|
5677 |
+
function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
|
5678 |
+
{
|
5679 |
+
if (stristr(php_uname(), 'windows')) {
|
5680 |
+
// ----- Look for potential disk letter
|
5681 |
+
if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
|
5682 |
+
$p_path = substr($p_path, $v_position+1);
|
5683 |
+
}
|
5684 |
+
// ----- Change potential windows directory separator
|
5685 |
+
if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
|
5686 |
+
$p_path = strtr($p_path, '\\', '/');
|
5687 |
+
}
|
5688 |
+
}
|
5689 |
+
return $p_path;
|
5690 |
+
}
|
lib/vendor/zip-factory/zip-factory/lib/vendor/pclzip-2-8-2/readme.txt
ADDED
@@ -0,0 +1,421 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// --------------------------------------------------------------------------------
|
2 |
+
// PclZip 2.8.2 - readme.txt
|
3 |
+
// --------------------------------------------------------------------------------
|
4 |
+
// License GNU/LGPL - August 2009
|
5 |
+
// Vincent Blavet - vincent@phpconcept.net
|
6 |
+
// http://www.phpconcept.net
|
7 |
+
// --------------------------------------------------------------------------------
|
8 |
+
// $Id: readme.txt,v 1.60 2009/09/30 20:35:21 vblavet Exp $
|
9 |
+
// --------------------------------------------------------------------------------
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
0 - Sommaire
|
14 |
+
============
|
15 |
+
1 - Introduction
|
16 |
+
2 - What's new
|
17 |
+
3 - Corrected bugs
|
18 |
+
4 - Known bugs or limitations
|
19 |
+
5 - License
|
20 |
+
6 - Warning
|
21 |
+
7 - Documentation
|
22 |
+
8 - Author
|
23 |
+
9 - Contribute
|
24 |
+
|
25 |
+
1 - Introduction
|
26 |
+
================
|
27 |
+
|
28 |
+
PclZip is a library that allow you to manage a Zip archive.
|
29 |
+
|
30 |
+
Full documentation about PclZip can be found here : http://www.phpconcept.net/pclzip
|
31 |
+
|
32 |
+
2 - What's new
|
33 |
+
==============
|
34 |
+
|
35 |
+
Version 2.8.2 :
|
36 |
+
- PCLZIP_CB_PRE_EXTRACT and PCLZIP_CB_POST_EXTRACT are now supported with
|
37 |
+
extraction as a string (PCLZIP_OPT_EXTRACT_AS_STRING). The string
|
38 |
+
can also be modified in the post-extract call back.
|
39 |
+
**Bugs correction :
|
40 |
+
- PCLZIP_OPT_REMOVE_ALL_PATH was not working correctly
|
41 |
+
- Remove use of eval() and do direct call to callback functions
|
42 |
+
- Correct support of 64bits systems (Thanks to WordPress team)
|
43 |
+
|
44 |
+
Version 2.8.1 :
|
45 |
+
- Move option PCLZIP_OPT_BY_EREG to PCLZIP_OPT_BY_PREG because ereg() is
|
46 |
+
deprecated in PHP 5.3. When using option PCLZIP_OPT_BY_EREG, PclZip will
|
47 |
+
automatically replace it by PCLZIP_OPT_BY_PREG.
|
48 |
+
|
49 |
+
Version 2.8 :
|
50 |
+
- Improve extraction of zip archive for large files by using temporary files
|
51 |
+
This feature is working like the one defined in r2.7.
|
52 |
+
Options are renamed : PCLZIP_OPT_TEMP_FILE_ON, PCLZIP_OPT_TEMP_FILE_OFF,
|
53 |
+
PCLZIP_OPT_TEMP_FILE_THRESHOLD
|
54 |
+
- Add a ratio constant PCLZIP_TEMPORARY_FILE_RATIO to configure the auto
|
55 |
+
sense of temporary file use.
|
56 |
+
- Bug correction : Reduce filepath in returned file list to remove ennoying
|
57 |
+
'.//' preambule in file path.
|
58 |
+
|
59 |
+
Version 2.7 :
|
60 |
+
- Improve creation of zip archive for large files :
|
61 |
+
PclZip will now autosense the configured memory and use temporary files
|
62 |
+
when large file is suspected.
|
63 |
+
This feature can also ne triggered by manual options in create() and add()
|
64 |
+
methods. 'PCLZIP_OPT_ADD_TEMP_FILE_ON' force the use of temporary files,
|
65 |
+
'PCLZIP_OPT_ADD_TEMP_FILE_OFF' disable the autosense technic,
|
66 |
+
'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD' allow for configuration of a size
|
67 |
+
threshold to use temporary files.
|
68 |
+
Using "temporary files" rather than "memory" might take more time, but
|
69 |
+
might give the ability to zip very large files :
|
70 |
+
Tested on my win laptop with a 88Mo file :
|
71 |
+
Zip "in-memory" : 18sec (max_execution_time=30, memory_limit=180Mo)
|
72 |
+
Zip "tmporary-files" : 23sec (max_execution_time=30, memory_limit=30Mo)
|
73 |
+
- Replace use of mktime() by time() to limit the E_STRICT error messages.
|
74 |
+
- Bug correction : When adding files with full windows path (drive letter)
|
75 |
+
PclZip is now working. Before, if the drive letter is not the default
|
76 |
+
path, PclZip was not able to add the file.
|
77 |
+
|
78 |
+
Version 2.6 :
|
79 |
+
- Code optimisation
|
80 |
+
- New attributes PCLZIP_ATT_FILE_COMMENT gives the ability to
|
81 |
+
add a comment for a specific file. (Don't really know if this is usefull)
|
82 |
+
- New attribute PCLZIP_ATT_FILE_CONTENT gives the ability to add a string
|
83 |
+
as a file.
|
84 |
+
- New attribute PCLZIP_ATT_FILE_MTIME modify the timestamp associated with
|
85 |
+
a file.
|
86 |
+
- Correct a bug. Files archived with a timestamp with 0h0m0s were extracted
|
87 |
+
with current time
|
88 |
+
- Add CRC value in the informations returned back for each file after an
|
89 |
+
action.
|
90 |
+
- Add missing closedir() statement.
|
91 |
+
- When adding a folder, and removing the path of this folder, files were
|
92 |
+
incorrectly added with a '/' at the beginning. Which means files are
|
93 |
+
related to root in unix systems. Corrected.
|
94 |
+
- Add conditional if before constant definition. This will allow users
|
95 |
+
to redefine constants without changing the file, and then improve
|
96 |
+
upgrade of pclzip code for new versions.
|
97 |
+
|
98 |
+
Version 2.5 :
|
99 |
+
- Introduce the ability to add file/folder with individual properties (file descriptor).
|
100 |
+
This gives for example the ability to change the filename of a zipped file.
|
101 |
+
. Able to add files individually
|
102 |
+
. Able to change full name
|
103 |
+
. Able to change short name
|
104 |
+
. Compatible with global options
|
105 |
+
- New attributes : PCLZIP_ATT_FILE_NAME, PCLZIP_ATT_FILE_NEW_SHORT_NAME, PCLZIP_ATT_FILE_NEW_FULL_NAME
|
106 |
+
- New error code : PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE
|
107 |
+
- Add a security control feature. PclZip can extract any file in any folder
|
108 |
+
of a system. People may use this to upload a zip file and try to override
|
109 |
+
a system file. The PCLZIP_OPT_EXTRACT_DIR_RESTRICTION will give the
|
110 |
+
ability to forgive any directory transversal behavior.
|
111 |
+
- New PCLZIP_OPT_EXTRACT_DIR_RESTRICTION : check extraction path
|
112 |
+
- New error code : PCLZIP_ERR_DIRECTORY_RESTRICTION
|
113 |
+
- Modification in PclZipUtilPathInclusion() : dir and path beginning with ./ will be prepend
|
114 |
+
by current path (getcwd())
|
115 |
+
|
116 |
+
Version 2.4 :
|
117 |
+
- Code improvment : try to speed up the code by removing unusefull call to pack()
|
118 |
+
- Correct bug in delete() : delete() should be called with no argument. This was not
|
119 |
+
the case in 2.3. This is corrected in 2.4.
|
120 |
+
- Correct a bug in path_inclusion function. When the path has several '../../', the
|
121 |
+
result was bad.
|
122 |
+
- Add a check for magic_quotes_runtime configuration. If enabled, PclZip will
|
123 |
+
disable it while working and det it back to its original value.
|
124 |
+
This resolve a lots of bad formated archive errors.
|
125 |
+
- Bug correction : PclZip now correctly unzip file in some specific situation,
|
126 |
+
when compressed content has same size as uncompressed content.
|
127 |
+
- Bug correction : When selecting option 'PCLZIP_OPT_REMOVE_ALL_PATH',
|
128 |
+
directories are not any more created.
|
129 |
+
- Code improvment : correct unclosed opendir(), better handling of . and .. in
|
130 |
+
loops.
|
131 |
+
|
132 |
+
|
133 |
+
Version 2.3 :
|
134 |
+
- Correct a bug with PHP5 : affecting the value 0xFE49FFE0 to a variable does not
|
135 |
+
give the same result in PHP4 and PHP5 ....
|
136 |
+
|
137 |
+
Version 2.2 :
|
138 |
+
- Try development of PCLZIP_OPT_CRYPT .....
|
139 |
+
However this becomes to a stop. To crypt/decrypt I need to multiply 2 long integers,
|
140 |
+
the result (greater than a long) is not supported by PHP. Even the use of bcmath
|
141 |
+
functions does not help. I did not find yet a solution ...;
|
142 |
+
- Add missing '/' at end of directory entries
|
143 |
+
- Check is a file is encrypted or not. Returns status 'unsupported_encryption' and/or
|
144 |
+
error code PCLZIP_ERR_UNSUPPORTED_ENCRYPTION.
|
145 |
+
- Corrected : Bad "version need to extract" field in local file header
|
146 |
+
- Add private method privCheckFileHeaders() in order to check local and central
|
147 |
+
file headers. PclZip is now supporting purpose bit flag bit 3. Purpose bit flag bit 3 gives
|
148 |
+
the ability to have a local file header without size, compressed size and crc filled.
|
149 |
+
- Add a generic status 'error' for file status
|
150 |
+
- Add control of compression type. PclZip only support deflate compression method.
|
151 |
+
Before v2.2, PclZip does not check the compression method used in an archive while
|
152 |
+
extracting. With v2.2 PclZip returns a new error status for a file using an unsupported
|
153 |
+
compression method. New status is "unsupported_compression". New error code is
|
154 |
+
PCLZIP_ERR_UNSUPPORTED_COMPRESSION.
|
155 |
+
- Add optional attribute PCLZIP_OPT_STOP_ON_ERROR. This will stop the extract of files
|
156 |
+
when errors like 'a folder with same name exists' or 'a newer file exists' or
|
157 |
+
'a write protected file' exists, rather than set a status for the concerning file
|
158 |
+
and resume the extract of the zip.
|
159 |
+
- Add optional attribute PCLZIP_OPT_REPLACE_NEWER. This will force, during an extract' the
|
160 |
+
replacement of the file, even if a newer version of the file exists.
|
161 |
+
Note that today if a file with the same name already exists but is older it will be
|
162 |
+
replaced by the extracted one.
|
163 |
+
- Improve PclZipUtilOption()
|
164 |
+
- Support of zip archive with trailing bytes. Before 2.2, PclZip checks that the central
|
165 |
+
directory structure is the last data in the archive. Crypt encryption/decryption of
|
166 |
+
zip archive put trailing 0 bytes after decryption. PclZip is now supporting this.
|
167 |
+
|
168 |
+
Version 2.1 :
|
169 |
+
- Add the ability to abort the extraction by using a user callback function.
|
170 |
+
The user can now return the value '2' in its callback which indicates to stop the
|
171 |
+
extraction. For a pre call-back extract is stopped before the extration of the current
|
172 |
+
file. For a post call back, the extraction is stopped after.
|
173 |
+
- Add the ability to extract a file (or several files) directly in the standard output.
|
174 |
+
This is done by the new parameter PCLZIP_OPT_EXTRACT_IN_OUTPUT with method extract().
|
175 |
+
- Add support for parameters PCLZIP_OPT_COMMENT, PCLZIP_OPT_ADD_COMMENT,
|
176 |
+
PCLZIP_OPT_PREPEND_COMMENT. This will create, replace, add, or prepend comments
|
177 |
+
in the zip archive.
|
178 |
+
- When merging two archives, the comments are not any more lost, but merged, with a
|
179 |
+
blank space separator.
|
180 |
+
- Corrected bug : Files are not deleted when all files are asked to be deleted.
|
181 |
+
- Corrected bug : Folders with name '0' made PclZip to abort the create or add feature.
|
182 |
+
|
183 |
+
|
184 |
+
Version 2.0 :
|
185 |
+
***** Warning : Some new features may break the backward compatibility for your scripts.
|
186 |
+
Please carefully read the readme file.
|
187 |
+
- Add the ability to delete by Index, name and regular expression. This feature is
|
188 |
+
performed by the method delete(), which uses the optional parameters
|
189 |
+
PCLZIP_OPT_BY_INDEX, PCLZIP_OPT_BY_NAME, PCLZIP_OPT_BY_EREG or PCLZIP_OPT_BY_PREG.
|
190 |
+
- Add the ability to extract by regular expression. To extract by regexp you must use the method
|
191 |
+
extract(), with the option PCLZIP_OPT_BY_EREG or PCLZIP_OPT_BY_PREG
|
192 |
+
(depending if you want to use ereg() or preg_match() syntax) followed by the
|
193 |
+
regular expression pattern.
|
194 |
+
- Add the ability to extract by index, directly with the extract() method. This is a
|
195 |
+
code improvment of the extractByIndex() method.
|
196 |
+
- Add the ability to extract by name. To extract by name you must use the method
|
197 |
+
extract(), with the option PCLZIP_OPT_BY_NAME followed by the filename to
|
198 |
+
extract or an array of filenames to extract. To extract all a folder, use the folder
|
199 |
+
name rather than the filename with a '/' at the end.
|
200 |
+
- Add the ability to add files without compression. This is done with a new attribute
|
201 |
+
which is PCLZIP_OPT_NO_COMPRESSION.
|
202 |
+
- Add the attribute PCLZIP_OPT_EXTRACT_AS_STRING, which allow to extract a file directly
|
203 |
+
in a string without using any file (or temporary file).
|
204 |
+
- Add constant PCLZIP_SEPARATOR for static configuration of filename separators in a single string.
|
205 |
+
The default separator is now a comma (,) and not any more a blank space.
|
206 |
+
THIS BREAK THE BACKWARD COMPATIBILITY : Please check if this may have an impact with
|
207 |
+
your script.
|
208 |
+
- Improve algorythm performance by removing the use of temporary files when adding or
|
209 |
+
extracting files in an archive.
|
210 |
+
- Add (correct) detection of empty filename zipping. This can occurs when the removed
|
211 |
+
path is the same
|
212 |
+
as a zipped dir. The dir is not zipped (['status'] = filtered), only its content.
|
213 |
+
- Add better support for windows paths (thanks for help from manus@manusfreedom.com).
|
214 |
+
- Corrected bug : When the archive file already exists with size=0, the add() method
|
215 |
+
fails. Corrected in 2.0.
|
216 |
+
- Remove the use of OS_WINDOWS constant. Use php_uname() function rather.
|
217 |
+
- Control the order of index ranges in extract by index feature.
|
218 |
+
- Change the internal management of folders (better handling of internal flag).
|
219 |
+
|
220 |
+
|
221 |
+
Version 1.3 :
|
222 |
+
- Removing the double include check. This is now done by include_once() and require_once()
|
223 |
+
PHP directives.
|
224 |
+
- Changing the error handling mecanism : Remove the use of an external error library.
|
225 |
+
The former PclError...() functions are replaced by internal equivalent methods.
|
226 |
+
By changing the environment variable PCLZIP_ERROR_EXTERNAL you can still use the former library.
|
227 |
+
Introducing the use of constants for error codes rather than integer values. This will help
|
228 |
+
in futur improvment.
|
229 |
+
Introduction of error handling functions like errorCode(), errorName() and errorInfo().
|
230 |
+
- Remove the deprecated use of calling function with arguments passed by reference.
|
231 |
+
- Add the calling of extract(), extractByIndex(), create() and add() functions
|
232 |
+
with variable options rather than fixed arguments.
|
233 |
+
- Add the ability to remove all the file path while extracting or adding,
|
234 |
+
without any need to specify the path to remove.
|
235 |
+
This is available for extract(), extractByIndex(), create() and add() functionS by using
|
236 |
+
the new variable options parameters :
|
237 |
+
- PCLZIP_OPT_REMOVE_ALL_PATH : by indicating this option while calling the fct.
|
238 |
+
- Ability to change the mode of a file after the extraction (chmod()).
|
239 |
+
This is available for extract() and extractByIndex() functionS by using
|
240 |
+
the new variable options parameters.
|
241 |
+
- PCLZIP_OPT_SET_CHMOD : by setting the value of this option.
|
242 |
+
- Ability to definition call-back options. These call-back will be called during the adding,
|
243 |
+
or the extracting of file (extract(), extractByIndex(), create() and add() functions) :
|
244 |
+
- PCLZIP_CB_PRE_EXTRACT : will be called before each extraction of a file. The user
|
245 |
+
can trigerred the change the filename of the extracted file. The user can triggered the
|
246 |
+
skip of the extraction. This is adding a 'skipped' status in the file list result value.
|
247 |
+
- PCLZIP_CB_POST_EXTRACT : will be called after each extraction of a file.
|
248 |
+
Nothing can be triggered from that point.
|
249 |
+
- PCLZIP_CB_PRE_ADD : will be called before each add of a file. The user
|
250 |
+
can trigerred the change the stored filename of the added file. The user can triggered the
|
251 |
+
skip of the add. This is adding a 'skipped' status in the file list result value.
|
252 |
+
- PCLZIP_CB_POST_ADD : will be called after each add of a file.
|
253 |
+
Nothing can be triggered from that point.
|
254 |
+
- Two status are added in the file list returned as function result : skipped & filename_too_long
|
255 |
+
'skipped' is used when a call-back function ask for skipping the file.
|
256 |
+
'filename_too_long' is used while adding a file with a too long filename to archive (the file is
|
257 |
+
not added)
|
258 |
+
- Adding the function PclZipUtilPathInclusion(), that check the inclusion of a path into
|
259 |
+
a directory.
|
260 |
+
- Add a check of the presence of the archive file before some actions (like list, ...)
|
261 |
+
- Add the initialisation of field "index" in header array. This means that by
|
262 |
+
default index will be -1 when not explicitly set by the methods.
|
263 |
+
|
264 |
+
Version 1.2 :
|
265 |
+
- Adding a duplicate function.
|
266 |
+
- Adding a merge function. The merge function is a "quick merge" function,
|
267 |
+
it just append the content of an archive at the end of the first one. There
|
268 |
+
is no check for duplicate files or more recent files.
|
269 |
+
- Improve the search of the central directory end.
|
270 |
+
|
271 |
+
Version 1.1.2 :
|
272 |
+
|
273 |
+
- Changing the license of PclZip. PclZip is now released under the GNU / LGPL license
|
274 |
+
(see License section).
|
275 |
+
- Adding the optional support of a static temporary directory. You will need to configure
|
276 |
+
the constant PCLZIP_TEMPORARY_DIR if you want to use this feature.
|
277 |
+
- Improving the rename() function. In some cases rename() does not work (different
|
278 |
+
Filesystems), so it will be replaced by a copy() + unlink() functions.
|
279 |
+
|
280 |
+
Version 1.1.1 :
|
281 |
+
|
282 |
+
- Maintenance release, no new feature.
|
283 |
+
|
284 |
+
Version 1.1 :
|
285 |
+
|
286 |
+
- New method Add() : adding files in the archive
|
287 |
+
- New method ExtractByIndex() : partial extract of the archive, files are identified by
|
288 |
+
their index in the archive
|
289 |
+
- New method DeleteByIndex() : delete some files/folder entries from the archive,
|
290 |
+
files are identified by their index in the archive.
|
291 |
+
- Adding a test of the zlib extension presence. If not present abort the script.
|
292 |
+
|
293 |
+
Version 1.0.1 :
|
294 |
+
|
295 |
+
- No new feature
|
296 |
+
|
297 |
+
|
298 |
+
3 - Corrected bugs
|
299 |
+
==================
|
300 |
+
|
301 |
+
Corrected in Version 2.0 :
|
302 |
+
- Corrected : During an extraction, if a call-back fucntion is used and try to skip
|
303 |
+
a file, all the extraction process is stopped.
|
304 |
+
|
305 |
+
Corrected in Version 1.3 :
|
306 |
+
- Corrected : Support of static synopsis for method extract() is broken.
|
307 |
+
- Corrected : invalid size of archive content field (0xFF) should be (0xFFFF).
|
308 |
+
- Corrected : When an extract is done with a remove_path parameter, the entry for
|
309 |
+
the directory with exactly the same path is not skipped/filtered.
|
310 |
+
- Corrected : extractByIndex() and deleteByIndex() were not managing index in the
|
311 |
+
right way. For example indexes '1,3-5,11' will only extract files 1 and 11. This
|
312 |
+
is due to a sort of the index resulting table that puts 11 before 3-5 (sort on
|
313 |
+
string and not interger). The sort is temporarilly removed, this means that
|
314 |
+
you must provide a sorted list of index ranges.
|
315 |
+
|
316 |
+
Corrected in Version 1.2 :
|
317 |
+
|
318 |
+
- Nothing.
|
319 |
+
|
320 |
+
Corrected in Version 1.1.2 :
|
321 |
+
|
322 |
+
- Corrected : Winzip is unable to delete or add new files in a PclZip created archives.
|
323 |
+
|
324 |
+
Corrected in Version 1.1.1 :
|
325 |
+
|
326 |
+
- Corrected : When archived file is not compressed (0% compression), the
|
327 |
+
extract method fails.
|
328 |
+
|
329 |
+
Corrected in Version 1.1 :
|
330 |
+
|
331 |
+
- Corrected : Adding a complete tree of folder may result in a bad archive
|
332 |
+
creation.
|
333 |
+
|
334 |
+
Corrected in Version 1.0.1 :
|
335 |
+
|
336 |
+
- Corrected : Error while compressing files greater than PCLZIP_READ_BLOCK_SIZE (default=1024).
|
337 |
+
|
338 |
+
|
339 |
+
4 - Known bugs or limitations
|
340 |
+
=============================
|
341 |
+
|
342 |
+
Please publish bugs reports in SourceForge :
|
343 |
+
http://sourceforge.net/tracker/?group_id=40254&atid=427564
|
344 |
+
|
345 |
+
In Version 2.x :
|
346 |
+
- PclZip does only support file uncompressed or compressed with deflate (compression method 8)
|
347 |
+
- PclZip does not support password protected zip archive
|
348 |
+
- Some concern were seen when changing mtime of a file while archiving.
|
349 |
+
Seems to be linked to Daylight Saving Time (PclTest_changing_mtime).
|
350 |
+
|
351 |
+
In Version 1.2 :
|
352 |
+
|
353 |
+
- merge() methods does not check for duplicate files or last date of modifications.
|
354 |
+
|
355 |
+
In Version 1.1 :
|
356 |
+
|
357 |
+
- Limitation : Using 'extract' fields in the file header in the zip archive is not supported.
|
358 |
+
- WinZip is unable to delete a single file in a PclZip created archive. It is also unable to
|
359 |
+
add a file in a PclZip created archive. (Corrected in v.1.2)
|
360 |
+
|
361 |
+
In Version 1.0.1 :
|
362 |
+
|
363 |
+
- Adding a complete tree of folder may result in a bad archive
|
364 |
+
creation. (Corrected in V.1.1).
|
365 |
+
- Path given to methods must be in the unix format (/) and not the Windows format (\).
|
366 |
+
Workaround : Use only / directory separators.
|
367 |
+
- PclZip is using temporary files that are sometime the name of the file with a .tmp or .gz
|
368 |
+
added suffix. Files with these names may already exist and may be overwritten.
|
369 |
+
Workaround : none.
|
370 |
+
- PclZip does not check if the zlib extension is present. If it is absent, the zip
|
371 |
+
file is not created and the lib abort without warning.
|
372 |
+
Workaround : enable the zlib extension on the php install
|
373 |
+
|
374 |
+
In Version 1.0 :
|
375 |
+
|
376 |
+
- Error while compressing files greater than PCLZIP_READ_BLOCK_SIZE (default=1024).
|
377 |
+
(Corrected in v.1.0.1)
|
378 |
+
- Limitation : Multi-disk zip archive are not supported.
|
379 |
+
|
380 |
+
|
381 |
+
5 - License
|
382 |
+
===========
|
383 |
+
|
384 |
+
Since version 1.1.2, PclZip Library is released under GNU/LGPL license.
|
385 |
+
This library is free, so you can use it at no cost.
|
386 |
+
|
387 |
+
HOWEVER, if you release a script, an application, a library or any kind of
|
388 |
+
code using PclZip library (or a part of it), YOU MUST :
|
389 |
+
- Indicate in the documentation (or a readme file), that your work
|
390 |
+
uses PclZip Library, and make a reference to the author and the web site
|
391 |
+
http://www.phpconcept.net
|
392 |
+
- Gives the ability to the final user to update the PclZip libary.
|
393 |
+
|
394 |
+
I will also appreciate that you send me a mail (vincent@phpconcept.net), just to
|
395 |
+
be aware that someone is using PclZip.
|
396 |
+
|
397 |
+
For more information about GNU/LGPL license : http://www.gnu.org
|
398 |
+
|
399 |
+
6 - Warning
|
400 |
+
=================
|
401 |
+
|
402 |
+
This library and the associated files are non commercial, non professional work.
|
403 |
+
It should not have unexpected results. However if any damage is caused by this software
|
404 |
+
the author can not be responsible.
|
405 |
+
The use of this software is at the risk of the user.
|
406 |
+
|
407 |
+
7 - Documentation
|
408 |
+
=================
|
409 |
+
PclZip User Manuel is available in English on PhpConcept : http://www.phpconcept.net/pclzip/man/en/index.php
|
410 |
+
A Russian translation was done by Feskov Kuzma : http://php.russofile.ru/ru/authors/unsort/zip/
|
411 |
+
|
412 |
+
8 - Author
|
413 |
+
==========
|
414 |
+
|
415 |
+
This software was written by Vincent Blavet (vincent@phpconcept.net) on its leasure time.
|
416 |
+
|
417 |
+
9 - Contribute
|
418 |
+
==============
|
419 |
+
If you want to contribute to the development of PclZip, please contact vincent@phpconcept.net.
|
420 |
+
If you can help in financing PhpConcept hosting service, please go to
|
421 |
+
http://www.phpconcept.net/soutien.php
|
lib/vendor/zipper/zipper.lib.php
DELETED
@@ -1,62 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( class_exists( 'ZipArchive' ) ) {
|
4 |
-
class Zipper extends ZipArchive {
|
5 |
-
protected $archive = null;
|
6 |
-
|
7 |
-
protected $root_dir = null;
|
8 |
-
|
9 |
-
public function __construct( $file ) {
|
10 |
-
if ( is_resource( $file ) ) {
|
11 |
-
$meta = stream_get_meta_data( $file );
|
12 |
-
$this->archive = $meta['uri'];
|
13 |
-
} else {
|
14 |
-
$this->archive = $file;
|
15 |
-
}
|
16 |
-
|
17 |
-
// Open Archive File
|
18 |
-
if ( !( $this->open( $this->archive ) === true ) ) {
|
19 |
-
throw new RuntimeException( 'Archive file cound not be created.' );
|
20 |
-
}
|
21 |
-
}
|
22 |
-
|
23 |
-
public function addDir( $path, $parent_dir = null, $include = array() ) {
|
24 |
-
// Use Recursive functions
|
25 |
-
$iterator = new RecursiveIteratorIterator(
|
26 |
-
new RecursiveDirectoryIterator( $path , RecursiveDirectoryIterator::SKIP_DOTS ),
|
27 |
-
RecursiveIteratorIterator::SELF_FIRST
|
28 |
-
);
|
29 |
-
|
30 |
-
// Prepare File Filter Pattern
|
31 |
-
$file_pattern = null;
|
32 |
-
if ( is_array( $include ) ) {
|
33 |
-
$filters = array();
|
34 |
-
foreach ( $include as $file ) {
|
35 |
-
$filters[] = str_replace( '\.\*', '.*' , preg_quote( $file, '/' ) );
|
36 |
-
}
|
37 |
-
|
38 |
-
$file_pattern = implode( '|', $filters );
|
39 |
-
}
|
40 |
-
|
41 |
-
foreach ( $iterator as $item ) {
|
42 |
-
// Validate file pattern
|
43 |
-
if ( $file_pattern ) {
|
44 |
-
if ( ! preg_match( '/^(' . $file_pattern . ')$/', $iterator->getSubPathName() ) ) {
|
45 |
-
continue;
|
46 |
-
}
|
47 |
-
}
|
48 |
-
|
49 |
-
// Add to archive
|
50 |
-
if ( $item->isDir() ) {
|
51 |
-
$this->addEmptyDir( $parent_dir . DIRECTORY_SEPARATOR . $iterator->getSubPathName() );
|
52 |
-
} else {
|
53 |
-
$this->addFile( $item->getPathname(), $parent_dir . DIRECTORY_SEPARATOR . $iterator->getSubPathName() );
|
54 |
-
}
|
55 |
-
}
|
56 |
-
}
|
57 |
-
|
58 |
-
public function getArchive() {
|
59 |
-
return $this->archive;
|
60 |
-
}
|
61 |
-
}
|
62 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/view/assets/css/export.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.ai1wm-checkbox{position:relative;display:inline-block;min-width:1em;height:1.25em;line-height:1em;outline:none;vertical-align:middle;margin-bottom:5px}.ai1wm-checkbox input{position:absolute;top:0px;left:0px;opacity:0;outline:none}.ai1wm-checkbox .box,.ai1wm-checkbox label{cursor:pointer;padding-left:2em;outline:none}.ai1wm-checkbox .box:before,.ai1wm-checkbox label:before{position:absolute;top:0em;left:0em;line-height:1;width:1em;height:1em;left:0em;content:'';border-radius:4px;background:#FFFFFF;transition:background-color 0.3s ease,box-shadow 0.3s ease;box-shadow:0em 0em 0em 1px rgba(0,0,0,0.2)}.ai1wm-checkbox .box:after,.ai1wm-checkbox label:after{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);opacity:0;content:'';position:absolute;background:transparent;border:0.2em solid #333333;border-top:none;border-right:none;transform:rotate(-45deg)}.ai1wm-checkbox .box:after,.ai1wm-checkbox label:after{top:0.275em;left:0.2em;width:0.45em;height:0.15em}.ai1wm-checkbox label{color:rgba(0,0,0,0.6);transition:color 0.2s ease}.ai1wm-checkbox label:hover{color:rgba(0,0,0,0.8)}.ai1wm-checkbox input:focus+label{color:rgba(0,0,0,0.8)}.ai1wm-checkbox+label{cursor:pointer;opacity:0.85;vertical-align:middle}.ai1wm-checkbox+label:hover{opacity:1}.ai1wm-checkbox{cursor:pointer}.ai1wm-checkbox .box,.ai1wm-checkbox label{padding-left:4em}.ai1wm-checkbox .box:before,.ai1wm-checkbox label:before{cursor:pointer;display:block;position:absolute;content:'';top:-0.25em;left:0em;z-index:1;background-color:#FFFFFF;width:3em;height:1.5em;transform:none;box-shadow:0px 0px 0px 1px rgba(0,0,0,0.1) inset;border-radius:50rem}.ai1wm-checkbox .box:after,.ai1wm-checkbox label:after{opacity:1;background-color:transparent;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;content:'';position:absolute;top:0.15em;left:0.5em;z-index:2;border:none;width:0.75em;height:0.75em;background-color:#D95C5C;border-radius:50rem;transition:background 0.3s ease 0s,left 0.3s ease 0s}.ai1wm-checkbox:active .box:before,.ai1wm-checkbox:active label:before{background-color:#F5F5F5}.ai1wm-checkbox input:checked+.box:after,.ai1wm-checkbox input:checked+label:after{left:1.75em;background-color:#89B84C}.ui.checkbox{font-size:1em}.ui.large.checkbox{font-size:1.25em}.ui.huge.checkbox{font-size:1.5em}.ai1wm-divider{margin:1rem 0rem;border-top:1px solid rgba(0,0,0,0.1);border-bottom:1px solid rgba(255,255,255,0.8);line-height:1;height:0em;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0);position:absolute;border:none;height:0em;margin:0em;background-color:transparent;font-size:0.875rem;font-weight:bold;text-align:center;text-transform:uppercase;color:rgba(0,0,0,0.8)}.ai1wm-divider{position:relative;top:0%;left:0%;margin:1rem 2.5rem;height:auto;padding:0em;line-height:1}.ai1wm-divider:before,.ai1wm-divider:after{position:absolute;top:50%;content:" ";z-index:3;width:50%;top:50%;height:0%;border-top:1px solid rgba(0,0,0,0.1);border-bottom:1px solid rgba(255,255,255,0.8)}.ai1wm-divider:before{left:0%;margin-left:-2.5rem}.ai1wm-divider:after{left:auto;right:0%;margin-right:-2.5rem}@font-face{font-family:'servmask';src:url("../font/servmask.eot");src:url("../font/servmask.eot?#iefix") format("embedded-opentype"),url("../font/servmask.woff") format("woff"),url("../font/servmask.ttf") format("truetype"),url("../font/servmask.svg#servmask") format("svg");font-weight:normal;font-style:normal}[class^="ai1wm-icon-"],[class*=" ai1wm-icon-"]{font-family:'servmask';speak:none;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ai1wm-icon-plus:before{content:"\e600"}.ai1wm-icon-plus2:before{content:"\e601"}.ai1wm-icon-plus3:before{content:"\e602"}.ai1wm-icon-history:before{content:"\e603"}.ai1wm-icon-arrow-down:before{content:"\e604"}.ai1wm-icon-arrow-right:before{content:"\e605"}.ai1wm-icon-arrow-down2:before{content:"\e606"}.ai1wm-icon-plus:before{content:"\e607"}.ai1wm-icon-paperplane:before{content:"\e608"}.ai1wm-icon-help:before{content:"\e609"}.ai1wm-icon-file:before{content:"\e60a"}@media (min-width: 855px){.ai1wm-row{margin-right:399px}.ai1wm-row:before,.ai1wm-row:after{content:" ";display:table}.ai1wm-row:after{clear:both}.ai1wm-left{float:left;width:100%}.ai1wm-right{float:right;width:377px;margin-right:-399px}.ai1wm-right .ai1wm-sidebar{width:100%}.ai1wm-right .ai1wm-segment{width:333px;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 white;color:#333333;background-color:#f9f9f9;padding:22px;text-decoration:none;text-shadow:0 1px 0 white;background-clip:padding-box}.ai1wm-right .ai1wm-feedback-email{width:100%;font-weight:normal;font-size:0.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-right .ai1wm-feedback-message{width:100%;border-radius:3px;font-size:0.8rem;padding:6px 10px;resize:none}.ai1wm-right .ai1wm-feedback-terms-segment{font-size:0.7rem;line-height:1rem;margin:4px 0 8px 0}}.ai1wm-holder{border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 white;padding:22px;background:#f9f9f9}.ai1wm-holder h1{margin-top:0 !important}.ai1wm-segment>.ai1wm-divider:first-child{margin-top:0 !important}@media (max-width: 854px){.ai1wm-container{margin-left:10px !important}.ai1wm-row{margin-right:0px !important}.ai1wm-right{float:left !important;width:100% !important;margin-top:18px;margin-right:0 !important}.ai1wm-right .ai1wm-sidebar{width:auto !important;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 white;padding:22px;background:#f9f9f9}.ai1wm-right .ai1wm-feedback-email{width:100%;font-weight:normal;font-size:0.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-right .ai1wm-feedback-message{width:100%;border-radius:3px;font-size:0.8rem;padding:6px 10px;resize:none}.ai1wm-right .ai1wm-feedback-terms-segment{font-size:0.7rem;line-height:1rem;margin:4px 0 8px 0}}.ai1wm-container{margin:20px 20px 0px 2px}.ai1wm-container:before,.ai1wm-container:after{content:" ";display:table}.ai1wm-container:after{clear:both}.ai1wm-replace-row{width:100%;box-shadow:outset 0 1px 0 0 white;border-radius:3px;color:#333333;font-size:11px;font-weight:bold;background-color:#f9f9f9;text-decoration:none;text-shadow:0 1px 0 white;background-clip:padding-box;margin-bottom:10px}.ai1wm-replace-row .ai1wm-field-inline{float:left;width:100%}.ai1wm-replace-row .ai1wm-field-inline input{width:100%;font-weight:normal;font-size:0.8rem;padding:0 10px;height:2.3rem;line-height:2.3rem;margin-bottom:4px}.ai1wm-field{margin-bottom:4px}.ai1wm-field input[type="text"],.ai1wm-field textarea{width:100%;font-weight:normal}.ai1wm-message{-moz-box-sizing:border-box;background-color:#EFEFEF;border-radius:4px;color:rgba(0,0,0,0.6);height:auto;margin:10px 0;min-height:18px;padding:10px;position:relative;transition:opacity 0.1s ease 0s, color 0.1s ease 0s, background 0.1s ease 0s, box-shadow 0.1s ease 0s}.ai1wm-message.ai1wm-green-message{background-color:#F2F8F0;color:#119000}.ai1wm-message.ai1wm-blue-message{background-color:#E6F4F9;color:#4D8796}.ai1wm-message.ai1wm-red-message{background-color:#F1D7D7;color:#A95252}.ai1wm-message p{margin:4px 0}.ai1wm-button-gray{border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 #fff;color:#333;display:inline-block;font-size:11px;font-weight:bold;background-color:#fafafa;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #fafafa),color-stop(100%, #dedede));background-image:-webkit-linear-gradient(#fafafa,#dedede);background-image:linear-gradient(#fafafa,#dedede);padding:7px 18px;text-decoration:none;text-shadow:0 1px 0 #fff;background-clip:padding-box}.ai1wm-button-gray:hover:not(:disabled){box-shadow:inset 0 1px 0 0 #fff;cursor:pointer;background-color:#ededed;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #ededed),color-stop(100%, #d6d6d6));background-image:-webkit-linear-gradient(#ededed,#d6d6d6);background-image:linear-gradient(#ededed,#d6d6d6)}.ai1wm-button-gray:active:not(:disabled){border:1px solid #d6d6d6;box-shadow:inset 0 0 8px 4px #cfcfcf,inset 0 0 8px 4px #cfcfcf,0 1px 1px 0 #eee}.ai1wm-button-gray:disabled{opacity:0.5;cursor:not-allowed}.ai1wm-button-green{border:1px solid #4d8b2c;border-radius:3px;box-shadow:inset 0 1px 0 0 #9cc587;color:#fff;display:inline-block;font-size:11px;font-weight:bold;background-color:#6eb649;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #6eb649),color-stop(100%, #539730));background-image:-webkit-linear-gradient(#6eb649,#539730);background-image:linear-gradient(#6eb649,#539730);padding:7px 18px;text-decoration:none;text-shadow:0 1px 0 #428122;background-clip:padding-box}.ai1wm-button-green:hover:not(:disabled){box-shadow:inset 0 1px 0 0 #7fb563;cursor:pointer;background-color:#649f46;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #649f46),color-stop(100%, #4d8a2d));background-image:-webkit-linear-gradient(#649f46,#4d8a2d);background-image:linear-gradient(#649f46,#4d8a2d)}.ai1wm-button-green:active:not(:disabled){border:1px solid #4d8b2c;box-shadow:inset 0 0 8px 4px #477e2a,inset 0 0 8px 4px #477e2a,0 1px 1px 0 #eee}.ai1wm-button-green:disabled{opacity:0.5;cursor:not-allowed}.ai1wm-button-blue{border:1px solid #007ba9;border-radius:3px;box-shadow:inset 0 1px 0 0 #45c7f7;color:#fff;display:inline-block;font-size:11px;font-weight:bold;background-color:#00aff0;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #00aff0),color-stop(100%, #0086b8));background-image:-webkit-linear-gradient(#00aff0,#0086b8);background-image:linear-gradient(#00aff0,#0086b8);padding:7px 18px;text-decoration:none;text-shadow:0 1px 0 #006c94;background-clip:padding-box}.ai1wm-button-blue:hover:not(:disabled){box-shadow:inset 0 1px 0 0 #13b9f6;cursor:pointer;background-color:#049ad2;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #049ad2),color-stop(100%, #007ba9));background-image:-webkit-linear-gradient(#049ad2,#007ba9);background-image:linear-gradient(#049ad2,#007ba9)}.ai1wm-button-blue:active:not(:disabled){border:1px solid #007ba9;box-shadow:inset 0 0 8px 4px #007099,inset 0 0 8px 4px #007099,0 1px 1px 0 #eee}.ai1wm-button-blue:disabled{opacity:0.5;cursor:not-allowed}.ai1wm-button-gray i,.ai1wm-button-green i,.ai1wm-button-blue i{margin-left:-0.5em;margin-right:0.2em}.ai1wm-button-gray i.ai1wm-alone,.ai1wm-button-green i.ai1wm-alone,.ai1wm-button-blue i.ai1wm-alone{margin-right:-0.5em !important}.ai1wm-clear{*zoom:1}.ai1wm-clear:before,.ai1wm-clear:after{content:" ";display:table}.ai1wm-clear:after{clear:both}.ai1wm-field-inline input{border-radius:5px}.ai1wm-toggle-checkbox label{color:#333333;display:inline-block;font-size:11px;font-weight:bold;text-decoration:none;text-shadow:0 1px 0 white}.ai1wm-accordion{margin:10px 0 20px 0}.ai1wm-accordion .ai1wm-title{cursor:pointer;float:left}.ai1wm-accordion .ai1wm-title:after{clear:both}.ai1wm-accordion .ai1wm-title:hover{color:rgba(0,116,162,0.8)}.ai1wm-accordion .ai1wm-content{display:none;margin:22px 0px 0px 22px}.ai1wm-accordion.ai1wm-active .ai1wm-title .ai1wm-icon-arrow-right:before{content:"\e606"}.ai1wm-accordion.ai1wm-active .ai1wm-content{display:block}.ai1wm-include-tables{display:inline-block;width:300px;margin:0 6px 0 0}.ai1wm-include-plugins{display:inline-block;width:300px;vertical-align:top}.ai1wm-include-media{display:inline-block;width:300px;margin:0 6px 0 0}.ai1wm-include-themes{display:inline-block;width:300px;vertical-align:top}
|
1 |
+
.ai1wm-checkbox{position:relative;display:inline-block;min-width:1em;height:1.25em;line-height:1em;outline:none;vertical-align:middle;margin-bottom:5px}.ai1wm-checkbox input{position:absolute;top:0px;left:0px;opacity:0;outline:none}.ai1wm-checkbox .box,.ai1wm-checkbox label{cursor:pointer;padding-left:2em;outline:none}.ai1wm-checkbox .box:before,.ai1wm-checkbox label:before{position:absolute;top:0em;left:0em;line-height:1;width:1em;height:1em;left:0em;content:'';border-radius:4px;background:#FFFFFF;transition:background-color 0.3s ease,box-shadow 0.3s ease;box-shadow:0em 0em 0em 1px rgba(0,0,0,0.2)}.ai1wm-checkbox .box:after,.ai1wm-checkbox label:after{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);opacity:0;content:'';position:absolute;background:transparent;border:0.2em solid #333333;border-top:none;border-right:none;transform:rotate(-45deg)}.ai1wm-checkbox .box:after,.ai1wm-checkbox label:after{top:0.275em;left:0.2em;width:0.45em;height:0.15em}.ai1wm-checkbox label{color:rgba(0,0,0,0.6);transition:color 0.2s ease}.ai1wm-checkbox label:hover{color:rgba(0,0,0,0.8)}.ai1wm-checkbox input:focus+label{color:rgba(0,0,0,0.8)}.ai1wm-checkbox+label{cursor:pointer;opacity:0.85;vertical-align:middle}.ai1wm-checkbox+label:hover{opacity:1}.ai1wm-checkbox{cursor:pointer}.ai1wm-checkbox .box,.ai1wm-checkbox label{padding-left:4em}.ai1wm-checkbox .box:before,.ai1wm-checkbox label:before{cursor:pointer;display:block;position:absolute;content:'';top:-0.25em;left:0em;z-index:1;background-color:#FFFFFF;width:3em;height:1.5em;transform:none;box-shadow:0px 0px 0px 1px rgba(0,0,0,0.1) inset;border-radius:50rem}.ai1wm-checkbox .box:after,.ai1wm-checkbox label:after{opacity:1;background-color:transparent;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;content:'';position:absolute;top:0.15em;left:0.5em;z-index:2;border:none;width:0.75em;height:0.75em;background-color:#D95C5C;border-radius:50rem;transition:background 0.3s ease 0s,left 0.3s ease 0s}.ai1wm-checkbox:active .box:before,.ai1wm-checkbox:active label:before{background-color:#F5F5F5}.ai1wm-checkbox input:checked+.box:after,.ai1wm-checkbox input:checked+label:after{left:1.75em;background-color:#89B84C}.ui.checkbox{font-size:1em}.ui.large.checkbox{font-size:1.25em}.ui.huge.checkbox{font-size:1.5em}.ai1wm-divider{margin:1rem 0rem;border-top:1px solid rgba(0,0,0,0.1);border-bottom:1px solid rgba(255,255,255,0.8);line-height:1;height:0em;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0);position:absolute;border:none;height:0em;margin:0em;background-color:transparent;font-size:0.875rem;font-weight:bold;text-align:center;text-transform:uppercase;color:rgba(0,0,0,0.8)}.ai1wm-divider{position:relative;top:0%;left:0%;margin:1rem 2.5rem;height:auto;padding:0em;line-height:1}.ai1wm-divider:before,.ai1wm-divider:after{position:absolute;top:50%;content:" ";z-index:3;width:50%;top:50%;height:0%;border-top:1px solid rgba(0,0,0,0.1);border-bottom:1px solid rgba(255,255,255,0.8)}.ai1wm-divider:before{left:0%;margin-left:-2.5rem}.ai1wm-divider:after{left:auto;right:0%;margin-right:-2.5rem}@font-face{font-family:'servmask';src:url("../font/servmask.eot");src:url("../font/servmask.eot?#iefix") format("embedded-opentype"),url("../font/servmask.woff") format("woff"),url("../font/servmask.ttf") format("truetype"),url("../font/servmask.svg#servmask") format("svg");font-weight:normal;font-style:normal}[class^="ai1wm-icon-"],[class*=" ai1wm-icon-"]{font-family:'servmask';speak:none;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ai1wm-icon-plus:before{content:"\e600"}.ai1wm-icon-plus2:before{content:"\e601"}.ai1wm-icon-plus3:before{content:"\e602"}.ai1wm-icon-history:before{content:"\e603"}.ai1wm-icon-arrow-down:before{content:"\e604"}.ai1wm-icon-arrow-right:before{content:"\e605"}.ai1wm-icon-arrow-down2:before{content:"\e606"}.ai1wm-icon-plus:before{content:"\e607"}.ai1wm-icon-paperplane:before{content:"\e608"}.ai1wm-icon-help:before{content:"\e609"}.ai1wm-icon-file:before{content:"\e60a"}@media (min-width: 855px){.ai1wm-row{margin-right:399px}.ai1wm-row:before,.ai1wm-row:after{content:" ";display:table}.ai1wm-row:after{clear:both}.ai1wm-left{float:left;width:100%}.ai1wm-right{float:right;width:377px;margin-right:-399px}.ai1wm-right .ai1wm-sidebar{width:100%}.ai1wm-right .ai1wm-segment{width:333px;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 white;color:#333333;background-color:#f9f9f9;padding:22px;text-decoration:none;text-shadow:0 1px 0 white;background-clip:padding-box}.ai1wm-right .ai1wm-feedback-email{width:100%;font-weight:normal;font-size:0.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-right .ai1wm-feedback-message{width:100%;border-radius:3px;font-size:0.8rem;padding:6px 10px;resize:none}.ai1wm-right .ai1wm-feedback-terms-segment{font-size:0.7rem;line-height:1rem;margin:4px 0 8px 0}.ai1wm-right .ai1wm-feedback-terms-segment>.ai1wm-feedback-terms{border-radius:3px}}.ai1wm-holder{border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 white;padding:22px;background:#f9f9f9}.ai1wm-holder h1{margin-top:0 !important}.ai1wm-segment>.ai1wm-divider:first-child{margin-top:0 !important}@media (max-width: 854px){.ai1wm-container{margin-left:10px !important}.ai1wm-row{margin-right:0px !important}.ai1wm-right{float:left !important;width:100% !important;margin-top:18px;margin-right:0 !important}.ai1wm-right .ai1wm-sidebar{width:auto !important;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 white;padding:22px;background:#f9f9f9}.ai1wm-right .ai1wm-feedback-email{width:100%;font-weight:normal;font-size:0.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-right .ai1wm-feedback-message{width:100%;border-radius:3px;font-size:0.8rem;padding:6px 10px;resize:none}.ai1wm-right .ai1wm-feedback-terms-segment{font-size:0.7rem;line-height:1rem;margin:4px 0 8px 0;border-radius:3px}.ai1wm-right .ai1wm-feedback-terms-segment>.ai1wm-feedback-terms{border-radius:3px}}.ai1wm-container{margin:20px 20px 0px 2px}.ai1wm-container:before,.ai1wm-container:after{content:" ";display:table}.ai1wm-container:after{clear:both}.ai1wm-replace-row{width:100%;box-shadow:outset 0 1px 0 0 white;border-radius:3px;color:#333333;font-size:11px;font-weight:bold;background-color:#f9f9f9;text-decoration:none;text-shadow:0 1px 0 white;background-clip:padding-box;margin-bottom:10px}.ai1wm-replace-row .ai1wm-field-inline{float:left;width:100%}.ai1wm-replace-row .ai1wm-field-inline input{width:100%;font-weight:normal;font-size:0.8rem;padding:0 10px;height:2.3rem;line-height:2.3rem;margin-bottom:4px}.ai1wm-field{margin-bottom:4px}.ai1wm-field input[type="text"],.ai1wm-field textarea{width:100%;font-weight:normal}.ai1wm-message{-moz-box-sizing:border-box;background-color:#EFEFEF;border-radius:4px;color:rgba(0,0,0,0.6);height:auto;margin:10px 0;min-height:18px;padding:10px;position:relative;transition:opacity 0.1s ease 0s, color 0.1s ease 0s, background 0.1s ease 0s, box-shadow 0.1s ease 0s}.ai1wm-message.ai1wm-green-message{background-color:#F2F8F0;color:#119000}.ai1wm-message.ai1wm-blue-message{background-color:#E6F4F9;color:#4D8796}.ai1wm-message.ai1wm-red-message{background-color:#F1D7D7;color:#A95252}.ai1wm-message p{margin:4px 0}.ai1wm-button-gray{border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 #fff;color:#333;display:inline-block;font-size:11px;font-weight:bold;background-color:#fafafa;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #fafafa),color-stop(100%, #dedede));background-image:-webkit-linear-gradient(#fafafa,#dedede);background-image:linear-gradient(#fafafa,#dedede);padding:7px 18px;text-decoration:none;text-shadow:0 1px 0 #fff;background-clip:padding-box}.ai1wm-button-gray:hover:not(:disabled){box-shadow:inset 0 1px 0 0 #fff;cursor:pointer;background-color:#ededed;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #ededed),color-stop(100%, #d6d6d6));background-image:-webkit-linear-gradient(#ededed,#d6d6d6);background-image:linear-gradient(#ededed,#d6d6d6)}.ai1wm-button-gray:active:not(:disabled){border:1px solid #d6d6d6;box-shadow:inset 0 0 8px 4px #cfcfcf,inset 0 0 8px 4px #cfcfcf,0 1px 1px 0 #eee}.ai1wm-button-gray:disabled{opacity:0.5;cursor:not-allowed}.ai1wm-button-green{border:1px solid #4d8b2c;border-radius:3px;box-shadow:inset 0 1px 0 0 #9cc587;color:#fff;display:inline-block;font-size:11px;font-weight:bold;background-color:#6eb649;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #6eb649),color-stop(100%, #539730));background-image:-webkit-linear-gradient(#6eb649,#539730);background-image:linear-gradient(#6eb649,#539730);padding:7px 18px;text-decoration:none;text-shadow:0 1px 0 #428122;background-clip:padding-box}.ai1wm-button-green:hover:not(:disabled){box-shadow:inset 0 1px 0 0 #7fb563;cursor:pointer;background-color:#649f46;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #649f46),color-stop(100%, #4d8a2d));background-image:-webkit-linear-gradient(#649f46,#4d8a2d);background-image:linear-gradient(#649f46,#4d8a2d)}.ai1wm-button-green:active:not(:disabled){border:1px solid #4d8b2c;box-shadow:inset 0 0 8px 4px #477e2a,inset 0 0 8px 4px #477e2a,0 1px 1px 0 #eee}.ai1wm-button-green:disabled{opacity:0.5;cursor:not-allowed}.ai1wm-button-blue{border:1px solid #007ba9;border-radius:3px;box-shadow:inset 0 1px 0 0 #45c7f7;color:#fff;display:inline-block;font-size:11px;font-weight:bold;background-color:#00aff0;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #00aff0),color-stop(100%, #0086b8));background-image:-webkit-linear-gradient(#00aff0,#0086b8);background-image:linear-gradient(#00aff0,#0086b8);padding:7px 18px;text-decoration:none;text-shadow:0 1px 0 #006c94;background-clip:padding-box}.ai1wm-button-blue:hover:not(:disabled){box-shadow:inset 0 1px 0 0 #13b9f6;cursor:pointer;background-color:#049ad2;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #049ad2),color-stop(100%, #007ba9));background-image:-webkit-linear-gradient(#049ad2,#007ba9);background-image:linear-gradient(#049ad2,#007ba9)}.ai1wm-button-blue:active:not(:disabled){border:1px solid #007ba9;box-shadow:inset 0 0 8px 4px #007099,inset 0 0 8px 4px #007099,0 1px 1px 0 #eee}.ai1wm-button-blue:disabled{opacity:0.5;cursor:not-allowed}.ai1wm-button-gray i,.ai1wm-button-green i,.ai1wm-button-blue i{margin-left:-0.5em;margin-right:0.2em}.ai1wm-button-gray i.ai1wm-alone,.ai1wm-button-green i.ai1wm-alone,.ai1wm-button-blue i.ai1wm-alone{margin-right:-0.5em !important}.ai1wm-clear{*zoom:1}.ai1wm-clear:before,.ai1wm-clear:after{content:" ";display:table}.ai1wm-clear:after{clear:both}.ai1wm-field-inline input{border-radius:5px}.ai1wm-toggle-checkbox label{color:#333333;display:inline-block;font-size:11px;font-weight:bold;text-decoration:none;text-shadow:0 1px 0 white}.ai1wm-accordion{margin:10px 0 20px 0}.ai1wm-accordion .ai1wm-title{cursor:pointer;float:left}.ai1wm-accordion .ai1wm-title:after{clear:both}.ai1wm-accordion .ai1wm-title:hover{color:rgba(0,116,162,0.8)}.ai1wm-accordion .ai1wm-content{display:none;margin:22px 0px 0px 22px}.ai1wm-accordion.ai1wm-active .ai1wm-title .ai1wm-icon-arrow-right:before{content:"\e606"}.ai1wm-accordion.ai1wm-active .ai1wm-content{display:block}.ai1wm-include-tables{display:inline-block;width:300px;margin:0 6px 0 0}.ai1wm-include-plugins{display:inline-block;width:300px;vertical-align:top}.ai1wm-include-media{display:inline-block;width:300px;margin:0 6px 0 0}.ai1wm-include-themes{display:inline-block;width:300px;vertical-align:top}
|
lib/view/assets/css/import.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.ai1wm-divider{margin:1rem 0rem;border-top:1px solid rgba(0,0,0,0.1);border-bottom:1px solid rgba(255,255,255,0.8);line-height:1;height:0em;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0);position:absolute;border:none;height:0em;margin:0em;background-color:transparent;font-size:0.875rem;font-weight:bold;text-align:center;text-transform:uppercase;color:rgba(0,0,0,0.8)}.ai1wm-divider{position:relative;top:0%;left:0%;margin:1rem 2.5rem;height:auto;padding:0em;line-height:1}.ai1wm-divider:before,.ai1wm-divider:after{position:absolute;top:50%;content:" ";z-index:3;width:50%;top:50%;height:0%;border-top:1px solid rgba(0,0,0,0.1);border-bottom:1px solid rgba(255,255,255,0.8)}.ai1wm-divider:before{left:0%;margin-left:-2.5rem}.ai1wm-divider:after{left:auto;right:0%;margin-right:-2.5rem}@font-face{font-family:'servmask';src:url("../font/servmask.eot");src:url("../font/servmask.eot?#iefix") format("embedded-opentype"),url("../font/servmask.woff") format("woff"),url("../font/servmask.ttf") format("truetype"),url("../font/servmask.svg#servmask") format("svg");font-weight:normal;font-style:normal}[class^="ai1wm-icon-"],[class*=" ai1wm-icon-"]{font-family:'servmask';speak:none;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ai1wm-icon-plus:before{content:"\e600"}.ai1wm-icon-plus2:before{content:"\e601"}.ai1wm-icon-plus3:before{content:"\e602"}.ai1wm-icon-history:before{content:"\e603"}.ai1wm-icon-arrow-down:before{content:"\e604"}.ai1wm-icon-arrow-right:before{content:"\e605"}.ai1wm-icon-arrow-down2:before{content:"\e606"}.ai1wm-icon-plus:before{content:"\e607"}.ai1wm-icon-paperplane:before{content:"\e608"}.ai1wm-icon-help:before{content:"\e609"}.ai1wm-icon-file:before{content:"\e60a"}@media (min-width: 855px){.ai1wm-row{margin-right:399px}.ai1wm-row:before,.ai1wm-row:after{content:" ";display:table}.ai1wm-row:after{clear:both}.ai1wm-left{float:left;width:100%}.ai1wm-right{float:right;width:377px;margin-right:-399px}.ai1wm-right .ai1wm-sidebar{width:100%}.ai1wm-right .ai1wm-segment{width:333px;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 white;color:#333333;background-color:#f9f9f9;padding:22px;text-decoration:none;text-shadow:0 1px 0 white;background-clip:padding-box}.ai1wm-right .ai1wm-feedback-email{width:100%;font-weight:normal;font-size:0.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-right .ai1wm-feedback-message{width:100%;border-radius:3px;font-size:0.8rem;padding:6px 10px;resize:none}.ai1wm-right .ai1wm-feedback-terms-segment{font-size:0.7rem;line-height:1rem;margin:4px 0 8px 0}}.ai1wm-holder{border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 white;padding:22px;background:#f9f9f9}.ai1wm-holder h1{margin-top:0 !important}.ai1wm-segment>.ai1wm-divider:first-child{margin-top:0 !important}@media (max-width: 854px){.ai1wm-container{margin-left:10px !important}.ai1wm-row{margin-right:0px !important}.ai1wm-right{float:left !important;width:100% !important;margin-top:18px;margin-right:0 !important}.ai1wm-right .ai1wm-sidebar{width:auto !important;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 white;padding:22px;background:#f9f9f9}.ai1wm-right .ai1wm-feedback-email{width:100%;font-weight:normal;font-size:0.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-right .ai1wm-feedback-message{width:100%;border-radius:3px;font-size:0.8rem;padding:6px 10px;resize:none}.ai1wm-right .ai1wm-feedback-terms-segment{font-size:0.7rem;line-height:1rem;margin:4px 0 8px 0}}.ai1wm-container{margin:20px 20px 0px 2px}.ai1wm-container:before,.ai1wm-container:after{content:" ";display:table}.ai1wm-container:after{clear:both}.ai1wm-replace-row{width:100%;box-shadow:outset 0 1px 0 0 white;border-radius:3px;color:#333333;font-size:11px;font-weight:bold;background-color:#f9f9f9;text-decoration:none;text-shadow:0 1px 0 white;background-clip:padding-box;margin-bottom:10px}.ai1wm-replace-row .ai1wm-field-inline{float:left;width:100%}.ai1wm-replace-row .ai1wm-field-inline input{width:100%;font-weight:normal;font-size:0.8rem;padding:0 10px;height:2.3rem;line-height:2.3rem;margin-bottom:4px}.ai1wm-field{margin-bottom:4px}.ai1wm-field input[type="text"],.ai1wm-field textarea{width:100%;font-weight:normal}.ai1wm-message{-moz-box-sizing:border-box;background-color:#EFEFEF;border-radius:4px;color:rgba(0,0,0,0.6);height:auto;margin:10px 0;min-height:18px;padding:10px;position:relative;transition:opacity 0.1s ease 0s, color 0.1s ease 0s, background 0.1s ease 0s, box-shadow 0.1s ease 0s}.ai1wm-message.ai1wm-green-message{background-color:#F2F8F0;color:#119000}.ai1wm-message.ai1wm-blue-message{background-color:#E6F4F9;color:#4D8796}.ai1wm-message.ai1wm-red-message{background-color:#F1D7D7;color:#A95252}.ai1wm-message p{margin:4px 0}.ai1wm-button-gray{border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 #fff;color:#333;display:inline-block;font-size:11px;font-weight:bold;background-color:#fafafa;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #fafafa),color-stop(100%, #dedede));background-image:-webkit-linear-gradient(#fafafa,#dedede);background-image:linear-gradient(#fafafa,#dedede);padding:7px 18px;text-decoration:none;text-shadow:0 1px 0 #fff;background-clip:padding-box}.ai1wm-button-gray:hover:not(:disabled){box-shadow:inset 0 1px 0 0 #fff;cursor:pointer;background-color:#ededed;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #ededed),color-stop(100%, #d6d6d6));background-image:-webkit-linear-gradient(#ededed,#d6d6d6);background-image:linear-gradient(#ededed,#d6d6d6)}.ai1wm-button-gray:active:not(:disabled){border:1px solid #d6d6d6;box-shadow:inset 0 0 8px 4px #cfcfcf,inset 0 0 8px 4px #cfcfcf,0 1px 1px 0 #eee}.ai1wm-button-gray:disabled{opacity:0.5;cursor:not-allowed}.ai1wm-button-green{border:1px solid #4d8b2c;border-radius:3px;box-shadow:inset 0 1px 0 0 #9cc587;color:#fff;display:inline-block;font-size:11px;font-weight:bold;background-color:#6eb649;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #6eb649),color-stop(100%, #539730));background-image:-webkit-linear-gradient(#6eb649,#539730);background-image:linear-gradient(#6eb649,#539730);padding:7px 18px;text-decoration:none;text-shadow:0 1px 0 #428122;background-clip:padding-box}.ai1wm-button-green:hover:not(:disabled){box-shadow:inset 0 1px 0 0 #7fb563;cursor:pointer;background-color:#649f46;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #649f46),color-stop(100%, #4d8a2d));background-image:-webkit-linear-gradient(#649f46,#4d8a2d);background-image:linear-gradient(#649f46,#4d8a2d)}.ai1wm-button-green:active:not(:disabled){border:1px solid #4d8b2c;box-shadow:inset 0 0 8px 4px #477e2a,inset 0 0 8px 4px #477e2a,0 1px 1px 0 #eee}.ai1wm-button-green:disabled{opacity:0.5;cursor:not-allowed}.ai1wm-button-blue{border:1px solid #007ba9;border-radius:3px;box-shadow:inset 0 1px 0 0 #45c7f7;color:#fff;display:inline-block;font-size:11px;font-weight:bold;background-color:#00aff0;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #00aff0),color-stop(100%, #0086b8));background-image:-webkit-linear-gradient(#00aff0,#0086b8);background-image:linear-gradient(#00aff0,#0086b8);padding:7px 18px;text-decoration:none;text-shadow:0 1px 0 #006c94;background-clip:padding-box}.ai1wm-button-blue:hover:not(:disabled){box-shadow:inset 0 1px 0 0 #13b9f6;cursor:pointer;background-color:#049ad2;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #049ad2),color-stop(100%, #007ba9));background-image:-webkit-linear-gradient(#049ad2,#007ba9);background-image:linear-gradient(#049ad2,#007ba9)}.ai1wm-button-blue:active:not(:disabled){border:1px solid #007ba9;box-shadow:inset 0 0 8px 4px #007099,inset 0 0 8px 4px #007099,0 1px 1px 0 #eee}.ai1wm-button-blue:disabled{opacity:0.5;cursor:not-allowed}.ai1wm-button-gray i,.ai1wm-button-green i,.ai1wm-button-blue i{margin-left:-0.5em;margin-right:0.2em}.ai1wm-button-gray i.ai1wm-alone,.ai1wm-button-green i.ai1wm-alone,.ai1wm-button-blue i.ai1wm-alone{margin-right:-0.5em !important}.ai1wm-clear{*zoom:1}.ai1wm-clear:before,.ai1wm-clear:after{content:" ";display:table}.ai1wm-clear:after{clear:both}.ai1wm-field-inline input{border-radius:5px}.ai1wm-toggle-checkbox label{color:#333333;display:inline-block;font-size:11px;font-weight:bold;text-decoration:none;text-shadow:0 1px 0 white}.ai1wm-drag-drop-area{border:4px dashed #DDDDDD;height:200px;margin:20px 0 16px 0;background:#fff}.ai1wm-drag-drop-area.dragover{background:rgba(255,255,255,0.4);border-color:green}.ai1wm-drag-drop-area .ai1wm-drag-drop-inside{margin:70px auto 0;width:250px}.ai1wm-drag-drop-inside p{display:block;text-align:center;color:#AAAAAA;font-size:14px;margin:5px 0}.ai1wm-drag-drop-inside p.ai1wm-drag-drop-info{font-size:20px}.ai1wm-drag-drop-inside p.ai1wm-upload-progress{margin:-15px 0 15px 0;display:none;color:#000;font-size:20px}.ai1wm-drag-over #ai1wm-drag-drop-area{border-color:#83b4d8}.ai1wm-upload-file-message{display:none}
|
1 |
+
.ai1wm-divider{margin:1rem 0rem;border-top:1px solid rgba(0,0,0,0.1);border-bottom:1px solid rgba(255,255,255,0.8);line-height:1;height:0em;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0);position:absolute;border:none;height:0em;margin:0em;background-color:transparent;font-size:0.875rem;font-weight:bold;text-align:center;text-transform:uppercase;color:rgba(0,0,0,0.8)}.ai1wm-divider{position:relative;top:0%;left:0%;margin:1rem 2.5rem;height:auto;padding:0em;line-height:1}.ai1wm-divider:before,.ai1wm-divider:after{position:absolute;top:50%;content:" ";z-index:3;width:50%;top:50%;height:0%;border-top:1px solid rgba(0,0,0,0.1);border-bottom:1px solid rgba(255,255,255,0.8)}.ai1wm-divider:before{left:0%;margin-left:-2.5rem}.ai1wm-divider:after{left:auto;right:0%;margin-right:-2.5rem}@font-face{font-family:'servmask';src:url("../font/servmask.eot");src:url("../font/servmask.eot?#iefix") format("embedded-opentype"),url("../font/servmask.woff") format("woff"),url("../font/servmask.ttf") format("truetype"),url("../font/servmask.svg#servmask") format("svg");font-weight:normal;font-style:normal}[class^="ai1wm-icon-"],[class*=" ai1wm-icon-"]{font-family:'servmask';speak:none;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ai1wm-icon-plus:before{content:"\e600"}.ai1wm-icon-plus2:before{content:"\e601"}.ai1wm-icon-plus3:before{content:"\e602"}.ai1wm-icon-history:before{content:"\e603"}.ai1wm-icon-arrow-down:before{content:"\e604"}.ai1wm-icon-arrow-right:before{content:"\e605"}.ai1wm-icon-arrow-down2:before{content:"\e606"}.ai1wm-icon-plus:before{content:"\e607"}.ai1wm-icon-paperplane:before{content:"\e608"}.ai1wm-icon-help:before{content:"\e609"}.ai1wm-icon-file:before{content:"\e60a"}@media (min-width: 855px){.ai1wm-row{margin-right:399px}.ai1wm-row:before,.ai1wm-row:after{content:" ";display:table}.ai1wm-row:after{clear:both}.ai1wm-left{float:left;width:100%}.ai1wm-right{float:right;width:377px;margin-right:-399px}.ai1wm-right .ai1wm-sidebar{width:100%}.ai1wm-right .ai1wm-segment{width:333px;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 white;color:#333333;background-color:#f9f9f9;padding:22px;text-decoration:none;text-shadow:0 1px 0 white;background-clip:padding-box}.ai1wm-right .ai1wm-feedback-email{width:100%;font-weight:normal;font-size:0.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-right .ai1wm-feedback-message{width:100%;border-radius:3px;font-size:0.8rem;padding:6px 10px;resize:none}.ai1wm-right .ai1wm-feedback-terms-segment{font-size:0.7rem;line-height:1rem;margin:4px 0 8px 0}.ai1wm-right .ai1wm-feedback-terms-segment>.ai1wm-feedback-terms{border-radius:3px}}.ai1wm-holder{border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 white;padding:22px;background:#f9f9f9}.ai1wm-holder h1{margin-top:0 !important}.ai1wm-segment>.ai1wm-divider:first-child{margin-top:0 !important}@media (max-width: 854px){.ai1wm-container{margin-left:10px !important}.ai1wm-row{margin-right:0px !important}.ai1wm-right{float:left !important;width:100% !important;margin-top:18px;margin-right:0 !important}.ai1wm-right .ai1wm-sidebar{width:auto !important;border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 white;padding:22px;background:#f9f9f9}.ai1wm-right .ai1wm-feedback-email{width:100%;font-weight:normal;font-size:0.8rem;height:2.3rem;line-height:2.3rem;border-radius:5px;margin-bottom:4px;padding:0 10px}.ai1wm-right .ai1wm-feedback-message{width:100%;border-radius:3px;font-size:0.8rem;padding:6px 10px;resize:none}.ai1wm-right .ai1wm-feedback-terms-segment{font-size:0.7rem;line-height:1rem;margin:4px 0 8px 0;border-radius:3px}.ai1wm-right .ai1wm-feedback-terms-segment>.ai1wm-feedback-terms{border-radius:3px}}.ai1wm-container{margin:20px 20px 0px 2px}.ai1wm-container:before,.ai1wm-container:after{content:" ";display:table}.ai1wm-container:after{clear:both}.ai1wm-replace-row{width:100%;box-shadow:outset 0 1px 0 0 white;border-radius:3px;color:#333333;font-size:11px;font-weight:bold;background-color:#f9f9f9;text-decoration:none;text-shadow:0 1px 0 white;background-clip:padding-box;margin-bottom:10px}.ai1wm-replace-row .ai1wm-field-inline{float:left;width:100%}.ai1wm-replace-row .ai1wm-field-inline input{width:100%;font-weight:normal;font-size:0.8rem;padding:0 10px;height:2.3rem;line-height:2.3rem;margin-bottom:4px}.ai1wm-field{margin-bottom:4px}.ai1wm-field input[type="text"],.ai1wm-field textarea{width:100%;font-weight:normal}.ai1wm-message{-moz-box-sizing:border-box;background-color:#EFEFEF;border-radius:4px;color:rgba(0,0,0,0.6);height:auto;margin:10px 0;min-height:18px;padding:10px;position:relative;transition:opacity 0.1s ease 0s, color 0.1s ease 0s, background 0.1s ease 0s, box-shadow 0.1s ease 0s}.ai1wm-message.ai1wm-green-message{background-color:#F2F8F0;color:#119000}.ai1wm-message.ai1wm-blue-message{background-color:#E6F4F9;color:#4D8796}.ai1wm-message.ai1wm-red-message{background-color:#F1D7D7;color:#A95252}.ai1wm-message p{margin:4px 0}.ai1wm-button-gray{border:1px solid #d6d6d6;border-radius:3px;box-shadow:inset 0 1px 0 0 #fff;color:#333;display:inline-block;font-size:11px;font-weight:bold;background-color:#fafafa;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #fafafa),color-stop(100%, #dedede));background-image:-webkit-linear-gradient(#fafafa,#dedede);background-image:linear-gradient(#fafafa,#dedede);padding:7px 18px;text-decoration:none;text-shadow:0 1px 0 #fff;background-clip:padding-box}.ai1wm-button-gray:hover:not(:disabled){box-shadow:inset 0 1px 0 0 #fff;cursor:pointer;background-color:#ededed;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #ededed),color-stop(100%, #d6d6d6));background-image:-webkit-linear-gradient(#ededed,#d6d6d6);background-image:linear-gradient(#ededed,#d6d6d6)}.ai1wm-button-gray:active:not(:disabled){border:1px solid #d6d6d6;box-shadow:inset 0 0 8px 4px #cfcfcf,inset 0 0 8px 4px #cfcfcf,0 1px 1px 0 #eee}.ai1wm-button-gray:disabled{opacity:0.5;cursor:not-allowed}.ai1wm-button-green{border:1px solid #4d8b2c;border-radius:3px;box-shadow:inset 0 1px 0 0 #9cc587;color:#fff;display:inline-block;font-size:11px;font-weight:bold;background-color:#6eb649;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #6eb649),color-stop(100%, #539730));background-image:-webkit-linear-gradient(#6eb649,#539730);background-image:linear-gradient(#6eb649,#539730);padding:7px 18px;text-decoration:none;text-shadow:0 1px 0 #428122;background-clip:padding-box}.ai1wm-button-green:hover:not(:disabled){box-shadow:inset 0 1px 0 0 #7fb563;cursor:pointer;background-color:#649f46;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #649f46),color-stop(100%, #4d8a2d));background-image:-webkit-linear-gradient(#649f46,#4d8a2d);background-image:linear-gradient(#649f46,#4d8a2d)}.ai1wm-button-green:active:not(:disabled){border:1px solid #4d8b2c;box-shadow:inset 0 0 8px 4px #477e2a,inset 0 0 8px 4px #477e2a,0 1px 1px 0 #eee}.ai1wm-button-green:disabled{opacity:0.5;cursor:not-allowed}.ai1wm-button-blue{border:1px solid #007ba9;border-radius:3px;box-shadow:inset 0 1px 0 0 #45c7f7;color:#fff;display:inline-block;font-size:11px;font-weight:bold;background-color:#00aff0;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #00aff0),color-stop(100%, #0086b8));background-image:-webkit-linear-gradient(#00aff0,#0086b8);background-image:linear-gradient(#00aff0,#0086b8);padding:7px 18px;text-decoration:none;text-shadow:0 1px 0 #006c94;background-clip:padding-box}.ai1wm-button-blue:hover:not(:disabled){box-shadow:inset 0 1px 0 0 #13b9f6;cursor:pointer;background-color:#049ad2;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #049ad2),color-stop(100%, #007ba9));background-image:-webkit-linear-gradient(#049ad2,#007ba9);background-image:linear-gradient(#049ad2,#007ba9)}.ai1wm-button-blue:active:not(:disabled){border:1px solid #007ba9;box-shadow:inset 0 0 8px 4px #007099,inset 0 0 8px 4px #007099,0 1px 1px 0 #eee}.ai1wm-button-blue:disabled{opacity:0.5;cursor:not-allowed}.ai1wm-button-gray i,.ai1wm-button-green i,.ai1wm-button-blue i{margin-left:-0.5em;margin-right:0.2em}.ai1wm-button-gray i.ai1wm-alone,.ai1wm-button-green i.ai1wm-alone,.ai1wm-button-blue i.ai1wm-alone{margin-right:-0.5em !important}.ai1wm-clear{*zoom:1}.ai1wm-clear:before,.ai1wm-clear:after{content:" ";display:table}.ai1wm-clear:after{clear:both}.ai1wm-field-inline input{border-radius:5px}.ai1wm-toggle-checkbox label{color:#333333;display:inline-block;font-size:11px;font-weight:bold;text-decoration:none;text-shadow:0 1px 0 white}.ai1wm-drag-drop-area{border:4px dashed #DDDDDD;height:200px;margin:20px 0 16px 0;background:#fff}.ai1wm-drag-drop-area.dragover{background:rgba(255,255,255,0.4);border-color:green}.ai1wm-drag-drop-area .ai1wm-drag-drop-inside{margin:70px auto 0;width:250px}.ai1wm-drag-drop-inside p{display:block;text-align:center;color:#AAAAAA;font-size:14px;margin:5px 0}.ai1wm-drag-drop-inside p.ai1wm-drag-drop-info{font-size:20px}.ai1wm-drag-drop-inside p.ai1wm-upload-progress{margin:-15px 0 15px 0;display:none;color:#000;font-size:20px}.ai1wm-drag-over #ai1wm-drag-drop-area{border-color:#83b4d8}.ai1wm-upload-file-message{display:none}
|
lib/view/assets/javascript/import.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
jQuery(document).ready(function($){"use strict";$("#ai1wm-feedback-submit").click(function(){var url=ai1wm_feedback.ajax.url,email=$(".ai1wm-feedback-email").val(),message=$(".ai1wm-feedback-message").val(),terms=$(".ai1wm-feedback-terms").is(":checked");$.ajax({type:"POST",url:url,data:{email:email,message:message,terms:+terms},success:function(data){var errors=data.errors;if(errors.length>0){$("#ai1wm-feedback .ai1wm-message").remove();var content=$("<div />").addClass("ai1wm-message ai1wm-red-message");$.each(errors,function(key,value){content.append("<p>"+value+"</p>")}),$("#ai1wm-feedback").prepend(content)}else{var content=$("<div />").addClass("ai1wm-message ai1wm-green-message").append("<p>Thanks for submitting your feedback!</p>");$("#ai1wm-feedback").html(content)}},dataType:"json",async:!1})})}),jQuery(document).ready(function($){"use strict";var display_upload_errors=function(errors){var box=$(".ai1wm-upload-file-message");box.removeClass("ai1wm-green-message").addClass("ai1wm-red-message"),box.find("p").remove(),errors.length>0?($.each(errors,function(index,value){box.append("<p>"+value+"</p>")}),box.show()):box.hide()},display_upload_messages=function(messages){var box=$(".ai1wm-upload-file-message");box.removeClass("ai1wm-red-message").addClass("ai1wm-green-message"),box.find("p").remove(),messages.length>0?($.each(messages,function(index,value){box.append("<p>"+value+"</p>")}),box.show()):box.hide()},upload_progress=function(up,file){var box=$(".ai1wm-upload-progress");box.text(file.percent+"%"),box.show()},upload_error=function(up,error){var message=null;message=-601===error.code?"File extension error! Please ensure that the file is in <strong>ZIP</strong> archive format.":error.message,display_upload_errors([message]),up.refresh()},file_uploaded=function(up,file,result){var json=$.parseJSON(result.response);display_upload_errors(json.errors)},upload_complete=function(){var errors=$(".ai1wm-upload-file-message.ai1wm-red-message p");0==errors.length&&display_upload_messages(["Archive was successfully uploaded and imported into
|
1 |
+
jQuery(document).ready(function($){"use strict";$("#ai1wm-feedback-submit").click(function(){var url=ai1wm_feedback.ajax.url,email=$(".ai1wm-feedback-email").val(),message=$(".ai1wm-feedback-message").val(),terms=$(".ai1wm-feedback-terms").is(":checked");$.ajax({type:"POST",url:url,data:{email:email,message:message,terms:+terms},success:function(data){var errors=data.errors;if(errors.length>0){$("#ai1wm-feedback .ai1wm-message").remove();var content=$("<div />").addClass("ai1wm-message ai1wm-red-message");$.each(errors,function(key,value){content.append("<p>"+value+"</p>")}),$("#ai1wm-feedback").prepend(content)}else{var content=$("<div />").addClass("ai1wm-message ai1wm-green-message").append("<p>Thanks for submitting your feedback!</p>");$("#ai1wm-feedback").html(content)}},dataType:"json",async:!1})})}),jQuery(document).ready(function($){"use strict";var display_upload_errors=function(errors){var box=$(".ai1wm-upload-file-message");box.removeClass("ai1wm-green-message").addClass("ai1wm-red-message"),box.find("p").remove(),errors.length>0?($.each(errors,function(index,value){box.append("<p>"+value+"</p>")}),box.show()):box.hide()},display_upload_messages=function(messages){var box=$(".ai1wm-upload-file-message");box.removeClass("ai1wm-red-message").addClass("ai1wm-green-message"),box.find("p").remove(),messages.length>0?($.each(messages,function(index,value){box.append("<p>"+value+"</p>")}),box.show()):box.hide()},upload_progress=function(up,file){var box=$(".ai1wm-upload-progress");box.text(file.percent+"%"),box.show()},upload_error=function(up,error){var message=null;message=-601===error.code?"File extension error! Please ensure that the file is in <strong>ZIP</strong> archive format.":error.message,display_upload_errors([message]),up.refresh()},file_uploaded=function(up,file,result){var json=$.parseJSON(result.response);display_upload_errors(json.errors)},upload_complete=function(){var errors=$(".ai1wm-upload-file-message.ai1wm-red-message p");0==errors.length&&display_upload_messages(["Archive was successfully uploaded and imported into WordPress."])},uploader=new plupload.Uploader(ai1wm_uploader);uploader.bind("Init",function(up){var uploaddiv=$("#ai1wm-plupload-upload-ui");up.features.dragdrop&&!$(document.body).hasClass("mobile")?$("#ai1wm-drag-drop-area").bind("dragover.wp-uploader",function(){uploaddiv.addClass("ai1wm-drag-over")}).bind("dragleave.wp-uploader, drop.wp-uploader",function(){uploaddiv.removeClass("ai1wm-drag-over")}):$("#ai1wm-drag-drop-area").unbind(".wp-uploader"),"html4"==up.runtime&&$(".upload-flash-bypass").hide()}),uploader.init(),uploader.bind("FilesAdded",function(up){up.refresh(),up.start()}),uploader.bind("BeforeUpload",function(){var box=$(".ai1wm-upload-file-message");box.hide()}),uploader.bind("UploadFile",function(){}),uploader.bind("UploadProgress",upload_progress),uploader.bind("Error",upload_error),uploader.bind("FileUploaded",file_uploaded),uploader.bind("UploadComplete",upload_complete)});
|
lib/view/export/index.php
CHANGED
@@ -93,6 +93,9 @@
|
|
93 |
<input type="checkbox" id="export-plugins" name="options[export-plugins]" />
|
94 |
<label for="export-plugins"><?php _e( 'Do not export plugins (files)' ); ?></label>
|
95 |
</div>
|
|
|
|
|
|
|
96 |
</div>
|
97 |
|
98 |
<div class="ai1wm-field">
|
@@ -104,14 +107,13 @@
|
|
104 |
|
105 |
<div class="ai1wm-field">
|
106 |
<div class="ai1wm-checkbox">
|
107 |
-
<input type="checkbox" id="
|
108 |
-
<label for="
|
109 |
</div>
|
110 |
</div>
|
111 |
</div>
|
112 |
</div>
|
113 |
|
114 |
-
<?php if ( class_exists( 'Zipper' ) ): ?>
|
115 |
<div class="ai1wm-field">
|
116 |
<div class="ai1wm-buttons">
|
117 |
<button type="submit" name="options[action]" value="export" class="ai1wm-button-green">
|
@@ -120,11 +122,6 @@
|
|
120 |
</button>
|
121 |
</div>
|
122 |
</div>
|
123 |
-
<?php else : ?>
|
124 |
-
<div class="ai1wm-message ai1wm-red-message">
|
125 |
-
<p><?php _e( 'Please enable zlib library in your php.ini configuration file in order to be able to export database and media library (files).' ); ?></p>
|
126 |
-
</div>
|
127 |
-
<?php endif; ?>
|
128 |
</form>
|
129 |
</div>
|
130 |
</div>
|
93 |
<input type="checkbox" id="export-plugins" name="options[export-plugins]" />
|
94 |
<label for="export-plugins"><?php _e( 'Do not export plugins (files)' ); ?></label>
|
95 |
</div>
|
96 |
+
<?php foreach ( $list_plugins as $key => $plugin ): ?>
|
97 |
+
<input type="hidden" name="options[include-plugins][<?php _e( $key ); ?>]" value="<?php _e( $plugin['Name'] ); ?>" />
|
98 |
+
<?php endforeach; ?>
|
99 |
</div>
|
100 |
|
101 |
<div class="ai1wm-field">
|
107 |
|
108 |
<div class="ai1wm-field">
|
109 |
<div class="ai1wm-checkbox">
|
110 |
+
<input type="checkbox" id="no-table-data" name="options[no-table-data]" />
|
111 |
+
<label for="no-table-data"><?php _e( 'Do not export table data' ); ?></label>
|
112 |
</div>
|
113 |
</div>
|
114 |
</div>
|
115 |
</div>
|
116 |
|
|
|
117 |
<div class="ai1wm-field">
|
118 |
<div class="ai1wm-buttons">
|
119 |
<button type="submit" name="options[action]" value="export" class="ai1wm-button-green">
|
122 |
</button>
|
123 |
</div>
|
124 |
</div>
|
|
|
|
|
|
|
|
|
|
|
125 |
</form>
|
126 |
</div>
|
127 |
</div>
|
loader.php
CHANGED
@@ -17,58 +17,52 @@
|
|
17 |
*/
|
18 |
|
19 |
// include all the files that you want to load in here
|
20 |
-
require_once
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
require_once
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
);
|
70 |
-
require_once(
|
71 |
-
AI1WM_MODEL_PATH .
|
72 |
-
DIRECTORY_SEPARATOR .
|
73 |
-
'class-ai1wm-import.php'
|
74 |
-
);
|
17 |
*/
|
18 |
|
19 |
// include all the files that you want to load in here
|
20 |
+
require_once AI1WM_VENDOR_PATH .
|
21 |
+
DIRECTORY_SEPARATOR .
|
22 |
+
'mysqldump-factory' .
|
23 |
+
DIRECTORY_SEPARATOR .
|
24 |
+
'mysqldump-factory' .
|
25 |
+
DIRECTORY_SEPARATOR .
|
26 |
+
'lib' .
|
27 |
+
DIRECTORY_SEPARATOR .
|
28 |
+
'MysqlDumpFactory.php';
|
29 |
+
|
30 |
+
require_once AI1WM_VENDOR_PATH .
|
31 |
+
DIRECTORY_SEPARATOR .
|
32 |
+
'bandar' .
|
33 |
+
DIRECTORY_SEPARATOR .
|
34 |
+
'bandar' .
|
35 |
+
DIRECTORY_SEPARATOR .
|
36 |
+
'lib' .
|
37 |
+
DIRECTORY_SEPARATOR .
|
38 |
+
'Bandar.php';
|
39 |
+
|
40 |
+
require_once AI1WM_VENDOR_PATH .
|
41 |
+
DIRECTORY_SEPARATOR .
|
42 |
+
'zip-factory' .
|
43 |
+
DIRECTORY_SEPARATOR .
|
44 |
+
'zip-factory' .
|
45 |
+
DIRECTORY_SEPARATOR .
|
46 |
+
'lib' .
|
47 |
+
DIRECTORY_SEPARATOR .
|
48 |
+
'ZipFactory.php';
|
49 |
+
|
50 |
+
require_once AI1WM_CONTROLLER_PATH .
|
51 |
+
DIRECTORY_SEPARATOR .
|
52 |
+
'class-ai1wm-main-controller.php';
|
53 |
+
|
54 |
+
require_once AI1WM_CONTROLLER_PATH .
|
55 |
+
DIRECTORY_SEPARATOR .
|
56 |
+
'class-ai1wm-import-controller.php';
|
57 |
+
|
58 |
+
require_once AI1WM_CONTROLLER_PATH .
|
59 |
+
DIRECTORY_SEPARATOR .
|
60 |
+
'class-ai1wm-export-controller.php';
|
61 |
+
|
62 |
+
require_once AI1WM_MODEL_PATH .
|
63 |
+
DIRECTORY_SEPARATOR .
|
64 |
+
'class-ai1wm-template.php';
|
65 |
+
|
66 |
+
require_once AI1WM_MODEL_PATH . DIRECTORY_SEPARATOR . 'class-ai1wm-export.php';
|
67 |
+
|
68 |
+
require_once AI1WM_MODEL_PATH . DIRECTORY_SEPARATOR . 'class-ai1wm-import.php';
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: yani.iliev, bangelov, mirkov
|
|
3 |
Tags: db migration, migration, wordpress migration, db backup, db restore, website backup, website restore, website migration, website deploy, wordpress deploy, db backup, database export, database serialization, database find replace
|
4 |
Requires at least: 3.3
|
5 |
Tested up to: 3.8
|
6 |
-
Stable tag: 1.
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
All-in-One WP Migration is the only tools that you will ever needs when you need to perform site migration of your WordPress blog.
|
@@ -16,7 +16,33 @@ You can apply unlimited find and replace operations on your database and the plu
|
|
16 |
All in One WP Plugin is the first plugin to offer true mobile experience on WordPress versions 3.3 and up.
|
17 |
|
18 |
= Bypass all upload size restriction =
|
19 |
-
We use chunks to import your data and that way we bypass any webserver upload size restrictions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
[youtube http://www.youtube.com/watch?v=5FMzLf9a4Dc]
|
22 |
|
@@ -34,6 +60,13 @@ We use chunks to import your data and that way we bypass any webserver upload si
|
|
34 |
|
35 |
== Changelog ==
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
= 1.1.0 =
|
38 |
* Importing files using chunks to overcome any webserver upload size restriction
|
39 |
* Fixed a bug where HTTP code error was shown to some users
|
3 |
Tags: db migration, migration, wordpress migration, db backup, db restore, website backup, website restore, website migration, website deploy, wordpress deploy, db backup, database export, database serialization, database find replace
|
4 |
Requires at least: 3.3
|
5 |
Tested up to: 3.8
|
6 |
+
Stable tag: 1.2.0
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
All-in-One WP Migration is the only tools that you will ever needs when you need to perform site migration of your WordPress blog.
|
16 |
All in One WP Plugin is the first plugin to offer true mobile experience on WordPress versions 3.3 and up.
|
17 |
|
18 |
= Bypass all upload size restriction =
|
19 |
+
* We use chunks to import your data and that way we bypass any webserver upload size restrictions up to **512MB** - commercial version supports up to **5GB**
|
20 |
+
|
21 |
+
= Works with PHP v5.2.17 and above =
|
22 |
+
* We tested the plugin on a php compiled with the following modules:
|
23 |
+
`./configure --with-zlib --with-mysql`
|
24 |
+
|
25 |
+
= Support for MySQL, PDO, MySQLi =
|
26 |
+
* No matter what php mysql driver your webserver ships with, we support it
|
27 |
+
|
28 |
+
= Support for ZipArchive and PclZIP =
|
29 |
+
* Your export files are archived using the fast ZipArchive pecl extension. If your server doesn't have it, we fall back to PclZIP which is included in WordPress
|
30 |
+
|
31 |
+
= True WordPress v3.3 Support =
|
32 |
+
* We tested every single WordPress version from `3.3` up to `3.8`
|
33 |
+
|
34 |
+
= Coming soon in a commercial version =
|
35 |
+
* A new, slicker design
|
36 |
+
* Themes picker - you can select exactly what themes you want to export - start with just theme names or dig deep and select single files
|
37 |
+
* Media picker - allows you to select what media files you want to export
|
38 |
+
* Plugins picker - allows you to select what plugins to export as well as to dig deeper and select the exact files to export
|
39 |
+
* Database picker - select what tables to export
|
40 |
+
* Custom post type picker - select what post types to export (pages, posts, events, videos etc)
|
41 |
+
* Post and Page picker - select what posts or pages you would like to include in your data export.
|
42 |
+
* Users picker - select the users that you want to include in your export
|
43 |
+
|
44 |
+
**If you signup for our beta program, you will receive a free license for the commercial version when we release it as well as a few other perks like a free staging platform and access to our super-fast `Opinionated WordPress Hosting`.**
|
45 |
+
[All in One WP Migration Beta](https://servmask.com/beta "All in One WP Migration")
|
46 |
|
47 |
[youtube http://www.youtube.com/watch?v=5FMzLf9a4Dc]
|
48 |
|
60 |
|
61 |
== Changelog ==
|
62 |
|
63 |
+
= 1.2.0 =
|
64 |
+
* Increased upload limit of files from 150MB to 500MB
|
65 |
+
* Use ZipArchive with fallback to PclZip (a few users notified us that they don’t have ZipArchive enabled on their servers)
|
66 |
+
* Use PDO with fallback to mysql (a few users notified us that they dont have PDO enabled on their servers, mysql is deprecated as of PHP v5.5 but we are supporting PHP v5.2.17).
|
67 |
+
* Support for PHP v5.2.17 and WordPress v3.3 and above.
|
68 |
+
* Fix a bug during export that causes plugins to not be exported on some hosts (the problem that you are experiencing).
|
69 |
+
|
70 |
= 1.1.0 =
|
71 |
* Importing files using chunks to overcome any webserver upload size restriction
|
72 |
* Fixed a bug where HTTP code error was shown to some users
|