Migration, Backup, Staging – WPvivid - Version 0.9.66

Version Description

  • Fixed a Dropbox folder bug.
  • Fixed a conflict between the unused image cleaner and some themes.
  • Fixed a problem that some used images in Elementor were identified as unused.
  • Fixed: Downloading backup would failed in some cases.
  • Added a check to Nginx server when creating a staging site.
  • Optimized the plugin code.
Download this release

Release Info

Developer wpvivid
Plugin Icon 128x128 Migration, Backup, Staging – WPvivid
Version 0.9.66
Comparing to
See all releases

Code changes from version 0.9.65 to 0.9.66

includes/class-wpvivid-restore-database.php CHANGED
@@ -963,7 +963,7 @@ class WPvivid_RestoreDB
963
  if(!empty($old_path)&&!empty($new_path))
964
  {
965
  $old_path_data= $row['path'];
966
- $new_path_data=str_replace($old_path,$new_path,$old_path_data);
967
  $update[] = '`path` = "' . $new_path_data . '"';
968
  }
969
 
@@ -1120,6 +1120,13 @@ class WPvivid_RestoreDB
1120
  $wpvivid_plugin->restore_data->write_log('finish replace rows', 'notice');
1121
  }
1122
 
 
 
 
 
 
 
 
1123
  private function replace_row_data($old_data)
1124
  {
1125
  $unserialize_data = @unserialize($old_data);
963
  if(!empty($old_path)&&!empty($new_path))
964
  {
965
  $old_path_data= $row['path'];
966
+ $new_path_data=$this->str_replace_first($old_path,$new_path,$old_path_data);
967
  $update[] = '`path` = "' . $new_path_data . '"';
968
  }
969
 
1120
  $wpvivid_plugin->restore_data->write_log('finish replace rows', 'notice');
1121
  }
1122
 
1123
+ public function str_replace_first($from, $to, $content)
1124
+ {
1125
+ $from = '/'.preg_quote($from, '/').'/';
1126
+
1127
+ return preg_replace($from, $to, $content, 1);
1128
+ }
1129
+
1130
  private function replace_row_data($old_data)
1131
  {
1132
  $unserialize_data = @unserialize($old_data);
includes/class-wpvivid.php CHANGED
@@ -1197,7 +1197,7 @@ class WPvivid {
1197
  {
1198
  $backup=new WPvivid_Backup();
1199
 
1200
- $backup->clearcache();
1201
  $backup_ret=$backup->backup($task_id);
1202
  $backup->clearcache();
1203
 
@@ -2743,6 +2743,8 @@ class WPvivid {
2743
  if (session_id())
2744
  session_write_close();
2745
 
 
 
2746
  $size = filesize($path);
2747
  if (!headers_sent()) {
2748
  header('Content-Description: File Transfer');
1197
  {
1198
  $backup=new WPvivid_Backup();
1199
 
1200
+ //$backup->clearcache();
1201
  $backup_ret=$backup->backup($task_id);
1202
  $backup->clearcache();
1203
 
2743
  if (session_id())
2744
  session_write_close();
2745
 
2746
+ @ini_set( 'memory_limit', '1024M' );
2747
+
2748
  $size = filesize($path);
2749
  if (!headers_sent()) {
2750
  header('Content-Description: File Transfer');
includes/customclass/class-wpvivid-base-dropbox.php CHANGED
@@ -41,17 +41,25 @@ class Dropbox_Base{
41
  }
42
  else
43
  {
44
- $this->option['access_token']= $result['data']['access_token'];
45
- $this->option['expires_in'] = $result['data']['expires_in'];
46
- $this->option['created'] = time();
47
- WPvivid_Setting::update_remote_option($this->option['id'],$this->option);
48
- $this -> access_token = $this->option['access_token'];
49
- $this -> created = $this->option['created'];
50
- $this -> expires_in = $this->option['expires_in'];
51
- $this -> refresh_token = $this->option['refresh_token'];
 
 
 
52
 
53
- $ret['result']='success';
54
- return $ret;
 
 
 
 
 
55
  }
56
  }
57
  else
41
  }
42
  else
43
  {
44
+ $remote_options=WPvivid_Setting::get_remote_option($this->option['id']);
45
+ if($remote_options!==false)
46
+ {
47
+ $remote_options['access_token']= $result['data']['access_token'];
48
+ $remote_options['expires_in'] = $result['data']['expires_in'];
49
+ $remote_options['created'] = time();
50
+ WPvivid_Setting::update_remote_option($this->option['id'],$remote_options);
51
+ $this -> access_token = $this->option['access_token'];
52
+ $this -> created = $this->option['created'];
53
+ $this -> expires_in = $this->option['expires_in'];
54
+ $this -> refresh_token = $this->option['refresh_token'];
55
 
56
+ $ret['result']='success';
57
+ return $ret;
58
+ }
59
+ else
60
+ {
61
+ return array('result' => WPVIVID_FAILED,'error'=>'get refresh token failed');
62
+ }
63
  }
64
  }
65
  else
includes/customclass/class-wpvivid-one-drive.php CHANGED
@@ -81,16 +81,17 @@ class WPvivid_one_drive extends WPvivid_Remote
81
  return;
82
  }
83
 
84
- $_GET['name'] = sanitize_text_field($_GET['name']);
85
 
86
  $remoteslist = WPvivid_Setting::get_all_remote_options();
87
  foreach ($remoteslist as $key => $value) {
88
- if (isset($value['name']) && $value['name'] == $_GET['name']) {
89
  echo '<div class="notice notice-warning is-dismissible"><p>'.__('Warning: The alias already exists in storage list.', 'wpvivid-backuprestore').'</p></div>';
90
  return;
91
  }
92
  }
93
 
 
94
  $auth_id = uniqid('wpvivid-auth-');
95
 
96
  $url = 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize'
@@ -98,7 +99,7 @@ class WPvivid_one_drive extends WPvivid_Remote
98
  . '&scope=' . urlencode('offline_access files.readwrite')
99
  . '&response_type=code'
100
  . '&redirect_uri=' . urlencode('https://auth.wpvivid.com/onedrive_v2/')
101
- . '&state=' . urlencode(admin_url() . 'admin.php?page=WPvivid' . '&action=wpvivid_one_drive_finish_auth&name=' . $_GET['name'] . '&default=' . $_GET['default'].'&auth_id='.$auth_id)
102
  . '&display=popup'
103
  . '&locale=en';
104
  header('Location: ' . esc_url_raw($url));
@@ -174,11 +175,12 @@ class WPvivid_one_drive extends WPvivid_Remote
174
  return;
175
  }
176
 
177
- $_GET['name'] = sanitize_text_field($_GET['name']);
 
178
  $auth_id = uniqid('wpvivid-auth-');
179
  $remoteslist = WPvivid_Setting::get_all_remote_options();
180
  foreach ($remoteslist as $key => $value) {
181
- if (isset($value['name']) && $value['name'] == $_GET['name'] && $key != $_GET['id']) {
182
  echo '<div class="notice notice-warning is-dismissible"><p>'.__('Warning: The alias already exists in storage list.', 'wpvivid-backuprestore').'</p></div>';
183
  return;
184
  }
@@ -189,7 +191,7 @@ class WPvivid_one_drive extends WPvivid_Remote
189
  . '&scope=' . urlencode('offline_access files.readwrite')
190
  . '&response_type=code'
191
  . '&redirect_uri=' . urlencode('https://auth.wpvivid.com/onedrive_v2/')
192
- . '&state=' . urlencode(admin_url() . 'admin.php?page=WPvivid' . '&action=wpvivid_one_drive_update_finish_auth&name=' . $_GET['name'] . '&id=' . $_GET['id'].'&auth_id='.$auth_id)
193
  . '&display=popup'
194
  . '&locale=en';
195
  header('Location: ' . esc_url_raw($url));
81
  return;
82
  }
83
 
84
+ $alias_name = sanitize_text_field($_GET['name']);
85
 
86
  $remoteslist = WPvivid_Setting::get_all_remote_options();
87
  foreach ($remoteslist as $key => $value) {
88
+ if (isset($value['name']) && $value['name'] == $alias_name) {
89
  echo '<div class="notice notice-warning is-dismissible"><p>'.__('Warning: The alias already exists in storage list.', 'wpvivid-backuprestore').'</p></div>';
90
  return;
91
  }
92
  }
93
 
94
+ $default = sanitize_text_field($_GET['default']);
95
  $auth_id = uniqid('wpvivid-auth-');
96
 
97
  $url = 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize'
99
  . '&scope=' . urlencode('offline_access files.readwrite')
100
  . '&response_type=code'
101
  . '&redirect_uri=' . urlencode('https://auth.wpvivid.com/onedrive_v2/')
102
+ . '&state=' . urlencode(admin_url() . 'admin.php?page=WPvivid' . '&action=wpvivid_one_drive_finish_auth&name='.$alias_name.'&default='.$default.'&auth_id='.$auth_id)
103
  . '&display=popup'
104
  . '&locale=en';
105
  header('Location: ' . esc_url_raw($url));
175
  return;
176
  }
177
 
178
+ $alias_name = sanitize_text_field($_GET['name']);
179
+ $id = sanitize_text_field($_GET['id']);
180
  $auth_id = uniqid('wpvivid-auth-');
181
  $remoteslist = WPvivid_Setting::get_all_remote_options();
182
  foreach ($remoteslist as $key => $value) {
183
+ if (isset($value['name']) && $value['name'] == $alias_name && $key != $id) {
184
  echo '<div class="notice notice-warning is-dismissible"><p>'.__('Warning: The alias already exists in storage list.', 'wpvivid-backuprestore').'</p></div>';
185
  return;
186
  }
191
  . '&scope=' . urlencode('offline_access files.readwrite')
192
  . '&response_type=code'
193
  . '&redirect_uri=' . urlencode('https://auth.wpvivid.com/onedrive_v2/')
194
+ . '&state=' . urlencode(admin_url() . 'admin.php?page=WPvivid' . '&action=wpvivid_one_drive_update_finish_auth&name='.$alias_name.'&id='.$id.'&auth_id='.$auth_id)
195
  . '&display=popup'
196
  . '&locale=en';
197
  header('Location: ' . esc_url_raw($url));
includes/staging/class-wpvivid-fresh-install-create-ui-display.php CHANGED
@@ -70,7 +70,7 @@ class WPvivid_Fresh_Install_Create_UI_Display_Free
70
  $themes_all_check = '';
71
  }
72
 
73
- $themes_table .= '<p><input type="checkbox" option="create_wp" name="Themes" value="' . esc_attr($file) . '" '. esc_html($checked) .'>' . esc_html($file). '</p>';
74
  }
75
 
76
  if ($has_themes)
@@ -135,7 +135,7 @@ class WPvivid_Fresh_Install_Create_UI_Display_Free
135
  $plugins_all_check = '';
136
  }
137
 
138
- $plugins_table .= '<p><input type="checkbox" option="create_wp" name="Plugins" value="' . esc_attr($info['slug']) . '" '. esc_html($checked) .'>' . esc_html($info['Name']) . '</p>';
139
  }
140
 
141
  if ($has_plugins)
@@ -257,7 +257,7 @@ class WPvivid_Fresh_Install_Create_UI_Display_Free
257
  ?>
258
  <div class="postbox quickstaging">
259
  <div id="wpvivid_create_new_wp_content">
260
- <div class="wpvivid-one-coloum" style="border:1px solid #f1f1f1;padding-bottom:0em; margin-top:1em;margin-bottom:1em;">
261
  <div class="wpvivid-one-coloum" style="background:#f5f5f5;padding-top:0em;padding-bottom:0em;display: none;">
262
  <div class="wpvivid-two-col">
263
  <p><span class="dashicons dashicons-awards wpvivid-dashicons-blue"></span><span><strong>Site Name: </strong></span><span class="wpvivid-fresh-install-staging-site-name"><?php echo $default_fresh_install_site; ?></span></p>
@@ -277,6 +277,20 @@ class WPvivid_Fresh_Install_Create_UI_Display_Free
277
  <span class="dashicons dashicons-portfolio wpvivid-dashicons-orange"></span>
278
  <span>Directory to Install the Fresh Install</span>
279
  </h2>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  <p>
281
  <label>
282
  <input type="radio" option="create_wp" name="choose_create_staging_dir" value="0" checked="checked">
@@ -315,17 +329,17 @@ class WPvivid_Fresh_Install_Create_UI_Display_Free
315
  <p>
316
  <label>
317
  <input type="radio" option="create_wp" name="choose_create_staging_db" value="0" checked="">
318
- <span>Share the same database with your live site (recommended)</span>
319
  </label>
320
  </p>
321
  <p>
322
  <label>
323
  <input type="radio" option="create_wp" name="choose_create_staging_db" value="1">
324
- <span>Install the staging site to another database</span>
325
  </label>
326
  </p>
327
  <p></p>
328
- <div class="" id="wpvivid_fresh_install_additional_database_account">
329
  <form>
