InfiniteWP Client - Version 1.3.6

Version Description

  • Fix: IWP's PCLZIP clash with other plugins. PCLZIP constants have been renamed to avoid further conflicts. This will fix empty folder error - "Error creating database backup folder (). Make sure you have correct write permissions."
  • Fix: Amazon S3 related - Call to a member function list_parts() on a non-object in wp-content/plugins/iwp-client/backup.class.multicall.php on line 4587.
Download this release

Release Info

Developer infinitewp
Plugin Icon 128x128 InfiniteWP Client
Version 1.3.6
Comparing to
See all releases

Code changes from version 1.3.5 to 1.3.6

Files changed (5) hide show
  1. backup.class.multicall.php +53 -53
  2. backup.class.singlecall.php +23 -23
  3. init.php +2 -2
  4. pclzip.class.php +617 -617
  5. readme.txt +4 -2
backup.class.multicall.php CHANGED
@@ -24,8 +24,8 @@ if(!defined('IWP_DB_DIR')){
24
define('IWP_DB_DIR', IWP_BACKUP_DIR . '/iwp_db');
25
}
26
27
- if(!defined('PCLZIP_TEMPORARY_DIR')){
28
- define('PCLZIP_TEMPORARY_DIR', WP_CONTENT_DIR . '/infinitewp/temp/');
29
}
30
31
@@ -226,27 +226,27 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
226
227
//pclzip temp folder creation
228
229
- if(file_exists(PCLZIP_TEMPORARY_DIR) && is_dir(PCLZIP_TEMPORARY_DIR))
230
{
231
$this->statusLog($historyID, array('stage' => 'verification', 'status' => 'processing', 'statusMsg' => 'Directorywritable'));
232
}
233
else
234
{
235
- $mkdir = @mkdir(PCLZIP_TEMPORARY_DIR, 0755, true);
236
if(!$mkdir){
237
- return $this->statusLog($historyID, array('stage' => 'verification', 'status' => 'error', 'statusMsg' => 'Error creating database backup folder (' . PCLZIP_TEMPORARY_DIR . '). Make sure you have corrrect write permissions.', 'statusCode' => 'error_creating_database_backup_folder'));
238
}
239
}
240
- if(is_writable(PCLZIP_TEMPORARY_DIR))
241
{
242
- @file_put_contents(PCLZIP_TEMPORARY_DIR . '/index.php', ''); //safe
243
}
244
else
245
{
246
- $chmod = chmod(PCLZIP_TEMPORARY_DIR, 777);
247
- if(!is_writable(PCLZIP_TEMPORARY_DIR)){
248
//$this->statusLog($historyID, "verification", false, "can't set 777");
249
- return $this->statusLog($historyID, array('stage' => 'verification', 'status' => 'error', 'statusMsg' => PCLZIP_TEMPORARY_DIR.' directory is not writable. Please set 755 or 777 file permission and try again.', 'statusCode' => 'pclzip_dir_not_writable'));
250
}
251
}
252
@@ -514,10 +514,10 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
514
//perform the zip operations here ..... for DB
515
iwp_mmb_print_flush('DB ZIP PCL: Start');
516
// fallback to pclzip
517
- //define('PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
518
/* require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
519
$archive = new IWPPclZip($backup_file);
520
- $result = $archive->add(IWP_DB_DIR, PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR); */
521
$result = $this -> backupFilesZIP($historyID);
522
iwp_mmb_print_flush('DB ZIP PCL: End');
523
/* @unlink($db_result);
@@ -1115,7 +1115,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1115
}
1116
1117
include_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
1118
- //define('PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
1119
1120
//include_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.split.php';
1121
$returnArr = array();
@@ -1152,8 +1152,8 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1152
{
1153
if(empty($p_filedescr_list))
1154
{
1155
- //define('PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
1156
- $p_filedescr_list_array = $archive->getFileList(IWP_DB_DIR, PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, PCLZIP_OPT_CHUNK_BLOCK_SIZE, $file_block_size, PCLZIP_OPT_HISTORY_ID, $historyID); //darkCode set the file block size here .. static values
1157
$p_filedescr_list = $p_filedescr_list_array['p_filedescr_list'];
1158
unset($p_filedescr_list_array['p_filedescr_list']);
1159
@@ -1186,7 +1186,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1186
{
1187
if(empty($p_filedescr_list))
1188
{
1189
- $p_filedescr_list_array = $archive->getFileList($include_data, PCLZIP_OPT_REMOVE_PATH, ABSPATH, PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, PCLZIP_OPT_CHUNK_BLOCK_SIZE, $file_block_size, PCLZIP_OPT_HISTORY_ID, $historyID); //testing darkCode set the file block size here .. static values
1190
1191
$p_filedescr_list = $p_filedescr_list_array['p_filedescr_list'];
1192
unset($p_filedescr_list_array['p_filedescr_list']);
@@ -1268,8 +1268,8 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1268
if ( ($p_filedescr_list[$j]['type'] == 'file')
1269
|| ($p_filedescr_list[$j]['type'] == 'virtual_file')
1270
|| ( ($p_filedescr_list[$j]['type'] == 'folder')
1271
- && ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
1272
- || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
1273
) {
1274
1275
$time = microtime(true);
@@ -1557,7 +1557,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1557
{
1558
if(empty($p_filedescr_list)||($nextCount == 0))
1559
{
1560
- $p_filedescr_list_array = $archive->getFileList(IWP_DB_DIR, PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, PCLZIP_OPT_CHUNK_BLOCK_SIZE, $file_block_size, PCLZIP_OPT_HISTORY_ID, $historyID);//darkCode set the file block size here .. static values
1561
$p_filedescr_list = $p_filedescr_list_array['p_filedescr_list'];
1562
1563
if($p_filedescr_list_array['status'] == 'partiallyCompleted')
@@ -1589,7 +1589,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1589
{
1590
if(empty($p_filedescr_list)||($nextCount == 0))
1591
{
1592
- $p_filedescr_list_array = $archive->getFileList($include_data, PCLZIP_OPT_REMOVE_PATH, ABSPATH, PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, PCLZIP_OPT_CHUNK_BLOCK_SIZE, $file_block_size, PCLZIP_OPT_HISTORY_ID, $historyID); //testing darkCode set the file block size here .. static values
1593
1594
$p_filedescr_list = $p_filedescr_list_array['p_filedescr_list'];
1595
@@ -1653,7 +1653,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1653
@rewind($archive->zip_fd);
1654
1655
// ----- Creates a temporay file
1656
- $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
1657
1658
// ----- Open the temporary file in write mode
1659
if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb+')) == 0)
@@ -1674,7 +1674,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1674
1675
while ($actualFileSize != 0)
1676
{
1677
- $v_read_size = ($actualFileSize < PCLZIP_READ_BLOCK_SIZE ? $actualFileSize : PCLZIP_READ_BLOCK_SIZE);
1678
$v_buffer = fread($archive->zip_fd, $v_read_size);
1679
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
1680
$actualFileSize -= $v_read_size;
@@ -1737,8 +1737,8 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1737
if ( ($p_filedescr_list[$j]['type'] == 'file')
1738
|| ($p_filedescr_list[$j]['type'] == 'virtual_file')
1739
|| ( ($p_filedescr_list[$j]['type'] == 'folder')
1740
- && ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
1741
- || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
1742
) {
1743
$time = microtime(true);
1744
$finish_part = $time;
@@ -1795,7 +1795,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1795
$v_size = $v_central_dir['size'];
1796
/* while ($v_size != 0)
1797
{
1798
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
1799
$v_buffer = @fread($v_zip_temp_fd, $v_read_size);
1800
@fwrite($archive->zip_fd, $v_buffer, $v_read_size);
1801
$v_size -= $v_read_size;
@@ -2389,7 +2389,7 @@ function task_now($task_name){
2389
//$this->back_hack($task_name, 'Files ZIP PCL: Start');
2390
iwp_mmb_print_flush('Files ZIP PCL: Start');
2391
if (!isset($archive)) {
2392
- //define('PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
2393
//require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
2394
require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
2395
$archive = new IWPPclZip($backup_file);
@@ -2435,16 +2435,16 @@ function task_now($task_name){
2435
}
2436
2437
if($fail_safe_files && $disable_comp){
2438
- $result = $archive->add($include_data, PCLZIP_OPT_REMOVE_PATH, ABSPATH, PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
2439
}
2440
elseif(!$fail_safe_files && $disable_comp){
2441
- $result = $archive->add($include_data, PCLZIP_OPT_REMOVE_PATH, ABSPATH, PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, PCLZIP_OPT_NO_COMPRESSION);
2442
}
2443
elseif($fail_safe_files && !$disable_comp){
2444
- $result = $archive->add($include_data, PCLZIP_OPT_REMOVE_PATH, ABSPATH, PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
2445
}
2446
else{
2447
- $result = $archive->add($include_data, PCLZIP_OPT_REMOVE_PATH, ABSPATH, PCLZIP_OPT_IWP_EXCLUDE, $exclude_data);
2448
}
2449
2450
iwp_mmb_print_flush('Files ZIP PCL: End');
@@ -2461,21 +2461,21 @@ function task_now($task_name){
2461
function fail_safe_pcl_db($backup_file,$fail_safe_files,$disable_comp){
2462
//$this->back_hack($task_name, 'DB ZIP PCL: Start');
2463
iwp_mmb_print_flush('DB ZIP PCL: Start');
2464
- //define('PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
2465
require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
2466
$archive = new IWPPclZip($backup_file);
2467
2468
if($fail_safe_files && $disable_comp){
2469
- $result_db = $archive->add(IWP_DB_DIR, PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
2470
}
2471
elseif(!$fail_safe_files && $disable_comp){
2472
- $result_db = $archive->add(IWP_DB_DIR, PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, PCLZIP_OPT_NO_COMPRESSION);
2473
}
2474
elseif($fail_safe_files && !$disable_comp){
2475
- $result_db = $archive->add(IWP_DB_DIR, PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
2476
}
2477
else{
2478
- $result_db = $archive->add(IWP_DB_DIR, PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR);
2479
}
2480
//$this->back_hack($task_name, 'DB ZIP PCL: End');
2481
iwp_mmb_print_flush('DB ZIP PCL: End');
@@ -2864,47 +2864,47 @@ function iwp_mmb_direct_to_any_copy($source, $destination, $overwrite = false, $
2864
2865
// do process
2866
//$temp_dir = get_temp_dir();
2867
- $temp_dir = PCLZIP_TEMPORARY_DIR;
2868
2869
2870
2871
- if(file_exists(PCLZIP_TEMPORARY_DIR) && is_dir(PCLZIP_TEMPORARY_DIR))
2872
{
2873
//
2874
}
2875
else
2876
{
2877
- if(file_exists(dirname(PCLZIP_TEMPORARY_DIR)) && is_dir(dirname(PCLZIP_TEMPORARY_DIR))){
2878
- @mkdir(PCLZIP_TEMPORARY_DIR, 0755, true);
2879
}
2880
else{
2881
- @mkdir(dirname(PCLZIP_TEMPORARY_DIR), 0755, true);
2882
- @mkdir(PCLZIP_TEMPORARY_DIR, 0755, true);
2883
}
2884
2885
}
2886
- if(is_writable(PCLZIP_TEMPORARY_DIR))
2887
{
2888
- @file_put_contents(PCLZIP_TEMPORARY_DIR . '/index.php', ''); //safe
2889
}
2890
else
2891
{
2892
- $chmod = chmod(PCLZIP_TEMPORARY_DIR, 777);
2893
- if(is_writable(PCLZIP_TEMPORARY_DIR)){
2894
- @file_put_contents(PCLZIP_TEMPORARY_DIR . '/index.php', ''); //safe
2895
}
2896
2897
}
2898
2899
- if(is_writable(PCLZIP_TEMPORARY_DIR))
2900
{
2901
- $temp_dir = PCLZIP_TEMPORARY_DIR;
2902
}
2903
else{
2904
$temp_dir = get_temp_dir();
2905
if(!is_writable($temp_dir)){
2906
return array(
2907
- 'error' => 'Temporary directory is not writable. Please set 777 permission for '.PCLZIP_TEMPORARY_DIR.' and try again.', 'error_code' => 'pclzip_temp_dir_not_writable_please_set_777'
2908
);
2909
}
2910
}
@@ -3051,12 +3051,12 @@ function iwp_mmb_direct_to_any_copy($source, $destination, $overwrite = false, $
3051
iwp_mmb_print_flush('ZIP Extract CMD: End');
3052
3053
if (!$result) { //fallback to pclzip
3054
- ////define('PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
3055
//require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
3056
//require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
3057
iwp_mmb_print_flush('ZIP Extract PCL: Start');
3058
$archive = new IWPPclZip($single_backup_file);
3059
- $result = $archive->extract(PCLZIP_OPT_PATH, $new_temp_folder, PCLZIP_OPT_REPLACE_NEWER);
3060
iwp_mmb_print_flush('ZIP Extract PCL: End');
3061
}
3062
@@ -4584,8 +4584,8 @@ function ftp_backup($historyID,$args = '')
4584
$backup_settings_values['s3_retrace_count'][$historyID] = $s3_retrace_count;
4585
update_option('iwp_client_multi_backup_temp_values', $backup_settings_values);
4586
4587
- $partsArray = $s3->list_parts($as3_bucket, $as3_file, $upload_id);
4588
- $nextPart = (count($partsArray) + 1);
4589
}
4590
else
4591
{
24
define('IWP_DB_DIR', IWP_BACKUP_DIR . '/iwp_db');
25
}
26
27
+ if(!defined('IWP_PCLZIP_TEMPORARY_DIR')){
28
+ define('IWP_PCLZIP_TEMPORARY_DIR', WP_CONTENT_DIR . '/infinitewp/temp/');
29
}
30
31
226
227
//pclzip temp folder creation
228
229
+ if(file_exists(IWP_PCLZIP_TEMPORARY_DIR) && is_dir(IWP_PCLZIP_TEMPORARY_DIR))
230
{
231
$this->statusLog($historyID, array('stage' => 'verification', 'status' => 'processing', 'statusMsg' => 'Directorywritable'));
232
}
233
else
234
{
235
+ $mkdir = @mkdir(IWP_PCLZIP_TEMPORARY_DIR, 0755, true);
236
if(!$mkdir){
237
+ return $this->statusLog($historyID, array('stage' => 'verification', 'status' => 'error', 'statusMsg' => 'Error creating database backup folder (' . IWP_PCLZIP_TEMPORARY_DIR . '). Make sure you have corrrect write permissions.', 'statusCode' => 'error_creating_database_backup_folder'));
238
}
239
}
240
+ if(is_writable(IWP_PCLZIP_TEMPORARY_DIR))
241
{
242
+ @file_put_contents(IWP_PCLZIP_TEMPORARY_DIR . '/index.php', ''); //safe
243
}
244
else
245
{
246
+ $chmod = chmod(IWP_PCLZIP_TEMPORARY_DIR, 777);
247
+ if(!is_writable(IWP_PCLZIP_TEMPORARY_DIR)){
248
//$this->statusLog($historyID, "verification", false, "can't set 777");
249
+ return $this->statusLog($historyID, array('stage' => 'verification', 'status' => 'error', 'statusMsg' => IWP_PCLZIP_TEMPORARY_DIR.' directory is not writable. Please set 755 or 777 file permission and try again.', 'statusCode' => 'pclzip_dir_not_writable'));
250
}
251
}
252
514
//perform the zip operations here ..... for DB
515
iwp_mmb_print_flush('DB ZIP PCL: Start');
516
// fallback to pclzip
517
+ //define('IWP_PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
518
/* require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
519
$archive = new IWPPclZip($backup_file);
520
+ $result = $archive->add(IWP_DB_DIR, IWP_PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR); */
521
$result = $this -> backupFilesZIP($historyID);
522
iwp_mmb_print_flush('DB ZIP PCL: End');
523
/* @unlink($db_result);
1115
}
1116
1117
include_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
1118
+ //define('IWP_PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
1119
1120
//include_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.split.php';
1121
$returnArr = array();
1152
{
1153
if(empty($p_filedescr_list))
1154
{
1155
+ //define('IWP_PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
1156
+ $p_filedescr_list_array = $archive->getFileList(IWP_DB_DIR, IWP_PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE, $file_block_size, IWP_PCLZIP_OPT_HISTORY_ID, $historyID); //darkCode set the file block size here .. static values
1157
$p_filedescr_list = $p_filedescr_list_array['p_filedescr_list'];
1158
unset($p_filedescr_list_array['p_filedescr_list']);
1159
1186
{
1187
if(empty($p_filedescr_list))
1188
{
1189
+ $p_filedescr_list_array = $archive->getFileList($include_data, IWP_PCLZIP_OPT_REMOVE_PATH, ABSPATH, IWP_PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE, $file_block_size, IWP_PCLZIP_OPT_HISTORY_ID, $historyID); //testing darkCode set the file block size here .. static values
1190
1191
$p_filedescr_list = $p_filedescr_list_array['p_filedescr_list'];
1192
unset($p_filedescr_list_array['p_filedescr_list']);
1268
if ( ($p_filedescr_list[$j]['type'] == 'file')
1269
|| ($p_filedescr_list[$j]['type'] == 'virtual_file')
1270
|| ( ($p_filedescr_list[$j]['type'] == 'folder')
1271
+ && ( !isset($p_options[IWP_PCLZIP_OPT_REMOVE_ALL_PATH])
1272
+ || !$p_options[IWP_PCLZIP_OPT_REMOVE_ALL_PATH]))
1273
) {
1274
1275
$time = microtime(true);
1557
{
1558
if(empty($p_filedescr_list)||($nextCount == 0))
1559
{
1560
+ $p_filedescr_list_array = $archive->getFileList(IWP_DB_DIR, IWP_PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE, $file_block_size, IWP_PCLZIP_OPT_HISTORY_ID, $historyID);//darkCode set the file block size here .. static values
1561
$p_filedescr_list = $p_filedescr_list_array['p_filedescr_list'];
1562
1563
if($p_filedescr_list_array['status'] == 'partiallyCompleted')
1589
{
1590
if(empty($p_filedescr_list)||($nextCount == 0))
1591
{
1592
+ $p_filedescr_list_array = $archive->getFileList($include_data, IWP_PCLZIP_OPT_REMOVE_PATH, ABSPATH, IWP_PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE, $file_block_size, IWP_PCLZIP_OPT_HISTORY_ID, $historyID); //testing darkCode set the file block size here .. static values
1593
1594
$p_filedescr_list = $p_filedescr_list_array['p_filedescr_list'];
1595
1653
@rewind($archive->zip_fd);
1654
1655
// ----- Creates a temporay file
1656
+ $v_zip_temp_name = IWP_PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
1657
1658
// ----- Open the temporary file in write mode
1659
if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb+')) == 0)
1674
1675
while ($actualFileSize != 0)
1676
{
1677
+ $v_read_size = ($actualFileSize < IWP_PCLZIP_READ_BLOCK_SIZE ? $actualFileSize : IWP_PCLZIP_READ_BLOCK_SIZE);
1678
$v_buffer = fread($archive->zip_fd, $v_read_size);
1679
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
1680
$actualFileSize -= $v_read_size;
1737
if ( ($p_filedescr_list[$j]['type'] == 'file')
1738
|| ($p_filedescr_list[$j]['type'] == 'virtual_file')
1739
|| ( ($p_filedescr_list[$j]['type'] == 'folder')
1740
+ && ( !isset($p_options[IWP_PCLZIP_OPT_REMOVE_ALL_PATH])
1741
+ || !$p_options[IWP_PCLZIP_OPT_REMOVE_ALL_PATH]))
1742
) {
1743
$time = microtime(true);
1744
$finish_part = $time;
1795
$v_size = $v_central_dir['size'];
1796
/* while ($v_size != 0)
1797
{
1798
+ $v_read_size = ($v_size < IWP_PCLZIP_READ_BLOCK_SIZE ? $v_size : IWP_PCLZIP_READ_BLOCK_SIZE);
1799
$v_buffer = @fread($v_zip_temp_fd, $v_read_size);
1800
@fwrite($archive->zip_fd, $v_buffer, $v_read_size);
1801
$v_size -= $v_read_size;
2389
//$this->back_hack($task_name, 'Files ZIP PCL: Start');
2390
iwp_mmb_print_flush('Files ZIP PCL: Start');
2391
if (!isset($archive)) {
2392
+ //define('IWP_PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
2393
//require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
2394
require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
2395
$archive = new IWPPclZip($backup_file);
2435
}
2436
2437
if($fail_safe_files && $disable_comp){
2438
+ $result = $archive->add($include_data, IWP_PCLZIP_OPT_REMOVE_PATH, ABSPATH, IWP_PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, IWP_PCLZIP_OPT_NO_COMPRESSION, IWP_PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
2439
}
2440
elseif(!$fail_safe_files && $disable_comp){
2441
+ $result = $archive->add($include_data, IWP_PCLZIP_OPT_REMOVE_PATH, ABSPATH, IWP_PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, IWP_PCLZIP_OPT_NO_COMPRESSION);
2442
}
2443
elseif($fail_safe_files && !$disable_comp){
2444
+ $result = $archive->add($include_data, IWP_PCLZIP_OPT_REMOVE_PATH, ABSPATH, IWP_PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, IWP_PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
2445
}
2446
else{
2447
+ $result = $archive->add($include_data, IWP_PCLZIP_OPT_REMOVE_PATH, ABSPATH, IWP_PCLZIP_OPT_IWP_EXCLUDE, $exclude_data);
2448
}
2449
2450
iwp_mmb_print_flush('Files ZIP PCL: End');
2461
function fail_safe_pcl_db($backup_file,$fail_safe_files,$disable_comp){
2462
//$this->back_hack($task_name, 'DB ZIP PCL: Start');
2463
iwp_mmb_print_flush('DB ZIP PCL: Start');
2464
+ //define('IWP_PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
2465
require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
2466
$archive = new IWPPclZip($backup_file);
2467
2468
if($fail_safe_files && $disable_comp){
2469
+ $result_db = $archive->add(IWP_DB_DIR, IWP_PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, IWP_PCLZIP_OPT_NO_COMPRESSION, IWP_PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
2470
}
2471
elseif(!$fail_safe_files && $disable_comp){
2472
+ $result_db = $archive->add(IWP_DB_DIR, IWP_PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, IWP_PCLZIP_OPT_NO_COMPRESSION);
2473
}
2474
elseif($fail_safe_files && !$disable_comp){
2475
+ $result_db = $archive->add(IWP_DB_DIR, IWP_PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, IWP_PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
2476
}
2477
else{
2478
+ $result_db = $archive->add(IWP_DB_DIR, IWP_PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR);
2479
}
2480
//$this->back_hack($task_name, 'DB ZIP PCL: End');
2481
iwp_mmb_print_flush('DB ZIP PCL: End');
2864
2865
// do process
2866
//$temp_dir = get_temp_dir();
2867
+ $temp_dir = IWP_PCLZIP_TEMPORARY_DIR;
2868
2869
2870
2871
+ if(file_exists(IWP_PCLZIP_TEMPORARY_DIR) && is_dir(IWP_PCLZIP_TEMPORARY_DIR))
2872
{
2873
//
2874
}
2875
else
2876
{
2877
+ if(file_exists(dirname(IWP_PCLZIP_TEMPORARY_DIR)) && is_dir(dirname(IWP_PCLZIP_TEMPORARY_DIR))){
2878
+ @mkdir(IWP_PCLZIP_TEMPORARY_DIR, 0755, true);
2879
}
2880
else{
2881
+ @mkdir(dirname(IWP_PCLZIP_TEMPORARY_DIR), 0755, true);
2882
+ @mkdir(IWP_PCLZIP_TEMPORARY_DIR, 0755, true);
2883
}
2884
2885
}
2886
+ if(is_writable(IWP_PCLZIP_TEMPORARY_DIR))
2887
{
2888
+ @file_put_contents(IWP_PCLZIP_TEMPORARY_DIR . '/index.php', ''); //safe
2889
}
2890
else
2891
{
2892
+ $chmod = chmod(IWP_PCLZIP_TEMPORARY_DIR, 777);
2893
+ if(is_writable(IWP_PCLZIP_TEMPORARY_DIR)){
2894
+ @file_put_contents(IWP_PCLZIP_TEMPORARY_DIR . '/index.php', ''); //safe
2895
}
2896
2897
}
2898
2899
+ if(is_writable(IWP_PCLZIP_TEMPORARY_DIR))
2900
{
2901
+ $temp_dir = IWP_PCLZIP_TEMPORARY_DIR;
2902
}
2903
else{
2904
$temp_dir = get_temp_dir();
2905
if(!is_writable($temp_dir)){
2906
return array(
2907
+ 'error' => 'Temporary directory is not writable. Please set 777 permission for '.IWP_PCLZIP_TEMPORARY_DIR.' and try again.', 'error_code' => 'pclzip_temp_dir_not_writable_please_set_777'
2908
);
2909
}
2910
}
3051
iwp_mmb_print_flush('ZIP Extract CMD: End');
3052
3053
if (!$result) { //fallback to pclzip
3054
+ ////define('IWP_PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
3055
//require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
3056
//require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
3057
iwp_mmb_print_flush('ZIP Extract PCL: Start');
3058
$archive = new IWPPclZip($single_backup_file);
3059
+ $result = $archive->extract(IWP_PCLZIP_OPT_PATH, $new_temp_folder, IWP_PCLZIP_OPT_REPLACE_NEWER);
3060
iwp_mmb_print_flush('ZIP Extract PCL: End');
3061
}
3062
4584
$backup_settings_values['s3_retrace_count'][$historyID] = $s3_retrace_count;
4585
update_option('iwp_client_multi_backup_temp_values', $backup_settings_values);
4586
4587
+ //$partsArray = $s3->list_parts($as3_bucket, $as3_file, $upload_id);//commenting this line because of fatal error $s3 object is not created, looks like these lines not required here
4588
+ //$nextPart = (count($partsArray) + 1);//commenting this line because of fatal error $s3 object is not created, looks like these lines not required here
4589
}
4590
else
4591
{
backup.class.singlecall.php CHANGED
@@ -25,8 +25,8 @@ if(!defined('IWP_DB_DIR')){
25
define('IWP_DB_DIR', IWP_BACKUP_DIR . '/iwp_db');
26
}
27
28
- if(!defined('PCLZIP_TEMPORARY_DIR')){
29
- define('PCLZIP_TEMPORARY_DIR', WP_CONTENT_DIR . '/infinitewp/temp/');
30
}
31
32
$zip_errors = array(
@@ -230,22 +230,22 @@ function delete_task_now($task_name){
230
231
//pclzip temp folder creation
232
233
- if(!(file_exists(PCLZIP_TEMPORARY_DIR) && is_dir(PCLZIP_TEMPORARY_DIR)))
234
{
235
- $mkdir = @mkdir(PCLZIP_TEMPORARY_DIR, 0755, true);
236
if(!$mkdir){
237
- return array('error' => 'Error creating database backup folder (' . PCLZIP_TEMPORARY_DIR . '). Make sure you have corrrect write permissions.');
238
}
239
}
240
- if(is_writable(PCLZIP_TEMPORARY_DIR))
241
{
242
- @file_put_contents(PCLZIP_TEMPORARY_DIR . '/index.php', ''); //safe
243
}
244
else
245
{
246
- $chmod = chmod(PCLZIP_TEMPORARY_DIR, 777);
247
- if(!is_writable(PCLZIP_TEMPORARY_DIR)){
248
- return array('error' => PCLZIP_TEMPORARY_DIR.' directory is not writable. Please set 755 or 777 file permission and try again.');
249
}
250
}
251
@@ -728,7 +728,7 @@ function delete_task_now($task_name){
728
//$this->back_hack($task_name, 'Files ZIP PCL: Start');
729
iwp_mmb_print_flush('Files ZIP PCL: Start');
730
if (!isset($archive)) {
731
- //define('PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
732
//require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
733
require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
734
$archive = new IWPPclZip($backup_file);
@@ -774,16 +774,16 @@ function delete_task_now($task_name){
774
}
775
776
if($fail_safe_files && $disable_comp){
777
- $result = $archive->add($include_data, PCLZIP_OPT_REMOVE_PATH, ABSPATH, PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
778
}
779
elseif(!$fail_safe_files && $disable_comp){
780
- $result = $archive->add($include_data, PCLZIP_OPT_REMOVE_PATH, ABSPATH, PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, PCLZIP_OPT_NO_COMPRESSION);
781
}
782
elseif($fail_safe_files && !$disable_comp){
783
- $result = $archive->add($include_data, PCLZIP_OPT_REMOVE_PATH, ABSPATH, PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
784
}
785
else{
786
- $result = $archive->add($include_data, PCLZIP_OPT_REMOVE_PATH, ABSPATH, PCLZIP_OPT_IWP_EXCLUDE, $exclude_data);
787
}
788
789
iwp_mmb_print_flush('Files ZIP PCL: End');
@@ -800,21 +800,21 @@ function delete_task_now($task_name){
800
function fail_safe_pcl_db($backup_file,$fail_safe_files,$disable_comp){
801
//$this->back_hack($task_name, 'DB ZIP PCL: Start');
802
iwp_mmb_print_flush('DB ZIP PCL: Start');
803
- //define('PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
804
require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
805
$archive = new IWPPclZip($backup_file);
806
807
if($fail_safe_files && $disable_comp){
808
- $result_db = $archive->add(IWP_DB_DIR, PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
809
}
810
elseif(!$fail_safe_files && $disable_comp){
811
- $result_db = $archive->add(IWP_DB_DIR, PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, PCLZIP_OPT_NO_COMPRESSION);
812
}
813
elseif($fail_safe_files && !$disable_comp){
814
- $result_db = $archive->add(IWP_DB_DIR, PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
815
}
816
else{
817
- $result_db = $archive->add(IWP_DB_DIR, PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR);
818
}
819
//$this->back_hack($task_name, 'DB ZIP PCL: End');
820
iwp_mmb_print_flush('DB ZIP PCL: End');
@@ -1472,13 +1472,13 @@ function iwp_mmb_direct_to_any_copy($source, $destination, $overwrite = false, $
1472
iwp_mmb_print_flush('ZIP Extract CMD: End');
1473
1474
if (!$result) { //fallback to pclzip
1475
- define('PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
1476
//require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
1477
require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
1478
iwp_mmb_print_flush('ZIP Extract PCL: Start');
1479
$archive = new IWPPclZip($backup_file);
1480
- $result = $archive->extract(PCLZIP_OPT_PATH, $new_temp_folder, PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1); //actual
1481
- //$result = $archive->extract(PCLZIP_OPT_PATH, $new_temp_folder, PCLZIP_OPT_REMOVE_PATH, $GLOBALS['iwp_mmb_plugin_dir'], PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
1482
iwp_mmb_print_flush('ZIP Extract PCL: End');
1483
}
1484
$this->wpdb_reconnect();
25
define('IWP_DB_DIR', IWP_BACKUP_DIR . '/iwp_db');
26
}
27
28
+ if(!defined('IWP_PCLZIP_TEMPORARY_DIR')){
29
+ define('IWP_PCLZIP_TEMPORARY_DIR', WP_CONTENT_DIR . '/infinitewp/temp/');
30
}
31
32
$zip_errors = array(
230
231
//pclzip temp folder creation
232
233
+ if(!(file_exists(IWP_PCLZIP_TEMPORARY_DIR) && is_dir(IWP_PCLZIP_TEMPORARY_DIR)))
234
{
235
+ $mkdir = @mkdir(IWP_PCLZIP_TEMPORARY_DIR, 0755, true);
236
if(!$mkdir){
237
+ return array('error' => 'Error creating database backup folder (' . IWP_PCLZIP_TEMPORARY_DIR . '). Make sure you have corrrect write permissions.');
238
}
239
}
240
+ if(is_writable(IWP_PCLZIP_TEMPORARY_DIR))
241
{
242
+ @file_put_contents(IWP_PCLZIP_TEMPORARY_DIR . '/index.php', ''); //safe
243
}
244
else
245
{
246
+ $chmod = chmod(IWP_PCLZIP_TEMPORARY_DIR, 777);
247
+ if(!is_writable(IWP_PCLZIP_TEMPORARY_DIR)){
248
+ return array('error' => IWP_PCLZIP_TEMPORARY_DIR.' directory is not writable. Please set 755 or 777 file permission and try again.');
249
}
250
}
251
728
//$this->back_hack($task_name, 'Files ZIP PCL: Start');
729
iwp_mmb_print_flush('Files ZIP PCL: Start');
730
if (!isset($archive)) {
731
+ //define('IWP_PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
732
//require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
733
require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
734
$archive = new IWPPclZip($backup_file);
774
}
775
776
if($fail_safe_files && $disable_comp){
777
+ $result = $archive->add($include_data, IWP_PCLZIP_OPT_REMOVE_PATH, ABSPATH, IWP_PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, IWP_PCLZIP_OPT_NO_COMPRESSION, IWP_PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
778
}
779
elseif(!$fail_safe_files && $disable_comp){
780
+ $result = $archive->add($include_data, IWP_PCLZIP_OPT_REMOVE_PATH, ABSPATH, IWP_PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, IWP_PCLZIP_OPT_NO_COMPRESSION);
781
}
782
elseif($fail_safe_files && !$disable_comp){
783
+ $result = $archive->add($include_data, IWP_PCLZIP_OPT_REMOVE_PATH, ABSPATH, IWP_PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, IWP_PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
784
}
785
else{
786
+ $result = $archive->add($include_data, IWP_PCLZIP_OPT_REMOVE_PATH, ABSPATH, IWP_PCLZIP_OPT_IWP_EXCLUDE, $exclude_data);
787
}
788
789
iwp_mmb_print_flush('Files ZIP PCL: End');
800
function fail_safe_pcl_db($backup_file,$fail_safe_files,$disable_comp){
801
//$this->back_hack($task_name, 'DB ZIP PCL: Start');
802
iwp_mmb_print_flush('DB ZIP PCL: Start');
803
+ //define('IWP_PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
804
require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
805
$archive = new IWPPclZip($backup_file);
806
807
if($fail_safe_files && $disable_comp){
808
+ $result_db = $archive->add(IWP_DB_DIR, IWP_PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, IWP_PCLZIP_OPT_NO_COMPRESSION, IWP_PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
809
}
810
elseif(!$fail_safe_files && $disable_comp){
811
+ $result_db = $archive->add(IWP_DB_DIR, IWP_PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, IWP_PCLZIP_OPT_NO_COMPRESSION);
812
}
813
elseif($fail_safe_files && !$disable_comp){
814
+ $result_db = $archive->add(IWP_DB_DIR, IWP_PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, IWP_PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
815
}
816
else{
817
+ $result_db = $archive->add(IWP_DB_DIR, IWP_PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR);
818
}
819
//$this->back_hack($task_name, 'DB ZIP PCL: End');
820
iwp_mmb_print_flush('DB ZIP PCL: End');
1472
iwp_mmb_print_flush('ZIP Extract CMD: End');
1473
1474
if (!$result) { //fallback to pclzip
1475
+ define('IWP_PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
1476
//require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
1477
require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
1478
iwp_mmb_print_flush('ZIP Extract PCL: Start');
1479
$archive = new IWPPclZip($backup_file);
1480
+ $result = $archive->extract(IWP_PCLZIP_OPT_PATH, $new_temp_folder, IWP_PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1); //actual
1481
+ //$result = $archive->extract(IWP_PCLZIP_OPT_PATH, $new_temp_folder, IWP_PCLZIP_OPT_REMOVE_PATH, $GLOBALS['iwp_mmb_plugin_dir'], IWP_PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
1482
iwp_mmb_print_flush('ZIP Extract PCL: End');
1483
}
1484
$this->wpdb_reconnect();
init.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: InfiniteWP - Client
4
Plugin URI: http://infinitewp.com/
5
Description: This is the client plugin of InfiniteWP that communicates with the InfiniteWP Admin panel.
6
Author: Revmakx
7
- Version: 1.3.5
8
Author URI: http://www.revmakx.com
9
*/
10
/************************************************************
@@ -26,7 +26,7 @@ Author URI: http://www.revmakx.com
26
**************************************************************/
27
28
if(!defined('IWP_MMB_CLIENT_VERSION'))
29
- define('IWP_MMB_CLIENT_VERSION', '1.3.5');
30
31
32
4
Plugin URI: http://infinitewp.com/
5
Description: This is the client plugin of InfiniteWP that communicates with the InfiniteWP Admin panel.
6
Author: Revmakx
7
+ Version: 1.3.6
8
Author URI: http://www.revmakx.com
9
*/
10
/************************************************************
26
**************************************************************/
27
28
if(!defined('IWP_MMB_CLIENT_VERSION'))
29
+ define('IWP_MMB_CLIENT_VERSION', '1.3.6');
30
31
32
pclzip.class.php CHANGED
@@ -26,8 +26,8 @@
26
// --------------------------------------------------------------------------------
27
28
// ----- Constants
29
- if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
30
- define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
31
}
32
33
// ----- File list separator
@@ -38,10 +38,10 @@
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
@@ -49,8 +49,8 @@
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
@@ -60,10 +60,10 @@
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
@@ -73,9 +73,9 @@
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
// --------------------------------------------------------------------------------
@@ -100,83 +100,83 @@
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
149
- define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 );
150
- define( 'PCLZIP_OPT_CHUNK_BLOCK_SIZE', 78999 ); //darkCode
151
- define( 'PCLZIP_OPT_HISTORY_ID', 79999 ); //darkCode
152
- define( 'PCLZIP_OPT_FILE_EXCLUDE_SIZE', 79997 ); //darkCode
153
- define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 );
154
- define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias
155
- define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 );
156
- define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias
157
- define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 );
158
- define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias
159
- define( 'PCLZIP_OPT_IWP_EXCLUDE', 77999 );//IWP Mod
160
161
162
// ----- File description attributes
163
- define( 'PCLZIP_ATT_FILE_NAME', 79001 );
164
- define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 );
165
- define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 );
166
- define( 'PCLZIP_ATT_FILE_MTIME', 79004 );
167
- define( 'PCLZIP_ATT_FILE_CONTENT', 79005 );
168
- define( 'PCLZIP_ATT_FILE_COMMENT', 79006 );
169
170
// ----- Call backs values
171
- define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );
172
- define( 'PCLZIP_CB_POST_EXTRACT', 78002 );
173
- define( 'PCLZIP_CB_PRE_ADD', 78003 );
174
- define( 'PCLZIP_CB_POST_ADD', 78004 );
175
/* For futur use
176
- define( 'PCLZIP_CB_PRE_LIST', 78005 );
177
- define( 'PCLZIP_CB_POST_LIST', 78006 );
178
- define( 'PCLZIP_CB_PRE_DELETE', 78007 );
179
- define( 'PCLZIP_CB_POST_DELETE', 78008 );
180
*/
181
182
// --------------------------------------------------------------------------------
@@ -211,14 +211,14 @@
211
var $magic_quotes_status;
212
213
// --------------------------------------------------------------------------------
214
- // Function : IWPPclZip()
215
// Description :
216
// Creates a IWPPclZip object and set the name of the associated Zip archive
217
// filename.
218
// Note that no real action is taken, if the archive does not exist it is not
219
// created. Use create() for that.
220
// --------------------------------------------------------------------------------
221
- function IWPPclZip($p_zipname)
222
{
223
224
// ----- Tests the zlib
@@ -263,12 +263,12 @@
263
// When $p_add_dir and $p_remove_dir are set, $p_remove_dir
264
// is removed first, before $p_add_dir is added.
265
// Options :
266
- // PCLZIP_OPT_ADD_PATH :
267
- // PCLZIP_OPT_REMOVE_PATH :
268
- // PCLZIP_OPT_REMOVE_ALL_PATH :
269
- // PCLZIP_OPT_COMMENT :
270
- // PCLZIP_CB_PRE_ADD :
271
- // PCLZIP_CB_POST_ADD :
272
// Return Values :
273
// 0 on failure,
274
// The list of the added files, with a status of the add action.
@@ -283,11 +283,11 @@
283
284
// ----- Set default values
285
$v_options = array();
286
- $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
287
- $v_options[PCLZIP_OPT_CHUNK_BLOCK_SIZE] = 15*1024*1024*1024;
288
- $v_options[PCLZIP_OPT_FILE_EXCLUDE_SIZE] = 15*1024*1024*1024;
289
- $v_options[PCLZIP_OPT_IWP_EXCLUDE] = array();
290
- $v_options[PCLZIP_OPT_HISTORY_ID] = 0;
291
292
// ----- Look for variable options arguments
293
$v_size = func_num_args();
@@ -306,21 +306,21 @@
306
307
// ----- Parse the options
308
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
309
- array (PCLZIP_OPT_REMOVE_PATH => 'optional',
310
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
311
- PCLZIP_OPT_ADD_PATH => 'optional',
312
- PCLZIP_CB_PRE_ADD => 'optional',
313
- PCLZIP_CB_POST_ADD => 'optional',
314
- PCLZIP_OPT_NO_COMPRESSION => 'optional',
315
- PCLZIP_OPT_COMMENT => 'optional',
316
- PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
317
- PCLZIP_OPT_TEMP_FILE_ON => 'optional',
318
- PCLZIP_OPT_TEMP_FILE_OFF => 'optional',
319
- PCLZIP_OPT_CHUNK_BLOCK_SIZE => 'optional',
320
- PCLZIP_OPT_FILE_EXCLUDE_SIZE => 'optional',
321
- PCLZIP_OPT_HISTORY_ID => 'optional',
322
- PCLZIP_OPT_IWP_EXCLUDE => 'optional',
323
- //, PCLZIP_OPT_CRYPT => 'optional'
324
));
325
if ($v_result != 1) {
326
return 0;
@@ -333,14 +333,14 @@
333
else {
334
335
// ----- Get the first argument
336
- $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
337
338
// ----- Look for the optional second argument
339
if ($v_size == 2) {
340
- $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
341
}
342
else if ($v_size > 2) {
343
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
344
"Invalid number / type of arguments");
345
return 0;
346
}
@@ -374,12 +374,12 @@
374
// ----- Look if the $p_filelist is a string
375
else if (is_string($p_filelist)) {
376
// ----- Create a list from the string
377
- $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
378
}
379
380
// ----- Invalid variable type for $p_filelist
381
else {
382
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
383
return 0;
384
}
385
@@ -387,7 +387,7 @@
387
if (sizeof($v_string_list) != 0) {
388
foreach ($v_string_list as $v_string) {
389
if ($v_string != '') {
390
- $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
391
}
392
else {
393
}
@@ -396,12 +396,12 @@
396
397
// ----- For each file in the list check the attributes
398
$v_supported_attributes
399
- = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
400
- ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
401
- ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
402
- ,PCLZIP_ATT_FILE_MTIME => 'optional'
403
- ,PCLZIP_ATT_FILE_CONTENT => 'optional'
404
- ,PCLZIP_ATT_FILE_COMMENT => 'optional'
405
);
406
foreach ($v_att_list as $v_entry) {
407
$v_result = $this->privFileDescrParseAtt($v_entry,
@@ -440,8 +440,8 @@
440
441
// ----- Set default values
442
$v_options = array();
443
- $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
444
- $v_options[PCLZIP_OPT_FILE_EXCLUDE_SIZE] = 15*1024*1024*1024;
445
446
// ----- Look for variable options arguments
447
$v_size = func_num_args();
@@ -460,23 +460,23 @@
460
461
// ----- Parse the options
462
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
463
- array (PCLZIP_OPT_REMOVE_PATH => 'optional',
464
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
465
- PCLZIP_OPT_ADD_PATH => 'optional',
466
- PCLZIP_CB_PRE_ADD => 'optional',
467
- PCLZIP_CB_POST_ADD => 'optional',
468
- PCLZIP_OPT_NO_COMPRESSION => 'optional',
469
- PCLZIP_OPT_COMMENT => 'optional',
470
- PCLZIP_OPT_ADD_COMMENT => 'optional',
471
- PCLZIP_OPT_PREPEND_COMMENT => 'optional',
472
- PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
473
- PCLZIP_OPT_TEMP_FILE_ON => 'optional',
474
- PCLZIP_OPT_TEMP_FILE_OFF => 'optional',
475
- PCLZIP_OPT_CHUNK_BLOCK_SIZE => 'optional',
476
- PCLZIP_OPT_FILE_EXCLUDE_SIZE => 'optional',
477
- PCLZIP_OPT_HISTORY_ID => 'optional',
478
- PCLZIP_OPT_IWP_EXCLUDE => 'optional',
479
- //, PCLZIP_OPT_CRYPT => 'optional'
480
));
481
if ($v_result != 1) {
482
return 0;
@@ -488,15 +488,15 @@
488
else {
489
490
// ----- Get the first argument
491
- $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
492
493
// ----- Look for the optional second argument
494
if ($v_size == 2) {
495
- $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
496
}
497
else if ($v_size > 2) {
498
// ----- Error log
499
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
500
501
// ----- Return
502
return 0;
@@ -531,30 +531,30 @@
531
// ----- Look if the $p_filelist is a string
532
else if (is_string($p_filelist)) {
533
// ----- Create a list from the string
534
- $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
535
}
536
537
// ----- Invalid variable type for $p_filelist
538
else {
539
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
540
return 0;
541
}
542
543
// ----- Reformat the string list
544
if (sizeof($v_string_list) != 0) {
545
foreach ($v_string_list as $v_string) {
546
- $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
547
}
548
}
549
550
// ----- For each file in the list check the attributes
551
$v_supported_attributes
552
- = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
553
- ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
554
- ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
555
- ,PCLZIP_ATT_FILE_MTIME => 'optional'
556
- ,PCLZIP_ATT_FILE_CONTENT => 'optional'
557
- ,PCLZIP_ATT_FILE_COMMENT => 'optional'
558
);
559
foreach ($v_att_list as $v_entry) {
560
$v_result = $this->privFileDescrParseAtt($v_entry,
@@ -571,7 +571,7 @@
571
$prevFileList = array();
572
$next_file_index = 0;
573
$complete_folder_list = array();
574
- $historyID = $v_options[PCLZIP_OPT_HISTORY_ID];
575
if($historyID)
576
{
577
$backupObj = new IWP_MMB_Backup_Multicall();
@@ -773,14 +773,14 @@
773
// When $p_add_dir and $p_remove_dir are set, $p_remove_dir
774
// is removed first, before $p_add_dir is added.
775
// Options :
776
- // PCLZIP_OPT_ADD_PATH :
777
- // PCLZIP_OPT_REMOVE_PATH :
778
- // PCLZIP_OPT_REMOVE_ALL_PATH :
779
- // PCLZIP_OPT_COMMENT :
780
- // PCLZIP_OPT_ADD_COMMENT :
781
- // PCLZIP_OPT_PREPEND_COMMENT :
782
- // PCLZIP_CB_PRE_ADD :
783
- // PCLZIP_CB_POST_ADD :
784
// Return Values :
785
// 0 on failure,
786
// The list of the added files, with a status of the add action.
@@ -795,11 +795,11 @@
795
796
// ----- Set default values
797
$v_options = array();
798
- $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
799
- $v_options[PCLZIP_OPT_CHUNK_BLOCK_SIZE] = 15*1024*1024*1024;
800
- $v_options[PCLZIP_OPT_FILE_EXCLUDE_SIZE] = 15*1024*1024*1024;
801
- $v_options[PCLZIP_OPT_IWP_EXCLUDE] = array();
802
- $v_options[PCLZIP_OPT_HISTORY_ID] = 0;
803
804
// ----- Look for variable options arguments
805
$v_size = func_num_args();
@@ -818,23 +818,23 @@
818
819
// ----- Parse the options
820
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
821
- array (PCLZIP_OPT_REMOVE_PATH => 'optional',
822
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
823
- PCLZIP_OPT_ADD_PATH => 'optional',
824
- PCLZIP_CB_PRE_ADD => 'optional',
825
- PCLZIP_CB_POST_ADD => 'optional',
826
- PCLZIP_OPT_NO_COMPRESSION => 'optional',
827
- PCLZIP_OPT_COMMENT => 'optional',
828
- PCLZIP_OPT_ADD_COMMENT => 'optional',
829
- PCLZIP_OPT_PREPEND_COMMENT => 'optional',
830
- PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
831
- PCLZIP_OPT_TEMP_FILE_ON => 'optional',
832
- PCLZIP_OPT_CHUNK_BLOCK_SIZE => 'optional',
833
- PCLZIP_OPT_FILE_EXCLUDE_SIZE => 'optional',
834
- PCLZIP_OPT_HISTORY_ID => 'optional',
835
- PCLZIP_OPT_TEMP_FILE_OFF => 'optional',
836
- PCLZIP_OPT_IWP_EXCLUDE => 'optional',
837
- //, PCLZIP_OPT_CRYPT => 'optional'
838
));
839
if ($v_result != 1) {
840
return 0;
@@ -847,15 +847,15 @@
847
else {
848
849
// ----- Get the first argument
850
- $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
851
852
// ----- Look for the optional second argument
853
if ($v_size == 2) {
854
- $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
855
}
856
else if ($v_size > 2) {
857
// ----- Error log
858
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
859
860
// ----- Return
861
return 0;
@@ -890,30 +890,30 @@
890
// ----- Look if the $p_filelist is a string
891
else if (is_string($p_filelist)) {
892
// ----- Create a list from the string
893
- $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
894
}
895
896
// ----- Invalid variable type for $p_filelist
897
else {
898
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
899
return 0;
900
}
901
902
// ----- Reformat the string list
903
if (sizeof($v_string_list) != 0) {
904
foreach ($v_string_list as $v_string) {
905
- $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
906
}
907
}
908
909
// ----- For each file in the list check the attributes
910
$v_supported_attributes
911
- = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
912
- ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
913
- ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
914
- ,PCLZIP_ATT_FILE_MTIME => 'optional'
915
- ,PCLZIP_ATT_FILE_CONTENT => 'optional'
916
- ,PCLZIP_ATT_FILE_COMMENT => 'optional'
917
);
918
foreach ($v_att_list as $v_entry) {
919
$v_result = $this->privFileDescrParseAtt($v_entry,
@@ -1020,20 +1020,20 @@
1020
// By default, if a newer file with the same name already exists, the
1021
// file is not extracted.
1022
//
1023
- // If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
1024
- // are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
1025
- // at the end of the path value of PCLZIP_OPT_PATH.
1026
// Parameters :
1027
// $p_path : Path where the files and directories are to be extracted
1028
// $p_remove_path : First part ('root' part) of the memorized path
1029
// (if any similar) to remove while extracting.
1030
// Options :
1031
- // PCLZIP_OPT_PATH :
1032
- // PCLZIP_OPT_ADD_PATH :
1033
- // PCLZIP_OPT_REMOVE_PATH :
1034
- // PCLZIP_OPT_REMOVE_ALL_PATH :
1035
- // PCLZIP_CB_PRE_EXTRACT :
1036
- // PCLZIP_CB_POST_EXTRACT :
1037
// Return Values :
1038
// 0 or a negative value on failure,
1039
// The list of the extracted files, with a status of the action.
@@ -1062,9 +1062,9 @@
1062
$v_size = func_num_args();
1063
1064
// ----- Default values for option
1065
- $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
1066
- $v_options[PCLZIP_OPT_CHUNK_BLOCK_SIZE] = 15*1024*1024*1024;
1067
- $v_options[PCLZIP_OPT_FILE_EXCLUDE_SIZE] = 15*1024*1024*1024;
1068
1069
// ----- Look for arguments
1070
if ($v_size > 0) {
@@ -1076,49 +1076,49 @@
1076
1077
// ----- Parse the options
1078
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
1079
- array (PCLZIP_OPT_PATH => 'optional',
1080
- PCLZIP_OPT_REMOVE_PATH => 'optional',
1081
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
1082
- PCLZIP_OPT_ADD_PATH => 'optional',
1083
- PCLZIP_CB_PRE_EXTRACT => 'optional',
1084
- PCLZIP_CB_POST_EXTRACT => 'optional',
1085
- PCLZIP_OPT_SET_CHMOD => 'optional',
1086
- PCLZIP_OPT_BY_NAME => 'optional',
1087
- PCLZIP_OPT_BY_EREG => 'optional',
1088
- PCLZIP_OPT_BY_PREG => 'optional',
1089
- PCLZIP_OPT_BY_INDEX => 'optional',
1090
- PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
1091
- PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional',
1092
- PCLZIP_OPT_REPLACE_NEWER => 'optional',
1093
- PCLZIP_OPT_STOP_ON_ERROR => 'optional',
1094
- PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
1095
- PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
1096
- PCLZIP_OPT_CHUNK_BLOCK_SIZE => 'optional',
1097
- PCLZIP_OPT_FILE_EXCLUDE_SIZE => 'optional',
1098
- PCLZIP_OPT_HISTORY_ID => 'optional',
1099
- PCLZIP_OPT_TEMP_FILE_ON => 'optional',
1100
- PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
1101
));
1102
if ($v_result != 1) {
1103
return 0;
1104
}
1105
1106
// ----- Set the arguments
1107
- if (isset($v_options[PCLZIP_OPT_PATH])) {
1108
- $v_path = $v_options[PCLZIP_OPT_PATH];
1109
}
1110
- if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
1111
- $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
1112
}
1113
- if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
1114
- $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
1115
}
1116
- if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
1117
// ----- Check for '/' in last path char
1118
if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
1119
$v_path .= '/';
1120
}
1121
- $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
1122
}
1123
}
1124
@@ -1136,7 +1136,7 @@
1136
}
1137
else if ($v_size > 2) {
1138
// ----- Error log
1139
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
1140
1141
// ----- Return
1142
return 0;
@@ -1184,17 +1184,17 @@
1184
// $p_remove_path : First part ('root' part) of the memorized path
1185
// (if any similar) to remove while extracting.
1186
// Options :
1187
- // PCLZIP_OPT_PATH :
1188
- // PCLZIP_OPT_ADD_PATH :
1189
- // PCLZIP_OPT_REMOVE_PATH :
1190
- // PCLZIP_OPT_REMOVE_ALL_PATH :
1191
- // PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and
1192
// not as files.
1193
// The resulting content is in a new field 'content' in the file
1194
// structure.
1195
// This option must be used alone (any other options are ignored).
1196
- // PCLZIP_CB_PRE_EXTRACT :
1197
- // PCLZIP_CB_POST_EXTRACT :
1198
// Return Values :
1199
// 0 on failure,
1200
// The list of the extracted files, with a status of the action.
@@ -1224,9 +1224,9 @@
1224
$v_size = func_num_args();
1225
1226
// ----- Default values for option
1227
- $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
1228
- $v_options[PCLZIP_OPT_CHUNK_BLOCK_SIZE] = 15*1024*1024*1024;
1229
- $v_options[PCLZIP_OPT_FILE_EXCLUDE_SIZE] = 15*1024*1024*1024;
1230
1231
// ----- Look for arguments
1232
if ($v_size > 1) {
@@ -1242,47 +1242,47 @@
1242
1243
// ----- Parse the options
1244
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
1245
- array (PCLZIP_OPT_PATH => 'optional',
1246
- PCLZIP_OPT_REMOVE_PATH => 'optional',
1247
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
1248
- PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
1249
- PCLZIP_OPT_ADD_PATH => 'optional',
1250
- PCLZIP_CB_PRE_EXTRACT => 'optional',
1251
- PCLZIP_CB_POST_EXTRACT => 'optional',
1252
- PCLZIP_OPT_SET_CHMOD => 'optional',
1253
- PCLZIP_OPT_REPLACE_NEWER => 'optional',
1254
- PCLZIP_OPT_STOP_ON_ERROR => 'optional',
1255
- PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
1256
- PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
1257
- PCLZIP_OPT_CHUNK_BLOCK_SIZE => 'optional',
1258
- PCLZIP_OPT_FILE_EXCLUDE_SIZE => 'optional',
1259
- PCLZIP_OPT_HISTORY_ID => 'optional',
1260
- PCLZIP_OPT_TEMP_FILE_ON => 'optional',
1261
- PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
1262
));
1263
if ($v_result != 1) {
1264
return 0;
1265
}
1266
1267
// ----- Set the arguments
1268
- if (isset($v_options[PCLZIP_OPT_PATH])) {
1269
- $v_path = $v_options[PCLZIP_OPT_PATH];
1270
}
1271
- if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
1272
- $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
1273
}
1274
- if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
1275
- $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
1276
}
1277
- if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
1278
// ----- Check for '/' in last path char
1279
if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
1280
$v_path .= '/';
1281
}
1282
- $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
1283
}
1284
- if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
1285
- $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
1286
}
1287
else {
1288
}
@@ -1302,7 +1302,7 @@
1302
}
1303
else if ($v_size > 2) {
1304
// ----- Error log
1305
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
1306
1307
// ----- Return
1308
return 0;
@@ -1315,14 +1315,14 @@
1315
// ----- Trick
1316
// Here I want to reuse extractByRule(), so I need to parse the $p_index
1317
// with privParseOptions()
1318
- $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
1319
$v_options_trick = array();
1320
$v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
1321
- array (PCLZIP_OPT_BY_INDEX => 'optional' ));
1322
if ($v_result != 1) {
1323
return 0;
1324
}
1325
- $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
1326
1327
// ----- Look for default option values
1328
$this->privOptionDefaultThreshold($v_options);
@@ -1346,10 +1346,10 @@
1346
// Parameters :
1347
// None or optional arguments.
1348
// Options :
1349
- // PCLZIP_OPT_BY_INDEX :
1350
- // PCLZIP_OPT_BY_NAME :
1351
- // PCLZIP_OPT_BY_EREG :
1352
- // PCLZIP_OPT_BY_PREG :
1353
// Return Values :
1354
// 0 on failure,
1355
// The list of the files which are still present in the archive.
@@ -1380,10 +1380,10 @@
1380
1381
// ----- Parse the options
1382
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
1383
- array (PCLZIP_OPT_BY_NAME => 'optional',
1384
- PCLZIP_OPT_BY_EREG => 'optional',
1385
- PCLZIP_OPT_BY_PREG => 'optional',
1386
- PCLZIP_OPT_BY_INDEX => 'optional' ));
1387
if ($v_result != 1) {
1388
return 0;
1389
}
@@ -1412,12 +1412,12 @@
1412
// Function : deleteByIndex()
1413
// Description :
1414
// ***** Deprecated *****
1415
- // delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered.
1416
// --------------------------------------------------------------------------------
1417
function deleteByIndex($p_index)
1418
{
1419
1420
- $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
1421
1422
// ----- Return
1423
return $p_list;
@@ -1468,7 +1468,7 @@
1468
$this->privSwapBackMagicQuotes();
1469
1470
// ----- Error log
1471
- IWPPclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
1472
1473
// ----- Return
1474
return 0;
@@ -1534,8 +1534,8 @@
1534
// TBC : Should also check the archive format
1535
if (!is_file($p_archive)) {
1536
// ----- Error log
1537
- IWPPclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
1538
- $v_result = PCLZIP_ERR_MISSING_FILE;
1539
}
1540
else {
1541
// ----- Duplicate the archive
@@ -1547,8 +1547,8 @@
1547
else
1548
{
1549
// ----- Error log
1550
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1551
- $v_result = PCLZIP_ERR_INVALID_PARAMETER;
1552
}
1553
1554
// ----- Return
@@ -1605,8 +1605,8 @@
1605
else
1606
{
1607
// ----- Error log
1608
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1609
- $v_result = PCLZIP_ERR_INVALID_PARAMETER;
1610
}
1611
1612
// ----- Return
@@ -1623,7 +1623,7 @@
1623
// --------------------------------------------------------------------------------
1624
function errorCode()
1625
{
1626
- if (PCLZIP_ERROR_EXTERNAL == 1) {
1627
return(PclErrorCode());
1628
}
1629
else {
@@ -1639,27 +1639,27 @@
1639
// --------------------------------------------------------------------------------
1640
function errorName($p_with_code=false)
1641
{
1642
- $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
1643
- PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
1644
- PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
1645
- PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
1646
- PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',
1647
- PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',
1648
- PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',
1649
- PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',
1650
- PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',
1651
- PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',
1652
- PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',
1653
- PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',
1654
- PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',
1655
- PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',
1656
- PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
1657
- PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',
1658
- PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE',
1659
- PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION',
1660
- PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION'
1661
- ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE'
1662
- ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION'
1663
);
1664
1665
if (isset($v_name[$this->error_code])) {
@@ -1685,7 +1685,7 @@
1685
// --------------------------------------------------------------------------------
1686
function errorInfo($p_full=false)
1687
{
1688
- if (PCLZIP_ERROR_EXTERNAL == 1) {
1689
return(PclErrorString());
1690
}
1691
else {
@@ -1735,14 +1735,14 @@
1735
// ----- Look if the file exits
1736
if (!is_file($this->zipname)) {
1737
// ----- Error log
1738
- IWPPclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
1739
return(false);
1740
}
1741
1742
// ----- Check that the file is readeable
1743
if (!is_readable($this->zipname)) {
1744
// ----- Error log
1745
- IWPPclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
1746
return(false);
1747
}
1748
@@ -1786,7 +1786,7 @@
1786
// ----- Check if the option is supported
1787
if (!isset($v_requested_options[$p_options_list[$i]])) {
1788
// ----- Error log
1789
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
1790
1791
// ----- Return
1792
return IWPPclZip::errorCode();
@@ -1795,19 +1795,19 @@
1795
// ----- Look for next option
1796
switch ($p_options_list[$i]) {
1797
// ----- Look for options that request a path value
1798
- case PCLZIP_OPT_IWP_EXCLUDE :
1799
if (is_array($p_options_list[$i+1])) {
1800
$v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1801
}
1802
$i++;
1803
break;
1804
- case PCLZIP_OPT_PATH :
1805
- case PCLZIP_OPT_REMOVE_PATH :
1806
- case PCLZIP_OPT_ADD_PATH :
1807
// ----- Check the number of parameters
1808
if (($i+1) >= $p_size) {
1809
// ----- Error log
1810
- IWPPclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
1811
1812
// ----- Return
1813
return IWPPclZip::errorCode();
@@ -1818,23 +1818,23 @@
1818
$i++;
1819
break;
1820
1821
- case PCLZIP_OPT_TEMP_FILE_THRESHOLD :
1822
// ----- Check the number of parameters
1823
if (($i+1) >= $p_size) {
1824
- IWPPclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
1825
return IWPPclZip::errorCode();
1826
}
1827
1828
// ----- Check for incompatible options
1829
- if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
1830
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".IWPPclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
1831
return IWPPclZip::errorCode();
1832
}
1833
1834
// ----- Check the value
1835
$v_value = $p_options_list[$i+1];
1836
if ((!is_integer($v_value)) || ($v_value<0)) {
1837
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
1838
return IWPPclZip::errorCode();
1839
}
1840
@@ -1844,17 +1844,17 @@
1844
break;
1845
1846
1847
- case PCLZIP_OPT_CHUNK_BLOCK_SIZE :
1848
// ----- Check the number of parameters
1849
if (($i+1) >= $p_size) {
1850
- IWPPclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
1851
return IWPPclZip::errorCode();
1852
}
1853
1854
// ----- Check the value
1855
$v_value = $p_options_list[$i+1];
1856
if ((!is_integer($v_value)) || ($v_value<0)) {
1857
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
1858
return IWPPclZip::errorCode();
1859
}
1860
@@ -1863,17 +1863,17 @@
1863
$i++;
1864
break;
1865
1866
- case PCLZIP_OPT_FILE_EXCLUDE_SIZE :
1867
// ----- Check the number of parameters
1868
if (($i+1) >= $p_size) {
1869
- IWPPclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
1870
return IWPPclZip::errorCode();
1871
}
1872
1873
// ----- Check the value
1874
$v_value = $p_options_list[$i+1];
1875
if ((!is_integer($v_value)) || ($v_value<0)) {
1876
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
1877
return IWPPclZip::errorCode();
1878
}
1879
@@ -1882,17 +1882,17 @@
1882
$i++;
1883
break;
1884
1885
- case PCLZIP_OPT_HISTORY_ID :
1886
// ----- Check the number of parameters
1887
if (($i+1) >= $p_size) {
1888
- IWPPclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
1889
return IWPPclZip::errorCode();
1890
}
1891
1892
// ----- Check the value
1893
$v_value = $p_options_list[$i+1];
1894
/* if ((!is_integer($v_value)) || ($v_value<0)) {
1895
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
1896
return IWPPclZip::errorCode();
1897
} */
1898
@@ -1901,36 +1901,36 @@
1901
$i++;
1902
break;
1903
1904
- case PCLZIP_OPT_TEMP_FILE_ON :
1905
// ----- Check for incompatible options
1906
- if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
1907
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".IWPPclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
1908
return IWPPclZip::errorCode();
1909
}
1910
1911
$v_result_list[$p_options_list[$i]] = true;
1912
break;
1913
1914
- case PCLZIP_OPT_TEMP_FILE_OFF :
1915
// ----- Check for incompatible options
1916
- if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) {
1917
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".IWPPclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'");
1918
return IWPPclZip::errorCode();
1919
}
1920
// ----- Check for incompatible options
1921
- if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
1922
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".IWPPclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
1923
return IWPPclZip::errorCode();
1924
}
1925
1926
$v_result_list[$p_options_list[$i]] = true;
1927
break;
1928
1929
- case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
1930
// ----- Check the number of parameters
1931
if (($i+1) >= $p_size) {
1932
// ----- Error log
1933
- IWPPclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
1934
1935
// ----- Return
1936
return IWPPclZip::errorCode();
@@ -1947,11 +1947,11 @@
1947
break;
1948
1949
// ----- Look for options that request an array of string for value
1950
- case PCLZIP_OPT_BY_NAME :
1951
// ----- Check the number of parameters
1952
if (($i+1) >= $p_size) {
1953
// ----- Error log
1954
- IWPPclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
1955
1956
// ----- Return
1957
return IWPPclZip::errorCode();
@@ -1966,7 +1966,7 @@
1966
}
1967
else {
1968
// ----- Error log
1969
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
1970
1971
// ----- Return
1972
return IWPPclZip::errorCode();
@@ -1975,16 +1975,16 @@
1975
break;
1976
1977
// ----- Look for options that request an EREG or PREG expression
1978
- case PCLZIP_OPT_BY_EREG :
1979
- // ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG
1980
- // to PCLZIP_OPT_BY_PREG
1981
- $p_options_list[$i] = PCLZIP_OPT_BY_PREG;
1982
- case PCLZIP_OPT_BY_PREG :
1983
- //case PCLZIP_OPT_CRYPT :
1984
// ----- Check the number of parameters
1985
if (($i+1) >= $p_size) {
1986
// ----- Error log
1987
- IWPPclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
1988
1989
// ----- Return
1990
return IWPPclZip::errorCode();
@@ -1996,7 +1996,7 @@
1996
}
1997
else {
1998
// ----- Error log
1999
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
2000
2001
// ----- Return
2002
return IWPPclZip::errorCode();
@@ -2005,13 +2005,13 @@
2005
break;
2006
2007
// ----- Look for options that takes a string
2008
- case PCLZIP_OPT_COMMENT :
2009
- case PCLZIP_OPT_ADD_COMMENT :
2010
- case PCLZIP_OPT_PREPEND_COMMENT :
2011
// ----- Check the number of parameters
2012
if (($i+1) >= $p_size) {
2013
// ----- Error log
2014
- IWPPclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE,
2015
"Missing parameter value for option '"
2016
.IWPPclZipUtilOptionText($p_options_list[$i])
2017
."'");
@@ -2026,7 +2026,7 @@
2026
}
2027
else {
2028
// ----- Error log
2029
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE,
2030
"Wrong parameter value for option '"
2031
.IWPPclZipUtilOptionText($p_options_list[$i])
2032
."'");
@@ -2038,11 +2038,11 @@
2038
break;
2039
2040
// ----- Look for options that request an array of index
2041
- case PCLZIP_OPT_BY_INDEX :
2042
// ----- Check the number of parameters
2043
if (($i+1) >= $p_size) {
2044
// ----- Error log
2045
- IWPPclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
2046
2047
// ----- Return
2048
return IWPPclZip::errorCode();
@@ -2066,7 +2066,7 @@
2066
}
2067
else {
2068
// ----- Error log
2069
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
2070
2071
// ----- Return
2072
return IWPPclZip::errorCode();
@@ -2099,7 +2099,7 @@
2099
}
2100
else {
2101
// ----- Error log
2102
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
2103
2104
// ----- Return
2105
return IWPPclZip::errorCode();
@@ -2112,7 +2112,7 @@
2112
2113
// ----- TBC : An automatic sort should be writen ...
2114
// ----- Error log
2115
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
2116
2117
// ----- Return
2118
return IWPPclZip::errorCode();
@@ -2130,21 +2130,21 @@
2130
break;
2131
2132
// ----- Look for options that request no value
2133
- case PCLZIP_OPT_REMOVE_ALL_PATH :
2134
- case PCLZIP_OPT_EXTRACT_AS_STRING :
2135
- case PCLZIP_OPT_NO_COMPRESSION :
2136
- case PCLZIP_OPT_EXTRACT_IN_OUTPUT :
2137
- case PCLZIP_OPT_REPLACE_NEWER :
2138
- case PCLZIP_OPT_STOP_ON_ERROR :
2139
$v_result_list[$p_options_list[$i]] = true;
2140
break;
2141
2142
// ----- Look for options that request an octal value
2143
- case PCLZIP_OPT_SET_CHMOD :
2144
// ----- Check the number of parameters
2145
if (($i+1) >= $p_size) {
2146
// ----- Error log
2147
- IWPPclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
2148
2149
// ----- Return
2150
return IWPPclZip::errorCode();
@@ -2156,20 +2156,20 @@
2156
break;
2157
2158
// ----- Look for options that request a call-back
2159
- case PCLZIP_CB_PRE_EXTRACT :
2160
- case PCLZIP_CB_POST_EXTRACT :
2161
- case PCLZIP_CB_PRE_ADD :
2162
- case PCLZIP_CB_POST_ADD :
2163
/* for futur use
2164
- case PCLZIP_CB_PRE_DELETE :
2165
- case PCLZIP_CB_POST_DELETE :
2166
- case PCLZIP_CB_PRE_LIST :
2167
- case PCLZIP_CB_POST_LIST :
2168
*/
2169
// ----- Check the number of parameters
2170
if (($i+1) >= $p_size) {
2171
// ----- Error log
2172
- IWPPclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
2173
2174
// ----- Return
2175
return IWPPclZip::errorCode();
@@ -2181,7 +2181,7 @@
2181
// ----- Check that the value is a valid existing function
2182
if (!function_exists($v_function_name)) {
2183
// ----- Error log
2184
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".IWPPclZipUtilOptionText($p_options_list[$i])."'");
2185
2186
// ----- Return
2187
return IWPPclZip::errorCode();
@@ -2194,7 +2194,7 @@
2194
2195
default :
2196
// ----- Error log
2197
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
2198
"Unknown parameter '"
2199
.$p_options_list[$i]."'");
2200
@@ -2214,7 +2214,7 @@
2214
// ----- Look if present
2215
if (!isset($v_result_list[$key])) {
2216
// ----- Error log
2217
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".IWPPclZipUtilOptionText($key)."(".$key.")");
2218
2219
// ----- Return
2220
return IWPPclZip::errorCode();
@@ -2224,7 +2224,7 @@
2224
}
2225
2226
// ----- Look for default values
2227
- if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
2228
2229
}
2230
@@ -2243,8 +2243,8 @@
2243
{
2244
$v_result=1;
2245
2246
- if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
2247
- || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
2248
return $v_result;
2249
}
2250
@@ -2262,12 +2262,12 @@
2262
if($last == 'k')
2263
$v_memory_limit = $v_memory_limit*1024;
2264
2265
- $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
2266
2267
2268
// ----- Sanity check : No threshold if value lower than 1M
2269
- if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
2270
- unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
2271
}
2272
2273
// ----- Return
@@ -2293,7 +2293,7 @@
2293
// ----- Check if the option is supported
2294
if (!isset($v_requested_options[$v_key])) {
2295
// ----- Error log
2296
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
2297
2298
// ----- Return
2299
return IWPPclZip::errorCode();
@@ -2301,75 +2301,75 @@
2301
2302
// ----- Look for attribute
2303
switch ($v_key) {
2304
- case PCLZIP_ATT_FILE_NAME :
2305
if (!is_string($v_value)) {
2306
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".IWPPclZipUtilOptionText($v_key)."'");
2307
return IWPPclZip::errorCode();
2308
}
2309
2310
$p_filedescr['filename'] = IWPPclZipUtilPathReduction($v_value);
2311
2312
if ($p_filedescr['filename'] == '') {
2313
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".IWPPclZipUtilOptionText($v_key)."'");
2314
return IWPPclZip::errorCode();
2315
}
2316
2317
break;
2318
2319
- case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
2320
if (!is_string($v_value)) {
2321
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".IWPPclZipUtilOptionText($v_key)."'");
2322
return IWPPclZip::errorCode();
2323
}
2324
2325
$p_filedescr['new_short_name'] = IWPPclZipUtilPathReduction($v_value);
2326
2327
if ($p_filedescr['new_short_name'] == '') {
2328
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".IWPPclZipUtilOptionText($v_key)."'");
2329
return IWPPclZip::errorCode();
2330
}
2331
break;
2332
2333
- case PCLZIP_ATT_FILE_NEW_FULL_NAME :
2334
if (!is_string($v_value)) {
2335
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".IWPPclZipUtilOptionText($v_key)."'");
2336
return IWPPclZip::errorCode();
2337
}
2338
2339
$p_filedescr['new_full_name'] = IWPPclZipUtilPathReduction($v_value);
2340
2341
if ($p_filedescr['new_full_name'] == '') {
2342
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".IWPPclZipUtilOptionText($v_key)."'");
2343
return IWPPclZip::errorCode();
2344
}
2345
break;
2346
2347
// ----- Look for options that takes a string
2348
- case PCLZIP_ATT_FILE_COMMENT :
2349
if (!is_string($v_value)) {
2350
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".IWPPclZipUtilOptionText($v_key)."'");
2351
return IWPPclZip::errorCode();
2352
}
2353
2354
$p_filedescr['comment'] = $v_value;
2355
break;
2356
2357
- case PCLZIP_ATT_FILE_MTIME :
2358
if (!is_integer($v_value)) {
2359
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".IWPPclZipUtilOptionText($v_key)."'");
2360
return IWPPclZip::errorCode();
2361
}
2362
2363
$p_filedescr['mtime'] = $v_value;
2364
break;
2365
2366
- case PCLZIP_ATT_FILE_CONTENT :
2367
$p_filedescr['content'] = $v_value;
2368
break;
2369
2370
default :
2371
// ----- Error log
2372
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
2373
"Unknown parameter '".$v_key."'");
2374
2375
// ----- Return
@@ -2383,7 +2383,7 @@
2383
if ($v_requested_options[$key] == 'mandatory') {
2384
// ----- Look if present
2385
if (!isset($p_file_list[$key])) {
2386
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".IWPPclZipUtilOptionText($key)."(".$key.")");
2387
return IWPPclZip::errorCode();
2388
}
2389
}
@@ -2417,8 +2417,8 @@
2417
$v_result=1;
2418
$reLoop = '';
2419
$reLoopCount = -1;
2420
- $limitSize = $p_options[PCLZIP_OPT_CHUNK_BLOCK_SIZE];
2421
- $excludeFileSize = $p_options[PCLZIP_OPT_FILE_EXCLUDE_SIZE];
2422
//$limitSize = 15*1024*1024*1024;
2423
// ----- Create a result list
2424
$v_result_list = array();
@@ -2441,7 +2441,7 @@
2441
if (@is_file($v_descr['filename'])) {
2442
if($is_get_file_list == 'getFileList')
2443
{
2444
- $exclude = $p_options[PCLZIP_OPT_IWP_EXCLUDE];
2445
$skip_this = false;
2446
if(!empty($exclude)){
2447
foreach($exclude as $item)
@@ -2616,7 +2616,7 @@
2616
// ----- Missing file
2617
else {
2618
// ----- Error log
2619
- IWPPclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
2620
2621
// ----- Return
2622
return IWPPclZip::errorCode();
@@ -2627,7 +2627,7 @@
2627
2628
//exclude IWP Mod
2629
$skip_this = false;
2630
- $exclude = $p_options[PCLZIP_OPT_IWP_EXCLUDE];
2631
if(!empty($exclude)){
2632
foreach($exclude as $item){
2633
if(strpos($v_descr['stored_filename'], $item) === 0){
@@ -2665,7 +2665,7 @@
2665
// Because the name of the folder was changed, the name of the
2666
// files/sub-folders also change
2667
if (($v_descr['stored_filename'] != $v_descr['filename'])
2668
- && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
2669
if ($v_descr['stored_filename'] != '') {
2670
$v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
2671
}
@@ -2807,7 +2807,7 @@
2807
@rewind($this->zip_fd);
2808
2809
// ----- Creates a temporay file
2810
- $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
2811
2812
// ----- Open the temporary file in write mode
2813
if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
@@ -2815,7 +2815,7 @@
2815
$this->privCloseFd();
2816
$this->privSwapBackMagicQuotes();
2817
2818
- IWPPclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
2819
2820
// ----- Return
2821
return IWPPclZip::errorCode();
@@ -2826,7 +2826,7 @@
2826
$v_size = $v_central_dir['offset'];
2827
while ($v_size != 0)
2828
{
2829
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2830
$v_buffer = fread($this->zip_fd, $v_read_size);
2831
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2832
$v_size -= $v_read_size;
@@ -2859,7 +2859,7 @@
2859
$v_size = $v_central_dir['size'];
2860
while ($v_size != 0)
2861
{
2862
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2863
$v_buffer = @fread($v_zip_temp_fd, $v_read_size);
2864
@fwrite($this->zip_fd, $v_buffer, $v_read_size);
2865
$v_size -= $v_read_size;
@@ -2887,14 +2887,14 @@
2887
2888
// ----- Zip file comment
2889
$v_comment = $v_central_dir['comment'];
2890
- if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2891
- $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2892
}
2893
- if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
2894
- $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT];
2895
}
2896
- if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
2897
- $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
2898
}
2899
2900
// ----- Calculate the size of the central header
@@ -2952,7 +2952,7 @@
2952
if ($this->zip_fd != 0)
2953
{
2954
// ----- Error log
2955
- IWPPclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
2956
2957
// ----- Return
2958
return IWPPclZip::errorCode();
@@ -2962,7 +2962,7 @@
2962
if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
2963
{
2964
// ----- Error log
2965
- IWPPclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
2966
2967
// ----- Return
2968
return IWPPclZip::errorCode();
@@ -3038,8 +3038,8 @@
3038
3039
// ----- Zip file comment
3040
$v_comment = '';
3041
- if (isset($p_options[PCLZIP_OPT_COMMENT])) {
3042
- $v_comment = $p_options[PCLZIP_OPT_COMMENT];
3043
}
3044
3045
// ----- Calculate the size of the central header
@@ -3093,7 +3093,7 @@
3093
// ----- Check the filename
3094
if ( ($p_filedescr_list[$j]['type'] != 'virtual_file')
3095
&& (!file_exists($p_filedescr_list[$j]['filename']))) {
3096
- IWPPclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
3097
return IWPPclZip::errorCode();
3098
}
3099
@@ -3104,8 +3104,8 @@
3104
if ( ($p_filedescr_list[$j]['type'] == 'file')
3105
|| ($p_filedescr_list[$j]['type'] == 'virtual_file')
3106
|| ( ($p_filedescr_list[$j]['type'] == 'folder')
3107
- && ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
3108
- || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
3109
) {
3110
3111
// ----- Add the file
@@ -3164,7 +3164,7 @@
3164
// TBC : Already done in the fileAtt check ... ?
3165
if ($p_filename == "") {
3166
// ----- Error log
3167
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
3168
3169
// ----- Return
3170
echo "false filename";
@@ -3248,7 +3248,7 @@
3248
}
3249
3250
// ----- Look for pre-add callback
3251
- if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
3252
3253
// ----- Generate a local information
3254
$v_local_header = array();
@@ -3257,8 +3257,8 @@
3257
// ----- Call the callback
3258
// Here I do not use call_user_func() because I need to send a reference to the
3259
// header.
3260
- // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);');
3261
- $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header);
3262
if ($v_result == 0) {
3263
// ----- Change the file status
3264
$p_header['status'] = "skipped";
@@ -3289,12 +3289,12 @@
3289
// ----- Look for a file
3290
if ($p_filedescr['type'] == 'file') {
3291
// ----- Look for using temporary file to zip
3292
- if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
3293
- && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
3294
- || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
3295
- && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
3296
$v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
3297
- if ($v_result < PCLZIP_ERR_NO_ERROR) {
3298
return $v_result;
3299
}
3300
}
@@ -3305,7 +3305,7 @@
3305
// ----- Open the source file
3306
//if (($v_file = @fopen($p_filename, "rb")) == 0) { //darkPrince
3307
if (($v_file = @fopen($p_filedescr['filename'], "rb")) == 0) {
3308
- IWPPclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode. Please try changing the file permission to 644 or exclude this file from your backup.");
3309
echo "File Read Error";
3310
return IWPPclZip::errorCode();
3311
}
@@ -3325,7 +3325,7 @@
3325
$p_header['crc'] = @crc32($v_content);
3326
3327
// ----- Look for no compression
3328
- if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
3329
// ----- Set header parameters
3330
$p_header['compressed_size'] = $p_header['size'];
3331
$p_header['compression'] = 0;
@@ -3362,7 +3362,7 @@
3362
$p_header['crc'] = @crc32($v_content);
3363
3364
// ----- Look for no compression
3365
- if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
3366
// ----- Set header parameters
3367
$p_header['compressed_size'] = $p_header['size'];
3368
$p_header['compression'] = 0;
@@ -3409,7 +3409,7 @@
3409
}
3410
3411
// ----- Look for post-add callback
3412
- if (isset($p_options[PCLZIP_CB_POST_ADD])) {
3413
3414
// ----- Generate a local information
3415
$v_local_header = array();
@@ -3418,8 +3418,8 @@
3418
// ----- Call the callback
3419
// Here I do not use call_user_func() because I need to send a reference to the
3420
// header.
3421
- // eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);');
3422
- $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header);
3423
if ($v_result == 0) {
3424
// ----- Ignored
3425
$v_result = 1;
@@ -3443,7 +3443,7 @@
3443
function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
3444
{
3445
$startTime = microtime(true);
3446
- $v_result=PCLZIP_ERR_NO_ERROR;
3447
3448
// ----- Working variable
3449
$p_filename = $p_filedescr['filename'];
@@ -3451,22 +3451,22 @@
3451
3452
// ----- Open the source file
3453
if (($v_file = @fopen($p_filename, "rb")) == 0) {
3454
- IWPPclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode. Please try changing the file permission to 644 or exclude this file from your backup.");
3455
//return array( 'error' => "Unable to open file '$p_filename' in binary read mode. Please try changing the file permission to 644 or exclude this file from your backup.");
3456
return IWPPclZip::errorCode();
3457
}
3458
3459
// ----- Creates a compressed temporary file
3460
- $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
3461
if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
3462
fclose($v_file);
3463
- IWPPclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
3464
//return array( 'error' => 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
3465
return IWPPclZip::errorCode();
3466
}
3467
3468
$tempLoopStart = microtime(true);
3469
- // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3470
//$v_size = iwp_mmb_get_file_size($p_filename);
3471
$v_size = $p_filedescr['size']; //darkPrince setting fileSize from Array
3472
if($p_filedescr['splitFilename'] != '')
@@ -3474,7 +3474,7 @@
3474
@fseek($v_file,$p_filedescr['splitOffset']);
3475
}
3476
while ($v_size != 0) {
3477
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
3478
3479
$v_buffer = @fread($v_file, $v_read_size);
3480
//$v_binary_data = pack('a'.$v_read_size, $v_buffer);
@@ -3490,14 +3490,14 @@
3490
// ----- Check the minimum file size
3491
if (iwp_mmb_get_file_size($v_gzip_temp_name) < 18) {
3492
echo "Check the minimum file size error";
3493
- IWPPclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
3494
//return array( 'error' => 'Zip-error: Error compressing the file "'.$p_filedescr['filename'].'".Try excluding this file and try again.');
3495
return IWPPclZip::errorCode();
3496
}
3497
3498
// ----- Extract the compressed attributes
3499
if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
3500
- IWPPclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
3501
return IWPPclZip::errorCode();
3502
}
3503
@@ -3533,16 +3533,16 @@
3533
// ----- Add the compressed data
3534
if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
3535
{
3536
- IWPPclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
3537
return IWPPclZip::errorCode();
3538
}
3539
3540
- // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3541
fseek($v_file_compressed, 10);
3542
$v_size = $p_header['compressed_size'];
3543
while ($v_size != 0)
3544
{
3545
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
3546
$v_buffer = @fread($v_file_compressed, $v_read_size);
3547
//$v_binary_data = pack('a'.$v_read_size, $v_buffer);
3548
@fwrite($this->zip_fd, $v_buffer, $v_read_size);
@@ -3575,20 +3575,20 @@
3575
3576
// ----- Working variables
3577
$p_filename = $p_filedescr['filename'];
3578
- if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
3579
- $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
3580
}
3581
else {
3582
$p_add_dir = '';
3583
}
3584
- if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
3585
- $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
3586
}
3587
else {
3588
$p_remove_dir = '';
3589
}
3590
- if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
3591
- $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
3592
}
3593
else {
3594
$p_remove_all_dir = 0;
@@ -3822,7 +3822,7 @@
3822
$this->privSwapBackMagicQuotes();
3823
3824
// ----- Error log
3825
- IWPPclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
3826
3827
// ----- Return
3828
return IWPPclZip::errorCode();
@@ -3843,7 +3843,7 @@
3843
$this->privSwapBackMagicQuotes();
3844
3845
// ----- Error log
3846
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3847
3848
// ----- Return
3849
return IWPPclZip::errorCode();
@@ -4000,7 +4000,7 @@
4000
$this->privSwapBackMagicQuotes();
4001
4002
// ----- Error log
4003
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4004
4005
// ----- Return
4006
return IWPPclZip::errorCode();
@@ -4027,23 +4027,23 @@
4027
$v_extract = false;
4028
4029
// ----- Look for extract by name rule
4030
- if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
4031
- && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
4032
4033
// ----- Look if the filename is in the list
4034
- for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
4035
4036
// ----- Look for a directory
4037
- if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
4038
4039
// ----- Look if the directory is in the filename path
4040
- if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4041
- && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4042
$v_extract = true;
4043
}
4044
}
4045
// ----- Look for a filename
4046
- elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
4047
$v_extract = true;
4048
}
4049
}
@@ -4052,39 +4052,39 @@
4052
// ----- Look for extract by ereg rule
4053
// ereg() is deprecated with PHP 5.3
4054
/*
4055
- else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
4056
- && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
4057
4058
- if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
4059
$v_extract = true;
4060
}
4061
}
4062
*/
4063
4064
// ----- Look for extract by preg rule
4065
- else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
4066
- && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
4067
4068
- if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
4069
$v_extract = true;
4070
}
4071
}
4072
4073
// ----- Look for extract by index rule
4074
- else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
4075
- && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
4076
4077
// ----- Look if the index is in the list
4078
- for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
4079
4080
- if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
4081
$v_extract = true;
4082
}
4083
- if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
4084
$j_start = $j+1;
4085
}
4086
4087
- if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
4088
break;
4089
}
4090
}
@@ -4101,13 +4101,13 @@
4101
&& ($v_header['compression'] != 0))) {
4102
$v_header['status'] = 'unsupported_compression';
4103
4104
- // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
4105
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
4106
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
4107
4108
$this->privSwapBackMagicQuotes();
4109
4110
- IWPPclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
4111
"Filename '".$v_header['stored_filename']."' is "
4112
."compressed by an unsupported compression "
4113
."method (".$v_header['compression'].") ");
@@ -4120,13 +4120,13 @@
4120
if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
4121
$v_header['status'] = 'unsupported_encryption';
4122
4123
- // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
4124
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
4125
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
4126
4127
$this->privSwapBackMagicQuotes();
4128
4129
- IWPPclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
4130
"Unsupported encryption for "
4131
." filename '".$v_header['stored_filename']
4132
."'");
@@ -4162,14 +4162,14 @@
4162
$this->privSwapBackMagicQuotes();
4163
4164
// ----- Error log
4165
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4166
4167
// ----- Return
4168
return IWPPclZip::errorCode();
4169
}
4170
4171
// ----- Look for extraction as string
4172
- if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
4173
4174
$v_string = '';
4175
@@ -4203,8 +4203,8 @@
4203
}
4204
}
4205
// ----- Look for extraction in standard output
4206
- elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
4207
- && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
4208
// ----- Extracting the file in standard output
4209
$v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
4210
if ($v_result1 < 1) {
@@ -4272,7 +4272,7 @@
4272
// Return Values :
4273
//
4274
// 1 : ... ?
4275
- // PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback
4276
// --------------------------------------------------------------------------------
4277
function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
4278
{
@@ -4334,22 +4334,22 @@
4334
}
4335
4336
// ----- Check a base_dir_restriction
4337
- if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
4338
$v_inclusion
4339
- = IWPPclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
4340
$p_entry['filename']);
4341
if ($v_inclusion == 0) {
4342
4343
- IWPPclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
4344
"Filename '".$p_entry['filename']."' is "
4345
- ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
4346
4347
return IWPPclZip::errorCode();
4348
}
4349
}
4350
4351
// ----- Look for pre-extract callback
4352
- if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4353
4354
// ----- Generate a local information
4355
$v_local_header = array();
@@ -4358,8 +4358,8 @@
4358
// ----- Call the callback
4359
// Here I do not use call_user_func() because I need to send a reference to the
4360
// header.
4361
- // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
4362
- $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4363
if ($v_result == 0) {
4364
// ----- Change the file status
4365
$p_entry['status'] = "skipped";
@@ -4370,7 +4370,7 @@
4370
if ($v_result == 2) {
4371
// ----- This status is internal and will be changed in 'skipped'
4372
$p_entry['status'] = "aborted";
4373
- $v_result = PCLZIP_ERR_USER_ABORTED;
4374
}
4375
4376
// ----- Update the informations
@@ -4393,13 +4393,13 @@
4393
// ----- Change the file status
4394
$p_entry['status'] = "already_a_directory";
4395
4396
- // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
4397
// For historical reason first IWPPclZip implementation does not stop
4398
// when this kind of error occurs.
4399
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
4400
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
4401
4402
- IWPPclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
4403
"Filename '".$p_entry['filename']."' is "
4404
."already used by an existing directory");
4405
@@ -4413,13 +4413,13 @@
4413
// ----- Change the file status
4414
$p_entry['status'] = "write_protected";
4415
4416
- // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
4417
// For historical reason first IWPPclZip implementation does not stop
4418
// when this kind of error occurs.
4419
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
4420
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
4421
4422
- IWPPclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
4423
"Filename '".$p_entry['filename']."' exists "
4424
."and is write protected");
4425
@@ -4431,21 +4431,21 @@
4431
else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
4432
{
4433
// ----- Change the file status
4434
- if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
4435
- && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
4436
}
4437
else {
4438
$p_entry['status'] = "newer_exist";
4439
4440
- // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
4441
// For historical reason first IWPPclZip implementation does not stop
4442
// when this kind of error occurs.
4443
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
4444
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
4445
4446
- IWPPclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
4447
"Newer version of '".$p_entry['filename']."' exists "
4448
- ."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
4449
4450
return IWPPclZip::errorCode();
4451
}
@@ -4497,11 +4497,11 @@
4497
}
4498
4499
4500
- // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
4501
$v_size = $p_entry['compressed_size'];
4502
while ($v_size != 0)
4503
{
4504
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
4505
$v_buffer = @fread($this->zip_fd, $v_read_size);
4506
/* Try to speed up the code
4507
$v_binary_data = pack('a'.$v_read_size, $v_buffer);
@@ -4523,18 +4523,18 @@
4523
// ----- TBC
4524
// Need to be finished
4525
if (($p_entry['flag'] & 1) == 1) {
4526
- IWPPclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
4527
return IWPPclZip::errorCode();
4528
}
4529
4530
4531
// ----- Look for using temporary file to unzip
4532
- if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
4533
- && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
4534
- || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
4535
- && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
4536
$v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
4537
- if ($v_result < PCLZIP_ERR_NO_ERROR) {
4538
return $v_result;
4539
}
4540
}
@@ -4581,10 +4581,10 @@
4581
}
4582
4583
// ----- Look for chmod option
4584
- if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
4585
4586
// ----- Change the mode of the file
4587
- @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
4588
}
4589
4590
}
@@ -4596,7 +4596,7 @@
4596
}
4597
4598
// ----- Look for post-extract callback
4599
- elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4600
4601
// ----- Generate a local information
4602
$v_local_header = array();
@@ -4605,12 +4605,12 @@
4605
// ----- Call the callback
4606
// Here I do not use call_user_func() because I need to send a reference to the
4607
// header.
4608
- // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
4609
- $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4610
4611
// ----- Look for abort result
4612
if ($v_result == 2) {
4613
- $v_result = PCLZIP_ERR_USER_ABORTED;
4614
}
4615
}
4616
@@ -4630,10 +4630,10 @@
4630
$v_result=1;
4631
4632
// ----- Creates a temporary file
4633
- $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
4634
if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
4635
fclose($v_file);
4636
- IWPPclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
4637
return IWPPclZip::errorCode();
4638
}
4639
@@ -4642,11 +4642,11 @@
4642
$v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
4643
@fwrite($v_dest_file, $v_binary_data, 10);
4644
4645
- // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
4646
$v_size = $p_entry['compressed_size'];
4647
while ($v_size != 0)
4648
{
4649
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
4650
$v_buffer = @fread($this->zip_fd, $v_read_size);
4651
//$v_binary_data = pack('a'.$v_read_size, $v_buffer);
4652
@fwrite($v_dest_file, $v_buffer, $v_read_size);
@@ -4670,15 +4670,15 @@
4670
if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
4671
@fclose($v_dest_file);
4672
$p_entry['status'] = "read_error";
4673
- IWPPclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
4674
return IWPPclZip::errorCode();
4675
}
4676
4677
4678
- // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
4679
$v_size = $p_entry['size'];
4680
while ($v_size != 0) {
4681
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
4682
$v_buffer = @gzread($v_src_file, $v_read_size);
4683
//$v_binary_data = pack('a'.$v_read_size, $v_buffer);
4684
@fwrite($v_dest_file, $v_buffer, $v_read_size);
@@ -4717,7 +4717,7 @@
4717
}
4718
4719
// ----- Look for pre-extract callback
4720
- if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4721
4722
// ----- Generate a local information
4723
$v_local_header = array();
@@ -4726,8 +4726,8 @@
4726
// ----- Call the callback
4727
// Here I do not use call_user_func() because I need to send a reference to the
4728
// header.
4729
- // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
4730
- $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4731
if ($v_result == 0) {
4732
// ----- Change the file status
4733
$p_entry['status'] = "skipped";
@@ -4738,7 +4738,7 @@
4738
if ($v_result == 2) {
4739
// ----- This status is internal and will be changed in 'skipped'
4740
$p_entry['status'] = "aborted";
4741
- $v_result = PCLZIP_ERR_USER_ABORTED;
4742
}
4743
4744
// ----- Update the informations
@@ -4785,7 +4785,7 @@
4785
}
4786
4787
// ----- Look for post-extract callback
4788
- elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4789
4790
// ----- Generate a local information
4791
$v_local_header = array();
@@ -4794,12 +4794,12 @@
4794
// ----- Call the callback
4795
// Here I do not use call_user_func() because I need to send a reference to the
4796
// header.
4797
- // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
4798
- $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4799
4800
// ----- Look for abort result
4801
if ($v_result == 2) {
4802
- $v_result = PCLZIP_ERR_USER_ABORTED;
4803
}
4804
}
4805
@@ -4832,7 +4832,7 @@
4832
}
4833
4834
// ----- Look for pre-extract callback
4835
- if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4836
4837
// ----- Generate a local information
4838
$v_local_header = array();
@@ -4841,8 +4841,8 @@
4841
// ----- Call the callback
4842
// Here I do not use call_user_func() because I need to send a reference to the
4843
// header.
4844
- // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
4845
- $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4846
if ($v_result == 0) {
4847
// ----- Change the file status
4848
$p_entry['status'] = "skipped";
@@ -4853,7 +4853,7 @@
4853
if ($v_result == 2) {
4854
// ----- This status is internal and will be changed in 'skipped'
4855
$p_entry['status'] = "aborted";
4856
- $v_result = PCLZIP_ERR_USER_ABORTED;
4857
}
4858
4859
// ----- Update the informations
@@ -4899,7 +4899,7 @@
4899
}
4900
4901
// ----- Look for post-extract callback
4902
- elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4903
4904
// ----- Generate a local information
4905
$v_local_header = array();
@@ -4912,8 +4912,8 @@
4912
// ----- Call the callback
4913
// Here I do not use call_user_func() because I need to send a reference to the
4914
// header.
4915
- // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
4916
- $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4917
4918
// ----- Swap back the content to header
4919
$p_string = $v_local_header['content'];
@@ -4921,7 +4921,7 @@
4921
4922
// ----- Look for abort result
4923
if ($v_result == 2) {
4924
- $v_result = PCLZIP_ERR_USER_ABORTED;
4925
}
4926
}
4927
@@ -4949,7 +4949,7 @@
4949
{
4950
4951
// ----- Error log
4952
- IWPPclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4953
4954
// ----- Return
4955
return IWPPclZip::errorCode();
@@ -4965,7 +4965,7 @@
4965
$p_header['status'] = "invalid_header";
4966
4967
// ----- Error log
4968
- IWPPclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4969
4970
// ----- Return
4971
return IWPPclZip::errorCode();
@@ -5052,7 +5052,7 @@
5052
{
5053
5054
// ----- Error log
5055
- IWPPclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
5056
5057
// ----- Return
5058
return IWPPclZip::errorCode();
@@ -5068,7 +5068,7 @@
5068
$p_header['status'] = "invalid_header";
5069
5070
// ----- Error log
5071
- IWPPclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
5072
5073
// ----- Return
5074
return IWPPclZip::errorCode();
@@ -5203,7 +5203,7 @@
5203
{
5204
// ----- Error log
5205
echo "Unable to go to the end of the archive";
5206
- IWPPclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
5207
if(($v_size > 2047999988 )||($v_size == 0)||($v_size < 0))
5208
{
5209
return array('error' => 'Unable to find End of Central Dir Record signature.');
@@ -5221,7 +5221,7 @@
5221
{
5222
echo 'Unable to seek back to the middle of the archive - 5091';
5223
// ----- Error log
5224
- IWPPclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
5225
5226
// ----- Return
5227
return IWPPclZip::errorCode();
@@ -5249,7 +5249,7 @@
5249
{
5250
echo "Unable to seek back to the middle of the archive - 5119";
5251
// ----- Error log
5252
- IWPPclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
5253
5254
// ----- Return
5255
return IWPPclZip::errorCode();
@@ -5284,7 +5284,7 @@
5284
{
5285
echo "Unable to find End of Central Dir Record signature ";
5286
// ----- Error log
5287
- IWPPclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
5288
5289
if(($v_size > 2047999988)||($v_size == 0))
5290
{
@@ -5303,7 +5303,7 @@
5303
{
5304
echo "Invalid End of Central Dir Record size : ";
5305
// ----- Error log
5306
- IWPPclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
5307
5308
// ----- Return
5309
return IWPPclZip::errorCode();
@@ -5322,7 +5322,7 @@
5322
if (0) {
5323
echo "The central dir is not at the end of the archive. Some trailing bytes exists after the archive.";
5324
// ----- Error log
5325
- IWPPclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT,
5326
'The central dir is not at the end of the archive.'
5327
.' Some trailing bytes exists after the archive.');
5328
@@ -5393,7 +5393,7 @@
5393
$this->privCloseFd();
5394
5395
// ----- Error log
5396
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
5397
5398
// ----- Return
5399
return IWPPclZip::errorCode();
@@ -5423,27 +5423,27 @@
5423
$v_found = false;
5424
5425
// ----- Look for extract by name rule
5426
- if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
5427
- && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
5428
5429
// ----- Look if the filename is in the list
5430
- for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
5431
5432
// ----- Look for a directory
5433
- if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
5434
5435
// ----- Look if the directory is in the filename path
5436
- if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
5437
- && (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])) {
5438
$v_found = true;
5439
}
5440
elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
5441
- && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
5442
$v_found = true;
5443
}
5444
}
5445
// ----- Look for a filename
5446
- elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
5447
$v_found = true;
5448
}
5449
}
@@ -5452,39 +5452,39 @@
5452
// ----- Look for extract by ereg rule
5453
// ereg() is deprecated with PHP 5.3
5454
/*
5455
- else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
5456
- && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
5457
5458
- if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
5459
$v_found = true;
5460
}
5461
}
5462
*/
5463
5464
// ----- Look for extract by preg rule
5465
- else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
5466
- && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
5467
5468
- if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
5469
$v_found = true;
5470
}
5471
}
5472
5473
// ----- Look for extract by index rule
5474
- else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
5475
- && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
5476
5477
// ----- Look if the index is in the list
5478
- for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
5479
5480
- if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
5481
$v_found = true;
5482
}
5483
- if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
5484
$j_start = $j+1;
5485
}
5486
5487
- if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
5488
break;
5489
}
5490
}
@@ -5508,7 +5508,7 @@
5508
if ($v_nb_extracted > 0) {
5509
5510
// ----- Creates a temporay file
5511
- $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
5512
5513
// ----- Creates a temporary zip archive
5514
$v_temp_zip = new IWPPclZip($v_zip_temp_name);
@@ -5533,7 +5533,7 @@
5533
@unlink($v_zip_temp_name);
5534
5535
// ----- Error log
5536
- IWPPclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
5537
5538
// ----- Return
5539
return IWPPclZip::errorCode();
@@ -5603,8 +5603,8 @@
5603
5604
// ----- Zip file comment
5605
$v_comment = '';
5606
- if (isset($p_options[PCLZIP_OPT_COMMENT])) {
5607
- $v_comment = $p_options[PCLZIP_OPT_COMMENT];
5608
}
5609
5610
// ----- Calculate the size of the central header
@@ -5707,7 +5707,7 @@
5707
if (!@mkdir($p_dir, 0777))
5708
{
5709
// ----- Error log
5710
- IWPPclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
5711
5712
// ----- Return
5713
return IWPPclZip::errorCode();
@@ -5792,7 +5792,7 @@
5792
@rewind($p_archive_to_add->zip_fd);
5793
5794
// ----- Creates a temporay file
5795
- $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
5796
5797
// ----- Open the temporary file in write mode
5798
if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
@@ -5800,7 +5800,7 @@
5800
$this->privCloseFd();
5801
$p_archive_to_add->privCloseFd();
5802
5803
- IWPPclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
5804
5805
// ----- Return
5806
return IWPPclZip::errorCode();
@@ -5811,7 +5811,7 @@
5811
$v_size = $v_central_dir['offset'];
5812
while ($v_size != 0)
5813
{
5814
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5815
$v_buffer = fread($this->zip_fd, $v_read_size);
5816
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5817
$v_size -= $v_read_size;
@@ -5821,7 +5821,7 @@
5821
$v_size = $v_central_dir_to_add['offset'];
5822
while ($v_size != 0)
5823
{
5824
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5825
$v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
5826
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5827
$v_size -= $v_read_size;
@@ -5834,7 +5834,7 @@
5834
$v_size = $v_central_dir['size'];
5835
while ($v_size != 0)
5836
{
5837
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5838
$v_buffer = @fread($this->zip_fd, $v_read_size);
5839
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5840
$v_size -= $v_read_size;
@@ -5844,7 +5844,7 @@
5844
$v_size = $v_central_dir_to_add['size'];
5845
while ($v_size != 0)
5846
{
5847
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5848
$v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
5849
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5850
$v_size -= $v_read_size;
@@ -5937,7 +5937,7 @@
5937
{
5938
$this->privCloseFd();
5939
5940
- IWPPclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
5941
5942
// ----- Return
5943
return IWPPclZip::errorCode();
@@ -5948,7 +5948,7 @@
5948
$v_size = iwp_mmb_get_file_size($p_archive_filename);
5949
while ($v_size != 0)
5950
{
5951
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5952
$v_buffer = fread($v_zip_temp_fd, $v_read_size);
5953
@fwrite($this->zip_fd, $v_buffer, $v_read_size);
5954
$v_size -= $v_read_size;
@@ -5972,7 +5972,7 @@
5972
// --------------------------------------------------------------------------------
5973
function privErrorLog($p_error_code=0, $p_error_string='')
5974
{
5975
- if (PCLZIP_ERROR_EXTERNAL == 1) {
5976
PclError($p_error_code, $p_error_string);
5977
}
5978
else {
@@ -5989,7 +5989,7 @@
5989
// --------------------------------------------------------------------------------
5990
function privErrorReset()
5991
{
5992
- if (PCLZIP_ERROR_EXTERNAL == 1) {
5993
PclErrorReset();
5994
}
5995
else {
@@ -6240,7 +6240,7 @@
6240
{
6241
while ($p_size != 0)
6242
{
6243
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
6244
$v_buffer = @fread($p_src, $v_read_size);
6245
@fwrite($p_dest, $v_buffer, $v_read_size);
6246
$p_size -= $v_read_size;
@@ -6250,7 +6250,7 @@
6250
{
6251
while ($p_size != 0)
6252
{
6253
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
6254
$v_buffer = @gzread($p_src, $v_read_size);
6255
@fwrite($p_dest, $v_buffer, $v_read_size);
6256
$p_size -= $v_read_size;
@@ -6260,7 +6260,7 @@
6260
{
6261
while ($p_size != 0)
6262
{
6263
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
6264
$v_buffer = @fread($p_src, $v_read_size);
6265
@gzwrite($p_dest, $v_buffer, $v_read_size);
6266
$p_size -= $v_read_size;
@@ -6270,7 +6270,7 @@
6270
{
6271
while ($p_size != 0)
6272
{
6273
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
6274
$v_buffer = @gzread($p_src, $v_read_size);
6275
@gzwrite($p_dest, $v_buffer, $v_read_size);
6276
$p_size -= $v_read_size;
@@ -6330,9 +6330,9 @@
6330
$v_list = get_defined_constants();
6331
for (reset($v_list); $v_key = key($v_list); next($v_list)) {
6332
$v_prefix = substr($v_key, 0, 10);
6333
- if (( ($v_prefix == 'PCLZIP_OPT')
6334
- || ($v_prefix == 'PCLZIP_CB_')
6335
- || ($v_prefix == 'PCLZIP_ATT'))
6336
&& ($v_list[$v_key] == $p_option)) {
6337
return $v_key;
6338
}
26
// --------------------------------------------------------------------------------
27
28
// ----- Constants
29
+ if (!defined('IWP_PCLZIP_READ_BLOCK_SIZE')) {
30
+ define( 'IWP_PCLZIP_READ_BLOCK_SIZE', 2048 );
31
}
32
33
// ----- File list separator
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( 'IWP_PCLZIP_SEPARATOR', ' ' );
42
// Recommanded values for smart separation of filenames.
43
+ if (!defined('IWP_PCLZIP_SEPARATOR')) {
44
+ define( 'IWP_PCLZIP_SEPARATOR', ',' );
45
}
46
47
// ----- Error configuration
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('IWP_PCLZIP_ERROR_EXTERNAL')) {
53
+ define( 'IWP_PCLZIP_ERROR_EXTERNAL', 0 );
54
}
55
56
// ----- Optional static temporary directory
60
// - MUST BE terminated by a '/'.
61
// - MUST be a valid, already created directory
62
// Samples :
63
+ // define( 'IWP_PCLZIP_TEMPORARY_DIR', '/temp/' );
64
+ // define( 'IWP_PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
65
+ if (!defined('IWP_PCLZIP_TEMPORARY_DIR')) {
66
+ define( 'IWP_PCLZIP_TEMPORARY_DIR', '' );
67
}
68
69
// ----- Optional threshold ratio for use of temporary files
73
// threshold = memory_limit * ratio.
74
// Recommended values are under 0.5. Default 0.47.
75
// Samples :
76
+ // define( 'IWP_PCLZIP_TEMPORARY_FILE_RATIO', 0.5 );
77
+ if (!defined('IWP_PCLZIP_TEMPORARY_FILE_RATIO')) {
78
+ define( 'IWP_PCLZIP_TEMPORARY_FILE_RATIO', 0.47 );
79
}
80
81
// --------------------------------------------------------------------------------
100
// -12 : Unable to rename file (rename)
101
// -13 : Invalid header checksum
102
// -14 : Invalid archive size
103
+ define( 'IWP_PCLZIP_ERR_USER_ABORTED', 2 );
104
+ define( 'IWP_PCLZIP_ERR_NO_ERROR', 0 );
105
+ define( 'IWP_PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );
106
+ define( 'IWP_PCLZIP_ERR_READ_OPEN_FAIL', -2 );
107
+ define( 'IWP_PCLZIP_ERR_INVALID_PARAMETER', -3 );
108
+ define( 'IWP_PCLZIP_ERR_MISSING_FILE', -4 );
109
+ define( 'IWP_PCLZIP_ERR_FILENAME_TOO_LONG', -5 );
110
+ define( 'IWP_PCLZIP_ERR_INVALID_ZIP', -6 );
111
+ define( 'IWP_PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );
112
+ define( 'IWP_PCLZIP_ERR_DIR_CREATE_FAIL', -8 );
113
+ define( 'IWP_PCLZIP_ERR_BAD_EXTENSION', -9 );
114
+ define( 'IWP_PCLZIP_ERR_BAD_FORMAT', -10 );
115
+ define( 'IWP_PCLZIP_ERR_DELETE_FILE_FAIL', -11 );
116
+ define( 'IWP_PCLZIP_ERR_RENAME_FILE_FAIL', -12 );
117
+ define( 'IWP_PCLZIP_ERR_BAD_CHECKSUM', -13 );
118
+ define( 'IWP_PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );
119
+ define( 'IWP_PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );
120
+ define( 'IWP_PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );
121
+ define( 'IWP_PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 );
122
+ define( 'IWP_PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 );
123
+ define( 'IWP_PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 );
124
+ define( 'IWP_PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 );
125
+ define( 'IWP_PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 );
126
127
// ----- Options values
128
+ define( 'IWP_PCLZIP_OPT_PATH', 77001 );
129
+ define( 'IWP_PCLZIP_OPT_ADD_PATH', 77002 );
130
+ define( 'IWP_PCLZIP_OPT_REMOVE_PATH', 77003 );
131
+ define( 'IWP_PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );
132
+ define( 'IWP_PCLZIP_OPT_SET_CHMOD', 77005 );
133
+ define( 'IWP_PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );
134
+ define( 'IWP_PCLZIP_OPT_NO_COMPRESSION', 77007 );
135
+ define( 'IWP_PCLZIP_OPT_BY_NAME', 77008 );
136
+ define( 'IWP_PCLZIP_OPT_BY_INDEX', 77009 );
137
+ define( 'IWP_PCLZIP_OPT_BY_EREG', 77010 );
138
+ define( 'IWP_PCLZIP_OPT_BY_PREG', 77011 );
139
+ define( 'IWP_PCLZIP_OPT_COMMENT', 77012 );
140
+ define( 'IWP_PCLZIP_OPT_ADD_COMMENT', 77013 );
141
+ define( 'IWP_PCLZIP_OPT_PREPEND_COMMENT', 77014 );
142
+ define( 'IWP_PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 );
143
+ define( 'IWP_PCLZIP_OPT_REPLACE_NEWER', 77016 );
144
+ define( 'IWP_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( 'IWP_PCLZIP_OPT_CRYPT', 77018 );
148
149
+ define( 'IWP_PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 );
150
+ define( 'IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE', 78999 ); //darkCode
151
+ define( 'IWP_PCLZIP_OPT_HISTORY_ID', 79999 ); //darkCode
152
+ define( 'IWP_PCLZIP_OPT_FILE_EXCLUDE_SIZE', 79997 ); //darkCode
153
+ define( 'IWP_PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 );
154
+ define( 'IWP_PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias
155
+ define( 'IWP_PCLZIP_OPT_TEMP_FILE_ON', 77021 );
156
+ define( 'IWP_PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias
157
+ define( 'IWP_PCLZIP_OPT_TEMP_FILE_OFF', 77022 );
158
+ define( 'IWP_PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias
159
+ define( 'IWP_PCLZIP_OPT_IWP_EXCLUDE', 77999 );//IWP Mod
160
161
162
// ----- File description attributes
163
+ define( 'IWP_PCLZIP_ATT_FILE_NAME', 79001 );
164
+ define( 'IWP_PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 );
165
+ define( 'IWP_PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 );
166
+ define( 'IWP_PCLZIP_ATT_FILE_MTIME', 79004 );
167
+ define( 'IWP_PCLZIP_ATT_FILE_CONTENT', 79005 );
168
+ define( 'IWP_PCLZIP_ATT_FILE_COMMENT', 79006 );
169
170
// ----- Call backs values
171
+ define( 'IWP_PCLZIP_CB_PRE_EXTRACT', 78001 );
172
+ define( 'IWP_PCLZIP_CB_POST_EXTRACT', 78002 );
173
+ define( 'IWP_PCLZIP_CB_PRE_ADD', 78003 );
174
+ define( 'IWP_PCLZIP_CB_POST_ADD', 78004 );
175
/* For futur use
176
+ define( 'IWP_PCLZIP_CB_PRE_LIST', 78005 );
177
+ define( 'IWP_PCLZIP_CB_POST_LIST', 78006 );
178
+ define( 'IWP_PCLZIP_CB_PRE_DELETE', 78007 );
179
+ define( 'IWP_PCLZIP_CB_POST_DELETE', 78008 );
180
*/
181
182