Migration, Backup, Staging – WPvivid - Version 0.9.59

Version Description

  • Fixed the PHP Guzzle library support compatibility issue which could cause backup failure in some cases.
  • Fixed some bugs in the plugin code.
  • Optimized the plugin code.
Download this release

Release Info

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

Code changes from version 0.9.58 to 0.9.59

Files changed (165) hide show
  1. admin/class-wpvivid-admin.php +55 -0
  2. includes/class-wpvivid-migrate.php +1 -1
  3. includes/class-wpvivid-zipclass.php +165 -5
  4. includes/class-wpvivid.php +12 -2
  5. includes/customclass/class-wpvivid-google-drive.php +2 -2
  6. includes/lib/google-api-php-client/src/Google/AccessToken/Revoke.php +4 -4
  7. includes/lib/google-api-php-client/src/Google/AccessToken/Verify.php +4 -4
  8. includes/lib/google-api-php-client/src/Google/AuthHandler/AuthHandlerFactory.php +2 -2
  9. includes/lib/google-api-php-client/src/Google/AuthHandler/Guzzle5AuthHandler.php +9 -9
  10. includes/lib/google-api-php-client/src/Google/AuthHandler/Guzzle6AuthHandler.php +9 -9
  11. includes/lib/google-api-php-client/src/Google/Client.php +13 -13
  12. includes/lib/google-api-php-client/src/Google/Http/Batch.php +5 -5
  13. includes/lib/google-api-php-client/src/Google/Http/MediaFileUpload.php +4 -4
  14. includes/lib/google-api-php-client/src/Google/Http/REST.php +7 -7
  15. includes/lib/google-api-php-client/src/Google/Service/Resource.php +1 -1
  16. includes/staging/class-wpvivid-staging-setting.php +2 -2
  17. includes/staging/class-wpvivid-staging.php +5 -10
  18. includes/zip/class-wpvivid-pclzip.php +5734 -0
  19. readme.txt +9 -5
  20. vendor/composer/autoload_files.php +18 -9
  21. vendor/composer/autoload_psr4.php +7 -7
  22. vendor/composer/autoload_static.php +30 -20
  23. vendor/composer/installed.json +7 -7
  24. vendor/google/auth/composer.json +1 -1
  25. vendor/google/auth/src/ApplicationDefaultCredentials.php +6 -6
  26. vendor/google/auth/src/Cache/InvalidArgumentException.php +2 -2
  27. vendor/google/auth/src/Cache/Item.php +2 -2
  28. vendor/google/auth/src/Cache/MemoryCacheItemPool.php +3 -3
  29. vendor/google/auth/src/Cache/SysVCacheItemPool.php +3 -3
  30. vendor/google/auth/src/CacheTrait.php +1 -1
  31. vendor/google/auth/src/Credentials/AppIdentityCredentials.php +2 -2
  32. vendor/google/auth/src/Credentials/GCECredentials.php +8 -8
  33. vendor/google/auth/src/Credentials/IAMCredentials.php +1 -1
  34. vendor/google/auth/src/Credentials/InsecureCredentials.php +2 -2
  35. vendor/google/auth/src/Credentials/ServiceAccountCredentials.php +3 -3
  36. vendor/google/auth/src/Credentials/ServiceAccountJwtAccessCredentials.php +3 -3
  37. vendor/google/auth/src/Credentials/UserRefreshCredentials.php +3 -3
  38. vendor/google/auth/src/CredentialsLoader.php +8 -8
  39. vendor/google/auth/src/FetchAuthTokenCache.php +2 -2
  40. vendor/google/auth/src/FetchAuthTokenInterface.php +1 -1
  41. vendor/google/auth/src/HttpHandler/Guzzle5HttpHandler.php +9 -9
  42. vendor/google/auth/src/HttpHandler/Guzzle6HttpHandler.php +4 -4
  43. vendor/google/auth/src/HttpHandler/HttpHandlerFactory.php +3 -3
  44. vendor/google/auth/src/Middleware/AuthTokenMiddleware.php +3 -3
  45. vendor/google/auth/src/Middleware/ScopedAccessTokenMiddleware.php +4 -4
  46. vendor/google/auth/src/Middleware/SimpleMiddleware.php +3 -3
  47. vendor/google/auth/src/OAuth2.php +7 -7
  48. vendor/google/auth/src/Subscriber/AuthTokenSubscriber.php +5 -5
  49. vendor/google/auth/src/Subscriber/ScopedAccessTokenSubscriber.php +6 -6
  50. vendor/google/auth/src/Subscriber/SimpleSubscriber.php +4 -4
  51. vendor/guzzle/guzzle/src/Guzzle/Log/PsrLogAdapter.php +2 -2
  52. vendor/guzzlehttp/guzzle/composer.json +2 -2
  53. vendor/guzzlehttp/guzzle/src/Client.php +8 -8
  54. vendor/guzzlehttp/guzzle/src/ClientInterface.php +6 -6
  55. vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php +3 -3
  56. vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php +3 -3
  57. vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php +3 -3
  58. vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php +1 -1
  59. vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php +1 -1
  60. vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php +3 -3
  61. vendor/guzzlehttp/guzzle/src/Exception/ClientException.php +1 -1
  62. vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php +2 -2
  63. vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php +1 -1
  64. vendor/guzzlehttp/guzzle/src/Exception/RequestException.php +5 -5
  65. vendor/guzzlehttp/guzzle/src/Exception/SeekException.php +2 -2
  66. vendor/guzzlehttp/guzzle/src/Exception/ServerException.php +1 -1
  67. vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php +1 -1
  68. vendor/guzzlehttp/guzzle/src/Exception/TransferException.php +1 -1
  69. vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php +13 -13
  70. vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php +2 -2
  71. vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php +3 -3
  72. vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php +5 -5
  73. vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php +7 -7
  74. vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php +13 -13
  75. vendor/guzzlehttp/guzzle/src/Handler/Proxy.php +3 -3
  76. vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php +18 -18
  77. vendor/guzzlehttp/guzzle/src/HandlerStack.php +2 -2
  78. vendor/guzzlehttp/guzzle/src/MessageFormatter.php +4 -4
  79. vendor/guzzlehttp/guzzle/src/Middleware.php +11 -11
  80. vendor/guzzlehttp/guzzle/src/Pool.php +5 -5
  81. vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php +4 -4
  82. vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php +9 -9
  83. vendor/guzzlehttp/guzzle/src/RequestOptions.php +1 -1
  84. vendor/guzzlehttp/guzzle/src/RetryMiddleware.php +7 -7
  85. vendor/guzzlehttp/guzzle/src/TransferStats.php +4 -4
  86. vendor/guzzlehttp/guzzle/src/UriTemplate.php +1 -1
  87. vendor/guzzlehttp/guzzle/src/functions.php +7 -7
  88. vendor/guzzlehttp/guzzle/src/functions_include.php +1 -1
  89. vendor/guzzlehttp/promises/composer.json +1 -1
  90. vendor/guzzlehttp/promises/src/AggregateException.php +1 -1
  91. vendor/guzzlehttp/promises/src/CancellationException.php +1 -1
  92. vendor/guzzlehttp/promises/src/Coroutine.php +1 -1
  93. vendor/guzzlehttp/promises/src/EachPromise.php +1 -1
  94. vendor/guzzlehttp/promises/src/FulfilledPromise.php +1 -1
  95. vendor/guzzlehttp/promises/src/Promise.php +1 -1
  96. vendor/guzzlehttp/promises/src/PromiseInterface.php +1 -1
  97. vendor/guzzlehttp/promises/src/PromisorInterface.php +1 -1
  98. vendor/guzzlehttp/promises/src/RejectedPromise.php +1 -1
  99. vendor/guzzlehttp/promises/src/RejectionException.php +1 -1
  100. vendor/guzzlehttp/promises/src/TaskQueue.php +1 -1
  101. vendor/guzzlehttp/promises/src/TaskQueueInterface.php +1 -1
  102. vendor/guzzlehttp/promises/src/functions.php +1 -1
  103. vendor/guzzlehttp/promises/src/functions_include.php +1 -1
  104. vendor/guzzlehttp/psr7/composer.json +2 -2
  105. vendor/guzzlehttp/psr7/src/AppendStream.php +2 -2
  106. vendor/guzzlehttp/psr7/src/BufferStream.php +2 -2
  107. vendor/guzzlehttp/psr7/src/CachingStream.php +2 -2
  108. vendor/guzzlehttp/psr7/src/DroppingStream.php +2 -2
  109. vendor/guzzlehttp/psr7/src/FnStream.php +2 -2
  110. vendor/guzzlehttp/psr7/src/InflateStream.php +2 -2
  111. vendor/guzzlehttp/psr7/src/LazyOpenStream.php +2 -2
  112. vendor/guzzlehttp/psr7/src/LimitStream.php +2 -2
  113. vendor/guzzlehttp/psr7/src/MessageTrait.php +2 -2
  114. vendor/guzzlehttp/psr7/src/MultipartStream.php +2 -2
  115. vendor/guzzlehttp/psr7/src/NoSeekStream.php +2 -2
  116. vendor/guzzlehttp/psr7/src/PumpStream.php +2 -2
  117. vendor/guzzlehttp/psr7/src/Request.php +4 -4
  118. vendor/guzzlehttp/psr7/src/Response.php +3 -3
  119. vendor/guzzlehttp/psr7/src/Rfc7230.php +1 -1
  120. vendor/guzzlehttp/psr7/src/ServerRequest.php +5 -5
  121. vendor/guzzlehttp/psr7/src/Stream.php +2 -2
  122. vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php +2 -2
  123. vendor/guzzlehttp/psr7/src/StreamWrapper.php +2 -2
  124. vendor/guzzlehttp/psr7/src/UploadedFile.php +3 -3
  125. vendor/guzzlehttp/psr7/src/Uri.php +2 -2
  126. vendor/guzzlehttp/psr7/src/UriNormalizer.php +2 -2
  127. vendor/guzzlehttp/psr7/src/UriResolver.php +2 -2
  128. vendor/guzzlehttp/psr7/src/functions.php +8 -8
  129. vendor/guzzlehttp/psr7/src/functions_include.php +1 -1
  130. vendor/monolog/monolog/src/Monolog/ErrorHandler.php +3 -3
  131. vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php +1 -1
  132. vendor/monolog/monolog/src/Monolog/Logger.php +2 -2
  133. vendor/monolog/monolog/src/Monolog/SignalHandler.php +2 -2
  134. vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php +1 -1
  135. vendor/monolog/monolog/tests/Monolog/Handler/PHPConsoleHandlerTest.php +1 -1
  136. vendor/monolog/monolog/tests/Monolog/Handler/PsrHandlerTest.php +1 -1
  137. vendor/monolog/monolog/tests/Monolog/PsrLogCompatTest.php +1 -1
  138. vendor/monolog/monolog/tests/Monolog/SignalHandlerTest.php +1 -1
  139. vendor/psr/cache/composer.json +1 -1
  140. vendor/psr/cache/src/CacheException.php +1 -1
  141. vendor/psr/cache/src/CacheItemInterface.php +1 -1
  142. vendor/psr/cache/src/CacheItemPoolInterface.php +1 -1
  143. vendor/psr/cache/src/InvalidArgumentException.php +1 -1
  144. vendor/psr/http-message/composer.json +1 -1
  145. vendor/psr/http-message/src/MessageInterface.php +1 -1
  146. vendor/psr/http-message/src/RequestInterface.php +1 -1
  147. vendor/psr/http-message/src/ResponseInterface.php +1 -1
  148. vendor/psr/http-message/src/ServerRequestInterface.php +1 -1
  149. vendor/psr/http-message/src/StreamInterface.php +1 -1
  150. vendor/psr/http-message/src/UploadedFileInterface.php +1 -1
  151. vendor/psr/http-message/src/UriInterface.php +1 -1
  152. vendor/psr/log/Psr/Log/AbstractLogger.php +1 -1
  153. vendor/psr/log/Psr/Log/InvalidArgumentException.php +1 -1
  154. vendor/psr/log/Psr/Log/LogLevel.php +1 -1
  155. vendor/psr/log/Psr/Log/LoggerAwareInterface.php +1 -1
  156. vendor/psr/log/Psr/Log/LoggerAwareTrait.php +1 -1
  157. vendor/psr/log/Psr/Log/LoggerInterface.php +1 -1
  158. vendor/psr/log/Psr/Log/LoggerTrait.php +1 -1
  159. vendor/psr/log/Psr/Log/NullLogger.php +1 -1
  160. vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php +6 -6
  161. vendor/psr/log/Psr/Log/Test/TestLogger.php +2 -2
  162. vendor/psr/log/composer.json +1 -1
  163. vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php +1 -1
  164. vendor/symfony/event-dispatcher/Tests/Debug/TraceableEventDispatcherTest.php +2 -2
  165. wpvivid-backuprestore.php +2 -2
admin/class-wpvivid-admin.php CHANGED
@@ -70,6 +70,8 @@ class WPvivid_Admin {
70
 
71
  add_filter('wpvivid_add_log_tab_page', array($this, 'add_log_tab_page'), 10);
72
 
 
 
73
  $this->plugin_name = $plugin_name;
74
  $this->version = $version;
75
  }
@@ -594,6 +596,59 @@ class WPvivid_Admin {
594
  }
595
  }
596
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
597
  public function init_js_var()
598
  {
599
  global $wpvivid_plugin;
70
 
71
  add_filter('wpvivid_add_log_tab_page', array($this, 'add_log_tab_page'), 10);
72
 
73
+ add_action('admin_notices', array($this, 'check_wpvivid_pro_version'));
74
+
75
  $this->plugin_name = $plugin_name;
76
  $this->version = $version;
77
  }
596
  }
597
  }
598
 
599
+ public function check_wpvivid_pro_version()
600
+ {
601
+ if (is_multisite())
602
+ {
603
+ if(!is_network_admin())
604
+ {
605
+ return ;
606
+ }
607
+ }
608
+
609
+ if(!function_exists('get_plugins'))
610
+ require_once(ABSPATH . 'wp-admin/includes/plugin.php');
611
+ $pro_wpvivid_slug='wpvivid-backup-pro/wpvivid-backup-pro.php';
612
+ if (is_multisite())
613
+ {
614
+ $active_plugins = array();
615
+ //network active
616
+ $mu_active_plugins = get_site_option( 'active_sitewide_plugins', array() );
617
+ if(!empty($mu_active_plugins)){
618
+ foreach ($mu_active_plugins as $plugin_name => $data){
619
+ $active_plugins[] = $plugin_name;
620
+ }
621
+ }
622
+ $plugins=get_mu_plugins();
623
+ if(count($plugins) == 0 || !isset($plugins[$pro_wpvivid_slug])){
624
+ $plugins=get_plugins();
625
+ }
626
+ }
627
+ else
628
+ {
629
+ $active_plugins = get_option('active_plugins');
630
+ $plugins=get_plugins();
631
+ }
632
+
633
+ if(!empty($plugins))
634
+ {
635
+ if(isset($plugins[$pro_wpvivid_slug]))
636
+ {
637
+ if(in_array($pro_wpvivid_slug, $active_plugins))
638
+ {
639
+ if(version_compare('2.0.23',$plugins[$pro_wpvivid_slug]['Version'],'>'))
640
+ {
641
+ ?>
642
+ <div class="notice notice-warning" style="padding: 11px 15px;">
643
+ <?php echo sprintf(__('We detected that you are using a lower version of %s Pro, please update it to 2.0.23 or higher to ensure backing up to Google Drive works properly.', 'wpvivid'), apply_filters('wpvivid_white_label_display', 'WPvivid Backup Plugin')); ?>
644
+ </div>
645
+ <?php
646
+ }
647
+ }
648
+ }
649
+ }
650
+ }
651
+
652
  public function init_js_var()
653
  {
654
  global $wpvivid_plugin;
includes/class-wpvivid-migrate.php CHANGED
@@ -1096,7 +1096,7 @@ class WPvivid_Migrate
1096
 
1097
  public function wpvivid_migrate_part_tip($html){
1098
  $backupdir=WPvivid_Setting::get_backupdir();
1099
- $html .= '<p>'.__('<strong>Tips: </strong>The unstable connection between sites could cause a failure of files transfer. In this case, uploading backups to destination site is a good alternative to the automatic website migration.', 'wpvivid-backuprestore').'</p>
1100
  <p><strong>'.__('How to migrate Wordpress site manually to a new domain(site) with WPvivid backup plugin?', 'wpvivid-backuprestore').'</strong></p>
1101
  <p>'.__('1. Download a backup in backups list to your computer.', 'wpvivid-backuprestore').'</p>
1102
  <p>'.__('2. Upload the backup to destination site. There are two ways available to use:', 'wpvivid-backuprestore').'</p>
1096
 
1097
  public function wpvivid_migrate_part_tip($html){
1098
  $backupdir=WPvivid_Setting::get_backupdir();
1099
+ $html .= '<p>'.__('<strong>Tips: </strong>Some web hosts may restrict the connection between the two sites, so you may get a 403 error or unstable connection issue when performing auto migration. In that case, it is recommended to manually transfer the site.', 'wpvivid-backuprestore').'</p>
1100
  <p><strong>'.__('How to migrate Wordpress site manually to a new domain(site) with WPvivid backup plugin?', 'wpvivid-backuprestore').'</strong></p>
1101
  <p>'.__('1. Download a backup in backups list to your computer.', 'wpvivid-backuprestore').'</p>
1102
  <p>'.__('2. Upload the backup to destination site. There are two ways available to use:', 'wpvivid-backuprestore').'</p>
includes/class-wpvivid-zipclass.php CHANGED
@@ -15,11 +15,13 @@ class WPvivid_ZipClass extends Wpvivid_Compress_Default
15
 
16
  public function __construct()
17
  {
18
- if (!class_exists('PclZip')) include_once(ABSPATH.'/wp-admin/includes/class-pclzip.php');
19
- if (!class_exists('PclZip')) {
 
 
20
  $this->last_error = array('result'=>WPVIVID_FAILED,'error'=>"Class PclZip is not detected. Please update or reinstall your WordPress.");
21
  }
22
- }
23
 
24
  public function get_packages($data,$write_child_files_json=false)
25
  {
@@ -1128,6 +1130,164 @@ class WPvivid_PclZip_Class
1128
  }
1129
  }
1130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1131
  $wpvivid_old_time=0;
1132
 
1133
  function wpvivid_function_per_add_callback($p_event, &$p_header)
@@ -1135,9 +1295,9 @@ function wpvivid_function_per_add_callback($p_event, &$p_header)
1135
  if(!file_exists($p_header['filename'])){
1136
  return 0;
1137
  }
1138
- if($p_header['size'] === 0){
1139
  return 0;
1140
- }
1141
 
1142
  global $wpvivid_old_time;
1143
  if(time()-$wpvivid_old_time>30)
15
 
16
  public function __construct()
17
  {
18
+ if (!class_exists('PclZip'))
19
+ include_once(ABSPATH.'/wp-admin/includes/class-pclzip.php');
20
+ if (!class_exists('PclZip'))
21
+ {
22
  $this->last_error = array('result'=>WPVIVID_FAILED,'error'=>"Class PclZip is not detected. Please update or reinstall your WordPress.");
23
  }
24
+ }
25
 
26
  public function get_packages($data,$write_child_files_json=false)
27
  {
1130
  }
1131
  }
1132
 
1133
+ class WPvivid_PclZip_Class_Ex
1134
+ {
1135
+ public function zip($name,$files,$options,$json_info=false)
1136
+ {
1137
+ global $wpvivid_plugin;
1138
+
1139
+ if(file_exists($name))
1140
+ @unlink($name);
1141
+
1142
+ if (!class_exists('WPvivid_PclZip'))
1143
+ include_once WPVIVID_PLUGIN_DIR . '/includes/zip/class-wpvivid-pclzip.php';
1144
+ $archive = new WPvivid_PclZip($name);
1145
+
1146
+ if(isset($options['compress']['no_compress']))
1147
+ {
1148
+ $no_compress=$options['compress']['no_compress'];
1149
+ }
1150
+ else
1151
+ {
1152
+ $no_compress=1;
1153
+ }
1154
+
1155
+ if(isset($options['compress']['use_temp_file']))
1156
+ {
1157
+ $use_temp_file=1;
1158
+ }
1159
+ else
1160
+ {
1161
+ $use_temp_file=0;
1162
+ }
1163
+
1164
+ if(isset($options['compress']['use_temp_size']))
1165
+ {
1166
+ $use_temp_size=$options['compress']['use_temp_size'];
1167
+ }
1168
+ else
1169
+ {
1170
+ $use_temp_size=16;
1171
+ }
1172
+
1173
+ if(isset($options['root_path']))
1174
+ {
1175
+ $replace_path=$options['root_path'];
1176
+ }
1177
+ else if(isset($options['root_flag']))
1178
+ {
1179
+ $replace_path=$this->get_root_flag_path($options['root_flag']);
1180
+ }
1181
+ else
1182
+ {
1183
+ $replace_path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir();
1184
+ }
1185
+
1186
+ if($json_info!==false)
1187
+ {
1188
+ $temp_path = dirname($name).DIRECTORY_SEPARATOR.'wpvivid_package_info.json';
1189
+ if(file_exists($temp_path))
1190
+ {
1191
+ @unlink($temp_path);
1192
+ }
1193
+ $json_info['php_version'] = phpversion();
1194
+ global $wpdb;
1195
+ $json_info['mysql_version'] = $wpdb->db_version();
1196
+ file_put_contents($temp_path,print_r(json_encode($json_info),true));
1197
+ $archive -> add($temp_path,WPVIVID_PCLZIP_OPT_REMOVE_PATH,dirname($temp_path));
1198
+ @unlink($temp_path);
1199
+ }
1200
+
1201
+ $wpvivid_plugin->wpvivid_log->WriteLog('Prepare to zip files. file: '.basename($name),'notice');
1202
+
1203
+ if($no_compress)
1204
+ {
1205
+ if($use_temp_file==1)
1206
+ {
1207
+ if($use_temp_size!=0)
1208
+ {
1209
+ $ret = $archive -> add($files,WPVIVID_PCLZIP_OPT_REMOVE_PATH,$replace_path,WPVIVID_PCLZIP_CB_PRE_ADD,'wpvivid_function_per_add_callback',WPVIVID_PCLZIP_OPT_NO_COMPRESSION,WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD,$use_temp_size);
1210
+ }
1211
+ else
1212
+ {
1213
+ $ret = $archive -> add($files,WPVIVID_PCLZIP_OPT_REMOVE_PATH,$replace_path,WPVIVID_PCLZIP_CB_PRE_ADD,'wpvivid_function_per_add_callback',WPVIVID_PCLZIP_OPT_NO_COMPRESSION,WPVIVID_PCLZIP_OPT_TEMP_FILE_ON);
1214
+ }
1215
+ }
1216
+ else
1217
+ {
1218
+ $ret = $archive -> add($files,WPVIVID_PCLZIP_OPT_REMOVE_PATH,$replace_path,WPVIVID_PCLZIP_CB_PRE_ADD,'wpvivid_function_per_add_callback',WPVIVID_PCLZIP_OPT_NO_COMPRESSION,WPVIVID_PCLZIP_OPT_TEMP_FILE_OFF);
1219
+ }
1220
+ }
1221
+ else
1222
+ {
1223
+ if($use_temp_file==1)
1224
+ {
1225
+ if($use_temp_size!=0)
1226
+ {
1227
+ $ret = $archive -> add($files,WPVIVID_PCLZIP_OPT_REMOVE_PATH,$replace_path,WPVIVID_PCLZIP_CB_PRE_ADD,'wpvivid_function_per_add_callback',WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD,$use_temp_size);
1228
+ }
1229
+ else
1230
+ {
1231
+ $ret = $archive -> add($files,WPVIVID_PCLZIP_OPT_REMOVE_PATH,$replace_path,WPVIVID_PCLZIP_CB_PRE_ADD,'wpvivid_function_per_add_callback',WPVIVID_PCLZIP_OPT_TEMP_FILE_ON);
1232
+ }
1233
+ }
1234
+ else
1235
+ {
1236
+ $ret = $archive -> add($files,WPVIVID_PCLZIP_OPT_REMOVE_PATH,$replace_path,WPVIVID_PCLZIP_CB_PRE_ADD,'wpvivid_function_per_add_callback',WPVIVID_PCLZIP_OPT_TEMP_FILE_OFF);
1237
+ }
1238
+ }
1239
+
1240
+ if(!$ret)
1241
+ {
1242
+ $wpvivid_plugin->wpvivid_log->WriteLog('Failed to add zip files, error: '.$archive->errorInfo(true),'notice');
1243
+ $size=size_format(disk_free_space(dirname($name)),2);
1244
+ $wpvivid_plugin->wpvivid_log->WriteLog('disk_free_space : '.$size,'notice');
1245
+ return array('result'=>WPVIVID_FAILED,'error'=>$archive->errorInfo(true));
1246
+ }
1247
+
1248
+ $size=filesize($name);
1249
+ if($size===false)
1250
+ {
1251
+ $wpvivid_plugin->wpvivid_log->WriteLog('Failed to add zip files, error: file not found after backup success','error');
1252
+ $size=size_format(disk_free_space(dirname($name)),2);
1253
+ $wpvivid_plugin->wpvivid_log->WriteLog('disk_free_space : '.$size,'notice');
1254
+ return array('result'=>WPVIVID_FAILED,'error'=>'The file compression failed while backing up becuase of '.$name.' file not found. Please try again. The available disk space: '.$size.'.');
1255
+ }
1256
+ else if($size==0)
1257
+ {
1258
+ $wpvivid_plugin->wpvivid_log->WriteLog('Failed to add zip files, error: file size 0B after backup success','error');
1259
+ $size=size_format(disk_free_space(dirname($name)),2);
1260
+ $wpvivid_plugin->wpvivid_log->WriteLog('disk_free_space : '.$size,'notice');
1261
+ return array('result'=>WPVIVID_FAILED,'error'=>'The file compression failed while backing up. The size of '.$name.' file is 0. Please make sure there is an enough disk space to backup. Then try again. The available disk space: '.$size.'.');
1262
+ }
1263
+
1264
+ $wpvivid_plugin->wpvivid_log->WriteLog('Adding zip files completed.'.basename($name).', filesize: '.size_format(filesize($name),2),'notice');
1265
+ $file_data = array();
1266
+ $file_data['file_name'] = basename($name);
1267
+ $file_data['size'] = filesize($name);
1268
+
1269
+ return array('result'=>WPVIVID_SUCCESS,'file_data'=>$file_data);
1270
+ }
1271
+
1272
+ public function get_root_flag_path($flag)
1273
+ {
1274
+ $path='';
1275
+ if($flag==WPVIVID_BACKUP_ROOT_WP_CONTENT)
1276
+ {
1277
+ $path=WP_CONTENT_DIR;
1278
+ }
1279
+ else if($flag==WPVIVID_BACKUP_ROOT_CUSTOM)
1280
+ {
1281
+ $path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir();
1282
+ }
1283
+ else if($flag==WPVIVID_BACKUP_ROOT_WP_ROOT)
1284
+ {
1285
+ $path=ABSPATH;
1286
+ }
1287
+ return $path;
1288
+ }
1289
+ }
1290
+
1291
  $wpvivid_old_time=0;
1292
 
1293
  function wpvivid_function_per_add_callback($p_event, &$p_header)
1295
  if(!file_exists($p_header['filename'])){
1296
  return 0;
1297
  }
1298
+ /*if($p_header['size'] === 0){
1299
  return 0;
1300
+ }*/
1301
 
1302
  global $wpvivid_old_time;
1303
  if(time()-$wpvivid_old_time>30)
includes/class-wpvivid.php CHANGED
@@ -136,6 +136,7 @@ class WPvivid {
136
 
137
  add_filter('wpvivid_get_mainwp_sync_data', array($this, 'get_mainwp_sync_data'), 10);
138
  //
 
139
  //Initialisation schedule hook
140
  $this->init_cron();
141
  //Initialisation log object
@@ -857,7 +858,7 @@ class WPvivid {
857
  if ($ret['result'] != WPVIVID_SUCCESS)
858
  {
859
  $this->end_shutdown_function=true;
860
- echo json_encode($ret);
861
  die();
862
  }
863
 
@@ -893,7 +894,7 @@ class WPvivid {
893
  $log->CloseFile();
894
  WPvivid_error_log::create_error_log($log->log_file);
895
  error_log($message);
896
- echo json_encode($ret);
897
  die();
898
  }
899
  }
@@ -6189,4 +6190,13 @@ class WPvivid {
6189
  $ret = $public_interface->mainwp_data($data);
6190
  return $ret;
6191
  }
 
 
 
 
 
 
 
 
 
6192
  }
136
 
137
  add_filter('wpvivid_get_mainwp_sync_data', array($this, 'get_mainwp_sync_data'), 10);
138
  //
139
+ add_filter('wpvivid_get_zip_object_class_ex',array($this, 'get_zip_object_class'));
140
  //Initialisation schedule hook
141
  $this->init_cron();
142
  //Initialisation log object
858
  if ($ret['result'] != WPVIVID_SUCCESS)
859
  {
860
  $this->end_shutdown_function=true;
861
+ //echo json_encode($ret);
862
  die();
863
  }
864
 
894
  $log->CloseFile();
895
  WPvivid_error_log::create_error_log($log->log_file);
896
  error_log($message);
897
+ //echo json_encode($ret);
898
  die();
899
  }
900
  }
6190
  $ret = $public_interface->mainwp_data($data);
6191
  return $ret;
6192
  }
6193
+
6194
+ public function get_zip_object_class($class)
6195
+ {
6196
+ if(version_compare(phpversion(),'8.0.0','>='))
6197
+ {
6198
+ return 'WPvivid_PclZip_Class';
6199
+ }
6200
+ return $class;
6201
+ }
6202
  }
includes/customclass/class-wpvivid-google-drive.php CHANGED
@@ -890,7 +890,7 @@ class Wpvivid_Google_drive extends WPvivid_Remote
890
  } else {
891
  $options['headers']['Range']='bytes=0-'.$upload_end;
892
  }
893
- $request = new GuzzleHttp\Psr7\Request('GET', $download_url,$options['headers']);
894
  $http_request = $http->send($request);
895
  $http_response=$http_request->getStatusCode();
896
  if (200 == $http_response || 206 == $http_response)
@@ -932,7 +932,7 @@ class Wpvivid_Google_drive extends WPvivid_Remote
932
  {
933
  $http = $client->authorize();
934
  $url='https://www.googleapis.com/drive/v2/files/'.$file_id;
935
- $request = new GuzzleHttp\Psr7\Request('GET', $url);
936
  $http_request = $http->send($request);
937
 
938
  $http_response=$http_request->getStatusCode();
890
  } else {
891
  $options['headers']['Range']='bytes=0-'.$upload_end;
892
  }
893
+ $request = new WPvividGuzzleHttp\Psr7\Request('GET', $download_url,$options['headers']);
894
  $http_request = $http->send($request);
895
  $http_response=$http_request->getStatusCode();
896
  if (200 == $http_response || 206 == $http_response)
932
  {
933
  $http = $client->authorize();
934
  $url='https://www.googleapis.com/drive/v2/files/'.$file_id;
935
+ $request = new WPvividGuzzleHttp\Psr7\Request('GET', $url);
936
  $http_request = $http->send($request);
937
 
938
  $http_response=$http_request->getStatusCode();
includes/lib/google-api-php-client/src/Google/AccessToken/Revoke.php CHANGED
@@ -16,10 +16,10 @@
16
  * limitations under the License.
17
  */
18
 
19
- use Google\Auth\HttpHandler\HttpHandlerFactory;
20
- use GuzzleHttp\ClientInterface;
21
- use GuzzleHttp\Psr7;
22
- use GuzzleHttp\Psr7\Request;
23
 
24
  /**
25
  * Wrapper around Google Access Tokens which provides convenience functions
16
  * limitations under the License.
17
  */
18
 
19
+ use WPvividGoogle\Auth\HttpHandler\HttpHandlerFactory;
20
+ use WPvividGuzzleHttp\ClientInterface;
21
+ use WPvividGuzzleHttp\Psr7;
22
+ use WPvividGuzzleHttp\Psr7\Request;
23
 
24
  /**
25
  * Wrapper around Google Access Tokens which provides convenience functions
includes/lib/google-api-php-client/src/Google/AccessToken/Verify.php CHANGED
@@ -18,10 +18,10 @@
18
 
19
  use Firebase\JWT\ExpiredException as ExpiredExceptionV3;
20
  use Firebase\JWT\SignatureInvalidException;
21
- use GuzzleHttp\Client;
22
- use GuzzleHttp\ClientInterface;
23
- use Psr\Cache\CacheItemPoolInterface;
24
- use Google\Auth\Cache\MemoryCacheItemPool;
25
  use Stash\Driver\FileSystem;
26
  use Stash\Pool;
27
 
18
 
19
  use Firebase\JWT\ExpiredException as ExpiredExceptionV3;
20
  use Firebase\JWT\SignatureInvalidException;
21
+ use WPvividGuzzleHttp\Client;
22
+ use WPvividGuzzleHttp\ClientInterface;
23
+ use WPvividPsr\Cache\CacheItemPoolInterface;
24
+ use WPvividGoogle\Auth\Cache\MemoryCacheItemPool;
25
  use Stash\Driver\FileSystem;
26
  use Stash\Pool;
27
 
includes/lib/google-api-php-client/src/Google/AuthHandler/AuthHandlerFactory.php CHANGED
@@ -15,8 +15,8 @@
15
  * limitations under the License.
16
  */
17
 
18
- use GuzzleHttp\Client;
19
- use GuzzleHttp\ClientInterface;
20
 
21
  class Google_AuthHandler_AuthHandlerFactory
22
  {
15
  * limitations under the License.
16
  */
17
 
18
+ use WPvividGuzzleHttp\Client;
19
+ use WPvividGuzzleHttp\ClientInterface;
20
 
21
  class Google_AuthHandler_AuthHandlerFactory
22
  {
includes/lib/google-api-php-client/src/Google/AuthHandler/Guzzle5AuthHandler.php CHANGED
@@ -1,14 +1,14 @@
1
  <?php
2
 
3
- use Google\Auth\CredentialsLoader;
4
- use Google\Auth\HttpHandler\HttpHandlerFactory;
5
- use Google\Auth\FetchAuthTokenCache;
6
- use Google\Auth\Subscriber\AuthTokenSubscriber;
7
- use Google\Auth\Subscriber\ScopedAccessTokenSubscriber;
8
- use Google\Auth\Subscriber\SimpleSubscriber;
9
- use GuzzleHttp\Client;
10
- use GuzzleHttp\ClientInterface;
11
- use Psr\Cache\CacheItemPoolInterface;
12
 
13
  /**
14
  *
1
  <?php
2
 
3
+ use WPvividGoogle\Auth\CredentialsLoader;
4
+ use WPvividGoogle\Auth\HttpHandler\HttpHandlerFactory;
5
+ use WPvividGoogle\Auth\FetchAuthTokenCache;
6
+ use WPvividGoogle\Auth\Subscriber\AuthTokenSubscriber;
7
+ use WPvividGoogle\Auth\Subscriber\ScopedAccessTokenSubscriber;
8
+ use WPvividGoogle\Auth\Subscriber\SimpleSubscriber;
9
+ use WPvividGuzzleHttp\Client;
10
+ use WPvividGuzzleHttp\ClientInterface;
11
+ use WPvividPsr\Cache\CacheItemPoolInterface;
12
 
13
  /**
14
  *
includes/lib/google-api-php-client/src/Google/AuthHandler/Guzzle6AuthHandler.php CHANGED
@@ -1,14 +1,14 @@
1
  <?php
2
 
3
- use Google\Auth\CredentialsLoader;
4
- use Google\Auth\HttpHandler\HttpHandlerFactory;
5
- use Google\Auth\FetchAuthTokenCache;
6
- use Google\Auth\Middleware\AuthTokenMiddleware;
7
- use Google\Auth\Middleware\ScopedAccessTokenMiddleware;
8
- use Google\Auth\Middleware\SimpleMiddleware;
9
- use GuzzleHttp\Client;
10
- use GuzzleHttp\ClientInterface;
11
- use Psr\Cache\CacheItemPoolInterface;
12
 
13
  /**
14
  *
1
  <?php
2
 
3
+ use WPvividGoogle\Auth\CredentialsLoader;
4
+ use WPvividGoogle\Auth\HttpHandler\HttpHandlerFactory;
5
+ use WPvividGoogle\Auth\FetchAuthTokenCache;
6
+ use WPvividGoogle\Auth\Middleware\AuthTokenMiddleware;
7
+ use WPvividGoogle\Auth\Middleware\ScopedAccessTokenMiddleware;
8
+ use WPvividGoogle\Auth\Middleware\SimpleMiddleware;
9
+ use WPvividGuzzleHttp\Client;
10
+ use WPvividGuzzleHttp\ClientInterface;
11
+ use WPvividPsr\Cache\CacheItemPoolInterface;
12
 
13
  /**
14
  *
includes/lib/google-api-php-client/src/Google/Client.php CHANGED
@@ -15,19 +15,19 @@
15
  * limitations under the License.
16
  */
17
 
18
- use Google\Auth\ApplicationDefaultCredentials;
19
- use Google\Auth\Cache\MemoryCacheItemPool;
20
- use Google\Auth\CredentialsLoader;
21
- use Google\Auth\HttpHandler\HttpHandlerFactory;
22
- use Google\Auth\OAuth2;
23
- use Google\Auth\Credentials\ServiceAccountCredentials;
24
- use Google\Auth\Credentials\UserRefreshCredentials;
25
- use GuzzleHttp\Client;
26
- use GuzzleHttp\ClientInterface;
27
- use GuzzleHttp\Ring\Client\StreamHandler;
28
- use Psr\Cache\CacheItemPoolInterface;
29
- use Psr\Http\Message\RequestInterface;
30
- use Psr\Log\LoggerInterface;
31
  use Monolog\Logger;
32
  use Monolog\Handler\StreamHandler as MonologStreamHandler;
33
  use Monolog\Handler\SyslogHandler as MonologSyslogHandler;
15
  * limitations under the License.
16
  */
17
 
18
+ use WPvividGoogle\Auth\ApplicationDefaultCredentials;
19
+ use WPvividGoogle\Auth\Cache\MemoryCacheItemPool;
20
+ use WPvividGoogle\Auth\CredentialsLoader;
21
+ use WPvividGoogle\Auth\HttpHandler\HttpHandlerFactory;
22
+ use WPvividGoogle\Auth\OAuth2;
23
+ use WPvividGoogle\Auth\Credentials\ServiceAccountCredentials;
24
+ use WPvividGoogle\Auth\Credentials\UserRefreshCredentials;
25
+ use WPvividGuzzleHttp\Client;
26
+ use WPvividGuzzleHttp\ClientInterface;
27
+ use WPvividGuzzleHttp\Ring\Client\StreamHandler;
28
+ use WPvividPsr\Cache\CacheItemPoolInterface;
29
+ use WPvividPsr\Http\Message\RequestInterface;
30
+ use WPvividPsr\Log\LoggerInterface;
31
  use Monolog\Logger;
32
  use Monolog\Handler\StreamHandler as MonologStreamHandler;
33
  use Monolog\Handler\SyslogHandler as MonologSyslogHandler;
includes/lib/google-api-php-client/src/Google/Http/Batch.php CHANGED
@@ -15,11 +15,11 @@
15
  * limitations under the License.
16
  */
17
 
18
- use GuzzleHttp\Psr7;
19
- use GuzzleHttp\Psr7\Request;
20
- use GuzzleHttp\Psr7\Response;
21
- use Psr\Http\Message\RequestInterface;
22
- use Psr\Http\Message\ResponseInterface;
23
 
24
  /**
25
  * Class to handle batched requests to the Google API service.
15
  * limitations under the License.
16
  */
17
 
18
+ use WPvividGuzzleHttp\Psr7;
19
+ use WPvividGuzzleHttp\Psr7\Request;
20
+ use WPvividGuzzleHttp\Psr7\Response;
21
+ use WPvividPsr\Http\Message\RequestInterface;
22
+ use WPvividPsr\Http\Message\ResponseInterface;
23
 
24
  /**
25
  * Class to handle batched requests to the Google API service.
includes/lib/google-api-php-client/src/Google/Http/MediaFileUpload.php CHANGED
@@ -15,10 +15,10 @@
15
  * limitations under the License.
16
  */
17
 
18
- use GuzzleHttp\Psr7;
19
- use GuzzleHttp\Psr7\Request;
20
- use GuzzleHttp\Psr7\Uri;
21
- use Psr\Http\Message\RequestInterface;
22
 
23
  /**
24
  * Manage large file uploads, which may be media but can be any type
15
  * limitations under the License.
16
  */
17
 
18
+ use WPvividGuzzleHttp\Psr7;
19
+ use WPvividGuzzleHttp\Psr7\Request;
20
+ use WPvividGuzzleHttp\Psr7\Uri;
21
+ use WPvividPsr\Http\Message\RequestInterface;
22
 
23
  /**
24
  * Manage large file uploads, which may be media but can be any type
includes/lib/google-api-php-client/src/Google/Http/REST.php CHANGED
@@ -15,12 +15,12 @@
15
  * limitations under the License.
16
  */
17
 
18
- use Google\Auth\HttpHandler\HttpHandlerFactory;
19
- use GuzzleHttp\ClientInterface;
20
- use GuzzleHttp\Exception\RequestException;
21
- use GuzzleHttp\Psr7\Response;
22
- use Psr\Http\Message\RequestInterface;
23
- use Psr\Http\Message\ResponseInterface;
24
 
25
  /**
26
  * This class implements the RESTful transport of apiServiceRequest()'s
@@ -80,7 +80,7 @@ class Google_Http_REST
80
 
81
  $response = $e->getResponse();
82
  // specific checking for Guzzle 5: convert to PSR7 response
83
- if ($response instanceof \GuzzleHttp\Message\ResponseInterface) {
84
  $response = new Response(
85
  $response->getStatusCode(),
86
  $response->getHeaders() ?: [],
15
  * limitations under the License.
16
  */
17
 
18
+ use WPvividGoogle\Auth\HttpHandler\HttpHandlerFactory;
19
+ use WPvividGuzzleHttp\ClientInterface;
20
+ use WPvividGuzzleHttp\Exception\RequestException;
21
+ use WPvividGuzzleHttp\Psr7\Response;
22
+ use WPvividPsr\Http\Message\RequestInterface;
23
+ use WPvividPsr\Http\Message\ResponseInterface;
24
 
25
  /**
26
  * This class implements the RESTful transport of apiServiceRequest()'s
80
 
81
  $response = $e->getResponse();
82
  // specific checking for Guzzle 5: convert to PSR7 response
83
+ if ($response instanceof \WPvividGuzzleHttp\Message\ResponseInterface) {
84
  $response = new Response(
85
  $response->getStatusCode(),
86
  $response->getHeaders() ?: [],
includes/lib/google-api-php-client/src/Google/Service/Resource.php CHANGED
@@ -15,7 +15,7 @@
15
  * limitations under the License.
16
  */
17
 
18
- use GuzzleHttp\Psr7\Request;
19
 
20
  /**
21
  * Implements the actual methods/resources of the discovered Google API using magic function
15
  * limitations under the License.
16
  */
17
 
18
+ use WPvividGuzzleHttp\Psr7\Request;
19
 
20
  /**
21
  * Implements the actual methods/resources of the discovered Google API using magic function
includes/staging/class-wpvivid-staging-setting.php CHANGED
@@ -56,7 +56,7 @@ class WPvivid_Staging_Setting_Free
56
  $staging_keep_setting = isset($options['staging_keep_setting']) ? $options['staging_keep_setting'] : true;
57
 
58
 
59
- $staging_not_need_login=isset($options['not_need_login']) ? $options['not_need_login'] : false;
60
  if($staging_not_need_login)
61
  {
62
  $staging_not_need_login_check='checked';
@@ -236,7 +236,7 @@ class WPvivid_Staging_Setting_Free
236
  $staging_keep_setting = isset($options['staging_keep_setting']) ? $options['staging_keep_setting'] : true;
237
 
238
 
239
- $staging_not_need_login=isset($options['not_need_login']) ? $options['not_need_login'] : false;
240
  if($staging_not_need_login)
241
  {
242
  $staging_not_need_login_check='checked';
56
  $staging_keep_setting = isset($options['staging_keep_setting']) ? $options['staging_keep_setting'] : true;
57
 
58
 
59
+ $staging_not_need_login=isset($options['not_need_login']) ? $options['not_need_login'] : true;
60
  if($staging_not_need_login)
61
  {
62
  $staging_not_need_login_check='checked';
236
  $staging_keep_setting = isset($options['staging_keep_setting']) ? $options['staging_keep_setting'] : true;
237
 
238
 
239
+ $staging_not_need_login=isset($options['not_need_login']) ? $options['not_need_login'] : true;
240
  if($staging_not_need_login)
241
  {
242
  $staging_not_need_login_check='checked';
includes/staging/class-wpvivid-staging.php CHANGED
@@ -1385,17 +1385,12 @@ class WPvivid_Staging_Free
1385
  $options=get_option('wpvivid_staging_options',array());
1386
  }
1387
 
1388
- if(isset($options['not_need_login']))
1389
- {
1390
- if(!$options['not_need_login']) {
1391
- if (!current_user_can('manage_options')) {
1392
- $this->output_login_page();
1393
- }
1394
- }
1395
- }
1396
- else
1397
  {
1398
- if (!current_user_can('manage_options')) {
 
1399
  $this->output_login_page();
1400
  }
1401
  }
1385
  $options=get_option('wpvivid_staging_options',array());
1386
  }
1387
 
1388
+ $staging_not_need_login=isset($options['not_need_login']) ? $options['not_need_login'] : true;
1389
+
1390
+ if(!$staging_not_need_login)
 
 
 
 
 
 
1391
  {
1392
+ if(!current_user_can('manage_options'))
1393
+ {
1394
  $this->output_login_page();
1395
  }
1396
  }
includes/zip/class-wpvivid-pclzip.php ADDED
@@ -0,0 +1,5734 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // --------------------------------------------------------------------------------
3
+ // PhpConcept Library - Zip Module 2.8.2
4
+ // --------------------------------------------------------------------------------
5
+ // License GNU/LGPL - Vincent Blavet - August 2009
6
+ // http://www.phpconcept.net
7
+ // --------------------------------------------------------------------------------
8
+ //
9
+ // Presentation :
10
+ // PclZip is a PHP library that manage ZIP archives.
11
+ // So far tests show that archives generated by PclZip are readable by
12
+ // WinZip application and other tools.
13
+ //
14
+ // Description :
15
+ // See readme.txt and http://www.phpconcept.net
16
+ //
17
+ // Warning :
18
+ // This library and the associated files are non commercial, non professional
19
+ // work.
20
+ // It should not have unexpected results. However if any damage is caused by
21
+ // this software the author can not be responsible.
22
+ // The use of this software is at the risk of the user.
23
+ //
24
+ // --------------------------------------------------------------------------------
25
+ // $Id: pclzip.lib.php,v 1.60 2009/09/30 21:01:04 vblavet Exp $
26
+ // --------------------------------------------------------------------------------
27
+
28
+ // ----- Constants
29
+ if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
30
+ define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
31
+ }
32
+
33
+ // ----- File list separator
34
+ // In version 1.x of PclZip, the separator for file list is a space
35
+ // (which is not a very smart choice, specifically for windows paths !).
36
+ // A better separator should be a comma (,). This constant gives you the
37
+ // ability to change that.
38
+ // However notice that changing this value, may have impact on existing
39
+ // scripts, using space separated filenames.
40
+ // Recommended values for compatibility with older versions :
41
+ //define( 'PCLZIP_SEPARATOR', ' ' );
42
+ // Recommended values for smart separation of filenames.
43
+ if (!defined('PCLZIP_SEPARATOR')) {
44
+ define( 'PCLZIP_SEPARATOR', ',' );
45
+ }
46
+
47
+ // ----- Error configuration
48
+ // 0 : PclZip Class integrated error handling
49
+ // 1 : PclError external library error handling. By enabling this
50
+ // you must ensure that you have included PclError library.
51
+ // [2,...] : reserved for futur use
52
+ if (!defined('PCLZIP_ERROR_EXTERNAL')) {
53
+ define( 'PCLZIP_ERROR_EXTERNAL', 0 );
54
+ }
55
+
56
+ // ----- Optional static temporary directory
57
+ // By default temporary files are generated in the script current
58
+ // path.
59
+ // If defined :
60
+ // - MUST BE terminated by a '/'.
61
+ // - MUST be a valid, already created directory
62
+ // Samples :
63
+ // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
64
+ // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
65
+ if (!defined('PCLZIP_TEMPORARY_DIR')) {
66
+ define( 'PCLZIP_TEMPORARY_DIR', '' );
67
+ }
68
+
69
+ // ----- Optional threshold ratio for use of temporary files
70
+ // Pclzip sense the size of the file to add/extract and decide to
71
+ // use or not temporary file. The algorithm is looking for
72
+ // memory_limit of PHP and apply a ratio.
73
+ // threshold = memory_limit * ratio.
74
+ // Recommended values are under 0.5. Default 0.47.
75
+ // Samples :
76
+ // define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 );
77
+ if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
78
+ define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 );
79
+ }
80
+
81
+ // --------------------------------------------------------------------------------
82
+ // ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED *****
83
+ // --------------------------------------------------------------------------------
84
+
85
+ // ----- Global variables
86
+ $g_pclzip_version = "2.8.2";
87
+
88
+ // ----- Error codes
89
+ // -1 : Unable to open file in binary write mode
90
+ // -2 : Unable to open file in binary read mode
91
+ // -3 : Invalid parameters
92
+ // -4 : File does not exist
93
+ // -5 : Filename is too long (max. 255)
94
+ // -6 : Not a valid zip file
95
+ // -7 : Invalid extracted file size
96
+ // -8 : Unable to create directory
97
+ // -9 : Invalid archive extension
98
+ // -10 : Invalid archive format
99
+ // -11 : Unable to delete file (unlink)
100
+ // -12 : Unable to rename file (rename)
101
+ // -13 : Invalid header checksum
102
+ // -14 : Invalid archive size
103
+ define( 'WPVIVID_PCLZIP_ERR_USER_ABORTED', 2 );
104
+ define( 'WPVIVID_PCLZIP_ERR_NO_ERROR', 0 );
105
+ define( 'WPVIVID_PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );
106
+ define( 'WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL', -2 );
107
+ define( 'WPVIVID_PCLZIP_ERR_INVALID_PARAMETER', -3 );
108
+ define( 'WPVIVID_PCLZIP_ERR_MISSING_FILE', -4 );
109
+ define( 'WPVIVID_PCLZIP_ERR_FILENAME_TOO_LONG', -5 );
110
+ define( 'WPVIVID_PCLZIP_ERR_INVALID_ZIP', -6 );
111
+ define( 'WPVIVID_PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );
112
+ define( 'WPVIVID_PCLZIP_ERR_DIR_CREATE_FAIL', -8 );
113
+ define( 'WPVIVID_PCLZIP_ERR_BAD_EXTENSION', -9 );
114
+ define( 'WPVIVID_PCLZIP_ERR_BAD_FORMAT', -10 );
115
+ define( 'WPVIVID_PCLZIP_ERR_DELETE_FILE_FAIL', -11 );
116
+ define( 'WPVIVID_PCLZIP_ERR_RENAME_FILE_FAIL', -12 );
117
+ define( 'WPVIVID_PCLZIP_ERR_BAD_CHECKSUM', -13 );
118
+ define( 'WPVIVID_PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );
119
+ define( 'WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );
120
+ define( 'WPVIVID_PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );
121
+ define( 'WPVIVID_PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 );
122
+ define( 'WPVIVID_PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 );
123
+ define( 'WPVIVID_PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 );
124
+ define( 'WPVIVID_PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 );
125
+ define( 'WPVIVID_PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 );
126
+
127
+ // ----- Options values
128
+ define( 'WPVIVID_PCLZIP_OPT_PATH', 77001 );
129
+ define( 'WPVIVID_PCLZIP_OPT_ADD_PATH', 77002 );
130
+ define( 'WPVIVID_PCLZIP_OPT_REMOVE_PATH', 77003 );
131
+ define( 'WPVIVID_PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );
132
+ define( 'WPVIVID_PCLZIP_OPT_SET_CHMOD', 77005 );
133
+ define( 'WPVIVID_PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );
134
+ define( 'WPVIVID_PCLZIP_OPT_NO_COMPRESSION', 77007 );
135
+ define( 'WPVIVID_PCLZIP_OPT_BY_NAME', 77008 );
136
+ define( 'WPVIVID_PCLZIP_OPT_BY_INDEX', 77009 );
137
+ define( 'WPVIVID_PCLZIP_OPT_BY_EREG', 77010 );
138
+ define( 'WPVIVID_PCLZIP_OPT_BY_PREG', 77011 );
139
+ define( 'WPVIVID_PCLZIP_OPT_COMMENT', 77012 );
140
+ define( 'WPVIVID_PCLZIP_OPT_ADD_COMMENT', 77013 );
141
+ define( 'WPVIVID_PCLZIP_OPT_PREPEND_COMMENT', 77014 );
142
+ define( 'WPVIVID_PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 );
143
+ define( 'WPVIVID_PCLZIP_OPT_REPLACE_NEWER', 77016 );
144
+ define( 'WPVIVID_PCLZIP_OPT_STOP_ON_ERROR', 77017 );
145
+ // Having big trouble with crypt. Need to multiply 2 long int
146
+ // which is not correctly supported by PHP ...
147
+ //define( 'PCLZIP_OPT_CRYPT', 77018 );
148
+ define( 'WPVIVID_PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 );
149
+ define( 'WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 );
150
+ define( 'WPVIVID_PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias
151
+ define( 'WPVIVID_PCLZIP_OPT_TEMP_FILE_ON', 77021 );
152
+ define( 'WPVIVID_PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias
153
+ define( 'WPVIVID_PCLZIP_OPT_TEMP_FILE_OFF', 77022 );
154
+ define( 'WPVIVID_PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias
155
+
156
+ // ----- File description attributes
157
+ define( 'WPVIVID_PCLZIP_ATT_FILE_NAME', 79001 );
158
+ define( 'WPVIVID_PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 );
159
+ define( 'WPVIVID_PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 );
160
+ define( 'WPVIVID_PCLZIP_ATT_FILE_MTIME', 79004 );
161
+ define( 'WPVIVID_PCLZIP_ATT_FILE_CONTENT', 79005 );
162
+ define( 'WPVIVID_PCLZIP_ATT_FILE_COMMENT', 79006 );
163
+
164
+ // ----- Call backs values
165
+ define( 'WPVIVID_PCLZIP_CB_PRE_EXTRACT', 78001 );
166
+ define( 'WPVIVID_PCLZIP_CB_POST_EXTRACT', 78002 );
167
+ define( 'WPVIVID_PCLZIP_CB_PRE_ADD', 78003 );
168
+ define( 'WPVIVID_PCLZIP_CB_POST_ADD', 78004 );
169
+ /* For futur use
170
+ define( 'PCLZIP_CB_PRE_LIST', 78005 );
171
+ define( 'PCLZIP_CB_POST_LIST', 78006 );
172
+ define( 'PCLZIP_CB_PRE_DELETE', 78007 );
173
+ define( 'PCLZIP_CB_POST_DELETE', 78008 );
174
+ */
175
+
176
+ // --------------------------------------------------------------------------------
177
+ // Class : PclZip
178
+ // Description :
179
+ // PclZip is the class that represent a Zip archive.
180
+ // The public methods allow the manipulation of the archive.
181
+ // Attributes :
182
+ // Attributes must not be accessed directly.
183
+ // Methods :
184
+ // PclZip() : Object creator
185
+ // create() : Creates the Zip archive
186
+ // listContent() : List the content of the Zip archive
187
+ // extract() : Extract the content of the archive
188
+ // properties() : List the properties of the archive
189
+ // --------------------------------------------------------------------------------
190
+ class WPvivid_PclZip
191
+ {
192
+ // ----- Filename of the zip file
193
+ var $zipname = '';
194
+
195
+ // ----- File descriptor of the zip file
196
+ var $zip_fd = 0;
197
+
198
+ // ----- Internal error handling
199
+ var $error_code = 1;
200
+ var $error_string = '';
201
+
202
+ // ----- Current status of the magic_quotes_runtime
203
+ // This value store the php configuration for magic_quotes
204
+ // The class can then disable the magic_quotes and reset it after
205
+ var $magic_quotes_status;
206
+
207
+ // --------------------------------------------------------------------------------
208
+ // Function : PclZip()
209
+ // Description :
210
+ // Creates a PclZip object and set the name of the associated Zip archive
211
+ // filename.
212
+ // Note that no real action is taken, if the archive does not exist it is not
213
+ // created. Use create() for that.
214
+ // --------------------------------------------------------------------------------
215
+ function __construct($p_zipname)
216
+ {
217
+
218
+ // ----- Tests the zlib
219
+ if (!function_exists('gzopen'))
220
+ {
221
+ die('Abort '.basename(__FILE__).' : Missing zlib extensions');
222
+ }
223
+
224
+ // ----- Set the attributes
225
+ $this->zipname = $p_zipname;
226
+ $this->zip_fd = 0;
227
+ $this->magic_quotes_status = -1;
228
+
229
+ // ----- Return
230
+ return;
231
+ }
232
+
233
+ public function PclZip($p_zipname) {
234
+ self::__construct($p_zipname);
235
+ }
236
+ // --------------------------------------------------------------------------------
237
+
238
+ // --------------------------------------------------------------------------------
239
+ // Function :
240
+ // create($p_filelist, $p_add_dir="", $p_remove_dir="")
241
+ // create($p_filelist, $p_option, $p_option_value, ...)
242
+ // Description :
243
+ // This method supports two different synopsis. The first one is historical.
244
+ // This method creates a Zip Archive. The Zip file is created in the
245
+ // filesystem. The files and directories indicated in $p_filelist
246
+ // are added in the archive. See the parameters description for the
247
+ // supported format of $p_filelist.
248
+ // When a directory is in the list, the directory and its content is added
249
+ // in the archive.
250
+ // In this synopsis, the function takes an optional variable list of
251
+ // options. See below the supported options.
252
+ // Parameters :
253
+ // $p_filelist : An array containing file or directory names, or
254
+ // a string containing one filename or one directory name, or
255
+ // a string containing a list of filenames and/or directory
256
+ // names separated by spaces.
257
+ // $p_add_dir : A path to add before the real path of the archived file,
258
+ // in order to have it memorized in the archive.
259
+ // $p_remove_dir : A path to remove from the real path of the file to archive,
260
+ // in order to have a shorter path memorized in the archive.
261
+ // When $p_add_dir and $p_remove_dir are set, $p_remove_dir
262
+ // is removed first, before $p_add_dir is added.
263
+ // Options :
264
+ // WPVIVID_PCLZIP_OPT_ADD_PATH :
265
+ // WPVIVID_PCLZIP_OPT_REMOVE_PATH :
266
+ // WPVIVID_PCLZIP_OPT_REMOVE_ALL_PATH :
267
+ // WPVIVID_PCLZIP_OPT_COMMENT :
268
+ // WPVIVID_PCLZIP_CB_PRE_ADD :
269
+ // WPVIVID_PCLZIP_CB_POST_ADD :
270
+ // Return Values :
271
+ // 0 on failure,
272
+ // The list of the added files, with a status of the add action.
273
+ // (see PclZip::listContent() for list entry format)
274
+ // --------------------------------------------------------------------------------
275
+ function create($p_filelist)
276
+ {
277
+ $v_result=1;
278
+
279
+ // ----- Reset the error handler
280
+ $this->privErrorReset();
281
+
282
+ // ----- Set default values
283
+ $v_options = array();
284
+ $v_options[WPVIVID_PCLZIP_OPT_NO_COMPRESSION] = FALSE;
285
+
286
+ // ----- Look for variable options arguments
287
+ $v_size = func_num_args();
288
+
289
+ // ----- Look for arguments
290
+ if ($v_size > 1) {
291
+ // ----- Get the arguments
292
+ $v_arg_list = func_get_args();
293
+
294
+ // ----- Remove from the options list the first argument
295
+ array_shift($v_arg_list);
296
+ $v_size--;
297
+
298
+ // ----- Look for first arg
299
+ if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
300
+
301
+ // ----- Parse the options
302
+ $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
303
+ array (WPVIVID_PCLZIP_OPT_REMOVE_PATH => 'optional',
304
+ WPVIVID_PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
305
+ WPVIVID_PCLZIP_OPT_ADD_PATH => 'optional',
306
+ WPVIVID_PCLZIP_CB_PRE_ADD => 'optional',
307
+ WPVIVID_PCLZIP_CB_POST_ADD => 'optional',
308
+ WPVIVID_PCLZIP_OPT_NO_COMPRESSION => 'optional',
309
+ WPVIVID_PCLZIP_OPT_COMMENT => 'optional',
310
+ WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
311
+ WPVIVID_PCLZIP_OPT_TEMP_FILE_ON => 'optional',
312
+ WPVIVID_PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
313
+ //, PCLZIP_OPT_CRYPT => 'optional'
314
+ ));
315
+ if ($v_result != 1) {
316
+ return 0;
317
+ }
318
+ }
319
+
320
+ // ----- Look for 2 args
321
+ // Here we need to support the first historic synopsis of the
322
+ // method.
323
+ else {
324
+
325
+ // ----- Get the first argument
326
+ $v_options[WPVIVID_PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
327
+
328
+ // ----- Look for the optional second argument
329
+ if ($v_size == 2) {
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
+ }
337
+ }
338
+ }
339
+
340
+ // ----- Look for default option values
341
+ $this->privOptionDefaultThreshold($v_options);
342
+
343
+ // ----- Init
344
+ $v_string_list = array();
345
+ $v_att_list = array();
346
+ $v_filedescr_list = array();
347
+ $p_result_list = array();
348
+
349
+ // ----- Look if the $p_filelist is really an array
350
+ if (is_array($p_filelist)) {
351
+
352
+ // ----- Look if the first element is also an array
353
+ // This will mean that this is a file description entry
354
+ if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
355
+ $v_att_list = $p_filelist;
356
+ }
357
+
358
+ // ----- The list is a list of string names
359
+ else {
360
+ $v_string_list = $p_filelist;
361
+ }
362
+ }
363
+
364
+ // ----- Look if the $p_filelist is a string
365
+ else if (is_string($p_filelist)) {
366
+ // ----- Create a list from the string
367
+ $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
368
+ }
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
+
376
+ // ----- Reformat the string list
377
+ if (sizeof($v_string_list) != 0) {
378
+ foreach ($v_string_list as $v_string) {
379
+ if ($v_string != '') {
380
+ $v_att_list[][WPVIVID_PCLZIP_ATT_FILE_NAME] = $v_string;
381
+ }
382
+ else {
383
+ }
384
+ }
385
+ }
386
+
387
+ // ----- For each file in the list check the attributes
388
+ $v_supported_attributes
389
+ = array ( WPVIVID_PCLZIP_ATT_FILE_NAME => 'mandatory'
390
+ ,WPVIVID_PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
391
+ ,WPVIVID_PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
392
+ ,WPVIVID_PCLZIP_ATT_FILE_MTIME => 'optional'
393
+ ,WPVIVID_PCLZIP_ATT_FILE_CONTENT => 'optional'
394
+ ,WPVIVID_PCLZIP_ATT_FILE_COMMENT => 'optional'
395
+ );
396
+ foreach ($v_att_list as $v_entry) {
397
+ $v_result = $this->privFileDescrParseAtt($v_entry,
398
+ $v_filedescr_list[],
399
+ $v_options,
400
+ $v_supported_attributes);
401
+ if ($v_result != 1) {
402
+ return 0;
403
+ }
404
+ }
405
+
406
+ // ----- Expand the filelist (expand directories)
407
+ $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
408
+ if ($v_result != 1) {
409
+ return 0;
410
+ }
411
+
412
+ // ----- Call the create fct
413
+ $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options);
414
+ if ($v_result != 1) {
415
+ return 0;
416
+ }
417
+
418
+ // ----- Return
419
+ return $p_result_list;
420
+ }
421
+ // --------------------------------------------------------------------------------
422
+
423
+ // --------------------------------------------------------------------------------
424
+ // Function :
425
+ // add($p_filelist, $p_add_dir="", $p_remove_dir="")
426
+ // add($p_filelist, $p_option, $p_option_value, ...)
427
+ // Description :
428
+ // This method supports two synopsis. The first one is historical.
429
+ // This methods add the list of files in an existing archive.
430
+ // If a file with the same name already exists, it is added at the end of the
431
+ // archive, the first one is still present.
432
+ // If the archive does not exist, it is created.
433
+ // Parameters :
434
+ // $p_filelist : An array containing file or directory names, or
435
+ // a string containing one filename or one directory name, or
436
+ // a string containing a list of filenames and/or directory
437
+ // names separated by spaces.
438
+ // $p_add_dir : A path to add before the real path of the archived file,
439
+ // in order to have it memorized in the archive.
440
+ // $p_remove_dir : A path to remove from the real path of the file to archive,
441
+ // in order to have a shorter path memorized in the archive.
442
+ // When $p_add_dir and $p_remove_dir are set, $p_remove_dir
443
+ // is removed first, before $p_add_dir is added.
444
+ // Options :
445
+ // WPVIVID_PCLZIP_OPT_ADD_PATH :
446
+ // WPVIVID_PCLZIP_OPT_REMOVE_PATH :
447
+ // WPVIVID_PCLZIP_OPT_REMOVE_ALL_PATH :
448
+ // WPVIVID_PCLZIP_OPT_COMMENT :
449
+ // WPVIVID_PCLZIP_OPT_ADD_COMMENT :
450
+ // WPVIVID_PCLZIP_OPT_PREPEND_COMMENT :
451
+ // WPVIVID_PCLZIP_CB_PRE_ADD :
452
+ // WPVIVID_PCLZIP_CB_POST_ADD :
453
+ // Return Values :
454
+ // 0 on failure,
455
+ // The list of the added files, with a status of the add action.
456
+ // (see PclZip::listContent() for list entry format)
457
+ // --------------------------------------------------------------------------------
458
+ function add($p_filelist)
459
+ {
460
+ $v_result=1;
461
+
462
+ // ----- Reset the error handler
463
+ $this->privErrorReset();
464
+
465
+ // ----- Set default values
466
+ $v_options = array();
467
+ $v_options[WPVIVID_PCLZIP_OPT_NO_COMPRESSION] = FALSE;
468
+
469
+ // ----- Look for variable options arguments
470
+ $v_size = func_num_args();
471
+
472
+ // ----- Look for arguments
473
+ if ($v_size > 1) {
474
+ // ----- Get the arguments
475
+ $v_arg_list = func_get_args();
476
+
477
+ // ----- Remove form the options list the first argument
478
+ array_shift($v_arg_list);
479
+ $v_size--;
480
+
481
+ // ----- Look for first arg
482
+ if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
483
+
484
+ // ----- Parse the options
485
+ $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
486
+ array (WPVIVID_PCLZIP_OPT_REMOVE_PATH => 'optional',
487
+ WPVIVID_PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
488
+ WPVIVID_PCLZIP_OPT_ADD_PATH => 'optional',
489
+ WPVIVID_PCLZIP_CB_PRE_ADD => 'optional',
490
+ WPVIVID_PCLZIP_CB_POST_ADD => 'optional',
491
+ WPVIVID_PCLZIP_OPT_NO_COMPRESSION => 'optional',
492
+ WPVIVID_PCLZIP_OPT_COMMENT => 'optional',
493
+ WPVIVID_PCLZIP_OPT_ADD_COMMENT => 'optional',
494
+ WPVIVID_PCLZIP_OPT_PREPEND_COMMENT => 'optional',
495
+ WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
496
+ WPVIVID_PCLZIP_OPT_TEMP_FILE_ON => 'optional',
497
+ WPVIVID_PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
498
+ //, PCLZIP_OPT_CRYPT => 'optional'
499
+ ));
500
+ if ($v_result != 1) {
501
+ return 0;
502
+ }
503
+ }
504
+
505
+ // ----- Look for 2 args
506
+ // Here we need to support the first historic synopsis of the
507
+ // method.
508
+ else {
509
+
510
+ // ----- Get the first argument
511
+ $v_options[WPVIVID_PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
512
+
513
+ // ----- Look for the optional second argument
514
+ if ($v_size == 2) {
515
+ $v_options[WPVIVID_PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
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;
523
+ }
524
+ }
525
+ }
526
+
527
+ // ----- Look for default option values
528
+ $this->privOptionDefaultThreshold($v_options);
529
+
530
+ // ----- Init
531
+ $v_string_list = array();
532
+ $v_att_list = array();
533
+ $v_filedescr_list = array();
534
+ $p_result_list = array();
535
+
536
+ // ----- Look if the $p_filelist is really an array
537
+ if (is_array($p_filelist)) {
538
+
539
+ // ----- Look if the first element is also an array
540
+ // This will mean that this is a file description entry
541
+ if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
542
+ $v_att_list = $p_filelist;
543
+ }
544
+
545
+ // ----- The list is a list of string names
546
+ else {
547
+ $v_string_list = $p_filelist;
548
+ }
549
+ }
550
+
551
+ // ----- Look if the $p_filelist is a string
552
+ else if (is_string($p_filelist)) {
553
+ // ----- Create a list from the string
554
+ $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
555
+ }
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
+
563
+ // ----- Reformat the string list
564
+ if (sizeof($v_string_list) != 0) {
565
+ foreach ($v_string_list as $v_string) {
566
+ $v_att_list[][WPVIVID_PCLZIP_ATT_FILE_NAME] = $v_string;
567
+ }
568
+ }
569
+
570
+ // ----- For each file in the list check the attributes
571
+ $v_supported_attributes
572
+ = array ( WPVIVID_PCLZIP_ATT_FILE_NAME => 'mandatory'
573
+ ,WPVIVID_PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
574
+ ,WPVIVID_PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
575
+ ,WPVIVID_PCLZIP_ATT_FILE_MTIME => 'optional'
576
+ ,WPVIVID_PCLZIP_ATT_FILE_CONTENT => 'optional'
577
+ ,WPVIVID_PCLZIP_ATT_FILE_COMMENT => 'optional'
578
+ );
579
+ foreach ($v_att_list as $v_entry) {
580
+ $v_result = $this->privFileDescrParseAtt($v_entry,
581
+ $v_filedescr_list[],
582
+ $v_options,
583
+ $v_supported_attributes);
584
+ if ($v_result != 1) {
585
+ return 0;
586
+ }
587
+ }
588
+
589
+ // ----- Expand the filelist (expand directories)
590
+ $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
591
+ if ($v_result != 1) {
592
+ return 0;
593
+ }
594
+
595
+ // ----- Call the create fct
596
+ $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
597
+ if ($v_result != 1) {
598
+ return 0;
599
+ }
600
+
601
+ // ----- Return
602
+ return $p_result_list;
603
+ }
604
+ // --------------------------------------------------------------------------------
605
+
606
+ // --------------------------------------------------------------------------------
607
+ // Function : listContent()
608
+ // Description :
609
+ // This public method, gives the list of the files and directories, with their
610
+ // properties.
611
+ // The properties of each entries in the list are (used also in other functions) :
612
+ // filename : Name of the file. For a create or add action it is the filename
613
+ // given by the user. For an extract function it is the filename
614
+ // of the extracted file.
615
+ // stored_filename : Name of the file / directory stored in the archive.
616
+ // size : Size of the stored file.
617
+ // compressed_size : Size of the file's data compressed in the archive
618
+ // (without the headers overhead)
619
+ // mtime : Last known modification date of the file (UNIX timestamp)
620
+ // comment : Comment associated with the file
621
+ // folder : true | false
622
+ // index : index of the file in the archive
623
+ // status : status of the action (depending of the action) :
624
+ // Values are :
625
+ // ok : OK !
626
+ // filtered : the file / dir is not extracted (filtered by user)
627
+ // already_a_directory : the file can not be extracted because a
628
+ // directory with the same name already exists
629
+ // write_protected : the file can not be extracted because a file
630
+ // with the same name already exists and is
631
+ // write protected
632
+ // newer_exist : the file was not extracted because a newer file exists
633
+ // path_creation_fail : the file is not extracted because the folder
634
+ // does not exist and can not be created
635
+ // write_error : the file was not extracted because there was a
636
+ // error while writing the file
637
+ // read_error : the file was not extracted because there was a error
638
+ // while reading the file
639
+ // invalid_header : the file was not extracted because of an archive
640
+ // format error (bad file header)
641
+ // Note that each time a method can continue operating when there
642
+ // is an action error on a file, the error is only logged in the file status.
643
+ // Return Values :
644
+ // 0 on an unrecoverable failure,
645
+ // The list of the files in the archive.
646
+ // --------------------------------------------------------------------------------
647
+ function listContent()
648
+ {
649
+ $v_result=1;
650
+
651
+ // ----- Reset the error handler
652
+ $this->privErrorReset();
653
+
654
+ // ----- Check archive
655
+ if (!$this->privCheckFormat()) {
656
+ return(0);
657
+ }
658
+
659
+ // ----- Call the extracting fct
660
+ $p_list = array();
661
+ if (($v_result = $this->privList($p_list)) != 1)
662
+ {
663
+ unset($p_list);
664
+ return(0);
665
+ }
666
+
667
+ // ----- Return
668
+ return $p_list;
669
+ }
670
+ // --------------------------------------------------------------------------------
671
+
672
+ // --------------------------------------------------------------------------------
673
+ // Function :
674
+ // extract($p_path="./", $p_remove_path="")
675
+ // extract([$p_option, $p_option_value, ...])
676
+ // Description :
677
+ // This method supports two synopsis. The first one is historical.
678
+ // This method extract all the files / directories from the archive to the
679
+ // folder indicated in $p_path.
680
+ // If you want to ignore the 'root' part of path of the memorized files
681
+ // you can indicate this in the optional $p_remove_path parameter.
682
+ // By default, if a newer file with the same name already exists, the
683
+ // file is not extracted.
684
+ //
685
+ // If both WPVIVID_PCLZIP_OPT_PATH and WPVIVID_PCLZIP_OPT_ADD_PATH options
686
+ // are used, the path indicated in WPVIVID_PCLZIP_OPT_ADD_PATH is append
687
+ // at the end of the path value of WPVIVID_PCLZIP_OPT_PATH.
688
+ // Parameters :
689
+ // $p_path : Path where the files and directories are to be extracted
690
+ // $p_remove_path : First part ('root' part) of the memorized path
691
+ // (if any similar) to remove while extracting.
692
+ // Options :
693
+ // WPVIVID_PCLZIP_OPT_PATH :
694
+ // WPVIVID_PCLZIP_OPT_ADD_PATH :
695
+ // WPVIVID_PCLZIP_OPT_REMOVE_PATH :
696
+ // WPVIVID_PCLZIP_OPT_REMOVE_ALL_PATH :
697
+ // WPVIVID_PCLZIP_CB_PRE_EXTRACT :
698
+ // WPVIVID_PCLZIP_CB_POST_EXTRACT :
699
+ // Return Values :
700
+ // 0 or a negative value on failure,
701
+ // The list of the extracted files, with a status of the action.
702
+ // (see PclZip::listContent() for list entry format)
703
+ // --------------------------------------------------------------------------------
704
+ function extract()
705
+ {
706
+ $v_result=1;
707
+
708
+ // ----- Reset the error handler
709
+ $this->privErrorReset();
710
+
711
+ // ----- Check archive
712
+ if (!$this->privCheckFormat()) {
713
+ return(0);
714
+ }
715
+
716
+ // ----- Set default values
717
+ $v_options = array();
718
+ // $v_path = "./";
719
+ $v_path = '';
720
+ $v_remove_path = "";
721
+ $v_remove_all_path = false;
722
+
723
+ // ----- Look for variable options arguments
724
+ $v_size = func_num_args();
725
+
726
+ // ----- Default values for option
727
+ $v_options[WPVIVID_PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
728
+
729
+ // ----- Look for arguments
730
+ if ($v_size > 0) {
731
+ // ----- Get the arguments
732
+ $v_arg_list = func_get_args();
733
+
734
+ // ----- Look for first arg
735
+ if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
736
+
737
+ // ----- Parse the options
738
+ $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
739
+ array (WPVIVID_PCLZIP_OPT_PATH => 'optional',
740
+ WPVIVID_PCLZIP_OPT_REMOVE_PATH => 'optional',
741
+ WPVIVID_PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
742
+ WPVIVID_PCLZIP_OPT_ADD_PATH => 'optional',
743
+ WPVIVID_PCLZIP_CB_PRE_EXTRACT => 'optional',
744
+ WPVIVID_PCLZIP_CB_POST_EXTRACT => 'optional',
745
+ WPVIVID_PCLZIP_OPT_SET_CHMOD => 'optional',
746
+ WPVIVID_PCLZIP_OPT_BY_NAME => 'optional',
747
+ WPVIVID_PCLZIP_OPT_BY_EREG => 'optional',
748
+ WPVIVID_PCLZIP_OPT_BY_PREG => 'optional',
749
+ WPVIVID_PCLZIP_OPT_BY_INDEX => 'optional',
750
+ WPVIVID_PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
751
+ WPVIVID_PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional',
752
+ WPVIVID_PCLZIP_OPT_REPLACE_NEWER => 'optional'
753
+ ,WPVIVID_PCLZIP_OPT_STOP_ON_ERROR => 'optional'
754
+ ,WPVIVID_PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
755
+ WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
756
+ WPVIVID_PCLZIP_OPT_TEMP_FILE_ON => 'optional',
757
+ WPVIVID_PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
758
+ ));
759
+ if ($v_result != 1) {
760
+ return 0;
761
+ }
762
+
763
+ // ----- Set the arguments
764
+ if (isset($v_options[WPVIVID_PCLZIP_OPT_PATH])) {
765
+ $v_path = $v_options[WPVIVID_PCLZIP_OPT_PATH];
766
+ }
767
+ if (isset($v_options[WPVIVID_PCLZIP_OPT_REMOVE_PATH])) {
768
+ $v_remove_path = $v_options[WPVIVID_PCLZIP_OPT_REMOVE_PATH];
769
+ }
770
+ if (isset($v_options[WPVIVID_PCLZIP_OPT_REMOVE_ALL_PATH])) {
771
+ $v_remove_all_path = $v_options[WPVIVID_PCLZIP_OPT_REMOVE_ALL_PATH];
772
+ }
773
+ if (isset($v_options[WPVIVID_PCLZIP_OPT_ADD_PATH])) {
774
+ // ----- Check for '/' in last path char
775
+ if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
776
+ $v_path .= '/';
777
+ }
778
+ $v_path .= $v_options[WPVIVID_PCLZIP_OPT_ADD_PATH];
779
+ }
780
+ }
781
+
782
+ // ----- Look for 2 args
783
+ // Here we need to support the first historic synopsis of the
784
+ // method.
785
+ else {
786
+
787
+ // ----- Get the first argument
788
+ $v_path = $v_arg_list[0];
789
+
790
+ // ----- Look for the optional second argument
791
+ if ($v_size == 2) {
792
+ $v_remove_path = $v_arg_list[1];
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;
800
+ }
801
+ }
802
+ }
803
+
804
+ // ----- Look for default option values
805
+ $this->privOptionDefaultThreshold($v_options);
806
+
807
+ // ----- Trace
808
+
809
+ // ----- Call the extracting fct
810
+ $p_list = array();
811
+ $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path,
812
+ $v_remove_all_path, $v_options);
813
+ if ($v_result < 1) {
814
+ unset($p_list);
815
+ return(0);
816
+ }
817
+
818
+ // ----- Return
819
+ return $p_list;
820
+ }
821
+ // --------------------------------------------------------------------------------
822
+
823
+
824
+ // --------------------------------------------------------------------------------
825
+ // Function :
826
+ // extractByIndex($p_index, $p_path="./", $p_remove_path="")
827
+ // extractByIndex($p_index, [$p_option, $p_option_value, ...])
828
+ // Description :
829
+ // This method supports two synopsis. The first one is historical.
830
+ // This method is doing a partial extract of the archive.
831
+ // The extracted files or folders are identified by their index in the
832
+ // archive (from 0 to n).
833
+ // Note that if the index identify a folder, only the folder entry is
834
+ // extracted, not all the files included in the archive.
835
+ // Parameters :
836
+ // $p_index : A single index (integer) or a string of indexes of files to
837
+ // extract. The form of the string is "0,4-6,8-12" with only numbers
838
+ // and '-' for range or ',' to separate ranges. No spaces or ';'
839
+ // are allowed.
840
+ // $p_path : Path where the files and directories are to be extracted
841
+ // $p_remove_path : First part ('root' part) of the memorized path
842
+ // (if any similar) to remove while extracting.
843
+ // Options :
844
+ // WPVIVID_PCLZIP_OPT_PATH :
845
+ // WPVIVID_PCLZIP_OPT_ADD_PATH :
846
+ // WPVIVID_PCLZIP_OPT_REMOVE_PATH :
847
+ // WPVIVID_PCLZIP_OPT_REMOVE_ALL_PATH :
848
+ // WPVIVID_PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and
849
+ // not as files.
850
+ // The resulting content is in a new field 'content' in the file
851
+ // structure.
852
+ // This option must be used alone (any other options are ignored).
853
+ // WPVIVID_PCLZIP_CB_PRE_EXTRACT :
854
+ // WPVIVID_PCLZIP_CB_POST_EXTRACT :
855
+ // Return Values :
856
+ // 0 on failure,
857
+ // The list of the extracted files, with a status of the action.
858
+ // (see PclZip::listContent() for list entry format)
859
+ // --------------------------------------------------------------------------------
860
+ //function extractByIndex($p_index, options...)
861
+ function extractByIndex($p_index)
862
+ {
863
+ $v_result=1;
864
+
865
+ // ----- Reset the error handler
866
+ $this->privErrorReset();
867
+
868
+ // ----- Check archive
869
+ if (!$this->privCheckFormat()) {
870
+ return(0);
871
+ }
872
+
873
+ // ----- Set default values
874
+ $v_options = array();
875
+ // $v_path = "./";
876
+ $v_path = '';
877
+ $v_remove_path = "";
878
+ $v_remove_all_path = false;
879
+
880
+ // ----- Look for variable options arguments
881
+ $v_size = func_num_args();
882
+
883
+ // ----- Default values for option
884
+ $v_options[WPVIVID_PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
885
+
886
+ // ----- Look for arguments
887
+ if ($v_size > 1) {
888
+ // ----- Get the arguments
889
+ $v_arg_list = func_get_args();
890
+
891
+ // ----- Remove form the options list the first argument
892
+ array_shift($v_arg_list);
893
+ $v_size--;
894
+
895
+ // ----- Look for first arg
896
+ if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
897
+
898
+ // ----- Parse the options
899
+ $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
900
+ array (WPVIVID_PCLZIP_OPT_PATH => 'optional',
901
+ WPVIVID_PCLZIP_OPT_REMOVE_PATH => 'optional',
902
+ WPVIVID_PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
903
+ WPVIVID_PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
904
+ WPVIVID_PCLZIP_OPT_ADD_PATH => 'optional',
905
+ WPVIVID_PCLZIP_CB_PRE_EXTRACT => 'optional',
906
+ WPVIVID_PCLZIP_CB_POST_EXTRACT => 'optional',
907
+ WPVIVID_PCLZIP_OPT_SET_CHMOD => 'optional',
908
+ WPVIVID_PCLZIP_OPT_REPLACE_NEWER => 'optional'
909
+ ,WPVIVID_PCLZIP_OPT_STOP_ON_ERROR => 'optional'
910
+ ,WPVIVID_PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
911
+ WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
912
+ WPVIVID_PCLZIP_OPT_TEMP_FILE_ON => 'optional',
913
+ WPVIVID_PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
914
+ ));
915
+ if ($v_result != 1) {
916
+ return 0;
917
+ }
918
+
919
+ // ----- Set the arguments
920
+ if (isset($v_options[WPVIVID_PCLZIP_OPT_PATH])) {
921
+ $v_path = $v_options[WPVIVID_PCLZIP_OPT_PATH];
922
+ }
923
+ if (isset($v_options[WPVIVID_PCLZIP_OPT_REMOVE_PATH])) {
924
+ $v_remove_path = $v_options[WPVIVID_PCLZIP_OPT_REMOVE_PATH];
925
+ }
926
+ if (isset($v_options[WPVIVID_PCLZIP_OPT_REMOVE_ALL_PATH])) {
927
+ $v_remove_all_path = $v_options[WPVIVID_PCLZIP_OPT_REMOVE_ALL_PATH];
928
+ }
929
+ if (isset($v_options[WPVIVID_PCLZIP_OPT_ADD_PATH])) {
930
+ // ----- Check for '/' in last path char
931
+ if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
932
+ $v_path .= '/';
933
+ }
934
+ $v_path .= $v_options[WPVIVID_PCLZIP_OPT_ADD_PATH];
935
+ }
936
+ if (!isset($v_options[WPVIVID_PCLZIP_OPT_EXTRACT_AS_STRING])) {
937
+ $v_options[WPVIVID_PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
938
+ }
939
+ else {
940
+ }
941
+ }
942
+
943
+ // ----- Look for 2 args
944
+ // Here we need to support the first historic synopsis of the
945
+ // method.
946
+ else {
947
+
948
+ // ----- Get the first argument
949
+ $v_path = $v_arg_list[0];
950
+
951
+ // ----- Look for the optional second argument
952
+ if ($v_size == 2) {
953
+ $v_remove_path = $v_arg_list[1];
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;
961
+ }
962
+ }
963
+ }
964
+
965
+ // ----- Trace
966
+
967
+ // ----- Trick
968
+ // Here I want to reuse extractByRule(), so I need to parse the $p_index
969
+ // with privParseOptions()
970
+ $v_arg_trick = array (WPVIVID_PCLZIP_OPT_BY_INDEX, $p_index);
971
+ $v_options_trick = array();
972
+ $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
973
+ array (WPVIVID_PCLZIP_OPT_BY_INDEX => 'optional' ));
974
+ if ($v_result != 1) {
975
+ return 0;
976
+ }
977
+ $v_options[WPVIVID_PCLZIP_OPT_BY_INDEX] = $v_options_trick[WPVIVID_PCLZIP_OPT_BY_INDEX];
978
+
979
+ // ----- Look for default option values
980
+ $this->privOptionDefaultThreshold($v_options);
981
+
982
+ // ----- Call the extracting fct
983
+ if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
984
+ return(0);
985
+ }
986
+
987
+ // ----- Return
988
+ return $p_list;
989
+ }
990
+ // --------------------------------------------------------------------------------
991
+
992
+ // --------------------------------------------------------------------------------
993
+ // Function :
994
+ // delete([$p_option, $p_option_value, ...])
995
+ // Description :
996
+ // This method removes files from the archive.
997
+ // If no parameters are given, then all the archive is emptied.
998
+ // Parameters :
999
+ // None or optional arguments.
1000
+ // Options :
1001
+ // WPVIVID_PCLZIP_OPT_BY_INDEX :
1002
+ // WPVIVID_PCLZIP_OPT_BY_NAME :
1003
+ // WPVIVID_PCLZIP_OPT_BY_EREG :
1004
+ // WPVIVID_PCLZIP_OPT_BY_PREG :
1005
+ // Return Values :
1006
+ // 0 on failure,
1007
+ // The list of the files which are still present in the archive.
1008
+ // (see PclZip::listContent() for list entry format)
1009
+ // --------------------------------------------------------------------------------
1010
+ function delete()
1011
+ {
1012
+ $v_result=1;
1013
+
1014
+ // ----- Reset the error handler
1015
+ $this->privErrorReset();
1016
+
1017
+ // ----- Check archive
1018
+ if (!$this->privCheckFormat()) {
1019
+ return(0);
1020
+ }
1021
+
1022
+ // ----- Set default values
1023
+ $v_options = array();
1024
+
1025
+ // ----- Look for variable options arguments
1026
+ $v_size = func_num_args();
1027
+
1028
+ // ----- Look for arguments
1029
+ if ($v_size > 0) {
1030
+ // ----- Get the arguments
1031
+ $v_arg_list = func_get_args();
1032
+
1033
+ // ----- Parse the options
1034
+ $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
1035
+ array (WPVIVID_PCLZIP_OPT_BY_NAME => 'optional',
1036
+ WPVIVID_PCLZIP_OPT_BY_EREG => 'optional',
1037
+ WPVIVID_PCLZIP_OPT_BY_PREG => 'optional',
1038
+ WPVIVID_PCLZIP_OPT_BY_INDEX => 'optional' ));
1039
+ if ($v_result != 1) {
1040
+ return 0;
1041
+ }
1042
+ }
1043
+
1044
+ // ----- Magic quotes trick
1045
+ $this->privDisableMagicQuotes();
1046
+
1047
+ // ----- Call the delete fct
1048
+ $v_list = array();
1049
+ if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
1050
+ $this->privSwapBackMagicQuotes();
1051
+ unset($v_list);
1052
+ return(0);
1053
+ }
1054
+
1055
+ // ----- Magic quotes trick
1056
+ $this->privSwapBackMagicQuotes();
1057
+
1058
+ // ----- Return
1059
+ return $v_list;
1060
+ }
1061
+ // --------------------------------------------------------------------------------
1062
+
1063
+ // --------------------------------------------------------------------------------
1064
+ // Function : deleteByIndex()
1065
+ // Description :
1066
+ // ***** Deprecated *****
1067
+ // delete(WPVIVID_PCLZIP_OPT_BY_INDEX, $p_index) should be preferred.
1068
+ // --------------------------------------------------------------------------------
1069
+ function deleteByIndex($p_index)
1070
+ {
1071
+
1072
+ $p_list = $this->delete(WPVIVID_PCLZIP_OPT_BY_INDEX, $p_index);
1073
+
1074
+ // ----- Return
1075
+ return $p_list;
1076
+ }
1077
+ // --------------------------------------------------------------------------------
1078
+
1079
+ // --------------------------------------------------------------------------------
1080
+ // Function : properties()
1081
+ // Description :
1082
+ // This method gives the properties of the archive.
1083
+ // The properties are :
1084
+ // nb : Number of files in the archive
1085
+ // comment : Comment associated with the archive file
1086
+ // status : not_exist, ok
1087
+ // Parameters :
1088
+ // None
1089
+ // Return Values :
1090
+ // 0 on failure,
1091
+ // An array with the archive properties.
1092
+ // --------------------------------------------------------------------------------
1093
+ function properties()
1094
+ {
1095
+
1096
+ // ----- Reset the error handler
1097
+ $this->privErrorReset();
1098
+
1099
+ // ----- Magic quotes trick
1100
+ $this->privDisableMagicQuotes();
1101
+
1102
+ // ----- Check archive
1103
+ if (!$this->privCheckFormat()) {
1104
+ $this->privSwapBackMagicQuotes();
1105
+ return(0);
1106
+ }
1107
+
1108
+ // ----- Default properties
1109
+ $v_prop = array();
1110
+ $v_prop['comment'] = '';
1111
+ $v_prop['nb'] = 0;
1112
+ $v_prop['status'] = 'not_exist';
1113
+
1114
+ // ----- Look if file exists
1115
+ if (@is_file($this->zipname))
1116
+ {
1117
+ // ----- Open the zip file
1118
+ if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
1119
+ {
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;
1127
+ }
1128
+
1129
+ // ----- Read the central directory information
1130
+ $v_central_dir = array();
1131
+ if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
1132
+ {
1133
+ $this->privSwapBackMagicQuotes();
1134
+ return 0;
1135
+ }
1136
+
1137
+ // ----- Close the zip file
1138
+ $this->privCloseFd();
1139
+
1140
+ // ----- Set the user attributes
1141
+ $v_prop['comment'] = $v_central_dir['comment'];
1142
+ $v_prop['nb'] = $v_central_dir['entries'];
1143
+ $v_prop['status'] = 'ok';
1144
+ }
1145
+
1146
+ // ----- Magic quotes trick
1147
+ $this->privSwapBackMagicQuotes();
1148
+
1149
+ // ----- Return
1150
+ return $v_prop;
1151
+ }
1152
+ // --------------------------------------------------------------------------------
1153
+
1154
+ // --------------------------------------------------------------------------------
1155
+ // Function : duplicate()
1156
+ // Description :
1157
+ // This method creates an archive by copying the content of an other one. If
1158
+ // the archive already exist, it is replaced by the new one without any warning.
1159
+ // Parameters :
1160
+ // $p_archive : The filename of a valid archive, or
1161
+ // a valid PclZip object.
1162
+ // Return Values :
1163
+ // 1 on success.
1164
+ // 0 or a negative value on error (error code).
1165
+ // --------------------------------------------------------------------------------
1166
+ function duplicate($p_archive)
1167
+ {
1168
+ $v_result = 1;
1169
+
1170
+ // ----- Reset the error handler
1171
+ $this->privErrorReset();
1172
+
1173
+ // ----- Look if the $p_archive is a PclZip object
1174
+ if (is_object($p_archive) && $p_archive instanceof pclzip)
1175
+ {
1176
+
1177
+ // ----- Duplicate the archive
1178
+ $v_result = $this->privDuplicate($p_archive->zipname);
1179
+ }
1180
+
1181
+ // ----- Look if the $p_archive is a string (so a filename)
1182
+ else if (is_string($p_archive))
1183
+ {
1184
+
1185
+ // ----- Check that $p_archive is a valid zip file
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 {
1193
+ // ----- Duplicate the archive
1194
+ $v_result = $this->privDuplicate($p_archive);
1195
+ }
1196
+ }
1197
+
1198
+ // ----- Invalid variable
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
+
1206
+ // ----- Return
1207
+ return $v_result;
1208
+ }
1209
+ // --------------------------------------------------------------------------------
1210
+
1211
+ // --------------------------------------------------------------------------------
1212
+ // Function : merge()
1213
+ // Description :
1214
+ // This method merge the $p_archive_to_add archive at the end of the current
1215
+ // one ($this).
1216
+ // If the archive ($this) does not exist, the merge becomes a duplicate.
1217
+ // If the $p_archive_to_add archive does not exist, the merge is a success.
1218
+ // Parameters :
1219
+ // $p_archive_to_add : It can be directly the filename of a valid zip archive,
1220
+ // or a PclZip object archive.
1221
+ // Return Values :
1222
+ // 1 on success,
1223
+ // 0 or negative values on error (see below).
1224
+ // --------------------------------------------------------------------------------
1225
+ function merge($p_archive_to_add)
1226
+ {
1227
+ $v_result = 1;
1228
+
1229
+ // ----- Reset the error handler
1230
+ $this->privErrorReset();
1231
+
1232
+ // ----- Check archive
1233
+ if (!$this->privCheckFormat()) {
1234
+ return(0);
1235
+ }
1236
+
1237
+ // ----- Look if the $p_archive_to_add is a PclZip object
1238
+ if (is_object($p_archive_to_add) && $p_archive_to_add instanceof pclzip)
1239
+ {
1240
+
1241
+ // ----- Merge the archive
1242
+ $v_result = $this->privMerge($p_archive_to_add);
1243
+ }
1244
+
1245
+ // ----- Look if the $p_archive_to_add is a string (so a filename)
1246
+ else if (is_string($p_archive_to_add))
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);
1254
+ }
1255
+
1256
+ // ----- Invalid variable
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
+
1264
+ // ----- Return
1265
+ return $v_result;
1266
+ }
1267
+ // --------------------------------------------------------------------------------
1268
+
1269
+
1270
+
1271
+ // --------------------------------------------------------------------------------
1272
+ // Function : errorCode()
1273
+ // Description :
1274
+ // Parameters :
1275
+ // --------------------------------------------------------------------------------
1276
+ function errorCode()
1277
+ {
1278
+ if (PCLZIP_ERROR_EXTERNAL == 1) {
1279
+ return(PclErrorCode());
1280
+ }
1281
+ else {
1282
+ return($this->error_code);
1283
+ }
1284
+ }
1285
+ // --------------------------------------------------------------------------------
1286
+
1287
+ // --------------------------------------------------------------------------------
1288
+ // Function : errorName()
1289
+ // Description :
1290
+ // Parameters :
1291
+ // --------------------------------------------------------------------------------
1292
+ function errorName($p_with_code=false)
1293
+ {
1294
+ $v_name = array ( WPVIVID_PCLZIP_ERR_NO_ERROR => 'WPVIVID_PCLZIP_ERR_NO_ERROR',
1295
+ WPVIVID_PCLZIP_ERR_WRITE_OPEN_FAIL => 'WPVIVID_PCLZIP_ERR_WRITE_OPEN_FAIL',
1296
+ WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL => 'WPVIVID_PCLZIP_ERR_READ_OPEN_FAIL',
1297
+ WPVIVID_PCLZIP_ERR_INVALID_PARAMETER => 'WPVIVID_PCLZIP_ERR_INVALID_PARAMETER',
1298
+ WPVIVID_PCLZIP_ERR_MISSING_FILE => 'WPVIVID_PCLZIP_ERR_MISSING_FILE',
1299
+ WPVIVID_PCLZIP_ERR_FILENAME_TOO_LONG => 'WPVIVID_PCLZIP_ERR_FILENAME_TOO_LONG',
1300
+ WPVIVID_PCLZIP_ERR_INVALID_ZIP => 'WPVIVID_PCLZIP_ERR_INVALID_ZIP',
1301
+ WPVIVID_PCLZIP_ERR_BAD_EXTRACTED_FILE => 'WPVIVID_PCLZIP_ERR_BAD_EXTRACTED_FILE',
1302
+ WPVIVID_PCLZIP_ERR_DIR_CREATE_FAIL => 'WPVIVID_PCLZIP_ERR_DIR_CREATE_FAIL',
1303
+ WPVIVID_PCLZIP_ERR_BAD_EXTENSION => 'WPVIVID_PCLZIP_ERR_BAD_EXTENSION',
1304
+ WPVIVID_PCLZIP_ERR_BAD_FORMAT => 'WPVIVID_PCLZIP_ERR_BAD_FORMAT',
1305
+ WPVIVID_PCLZIP_ERR_DELETE_FILE_FAIL => 'WPVIVID_PCLZIP_ERR_DELETE_FILE_FAIL',
1306
+ WPVIVID_PCLZIP_ERR_RENAME_FILE_FAIL => 'WPVIVID_PCLZIP_ERR_RENAME_FILE_FAIL',
1307
+ WPVIVID_PCLZIP_ERR_BAD_CHECKSUM => 'WPVIVID_PCLZIP_ERR_BAD_CHECKSUM',
1308
+ WPVIVID_PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'WPVIVID_PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
1309
+ WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE => 'WPVIVID_PCLZIP_ERR_MISSING_OPTION_VALUE',
1310
+ WPVIVID_PCLZIP_ERR_INVALID_OPTION_VALUE => 'WPVIVID_PCLZIP_ERR_INVALID_OPTION_VALUE',
1311
+ WPVIVID_PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'WPVIVID_PCLZIP_ERR_UNSUPPORTED_COMPRESSION',
1312
+ WPVIVID_PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'WPVIVID_PCLZIP_ERR_UNSUPPORTED_ENCRYPTION'
1313
+ ,WPVIVID_PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'WPVIVID_PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE'
1314
+ ,WPVIVID_PCLZIP_ERR_DIRECTORY_RESTRICTION => 'WPVIVID_PCLZIP_ERR_DIRECTORY_RESTRICTION'
1315
+ );
1316
+
1317
+ if (isset($v_name[$this->error_code])) {
1318
+ $v_value = $v_name[$this->error_code];
1319
+ }
1320
+ else {
1321
+ $v_value = 'NoName';
1322
+ }
1323
+
1324
+ if ($p_with_code) {
1325
+ return($v_value.' ('.$this->error_code.')');
1326
+ }
1327
+ else {
1328
+ return($v_value);
1329
+ }
1330
+ }
1331
+ // --------------------------------------------------------------------------------
1332
+
1333
+ // --------------------------------------------------------------------------------
1334
+ // Function : errorInfo()
1335
+ // Description :
1336
+ // Parameters :
1337
+ // --------------------------------------------------------------------------------
1338
+ function errorInfo($p_full=false)
1339
+ {
1340
+ if (PCLZIP_ERROR_EXTERNAL == 1) {
1341
+ return(PclErrorString());
1342
+ }
1343
+ else {
1344
+ if ($p_full) {
1345
+ return($this->errorName(true)." : ".$this->error_string);
1346
+ }
1347
+ else {
1348
+ return($this->error_string." [code ".$this->error_code."]");
1349
+ }
1350
+ }
1351
+ }
1352
+ // --------------------------------------------------------------------------------
1353
+
1354
+
1355
+ // --------------------------------------------------------------------------------
1356
+ // ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS *****
1357
+ // ***** *****
1358
+ // ***** THESES FUNCTIONS MUST NOT BE USED DIRECTLY *****
1359
+ // --------------------------------------------------------------------------------
1360
+
1361
+
1362
+
1363
+ // --------------------------------------------------------------------------------
1364
+ // Function : privCheckFormat()
1365
+ // Description :
1366
+ // This method check that the archive exists and is a valid zip archive.
1367
+ // Several level of check exists. (futur)
1368
+ // Parameters :
1369
+ // $p_level : Level of check. Default 0.
1370
+ // 0 : Check the first bytes (magic codes) (default value))
1371
+ // 1 : 0 + Check the central directory (futur)
1372
+ // 2 : 1 + Check each file header (futur)
1373
+ // Return Values :
1374
+ // true on success,
1375
+ // false on error, the error code is set.
1376
+ // --------------------------------------------------------------------------------
1377
+ function privCheckFormat($p_level=0)
1378
+ {
1379
+ $v_result = true;
1380
+
1381
+ // ----- Reset the file system cache
1382
+ clearstatcache();
1383
+
1384
+ // ----- Reset the error handler
1385
+ $this->privErrorReset();
1386
+
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
+
1401
+ // ----- Check the magic code
1402
+ // TBC
1403
+
1404
+ // ----- Check the central header
1405
+ // TBC
1406
+
1407
+ // ----- Check each file header
1408
+ // TBC
1409
+
1410
+ // ----- Return
1411
+ return $v_result;
1412
+ }
1413
+ // --------------------------------------------------------------------------------
1414
+
1415
+ // --------------------------------------------------------------------------------
1416
+ // Function : privParseOptions()
1417
+ // Description :
1418
+ // This internal methods reads the variable list of arguments ($p_options_list,
1419
+ // $p_size) and generate an array with the options and values ($v_result_list).
1420
+ // $v_requested_options contains the options that can be present and those that
1421
+ // must be present.
1422
+ // $v_requested_options is an array, with the option value as key, and 'optional',
1423
+ // or 'mandatory' as value.
1424
+ // Parameters :
1425
+ // See above.
1426
+ // Return Values :
1427
+ // 1 on success.
1428
+ // 0 on failure.
1429
+ // --------------------------------------------------------------------------------
1430
+ function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
1431
+ {
1432
+ $v_result=1;
1433
+
1434
+ // ----- Read the options
1435
+ $i=0;
1436
+ while ($i<$p_size) {
1437
+
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
1448
+ switch ($p_options_list[$i]) {
1449
+ // ----- Look for options that request a path value
1450
+ case WPVIVID_PCLZIP_OPT_PATH :
1451
+ case WPVIVID_PCLZIP_OPT_REMOVE_PATH :
1452
+ case WPVIVID_PCLZIP_OPT_ADD_PATH :
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
1463
+ $v_result_list[$p_options_list[$i]] = WPvivid_PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1464
+ $i++;
1465
+ break;
1466
+
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)
1488
+ $v_result_list[$p_options_list[$i]] = $v_value*1048576;
1489
+ $i++;
1490
+ break;
1491
+
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;
1500
+ break;
1501
+
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;
1515
+ break;
1516
+
1517
+ case WPVIVID_PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
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
1528
+ if ( is_string($p_options_list[$i+1])
1529
+ && ($p_options_list[$i+1] != '')) {
1530
+ $v_result_list[$p_options_list[$i]] = WPvivid_PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1531
+ $i++;
1532
+ }
1533
+ else {
1534
+ }
1535
+ break;
1536
+
1537
+ // ----- Look for options that request an array of string for value
1538
+ case WPVIVID_PCLZIP_OPT_BY_NAME :
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
1549
+ if (is_string($p_options_list[$i+1])) {
1550
+ $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
1551
+ }
1552
+ else if (is_array($p_options_list[$i+1])) {
1553
+ $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
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;
1564
+
1565
+ // ----- Look for options that request an EREG or PREG expression
1566
+ case WPVIVID_PCLZIP_OPT_BY_EREG :
1567
+ // ereg() is deprecated starting with PHP 5.3. Move WPVIVID_PCLZIP_OPT_BY_EREG
1568
+ // to WPVIVID_PCLZIP_OPT_BY_PREG
1569
+ $p_options_list[$i] = WPVIVID_PCLZIP_OPT_BY_PREG;
1570
+ case WPVIVID_PCLZIP_OPT_BY_PREG :
1571
+ //case PCLZIP_OPT_CRYPT :
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
1582
+ if (is_string($p_options_list[$i+1])) {
1583
+ $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
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;
1594
+
1595
+ // ----- Look for options that takes a string
1596
+ case WPVIVID_PCLZIP_OPT_COMMENT :
1597
+ case WPVIVID_PCLZIP_OPT_ADD_COMMENT :
1598
+ case WPVIVID_PCLZIP_OPT_PREPEND_COMMENT :
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
1612
+ if (is_string($p_options_list[$i+1])) {
1613
+ $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
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;
1627
+
1628
+ // ----- Look for options that request an array of index
1629
+ case WPVIVID_PCLZIP_OPT_BY_INDEX :
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
1640
+ $v_work_list = array();
1641
+ if (is_string($p_options_list[$i+1])) {
1642
+
1643
+ // ----- Remove spaces
1644
+ $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
1645
+
1646
+ // ----- Parse items
1647
+ $v_work_list = explode(",", $p_options_list[$i+1]);
1648
+ }
1649
+ else if (is_integer($p_options_list[$i+1])) {
1650
+ $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
1651
+ }
1652
+ else if (is_array($p_options_list[$i+1])) {
1653
+ $v_work_list = $p_options_list[$i+1];
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
1664
+ // each index item in the list must be a couple with a start and
1665
+ // an end value : [0,3], [5-5], [8-10], ...
1666
+ // ----- Check the format of each item
1667
+ $v_sort_flag=false;
1668
+ $v_sort_value=0;
1669
+ for ($j=0; $j<sizeof($v_work_list); $j++) {
1670
+ // ----- Explode the item
1671
+ $v_item_list = explode("-", $v_work_list[$j]);
1672
+ $v_size_item_list = sizeof($v_item_list);
1673
+
1674
+ // ----- TBC : Here we might check that each item is a
1675
+ // real integer ...
1676
+
1677
+ // ----- Look for single value
1678
+ if ($v_size_item_list == 1) {
1679
+ // ----- Set the option value
1680
+ $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1681
+ $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];
1682
+ }
1683
+ elseif ($v_size_item_list == 2) {
1684
+ // ----- Set the option value
1685
+ $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1686
+ $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];
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
+
1697
+ // ----- Look for list sort
1698
+ if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
1699
+ $v_sort_flag=true;
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
+ }
1710
+
1711
+ // ----- Sort the items
1712
+ if ($v_sort_flag) {
1713
+ // TBC : To Be Completed
1714
+ }
1715
+
1716
+ // ----- Next option
1717
+ $i++;
1718
+ break;
1719
+
1720
+ // ----- Look for options that request no value
1721
+ case WPVIVID_PCLZIP_OPT_REMOVE_ALL_PATH :
1722
+ case WPVIVID_PCLZIP_OPT_EXTRACT_AS_STRING :
1723
+ case WPVIVID_PCLZIP_OPT_NO_COMPRESSION :
1724
+ case WPVIVID_PCLZIP_OPT_EXTRACT_IN_OUTPUT :
1725
+ case WPVIVID_PCLZIP_OPT_REPLACE_NEWER :
1726
+ case WPVIVID_PCLZIP_OPT_STOP_ON_ERROR :
1727
+ $v_result_list[$p_options_list[$i]] = true;
1728
+ break;
1729
+
1730
+ // ----- Look for options that request an octal value
1731
+ case WPVIVID_PCLZIP_OPT_SET_CHMOD :
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
1742
+ $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1743
+ $i++;
1744
+ break;
1745
+
1746
+ // ----- Look for options that request a call-back
1747
+ case WPVIVID_PCLZIP_CB_PRE_EXTRACT :
1748
+ case WPVIVID_PCLZIP_CB_POST_EXTRACT :
1749
+ case WPVIVID_PCLZIP_CB_PRE_ADD :
1750
+ case WPVIVID_PCLZIP_CB_POST_ADD :
1751
+ /* for futur use
1752
+ case PCLZIP_CB_PRE_DELETE :
1753
+ case PCLZIP_CB_POST_DELETE :
1754
+ case PCLZIP_CB_PRE_LIST :
1755
+ case PCLZIP_CB_POST_LIST :
1756
+ */
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
1767
+ $v_function_name = $p_options_list[$i+1];
1768
+
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
1779
+ $v_result_list[$p_options_list[$i]] = $v_function_name;
1780
+ $i++;
1781
+ break;
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
1794
+ $i++;
1795
+ }
1796
+
1797
+ // ----- Look for mandatory options
1798
+ if ($v_requested_options !== false) {
1799
+ for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1800
+ // ----- Look for mandatory option
1801
+ if ($v_requested_options[$key] == 'mandatory') {
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
+ }
1812
+ }
1813
+
1814
+ // ----- Look for default values
1815
+ if (!isset($v_result_list[WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
1816
+
1817
+ }
1818
+
1819
+ // ----- Return
1820
+ return $v_result;
1821
+ }
1822
+ // --------------------------------------------------------------------------------
1823
+
1824
+ // --------------------------------------------------------------------------------
1825
+ // Function : privOptionDefaultThreshold()
1826
+ // Description :
1827
+ // Parameters :
1828
+ // Return Values :
1829
+ // --------------------------------------------------------------------------------
1830
+ function privOptionDefaultThreshold(&$p_options)
1831
+ {
1832
+ $v_result=1;
1833
+
1834
+ if (isset($p_options[WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD])
1835
+ || isset($p_options[WPVIVID_PCLZIP_OPT_TEMP_FILE_OFF])) {
1836
+ return $v_result;
1837
+ }
1838
+
1839
+ // ----- Get 'memory_limit' configuration value
1840
+ $v_memory_limit = ini_get('memory_limit');
1841
+ $v_memory_limit = trim($v_memory_limit);
1842
+ $v_memory_limit_int = (int) $v_memory_limit;
1843
+ $last = strtolower(substr($v_memory_limit, -1));
1844
+
1845
+ if($last == 'g')
1846
+ //$v_memory_limit_int = $v_memory_limit_int*1024*1024*1024;
1847
+ $v_memory_limit_int = $v_memory_limit_int*1073741824;
1848
+ if($last == 'm')
1849
+ //$v_memory_limit_int = $v_memory_limit_int*1024*1024;
1850
+ $v_memory_limit_int = $v_memory_limit_int*1048576;
1851
+ if($last == 'k')
1852
+ $v_memory_limit_int = $v_memory_limit_int*1024;
1853
+
1854
+ $p_options[WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit_int*PCLZIP_TEMPORARY_FILE_RATIO);
1855
+
1856
+
1857
+ // ----- Sanity check : No threshold if value lower than 1M
1858
+ if ($p_options[WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
1859
+ unset($p_options[WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
1860
+ }
1861
+
1862
+ // ----- Return
1863
+ return $v_result;
1864
+ }
1865
+ // --------------------------------------------------------------------------------
1866
+
1867
+ // --------------------------------------------------------------------------------
1868
+ // Function : privFileDescrParseAtt()
1869
+ // Description :
1870
+ // Parameters :
1871
+ // Return Values :
1872
+ // 1 on success.
1873
+ // 0 on failure.
1874
+ // --------------------------------------------------------------------------------
1875
+ function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
1876
+ {
1877
+ $v_result=1;
1878
+
1879
+ // ----- For each file in the list check the attributes
1880
+ foreach ($p_file_list as $v_key => $v_value) {
1881
+
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;
1944
+ break;
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;
1953
+ break;
1954
+
1955
+ case WPVIVID_PCLZIP_ATT_FILE_CONTENT :
1956
+ $p_filedescr['content'] = $v_value;
1957
+ break;
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
1969
+ if ($v_requested_options !== false) {
1970
+ for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1971
+ // ----- Look for mandatory option
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
+ }
1980
+ }
1981
+
1982
+ // end foreach
1983
+ }
1984
+
1985
+ // ----- Return
1986
+ return $v_result;
1987
+ }
1988
+ // --------------------------------------------------------------------------------
1989
+
1990
+ // --------------------------------------------------------------------------------
1991
+ // Function : privFileDescrExpand()
1992
+ // Description :
1993
+ // This method look for each item of the list to see if its a file, a folder
1994
+ // or a string to be added as file. For any other type of files (link, other)
1995
+ // just ignore the item.
1996
+ // Then prepare the information that will be stored for that file.
1997
+ // When its a folder, expand the folder with all the files that are in that
1998
+ // folder (recursively).
1999
+ // Parameters :
2000
+ // Return Values :
2001
+ // 1 on success.
2002
+ // 0 on failure.
2003
+ // --------------------------------------------------------------------------------
2004
+ function privFileDescrExpand(&$p_filedescr_list, &$p_options)
2005
+ {
2006
+ $v_result=1;
2007
+
2008
+ // ----- Create a result list
2009
+ $v_result_list = array();
2010
+
2011
+ // ----- Look each entry
2012
+ for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
2013
+
2014
+ // ----- Get filedescr
2015
+ $v_descr = $p_filedescr_list[$i];
2016
+
2017
+ // ----- Reduce the filename
2018
+ $v_descr['filename'] = WPvivid_PclZipUtilTranslateWinPath($v_descr['filename'], false);
2019
+ $v_descr['filename'] = WPvivid_PclZipUtilPathReduction($v_descr['filename']);
2020
+
2021
+ // ----- Look for real file or folder
2022
+ if (file_exists($v_descr['filename'])) {
2023
+ if (@is_file($v_descr['filename'])) {
2024
+ $v_descr['type'] = 'file';
2025
+ }
2026
+ else if (@is_dir($v_descr['filename'])) {
2027
+ $v_descr['type'] = 'folder';
2028
+ }
2029
+ else if (@is_link($v_descr['filename'])) {
2030
+ // skip
2031
+ continue;
2032
+ }
2033
+ else {
2034
+ // skip
2035
+ continue;
2036
+ }
2037
+ }
2038
+
2039
+ // ----- Look for string added as file
2040
+ else if (isset($v_descr['content'])) {
2041
+ $v_descr['type'] = 'virtual_file';
2042
+ }
2043
+
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
2054
+ $this->privCalculateStoredFilename($v_descr, $p_options);
2055
+
2056
+ // ----- Add the descriptor in result list
2057
+ $v_result_list[sizeof($v_result_list)] = $v_descr;
2058
+
2059
+ // ----- Look for folder
2060
+ if ($v_descr['type'] == 'folder') {
2061
+ // ----- List of items in folder
2062
+ $v_dirlist_descr = array();
2063
+ $v_dirlist_nb = 0;
2064
+ if ($v_folder_handler = @opendir($v_descr['filename'])) {
2065
+ while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
2066
+
2067
+ // ----- Skip '.' and '..'
2068
+ if (($v_item_handler == '.') || ($v_item_handler == '..')) {
2069
+ continue;
2070
+ }
2071
+
2072
+ // ----- Compose the full filename
2073
+ $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler;
2074
+
2075
+ // ----- Look for different stored filename
2076
+ // Because the name of the folder was changed, the name of the
2077
+ // files/sub-folders also change
2078
+ if (($v_descr['stored_filename'] != $v_descr['filename'])
2079
+ && (!isset($p_options[WPVIVID_PCLZIP_OPT_REMOVE_ALL_PATH]))) {
2080
+ if ($v_descr['stored_filename'] != '') {
2081
+ $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
2082
+ }
2083
+ else {
2084
+ $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
2085
+ }
2086
+ }
2087
+
2088
+ $v_dirlist_nb++;
2089
+ }
2090
+
2091
+ @closedir($v_folder_handler);
2092
+ }
2093
+ else {
2094
+ // TBC : unable to open folder in read mode
2095
+ }
2096
+
2097
+ // ----- Expand each element of the list
2098
+ if ($v_dirlist_nb != 0) {
2099
+ // ----- Expand
2100
+ if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
2101
+ return $v_result;
2102
+ }
2103
+
2104
+ // ----- Concat the resulting list
2105
+ $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
2106
+ }
2107
+ else {
2108
+ }
2109
+
2110
+ // ----- Free local array
2111
+ unset($v_dirlist_descr);
2112
+ }
2113
+ }
2114
+
2115
+ // ----- Get the result list
2116
+ $p_filedescr_list = $v_result_list;
2117
+
2118
+ // ----- Return
2119
+ return $v_result;
2120
+ }
2121
+ // --------------------------------------------------------------------------------
2122
+
2123
+ // --------------------------------------------------------------------------------
2124
+ // Function : privCreate()
2125
+ // Description :
2126
+ // Parameters :
2127
+ // Return Values :
2128
+ // --------------------------------------------------------------------------------
2129
+ function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
2130
+ {
2131
+ $v_result=1;
2132
+ $v_list_detail = array();
2133
+
2134
+ // ----- Magic quotes trick
2135
+ $this->privDisableMagicQuotes();
2136
+
2137
+ // ----- Open the file in write mode
2138
+ if (($v_result = $this->privOpenFd('wb')) != 1)
2139
+ {
2140
+ // ----- Return
2141
+ return $v_result;
2142
+ }
2143
+
2144
+ // ----- Add the list of files
2145
+ $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options);
2146
+
2147
+ // ----- Close
2148
+ $this->privCloseFd();
2149
+
2150
+ // ----- Magic quotes trick
2151
+ $this->privSwapBackMagicQuotes();
2152
+
2153
+ // ----- Return
2154
+ return $v_result;
2155
+ }
2156
+ // --------------------------------------------------------------------------------
2157
+
2158
+ // --------------------------------------------------------------------------------
2159
+ // Function : privAdd()
2160
+ // Description :
2161
+ // Parameters :
2162
+ // Return Values :
2163
+ // --------------------------------------------------------------------------------
2164
+ function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
2165
+ {
2166
+ $v_result=1;
2167
+ $v_list_detail = array();
2168
+
2169
+ // ----- Look if the archive exists or is empty
2170
+ if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
2171
+ {
2172
+
2173
+ // ----- Do a create
2174
+ $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
2175
+
2176
+ // ----- Return
2177
+ return $v_result;
2178
+ }
2179
+ // ----- Magic quotes trick
2180
+ $this->privDisableMagicQuotes();
2181
+
2182
+ // ----- Open the zip file
2183
+ if (($v_result=$this->privOpenFd('rb')) != 1)
2184
+ {
2185
+ // ----- Magic quotes trick
2186
+ $this->privSwapBackMagicQuotes();
2187
+
2188
+ // ----- Return
2189
+ return $v_result;
2190
+ }
2191
+
2192
+ // ----- Read the central directory information
2193
+ $v_central_dir = array();
2194
+ if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
2195
+ {
2196
+ $this->privCloseFd();
2197
+ $this->privSwapBackMagicQuotes();
2198
+ return $v_result;
2199
+ }
2200
+
2201
+ // ----- Go to beginning of File
2202
+ @rewind($this->zip_fd);
2203
+
2204
+ // ----- Creates a temporary file
2205
+ $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
2206
+
2207
+ // ----- Open the temporary file in write mode
2208
+ if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
2209
+ {
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
2220
+ // TBC : Here I should better append the file and go back to erase the central dir
2221
+ $v_size = $v_central_dir['offset'];
2222
+ while ($v_size != 0)
2223
+ {
2224
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2225
+ $v_buffer = fread($this->zip_fd, $v_read_size);
2226
+ @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2227
+ $v_size -= $v_read_size;
2228
+ }
2229
+
2230
+ // ----- Swap the file descriptor
2231
+ // Here is a trick : I swap the temporary fd with the zip fd, in order to use
2232
+ // the following methods on the temporary fil and not the real archive
2233
+ $v_swap = $this->zip_fd;
2234
+ $this->zip_fd = $v_zip_temp_fd;
2235
+ $v_zip_temp_fd = $v_swap;
2236
+
2237
+ // ----- Add the files
2238
+ $v_header_list = array();
2239
+ if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2240
+ {
2241
+ fclose($v_zip_temp_fd);
2242
+ $this->privCloseFd();
2243
+ @unlink($v_zip_temp_name);
2244
+ $this->privSwapBackMagicQuotes();
2245
+
2246
+ // ----- Return
2247
+ return $v_result;
2248
+ }
2249
+
2250
+ // ----- Store the offset of the central dir
2251
+ $v_offset = @ftell($this->zip_fd);
2252
+
2253
+ // ----- Copy the block of file headers from the old archive
2254
+ $v_size = $v_central_dir['size'];
2255
+ while ($v_size != 0)
2256
+ {
2257
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2258
+ $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
2259
+ @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2260
+ $v_size -= $v_read_size;
2261
+ }
2262
+
2263
+ // ----- Create the Central Dir files header
2264
+ for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
2265
+ {
2266
+ // ----- Create the file header
2267
+ if ($v_header_list[$i]['status'] == 'ok') {
2268
+ if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2269
+ fclose($v_zip_temp_fd);
2270
+ $this->privCloseFd();
2271
+ @unlink($v_zip_temp_name);
2272
+ $this->privSwapBackMagicQuotes();
2273
+
2274
+ // ----- Return
2275
+ return $v_result;
2276
+ }
2277
+ $v_count++;
2278
+ }
2279
+
2280
+ // ----- Transform the header to a 'usable' info
2281
+ $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2282
+ }
2283
+
2284
+ // ----- Zip file comment
2285
+ $v_comment = $v_central_dir['comment'];
2286
+ if (isset($p_options[WPVIVID_PCLZIP_OPT_COMMENT])) {
2287
+ $v_comment = $p_options[WPVIVID_PCLZIP_OPT_COMMENT];
2288
+ }
2289
+ if (isset($p_options[WPVIVID_PCLZIP_OPT_ADD_COMMENT])) {
2290
+ $v_comment = $v_comment.$p_options[WPVIVID_PCLZIP_OPT_ADD_COMMENT];
2291
+ }
2292
+ if (isset($p_options[WPVIVID_PCLZIP_OPT_PREPEND_COMMENT])) {
2293
+ $v_comment = $p_options[WPVIVID_PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
2294
+ }
2295
+
2296
+ // ----- Calculate the size of the central header
2297
+ $v_size = @ftell($this->zip_fd)-$v_offset;
2298
+
2299
+ // ----- Create the central dir footer
2300
+ if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
2301
+ {
2302
+ // ----- Reset the file list
2303
+ unset($v_header_list);
2304
+ $this->privSwapBackMagicQuotes();
2305
+
2306
+ // ----- Return
2307
+ return $v_result;
2308
+ }
2309
+
2310
+ // ----- Swap back the file descriptor
2311
+ $v_swap = $this->zip_fd;
2312
+ $this->zip_fd = $v_zip_temp_fd;
2313
+ $v_zip_temp_fd = $v_swap;
2314
+
2315
+ // ----- Close
2316
+ $this->privCloseFd();
2317
+
2318
+ // ----- Close the temporary file
2319
+ @fclose($v_zip_temp_fd);
2320
+
2321
+ // ----- Magic quotes trick
2322
+ $this->privSwapBackMagicQuotes();
2323
+
2324
+ // ----- Delete the zip file
2325
+ // TBC : I should test the result ...
2326
+ @unlink($this->zipname);
2327
+
2328
+ // ----- Rename the temporary file
2329
+ // TBC : I should test the result ...
2330
+ //@rename($v_zip_temp_name, $this->zipname);
2331
+ WPvivid_PclZipUtilRename($v_zip_temp_name, $this->zipname);
2332
+
2333
+ // ----- Return
2334
+ return $v_result;
2335
+ }
2336
+ // --------------------------------------------------------------------------------
2337
+
2338
+ // --------------------------------------------------------------------------------
2339
+ // Function : privOpenFd()
2340
+ // Description :
2341
+ // Parameters :
2342
+ // --------------------------------------------------------------------------------
2343
+ function privOpenFd($p_mode)
2344
+ {
2345
+ $v_result=1;
2346
+
2347
+ // ----- Look if already open
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
2368
+ return $v_result;
2369
+ }
2370
+ // --------------------------------------------------------------------------------
2371
+
2372
+ // --------------------------------------------------------------------------------
2373
+ // Function : privCloseFd()
2374
+ // Description :
2375
+ // Parameters :
2376
+ // --------------------------------------------------------------------------------
2377
+ function privCloseFd()
2378
+ {
2379
+ $v_result=1;
2380
+
2381
+ if ($this->zip_fd != 0)
2382
+ @fclose($this->zip_fd);
2383
+ $this->zip_fd = 0;
2384
+
2385
+ // ----- Return
2386
+ return $v_result;
2387
+ }
2388
+ // --------------------------------------------------------------------------------
2389
+
2390
+ // --------------------------------------------------------------------------------
2391
+ // Function : privAddList()
2392
+ // Description :
2393
+ // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is
2394
+ // different from the real path of the file. This is useful if you want to have PclTar
2395
+ // running in any directory, and memorize relative path from an other directory.
2396
+ // Parameters :
2397
+ // $p_list : An array containing the file or directory names to add in the tar
2398
+ // $p_result_list : list of added files with their properties (specially the status field)
2399
+ // $p_add_dir : Path to add in the filename path archived
2400
+ // $p_remove_dir : Path to remove in the filename path archived
2401
+ // Return Values :
2402
+ // --------------------------------------------------------------------------------
2403
+ // function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
2404
+ function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
2405
+ {
2406
+ $v_result=1;
2407
+
2408
+ // ----- Add the files
2409
+ $v_header_list = array();
2410
+ if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2411
+ {
2412
+ // ----- Return
2413
+ return $v_result;
2414
+ }
2415
+
2416
+ // ----- Store the offset of the central dir
2417
+ $v_offset = @ftell($this->zip_fd);
2418
+
2419
+ // ----- Create the Central Dir files header
2420
+ for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
2421
+ {
2422
+ // ----- Create the file header
2423
+ if ($v_header_list[$i]['status'] == 'ok') {
2424
+ if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2425
+ // ----- Return
2426
+ return $v_result;
2427
+ }
2428
+ $v_count++;
2429
+ }
2430
+
2431
+ // ----- Transform the header to a 'usable' info
2432
+ $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2433
+ }
2434
+
2435
+ // ----- Zip file comment
2436
+ $v_comment = '';
2437
+ if (isset($p_options[WPVIVID_PCLZIP_OPT_COMMENT])) {
2438
+ $v_comment = $p_options[WPVIVID_PCLZIP_OPT_COMMENT];
2439
+ }
2440
+
2441
+ // ----- Calculate the size of the central header
2442
+ $v_size = @ftell($this->zip_fd)-$v_offset;
2443
+
2444
+ // ----- Create the central dir footer
2445
+ if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
2446
+ {
2447
+ // ----- Reset the file list
2448
+ unset($v_header_list);
2449
+
2450
+ // ----- Return
2451
+ return $v_result;
2452
+ }
2453
+
2454
+ // ----- Return
2455
+ return $v_result;
2456
+ }
2457
+ // --------------------------------------------------------------------------------
2458
+
2459
+ // --------------------------------------------------------------------------------
2460
+ // Function : privAddFileList()
2461
+ // Description :
2462
+ // Parameters :
2463
+ // $p_filedescr_list : An array containing the file description
2464
+ // or directory names to add in the zip
2465
+ // $p_result_list : list of added files with their properties (specially the status field)
2466
+ // Return Values :
2467
+ // --------------------------------------------------------------------------------
2468
+ function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
2469
+ {
2470
+ $v_result=1;
2471
+ $v_header = array();
2472
+
2473
+ // ----- Recuperate the current number of elt in list
2474
+ $v_nb = sizeof($p_result_list);
2475
+
2476
+ // ----- Loop on the files
2477
+ for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
2478
+ // ----- Format the filename
2479
+ $p_filedescr_list[$j]['filename']
2480
+ = WPvivid_PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
2481
+
2482
+
2483
+ // ----- Skip empty file names
2484
+ // TBC : Can this be possible ? not checked in DescrParseAtt ?
2485
+ if ($p_filedescr_list[$j]['filename'] == "") {
2486
+ continue;
2487
+ }
2488
+
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
2497
+ // or a dir with all its path removed
2498
+ // if ( (is_file($p_filedescr_list[$j]['filename']))
2499
+ // || ( is_dir($p_filedescr_list[$j]['filename'])
2500
+ if ( ($p_filedescr_list[$j]['type'] == 'file')
2501
+ || ($p_filedescr_list[$j]['type'] == 'virtual_file')
2502
+ || ( ($p_filedescr_list[$j]['type'] == 'folder')
2503
+ && ( !isset($p_options[WPVIVID_PCLZIP_OPT_REMOVE_ALL_PATH])
2504
+ || !$p_options[WPVIVID_PCLZIP_OPT_REMOVE_ALL_PATH]))
2505
+ ) {
2506
+
2507
+ // ----- Add the file
2508
+ $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header,
2509
+ $p_options);
2510
+ if ($v_result != 1) {
2511
+ return $v_result;
2512
+ }
2513
+
2514
+ // ----- Store the file infos
2515
+ $p_result_list[$v_nb++] = $v_header;
2516
+ }
2517
+ }
2518
+
2519
+ // ----- Return
2520
+ return $v_result;
2521
+ }
2522
+ // --------------------------------------------------------------------------------
2523
+
2524
+ // --------------------------------------------------------------------------------
2525
+ // Function : privAddFile()
2526
+ // Description :
2527
+ // Parameters :
2528
+ // Return Values :
2529
+ // --------------------------------------------------------------------------------
2530
+ function privAddFile($p_filedescr, &$p_header, &$p_options)
2531
+ {
2532
+ $v_result=1;
2533
+
2534
+ // ----- Working variable
2535
+ $p_filename = $p_filedescr['filename'];
2536
+
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
2547
+ /* TBC : Removed
2548
+ if (isset($p_filedescr['stored_filename'])) {
2549
+ $v_stored_filename = $p_filedescr['stored_filename'];
2550
+ }
2551
+ else {
2552
+ $v_stored_filename = $p_filedescr['stored_filename'];
2553
+ }
2554
+ */
2555
+
2556
+ // ----- Set the file properties
2557
+ clearstatcache();
2558
+ $p_header['version'] = 20;
2559
+ $p_header['version_extracted'] = 10;
2560
+ $p_header['flag'] = 0;
2561
+ $p_header['compression'] = 0;
2562
+ $p_header['crc'] = 0;
2563
+ $p_header['compressed_size'] = 0;
2564
+ $p_header['filename_len'] = strlen($p_filename);
2565
+ $p_header['extra_len'] = 0;
2566
+ $p_header['disk'] = 0;
2567
+ $p_header['internal'] = 0;
2568
+ $p_header['offset'] = 0;
2569
+ $p_header['filename'] = $p_filename;
2570
+ // TBC : Removed $p_header['stored_filename'] = $v_stored_filename;
2571
+ $p_header['stored_filename'] = $p_filedescr['stored_filename'];
2572
+ $p_header['extra'] = '';
2573
+ $p_header['status'] = 'ok';
2574
+ $p_header['index'] = -1;
2575
+
2576
+ // ----- Look for regular file
2577
+ if ($p_filedescr['type']=='file') {
2578
+ $p_header['external'] = 0x00000000;
2579
+ $p_header['size'] = filesize($p_filename);
2580
+ }
2581
+
2582
+ // ----- Look for regular folder
2583
+ else if ($p_filedescr['type']=='folder') {
2584
+ $p_header['external'] = 0x00000010;
2585
+ $p_header['mtime'] = filemtime($p_filename);
2586
+ $p_header['size'] = filesize($p_filename);
2587
+ }
2588
+
2589
+ // ----- Look for virtual file
2590
+ else if ($p_filedescr['type'] == 'virtual_file') {
2591
+ $p_header['external'] = 0x00000000;
2592
+ $p_header['size'] = strlen($p_filedescr['content']);
2593
+ }
2594
+
2595
+
2596
+ // ----- Look for filetime
2597
+ if (isset($p_filedescr['mtime'])) {
2598
+ $p_header['mtime'] = $p_filedescr['mtime'];
2599
+ }
2600
+ else if ($p_filedescr['type'] == 'virtual_file') {
2601
+ $p_header['mtime'] = time();
2602
+ }
2603
+ else {
2604
+ $p_header['mtime'] = filemtime($p_filename);
2605
+ }
2606
+
2607
+ // ------ Look for file comment
2608
+ if (isset($p_filedescr['comment'])) {
2609
+ $p_header['comment_len'] = strlen($p_filedescr['comment']);
2610
+ $p_header['comment'] = $p_filedescr['comment'];
2611
+ }
2612
+ else {
2613
+ $p_header['comment_len'] = 0;
2614
+ $p_header['comment'] = '';
2615
+ }
2616
+
2617
+ // ----- Look for pre-add callback
2618
+ if (isset($p_options[WPVIVID_PCLZIP_CB_PRE_ADD])) {
2619
+
2620
+ // ----- Generate a local information
2621
+ $v_local_header = array();
2622
+ $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2623
+
2624
+ // ----- Call the callback
2625
+ // Here I do not use call_user_func() because I need to send a reference to the
2626
+ // header.
2627
+ $v_result = $p_options[WPVIVID_PCLZIP_CB_PRE_ADD](WPVIVID_PCLZIP_CB_PRE_ADD, $v_local_header);
2628
+ if ($v_result == 0) {
2629
+ // ----- Change the file status
2630
+ $p_header['status'] = "skipped";
2631
+ $v_result = 1;
2632
+ }
2633
+
2634
+ // ----- Update the information
2635
+ // Only some fields can be modified
2636
+ if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
2637
+ $p_header['stored_filename'] = WPvivid_PclZipUtilPathReduction($v_local_header['stored_filename']);
2638
+ }
2639
+ }
2640
+
2641
+ // ----- Look for empty stored filename
2642
+ if ($p_header['stored_filename'] == "") {
2643
+ $p_header['status'] = "filtered";
2644
+ }
2645
+
2646
+ // ----- Check the path length
2647
+ if (strlen($p_header['stored_filename']) > 0xFF) {
2648
+ $p_header['status'] = 'filename_too_long';
2649
+ }
2650
+
2651
+ // ----- Look if no error, or file not skipped
2652
+ if ($p_header['status'] == 'ok') {
2653
+
2654
+ // ----- Look for a file
2655
+ if ($p_filedescr['type'] == 'file') {
2656
+ // ----- Look for using temporary file to zip
2657
+ if ( (!isset($p_options[WPVIVID_PCLZIP_OPT_TEMP_FILE_OFF]))
2658
+ && (isset($p_options[WPVIVID_PCLZIP_OPT_TEMP_FILE_ON])
2659
+ || (isset($p_options[WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD])
2660
+ && ($p_options[WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
2661
+ $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
2662
+ if ($v_result < WPVIVID_PCLZIP_ERR_NO_ERROR) {
2663
+ return $v_result;
2664
+ }
2665
+ }
2666
+
2667
+ // ----- Use "in memory" zip algo
2668
+ else {
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
2677
+ if($p_header['size']==0)
2678
+ {
2679
+ $v_content='';
2680
+ }
2681
+ else
2682
+ {
2683
+ $v_content = @fread($v_file, $p_header['size']);
2684
+ }
2685
+
2686
+ // ----- Close the file
2687
+ @fclose($v_file);
2688
+
2689
+ // ----- Calculate the CRC
2690
+ $p_header['crc'] = @crc32($v_content);
2691
+
2692
+ // ----- Look for no compression
2693
+ if ($p_options[WPVIVID_PCLZIP_OPT_NO_COMPRESSION]) {
2694
+ // ----- Set header parameters
2695
+ $p_header['compressed_size'] = $p_header['size'];
2696
+ $p_header['compression'] = 0;
2697
+ }
2698
+
2699
+ // ----- Look for normal compression
2700
+ else {
2701
+ // ----- Compress the content
2702
+ $v_content = @gzdeflate($v_content);
2703
+
2704
+ // ----- Set header parameters
2705
+ $p_header['compressed_size'] = strlen($v_content);
2706
+ $p_header['compression'] = 8;
2707
+ }
2708
+
2709
+ // ----- Call the header generation
2710
+ if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2711
+ @fclose($v_file);
2712
+ return $v_result;
2713
+ }
2714
+
2715
+ // ----- Write the compressed (or not) content
2716
+ @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
2717
+
2718
+ }
2719
+
2720
+ }
2721
+
2722
+ // ----- Look for a virtual file (a file from string)
2723
+ else if ($p_filedescr['type'] == 'virtual_file') {
2724
+
2725
+ $v_content = $p_filedescr['content'];
2726
+
2727
+ // ----- Calculate the CRC
2728
+ $p_header['crc'] = @crc32($v_content);
2729
+
2730
+ // ----- Look for no compression
2731
+ if ($p_options[WPVIVID_PCLZIP_OPT_NO_COMPRESSION]) {
2732
+ // ----- Set header parameters
2733
+ $p_header['compressed_size'] = $p_header['size'];
2734
+ $p_header['compression'] = 0;
2735
+ }
2736
+
2737
+ // ----- Look for normal compression
2738
+ else {
2739
+ // ----- Compress the content
2740
+ $v_content = @gzdeflate($v_content);
2741
+
2742
+ // ----- Set header parameters
2743
+ $p_header['compressed_size'] = strlen($v_content);
2744
+ $p_header['compression'] = 8;
2745
+ }
2746
+
2747
+ // ----- Call the header generation
2748
+ if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2749
+ @fclose($v_file);
2750
+ return $v_result;
2751
+ }
2752
+
2753
+ // ----- Write the compressed (or not) content
2754
+ @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
2755
+ }
2756
+
2757
+ // ----- Look for a directory
2758
+ else if ($p_filedescr['type'] == 'folder') {
2759
+ // ----- Look for directory last '/'
2760
+ if (@substr($p_header['stored_filename'], -1) != '/') {
2761
+ $p_header['stored_filename'] .= '/';
2762
+ }
2763
+
2764
+ // ----- Set the file properties
2765
+ $p_header['size'] = 0;
2766
+ //$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked
2767
+ $p_header['external'] = 0x00000010; // Value for a folder : to be checked
2768
+
2769
+ // ----- Call the header generation
2770
+ if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
2771
+ {
2772
+ return $v_result;
2773
+ }
2774
+ }
2775
+ }
2776
+
2777
+ // ----- Look for post-add callback
2778
+ if (isset($p_options[WPVIVID_PCLZIP_CB_POST_ADD])) {
2779
+
2780
+ // ----- Generate a local information
2781
+ $v_local_header = array();
2782
+ $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2783
+
2784
+ // ----- Call the callback
2785
+ // Here I do not use call_user_func() because I need to send a reference to the
2786
+ // header.
2787
+ $v_result = $p_options[WPVIVID_PCLZIP_CB_POST_ADD](WPVIVID_PCLZIP_CB_POST_ADD, $v_local_header);
2788
+ if ($v_result == 0) {
2789
+ // ----- Ignored
2790
+ $v_result = 1;
2791
+ }
2792
+
2793
+ // ----- Update the information
2794
+ // Nothing can be modified
2795
+ }
2796
+
2797
+ // ----- Return
2798
+ return $v_result;
2799
+ }
2800
+ // --------------------------------------------------------------------------------
2801
+
2802
+ // --------------------------------------------------------------------------------
2803
+ // Function : privAddFileUsingTempFile()
2804
+ // Description :
2805
+ // Parameters :
2806
+ // Return Values :
2807
+ // --------------------------------------------------------------------------------
2808
+ function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
2809
+ {
2810
+ $v_result=WPVIVID_PCLZIP_ERR_NO_ERROR;
2811
+
2812
+ // ----- Working variable
2813
+ $p_filename = $p_filedescr['filename'];
2814
+
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
2831
+ $v_size = filesize($p_filename);
2832
+ while ($v_size != 0) {
2833
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2834
+ $v_buffer = @fread($v_file, $v_read_size);
2835
+ //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
2836
+ @gzputs($v_file_compressed, $v_buffer, $v_read_size);
2837
+ $v_size -= $v_read_size;
2838
+ }
2839
+
2840
+ // ----- Close the file
2841
+ @fclose($v_file);
2842
+ @gzclose($v_file_compressed);
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
2857
+ $v_binary_data = @fread($v_file_compressed, 10);
2858
+ $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);
2859
+
2860
+ // ----- Check some parameters
2861
+ $v_data_header['os'] = bin2hex($v_data_header['os']);
2862
+
2863
+ // ----- Read the gzip file footer
2864
+ @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8);
2865
+ $v_binary_data = @fread($v_file_compressed, 8);
2866
+ $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
2867
+
2868
+ // ----- Set the attributes
2869
+ $p_header['compression'] = ord($v_data_header['cm']);
2870
+ //$p_header['mtime'] = $v_data_header['mtime'];
2871
+ $p_header['crc'] = $v_data_footer['crc'];
2872
+ $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18;
2873
+
2874
+ // ----- Close the file
2875
+ @fclose($v_file_compressed);
2876
+
2877
+ // ----- Call the header generation
2878
+ if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2879
+ return $v_result;
2880
+ }
2881
+
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
2890
+ fseek($v_file_compressed, 10);
2891
+ $v_size = $p_header['compressed_size'];
2892
+ while ($v_size != 0)
2893
+ {
2894
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2895
+ $v_buffer = @fread($v_file_compressed, $v_read_size);
2896
+ //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
2897
+ @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2898
+ $v_size -= $v_read_size;
2899
+ }
2900
+
2901
+ // ----- Close the file
2902
+ @fclose($v_file_compressed);
2903
+
2904
+ // ----- Unlink the temporary file
2905
+ @unlink($v_gzip_temp_name);
2906
+
2907
+ // ----- Return
2908
+ return $v_result;
2909
+ }
2910
+ // --------------------------------------------------------------------------------
2911
+
2912
+ // --------------------------------------------------------------------------------
2913
+ // Function : privCalculateStoredFilename()
2914
+ // Description :
2915
+ // Based on file descriptor properties and global options, this method
2916
+ // calculate the filename that will be stored in the archive.
2917
+ // Parameters :
2918
+ // Return Values :
2919
+ // --------------------------------------------------------------------------------
2920
+ function privCalculateStoredFilename(&$p_filedescr, &$p_options)
2921
+ {
2922
+ $v_result=1;
2923
+
2924
+ // ----- Working variables
2925
+ $p_filename = $p_filedescr['filename'];
2926
+ if (isset($p_options[WPVIVID_PCLZIP_OPT_ADD_PATH])) {
2927
+ $p_add_dir = $p_options[WPVIVID_PCLZIP_OPT_ADD_PATH];
2928
+ }
2929
+ else {
2930
+ $p_add_dir = '';
2931
+ }
2932
+ if (isset($p_options[WPVIVID_PCLZIP_OPT_REMOVE_PATH])) {
2933
+ $p_remove_dir = $p_options[WPVIVID_PCLZIP_OPT_REMOVE_PATH];
2934
+ }
2935
+ else {
2936
+ $p_remove_dir = '';
2937
+ }
2938
+ if (isset($p_options[WPVIVID_PCLZIP_OPT_REMOVE_ALL_PATH])) {
2939
+ $p_remove_all_dir = $p_options[WPVIVID_PCLZIP_OPT_REMOVE_ALL_PATH];
2940
+ }
2941
+ else {
2942
+ $p_remove_all_dir = 0;
2943
+ }
2944
+
2945
+
2946
+ // ----- Look for full name change
2947
+ if (isset($p_filedescr['new_full_name'])) {
2948
+ // ----- Remove drive letter if any
2949
+ $v_stored_filename = WPvivid_PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
2950
+ }
2951
+
2952
+ // ----- Look for path and/or short name change
2953
+ else {
2954
+
2955
+ // ----- Look for short name change
2956
+ // Its when we change just the filename but not the path
2957
+ if (isset($p_filedescr['new_short_name'])) {
2958
+ $v_path_info = pathinfo($p_filename);
2959
+ $v_dir = '';
2960
+ if ($v_path_info['dirname'] != '') {
2961
+ $v_dir = $v_path_info['dirname'].'/';
2962
+ }
2963
+ $v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
2964
+ }
2965
+ else {
2966
+ // ----- Calculate the stored filename
2967
+ $v_stored_filename = $p_filename;
2968
+ }
2969
+
2970
+ // ----- Look for all path to remove
2971
+ if ($p_remove_all_dir) {
2972
+ $v_stored_filename = basename($p_filename);
2973
+ }
2974
+ // ----- Look for partial path remove
2975
+ else if ($p_remove_dir != "") {
2976
+ if (substr($p_remove_dir, -1) != '/')
2977
+ $p_remove_dir .= "/";
2978
+
2979
+ if ( (substr($p_filename, 0, 2) == "./")
2980
+ || (substr($p_remove_dir, 0, 2) == "./")) {
2981
+
2982
+ if ( (substr($p_filename, 0, 2) == "./")
2983
+ && (substr($p_remove_dir, 0, 2) != "./")) {
2984
+ $p_remove_dir = "./".$p_remove_dir;
2985
+ }
2986
+ if ( (substr($p_filename, 0, 2) != "./")
2987
+ && (substr($p_remove_dir, 0, 2) == "./")) {
2988
+ $p_remove_dir = substr($p_remove_dir, 2);
2989
+ }
2990
+ }
2991
+
2992
+ $v_compare = WPvivid_PclZipUtilPathInclusion($p_remove_dir,
2993
+ $v_stored_filename);
2994
+ if ($v_compare > 0) {
2995
+ if ($v_compare == 2) {
2996
+ $v_stored_filename = "";
2997
+ }
2998
+ else {
2999
+ $v_stored_filename = substr($v_stored_filename,
3000
+ strlen($p_remove_dir));
3001
+ }
3002
+ }
3003
+ }
3004
+
3005
+ // ----- Remove drive letter if any
3006
+ $v_stored_filename = WPvivid_PclZipUtilTranslateWinPath($v_stored_filename);
3007
+
3008
+ // ----- Look for path to add
3009
+ if ($p_add_dir != "") {
3010
+ if (substr($p_add_dir, -1) == "/")
3011
+ $v_stored_filename = $p_add_dir.$v_stored_filename;
3012
+ else
3013
+ $v_stored_filename = $p_add_dir."/".$v_stored_filename;
3014
+ }
3015
+ }
3016
+
3017
+ // ----- Filename (reduce the path of stored name)
3018
+ $v_stored_filename = WPvivid_PclZipUtilPathReduction($v_stored_filename);
3019
+ $p_filedescr['stored_filename'] = $v_stored_filename;
3020
+
3021
+ // ----- Return
3022
+ return $v_result;
3023
+ }
3024
+ // --------------------------------------------------------------------------------
3025
+
3026
+ // --------------------------------------------------------------------------------
3027
+ // Function : privWriteFileHeader()
3028
+ // Description :
3029
+ // Parameters :
3030
+ // Return Values :
3031
+ // --------------------------------------------------------------------------------
3032
+ function privWriteFileHeader(&$p_header)
3033
+ {
3034
+ $v_result=1;
3035
+
3036
+ // ----- Store the offset position of the file
3037
+ $p_header['offset'] = ftell($this->zip_fd);
3038
+
3039
+ // ----- Transform UNIX mtime to DOS format mdate/mtime
3040
+ $v_date = getdate($p_header['mtime']);
3041
+ $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3042
+ $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3043
+
3044
+ // ----- Packed data
3045
+ $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
3046
+ $p_header['version_extracted'], $p_header['flag'],
3047
+ $p_header['compression'], $v_mtime, $v_mdate,
3048
+ $p_header['crc'], $p_header['compressed_size'],
3049
+ $p_header['size'],
3050
+ strlen($p_header['stored_filename']),
3051
+ $p_header['extra_len']);
3052
+
3053
+ // ----- Write the first 148 bytes of the header in the archive
3054
+ fputs($this->zip_fd, $v_binary_data, 30);
3055
+
3056
+ // ----- Write the variable fields
3057
+ if (strlen($p_header['stored_filename']) != 0)
3058
+ {
3059
+ fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
3060
+ }
3061
+ if ($p_header['extra_len'] != 0)
3062
+ {
3063
+ fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
3064
+ }
3065
+
3066
+ // ----- Return
3067
+ return $v_result;
3068
+ }
3069
+ // --------------------------------------------------------------------------------
3070
+
3071
+ // --------------------------------------------------------------------------------
3072
+ // Function : privWriteCentralFileHeader()
3073
+ // Description :
3074
+ // Parameters :
3075
+ // Return Values :
3076
+ // --------------------------------------------------------------------------------
3077
+ function privWriteCentralFileHeader(&$p_header)
3078
+ {
3079
+ $v_result=1;
3080
+
3081
+ // TBC
3082
+ //for(reset($p_header); $key = key($p_header); next($p_header)) {
3083
+ //}
3084
+
3085
+ // ----- Transform UNIX mtime to DOS format mdate/mtime
3086
+ $v_date = getdate($p_header['mtime']);
3087
+ $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3088
+ $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3089
+
3090
+
3091
+ // ----- Packed data
3092
+ $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
3093
+ $p_header['version'], $p_header['version_extracted'],
3094
+ $p_header['flag'], $p_header['compression'],
3095
+ $v_mtime, $v_mdate, $p_header['crc'],
3096
+ $p_header['compressed_size'], $p_header['size'],
3097
+ strlen($p_header['stored_filename']),
3098
+ $p_header['extra_len'], $p_header['comment_len'],
3099
+ $p_header['disk'], $p_header['internal'],
3100
+ $p_header['external'], $p_header['offset']);
3101
+
3102
+ // ----- Write the 42 bytes of the header in the zip file
3103
+ fputs($this->zip_fd, $v_binary_data, 46);
3104
+
3105
+ // ----- Write the variable fields
3106
+ if (strlen($p_header['stored_filename']) != 0)
3107
+ {
3108
+ fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
3109
+ }
3110
+ if ($p_header['extra_len'] != 0)
3111
+ {
3112
+ fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
3113
+ }
3114
+ if ($p_header['comment_len'] != 0)
3115
+ {
3116
+ fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
3117
+ }
3118
+
3119
+ // ----- Return
3120
+ return $v_result;
3121
+ }
3122
+ // --------------------------------------------------------------------------------
3123
+
3124
+ // --------------------------------------------------------------------------------
3125
+ // Function : privWriteCentralHeader()
3126
+ // Description :
3127
+ // Parameters :
3128
+ // Return Values :
3129
+ // --------------------------------------------------------------------------------
3130
+ function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
3131
+ {
3132
+ $v_result=1;
3133
+
3134
+ // ----- Packed data
3135
+ $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
3136
+ $p_nb_entries, $p_size,
3137
+ $p_offset, strlen($p_comment));
3138
+
3139
+ // ----- Write the 22 bytes of the header in the zip file
3140
+ fputs($this->zip_fd, $v_binary_data, 22);
3141
+
3142
+ // ----- Write the variable fields
3143
+ if (strlen($p_comment) != 0)
3144
+ {
3145
+ fputs($this->zip_fd, $p_comment, strlen($p_comment));
3146
+ }
3147
+
3148
+ // ----- Return
3149
+ return $v_result;
3150
+ }
3151
+ // --------------------------------------------------------------------------------
3152
+
3153
+ // --------------------------------------------------------------------------------
3154
+ // Function : privList()
3155
+ // Description :
3156
+ // Parameters :
3157
+ // Return Values :
3158
+ // --------------------------------------------------------------------------------
3159
+ function privList(&$p_list)
3160
+ {
3161
+ $v_result=1;
3162
+
3163
+ // ----- Magic quotes trick
3164
+ $this->privDisableMagicQuotes();
3165
+
3166
+ // ----- Open the zip file
3167
+ if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
3168
+ {
3169
+ // ----- Magic quotes trick
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
3180
+ $v_central_dir = array();
3181
+ if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
3182
+ {
3183
+ $this->privSwapBackMagicQuotes();
3184
+ return $v_result;
3185
+ }
3186
+
3187
+ // ----- Go to beginning of Central Dir
3188
+ @rewind($this->zip_fd);
3189
+ if (@fseek($this->zip_fd, $v_central_dir['offset']))
3190
+ {
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
3201
+ for ($i=0; $i<$v_central_dir['entries']; $i++)
3202
+ {
3203
+ // ----- Read the file header
3204
+ if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3205
+ {
3206
+ $this->privSwapBackMagicQuotes();
3207
+ return $v_result;
3208
+ }
3209
+ $v_header['index'] = $i;
3210
+
3211
+ // ----- Get the only interesting attributes
3212
+ $this->privConvertHeader2FileInfo($v_header, $p_list[$i]);
3213
+ unset($v_header);
3214
+ }
3215
+
3216
+ // ----- Close the zip file
3217
+ $this->privCloseFd();
3218
+
3219
+ // ----- Magic quotes trick
3220
+ $this->privSwapBackMagicQuotes();
3221
+
3222
+ // ----- Return
3223
+ return $v_result;
3224
+ }
3225
+ // --------------------------------------------------------------------------------
3226
+
3227
+ // --------------------------------------------------------------------------------
3228
+ // Function : privConvertHeader2FileInfo()
3229
+ // Description :
3230
+ // This function takes the file information from the central directory
3231
+ // entries and extract the interesting parameters that will be given back.
3232
+ // The resulting file infos are set in the array $p_info
3233
+ // $p_info['filename'] : Filename with full path. Given by user (add),
3234
+ // extracted in the filesystem (extract).
3235
+ // $p_info['stored_filename'] : Stored filename in the archive.
3236
+ // $p_info['size'] = Size of the file.
3237
+ // $p_info['compressed_size'] = Compressed size of the file.
3238
+ // $p_info['mtime'] = Last modification date of the file.
3239
+ // $p_info['comment'] = Comment associated with the file.
3240
+ // $p_info['folder'] = true/false : indicates if the entry is a folder or not.
3241
+ // $p_info['status'] = status of the action on the file.
3242
+ // $p_info['crc'] = CRC of the file content.
3243
+ // Parameters :
3244
+ // Return Values :
3245
+ // --------------------------------------------------------------------------------
3246
+ function privConvertHeader2FileInfo($p_header, &$p_info)
3247
+ {
3248
+ $v_result=1;
3249
+
3250
+ // ----- Get the interesting attributes
3251
+ $v_temp_path = WPvivid_PclZipUtilPathReduction($p_header['filename']);
3252
+ $p_info['filename'] = $v_temp_path;
3253
+ $v_temp_path = WPvivid_PclZipUtilPathReduction($p_header['stored_filename']);
3254
+ $p_info['stored_filename'] = $v_temp_path;
3255
+ $p_info['size'] = $p_header['size'];
3256
+ $p_info['compressed_size'] = $p_header['compressed_size'];
3257
+ $p_info['mtime'] = $p_header['mtime'];
3258
+ $p_info['comment'] = $p_header['comment'];
3259
+ $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
3260
+ $p_info['index'] = $p_header['index'];
3261
+ $p_info['status'] = $p_header['status'];
3262
+ $p_info['crc'] = $p_header['crc'];
3263
+
3264
+ // ----- Return
3265
+ return $v_result;
3266
+ }
3267
+ // --------------------------------------------------------------------------------
3268
+
3269
+ // --------------------------------------------------------------------------------
3270
+ // Function : privExtractByRule()
3271
+ // Description :
3272
+ // Extract a file or directory depending of rules (by index, by name, ...)
3273
+ // Parameters :
3274
+ // $p_file_list : An array where will be placed the properties of each
3275
+ // extracted file
3276
+ // $p_path : Path to add while writing the extracted files
3277
+ // $p_remove_path : Path to remove (from the file memorized path) while writing the
3278
+ // extracted files. If the path does not match the file path,
3279
+ // the file is extracted with its memorized path.
3280
+ // $p_remove_path does not apply to 'list' mode.
3281
+ // $p_path and $p_remove_path are commulative.
3282
+ // Return Values :
3283
+ // 1 on success,0 or less on error (see error code list)
3284
+ // --------------------------------------------------------------------------------
3285
+ function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3286
+ {
3287
+ $v_result=1;
3288
+
3289
+ // ----- Magic quotes trick
3290
+ $this->privDisableMagicQuotes();
3291
+
3292
+ // ----- Check the path
3293
+ if ( ($p_path == "")
3294
+ || ( (substr($p_path, 0, 1) != "/")
3295
+ && (substr($p_path, 0, 3) != "../")
3296
+ && (substr($p_path,1,2)!=":/")))
3297
+ $p_path = "./".$p_path;
3298
+
3299
+ // ----- Reduce the path last (and duplicated) '/'
3300
+ if (($p_path != "./") && ($p_path != "/"))
3301
+ {
3302
+ // ----- Look for the path end '/'
3303
+ while (substr($p_path, -1) == "/")
3304
+ {
3305
+ $p_path = substr($p_path, 0, strlen($p_path)-1);
3306
+ }
3307
+ }
3308
+
3309
+ // ----- Look for path to remove format (should end by /)
3310
+ if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))
3311
+ {
3312
+ $p_remove_path .= '/';
3313
+ }
3314
+ $p_remove_path_size = strlen($p_remove_path);
3315
+
3316
+ // ----- Open the zip file
3317
+ if (($v_result = $this->privOpenFd('rb')) != 1)
3318
+ {
3319
+ $this->privSwapBackMagicQuotes();
3320
+ return $v_result;
3321
+ }
3322
+
3323
+ // ----- Read the central directory information
3324
+ $v_central_dir = array();
3325
+ if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
3326
+ {
3327
+ // ----- Close the zip file
3328
+ $this->privCloseFd();
3329
+ $this->privSwapBackMagicQuotes();
3330
+
3331
+ return $v_result;
3332
+ }
3333
+
3334
+ // ----- Start at beginning of Central Dir
3335
+ $v_pos_entry = $v_central_dir['offset'];
3336
+
3337
+ // ----- Read each entry
3338
+ $j_start = 0;
3339
+ for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
3340
+ {
3341
+
3342
+ // ----- Read next Central dir entry
3343
+ @rewind($this->zip_fd);
3344
+ if (@fseek($this->zip_fd, $v_pos_entry))
3345
+ {
3346
+ // ----- Close the zip file
3347
+ $this->privCloseFd();
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
3358
+ $v_header = array();
3359
+ if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3360
+ {
3361
+ // ----- Close the zip file
3362
+ $this->privCloseFd();
3363
+ $this->privSwapBackMagicQuotes();
3364
+
3365
+ return $v_result;
3366
+ }
3367
+
3368
+ // ----- Store the index
3369
+ $v_header['index'] = $i;
3370
+
3371
+ // ----- Store the file position
3372
+ $v_pos_entry = ftell($this->zip_fd);
3373
+
3374
+ // ----- Look for the specific extract rules
3375
+ $v_extract = false;
3376
+
3377
+ // ----- Look for extract by name rule
3378
+ if ( (isset($p_options[WPVIVID_PCLZIP_OPT_BY_NAME]))
3379
+ && ($p_options[WPVIVID_PCLZIP_OPT_BY_NAME] != 0)) {
3380
+
3381
+ // ----- Look if the filename is in the list
3382
+ for ($j=0; ($j<sizeof($p_options[WPVIVID_PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
3383
+
3384
+ // ----- Look for a directory
3385
+ if (substr($p_options[WPVIVID_PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
3386
+
3387
+ // ----- Look if the directory is in the filename path
3388
+ if ( (strlen($v_header['stored_filename']) > strlen($p_options[WPVIVID_PCLZIP_OPT_BY_NAME][$j]))
3389
+ && (substr($v_header['stored_filename'], 0, strlen($p_options[WPVIVID_PCLZIP_OPT_BY_NAME][$j])) == $p_options[WPVIVID_PCLZIP_OPT_BY_NAME][$j])) {
3390
+ $v_extract = true;
3391
+ }
3392
+ }
3393
+ // ----- Look for a filename
3394
+ elseif ($v_header['stored_filename'] == $p_options[WPVIVID_PCLZIP_OPT_BY_NAME][$j]) {
3395
+ $v_extract = true;
3396
+ }
3397
+ }
3398
+ }
3399
+
3400
+ // ----- Look for extract by ereg rule
3401
+ // ereg() is deprecated with PHP 5.3
3402
+ /*
3403
+ else if ( (isset($p_options[WPVIVID_PCLZIP_OPT_BY_EREG]))
3404
+ && ($p_options[WPVIVID_PCLZIP_OPT_BY_EREG] != "")) {
3405
+
3406
+ if (ereg($p_options[WPVIVID_PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
3407
+ $v_extract = true;
3408
+ }
3409
+ }
3410
+ */
3411
+
3412
+ // ----- Look for extract by preg rule
3413
+ else if ( (isset($p_options[WPVIVID_PCLZIP_OPT_BY_PREG]))
3414
+ && ($p_options[WPVIVID_PCLZIP_OPT_BY_PREG] != "")) {
3415
+
3416
+ if (preg_match($p_options[WPVIVID_PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
3417
+ $v_extract = true;
3418
+ }
3419
+ }
3420
+
3421
+ // ----- Look for extract by index rule
3422
+ else if ( (isset($p_options[WPVIVID_PCLZIP_OPT_BY_INDEX]))
3423
+ && ($p_options[WPVIVID_PCLZIP_OPT_BY_INDEX] != 0)) {
3424
+
3425
+ // ----- Look if the index is in the list
3426
+ for ($j=$j_start; ($j<sizeof($p_options[WPVIVID_PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
3427
+
3428
+ if (($i>=$p_options[WPVIVID_PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[WPVIVID_PCLZIP_OPT_BY_INDEX][$j]['end'])) {
3429
+ $v_extract = true;
3430
+ }
3431
+ if ($i>=$p_options[WPVIVID_PCLZIP_OPT_BY_INDEX][$j]['end']) {
3432
+ $j_start = $j+1;
3433
+ }
3434
+
3435
+ if ($p_options[WPVIVID_PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
3436
+ break;
3437
+ }
3438
+ }
3439
+ }
3440
+
3441
+ // ----- Look for no rule, which means extract all the archive
3442
+ else {
3443
+ $v_extract = true;
3444
+ }
3445
+
3446
+ // ----- Check compression method
3447
+ if ( ($v_extract)
3448
+ && ( ($v_header['compression'] != 8)
3449
+ && ($v_header['compression'] != 0))) {
3450
+ $v_header['status'] = 'unsupported_compression';
3451
+
3452
+ // ----- Look for WPVIVID_PCLZIP_OPT_STOP_ON_ERROR
3453
+ if ( (isset($p_options[WPVIVID_PCLZIP_OPT_STOP_ON_ERROR]))
3454
+ && ($p_options[WPVIVID_PCLZIP_OPT_STOP_ON_ERROR]===true)) {
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
+
3467
+ // ----- Check encrypted files
3468
+ if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
3469
+ $v_header['status'] = 'unsupported_encryption';
3470
+
3471
+ // ----- Look for WPVIVID_PCLZIP_OPT_STOP_ON_ERROR
3472
+ if ( (isset($p_options[WPVIVID_PCLZIP_OPT_STOP_ON_ERROR]))
3473
+ && ($p_options[WPVIVID_PCLZIP_OPT_STOP_ON_ERROR]===true)) {
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
+
3486
+ // ----- Look for real extraction
3487
+ if (($v_extract) && ($v_header['status'] != 'ok')) {
3488
+ $v_result = $this->privConvertHeader2FileInfo($v_header,
3489
+ $p_file_list[$v_nb_extracted++]);
3490
+ if ($v_result != 1) {
3491
+ $this->privCloseFd();
3492
+ $this->privSwapBackMagicQuotes();
3493
+ return $v_result;
3494
+ }
3495
+
3496
+ $v_extract = false;
3497
+ }
3498
+
3499
+ // ----- Look for real extraction
3500
+ if ($v_extract)
3501
+ {
3502
+
3503
+ // ----- Go to the file position
3504
+ @rewind($this->zip_fd);
3505
+ if (@fseek($this->zip_fd, $v_header['offset']))
3506
+ {
3507
+ // ----- Close the zip file
3508
+ $this->privCloseFd();
3509
+
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
3520
+ if ($p_options[WPVIVID_PCLZIP_OPT_EXTRACT_AS_STRING]) {
3521
+
3522
+ $v_string = '';
3523
+
3524
+ // ----- Extracting the file
3525
+ $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options);
3526
+ if ($v_result1 < 1) {
3527
+ $this->privCloseFd();
3528
+ $this->privSwapBackMagicQuotes();
3529
+ return $v_result1;
3530
+ }
3531
+
3532
+ // ----- Get the only interesting attributes
3533
+ if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
3534
+ {
3535
+ // ----- Close the zip file
3536
+ $this->privCloseFd();
3537
+ $this->privSwapBackMagicQuotes();
3538
+
3539
+ return $v_result;
3540
+ }
3541
+
3542
+ // ----- Set the file content
3543
+ $p_file_list[$v_nb_extracted]['content'] = $v_string;
3544
+
3545
+ // ----- Next extracted file
3546
+ $v_nb_extracted++;
3547
+
3548
+ // ----- Look for user callback abort
3549
+ if ($v_result1 == 2) {
3550
+ break;
3551
+ }
3552
+ }
3553
+ // ----- Look for extraction in standard output
3554
+ elseif ( (isset($p_options[WPVIVID_PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
3555
+ && ($p_options[WPVIVID_PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
3556
+ // ----- Extracting the file in standard output
3557
+ $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
3558
+ if ($v_result1 < 1) {
3559
+ $this->privCloseFd();
3560
+ $this->privSwapBackMagicQuotes();
3561
+ return $v_result1;
3562
+ }
3563
+
3564
+ // ----- Get the only interesting attributes
3565
+ if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
3566
+ $this->privCloseFd();
3567
+ $this->privSwapBackMagicQuotes();
3568
+ return $v_result;
3569
+ }
3570
+
3571
+ // ----- Look for user callback abort
3572
+ if ($v_result1 == 2) {
3573
+ break;
3574
+ }
3575
+ }
3576
+ // ----- Look for normal extraction
3577
+ else {
3578
+ // ----- Extracting the file
3579
+ $v_result1 = $this->privExtractFile($v_header,
3580
+ $p_path, $p_remove_path,
3581
+ $p_remove_all_path,
3582
+ $p_options);
3583
+ if ($v_result1 < 1) {
3584
+ $this->privCloseFd();
3585
+ $this->privSwapBackMagicQuotes();
3586
+ return $v_result1;
3587
+ }
3588
+
3589
+ // ----- Get the only interesting attributes
3590
+ if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
3591
+ {
3592
+ // ----- Close the zip file
3593
+ $this->privCloseFd();
3594
+ $this->privSwapBackMagicQuotes();
3595
+
3596
+ return $v_result;
3597
+ }
3598
+
3599
+ // ----- Look for user callback abort
3600
+ if ($v_result1 == 2) {
3601
+ break;
3602
+ }
3603
+ }
3604
+ }
3605
+ }
3606
+
3607
+ // ----- Close the zip file
3608
+ $this->privCloseFd();
3609
+ $this->privSwapBackMagicQuotes();
3610
+
3611
+ // ----- Return
3612
+ return $v_result;
3613
+ }
3614
+ // --------------------------------------------------------------------------------
3615
+
3616
+ // --------------------------------------------------------------------------------
3617
+ // Function : privExtractFile()
3618
+ // Description :
3619
+ // Parameters :
3620
+ // Return Values :
3621
+ //
3622
+ // 1 : ... ?
3623
+ // WPVIVID_PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback
3624
+ // --------------------------------------------------------------------------------
3625
+ function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3626
+ {
3627
+ $v_result=1;
3628
+
3629
+ // ----- Read the file header
3630
+ if (($v_result = $this->privReadFileHeader($v_header)) != 1)
3631
+ {
3632
+ // ----- Return
3633
+ return $v_result;
3634
+ }
3635
+
3636
+
3637
+ // ----- Check that the file header is coherent with $p_entry info
3638
+ if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
3639
+ // TBC
3640
+ }
3641
+
3642
+ // ----- Look for all path to remove
3643
+ if ($p_remove_all_path == true) {
3644
+ // ----- Look for folder entry that not need to be extracted
3645
+ if (($p_entry['external']&0x00000010)==0x00000010) {
3646
+
3647
+ $p_entry['status'] = "filtered";
3648
+
3649
+ return $v_result;
3650
+ }
3651
+
3652
+ // ----- Get the basename of the path
3653
+ $p_entry['filename'] = basename($p_entry['filename']);
3654
+ }
3655
+
3656
+ // ----- Look for path to remove
3657
+ else if ($p_remove_path != "")
3658
+ {
3659
+ if (WPvivid_PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
3660
+ {
3661
+
3662
+ // ----- Change the file status
3663
+ $p_entry['status'] = "filtered";
3664
+
3665
+ // ----- Return
3666
+ return $v_result;
3667
+ }
3668
+
3669
+ $p_remove_path_size = strlen($p_remove_path);
3670
+ if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
3671
+ {
3672
+
3673
+ // ----- Remove the path
3674
+ $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
3675
+
3676
+ }
3677
+ }
3678
+
3679
+ // ----- Add the path
3680
+ if ($p_path != '') {
3681
+ $p_entry['filename'] = $p_path."/".$p_entry['filename'];
3682
+ }
3683
+
3684
+ // ----- Check a base_dir_restriction
3685
+ if (isset($p_options[WPVIVID_PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
3686
+ $v_inclusion
3687
+ = WPvivid_PclZipUtilPathInclusion($p_options[WPVIVID_PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
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
+
3699
+ // ----- Look for pre-extract callback
3700
+ if (isset($p_options[WPVIVID_PCLZIP_CB_PRE_EXTRACT])) {
3701
+
3702
+ // ----- Generate a local information
3703
+ $v_local_header = array();
3704
+ $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3705
+
3706
+ // ----- Call the callback
3707
+ // Here I do not use call_user_func() because I need to send a reference to the
3708
+ // header.
3709
+ $v_result = $p_options[WPVIVID_PCLZIP_CB_PRE_EXTRACT](WPVIVID_PCLZIP_CB_PRE_EXTRACT, $v_local_header);
3710
+ if ($v_result == 0) {
3711
+ // ----- Change the file status
3712
+ $p_entry['status'] = "skipped";
3713
+ $v_result = 1;
3714
+ }
3715
+
3716
+ // ----- Look for abort result
3717
+ if ($v_result == 2) {
3718
+ // ----- This status is internal and will be changed in 'skipped'
3719
+ $p_entry['status'] = "aborted";
3720
+ $v_result = WPVIVID_PCLZIP_ERR_USER_ABORTED;
3721
+ }
3722
+
3723
+ // ----- Update the information
3724
+ // Only some fields can be modified
3725
+ $p_entry['filename'] = $v_local_header['filename'];
3726
+ }
3727
+
3728
+
3729
+ // ----- Look if extraction should be done
3730
+ if ($p_entry['status'] == 'ok') {
3731
+
3732
+ // ----- Look for specific actions while the file exist
3733
+ if (file_exists($p_entry['filename']))
3734
+ {
3735
+
3736
+ // ----- Look if file is a directory
3737
+ if (is_dir($p_entry['filename']))
3738
+ {
3739
+
3740
+ // ----- Change the file status
3741
+ $p_entry['status'] = "already_a_directory";
3742
+
3743
+ // ----- Look for WPVIVID_PCLZIP_OPT_STOP_ON_ERROR
3744
+ // For historical reason first PclZip implementation does not stop
3745
+ // when this kind of error occurs.
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
3757
+ else if (!is_writeable($p_entry['filename']))
3758
+ {
3759
+
3760
+ // ----- Change the file status
3761
+ $p_entry['status'] = "write_protected";
3762
+
3763
+ // ----- Look for WPVIVID_PCLZIP_OPT_STOP_ON_ERROR
3764
+ // For historical reason first PclZip implementation does not stop
3765
+ // when this kind of error occurs.
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
+
3777
+ // ----- Look if the extracted file is older
3778
+ else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
3779
+ {
3780
+ // ----- Change the file status
3781
+ if ( (isset($p_options[WPVIVID_PCLZIP_OPT_REPLACE_NEWER]))
3782
+ && ($p_options[WPVIVID_PCLZIP_OPT_REPLACE_NEWER]===true)) {
3783
+ }
3784
+ else {
3785
+ $p_entry['status'] = "newer_exist";
3786
+
3787
+ // ----- Look for WPVIVID_PCLZIP_OPT_STOP_ON_ERROR
3788
+ // For historical reason first PclZip implementation does not stop
3789
+ // when this kind of error occurs.
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
+ }
3801
+ else {
3802
+ }
3803
+ }
3804
+
3805
+ // ----- Check the directory availability and create it if necessary
3806
+ else {
3807
+ if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
3808
+ $v_dir_to_check = $p_entry['filename'];
3809
+ else if (!strstr($p_entry['filename'], "/"))
3810
+ $v_dir_to_check = "";
3811
+ else
3812
+ $v_dir_to_check = dirname($p_entry['filename']);
3813
+
3814
+ if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
3815
+
3816
+ // ----- Change the file status
3817
+ $p_entry['status'] = "path_creation_fail";
3818
+
3819
+ // ----- Return
3820
+ //return $v_result;
3821
+ $v_result = 1;
3822
+ }
3823
+ }
3824
+ }
3825
+
3826
+ // ----- Look if extraction should be done
3827
+ if ($p_entry['status'] == 'ok') {
3828
+
3829
+ // ----- Do the extraction (if not a folder)
3830
+ if (!(($p_entry['external']&0x00000010)==0x00000010))
3831
+ {
3832
+ // ----- Look for not compressed file
3833
+ if ($p_entry['compression'] == 0) {
3834
+
3835
+ // ----- Opening destination file
3836
+ if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
3837
+ {
3838
+
3839
+ // ----- Change the file status
3840
+ $p_entry['status'] = "write_error";
3841
+
3842
+ // ----- Return
3843
+ return $v_result;
3844
+ }
3845
+
3846
+
3847
+ // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3848
+ $v_size = $p_entry['compressed_size'];
3849
+ while ($v_size != 0)
3850
+ {
3851
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
3852
+ $v_buffer = @fread($this->zip_fd, $v_read_size);
3853
+ /* Try to speed up the code
3854
+ $v_binary_data = pack('a'.$v_read_size, $v_buffer);
3855
+ @fwrite($v_dest_file, $v_binary_data, $v_read_size);
3856
+ */
3857
+ @fwrite($v_dest_file, $v_buffer, $v_read_size);
3858
+ $v_size -= $v_read_size;
3859
+ }
3860
+
3861
+ // ----- Closing the destination file
3862
+ fclose($v_dest_file);
3863
+
3864
+ // ----- Change the file mtime
3865
+ touch($p_entry['filename'], $p_entry['mtime']);
3866
+
3867
+
3868
+ }
3869
+ else {
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
+
3878
+ // ----- Look for using temporary file to unzip
3879
+ if ( (!isset($p_options[WPVIVID_PCLZIP_OPT_TEMP_FILE_OFF]))
3880
+ && (isset($p_options[WPVIVID_PCLZIP_OPT_TEMP_FILE_ON])
3881
+ || (isset($p_options[WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD])
3882
+ && ($p_options[WPVIVID_PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
3883
+ $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
3884
+ if ($v_result < WPVIVID_PCLZIP_ERR_NO_ERROR) {
3885
+ return $v_result;
3886
+ }
3887
+ }
3888
+
3889
+ // ----- Look for extract in memory
3890
+ else {
3891
+
3892
+
3893
+ // ----- Read the compressed file in a buffer (one shot)
3894
+ if ( $p_entry['compressed_size'] > 0 ) {
3895
+ $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
3896
+ }
3897
+ else {
3898
+ $v_buffer = false;
3899
+ }
3900
+
3901
+ // ----- Decompress the file
3902
+ $v_file_content = @gzinflate($v_buffer);
3903
+ unset($v_buffer);
3904
+ if ($v_file_content === FALSE) {
3905
+
3906
+ // ----- Change the file status
3907
+ // TBC
3908
+ $p_entry['status'] = "error";
3909
+
3910
+ return $v_result;
3911
+ }
3912
+
3913
+ // ----- Opening destination file
3914
+ if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
3915
+
3916
+ // ----- Change the file status
3917
+ $p_entry['status'] = "write_error";
3918
+
3919
+ return $v_result;
3920
+ }
3921
+
3922
+ // ----- Write the uncompressed data
3923
+ @fwrite($v_dest_file, $v_file_content, $p_entry['size']);
3924
+ unset($v_file_content);
3925
+
3926
+ // ----- Closing the destination file
3927
+ @fclose($v_dest_file);
3928
+
3929
+ }
3930
+
3931
+ // ----- Change the file mtime
3932
+ @touch($p_entry['filename'], $p_entry['mtime']);
3933
+ }
3934
+
3935
+ // ----- Look for chmod option
3936
+ if (isset($p_options[WPVIVID_PCLZIP_OPT_SET_CHMOD])) {
3937
+
3938
+ // ----- Change the mode of the file
3939
+ @chmod($p_entry['filename'], $p_options[WPVIVID_PCLZIP_OPT_SET_CHMOD]);
3940
+ }
3941
+
3942
+ }
3943
+ }
3944
+
3945
+ // ----- Change abort status
3946
+ if ($p_entry['status'] == "aborted") {
3947
+ $p_entry['status'] = "skipped";
3948
+ }
3949
+
3950
+ // ----- Look for post-extract callback
3951
+ elseif (isset($p_options[WPVIVID_PCLZIP_CB_POST_EXTRACT])) {
3952
+
3953
+ // ----- Generate a local information
3954
+ $v_local_header = array();
3955
+ $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3956
+
3957
+ // ----- Call the callback
3958
+ // Here I do not use call_user_func() because I need to send a reference to the
3959
+ // header.
3960
+ $v_result = $p_options[WPVIVID_PCLZIP_CB_POST_EXTRACT](WPVIVID_PCLZIP_CB_POST_EXTRACT, $v_local_header);
3961
+
3962
+ // ----- Look for abort result
3963
+ if ($v_result == 2) {
3964
+ $v_result = WPVIVID_PCLZIP_ERR_USER_ABORTED;
3965
+ }
3966
+ }
3967
+
3968
+ // ----- Return
3969
+ return $v_result;
3970
+ }
3971
+ // --------------------------------------------------------------------------------
3972
+
3973
+ // --------------------------------------------------------------------------------
3974
+ // Function : privExtractFileUsingTempFile()
3975
+ // Description :
3976
+ // Parameters :
3977
+ // Return Values :
3978
+ // --------------------------------------------------------------------------------
3979
+ function privExtractFileUsingTempFile(&$p_entry, &$p_options)
3980
+ {
3981
+ $v_result=1;
3982
+
3983
+ // ----- Creates a temporary file
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
+
3992
+ // ----- Write gz file format header
3993
+ $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
3994
+ @fwrite($v_dest_file, $v_binary_data, 10);
3995
+
3996
+ // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3997
+ $v_size = $p_entry['compressed_size'];
3998
+ while ($v_size != 0)
3999
+ {
4000
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
4001
+ $v_buffer = @fread($this->zip_fd, $v_read_size);
4002
+ //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
4003
+ @fwrite($v_dest_file, $v_buffer, $v_read_size);
4004
+ $v_size -= $v_read_size;
4005
+ }
4006
+
4007
+ // ----- Write gz file format footer
4008
+ $v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']);
4009
+ @fwrite($v_dest_file, $v_binary_data, 8);
4010
+
4011
+ // ----- Close the temporary file
4012
+ @fclose($v_dest_file);
4013
+
4014
+ // ----- Opening destination file
4015
+ if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
4016
+ $p_entry['status'] = "write_error";
4017
+ return $v_result;
4018
+ }
4019
+
4020
+ // ----- Open the temporary gz file
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
+
4029
+ // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
4030
+ $v_size = $p_entry['size'];
4031
+ while ($v_size != 0) {
4032
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
4033
+ $v_buffer = @gzread($v_src_file, $v_read_size);
4034
+ //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
4035
+ @fwrite($v_dest_file, $v_buffer, $v_read_size);
4036
+ $v_size -= $v_read_size;
4037
+ }
4038
+ @fclose($v_dest_file);
4039
+ @gzclose($v_src_file);
4040
+
4041
+ // ----- Delete the temporary file
4042
+ @unlink($v_gzip_temp_name);
4043
+
4044
+ // ----- Return
4045
+ return $v_result;
4046
+ }
4047
+ // --------------------------------------------------------------------------------
4048
+
4049
+ // --------------------------------------------------------------------------------
4050
+ // Function : privExtractFileInOutput()
4051
+ // Description :
4052
+ // Parameters :
4053
+ // Return Values :
4054
+ // --------------------------------------------------------------------------------
4055
+ function privExtractFileInOutput(&$p_entry, &$p_options)
4056
+ {
4057
+ $v_result=1;
4058
+
4059
+ // ----- Read the file header
4060
+ if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
4061
+ return $v_result;
4062
+ }
4063
+
4064
+
4065
+ // ----- Check that the file header is coherent with $p_entry info
4066
+ if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
4067
+ // TBC
4068
+ }
4069
+
4070
+ // ----- Look for pre-extract callback
4071
+ if (isset($p_options[WPVIVID_PCLZIP_CB_PRE_EXTRACT])) {
4072
+
4073
+ // ----- Generate a local information
4074
+ $v_local_header = array();
4075
+ $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4076
+
4077
+ // ----- Call the callback
4078
+ // Here I do not use call_user_func() because I need to send a reference to the
4079
+ // header.
4080
+ // eval('$v_result = '.$p_options[WPVIVID_PCLZIP_CB_PRE_EXTRACT].'(WPVIVID_PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
4081
+ $v_result = $p_options[WPVIVID_PCLZIP_CB_PRE_EXTRACT](WPVIVID_PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4082
+ if ($v_result == 0) {
4083
+ // ----- Change the file status
4084
+ $p_entry['status'] = "skipped";
4085
+ $v_result = 1;
4086
+ }
4087
+
4088
+ // ----- Look for abort result
4089
+ if ($v_result == 2) {
4090
+ // ----- This status is internal and will be changed in 'skipped'
4091
+ $p_entry['status'] = "aborted";
4092
+ $v_result = WPVIVID_PCLZIP_ERR_USER_ABORTED;
4093
+ }
4094
+
4095
+ // ----- Update the information
4096
+ // Only some fields can be modified
4097
+ $p_entry['filename'] = $v_local_header['filename'];
4098
+ }
4099
+
4100
+ // ----- Trace
4101
+
4102
+ // ----- Look if extraction should be done
4103
+ if ($p_entry['status'] == 'ok') {
4104
+
4105
+ // ----- Do the extraction (if not a folder)
4106
+ if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4107
+ // ----- Look for not compressed file
4108
+ if ($p_entry['compressed_size'] == $p_entry['size']) {
4109
+
4110
+ // ----- Read the file in a buffer (one shot)
4111
+ if ( $p_entry['compressed_size'] > 0 ) {
4112
+ $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
4113
+ }
4114
+ else {
4115
+ $v_buffer = false;
4116
+ }
4117
+
4118
+ // ----- Send the file to the output
4119
+ echo $v_buffer;
4120
+ unset($v_buffer);
4121
+ }
4122
+ else {
4123
+
4124
+ // ----- Read the compressed file in a buffer (one shot)
4125
+ if ( $p_entry['compressed_size'] > 0 ) {
4126
+ $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
4127
+ }
4128
+ else {
4129
+ $v_buffer = false;
4130
+ }
4131
+
4132
+ // ----- Decompress the file
4133
+ $v_file_content = gzinflate($v_buffer);
4134
+ unset($v_buffer);
4135
+
4136
+ // ----- Send the file to the output
4137
+ echo $v_file_content;
4138
+ unset($v_file_content);
4139
+ }
4140
+ }
4141
+ }
4142
+
4143
+ // ----- Change abort status
4144
+ if ($p_entry['status'] == "aborted") {
4145
+ $p_entry['status'] = "skipped";
4146
+ }
4147
+
4148
+ // ----- Look for post-extract callback
4149
+ elseif (isset($p_options[WPVIVID_PCLZIP_CB_POST_EXTRACT])) {
4150
+
4151
+ // ----- Generate a local information
4152
+ $v_local_header = array();
4153
+ $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4154
+
4155
+ // ----- Call the callback
4156
+ // Here I do not use call_user_func() because I need to send a reference to the
4157
+ // header.
4158
+ $v_result = $p_options[WPVIVID_PCLZIP_CB_POST_EXTRACT](WPVIVID_PCLZIP_CB_POST_EXTRACT, $v_local_header);
4159
+
4160
+ // ----- Look for abort result
4161
+ if ($v_result == 2) {
4162
+ $v_result = WPVIVID_PCLZIP_ERR_USER_ABORTED;
4163
+ }
4164
+ }
4165
+
4166
+ return $v_result;
4167
+ }
4168
+ // --------------------------------------------------------------------------------
4169
+
4170
+ // --------------------------------------------------------------------------------
4171
+ // Function : privExtractFileAsString()
4172
+ // Description :
4173
+ // Parameters :
4174
+ // Return Values :
4175
+ // --------------------------------------------------------------------------------
4176
+ function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
4177
+ {
4178
+ $v_result=1;
4179
+
4180
+ // ----- Read the file header
4181
+ $v_header = array();
4182
+ if (($v_result = $this->privReadFileHeader($v_header)) != 1)
4183
+ {
4184
+ // ----- Return
4185
+ return $v_result;
4186
+ }
4187
+
4188
+
4189
+ // ----- Check that the file header is coherent with $p_entry info
4190
+ if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
4191
+ // TBC
4192
+ }
4193
+
4194
+ // ----- Look for pre-extract callback
4195
+ if (isset($p_options[WPVIVID_PCLZIP_CB_PRE_EXTRACT])) {
4196
+
4197
+ // ----- Generate a local information
4198
+ $v_local_header = array();
4199
+ $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4200
+
4201
+ // ----- Call the callback
4202
+ // Here I do not use call_user_func() because I need to send a reference to the
4203
+ // header.
4204
+ $v_result = $p_options[WPVIVID_PCLZIP_CB_PRE_EXTRACT](WPVIVID_PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4205
+ if ($v_result == 0) {
4206
+ // ----- Change the file status
4207
+ $p_entry['status'] = "skipped";
4208
+ $v_result = 1;
4209
+ }
4210
+
4211
+ // ----- Look for abort result
4212
+ if ($v_result == 2) {
4213
+ // ----- This status is internal and will be changed in 'skipped'
4214
+ $p_entry['status'] = "aborted";
4215
+ $v_result = WPVIVID_PCLZIP_ERR_USER_ABORTED;
4216
+ }
4217
+
4218
+ // ----- Update the information
4219
+ // Only some fields can be modified
4220
+ $p_entry['filename'] = $v_local_header['filename'];
4221
+ }
4222
+
4223
+
4224
+ // ----- Look if extraction should be done
4225
+ if ($p_entry['status'] == 'ok') {
4226
+
4227
+ // ----- Do the extraction (if not a folder)
4228
+ if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4229
+ // ----- Look for not compressed file
4230
+ // if ($p_entry['compressed_size'] == $p_entry['size'])
4231
+ if ($p_entry['compression'] == 0) {
4232
+
4233
+ // ----- Reading the file
4234
+ if ( $p_entry['compressed_size'] > 0 ) {
4235
+ $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
4236
+ }
4237
+ else {
4238
+ $p_string = false;
4239
+ }
4240
+ }
4241
+ else {
4242
+
4243
+ // ----- Reading the file
4244
+ if ( $p_entry['compressed_size'] > 0 ) {
4245
+ $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
4246
+ }
4247
+ else {
4248
+ $v_data = false;
4249
+ }
4250
+
4251
+ // ----- Decompress the file
4252
+ if (($p_string = @gzinflate($v_data)) === FALSE) {
4253
+ // TBC
4254
+ }
4255
+ }
4256
+
4257
+ // ----- Trace
4258
+ }
4259
+ else {
4260
+ // TBC : error : can not extract a folder in a string
4261
+ }
4262
+
4263
+ }
4264
+
4265
+ // ----- Change abort status
4266
+ if ($p_entry['status'] == "aborted") {
4267
+ $p_entry['status'] = "skipped";
4268
+ }
4269
+
4270
+ // ----- Look for post-extract callback
4271
+ elseif (isset($p_options[WPVIVID_PCLZIP_CB_POST_EXTRACT])) {
4272
+
4273
+ // ----- Generate a local information
4274
+ $v_local_header = array();
4275
+ $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4276
+
4277
+ // ----- Swap the content to header
4278
+ $v_local_header['content'] = $p_string;
4279
+ $p_string = '';
4280
+
4281
+ // ----- Call the callback
4282
+ // Here I do not use call_user_func() because I need to send a reference to the
4283
+ // header.
4284
+ $v_result = $p_options[WPVIVID_PCLZIP_CB_POST_EXTRACT](WPVIVID_PCLZIP_CB_POST_EXTRACT, $v_local_header);
4285
+
4286
+ // ----- Swap back the content to header
4287
+ $p_string = $v_local_header['content'];
4288
+ unset($v_local_header['content']);
4289
+
4290
+ // ----- Look for abort result
4291
+ if ($v_result == 2) {
4292
+ $v_result = WPVIVID_PCLZIP_ERR_USER_ABORTED;
4293
+ }
4294
+ }
4295
+
4296
+ // ----- Return
4297
+ return $v_result;
4298
+ }
4299
+ // --------------------------------------------------------------------------------
4300
+
4301
+ // --------------------------------------------------------------------------------
4302
+ // Function : privReadFileHeader()
4303
+ // Description :
4304
+ // Parameters :
4305
+ // Return Values :
4306
+ // --------------------------------------------------------------------------------
4307
+ function privReadFileHeader(&$p_header)
4308
+ {
4309
+ $v_result=1;
4310
+
4311
+ // ----- Read the 4 bytes signature
4312
+ $v_binary_data = @fread($this->zip_fd, 4);
4313
+ $v_data = unpack('Vid', $v_binary_data);
4314
+
4315
+ // ----- Check signature
4316
+ if ($v_data['id'] != 0x04034b50)
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
4327
+ $v_binary_data = fread($this->zip_fd, 26);
4328
+
4329
+ // ----- Look for invalid block size
4330
+ if (strlen($v_binary_data) != 26)
4331
+ {
4332
+ $p_header['filename'] = "";
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
4343
+ $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
4344
+
4345
+ // ----- Get filename
4346
+ $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
4347
+
4348
+ // ----- Get extra_fields
4349
+ if ($v_data['extra_len'] != 0) {
4350
+ $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
4351
+ }
4352
+ else {
4353
+ $p_header['extra'] = '';
4354
+ }
4355
+
4356
+ // ----- Extract properties
4357
+ $p_header['version_extracted'] = $v_data['version'];
4358
+ $p_header['compression'] = $v_data['compression'];
4359
+ $p_header['size'] = $v_data['size'];
4360
+ $p_header['compressed_size'] = $v_data['compressed_size'];
4361
+ $p_header['crc'] = $v_data['crc'];
4362
+ $p_header['flag'] = $v_data['flag'];
4363
+ $p_header['filename_len'] = $v_data['filename_len'];
4364
+
4365
+ // ----- Recuperate date in UNIX format
4366
+ $p_header['mdate'] = $v_data['mdate'];
4367
+ $p_header['mtime'] = $v_data['mtime'];
4368
+ if ($p_header['mdate'] && $p_header['mtime'])
4369
+ {
4370
+ // ----- Extract time
4371
+ $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4372
+ $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4373
+ $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4374
+
4375
+ // ----- Extract date
4376
+ $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4377
+ $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4378
+ $v_day = $p_header['mdate'] & 0x001F;
4379
+
4380
+ // ----- Get UNIX date format
4381
+ $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4382
+
4383
+ }
4384
+ else
4385
+ {
4386
+ $p_header['mtime'] = time();
4387
+ }
4388
+
4389
+ // TBC
4390
+ //for(reset($v_data); $key = key($v_data); next($v_data)) {
4391
+ //}
4392
+
4393
+ // ----- Set the stored filename
4394
+ $p_header['stored_filename'] = $p_header['filename'];
4395
+
4396
+ // ----- Set the status field
4397
+ $p_header['status'] = "ok";
4398
+
4399
+ // ----- Return
4400
+ return $v_result;
4401
+ }
4402
+ // --------------------------------------------------------------------------------
4403
+
4404
+ // --------------------------------------------------------------------------------
4405
+ // Function : privReadCentralFileHeader()
4406
+ // Description :
4407
+ // Parameters :
4408
+ // Return Values :
4409
+ // --------------------------------------------------------------------------------
4410
+ function privReadCentralFileHeader(&$p_header)
4411
+ {
4412
+ $v_result=1;
4413
+
4414
+ // ----- Read the 4 bytes signature
4415
+ $v_binary_data = @fread($this->zip_fd, 4);
4416
+ $v_data = unpack('Vid', $v_binary_data);
4417
+
4418
+ // ----- Check signature
4419
+ if ($v_data['id'] != 0x02014b50)
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
4430
+ $v_binary_data = fread($this->zip_fd, 42);
4431
+
4432
+ // ----- Look for invalid block size
4433
+ if (strlen($v_binary_data) != 42)
4434
+ {
4435
+ $p_header['filename'] = "";
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
4446
+ $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
4447
+
4448
+ // ----- Get filename
4449
+ if ($p_header['filename_len'] != 0)
4450
+ $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
4451
+ else
4452
+ $p_header['filename'] = '';
4453
+
4454
+ // ----- Get extra
4455
+ if ($p_header['extra_len'] != 0)
4456
+ $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
4457
+ else
4458
+ $p_header['extra'] = '';
4459
+
4460
+ // ----- Get comment
4461
+ if ($p_header['comment_len'] != 0)
4462
+ $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
4463
+ else
4464
+ $p_header['comment'] = '';
4465
+
4466
+ // ----- Extract properties
4467
+
4468
+ // ----- Recuperate date in UNIX format
4469
+ //if ($p_header['mdate'] && $p_header['mtime'])
4470
+ // TBC : bug : this was ignoring time with 0/0/0
4471
+ if (1)
4472
+ {
4473
+ // ----- Extract time
4474
+ $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4475
+ $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4476
+ $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4477
+
4478
+ // ----- Extract date
4479
+ $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4480
+ $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4481
+ $v_day = $p_header['mdate'] & 0x001F;
4482
+
4483
+ // ----- Get UNIX date format
4484
+ $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4485
+
4486
+ }
4487
+ else
4488
+ {
4489
+ $p_header['mtime'] = time();
4490
+ }
4491
+
4492
+ // ----- Set the stored filename
4493
+ $p_header['stored_filename'] = $p_header['filename'];
4494
+
4495
+ // ----- Set default status to ok
4496
+ $p_header['status'] = 'ok';
4497
+
4498
+ // ----- Look if it is a directory
4499
+ if (substr($p_header['filename'], -1) == '/') {
4500
+ //$p_header['external'] = 0x41FF0010;
4501
+ $p_header['external'] = 0x00000010;
4502
+ }
4503
+
4504
+
4505
+ // ----- Return
4506
+ return $v_result;
4507
+ }
4508
+ // --------------------------------------------------------------------------------
4509
+
4510
+ // --------------------------------------------------------------------------------
4511
+ // Function : privCheckFileHeaders()
4512
+ // Description :
4513
+ // Parameters :
4514
+ // Return Values :
4515
+ // 1 on success,
4516
+ // 0 on error;
4517
+ // --------------------------------------------------------------------------------
4518
+ function privCheckFileHeaders(&$p_local_header, &$p_central_header)
4519
+ {
4520
+ $v_result=1;
4521
+
4522
+ // ----- Check the static values
4523
+ // TBC
4524
+ if ($p_local_header['filename'] != $p_central_header['filename']) {
4525
+ }
4526
+ if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) {
4527
+ }
4528
+ if ($p_local_header['flag'] != $p_central_header['flag']) {
4529
+ }
4530
+ if ($p_local_header['compression'] != $p_central_header['compression']) {
4531
+ }
4532
+ if ($p_local_header['mtime'] != $p_central_header['mtime']) {
4533
+ }
4534
+ if ($p_local_header['filename_len'] != $p_central_header['filename_len']) {
4535
+ }
4536
+
4537
+ // ----- Look for flag bit 3
4538
+ if (($p_local_header['flag'] & 8) == 8) {
4539
+ $p_local_header['size'] = $p_central_header['size'];
4540
+ $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
4541
+ $p_local_header['crc'] = $p_central_header['crc'];
4542
+ }
4543
+
4544
+ // ----- Return
4545
+ return $v_result;
4546
+ }
4547
+ // --------------------------------------------------------------------------------
4548
+
4549
+ // --------------------------------------------------------------------------------
4550
+ // Function : privReadEndCentralDir()
4551
+ // Description :
4552
+ // Parameters :
4553
+ // Return Values :
4554
+ // --------------------------------------------------------------------------------
4555
+ function privReadEndCentralDir(&$p_central_dir)
4556
+ {
4557
+ $v_result=1;
4558
+
4559
+ // ----- Go to the end of the zip file
4560
+ $v_size = filesize($this->zipname);
4561
+ @fseek($this->zip_fd, $v_size);
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)
4572
+ // in this case the end of central dir is at 22 bytes of the file end
4573
+ $v_found = 0;
4574
+ if ($v_size > 26) {
4575
+ @fseek($this->zip_fd, $v_size-22);
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
4586
+ $v_binary_data = @fread($this->zip_fd, 4);
4587
+ $v_data = @unpack('Vid', $v_binary_data);
4588
+
4589
+ // ----- Check signature
4590
+ if ($v_data['id'] == 0x06054b50) {
4591
+ $v_found = 1;
4592
+ }
4593
+
4594
+ $v_pos = ftell($this->zip_fd);
4595
+ }
4596
+
4597
+ // ----- Go back to the maximum possible size of the Central Dir End Record
4598
+ if (!$v_found) {
4599
+ $v_maximum_size = 65557; // 0xFFFF + 22;
4600
+ if ($v_maximum_size > $v_size)
4601
+ $v_maximum_size = $v_size;
4602
+ @fseek($this->zip_fd, $v_size-$v_maximum_size);
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
4613
+ $v_pos = ftell($this->zip_fd);
4614
+ $v_bytes = 0x00000000;
4615
+ while ($v_pos < $v_size)
4616
+ {
4617
+ // ----- Read a byte
4618
+ $v_byte = @fread($this->zip_fd, 1);
4619
+
4620
+ // ----- Add the byte
4621
+ //$v_bytes = ($v_bytes << 8) | Ord($v_byte);
4622
+ // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number
4623
+ // Otherwise on systems where we have 64bit integers the check below for the magic number will fail.
4624
+ $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
4625
+
4626
+ // ----- Compare the bytes
4627
+ if ($v_bytes == 0x504b0506)
4628
+ {
4629
+ $v_pos++;
4630
+ break;
4631
+ }
4632
+
4633
+ $v_pos++;
4634
+ }
4635
+
4636
+ // ----- Look if not found end of central dir
4637
+ if ($v_pos == $v_size)
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
+
4648
+ // ----- Read the first 18 bytes of the header
4649
+ $v_binary_data = fread($this->zip_fd, 18);
4650
+
4651
+ // ----- Look for invalid block size
4652
+ if (strlen($v_binary_data) != 18)
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
4663
+ $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
4664
+
4665
+ // ----- Check the global size
4666
+ if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
4667
+
4668
+ // ----- Removed in release 2.2 see readme file
4669
+ // The check of the file size is a little too strict.
4670
+ // Some bugs where found when a zip is encrypted/decrypted with 'crypt'.
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
+
4683
+ // ----- Get comment
4684
+ if ($v_data['comment_size'] != 0) {
4685
+ $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
4686
+ }
4687
+ else
4688
+ $p_central_dir['comment'] = '';
4689
+
4690
+ $p_central_dir['entries'] = $v_data['entries'];
4691
+ $p_central_dir['disk_entries'] = $v_data['disk_entries'];
4692
+ $p_central_dir['offset'] = $v_data['offset'];
4693
+ $p_central_dir['size'] = $v_data['size'];
4694
+ $p_central_dir['disk'] = $v_data['disk'];
4695
+ $p_central_dir['disk_start'] = $v_data['disk_start'];
4696
+
4697
+ // TBC
4698
+ //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
4699
+ //}
4700
+
4701
+ // ----- Return
4702
+ return $v_result;
4703
+ }
4704
+ // --------------------------------------------------------------------------------
4705
+
4706
+ // --------------------------------------------------------------------------------
4707
+ // Function : privDeleteByRule()
4708
+ // Description :
4709
+ // Parameters :
4710
+ // Return Values :
4711
+ // --------------------------------------------------------------------------------
4712
+ function privDeleteByRule(&$p_result_list, &$p_options)
4713
+ {
4714
+ $v_result=1;
4715
+ $v_list_detail = array();
4716
+
4717
+ // ----- Open the zip file
4718
+ if (($v_result=$this->privOpenFd('rb')) != 1)
4719
+ {
4720
+ // ----- Return
4721
+ return $v_result;
4722
+ }
4723
+
4724
+ // ----- Read the central directory information
4725
+ $v_central_dir = array();
4726
+ if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
4727
+ {
4728
+ $this->privCloseFd();
4729
+ return $v_result;
4730
+ }
4731
+
4732
+ // ----- Go to beginning of File
4733
+ @rewind($this->zip_fd);
4734
+
4735
+ // ----- Scan all the files
4736
+ // ----- Start at beginning of Central Dir
4737
+ $v_pos_entry = $v_central_dir['offset'];
4738
+ @rewind($this->zip_fd);
4739
+ if (@fseek($this->zip_fd, $v_pos_entry))
4740
+ {
4741
+ // ----- Close the zip file
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
4752
+ $v_header_list = array();
4753
+ $j_start = 0;
4754
+ for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
4755
+ {
4756
+
4757
+ // ----- Read the file header
4758
+ $v_header_list[$v_nb_extracted] = array();
4759
+ if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)
4760
+ {
4761
+ // ----- Close the zip file
4762
+ $this->privCloseFd();
4763
+
4764
+ return $v_result;
4765
+ }
4766
+
4767
+
4768
+ // ----- Store the index
4769
+ $v_header_list[$v_nb_extracted]['index'] = $i;
4770
+
4771
+ // ----- Look for the specific extract rules
4772
+ $v_found = false;
4773
+
4774
+ // ----- Look for extract by name rule
4775
+ if ( (isset($p_options[WPVIVID_PCLZIP_OPT_BY_NAME]))
4776
+ && ($p_options[WPVIVID_PCLZIP_OPT_BY_NAME] != 0)) {
4777
+
4778
+ // ----- Look if the filename is in the list
4779
+ for ($j=0; ($j<sizeof($p_options[WPVIVID_PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
4780
+
4781
+ // ----- Look for a directory
4782
+ if (substr($p_options[WPVIVID_PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
4783
+
4784
+ // ----- Look if the directory is in the filename path
4785
+ if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[WPVIVID_PCLZIP_OPT_BY_NAME][$j]))
4786
+ && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[WPVIVID_PCLZIP_OPT_BY_NAME][$j])) == $p_options[WPVIVID_PCLZIP_OPT_BY_NAME][$j])) {
4787
+ $v_found = true;
4788
+ }
4789
+ elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4790
+ && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[WPVIVID_PCLZIP_OPT_BY_NAME][$j])) {
4791
+ $v_found = true;
4792
+ }
4793
+ }
4794
+ // ----- Look for a filename
4795
+ elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[WPVIVID_PCLZIP_OPT_BY_NAME][$j]) {
4796
+ $v_found = true;
4797
+ }
4798
+ }
4799
+ }
4800
+
4801
+ // ----- Look for extract by ereg rule
4802
+ // ereg() is deprecated with PHP 5.3
4803
+ /*
4804
+ else if ( (isset($p_options[WPVIVID_PCLZIP_OPT_BY_EREG]))
4805
+ && ($p_options[WPVIVID_PCLZIP_OPT_BY_EREG] != "")) {
4806
+
4807
+ if (ereg($p_options[WPVIVID_PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
4808
+ $v_found = true;
4809
+ }
4810
+ }
4811
+ */
4812
+
4813
+ // ----- Look for extract by preg rule
4814
+ else if ( (isset($p_options[WPVIVID_PCLZIP_OPT_BY_PREG]))
4815
+ && ($p_options[WPVIVID_PCLZIP_OPT_BY_PREG] != "")) {
4816
+
4817
+ if (preg_match($p_options[WPVIVID_PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
4818
+ $v_found = true;
4819
+ }
4820
+ }
4821
+
4822
+ // ----- Look for extract by index rule
4823
+ else if ( (isset($p_options[WPVIVID_PCLZIP_OPT_BY_INDEX]))
4824
+ && ($p_options[WPVIVID_PCLZIP_OPT_BY_INDEX] != 0)) {
4825
+
4826
+ // ----- Look if the index is in the list
4827
+ for ($j=$j_start; ($j<sizeof($p_options[WPVIVID_PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
4828
+
4829
+ if (($i>=$p_options[WPVIVID_PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[WPVIVID_PCLZIP_OPT_BY_INDEX][$j]['end'])) {
4830
+ $v_found = true;
4831
+ }
4832
+ if ($i>=$p_options[WPVIVID_PCLZIP_OPT_BY_INDEX][$j]['end']) {
4833
+ $j_start = $j+1;
4834
+ }
4835
+
4836
+ if ($p_options[WPVIVID_PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
4837
+ break;
4838
+ }
4839
+ }
4840
+ }
4841
+ else {
4842
+ $v_found = true;
4843
+ }
4844
+
4845
+ // ----- Look for deletion
4846
+ if ($v_found)
4847
+ {
4848
+ unset($v_header_list[$v_nb_extracted]);
4849
+ }
4850
+ else
4851
+ {
4852
+ $v_nb_extracted++;
4853
+ }
4854
+ }
4855
+
4856
+ // ----- Look if something need to be deleted
4857
+ if ($v_nb_extracted > 0) {
4858
+
4859
+ // ----- Creates a temporary file
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) {
4867
+ $this->privCloseFd();
4868
+
4869
+ // ----- Return
4870
+ return $v_result;
4871
+ }
4872
+
4873
+ // ----- Look which file need to be kept
4874
+ for ($i=0; $i<sizeof($v_header_list); $i++) {
4875
+
4876
+ // ----- Calculate the position of the header
4877
+ @rewind($this->zip_fd);
4878
+ if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) {
4879
+ // ----- Close the zip file
4880
+ $this->privCloseFd();
4881
+ $v_temp_zip->privCloseFd();
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
4892
+ $v_local_header = array();
4893
+ if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) {
4894
+ // ----- Close the zip file
4895
+ $this->privCloseFd();
4896
+ $v_temp_zip->privCloseFd();
4897
+ @unlink($v_zip_temp_name);
4898
+
4899
+ // ----- Return
4900
+ return $v_result;
4901
+ }
4902
+
4903
+ // ----- Check that local file header is same as central file header
4904
+ if ($this->privCheckFileHeaders($v_local_header,
4905
+ $v_header_list[$i]) != 1) {
4906
+ // TBC
4907
+ }
4908
+ unset($v_local_header);
4909
+
4910
+ // ----- Write the file header
4911
+ if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) {
4912
+ // ----- Close the zip file
4913
+ $this->privCloseFd();
4914
+ $v_temp_zip->privCloseFd();
4915
+ @unlink($v_zip_temp_name);
4916
+
4917
+ // ----- Return
4918
+ return $v_result;
4919
+ }
4920
+
4921
+ // ----- Read/write the data block
4922
+ if (($v_result = WPvivid_PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
4923
+ // ----- Close the zip file
4924
+ $this->privCloseFd();
4925
+ $v_temp_zip->privCloseFd();
4926
+ @unlink($v_zip_temp_name);
4927
+
4928
+ // ----- Return
4929
+ return $v_result;
4930
+ }
4931
+ }
4932
+
4933
+ // ----- Store the offset of the central dir
4934
+ $v_offset = @ftell($v_temp_zip->zip_fd);
4935
+
4936
+ // ----- Re-Create the Central Dir files header
4937
+ for ($i=0; $i<sizeof($v_header_list); $i++) {
4938
+ // ----- Create the file header
4939
+ if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
4940
+ $v_temp_zip->privCloseFd();
4941
+ $this->privCloseFd();
4942
+ @unlink($v_zip_temp_name);
4943
+
4944
+ // ----- Return
4945
+ return $v_result;
4946
+ }
4947
+
4948
+ // ----- Transform the header to a 'usable' info
4949
+ $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
4950
+ }
4951
+
4952
+
4953
+ // ----- Zip file comment
4954
+ $v_comment = '';
4955
+ if (isset($p_options[WPVIVID_PCLZIP_OPT_COMMENT])) {
4956
+ $v_comment = $p_options[WPVIVID_PCLZIP_OPT_COMMENT];
4957
+ }
4958
+
4959
+ // ----- Calculate the size of the central header
4960
+ $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
4961
+
4962
+ // ----- Create the central dir footer
4963
+ if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
4964
+ // ----- Reset the file list
4965
+ unset($v_header_list);
4966
+ $v_temp_zip->privCloseFd();
4967
+ $this->privCloseFd();
4968
+ @unlink($v_zip_temp_name);
4969
+
4970
+ // ----- Return
4971
+ return $v_result;
4972
+ }
4973
+
4974
+ // ----- Close
4975
+ $v_temp_zip->privCloseFd();
4976
+ $this->privCloseFd();
4977
+
4978
+ // ----- Delete the zip file
4979
+ // TBC : I should test the result ...
4980
+ @unlink($this->zipname);
4981
+
4982
+ // ----- Rename the temporary file
4983
+ // TBC : I should test the result ...
4984
+ //@rename($v_zip_temp_name, $this->zipname);
4985
+ WPvivid_PclZipUtilRename($v_zip_temp_name, $this->zipname);
4986
+
4987
+ // ----- Destroy the temporary archive
4988
+ unset($v_temp_zip);
4989
+ }
4990
+
4991
+ // ----- Remove every files : reset the file
4992
+ else if ($v_central_dir['entries'] != 0) {
4993
+ $this->privCloseFd();
4994
+
4995
+ if (($v_result = $this->privOpenFd('wb')) != 1) {
4996
+ return $v_result;
4997
+ }
4998
+
4999
+ if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
5000
+ return $v_result;
5001
+ }
5002
+
5003
+ $this->privCloseFd();
5004
+ }
5005
+
5006
+ // ----- Return
5007
+ return $v_result;
5008
+ }
5009
+ // --------------------------------------------------------------------------------
5010
+
5011
+ // --------------------------------------------------------------------------------
5012
+ // Function : privDirCheck()
5013
+ // Description :
5014
+ // Check if a directory exists, if not it creates it and all the parents directory
5015
+ // which may be useful.
5016
+ // Parameters :
5017
+ // $p_dir : Directory path to check.
5018
+ // Return Values :
5019
+ // 1 : OK
5020
+ // -1 : Unable to create directory
5021
+ // --------------------------------------------------------------------------------
5022
+ function privDirCheck($p_dir, $p_is_dir=false)
5023
+ {
5024
+ $v_result = 1;
5025
+
5026
+
5027
+ // ----- Remove the final '/'
5028
+ if (($p_is_dir) && (substr($p_dir, -1)=='/'))
5029
+ {
5030
+ $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
5031
+ }
5032
+
5033
+ // ----- Check the directory availability
5034
+ if ((is_dir($p_dir)) || ($p_dir == ""))
5035
+ {
5036
+ return 1;
5037
+ }
5038
+
5039
+ // ----- Extract parent directory
5040
+ $p_parent_dir = dirname($p_dir);
5041
+
5042
+ // ----- Just a check
5043
+ if ($p_parent_dir != $p_dir)
5044
+ {
5045
+ // ----- Look for parent directory
5046
+ if ($p_parent_dir != "")
5047
+ {
5048
+ if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
5049
+ {
5050
+ return $v_result;
5051
+ }
5052
+ }
5053
+ }
5054
+
5055
+ // ----- Create the directory
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
5066
+ return $v_result;
5067
+ }
5068
+ // --------------------------------------------------------------------------------
5069
+
5070
+ // --------------------------------------------------------------------------------
5071
+ // Function : privMerge()
5072
+ // Description :
5073
+ // If $p_archive_to_add does not exist, the function exit with a success result.
5074
+ // Parameters :
5075
+ // Return Values :
5076
+ // --------------------------------------------------------------------------------
5077
+ function privMerge(&$p_archive_to_add)
5078
+ {
5079
+ $v_result=1;
5080
+
5081
+ // ----- Look if the archive_to_add exists
5082
+ if (!is_file($p_archive_to_add->zipname))
5083
+ {
5084
+
5085
+ // ----- Nothing to merge, so merge is a success
5086
+ $v_result = 1;
5087
+
5088
+ // ----- Return
5089
+ return $v_result;
5090
+ }
5091
+
5092
+ // ----- Look if the archive exists
5093
+ if (!is_file($this->zipname))
5094
+ {
5095
+
5096
+ // ----- Do a duplicate
5097
+ $v_result = $this->privDuplicate($p_archive_to_add->zipname);
5098
+
5099
+ // ----- Return
5100
+ return $v_result;
5101
+ }
5102
+
5103
+ // ----- Open the zip file
5104
+ if (($v_result=$this->privOpenFd('rb')) != 1)
5105
+ {
5106
+ // ----- Return
5107
+ return $v_result;
5108
+ }
5109
+
5110
+ // ----- Read the central directory information
5111
+ $v_central_dir = array();
5112
+ if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
5113
+ {
5114
+ $this->privCloseFd();
5115
+ return $v_result;
5116
+ }
5117
+
5118
+ // ----- Go to beginning of File
5119
+ @rewind($this->zip_fd);
5120
+
5121
+ // ----- Open the archive_to_add file
5122
+ if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
5123
+ {
5124
+ $this->privCloseFd();
5125
+
5126
+ // ----- Return
5127
+ return $v_result;
5128
+ }
5129
+
5130
+ // ----- Read the central directory information
5131
+ $v_central_dir_to_add = array();
5132
+ if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)
5133
+ {
5134
+ $this->privCloseFd();
5135
+ $p_archive_to_add->privCloseFd();
5136
+
5137
+ return $v_result;
5138
+ }
5139
+
5140
+ // ----- Go to beginning of File
5141
+ @rewind($p_archive_to_add->zip_fd);
5142
+
5143
+ // ----- Creates a temporary file
5144
+ $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
5145
+
5146
+ // ----- Open the temporary file in write mode
5147
+ if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
5148
+ {
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
5159
+ // TBC : Here I should better append the file and go back to erase the central dir
5160
+ $v_size = $v_central_dir['offset'];
5161
+ while ($v_size != 0)
5162
+ {
5163
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5164
+ $v_buffer = fread($this->zip_fd, $v_read_size);
5165
+ @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5166
+ $v_size -= $v_read_size;
5167
+ }
5168
+
5169
+ // ----- Copy the files from the archive_to_add into the temporary file
5170
+ $v_size = $v_central_dir_to_add['offset'];
5171
+ while ($v_size != 0)
5172
+ {
5173
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5174
+ $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
5175
+ @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5176
+ $v_size -= $v_read_size;
5177
+ }
5178
+
5179
+ // ----- Store the offset of the central dir
5180
+ $v_offset = @ftell($v_zip_temp_fd);
5181
+
5182
+ // ----- Copy the block of file headers from the old archive
5183
+ $v_size = $v_central_dir['size'];
5184
+ while ($v_size != 0)
5185
+ {
5186
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5187
+ $v_buffer = @fread($this->zip_fd, $v_read_size);
5188
+ @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5189
+ $v_size -= $v_read_size;
5190
+ }
5191
+
5192
+ // ----- Copy the block of file headers from the archive_to_add
5193
+ $v_size = $v_central_dir_to_add['size'];
5194
+ while ($v_size != 0)
5195
+ {
5196
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5197
+ $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
5198
+ @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5199
+ $v_size -= $v_read_size;
5200
+ }
5201
+
5202
+ // ----- Merge the file comments
5203
+ $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment'];
5204
+
5205
+ // ----- Calculate the size of the (new) central header
5206
+ $v_size = @ftell($v_zip_temp_fd)-$v_offset;
5207
+
5208
+ // ----- Swap the file descriptor
5209
+ // Here is a trick : I swap the temporary fd with the zip fd, in order to use
5210
+ // the following methods on the temporary fil and not the real archive fd
5211
+ $v_swap = $this->zip_fd;
5212
+ $this->zip_fd = $v_zip_temp_fd;
5213
+ $v_zip_temp_fd = $v_swap;
5214
+
5215
+ // ----- Create the central dir footer
5216
+ if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
5217
+ {
5218
+ $this->privCloseFd();
5219
+ $p_archive_to_add->privCloseFd();
5220
+ @fclose($v_zip_temp_fd);
5221
+ $this->zip_fd = null;
5222
+
5223
+ // ----- Reset the file list
5224
+ unset($v_header_list);
5225
+
5226
+ // ----- Return
5227
+ return $v_result;
5228
+ }
5229
+
5230
+ // ----- Swap back the file descriptor
5231
+ $v_swap = $this->zip_fd;
5232
+ $this->zip_fd = $v_zip_temp_fd;
5233
+ $v_zip_temp_fd = $v_swap;
5234
+
5235
+ // ----- Close
5236
+ $this->privCloseFd();
5237
+ $p_archive_to_add->privCloseFd();
5238
+
5239
+ // ----- Close the temporary file
5240
+ @fclose($v_zip_temp_fd);
5241
+
5242
+ // ----- Delete the zip file
5243
+ // TBC : I should test the result ...
5244
+ @unlink($this->zipname);
5245
+
5246
+ // ----- Rename the temporary file
5247
+ // TBC : I should test the result ...
5248
+ //@rename($v_zip_temp_name, $this->zipname);
5249
+ WPvivid_PclZipUtilRename($v_zip_temp_name, $this->zipname);
5250
+
5251
+ // ----- Return
5252
+ return $v_result;
5253
+ }
5254
+ // --------------------------------------------------------------------------------
5255
+
5256
+ // --------------------------------------------------------------------------------
5257
+ // Function : privDuplicate()
5258
+ // Description :
5259
+ // Parameters :
5260
+ // Return Values :
5261
+ // --------------------------------------------------------------------------------
5262
+ function privDuplicate($p_archive_filename)
5263
+ {
5264
+ $v_result=1;
5265
+
5266
+ // ----- Look if the $p_archive_filename exists
5267
+ if (!is_file($p_archive_filename))
5268
+ {
5269
+
5270
+ // ----- Nothing to duplicate, so duplicate is a success.
5271
+ $v_result = 1;
5272
+
5273
+ // ----- Return
5274
+ return $v_result;
5275
+ }
5276
+
5277
+ // ----- Open the zip file
5278
+ if (($v_result=$this->privOpenFd('wb')) != 1)
5279
+ {
5280
+ // ----- Return
5281
+ return $v_result;
5282
+ }
5283
+
5284
+ // ----- Open the temporary file in write mode
5285
+ if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
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
5296
+ // TBC : Here I should better append the file and go back to erase the central dir
5297
+ $v_size = filesize($p_archive_filename);
5298
+ while ($v_size != 0)
5299
+ {
5300
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5301
+ $v_buffer = fread($v_zip_temp_fd, $v_read_size);
5302
+ @fwrite($this->zip_fd, $v_buffer, $v_read_size);
5303
+ $v_size -= $v_read_size;
5304
+ }
5305
+
5306
+ // ----- Close
5307
+ $this->privCloseFd();
5308
+
5309
+ // ----- Close the temporary file
5310
+ @fclose($v_zip_temp_fd);
5311
+
5312
+ // ----- Return
5313
+ return $v_result;
5314
+ }
5315
+ // --------------------------------------------------------------------------------
5316
+
5317
+ // --------------------------------------------------------------------------------
5318
+ // Function : privErrorLog()
5319
+ // Description :
5320
+ // Parameters :
5321
+ // --------------------------------------------------------------------------------
5322
+ function privErrorLog($p_error_code=0, $p_error_string='')
5323
+ {
5324
+ if (PCLZIP_ERROR_EXTERNAL == 1) {
5325
+ PclError($p_error_code, $p_error_string);
5326
+ }
5327
+ else {
5328
+ $this->error_code = $p_error_code;
5329
+ $this->error_string = $p_error_string;
5330
+ }
5331
+ }
5332
+ // --------------------------------------------------------------------------------
5333
+
5334
+ // --------------------------------------------------------------------------------
5335
+ // Function : privErrorReset()
5336
+ // Description :
5337
+ // Parameters :
5338
+ // --------------------------------------------------------------------------------
5339
+ function privErrorReset()
5340
+ {
5341
+ if (PCLZIP_ERROR_EXTERNAL == 1) {
5342
+ PclErrorReset();
5343
+ }
5344
+ else {
5345
+ $this->error_code = 0;
5346
+ $this->error_string = '';
5347
+ }
5348
+ }
5349
+ // --------------------------------------------------------------------------------
5350
+
5351
+ // --------------------------------------------------------------------------------
5352
+ // Function : privDisableMagicQuotes()
5353
+ // Description :
5354
+ // Parameters :
5355
+ // Return Values :
5356
+ // --------------------------------------------------------------------------------
5357
+ function privDisableMagicQuotes()
5358
+ {
5359
+ $v_result=1;
5360
+
5361
+ // EDIT for WordPress 5.3.0
5362
+ // magic_quote functions are deprecated in PHP 7.4, now assuming it's always off.
5363
+ /*
5364
+
5365
+ // ----- Look if function exists
5366
+ if ( (!function_exists("get_magic_quotes_runtime"))
5367
+ || (!function_exists("set_magic_quotes_runtime"))) {
5368
+ return $v_result;
5369
+ }
5370
+
5371
+ // ----- Look if already done
5372
+ if ($this->magic_quotes_status != -1) {
5373
+ return $v_result;
5374
+ }
5375
+
5376
+ // ----- Get and memorize the magic_quote value
5377
+ $this->magic_quotes_status = @get_magic_quotes_runtime();
5378
+
5379
+ // ----- Disable magic_quotes
5380
+ if ($this->magic_quotes_status == 1) {
5381
+ @set_magic_quotes_runtime(0);
5382
+ }
5383
+ */
5384
+
5385
+ // ----- Return
5386
+ return $v_result;
5387
+ }
5388
+ // --------------------------------------------------------------------------------
5389
+
5390
+ // --------------------------------------------------------------------------------
5391
+ // Function : privSwapBackMagicQuotes()
5392
+ // Description :
5393
+ // Parameters :
5394
+ // Return Values :
5395
+ // --------------------------------------------------------------------------------
5396
+ function privSwapBackMagicQuotes()
5397
+ {
5398
+ $v_result=1;
5399
+
5400
+ // EDIT for WordPress 5.3.0
5401
+ // magic_quote functions are deprecated in PHP 7.4, now assuming it's always off.
5402
+ /*
5403
+
5404
+ // ----- Look if function exists
5405
+ if ( (!function_exists("get_magic_quotes_runtime"))
5406
+ || (!function_exists("set_magic_quotes_runtime"))) {
5407
+ return $v_result;
5408
+ }
5409
+
5410
+ // ----- Look if something to do
5411
+ if ($this->magic_quotes_status != -1) {
5412
+ return $v_result;
5413
+ }
5414
+
5415
+ // ----- Swap back magic_quotes
5416
+ if ($this->magic_quotes_status == 1) {
5417
+ @set_magic_quotes_runtime($this->magic_quotes_status);
5418
+ }
5419
+
5420
+ */
5421
+ // ----- Return
5422
+ return $v_result;
5423
+ }
5424
+ // --------------------------------------------------------------------------------
5425
+
5426
+ }
5427
+ // End of class
5428
+ // --------------------------------------------------------------------------------
5429
+
5430
+ // --------------------------------------------------------------------------------
5431
+ // Function : WPvivid_PclZipUtilPathReduction()
5432
+ // Description :
5433
+ // Parameters :
5434
+ // Return Values :
5435
+ // --------------------------------------------------------------------------------
5436
+ function WPvivid_PclZipUtilPathReduction($p_dir)
5437
+ {
5438
+ $v_result = "";
5439
+
5440
+ // ----- Look for not empty path
5441
+ if ($p_dir != "") {
5442
+ // ----- Explode path by directory names
5443
+ $v_list = explode("/", $p_dir);
5444
+
5445
+ // ----- Study directories from last to first
5446
+ $v_skip = 0;
5447
+ for ($i=sizeof($v_list)-1; $i>=0; $i--) {
5448
+ // ----- Look for current path
5449
+ if ($v_list[$i] == ".") {
5450
+ // ----- Ignore this directory
5451
+ // Should be the first $i=0, but no check is done
5452
+ }
5453
+ else if ($v_list[$i] == "..") {
5454
+ $v_skip++;
5455
+ }
5456
+ else if ($v_list[$i] == "") {
5457
+ // ----- First '/' i.e. root slash
5458
+ if ($i == 0) {
5459
+ $v_result = "/".$v_result;
5460
+ if ($v_skip > 0) {
5461
+ // ----- It is an invalid path, so the path is not modified
5462
+ // TBC
5463
+ $v_result = $p_dir;
5464
+ $v_skip = 0;
5465
+ }
5466
+ }
5467
+ // ----- Last '/' i.e. indicates a directory
5468
+ else if ($i == (sizeof($v_list)-1)) {
5469
+ $v_result = $v_list[$i];
5470
+ }
5471
+ // ----- Double '/' inside the path
5472
+ else {
5473
+ // ----- Ignore only the double '//' in path,
5474
+ // but not the first and last '/'
5475
+ }
5476
+ }
5477
+ else {
5478
+ // ----- Look for item to skip
5479
+ if ($v_skip > 0) {
5480
+ $v_skip--;
5481
+ }
5482
+ else {
5483
+ $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
5484
+ }
5485
+ }
5486
+ }
5487
+
5488
+ // ----- Look for skip
5489
+ if ($v_skip > 0) {
5490
+ while ($v_skip > 0) {
5491
+ $v_result = '../'.$v_result;
5492
+ $v_skip--;
5493
+ }
5494
+ }
5495
+ }
5496
+
5497
+ // ----- Return
5498
+ return $v_result;
5499
+ }
5500
+ // --------------------------------------------------------------------------------
5501
+
5502
+ // --------------------------------------------------------------------------------
5503
+ // Function : WPvivid_PclZipUtilPathInclusion()
5504
+ // Description :
5505
+ // This function indicates if the path $p_path is under the $p_dir tree. Or,
5506
+ // said in an other way, if the file or sub-dir $p_path is inside the dir
5507
+ // $p_dir.
5508
+ // The function indicates also if the path is exactly the same as the dir.
5509
+ // This function supports path with duplicated '/' like '//', but does not
5510
+ // support '.' or '..' statements.
5511
+ // Parameters :
5512
+ // Return Values :
5513
+ // 0 if $p_path is not inside directory $p_dir
5514
+ // 1 if $p_path is inside directory $p_dir
5515
+ // 2 if $p_path is exactly the same as $p_dir
5516
+ // --------------------------------------------------------------------------------
5517
+ function WPvivid_PclZipUtilPathInclusion($p_dir, $p_path)
5518
+ {
5519
+ $v_result = 1;
5520
+
5521
+ // ----- Look for path beginning by ./
5522
+ if ( ($p_dir == '.')
5523
+ || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
5524
+ $p_dir = WPvivid_PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
5525
+ }
5526
+ if ( ($p_path == '.')
5527
+ || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
5528
+ $p_path = WPvivid_PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
5529
+ }
5530
+
5531
+ // ----- Explode dir and path by directory separator
5532
+ $v_list_dir = explode("/", $p_dir);
5533
+ $v_list_dir_size = sizeof($v_list_dir);
5534
+ $v_list_path = explode("/", $p_path);
5535
+ $v_list_path_size = sizeof($v_list_path);
5536
+
5537
+ // ----- Study directories paths
5538
+ $i = 0;
5539
+ $j = 0;
5540
+ while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
5541
+
5542
+ // ----- Look for empty dir (path reduction)
5543
+ if ($v_list_dir[$i] == '') {
5544
+ $i++;
5545
+ continue;
5546
+ }
5547
+ if ($v_list_path[$j] == '') {
5548
+ $j++;
5549
+ continue;
5550
+ }
5551
+
5552
+ // ----- Compare the items
5553
+ if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) {
5554
+ $v_result = 0;
5555
+ }
5556
+
5557
+ // ----- Next items
5558
+ $i++;
5559
+ $j++;
5560
+ }
5561
+
5562
+ // ----- Look if everything seems to be the same
5563
+ if ($v_result) {
5564
+ // ----- Skip all the empty items
5565
+ while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
5566
+ while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
5567
+
5568
+ if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
5569
+ // ----- There are exactly the same
5570
+ $v_result = 2;
5571
+ }
5572
+ else if ($i < $v_list_dir_size) {
5573
+ // ----- The path is shorter than the dir
5574
+ $v_result = 0;
5575
+ }
5576
+ }
5577
+
5578
+ // ----- Return
5579
+ return $v_result;
5580
+ }
5581
+ // --------------------------------------------------------------------------------
5582
+
5583
+ // --------------------------------------------------------------------------------
5584
+ // Function : WPvivid_PclZipUtilCopyBlock()
5585
+ // Description :
5586
+ // Parameters :
5587
+ // $p_mode : read/write compression mode
5588
+ // 0 : src & dest normal
5589
+ // 1 : src gzip, dest normal
5590
+ // 2 : src normal, dest gzip
5591
+ // 3 : src & dest gzip
5592
+ // Return Values :
5593
+ // --------------------------------------------------------------------------------
5594
+ function WPvivid_PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
5595
+ {
5596
+ $v_result = 1;
5597
+
5598
+ if ($p_mode==0)
5599
+ {
5600
+ while ($p_size != 0)
5601
+ {
5602
+ $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5603
+ $v_buffer = @fread($p_src, $v_read_size);
5604
+ @fwrite($p_dest, $v_buffer, $v_read_size);
5605
+ $p_size -= $v_read_size;
5606
+ }
5607
+ }
5608
+ else if ($p_mode==1)
5609
+ {
5610
+ while ($p_size != 0)
5611
+ {
5612
+ $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5613
+ $v_buffer = @gzread($p_src, $v_read_size);
5614
+ @fwrite($p_dest, $v_buffer, $v_read_size);
5615
+ $p_size -= $v_read_size;
5616
+ }
5617
+ }
5618
+ else if ($p_mode==2)
5619
+ {
5620
+ while ($p_size != 0)
5621
+ {
5622
+ $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5623
+ $v_buffer = @fread($p_src, $v_read_size);
5624
+ @gzwrite($p_dest, $v_buffer, $v_read_size);
5625
+ $p_size -= $v_read_size;
5626
+ }
5627
+ }
5628
+ else if ($p_mode==3)
5629
+ {
5630
+ while ($p_size != 0)
5631
+ {
5632
+ $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5633
+ $v_buffer = @gzread($p_src, $v_read_size);
5634
+ @gzwrite($p_dest, $v_buffer, $v_read_size);
5635
+ $p_size -= $v_read_size;
5636
+ }
5637
+ }
5638
+
5639
+ // ----- Return
5640
+ return $v_result;
5641
+ }
5642
+ // --------------------------------------------------------------------------------
5643
+
5644
+ // --------------------------------------------------------------------------------
5645
+ // Function : WPvivid_PclZipUtilRename()
5646
+ // Description :
5647
+ // This function tries to do a simple rename() function. If it fails, it
5648
+ // tries to copy the $p_src file in a new $p_dest file and then unlink the
5649
+ // first one.
5650
+ // Parameters :
5651
+ // $p_src : Old filename
5652
+ // $p_dest : New filename
5653
+ // Return Values :
5654
+ // 1 on success, 0 on failure.
5655
+ // --------------------------------------------------------------------------------
5656
+ function WPvivid_PclZipUtilRename($p_src, $p_dest)
5657
+ {
5658
+ $v_result = 1;
5659
+
5660
+ // ----- Try to rename the files
5661
+ if (!@rename($p_src, $p_dest)) {
5662
+
5663
+ // ----- Try to copy & unlink the src
5664
+ if (!@copy($p_src, $p_dest)) {
5665
+ $v_result = 0;
5666
+ }
5667
+ else if (!@unlink($p_src)) {
5668
+ $v_result = 0;
5669
+ }
5670
+ }
5671
+
5672
+ // ----- Return
5673
+ return $v_result;
5674
+ }
5675
+ // --------------------------------------------------------------------------------
5676
+
5677
+ // --------------------------------------------------------------------------------
5678
+ // Function : WPvivid_PclZipUtilOptionText()
5679
+ // Description :
5680
+ // Translate option value in text. Mainly for debug purpose.
5681
+ // Parameters :
5682
+ // $p_option : the option value.
5683
+ // Return Values :
5684
+ // The option text value.
5685
+ // --------------------------------------------------------------------------------
5686
+ function WPvivid_PclZipUtilOptionText($p_option)
5687
+ {
5688
+
5689
+ $v_list = get_defined_constants();
5690
+ for (reset($v_list); $v_key = key($v_list); next($v_list)) {
5691
+ $v_prefix = substr($v_key, 0, 10);
5692
+ if (( ($v_prefix == 'PCLZIP_OPT')
5693
+ || ($v_prefix == 'PCLZIP_CB_')
5694
+ || ($v_prefix == 'PCLZIP_ATT'))
5695
+ && ($v_list[$v_key] == $p_option)) {
5696
+ return $v_key;
5697
+ }
5698
+ }
5699
+
5700
+ $v_result = 'Unknown';
5701
+
5702
+ return $v_result;
5703
+ }
5704
+ // --------------------------------------------------------------------------------
5705
+
5706
+ // --------------------------------------------------------------------------------
5707
+ // Function : WPvivid_PclZipUtilTranslateWinPath()
5708
+ // Description :
5709
+ // Translate windows path by replacing '\' by '/' and optionally removing
5710
+ // drive letter.
5711
+ // Parameters :
5712
+ // $p_path : path to translate.
5713
+ // $p_remove_disk_letter : true | false
5714
+ // Return Values :
5715
+ // The path translated.
5716
+ // --------------------------------------------------------------------------------
5717
+ function WPvivid_PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
5718
+ {
5719
+ if (stristr(php_uname(), 'windows')) {
5720
+ // ----- Look for potential disk letter
5721
+ if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
5722
+ $p_path = substr($p_path, $v_position+1);
5723
+ }
5724
+ // ----- Change potential windows directory separator
5725
+ if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
5726
+ $p_path = strtr($p_path, '\\', '/');
5727
+ }
5728
+ }
5729
+ return $p_path;
5730
+ }
5731
+ // --------------------------------------------------------------------------------
5732
+
5733
+
5734
+ ?>
readme.txt CHANGED
@@ -4,18 +4,18 @@ Tags: move, clone, migrate, staging, backup, restore, auto backup, cloud backup
4
  Requires at least: 4.5
5
  Tested up to: 5.8
6
  Requires PHP: 5.3
7
- Stable tag: 0.9.58
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
11
- Auto migrate, move, duplicate, back up WP. Create staging sites. All-in-one backup, migration & staging plugin. Schedule, offsite backup.
12
 
13
  == Description ==
14
  WPvivid Backup Plugin offers backup, migration, and staging as basic features, and is integrating more and more elegant features, such as unused images cleaner etc.
15
 
16
  Create a staging site on a subdirectory to safely test WordPress, plugins, themes and website changes.
17
 
18
- Migrate a copy of WP site to a new host (a new domain), schedule backups, send backups to leading remote storage, clean unused images before backup and migration. All in one backup & migration plugin.
19
 
20
  == WPvivid Backup for MainWP ==
21
  [WPvivid Backup for MainWP](https://wpvivid.com/wpvivid-backup-for-mainwp) is now available to download.
@@ -60,7 +60,7 @@ WPvivid Backup Plugin has been tested by our users to migrate well on websites b
60
  = 1. Easy Backups =
61
  Easily create a backup of your WordPress site. You can choose to back up the entire site(database+files), all files, or database only.
62
  = 2. Auto Migration =
63
- Migrate your WordPress site to a new domain with a single click. WPvivid Backup Plugin supports site migration from dev environment to a new server, from dev environment to a new domain or from a live server to another.
64
 
65
  You can also migrate a site to a subdirectory, from a.com to b.com, from a.com to a.com/directory and from a.com to b.com/directory.
66
 
@@ -157,7 +157,7 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
157
 
158
  == Frequently Asked Questions ==
159
  = What does WPvivid Backup Plugin do? =
160
- As the name says, WPvivid Backup Plugin is an all in one free WP backup plugin that enables you to easily migrate a WordPress site to a new domain, to perform manual and scheduled backups of your WordPress site, to back up to cloud storage and restore backups directly from your sites admin dashboard.
161
  = Does WPvivid Backup Plugin also migrate my site? Is it a free feature? =
162
  Yes, we have added website migration feature since version 0.9.14.
163
  Yes, it's a completely free feature.
@@ -192,6 +192,10 @@ Thank you for translating WPvivid Backup Plugin to your languages!
192
  * [Nima](https://profiles.wordpress.org/nima78600/) (Persian)
193
 
194
  == Changelog ==
 
 
 
 
195
  = 0.9.58 =
196
  - Fixed a fatal error with the last update.
197
  = 0.9.57 =
4
  Requires at least: 4.5
5
  Tested up to: 5.8
6
  Requires PHP: 5.3
7
+ Stable tag: 0.9.59
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
11
+ Auto migrate, move, duplicate, clone, back up WP. Create staging sites. All-in-one backup, migration & staging plugin. Schedule, offsite backup.
12
 
13
  == Description ==
14
  WPvivid Backup Plugin offers backup, migration, and staging as basic features, and is integrating more and more elegant features, such as unused images cleaner etc.
15
 
16
  Create a staging site on a subdirectory to safely test WordPress, plugins, themes and website changes.
17
 
18
+ Clone and migrate a copy of WP site to a new host (a new domain), schedule backups, send backups to leading remote storage, clean unused images before backup and migration. All in one backup & migration plugin.
19
 
20
  == WPvivid Backup for MainWP ==
21
  [WPvivid Backup for MainWP](https://wpvivid.com/wpvivid-backup-for-mainwp) is now available to download.
60
  = 1. Easy Backups =
61
  Easily create a backup of your WordPress site. You can choose to back up the entire site(database+files), all files, or database only.
62
  = 2. Auto Migration =
63
+ Clone and migrate your WordPress site to a new domain with a single click. WPvivid Backup Plugin supports site migration from dev environment to a new server, from dev environment to a new domain or from a live server to another.
64
 
65
  You can also migrate a site to a subdirectory, from a.com to b.com, from a.com to a.com/directory and from a.com to b.com/directory.
66
 
157
 
158
  == Frequently Asked Questions ==
159
  = What does WPvivid Backup Plugin do? =
160
+ As the name says, WPvivid Backup Plugin is an all in one free WP backup plugin that enables you to easily clone and migrate a WordPress site to a new domain, to perform manual and scheduled backups of your WordPress site, to back up to cloud storage and restore backups directly from your sites admin dashboard.
161
  = Does WPvivid Backup Plugin also migrate my site? Is it a free feature? =
162
  Yes, we have added website migration feature since version 0.9.14.
163
  Yes, it's a completely free feature.
192
  * [Nima](https://profiles.wordpress.org/nima78600/) (Persian)
193
 
194
  == Changelog ==
195
+ = 0.9.59 =
196
+ - Fixed the PHP Guzzle library support compatibility issue which could cause backup failure in some cases.
197
+ - Fixed some bugs in the plugin code.
198
+ - Optimized the plugin code.
199
  = 0.9.58 =
200
  - Fixed a fatal error with the last update.
201
  = 0.9.57 =
vendor/composer/autoload_files.php CHANGED
@@ -8,20 +8,29 @@ $baseDir = dirname($vendorDir);
8
  if (PHP_VERSION_ID < 50500)
9
  {
10
  return array(
11
- '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
12
- 'decc78cc4436b1292c6c0d151b19445c' => $vendorDir . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
13
- '3919eeb97e98d4648304477f8ef734ba' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
 
 
 
14
  );
15
  }
16
  else
17
  {
18
  return array(
19
- '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
20
- 'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
21
- 'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
22
- '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
23
- 'decc78cc4436b1292c6c0d151b19445c' => $vendorDir . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
24
- '3919eeb97e98d4648304477f8ef734ba' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
 
 
 
 
 
 
25
  );
26
  }
27
 
8
  if (PHP_VERSION_ID < 50500)
9
  {
10
  return array(
11
+ //'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
12
+ //'decc78cc4436b1292c6c0d151b19445c' => $vendorDir . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
13
+ //'3919eeb97e98d4648304477f8ef734ba' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
14
+ '7b11c4dc42b3b3023073cb14e519684c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
15
+ 'decc78cc4436b1292c6c0d151b19446c' => $vendorDir . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
16
+ '3919eeb97e98d4648304477f8ef735ba' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
17
  );
18
  }
19
  else
20
  {
21
  return array(
22
+ //'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
23
+ //'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
24
+ //'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
25
+ //'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
26
+ //'decc78cc4436b1292c6c0d151b19445c' => $vendorDir . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
27
+ //'3919eeb97e98d4648304477f8ef734ba' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
28
+ '7b11c4dc42b3b3023073cb14e519684c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
29
+ 'c964ee0ededf28c96ebd9db5099ef911' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
30
+ 'a0edc8309cc5e1d60e3047b5df6b7057' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
31
+ '37a3dc5111fe8f707ab4c132ef1dbc63' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
32
+ 'decc78cc4436b1292c6c0d151b19446c' => $vendorDir . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
33
+ '3919eeb97e98d4648304477f8ef735ba' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
34
  );
35
  }
36
 
vendor/composer/autoload_psr4.php CHANGED
@@ -7,13 +7,13 @@ $baseDir = dirname($vendorDir);
7
 
8
  return array(
9
  'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'),
10
- 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
11
- 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
12
- 'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'),
13
  'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
14
- 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
15
- 'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'),
16
- 'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
17
- 'Google\\Auth\\' => array($vendorDir . '/google/auth/src'),
18
  'Firebase\\JWT\\' => array($vendorDir . '/firebase/php-jwt/src'),
19
  );
7
 
8
  return array(
9
  'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'),
10
+ 'WPvividPsr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
11
+ 'WPvividPsr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
12
+ 'WPvividPsr\\Cache\\' => array($vendorDir . '/psr/cache/src'),
13
  'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
14
+ 'WPvividGuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
15
+ 'WPvividGuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'),
16
+ 'WPvividGuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
17
+ 'WPvividGoogle\\Auth\\' => array($vendorDir . '/google/auth/src'),
18
  'Firebase\\JWT\\' => array($vendorDir . '/firebase/php-jwt/src'),
19
  );
vendor/composer/autoload_static.php CHANGED
@@ -7,12 +7,19 @@ namespace Composer\Autoload;
7
  class ComposerStaticInit381ef710b1ae857a1b0cca4550c7cd7e
8
  {
9
  public static $files = array (
10
- '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
11
- 'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
12
- 'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
13
- '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
14
- 'decc78cc4436b1292c6c0d151b19445c' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
15
- '3919eeb97e98d4648304477f8ef734ba' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
 
 
 
 
 
 
 
16
  );
17
 
18
  public static $prefixLengthsPsr4 = array (
@@ -20,22 +27,25 @@ class ComposerStaticInit381ef710b1ae857a1b0cca4550c7cd7e
20
  array (
21
  'Symfony\\Component\\EventDispatcher\\' => 34,
22
  ),
23
- 'P' =>
24
  array (
25
  'Psr\\Log\\' => 8,
26
  'Psr\\Http\\Message\\' => 17,
27
  'Psr\\Cache\\' => 10,
28
- ),
29
  'M' =>
30
  array (
31
  'Monolog\\' => 8,
32
  ),
33
- 'G' =>
34
  array (
35
- 'GuzzleHttp\\Psr7\\' => 16,
36
- 'GuzzleHttp\\Promise\\' => 19,
37
- 'GuzzleHttp\\' => 11,
38
- 'Google\\Auth\\' => 12,
 
 
 
39
  ),
40
  'F' =>
41
  array (
@@ -48,15 +58,15 @@ class ComposerStaticInit381ef710b1ae857a1b0cca4550c7cd7e
48
  array (
49
  0 => __DIR__ . '/..' . '/symfony/event-dispatcher',
50
  ),
51
- 'Psr\\Log\\' =>
52
  array (
53
  0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
54
  ),
55
- 'Psr\\Http\\Message\\' =>
56
  array (
57
  0 => __DIR__ . '/..' . '/psr/http-message/src',
58
  ),
59
- 'Psr\\Cache\\' =>
60
  array (
61
  0 => __DIR__ . '/..' . '/psr/cache/src',
62
  ),
@@ -64,19 +74,19 @@ class ComposerStaticInit381ef710b1ae857a1b0cca4550c7cd7e
64
  array (
65
  0 => __DIR__ . '/..' . '/monolog/monolog/src/Monolog',
66
  ),
67
- 'GuzzleHttp\\Psr7\\' =>
68
  array (
69
  0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src',
70
  ),
71
- 'GuzzleHttp\\Promise\\' =>
72
  array (
73
  0 => __DIR__ . '/..' . '/guzzlehttp/promises/src',
74
  ),
75
- 'GuzzleHttp\\' =>
76
  array (
77
  0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src',
78
  ),
79
- 'Google\\Auth\\' =>
80
  array (
81
  0 => __DIR__ . '/..' . '/google/auth/src',
82
  ),
7
  class ComposerStaticInit381ef710b1ae857a1b0cca4550c7cd7e
8
  {
9
  public static $files = array (
10
+ //'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
11
+ //'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
12
+ //'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
13
+ //'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
14
+ //'decc78cc4436b1292c6c0d151b19445c' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
15
+ //'3919eeb97e98d4648304477f8ef734ba' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
16
+ '7b11c4dc42b3b3023073cb14e519684c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
17
+ 'c964ee0ededf28c96ebd9db5099ef911' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
18
+ 'a0edc8309cc5e1d60e3047b5df6b7057' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
19
+ '37a3dc5111fe8f707ab4c132ef1dbc63' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
20
+ 'decc78cc4436b1292c6c0d151b19446c' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
21
+ '3919eeb97e98d4648304477f8ef735ba' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
22
+
23
  );
24
 
25
  public static $prefixLengthsPsr4 = array (
27
  array (
28
  'Symfony\\Component\\EventDispatcher\\' => 34,
29
  ),
30
+ /*'P' =>
31
  array (
32
  'Psr\\Log\\' => 8,
33
  'Psr\\Http\\Message\\' => 17,
34
  'Psr\\Cache\\' => 10,
35
+ ),*/
36
  'M' =>
37
  array (
38
  'Monolog\\' => 8,
39
  ),
40
+ 'W' =>
41
  array (
42
+ 'WPvividGuzzleHttp\\Psr7\\' => 23,
43
+ 'WPvividGuzzleHttp\\Promise\\' => 26,
44
+ 'WPvividGuzzleHttp\\' => 18,
45
+ 'WPvividGoogle\\Auth\\' => 19,
46
+ 'WPvividPsr\\Log\\' => 15,
47
+ 'WPvividPsr\\Http\\Message\\' => 24,
48
+ 'WPvividPsr\\Cache\\' => 17,
49
  ),
50
  'F' =>
51
  array (
58
  array (
59
  0 => __DIR__ . '/..' . '/symfony/event-dispatcher',
60
  ),
61
+ 'WPvividPsr\\Log\\' =>
62
  array (
63
  0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
64
  ),
65
+ 'WPvividPsr\\Http\\Message\\' =>
66
  array (
67
  0 => __DIR__ . '/..' . '/psr/http-message/src',
68
  ),
69
+ 'WPvividPsr\\Cache\\' =>
70
  array (
71
  0 => __DIR__ . '/..' . '/psr/cache/src',
72
  ),
74
  array (
75
  0 => __DIR__ . '/..' . '/monolog/monolog/src/Monolog',
76
  ),
77
+ 'WPvividGuzzleHttp\\Psr7\\' =>
78
  array (
79
  0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src',
80
  ),
81
+ 'WPvividGuzzleHttp\\Promise\\' =>
82
  array (
83
  0 => __DIR__ . '/..' . '/guzzlehttp/promises/src',
84
  ),
85
+ 'WPvividGuzzleHttp\\' =>
86
  array (
87
  0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src',
88
  ),
89
+ 'WPvividGoogle\\Auth\\' =>
90
  array (
91
  0 => __DIR__ . '/..' . '/google/auth/src',
92
  ),
vendor/composer/installed.json CHANGED
@@ -138,7 +138,7 @@
138
  "installation-source": "dist",
139
  "autoload": {
140
  "psr-4": {
141
- "Google\\Auth\\": "src"
142
  }
143
  },
144
  "notification-url": "https://packagist.org/downloads/",
@@ -304,7 +304,7 @@
304
  "src/functions_include.php"
305
  ],
306
  "psr-4": {
307
- "GuzzleHttp\\": "src/"
308
  }
309
  },
310
  "notification-url": "https://packagist.org/downloads/",
@@ -367,7 +367,7 @@
367
  "installation-source": "dist",
368
  "autoload": {
369
  "psr-4": {
370
- "GuzzleHttp\\Promise\\": "src/"
371
  },
372
  "files": [
373
  "src/functions_include.php"
@@ -431,7 +431,7 @@
431
  "installation-source": "dist",
432
  "autoload": {
433
  "psr-4": {
434
- "GuzzleHttp\\Psr7\\": "src/"
435
  },
436
  "files": [
437
  "src/functions_include.php"
@@ -691,7 +691,7 @@
691
  "installation-source": "dist",
692
  "autoload": {
693
  "psr-4": {
694
- "Psr\\Cache\\": "src/"
695
  }
696
  },
697
  "notification-url": "https://packagist.org/downloads/",
@@ -745,7 +745,7 @@
745
  "installation-source": "dist",
746
  "autoload": {
747
  "psr-4": {
748
- "Psr\\Http\\Message\\": "src/"
749
  }
750
  },
751
  "notification-url": "https://packagist.org/downloads/",
@@ -803,7 +803,7 @@
803
  "installation-source": "dist",
804
  "autoload": {
805
  "psr-4": {
806
- "Psr\\Log\\": "Psr/Log/"
807
  }
808
  },
809
  "notification-url": "https://packagist.org/downloads/",
138
  "installation-source": "dist",
139
  "autoload": {
140
  "psr-4": {
141
+ "WPvividGoogle\\Auth\\": "src"
142
  }
143
  },
144
  "notification-url": "https://packagist.org/downloads/",
304
  "src/functions_include.php"
305
  ],
306
  "psr-4": {
307
+ "WPvividGuzzleHttp\\": "src/"
308
  }
309
  },
310
  "notification-url": "https://packagist.org/downloads/",
367
  "installation-source": "dist",
368
  "autoload": {
369
  "psr-4": {
370
+ "WPvividGuzzleHttp\\Promise\\": "src/"
371
  },
372
  "files": [
373
  "src/functions_include.php"
431
  "installation-source": "dist",
432
  "autoload": {
433
  "psr-4": {
434
+ "WPvividGuzzleHttp\\Psr7\\": "src/"
435
  },
436
  "files": [
437
  "src/functions_include.php"
691
  "installation-source": "dist",
692
  "autoload": {
693
  "psr-4": {
694
+ "WPvividPsr\\Cache\\": "src/"
695
  }
696
  },
697
  "notification-url": "https://packagist.org/downloads/",
745
  "installation-source": "dist",
746
  "autoload": {
747
  "psr-4": {
748
+ "WPvividPsr\\Http\\Message\\": "src/"
749
  }
750
  },
751
  "notification-url": "https://packagist.org/downloads/",
803
  "installation-source": "dist",
804
  "autoload": {
805
  "psr-4": {
806
+ "WPvividPsr\\Log\\": "Psr/Log/"
807
  }
808
  },
809
  "notification-url": "https://packagist.org/downloads/",
vendor/google/auth/composer.json CHANGED
@@ -21,7 +21,7 @@
21
  },
22
  "autoload": {
23
  "psr-4": {
24
- "Google\\Auth\\": "src"
25
  }
26
  }
27
  }
21
  },
22
  "autoload": {
23
  "psr-4": {
24
+ "WPvividGoogle\\Auth\\": "src"
25
  }
26
  }
27
  }
vendor/google/auth/src/ApplicationDefaultCredentials.php CHANGED
@@ -15,14 +15,14 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth;
19
 
20
  use DomainException;
21
- use Google\Auth\Credentials\AppIdentityCredentials;
22
- use Google\Auth\Credentials\GCECredentials;
23
- use Google\Auth\Middleware\AuthTokenMiddleware;
24
- use Google\Auth\Subscriber\AuthTokenSubscriber;
25
- use Psr\Cache\CacheItemPoolInterface;
26
 
27
  /**
28
  * ApplicationDefaultCredentials obtains the default credentials for
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth;
19
 
20
  use DomainException;
21
+ use WPvividGoogle\Auth\Credentials\AppIdentityCredentials;
22
+ use WPvividGoogle\Auth\Credentials\GCECredentials;
23
+ use WPvividGoogle\Auth\Middleware\AuthTokenMiddleware;
24
+ use WPvividGoogle\Auth\Subscriber\AuthTokenSubscriber;
25
+ use WPvividPsr\Cache\CacheItemPoolInterface;
26
 
27
  /**
28
  * ApplicationDefaultCredentials obtains the default credentials for
vendor/google/auth/src/Cache/InvalidArgumentException.php CHANGED
@@ -15,9 +15,9 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth\Cache;
19
 
20
- use Psr\Cache\InvalidArgumentException as PsrInvalidArgumentException;
21
 
22
  class InvalidArgumentException extends \InvalidArgumentException implements PsrInvalidArgumentException
23
  {
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth\Cache;
19
 
20
+ use WPvividPsr\Cache\InvalidArgumentException as PsrInvalidArgumentException;
21
 
22
  class InvalidArgumentException extends \InvalidArgumentException implements PsrInvalidArgumentException
23
  {
vendor/google/auth/src/Cache/Item.php CHANGED
@@ -15,9 +15,9 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth\Cache;
19
 
20
- use Psr\Cache\CacheItemInterface;
21
 
22
  /**
23
  * A cache item.
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth\Cache;
19
 
20
+ use WPvividPsr\Cache\CacheItemInterface;
21
 
22
  /**
23
  * A cache item.
vendor/google/auth/src/Cache/MemoryCacheItemPool.php CHANGED
@@ -15,10 +15,10 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth\Cache;
19
 
20
- use Psr\Cache\CacheItemInterface;
21
- use Psr\Cache\CacheItemPoolInterface;
22
 
23
  /**
24
  * Simple in-memory cache implementation.
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth\Cache;
19
 
20
+ use WPvividPsr\Cache\CacheItemInterface;
21
+ use WPvividPsr\Cache\CacheItemPoolInterface;
22
 
23
  /**
24
  * Simple in-memory cache implementation.
vendor/google/auth/src/Cache/SysVCacheItemPool.php CHANGED
@@ -14,10 +14,10 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- namespace Google\Auth\Cache;
18
 
19
- use Psr\Cache\CacheItemInterface;
20
- use Psr\Cache\CacheItemPoolInterface;
21
 
22
  /**
23
  * SystemV shared memory based CacheItemPool implementation.
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+ namespace WPvividGoogle\Auth\Cache;
18
 
19
+ use WPvividPsr\Cache\CacheItemInterface;
20
+ use WPvividPsr\Cache\CacheItemPoolInterface;
21
 
22
  /**
23
  * SystemV shared memory based CacheItemPool implementation.
vendor/google/auth/src/CacheTrait.php CHANGED
@@ -15,7 +15,7 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth;
19
 
20
  trait CacheTrait
21
  {
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth;
19
 
20
  trait CacheTrait
21
  {
vendor/google/auth/src/Credentials/AppIdentityCredentials.php CHANGED
@@ -15,7 +15,7 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth\Credentials;
19
 
20
  /*
21
  * The AppIdentityService class is automatically defined on App Engine,
@@ -23,7 +23,7 @@ namespace Google\Auth\Credentials;
23
  * PHP fatal error in the App Engine environment.
24
  */
25
  use google\appengine\api\app_identity\AppIdentityService;
26
- use Google\Auth\CredentialsLoader;
27
 
28
  /**
29
  * AppIdentityCredentials supports authorization on Google App Engine.
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth\Credentials;
19
 
20
  /*
21
  * The AppIdentityService class is automatically defined on App Engine,
23
  * PHP fatal error in the App Engine environment.
24
  */
25
  use google\appengine\api\app_identity\AppIdentityService;
26
+ use WPvividGoogle\Auth\CredentialsLoader;
27
 
28
  /**
29
  * AppIdentityCredentials supports authorization on Google App Engine.
vendor/google/auth/src/Credentials/GCECredentials.php CHANGED
@@ -15,14 +15,14 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth\Credentials;
19
-
20
- use Google\Auth\CredentialsLoader;
21
- use Google\Auth\HttpHandler\HttpHandlerFactory;
22
- use GuzzleHttp\Exception\ClientException;
23
- use GuzzleHttp\Exception\RequestException;
24
- use GuzzleHttp\Exception\ServerException;
25
- use GuzzleHttp\Psr7\Request;
26
 
27
  /**
28
  * GCECredentials supports authorization on Google Compute Engine.
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth\Credentials;
19
+
20
+ use WPvividGoogle\Auth\CredentialsLoader;
21
+ use WPvividGoogle\Auth\HttpHandler\HttpHandlerFactory;
22
+ use WPvividGuzzleHttp\Exception\ClientException;
23
+ use WPvividGuzzleHttp\Exception\RequestException;
24
+ use WPvividGuzzleHttp\Exception\ServerException;
25
+ use WPvividGuzzleHttp\Psr7\Request;
26
 
27
  /**
28
  * GCECredentials supports authorization on Google Compute Engine.
vendor/google/auth/src/Credentials/IAMCredentials.php CHANGED
@@ -15,7 +15,7 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth\Credentials;
19
 
20
  /**
21
  * Authenticates requests using IAM credentials.
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth\Credentials;
19
 
20
  /**
21
  * Authenticates requests using IAM credentials.
vendor/google/auth/src/Credentials/InsecureCredentials.php CHANGED
@@ -15,9 +15,9 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth\Credentials;
19
 
20
- use Google\Auth\FetchAuthTokenInterface;
21
 
22
  /**
23
  * Provides a set of credentials that will always return an empty access token.
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth\Credentials;
19
 
20
+ use WPvividGoogle\Auth\FetchAuthTokenInterface;
21
 
22
  /**
23
  * Provides a set of credentials that will always return an empty access token.
vendor/google/auth/src/Credentials/ServiceAccountCredentials.php CHANGED
@@ -15,10 +15,10 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth\Credentials;
19
 
20
- use Google\Auth\CredentialsLoader;
21
- use Google\Auth\OAuth2;
22
 
23
  /**
24
  * ServiceAccountCredentials supports authorization using a Google service
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth\Credentials;
19
 
20
+ use WPvividGoogle\Auth\CredentialsLoader;
21
+ use WPvividGoogle\Auth\OAuth2;
22
 
23
  /**
24
  * ServiceAccountCredentials supports authorization using a Google service
vendor/google/auth/src/Credentials/ServiceAccountJwtAccessCredentials.php CHANGED
@@ -15,10 +15,10 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth\Credentials;
19
 
20
- use Google\Auth\CredentialsLoader;
21
- use Google\Auth\OAuth2;
22
 
23
  /**
24
  * Authenticates requests using Google's Service Account credentials via
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth\Credentials;
19
 
20
+ use WPvividGoogle\Auth\CredentialsLoader;
21
+ use WPvividGoogle\Auth\OAuth2;
22
 
23
  /**
24
  * Authenticates requests using Google's Service Account credentials via
vendor/google/auth/src/Credentials/UserRefreshCredentials.php CHANGED
@@ -15,10 +15,10 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth\Credentials;
19
 
20
- use Google\Auth\CredentialsLoader;
21
- use Google\Auth\OAuth2;
22
 
23
  /**
24
  * Authenticates requests using User Refresh credentials.
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth\Credentials;
19
 
20
+ use WPvividGoogle\Auth\CredentialsLoader;
21
+ use WPvividGoogle\Auth\OAuth2;
22
 
23
  /**
24
  * Authenticates requests using User Refresh credentials.
vendor/google/auth/src/CredentialsLoader.php CHANGED
@@ -15,11 +15,11 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth;
19
 
20
- use Google\Auth\Credentials\InsecureCredentials;
21
- use Google\Auth\Credentials\ServiceAccountCredentials;
22
- use Google\Auth\Credentials\UserRefreshCredentials;
23
 
24
  /**
25
  * CredentialsLoader contains the behaviour used to locate and find default
@@ -146,11 +146,11 @@ abstract class CredentialsLoader implements FetchAuthTokenInterface
146
  callable $httpHandler = null,
147
  callable $tokenCallback = null
148
  ) {
149
- $version = \GuzzleHttp\ClientInterface::VERSION;
150
 
151
  switch ($version[0]) {
152
  case '5':
153
- $client = new \GuzzleHttp\Client($httpClientOptions);
154
  $client->setDefaultOption('auth', 'google_auth');
155
  $subscriber = new Subscriber\AuthTokenSubscriber(
156
  $fetcher,
@@ -165,10 +165,10 @@ abstract class CredentialsLoader implements FetchAuthTokenInterface
165
  $httpHandler,
166
  $tokenCallback
167
  );
168
- $stack = \GuzzleHttp\HandlerStack::create();
169
  $stack->push($middleware);
170
 
171
- return new \GuzzleHttp\Client([
172
  'handler' => $stack,
173
  'auth' => 'google_auth',
174
  ] + $httpClientOptions);
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth;
19
 
20
+ use WPvividGoogle\Auth\Credentials\InsecureCredentials;
21
+ use WPvividGoogle\Auth\Credentials\ServiceAccountCredentials;
22
+ use WPvividGoogle\Auth\Credentials\UserRefreshCredentials;
23
 
24
  /**
25
  * CredentialsLoader contains the behaviour used to locate and find default
146
  callable $httpHandler = null,
147
  callable $tokenCallback = null
148
  ) {
149
+ $version = \WPvividGuzzleHttp\ClientInterface::VERSION;
150
 
151
  switch ($version[0]) {
152
  case '5':
153
+ $client = new \WPvividGuzzleHttp\Client($httpClientOptions);
154
  $client->setDefaultOption('auth', 'google_auth');
155
  $subscriber = new Subscriber\AuthTokenSubscriber(
156
  $fetcher,
165
  $httpHandler,
166
  $tokenCallback
167
  );
168
+ $stack = \WPvividGuzzleHttp\HandlerStack::create();
169
  $stack->push($middleware);
170
 
171
+ return new \WPvividGuzzleHttp\Client([
172
  'handler' => $stack,
173
  'auth' => 'google_auth',
174
  ] + $httpClientOptions);
vendor/google/auth/src/FetchAuthTokenCache.php CHANGED
@@ -15,9 +15,9 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth;
19
 
20
- use Psr\Cache\CacheItemPoolInterface;
21
 
22
  /**
23
  * A class to implement caching for any object implementing
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth;
19
 
20
+ use WPvividPsr\Cache\CacheItemPoolInterface;
21
 
22
  /**
23
  * A class to implement caching for any object implementing
vendor/google/auth/src/FetchAuthTokenInterface.php CHANGED
@@ -15,7 +15,7 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth;
19
 
20
  /**
21
  * An interface implemented by objects that can fetch auth tokens.
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth;
19
 
20
  /**
21
  * An interface implemented by objects that can fetch auth tokens.
vendor/google/auth/src/HttpHandler/Guzzle5HttpHandler.php CHANGED
@@ -14,16 +14,16 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- namespace Google\Auth\HttpHandler;
18
 
19
  use Exception;
20
- use GuzzleHttp\ClientInterface;
21
- use GuzzleHttp\Message\ResponseInterface as Guzzle5ResponseInterface;
22
- use GuzzleHttp\Promise\Promise;
23
- use GuzzleHttp\Promise\RejectedPromise;
24
- use GuzzleHttp\Psr7\Response;
25
- use Psr\Http\Message\RequestInterface;
26
- use Psr\Http\Message\ResponseInterface;
27
 
28
  class Guzzle5HttpHandler
29
  {
@@ -67,7 +67,7 @@ class Guzzle5HttpHandler
67
  */
68
  public function async(RequestInterface $request, array $options = [])
69
  {
70
- if (!class_exists('GuzzleHttp\Promise\Promise')) {
71
  throw new Exception('Install guzzlehttp/promises to use async with Guzzle 5');
72
  }
73
 
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+ namespace WPvividGoogle\Auth\HttpHandler;
18
 
19
  use Exception;
20
+ use WPvividGuzzleHttp\ClientInterface;
21
+ use WPvividGuzzleHttp\Message\ResponseInterface as Guzzle5ResponseInterface;
22
+ use WPvividGuzzleHttp\Promise\Promise;
23
+ use WPvividGuzzleHttp\Promise\RejectedPromise;
24
+ use WPvividGuzzleHttp\Psr7\Response;
25
+ use WPvividPsr\Http\Message\RequestInterface;
26
+ use WPvividPsr\Http\Message\ResponseInterface;
27
 
28
  class Guzzle5HttpHandler
29
  {
67
  */
68
  public function async(RequestInterface $request, array $options = [])
69
  {
70
+ if (!class_exists('WPvividGuzzleHttp\Promise\Promise')) {
71
  throw new Exception('Install guzzlehttp/promises to use async with Guzzle 5');
72
  }
73
 
vendor/google/auth/src/HttpHandler/Guzzle6HttpHandler.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
 
3
- namespace Google\Auth\HttpHandler;
4
 
5
- use GuzzleHttp\ClientInterface;
6
- use Psr\Http\Message\RequestInterface;
7
- use Psr\Http\Message\ResponseInterface;
8
 
9
  class Guzzle6HttpHandler
10
  {
1
  <?php
2
 
3
+ namespace WPvividGoogle\Auth\HttpHandler;
4
 
5
+ use WPvividGuzzleHttp\ClientInterface;
6
+ use WPvividPsr\Http\Message\RequestInterface;
7
+ use WPvividPsr\Http\Message\ResponseInterface;
8
 
9
  class Guzzle6HttpHandler
10
  {
vendor/google/auth/src/HttpHandler/HttpHandlerFactory.php CHANGED
@@ -14,10 +14,10 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- namespace Google\Auth\HttpHandler;
18
 
19
- use GuzzleHttp\Client;
20
- use GuzzleHttp\ClientInterface;
21
 
22
  class HttpHandlerFactory
23
  {
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+ namespace WPvividGoogle\Auth\HttpHandler;
18
 
19
+ use WPvividGuzzleHttp\Client;
20
+ use WPvividGuzzleHttp\ClientInterface;
21
 
22
  class HttpHandlerFactory
23
  {
vendor/google/auth/src/Middleware/AuthTokenMiddleware.php CHANGED
@@ -15,10 +15,10 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth\Middleware;
19
 
20
- use Google\Auth\FetchAuthTokenInterface;
21
- use Psr\Http\Message\RequestInterface;
22
 
23
  /**
24
  * AuthTokenMiddleware is a Guzzle Middleware that adds an Authorization header
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth\Middleware;
19
 
20
+ use WPvividGoogle\Auth\FetchAuthTokenInterface;
21
+ use WPvividPsr\Http\Message\RequestInterface;
22
 
23
  /**
24
  * AuthTokenMiddleware is a Guzzle Middleware that adds an Authorization header
vendor/google/auth/src/Middleware/ScopedAccessTokenMiddleware.php CHANGED
@@ -15,11 +15,11 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth\Middleware;
19
 
20
- use Google\Auth\CacheTrait;
21
- use Psr\Cache\CacheItemPoolInterface;
22
- use Psr\Http\Message\RequestInterface;
23
 
24
  /**
25
  * ScopedAccessTokenMiddleware is a Guzzle Middleware that adds an Authorization
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth\Middleware;
19
 
20
+ use WPvividGoogle\Auth\CacheTrait;
21
+ use WPvividPsr\Cache\CacheItemPoolInterface;
22
+ use WPvividPsr\Http\Message\RequestInterface;
23
 
24
  /**
25
  * ScopedAccessTokenMiddleware is a Guzzle Middleware that adds an Authorization
vendor/google/auth/src/Middleware/SimpleMiddleware.php CHANGED
@@ -15,10 +15,10 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth\Middleware;
19
 
20
- use GuzzleHttp\Psr7;
21
- use Psr\Http\Message\RequestInterface;
22
 
23
  /**
24
  * SimpleMiddleware is a Guzzle Middleware that implements Google's Simple API
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth\Middleware;
19
 
20
+ use WPvividGuzzleHttp\Psr7;
21
+ use WPvividPsr\Http\Message\RequestInterface;
22
 
23
  /**
24
  * SimpleMiddleware is a Guzzle Middleware that implements Google's Simple API
vendor/google/auth/src/OAuth2.php CHANGED
@@ -15,15 +15,15 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth;
19
 
20
- use Google\Auth\HttpHandler\HttpHandlerFactory;
21
- use GuzzleHttp\Psr7;
22
- use GuzzleHttp\Psr7\Request;
23
  use InvalidArgumentException;
24
- use Psr\Http\Message\RequestInterface;
25
- use Psr\Http\Message\ResponseInterface;
26
- use Psr\Http\Message\UriInterface;
27
 
28
  /**
29
  * OAuth2 supports authentication by OAuth2 2-legged flows.
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth;
19
 
20
+ use WPvividGoogle\Auth\HttpHandler\HttpHandlerFactory;
21
+ use WPvividGuzzleHttp\Psr7;
22
+ use WPvividGuzzleHttp\Psr7\Request;
23
  use InvalidArgumentException;
24
+ use WPvividPsr\Http\Message\RequestInterface;
25
+ use WPvividPsr\Http\Message\ResponseInterface;
26
+ use WPvividPsr\Http\Message\UriInterface;
27
 
28
  /**
29
  * OAuth2 supports authentication by OAuth2 2-legged flows.
vendor/google/auth/src/Subscriber/AuthTokenSubscriber.php CHANGED
@@ -15,12 +15,12 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth\Subscriber;
19
 
20
- use Google\Auth\FetchAuthTokenInterface;
21
- use GuzzleHttp\Event\BeforeEvent;
22
- use GuzzleHttp\Event\RequestEvents;
23
- use GuzzleHttp\Event\SubscriberInterface;
24
 
25
  /**
26
  * AuthTokenSubscriber is a Guzzle Subscriber that adds an Authorization header
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth\Subscriber;
19
 
20
+ use WPvividGoogle\Auth\FetchAuthTokenInterface;
21
+ use WPvividGuzzleHttp\Event\BeforeEvent;
22
+ use WPvividGuzzleHttp\Event\RequestEvents;
23
+ use WPvividGuzzleHttp\Event\SubscriberInterface;
24
 
25
  /**
26
  * AuthTokenSubscriber is a Guzzle Subscriber that adds an Authorization header
vendor/google/auth/src/Subscriber/ScopedAccessTokenSubscriber.php CHANGED
@@ -15,13 +15,13 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth\Subscriber;
19
 
20
- use Google\Auth\CacheTrait;
21
- use GuzzleHttp\Event\BeforeEvent;
22
- use GuzzleHttp\Event\RequestEvents;
23
- use GuzzleHttp\Event\SubscriberInterface;
24
- use Psr\Cache\CacheItemPoolInterface;
25
 
26
  /**
27
  * ScopedAccessTokenSubscriber is a Guzzle Subscriber that adds an Authorization
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth\Subscriber;
19
 
20
+ use WPvividGoogle\Auth\CacheTrait;
21
+ use WPvividGuzzleHttp\Event\BeforeEvent;
22
+ use WPvividGuzzleHttp\Event\RequestEvents;
23
+ use WPvividGuzzleHttp\Event\SubscriberInterface;
24
+ use WPvividPsr\Cache\CacheItemPoolInterface;
25
 
26
  /**
27
  * ScopedAccessTokenSubscriber is a Guzzle Subscriber that adds an Authorization
vendor/google/auth/src/Subscriber/SimpleSubscriber.php CHANGED
@@ -15,11 +15,11 @@
15
  * limitations under the License.
16
  */
17
 
18
- namespace Google\Auth\Subscriber;
19
 
20
- use GuzzleHttp\Event\BeforeEvent;
21
- use GuzzleHttp\Event\RequestEvents;
22
- use GuzzleHttp\Event\SubscriberInterface;
23
 
24
  /**
25
  * SimpleSubscriber is a Guzzle Subscriber that implements Google's Simple API
15
  * limitations under the License.
16
  */
17
 
18
+ namespace WPvividGoogle\Auth\Subscriber;
19
 
20
+ use WPvividGuzzleHttp\Event\BeforeEvent;
21
+ use WPvividGuzzleHttp\Event\RequestEvents;
22
+ use WPvividGuzzleHttp\Event\SubscriberInterface;
23
 
24
  /**
25
  * SimpleSubscriber is a Guzzle Subscriber that implements Google's Simple API
vendor/guzzle/guzzle/src/Guzzle/Log/PsrLogAdapter.php CHANGED
@@ -2,8 +2,8 @@
2
 
3
  namespace Guzzle\Log;
4
 
5
- use Psr\Log\LogLevel;
6
- use Psr\Log\LoggerInterface;
7
 
8
  /**
9
  * PSR-3 log adapter
2
 
3
  namespace Guzzle\Log;
4
 
5
+ use WPvividPsr\Log\LogLevel;
6
+ use WPvividPsr\Log\LoggerInterface;
7
 
8
  /**
9
  * PSR-3 log adapter
vendor/guzzlehttp/guzzle/composer.json CHANGED
@@ -25,12 +25,12 @@
25
  "autoload": {
26
  "files": ["src/functions_include.php"],
27
  "psr-4": {
28
- "GuzzleHttp\\": "src/"
29
  }
30
  },
31
  "autoload-dev": {
32
  "psr-4": {
33
- "GuzzleHttp\\Tests\\": "tests/"
34
  }
35
  },
36
  "suggest": {
25
  "autoload": {
26
  "files": ["src/functions_include.php"],
27
  "psr-4": {
28
+ "WPvividGuzzleHttp\\": "src/"
29
  }
30
  },
31
  "autoload-dev": {
32
  "psr-4": {
33
+ "WPvividGuzzleHttp\\Tests\\": "tests/"
34
  }
35
  },
36
  "suggest": {
vendor/guzzlehttp/guzzle/src/Client.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
- namespace GuzzleHttp;
3
 
4
- use GuzzleHttp\Cookie\CookieJar;
5
- use GuzzleHttp\Promise;
6
- use GuzzleHttp\Psr7;
7
- use Psr\Http\Message\UriInterface;
8
- use Psr\Http\Message\RequestInterface;
9
- use Psr\Http\Message\ResponseInterface;
10
 
11
  /**
12
  * @method ResponseInterface get(string|UriInterface $uri, array $options = [])
@@ -320,7 +320,7 @@ class Client implements ClientInterface
320
  }
321
 
322
  if (isset($options['json'])) {
323
- $options['body'] = \GuzzleHttp\json_encode($options['json']);
324
  unset($options['json']);
325
  // Ensure that we don't have the header in different case and set the new value.
326
  $options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']);
1
  <?php
2
+ namespace WPvividGuzzleHttp;
3
 
4
+ use WPvividGuzzleHttp\Cookie\CookieJar;
5
+ use WPvividGuzzleHttp\Promise;
6
+ use WPvividGuzzleHttp\Psr7;
7
+ use WPvividPsr\Http\Message\UriInterface;
8
+ use WPvividPsr\Http\Message\RequestInterface;
9
+ use WPvividPsr\Http\Message\ResponseInterface;
10
 
11
  /**
12
  * @method ResponseInterface get(string|UriInterface $uri, array $options = [])
320
  }
321
 
322
  if (isset($options['json'])) {
323
+ $options['body'] = \WPvividGuzzleHttp\json_encode($options['json']);
324
  unset($options['json']);
325
  // Ensure that we don't have the header in different case and set the new value.
326
  $options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']);
vendor/guzzlehttp/guzzle/src/ClientInterface.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
- namespace GuzzleHttp;
3
 
4
- use GuzzleHttp\Promise\PromiseInterface;
5
- use GuzzleHttp\Exception\GuzzleException;
6
- use Psr\Http\Message\RequestInterface;
7
- use Psr\Http\Message\ResponseInterface;
8
- use Psr\Http\Message\UriInterface;
9
 
10
  /**
11
  * Client interface for sending HTTP requests.
1
  <?php
2
+ namespace WPvividGuzzleHttp;
3
 
4
+ use WPvividGuzzleHttp\Promise\PromiseInterface;
5
+ use WPvividGuzzleHttp\Exception\GuzzleException;
6
+ use WPvividPsr\Http\Message\RequestInterface;
7
+ use WPvividPsr\Http\Message\ResponseInterface;
8
+ use WPvividPsr\Http\Message\UriInterface;
9
 
10
  /**
11
  * Client interface for sending HTTP requests.
vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
- namespace GuzzleHttp\Cookie;
3
 
4
- use Psr\Http\Message\RequestInterface;
5
- use Psr\Http\Message\ResponseInterface;
6
 
7
  /**
8
  * Cookie jar that stores cookies as an array
1
  <?php
2
+ namespace WPvividGuzzleHttp\Cookie;
3
 
4
+ use WPvividPsr\Http\Message\RequestInterface;
5
+ use WPvividPsr\Http\Message\ResponseInterface;
6
 
7
  /**
8
  * Cookie jar that stores cookies as an array
vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
- namespace GuzzleHttp\Cookie;
3
 
4
- use Psr\Http\Message\RequestInterface;
5
- use Psr\Http\Message\ResponseInterface;
6
 
7
  /**
8
  * Stores HTTP cookies.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Cookie;
3
 
4
+ use WPvividPsr\Http\Message\RequestInterface;
5
+ use WPvividPsr\Http\Message\ResponseInterface;
6
 
7
  /**
8
  * Stores HTTP cookies.
vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp\Cookie;
3
 
4
  /**
5
  * Persists non-session cookies using a JSON formatted file
@@ -55,7 +55,7 @@ class FileCookieJar extends CookieJar
55
  }
56
  }
57
 
58
- $jsonStr = \GuzzleHttp\json_encode($json);
59
  if (false === file_put_contents($filename, $jsonStr)) {
60
  throw new \RuntimeException("Unable to save file {$filename}");
61
  }
@@ -78,7 +78,7 @@ class FileCookieJar extends CookieJar
78
  return;
79
  }
80
 
81
- $data = \GuzzleHttp\json_decode($json, true);
82
  if (is_array($data)) {
83
  foreach (json_decode($json, true) as $cookie) {
84
  $this->setCookie(new SetCookie($cookie));
1
  <?php
2
+ namespace WPvividGuzzleHttp\Cookie;
3
 
4
  /**
5
  * Persists non-session cookies using a JSON formatted file
55
  }
56
  }
57
 
58
+ $jsonStr = \WPvividGuzzleHttp\json_encode($json);
59
  if (false === file_put_contents($filename, $jsonStr)) {
60
  throw new \RuntimeException("Unable to save file {$filename}");
61
  }
78
  return;
79
  }
80
 
81
+ $data = \WPvividGuzzleHttp\json_decode($json, true);
82
  if (is_array($data)) {
83
  foreach (json_decode($json, true) as $cookie) {
84
  $this->setCookie(new SetCookie($cookie));
vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp\Cookie;
3
 
4
  /**
5
  * Persists cookies in the client session
1
  <?php
2
+ namespace WPvividGuzzleHttp\Cookie;
3
 
4
  /**
5
  * Persists cookies in the client session
vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp\Cookie;
3
 
4
  /**
5
  * Set-Cookie object
1
  <?php
2
+ namespace WPvividGuzzleHttp\Cookie;
3
 
4
  /**
5
  * Set-Cookie object
vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
- namespace GuzzleHttp\Exception;
3
 
4
- use Psr\Http\Message\RequestInterface;
5
- use Psr\Http\Message\ResponseInterface;
6
 
7
  /**
8
  * Exception when an HTTP error occurs (4xx or 5xx error)
1
  <?php
2
+ namespace WPvividGuzzleHttp\Exception;
3
 
4
+ use WPvividPsr\Http\Message\RequestInterface;
5
+ use WPvividPsr\Http\Message\ResponseInterface;
6
 
7
  /**
8
  * Exception when an HTTP error occurs (4xx or 5xx error)
vendor/guzzlehttp/guzzle/src/Exception/ClientException.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp\Exception;
3
 
4
  /**
5
  * Exception when a client error is encountered (4xx codes)
1
  <?php
2
+ namespace WPvividGuzzleHttp\Exception;
3
 
4
  /**
5
  * Exception when a client error is encountered (4xx codes)
vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Exception;
3
 
4
- use Psr\Http\Message\RequestInterface;
5
 
6
  /**
7
  * Exception thrown when a connection cannot be established.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Exception;
3
 
4
+ use WPvividPsr\Http\Message\RequestInterface;
5
 
6
  /**
7
  * Exception thrown when a connection cannot be established.
vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp\Exception;
3
 
4
  /**
5
  * @method string getMessage()
1
  <?php
2
+ namespace WPvividGuzzleHttp\Exception;
3
 
4
  /**
5
  * @method string getMessage()
vendor/guzzlehttp/guzzle/src/Exception/RequestException.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
- namespace GuzzleHttp\Exception;
3
 
4
- use Psr\Http\Message\RequestInterface;
5
- use Psr\Http\Message\ResponseInterface;
6
- use GuzzleHttp\Promise\PromiseInterface;
7
- use Psr\Http\Message\UriInterface;
8
 
9
  /**
10
  * HTTP Request exception
1
  <?php
2
+ namespace WPvividGuzzleHttp\Exception;
3
 
4
+ use WPvividPsr\Http\Message\RequestInterface;
5
+ use WPvividPsr\Http\Message\ResponseInterface;
6
+ use WPvividGuzzleHttp\Promise\PromiseInterface;
7
+ use WPvividPsr\Http\Message\UriInterface;
8
 
9
  /**
10
  * HTTP Request exception
vendor/guzzlehttp/guzzle/src/Exception/SeekException.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Exception;
3
 
4
- use Psr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Exception thrown when a seek fails on a stream.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Exception;
3
 
4
+ use WPvividPsr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Exception thrown when a seek fails on a stream.
vendor/guzzlehttp/guzzle/src/Exception/ServerException.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp\Exception;
3
 
4
  /**
5
  * Exception when a server error is encountered (5xx codes)
1
  <?php
2
+ namespace WPvividGuzzleHttp\Exception;
3
 
4
  /**
5
  * Exception when a server error is encountered (5xx codes)
vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php CHANGED
@@ -1,4 +1,4 @@
1
  <?php
2
- namespace GuzzleHttp\Exception;
3
 
4
  class TooManyRedirectsException extends RequestException {}
1
  <?php
2
+ namespace WPvividGuzzleHttp\Exception;
3
 
4
  class TooManyRedirectsException extends RequestException {}
vendor/guzzlehttp/guzzle/src/Exception/TransferException.php CHANGED
@@ -1,4 +1,4 @@
1
  <?php
2
- namespace GuzzleHttp\Exception;
3
 
4
  class TransferException extends \RuntimeException implements GuzzleException {}
1
  <?php
2
+ namespace WPvividGuzzleHttp\Exception;
3
 
4
  class TransferException extends \RuntimeException implements GuzzleException {}
vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php CHANGED
@@ -1,13 +1,13 @@
1
  <?php
2
- namespace GuzzleHttp\Handler;
3
 
4
- use GuzzleHttp\Exception\RequestException;
5
- use GuzzleHttp\Exception\ConnectException;
6
- use GuzzleHttp\Promise\FulfilledPromise;
7
- use GuzzleHttp\Psr7;
8
- use GuzzleHttp\Psr7\LazyOpenStream;
9
- use GuzzleHttp\TransferStats;
10
- use Psr\Http\Message\RequestInterface;
11
 
12
  /**
13
  * Creates curl resources from a request
@@ -162,7 +162,7 @@ class CurlFactory implements CurlFactoryInterface
162
  // If an exception was encountered during the onHeaders event, then
163
  // return a rejected promise that wraps that exception.
164
  if ($easy->onHeadersException) {
165
- return \GuzzleHttp\Promise\rejection_for(
166
  new RequestException(
167
  'An error was encountered during the on_headers event',
168
  $easy->request,
@@ -185,7 +185,7 @@ class CurlFactory implements CurlFactoryInterface
185
  ? new ConnectException($message, $easy->request, null, $ctx)
186
  : new RequestException($message, $easy->request, $easy->response, null, $ctx);
187
 
188
- return \GuzzleHttp\Promise\rejection_for($error);
189
  }
190
 
191
  private function getDefaultConf(EasyHandle $easy)
@@ -364,7 +364,7 @@ class CurlFactory implements CurlFactoryInterface
364
  if (isset($options['sink'])) {
365
  $sink = $options['sink'];
366
  if (!is_string($sink)) {
367
- $sink = \GuzzleHttp\Psr7\stream_for($sink);
368
  } elseif (!is_dir(dirname($sink))) {
369
  // Ensure that the directory exists before failing in curl.
370
  throw new \RuntimeException(sprintf(
@@ -416,7 +416,7 @@ class CurlFactory implements CurlFactoryInterface
416
  if (isset($options['proxy'][$scheme])) {
417
  $host = $easy->request->getUri()->getHost();
418
  if (!isset($options['proxy']['no']) ||
419
- !\GuzzleHttp\is_host_in_noproxy($host, $options['proxy']['no'])
420
  ) {
421
  $conf[CURLOPT_PROXY] = $options['proxy'][$scheme];
422
  }
@@ -471,7 +471,7 @@ class CurlFactory implements CurlFactoryInterface
471
  }
472
 
473
  if (!empty($options['debug'])) {
474
- $conf[CURLOPT_STDERR] = \GuzzleHttp\debug_resource($options['debug']);
475
  $conf[CURLOPT_VERBOSE] = true;
476
  }
477
  }
1
  <?php
2
+ namespace WPvividGuzzleHttp\Handler;
3
 
4
+ use WPvividGuzzleHttp\Exception\RequestException;
5
+ use WPvividGuzzleHttp\Exception\ConnectException;
6
+ use WPvividGuzzleHttp\Promise\FulfilledPromise;
7
+ use WPvividGuzzleHttp\Psr7;
8
+ use WPvividGuzzleHttp\Psr7\LazyOpenStream;
9
+ use WPvividGuzzleHttp\TransferStats;
10
+ use WPvividPsr\Http\Message\RequestInterface;
11
 
12
  /**
13
  * Creates curl resources from a request
162
  // If an exception was encountered during the onHeaders event, then
163
  // return a rejected promise that wraps that exception.
164
  if ($easy->onHeadersException) {
165
+ return \WPvividGuzzleHttp\Promise\rejection_for(
166
  new RequestException(
167
  'An error was encountered during the on_headers event',
168
  $easy->request,
185
  ? new ConnectException($message, $easy->request, null, $ctx)
186
  : new RequestException($message, $easy->request, $easy->response, null, $ctx);
187
 
188
+ return \WPvividGuzzleHttp\Promise\rejection_for($error);
189
  }
190
 
191
  private function getDefaultConf(EasyHandle $easy)
364
  if (isset($options['sink'])) {
365
  $sink = $options['sink'];
366
  if (!is_string($sink)) {
367
+ $sink = \WPvividGuzzleHttp\Psr7\stream_for($sink);
368
  } elseif (!is_dir(dirname($sink))) {
369
  // Ensure that the directory exists before failing in curl.
370
  throw new \RuntimeException(sprintf(
416
  if (isset($options['proxy'][$scheme])) {
417
  $host = $easy->request->getUri()->getHost();
418
  if (!isset($options['proxy']['no']) ||
419
+ !\WPvividGuzzleHttp\is_host_in_noproxy($host, $options['proxy']['no'])
420
  ) {
421
  $conf[CURLOPT_PROXY] = $options['proxy'][$scheme];
422
  }
471
  }
472
 
473
  if (!empty($options['debug'])) {
474
+ $conf[CURLOPT_STDERR] = \WPvividGuzzleHttp\debug_resource($options['debug']);
475
  $conf[CURLOPT_VERBOSE] = true;
476
  }
477
  }
vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Handler;
3
 
4
- use Psr\Http\Message\RequestInterface;
5
 
6
  interface CurlFactoryInterface
7
  {
1
  <?php
2
+ namespace WPvividGuzzleHttp\Handler;
3
 
4
+ use WPvividPsr\Http\Message\RequestInterface;
5
 
6
  interface CurlFactoryInterface
7
  {
vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
- namespace GuzzleHttp\Handler;
3
 
4
- use GuzzleHttp\Psr7;
5
- use Psr\Http\Message\RequestInterface;
6
 
7
  /**
8
  * HTTP handler that uses cURL easy handles as a transport layer.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Handler;
3
 
4
+ use WPvividGuzzleHttp\Psr7;
5
+ use WPvividPsr\Http\Message\RequestInterface;
6
 
7
  /**
8
  * HTTP handler that uses cURL easy handles as a transport layer.
vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
- namespace GuzzleHttp\Handler;
3
 
4
- use GuzzleHttp\Promise as P;
5
- use GuzzleHttp\Promise\Promise;
6
- use GuzzleHttp\Psr7;
7
- use Psr\Http\Message\RequestInterface;
8
 
9
  /**
10
  * Returns an asynchronous response using curl_multi_* functions.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Handler;
3
 
4
+ use WPvividGuzzleHttp\Promise as P;
5
+ use WPvividGuzzleHttp\Promise\Promise;
6
+ use WPvividGuzzleHttp\Psr7;
7
+ use WPvividPsr\Http\Message\RequestInterface;
8
 
9
  /**
10
  * Returns an asynchronous response using curl_multi_* functions.
vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
- namespace GuzzleHttp\Handler;
3
 
4
- use GuzzleHttp\Psr7\Response;
5
- use Psr\Http\Message\RequestInterface;
6
- use Psr\Http\Message\ResponseInterface;
7
- use Psr\Http\Message\StreamInterface;
8
 
9
  /**
10
  * Represents a cURL easy handle and the data it populates.
@@ -50,8 +50,8 @@ final class EasyHandle
50
 
51
  // HTTP-version SP status-code SP reason-phrase
52
  $startLine = explode(' ', array_shift($this->headers), 3);
53
- $headers = \GuzzleHttp\headers_from_lines($this->headers);
54
- $normalizedKeys = \GuzzleHttp\normalize_header_keys($headers);
55
 
56
  if (!empty($this->options['decode_content'])
57
  && isset($normalizedKeys['content-encoding'])
1
  <?php
2
+ namespace WPvividGuzzleHttp\Handler;
3
 
4
+ use WPvividGuzzleHttp\Psr7\Response;
5
+ use WPvividPsr\Http\Message\RequestInterface;
6
+ use WPvividPsr\Http\Message\ResponseInterface;
7
+ use WPvividPsr\Http\Message\StreamInterface;
8
 
9
  /**
10
  * Represents a cURL easy handle and the data it populates.
50
 
51
  // HTTP-version SP status-code SP reason-phrase
52
  $startLine = explode(' ', array_shift($this->headers), 3);
53
+ $headers = \WPvividGuzzleHttp\headers_from_lines($this->headers);
54
+ $normalizedKeys = \WPvividGuzzleHttp\normalize_header_keys($headers);
55
 
56
  if (!empty($this->options['decode_content'])
57
  && isset($normalizedKeys['content-encoding'])
vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php CHANGED
@@ -1,13 +1,13 @@
1
  <?php
2
- namespace GuzzleHttp\Handler;
3
 
4
- use GuzzleHttp\Exception\RequestException;
5
- use GuzzleHttp\HandlerStack;
6
- use GuzzleHttp\Promise\PromiseInterface;
7
- use GuzzleHttp\Promise\RejectedPromise;
8
- use GuzzleHttp\TransferStats;
9
- use Psr\Http\Message\RequestInterface;
10
- use Psr\Http\Message\ResponseInterface;
11
 
12
  /**
13
  * Handler that returns responses or throw exceptions from a queue.
@@ -91,8 +91,8 @@ class MockHandler implements \Countable
91
  }
92
 
93
  $response = $response instanceof \Exception
94
- ? \GuzzleHttp\Promise\rejection_for($response)
95
- : \GuzzleHttp\Promise\promise_for($response);
96
 
97
  return $response->then(
98
  function ($value) use ($request, $options) {
@@ -108,7 +108,7 @@ class MockHandler implements \Countable
108
  fwrite($sink, $contents);
109
  } elseif (is_string($sink)) {
110
  file_put_contents($sink, $contents);
111
- } elseif ($sink instanceof \Psr\Http\Message\StreamInterface) {
112
  $sink->write($contents);
113
  }
114
  }
@@ -120,7 +120,7 @@ class MockHandler implements \Countable
120
  if ($this->onRejected) {
121
  call_user_func($this->onRejected, $reason);
122
  }
123
- return \GuzzleHttp\Promise\rejection_for($reason);
124
  }
125
  );
126
  }
@@ -140,7 +140,7 @@ class MockHandler implements \Countable
140
  $this->queue[] = $value;
141
  } else {
142
  throw new \InvalidArgumentException('Expected a response or '
143
- . 'exception. Found ' . \GuzzleHttp\describe_type($value));
144
  }
145
  }
146
  }
1
  <?php
2
+ namespace WPvividGuzzleHttp\Handler;
3
 
4
+ use WPvividGuzzleHttp\Exception\RequestException;
5
+ use WPvividGuzzleHttp\HandlerStack;
6
+ use WPvividGuzzleHttp\Promise\PromiseInterface;
7
+ use WPvividGuzzleHttp\Promise\RejectedPromise;
8
+ use WPvividGuzzleHttp\TransferStats;
9
+ use WPvividPsr\Http\Message\RequestInterface;
10
+ use WPvividPsr\Http\Message\ResponseInterface;
11
 
12
  /**
13
  * Handler that returns responses or throw exceptions from a queue.
91
  }
92
 
93
  $response = $response instanceof \Exception
94
+ ? \WPvividGuzzleHttp\Promise\rejection_for($response)
95
+ : \WPvividGuzzleHttp\Promise\promise_for($response);
96
 
97
  return $response->then(
98
  function ($value) use ($request, $options) {
108
  fwrite($sink, $contents);
109
  } elseif (is_string($sink)) {
110
  file_put_contents($sink, $contents);
111
+ } elseif ($sink instanceof \WPvividPsr\Http\Message\StreamInterface) {
112
  $sink->write($contents);
113
  }
114
  }
120
  if ($this->onRejected) {
121
  call_user_func($this->onRejected, $reason);
122
  }
123
+ return \WPvividGuzzleHttp\Promise\rejection_for($reason);
124
  }
125
  );
126
  }
140
  $this->queue[] = $value;
141
  } else {
142
  throw new \InvalidArgumentException('Expected a response or '
143
+ . 'exception. Found ' . \WPvividGuzzleHttp\describe_type($value));
144
  }
145
  }
146
  }
vendor/guzzlehttp/guzzle/src/Handler/Proxy.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
- namespace GuzzleHttp\Handler;
3
 
4
- use GuzzleHttp\RequestOptions;
5
- use Psr\Http\Message\RequestInterface;
6
 
7
  /**
8
  * Provides basic proxies for handlers.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Handler;
3
 
4
+ use WPvividGuzzleHttp\RequestOptions;
5
+ use WPvividPsr\Http\Message\RequestInterface;
6
 
7
  /**
8
  * Provides basic proxies for handlers.
vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php CHANGED
@@ -1,15 +1,15 @@
1
  <?php
2
- namespace GuzzleHttp\Handler;
3
-
4
- use GuzzleHttp\Exception\RequestException;
5
- use GuzzleHttp\Exception\ConnectException;
6
- use GuzzleHttp\Promise\FulfilledPromise;
7
- use GuzzleHttp\Promise\PromiseInterface;
8
- use GuzzleHttp\Psr7;
9
- use GuzzleHttp\TransferStats;
10
- use Psr\Http\Message\RequestInterface;
11
- use Psr\Http\Message\ResponseInterface;
12
- use Psr\Http\Message\StreamInterface;
13
 
14
  /**
15
  * HTTP handler that uses PHP's HTTP stream wrapper.
@@ -67,7 +67,7 @@ class StreamHandler
67
  $e = RequestException::wrapException($request, $e);
68
  $this->invokeStats($options, $request, $startTime, null, $e);
69
 
70
- return \GuzzleHttp\Promise\rejection_for($e);
71
  }
72
  }
73
 
@@ -102,7 +102,7 @@ class StreamHandler
102
  $ver = explode('/', $parts[0])[1];
103
  $status = $parts[1];
104
  $reason = isset($parts[2]) ? $parts[2] : null;
105
- $headers = \GuzzleHttp\headers_from_lines($hdrs);
106
  list($stream, $headers) = $this->checkDecode($options, $headers, $stream);
107
  $stream = Psr7\stream_for($stream);
108
  $sink = $stream;
@@ -119,7 +119,7 @@ class StreamHandler
119
  } catch (\Exception $e) {
120
  $msg = 'An error was encountered during the on_headers event';
121
  $ex = new RequestException($msg, $request, $response, $e);
122
- return \GuzzleHttp\Promise\rejection_for($ex);
123
  }
124
  }
125
 
@@ -157,7 +157,7 @@ class StreamHandler
157
  {
158
  // Automatically decode responses when instructed.
159
  if (!empty($options['decode_content'])) {
160
- $normalizedKeys = \GuzzleHttp\normalize_header_keys($headers);
161
  if (isset($normalizedKeys['content-encoding'])) {
162
  $encoding = $headers[$normalizedKeys['content-encoding']];
163
  if ($encoding[0] === 'gzip' || $encoding[0] === 'deflate') {
@@ -400,7 +400,7 @@ class StreamHandler
400
  $scheme = $request->getUri()->getScheme();
401
  if (isset($value[$scheme])) {
402
  if (!isset($value['no'])
403
- || !\GuzzleHttp\is_host_in_noproxy(
404
  $request->getUri()->getHost(),
405
  $value['no']
406
  )
@@ -424,7 +424,7 @@ class StreamHandler
424
  // PHP 5.6 or greater will find the system cert by default. When
425
  // < 5.6, use the Guzzle bundled cacert.
426
  if (PHP_VERSION_ID < 50600) {
427
- $options['ssl']['cafile'] = \GuzzleHttp\default_ca_bundle();
428
  }
429
  } elseif (is_string($value)) {
430
  $options['ssl']['cafile'] = $value;
@@ -491,7 +491,7 @@ class StreamHandler
491
  static $args = ['severity', 'message', 'message_code',
492
  'bytes_transferred', 'bytes_max'];
493
 
494
- $value = \GuzzleHttp\debug_resource($value);
495
  $ident = $request->getMethod() . ' ' . $request->getUri()->withFragment('');
496
  $this->addNotification(
497
  $params,
1
  <?php
2
+ namespace WPvividGuzzleHttp\Handler;
3
+
4
+ use WPvividGuzzleHttp\Exception\RequestException;
5
+ use WPvividGuzzleHttp\Exception\ConnectException;
6
+ use WPvividGuzzleHttp\Promise\FulfilledPromise;
7
+ use WPvividGuzzleHttp\Promise\PromiseInterface;
8
+ use WPvividGuzzleHttp\Psr7;
9
+ use WPvividGuzzleHttp\TransferStats;
10
+ use WPvividPsr\Http\Message\RequestInterface;
11
+ use WPvividPsr\Http\Message\ResponseInterface;
12
+ use WPvividPsr\Http\Message\StreamInterface;
13
 
14
  /**
15
  * HTTP handler that uses PHP's HTTP stream wrapper.
67
  $e = RequestException::wrapException($request, $e);
68
  $this->invokeStats($options, $request, $startTime, null, $e);
69
 
70
+ return \WPvividGuzzleHttp\Promise\rejection_for($e);
71
  }
72
  }
73
 
102
  $ver = explode('/', $parts[0])[1];
103
  $status = $parts[1];
104
  $reason = isset($parts[2]) ? $parts[2] : null;
105
+ $headers = \WPvividGuzzleHttp\headers_from_lines($hdrs);
106
  list($stream, $headers) = $this->checkDecode($options, $headers, $stream);
107
  $stream = Psr7\stream_for($stream);
108
  $sink = $stream;
119
  } catch (\Exception $e) {
120
  $msg = 'An error was encountered during the on_headers event';
121
  $ex = new RequestException($msg, $request, $response, $e);
122
+ return \WPvividGuzzleHttp\Promise\rejection_for($ex);
123
  }
124
  }
125
 
157
  {
158
  // Automatically decode responses when instructed.
159
  if (!empty($options['decode_content'])) {
160
+ $normalizedKeys = \WPvividGuzzleHttp\normalize_header_keys($headers);
161
  if (isset($normalizedKeys['content-encoding'])) {
162
  $encoding = $headers[$normalizedKeys['content-encoding']];
163
  if ($encoding[0] === 'gzip' || $encoding[0] === 'deflate') {
400
  $scheme = $request->getUri()->getScheme();
401
  if (isset($value[$scheme])) {
402
  if (!isset($value['no'])
403
+ || !\WPvividGuzzleHttp\is_host_in_noproxy(
404
  $request->getUri()->getHost(),
405
  $value['no']
406
  )
424
  // PHP 5.6 or greater will find the system cert by default. When
425
  // < 5.6, use the Guzzle bundled cacert.
426
  if (PHP_VERSION_ID < 50600) {
427
+ $options['ssl']['cafile'] = \WPvividGuzzleHttp\default_ca_bundle();
428
  }
429
  } elseif (is_string($value)) {
430
  $options['ssl']['cafile'] = $value;
491
  static $args = ['severity', 'message', 'message_code',
492
  'bytes_transferred', 'bytes_max'];
493
 
494
+ $value = \WPvividGuzzleHttp\debug_resource($value);
495
  $ident = $request->getMethod() . ' ' . $request->getUri()->withFragment('');
496
  $this->addNotification(
497
  $params,
vendor/guzzlehttp/guzzle/src/HandlerStack.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp;
3
 
4
- use Psr\Http\Message\RequestInterface;
5
 
6
  /**
7
  * Creates a composed Guzzle handler function by stacking middlewares on top of
1
  <?php
2
+ namespace WPvividGuzzleHttp;
3
 
4
+ use WPvividPsr\Http\Message\RequestInterface;
5
 
6
  /**
7
  * Creates a composed Guzzle handler function by stacking middlewares on top of
vendor/guzzlehttp/guzzle/src/MessageFormatter.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
- namespace GuzzleHttp;
3
 
4
- use Psr\Http\Message\MessageInterface;
5
- use Psr\Http\Message\RequestInterface;
6
- use Psr\Http\Message\ResponseInterface;
7
 
8
  /**
9
  * Formats log messages using variable substitutions for requests, responses,
1
  <?php
2
+ namespace WPvividGuzzleHttp;
3
 
4
+ use WPvividPsr\Http\Message\MessageInterface;
5
+ use WPvividPsr\Http\Message\RequestInterface;
6
+ use WPvividPsr\Http\Message\ResponseInterface;
7
 
8
  /**
9
  * Formats log messages using variable substitutions for requests, responses,
vendor/guzzlehttp/guzzle/src/Middleware.php CHANGED
@@ -1,13 +1,13 @@
1
  <?php
2
- namespace GuzzleHttp;
3
 
4
- use GuzzleHttp\Cookie\CookieJarInterface;
5
- use GuzzleHttp\Exception\RequestException;
6
- use GuzzleHttp\Promise\RejectedPromise;
7
- use GuzzleHttp\Psr7;
8
- use Psr\Http\Message\ResponseInterface;
9
- use Psr\Log\LoggerInterface;
10
- use Psr\Log\LogLevel;
11
 
12
  /**
13
  * Functions used to create and wrap handlers with handler middleware.
@@ -29,7 +29,7 @@ final class Middleware
29
  if (empty($options['cookies'])) {
30
  return $handler($request, $options);
31
  } elseif (!($options['cookies'] instanceof CookieJarInterface)) {
32
- throw new \InvalidArgumentException('cookies must be an instance of GuzzleHttp\Cookie\CookieJarInterface');
33
  }
34
  $cookieJar = $options['cookies'];
35
  $request = $cookieJar->withCookieHeader($request);
@@ -103,7 +103,7 @@ final class Middleware
103
  'error' => $reason,
104
  'options' => $options
105
  ];
106
- return \GuzzleHttp\Promise\rejection_for($reason);
107
  }
108
  );
109
  };
@@ -199,7 +199,7 @@ final class Middleware
199
  : null;
200
  $message = $formatter->format($request, $response, $reason);
201
  $logger->notice($message);
202
- return \GuzzleHttp\Promise\rejection_for($reason);
203
  }
204
  );
205
  };
1
  <?php
2
+ namespace WPvividGuzzleHttp;
3
 
4
+ use WPvividGuzzleHttp\Cookie\CookieJarInterface;
5
+ use WPvividGuzzleHttp\Exception\RequestException;
6
+ use WPvividGuzzleHttp\Promise\RejectedPromise;
7
+ use WPvividGuzzleHttp\Psr7;
8
+ use WPvividPsr\Http\Message\ResponseInterface;
9
+ use WPvividPsr\Log\LoggerInterface;
10
+ use WPvividPsr\Log\LogLevel;
11
 
12
  /**
13
  * Functions used to create and wrap handlers with handler middleware.
29
  if (empty($options['cookies'])) {
30
  return $handler($request, $options);
31
  } elseif (!($options['cookies'] instanceof CookieJarInterface)) {
32
+ throw new \InvalidArgumentException('cookies must be an instance of WPvividGuzzleHttp\Cookie\CookieJarInterface');
33
  }
34
  $cookieJar = $options['cookies'];
35
  $request = $cookieJar->withCookieHeader($request);
103
  'error' => $reason,
104
  'options' => $options
105
  ];
106
+ return \WPvividGuzzleHttp\Promise\rejection_for($reason);
107
  }
108
  );
109
  };
199
  : null;
200
  $message = $formatter->format($request, $response, $reason);
201
  $logger->notice($message);
202
+ return \WPvividGuzzleHttp\Promise\rejection_for($reason);
203
  }
204
  );
205
  };
vendor/guzzlehttp/guzzle/src/Pool.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
- namespace GuzzleHttp;
3
 
4
- use GuzzleHttp\Promise\PromisorInterface;
5
- use Psr\Http\Message\RequestInterface;
6
- use GuzzleHttp\Promise\EachPromise;
7
 
8
  /**
9
  * Sends and iterator of requests concurrently using a capped pool size.
@@ -50,7 +50,7 @@ class Pool implements PromisorInterface
50
  $opts = [];
51
  }
52
 
53
- $iterable = \GuzzleHttp\Promise\iter_for($requests);
54
  $requests = function () use ($iterable, $client, $opts) {
55
  foreach ($iterable as $key => $rfn) {
56
  if ($rfn instanceof RequestInterface) {
1
  <?php
2
+ namespace WPvividGuzzleHttp;
3
 
4
+ use WPvividGuzzleHttp\Promise\PromisorInterface;
5
+ use WPvividPsr\Http\Message\RequestInterface;
6
+ use WPvividGuzzleHttp\Promise\EachPromise;
7
 
8
  /**
9
  * Sends and iterator of requests concurrently using a capped pool size.
50
  $opts = [];
51
  }
52
 
53
+ $iterable = \WPvividGuzzleHttp\Promise\iter_for($requests);
54
  $requests = function () use ($iterable, $client, $opts) {
55
  foreach ($iterable as $key => $rfn) {
56
  if ($rfn instanceof RequestInterface) {
vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
- namespace GuzzleHttp;
3
 
4
- use GuzzleHttp\Promise\PromiseInterface;
5
- use GuzzleHttp\Psr7;
6
- use Psr\Http\Message\RequestInterface;
7
 
8
  /**
9
  * Prepares requests that contain a body, adding the Content-Length,
1
  <?php
2
+ namespace WPvividGuzzleHttp;
3
 
4
+ use WPvividGuzzleHttp\Promise\PromiseInterface;
5
+ use WPvividGuzzleHttp\Psr7;
6
+ use WPvividPsr\Http\Message\RequestInterface;
7
 
8
  /**
9
  * Prepares requests that contain a body, adding the Content-Length,
vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php CHANGED
@@ -1,13 +1,13 @@
1
  <?php
2
- namespace GuzzleHttp;
3
-
4
- use GuzzleHttp\Exception\BadResponseException;
5
- use GuzzleHttp\Exception\TooManyRedirectsException;
6
- use GuzzleHttp\Promise\PromiseInterface;
7
- use GuzzleHttp\Psr7;
8
- use Psr\Http\Message\RequestInterface;
9
- use Psr\Http\Message\ResponseInterface;
10
- use Psr\Http\Message\UriInterface;
11
 
12
  /**
13
  * Request redirect middleware.
1
  <?php
2
+ namespace WPvividGuzzleHttp;
3
+
4
+ use WPvividGuzzleHttp\Exception\BadResponseException;
5
+ use WPvividGuzzleHttp\Exception\TooManyRedirectsException;
6
+ use WPvividGuzzleHttp\Promise\PromiseInterface;
7
+ use WPvividGuzzleHttp\Psr7;
8
+ use WPvividPsr\Http\Message\RequestInterface;
9
+ use WPvividPsr\Http\Message\ResponseInterface;
10
+ use WPvividPsr\Http\Message\UriInterface;
11
 
12
  /**
13
  * Request redirect middleware.
vendor/guzzlehttp/guzzle/src/RequestOptions.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp;
3
 
4
  /**
5
  * This class contains a list of built-in Guzzle request options.
1
  <?php
2
+ namespace WPvividGuzzleHttp;
3
 
4
  /**
5
  * This class contains a list of built-in Guzzle request options.
vendor/guzzlehttp/guzzle/src/RetryMiddleware.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
- namespace GuzzleHttp;
3
 
4
- use GuzzleHttp\Promise\PromiseInterface;
5
- use GuzzleHttp\Promise\RejectedPromise;
6
- use GuzzleHttp\Psr7;
7
- use Psr\Http\Message\RequestInterface;
8
- use Psr\Http\Message\ResponseInterface;
9
 
10
  /**
11
  * Middleware that retries requests based on the boolean result of
@@ -97,7 +97,7 @@ class RetryMiddleware
97
  null,
98
  $reason
99
  )) {
100
- return \GuzzleHttp\Promise\rejection_for($reason);
101
  }
102
  return $this->doRetry($req, $options);
103
  };
1
  <?php
2
+ namespace WPvividGuzzleHttp;
3
 
4
+ use WPvividGuzzleHttp\Promise\PromiseInterface;
5
+ use WPvividGuzzleHttp\Promise\RejectedPromise;
6
+ use WPvividGuzzleHttp\Psr7;
7
+ use WPvividPsr\Http\Message\RequestInterface;
8
+ use WPvividPsr\Http\Message\ResponseInterface;
9
 
10
  /**
11
  * Middleware that retries requests based on the boolean result of
97
  null,
98
  $reason
99
  )) {
100
+ return \WPvividGuzzleHttp\Promise\rejection_for($reason);
101
  }
102
  return $this->doRetry($req, $options);
103
  };
vendor/guzzlehttp/guzzle/src/TransferStats.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
- namespace GuzzleHttp;
3
 
4
- use Psr\Http\Message\RequestInterface;
5
- use Psr\Http\Message\ResponseInterface;
6
- use Psr\Http\Message\UriInterface;
7
 
8
  /**
9
  * Represents data at the point after it was transferred either successfully
1
  <?php
2
+ namespace WPvividGuzzleHttp;
3
 
4
+ use WPvividPsr\Http\Message\RequestInterface;
5
+ use WPvividPsr\Http\Message\ResponseInterface;
6
+ use WPvividPsr\Http\Message\UriInterface;
7
 
8
  /**
9
  * Represents data at the point after it was transferred either successfully
vendor/guzzlehttp/guzzle/src/UriTemplate.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp;
3
 
4
  /**
5
  * Expands URI templates. Userland implementation of PECL uri_template.
1
  <?php
2
+ namespace WPvividGuzzleHttp;
3
 
4
  /**
5
  * Expands URI templates. Userland implementation of PECL uri_template.
vendor/guzzlehttp/guzzle/src/functions.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
- namespace GuzzleHttp;
3
 
4
- use GuzzleHttp\Handler\CurlHandler;
5
- use GuzzleHttp\Handler\CurlMultiHandler;
6
- use GuzzleHttp\Handler\Proxy;
7
- use GuzzleHttp\Handler\StreamHandler;
8
 
9
  /**
10
  * Expands a URI template
@@ -116,7 +116,7 @@ function choose_handler()
116
  ? Proxy::wrapStreaming($handler, new StreamHandler())
117
  : new StreamHandler();
118
  } elseif (!$handler) {
119
- throw new \RuntimeException('GuzzleHttp requires cURL, the '
120
  . 'allow_url_fopen ini setting, or a custom HTTP handler.');
121
  }
122
 
@@ -133,7 +133,7 @@ function default_user_agent()
133
  static $defaultAgent = '';
134
 
135
  if (!$defaultAgent) {
136
- $defaultAgent = 'GuzzleHttp/' . Client::VERSION;
137
  if (extension_loaded('curl') && function_exists('curl_version')) {
138
  $defaultAgent .= ' curl/' . \curl_version()['version'];
139
  }
1
  <?php
2
+ namespace WPvividGuzzleHttp;
3
 
4
+ use WPvividGuzzleHttp\Handler\CurlHandler;
5
+ use WPvividGuzzleHttp\Handler\CurlMultiHandler;
6
+ use WPvividGuzzleHttp\Handler\Proxy;
7
+ use WPvividGuzzleHttp\Handler\StreamHandler;
8
 
9
  /**
10
  * Expands a URI template
116
  ? Proxy::wrapStreaming($handler, new StreamHandler())
117
  : new StreamHandler();
118
  } elseif (!$handler) {
119
+ throw new \RuntimeException('WPvividGuzzleHttp requires cURL, the '
120
  . 'allow_url_fopen ini setting, or a custom HTTP handler.');
121
  }
122
 
133
  static $defaultAgent = '';
134
 
135
  if (!$defaultAgent) {
136
+ $defaultAgent = 'WPvividGuzzleHttp/' . Client::VERSION;
137
  if (extension_loaded('curl') && function_exists('curl_version')) {
138
  $defaultAgent .= ' curl/' . \curl_version()['version'];
139
  }
vendor/guzzlehttp/guzzle/src/functions_include.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
  // Don't redefine the functions if included multiple times.
4
- if (!function_exists('GuzzleHttp\uri_template')) {
5
  require __DIR__ . '/functions.php';
6
  }
1
  <?php
2
 
3
  // Don't redefine the functions if included multiple times.
4
+ if (!function_exists('WPvividGuzzleHttp\uri_template')) {
5
  require __DIR__ . '/functions.php';
6
  }
vendor/guzzlehttp/promises/composer.json CHANGED
@@ -18,7 +18,7 @@
18
  },
19
  "autoload": {
20
  "psr-4": {
21
- "GuzzleHttp\\Promise\\": "src/"
22
  },
23
  "files": ["src/functions_include.php"]
24
  },
18
  },
19
  "autoload": {
20
  "psr-4": {
21
+ "WPvividGuzzleHttp\\Promise\\": "src/"
22
  },
23
  "files": ["src/functions_include.php"]
24
  },
vendor/guzzlehttp/promises/src/AggregateException.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp\Promise;
3
 
4
  /**
5
  * Exception thrown when too many errors occur in the some() or any() methods.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Promise;
3
 
4
  /**
5
  * Exception thrown when too many errors occur in the some() or any() methods.
vendor/guzzlehttp/promises/src/CancellationException.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp\Promise;
3
 
4
  /**
5
  * Exception that is set as the reason for a promise that has been cancelled.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Promise;
3
 
4
  /**
5
  * Exception that is set as the reason for a promise that has been cancelled.
vendor/guzzlehttp/promises/src/Coroutine.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp\Promise;
3
 
4
  use Exception;
5
  use Generator;
1
  <?php
2
+ namespace WPvividGuzzleHttp\Promise;
3
 
4
  use Exception;
5
  use Generator;
vendor/guzzlehttp/promises/src/EachPromise.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp\Promise;
3
 
4
  /**
5
  * Represents a promise that iterates over many promises and invokes
1
  <?php
2
+ namespace WPvividGuzzleHttp\Promise;
3
 
4
  /**
5
  * Represents a promise that iterates over many promises and invokes
vendor/guzzlehttp/promises/src/FulfilledPromise.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp\Promise;
3
 
4
  /**
5
  * A promise that has been fulfilled.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Promise;
3
 
4
  /**
5
  * A promise that has been fulfilled.
vendor/guzzlehttp/promises/src/Promise.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp\Promise;
3
 
4
  /**
5
  * Promises/A+ implementation that avoids recursion when possible.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Promise;
3
 
4
  /**
5
  * Promises/A+ implementation that avoids recursion when possible.
vendor/guzzlehttp/promises/src/PromiseInterface.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp\Promise;
3
 
4
  /**
5
  * A promise represents the eventual result of an asynchronous operation.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Promise;
3
 
4
  /**
5
  * A promise represents the eventual result of an asynchronous operation.
vendor/guzzlehttp/promises/src/PromisorInterface.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp\Promise;
3
 
4
  /**
5
  * Interface used with classes that return a promise.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Promise;
3
 
4
  /**
5
  * Interface used with classes that return a promise.
vendor/guzzlehttp/promises/src/RejectedPromise.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp\Promise;
3
 
4
  /**
5
  * A promise that has been rejected.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Promise;
3
 
4
  /**
5
  * A promise that has been rejected.
vendor/guzzlehttp/promises/src/RejectionException.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp\Promise;
3
 
4
  /**
5
  * A special exception that is thrown when waiting on a rejected promise.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Promise;
3
 
4
  /**
5
  * A special exception that is thrown when waiting on a rejected promise.
vendor/guzzlehttp/promises/src/TaskQueue.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp\Promise;
3
 
4
  /**
5
  * A task queue that executes tasks in a FIFO order.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Promise;
3
 
4
  /**
5
  * A task queue that executes tasks in a FIFO order.
vendor/guzzlehttp/promises/src/TaskQueueInterface.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp\Promise;
3
 
4
  interface TaskQueueInterface
5
  {
1
  <?php
2
+ namespace WPvividGuzzleHttp\Promise;
3
 
4
  interface TaskQueueInterface
5
  {
vendor/guzzlehttp/promises/src/functions.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace GuzzleHttp\Promise;
3
 
4
  /**
5
  * Get the global task queue used for promise resolution.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Promise;
3
 
4
  /**
5
  * Get the global task queue used for promise resolution.
vendor/guzzlehttp/promises/src/functions_include.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
  // Don't redefine the functions if included multiple times.
4
- if (!function_exists('GuzzleHttp\Promise\promise_for')) {
5
  require __DIR__ . '/functions.php';
6
  }
1
  <?php
2
 
3
  // Don't redefine the functions if included multiple times.
4
+ if (!function_exists('WPvividGuzzleHttp\Promise\promise_for')) {
5
  require __DIR__ . '/functions.php';
6
  }
vendor/guzzlehttp/psr7/composer.json CHANGED
@@ -28,13 +28,13 @@
28
  },
29
  "autoload": {
30
  "psr-4": {
31
- "GuzzleHttp\\Psr7\\": "src/"
32
  },
33
  "files": ["src/functions_include.php"]
34
  },
35
  "autoload-dev": {
36
  "psr-4": {
37
- "GuzzleHttp\\Tests\\Psr7\\": "tests/"
38
  }
39
  },
40
  "extra": {
28
  },
29
  "autoload": {
30
  "psr-4": {
31
+ "WPvividGuzzleHttp\\Psr7\\": "src/"
32
  },
33
  "files": ["src/functions_include.php"]
34
  },
35
  "autoload-dev": {
36
  "psr-4": {
37
+ "WPvividGuzzleHttp\\Tests\\Psr7\\": "tests/"
38
  }
39
  },
40
  "extra": {
vendor/guzzlehttp/psr7/src/AppendStream.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
- use Psr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Reads from multiple streams, one after the other.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
+ use WPvividPsr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Reads from multiple streams, one after the other.
vendor/guzzlehttp/psr7/src/BufferStream.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
- use Psr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Provides a buffer stream that can be written to to fill a buffer, and read
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
+ use WPvividPsr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Provides a buffer stream that can be written to to fill a buffer, and read
vendor/guzzlehttp/psr7/src/CachingStream.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
- use Psr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Stream decorator that can cache previously read bytes from a sequentially
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
+ use WPvividPsr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Stream decorator that can cache previously read bytes from a sequentially
vendor/guzzlehttp/psr7/src/DroppingStream.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
- use Psr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Stream decorator that begins dropping data once the size of the underlying
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
+ use WPvividPsr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Stream decorator that begins dropping data once the size of the underlying
vendor/guzzlehttp/psr7/src/FnStream.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
- use Psr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Compose stream implementations based on a hash of functions.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
+ use WPvividPsr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Compose stream implementations based on a hash of functions.
vendor/guzzlehttp/psr7/src/InflateStream.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
- use Psr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
+ use WPvividPsr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
vendor/guzzlehttp/psr7/src/LazyOpenStream.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
- use Psr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Lazily reads or writes to a file that is opened only after an IO operation
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
+ use WPvividPsr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Lazily reads or writes to a file that is opened only after an IO operation
vendor/guzzlehttp/psr7/src/LimitStream.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
- use Psr\Http\Message\StreamInterface;
5
 
6
 
7
  /**
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
+ use WPvividPsr\Http\Message\StreamInterface;
5
 
6
 
7
  /**
vendor/guzzlehttp/psr7/src/MessageTrait.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
- use Psr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Trait implementing functionality common to requests and responses.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
+ use WPvividPsr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Trait implementing functionality common to requests and responses.
vendor/guzzlehttp/psr7/src/MultipartStream.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
- use Psr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Stream that when read returns bytes for a streaming multipart or
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
+ use WPvividPsr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Stream that when read returns bytes for a streaming multipart or
vendor/guzzlehttp/psr7/src/NoSeekStream.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
- use Psr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Stream decorator that prevents a stream from being seeked
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
+ use WPvividPsr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Stream decorator that prevents a stream from being seeked
vendor/guzzlehttp/psr7/src/PumpStream.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
- use Psr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Provides a read only stream that pumps data from a PHP callable.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
+ use WPvividPsr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Provides a read only stream that pumps data from a PHP callable.
vendor/guzzlehttp/psr7/src/Request.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
  use InvalidArgumentException;
5
- use Psr\Http\Message\RequestInterface;
6
- use Psr\Http\Message\StreamInterface;
7
- use Psr\Http\Message\UriInterface;
8
 
9
  /**
10
  * PSR-7 request implementation.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
  use InvalidArgumentException;
5
+ use WPvividPsr\Http\Message\RequestInterface;
6
+ use WPvividPsr\Http\Message\StreamInterface;
7
+ use WPvividPsr\Http\Message\UriInterface;
8
 
9
  /**
10
  * PSR-7 request implementation.
vendor/guzzlehttp/psr7/src/Response.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
- use Psr\Http\Message\ResponseInterface;
5
- use Psr\Http\Message\StreamInterface;
6
 
7
  /**
8
  * PSR-7 response implementation.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
+ use WPvividPsr\Http\Message\ResponseInterface;
5
+ use WPvividPsr\Http\Message\StreamInterface;
6
 
7
  /**
8
  * PSR-7 response implementation.
vendor/guzzlehttp/psr7/src/Rfc7230.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace GuzzleHttp\Psr7;
4
 
5
  final class Rfc7230
6
  {
1
  <?php
2
 
3
+ namespace WPvividGuzzleHttp\Psr7;
4
 
5
  final class Rfc7230
6
  {
vendor/guzzlehttp/psr7/src/ServerRequest.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
 
3
- namespace GuzzleHttp\Psr7;
4
 
5
  use InvalidArgumentException;
6
- use Psr\Http\Message\ServerRequestInterface;
7
- use Psr\Http\Message\UriInterface;
8
- use Psr\Http\Message\StreamInterface;
9
- use Psr\Http\Message\UploadedFileInterface;
10
 
11
  /**
12
  * Server-side HTTP request
1
  <?php
2
 
3
+ namespace WPvividGuzzleHttp\Psr7;
4
 
5
  use InvalidArgumentException;
6
+ use WPvividPsr\Http\Message\ServerRequestInterface;
7
+ use WPvividPsr\Http\Message\UriInterface;
8
+ use WPvividPsr\Http\Message\StreamInterface;
9
+ use WPvividPsr\Http\Message\UploadedFileInterface;
10
 
11
  /**
12
  * Server-side HTTP request
vendor/guzzlehttp/psr7/src/Stream.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
- use Psr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * PHP stream implementation.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
+ use WPvividPsr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * PHP stream implementation.
vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
- use Psr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Stream decorator trait
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
+ use WPvividPsr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Stream decorator trait
vendor/guzzlehttp/psr7/src/StreamWrapper.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
- use Psr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Converts Guzzle streams into PHP stream resources.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
+ use WPvividPsr\Http\Message\StreamInterface;
5
 
6
  /**
7
  * Converts Guzzle streams into PHP stream resources.
vendor/guzzlehttp/psr7/src/UploadedFile.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
  use InvalidArgumentException;
5
- use Psr\Http\Message\StreamInterface;
6
- use Psr\Http\Message\UploadedFileInterface;
7
  use RuntimeException;
8
 
9
  class UploadedFile implements UploadedFileInterface
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
  use InvalidArgumentException;
5
+ use WPvividPsr\Http\Message\StreamInterface;
6
+ use WPvividPsr\Http\Message\UploadedFileInterface;
7
  use RuntimeException;
8
 
9
  class UploadedFile implements UploadedFileInterface
vendor/guzzlehttp/psr7/src/Uri.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
- use Psr\Http\Message\UriInterface;
5
 
6
  /**
7
  * PSR-7 URI implementation.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
+ use WPvividPsr\Http\Message\UriInterface;
5
 
6
  /**
7
  * PSR-7 URI implementation.
vendor/guzzlehttp/psr7/src/UriNormalizer.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
- use Psr\Http\Message\UriInterface;
5
 
6
  /**
7
  * Provides methods to normalize and compare URIs.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
+ use WPvividPsr\Http\Message\UriInterface;
5
 
6
  /**
7
  * Provides methods to normalize and compare URIs.
vendor/guzzlehttp/psr7/src/UriResolver.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
 
4
- use Psr\Http\Message\UriInterface;
5
 
6
  /**
7
  * Resolves a URI reference in the context of a base URI and the opposite way.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
 
4
+ use WPvividPsr\Http\Message\UriInterface;
5
 
6
  /**
7
  * Resolves a URI reference in the context of a base URI and the opposite way.
vendor/guzzlehttp/psr7/src/functions.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
- namespace GuzzleHttp\Psr7;
3
-
4
- use Psr\Http\Message\MessageInterface;
5
- use Psr\Http\Message\RequestInterface;
6
- use Psr\Http\Message\ResponseInterface;
7
- use Psr\Http\Message\ServerRequestInterface;
8
- use Psr\Http\Message\StreamInterface;
9
- use Psr\Http\Message\UriInterface;
10
 
11
  /**
12
  * Returns the string representation of an HTTP message.
1
  <?php
2
+ namespace WPvividGuzzleHttp\Psr7;
3
+
4
+ use WPvividPsr\Http\Message\MessageInterface;
5
+ use WPvividPsr\Http\Message\RequestInterface;
6
+ use WPvividPsr\Http\Message\ResponseInterface;
7
+ use WPvividPsr\Http\Message\ServerRequestInterface;
8
+ use WPvividPsr\Http\Message\StreamInterface;
9
+ use WPvividPsr\Http\Message\UriInterface;
10
 
11
  /**
12
  * Returns the string representation of an HTTP message.
vendor/guzzlehttp/psr7/src/functions_include.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
  // Don't redefine the functions if included multiple times.
4
- if (!function_exists('GuzzleHttp\Psr7\str')) {
5
  require __DIR__ . '/functions.php';
6
  }
1
  <?php
2
 
3
  // Don't redefine the functions if included multiple times.
4
+ if (!function_exists('WPvividGuzzleHttp\Psr7\str')) {
5
  require __DIR__ . '/functions.php';
6
  }
vendor/monolog/monolog/src/Monolog/ErrorHandler.php CHANGED
@@ -11,8 +11,8 @@
11
 
12
  namespace Monolog;
13
 
14
- use Psr\Log\LoggerInterface;
15
- use Psr\Log\LogLevel;
16
  use Monolog\Handler\AbstractHandler;
17
  use Monolog\Registry;
18
 
@@ -61,7 +61,7 @@ class ErrorHandler
61
  public static function register(LoggerInterface $logger, $errorLevelMap = array(), $exceptionLevel = null, $fatalLevel = null)
62
  {
63
  //Forces the autoloader to run for LogLevel. Fixes an autoload issue at compile-time on PHP5.3. See https://github.com/Seldaek/monolog/pull/929
64
- class_exists('\\Psr\\Log\\LogLevel', true);
65
 
66
  $handler = new static($logger);
67
  if ($errorLevelMap !== false) {
11
 
12
  namespace Monolog;
13
 
14
+ use WPvividPsr\Log\LoggerInterface;
15
+ use WPvividPsr\Log\LogLevel;
16
  use Monolog\Handler\AbstractHandler;
17
  use Monolog\Registry;
18
 
61
  public static function register(LoggerInterface $logger, $errorLevelMap = array(), $exceptionLevel = null, $fatalLevel = null)
62
  {
63
  //Forces the autoloader to run for LogLevel. Fixes an autoload issue at compile-time on PHP5.3. See https://github.com/Seldaek/monolog/pull/929
64
+ class_exists('\\WPvividPsr\\Log\\LogLevel', true);
65
 
66
  $handler = new static($logger);
67
  if ($errorLevelMap !== false) {
vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php CHANGED
@@ -12,7 +12,7 @@
12
  namespace Monolog\Handler;
13
 
14
  use Monolog\Logger;
15
- use Psr\Log\LoggerInterface;
16
 
17
  /**
18
  * Proxies log messages to an existing PSR-3 compliant logger.
12
  namespace Monolog\Handler;
13
 
14
  use Monolog\Logger;
15
+ use WPvividPsr\Log\LoggerInterface;
16
 
17
  /**
18
  * Proxies log messages to an existing PSR-3 compliant logger.
vendor/monolog/monolog/src/Monolog/Logger.php CHANGED
@@ -13,8 +13,8 @@ namespace Monolog;
13
 
14
  use Monolog\Handler\HandlerInterface;
15
  use Monolog\Handler\StreamHandler;
16
- use Psr\Log\LoggerInterface;
17
- use Psr\Log\InvalidArgumentException;
18
  use Exception;
19
 
20
  /**
13
 
14
  use Monolog\Handler\HandlerInterface;
15
  use Monolog\Handler\StreamHandler;
16
+ use WPvividPsr\Log\LoggerInterface;
17
+ use WPvividPsr\Log\InvalidArgumentException;
18
  use Exception;
19
 
20
  /**
vendor/monolog/monolog/src/Monolog/SignalHandler.php CHANGED
@@ -11,8 +11,8 @@
11
 
12
  namespace Monolog;
13
 
14
- use Psr\Log\LoggerInterface;
15
- use Psr\Log\LogLevel;
16
  use ReflectionExtension;
17
 
18
  /**
11
 
12
  namespace Monolog;
13
 
14
+ use WPvividPsr\Log\LoggerInterface;
15
+ use WPvividPsr\Log\LogLevel;
16
  use ReflectionExtension;
17
 
18
  /**
vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php CHANGED
@@ -15,7 +15,7 @@ use Monolog\TestCase;
15
  use Monolog\Logger;
16
  use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
17
  use Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy;
18
- use Psr\Log\LogLevel;
19
 
20
  class FingersCrossedHandlerTest extends TestCase
21
  {
15
  use Monolog\Logger;
16
  use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
17
  use Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy;
18
+ use WPvividPsr\Log\LogLevel;
19
 
20
  class FingersCrossedHandlerTest extends TestCase
21
  {
vendor/monolog/monolog/tests/Monolog/Handler/PHPConsoleHandlerTest.php CHANGED
@@ -181,7 +181,7 @@ class PHPConsoleHandlerTest extends TestCase
181
  );
182
  $handler = $this->initLogger();
183
  $handler->log(
184
- \Psr\Log\LogLevel::ERROR,
185
  sprintf('Uncaught Exception %s: "%s" at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()),
186
  array('exception' => $e)
187
  );
181
  );
182
  $handler = $this->initLogger();
183
  $handler->log(
184
+ \WPvividPsr\Log\LogLevel::ERROR,
185
  sprintf('Uncaught Exception %s: "%s" at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()),
186
  array('exception' => $e)
187
  );
vendor/monolog/monolog/tests/Monolog/Handler/PsrHandlerTest.php CHANGED
@@ -39,7 +39,7 @@ class PsrHandlerTest extends TestCase
39
  $message = 'Hello, world! ' . $level;
40
  $context = array('foo' => 'bar', 'level' => $level);
41
 
42
- $psrLogger = $this->getMock('Psr\Log\NullLogger');
43
  $psrLogger->expects($this->once())
44
  ->method('log')
45
  ->with(strtolower($levelName), $message, $context);
39
  $message = 'Hello, world! ' . $level;
40
  $context = array('foo' => 'bar', 'level' => $level);
41
 
42
+ $psrLogger = $this->getMock('WPvividPsr\Log\NullLogger');
43
  $psrLogger->expects($this->once())
44
  ->method('log')
45
  ->with(strtolower($levelName), $message, $context);
vendor/monolog/monolog/tests/Monolog/PsrLogCompatTest.php CHANGED
@@ -14,7 +14,7 @@ namespace Monolog;
14
  use Monolog\Handler\TestHandler;
15
  use Monolog\Formatter\LineFormatter;
16
  use Monolog\Processor\PsrLogMessageProcessor;
17
- use Psr\Log\Test\LoggerInterfaceTest;
18
 
19
  class PsrLogCompatTest extends LoggerInterfaceTest
20
  {
14
  use Monolog\Handler\TestHandler;
15
  use Monolog\Formatter\LineFormatter;
16
  use Monolog\Processor\PsrLogMessageProcessor;
17
+ use WPvividPsr\Log\Test\LoggerInterfaceTest;
18
 
19
  class PsrLogCompatTest extends LoggerInterfaceTest
20
  {
vendor/monolog/monolog/tests/Monolog/SignalHandlerTest.php CHANGED
@@ -13,7 +13,7 @@ namespace Monolog;
13
 
14
  use Monolog\Handler\StreamHandler;
15
  use Monolog\Handler\TestHandler;
16
- use Psr\Log\LogLevel;
17
 
18
  /**
19
  * @author Robert Gust-Bardon <robert@gust-bardon.org>
13
 
14
  use Monolog\Handler\StreamHandler;
15
  use Monolog\Handler\TestHandler;
16
+ use WPvividPsr\Log\LogLevel;
17
 
18
  /**
19
  * @author Robert Gust-Bardon <robert@gust-bardon.org>
vendor/psr/cache/composer.json CHANGED
@@ -14,7 +14,7 @@
14
  },
15
  "autoload": {
16
  "psr-4": {
17
- "Psr\\Cache\\": "src/"
18
  }
19
  },
20
  "extra": {
14
  },
15
  "autoload": {
16
  "psr-4": {
17
+ "WPvividPsr\\Cache\\": "src/"
18
  }
19
  },
20
  "extra": {
vendor/psr/cache/src/CacheException.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Psr\Cache;
4
 
5
  /**
6
  * Exception interface for all exceptions thrown by an Implementing Library.
1
  <?php
2
 
3
+ namespace WPvividPsr\Cache;
4
 
5
  /**
6
  * Exception interface for all exceptions thrown by an Implementing Library.
vendor/psr/cache/src/CacheItemInterface.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Psr\Cache;
4
 
5
  /**
6
  * CacheItemInterface defines an interface for interacting with objects inside a cache.
1
  <?php
2
 
3
+ namespace WPvividPsr\Cache;
4
 
5
  /**
6
  * CacheItemInterface defines an interface for interacting with objects inside a cache.
vendor/psr/cache/src/CacheItemPoolInterface.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Psr\Cache;
4
 
5
  /**
6
  * CacheItemPoolInterface generates CacheItemInterface objects.
1
  <?php
2
 
3
+ namespace WPvividPsr\Cache;
4
 
5
  /**
6
  * CacheItemPoolInterface generates CacheItemInterface objects.
vendor/psr/cache/src/InvalidArgumentException.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Psr\Cache;
4
 
5
  /**
6
  * Exception interface for invalid cache arguments.
1
  <?php
2
 
3
+ namespace WPvividPsr\Cache;
4
 
5
  /**
6
  * Exception interface for invalid cache arguments.
vendor/psr/http-message/composer.json CHANGED
@@ -15,7 +15,7 @@
15
  },
16
  "autoload": {
17
  "psr-4": {
18
- "Psr\\Http\\Message\\": "src/"
19
  }
20
  },
21
  "extra": {
15
  },
16
  "autoload": {
17
  "psr-4": {
18
+ "WPvividPsr\\Http\\Message\\": "src/"
19
  }
20
  },
21
  "extra": {
vendor/psr/http-message/src/MessageInterface.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Psr\Http\Message;
4
 
5
  /**
6
  * HTTP messages consist of requests from a client to a server and responses
1
  <?php
2
 
3
+ namespace WPvividPsr\Http\Message;
4
 
5
  /**
6
  * HTTP messages consist of requests from a client to a server and responses
vendor/psr/http-message/src/RequestInterface.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Psr\Http\Message;
4
 
5
  /**
6
  * Representation of an outgoing, client-side request.
1
  <?php
2
 
3
+ namespace WPvividPsr\Http\Message;
4
 
5
  /**
6
  * Representation of an outgoing, client-side request.
vendor/psr/http-message/src/ResponseInterface.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Psr\Http\Message;
4
 
5
  /**
6
  * Representation of an outgoing, server-side response.
1
  <?php
2
 
3
+ namespace WPvividPsr\Http\Message;
4
 
5
  /**
6
  * Representation of an outgoing, server-side response.
vendor/psr/http-message/src/ServerRequestInterface.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Psr\Http\Message;
4
 
5
  /**
6
  * Representation of an incoming, server-side HTTP request.
1
  <?php
2
 
3
+ namespace WPvividPsr\Http\Message;
4
 
5
  /**
6
  * Representation of an incoming, server-side HTTP request.
vendor/psr/http-message/src/StreamInterface.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Psr\Http\Message;
4
 
5
  /**
6
  * Describes a data stream.
1
  <?php
2
 
3
+ namespace WPvividPsr\Http\Message;
4
 
5
  /**
6
  * Describes a data stream.
vendor/psr/http-message/src/UploadedFileInterface.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Psr\Http\Message;
4
 
5
  /**
6
  * Value object representing a file uploaded through an HTTP request.
1
  <?php
2
 
3
+ namespace WPvividPsr\Http\Message;
4
 
5
  /**
6
  * Value object representing a file uploaded through an HTTP request.
vendor/psr/http-message/src/UriInterface.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace Psr\Http\Message;
3
 
4
  /**
5
  * Value object representing a URI.
1
  <?php
2
+ namespace WPvividPsr\Http\Message;
3
 
4
  /**
5
  * Value object representing a URI.
vendor/psr/log/Psr/Log/AbstractLogger.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Psr\Log;
4
 
5
  /**
6
  * This is a simple Logger implementation that other Loggers can inherit from.
1
  <?php
2
 
3
+ namespace WPvividPsr\Log;
4
 
5
  /**
6
  * This is a simple Logger implementation that other Loggers can inherit from.
vendor/psr/log/Psr/Log/InvalidArgumentException.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Psr\Log;
4
 
5
  class InvalidArgumentException extends \InvalidArgumentException
6
  {
1
  <?php
2
 
3
+ namespace WPvividPsr\Log;
4
 
5
  class InvalidArgumentException extends \InvalidArgumentException
6
  {
vendor/psr/log/Psr/Log/LogLevel.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Psr\Log;
4
 
5
  /**
6
  * Describes log levels.
1
  <?php
2
 
3
+ namespace WPvividPsr\Log;
4
 
5
  /**
6
  * Describes log levels.
vendor/psr/log/Psr/Log/LoggerAwareInterface.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Psr\Log;
4
 
5
  /**
6
  * Describes a logger-aware instance.
1
  <?php
2
 
3
+ namespace WPvividPsr\Log;
4
 
5
  /**
6
  * Describes a logger-aware instance.
vendor/psr/log/Psr/Log/LoggerAwareTrait.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Psr\Log;
4
 
5
  /**
6
  * Basic Implementation of LoggerAwareInterface.
1
  <?php
2
 
3
+ namespace WPvividPsr\Log;
4
 
5
  /**
6
  * Basic Implementation of LoggerAwareInterface.
vendor/psr/log/Psr/Log/LoggerInterface.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Psr\Log;
4
 
5
  /**
6
  * Describes a logger instance.
1
  <?php
2
 
3
+ namespace WPvividPsr\Log;
4
 
5
  /**
6
  * Describes a logger instance.
vendor/psr/log/Psr/Log/LoggerTrait.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Psr\Log;
4
 
5
  /**
6
  * This is a simple Logger trait that classes unable to extend AbstractLogger
1
  <?php
2
 
3
+ namespace WPvividPsr\Log;
4
 
5
  /**
6
  * This is a simple Logger trait that classes unable to extend AbstractLogger
vendor/psr/log/Psr/Log/NullLogger.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace Psr\Log;
4
 
5
  /**
6
  * This Logger can be used to avoid conditional log calls.
1
  <?php
2
 
3
+ namespace WPvividPsr\Log;
4
 
5
  /**
6
  * This Logger can be used to avoid conditional log calls.
vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
 
3
- namespace Psr\Log\Test;
4
 
5
- use Psr\Log\LoggerInterface;
6
- use Psr\Log\LogLevel;
7
 
8
  /**
9
  * Provides a base test class for ensuring compliance with the LoggerInterface.
@@ -31,7 +31,7 @@ abstract class LoggerInterfaceTest extends \PHPUnit_Framework_TestCase
31
 
32
  public function testImplements()
33
  {
34
- $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger());
35
  }
36
 
37
  /**
@@ -85,9 +85,9 @@ abstract class LoggerInterfaceTest extends \PHPUnit_Framework_TestCase
85
  public function testObjectCastToString()
86
  {
87
  if (method_exists($this, 'createPartialMock')) {
88
- $dummy = $this->createPartialMock('Psr\Log\Test\DummyTest', array('__toString'));
89
  } else {
90
- $dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString'));
91
  }
92
  $dummy->expects($this->once())
93
  ->method('__toString')
1
  <?php
2
 
3
+ namespace WPvividPsr\Log\Test;
4
 
5
+ use WPvividPsr\Log\LoggerInterface;
6
+ use WPvividPsr\Log\LogLevel;
7
 
8
  /**
9
  * Provides a base test class for ensuring compliance with the LoggerInterface.
31
 
32
  public function testImplements()
33
  {
34
+ $this->assertInstanceOf('WPvividPsr\Log\LoggerInterface', $this->getLogger());
35
  }
36
 
37
  /**
85
  public function testObjectCastToString()
86
  {
87
  if (method_exists($this, 'createPartialMock')) {
88
+ $dummy = $this->createPartialMock('WPvividPsr\Log\Test\DummyTest', array('__toString'));
89
  } else {
90
+ $dummy = $this->getMock('WPvividPsr\Log\Test\DummyTest', array('__toString'));
91
  }
92
  $dummy->expects($this->once())
93
  ->method('__toString')
vendor/psr/log/Psr/Log/Test/TestLogger.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
 
3
- namespace Psr\Log\Test;
4
 
5
- use Psr\Log\AbstractLogger;
6
 
7
  /**
8
  * Used for testing purposes.
1
  <?php
2
 
3
+ namespace WPvividPsr\Log\Test;
4
 
5
+ use WPvividPsr\Log\AbstractLogger;
6
 
7
  /**
8
  * Used for testing purposes.
vendor/psr/log/composer.json CHANGED
@@ -15,7 +15,7 @@
15
  },
16
  "autoload": {
17
  "psr-4": {
18
- "Psr\\Log\\": "Psr/Log/"
19
  }
20
  },
21
  "extra": {
15
  },
16
  "autoload": {
17
  "psr-4": {
18
+ "WPvividPsr\\Log\\": "Psr/Log/"
19
  }
20
  },
21
  "extra": {
vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php CHANGED
@@ -11,7 +11,7 @@
11
 
12
  namespace Symfony\Component\EventDispatcher\Debug;
13
 
14
- use Psr\Log\LoggerInterface;
15
  use Symfony\Component\EventDispatcher\Event;
16
  use Symfony\Component\EventDispatcher\EventDispatcherInterface;
17
  use Symfony\Component\EventDispatcher\EventSubscriberInterface;
11
 
12
  namespace Symfony\Component\EventDispatcher\Debug;
13
 
14
+ use WPvividPsr\Log\LoggerInterface;
15
  use Symfony\Component\EventDispatcher\Event;
16
  use Symfony\Component\EventDispatcher\EventDispatcherInterface;
17
  use Symfony\Component\EventDispatcher\EventSubscriberInterface;
vendor/symfony/event-dispatcher/Tests/Debug/TraceableEventDispatcherTest.php CHANGED
@@ -152,7 +152,7 @@ class TraceableEventDispatcherTest extends TestCase
152
 
153
  public function testLogger()
154
  {
155
- $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
156
 
157
  $dispatcher = new EventDispatcher();
158
  $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger);
@@ -167,7 +167,7 @@ class TraceableEventDispatcherTest extends TestCase
167
 
168
  public function testLoggerWithStoppedEvent()
169
  {
170
- $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
171
 
172
  $dispatcher = new EventDispatcher();
173
  $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger);
152
 
153
  public function testLogger()
154
  {
155
+ $logger = $this->getMockBuilder('WPvividPsr\Log\LoggerInterface')->getMock();
156
 
157
  $dispatcher = new EventDispatcher();
158
  $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger);
167
 
168
  public function testLoggerWithStoppedEvent()
169
  {
170
+ $logger = $this->getMockBuilder('WPvividPsr\Log\LoggerInterface')->getMock();
171
 
172
  $dispatcher = new EventDispatcher();
173
  $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger);
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.58
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.58' );
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.59
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.59' );
25
  //
26
  define('WPVIVID_RESTORE_INIT','init');
27
  define('WPVIVID_RESTORE_READY','ready');