330
  <p><label><input type="text" option="create_wp" name="database-name" autocomplete="off" placeholder="DB Name" title="DB Name" readonly></label>
331
  <label><input type="text" option="create_wp" name="database-user" autocomplete="off" placeholder="DB Username" title="DB Username" readonly></label></p>
@@ -337,17 +351,28 @@ class WPvivid_Fresh_Install_Create_UI_Display_Free
337
  <div style="clear: both;"></div>
338
  </div>
339
  </div>
 
340
 
 
 
 
 
 
 
341
  <div>
342
- <div class="wpvivid-two-col">
343
- <h2 style="padding-left:0em;"><span class="dashicons dashicons-admin-page wpvivid-dashicons-orange"></span><span>Choose Themes to Be Copied to The Fresh Install</span></h2>
344
- <div style="padding:0em 1em 0 1em; height: 300px; overflow-y:auto;border:1px solid #f1f1f1;max-height: 468px">
 
 
345
  <?php echo $this->output_themes_plugins_info('theme'); ?>
346
  </div>
347
  </div>
348
- <div class="wpvivid-two-col" style="">
349
- <h2 style="padding-left:0em;"><span class="dashicons dashicons-admin-page wpvivid-dashicons-orange"></span><span>Choose Plugins to Be Copied to The Fresh Install</span></h2>
350
- <div style="padding:0em 1em 0 1em; height: 300px; overflow-y:auto;border:1px solid #f1f1f1;max-height: 468px">
 
 
351
  <?php echo $this->output_themes_plugins_info('plugin'); ?>
352
  </div>
353
  </div>
@@ -357,6 +382,9 @@ class WPvivid_Fresh_Install_Create_UI_Display_Free
357
  <div style="padding:1em 1em 0 0;">
358
  <input class="button-primary wpvivid_setting_general_save" id="wpvivid_create_new_wp" type="submit" value="Create Now"><span> Note: Please don't refresh the page while creating a fresh install.</span>
359
  </div>
 
 
 
360
  </div>
361
 
362
  <div id="wpvivid_create_new_wp_progress" style="display: none;">
@@ -379,11 +407,77 @@ class WPvivid_Fresh_Install_Create_UI_Display_Free
379
  var default_fresh_install_site = '<?php echo $default_fresh_install_site; ?>';
380
  var default_content_fresh_install_site = '<?php echo $default_content_fresh_install_site; ?>';
381
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
382
  jQuery('#wpvivid_create_new_wp_content').on("click", 'input:radio[name=choose_create_staging_db]', function(){
383
  if(jQuery(this).prop('checked')){
384
  var value = jQuery(this).val();
385
  if(value === '0'){
386
- //jQuery('#wpvivid_fresh_install_additional_database_account').hide();
387
  jQuery('#wpvivid_fresh_install_additional_database_account').find('input[name=database-name]').attr('readonly', true);
388
  jQuery('#wpvivid_fresh_install_additional_database_account').find('input[name=database-user]').attr('readonly', true);
389
  jQuery('#wpvivid_fresh_install_additional_database_account').find('input[name=database-pass]').attr('readonly', true);
@@ -391,7 +485,7 @@ class WPvivid_Fresh_Install_Create_UI_Display_Free
391
  jQuery('#wpvivid_create_new_wp_content').find('.wpvivid-staging-additional-database-name-display').html('<?php echo DB_NAME; ?>');
392
  }
393
  else{
394
- //jQuery('#wpvivid_fresh_install_additional_database_account').show();
395
  jQuery('#wpvivid_fresh_install_additional_database_account').find('input[name=database-name]').attr('readonly', false);
396
  jQuery('#wpvivid_fresh_install_additional_database_account').find('input[name=database-user]').attr('readonly', false);
397
  jQuery('#wpvivid_fresh_install_additional_database_account').find('input[name=database-pass]').attr('readonly', false);
@@ -519,12 +613,53 @@ class WPvivid_Fresh_Install_Create_UI_Display_Free
519
  return;
520
  }
521
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
522
  var ajax_data =
523
  {
524
  'action': 'wpvividstg_check_staging_dir_free',
525
  'root_dir':staging_root_dir,
526
  'path': path,
527
  'table_prefix': table_prefix,
 
528
  };
529
  wpvivid_post_request(ajax_data, function (data)
530
  {
@@ -550,45 +685,6 @@ class WPvivid_Fresh_Install_Create_UI_Display_Free
550
  }
551
  else
552
  {
553
- var additional_database_json = {};
554
-
555
- var additional_database_option = '0';
556
- jQuery('input[option=create_wp][name=choose_create_staging_db]').each(function ()
557
- {
558
- if (jQuery(this).prop('checked'))
559
- {
560
- additional_database_option = jQuery(this).val();
561
- }
562
- });
563
-
564
- if (additional_database_option === '1')
565
- {
566
- additional_database_json['additional_database_check'] = '1';
567
- additional_database_json['additional_database_info'] = {};
568
- additional_database_json['additional_database_info']['db_user'] = jQuery('input[option=create_wp][name=database-user]').val();
569
- additional_database_json['additional_database_info']['db_pass'] = jQuery('input[option=create_wp][name=database-pass]').val();
570
- additional_database_json['additional_database_info']['db_host'] = jQuery('input[option=create_wp][name=database-host]').val();
571
- additional_database_json['additional_database_info']['db_name'] = jQuery('input[option=create_wp][name=database-name]').val();
572
- if (additional_database_json['additional_database_info']['db_name'] === '')
573
- {
574
- alert('Database Name is required.');
575
- return;
576
- }
577
- if (additional_database_json['additional_database_info']['db_user'] === '')
578
- {
579
- alert('Database User is required.');
580
- return;
581
- }
582
- if (additional_database_json['additional_database_info']['db_host'] === '')
583
- {
584
- alert('Database Host is required.');
585
- return;
586
- }
587
- }
588
- else {
589
- additional_database_json['additional_database_check'] = '0';
590
- }
591
- var additional_database_info=JSON.stringify(additional_database_json);
592
  var custom_dir_json = wpvivid_get_custom_create_new_wp_option();
593
  var custom_dir = JSON.stringify(custom_dir_json);
594
 
70
  $themes_all_check = '';
71
  }
72
 
73
+ $themes_table .= '<div class="wpvivid-text-line"><input type="checkbox" option="create_wp" name="Themes" value="' . esc_attr($file) . '" '. esc_html($checked) .'>' . esc_html($file) . '</div>';
74
  }
75
 
76
  if ($has_themes)
135
  $plugins_all_check = '';
136
  }
137
 
138
+ $plugins_table .= '<div class="wpvivid-text-line"><input type="checkbox" option="create_wp" name="Plugins" value="' . esc_attr($info['slug']) . '" '. esc_html($checked) .'>' . esc_html($info['Name']) . '</div>';
139
  }
140
 
141
  if ($has_plugins)
257
  ?>
258
  <div class="postbox quickstaging">
259
  <div id="wpvivid_create_new_wp_content">
260
+ <div class="wpvivid-one-coloum" style="border:1px solid #f1f1f1;padding-bottom:0em; margin-top:0em;margin-bottom:1em;">
261
  <div class="wpvivid-one-coloum" style="background:#f5f5f5;padding-top:0em;padding-bottom:0em;display: none;">
262
  <div class="wpvivid-two-col">
263
  <p><span class="dashicons dashicons-awards wpvivid-dashicons-blue"></span><span><strong>Site Name: </strong></span><span class="wpvivid-fresh-install-staging-site-name"><?php echo $default_fresh_install_site; ?></span></p>
277
  <span class="dashicons dashicons-portfolio wpvivid-dashicons-orange"></span>
278
  <span>Directory to Install the Fresh Install</span>
279
  </h2>
280
+ <?php
281
+ $server_type = $_SERVER['SERVER_SOFTWARE'];
282
+ if(preg_match('/nginx/i', $server_type))
283
+ {
284
+ ?>
285
+ <div style="border:1px solid #ccc; padding:0 1em;margin-top:1em; border-radius:0.5em;">
286
+ <p>
287
+ <span>We detected that your web server is Nginx, please add specific rewrite rules to the Nginx config file for the staging site working properly. <a href="https://docs.wpvivid.com/add-rewrite-rules-to-nginx.html">How to</a></span>
288
+ <p>
289
+ <div style="clear:both;"></div>
290
+ </div>
291
+ <?php
292
+ }
293
+ ?>
294
  <p>
295
  <label>
296
  <input type="radio" option="create_wp" name="choose_create_staging_dir" value="0" checked="checked">
329
  <p>
330
  <label>
331
  <input type="radio" option="create_wp" name="choose_create_staging_db" value="0" checked="">
332
+ <span>Install the staging site to the live site's database (recommended)</span>
333
  </label>
334
  </p>
335
  <p>
336
  <label>
337
  <input type="radio" option="create_wp" name="choose_create_staging_db" value="1">
338
+ <span>Install the staging site to a separate database</span>
339
  </label>
340
  </p>
341
  <p></p>
342
+ <div class="" id="wpvivid_fresh_install_additional_database_account" style="display: none;">
343
  <form>
344
  <p><label><input type="text" option="create_wp" name="database-name" autocomplete="off" placeholder="DB Name" title="DB Name" readonly></label>
345
  <label><input type="text" option="create_wp" name="database-user" autocomplete="off" placeholder="DB Username" title="DB Username" readonly></label></p>
351
  <div style="clear: both;"></div>
352
  </div>
353
  </div>
354
+ <div style="clear: both;"></div>
355
 
356
+ <div style="background:#f1f1f1;">
357
+ <h2 style="padding-left:1em;padding-top:0.6em;">
358
+ <span class="dashicons dashicons-grid-view wpvivid-dashicons-blue"></span>
359
+ <span>Themes And Plugins</span>
360
+ </h2>
361
+ </div>
362
  <div>
363
+ <div class="wpvivid-two-col" style="padding:0.2em;">
364
+ <div style="padding:0 0 0.5em 0.2em;">
365
+ <span><span>Check All </span><input type="checkbox" name="wpvivid_check_all_fresh_install_themes"></span>
366
+ </div>
367
+ <div style="padding:0.3em;height:300px;overflow-y:auto; border:1px solid #ccc;">
368
  <?php echo $this->output_themes_plugins_info('theme'); ?>
369
  </div>
370
  </div>
371
+ <div class="wpvivid-two-col" style="padding:0.2em;">
372
+ <div style="padding:0 0 0.5em 0.2em;">
373
+ <span><span>Check All </span><input type="checkbox" name="wpvivid_check_all_fresh_install_plugins"></span>
374
+ </div>
375
+ <div style="padding:0.3em;height:300px;overflow-y:auto;border:1px solid #ccc;">
376
  <?php echo $this->output_themes_plugins_info('plugin'); ?>
377
  </div>
378
  </div>
382
  <div style="padding:1em 1em 0 0;">
383
  <input class="button-primary wpvivid_setting_general_save" id="wpvivid_create_new_wp" type="submit" value="Create Now"><span> Note: Please don't refresh the page while creating a fresh install.</span>
384
  </div>
385
+ <div style="padding:1em 1em 0 0;">
386
+ <span>Tips: Please temporarily deactivate all cache, firewall and redirect plugins before creating a staging site to rule out possibilities of unknown failures.</span>
387
+ </div>
388
  </div>
389
 
390
  <div id="wpvivid_create_new_wp_progress" style="display: none;">
407
  var default_fresh_install_site = '<?php echo $default_fresh_install_site; ?>';
408
  var default_content_fresh_install_site = '<?php echo $default_content_fresh_install_site; ?>';
409
 
410
+ jQuery('input:checkbox[name=wpvivid_check_all_fresh_install_themes]').on("click", function(){
411
+ if(jQuery(this).prop('checked'))
412
+ {
413
+ jQuery('input:checkbox[option=create_wp][name=Themes]').prop('checked', true);
414
+ }
415
+ else
416
+ {
417
+ jQuery('input:checkbox[option=create_wp][name=Themes]').prop('checked', false);
418
+ }
419
+ });
420
+
421
+ jQuery('input:checkbox[name=wpvivid_check_all_fresh_install_plugins]').on("click", function(){
422
+ if(jQuery(this).prop('checked'))
423
+ {
424
+ jQuery('input:checkbox[option=create_wp][name=Plugins]').prop('checked', true);
425
+ }
426
+ else
427
+ {
428
+ jQuery('input:checkbox[option=create_wp][name=Plugins]').prop('checked', false);
429
+ }
430
+ });
431
+
432
+ jQuery('input:checkbox[option=create_wp][name=Themes]').on("click", function(){
433
+ if(jQuery(this).prop('checked'))
434
+ {
435
+ var all_check = true;
436
+ jQuery('input:checkbox[option=create_wp][name=Themes]').each(function(){
437
+ if(!jQuery(this).prop('checked')){
438
+ all_check = false;
439
+ }
440
+ });
441
+ if(all_check) {
442
+ jQuery('input:checkbox[name=wpvivid_check_all_fresh_install_themes]').prop('checked', true);
443
+ }
444
+ else {
445
+ jQuery('input:checkbox[name=wpvivid_check_all_fresh_install_themes]').prop('checked', false);
446
+ }
447
+ }
448
+ else
449
+ {
450
+ jQuery('input:checkbox[name=wpvivid_check_all_fresh_install_themes]').prop('checked', false);
451
+ }
452
+ });
453
+
454
+ jQuery('input:checkbox[option=create_wp][name=Plugins]').on("click", function(){
455
+ if(jQuery(this).prop('checked'))
456
+ {
457
+ var all_check = true;
458
+ jQuery('input:checkbox[option=create_wp][name=Plugins]').each(function(){
459
+ if(!jQuery(this).prop('checked')){
460
+ all_check = false;
461
+ }
462
+ });
463
+ if(all_check) {
464
+ jQuery('input:checkbox[name=wpvivid_check_all_fresh_install_plugins]').prop('checked', true);
465
+ }
466
+ else {
467
+ jQuery('input:checkbox[name=wpvivid_check_all_fresh_install_plugins]').prop('checked', false);
468
+ }
469
+ }
470
+ else
471
+ {
472
+ jQuery('input:checkbox[name=wpvivid_check_all_fresh_install_plugins]').prop('checked', false);
473
+ }
474
+ });
475
+
476
  jQuery('#wpvivid_create_new_wp_content').on("click", 'input:radio[name=choose_create_staging_db]', function(){
477
  if(jQuery(this).prop('checked')){
478
  var value = jQuery(this).val();
479
  if(value === '0'){
480
+ jQuery('#wpvivid_fresh_install_additional_database_account').hide();
481
  jQuery('#wpvivid_fresh_install_additional_database_account').find('input[name=database-name]').attr('readonly', true);
482
  jQuery('#wpvivid_fresh_install_additional_database_account').find('input[name=database-user]').attr('readonly', true);
483
  jQuery('#wpvivid_fresh_install_additional_database_account').find('input[name=database-pass]').attr('readonly', true);
485
  jQuery('#wpvivid_create_new_wp_content').find('.wpvivid-staging-additional-database-name-display').html('<?php echo DB_NAME; ?>');
486
  }
487
  else{
488
+ jQuery('#wpvivid_fresh_install_additional_database_account').show();
489
  jQuery('#wpvivid_fresh_install_additional_database_account').find('input[name=database-name]').attr('readonly', false);
490
  jQuery('#wpvivid_fresh_install_additional_database_account').find('input[name=database-user]').attr('readonly', false);
491
  jQuery('#wpvivid_fresh_install_additional_database_account').find('input[name=database-pass]').attr('readonly', false);
613
  return;
614
  }
615
 
616
+ var additional_database_json = {};
617
+
618
+ var additional_database_option = '0';
619
+ jQuery('input[option=create_wp][name=choose_create_staging_db]').each(function ()
620
+ {
621
+ if (jQuery(this).prop('checked'))
622
+ {
623
+ additional_database_option = jQuery(this).val();
624
+ }
625
+ });
626
+
627
+ if (additional_database_option === '1')
628
+ {
629
+ additional_database_json['additional_database_check'] = '1';
630
+ additional_database_json['additional_database_info'] = {};
631
+ additional_database_json['additional_database_info']['db_user'] = jQuery('input[option=create_wp][name=database-user]').val();
632
+ additional_database_json['additional_database_info']['db_pass'] = jQuery('input[option=create_wp][name=database-pass]').val();
633
+ additional_database_json['additional_database_info']['db_host'] = jQuery('input[option=create_wp][name=database-host]').val();
634
+ additional_database_json['additional_database_info']['db_name'] = jQuery('input[option=create_wp][name=database-name]').val();
635
+ if (additional_database_json['additional_database_info']['db_name'] === '')
636
+ {
637
+ alert('Database Name is required.');
638
+ return;
639
+ }
640
+ if (additional_database_json['additional_database_info']['db_user'] === '')
641
+ {
642
+ alert('Database User is required.');
643
+ return;
644
+ }
645
+ if (additional_database_json['additional_database_info']['db_host'] === '')
646
+ {
647
+ alert('Database Host is required.');
648
+ return;
649
+ }
650
+ }
651
+ else {
652
+ additional_database_json['additional_database_check'] = '0';
653
+ }
654
+ var additional_database_info=JSON.stringify(additional_database_json);
655
+
656
  var ajax_data =
657
  {
658
  'action': 'wpvividstg_check_staging_dir_free',
659
  'root_dir':staging_root_dir,
660
  'path': path,
661
  'table_prefix': table_prefix,
662
+ 'additional_db': additional_database_info
663
  };
664
  wpvivid_post_request(ajax_data, function (data)
665
  {
685
  }
686
  else
687
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
688
  var custom_dir_json = wpvivid_get_custom_create_new_wp_option();
689
  var custom_dir = JSON.stringify(custom_dir_json);
690
 
includes/staging/class-wpvivid-staging-create-ui-display.php CHANGED
@@ -84,7 +84,7 @@ class WPvivid_Staging_Create_UI_Display_Free
84
  }
85
  ?>
86
  <div class="postbox quickstaging">
87
- <div class="wpvivid-one-coloum" id="wpvivid_create_staging_step1" style="border:1px solid #f1f1f1;padding-bottom:0em; margin-top:1em;margin-bottom:1em;">
88
  <div class="wpvivid-one-coloum" style="background:#f5f5f5;padding-top:0em;padding-bottom:0em;display: none;">
89
  <div class="wpvivid-two-col">
90
  <p><span class="dashicons dashicons-awards wpvivid-dashicons-blue"></span><span><strong>Site Name: </strong></span><span class="wpvivid-staging-site-name"><?php echo $default_staging_site; ?></span></p>
@@ -104,6 +104,20 @@ class WPvivid_Staging_Create_UI_Display_Free
104
  <span class="dashicons dashicons-portfolio wpvivid-dashicons-orange"></span>
105
  <span>Directory to Install the Staging Site</span>
106
  </h2>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  <p>
108
  <label>
109
  <input type="radio" name="choose_staging_dir" value="0" checked="checked">
@@ -142,17 +156,17 @@ class WPvivid_Staging_Create_UI_Display_Free
142
  <p>
143
  <label>
144
  <input type="radio" name="choose_staging_db" value="0" checked="">
145
- <span>Share the same database with your live site (recommended)</span>
146
  </label>
147
  </p>
148
  <p>
149
  <label>
150
  <input type="radio" name="choose_staging_db" value="1">
151
- <span>Install the staging site to another database</span>
152
  </label>
153
  </p>
154
  <p></p>
155
- <div class="" id="wpvivid_additional_database_account">
156
  <form>
157
  <p><label><input type="text" class="wpvivid-additional-database-name" autocomplete="off" placeholder="DB Name" title="DB Name" readonly></label>
158
  <label><input type="text" class="wpvivid-additional-database-user" autocomplete="off" placeholder="DB Username" title="DB Username" readonly></label></p>
@@ -191,6 +205,9 @@ class WPvivid_Staging_Create_UI_Display_Free
191
  <div id="wpvivid_create_staging_content">
192
  <input class="button-primary wpvivid_setting_general_save" id="wpvivid_create_staging" type="submit" value="Create Now" /><span> Note: Please don't refresh the page while creating a staging site.</span>
193
  </div>
 
 
 
194
  </div>
195
 
196
  <div id="wpvivid_create_staging_step2" style="display: none;">
@@ -255,7 +272,7 @@ class WPvivid_Staging_Create_UI_Display_Free
255
  if(jQuery(this).prop('checked')){
256
  var value = jQuery(this).val();
257
  if(value === '0'){
258
- //jQuery('#wpvivid_additional_database_account').hide();
259
  jQuery('#wpvivid_additional_database_account').find('.wpvivid-additional-database-name').attr('readonly', true);
260
  jQuery('#wpvivid_additional_database_account').find('.wpvivid-additional-database-user').attr('readonly', true);
261
  jQuery('#wpvivid_additional_database_account').find('.wpvivid-additional-database-pass').attr('readonly', true);
@@ -263,7 +280,7 @@ class WPvivid_Staging_Create_UI_Display_Free
263
  jQuery('.wpvivid-staging-additional-database-name-display').html('<?php echo DB_NAME; ?>');
264
  }
265
  else{
266
- //jQuery('#wpvivid_additional_database_account').show();
267
  jQuery('#wpvivid_additional_database_account').find('.wpvivid-additional-database-name').attr('readonly', false);
268
  jQuery('#wpvivid_additional_database_account').find('.wpvivid-additional-database-user').attr('readonly', false);
269
  jQuery('#wpvivid_additional_database_account').find('.wpvivid-additional-database-pass').attr('readonly', false);
@@ -609,6 +626,7 @@ class WPvivid_Staging_Create_UI_Display_Free
609
  'root_dir':staging_root_dir,
610
  'path': path,
611
  'table_prefix': table_prefix,
 
612
  };
613
  wpvivid_post_request(ajax_data, function (data)
614
  {
84
  }
85
  ?>
86
  <div class="postbox quickstaging">
87
+ <div class="wpvivid-one-coloum" id="wpvivid_create_staging_step1" style="border:1px solid #f1f1f1;padding-bottom:0em; margin-top:0em;margin-bottom:1em;">
88
  <div class="wpvivid-one-coloum" style="background:#f5f5f5;padding-top:0em;padding-bottom:0em;display: none;">
89
  <div class="wpvivid-two-col">
90
  <p><span class="dashicons dashicons-awards wpvivid-dashicons-blue"></span><span><strong>Site Name: </strong></span><span class="wpvivid-staging-site-name"><?php echo $default_staging_site; ?></span></p>
104
  <span class="dashicons dashicons-portfolio wpvivid-dashicons-orange"></span>
105
  <span>Directory to Install the Staging Site</span>
106
  </h2>
107
+ <?php
108
+ $server_type = $_SERVER['SERVER_SOFTWARE'];
109
+ if(preg_match('/nginx/i', $server_type))
110
+ {
111
+ ?>
112
+ <div style="border:1px solid #ccc; padding:0 1em;margin-top:1em; border-radius:0.5em;">
113
+ <p>
114
+ <span>We detected that your web server is Nginx, please add specific rewrite rules to the Nginx config file for the staging site working properly. <a href="https://docs.wpvivid.com/add-rewrite-rules-to-nginx.html">How to</a></span>
115
+ <p>
116
+ <div style="clear:both;"></div>
117
+ </div>
118
+ <?php
119
+ }
120
+ ?>
121
  <p>
122
  <label>
123
  <input type="radio" name="choose_staging_dir" value="0" checked="checked">
156
  <p>
157
  <label>
158
  <input type="radio" name="choose_staging_db" value="0" checked="">
159
+ <span>Install the staging site to the live site's database (recommended)</span>
160
  </label>
161
  </p>
162
  <p>
163
  <label>
164
  <input type="radio" name="choose_staging_db" value="1">
165
+ <span>Install the staging site to a separate database</span>
166
  </label>
167
  </p>
168
  <p></p>
169
+ <div class="" id="wpvivid_additional_database_account" style="display: none;">
170
  <form>
171
  <p><label><input type="text" class="wpvivid-additional-database-name" autocomplete="off" placeholder="DB Name" title="DB Name" readonly></label>
172
  <label><input type="text" class="wpvivid-additional-database-user" autocomplete="off" placeholder="DB Username" title="DB Username" readonly></label></p>
205
  <div id="wpvivid_create_staging_content">
206
  <input class="button-primary wpvivid_setting_general_save" id="wpvivid_create_staging" type="submit" value="Create Now" /><span> Note: Please don't refresh the page while creating a staging site.</span>
207
  </div>
208
+ <div style="padding:1em 1em 0 0;">
209
+ <span>Tips: Please temporarily deactivate all cache, firewall and redirect plugins before creating a staging site to rule out possibilities of unknown failures.</span>
210
+ </div>
211
  </div>
212
 
213
  <div id="wpvivid_create_staging_step2" style="display: none;">
272
  if(jQuery(this).prop('checked')){
273
  var value = jQuery(this).val();
274
  if(value === '0'){
275
+ jQuery('#wpvivid_additional_database_account').hide();
276
  jQuery('#wpvivid_additional_database_account').find('.wpvivid-additional-database-name').attr('readonly', true);
277
  jQuery('#wpvivid_additional_database_account').find('.wpvivid-additional-database-user').attr('readonly', true);
278
  jQuery('#wpvivid_additional_database_account').find('.wpvivid-additional-database-pass').attr('readonly', true);
280
  jQuery('.wpvivid-staging-additional-database-name-display').html('<?php echo DB_NAME; ?>');
281
  }
282
  else{
283
+ jQuery('#wpvivid_additional_database_account').show();
284
  jQuery('#wpvivid_additional_database_account').find('.wpvivid-additional-database-name').attr('readonly', false);
285
  jQuery('#wpvivid_additional_database_account').find('.wpvivid-additional-database-user').attr('readonly', false);
286
  jQuery('#wpvivid_additional_database_account').find('.wpvivid-additional-database-pass').attr('readonly', false);
626
  'root_dir':staging_root_dir,
627
  'path': path,
628
  'table_prefix': table_prefix,
629
+ 'additional_db': additional_database_info
630
  };
631
  wpvivid_post_request(ajax_data, function (data)
632
  {
includes/staging/class-wpvivid-staging.php CHANGED
@@ -1759,15 +1759,49 @@ class WPvivid_Staging_Free
1759
  }
1760
  }
1761
 
1762
- global $wpdb;
1763
- $sql = $wpdb->prepare("SHOW TABLES LIKE %s;", $wpdb->esc_like($table_prefix) . '%');
1764
- $result = $wpdb->get_results($sql, OBJECT_K);
1765
- if (!empty($result))
1766
  {
1767
- $ret['result'] = 'failed';
1768
- $ret['error'] = 'The table prefix already exists.';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1769
  }
1770
-
1771
  echo json_encode($ret);
1772
  }
1773
  catch (Exception $error)
@@ -2394,11 +2428,16 @@ class WPvivid_Staging_Free
2394
  $db_connect['new_prefix'] = $table_prefix;
2395
  if(isset($additional_db_options['additional_database_check']) && $additional_db_options['additional_database_check'] == '1')
2396
  {
2397
- $option['data']['db_connect']['des_use_additional_db'] = true;
2398
  $option['data']['db_connect']['des_dbuser'] = $additional_db_options['additional_database_info']['db_user'];
2399
  $option['data']['db_connect']['des_dbpassword'] = $additional_db_options['additional_database_info']['db_pass'];
2400
  $option['data']['db_connect']['des_dbname'] = $additional_db_options['additional_database_info']['db_name'];
2401
- $option['data']['db_connect']['des_dbhost'] = $additional_db_options['additional_database_info']['db_host'];
 
 
 
 
 
2402
  }
2403
 
2404
  return $db_connect;
1759
  }
1760
  }
1761
 
1762
+ if(isset($_POST['additional_db']))
 
 
 
1763
  {
1764
+ $additional_db_json = $_POST['additional_db'];
1765
+ $additional_db_json = stripslashes($additional_db_json);
1766
+ $additional_db_options = json_decode($additional_db_json, true);
1767
+ if($additional_db_options['additional_database_check'] === '1')
1768
+ {
1769
+ $db_user = sanitize_text_field($additional_db_options['additional_database_info']['db_user']);
1770
+ $db_pass = sanitize_text_field($additional_db_options['additional_database_info']['db_pass']);
1771
+ $db_host = sanitize_text_field($additional_db_options['additional_database_info']['db_host']);
1772
+ $db_name = sanitize_text_field($additional_db_options['additional_database_info']['db_name']);
1773
+ $db = new wpdb($db_user, $db_pass, $db_name, $db_host);
1774
+ $sql = $db->prepare("SHOW TABLES LIKE %s;", $db->esc_like($table_prefix) . '%');
1775
+ $result = $db->get_results($sql, OBJECT_K);
1776
+ if (!empty($result))
1777
+ {
1778
+ $ret['result'] = 'failed';
1779
+ $ret['error'] = 'The table prefix already exists.';
1780
+ }
1781
+ }
1782
+ else
1783
+ {
1784
+ global $wpdb;
1785
+ $sql = $wpdb->prepare("SHOW TABLES LIKE %s;", $wpdb->esc_like($table_prefix) . '%');
1786
+ $result = $wpdb->get_results($sql, OBJECT_K);
1787
+ if (!empty($result))
1788
+ {
1789
+ $ret['result'] = 'failed';
1790
+ $ret['error'] = 'The table prefix already exists.';
1791
+ }
1792
+ }
1793
+ }
1794
+ else
1795
+ {
1796
+ global $wpdb;
1797
+ $sql = $wpdb->prepare("SHOW TABLES LIKE %s;", $wpdb->esc_like($table_prefix) . '%');
1798
+ $result = $wpdb->get_results($sql, OBJECT_K);
1799
+ if (!empty($result))
1800
+ {
1801
+ $ret['result'] = 'failed';
1802
+ $ret['error'] = 'The table prefix already exists.';
1803
+ }
1804
  }
 
1805
  echo json_encode($ret);
1806
  }
1807
  catch (Exception $error)
2428
  $db_connect['new_prefix'] = $table_prefix;
2429
  if(isset($additional_db_options['additional_database_check']) && $additional_db_options['additional_database_check'] == '1')
2430
  {
2431
+ /*$option['data']['db_connect']['des_use_additional_db'] = true;
2432
  $option['data']['db_connect']['des_dbuser'] = $additional_db_options['additional_database_info']['db_user'];
2433
  $option['data']['db_connect']['des_dbpassword'] = $additional_db_options['additional_database_info']['db_pass'];
2434
  $option['data']['db_connect']['des_dbname'] = $additional_db_options['additional_database_info']['db_name'];
2435
+ $option['data']['db_connect']['des_dbhost'] = $additional_db_options['additional_database_info']['db_host'];*/
2436
+ $db_connect['des_use_additional_db'] = true;
2437
+ $db_connect['des_dbuser'] = $additional_db_options['additional_database_info']['db_user'];
2438
+ $db_connect['des_dbpassword'] = $additional_db_options['additional_database_info']['db_pass'];
2439
+ $db_connect['des_dbname'] = $additional_db_options['additional_database_info']['db_name'];
2440
+ $db_connect['des_dbhost'] = $additional_db_options['additional_database_info']['db_host'];
2441
  }
2442
 
2443
  return $db_connect;
includes/upload-cleaner/class-wpvivid-uploads-scanner.php CHANGED
@@ -454,7 +454,10 @@ class WPvivid_Uploads_Scanner
454
  $html = get_post_field( 'post_content', $post );
455
 
456
  $html = mb_convert_encoding( $html, 'HTML-ENTITIES', 'UTF-8' );
 
457
  $html = do_shortcode( $html );
 
 
458
  $html = wp_filter_content_tags( $html );
459
 
460
  if ( !class_exists("DOMDocument") )
@@ -881,6 +884,18 @@ class WPvivid_Uploads_Scanner
881
  }
882
  }
883
  }
 
 
 
 
 
 
 
 
 
 
 
 
884
  }
885
 
886
  if(!empty($element_data['elements']))
@@ -1053,7 +1068,14 @@ class WPvivid_Uploads_Scanner
1053
 
1054
  $exclude_regex=apply_filters('wpvivid_uc_scan_exclude_files_regex',array());
1055
 
1056
- $this->scan_list_uploaded_files($files, $root_path.DIRECTORY_SEPARATOR.$folder,$root_path,$regex,$exclude_regex);
 
 
 
 
 
 
 
1057
 
1058
  return $files;
1059
  }
@@ -1162,6 +1184,36 @@ class WPvivid_Uploads_Scanner
1162
  return $folders;
1163
  }
1164
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1165
  function scan_list_uploaded_files( &$files,$path,$root,$regex=array(),$exclude_regex=array())
1166
  {
1167
  $count = 0;
454
  $html = get_post_field( 'post_content', $post );
455
 
456
  $html = mb_convert_encoding( $html, 'HTML-ENTITIES', 'UTF-8' );
457
+ ob_start();
458
  $html = do_shortcode( $html );
459
+ ob_clean();
460
+ ob_end_flush();
461
  $html = wp_filter_content_tags( $html );
462
 
463
  if ( !class_exists("DOMDocument") )
884
  }
885
  }
886
  }
887
+
888
+ if(isset($settings['background_image']))
889
+ {
890
+ if(isset($settings['background_image']['id']))
891
+ {
892
+ if(!in_array($settings['background_image']['id'],$attachment_added_ids))
893
+ {
894
+ $element_image[]=$settings['background_image']['id'];
895
+ $attachment_added_ids[]=$settings['background_image']['id'];
896
+ }
897
+ }
898
+ }
899
  }
900
 
901
  if(!empty($element_data['elements']))
1068
 
1069
  $exclude_regex=apply_filters('wpvivid_uc_scan_exclude_files_regex',array());
1070
 
1071
+ if($folder === '.')
1072
+ {
1073
+ $this->scan_root_uploaded_files($files, $root_path.DIRECTORY_SEPARATOR.$folder,$root_path,$regex,$exclude_regex);
1074
+ }
1075
+ else
1076
+ {
1077
+ $this->scan_list_uploaded_files($files, $root_path.DIRECTORY_SEPARATOR.$folder,$root_path,$regex,$exclude_regex);
1078
+ }
1079
 
1080
  return $files;
1081
  }
1184
  return $folders;
1185
  }
1186
 
1187
+ function scan_root_uploaded_files( &$files,$path,$root,$regex=array(),$exclude_regex=array())
1188
+ {
1189
+ $count = 0;
1190
+ if(is_dir($path))
1191
+ {
1192
+ $handler = opendir($path);
1193
+ if($handler!==false)
1194
+ {
1195
+ while (($filename = readdir($handler)) !== false)
1196
+ {
1197
+ if ($filename != "." && $filename != "..")
1198
+ {
1199
+ $count++;
1200
+ if ($this->regex_match($exclude_regex, $path . DIRECTORY_SEPARATOR . $filename, 0))
1201
+ {
1202
+ if($this->regex_match($regex, $filename, 1))
1203
+ {
1204
+ $result['files'][] = $filename;
1205
+ $files[] = str_replace($path . DIRECTORY_SEPARATOR,'',$path . DIRECTORY_SEPARATOR . $filename);
1206
+ }
1207
+ }
1208
+ }
1209
+ }
1210
+ if($handler)
1211
+ @closedir($handler);
1212
+ }
1213
+ }
1214
+ return $files;
1215
+ }
1216
+
1217
  function scan_list_uploaded_files( &$files,$path,$root,$regex=array(),$exclude_regex=array())
1218
  {
1219
  $count = 0;
includes/zip/class-wpvivid-pclzip.php CHANGED
@@ -330,7 +330,7 @@
330
  $v_options[WPVIVID_PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
331
  }
332
  else if ($v_size > 2) {
333
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER,
334
  "Invalid number / type of arguments");
335
  return 0;
336
  }
@@ -369,7 +369,7 @@
369
 
370
  // ----- Invalid variable type for $p_filelist
371
  else {
372
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
373
  return 0;
374
  }
375
 
@@ -516,7 +516,7 @@
516
  }
517
  else if ($v_size > 2) {
518
  // ----- Error log
519
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
520
 
521
  // ----- Return
522
  return 0;
@@ -556,7 +556,7 @@
556
 
557
  // ----- Invalid variable type for $p_filelist
558
  else {
559
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
560
  return 0;
561
  }
562
 
@@ -793,7 +793,7 @@
793
  }
794
  else if ($v_size > 2) {
795
  // ----- Error log
796
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
797
 
798
  // ----- Return
799
  return 0;
@@ -954,7 +954,7 @@
954
  }
955
  else if ($v_size > 2) {
956
  // ----- Error log
957
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
958
 
959
  // ----- Return
960
  return 0;
@@ -1120,7 +1120,7 @@
1120
  $this->privSwapBackMagicQuotes();
1121
 
1122
  // ----- Error log
1123
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
1124
 
1125
  // ----- Return
1126
  return 0;
@@ -1186,7 +1186,7 @@
1186
  // TBC : Should also check the archive format
1187
  if (!is_file($p_archive)) {
1188
  // ----- Error log
1189
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
1190
  $v_result = WPVIVID_PCLZIP_ERR_MISSING_FILE;
1191
  }
1192
  else {
@@ -1199,7 +1199,7 @@
1199
  else
1200
  {
1201
  // ----- Error log
1202
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1203
  $v_result = WPVIVID_PCLZIP_ERR_INVALID_PARAMETER;
1204
  }
1205
 
@@ -1247,7 +1247,7 @@
1247
  {
1248
 
1249
  // ----- Create a temporary archive
1250
- $v_object_archive = new PclZip($p_archive_to_add);
1251
 
1252
  // ----- Merge the archive
1253
  $v_result = $this->privMerge($v_object_archive);
@@ -1257,7 +1257,7 @@
1257
  else
1258
  {
1259
  // ----- Error log
1260
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1261
  $v_result = WPVIVID_PCLZIP_ERR_INVALID_PARAMETER;
1262
  }
1263
 
@@ -1387,14 +1387,14 @@
1387
  // ----- Look if the file exits
1388
  if (!is_file($this->zipname)) {
1389
  // ----- Error log
1390
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
1391
  return(false);
1392
  }
1393
 
1394
  // ----- Check that the file is readable
1395
  if (!is_readable($this->zipname)) {
1396
  // ----- Error log
1397
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
1398
  return(false);
1399
  }
1400
 
@@ -1438,10 +1438,10 @@
1438
  // ----- Check if the option is supported
1439
  if (!isset($v_requested_options[$p_options_list[$i]])) {
1440
  // ----- Error log
1441
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
1442
 
1443
  // ----- Return
1444
- return PclZip::errorCode();
1445
  }
1446
 
1447
  // ----- Look for next option
@@ -1453,10 +1453,10 @@
1453
  // ----- Check the number of parameters
1454
  if (($i+1) >= $p_size) {
1455
  // ----- Error log
1456
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1457
 
1458
  // ----- Return
1459
- return PclZip::errorCode();
1460
  }
1461
 
1462
  // ----- Get the value
@@ -1467,21 +1467,21 @@
1467
  case WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD :
1468
  // ----- Check the number of parameters
1469
  if (($i+1) >= $p_size) {
1470
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1471
- return PclZip::errorCode();
1472
  }
1473
 
1474
  // ----- Check for incompatible options
1475
  if (isset($v_result_list[WPVIVID_PCLZIP_OPT_TEMP_FILE_OFF])) {
1476
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'WPVIVID_PCLZIP_OPT_TEMP_FILE_OFF'");
1477
- return PclZip::errorCode();
1478
  }
1479
 
1480
  // ----- Check the value
1481
  $v_value = $p_options_list[$i+1];
1482
  if ((!is_integer($v_value)) || ($v_value<0)) {
1483
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1484
- return PclZip::errorCode();
1485
  }
1486
 
1487
  // ----- Get the value (and convert it in bytes)
@@ -1492,8 +1492,8 @@
1492
  case WPVIVID_PCLZIP_OPT_TEMP_FILE_ON :
1493
  // ----- Check for incompatible options
1494
  if (isset($v_result_list[WPVIVID_PCLZIP_OPT_TEMP_FILE_OFF])) {
1495
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'WPVIVID_PCLZIP_OPT_TEMP_FILE_OFF'");
1496
- return PclZip::errorCode();
1497
  }
1498
 
1499
  $v_result_list[$p_options_list[$i]] = true;
@@ -1502,13 +1502,13 @@
1502
  case WPVIVID_PCLZIP_OPT_TEMP_FILE_OFF :
1503
  // ----- Check for incompatible options
1504
  if (isset($v_result_list[WPVIVID_PCLZIP_OPT_TEMP_FILE_ON])) {
1505
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'WPVIVID_PCLZIP_OPT_TEMP_FILE_ON'");
1506
- return PclZip::errorCode();
1507
  }
1508
  // ----- Check for incompatible options
1509
  if (isset($v_result_list[WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
1510
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
1511
- return PclZip::errorCode();
1512
  }
1513
 
1514
  $v_result_list[$p_options_list[$i]] = true;
@@ -1518,10 +1518,10 @@
1518
  // ----- Check the number of parameters
1519
  if (($i+1) >= $p_size) {
1520
  // ----- Error log
1521
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1522
 
1523
  // ----- Return
1524
- return PclZip::errorCode();
1525
  }
1526
 
1527
  // ----- Get the value
@@ -1539,10 +1539,10 @@
1539
  // ----- Check the number of parameters
1540
  if (($i+1) >= $p_size) {
1541
  // ----- Error log
1542
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1543
 
1544
  // ----- Return
1545
- return PclZip::errorCode();
1546
  }
1547
 
1548
  // ----- Get the value
@@ -1554,10 +1554,10 @@
1554
  }
1555
  else {
1556
  // ----- Error log
1557
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1558
 
1559
  // ----- Return
1560
- return PclZip::errorCode();
1561
  }
1562
  $i++;
1563
  break;
@@ -1572,10 +1572,10 @@
1572
  // ----- Check the number of parameters
1573
  if (($i+1) >= $p_size) {
1574
  // ----- Error log
1575
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1576
 
1577
  // ----- Return
1578
- return PclZip::errorCode();
1579
  }
1580
 
1581
  // ----- Get the value
@@ -1584,10 +1584,10 @@
1584
  }
1585
  else {
1586
  // ----- Error log
1587
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1588
 
1589
  // ----- Return
1590
- return PclZip::errorCode();
1591
  }
1592
  $i++;
1593
  break;
@@ -1599,13 +1599,13 @@
1599
  // ----- Check the number of parameters
1600
  if (($i+1) >= $p_size) {
1601
  // ----- Error log
1602
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE,
1603
  "Missing parameter value for option '"
1604
  .WPvivid_PclZipUtilOptionText($p_options_list[$i])
1605
  ."'");
1606
 
1607
  // ----- Return
1608
- return PclZip::errorCode();
1609
  }
1610
 
1611
  // ----- Get the value
@@ -1614,13 +1614,13 @@
1614
  }
1615
  else {
1616
  // ----- Error log
1617
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_OPTION_VALUE,
1618
  "Wrong parameter value for option '"
1619
  .WPvivid_PclZipUtilOptionText($p_options_list[$i])
1620
  ."'");
1621
 
1622
  // ----- Return
1623
- return PclZip::errorCode();
1624
  }
1625
  $i++;
1626
  break;
@@ -1630,10 +1630,10 @@
1630
  // ----- Check the number of parameters
1631
  if (($i+1) >= $p_size) {
1632
  // ----- Error log
1633
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1634
 
1635
  // ----- Return
1636
- return PclZip::errorCode();
1637
  }
1638
 
1639
  // ----- Get the value
@@ -1654,10 +1654,10 @@
1654
  }
1655
  else {
1656
  // ----- Error log
1657
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1658
 
1659
  // ----- Return
1660
- return PclZip::errorCode();
1661
  }
1662
 
1663
  // ----- Reduce the index list
@@ -1687,10 +1687,10 @@
1687
  }
1688
  else {
1689
  // ----- Error log
1690
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1691
 
1692
  // ----- Return
1693
- return PclZip::errorCode();
1694
  }
1695
 
1696
 
@@ -1700,10 +1700,10 @@
1700
 
1701
  // ----- TBC : An automatic sort should be written ...
1702
  // ----- Error log
1703
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1704
 
1705
  // ----- Return
1706
- return PclZip::errorCode();
1707
  }
1708
  $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
1709
  }
@@ -1732,10 +1732,10 @@
1732
  // ----- Check the number of parameters
1733
  if (($i+1) >= $p_size) {
1734
  // ----- Error log
1735
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1736
 
1737
  // ----- Return
1738
- return PclZip::errorCode();
1739
  }
1740
 
1741
  // ----- Get the value
@@ -1757,10 +1757,10 @@
1757
  // ----- Check the number of parameters
1758
  if (($i+1) >= $p_size) {
1759
  // ----- Error log
1760
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1761
 
1762
  // ----- Return
1763
- return PclZip::errorCode();
1764
  }
1765
 
1766
  // ----- Get the value
@@ -1769,10 +1769,10 @@
1769
  // ----- Check that the value is a valid existing function
1770
  if (!function_exists($v_function_name)) {
1771
  // ----- Error log
1772
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1773
 
1774
  // ----- Return
1775
- return PclZip::errorCode();
1776
  }
1777
 
1778
  // ----- Set the attribute
@@ -1782,12 +1782,12 @@
1782
 
1783
  default :
1784
  // ----- Error log
1785
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER,
1786
  "Unknown parameter '"
1787
  .$p_options_list[$i]."'");
1788
 
1789
  // ----- Return
1790
- return PclZip::errorCode();
1791
  }
1792
 
1793
  // ----- Next options
@@ -1802,10 +1802,10 @@
1802
  // ----- Look if present
1803
  if (!isset($v_result_list[$key])) {
1804
  // ----- Error log
1805
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".WPvivid_PclZipUtilOptionText($key)."(".$key.")");
1806
 
1807
  // ----- Return
1808
- return PclZip::errorCode();
1809
  }
1810
  }
1811
  }
@@ -1882,62 +1882,62 @@
1882
  // ----- Check if the option is supported
1883
  if (!isset($v_requested_options[$v_key])) {
1884
  // ----- Error log
1885
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
1886
 
1887
  // ----- Return
1888
- return PclZip::errorCode();
1889
  }
1890
 
1891
  // ----- Look for attribute
1892
  switch ($v_key) {
1893
  case WPVIVID_PCLZIP_ATT_FILE_NAME :
1894
  if (!is_string($v_value)) {
1895
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".WPvivid_PclZipUtilOptionText($v_key)."'");
1896
- return PclZip::errorCode();
1897
  }
1898
 
1899
  $p_filedescr['filename'] = WPvivid_PclZipUtilPathReduction($v_value);
1900
 
1901
  if ($p_filedescr['filename'] == '') {
1902
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".WPvivid_PclZipUtilOptionText($v_key)."'");
1903
- return PclZip::errorCode();
1904
  }
1905
 
1906
  break;
1907
 
1908
  case WPVIVID_PCLZIP_ATT_FILE_NEW_SHORT_NAME :
1909
  if (!is_string($v_value)) {
1910
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".WPvivid_PclZipUtilOptionText($v_key)."'");
1911
- return PclZip::errorCode();
1912
  }
1913
 
1914
  $p_filedescr['new_short_name'] = WPvivid_PclZipUtilPathReduction($v_value);
1915
 
1916
  if ($p_filedescr['new_short_name'] == '') {
1917
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".WPvivid_PclZipUtilOptionText($v_key)."'");
1918
- return PclZip::errorCode();
1919
  }
1920
  break;
1921
 
1922
  case WPVIVID_PCLZIP_ATT_FILE_NEW_FULL_NAME :
1923
  if (!is_string($v_value)) {
1924
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".WPvivid_PclZipUtilOptionText($v_key)."'");
1925
- return PclZip::errorCode();
1926
  }
1927
 
1928
  $p_filedescr['new_full_name'] = WPvivid_PclZipUtilPathReduction($v_value);
1929
 
1930
  if ($p_filedescr['new_full_name'] == '') {
1931
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".WPvivid_PclZipUtilOptionText($v_key)."'");
1932
- return PclZip::errorCode();
1933
  }
1934
  break;
1935
 
1936
  // ----- Look for options that takes a string
1937
  case WPVIVID_PCLZIP_ATT_FILE_COMMENT :
1938
  if (!is_string($v_value)) {
1939
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".WPvivid_PclZipUtilOptionText($v_key)."'");
1940
- return PclZip::errorCode();
1941
  }
1942
 
1943
  $p_filedescr['comment'] = $v_value;
@@ -1945,8 +1945,8 @@
1945
 
1946
  case WPVIVID_PCLZIP_ATT_FILE_MTIME :
1947
  if (!is_integer($v_value)) {
1948
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".WPvivid_PclZipUtilOptionText($v_key)."'");
1949
- return PclZip::errorCode();
1950
  }
1951
 
1952
  $p_filedescr['mtime'] = $v_value;
@@ -1958,11 +1958,11 @@
1958
 
1959
  default :
1960
  // ----- Error log
1961
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER,
1962
  "Unknown parameter '".$v_key."'");
1963
 
1964
  // ----- Return
1965
- return PclZip::errorCode();
1966
  }
1967
 
1968
  // ----- Look for mandatory options
@@ -1972,8 +1972,8 @@
1972
  if ($v_requested_options[$key] == 'mandatory') {
1973
  // ----- Look if present
1974
  if (!isset($p_file_list[$key])) {
1975
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".WPvivid_PclZipUtilOptionText($key)."(".$key.")");
1976
- return PclZip::errorCode();
1977
  }
1978
  }
1979
  }
@@ -2044,10 +2044,10 @@
2044
  // ----- Missing file
2045
  else {
2046
  // ----- Error log
2047
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
2048
 
2049
  // ----- Return
2050
- return PclZip::errorCode();
2051
  }
2052
 
2053
  // ----- Calculate the stored filename
@@ -2210,10 +2210,10 @@
2210
  $this->privCloseFd();
2211
  $this->privSwapBackMagicQuotes();
2212
 
2213
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
2214
 
2215
  // ----- Return
2216
- return PclZip::errorCode();
2217
  }
2218
 
2219
  // ----- Copy the files from the archive to the temporary file
@@ -2348,20 +2348,20 @@
2348
  if ($this->zip_fd != 0)
2349
  {
2350
  // ----- Error log
2351
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
2352
 
2353
  // ----- Return
2354
- return PclZip::errorCode();
2355
  }
2356
 
2357
  // ----- Open the zip file
2358
  if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
2359
  {
2360
  // ----- Error log
2361
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
2362
 
2363
  // ----- Return
2364
- return PclZip::errorCode();
2365
  }
2366
 
2367
  // ----- Return
@@ -2489,8 +2489,8 @@
2489
  // ----- Check the filename
2490
  if ( ($p_filedescr_list[$j]['type'] != 'virtual_file')
2491
  && (!file_exists($p_filedescr_list[$j]['filename']))) {
2492
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
2493
- return PclZip::errorCode();
2494
  }
2495
 
2496
  // ----- Look if it is a file or a dir with no all path remove option
@@ -2537,10 +2537,10 @@
2537
  // TBC : Already done in the fileAtt check ... ?
2538
  if ($p_filename == "") {
2539
  // ----- Error log
2540
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
2541
 
2542
  // ----- Return
2543
- return PclZip::errorCode();
2544
  }
2545
 
2546
  // ----- Look for a stored different filename
@@ -2669,8 +2669,8 @@
2669
 
2670
  // ----- Open the source file
2671
  if (($v_file = @fopen($p_filename, "rb")) == 0) {
2672
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2673
- return PclZip::errorCode();
2674
  }
2675
 
2676
  // ----- Read the file content
@@ -2815,16 +2815,16 @@
2815
 
2816
  // ----- Open the source file
2817
  if (($v_file = @fopen($p_filename, "rb")) == 0) {
2818
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2819
- return PclZip::errorCode();
2820
  }
2821
 
2822
  // ----- Creates a compressed temporary file
2823
  $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
2824
  if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
2825
  fclose($v_file);
2826
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
2827
- return PclZip::errorCode();
2828
  }
2829
 
2830
  // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
@@ -2843,14 +2843,14 @@
2843
 
2844
  // ----- Check the minimum file size
2845
  if (filesize($v_gzip_temp_name) < 18) {
2846
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
2847
- return PclZip::errorCode();
2848
  }
2849
 
2850
  // ----- Extract the compressed attributes
2851
  if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
2852
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2853
- return PclZip::errorCode();
2854
  }
2855
 
2856
  // ----- Read the gzip file header
@@ -2882,8 +2882,8 @@
2882
  // ----- Add the compressed data
2883
  if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
2884
  {
2885
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2886
- return PclZip::errorCode();
2887
  }
2888
 
2889
  // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
@@ -3170,10 +3170,10 @@
3170
  $this->privSwapBackMagicQuotes();
3171
 
3172
  // ----- Error log
3173
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
3174
 
3175
  // ----- Return
3176
- return PclZip::errorCode();
3177
  }
3178
 
3179
  // ----- Read the central directory information
@@ -3191,10 +3191,10 @@
3191
  $this->privSwapBackMagicQuotes();
3192
 
3193
  // ----- Error log
3194
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3195
 
3196
  // ----- Return
3197
- return PclZip::errorCode();
3198
  }
3199
 
3200
  // ----- Read each entry
@@ -3348,10 +3348,10 @@
3348
  $this->privSwapBackMagicQuotes();
3349
 
3350
  // ----- Error log
3351
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3352
 
3353
  // ----- Return
3354
- return PclZip::errorCode();
3355
  }
3356
 
3357
  // ----- Read the file header
@@ -3455,12 +3455,12 @@
3455
 
3456
  $this->privSwapBackMagicQuotes();
3457
 
3458
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
3459
  "Filename '".$v_header['stored_filename']."' is "
3460
  ."compressed by an unsupported compression "
3461
  ."method (".$v_header['compression'].") ");
3462
 
3463
- return PclZip::errorCode();
3464
  }
3465
  }
3466
 
@@ -3474,12 +3474,12 @@
3474
 
3475
  $this->privSwapBackMagicQuotes();
3476
 
3477
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
3478
  "Unsupported encryption for "
3479
  ." filename '".$v_header['stored_filename']
3480
  ."'");
3481
 
3482
- return PclZip::errorCode();
3483
  }
3484
  }
3485
 
@@ -3510,10 +3510,10 @@
3510
  $this->privSwapBackMagicQuotes();
3511
 
3512
  // ----- Error log
3513
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3514
 
3515
  // ----- Return
3516
- return PclZip::errorCode();
3517
  }
3518
 
3519
  // ----- Look for extraction as string
@@ -3688,11 +3688,11 @@
3688
  $p_entry['filename']);
3689
  if ($v_inclusion == 0) {
3690
 
3691
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_DIRECTORY_RESTRICTION,
3692
  "Filename '".$p_entry['filename']."' is "
3693
  ."outside WPVIVID_PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
3694
 
3695
- return PclZip::errorCode();
3696
  }
3697
  }
3698
 
@@ -3746,11 +3746,11 @@
3746
  if ( (isset($p_options[WPVIVID_PCLZIP_OPT_STOP_ON_ERROR]))
3747
  && ($p_options[WPVIVID_PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3748
 
3749
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_ALREADY_A_DIRECTORY,
3750
  "Filename '".$p_entry['filename']."' is "
3751
  ."already used by an existing directory");
3752
 
3753
- return PclZip::errorCode();
3754
  }
3755
  }
3756
  // ----- Look if file is write protected
@@ -3766,11 +3766,11 @@
3766
  if ( (isset($p_options[WPVIVID_PCLZIP_OPT_STOP_ON_ERROR]))
3767
  && ($p_options[WPVIVID_PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3768
 
3769
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_WRITE_OPEN_FAIL,
3770
  "Filename '".$p_entry['filename']."' exists "
3771
  ."and is write protected");
3772
 
3773
- return PclZip::errorCode();
3774
  }
3775
  }
3776
 
@@ -3790,11 +3790,11 @@
3790
  if ( (isset($p_options[WPVIVID_PCLZIP_OPT_STOP_ON_ERROR]))
3791
  && ($p_options[WPVIVID_PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3792
 
3793
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_WRITE_OPEN_FAIL,
3794
  "Newer version of '".$p_entry['filename']."' exists "
3795
  ."and option WPVIVID_PCLZIP_OPT_REPLACE_NEWER is not selected");
3796
 
3797
- return PclZip::errorCode();
3798
  }
3799
  }
3800
  }
@@ -3870,8 +3870,8 @@
3870
  // ----- TBC
3871
  // Need to be finished
3872
  if (($p_entry['flag'] & 1) == 1) {
3873
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
3874
- return PclZip::errorCode();
3875
  }
3876
 
3877
 
@@ -3984,8 +3984,8 @@
3984
  $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
3985
  if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
3986
  fclose($v_file);
3987
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
3988
- return PclZip::errorCode();
3989
  }
3990
 
3991
 
@@ -4021,8 +4021,8 @@
4021
  if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
4022
  @fclose($v_dest_file);
4023
  $p_entry['status'] = "read_error";
4024
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
4025
- return PclZip::errorCode();
4026
  }
4027
 
4028
 
@@ -4317,10 +4317,10 @@
4317
  {
4318
 
4319
  // ----- Error log
4320
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4321
 
4322
  // ----- Return
4323
- return PclZip::errorCode();
4324
  }
4325
 
4326
  // ----- Read the first 42 bytes of the header
@@ -4333,10 +4333,10 @@
4333
  $p_header['status'] = "invalid_header";
4334
 
4335
  // ----- Error log
4336
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4337
 
4338
  // ----- Return
4339
- return PclZip::errorCode();
4340
  }
4341
 
4342
  // ----- Extract the values
@@ -4420,10 +4420,10 @@
4420
  {
4421
 
4422
  // ----- Error log
4423
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4424
 
4425
  // ----- Return
4426
- return PclZip::errorCode();
4427
  }
4428
 
4429
  // ----- Read the first 42 bytes of the header
@@ -4436,10 +4436,10 @@
4436
  $p_header['status'] = "invalid_header";
4437
 
4438
  // ----- Error log
4439
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4440
 
4441
  // ----- Return
4442
- return PclZip::errorCode();
4443
  }
4444
 
4445
  // ----- Extract the values
@@ -4562,10 +4562,10 @@
4562
  if (@ftell($this->zip_fd) != $v_size)
4563
  {
4564
  // ----- Error log
4565
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
4566
 
4567
  // ----- Return
4568
- return PclZip::errorCode();
4569
  }
4570
 
4571
  // ----- First try : look if this is an archive with no commentaries (most of the time)
@@ -4576,10 +4576,10 @@
4576
  if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
4577
  {
4578
  // ----- Error log
4579
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4580
 
4581
  // ----- Return
4582
- return PclZip::errorCode();
4583
  }
4584
 
4585
  // ----- Read for bytes
@@ -4603,10 +4603,10 @@
4603
  if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
4604
  {
4605
  // ----- Error log
4606
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4607
 
4608
  // ----- Return
4609
- return PclZip::errorCode();
4610
  }
4611
 
4612
  // ----- Read byte per byte in order to find the signature
@@ -4638,10 +4638,10 @@
4638
  {
4639
 
4640
  // ----- Error log
4641
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
4642
 
4643
  // ----- Return
4644
- return PclZip::errorCode();
4645
  }
4646
  }
4647
 
@@ -4653,10 +4653,10 @@
4653
  {
4654
 
4655
  // ----- Error log
4656
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
4657
 
4658
  // ----- Return
4659
- return PclZip::errorCode();
4660
  }
4661
 
4662
  // ----- Extract the values
@@ -4671,12 +4671,12 @@
4671
  // While decrypted, zip has training 0 bytes
4672
  if (0) {
4673
  // ----- Error log
4674
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT,
4675
  'The central dir is not at the end of the archive.'
4676
  .' Some trailing bytes exists after the archive.');
4677
 
4678
  // ----- Return
4679
- return PclZip::errorCode();
4680
  }
4681
  }
4682
 
@@ -4742,10 +4742,10 @@
4742
  $this->privCloseFd();
4743
 
4744
  // ----- Error log
4745
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4746
 
4747
  // ----- Return
4748
- return PclZip::errorCode();
4749
  }
4750
 
4751
  // ----- Read each entry
@@ -4860,7 +4860,7 @@
4860
  $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
4861
 
4862
  // ----- Creates a temporary zip archive
4863
- $v_temp_zip = new PclZip($v_zip_temp_name);
4864
 
4865
  // ----- Open the temporary zip file in write mode
4866
  if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
@@ -4882,10 +4882,10 @@
4882
  @unlink($v_zip_temp_name);
4883
 
4884
  // ----- Error log
4885
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4886
 
4887
  // ----- Return
4888
- return PclZip::errorCode();
4889
  }
4890
 
4891
  // ----- Read the file header
@@ -5056,10 +5056,10 @@
5056
  if (!@mkdir($p_dir, 0777))
5057
  {
5058
  // ----- Error log
5059
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
5060
 
5061
  // ----- Return
5062
- return PclZip::errorCode();
5063
  }
5064
 
5065
  // ----- Return
@@ -5149,10 +5149,10 @@
5149
  $this->privCloseFd();
5150
  $p_archive_to_add->privCloseFd();
5151
 
5152
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
5153
 
5154
  // ----- Return
5155
- return PclZip::errorCode();
5156
  }
5157
 
5158
  // ----- Copy the files from the archive to the temporary file
@@ -5286,10 +5286,10 @@
5286
  {
5287
  $this->privCloseFd();
5288
 
5289
- PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
5290
 
5291
- // ----- Return
5292
- return PclZip::errorCode();
5293
  }
5294
 
5295
  // ----- Copy the files from the archive to the temporary file
330
  $v_options[WPVIVID_PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
331
  }
332
  else if ($v_size > 2) {
333
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER,
334
  "Invalid number / type of arguments");
335
  return 0;
336
  }
369
 
370
  // ----- Invalid variable type for $p_filelist
371
  else {
372
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
373
  return 0;
374
  }
375
 
516
  }
517
  else if ($v_size > 2) {
518
  // ----- Error log
519
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
520
 
521
  // ----- Return
522
  return 0;
556
 
557
  // ----- Invalid variable type for $p_filelist
558
  else {
559
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
560
  return 0;
561
  }
562
 
793
  }
794
  else if ($v_size > 2) {
795
  // ----- Error log
796
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
797
 
798
  // ----- Return
799
  return 0;
954
  }
955
  else if ($v_size > 2) {
956
  // ----- Error log
957
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
958
 
959
  // ----- Return
960
  return 0;
1120
  $this->privSwapBackMagicQuotes();
1121
 
1122
  // ----- Error log
1123
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
1124
 
1125
  // ----- Return
1126
  return 0;
1186
  // TBC : Should also check the archive format
1187
  if (!is_file($p_archive)) {
1188
  // ----- Error log
1189
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
1190
  $v_result = WPVIVID_PCLZIP_ERR_MISSING_FILE;
1191
  }
1192
  else {
1199
  else
1200
  {
1201
  // ----- Error log
1202
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1203
  $v_result = WPVIVID_PCLZIP_ERR_INVALID_PARAMETER;
1204
  }
1205
 
1247
  {
1248
 
1249
  // ----- Create a temporary archive
1250
+ $v_object_archive = new WPvivid_PclZip($p_archive_to_add);
1251
 
1252
  // ----- Merge the archive
1253
  $v_result = $this->privMerge($v_object_archive);
1257
  else
1258
  {
1259
  // ----- Error log
1260
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1261
  $v_result = WPVIVID_PCLZIP_ERR_INVALID_PARAMETER;
1262
  }
1263
 
1387
  // ----- Look if the file exits
1388
  if (!is_file($this->zipname)) {
1389
  // ----- Error log
1390
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
1391
  return(false);
1392
  }
1393
 
1394
  // ----- Check that the file is readable
1395
  if (!is_readable($this->zipname)) {
1396
  // ----- Error log
1397
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
1398
  return(false);
1399
  }
1400
 
1438
  // ----- Check if the option is supported
1439
  if (!isset($v_requested_options[$p_options_list[$i]])) {
1440
  // ----- Error log
1441
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
1442
 
1443
  // ----- Return
1444
+ return WPvivid_PclZip::errorCode();
1445
  }
1446
 
1447
  // ----- Look for next option
1453
  // ----- Check the number of parameters
1454
  if (($i+1) >= $p_size) {
1455
  // ----- Error log
1456
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1457
 
1458
  // ----- Return
1459
+ return WPvivid_PclZip::errorCode();
1460
  }
1461
 
1462
  // ----- Get the value
1467
  case WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD :
1468
  // ----- Check the number of parameters
1469
  if (($i+1) >= $p_size) {
1470
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1471
+ return WPvivid_PclZip::errorCode();
1472
  }
1473
 
1474
  // ----- Check for incompatible options
1475
  if (isset($v_result_list[WPVIVID_PCLZIP_OPT_TEMP_FILE_OFF])) {
1476
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'WPVIVID_PCLZIP_OPT_TEMP_FILE_OFF'");
1477
+ return WPvivid_PclZip::errorCode();
1478
  }
1479
 
1480
  // ----- Check the value
1481
  $v_value = $p_options_list[$i+1];
1482
  if ((!is_integer($v_value)) || ($v_value<0)) {
1483
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1484
+ return WPvivid_PclZip::errorCode();
1485
  }
1486
 
1487
  // ----- Get the value (and convert it in bytes)
1492
  case WPVIVID_PCLZIP_OPT_TEMP_FILE_ON :
1493
  // ----- Check for incompatible options
1494
  if (isset($v_result_list[WPVIVID_PCLZIP_OPT_TEMP_FILE_OFF])) {
1495
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'WPVIVID_PCLZIP_OPT_TEMP_FILE_OFF'");
1496
+ return WPvivid_PclZip::errorCode();
1497
  }
1498
 
1499
  $v_result_list[$p_options_list[$i]] = true;
1502
  case WPVIVID_PCLZIP_OPT_TEMP_FILE_OFF :
1503
  // ----- Check for incompatible options
1504
  if (isset($v_result_list[WPVIVID_PCLZIP_OPT_TEMP_FILE_ON])) {
1505
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'WPVIVID_PCLZIP_OPT_TEMP_FILE_ON'");
1506
+ return WPvivid_PclZip::errorCode();
1507
  }
1508
  // ----- Check for incompatible options
1509
  if (isset($v_result_list[WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
1510
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
1511
+ return WPvivid_PclZip::errorCode();
1512
  }
1513
 
1514
  $v_result_list[$p_options_list[$i]] = true;
1518
  // ----- Check the number of parameters
1519
  if (($i+1) >= $p_size) {
1520
  // ----- Error log
1521
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1522
 
1523
  // ----- Return
1524
+ return WPvivid_PclZip::errorCode();
1525
  }
1526
 
1527
  // ----- Get the value
1539
  // ----- Check the number of parameters
1540
  if (($i+1) >= $p_size) {
1541
  // ----- Error log
1542
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1543
 
1544
  // ----- Return
1545
+ return WPvivid_PclZip::errorCode();
1546
  }
1547
 
1548
  // ----- Get the value
1554
  }
1555
  else {
1556
  // ----- Error log
1557
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1558
 
1559
  // ----- Return
1560
+ return WPvivid_PclZip::errorCode();
1561
  }
1562
  $i++;
1563
  break;
1572
  // ----- Check the number of parameters
1573
  if (($i+1) >= $p_size) {
1574
  // ----- Error log
1575
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1576
 
1577
  // ----- Return
1578
+ return WPvivid_PclZip::errorCode();
1579
  }
1580
 
1581
  // ----- Get the value
1584
  }
1585
  else {
1586
  // ----- Error log
1587
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1588
 
1589
  // ----- Return
1590
+ return WPvivid_PclZip::errorCode();
1591
  }
1592
  $i++;
1593
  break;
1599
  // ----- Check the number of parameters
1600
  if (($i+1) >= $p_size) {
1601
  // ----- Error log
1602
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE,
1603
  "Missing parameter value for option '"
1604
  .WPvivid_PclZipUtilOptionText($p_options_list[$i])
1605
  ."'");
1606
 
1607
  // ----- Return
1608
+ return WPvivid_PclZip::errorCode();
1609
  }
1610
 
1611
  // ----- Get the value
1614
  }
1615
  else {
1616
  // ----- Error log
1617
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_OPTION_VALUE,
1618
  "Wrong parameter value for option '"
1619
  .WPvivid_PclZipUtilOptionText($p_options_list[$i])
1620
  ."'");
1621
 
1622
  // ----- Return
1623
+ return WPvivid_PclZip::errorCode();
1624
  }
1625
  $i++;
1626
  break;
1630
  // ----- Check the number of parameters
1631
  if (($i+1) >= $p_size) {
1632
  // ----- Error log
1633
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1634
 
1635
  // ----- Return
1636
+ return WPvivid_PclZip::errorCode();
1637
  }
1638
 
1639
  // ----- Get the value
1654
  }
1655
  else {
1656
  // ----- Error log
1657
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1658
 
1659
  // ----- Return
1660
+ return WPvivid_PclZip::errorCode();
1661
  }
1662
 
1663
  // ----- Reduce the index list
1687
  }
1688
  else {
1689
  // ----- Error log
1690
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1691
 
1692
  // ----- Return
1693
+ return WPvivid_PclZip::errorCode();
1694
  }
1695
 
1696
 
1700
 
1701
  // ----- TBC : An automatic sort should be written ...
1702
  // ----- Error log
1703
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1704
 
1705
  // ----- Return
1706
+ return WPvivid_PclZip::errorCode();
1707
  }
1708
  $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
1709
  }
1732
  // ----- Check the number of parameters
1733
  if (($i+1) >= $p_size) {
1734
  // ----- Error log
1735
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1736
 
1737
  // ----- Return
1738
+ return WPvivid_PclZip::errorCode();
1739
  }
1740
 
1741
  // ----- Get the value
1757
  // ----- Check the number of parameters
1758
  if (($i+1) >= $p_size) {
1759
  // ----- Error log
1760
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1761
 
1762
  // ----- Return
1763
+ return WPvivid_PclZip::errorCode();
1764
  }
1765
 
1766
  // ----- Get the value
1769
  // ----- Check that the value is a valid existing function
1770
  if (!function_exists($v_function_name)) {
1771
  // ----- Error log
1772
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".WPvivid_PclZipUtilOptionText($p_options_list[$i])."'");
1773
 
1774
  // ----- Return
1775
+ return WPvivid_PclZip::errorCode();
1776
  }
1777
 
1778
  // ----- Set the attribute
1782
 
1783
  default :
1784
  // ----- Error log
1785
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER,
1786
  "Unknown parameter '"
1787
  .$p_options_list[$i]."'");
1788
 
1789
  // ----- Return
1790
+ return WPvivid_PclZip::errorCode();
1791
  }
1792
 
1793
  // ----- Next options
1802
  // ----- Look if present
1803
  if (!isset($v_result_list[$key])) {
1804
  // ----- Error log
1805
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".WPvivid_PclZipUtilOptionText($key)."(".$key.")");
1806
 
1807
  // ----- Return
1808
+ return WPvivid_PclZip::errorCode();
1809
  }
1810
  }
1811
  }
1882
  // ----- Check if the option is supported
1883
  if (!isset($v_requested_options[$v_key])) {
1884
  // ----- Error log
1885
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
1886
 
1887
  // ----- Return
1888
+ return WPvivid_PclZip::errorCode();
1889
  }
1890
 
1891
  // ----- Look for attribute
1892
  switch ($v_key) {
1893
  case WPVIVID_PCLZIP_ATT_FILE_NAME :
1894
  if (!is_string($v_value)) {
1895
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".WPvivid_PclZipUtilOptionText($v_key)."'");
1896
+ return WPvivid_PclZip::errorCode();
1897
  }
1898
 
1899
  $p_filedescr['filename'] = WPvivid_PclZipUtilPathReduction($v_value);
1900
 
1901
  if ($p_filedescr['filename'] == '') {
1902
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".WPvivid_PclZipUtilOptionText($v_key)."'");
1903
+ return WPvivid_PclZip::errorCode();
1904
  }
1905
 
1906
  break;
1907
 
1908
  case WPVIVID_PCLZIP_ATT_FILE_NEW_SHORT_NAME :
1909
  if (!is_string($v_value)) {
1910
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".WPvivid_PclZipUtilOptionText($v_key)."'");
1911
+ return WPvivid_PclZip::errorCode();
1912
  }
1913
 
1914
  $p_filedescr['new_short_name'] = WPvivid_PclZipUtilPathReduction($v_value);
1915
 
1916
  if ($p_filedescr['new_short_name'] == '') {
1917
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".WPvivid_PclZipUtilOptionText($v_key)."'");
1918
+ return WPvivid_PclZip::errorCode();
1919
  }
1920
  break;
1921
 
1922
  case WPVIVID_PCLZIP_ATT_FILE_NEW_FULL_NAME :
1923
  if (!is_string($v_value)) {
1924
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".WPvivid_PclZipUtilOptionText($v_key)."'");
1925
+ return WPvivid_PclZip::errorCode();
1926
  }
1927
 
1928
  $p_filedescr['new_full_name'] = WPvivid_PclZipUtilPathReduction($v_value);
1929
 
1930
  if ($p_filedescr['new_full_name'] == '') {
1931
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".WPvivid_PclZipUtilOptionText($v_key)."'");
1932
+ return WPvivid_PclZip::errorCode();
1933
  }
1934
  break;
1935
 
1936
  // ----- Look for options that takes a string
1937
  case WPVIVID_PCLZIP_ATT_FILE_COMMENT :
1938
  if (!is_string($v_value)) {
1939
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".WPvivid_PclZipUtilOptionText($v_key)."'");
1940
+ return WPvivid_PclZip::errorCode();
1941
  }
1942
 
1943
  $p_filedescr['comment'] = $v_value;
1945
 
1946
  case WPVIVID_PCLZIP_ATT_FILE_MTIME :
1947
  if (!is_integer($v_value)) {
1948
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".WPvivid_PclZipUtilOptionText($v_key)."'");
1949
+ return WPvivid_PclZip::errorCode();
1950
  }
1951
 
1952
  $p_filedescr['mtime'] = $v_value;
1958
 
1959
  default :
1960
  // ----- Error log
1961
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER,
1962
  "Unknown parameter '".$v_key."'");
1963
 
1964
  // ----- Return
1965
+ return WPvivid_PclZip::errorCode();
1966
  }
1967
 
1968
  // ----- Look for mandatory options
1972
  if ($v_requested_options[$key] == 'mandatory') {
1973
  // ----- Look if present
1974
  if (!isset($p_file_list[$key])) {
1975
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".WPvivid_PclZipUtilOptionText($key)."(".$key.")");
1976
+ return WPvivid_PclZip::errorCode();
1977
  }
1978
  }
1979
  }
2044
  // ----- Missing file
2045
  else {
2046
  // ----- Error log
2047
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
2048
 
2049
  // ----- Return
2050
+ return WPvivid_PclZip::errorCode();
2051
  }
2052
 
2053
  // ----- Calculate the stored filename
2210
  $this->privCloseFd();
2211
  $this->privSwapBackMagicQuotes();
2212
 
2213
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
2214
 
2215
  // ----- Return
2216
+ return WPvivid_PclZip::errorCode();
2217
  }
2218
 
2219
  // ----- Copy the files from the archive to the temporary file
2348
  if ($this->zip_fd != 0)
2349
  {
2350
  // ----- Error log
2351
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
2352
 
2353
  // ----- Return
2354
+ return WPvivid_PclZip::errorCode();
2355
  }
2356
 
2357
  // ----- Open the zip file
2358
  if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
2359
  {
2360
  // ----- Error log
2361
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
2362
 
2363
  // ----- Return
2364
+ return WPvivid_PclZip::errorCode();
2365
  }
2366
 
2367
  // ----- Return
2489
  // ----- Check the filename
2490
  if ( ($p_filedescr_list[$j]['type'] != 'virtual_file')
2491
  && (!file_exists($p_filedescr_list[$j]['filename']))) {
2492
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
2493
+ return WPvivid_PclZip::errorCode();
2494
  }
2495
 
2496
  // ----- Look if it is a file or a dir with no all path remove option
2537
  // TBC : Already done in the fileAtt check ... ?
2538
  if ($p_filename == "") {
2539
  // ----- Error log
2540
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
2541
 
2542
  // ----- Return
2543
+ return WPvivid_PclZip::errorCode();
2544
  }
2545
 
2546
  // ----- Look for a stored different filename
2669
 
2670
  // ----- Open the source file
2671
  if (($v_file = @fopen($p_filename, "rb")) == 0) {
2672
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2673
+ return WPvivid_PclZip::errorCode();
2674
  }
2675
 
2676
  // ----- Read the file content
2815
 
2816
  // ----- Open the source file
2817
  if (($v_file = @fopen($p_filename, "rb")) == 0) {
2818
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2819
+ return WPvivid_PclZip::errorCode();
2820
  }
2821
 
2822
  // ----- Creates a compressed temporary file
2823
  $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
2824
  if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
2825
  fclose($v_file);
2826
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
2827
+ return WPvivid_PclZip::errorCode();
2828
  }
2829
 
2830
  // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
2843
 
2844
  // ----- Check the minimum file size
2845
  if (filesize($v_gzip_temp_name) < 18) {
2846
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
2847
+ return WPvivid_PclZip::errorCode();
2848
  }
2849
 
2850
  // ----- Extract the compressed attributes
2851
  if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
2852
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2853
+ return WPvivid_PclZip::errorCode();
2854
  }
2855
 
2856
  // ----- Read the gzip file header
2882
  // ----- Add the compressed data
2883
  if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
2884
  {
2885
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2886
+ return WPvivid_PclZip::errorCode();
2887
  }
2888
 
2889
  // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3170
  $this->privSwapBackMagicQuotes();
3171
 
3172
  // ----- Error log
3173
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
3174
 
3175
  // ----- Return
3176
+ return WPvivid_PclZip::errorCode();
3177
  }
3178
 
3179
  // ----- Read the central directory information
3191
  $this->privSwapBackMagicQuotes();
3192
 
3193
  // ----- Error log
3194
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3195
 
3196
  // ----- Return
3197
+ return WPvivid_PclZip::errorCode();
3198
  }
3199
 
3200
  // ----- Read each entry
3348
  $this->privSwapBackMagicQuotes();
3349
 
3350
  // ----- Error log
3351
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3352
 
3353
  // ----- Return
3354
+ return WPvivid_PclZip::errorCode();
3355
  }
3356
 
3357
  // ----- Read the file header
3455
 
3456
  $this->privSwapBackMagicQuotes();
3457
 
3458
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
3459
  "Filename '".$v_header['stored_filename']."' is "
3460
  ."compressed by an unsupported compression "
3461
  ."method (".$v_header['compression'].") ");
3462
 
3463
+ return WPvivid_PclZip::errorCode();
3464
  }
3465
  }
3466
 
3474
 
3475
  $this->privSwapBackMagicQuotes();
3476
 
3477
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
3478
  "Unsupported encryption for "
3479
  ." filename '".$v_header['stored_filename']
3480
  ."'");
3481
 
3482
+ return WPvivid_PclZip::errorCode();
3483
  }
3484
  }
3485
 
3510
  $this->privSwapBackMagicQuotes();
3511
 
3512
  // ----- Error log
3513
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3514
 
3515
  // ----- Return
3516
+ return WPvivid_PclZip::errorCode();
3517
  }
3518
 
3519
  // ----- Look for extraction as string
3688
  $p_entry['filename']);
3689
  if ($v_inclusion == 0) {
3690
 
3691
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_DIRECTORY_RESTRICTION,
3692
  "Filename '".$p_entry['filename']."' is "
3693
  ."outside WPVIVID_PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
3694
 
3695
+ return WPvivid_PclZip::errorCode();
3696
  }
3697
  }
3698
 
3746
  if ( (isset($p_options[WPVIVID_PCLZIP_OPT_STOP_ON_ERROR]))
3747
  && ($p_options[WPVIVID_PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3748
 
3749
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_ALREADY_A_DIRECTORY,
3750
  "Filename '".$p_entry['filename']."' is "
3751
  ."already used by an existing directory");
3752
 
3753
+ return WPvivid_PclZip::errorCode();
3754
  }
3755
  }
3756
  // ----- Look if file is write protected
3766
  if ( (isset($p_options[WPVIVID_PCLZIP_OPT_STOP_ON_ERROR]))
3767
  && ($p_options[WPVIVID_PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3768
 
3769
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_WRITE_OPEN_FAIL,
3770
  "Filename '".$p_entry['filename']."' exists "
3771
  ."and is write protected");
3772
 
3773
+ return WPvivid_PclZip::errorCode();
3774
  }
3775
  }
3776
 
3790
  if ( (isset($p_options[WPVIVID_PCLZIP_OPT_STOP_ON_ERROR]))
3791
  && ($p_options[WPVIVID_PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3792
 
3793
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_WRITE_OPEN_FAIL,
3794
  "Newer version of '".$p_entry['filename']."' exists "
3795
  ."and option WPVIVID_PCLZIP_OPT_REPLACE_NEWER is not selected");
3796
 
3797
+ return WPvivid_PclZip::errorCode();
3798
  }
3799
  }
3800
  }
3870
  // ----- TBC
3871
  // Need to be finished
3872
  if (($p_entry['flag'] & 1) == 1) {
3873
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
3874
+ return WPvivid_PclZip::errorCode();
3875
  }
3876
 
3877
 
3984
  $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
3985
  if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
3986
  fclose($v_file);
3987
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
3988
+ return WPvivid_PclZip::errorCode();
3989
  }
3990
 
3991
 
4021
  if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
4022
  @fclose($v_dest_file);
4023
  $p_entry['status'] = "read_error";
4024
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
4025
+ return WPvivid_PclZip::errorCode();
4026
  }
4027
 
4028
 
4317
  {
4318
 
4319
  // ----- Error log
4320
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4321
 
4322
  // ----- Return
4323
+ return WPvivid_PclZip::errorCode();
4324
  }
4325
 
4326
  // ----- Read the first 42 bytes of the header
4333
  $p_header['status'] = "invalid_header";
4334
 
4335
  // ----- Error log
4336
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4337
 
4338
  // ----- Return
4339
+ return WPvivid_PclZip::errorCode();
4340
  }
4341
 
4342
  // ----- Extract the values
4420
  {
4421
 
4422
  // ----- Error log
4423
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4424
 
4425
  // ----- Return
4426
+ return WPvivid_PclZip::errorCode();
4427
  }
4428
 
4429
  // ----- Read the first 42 bytes of the header
4436
  $p_header['status'] = "invalid_header";
4437
 
4438
  // ----- Error log
4439
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4440
 
4441
  // ----- Return
4442
+ return WPvivid_PclZip::errorCode();
4443
  }
4444
 
4445
  // ----- Extract the values
4562
  if (@ftell($this->zip_fd) != $v_size)
4563
  {
4564
  // ----- Error log
4565
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
4566
 
4567
  // ----- Return
4568
+ return WPvivid_PclZip::errorCode();
4569
  }
4570
 
4571
  // ----- First try : look if this is an archive with no commentaries (most of the time)
4576
  if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
4577
  {
4578
  // ----- Error log
4579
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4580
 
4581
  // ----- Return
4582
+ return WPvivid_PclZip::errorCode();
4583
  }
4584
 
4585
  // ----- Read for bytes
4603
  if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
4604
  {
4605
  // ----- Error log
4606
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4607
 
4608
  // ----- Return
4609
+ return WPvivid_PclZip::errorCode();
4610
  }
4611
 
4612
  // ----- Read byte per byte in order to find the signature
4638
  {
4639
 
4640
  // ----- Error log
4641
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
4642
 
4643
  // ----- Return
4644
+ return WPvivid_PclZip::errorCode();
4645
  }
4646
  }
4647
 
4653
  {
4654
 
4655
  // ----- Error log
4656
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
4657
 
4658
  // ----- Return
4659
+ return WPvivid_PclZip::errorCode();
4660
  }
4661
 
4662
  // ----- Extract the values
4671
  // While decrypted, zip has training 0 bytes
4672
  if (0) {
4673
  // ----- Error log
4674
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_BAD_FORMAT,
4675
  'The central dir is not at the end of the archive.'
4676
  .' Some trailing bytes exists after the archive.');
4677
 
4678
  // ----- Return
4679
+ return WPvivid_PclZip::errorCode();
4680
  }
4681
  }
4682
 
4742
  $this->privCloseFd();
4743
 
4744
  // ----- Error log
4745
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4746
 
4747
  // ----- Return
4748
+ return WPvivid_PclZip::errorCode();
4749
  }
4750
 
4751
  // ----- Read each entry
4860
  $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
4861
 
4862
  // ----- Creates a temporary zip archive
4863
+ $v_temp_zip = new WPvivid_PclZip($v_zip_temp_name);
4864
 
4865
  // ----- Open the temporary zip file in write mode
4866
  if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
4882
  @unlink($v_zip_temp_name);
4883
 
4884
  // ----- Error log
4885
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4886
 
4887
  // ----- Return
4888
+ return WPvivid_PclZip::errorCode();
4889
  }
4890
 
4891
  // ----- Read the file header
5056
  if (!@mkdir($p_dir, 0777))
5057
  {
5058
  // ----- Error log
5059
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
5060
 
5061
  // ----- Return
5062
+ return WPvivid_PclZip::errorCode();
5063
  }
5064
 
5065
  // ----- Return
5149
  $this->privCloseFd();
5150
  $p_archive_to_add->privCloseFd();
5151
 
5152
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
5153
 
5154
  // ----- Return
5155
+ return WPvivid_PclZip::errorCode();
5156
  }
5157
 
5158
  // ----- Copy the files from the archive to the temporary file
5286
  {
5287
  $this->privCloseFd();
5288
 
5289
+ WPvivid_PclZip::privErrorLog(WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
5290
 
5291
+ // ----- ReturnR
5292
+ return WPvivid_PclZip::errorCode();
5293
  }
5294
 
5295
  // ----- Copy the files from the archive to the temporary file
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: wpvivid
3
  Tags: move, clone, migrate, staging, backup, restore, auto backup, cloud backup
4
  Requires at least: 4.5
5
- Tested up to: 5.8.1
6
  Requires PHP: 5.3
7
- Stable tag: 0.9.65
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
@@ -192,6 +192,13 @@ Thank you for translating WPvivid Backup Plugin to your languages!
192
  * [Nima](https://profiles.wordpress.org/nima78600/) (Persian)
193
 
194
  == Changelog ==
 
 
 
 
 
 
 
195
  = 0.9.65 =
196
  - Fixed: Some WPvivid Backup Plugin settings were reset to default after restore.
197
  - Fixed: Some urls could not be replaced because of escape format problems after restore.
2
  Contributors: wpvivid
3
  Tags: move, clone, migrate, staging, backup, restore, auto backup, cloud backup
4
  Requires at least: 4.5
5
+ Tested up to: 5.8.2
6
  Requires PHP: 5.3
7
+ Stable tag: 0.9.66
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
192
  * [Nima](https://profiles.wordpress.org/nima78600/) (Persian)
193
 
194
  == Changelog ==
195
+ = 0.9.66 =
196
+ - Fixed a Dropbox folder bug.
197
+ - Fixed a conflict between the unused image cleaner and some themes.
198
+ - Fixed a problem that some used images in Elementor were identified as unused.
199
+ - Fixed: Downloading backup would failed in some cases.
200
+ - Added a check to Nginx server when creating a staging site.
201
+ - Optimized the plugin code.
202
  = 0.9.65 =
203
  - Fixed: Some WPvivid Backup Plugin settings were reset to default after restore.
204
  - Fixed: Some urls could not be replaced because of escape format problems after restore.
wpvivid-backuprestore.php CHANGED
@@ -7,7 +7,7 @@
7
  * @wordpress-plugin
8
  * Plugin Name: WPvivid Backup Plugin
9
  * Description: Clone or copy WP sites then move or migrate them to new host (new domain), schedule backups, transfer backups to leading remote storage. All in one.
10
- * Version: 0.9.65
11
  * Author: WPvivid Team
12
  * Author URI: https://wpvivid.com
13
  * License: GPL-3.0+
@@ -21,7 +21,7 @@ if ( ! defined( 'WPINC' ) ) {
21
  die;
22
  }
23
 
24
- define( 'WPVIVID_PLUGIN_VERSION', '0.9.65' );
25
  //
26
  define('WPVIVID_RESTORE_INIT','init');
27
  define('WPVIVID_RESTORE_READY','ready');
7
  * @wordpress-plugin
8
  * Plugin Name: WPvivid Backup Plugin
9
  * Description: Clone or copy WP sites then move or migrate them to new host (new domain), schedule backups, transfer backups to leading remote storage. All in one.
10
+ * Version: 0.9.66
11
  * Author: WPvivid Team
12
  * Author URI: https://wpvivid.com
13
  * License: GPL-3.0+
21
  die;
22
  }
23
 
24
+ define( 'WPVIVID_PLUGIN_VERSION', '0.9.66' );
25
  //
26
  define('WPVIVID_RESTORE_INIT','init');
27
  define('WPVIVID_RESTORE_READY','ready');