Migration, Backup, Staging – WPvivid - Version 0.9.8

Version Description

  • Added support for Google Drive, Micosoft OneDrive, Dropbox cloud storage.
  • Fixed a bug where restoring a backup from cloud storage would fail because of failure of downloading the backup from cloud storage to localhost.
  • Optimized code of the plugin.
Download this release

Release Info

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

Code changes from version 0.9.7 to 0.9.8

Files changed (174) hide show
  1. admin/class-wpvivid-admin.php +0 -1
  2. admin/js/wpvivid-admin.js +375 -742
  3. admin/partials/wpvivid-admin-display.php +24 -12
  4. admin/partials/wpvivid-backup-restore-page-display.php +116 -38
  5. admin/partials/wpvivid-logs-page-display.php +3 -32
  6. admin/partials/wpvivid-remote-storage-page-display.php +76 -10
  7. admin/partials/wpvivid-settings-page-display.php +7 -7
  8. includes/class-wpvivid-backup-site.php +1 -1
  9. includes/class-wpvivid-downloader.php +10 -1
  10. includes/class-wpvivid-remote-collection.php +44 -12
  11. includes/class-wpvivid-setting.php +32 -8
  12. includes/class-wpvivid-taskmanager.php +29 -0
  13. includes/class-wpvivid.php +574 -72
  14. includes/customclass/class-wpvivid-amazons3-plus.php +71 -16
  15. includes/customclass/class-wpvivid-extend-sftp.php +1 -4
  16. includes/customclass/class-wpvivid-ftpclass.php +69 -28
  17. includes/customclass/class-wpvivid-sftpclass.php +69 -22
  18. readme.txt +84 -93
  19. vendor/autoload.php +7 -0
  20. vendor/composer/ClassLoader.php +445 -0
  21. vendor/composer/LICENSE +21 -0
  22. vendor/composer/autoload_classmap.php +11 -0
  23. vendor/composer/autoload_files.php +15 -0
  24. vendor/composer/autoload_namespaces.php +16 -0
  25. vendor/composer/autoload_psr4.php +18 -0
  26. vendor/composer/autoload_real.php +74 -0
  27. vendor/composer/autoload_static.php +145 -0
  28. vendor/composer/include_paths.php +10 -0
  29. vendor/composer/installed.json +699 -0
  30. vendor/firebase/php-jwt/LICENSE +30 -0
  31. vendor/firebase/php-jwt/README.md +200 -0
  32. vendor/firebase/php-jwt/composer.json +29 -0
  33. vendor/firebase/php-jwt/src/BeforeValidException.php +7 -0
  34. vendor/firebase/php-jwt/src/ExpiredException.php +7 -0
  35. vendor/firebase/php-jwt/src/JWT.php +379 -0
  36. vendor/firebase/php-jwt/src/SignatureInvalidException.php +7 -0
  37. vendor/google/apiclient-services/LICENSE +203 -0
  38. vendor/google/apiclient-services/README.md +23 -0
  39. vendor/google/apiclient-services/composer.json +19 -0
  40. vendor/google/apiclient-services/src/Google/Service/Drive.php +950 -0
  41. vendor/google/apiclient-services/src/Google/Service/Drive/About.php +142 -0
  42. vendor/google/apiclient-services/src/Google/Service/Drive/AboutStorageQuota.php +57 -0
  43. vendor/google/apiclient-services/src/Google/Service/Drive/AboutTeamDriveThemes.php +48 -0
  44. vendor/google/apiclient-services/src/Google/Service/Drive/Change.php +107 -0
  45. vendor/google/apiclient-services/src/Google/Service/Drive/ChangeList.php +65 -0
  46. vendor/google/apiclient-services/src/Google/Service/Drive/Channel.php +111 -0
  47. vendor/google/apiclient-services/src/Google/Service/Drive/Comment.php +151 -0
  48. vendor/google/apiclient-services/src/Google/Service/Drive/CommentList.php +56 -0
  49. vendor/google/apiclient-services/src/Google/Service/Drive/CommentQuotedFileContent.php +39 -0
  50. vendor/google/apiclient-services/src/Google/Service/Drive/DriveFile.php +571 -0
  51. vendor/google/apiclient-services/src/Google/Service/Drive/DriveFileCapabilities.php +237 -0
  52. vendor/google/apiclient-services/src/Google/Service/Drive/DriveFileContentHints.php +46 -0
  53. vendor/google/apiclient-services/src/Google/Service/Drive/DriveFileContentHintsThumbnail.php +39 -0
  54. vendor/google/apiclient-services/src/Google/Service/Drive/DriveFileImageMediaMetadata.php +217 -0
  55. vendor/google/apiclient-services/src/Google/Service/Drive/DriveFileImageMediaMetadataLocation.php +48 -0
  56. vendor/google/apiclient-services/src/Google/Service/Drive/DriveFileVideoMediaMetadata.php +48 -0
  57. vendor/google/apiclient-services/src/Google/Service/Drive/FileList.php +65 -0
  58. vendor/google/apiclient-services/src/Google/Service/Drive/GeneratedIds.php +49 -0
  59. vendor/google/apiclient-services/src/Google/Service/Drive/Permission.php +137 -0
  60. vendor/google/apiclient-services/src/Google/Service/Drive/PermissionList.php +56 -0
  61. vendor/google/apiclient-services/src/Google/Service/Drive/PermissionTeamDrivePermissionDetails.php +57 -0
  62. vendor/google/apiclient-services/src/Google/Service/Drive/Reply.php +109 -0
  63. vendor/google/apiclient-services/src/Google/Service/Drive/ReplyList.php +56 -0
  64. vendor/google/apiclient-services/src/Google/Service/Drive/Resource/About.php +41 -0
  65. vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Changes.php +121 -0
  66. vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Channels.php +40 -0
  67. vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Comments.php +109 -0
  68. vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Files.php +255 -0
  69. vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Permissions.php +147 -0
  70. vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Replies.php +112 -0
  71. vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Revisions.php +93 -0
  72. vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Teamdrives.php +113 -0
  73. vendor/google/apiclient-services/src/Google/Service/Drive/Revision.php +145 -0
  74. vendor/google/apiclient-services/src/Google/Service/Drive/RevisionList.php +56 -0
  75. vendor/google/apiclient-services/src/Google/Service/Drive/StartPageToken.php +39 -0
  76. vendor/google/apiclient-services/src/Google/Service/Drive/TeamDrive.php +132 -0
  77. vendor/google/apiclient-services/src/Google/Service/Drive/TeamDriveBackgroundImageFile.php +57 -0
  78. vendor/google/apiclient-services/src/Google/Service/Drive/TeamDriveCapabilities.php +192 -0
  79. vendor/google/apiclient-services/src/Google/Service/Drive/TeamDriveList.php +56 -0
  80. vendor/google/apiclient-services/src/Google/Service/Drive/TeamDriveRestrictions.php +57 -0
  81. vendor/google/apiclient-services/src/Google/Service/Drive/User.php +75 -0
  82. vendor/google/auth/.editorconfig +18 -0
  83. vendor/google/auth/.gitignore +7 -0
  84. vendor/google/auth/.php_cs +54 -0
  85. vendor/google/auth/.travis.yml +32 -0
  86. vendor/google/auth/CHANGELOG.md +81 -0
  87. vendor/google/auth/CODE_OF_CONDUCT.md +43 -0
  88. vendor/google/auth/CONTRIBUTING.md +73 -0
  89. vendor/google/auth/COPYING +202 -0
  90. vendor/google/auth/LICENSE +203 -0
  91. vendor/google/auth/README.md +150 -0
  92. vendor/google/auth/autoload.php +34 -0
  93. vendor/google/auth/composer.json +27 -0
  94. vendor/google/auth/phpunit.xml.dist +19 -0
  95. vendor/google/auth/src/ApplicationDefaultCredentials.php +173 -0
  96. vendor/google/auth/src/Cache/InvalidArgumentException.php +24 -0
  97. vendor/google/auth/src/Cache/Item.php +185 -0
  98. vendor/google/auth/src/Cache/MemoryCacheItemPool.php +154 -0
  99. vendor/google/auth/src/Cache/SysVCacheItemPool.php +231 -0
  100. vendor/google/auth/src/CacheTrait.php +83 -0
  101. vendor/google/auth/src/Credentials/AppIdentityCredentials.php +159 -0
  102. vendor/google/auth/src/Credentials/GCECredentials.php +233 -0
  103. vendor/google/auth/src/Credentials/IAMCredentials.php +89 -0
  104. vendor/google/auth/src/Credentials/InsecureCredentials.php +68 -0
  105. vendor/google/auth/src/Credentials/ServiceAccountCredentials.php +177 -0
  106. vendor/google/auth/src/Credentials/ServiceAccountJwtAccessCredentials.php +131 -0
  107. vendor/google/auth/src/Credentials/UserRefreshCredentials.php +131 -0
  108. vendor/google/auth/src/CredentialsLoader.php +223 -0
  109. vendor/google/auth/src/FetchAuthTokenCache.php +108 -0
  110. vendor/google/auth/src/FetchAuthTokenInterface.php +55 -0
  111. vendor/google/auth/src/HttpHandler/Guzzle5HttpHandler.php +128 -0
  112. vendor/google/auth/src/HttpHandler/Guzzle6HttpHandler.php +49 -0
  113. vendor/google/auth/src/HttpHandler/HttpHandlerFactory.php +47 -0
  114. vendor/google/auth/src/Middleware/AuthTokenMiddleware.php +126 -0
  115. vendor/google/auth/src/Middleware/ScopedAccessTokenMiddleware.php +175 -0
  116. vendor/google/auth/src/Middleware/SimpleMiddleware.php +93 -0
  117. vendor/google/auth/src/OAuth2.php +1345 -0
  118. vendor/google/auth/src/Subscriber/AuthTokenSubscriber.php +118 -0
  119. vendor/google/auth/src/Subscriber/ScopedAccessTokenSubscriber.php +177 -0
  120. vendor/google/auth/src/Subscriber/SimpleSubscriber.php +90 -0
  121. vendor/guzzlehttp/guzzle/CHANGELOG.md +1287 -0
  122. vendor/guzzlehttp/guzzle/LICENSE +19 -0
  123. vendor/guzzlehttp/guzzle/README.md +91 -0
  124. vendor/guzzlehttp/guzzle/UPGRADING.md +1203 -0
  125. vendor/guzzlehttp/guzzle/composer.json +44 -0
  126. vendor/guzzlehttp/guzzle/src/Client.php +422 -0
  127. vendor/guzzlehttp/guzzle/src/ClientInterface.php +84 -0
  128. vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php +314 -0
  129. vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php +84 -0
  130. vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php +90 -0
  131. vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php +71 -0
  132. vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php +403 -0
  133. vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php +27 -0
  134. vendor/guzzlehttp/guzzle/src/Exception/ClientException.php +7 -0
  135. vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php +37 -0
  136. vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php +13 -0
  137. vendor/guzzlehttp/guzzle/src/Exception/RequestException.php +217 -0
  138. vendor/guzzlehttp/guzzle/src/Exception/SeekException.php +27 -0
  139. vendor/guzzlehttp/guzzle/src/Exception/ServerException.php +7 -0
  140. vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php +4 -0
  141. vendor/guzzlehttp/guzzle/src/Exception/TransferException.php +4 -0
  142. vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php +565 -0
  143. vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php +27 -0
  144. vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php +45 -0
  145. vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php +199 -0
  146. vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php +92 -0
  147. vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php +189 -0
  148. vendor/guzzlehttp/guzzle/src/Handler/Proxy.php +55 -0
  149. vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php +532 -0
  150. vendor/guzzlehttp/guzzle/src/HandlerStack.php +273 -0
  151. vendor/guzzlehttp/guzzle/src/MessageFormatter.php +180 -0
  152. vendor/guzzlehttp/guzzle/src/Middleware.php +255 -0
  153. vendor/guzzlehttp/guzzle/src/Pool.php +123 -0
  154. vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php +106 -0
  155. vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php +237 -0
  156. vendor/guzzlehttp/guzzle/src/RequestOptions.php +255 -0
  157. vendor/guzzlehttp/guzzle/src/RetryMiddleware.php +112 -0
  158. vendor/guzzlehttp/guzzle/src/TransferStats.php +126 -0
  159. vendor/guzzlehttp/guzzle/src/UriTemplate.php +237 -0
  160. vendor/guzzlehttp/guzzle/src/functions.php +333 -0
  161. vendor/guzzlehttp/guzzle/src/functions_include.php +6 -0
  162. vendor/guzzlehttp/promises/CHANGELOG.md +65 -0
  163. vendor/guzzlehttp/promises/LICENSE +19 -0
  164. vendor/guzzlehttp/promises/Makefile +13 -0
  165. vendor/guzzlehttp/promises/README.md +504 -0
  166. vendor/guzzlehttp/promises/composer.json +34 -0
  167. vendor/guzzlehttp/promises/src/AggregateException.php +16 -0
  168. vendor/guzzlehttp/promises/src/CancellationException.php +9 -0
  169. vendor/guzzlehttp/promises/src/Coroutine.php +151 -0
  170. vendor/guzzlehttp/promises/src/EachPromise.php +229 -0
  171. vendor/guzzlehttp/promises/src/FulfilledPromise.php +82 -0
  172. vendor/guzzlehttp/promises/src/Promise.php +280 -0
  173. vendor/guzzlehttp/promises/src/PromiseInterface.php +93 -0
  174. vendor/guzzlehttp/promises/src/PromisorInterface.php +1 -0
admin/class-wpvivid-admin.php CHANGED
@@ -264,5 +264,4 @@ class WPvivid_Admin {
264
  global $request_page;
265
  return $request_page;
266
  }
267
-
268
  }
264
  global $request_page;
265
  return $request_page;
266
  }
 
267
  }
admin/js/wpvivid-admin.js CHANGED
@@ -12,6 +12,8 @@ var wpvivid_completed_backup = 1;
12
  var wpvivid_prepare_backup=false;
13
  var wpvivid_restoring=false;
14
  var wpvivid_location_href=false;
 
 
15
 
16
  (function ($) {
17
  'use strict';
@@ -64,10 +66,14 @@ var wpvivid_location_href=false;
64
 
65
  $('input[option=add-remote]').click(function(){
66
  var storage_type = $(".storage-providers-active").attr("remote_type");
67
- wpvivid_add_remote_storage('wpvivid_test_remote_connection', storage_type);
68
  wpvivid_settings_changed = false;
69
  });
70
 
 
 
 
 
71
  $('#backup_list_all_check').click(function(){
72
  var name = '';
73
  if($('#backup_list_all_check').prop('checked')) {
@@ -96,16 +102,12 @@ var wpvivid_location_href=false;
96
  }
97
  });
98
 
99
- $('#wpvivid_choose_remote_storage').click(function(){
100
- jQuery('#wpvivid_upload_storage').show();
101
- });
102
-
103
  $('#wpvivid_backup_cancel_btn').click(function(){
104
  wpvivid_cancel_backup();
105
  });
106
 
107
  $('#wpvivid_backup_log_btn').click(function(){
108
- wpvivid_read_backup_log();
109
  });
110
 
111
  $('#wpvivid_send_email_test').click(function(){
@@ -120,10 +122,6 @@ var wpvivid_location_href=false;
120
  wpvivid_import_settings();
121
  });
122
 
123
- $('#wpvivid_last_backup_msg_log').click(function(){
124
- wpvivid_retrieve_last_backup_log();
125
- });
126
-
127
  $('#wpvivid_set_default_remote_storage').click(function(){
128
  wpvivid_set_default_remote_storage();
129
  wpvivid_settings_changed = false;
@@ -237,71 +235,21 @@ function wpvivid_check_runningtask(){
237
  if (jsonarray.backup.result === 'success') {
238
  wpvivid_prepare_backup = false;
239
  jQuery.each(jsonarray.backup.data, function (index, value) {
240
- if (value.size != false) {
241
- if (typeof(value.size.db_size) !== 'undefined' && value.size.db_size !== '') {
242
- jQuery('#wpvivid_backup_database_size').html(value.size.db_size);
243
- }
244
- else {
245
- jQuery('#wpvivid_backup_database_size').html('');
246
- }
247
- if (typeof(value.size.files_size.sum) !== 'undefined' && value.size.files_size.sum !== '') {
248
- jQuery('#wpvivid_backup_file_size').html(value.size.files_size.sum);
249
- }
250
- else {
251
- jQuery('#wpvivid_backup_file_size').html('');
252
- }
253
- }
254
  if (value.status.str === 'ready') {
255
- jQuery('#wpvivid_current_doing').html('Ready to backup. Progress: 0%, running time: 0second.');
256
- var percent = '0%';
257
- jQuery('#wpvivid_action_progress_bar_percent').css('width', percent);
258
  m_need_update = true;
259
  }
260
  else if (value.status.str === 'running') {
261
  running_backup_taskid = index;
262
  jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
263
  jQuery('#wpvivid_postbox_backup_percent').show();
264
- if (value.is_canceled === false) {
265
- jQuery('#wpvivid_backup_cancel_btn').css({'pointer-events': 'auto', 'opacity': '1'});
266
- jQuery('#wpvivid_backup_log_btn').css({'pointer-events': 'auto', 'opacity': '1'});
267
- if (value.data.doing !== '') {
268
- var percent = 0;
269
- if (value.data.type === 'backup') {
270
- percent = value.data.progress;
271
- }
272
- else if (value.data.type === 'upload') {
273
- percent = value.data.progress;
274
- }
275
- percent = percent + '%';
276
- jQuery('#wpvivid_action_progress_bar_percent').css('width', percent);
277
- var time = wpvivid_calc_backup_elapsed_time(value.data.running_time);
278
- if (value.is_canceled === false) {
279
- jQuery('#wpvivid_current_doing').html(value.data.descript + ' Progress: ' + percent + ', running time: ' + time + '.');
280
- }
281
- }
282
- }
283
- else {
284
- jQuery('#wpvivid_backup_cancel_btn').css({'pointer-events': 'nano', 'opacity': '0.4'});
285
- jQuery('#wpvivid_current_doing').html('The backup will be canceled after backing up the current chunk ends.');
286
- }
287
  m_need_update = true;
288
  }
289
  else if (value.status.str === 'wait_resume') {
290
- jQuery('#wpvivid_backup_cancel_btn').css({'pointer-events': 'auto', 'opacity': '1'});
291
- jQuery('#wpvivid_backup_log_btn').css({'pointer-events': 'auto', 'opacity': '1'});
292
- var info = 'Task ' + index + ' timed out, backup task will retry in ' + value.data.next_resume_time + ' seconds, retry times: ' + value.status.resume_count + '.';
293
  jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
294
  jQuery('#wpvivid_postbox_backup_percent').show();
295
- var percent = 0;
296
- if (value.data.type === 'backup') {
297
- percent = value.data.progress;
298
- }
299
- else if (value.data.type === 'upload') {
300
- percent = value.data.progress;
301
- }
302
- percent = percent + '%';
303
- jQuery('#wpvivid_action_progress_bar_percent').css('width', percent);
304
- jQuery('#wpvivid_current_doing').html(info);
305
  if (value.data.next_resume_time !== 'get next resume time failed.') {
306
  wpvivid_resume_backup(index, value.data.next_resume_time);
307
  }
@@ -311,54 +259,38 @@ function wpvivid_check_runningtask(){
311
  }
312
  }
313
  else if (value.status.str === 'no_responds') {
314
- jQuery('#wpvivid_backup_cancel_btn').css({'pointer-events': 'auto', 'opacity': '1'});
315
- jQuery('#wpvivid_backup_log_btn').css({'pointer-events': 'auto', 'opacity': '1'});
316
  running_backup_taskid = index;
317
  jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
318
  jQuery('#wpvivid_postbox_backup_percent').show();
319
- if (value.is_canceled === false) {
320
- if (value.data.doing !== '') {
321
- var percent = 0;
322
- if (value.data.type === 'backup') {
323
- percent = value.data.progress;
324
- }
325
- else if (value.data.type === 'upload') {
326
- percent = value.data.progress;
327
- }
328
- percent = percent + '%';
329
- jQuery('#wpvivid_action_progress_bar_percent').css('width', percent);
330
- var time = wpvivid_calc_backup_elapsed_time(value.data.running_time);
331
- if (value.is_canceled === false) {
332
- jQuery('#wpvivid_current_doing').html('Task , ' + value.data.doing + ' is not responding. Progress: ' + percent + ', running time: ' + time);
333
- }
334
- }
335
- }
336
- else {
337
- jQuery('#wpvivid_backup_cancel_btn').css({'pointer-events': 'nano', 'opacity': '0.4'});
338
- jQuery('#wpvivid_current_doing').html('The backup will be canceled after backing up the current chunk ends.');
339
- }
340
  m_need_update = true;
341
  }
342
  else if (value.status.str === 'completed') {
343
- jQuery('#wpvivid_backup_cancel_btn').css({'pointer-events': 'auto', 'opacity': '1'});
344
- jQuery('#wpvivid_backup_log_btn').css({'pointer-events': 'auto', 'opacity': '1'});
345
  var info = 'Task ' + index + ' completed.';
346
  wpvivid_add_notice('Backup', 'Success', info);
347
  jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'auto', 'opacity': '1'});
348
  jQuery('#wpvivid_postbox_backup_percent').hide();
349
- wpvivid_retrieve_backup_list();
350
- wpvivid_retrieve_last_backup_message();
351
- wpvivid_retrieve_log_list();
 
 
 
 
352
  wpvivid_delete_backup_task(index);
353
  }
354
  else if (value.status.str === 'error') {
355
- jQuery('#wpvivid_backup_cancel_btn').css({'pointer-events': 'auto', 'opacity': '1'});
356
- jQuery('#wpvivid_backup_log_btn').css({'pointer-events': 'auto', 'opacity': '1'});
357
  var info = 'Backup error: ' + value.status.error + ', task id: ' + index;
358
  wpvivid_add_notice('Backup', 'Error', info);
359
  jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'auto', 'opacity': '1'});
360
  jQuery('#wpvivid_postbox_backup_percent').hide();
361
- wpvivid_retrieve_last_backup_message();
 
 
 
 
362
  wpvivid_delete_backup_task(index);
363
  }
364
  });
@@ -372,42 +304,38 @@ function wpvivid_check_runningtask(){
372
  jQuery('#wpvivid_backup_log_btn').css({'pointer-events': 'auto', 'opacity': '1'});
373
  jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'auto', 'opacity': '1'});
374
  jQuery('#wpvivid_postbox_backup_percent').hide();
 
375
  wpvivid_retrieve_last_backup_message();
376
  wpvivid_retrieve_log_list();
377
  running_backup_taskid='';
378
  }
379
-
380
  }
381
  if (jsonarray.download.data.length !== 0) {
382
  b_has_data = true;
383
  task_retry_times = 0;
384
- var download_array = new Array('backup_type', 'download_type', 'delete_button_id', 'download_button_id', 'progress_id', 'download_text_id', 'split_file_id');
385
  var i = 0;
386
- var file_part = '';
387
  jQuery.each(jsonarray.download.data.type, function (index, value) {
388
- download_array = wpvivid_get_download_info(index, download_array);
389
  var file_name = '';
390
- var part_num = '';
 
391
  jQuery.each(value.files, function (index1, value1) {
392
  i++;
393
- part_num = wpvivid_prefix_integer(i);
394
  file_name = index1;
395
  var progress = '0%';
396
  if (value1.status === 'need_download') {
397
- progress = '0%';
398
- jQuery('#' + tmp_current_click_backupid + '-progress-part-' + i).css('width', progress);
399
  if (m_downloading_file_name === file_name) {
400
  m_need_update = true;
401
  }
 
 
402
  }
403
  else if (value1.status === 'running') {
404
  if (m_downloading_file_name === file_name) {
405
  wpvivid_lock_download(tmp_current_click_backupid);
406
  }
407
- progress = value1.progress_text + '%';
408
- jQuery('#' + tmp_current_click_backupid + '-text-part-' + i).html('<a>Retriving(remote storage to web server)</a>');
409
- jQuery('#' + tmp_current_click_backupid + '-progress-part-' + i).css('width', progress);
410
  m_need_update = true;
 
 
411
  }
412
  else if (value1.status === 'completed') {
413
  if (m_downloading_file_name === file_name) {
@@ -415,9 +343,8 @@ function wpvivid_check_runningtask(){
415
  m_downloading_id = '';
416
  m_downloading_file_name = '';
417
  }
418
- progress = '100%';
419
- jQuery('#' + tmp_current_click_backupid + '-text-part-' + i).html('<a onclick="wpvivid_download(\'' + tmp_current_click_backupid + '\', \'' + index + '\', \'' + file_name + '\');" style="cursor: pointer">Download</a>');
420
- jQuery('#' + tmp_current_click_backupid + '-progress-part-' + i).css('width', progress);
421
  }
422
  else if (value1.status === 'error') {
423
  if (m_downloading_file_name === file_name) {
@@ -426,9 +353,8 @@ function wpvivid_check_runningtask(){
426
  m_downloading_file_name = '';
427
  }
428
  alert(value1.error);
429
- progress = '0%';
430
- jQuery('#' + tmp_current_click_backupid + '-text-part-' + i).html('<a onclick="wpvivid_prepare_download(\'' + i + '\', \'' + tmp_current_click_backupid + '\', \'' + file_name + '\');" style="cursor: pointer">Prepare to Download</a>');
431
- jQuery('#' + tmp_current_click_backupid + '-progress-part-' + i).css('width', progress);
432
  }
433
  else if (value1.stauts === 'timeout') {
434
  if (m_downloading_file_name === file_name) {
@@ -437,11 +363,14 @@ function wpvivid_check_runningtask(){
437
  m_downloading_file_name = '';
438
  }
439
  alert('Download timeout, please retry.');
440
- progress = '0%';
441
- jQuery('#' + tmp_current_click_backupid + '-text-part-' + i).html('<a onclick="wpvivid_prepare_download(\'' + i + '\', \'' + tmp_current_click_backupid + '\', \'' + file_name + '\');" style="cursor: pointer">Prepare to Download</a>');
442
- jQuery('#' + tmp_current_click_backupid + '-progress-part-' + i).css('width', progress);
443
  }
444
  });
 
 
 
 
445
  });
446
  }
447
  if (!b_has_data) {
@@ -474,8 +403,14 @@ function wpvivid_cancel_backup(){
474
  'task_id': running_backup_taskid
475
  };
476
  jQuery('#wpvivid_backup_cancel_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
477
- jQuery('#wpvivid_current_doing').html('The backup will be canceled after backing up the current chunk ends.');
478
  wpvivid_post_request(ajax_data, function(data){
 
 
 
 
 
 
 
479
  }, function(XMLHttpRequest, textStatus, errorThrown) {
480
  jQuery('#wpvivid_backup_cancel_btn').css({'pointer-events': 'auto', 'opacity': '1'});
481
  var error_message = wpvivid_output_ajaxerror('cancelling the backup', textStatus, errorThrown);
@@ -483,24 +418,99 @@ function wpvivid_cancel_backup(){
483
  });
484
  }
485
 
486
- /**
487
- * Read the backup log during the the process of a backup
488
- */
489
- function wpvivid_read_backup_log(){
490
- jQuery('#wpvivid_tab_backup_log').show();
491
- wpvivid_click_switch_backup_page('wpvivid_tab_backup_log');
492
- var ajax_data = {
493
- 'action':'wpvivid_view_backup_task_log',
494
- 'id':running_backup_taskid
495
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
496
  wpvivid_post_request(ajax_data, function(data){
497
- wpvivid_show_log(data);
498
  }, function(XMLHttpRequest, textStatus, errorThrown) {
499
  var div = 'Reading the log failed. Please try again.';
500
  jQuery('#wpvivid_display_log_content').html(div);
501
  });
502
  }
503
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
504
  /**
505
  * Start backing up
506
  */
@@ -548,7 +558,8 @@ function wpvivid_start_backup(){
548
  }
549
  m_backup_task_id = jsonarray.task_id;
550
  if (jsonarray.check.alert_db === false && jsonarray.check.alter_files === false && jsonarray.check.alter_fcgi === false) {
551
- wpvivid_retrieve_backup_list();
 
552
  wpvivid_backup_now(jsonarray.task_id);
553
  }
554
  else {
@@ -559,7 +570,8 @@ function wpvivid_start_backup(){
559
  'Click OK button and continue to back up.';
560
  var ret = confirm(descript);
561
  if (ret === true) {
562
- wpvivid_retrieve_backup_list();
 
563
  wpvivid_backup_now(m_backup_task_id);
564
  }
565
  else {
@@ -612,7 +624,7 @@ function wpvivid_delete_ready_task(error){
612
  *
613
  * @param backup_id - A unique ID for a backup
614
  */
615
- function wpvivid_delete_selected_backup(backup_id){
616
  var name = '';
617
  jQuery('#wpvivid_backuplist tr').each(function(i){
618
  jQuery(this).children('td').each(function (j) {
@@ -657,12 +669,12 @@ function wpvivid_delete_selected_backup(backup_id){
657
  alert(error_message);
658
  });
659
  }
660
- }
661
 
662
  /**
663
  * Delete multiple backups in one operation
664
  */
665
- function wpvivid_delete_backups_inbatches(){
666
  var delete_backup_array = new Array();
667
  var count = 0;
668
  var bdownloading = false;
@@ -708,7 +720,7 @@ function wpvivid_delete_backups_inbatches(){
708
  });
709
  }
710
  }
711
- }
712
 
713
  /**
714
  * Resume the backup task automatically in 1 minute in a timeout situation
@@ -738,33 +750,7 @@ function wpvivid_retrieve_last_backup_message(){
738
  wpvivid_post_request(ajax_data, function(data){
739
  try {
740
  var jsonarray = jQuery.parseJSON(data);
741
- if (jsonarray.result === 'success') {
742
- if (jsonarray.data.status.str === 'completed') {
743
- var backup_status = 'Succeed';
744
- var last_backup_msg = 'Last backup: ' + jsonarray.data.status.start_time + ' ' + backup_status + ' <a onclick="wpvivid_retrieve_last_backup_log();" style="cursor:pointer;"> Log</a>';
745
- jQuery('#wpvivid_last_backup_msg').html(last_backup_msg);
746
- }
747
- else if (jsonarray.data.status.str === 'error') {
748
- var backup_status = 'Failed';
749
- var last_backup_msg = 'Last backup: ' + jsonarray.data.status.start_time + ' ' + backup_status + ' <a onclick="wpvivid_retrieve_last_backup_log();" style="cursor:pointer;"> Log</a>';
750
- jQuery('#wpvivid_last_backup_msg').html(last_backup_msg);
751
- }
752
- else if (jsonarray.data.status.str === 'cancel') {
753
- var backup_status = 'Failed';
754
- var last_backup_msg = 'Last backup: ' + jsonarray.data.status.start_time + ' ' + backup_status + ' <a onclick=\"wpvivid_retrieve_last_backup_log();\" style=\"cursor:pointer;\"> Log</a>';
755
- jQuery('#wpvivid_last_backup_msg').html(last_backup_msg);
756
- }
757
- else {
758
- jQuery('#wpvivid_last_backup_msg_log').hide();
759
- var last_backup_msg = 'Last backup: The last backup message not found.';
760
- jQuery('#wpvivid_last_backup_msg').html(last_backup_msg);
761
- }
762
- }
763
- else if (jsonarray.result === 'failed') {
764
- jQuery('#wpvivid_last_backup_msg_log').hide();
765
- var last_backup_msg = jsonarray.data;
766
- jQuery('#wpvivid_last_backup_msg').html(last_backup_msg);
767
- }
768
  }
769
  catch(err){
770
  alert(err);
@@ -781,41 +767,23 @@ function wpvivid_retrieve_last_backup_message(){
781
  * @param action - The action to add or test a remote storage
782
  * @param storage_type - Remote storage types (Amazon S3, SFTP and FTP server)
783
  */
784
- function wpvivid_add_remote_storage(action, storage_type)
785
  {
786
- var bcheck = true;
787
- var name = jQuery('input:text[option='+storage_type+'][name=name]').val();
788
- if(wpvivid_check_repeat_storage_alias(name) === -1){
789
- bcheck = false;
790
- alert("Warning: The alias already exists in storage list.");
791
- }
792
- if(bcheck) {
793
- var remote_from = wpvivid_ajax_data_transfer(storage_type);
794
- var ajax_data;
795
- ajax_data = {
796
- 'action': action,
797
- 'remote': remote_from,
798
- 'type': storage_type
799
- };
800
- jQuery('input[option=add-remote]').css({'pointer-events': 'nano', 'opacity': '0.4'});
801
- wpvivid_post_request(ajax_data, function (data) {
802
- if (action === 'wpvivid_test_remote_connection') {
803
- try {
804
- var jsonarray = jQuery.parseJSON(data);
805
- if (jsonarray.result === 'success') {
806
- wpvivid_add_remote_storage('wpvivid_add_remote', storage_type);
807
- }
808
- else if (jsonarray.result === 'failed') {
809
- alert(jsonarray.error);
810
- jQuery('input[option=add-remote]').css({'pointer-events': 'auto', 'opacity': '1'});
811
- }
812
- }
813
- catch (err) {
814
- alert(err);
815
- jQuery('input[option=add-remote]').css({'pointer-events': 'auto', 'opacity': '1'});
816
- }
817
- }
818
- else if (action === 'wpvivid_add_remote') {
819
  jQuery('input[option=add-remote]').css({'pointer-events': 'auto', 'opacity': '1'});
820
  jQuery('input:text[option='+storage_type+']').each(function(){
821
  jQuery(this).val('');
@@ -825,17 +793,31 @@ function wpvivid_add_remote_storage(action, storage_type)
825
  });
826
  wpvivid_handle_remote_storage_data(data);
827
  }
828
- }, function (XMLHttpRequest, textStatus, errorThrown) {
829
- jQuery('input[option=add-remote]').css({'pointer-events': 'auto', 'opacity': '1'});
830
- if (action === 'wpvivid_test_remote_connection') {
831
- var error_message = wpvivid_output_ajaxerror('testing the remote storage connection', textStatus, errorThrown);
832
- }
833
- else if (action === 'wpvivid_add_remote') {
834
- var error_message = wpvivid_output_ajaxerror('adding the remote storage', textStatus, errorThrown);
835
  }
836
- alert(error_message);
837
- });
838
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
839
  }
840
 
841
  function wpvivid_handle_remote_storage_data(data){
@@ -859,6 +841,94 @@ function wpvivid_handle_remote_storage_data(data){
859
  }
860
  }
861
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
862
  /*
863
  * Delete the selected remote storage from the list
864
  *
@@ -870,7 +940,7 @@ function wpvivid_delete_remote_storage(storage_id){
870
  if(ret === true){
871
  var ajax_data = {
872
  'action': 'wpvivid_delete_remote',
873
- 'remote_id':storage_id
874
  };
875
  wpvivid_post_request(ajax_data, function(data){
876
  wpvivid_handle_remote_storage_data(data);
@@ -889,7 +959,16 @@ function wpvivid_retrieve_backup_list(){
889
  'action': 'wpvivid_get_backup_list'
890
  };
891
  wpvivid_post_request(ajax_data, function(data){
892
- wpvivid_handle_backup_data(data);
 
 
 
 
 
 
 
 
 
893
  },function(XMLHttpRequest, textStatus, errorThrown) {
894
  setTimeout(function () {
895
  wpvivid_retrieve_backup_list();
@@ -898,7 +977,6 @@ function wpvivid_retrieve_backup_list(){
898
  }
899
 
900
  function wpvivid_handle_backup_data(data){
901
- var i = 0;
902
  try {
903
  var jsonarray = jQuery.parseJSON(data);
904
  if (jsonarray.result === 'success') {
@@ -1026,54 +1104,6 @@ function wpvivid_import_settings(){
1026
  }
1027
  }
1028
 
1029
- /**
1030
- * Retrieve the last backup log
1031
- */
1032
- function wpvivid_retrieve_last_backup_log(){
1033
- jQuery('#wpvivid_tab_backup_log').show();
1034
- wpvivid_click_switch_backup_page('wpvivid_tab_backup_log');
1035
- var ajax_data={
1036
- 'action': 'wpvivid_get_last_backup'
1037
- };
1038
- wpvivid_post_request(ajax_data, function(data){
1039
- try {
1040
- var jsonarray = jQuery.parseJSON(data);
1041
- if (jsonarray.result !== 'failed') {
1042
- if (jsonarray.data.length !== 0) {
1043
- ajax_data = {
1044
- 'action': 'wpvivid_read_last_backup_log',
1045
- 'log_file_name': jsonarray.data.log_file_name
1046
- };
1047
- wpvivid_post_request(ajax_data, function (data) {
1048
- try {
1049
- var jsonarray = jQuery.parseJSON(data);
1050
- if (jsonarray.result === 'success') {
1051
- wpvivid_show_log(data);
1052
- }
1053
- else {
1054
- var div = 'Reading the log failed. Please try again.';
1055
- jQuery('#wpvivid_display_log_content').html(div);
1056
- }
1057
- }
1058
- catch(err){
1059
- alert(err);
1060
- }
1061
- }, function (XMLHttpRequest, textStatus, errorThrown) {
1062
- var div = 'Reading the log failed. Please try again.';
1063
- jQuery('#wpvivid_display_log_content').html(div);
1064
- });
1065
- }
1066
- }
1067
- }
1068
- catch(err){
1069
- alert(err);
1070
- }
1071
- }, function(XMLHttpRequest, textStatus, errorThrown) {
1072
- var div = 'Reading the log failed. Please try again.';
1073
- jQuery('#wpvivid_display_log_content').html(div);
1074
- });
1075
- }
1076
-
1077
  /**
1078
  * This function will control interface flow.
1079
  */
@@ -1088,27 +1118,6 @@ function wpvivid_interface_flow_control(){
1088
  }
1089
  });
1090
 
1091
- jQuery('#wpvivid_upload_storage_save_change').click(function(){
1092
- jQuery('#wpvivid_backup_storage_list tr').each(function(i){
1093
- jQuery(this).children('td').each(function(j){
1094
- if(j == 0){
1095
- if (jQuery(this).find("input[type=checkbox]").prop('checked')) {
1096
- if (jQuery(this).next().text() === 'FTP'){
1097
- jQuery('#wpvivid_upload_storage_type_ftp').attr('src', wpvivid_plugurl+'/images/storage-ftp.png');
1098
- }
1099
- else if(jQuery(this).next().text() === 'SFTP'){
1100
- jQuery('#wpvivid_upload_storage_type_sftp').attr('src', wpvivid_plugurl+'/images/storage-sftp.png');
1101
- }
1102
- else if(jQuery(this).next().text() === 'Amazon S3'){
1103
- jQuery('#wpvivid_upload_storage_type_amazon_s3').attr('src', wpvivid_plugurl+'/images/storage-amazon-s3.png');
1104
- }
1105
- }
1106
- }
1107
- });
1108
- });
1109
- jQuery('#wpvivid_upload_storage').hide();
1110
- });
1111
-
1112
  jQuery('#wpvivid_schedule_enable').click(function(){
1113
  if (jQuery('#wpvivid_schedule_enable').prop('checked') === true){
1114
  jQuery('#wpvivid_schedule_backup_schedule').show();
@@ -1173,7 +1182,7 @@ function wpvivid_interface_flow_control(){
1173
  }
1174
  });
1175
 
1176
- jQuery('#settings-page input[type=checkbox]:not([name=junk-files])').on("change", function(){
1177
  wpvivid_settings_changed = true;
1178
  });
1179
 
@@ -1261,7 +1270,7 @@ function wpvivid_add_notice(notice_action, notice_type, notice_msg){
1261
  else if(notice_type === "Success"){
1262
  wpvivid_clear_notice('wpvivid_backup_notice');
1263
  jQuery('#wpvivid_backup_notice').show();
1264
- var success_msg = wpvivid_completed_backup + " backup tasks have been completed. Please switch to <a href=\"#\" onclick=\"wpvivid_click_switch_page('wpvivid_tab_log', '');\">Log</a> page to check the details.\n";
1265
  div = "<div class=\"notice notice-success is-dismissible inline\"><p>" + success_msg + "</p>" +
1266
  "<button type='button' class='notice-dismiss' onclick='click_dismiss_notice(this);'>" +
1267
  "<span class='screen-reader-text'>Dismiss this notice.</span>" +
@@ -1362,38 +1371,22 @@ function wpvivid_initialize_download(backup_id){
1362
  jQuery('#wpvivid_download_loading_'+backup_id).removeClass('is-active');
1363
  if (jsonarray.result === 'success') {
1364
  jQuery('#wpvivid_file_part_' + backup_id).html("");
1365
- var download_array = new Array('backup_type', 'download_type', 'delete_button_id', 'download_button_id', 'progress_id', 'download_text_id', 'split_file_id');
1366
  var i = 0;
1367
- var file_part = "";
1368
  var file_not_found = false;
1369
  jQuery.each(jsonarray.data.type, function (index, value) {
1370
- download_array = wpvivid_get_download_info(index, download_array);
1371
  var file_name = '';
1372
- var part_num = '';
1373
  jQuery.each(value.files, function (index1, value1) {
1374
  i++;
1375
- part_num = wpvivid_prefix_integer(i);
1376
  file_name = index1;
1377
  if (value1.status === 'need_download') {
1378
- file_part = "<div style=\"float:left;margin:10px 10px 10px 0px;text-align:center; width:290px;\">" +
1379
- "<span>Part" + part_num + "</span></br>" +
1380
- "<span id=\"" + backup_id + "-text-part-" + i + "\"><a onclick=\"wpvivid_prepare_download('" + i + "', '" + backup_id + "', '" + file_name + "');\" style=\"cursor: pointer\">Prepare to Download</a></span></br>" +
1381
- "<div style=\"width:100%;height:5px; background-color:#dcdcdc;\"><div id=\"" + backup_id + "-progress-part-" + i + "\" style=\"background-color:#0085ba; float:left;width:0%;height:5px;\"></div></div>" +
1382
- "<span>size:</span><span>" + value1.size + "</span>" +
1383
- "</div>";
1384
- jQuery('#wpvivid_file_part_' + backup_id).append(file_part);
1385
  }
1386
  else if (value1.status === 'running') {
1387
  if (m_downloading_file_name === file_name) {
1388
  wpvivid_lock_download(tmp_current_click_backupid);
1389
  }
1390
- file_part = "<div style=\"float:left;margin:10px 10px 10px 0px;text-align:center; width:290px;\">" +
1391
- "<span>Part" + part_num + "</span></br>" +
1392
- "<span id=\"" + backup_id + "-text-part-" + i + "\"><a >Retriving(remote storage to web server)</a></span></br>" +
1393
- "<div style=\"width:100%;height:5px; background-color:#dcdcdc;\"><div id=\"" + backup_id + "-progress-part-" + i + "\" style=\"background-color:#0085ba; float:left;width:50%;height:5px;\"></div></div>" +
1394
- "<span>size:</span><span>" + value1.size + "</span>" +
1395
- "</div>";
1396
- jQuery('#wpvivid_file_part_' + backup_id).append(file_part);
1397
  }
1398
  else if (value1.status === 'completed') {
1399
  if (m_downloading_file_name === file_name) {
@@ -1401,28 +1394,8 @@ function wpvivid_initialize_download(backup_id){
1401
  m_downloading_id = '';
1402
  m_downloading_file_name = '';
1403
  }
1404
- file_part = "<div style=\"float:left;margin:10px 10px 10px 0px;text-align:center; width:290px;\">" +
1405
- "<span>Part" + part_num + "</span></br>" +
1406
- "<span id=\"" + backup_id + "-text-part-" + i + "\"><a onclick=\"wpvivid_download('" + backup_id + "', '" + index + "', '" + file_name + "');\" style=\"cursor: pointer\">Download</a></span></br>" +
1407
- "<div style=\"width:100%;height:5px; background-color:#dcdcdc;\"><div id=\"" + backup_id + "-progress-part-" + i + "\" style=\"background-color:#0085ba; float:left;width:100%;height:5px;\"></div></div>" +
1408
- "<span>size:</span><span>" + value1.size + "</span>" +
1409
- "</div>";
1410
- jQuery('#wpvivid_file_part_' + backup_id).append(file_part);
1411
- }
1412
- else if (value1.status === 'error') {
1413
- if (m_downloading_file_name === file_name) {
1414
- wpvivid_unlock_download(tmp_current_click_backupid);
1415
- m_downloading_id = '';
1416
- m_downloading_file_name = '';
1417
- }
1418
- alert(value1.error);
1419
- file_part = "<div style=\"float:left;margin:10px 10px 10px 0px;text-align:center; width:290px;\">" +
1420
- "<span>Part" + part_num + "</span></br>" +
1421
- "<span id=\"" + backup_id + "-text-part-" + i + "\"><a onclick=\"wpvivid_prepare_download('" + i + "', '" + backup_id + "', '" + file_name + "');\" style=\"cursor: pointer\">Prepare to Download</a></span></br>" +
1422
- "<div style=\"width:100%;height:5px; background-color:#dcdcdc;\"><div id=\"" + backup_id + "-progress-part-" + i + "\" style=\"background-color:#0085ba; float:left;width:0%;height:5px;\"></div></div>" +
1423
- "<span>size:</span><span>" + value1.size + "</span>" +
1424
- "</div>";
1425
- jQuery('#wpvivid_file_part_' + backup_id).append(file_part);
1426
  }
1427
  else if (value1.status === 'timeout') {
1428
  if (m_downloading_file_name === file_name) {
@@ -1430,34 +1403,20 @@ function wpvivid_initialize_download(backup_id){
1430
  m_downloading_id = '';
1431
  m_downloading_file_name = '';
1432
  }
1433
- file_part = "<div style=\"float:left;margin:10px 10px 10px 0px;text-align:center; width:290px;\">" +
1434
- "<span>Part" + part_num + "</span></br>" +
1435
- "<span id=\"" + backup_id + "-text-part-" + i + "\"><a onclick=\"wpvivid_prepare_download('" + i + "', '" + backup_id + "', '" + file_name + "');\" style=\"cursor: pointer\">Prepare to Download</a></span></br>" +
1436
- "<div style=\"width:100%;height:5px; background-color:#dcdcdc;\"><div id=\"" + backup_id + "-progress-part-" + i + "\" style=\"background-color:#0085ba; float:left;width:0%;height:5px;\"></div></div>" +
1437
- "<span>size:</span><span>" + value1.size + "</span>" +
1438
- "</div>";
1439
- jQuery('#wpvivid_file_part_' + backup_id).append(file_part);
1440
  }
1441
  else if (value1.status === 'file_not_found') {
1442
  wpvivid_unlock_download(tmp_current_click_backupid);
1443
  wpvivid_reset_backup_list();
1444
  file_not_found = true;
1445
  alert("Download failed, file not found. The file might has been moved, renamed or deleted. Please verify the file exists and try again.");
 
1446
  return false;
1447
  }
1448
  });
1449
  if (file_not_found === false) {
1450
- if (i % 2 !== 0) {
1451
- i++;
1452
- part_num = wpvivid_prefix_integer(i);
1453
- file_part = "<div style=\"float:left;margin:10px 10px 10px 0px;text-align:center; width:290px; color:#cccccc;\">" +
1454
- "<span>Part" + part_num + "</span></br>" +
1455
- "<span>Download</span></br>" +
1456
- "<div style=\"width:100%;height:5px; background-color:#dcdcdc;\"><div style=\"background-color:#0085ba; float:left;width:0%;height:5px;\"></div></div>" +
1457
- "<span>size:</span><span>0</span>" +
1458
- "</div>";
1459
- jQuery('#wpvivid_file_part_' + backup_id).append(file_part);
1460
- }
1461
  }
1462
  });
1463
  }
@@ -1510,98 +1469,6 @@ function wpvivid_unlock_download(backup_id){
1510
  });
1511
  }
1512
 
1513
- function wpvivid_get_download_info(type, download_array){
1514
- var backup_type;
1515
- var download_type;
1516
- var delete_button_id;
1517
- var download_button_id;
1518
- var progress_id;
1519
- var download_text_id;
1520
- var split_file_id;
1521
- switch(type){
1522
- case "backup_merge":
1523
- backup_type = "All";
1524
- download_type = "all";
1525
- delete_button_id = "wpvivid_delete_button_all";
1526
- download_button_id = "wpvivid_download_button_all";
1527
- progress_id = "tr_progress_bar_all";
1528
- download_text_id = "wpvivid_download_text_all";
1529
- split_file_id = "wpvivid_split_all";
1530
- break;
1531
- case "all":
1532
- backup_type = "All";
1533
- download_type = "all";
1534
- delete_button_id = "wpvivid_delete_button_all";
1535
- download_button_id = "wpvivid_download_button_all";
1536
- progress_id = "tr_progress_bar_all";
1537
- download_text_id = "wpvivid_download_text_all";
1538
- split_file_id = "wpvivid_split_all";
1539
- break;
1540
- case "backup_db":
1541
- backup_type = "Database";
1542
- download_type = "backup_db";
1543
- delete_button_id = "wpvivid_delete_button_db";
1544
- download_button_id = "wpvivid_download_button_db";
1545
- progress_id = "tr_progress_bar_db";
1546
- download_text_id = "wpvivid_download_text_db";
1547
- split_file_id = "wpvivid_split_db";
1548
- break;
1549
- case "backup_themes":
1550
- backup_type = "Themes";
1551
- download_type = "backup_themes";
1552
- delete_button_id = "wpvivid_delete_button_themes";
1553
- download_button_id = "wpvivid_download_button_themes";
1554
- progress_id = "tr_progress_bar_themes";
1555
- download_text_id = "wpvivid_download_text_themes";
1556
- split_file_id = "wpvivid_split_themes";
1557
- break;
1558
- case "backup_plugin":
1559
- backup_type = "Plugins";
1560
- download_type = "backup_plugin";
1561
- delete_button_id = "wpvivid_delete_button_plugin";
1562
- download_button_id = "wpvivid_download_button_plugin";
1563
- progress_id = "tr_progress_bar_plugin";
1564
- download_text_id = "wpvivid_download_text_plugin";
1565
- split_file_id = "wpvivid_split_plugin";
1566
- break;
1567
- case "backup_uploads":
1568
- backup_type = "Uploads";
1569
- download_type = "backup_uploads";
1570
- delete_button_id = "wpvivid_delete_button_uploads";
1571
- download_button_id = "wpvivid_download_button_uploads";
1572
- progress_id = "tr_progress_bar_uploads";
1573
- download_text_id = "wpvivid_download_text_uploads";
1574
- split_file_id = "wpvivid_split_uploads";
1575
- break;
1576
- case "backup_content":
1577
- backup_type = "Content";
1578
- download_type = "backup_content";
1579
- delete_button_id = "wpvivid_delete_button_content";
1580
- download_button_id = "wpvivid_download_button_content";
1581
- progress_id = "tr_progress_bar_content";
1582
- download_text_id = "wpvivid_download_text_content";
1583
- split_file_id = "wpvivid_split_content";
1584
- break;
1585
- case "backup_core":
1586
- backup_type = "Core";
1587
- download_type = "backup_core";
1588
- delete_button_id = "wpvivid_delete_button_core";
1589
- download_button_id = "wpvivid_download_button_core";
1590
- progress_id = "tr_progress_bar_core";
1591
- download_text_id = "wpvivid_download_text_core";
1592
- split_file_id = "wpvivid_split_core";
1593
- break;
1594
- }
1595
- download_array['backup_type'] = backup_type;
1596
- download_array['download_type'] = download_type;
1597
- download_array['delete_button_id'] = delete_button_id;
1598
- download_array['download_button_id'] = download_button_id;
1599
- download_array['progress_id'] = progress_id;
1600
- download_array['download_text_id'] = download_text_id;
1601
- download_array['split_file_id'] = split_file_id;
1602
- return download_array;
1603
- }
1604
-
1605
  function wpvivid_clear_notice(notice_id){
1606
  var t = document.getElementById(notice_id);
1607
  var oDiv = t.getElementsByTagName("div");
@@ -1633,16 +1500,20 @@ function wpvivid_prepare_download(part_num, backup_id, file_name){
1633
  m_need_update = true;
1634
  wpvivid_lock_download(backup_id);
1635
  m_downloading_id = backup_id;
 
1636
  m_downloading_file_name = file_name;
1637
- wpvivid_post_request(ajax_data, function(data){
1638
- }, function(XMLHttpRequest, textStatus, errorThrown) {
1639
- var error_message = wpvivid_output_ajaxerror('initializing download information', textStatus, errorThrown);
 
 
1640
  alert(error_message);
1641
  wpvivid_unlock_download(backup_id);
1642
  jQuery("#"+backup_id+"-text-part-"+part_num).html("<a onclick=\"wpvivid_prepare_download('" + part_num + "', '" + backup_id + "', '" + file_name + "');\" style=\"cursor: pointer\">Prepare to Download</a>");
1643
  jQuery("#"+backup_id+"-progress-part-"+part_num).css('width', progress);
1644
  m_downloading_id = '';
1645
  m_downloading_file_name = '';
 
1646
  }, 0);
1647
  }
1648
 
@@ -1658,77 +1529,6 @@ function wpvivid_download(backup_id, backup_type, file_name){
1658
  location.href =ajaxurl+'?action=wpvivid_download_backup&backup_id='+backup_id+'&download_type='+backup_type+'&file_name='+file_name;
1659
  }
1660
 
1661
- /**
1662
- * Verify whether the entered alias for the remote storage already exists in the list
1663
- *
1664
- * @param storage_alias - An alias for a remote storage
1665
- *
1666
- * @returns {number}
1667
- */
1668
- function wpvivid_check_repeat_storage_alias(storage_alias){
1669
- var find = 1;
1670
- jQuery('#wpvivid_remote_storage_list tr').each(function (i) {
1671
- jQuery(this).children('td').each(function (j) {
1672
- if (j == 3) {
1673
- if (jQuery(this).text() == storage_alias) {
1674
- find = -1;
1675
- return false;
1676
- }
1677
- }
1678
- });
1679
- });
1680
- return find;
1681
- }
1682
-
1683
- /**
1684
- * This function will initialize the Log information.
1685
- *
1686
- * @param backup_id - The unique ID for the backup
1687
- */
1688
- function wpvivid_initialize_log(backup_id){
1689
- jQuery('#wpvivid_tab_backup_log').show();
1690
- wpvivid_click_switch_backup_page('wpvivid_tab_backup_log');
1691
- var ajax_data={
1692
- 'action':'wpvivid_view_backup_log',
1693
- 'id':backup_id
1694
- };
1695
- wpvivid_post_request(ajax_data, function(data){
1696
- wpvivid_show_log(data);
1697
- }, function(XMLHttpRequest, textStatus, errorThrown) {
1698
- var div = "Reading the log failed. Please try again.";
1699
- jQuery('#wpvivid_display_log_content').html(div);
1700
- });
1701
- }
1702
-
1703
- /**
1704
- * This function will show the log on a text box.
1705
- *
1706
- * @param log_msg - The log message returned by server
1707
- */
1708
- function wpvivid_show_log(log_msg){
1709
- jQuery('#wpvivid_display_log_content').html("");
1710
- try {
1711
- var jsonarray = jQuery.parseJSON(log_msg);
1712
- if (jsonarray.result === "success") {
1713
- var log_data = jsonarray.data;
1714
- while (log_data.indexOf('\n') >= 0) {
1715
- var iLength = log_data.indexOf('\n');
1716
- var log = log_data.substring(0, iLength);
1717
- log_data = log_data.substring(iLength + 1);
1718
- var insert_log = "<div style=\"clear:both;\">" + log + "</div>";
1719
- jQuery('#wpvivid_display_log_content').append(insert_log);
1720
- }
1721
- }
1722
- else if (jsonarray.result === "failed") {
1723
- var div = "Reading the log failed. Please try again.";
1724
- jQuery('#wpvivid_display_log_content').html(div);
1725
- }
1726
- }
1727
- catch(err){
1728
- alert(err);
1729
- }
1730
- }
1731
-
1732
  function wpvivid_click_check_backup(backup_id){
1733
  var name = "";
1734
  var all_check = true;
@@ -1767,57 +1567,41 @@ function wpvivid_click_check_backup(backup_id){
1767
  function wpvivid_getrequest() {
1768
  switch(wpvivid_page_request){
1769
  case "backup":
1770
- wpvivid_click_switch_page('wpvivid_tab_general', '');
1771
  break;
1772
  case "settings":
1773
- wpvivid_click_switch_page('wpvivid_tab_setting', '');
1774
  break;
1775
  case "remote":
1776
- wpvivid_click_switch_page('wpvivid_tab_remote_storage', '');
1777
  break;
1778
  case "website":
1779
- wpvivid_click_switch_page('wpvivid_tab_debug', '');
1780
  break;
1781
  case "log":
1782
- wpvivid_click_switch_page('wpvivid_tab_log', '');
1783
  break;
1784
  default:
1785
- wpvivid_click_switch_page('wpvivid_tab_general', '');
1786
  break;
1787
  }
1788
  }
1789
 
1790
- function wpvivid_click_switch_page(type, page){
1791
- jQuery('.tabcontent:not(.' + type + ')').hide();
1792
- jQuery('.tabcontent.' + type).show();
1793
- jQuery('.wrap-nav-tab:not(#' + type + ')').removeClass('nav-tab-active');
1794
- jQuery('.wrap-nav-tab#' + type).addClass('nav-tab-active');
1795
- if(page !== "") {
1796
- jQuery('.storage-content:not(.' + page + ')').hide();
1797
- jQuery('.storage-content.' + page).show();
1798
- jQuery('.storage-menu:not(#' + page + ')').removeClass('storage-menu-active');
1799
- jQuery('.storage-menu#' + page).addClass('storage-menu-active');
1800
  }
1801
  }
1802
 
1803
- function wpvivid_close_tab(event, type){
1804
  event.stopPropagation();
1805
- if(type === 'log'){
1806
- jQuery('#wpvivid_tab_backup_log').hide();
1807
- }
1808
- else if(type === 'restore'){
1809
- jQuery('#wpvivid_tab_restore').hide();
1810
- }
1811
- wpvivid_click_switch_backup_page('wpvivid_tab_backup');
1812
- }
1813
-
1814
- function wpvivid_click_switch_backup_page(type){
1815
- jQuery('.table-list-content:not(.' + type + ')').hide();
1816
- jQuery('.table-list-content.' + type).show();
1817
- jQuery('.table-nav-tab:not(#' + type + ')').removeClass('nav-tab-active');
1818
- jQuery('.table-nav-tab#' + type).addClass('nav-tab-active');
1819
- var top = jQuery('#'+type).offset().top-jQuery('#'+type).height();
1820
- jQuery('html, body').animate({scrollTop:top}, 'slow');
1821
  }
1822
 
1823
  /**
@@ -1830,30 +1614,10 @@ function wpvivid_retrieve_log_list(){
1830
  wpvivid_post_request(ajax_data, function(data){
1831
  try {
1832
  var jsonarray = jQuery.parseJSON(data);
1833
- jQuery('#wpvivid_loglist').html("");
1834
  if (jsonarray.result === "success") {
1835
- var log_count = 0;
1836
- jQuery.each(jsonarray.data.log_list.file, function (index, value) {
1837
- var log_time = value.time;
1838
- if (log_time === "") {
1839
- log_time = "N/A";
1840
- }
1841
- var log_des = value.des;
1842
- if (log_des === "") {
1843
- log_des = "N/A";
1844
- }
1845
- var log_tr = "<tr>" +
1846
- "<td class=\"row-title\"><label for=\"tablecell\">" + log_time + "</label></td>" +
1847
- "<td>" + log_des + "</td>" +
1848
- "<td>" + value.file_name + "</td>" +
1849
- "<td><a onclick='wpvivid_view_log(\"" + log_count + "\");' style=\"cursor:pointer;\" ><img src=\"" + wpvivid_plugurl + "/images/Log.png\" style=\"vertical-align:middle;\">Log</a></td>" +
1850
- "<td id=\"" + log_count + "\" style='display: none'>" + value.path + "</td>"
1851
- "</tr>";
1852
- var log_table = jQuery('#wpvivid_loglist');
1853
- log_table.append(log_tr);
1854
- log_count++;
1855
- });
1856
- wpvivid_log_count = log_count;
1857
  wpvivid_display_log_page();
1858
  }
1859
  }
@@ -1867,91 +1631,22 @@ function wpvivid_retrieve_log_list(){
1867
  });
1868
  }
1869
 
1870
- function wpvivid_view_log(num){
1871
- jQuery('#wpvivid_read_log_content').html("");
1872
- var log_path = '';
1873
- jQuery('#wpvivid_loglist tr').each(function(i){
1874
- jQuery(this).children('td').each(function (j) {
1875
- if (j == 4) {
1876
- var id = jQuery(this).attr("id");
1877
- if(id === num){
1878
- log_path = jQuery(this).text();
1879
- }
1880
- }
1881
- });
1882
- });
1883
- wpvivid_click_switch_page('wpvivid_tab_read_log', '');
1884
- jQuery('#wpvivid_tab_read_log').show();
1885
- if(log_path !== "") {
1886
- var ajax_data = {
1887
- 'action': 'wpvivid_view_log',
1888
- 'path': log_path
1889
- };
1890
- wpvivid_post_request(ajax_data, function (data) {
1891
- try {
1892
- var jsonarray = jQuery.parseJSON(data);
1893
- jQuery('#wpvivid_read_log_content').html("");
1894
- if (jsonarray.result === "success") {
1895
- var log_data = jsonarray.data;
1896
- while (log_data.indexOf('\n') >= 0) {
1897
- var iLength = log_data.indexOf('\n');
1898
- var log = log_data.substring(0, iLength);
1899
- log_data = log_data.substring(iLength + 1);
1900
- var insert_log = "<div style=\"clear:both;\">" + log + "</div>";
1901
- jQuery('#wpvivid_read_log_content').append(insert_log);
1902
- }
1903
- }
1904
- else if (jsonarray.result === "failed") {
1905
- var div = "Reading the log failed. Please try again.";
1906
- jQuery('#wpvivid_read_log_content').html(div);
1907
- }
1908
- }
1909
- catch(err){
1910
- alert(err);
1911
- }
1912
- }, function (XMLHttpRequest, textStatus, errorThrown) {
1913
- var div = "Reading the log failed. Please try again.";
1914
- jQuery('#wpvivid_read_log_content').html(div);
1915
- });
1916
- }
1917
- else{
1918
- var div = "Reading the log failed. Please try again.";
1919
- jQuery('#wpvivid_read_log_content').html(div);
1920
- }
1921
- }
1922
-
1923
  /**
1924
  * Set a default remote storage for backups.
1925
  */
1926
  function wpvivid_set_default_remote_storage(){
1927
- var has_checked = false;
1928
- jQuery('#wpvivid_remote_storage_list tr').each(function (i) {
1929
- jQuery(this).children('td').each(function (j) {
1930
- if (j === 1) {
1931
- if (jQuery(this).find("input[type=checkbox]").prop('checked') === true) {
1932
- has_checked = true;
1933
- }
1934
- }
1935
- });
 
 
1936
  });
1937
- if(has_checked === true){
1938
- var remote_storage = new Array();
1939
- remote_storage[0] = jQuery("input[name='remote_storage']:checked").val();
1940
- var remote_storage_type = jQuery("input[name='remote_storage']:checked").parent().next().text();
1941
- var ajax_data = {
1942
- 'action': 'wpvivid_set_default_remote_storage',
1943
- 'remote_storage': remote_storage
1944
- };
1945
- wpvivid_post_request(ajax_data, function(data){
1946
- wpvivid_handle_remote_storage_data(data);
1947
- }, function(XMLHttpRequest, textStatus, errorThrown) {
1948
- var error_message = wpvivid_output_ajaxerror('setting up the default remote storage', textStatus, errorThrown);
1949
- alert(error_message);
1950
- });
1951
- }
1952
- else{
1953
- alert("Choose one storage from the list to be the default storage.");
1954
- }
1955
  }
1956
 
1957
  function wpvivid_pre_log_page(){
@@ -2015,33 +1710,18 @@ function wpvivid_set_backup_lock(backup_id, lock_status){
2015
  catch(err){
2016
  alert(err);
2017
  }
2018
-
2019
- //wpvivid_handle_backup_data(data);
2020
  }, function(XMLHttpRequest, textStatus, errorThrown) {
2021
  var error_message = wpvivid_output_ajaxerror('setting up a lock for the backup', textStatus, errorThrown);
2022
  alert(error_message);
2023
  });
2024
  }
2025
 
2026
- function wpvivid_close_main_tab(event, type){
2027
- event.stopPropagation();
2028
- if(type === 'log'){
2029
- jQuery('#wpvivid_tab_read_log').hide();
2030
- wpvivid_click_switch_page('wpvivid_tab_log', '');
2031
- }
2032
- else if(type === 'custom'){
2033
- jQuery('#wpvivid_tab_custom_backup').hide();
2034
- wpvivid_click_switch_page('wpvivid_tab_general', '');
2035
- }
2036
- }
2037
-
2038
-
2039
  function wpvivid_initialize_restore(backup_id, backup_time){
2040
  jQuery('#wpvivid_restore_backup_time').html(backup_time);
2041
  m_restore_backup_id = backup_id;
2042
  jQuery('#wpvivid_restore_log').html("");
2043
  jQuery('#wpvivid_tab_restore').show();
2044
- wpvivid_click_switch_backup_page('wpvivid_tab_restore');
2045
  wpvivid_init_restore_data();
2046
  }
2047
 
@@ -2129,13 +1809,14 @@ function wpvivid_prepare_restore(){
2129
  wpvivid_restore();
2130
  }
2131
  else if (jsonarray.result === "need_download") {
 
2132
  var download_array = new Array();
2133
  var download_num = 0;
2134
  var start_download_num = 0;
2135
  wpvivid_display_restore_msg("Backup is not found on web server. Prepare to download it from remote storage.");
2136
  jQuery.each(jsonarray.files, function (index, value) {
2137
  if (value.status === "need_download") {
2138
- download_array[download_num] = new Array('file_name', 'file_size');
2139
  download_array[download_num]['file_name'] = index;
2140
  download_array[download_num]['file_size'] = value.size;
2141
  download_array[download_num]['md5'] = value.md5;
@@ -2167,7 +1848,7 @@ function wpvivid_download_restore_file(download_array, download_num, start_downl
2167
  'backup_id': m_restore_backup_id,
2168
  'file_name': download_array[start_download_num]['file_name'],
2169
  'file_size': download_array[start_download_num]['file_size'],
2170
- 'md5': download_array[download_num]['md5']
2171
  }
2172
  wpvivid_post_request(ajax_data, function (data) {
2173
  wpvivid_display_restore_msg("Download restore file " + download_array[start_download_num]['file_name'] + " completed.");
@@ -2182,6 +1863,7 @@ function wpvivid_download_restore_file(download_array, download_num, start_downl
2182
  jQuery('#wpvivid_rollback_btn').hide();
2183
  var error_message = wpvivid_output_ajaxerror('downloading backups', textStatus, errorThrown);
2184
  wpvivid_display_restore_msg(error_message);
 
2185
  });
2186
  }
2187
  else{
@@ -2561,74 +2243,43 @@ function wpvivid_calculate_diskspaceused(){
2561
  * Clean junk files created during backups and restorations off your web server disk.
2562
  */
2563
  function wpvivid_clean_junk_files(){
2564
- var log = "0";
2565
- var backup_cache = "0";
2566
- var junk_files = "0";
2567
- var old_files = "0";
2568
- if(jQuery('input[name="junk-files"][value="junk-log"]').prop('checked') === true)
2569
- {
2570
- log = "1";
2571
- }
2572
- if(jQuery('input[name="junk-files"][value="junk-backup-cache"]').prop('checked') === true)
2573
- {
2574
- backup_cache = "1";
2575
- }
2576
- if(jQuery('input[name="junk-files"][value="junk-files"]').prop('checked') === true)
2577
- {
2578
- junk_files = "1";
2579
- }
2580
- if(jQuery('input[name="junk-files"][value="junk-temporary-files"]').prop('checked') === true)
2581
- {
2582
- old_files = "1";
2583
- }
2584
- if(log === "0" && backup_cache === "0" && junk_files === "0" && old_files === "0"){
2585
- alert("Choose at least one type of junk files for deleting.");
2586
- }
2587
- else {
2588
- var descript = 'The selected item(s) will be permanently deleted. Are you sure you want to continue?';
2589
- var ret = confirm(descript);
2590
- if(ret === true){
2591
- var options = {
2592
- "log": log,
2593
- 'backup_cache': backup_cache,
2594
- 'junk_files': junk_files,
2595
- 'old_files': old_files
2596
- };
2597
- var json = JSON.stringify(options);
2598
- var ajax_data = {
2599
- 'action': 'wpvivid_clean_local_storage',
2600
- 'options': json
2601
- };
2602
- jQuery('#wpvivid_calculate_size').css({'pointer-events': 'none', 'opacity': '0.4'});
2603
- jQuery('#wpvivid_clean_junk_file').css({'pointer-events': 'none', 'opacity': '0.4'});
2604
- wpvivid_post_request(ajax_data, function (data) {
2605
- jQuery('#wpvivid_calculate_size').css({'pointer-events': 'auto', 'opacity': '1'});
2606
- jQuery('#wpvivid_clean_junk_file').css({'pointer-events': 'auto', 'opacity': '1'});
2607
- jQuery('input[name="junk-files"][value="junk-log"]').prop('checked', false);
2608
- jQuery('input[name="junk-files"][value="junk-backup-cache"]').prop('checked', false);
2609
- jQuery('input[name="junk-files"][value="junk-files"]').prop('checked', false);
2610
- jQuery('input[name="junk-files"][value="junk-temporary-files"]').prop('checked', false);
2611
- alert("The selected junk flies have been deleted.");
2612
- try {
2613
- var jsonarray = jQuery.parseJSON(data);
2614
- if (jsonarray.result === "success") {
2615
- jQuery('#wpvivid_junk_sum_size').html(jsonarray.data.sum_size);
2616
- jQuery('#wpvivid_junk_log_path').html(jsonarray.data.log_path);
2617
- jQuery('#wpvivid_junk_file_path').html(jsonarray.data.junk_path);
2618
- jQuery('#wpvivid_restore_temp_file_path').html(jsonarray.data.old_files_path);
2619
- }
2620
- wpvivid_retrieve_log_list();
2621
- }
2622
- catch(err){
2623
- alert(err);
2624
  }
2625
- }, function (XMLHttpRequest, textStatus, errorThrown) {
2626
- var error_message = wpvivid_output_ajaxerror('cleaning out junk files', textStatus, errorThrown);
2627
- alert(error_message);
2628
- jQuery('#wpvivid_calculate_size').css({'pointer-events': 'auto', 'opacity': '1'});
2629
- jQuery('#wpvivid_clean_junk_file').css({'pointer-events': 'auto', 'opacity': '1'});
2630
- });
2631
- }
 
 
 
2632
  }
2633
  }
2634
 
@@ -2655,23 +2306,6 @@ function wpvivid_output_ajaxerror(action, textStatus, errorThrown){
2655
  return error_msg;
2656
  }
2657
 
2658
- function wpvivid_prefix_integer(num) {
2659
- var num_length = num.toString().length;
2660
- if(num_length < 2) num_length = 2;
2661
- return (Array(num_length).join('0') + num).slice(-num_length);
2662
- }
2663
-
2664
- function wpvivid_add_review_info(action){
2665
- var ajax_data={
2666
- 'action': 'wpvivid_need_review',
2667
- 'review': action
2668
- };
2669
- jQuery('#wpvivid_notice_rate').hide();
2670
- wpvivid_post_request(ajax_data, function(data){
2671
- }, function(XMLHttpRequest, textStatus, errorThrown) {
2672
- });
2673
- }
2674
-
2675
  function wpvivid_ajax_data_transfer(data_type){
2676
  var json = {};
2677
  jQuery('input:checkbox[option='+data_type+']').each(function() {
@@ -2685,8 +2319,7 @@ function wpvivid_ajax_data_transfer(data_type){
2685
  }
2686
  json[key]=value;
2687
  });
2688
- jQuery('input:radio[option='+data_type+']').each(function()
2689
- {
2690
  if(jQuery(this).prop('checked'))
2691
  {
2692
  var key = jQuery(this).prop('name');
12
  var wpvivid_prepare_backup=false;
13
  var wpvivid_restoring=false;
14
  var wpvivid_location_href=false;
15
+ var wpvivid_editing_storage_id = '';
16
+ var wpvivid_editing_storage_type = '';
17
 
18
  (function ($) {
19
  'use strict';
66
 
67
  $('input[option=add-remote]').click(function(){
68
  var storage_type = $(".storage-providers-active").attr("remote_type");
69
+ wpvivid_add_remote_storage(storage_type);
70
  wpvivid_settings_changed = false;
71
  });
72
 
73
+ $('input[option=edit-remote]').click(function(){
74
+ wpvivid_edit_remote_storage();
75
+ });
76
+
77
  $('#backup_list_all_check').click(function(){
78
  var name = '';
79
  if($('#backup_list_all_check').prop('checked')) {
102
  }
103
  });
104
 
 
 
 
 
105
  $('#wpvivid_backup_cancel_btn').click(function(){
106
  wpvivid_cancel_backup();
107
  });
108
 
109
  $('#wpvivid_backup_log_btn').click(function(){
110
+ wpvivid_read_log('wpvivid_view_backup_task_log');
111
  });
112
 
113
  $('#wpvivid_send_email_test').click(function(){
122
  wpvivid_import_settings();
123
  });
124
 
 
 
 
 
125
  $('#wpvivid_set_default_remote_storage').click(function(){
126
  wpvivid_set_default_remote_storage();
127
  wpvivid_settings_changed = false;
235
  if (jsonarray.backup.result === 'success') {
236
  wpvivid_prepare_backup = false;
237
  jQuery.each(jsonarray.backup.data, function (index, value) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  if (value.status.str === 'ready') {
239
+ jQuery('#wpvivid_postbox_backup_percent').html(value.progress_html);
 
 
240
  m_need_update = true;
241
  }
242
  else if (value.status.str === 'running') {
243
  running_backup_taskid = index;
244
  jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
245
  jQuery('#wpvivid_postbox_backup_percent').show();
246
+ jQuery('#wpvivid_postbox_backup_percent').html(value.progress_html);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  m_need_update = true;
248
  }
249
  else if (value.status.str === 'wait_resume') {
 
 
 
250
  jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
251
  jQuery('#wpvivid_postbox_backup_percent').show();
252
+ jQuery('#wpvivid_postbox_backup_percent').html(value.progress_html);
 
 
 
 
 
 
 
 
 
253
  if (value.data.next_resume_time !== 'get next resume time failed.') {
254
  wpvivid_resume_backup(index, value.data.next_resume_time);
255
  }
259
  }
260
  }
261
  else if (value.status.str === 'no_responds') {
 
 
262
  running_backup_taskid = index;
263
  jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
264
  jQuery('#wpvivid_postbox_backup_percent').show();
265
+ jQuery('#wpvivid_postbox_backup_percent').html(value.progress_html);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  m_need_update = true;
267
  }
268
  else if (value.status.str === 'completed') {
269
+ jQuery('#wpvivid_postbox_backup_percent').html(value.progress_html);
 
270
  var info = 'Task ' + index + ' completed.';
271
  wpvivid_add_notice('Backup', 'Success', info);
272
  jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'auto', 'opacity': '1'});
273
  jQuery('#wpvivid_postbox_backup_percent').hide();
274
+ jQuery('#wpvivid_backuplist').html('');
275
+ jQuery('#wpvivid_backuplist').append(value.backuplist_html);
276
+ jQuery('#wpvivid_last_backup_msg').html(jsonarray.last_msg_html);
277
+ jQuery('#wpvivid_loglist').html("");
278
+ jQuery('#wpvivid_loglist').append(jsonarray.log_html);
279
+ wpvivid_log_count = jsonarray.log_count;
280
+ wpvivid_display_log_page();
281
  wpvivid_delete_backup_task(index);
282
  }
283
  else if (value.status.str === 'error') {
284
+ jQuery('#wpvivid_postbox_backup_percent').html(value.progress_html);
 
285
  var info = 'Backup error: ' + value.status.error + ', task id: ' + index;
286
  wpvivid_add_notice('Backup', 'Error', info);
287
  jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'auto', 'opacity': '1'});
288
  jQuery('#wpvivid_postbox_backup_percent').hide();
289
+ jQuery('#wpvivid_backuplist').html('');
290
+ jQuery('#wpvivid_backuplist').append(value.backuplist_html);
291
+ jQuery('#wpvivid_last_backup_msg').html(jsonarray.last_msg_html);
292
+ jQuery('#wpvivid_loglist').html("");
293
+ jQuery('#wpvivid_loglist').append(jsonarray.log_html);
294
  wpvivid_delete_backup_task(index);
295
  }
296
  });
304
  jQuery('#wpvivid_backup_log_btn').css({'pointer-events': 'auto', 'opacity': '1'});
305
  jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'auto', 'opacity': '1'});
306
  jQuery('#wpvivid_postbox_backup_percent').hide();
307
+ wpvivid_retrieve_backup_list();
308
  wpvivid_retrieve_last_backup_message();
309
  wpvivid_retrieve_log_list();
310
  running_backup_taskid='';
311
  }
 
312
  }
313
  if (jsonarray.download.data.length !== 0) {
314
  b_has_data = true;
315
  task_retry_times = 0;
 
316
  var i = 0;
 
317
  jQuery.each(jsonarray.download.data.type, function (index, value) {
 
318
  var file_name = '';
319
+ jQuery('#wpvivid_file_part_' + tmp_current_click_backupid).html("");
320
+ var b_download_finish=false;
321
  jQuery.each(value.files, function (index1, value1) {
322
  i++;
 
323
  file_name = index1;
324
  var progress = '0%';
325
  if (value1.status === 'need_download') {
 
 
326
  if (m_downloading_file_name === file_name) {
327
  m_need_update = true;
328
  }
329
+ jQuery('#wpvivid_file_part_' + tmp_current_click_backupid).append(value1.html);
330
+ b_download_finish=true;
331
  }
332
  else if (value1.status === 'running') {
333
  if (m_downloading_file_name === file_name) {
334
  wpvivid_lock_download(tmp_current_click_backupid);
335
  }
 
 
 
336
  m_need_update = true;
337
+ jQuery('#wpvivid_file_part_' + tmp_current_click_backupid).append(value1.html);
338
+ b_download_finish=false;
339
  }
340
  else if (value1.status === 'completed') {
341
  if (m_downloading_file_name === file_name) {
343
  m_downloading_id = '';
344
  m_downloading_file_name = '';
345
  }
346
+ jQuery('#wpvivid_file_part_' + tmp_current_click_backupid).append(value1.html);
347
+ b_download_finish=true;
 
348
  }
349
  else if (value1.status === 'error') {
350
  if (m_downloading_file_name === file_name) {
353
  m_downloading_file_name = '';
354
  }
355
  alert(value1.error);
356
+ jQuery('#wpvivid_file_part_' + tmp_current_click_backupid).append(value1.html);
357
+ b_download_finish=true;
 
358
  }
359
  else if (value1.stauts === 'timeout') {
360
  if (m_downloading_file_name === file_name) {
363
  m_downloading_file_name = '';
364
  }
365
  alert('Download timeout, please retry.');
366
+ jQuery('#wpvivid_file_part_' + tmp_current_click_backupid).append(value1.html);
367
+ b_download_finish=true;
 
368
  }
369
  });
370
+ jQuery('#wpvivid_file_part_' + tmp_current_click_backupid).append(value.place_html);
371
+ if(b_download_finish==true){
372
+ tmp_current_click_backupid = '';
373
+ }
374
  });
375
  }
376
  if (!b_has_data) {
403
  'task_id': running_backup_taskid
404
  };
405
  jQuery('#wpvivid_backup_cancel_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
 
406
  wpvivid_post_request(ajax_data, function(data){
407
+ try {
408
+ var jsonarray = jQuery.parseJSON(data);
409
+ jQuery('#wpvivid_current_doing').html(jsonarray.msg);
410
+ }
411
+ catch(err){
412
+ alert(err);
413
+ }
414
  }, function(XMLHttpRequest, textStatus, errorThrown) {
415
  jQuery('#wpvivid_backup_cancel_btn').css({'pointer-events': 'auto', 'opacity': '1'});
416
  var error_message = wpvivid_output_ajaxerror('cancelling the backup', textStatus, errorThrown);
418
  });
419
  }
420
 
421
+ function wpvivid_read_log(action, param){
422
+ var tab_id = '';
423
+ var content_id = '';
424
+ var ajax_data = '';
425
+ var show_page = '';
426
+ if(typeof param === 'undefined') param = '';
427
+ switch(action){
428
+ case 'wpvivid_view_backup_task_log':
429
+ ajax_data = {
430
+ 'action':action,
431
+ 'id':running_backup_taskid
432
+ };
433
+ tab_id = 'wpvivid_tab_backup_log';
434
+ content_id = 'wpvivid_display_log_content';
435
+ show_page = 'backup_page';
436
+ break;
437
+ case 'wpvivid_read_last_backup_log':
438
+ var ajax_data = {
439
+ 'action': action,
440
+ 'log_file_name': param
441
+ };
442
+ tab_id = 'wpvivid_tab_backup_log';
443
+ content_id = 'wpvivid_display_log_content';
444
+ show_page = 'backup_page';
445
+ break;
446
+ case 'wpvivid_view_backup_log':
447
+ var ajax_data={
448
+ 'action':action,
449
+ 'id':param
450
+ };
451
+ tab_id = 'wpvivid_tab_backup_log';
452
+ content_id = 'wpvivid_display_log_content';
453
+ show_page = 'backup_page';
454
+ break;
455
+ case 'wpvivid_view_log':
456
+ var ajax_data={
457
+ 'action':action,
458
+ 'path':param
459
+ };
460
+ tab_id = 'wpvivid_tab_read_log';
461
+ content_id = 'wpvivid_read_log_content';
462
+ show_page = 'log_page';
463
+ break;
464
+ default:
465
+ break;
466
+ }
467
+ jQuery('#'+tab_id).show();
468
+ jQuery('#'+content_id).html("");
469
+ if(show_page === 'backup_page'){
470
+ //wpvivid_click_switch_backup_page(tab_id);
471
+ wpvivid_click_switch_page('backup', tab_id, true);
472
+ }
473
+ else if(show_page === 'log_page') {
474
+ wpvivid_click_switch_page('wrap', tab_id, true);
475
+ }
476
  wpvivid_post_request(ajax_data, function(data){
477
+ wpvivid_show_log(data, content_id);
478
  }, function(XMLHttpRequest, textStatus, errorThrown) {
479
  var div = 'Reading the log failed. Please try again.';
480
  jQuery('#wpvivid_display_log_content').html(div);
481
  });
482
  }
483
 
484
+ /**
485
+ * This function will show the log on a text box.
486
+ *
487
+ * @param data - The log message returned by server
488
+ */
489
+ function wpvivid_show_log(data, content_id){
490
+ jQuery('#'+content_id).html("");
491
+ try {
492
+ var jsonarray = jQuery.parseJSON(data);
493
+ if (jsonarray.result === "success") {
494
+ var log_data = jsonarray.data;
495
+ while (log_data.indexOf('\n') >= 0) {
496
+ var iLength = log_data.indexOf('\n');
497
+ var log = log_data.substring(0, iLength);
498
+ log_data = log_data.substring(iLength + 1);
499
+ var insert_log = "<div style=\"clear:both;\">" + log + "</div>";
500
+ jQuery('#'+content_id).append(insert_log);
501
+ }
502
+ }
503
+ else if (jsonarray.result === "failed") {
504
+ jQuery('#'+content_id).html(jsonarray.error);
505
+ }
506
+ }
507
+ catch(err){
508
+ alert(err);
509
+ var div = "Reading the log failed. Please try again.";
510
+ jQuery('#'+content_id).html(div);
511
+ }
512
+ }
513
+
514
  /**
515
  * Start backing up
516
  */
558
  }
559
  m_backup_task_id = jsonarray.task_id;
560
  if (jsonarray.check.alert_db === false && jsonarray.check.alter_files === false && jsonarray.check.alter_fcgi === false) {
561
+ jQuery('#wpvivid_backuplist').html('');
562
+ jQuery('#wpvivid_backuplist').append(jsonarray.html);
563
  wpvivid_backup_now(jsonarray.task_id);
564
  }
565
  else {
570
  'Click OK button and continue to back up.';
571
  var ret = confirm(descript);
572
  if (ret === true) {
573
+ jQuery('#wpvivid_backuplist').html('');
574
+ jQuery('#wpvivid_backuplist').append(jsonarray.html);
575
  wpvivid_backup_now(m_backup_task_id);
576
  }
577
  else {
624
  *
625
  * @param backup_id - A unique ID for a backup
626
  */
627
+ /*function wpvivid_delete_selected_backup(backup_id){
628
  var name = '';
629
  jQuery('#wpvivid_backuplist tr').each(function(i){
630
  jQuery(this).children('td').each(function (j) {
669
  alert(error_message);
670
  });
671
  }
672
+ }*/
673
 
674
  /**
675
  * Delete multiple backups in one operation
676
  */
677
+ /*function wpvivid_delete_backups_inbatches(){
678
  var delete_backup_array = new Array();
679
  var count = 0;
680
  var bdownloading = false;
720
  });
721
  }
722
  }
723
+ }*/
724
 
725
  /**
726
  * Resume the backup task automatically in 1 minute in a timeout situation
750
  wpvivid_post_request(ajax_data, function(data){
751
  try {
752
  var jsonarray = jQuery.parseJSON(data);
753
+ jQuery('#wpvivid_last_backup_msg').html(jsonarray.data);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
754
  }
755
  catch(err){
756
  alert(err);
767
  * @param action - The action to add or test a remote storage
768
  * @param storage_type - Remote storage types (Amazon S3, SFTP and FTP server)
769
  */
770
+ function wpvivid_add_remote_storage(storage_type)
771
  {
772
+ var remote_from = wpvivid_ajax_data_transfer(storage_type);
773
+ var ajax_data;
774
+ ajax_data = {
775
+ 'action': 'wpvivid_add_remote',
776
+ 'remote': remote_from,
777
+ 'type': storage_type
778
+ };
779
+ jQuery('input[option=add-remote]').css({'pointer-events': 'nano', 'opacity': '0.4'});
780
+ wpvivid_post_request(ajax_data, function (data)
781
+ {
782
+ try
783
+ {
784
+ var jsonarray = jQuery.parseJSON(data);
785
+ if (jsonarray.result === 'success')
786
+ {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
787
  jQuery('input[option=add-remote]').css({'pointer-events': 'auto', 'opacity': '1'});
788
  jQuery('input:text[option='+storage_type+']').each(function(){
789
  jQuery(this).val('');
793
  });
794
  wpvivid_handle_remote_storage_data(data);
795
  }
796
+ else if (jsonarray.result === 'failed')
797
+ {
798
+ alert(jsonarray.error);
799
+ jQuery('input[option=add-remote]').css({'pointer-events': 'auto', 'opacity': '1'});
 
 
 
800
  }
801
+ }
802
+ catch (err)
803
+ {
804
+ alert(err);
805
+ jQuery('input[option=add-remote]').css({'pointer-events': 'auto', 'opacity': '1'});
806
+ }
807
+
808
+ }, function (XMLHttpRequest, textStatus, errorThrown)
809
+ {
810
+ jQuery('input[option=add-remote]').css({'pointer-events': 'auto', 'opacity': '1'});
811
+ if (action === 'wpvivid_test_remote_connection')
812
+ {
813
+ var error_message = wpvivid_output_ajaxerror('testing the remote storage connection', textStatus, errorThrown);
814
+ }
815
+ else if (action === 'wpvivid_add_remote')
816
+ {
817
+ var error_message = wpvivid_output_ajaxerror('adding the remote storage', textStatus, errorThrown);
818
+ }
819
+ alert(error_message);
820
+ });
821
  }
822
 
823
  function wpvivid_handle_remote_storage_data(data){
841
  }
842
  }
843
 
844
+ function click_retrieve_remote_storage(id,type,name)
845
+ {
846
+ wpvivid_editing_storage_id = id;
847
+ jQuery('.remote-storage-edit').hide();
848
+ jQuery('#wpvivid_tab_storage_edit').show();
849
+ jQuery('#wpvivid_tab_storage_edit_text').html(name);
850
+ wpvivid_editing_storage_type=type;
851
+ jQuery('#remote_storage_edit_'+wpvivid_editing_storage_type).fadeIn();
852
+ wpvivid_click_switch_page('storage', 'wpvivid_tab_storage_edit', true);
853
+
854
+ var ajax_data = {
855
+ 'action': 'wpvivid_retrieve_remote',
856
+ 'remote_id': id
857
+ };
858
+ wpvivid_post_request(ajax_data, function(data)
859
+ {
860
+ try
861
+ {
862
+ var jsonarray = jQuery.parseJSON(data);
863
+ if (jsonarray.result === 'success')
864
+ {
865
+ jQuery('input:text[option=edit-'+jsonarray.type+']').each(function(){
866
+ var key = jQuery(this).prop('name');
867
+ jQuery(this).val(jsonarray[key]);
868
+ });
869
+ jQuery('input:password[option=edit-'+jsonarray.type+']').each(function(){
870
+ var key = jQuery(this).prop('name');
871
+ jQuery(this).val(jsonarray[key]);
872
+ });
873
+ jQuery('input:checkbox[option=edit-'+jsonarray.type+']').each(function() {
874
+ var key = jQuery(this).prop('name');
875
+ var value;
876
+ if(jsonarray[key] == '0'){
877
+ value = false;
878
+ }
879
+ else{
880
+ value = true;
881
+ }
882
+ jQuery(this).prop('checked', value);
883
+ });
884
+ }
885
+ else
886
+ {
887
+ alert(jsonarray.error);
888
+ }
889
+ }
890
+ catch(err)
891
+ {
892
+ alert(err);
893
+ }
894
+ },function(XMLHttpRequest, textStatus, errorThrown)
895
+ {
896
+ var error_message = wpvivid_output_ajaxerror('retrieving the remote storage', textStatus, errorThrown);
897
+ alert(error_message);
898
+ });
899
+ }
900
+
901
+ function wpvivid_edit_remote_storage() {
902
+ var data_tran = 'edit-'+wpvivid_editing_storage_type;
903
+ var remote_data = wpvivid_ajax_data_transfer(data_tran);
904
+ var ajax_data;
905
+ ajax_data = {
906
+ 'action': 'wpvivid_edit_remote',
907
+ 'remote': remote_data,
908
+ 'id': wpvivid_editing_storage_id,
909
+ 'type': wpvivid_editing_storage_type
910
+ };
911
+ wpvivid_post_request(ajax_data, function(data){
912
+ try {
913
+ var jsonarray = jQuery.parseJSON(data);
914
+ if (jsonarray.result === 'success') {
915
+ jQuery('#wpvivid_tab_storage_edit').hide();
916
+ wpvivid_click_switch_page('storage', 'wpvivid_tab_storage_list', true);
917
+ wpvivid_handle_remote_storage_data(data);
918
+ }
919
+ else if (jsonarray.result === 'failed') {
920
+ alert(jsonarray.error);
921
+ }
922
+ }
923
+ catch(err){
924
+ alert(err);
925
+ }
926
+ },function(XMLHttpRequest, textStatus, errorThrown) {
927
+ var error_message = wpvivid_output_ajaxerror('editing the remote storage', textStatus, errorThrown);
928
+ alert(error_message);
929
+ });
930
+ }
931
+
932
  /*
933
  * Delete the selected remote storage from the list
934
  *
940
  if(ret === true){
941
  var ajax_data = {
942
  'action': 'wpvivid_delete_remote',
943
+ 'remote_id': storage_id
944
  };
945
  wpvivid_post_request(ajax_data, function(data){
946
  wpvivid_handle_remote_storage_data(data);
959
  'action': 'wpvivid_get_backup_list'
960
  };
961
  wpvivid_post_request(ajax_data, function(data){
962
+ try {
963
+ var jsonarray = jQuery.parseJSON(data);
964
+ if (jsonarray.result === 'success') {
965
+ jQuery('#wpvivid_backuplist').html('');
966
+ jQuery('#wpvivid_backuplist').append(jsonarray.html);
967
+ }
968
+ }
969
+ catch(err){
970
+ alert(err);
971
+ }
972
  },function(XMLHttpRequest, textStatus, errorThrown) {
973
  setTimeout(function () {
974
  wpvivid_retrieve_backup_list();
977
  }
978
 
979
  function wpvivid_handle_backup_data(data){
 
980
  try {
981
  var jsonarray = jQuery.parseJSON(data);
982
  if (jsonarray.result === 'success') {
1104
  }
1105
  }
1106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1107
  /**
1108
  * This function will control interface flow.
1109
  */
1118
  }
1119
  });
1120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1121
  jQuery('#wpvivid_schedule_enable').click(function(){
1122
  if (jQuery('#wpvivid_schedule_enable').prop('checked') === true){
1123
  jQuery('#wpvivid_schedule_backup_schedule').show();
1182
  }
1183
  });
1184
 
1185
+ jQuery('#settings-page input[type=checkbox]:not([option=junk-files])').on("change", function(){
1186
  wpvivid_settings_changed = true;
1187
  });
1188
 
1270
  else if(notice_type === "Success"){
1271
  wpvivid_clear_notice('wpvivid_backup_notice');
1272
  jQuery('#wpvivid_backup_notice').show();
1273
+ var success_msg = wpvivid_completed_backup + " backup tasks have been completed. Please switch to <a href=\"#\" onclick=\"wpvivid_click_switch_page('wrap', 'wpvivid_tab_log', true);\">Log</a> page to check the details.\n";
1274
  div = "<div class=\"notice notice-success is-dismissible inline\"><p>" + success_msg + "</p>" +
1275
  "<button type='button' class='notice-dismiss' onclick='click_dismiss_notice(this);'>" +
1276
  "<span class='screen-reader-text'>Dismiss this notice.</span>" +
1371
  jQuery('#wpvivid_download_loading_'+backup_id).removeClass('is-active');
1372
  if (jsonarray.result === 'success') {
1373
  jQuery('#wpvivid_file_part_' + backup_id).html("");
 
1374
  var i = 0;
 
1375
  var file_not_found = false;
1376
  jQuery.each(jsonarray.data.type, function (index, value) {
 
1377
  var file_name = '';
 
1378
  jQuery.each(value.files, function (index1, value1) {
1379
  i++;
 
1380
  file_name = index1;
1381
  if (value1.status === 'need_download') {
1382
+ jQuery('#wpvivid_file_part_' + backup_id).append(value1.html);
1383
+ tmp_current_click_backupid = '';
 
 
 
 
 
1384
  }
1385
  else if (value1.status === 'running') {
1386
  if (m_downloading_file_name === file_name) {
1387
  wpvivid_lock_download(tmp_current_click_backupid);
1388
  }
1389
+ jQuery('#wpvivid_file_part_' + backup_id).append(value1.html);
 
 
 
 
 
 
1390
  }
1391
  else if (value1.status === 'completed') {
1392
  if (m_downloading_file_name === file_name) {
1394
  m_downloading_id = '';
1395
  m_downloading_file_name = '';
1396
  }
1397
+ jQuery('#wpvivid_file_part_' + backup_id).append(value1.html);
1398
+ tmp_current_click_backupid = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1399
  }
1400
  else if (value1.status === 'timeout') {
1401
  if (m_downloading_file_name === file_name) {
1403
  m_downloading_id = '';
1404
  m_downloading_file_name = '';
1405
  }
1406
+ jQuery('#wpvivid_file_part_' + backup_id).append(value1.html);
1407
+ tmp_current_click_backupid = '';
 
 
 
 
 
1408
  }
1409
  else if (value1.status === 'file_not_found') {
1410
  wpvivid_unlock_download(tmp_current_click_backupid);
1411
  wpvivid_reset_backup_list();
1412
  file_not_found = true;
1413
  alert("Download failed, file not found. The file might has been moved, renamed or deleted. Please verify the file exists and try again.");
1414
+ tmp_current_click_backupid = '';
1415
  return false;
1416
  }
1417
  });
1418
  if (file_not_found === false) {
1419
+ jQuery('#wpvivid_file_part_' + backup_id).append(value.place_html);
 
 
 
 
 
 
 
 
 
 
1420
  }
1421
  });
1422
  }
1469
  });
1470
  }
1471
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1472
  function wpvivid_clear_notice(notice_id){
1473
  var t = document.getElementById(notice_id);
1474
  var oDiv = t.getElementsByTagName("div");
1500
  m_need_update = true;
1501
  wpvivid_lock_download(backup_id);
1502
  m_downloading_id = backup_id;
1503
+ tmp_current_click_backupid = backup_id;
1504
  m_downloading_file_name = file_name;
1505
+ wpvivid_post_request(ajax_data, function(data)
1506
+ {
1507
+ }, function(XMLHttpRequest, textStatus, errorThrown)
1508
+ {
1509
+ var error_message = wpvivid_output_ajaxerror('downloading a backup', textStatus, errorThrown);
1510
  alert(error_message);
1511
  wpvivid_unlock_download(backup_id);
1512
  jQuery("#"+backup_id+"-text-part-"+part_num).html("<a onclick=\"wpvivid_prepare_download('" + part_num + "', '" + backup_id + "', '" + file_name + "');\" style=\"cursor: pointer\">Prepare to Download</a>");
1513
  jQuery("#"+backup_id+"-progress-part-"+part_num).css('width', progress);
1514
  m_downloading_id = '';
1515
  m_downloading_file_name = '';
1516
+ tmp_current_click_backupid = '';
1517
  }, 0);
1518
  }
1519
 
1529
  location.href =ajaxurl+'?action=wpvivid_download_backup&backup_id='+backup_id+'&download_type='+backup_type+'&file_name='+file_name;
1530
  }
1531
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1532
  function wpvivid_click_check_backup(backup_id){
1533
  var name = "";
1534
  var all_check = true;
1567
  function wpvivid_getrequest() {
1568
  switch(wpvivid_page_request){
1569
  case "backup":
1570
+ wpvivid_click_switch_page('wrap', 'wpvivid_tab_general', false);
1571
  break;
1572
  case "settings":
1573
+ wpvivid_click_switch_page('wrap', 'wpvivid_tab_setting', false);
1574
  break;
1575
  case "remote":
1576
+ wpvivid_click_switch_page('wrap', 'wpvivid_tab_remote_storage', false);
1577
  break;
1578
  case "website":
1579
+ wpvivid_click_switch_page('wrap', 'wpvivid_tab_debug', false);
1580
  break;
1581
  case "log":
1582
+ wpvivid_click_switch_page('wrap', 'wpvivid_tab_log', false);
1583
  break;
1584
  default:
1585
+ wpvivid_click_switch_page('wrap', 'wpvivid_tab_general', false);
1586
  break;
1587
  }
1588
  }
1589
 
1590
+ function wpvivid_click_switch_page(tab, type, scroll){
1591
+ jQuery('.'+tab+'-tab-content:not(.' + type + ')').hide();
1592
+ jQuery('.'+tab+'-tab-content.' + type).show();
1593
+ jQuery('.'+tab+'-nav-tab:not(#' + type + ')').removeClass('nav-tab-active');
1594
+ jQuery('.'+tab+'-nav-tab#' + type).addClass('nav-tab-active');
1595
+ if(scroll == true){
1596
+ var top = jQuery('#'+type).offset().top-jQuery('#'+type).height();
1597
+ jQuery('html, body').animate({scrollTop:top}, 'slow');
 
 
1598
  }
1599
  }
1600
 
1601
+ function wpvivid_close_tab(event, hide_tab, type, show_tab){
1602
  event.stopPropagation();
1603
+ jQuery('#'+hide_tab).hide();
1604
+ wpvivid_click_switch_page(type, show_tab, true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1605
  }
1606
 
1607
  /**
1614
  wpvivid_post_request(ajax_data, function(data){
1615
  try {
1616
  var jsonarray = jQuery.parseJSON(data);
 
1617
  if (jsonarray.result === "success") {
1618
+ jQuery('#wpvivid_loglist').html("");
1619
+ jQuery('#wpvivid_loglist').append(jsonarray.html);
1620
+ wpvivid_log_count = jsonarray.log_count;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1621
  wpvivid_display_log_page();
1622
  }
1623
  }
1631
  });
1632
  }
1633
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1634
  /**
1635
  * Set a default remote storage for backups.
1636
  */
1637
  function wpvivid_set_default_remote_storage(){
1638
+ var remote_storage = new Array();
1639
+ remote_storage[0] = jQuery("input[name='remote_storage']:checked").val();
1640
+ var ajax_data = {
1641
+ 'action': 'wpvivid_set_default_remote_storage',
1642
+ 'remote_storage': remote_storage
1643
+ };
1644
+ wpvivid_post_request(ajax_data, function(data){
1645
+ wpvivid_handle_remote_storage_data(data);
1646
+ }, function(XMLHttpRequest, textStatus, errorThrown) {
1647
+ var error_message = wpvivid_output_ajaxerror('setting up the default remote storage', textStatus, errorThrown);
1648
+ alert(error_message);
1649
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1650
  }
1651
 
1652
  function wpvivid_pre_log_page(){
1710
  catch(err){
1711
  alert(err);
1712
  }
 
 
1713
  }, function(XMLHttpRequest, textStatus, errorThrown) {
1714
  var error_message = wpvivid_output_ajaxerror('setting up a lock for the backup', textStatus, errorThrown);
1715
  alert(error_message);
1716
  });
1717
  }
1718
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1719
  function wpvivid_initialize_restore(backup_id, backup_time){
1720
  jQuery('#wpvivid_restore_backup_time').html(backup_time);
1721
  m_restore_backup_id = backup_id;
1722
  jQuery('#wpvivid_restore_log').html("");
1723
  jQuery('#wpvivid_tab_restore').show();
1724
+ wpvivid_click_switch_page('backup', 'wpvivid_tab_restore', true);
1725
  wpvivid_init_restore_data();
1726
  }
1727
 
1809
  wpvivid_restore();
1810
  }
1811
  else if (jsonarray.result === "need_download") {
1812
+ wpvivid_restore_lock();
1813
  var download_array = new Array();
1814
  var download_num = 0;
1815
  var start_download_num = 0;
1816
  wpvivid_display_restore_msg("Backup is not found on web server. Prepare to download it from remote storage.");
1817
  jQuery.each(jsonarray.files, function (index, value) {
1818
  if (value.status === "need_download") {
1819
+ download_array[download_num] = new Array('file_name', 'file_size', 'md5');
1820
  download_array[download_num]['file_name'] = index;
1821
  download_array[download_num]['file_size'] = value.size;
1822
  download_array[download_num]['md5'] = value.md5;
1848
  'backup_id': m_restore_backup_id,
1849
  'file_name': download_array[start_download_num]['file_name'],
1850
  'file_size': download_array[start_download_num]['file_size'],
1851
+ 'md5': download_array[start_download_num]['md5']
1852
  }
1853
  wpvivid_post_request(ajax_data, function (data) {
1854
  wpvivid_display_restore_msg("Download restore file " + download_array[start_download_num]['file_name'] + " completed.");
1863
  jQuery('#wpvivid_rollback_btn').hide();
1864
  var error_message = wpvivid_output_ajaxerror('downloading backups', textStatus, errorThrown);
1865
  wpvivid_display_restore_msg(error_message);
1866
+ wpvivid_restore_unlock();
1867
  });
1868
  }
1869
  else{
2243
  * Clean junk files created during backups and restorations off your web server disk.
2244
  */
2245
  function wpvivid_clean_junk_files(){
2246
+ var descript = 'The selected item(s) will be permanently deleted. Are you sure you want to continue?';
2247
+ var ret = confirm(descript);
2248
+ if(ret === true){
2249
+ var option_data = wpvivid_ajax_data_transfer('junk-files');
2250
+ var ajax_data = {
2251
+ 'action': 'wpvivid_clean_local_storage',
2252
+ 'options': option_data
2253
+ };
2254
+ jQuery('#wpvivid_calculate_size').css({'pointer-events': 'none', 'opacity': '0.4'});
2255
+ jQuery('#wpvivid_clean_junk_file').css({'pointer-events': 'none', 'opacity': '0.4'});
2256
+ wpvivid_post_request(ajax_data, function (data) {
2257
+ jQuery('#wpvivid_calculate_size').css({'pointer-events': 'auto', 'opacity': '1'});
2258
+ jQuery('#wpvivid_clean_junk_file').css({'pointer-events': 'auto', 'opacity': '1'});
2259
+ jQuery('input[option="junk-files"]').prop('checked', false);
2260
+ try {
2261
+ var jsonarray = jQuery.parseJSON(data);
2262
+ alert(jsonarray.msg);
2263
+ if (jsonarray.result === "success") {
2264
+ jQuery('#wpvivid_junk_sum_size').html(jsonarray.data.sum_size);
2265
+ jQuery('#wpvivid_junk_log_path').html(jsonarray.data.log_path);
2266
+ jQuery('#wpvivid_junk_file_path').html(jsonarray.data.junk_path);
2267
+ jQuery('#wpvivid_restore_temp_file_path').html(jsonarray.data.old_files_path);
2268
+ jQuery('#wpvivid_loglist').html("");
2269
+ jQuery('#wpvivid_loglist').append(jsonarray.html);
2270
+ wpvivid_log_count = jsonarray.log_count;
2271
+ wpvivid_display_log_page();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2272
  }
2273
+ }
2274
+ catch(err){
2275
+ alert(err);
2276
+ }
2277
+ }, function (XMLHttpRequest, textStatus, errorThrown) {
2278
+ var error_message = wpvivid_output_ajaxerror('cleaning out junk files', textStatus, errorThrown);
2279
+ alert(error_message);
2280
+ jQuery('#wpvivid_calculate_size').css({'pointer-events': 'auto', 'opacity': '1'});
2281
+ jQuery('#wpvivid_clean_junk_file').css({'pointer-events': 'auto', 'opacity': '1'});
2282
+ });
2283
  }
2284
  }
2285
 
2306
  return error_msg;
2307
  }
2308
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2309
  function wpvivid_ajax_data_transfer(data_type){
2310
  var json = {};
2311
  jQuery('input:checkbox[option='+data_type+']').each(function() {
2319
  }
2320
  json[key]=value;
2321
  });
2322
+ jQuery('input:radio[option='+data_type+']').each(function() {
 
2323
  if(jQuery(this).prop('checked'))
2324
  {
2325
  var key = jQuery(this).prop('name');
admin/partials/wpvivid-admin-display.php CHANGED
@@ -15,6 +15,7 @@ if (!defined('WPVIVID_PLUGIN_DIR')){
15
  }
16
 
17
  global $wpvivid_pulgin;
 
18
  $last_backup_message=WPvivid_Setting::get_option('wpvivid_last_msg');
19
  $backuplist=WPvivid_Backuplist::get_backuplist();
20
  $remoteslist=WPvivid_Setting::get_all_remote_options();
@@ -36,8 +37,19 @@ $wpvivid_version=WPVIVID_PLUGIN_VERSION;
36
  ?>
37
 
38
  <div class="wrap">
39
- <h1><?php _e('WPvivid Backup/Restore', 'wpvivid'); ?></h1>
40
- <div id="wpvivid_backup_notice"></div>
 
 
 
 
 
 
 
 
 
 
 
41
  </div>
42
  <h2 class="nav-tab-wrapper">
43
  <a href="#" id="wpvivid_tab_general" class="nav-tab wrap-nav-tab nav-tab-active" onclick="switchTabs(event,'general-page')"><?php _e('Backup & Restore', 'wpvivid'); ?></a>
@@ -48,7 +60,7 @@ $wpvivid_version=WPVIVID_PLUGIN_VERSION;
48
  <a href="#" id="wpvivid_tab_read_log" class="nav-tab wrap-nav-tab delete" onclick="switchTabs(event,'log-read-page')" style="display: none;">
49
  <div style="margin-right: 15px;"><?php _e('Log', 'wpvivid'); ?></div>
50
  <div class="nav-tab-delete-img">
51
- <img src="<?php echo esc_url(plugins_url( 'images/delete-tab.png', __FILE__ )); ?>" style="vertical-align:middle; cursor:pointer;" onclick="wpvivid_close_main_tab(event, 'log');" />
52
  </div>
53
  </a>
54
  <?php do_action('wpvivid_backuprestore_add_tab');?>
@@ -58,22 +70,22 @@ $wpvivid_version=WPVIVID_PLUGIN_VERSION;
58
  <div id="post-body" class="metabox-holder columns-2">
59
  <div id="post-body-content">
60
  <div class="inside" style="margin-top:0px;">
61
- <div id="general-page" class="tabcontent wpvivid_tab_general" name="tab-backup" style="width:100%;">
62
  <?php include_once plugin_dir_path( dirname( __FILE__ ) ) .'partials/wpvivid-backup-restore-page-display.php'; ?>
63
  </div>
64
- <div id="storage-page" class="tabcontent wpvivid_tab_remote_storage" name="tab-storage" style="display:none;">
65
  <?php include_once plugin_dir_path( dirname( __FILE__ ) ) .'partials/wpvivid-remote-storage-page-display.php'; ?>
66
  </div>
67
- <div id="settings-page" class="tabcontent wpvivid_tab_setting" name="tab-setting" style="display:none;">
68
  <?php include_once plugin_dir_path( dirname( __FILE__ ) ) .'partials/wpvivid-settings-page-display.php'; ?>
69
  </div>
70
- <div id="debug-page" class="tabcontent wpvivid_tab_debug" name="tab-debug" style="display:none;">
71
  <?php include_once plugin_dir_path( dirname( __FILE__ ) ) .'partials/wpvivid-website-info-page-display.php'; ?>
72
  </div>
73
- <div id="logs-page" class="tabcontent wpvivid_tab_log" name="tab-logs" style="display:none;">
74
  <?php include_once plugin_dir_path( dirname( __FILE__ ) ) .'partials/wpvivid-logs-page-display.php'; ?>
75
  </div>
76
- <div id="log-read-page" class="tabcontent wpvivid_tab_read_log" style="display:none;">
77
  <?php include_once plugin_dir_path( dirname( __FILE__ ) ) .'partials/wpvivid-log-read-page-display.php'; ?>
78
  </div>
79
  <?php do_action('wpvivid_backuprestore_add_page');?>
@@ -99,7 +111,7 @@ $wpvivid_version=WPVIVID_PLUGIN_VERSION;
99
  var i, tabcontent, tablinks;
100
 
101
  // Get all elements with class="tabcontent" and hide them
102
- tabcontent = document.getElementsByClassName("tabcontent");
103
  for (i = 0; i < tabcontent.length; i++) {
104
  tabcontent[i].style.display = "none";
105
  }
@@ -119,13 +131,13 @@ $wpvivid_version=WPVIVID_PLUGIN_VERSION;
119
  var i, tabcontent, tablinks;
120
 
121
  // Get all elements with class="table-list-content" and hide them
122
- tabcontent = document.getElementsByClassName("table-list-content");
123
  for (i = 0; i < tabcontent.length; i++) {
124
  tabcontent[i].style.display = "none";
125
  }
126
 
127
  // Get all elements with class="table-nav-tab" and remove the class "nav-tab-active"
128
- tablinks = document.getElementsByClassName("table-nav-tab");
129
  for (i = 0; i < tablinks.length; i++) {
130
  tablinks[i].className = tablinks[i].className.replace(" nav-tab-active", "");
131
  }
15
  }
16
 
17
  global $wpvivid_pulgin;
18
+
19
  $last_backup_message=WPvivid_Setting::get_option('wpvivid_last_msg');
20
  $backuplist=WPvivid_Backuplist::get_backuplist();
21
  $remoteslist=WPvivid_Setting::get_all_remote_options();
37
  ?>
38
 
39
  <div class="wrap">
40
+ <h1><?php _e('WP Automatic Cloud Backup by WPvivid', 'wpvivid'); ?></h1>
41
+ <div id="wpvivid_backup_notice">
42
+ <?php
43
+ if($schedule['enable'] == true) {
44
+ if($schedule['backup']['remote'] === 1)
45
+ {
46
+ if($default_remote_storage == ''){
47
+ _e('<div class="notice notice-warning is-dismissible"><p>Warning: There is no default remote storage available for the scheduled backups, please set up it first.</p></div>');
48
+ }
49
+ }
50
+ }
51
+ ?>
52
+ </div>
53
  </div>
54
  <h2 class="nav-tab-wrapper">
55
  <a href="#" id="wpvivid_tab_general" class="nav-tab wrap-nav-tab nav-tab-active" onclick="switchTabs(event,'general-page')"><?php _e('Backup & Restore', 'wpvivid'); ?></a>
60
  <a href="#" id="wpvivid_tab_read_log" class="nav-tab wrap-nav-tab delete" onclick="switchTabs(event,'log-read-page')" style="display: none;">
61
  <div style="margin-right: 15px;"><?php _e('Log', 'wpvivid'); ?></div>
62
  <div class="nav-tab-delete-img">
63
+ <img src="<?php echo esc_url(plugins_url( 'images/delete-tab.png', __FILE__ )); ?>" style="vertical-align:middle; cursor:pointer;" onclick="wpvivid_close_tab(event, 'wpvivid_tab_read_log', 'wrap', 'wpvivid_tab_log');" />
64
  </div>
65
  </a>
66
  <?php do_action('wpvivid_backuprestore_add_tab');?>
70
  <div id="post-body" class="metabox-holder columns-2">
71
  <div id="post-body-content">
72
  <div class="inside" style="margin-top:0px;">
73
+ <div id="general-page" class="wrap-tab-content wpvivid_tab_general" name="tab-backup" style="width:100%;">
74
  <?php include_once plugin_dir_path( dirname( __FILE__ ) ) .'partials/wpvivid-backup-restore-page-display.php'; ?>
75
  </div>
76
+ <div id="storage-page" class="wrap-tab-content wpvivid_tab_remote_storage" name="tab-storage" style="display:none;">
77
  <?php include_once plugin_dir_path( dirname( __FILE__ ) ) .'partials/wpvivid-remote-storage-page-display.php'; ?>
78
  </div>
79
+ <div id="settings-page" class="wrap-tab-content wpvivid_tab_setting" name="tab-setting" style="display:none;">
80
  <?php include_once plugin_dir_path( dirname( __FILE__ ) ) .'partials/wpvivid-settings-page-display.php'; ?>
81
  </div>
82
+ <div id="debug-page" class="wrap-tab-content wpvivid_tab_debug" name="tab-debug" style="display:none;">
83
  <?php include_once plugin_dir_path( dirname( __FILE__ ) ) .'partials/wpvivid-website-info-page-display.php'; ?>
84
  </div>
85
+ <div id="logs-page" class="wrap-tab-content wpvivid_tab_log" name="tab-logs" style="display:none;">
86
  <?php include_once plugin_dir_path( dirname( __FILE__ ) ) .'partials/wpvivid-logs-page-display.php'; ?>
87
  </div>
88
+ <div id="log-read-page" class="wrap-tab-content wpvivid_tab_read_log" style="display:none;">
89
  <?php include_once plugin_dir_path( dirname( __FILE__ ) ) .'partials/wpvivid-log-read-page-display.php'; ?>
90
  </div>
91
  <?php do_action('wpvivid_backuprestore_add_page');?>
111
  var i, tabcontent, tablinks;
112
 
113
  // Get all elements with class="tabcontent" and hide them
114
+ tabcontent = document.getElementsByClassName("wrap-tab-content");
115
  for (i = 0; i < tabcontent.length; i++) {
116
  tabcontent[i].style.display = "none";
117
  }
131
  var i, tabcontent, tablinks;
132
 
133
  // Get all elements with class="table-list-content" and hide them
134
+ tabcontent = document.getElementsByClassName("backup-tab-content");
135
  for (i = 0; i < tabcontent.length; i++) {
136
  tabcontent[i].style.display = "none";
137
  }
138
 
139
  // Get all elements with class="table-nav-tab" and remove the class "nav-tab-active"
140
+ tablinks = document.getElementsByClassName("backup-nav-tab");
141
  for (i = 0; i < tablinks.length; i++) {
142
  tablinks[i].className = tablinks[i].className.replace(" nav-tab-active", "");
143
  }
admin/partials/wpvivid-backup-restore-page-display.php CHANGED
@@ -31,7 +31,7 @@ function wpvivid_backup_manual(){
31
  <div class="quickstart-storage-setting">
32
  <span class="list-top-chip backup" name="ismerge" value="1"><?php _e('Local Storage Directory: '); ?></span>
33
  <span class="list-top-chip" id="wpvivid_local_storage_path"><?php echo WP_CONTENT_DIR.'/'.$backupdir; ?></span>
34
- <span class="list-top-chip" id=""><a href="#" onclick="wpvivid_click_switch_page('wpvivid_tab_setting', '');"><?php _e(' rename directory', 'wpvivid'); ?></a></span>
35
  </div>
36
  <div class="quickstart-archive-block">
37
  <fieldset>
@@ -95,7 +95,6 @@ function wpvivid_backup_manual(){
95
  }
96
 
97
  function wpvivid_backup_schedule(){
98
- $last_backup_message=WPvivid_Setting::get_option('wpvivid_last_msg');
99
  ?>
100
  <div class="postbox qucikbackup-schedule" id="wpvivid_postbox_backup_schedule">
101
  <h2><span><?php _e( 'Backup Schedule','wpvivid'); ?></span></h2>
@@ -110,28 +109,15 @@ function wpvivid_backup_schedule(){
110
  $schedule_status='Disabled';
111
  $next_backup_time='N/A';
112
  }
113
- if(empty($last_backup_message)) {
114
- $last_backup_msg='The last backup message not found.';
115
- }
116
- else{
117
- if ($last_backup_message['status']['str'] === "completed") {
118
- $last_backup_msg=date("M d, Y H:i", $last_backup_message['status']['start_time']).' Succeed <a id="wpvivid_last_backup_msg_log" style="cursor:pointer;"> Log</a>';
119
- }
120
- else if ($last_backup_message['status']['str'] === "error") {
121
- $last_backup_msg=date("M d, Y H:i", $last_backup_message['status']['start_time']).' Failed <a id="wpvivid_last_backup_msg_log" style="cursor:pointer;"> Log</a>';
122
- }
123
- else if($last_backup_message['status']['str'] === "cancel"){
124
- $last_backup_msg=date("M d, Y H:i", $last_backup_message['status']['start_time']).' Failed <a id="wpvivid_last_backup_msg_log" style="cursor:pointer;"> Log</a>';
125
- }
126
- else{
127
- $last_backup_msg='The last backup message not found.';
128
- }
129
- }
130
  ?>
131
  <p id="wpvivid_schedule_status"><strong><?php _e('Schedule Status: '); ?></strong><?php _e($schedule_status, 'wpvivid'); ?></p>
132
  <div id="wpvivid_schedule_info">
133
  <p><strong><?php _e('Server Time: '); ?></strong><?php _e(date("l, F d, Y H:i",time()), 'wpvivid'); ?></p>
134
- <p><span id="wpvivid_last_backup_msg"><strong><?php _e('Last Backup: '); ?></strong><?php _e($last_backup_msg, 'wpvivid'); ?></span></p>
 
 
 
 
135
  <p id="wpvivid_next_backup"><strong><?php _e('Next Backup: '); ?></strong><?php _e($next_backup_time, 'wpvivid'); ?></p>
136
  </div>
137
  </div>
@@ -142,16 +128,16 @@ function wpvivid_backup_schedule(){
142
 
143
  function wpvivid_add_tab_backup(){
144
  ?>
145
- <a href="#" id="wpvivid_tab_backup" class="nav-tab table-nav-tab nav-tab-active" onclick="switchrestoreTabs(event,'page-backups')"><?php _e('Backups', 'wpvivid'); ?></a>
146
  <?php
147
  }
148
 
149
  function wpvivid_add_tab_log(){
150
  ?>
151
- <a href="#" id="wpvivid_tab_backup_log" class="nav-tab table-nav-tab delete" onclick="switchrestoreTabs(event,'page-log')" style="display: none;">
152
  <div style="margin-right: 15px;"><?php _e('Log', 'wpvivid'); ?></div>
153
  <div class="nav-tab-delete-img">
154
- <img src="<?php echo esc_url(plugins_url( 'images/delete-tab.png', __FILE__ )); ?>" style="vertical-align:middle; cursor:pointer;" onclick="wpvivid_close_tab(event, 'log');" />
155
  </div>
156
  </a>
157
  <?php
@@ -159,10 +145,10 @@ function wpvivid_add_tab_log(){
159
 
160
  function wpvivid_add_tab_restore(){
161
  ?>
162
- <a href="#" id="wpvivid_tab_restore" class="nav-tab table-nav-tab delete" onclick="switchrestoreTabs(event,'page-restore')" style="display: none;">
163
  <div style="margin-right: 15px;"><?php _e('Restore', 'wpvivid'); ?></div>
164
  <div class="nav-tab-delete-img">
165
- <img src="<?php echo esc_url(plugins_url( 'images/delete-tab.png', __FILE__ )); ?>" style="vertical-align:middle; cursor:pointer;" onclick="wpvivid_close_tab(event, 'restore');" />
166
  </div>
167
  </a>
168
  <?php
@@ -171,7 +157,7 @@ function wpvivid_add_tab_restore(){
171
  function wpvivid_add_page_backup(){
172
  $backuplist=WPvivid_Backuplist::get_backuplist();
173
  ?>
174
- <div class="table-list-content wpvivid_tab_backup" id="page-backups">
175
  <div style="margin-top:10px; margin-bottom:10px;">
176
  <?php
177
  $descript='';
@@ -211,14 +197,108 @@ function wpvivid_add_page_backup(){
211
  </tr>
212
  </tfoot>
213
  </table>
214
-
215
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
  <?php
217
  }
218
 
219
  function wpvivid_add_page_log(){
220
  ?>
221
- <div class="table-list-content wpvivid_tab_backup_log" id="page-log" style="display:none;">
222
  <div class="postbox restore_log" id="wpvivid_display_log_content">
223
  <div></div>
224
  </div>
@@ -228,7 +308,7 @@ function wpvivid_add_page_log(){
228
 
229
  function wpvivid_add_page_restore(){
230
  ?>
231
- <div class="table-list-content wpvivid_tab_restore" id="page-restore" style="display:none;">
232
  <div>
233
  <h3><?php _e('Restore backup from:', 'wpvivid'); ?><span id="wpvivid_restore_backup_time"></span></h3>
234
  <p><strong><?php _e('Please do not close the page or switch to other pages when a restore task is running, as it could trigger some unexpected errors.', 'wpvivid'); ?></strong></p>
@@ -247,6 +327,12 @@ function wpvivid_add_page_restore(){
247
  function wpvivid_backup_do_js(){
248
  global $wpvivid_pulgin;
249
  $backup_task=$wpvivid_pulgin->_list_tasks(false);
 
 
 
 
 
 
250
  if(empty($backup_task['backup']['data'])){
251
  ?>
252
  jQuery('#wpvivid_postbox_backup_percent').hide();
@@ -263,18 +349,10 @@ function wpvivid_backup_do_js(){
263
  jQuery('#wpvivid_backup_cancel_btn').css({'pointer-events': 'nano', 'opacity': '0.4'});
264
  jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'nano', 'opacity': '0.4'});
265
  jQuery('#wpvivid_action_progress_bar_percent').css('width', <?php echo $percent; ?>+'%');
266
- <?php
267
- $general_setting=WPvivid_Setting::get_setting(true, "");
268
- if($general_setting['options']['wpvivid_common_setting']['estimate_backup'] === false){
269
- ?>
270
- jQuery('#wpvivid_estimate_backup_info').hide();
271
- <?php
272
- }
273
- ?>
274
  jQuery('#wpvivid_backup_database_size').html('<?php echo $value['size']['db_size']; ?>');
275
  jQuery('#wpvivid_backup_file_size').html('<?php echo $value['size']['files_size']['sum']; ?>');
276
  <?php
277
- if($value['is_canceled'] === false){
278
  $descript=$value['data']['descript'];
279
  $backup_running_time=$value['data']['running_time'];
280
  $output = '';
31
  <div class="quickstart-storage-setting">
32
  <span class="list-top-chip backup" name="ismerge" value="1"><?php _e('Local Storage Directory: '); ?></span>
33
  <span class="list-top-chip" id="wpvivid_local_storage_path"><?php echo WP_CONTENT_DIR.'/'.$backupdir; ?></span>
34
+ <span class="list-top-chip" id=""><a href="#" onclick="wpvivid_click_switch_page('wrap', 'wpvivid_tab_setting', true);"><?php _e(' rename directory', 'wpvivid'); ?></a></span>
35
  </div>
36
  <div class="quickstart-archive-block">
37
  <fieldset>
95
  }
96
 
97
  function wpvivid_backup_schedule(){
 
98
  ?>
99
  <div class="postbox qucikbackup-schedule" id="wpvivid_postbox_backup_schedule">
100
  <h2><span><?php _e( 'Backup Schedule','wpvivid'); ?></span></h2>
109
  $schedule_status='Disabled';
110
  $next_backup_time='N/A';
111
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  ?>
113
  <p id="wpvivid_schedule_status"><strong><?php _e('Schedule Status: '); ?></strong><?php _e($schedule_status, 'wpvivid'); ?></p>
114
  <div id="wpvivid_schedule_info">
115
  <p><strong><?php _e('Server Time: '); ?></strong><?php _e(date("l, F d, Y H:i",time()), 'wpvivid'); ?></p>
116
+ <p><span id="wpvivid_last_backup_msg"><?php
117
+ $html='';
118
+ $html=apply_filters('wpvivid_get_last_backup_message', $html);
119
+ echo $html;
120
+ ?></span></p>
121
  <p id="wpvivid_next_backup"><strong><?php _e('Next Backup: '); ?></strong><?php _e($next_backup_time, 'wpvivid'); ?></p>
122
  </div>
123
  </div>
128
 
129
  function wpvivid_add_tab_backup(){
130
  ?>
131
+ <a href="#" id="wpvivid_tab_backup" class="nav-tab backup-nav-tab nav-tab-active" onclick="switchrestoreTabs(event,'page-backups')"><?php _e('Backups', 'wpvivid'); ?></a>
132
  <?php
133
  }
134
 
135
  function wpvivid_add_tab_log(){
136
  ?>
137
+ <a href="#" id="wpvivid_tab_backup_log" class="nav-tab backup-nav-tab delete" onclick="switchrestoreTabs(event,'page-log')" style="display: none;">
138
  <div style="margin-right: 15px;"><?php _e('Log', 'wpvivid'); ?></div>
139
  <div class="nav-tab-delete-img">
140
+ <img src="<?php echo esc_url(plugins_url( 'images/delete-tab.png', __FILE__ )); ?>" style="vertical-align:middle; cursor:pointer;" onclick="wpvivid_close_tab(event, 'wpvivid_tab_backup_log', 'backup', 'wpvivid_tab_backup');" />
141
  </div>
142
  </a>
143
  <?php
145
 
146
  function wpvivid_add_tab_restore(){
147
  ?>
148
+ <a href="#" id="wpvivid_tab_restore" class="nav-tab backup-nav-tab delete" onclick="switchrestoreTabs(event,'page-restore')" style="display: none;">
149
  <div style="margin-right: 15px;"><?php _e('Restore', 'wpvivid'); ?></div>
150
  <div class="nav-tab-delete-img">
151
+ <img src="<?php echo esc_url(plugins_url( 'images/delete-tab.png', __FILE__ )); ?>" style="vertical-align:middle; cursor:pointer;" onclick="wpvivid_close_tab(event, 'wpvivid_tab_restore', 'backup', 'wpvivid_tab_backup');" />
152
  </div>
153
  </a>
154
  <?php
157
  function wpvivid_add_page_backup(){
158
  $backuplist=WPvivid_Backuplist::get_backuplist();
159
  ?>
160
+ <div class="backup-tab-content wpvivid_tab_backup" id="page-backups">
161
  <div style="margin-top:10px; margin-bottom:10px;">
162
  <?php
163
  $descript='';
197
  </tr>
198
  </tfoot>
199
  </table>
 
200
  </div>
201
+ <script>
202
+ function wpvivid_delete_selected_backup(backup_id){
203
+ var name = '';
204
+ jQuery('#wpvivid_backuplist tr').each(function(i){
205
+ jQuery(this).children('td').each(function (j) {
206
+ if (j == 0) {
207
+ var id = jQuery(this).parent().children('th').find("input[type=checkbox]").attr("id");
208
+ if(id === backup_id){
209
+ name = jQuery(this).parent().children('td').eq(0).find('img').attr('name');
210
+ }
211
+ }
212
+ });
213
+ });
214
+ var descript = '';
215
+ var force_del = 0;
216
+ var bdownloading = false;
217
+ if(name === 'lock') {
218
+ descript = '<?php _e('This backup is locked, are you sure to remove it? This backup will be deleted permanently from your hosting (localhost) and remote storages.', 'wpvivid'); ?>';
219
+ force_del = 1;
220
+ }
221
+ else{
222
+ descript = '<?php _e('Are you sure to remove this backup? This backup will be deleted permanently from your hosting (localhost) and remote storages.', 'wpvivid'); ?>';
223
+ force_del = 0;
224
+ }
225
+ if(m_downloading_id === backup_id){
226
+ bdownloading = true;
227
+ descript = '<?php _e('This request will delete the backup being downloaded, are you sure you want to continue?', 'wpvivid'); ?>';
228
+ force_del = 1;
229
+ }
230
+ var ret = confirm(descript);
231
+ if(ret === true){
232
+ var ajax_data={
233
+ 'action': 'wpvivid_delete_backup',
234
+ 'backup_id': backup_id,
235
+ 'force': force_del
236
+ };
237
+ wpvivid_post_request(ajax_data, function(data){
238
+ wpvivid_handle_backup_data(data);
239
+ if(bdownloading){
240
+ m_downloading_id = '';
241
+ }
242
+ }, function(XMLHttpRequest, textStatus, errorThrown) {
243
+ var error_message = wpvivid_output_ajaxerror('deleting the backup', textStatus, errorThrown);
244
+ alert(error_message);
245
+ });
246
+ }
247
+ }
248
+ function wpvivid_delete_backups_inbatches(){
249
+ var delete_backup_array = new Array();
250
+ var count = 0;
251
+ var bdownloading = false;
252
+ jQuery('#wpvivid_backuplist tr').each(function (i) {
253
+ jQuery(this).children('th').each(function (j) {
254
+ if (j == 0) {
255
+ if(jQuery(this).find('input[type=checkbox]').prop('checked')){
256
+ delete_backup_array[count] = jQuery(this).find('input[type=checkbox]').attr('id');
257
+ if(m_downloading_id === jQuery(this).find('input[type=checkbox]').attr('id')){
258
+ bdownloading = true;
259
+ }
260
+ count++;
261
+ }
262
+ }
263
+ });
264
+ });
265
+ if( count === 0 ){
266
+ alert('<?php _e('Please select at least one item.','wpvivid'); ?>');
267
+ }
268
+ else {
269
+ var descript = '';
270
+ if(bdownloading) {
271
+ descript = '<?php _e('This request might delete the backup being downloaded, are you sure you want to continue?', 'wpvivid'); ?>';
272
+ }
273
+ else{
274
+ descript = '<?php _e('Are you sure to remove the selected backups? These backups will be deleted permanently from your hosting (localhost).', 'wpvivid'); ?>';
275
+ }
276
+ var ret = confirm(descript);
277
+ if (ret === true) {
278
+ var ajax_data = {
279
+ 'action': 'wpvivid_delete_backup_array',
280
+ 'backup_id': delete_backup_array
281
+ };
282
+ wpvivid_post_request(ajax_data, function (data) {
283
+ wpvivid_handle_backup_data(data);
284
+ jQuery('#backup_list_all_check').prop('checked', false);
285
+ if(bdownloading){
286
+ m_downloading_id = '';
287
+ }
288
+ }, function (XMLHttpRequest, textStatus, errorThrown) {
289
+ var error_message = wpvivid_output_ajaxerror('deleting the backup', textStatus, errorThrown);
290
+ alert(error_message);
291
+ });
292
+ }
293
+ }
294
+ }
295
+ </script>
296
  <?php
297
  }
298
 
299
  function wpvivid_add_page_log(){
300
  ?>
301
+ <div class="backup-tab-content wpvivid_tab_backup_log" id="page-log" style="display:none;">
302
  <div class="postbox restore_log" id="wpvivid_display_log_content">
303
  <div></div>
304
  </div>
308
 
309
  function wpvivid_add_page_restore(){
310
  ?>
311
+ <div class="backup-tab-content wpvivid_tab_restore" id="page-restore" style="display:none;">
312
  <div>
313
  <h3><?php _e('Restore backup from:', 'wpvivid'); ?><span id="wpvivid_restore_backup_time"></span></h3>
314
  <p><strong><?php _e('Please do not close the page or switch to other pages when a restore task is running, as it could trigger some unexpected errors.', 'wpvivid'); ?></strong></p>
327
  function wpvivid_backup_do_js(){
328
  global $wpvivid_pulgin;
329
  $backup_task=$wpvivid_pulgin->_list_tasks(false);
330
+ $general_setting=WPvivid_Setting::get_setting(true, "");
331
+ if($general_setting['options']['wpvivid_common_setting']['estimate_backup'] == 0){
332
+ ?>
333
+ jQuery('#wpvivid_estimate_backup_info').hide();
334
+ <?php
335
+ }
336
  if(empty($backup_task['backup']['data'])){
337
  ?>
338
  jQuery('#wpvivid_postbox_backup_percent').hide();
349
  jQuery('#wpvivid_backup_cancel_btn').css({'pointer-events': 'nano', 'opacity': '0.4'});
350
  jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'nano', 'opacity': '0.4'});
351
  jQuery('#wpvivid_action_progress_bar_percent').css('width', <?php echo $percent; ?>+'%');
 
 
 
 
 
 
 
 
352
  jQuery('#wpvivid_backup_database_size').html('<?php echo $value['size']['db_size']; ?>');
353
  jQuery('#wpvivid_backup_file_size').html('<?php echo $value['size']['files_size']['sum']; ?>');
354
  <?php
355
+ if($value['is_canceled'] == false){
356
  $descript=$value['data']['descript'];
357
  $backup_running_time=$value['data']['running_time'];
358
  $output = '';
admin/partials/wpvivid-logs-page-display.php CHANGED
@@ -23,38 +23,9 @@
23
  </thead>
24
  <tbody class="wpvivid-loglist" id="wpvivid_loglist">
25
  <?php
26
- $current_num=1;
27
- if(!empty($loglist['log_list']['file'])) {
28
- $log_index=0;
29
- foreach ($loglist['log_list']['file'] as $value) {
30
- if ($current_num <= $max_log_diaplay) {
31
- $log_tr_display = '';
32
- } else {
33
- $log_tr_display = 'display: none;';
34
- }
35
- if (empty($value['time'])) {
36
- $value['time'] = 'N/A';
37
- }
38
- if (empty($value['des'])) {
39
- $value['des'] = 'N/A';
40
- }
41
- ?>
42
- <tr style="<?php esc_attr_e($log_tr_display, 'wpvivid'); ?>">
43
- <td class="row-title"><label for="tablecell"><?php _e($value['time'], 'wpvivid') ?></label>
44
- </td>
45
- <td><?php _e($value['des'], 'wpvivid') ?></td>
46
- <td><?php _e($value['file_name'], 'wpvivid') ?></td>
47
- <td>
48
- <a onclick='wpvivid_view_log("<?php _e($log_index); ?>")'
49
- style="cursor:pointer;"><img
50
- src="<?php echo esc_url(plugins_url('images/Log.png', __FILE__)); ?>"
51
- style="vertical-align:middle;">Log</a></td>
52
- <td id="<?php _e($log_index); ?>" style="display: none"><?php _e($value['path']); ?></td>
53
- </tr><?php
54
- $log_index++;
55
- $current_num++;
56
- }
57
- }
58
  ?>
59
  </tbody>
60
  </table>
23
  </thead>
24
  <tbody class="wpvivid-loglist" id="wpvivid_loglist">
25
  <?php
26
+ $html = '';
27
+ $html = apply_filters('wpvivid_get_log_list', $html);
28
+ echo $html['html'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  ?>
30
  </tbody>
31
  </table>
admin/partials/wpvivid-remote-storage-page-display.php CHANGED
@@ -1,16 +1,27 @@
1
  <?php
2
 
3
- ?>
 
 
 
 
4
 
5
- <div>
6
- <div class="storage-content" id="storage-brand-2" style="">
7
- <div class="postbox">
8
- <?php do_action('wpvivid_add_storage_tab'); ?>
 
 
9
  </div>
10
- <div class="postbox storage-account-block" id="wpvivid_storage_account_block">
11
- <?php do_action('wpvivid_add_storage_page'); ?>
12
- </div>
13
- <div class="schedule-tab-block"><?php _e('Please choose one storage to save your backups (remote storage)', 'wpvivid'); ?></div>
 
 
 
 
 
14
  <div class="">
15
  <table class="widefat">
16
  <thead>
@@ -19,7 +30,7 @@
19
  <th></th>
20
  <th><?php _e( 'Storage Provider', 'wpvivid' ); ?></th>
21
  <th class="row-title"><?php _e( 'Remote Storage Name', 'wpvivid' ); ?></th>
22
- <th><?php _e( 'Action', 'wpvivid' ); ?></th>
23
  </tr>
24
  </thead>
25
  <tbody class="wpvivid-remote-storage-list" id="wpvivid_remote_storage_list">
@@ -37,7 +48,39 @@
37
  </table>
38
  </div>
39
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  </div>
 
 
41
  <script>
42
  function select_remote_storage(evt, storage_page_id)
43
  {
@@ -51,4 +94,27 @@
51
  jQuery(".storage-account-page").hide();
52
  jQuery("#"+storage_page_id).show();
53
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  </script>
1
  <?php
2
 
3
+ function wpvivid_add_tab_storage_list(){
4
+ ?>
5
+ <a href="#" id="wpvivid_tab_storage_list" class="nav-tab storage-nav-tab nav-tab-active" onclick="switchstorageTabs(event,'page-storage-list','page-storage-list')"><?php _e('Storages', 'wpvivid'); ?></a>
6
+ <?php
7
+ }
8
 
9
+ function wpvivid_add_tab_storage_edit(){
10
+ ?>
11
+ <a href="#" id="wpvivid_tab_storage_edit" class="nav-tab storage-nav-tab delete" onclick="switchstorageTabs(event,'page-storage_edit','page-storage_edit')" style="display: none;">
12
+ <div id="wpvivid_tab_storage_edit_text" style="margin-right: 15px;"><?php _e('Storage Edit', 'wpvivid'); ?></div>
13
+ <div class="nav-tab-delete-img">
14
+ <img src="<?php echo esc_url(plugins_url( 'images/delete-tab.png', __FILE__ )); ?>" style="vertical-align:middle; cursor:pointer;" onclick="wpvivid_close_tab(event, 'wpvivid_tab_storage_edit', 'storage', 'wpvivid_tab_storage_list');" />
15
  </div>
16
+ </a>
17
+ <?php
18
+ }
19
+
20
+ function wpvivid_add_page_storage_list(){
21
+ ?>
22
+ <div class="storage-tab-content wpvivid_tab_storage_list" id="page-storage-list">
23
+ <div style="margin-top:10px;"><p><strong><?php _e('Please choose one storage to save your backups (remote storage)', 'wpvivid'); ?></strong></p></div>
24
+ <div class="schedule-tab-block"></div>
25
  <div class="">
26
  <table class="widefat">
27
  <thead>
30
  <th></th>
31
  <th><?php _e( 'Storage Provider', 'wpvivid' ); ?></th>
32
  <th class="row-title"><?php _e( 'Remote Storage Name', 'wpvivid' ); ?></th>
33
+ <th><?php _e( 'Actions', 'wpvivid' ); ?></th>
34
  </tr>
35
  </thead>
36
  <tbody class="wpvivid-remote-storage-list" id="wpvivid_remote_storage_list">
48
  </table>
49
  </div>
50
  </div>
51
+ <?php
52
+ }
53
+
54
+ function wpvivid_add_page_storage_edit(){
55
+ ?>
56
+ <div class="storage-tab-content wpvivid_tab_storage_edit" id="page-storage_edit" style="display:none;">
57
+ <div><?php do_action('wpvivid_edit_remote_page'); ?></div>
58
+ </div>
59
+ <?php
60
+ }
61
+
62
+ add_action('wpvivid_storage_add_tab', 'wpvivid_add_tab_storage_list', 10);
63
+ add_action('wpvivid_storage_add_tab', 'wpvivid_add_tab_storage_edit', 11);
64
+ add_action('wpvivid_storage_add_page', 'wpvivid_add_page_storage_list', 10);
65
+ add_action('wpvivid_storage_add_page', 'wpvivid_add_page_storage_edit', 11);
66
+ ?>
67
+
68
+ <div>
69
+ <div class="storage-content" id="storage-brand-2" style="">
70
+ <div class="postbox">
71
+ <?php do_action('wpvivid_add_storage_tab'); ?>
72
+ </div>
73
+ <div class="postbox storage-account-block" id="wpvivid_storage_account_block">
74
+ <?php do_action('wpvivid_add_storage_page'); ?>
75
+ </div>
76
+ <h2 class="nav-tab-wrapper" style="padding-bottom:0!important;">
77
+ <?php do_action('wpvivid_storage_add_tab'); ?>
78
+ </h2>
79
+ <?php do_action('wpvivid_storage_add_page'); ?>
80
+ </div>
81
  </div>
82
+
83
+
84
  <script>
85
  function select_remote_storage(evt, storage_page_id)
86
  {
94
  jQuery(".storage-account-page").hide();
95
  jQuery("#"+storage_page_id).show();
96
  }
97
+ function switchstorageTabs(evt,contentName,storage_page_id) {
98
+ // Declare all variables
99
+ var i, tabcontent, tablinks;
100
+
101
+ // Get all elements with class="table-list-content" and hide them
102
+ tabcontent = document.getElementsByClassName("storage-tab-content");
103
+ for (i = 0; i < tabcontent.length; i++) {
104
+ tabcontent[i].style.display = "none";
105
+ }
106
+
107
+ // Get all elements with class="table-nav-tab" and remove the class "nav-tab-active"
108
+ tablinks = document.getElementsByClassName("storage-nav-tab");
109
+ for (i = 0; i < tablinks.length; i++) {
110
+ tablinks[i].className = tablinks[i].className.replace(" nav-tab-active", "");
111
+ }
112
+
113
+ // Show the current tab, and add an "storage-menu-active" class to the button that opened the tab
114
+ document.getElementById(contentName).style.display = "block";
115
+ evt.currentTarget.className += " nav-tab-active";
116
+
117
+ var top = jQuery('#'+storage_page_id).offset().top-jQuery('#'+storage_page_id).height();
118
+ jQuery('html, body').animate({scrollTop:top}, 'slow');
119
+ }
120
  </script>
admin/partials/wpvivid-settings-page-display.php CHANGED
@@ -220,25 +220,25 @@ function wpvivid_clean_junk()
220
  <div class="schedule-tab-block">
221
  <fieldset>
222
  <label for="wpvivid_junk_log">
223
- <input id="wpvivid_junk_log" name="junk-files" type="checkbox" id="" value="junk-log" />
224
  <span><?php _e( 'logs', 'wpvivid' ); ?></span>
225
  <span><?php _e('Path:', 'wpvivid' ); ?></span><span id="wpvivid_junk_log_path"><?php _e($junk_file['log_path'], 'wpvivid'); ?></span>
226
  </label>
227
  </fieldset>
228
  <fieldset>
229
  <label for="wpvivid_junk_backup_cache">
230
- <input id="wpvivid_junk_backup_cache" name="junk-files" type="checkbox" id="" value="junk-backup-cache" />
231
  <span><?php _e( 'Backup Cache', 'wpvivid' ); ?></span>
232
  </label>
233
  <label for="wpvivid_junk_file">
234
- <input id="wpvivid_junk_file" name="junk-files" type="checkbox" id="" value="junk-files" />
235
  <span><?php _e( 'Junk', 'wpvivid' ); ?></span>
236
  <span><?php _e('Path:', 'wpvivid' ); ?></span><span id="wpvivid_junk_file_path"><?php _e($junk_file['junk_path'], 'wpvivid'); ?></span>
237
  </label>
238
  </fieldset>
239
  <fieldset>
240
  <label for="wpvivid_junk_temporary_file">
241
- <input id="wpvivid_junk_temporary_file" name="junk-files" type="checkbox" id="" value="junk-temporary-files" />
242
  <span><?php _e( 'Temporary Files', 'wpvivid' ); ?></span>
243
  <span><?php _e('Path:', 'wpvivid'); ?></span><span id="wpvivid_restore_temp_file_path"><?php _e($junk_file['old_files_path'], 'wpvivid'); ?></span>
244
  <p><?php _e('Temporary Files are created by wpvivid when restoring a website.', 'wpvivid'); ?></p>
@@ -342,7 +342,7 @@ function wpvivid_schedule_settings()
342
  </label>
343
  </fieldset>
344
  </div>
345
- <div id="schedule_upload_storage">
346
  <?php
347
  $pic='';
348
  $pic= apply_filters('wpvivid_schedule_add_remote_pic',$pic);
@@ -422,8 +422,8 @@ function wpvivid_schedule_do_js()
422
  <?php
423
  }
424
 
425
- add_action('wpvivid_setting_add_cell','wpvivid_schedule_settings',10);
426
- add_action('wpvivid_setting_add_cell','wpvivid_general_settings',11);
427
  add_action('wpvivid_setting_add_cell','wpvivid_compressing',12);
428
  add_action('wpvivid_setting_add_cell','wpvivid_email_report',13);
429
  add_action('wpvivid_setting_add_cell','wpvivid_clean_junk',14);
220
  <div class="schedule-tab-block">
221
  <fieldset>
222
  <label for="wpvivid_junk_log">
223
+ <input type="checkbox" id="wpvivid_junk_log" option="junk-files" name="log" value="junk-log" />
224
  <span><?php _e( 'logs', 'wpvivid' ); ?></span>
225
  <span><?php _e('Path:', 'wpvivid' ); ?></span><span id="wpvivid_junk_log_path"><?php _e($junk_file['log_path'], 'wpvivid'); ?></span>
226
  </label>
227
  </fieldset>
228
  <fieldset>
229
  <label for="wpvivid_junk_backup_cache">
230
+ <input type="checkbox" id="wpvivid_junk_backup_cache" option="junk-files" name="backup_cache" value="junk-backup-cache" />
231
  <span><?php _e( 'Backup Cache', 'wpvivid' ); ?></span>
232
  </label>
233
  <label for="wpvivid_junk_file">
234
+ <input type="checkbox" id="wpvivid_junk_file" option="junk-files" name="junk_files" value="junk-files" />
235
  <span><?php _e( 'Junk', 'wpvivid' ); ?></span>
236
  <span><?php _e('Path:', 'wpvivid' ); ?></span><span id="wpvivid_junk_file_path"><?php _e($junk_file['junk_path'], 'wpvivid'); ?></span>
237
  </label>
238
  </fieldset>
239
  <fieldset>
240
  <label for="wpvivid_junk_temporary_file">
241
+ <input type="checkbox" id="wpvivid_junk_temporary_file" option="junk-files" name="old_files" value="junk-temporary-files" />
242
  <span><?php _e( 'Temporary Files', 'wpvivid' ); ?></span>
243
  <span><?php _e('Path:', 'wpvivid'); ?></span><span id="wpvivid_restore_temp_file_path"><?php _e($junk_file['old_files_path'], 'wpvivid'); ?></span>
244
  <p><?php _e('Temporary Files are created by wpvivid when restoring a website.', 'wpvivid'); ?></p>
342
  </label>
343
  </fieldset>
344
  </div>
345
+ <div id="schedule_upload_storage" style="cursor:pointer;" title="Highlighted icon illuminates that you have choosed a remote storage to store backups">
346
  <?php
347
  $pic='';
348
  $pic= apply_filters('wpvivid_schedule_add_remote_pic',$pic);
422
  <?php
423
  }
424
 
425
+ add_action('wpvivid_setting_add_cell','wpvivid_general_settings',10);
426
+ add_action('wpvivid_setting_add_cell','wpvivid_schedule_settings',11);
427
  add_action('wpvivid_setting_add_cell','wpvivid_compressing',12);
428
  add_action('wpvivid_setting_add_cell','wpvivid_email_report',13);
429
  add_action('wpvivid_setting_add_cell','wpvivid_clean_junk',14);
includes/class-wpvivid-backup-site.php CHANGED
@@ -30,7 +30,7 @@ class WPvivid_Backup_Site
30
  break;
31
 
32
  }
33
- $data['log']-> WriteLog('compressing '.$data['type'].' completed','notice');
34
  return $flag;
35
  }
36
 
30
  break;
31
 
32
  }
33
+ $data['log']-> WriteLog('Compressing '.$data['type'].' completed','notice');
34
  return $flag;
35
  }
36
 
includes/class-wpvivid-downloader.php CHANGED
@@ -127,7 +127,16 @@ class WPvivid_downloader
127
  }
128
  else
129
  {
130
- $task=WPvivid_taskmanager::new_download_task($download_info['backup_id'],$download_option,$need_download_files);
 
 
 
 
 
 
 
 
 
131
  }
132
 
133
  foreach ($need_download_files as $file)
127
  }
128
  else
129
  {
130
+ if(WPvivid_taskmanager::is_download_task_running($download_info['backup_id'],$download_option,$download_info['file_name']))
131
+ {
132
+ global $wpvivid_pulgin;
133
+ $wpvivid_pulgin->wpvivid_log->WriteLog('has a downloading task,exit download.','test');
134
+ return false;
135
+ }
136
+ else
137
+ {
138
+ $task=WPvivid_taskmanager::new_download_task($download_info['backup_id'],$download_option,$need_download_files);
139
+ }
140
  }
141
 
142
  foreach ($need_download_files as $file)
includes/class-wpvivid-remote-collection.php CHANGED
@@ -10,6 +10,9 @@ require_once WPVIVID_PLUGIN_DIR .'/includes/customclass/class-wpvivid-remote-def
10
  require_once WPVIVID_PLUGIN_DIR .'/includes/customclass/class-wpvivid-ftpclass.php';
11
  require_once WPVIVID_PLUGIN_DIR. '/includes/customclass/class-wpvivid-sftpclass.php';
12
  require_once WPVIVID_PLUGIN_DIR . '/includes/customclass/class-wpvivid-amazons3-plus.php';
 
 
 
13
 
14
  class WPvivid_Remote_collection
15
  {
@@ -38,26 +41,52 @@ class WPvivid_Remote_collection
38
  return $object;
39
  }
40
 
41
- public function add_remote($remote)
42
  {
 
43
 
44
- if(is_array($remote)&&array_key_exists('type',$remote)&&array_key_exists($remote['type'],$this->remote_collection))
 
 
45
  {
46
- $default=$remote['default'];
47
- unset($remote['default']);
48
- $id=WPvivid_Setting::add_remote_options($remote);
49
- if($default==1)
50
  {
51
- $remote_ids[]=$id;
52
- WPvivid_Setting::update_user_history('remote_selected',$remote_ids);
 
 
 
 
 
 
 
53
  }
54
- $ret['result']=WPVIVID_SUCCESS;
55
  }
56
- else
 
 
 
 
 
 
 
 
 
 
 
57
  {
58
- $ret['result']=WPVIVID_FAILED;
59
- $ret['error']='not found remote type';
 
 
 
 
 
 
60
  }
 
61
  return $ret;
62
  }
63
 
@@ -67,6 +96,9 @@ class WPvivid_Remote_collection
67
  $remote_collection['sftp']='WPvivid_SFTPClass';
68
  $remote_collection['ftp']='WPvivid_FTPClass';
69
  $remote_collection['amazons3']='WPvivid_AMAZONS3Class';
 
 
 
70
  return $remote_collection;
71
  }
72
 
10
  require_once WPVIVID_PLUGIN_DIR .'/includes/customclass/class-wpvivid-ftpclass.php';
11
  require_once WPVIVID_PLUGIN_DIR. '/includes/customclass/class-wpvivid-sftpclass.php';
12
  require_once WPVIVID_PLUGIN_DIR . '/includes/customclass/class-wpvivid-amazons3-plus.php';
13
+ require_once WPVIVID_PLUGIN_DIR . '/includes/customclass/class-wpvivid-google-drive.php';
14
+ require_once WPVIVID_PLUGIN_DIR . '/includes/customclass/class-wpvivid-dropbox.php';
15
+ require_once WPVIVID_PLUGIN_DIR . '/includes/customclass/class-wpvivid-one-drive.php';
16
 
17
  class WPvivid_Remote_collection
18
  {
41
  return $object;
42
  }
43
 
44
+ public function add_remote($remote_option)
45
  {
46
+ $remote=$this->get_remote($remote_option);
47
 
48
+ $ret=$remote->sanitize_options();
49
+
50
+ if($ret['result']=='success')
51
  {
52
+ $remote_option=$ret['options'];
53
+ $ret=$remote->test_connect();
54
+ if($ret['result']=='success')
 
55
  {
56
+ $ret=array();
57
+ $default=$remote_option['default'];
58
+ $id=WPvivid_Setting::add_remote_options($remote_option);
59
+ if($default==1)
60
+ {
61
+ $remote_ids[]=$id;
62
+ WPvivid_Setting::update_user_history('remote_selected',$remote_ids);
63
+ }
64
+ $ret['result']=WPVIVID_SUCCESS;
65
  }
 
66
  }
67
+
68
+ return $ret;
69
+ }
70
+
71
+ public function update_remote($id,$remote_option)
72
+ {
73
+ $remote=$this->get_remote($remote_option);
74
+
75
+ $old_remote=WPvivid_Setting::get_remote_option($id);
76
+
77
+ $ret=$remote->sanitize_options($old_remote['name']);
78
+ if($ret['result']=='success')
79
  {
80
+ $remote_option=$ret['options'];
81
+ $ret=$remote->test_connect();
82
+ if($ret['result']=='success')
83
+ {
84
+ $ret=array();
85
+ WPvivid_Setting::update_remote_option($id,$remote_option);
86
+ $ret['result']=WPVIVID_SUCCESS;
87
+ }
88
  }
89
+
90
  return $ret;
91
  }
92
 
96
  $remote_collection['sftp']='WPvivid_SFTPClass';
97
  $remote_collection['ftp']='WPvivid_FTPClass';
98
  $remote_collection['amazons3']='WPvivid_AMAZONS3Class';
99
+ $remote_collection[WPVIVID_REMOTE_GOOGLEDRIVE] = 'Wpvivid_Google_drive';
100
+ $remote_collection['dropbox']='WPvivid_Dropbox';
101
+ $remote_collection[WPVIVID_REMOTE_ONEDRIVE] = 'Wpvivid_one_drive';
102
  return $remote_collection;
103
  }
104
 
includes/class-wpvivid-setting.php CHANGED
@@ -306,6 +306,19 @@ class WPvivid_Setting
306
  return $backup_options;
307
  }
308
 
 
 
 
 
 
 
 
 
 
 
 
 
 
309
  public static function get_remote_options($remote_ids=array())
310
  {
311
  if(empty($remote_ids))
@@ -340,14 +353,6 @@ class WPvivid_Setting
340
  return $upload_options;
341
  }
342
 
343
- public static function update_remote_option($id,$remote)
344
- {
345
- $upload_options=self::get_option('wpvivid_upload_setting');
346
- $upload_options[$id]=$remote;
347
-
348
- self::update_option('wpvivid_upload_setting',$upload_options);
349
- }
350
-
351
  public static function add_remote_options($remote)
352
  {
353
  $upload_options=self::get_option('wpvivid_upload_setting');
@@ -362,6 +367,8 @@ class WPvivid_Setting
362
 
363
  public static function delete_remote_option($id)
364
  {
 
 
365
  $upload_options=self::get_option('wpvivid_upload_setting');
366
 
367
  if(array_key_exists($id,$upload_options))
@@ -377,6 +384,23 @@ class WPvivid_Setting
377
  }
378
  }
379
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
380
  public static function get_setting($all,$options_name)
381
  {
382
  $get_options=array();
306
  return $backup_options;
307
  }
308
 
309
+ public static function get_remote_option($id)
310
+ {
311
+ $upload_options=self::get_option('wpvivid_upload_setting');
312
+ if(array_key_exists($id,$upload_options))
313
+ {
314
+ return $upload_options[$id];
315
+ }
316
+ else
317
+ {
318
+ return false;
319
+ }
320
+ }
321
+
322
  public static function get_remote_options($remote_ids=array())
323
  {
324
  if(empty($remote_ids))
353
  return $upload_options;
354
  }
355
 
 
 
 
 
 
 
 
 
356
  public static function add_remote_options($remote)
357
  {
358
  $upload_options=self::get_option('wpvivid_upload_setting');
367
 
368
  public static function delete_remote_option($id)
369
  {
370
+ do_action('wpvivid_delete_remote_token',$id);
371
+
372
  $upload_options=self::get_option('wpvivid_upload_setting');
373
 
374
  if(array_key_exists($id,$upload_options))
384
  }
385
  }
386
 
387
+ public static function update_remote_option($remote_id,$remote)
388
+ {
389
+ $upload_options=self::get_option('wpvivid_upload_setting');
390
+
391
+ if(array_key_exists($remote_id,$upload_options))
392
+ {
393
+ $remote=apply_filters('wpvivid_pre_add_remote',$remote,$remote_id);
394
+ $upload_options[$remote_id]=$remote;
395
+ self::update_option('wpvivid_upload_setting',$upload_options);
396
+ return true;
397
+ }
398
+ else
399
+ {
400
+ return false;
401
+ }
402
+ }
403
+
404
  public static function get_setting($all,$options_name)
405
  {
406
  $get_options=array();
includes/class-wpvivid-taskmanager.php CHANGED
@@ -412,6 +412,35 @@ class WPvivid_taskmanager
412
  }
413
  return false;
414
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
415
  public static function delete_download_task($backup_id,$file_name)
416
  {
417
  $default = array();
412
  }
413
  return false;
414
  }
415
+ public static function is_download_task_running($backup_id,$download_type,$file_name)
416
+ {
417
+ $default = array();
418
+ $options = get_option('wpvivid_download_task', $default);
419
+
420
+ if(empty($options))
421
+ {
422
+ return false;
423
+ }
424
+ if(array_key_exists($backup_id,$options))
425
+ {
426
+ if(array_key_exists($download_type,$options[$backup_id]))
427
+ {
428
+ if(array_key_exists($file_name,$options[$backup_id][$download_type]['files']))
429
+ {
430
+ $task=$options[$backup_id][$download_type];
431
+
432
+ if(time()-$task['run_time']>60)
433
+ {
434
+ return false;
435
+ }
436
+ else {
437
+ return true;
438
+ }
439
+ }
440
+ }
441
+ }
442
+ return false;
443
+ }
444
  public static function delete_download_task($backup_id,$file_name)
445
  {
446
  $default = array();
includes/class-wpvivid.php CHANGED
@@ -85,6 +85,8 @@ class WPvivid {
85
  add_filter('wpvivid_add_remote_storage_list', array( $this, 'wpvivid_add_remote_storage_list' ), 10);
86
  add_filter('wpvivid_schedule_add_remote_pic', array( $this, 'wpvivid_schedule_add_remote_pic' ), 10);
87
  add_filter('wpvivid_get_remote_directory', array( $this, 'wpvivid_get_remote_directory' ), 10);
 
 
88
 
89
  //Initialisation schedule hook
90
  $this->init_cron();
@@ -124,7 +126,6 @@ class WPvivid {
124
  include_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpvivid-mail-report.php';
125
  include_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpvivid-restore.php';
126
 
127
-
128
  include_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpvivid-remote-collection.php';
129
  $this->remote_collection=new WPvivid_Remote_collection();
130
  }
@@ -151,6 +152,15 @@ class WPvivid {
151
  // Add Settings link to the plugin
152
  $plugin_basename = plugin_basename( plugin_dir_path( __DIR__ ) . 'wpvivid-backuprestore.php' );
153
  add_filter('plugin_action_links_' . $plugin_basename, array( $plugin_admin,'add_action_links'));
 
 
 
 
 
 
 
 
 
154
  }
155
 
156
  public function wpjam_pre_update_option_cache($value, $option)
@@ -167,6 +177,10 @@ class WPvivid {
167
  add_action('wp_ajax_wpvivid_add_remote',array( $this,'add_remote'));
168
  //Delete remote storage
169
  add_action('wp_ajax_wpvivid_delete_remote',array( $this,'delete_remote'));
 
 
 
 
170
  //List exist remote
171
  add_action('wp_ajax_wpvivid_list_remote',array( $this,'list_remote'));
172
  //Test remote connection
@@ -258,8 +272,6 @@ class WPvivid {
258
  add_action('wp_ajax_wpvivid_set_default_remote_storage',array( $this,'set_default_remote_storage'));
259
  //Get default remote storage when backing up
260
  add_action('wp_ajax_wpvivid_get_default_remote_storage',array( $this,'get_default_remote_storage'));
261
- //
262
- add_action('wp_ajax_wpvivid_need_review',array( $this,'need_review'));
263
  }
264
 
265
  public function get_plugin_name()
@@ -344,6 +356,9 @@ class WPvivid {
344
  {
345
  //Check the website data to be backed up
346
  $ret['check']=$this->check_backup($ret['task_id'],$backup_options['backup_files']);
 
 
 
347
  }
348
  echo json_encode($ret);
349
 
@@ -483,7 +498,11 @@ class WPvivid {
483
  $json['data']=$buffer;
484
  echo json_encode($json);
485
  }
486
-
 
 
 
 
487
  die();
488
  }
489
  /**
@@ -496,6 +515,9 @@ class WPvivid {
496
  $this->ajax_check_security();
497
  if(!isset($_POST['log_file_name'])||empty($_POST['log_file_name'])||!is_string($_POST['log_file_name']))
498
  {
 
 
 
499
  die();
500
  }
501
  $option=sanitize_text_field($_POST['log_file_name']);
@@ -583,7 +605,11 @@ class WPvivid {
583
  $json['data']=$buffer;
584
  echo json_encode($json);
585
  }
586
-
 
 
 
 
587
  die();
588
  }
589
  /**
@@ -613,6 +639,7 @@ class WPvivid {
613
  $this->add_monitor_event($task_id,10);
614
  }
615
  $json['result']='success';
 
616
  echo json_encode($json);
617
  }
618
  die();
@@ -1078,12 +1105,6 @@ class WPvivid {
1078
  $this->wpvivid_log->WriteLog('Backup succeeded.','notice');
1079
  WPvivid_Backuplist::add_new_backup($task_id,$backup_data);
1080
 
1081
- $need_review=get_option('wpvivid_need_review','not');
1082
- if($need_review=='not')
1083
- {
1084
- update_option('wpvivid_need_review','show');
1085
- }
1086
-
1087
  WPvivid_mail_report::send_report_mail($task_id);
1088
 
1089
  $remote_options=WPvivid_taskmanager::get_task_options($task_id,'remote_options');
@@ -1875,6 +1896,72 @@ class WPvivid {
1875
  {
1876
  $this->ajax_check_security();
1877
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1878
  if(!isset($_POST['backup_id'])||empty($_POST['backup_id'])||!is_string($_POST['backup_id'])||!isset($_POST['file_name'])||empty($_POST['file_name'])||!is_string($_POST['file_name']))
1879
  {
1880
  die();
@@ -1969,6 +2056,8 @@ class WPvivid {
1969
  }
1970
 
1971
  $path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$download_dir.DIRECTORY_SEPARATOR;
 
 
1972
  foreach ($files as $file)
1973
  {
1974
  $b_need_download=true;
@@ -1981,7 +2070,12 @@ class WPvivid {
1981
  $b_need_download=false;
1982
  }
1983
  }
1984
-
 
 
 
 
 
1985
  if($b_need_download)
1986
  {
1987
  $task=WPvivid_taskmanager::get_download_task($backup_id,$check_type,$file['file_name']);
@@ -1990,6 +2084,12 @@ class WPvivid {
1990
  if($b_has_remote)
1991
  {
1992
  $data['files'][$file['file_name']]['status']='need_download';
 
 
 
 
 
 
1993
  }
1994
  else
1995
  {
@@ -2003,10 +2103,22 @@ class WPvivid {
2003
  if(time()-$task['run_time']>60)
2004
  {
2005
  $data['files'][$file['file_name']]['status']='timeout';
 
 
 
 
 
 
2006
  }
2007
  else
2008
  {
2009
  $data['files'][$file['file_name']]['status'] = 'running';
 
 
 
 
 
 
2010
  }
2011
  $data['files'][$file['file_name']]['progress_text']=$task['progress_text'];
2012
  }
@@ -2015,6 +2127,12 @@ class WPvivid {
2015
  if($b_has_remote)
2016
  {
2017
  $data['files'][$file['file_name']]['status']='need_download';
 
 
 
 
 
 
2018
  WPvivid_taskmanager::delete_download_task($backup_id,$file['file_name']);
2019
  }
2020
  else
@@ -2028,6 +2146,12 @@ class WPvivid {
2028
  if($b_has_remote)
2029
  {
2030
  $data['files'][$file['file_name']]['status']='need_download';
 
 
 
 
 
 
2031
  WPvivid_taskmanager::delete_download_task($backup_id,$file['file_name']);
2032
  }
2033
  else
@@ -2046,8 +2170,34 @@ class WPvivid {
2046
  $data['files'][$file['file_name']]['status']='completed';
2047
  $download_path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$download_dir.DIRECTORY_SEPARATOR.$file['file_name'];
2048
  $data['files'][$file['file_name']]['download_path']=$download_path;
 
 
 
 
 
 
2049
  }
2050
  $data['files'][$file['file_name']]['size']=$this->formatBytes($file['size']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2051
  }
2052
 
2053
  return $data;
@@ -2079,8 +2229,16 @@ class WPvivid {
2079
  }
2080
  }
2081
 
 
 
2082
  foreach ($files as $file)
2083
  {
 
 
 
 
 
 
2084
  $task=WPvivid_taskmanager::get_download_task($backup_id,$check_type,$file['file_name']);
2085
  if($task!==false)
2086
  {
@@ -2089,21 +2247,45 @@ class WPvivid {
2089
  if(time()-$task['run_time']>60)
2090
  {
2091
  $data['files'][$file['file_name']]['status']='timeout';
 
 
 
 
 
 
2092
  }
2093
  else
2094
  {
2095
  $data['files'][$file['file_name']]['status'] = 'running';
 
 
 
 
 
 
2096
  }
2097
  $data['files'][$file['file_name']]['progress_text'] = $task['progress_text'];
2098
  } else if ($task['files'][$file['file_name']]['status'] == 'completed')
2099
  {
2100
  $data['files'][$file['file_name']]['status'] = 'completed';
 
 
 
 
 
 
2101
  $download_path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$download_dir.DIRECTORY_SEPARATOR.$file['file_name'];
2102
  $data['files'][$file['file_name']]['download_path']=$download_path;
2103
  WPvivid_taskmanager::delete_download_task($backup_id, $file['file_name']);
2104
  } else if ($task['files'][$file['file_name']]['status'] == 'error')
2105
  {
2106
  $data['files'][$file['file_name']]['status'] = 'error';
 
 
 
 
 
 
2107
  $data['files'][$file['file_name']]['error']=__($task['files'][$file['file_name']]['error'], 'wpvivid');
2108
  WPvivid_taskmanager::delete_download_task($backup_id, $file['file_name']);
2109
  }
@@ -2113,9 +2295,35 @@ class WPvivid {
2113
  if($data['files'][$file['file_name']]['status']=='error')
2114
  {
2115
  $data['files'][$file['file_name']]['status']='need_download';
 
 
 
 
 
 
2116
  $data['files'][$file['file_name']]['error']='';
2117
  }
2118
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2119
  }
2120
 
2121
  return $data;
@@ -2524,6 +2732,7 @@ class WPvivid {
2524
  {
2525
  die();
2526
  }
 
2527
  $remote_options['type']=$_POST['type'];
2528
  $ret=$this->remote_collection->add_remote($remote_options);
2529
  if($ret['result']=='success')
@@ -2581,6 +2790,77 @@ class WPvivid {
2581
  echo json_encode($ret);
2582
  die();
2583
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2584
  /**
2585
  * List exist remote
2586
  *
@@ -3074,17 +3354,40 @@ class WPvivid {
3074
  {
3075
  $this->ajax_check_security('manage_options');
3076
 
 
 
 
 
 
 
 
 
 
 
 
3077
  $message=WPvivid_Setting::get_last_backup_message('wpvivid_last_msg');
3078
  if(empty($message)){
3079
- $ret['result']='failed';
3080
- $ret['data']=__('The last backup message not found.', 'wpvivid');
3081
  }
3082
  else{
3083
- $ret['result']='success';
3084
- $ret['data']=$message;
 
 
 
 
 
 
 
 
 
 
 
 
 
3085
  }
3086
- echo json_encode($ret);
3087
- die();
3088
  }
3089
 
3090
  public function list_tasks()
@@ -3128,18 +3431,173 @@ class WPvivid {
3128
  }
3129
  }
3130
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3131
  }
3132
  }
3133
 
3134
  $ret['backup']['result']='success';
3135
  $ret['backup']['data']=$list_tasks;
 
3136
  $ret['download']['data']=array();
3137
  if($backup_id !== false) {
3138
  $ret['download'] = self::update_download_page($backup_id);
3139
  }
 
 
 
 
 
 
 
 
 
 
3140
  return $ret;
3141
  }
3142
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3143
  public function clean_cache()
3144
  {
3145
  delete_option('wpvivid_download_cache');
@@ -3353,6 +3811,13 @@ class WPvivid {
3353
  {
3354
  die();
3355
  }
 
 
 
 
 
 
 
3356
  $delete_files = array();
3357
  $delete_folder=array();
3358
  if($options['log']=='1')
@@ -3432,7 +3897,12 @@ class WPvivid {
3432
  }
3433
 
3434
  $ret['result']='success';
 
3435
  $ret['data']=$this->_junk_files_info();
 
 
 
 
3436
  echo json_encode($ret);
3437
  die();
3438
  }
@@ -3539,6 +4009,9 @@ class WPvivid {
3539
 
3540
  if(!isset($_POST['remote_storage'])||empty($_POST['remote_storage'])||!is_array($_POST['remote_storage']))
3541
  {
 
 
 
3542
  die();
3543
  }
3544
  $remote_storage = $_POST['remote_storage'];
@@ -3960,13 +4433,56 @@ class WPvivid {
3960
  public function get_log_list()
3961
  {
3962
  $this->ajax_check_security();
3963
-
3964
  $ret['result']='success';
3965
- $ret['data']=$this->get_log_list_ex();
 
 
 
3966
  echo json_encode($ret);
3967
  die();
3968
  }
3969
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3970
  public function get_log_list_ex(){
3971
  $ret['log_list']['file']=array();
3972
  $log=new WPvivid_Log();
@@ -4061,7 +4577,7 @@ class WPvivid {
4061
  if(!file_exists($path))
4062
  {
4063
  $json['result']='failed';
4064
- $json['error']=__('log file not found.', 'wpvivid').$path;
4065
  echo json_encode($json);
4066
  die();
4067
  }
@@ -4087,7 +4603,11 @@ class WPvivid {
4087
  $json['data']=$buffer;
4088
  echo json_encode($json);
4089
  }
4090
-
 
 
 
 
4091
  die();
4092
  }
4093
 
@@ -4245,25 +4765,13 @@ class WPvivid {
4245
  die();
4246
  }
4247
 
4248
- public function need_review()
4249
  {
4250
- $this->ajax_check_security();
4251
-
4252
- if(isset($_POST['review']))
4253
- {
4254
- $review=$_POST['review'];
4255
- if($review=='next_time')
4256
- {
4257
- $review=time()+ 604800;
4258
- }
4259
- update_option('wpvivid_need_review',$review);
4260
- }
4261
- die();
4262
- }
4263
-
4264
- public function wpvivid_add_backup_list($html){
4265
  $html = '';
4266
  $backuplist=WPvivid_Backuplist::get_backuplist();
 
 
 
4267
  foreach ($backuplist as $key=>$value) {
4268
  if(empty($value['lock'])){
4269
  $backup_lock='/admin/partials/images/unlocked.png';
@@ -4279,18 +4787,24 @@ class WPvivid {
4279
  $lock_status='lock';
4280
  }
4281
  }
4282
- $amazon_s3_url='/admin/partials/images/storage-amazon-s3(gray).png';
4283
- $ftp_url='/admin/partials/images/storage-ftp(gray).png';
4284
- $sftp_url='/admin/partials/images/storage-sftp(gray).png';
4285
- foreach ($value['remote'] as $storage_type) {
4286
- if($storage_type['type'] === WPVIVID_REMOTE_AMAZONS3){
4287
- $amazon_s3_url='/admin/partials/images/storage-amazon-s3.png';
4288
- }
4289
- if($storage_type['type'] === WPVIVID_REMOTE_FTP){
4290
- $ftp_url='/admin/partials/images/storage-ftp.png';
4291
- }
4292
- if($storage_type['type'] === WPVIVID_REMOTE_SFTP){
4293
- $sftp_url='/admin/partials/images/storage-sftp.png';
 
 
 
 
 
 
4294
  }
4295
  }
4296
  $html .= '<tr>
@@ -4303,17 +4817,13 @@ class WPvivid {
4303
  <img src="'.esc_url(WPVIVID_PLUGIN_URL.$backup_lock).'" name="'.esc_attr($lock_status, 'wpvivid').'" onclick="wpvivid_set_backup_lock(\''.__($key, 'wpvivid').'\', \''.__($lock_status, 'wpvivid').'\');" style="vertical-align:middle; cursor:pointer;"/>
4304
  </span>
4305
  | <span>'.__('Type:', 'wpvivid').'</span><span>'.__($value['type'], 'wpvivid').'</span>
4306
- |<span title="Backup log"><a href="#" onclick="wpvivid_initialize_log(\''.__($key, 'wpvivid').'\');"><img src="'.esc_url(WPVIVID_PLUGIN_URL.'/admin/partials/images/Log.png').'" style="vertical-align:middle;cursor:pointer;"/>'.__('Log', 'wpvivid').'</a></span>
4307
  |<span title="Restore Website from The Backup"><a href="#" onclick="wpvivid_initialize_restore(\''.__($key, 'wpvivid').'\',\''.__(date('M d, Y H:i',$value['create_time']), 'wpvivid').'\');"><img src="'.esc_url(WPVIVID_PLUGIN_URL. '/admin/partials/images/Restore.png').'" style="vertical-align:middle;cursor:pointer;"/>'.__('Restore', 'wpvivid').'</a></span>
4308
  </div>
4309
  </div>
4310
  </td>
4311
  <td class="tablelistcolumn">
4312
- <div style="float:left;padding:10px 10px 10px 0px;">
4313
- <img src="'.esc_url(WPVIVID_PLUGIN_URL.$amazon_s3_url).'" style="vertical-align:middle; " title="Amazon S3"/>
4314
- <img src="'.esc_url(WPVIVID_PLUGIN_URL.$ftp_url).'" style="vertical-align:middle;" title="FTP"/>
4315
- <img src="'.esc_url(WPVIVID_PLUGIN_URL.$sftp_url).'" style="vertical-align:middle;" title="SFTP"/>
4316
- </div>
4317
  </td>
4318
  <td class="tablelistcolumn">
4319
  <div id="wpvivid_file_part_'.__($key, 'wpvivid').'" style="float:left;padding:10px 10px 10px 0px;">
@@ -4333,7 +4843,8 @@ class WPvivid {
4333
  return $html;
4334
  }
4335
 
4336
- public function wpvivid_add_remote_storage_list($html){
 
4337
  $html = '';
4338
  $remoteslist=WPvivid_Setting::get_all_remote_options();
4339
  $default_remote_storage='';
@@ -4356,16 +4867,17 @@ class WPvivid {
4356
  $check_status='';
4357
  }
4358
  $storage_type = $value['type'];
4359
-
4360
  $html .= '<tr>
4361
  <td>'.__($i++, 'wpvivid').'</td>
4362
  <td><input type="checkbox" name="remote_storage" value="'.esc_attr($key, 'wpvivid').'" '.esc_attr($check_status, 'wpvivid').' /></td>
4363
  <td>'.__($storage_type, 'wpvivid').'</td>
4364
  <td class="row-title"><label for="tablecell">'.__($value['name'], 'wpvivid').'</label></td>
4365
- <td onclick="wpvivid_delete_remote_storage(\''.__($key, 'wpvivid').'\');"><img src="'.esc_url(WPVIVID_PLUGIN_URL.'/admin/partials/images/Delete.png').'" style="vertical-align:middle; cursor:pointer;" title="Delete the backup"/>
 
 
4366
  </td>
4367
  </tr>';
4368
-
4369
  }
4370
  return $html;
4371
  }
@@ -4398,7 +4910,7 @@ class WPvivid {
4398
  }
4399
  $html .= '<img src="' . esc_url(WPVIVID_PLUGIN_URL . $pic) . '" style="vertical-align:middle; " title="' . $title . '"/>';
4400
  }
4401
- $html.='<img onclick="wpvivid_click_switch_page(\'wpvivid_tab_remote_storage\', \'\');" src="'.esc_url(WPVIVID_PLUGIN_URL.'/admin/partials/images/add-storages.png').'" style="vertical-align:middle;" title="Add a storage"/>';
4402
  }
4403
  return $html;
4404
  }
@@ -4411,17 +4923,7 @@ class WPvivid {
4411
  {
4412
  foreach ($out_of_date['remote_options'] as $value)
4413
  {
4414
- if($value['type'] === 'ftp' || $value['type'] === 'sftp')
4415
- {
4416
- $out_of_date_remote=$value['path'];
4417
- }
4418
- else if($value['type'] === WPVIVID_REMOTE_AMAZONS3)
4419
- {
4420
- $out_of_date_remote=$value['s3Path'];
4421
- }
4422
- else{
4423
- $out_of_date_remote='There is no path for remote storage, please set it up first.';
4424
- }
4425
  }
4426
  }
4427
  return $out_of_date_remote;
85
  add_filter('wpvivid_add_remote_storage_list', array( $this, 'wpvivid_add_remote_storage_list' ), 10);
86
  add_filter('wpvivid_schedule_add_remote_pic', array( $this, 'wpvivid_schedule_add_remote_pic' ), 10);
87
  add_filter('wpvivid_get_remote_directory', array( $this, 'wpvivid_get_remote_directory' ), 10);
88
+ add_filter('wpvivid_get_log_list', array( $this, 'wpvivid_get_log_list' ), 10);
89
+ add_filter('wpvivid_get_last_backup_message', array( $this, 'wpvivid_get_last_backup_message' ), 10);
90
 
91
  //Initialisation schedule hook
92
  $this->init_cron();
126
  include_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpvivid-mail-report.php';
127
  include_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpvivid-restore.php';
128
 
 
129
  include_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpvivid-remote-collection.php';
130
  $this->remote_collection=new WPvivid_Remote_collection();
131
  }
152
  // Add Settings link to the plugin
153
  $plugin_basename = plugin_basename( plugin_dir_path( __DIR__ ) . 'wpvivid-backuprestore.php' );
154
  add_filter('plugin_action_links_' . $plugin_basename, array( $plugin_admin,'add_action_links'));
155
+
156
+ add_filter('wpvivid_pre_add_remote',array($this, 'pre_add_remote'),10,2);
157
+ //
158
+ }
159
+
160
+ public function pre_add_remote($remote,$id)
161
+ {
162
+ unset($remote['default']);
163
+ return $remote;
164
  }
165
 
166
  public function wpjam_pre_update_option_cache($value, $option)
177
  add_action('wp_ajax_wpvivid_add_remote',array( $this,'add_remote'));
178
  //Delete remote storage
179
  add_action('wp_ajax_wpvivid_delete_remote',array( $this,'delete_remote'));
180
+ //Retrieve remote storage
181
+ add_action('wp_ajax_wpvivid_retrieve_remote',array( $this,'retrieve_remote'));
182
+ //Edit remote storage
183
+ add_action('wp_ajax_wpvivid_edit_remote',array( $this,'edit_remote'));
184
  //List exist remote
185
  add_action('wp_ajax_wpvivid_list_remote',array( $this,'list_remote'));
186
  //Test remote connection
272
  add_action('wp_ajax_wpvivid_set_default_remote_storage',array( $this,'set_default_remote_storage'));
273
  //Get default remote storage when backing up
274
  add_action('wp_ajax_wpvivid_get_default_remote_storage',array( $this,'get_default_remote_storage'));
 
 
275
  }
276
 
277
  public function get_plugin_name()
356
  {
357
  //Check the website data to be backed up
358
  $ret['check']=$this->check_backup($ret['task_id'],$backup_options['backup_files']);
359
+ $html = '';
360
+ $html = apply_filters('wpvivid_add_backup_list', $html);
361
+ $ret['html'] = $html;
362
  }
363
  echo json_encode($ret);
364
 
498
  $json['data']=$buffer;
499
  echo json_encode($json);
500
  }
501
+ else{
502
+ $json['result']='failed';
503
+ $json['error']=__('Reading the log failed. Please try again.', 'wpvivid');
504
+ echo json_encode($json);
505
+ }
506
  die();
507
  }
508
  /**
515
  $this->ajax_check_security();
516
  if(!isset($_POST['log_file_name'])||empty($_POST['log_file_name'])||!is_string($_POST['log_file_name']))
517
  {
518
+ $json['result']='failed';
519
+ $json['error']=__('Reading the log failed. Please try again.', 'wpvivid');
520
+ echo json_encode($json);
521
  die();
522
  }
523
  $option=sanitize_text_field($_POST['log_file_name']);
605
  $json['data']=$buffer;
606
  echo json_encode($json);
607
  }
608
+ else{
609
+ $json['result']='failed';
610
+ $json['error']=__('Reading the log failed. Please try again.', 'wpvivid');
611
+ echo json_encode($json);
612
+ }
613
  die();
614
  }
615
  /**
639
  $this->add_monitor_event($task_id,10);
640
  }
641
  $json['result']='success';
642
+ $json['msg']=__('The backup will be canceled after backing up the current chunk ends.', 'wpvivid');
643
  echo json_encode($json);
644
  }
645
  die();
1105
  $this->wpvivid_log->WriteLog('Backup succeeded.','notice');
1106
  WPvivid_Backuplist::add_new_backup($task_id,$backup_data);
1107
 
 
 
 
 
 
 
1108
  WPvivid_mail_report::send_report_mail($task_id);
1109
 
1110
  $remote_options=WPvivid_taskmanager::get_task_options($task_id,'remote_options');
1896
  {
1897
  $this->ajax_check_security();
1898
 
1899
+ /*global $wpvivid_pulgin;
1900
+ $log_file_name=uniqid('test-');
1901
+ $wpvivid_pulgin->wpvivid_log=new WPvivid_Log();
1902
+ $wpvivid_pulgin->wpvivid_log->CreateLogFile($log_file_name,'no_folder','test');
1903
+ $wpvivid_pulgin->wpvivid_log->WriteLog('start.','test');
1904
+ $pid=getmypid();
1905
+ $wpvivid_pulgin->wpvivid_log->WriteLog('pid:'.$pid,'test');
1906
+ if (defined('DOING_AJAX') && DOING_AJAX)
1907
+ {
1908
+ $wpvivid_pulgin->wpvivid_log->WriteLog('call from ajax','test');
1909
+ }
1910
+ else
1911
+ {
1912
+ $wpvivid_pulgin->wpvivid_log->WriteLog('call not from ajax','test');
1913
+ }
1914
+ if(!isset($_POST['backup_id'])||empty($_POST['backup_id'])||!is_string($_POST['backup_id'])||!isset($_POST['file_name'])||empty($_POST['file_name'])||!is_string($_POST['file_name']))
1915
+ {
1916
+ die();
1917
+ }
1918
+ $download_info=array();
1919
+ $download_info['backup_id']=sanitize_key($_POST['backup_id']);
1920
+ $download_info['file_name']=sanitize_file_name($_POST['file_name']);
1921
+
1922
+ $this->set_time_limit(900);
1923
+
1924
+ $ret['result']='success';
1925
+ $json=json_encode($ret);
1926
+ header('Content-Length: '.strlen($json));
1927
+ header('Connection: close');
1928
+ header('Content-Encoding: none');
1929
+
1930
+ if (session_id())
1931
+ session_write_close();
1932
+ echo $json;
1933
+
1934
+ if(function_exists('fastcgi_finish_request'))
1935
+ {
1936
+ fastcgi_finish_request();
1937
+ }
1938
+ else
1939
+ {
1940
+ ob_flush();
1941
+ flush();
1942
+ }
1943
+
1944
+ try
1945
+ {
1946
+ $downloader=new WPvivid_downloader();
1947
+ $downloader->ready_download($download_info);
1948
+ }
1949
+ catch (Exception $e)
1950
+ {
1951
+ $message = 'A exception ('.get_class($e).') occurred '.$e->getMessage().' (Code: '.$e->getCode().', line '.$e->getLine().' in '.$e->getFile().')';
1952
+ error_log($message);
1953
+ }
1954
+ catch (Error $e)
1955
+ {
1956
+ $message = 'A error ('.get_class($e).') has occurred: '.$e->getMessage().' (Code: '.$e->getCode().', line '.$e->getLine().' in '.$e->getFile().')';
1957
+ error_log($message);
1958
+ }
1959
+
1960
+ $ret['result']='success';
1961
+ $json=json_encode($ret);
1962
+ echo $json;
1963
+ die();*/
1964
+
1965
  if(!isset($_POST['backup_id'])||empty($_POST['backup_id'])||!is_string($_POST['backup_id'])||!isset($_POST['file_name'])||empty($_POST['file_name'])||!is_string($_POST['file_name']))
1966
  {
1967
  die();
2056
  }
2057
 
2058
  $path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$download_dir.DIRECTORY_SEPARATOR;
2059
+ $file_count=0;
2060
+ $file_part_num=1;
2061
  foreach ($files as $file)
2062
  {
2063
  $b_need_download=true;
2070
  $b_need_download=false;
2071
  }
2072
  }
2073
+ if($file_part_num < 10){
2074
+ $format_part=sprintf("%02d", $file_part_num);
2075
+ }
2076
+ else{
2077
+ $format_part=$file_part_num;
2078
+ }
2079
  if($b_need_download)
2080
  {
2081
  $task=WPvivid_taskmanager::get_download_task($backup_id,$check_type,$file['file_name']);
2084
  if($b_has_remote)
2085
  {
2086
  $data['files'][$file['file_name']]['status']='need_download';
2087
+ $data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0px;text-align:center; width:290px;">
2088
+ <span>Part'.$format_part.'</span></br>
2089
+ <span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
2090
+ <div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:0%;height:5px;"></div></div>
2091
+ <span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
2092
+ </div>';
2093
  }
2094
  else
2095
  {
2103
  if(time()-$task['run_time']>60)
2104
  {
2105
  $data['files'][$file['file_name']]['status']='timeout';
2106
+ $data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0px;text-align:center; width:290px;">
2107
+ <span>Part'.$format_part.'</span></br>
2108
+ <span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
2109
+ <div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:'.$task['progress_text'].'%;height:5px;"></div></div>
2110
+ <span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
2111
+ </div>';
2112
  }
2113
  else
2114
  {
2115
  $data['files'][$file['file_name']]['status'] = 'running';
2116
+ $data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0px;text-align:center; width:290px;">
2117
+ <span>Part'.$format_part.'</span></br>
2118
+ <span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a >Retriving(remote storage to web server)</a></span></br>
2119
+ <div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:'.$task['progress_text'].'%;height:5px;"></div></div>
2120
+ <span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
2121
+ </div>';
2122
  }
2123
  $data['files'][$file['file_name']]['progress_text']=$task['progress_text'];
2124
  }
2127
  if($b_has_remote)
2128
  {
2129
  $data['files'][$file['file_name']]['status']='need_download';
2130
+ $data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0px;text-align:center; width:290px;">
2131
+ <span>Part'.$format_part.'</span></br>
2132
+ <span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
2133
+ <div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:0%;height:5px;"></div></div>
2134
+ <span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
2135
+ </div>';
2136
  WPvivid_taskmanager::delete_download_task($backup_id,$file['file_name']);
2137
  }
2138
  else
2146
  if($b_has_remote)
2147
  {
2148
  $data['files'][$file['file_name']]['status']='need_download';
2149
+ $data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0px;text-align:center; width:290px;">
2150
+ <span>Part'.$format_part.'</span></br>
2151
+ <span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
2152
+ <div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:0%;height:5px;"></div></div>
2153
+ <span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
2154
+ </div>';
2155
  WPvivid_taskmanager::delete_download_task($backup_id,$file['file_name']);
2156
  }
2157
  else
2170
  $data['files'][$file['file_name']]['status']='completed';
2171
  $download_path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$download_dir.DIRECTORY_SEPARATOR.$file['file_name'];
2172
  $data['files'][$file['file_name']]['download_path']=$download_path;
2173
+ $data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0px;text-align:center; width:290px;">
2174
+ <span>Part'.$format_part.'</span></br>
2175
+ <span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_download(\''.$backup_id.'\', \''.$check_type.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Download</a></span></br>
2176
+ <div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:100%;height:5px;"></div></div>
2177
+ <span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
2178
+ </div>';
2179
  }
2180
  $data['files'][$file['file_name']]['size']=$this->formatBytes($file['size']);
2181
+ $file_count++;
2182
+ $file_part_num++;
2183
+ }
2184
+ if ($file_count % 2 != 0) {
2185
+ $file_count++;
2186
+ if($file_count < 10){
2187
+ $format_part=sprintf("%02d", $file_count);
2188
+ }
2189
+ else{
2190
+ $format_part=$file_count;
2191
+ }
2192
+ $data['place_html']='<div style="float:left;margin:10px 10px 10px 0px;text-align:center; width:290px; color:#cccccc;">
2193
+ <span>Part'.$format_part.'</span></br>
2194
+ <span>Download</span></br>
2195
+ <div style="width:100%;height:5px; background-color:#dcdcdc;"><div style="background-color:#0085ba; float:left;width:0%;height:5px;"></div></div>
2196
+ <span>size:</span><span>0</span>
2197
+ </div>';
2198
+ }
2199
+ else{
2200
+ $data['place_html']='';
2201
  }
2202
 
2203
  return $data;
2229
  }
2230
  }
2231
 
2232
+ $file_count=0;
2233
+ $file_part_num=1;
2234
  foreach ($files as $file)
2235
  {
2236
+ if($file_part_num < 10){
2237
+ $format_part=sprintf("%02d", $file_part_num);
2238
+ }
2239
+ else{
2240
+ $format_part=$file_part_num;
2241
+ }
2242
  $task=WPvivid_taskmanager::get_download_task($backup_id,$check_type,$file['file_name']);
2243
  if($task!==false)
2244
  {
2247
  if(time()-$task['run_time']>60)
2248
  {
2249
  $data['files'][$file['file_name']]['status']='timeout';
2250
+ $data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0px;text-align:center; width:290px;">
2251
+ <span>Part'.$format_part.'</span></br>
2252
+ <span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
2253
+ <div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:'.$task['progress_text'].'%;height:5px;"></div></div>
2254
+ <span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
2255
+ </div>';
2256
  }
2257
  else
2258
  {
2259
  $data['files'][$file['file_name']]['status'] = 'running';
2260
+ $data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0px;text-align:center; width:290px;">
2261
+ <span>Part'.$format_part.'</span></br>
2262
+ <span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a >Retriving(remote storage to web server)</a></span></br>
2263
+ <div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:'.$task['progress_text'].'%;height:5px;"></div></div>
2264
+ <span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
2265
+ </div>';
2266
  }
2267
  $data['files'][$file['file_name']]['progress_text'] = $task['progress_text'];
2268
  } else if ($task['files'][$file['file_name']]['status'] == 'completed')
2269
  {
2270
  $data['files'][$file['file_name']]['status'] = 'completed';
2271
+ $data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0px;text-align:center; width:290px;">
2272
+ <span>Part'.$format_part.'</span></br>
2273
+ <span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_download(\''.$backup_id.'\', \''.$check_type.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Download</a></span></br>
2274
+ <div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:100%;height:5px;"></div></div>
2275
+ <span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
2276
+ </div>';
2277
  $download_path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$download_dir.DIRECTORY_SEPARATOR.$file['file_name'];
2278
  $data['files'][$file['file_name']]['download_path']=$download_path;
2279
  WPvivid_taskmanager::delete_download_task($backup_id, $file['file_name']);
2280
  } else if ($task['files'][$file['file_name']]['status'] == 'error')
2281
  {
2282
  $data['files'][$file['file_name']]['status'] = 'error';
2283
+ $data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0px;text-align:center; width:290px;">
2284
+ <span>Part'.$format_part.'</span></br>
2285
+ <span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
2286
+ <div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:0%;height:5px;"></div></div>
2287
+ <span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
2288
+ </div>';
2289
  $data['files'][$file['file_name']]['error']=__($task['files'][$file['file_name']]['error'], 'wpvivid');
2290
  WPvivid_taskmanager::delete_download_task($backup_id, $file['file_name']);
2291
  }
2295
  if($data['files'][$file['file_name']]['status']=='error')
2296
  {
2297
  $data['files'][$file['file_name']]['status']='need_download';
2298
+ $data['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0px;text-align:center; width:290px;">
2299
+ <span>Part'.$format_part.'</span></br>
2300
+ <span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_prepare_download(\''.$file_part_num.'\', \''.$backup_id.'\', \''.$file['file_name'].'\');" style="cursor: pointer">Prepare to Download</a></span></br>
2301
+ <div style="width:100%;height:5px; background-color:#dcdcdc;"><div id=\''.$backup_id.'-progress-part-'.$file_part_num.'\' style="background-color:#0085ba; float:left;width:0%;height:5px;"></div></div>
2302
+ <span>size:</span><span>'.$this->formatBytes($file['size']).'</span>
2303
+ </div>';
2304
  $data['files'][$file['file_name']]['error']='';
2305
  }
2306
  }
2307
+ $file_count++;
2308
+ $file_part_num++;
2309
+ }
2310
+ if ($file_count % 2 != 0) {
2311
+ $file_count++;
2312
+ if($file_count < 10){
2313
+ $format_part=sprintf("%02d", $file_count);
2314
+ }
2315
+ else{
2316
+ $format_part=$file_count;
2317
+ }
2318
+ $data['place_html']='<div style="float:left;margin:10px 10px 10px 0px;text-align:center; width:290px; color:#cccccc;">
2319
+ <span>Part'.$format_part.'</span></br>
2320
+ <span>Download</span></br>
2321
+ <div style="width:100%;height:5px; background-color:#dcdcdc;"><div style="background-color:#0085ba; float:left;width:0%;height:5px;"></div></div>
2322
+ <span>size:</span><span>0</span>
2323
+ </div>';
2324
+ }
2325
+ else{
2326
+ $data['place_html']='';
2327
  }
2328
 
2329
  return $data;
2732
  {
2733
  die();
2734
  }
2735
+
2736
  $remote_options['type']=$_POST['type'];
2737
  $ret=$this->remote_collection->add_remote($remote_options);
2738
  if($ret['result']=='success')
2790
  echo json_encode($ret);
2791
  die();
2792
  }
2793
+
2794
+ /**
2795
+ * Retrieve remote storage
2796
+ *
2797
+ * @since 0.9.8
2798
+ */
2799
+ public function retrieve_remote()
2800
+ {
2801
+ $this->ajax_check_security();
2802
+ if(empty($_POST)||!isset($_POST['remote_id'])||!is_string($_POST['remote_id']))
2803
+ {
2804
+ die();
2805
+ }
2806
+ $id=sanitize_key($_POST['remote_id']);
2807
+ $remoteslist=WPvivid_Setting::get_all_remote_options();
2808
+ $ret['result']=WPVIVID_FAILED;
2809
+ $ret['error']=__('Failed to get the remote storage information. Please try again later.', 'wpvivid');
2810
+ foreach ($remoteslist as $key=>$value)
2811
+ {
2812
+ if($key == $id){
2813
+ if($key === 'remote_selected')
2814
+ {
2815
+ continue;
2816
+ }
2817
+ $ret = $value;
2818
+ $ret['result']=WPVIVID_SUCCESS;
2819
+ break;
2820
+ }
2821
+ }
2822
+ echo json_encode($ret);
2823
+ die();
2824
+ }
2825
+ /**
2826
+ * Edit remote storage
2827
+ *
2828
+ * @since 0.9.8
2829
+ */
2830
+ public function edit_remote()
2831
+ {
2832
+ $this->ajax_check_security();
2833
+ if(empty($_POST)||!isset($_POST['remote'])||!is_string($_POST['remote'])||!isset($_POST['id'])||!is_string($_POST['id'])||!isset($_POST['type'])||!is_string($_POST['type']))
2834
+ {
2835
+ die();
2836
+ }
2837
+ $json=$_POST['remote'];
2838
+ $json =stripslashes($json);
2839
+ $remote_options =json_decode($json,true);
2840
+ if(is_null($remote_options))
2841
+ {
2842
+ die();
2843
+ }
2844
+ $remote_options['type']=$_POST['type'];
2845
+ $ret=$this->remote_collection->update_remote($_POST['id'],$remote_options);
2846
+
2847
+ if($ret['result']=='success')
2848
+ {
2849
+ $ret['result']=WPVIVID_SUCCESS;
2850
+ $html = '';
2851
+ $html = apply_filters('wpvivid_add_remote_storage_list', $html);
2852
+ $ret['html'] = $html;
2853
+ $pic = '';
2854
+ $pic = apply_filters('wpvivid_schedule_add_remote_pic', $pic);
2855
+ $ret['pic'] = $pic;
2856
+ $dir = '';
2857
+ $dir = apply_filters('wpvivid_get_remote_directory', $dir);
2858
+ $ret['dir'] = $dir;
2859
+ }
2860
+
2861
+ echo json_encode($ret);
2862
+ die();
2863
+ }
2864
  /**
2865
  * List exist remote
2866
  *
3354
  {
3355
  $this->ajax_check_security('manage_options');
3356
 
3357
+ $html='';
3358
+ $html=apply_filters('wpvivid_get_last_backup_message', $html);
3359
+ $ret['data']=$html;
3360
+
3361
+ echo json_encode($ret);
3362
+ die();
3363
+ }
3364
+
3365
+ public function wpvivid_get_last_backup_message($html)
3366
+ {
3367
+ $html='';
3368
  $message=WPvivid_Setting::get_last_backup_message('wpvivid_last_msg');
3369
  if(empty($message)){
3370
+ $last_message=__('The last backup message not found.', 'wpvivid');
 
3371
  }
3372
  else{
3373
+ if($message['status']['str'] == 'completed'){
3374
+ $backup_status='Succeed';
3375
+ $last_message=$message['status']['start_time'].' '.$backup_status.' <a onclick="wpvivid_read_log(\''.__('wpvivid_read_last_backup_log').'\', \''.$message['log_file_name'].'\');" style="cursor:pointer;"> Log</a>';
3376
+ }
3377
+ elseif($message['status']['str'] == 'error'){
3378
+ $backup_status='Failed';
3379
+ $last_message=$message['status']['start_time'].' '.$backup_status.' <a onclick="wpvivid_read_log(\''.__('wpvivid_read_last_backup_log').'\', \''.$message['log_file_name'].'\');" style="cursor:pointer;"> Log</a>';
3380
+ }
3381
+ elseif($message['status']['str'] == 'cancel'){
3382
+ $backup_status='Failed';
3383
+ $last_message=$message['status']['start_time'].' '.$backup_status.' <a onclick="wpvivid_read_log(\''.__('wpvivid_read_last_backup_log').'\', \''.$message['log_file_name'].'\');" style="cursor:pointer;"> Log</a>';
3384
+ }
3385
+ else{
3386
+ $last_message=__('The last backup message not found.', 'wpvivid');
3387
+ }
3388
  }
3389
+ $html .= '<strong>'.__('Last Backup: ', 'wpvivid').'</strong>'.$last_message;
3390
+ return $html;
3391
  }
3392
 
3393
  public function list_tasks()
3431
  }
3432
  }
3433
  }
3434
+
3435
+ $general_setting=WPvivid_Setting::get_setting(true, "");
3436
+ if($general_setting['options']['wpvivid_common_setting']['estimate_backup'] == 0){
3437
+ $estimate_backup='display: none';
3438
+ }
3439
+ else{
3440
+ $estimate_backup='';
3441
+ }
3442
+ $backup_percent=$list_tasks[$task['id']]['data']['progress'].'%';
3443
+ if($list_tasks[$task['id']]['size']['db_size'] == false){
3444
+ $db_size=0;
3445
+ }
3446
+ else{
3447
+ $db_size=$list_tasks[$task['id']]['size']['db_size'];
3448
+ }
3449
+ if($list_tasks[$task['id']]['size']['files_size'] == false){
3450
+ $file_size=0;
3451
+ }
3452
+ else{
3453
+ $file_size=$list_tasks[$task['id']]['size']['files_size']['sum'];
3454
+ }
3455
+ $descript='';
3456
+ $css_btn_cancel='pointer-events: auto; opacity: 1;';
3457
+ $css_btn_log='pointer-events: auto; opacity: 1;';
3458
+ if($list_tasks[$task['id']]['status']['str']=='ready'){
3459
+ $descript=__('Ready to backup. Progress: 0%, running time: 0second.','wpvivid');
3460
+ $css_btn_cancel='pointer-events: none; opacity: 0.4;';
3461
+ $css_btn_log='pointer-events: none; opacity: 0.4;';
3462
+ }
3463
+ else if($list_tasks[$task['id']]['status']['str']=='running'){
3464
+ $time=$this->wpvivid_calc_backup_elapsed_time($list_tasks[$task['id']]['data']['running_time']);
3465
+ if($list_tasks[$task['id']]['is_canceled'] == false){
3466
+ $descript=$list_tasks[$task['id']]['data']['descript'].__(' Progress: ','wpvivid').$backup_percent.__(', running time: ','wpvivid').$time;
3467
+ $css_btn_cancel='pointer-events: auto; opacity: 1;';
3468
+ $css_btn_log='pointer-events: auto; opacity: 1;';
3469
+ }
3470
+ else{
3471
+ $descript=__('The backup will be canceled after backing up the current chunk ends.','wpvivid');
3472
+ $css_btn_cancel='pointer-events: none; opacity: 0.4;';
3473
+ $css_btn_log='pointer-events: auto; opacity: 1;';
3474
+ }
3475
+ }
3476
+ else if($list_tasks[$task['id']]['status']['str']=='wait_resume'){
3477
+ $descript='Task '.$task['id'].' timed out, backup task will retry in '.$list_tasks[$task['id']]['data']['next_resume_time'].' seconds, retry times: '.$list_tasks[$task['id']]['status']['resume_count'].'.';
3478
+ $css_btn_cancel='pointer-events: auto; opacity: 1;';
3479
+ $css_btn_log='pointer-events: auto; opacity: 1;';
3480
+ }
3481
+ else if($list_tasks[$task['id']]['status']['str']=='no_responds'){
3482
+ $time=$this->wpvivid_calc_backup_elapsed_time($list_tasks[$task['id']]['data']['running_time']);
3483
+ if($list_tasks[$task['id']]['is_canceled'] == false){
3484
+ $descript='Task , '.$list_tasks[$task['id']]['data']['doing'].' is not responding. Progress: '.$backup_percent.', running time: '.$time;
3485
+ $css_btn_cancel='pointer-events: auto; opacity: 1;';
3486
+ $css_btn_log='pointer-events: auto; opacity: 1;';
3487
+ }
3488
+ else{
3489
+ $descript=__('The backup will be canceled after backing up the current chunk ends.','wpvivid');
3490
+ $css_btn_cancel='pointer-events: none; opacity: 0.4;';
3491
+ $css_btn_log='pointer-events: auto; opacity: 1;';
3492
+ }
3493
+ }
3494
+ else if($list_tasks[$task['id']]['status']['str']=='completed'){
3495
+ $descript='Task '.$task['id'].' completed.';
3496
+ $css_btn_cancel='pointer-events: auto; opacity: 1;';
3497
+ $css_btn_log='pointer-events: auto; opacity: 1;';
3498
+ $html = '';
3499
+ $html = apply_filters('wpvivid_add_backup_list', $html);
3500
+ $list_tasks[$task['id']]['backuplist_html'] = $html;
3501
+ }
3502
+ else if($list_tasks[$task['id']]['status']['str']=='error'){
3503
+ $descript='Backup error: '.$list_tasks[$task['id']]['status']['error'];
3504
+ $css_btn_cancel='pointer-events: auto; opacity: 1;';
3505
+ $css_btn_log='pointer-events: auto; opacity: 1;';
3506
+ $html = '';
3507
+ $html = apply_filters('wpvivid_add_backup_list', $html);
3508
+ $list_tasks[$task['id']]['backuplist_html'] = $html;
3509
+ }
3510
+
3511
+ $list_tasks[$task['id']]['progress_html']='<div class="action-progress-bar" id="wpvivid_action_progress_bar">
3512
+ <div class="action-progress-bar-percent" id="wpvivid_action_progress_bar_percent" style="height:24px;width:'.$backup_percent.'"></div>
3513
+ </div>
3514
+ <div id="wpvivid_estimate_backup_info" style="'.$estimate_backup.'">
3515
+ <div class="backup-basic-info"><span>'.__('Database Size:', 'wpvivid').'</span><span id="wpvivid_backup_database_size">'.$db_size.'</span></div>
3516
+ <div class="backup-basic-info"><span>'.__('File Size:', 'wpvivid').'</span><span id="wpvivid_backup_file_size">'.$file_size.'</span></div>
3517
+ </div>
3518
+ <div style="clear:both;"></div>
3519
+ <div style="margin-left:10px; float: left; width:100%;"><p id="wpvivid_current_doing">'.$descript.'</p></div>
3520
+ <div style="clear: both;"></div>
3521
+ <div>
3522
+ <div id="wpvivid_backup_cancel" class="backup-log-btn"><input class="button-primary" id="wpvivid_backup_cancel_btn" type="submit" value="'.esc_attr('Cancel', 'wpvivid' ).'" onclick="wpvivid_cancel_backup();" style="'.$css_btn_cancel.'" /></div>
3523
+ <div id="wpvivid_backup_log" class="backup-log-btn"><input class="button-primary backup-log-btn" id="wpvivid_backup_log_btn" type="submit" value="'.esc_attr('Log', 'wpvivid' ).'" onclick="wpvivid_read_log(\''.__('wpvivid_view_backup_task_log').'\');" style="'.$css_btn_log.'" /></div>
3524
+ </div>
3525
+ <div style="clear: both;"></div>';
3526
+
3527
  }
3528
  }
3529
 
3530
  $ret['backup']['result']='success';
3531
  $ret['backup']['data']=$list_tasks;
3532
+
3533
  $ret['download']['data']=array();
3534
  if($backup_id !== false) {
3535
  $ret['download'] = self::update_download_page($backup_id);
3536
  }
3537
+
3538
+ $html='';
3539
+ $html=apply_filters('wpvivid_get_last_backup_message', $html);
3540
+ $ret['last_msg_html']=$html;
3541
+
3542
+ $html='';
3543
+ $html=apply_filters('wpvivid_get_log_list', $html);
3544
+ $ret['log_html'] = $html['html'];
3545
+ $ret['log_count'] = $html['log_count'];
3546
+
3547
  return $ret;
3548
  }
3549
 
3550
+ public function wpvivid_calc_backup_elapsed_time($time)
3551
+ {
3552
+ if(is_numeric($time)){
3553
+ $value = array(
3554
+ "years" => 0, "days" => 0, "hours" => 0,
3555
+ "minutes" => 0, "seconds" => 0,
3556
+ );
3557
+ if($time >= 31556926){
3558
+ $value["years"] = floor($time/31556926);
3559
+ $time = ($time%31556926);
3560
+ $value["days"] = floor($time/86400);
3561
+ $time = ($time%86400);
3562
+ $value["hours"] = floor($time/3600);
3563
+ $time = ($time%3600);
3564
+ $value["minutes"] = floor($time/60);
3565
+ $time = ($time%60);
3566
+ $value["seconds"] = floor($time);
3567
+ $t=$value["years"] ."year". $value["days"] ."day". $value["hours"] ."hour". $value["minutes"] ."min".$value["seconds"]."second";
3568
+ }
3569
+ else if($time >= 86400){
3570
+ $value["days"] = floor($time/86400);
3571
+ $time = ($time%86400);
3572
+ $value["hours"] = floor($time/3600);
3573
+ $time = ($time%3600);
3574
+ $value["minutes"] = floor($time/60);
3575
+ $time = ($time%60);
3576
+ $value["seconds"] = floor($time);
3577
+ $t=$value["days"] ."day". $value["hours"] ."hour". $value["minutes"] ."min".$value["seconds"]."second";
3578
+ }
3579
+ else if($time >= 3600){
3580
+ $value["hours"] = floor($time/3600);
3581
+ $time = ($time%3600);
3582
+ $value["minutes"] = floor($time/60);
3583
+ $time = ($time%60);
3584
+ $value["seconds"] = floor($time);
3585
+ $t=$value["hours"] ."hour". $value["minutes"] ."min".$value["seconds"]."second";
3586
+ }
3587
+ else if($time >= 60){
3588
+ $value["minutes"] = floor($time/60);
3589
+ $time = ($time%60);
3590
+ $value["seconds"] = floor($time);
3591
+ $t=$value["minutes"] ."min".$value["seconds"]."second";
3592
+ }
3593
+ else{
3594
+ $value["seconds"] = floor($time);
3595
+ $t=$value["seconds"]."second";
3596
+ }
3597
+ Return $t;
3598
+ }
3599
+ }
3600
+
3601
  public function clean_cache()
3602
  {
3603
  delete_option('wpvivid_download_cache');
3811
  {
3812
  die();
3813
  }
3814
+ if($options['log']=='0' && $options['backup_cache']=='0' && $options['junk_files']=='0' && $options['old_files']=='0')
3815
+ {
3816
+ $ret['result']=WPVIVID_FAILED;
3817
+ $ret['msg']=__('Choose at least one type of junk files for deleting.', 'wpvivid');
3818
+ echo json_encode($ret);
3819
+ die();
3820
+ }
3821
  $delete_files = array();
3822
  $delete_folder=array();
3823
  if($options['log']=='1')
3897
  }
3898
 
3899
  $ret['result']='success';
3900
+ $ret['msg']=__('The selected junk flies have been deleted.', 'wpvivid');
3901
  $ret['data']=$this->_junk_files_info();
3902
+ $html = '';
3903
+ $html = apply_filters('wpvivid_get_log_list', $html);
3904
+ $ret['html'] = $html['html'];
3905
+ $ret['log_count'] = $html['log_count'];
3906
  echo json_encode($ret);
3907
  die();
3908
  }
4009
 
4010
  if(!isset($_POST['remote_storage'])||empty($_POST['remote_storage'])||!is_array($_POST['remote_storage']))
4011
  {
4012
+ $ret['result'] = WPVIVID_FAILED;
4013
+ $ret['error'] = __('Choose one storage from the list to be the default storage.', 'wpvivid');
4014
+ echo json_encode($ret);
4015
  die();
4016
  }
4017
  $remote_storage = $_POST['remote_storage'];
4433
  public function get_log_list()
4434
  {
4435
  $this->ajax_check_security();
 
4436
  $ret['result']='success';
4437
+ $html = '';
4438
+ $html = apply_filters('wpvivid_get_log_list', $html);
4439
+ $ret['html'] = $html['html'];
4440
+ $ret['log_count'] = $html['log_count'];
4441
  echo json_encode($ret);
4442
  die();
4443
  }
4444
 
4445
+ public function wpvivid_get_log_list($html)
4446
+ {
4447
+ $html = '';
4448
+ $loglist=$this->get_log_list_ex();
4449
+ $current_num=1;
4450
+ $max_log_diaplay=20;
4451
+ $log_index=0;
4452
+ $pic_log='/admin/partials/images/Log.png';
4453
+ if(!empty($loglist['log_list']['file'])) {
4454
+ foreach ($loglist['log_list']['file'] as $value) {
4455
+ if ($current_num <= $max_log_diaplay) {
4456
+ $log_tr_display = '';
4457
+ } else {
4458
+ $log_tr_display = 'display: none;';
4459
+ }
4460
+ if (empty($value['time'])) {
4461
+ $value['time'] = 'N/A';
4462
+ }
4463
+ if (empty($value['des'])) {
4464
+ $value['des'] = 'N/A';
4465
+ }
4466
+ $html .= '<tr style="'.esc_attr($log_tr_display, 'wpvivid').'">
4467
+ <td class="row-title"><label for="tablecell">'.__($value['time'], 'wpvivid').'</label>
4468
+ </td>
4469
+ <td>'.__($value['des'], 'wpvivid').'</td>
4470
+ <td>'.__($value['file_name'], 'wpvivid').'</td>
4471
+ <td>
4472
+ <a onclick="wpvivid_read_log(\''.__('wpvivid_view_log').'\', \''.__($value['path']).'\')" style="cursor:pointer;">
4473
+ <img src="'.esc_url(WPVIVID_PLUGIN_URL.$pic_log).'" style="vertical-align:middle;">Log
4474
+ </a>
4475
+ </td>
4476
+ </tr>';
4477
+ $log_index++;
4478
+ $current_num++;
4479
+ }
4480
+ }
4481
+ $ret['log_count']=$log_index;
4482
+ $ret['html']=$html;
4483
+ return $ret;
4484
+ }
4485
+
4486
  public function get_log_list_ex(){
4487
  $ret['log_list']['file']=array();
4488
  $log=new WPvivid_Log();
4577
  if(!file_exists($path))
4578
  {
4579
  $json['result']='failed';
4580
+ $json['error']=__('The log not found.', 'wpvivid');
4581
  echo json_encode($json);
4582
  die();
4583
  }
4603
  $json['data']=$buffer;
4604
  echo json_encode($json);
4605
  }
4606
+ else{
4607
+ $json['result']='failed';
4608
+ $json['error']=__('Reading the log failed. Please try again.', 'wpvivid');
4609
+ echo json_encode($json);
4610
+ }
4611
  die();
4612
  }
4613
 
4765
  die();
4766
  }
4767
 
4768
+ public function wpvivid_add_backup_list($html)
4769
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4770
  $html = '';
4771
  $backuplist=WPvivid_Backuplist::get_backuplist();
4772
+ $remote=array();
4773
+ $remote=apply_filters('wpvivid_remote_pic', $remote);
4774
+
4775
  foreach ($backuplist as $key=>$value) {
4776
  if(empty($value['lock'])){
4777
  $backup_lock='/admin/partials/images/unlocked.png';
4787
  $lock_status='lock';
4788
  }
4789
  }
4790
+
4791
+ $remote_pic_html='';
4792
+ $b_has_remote=false;
4793
+ if(is_array($remote)) {
4794
+ foreach ($remote as $key1 => $value1) {
4795
+ foreach ($value['remote'] as $storage_type) {
4796
+ $b_has_remote=true;
4797
+ if ($key1 === $storage_type['type']) {
4798
+ $pic = $value1['selected_pic'];
4799
+ } else {
4800
+ $pic = $value1['default_pic'];
4801
+ }
4802
+ }
4803
+ if(!$b_has_remote){
4804
+ $pic = $value1['default_pic'];
4805
+ }
4806
+ $title = $value1['title'];
4807
+ $remote_pic_html .= '<img src="' . esc_url(WPVIVID_PLUGIN_URL . $pic) . '" style="vertical-align:middle; " title="' . $title . '"/>';
4808
  }
4809
  }
4810
  $html .= '<tr>
4817
  <img src="'.esc_url(WPVIVID_PLUGIN_URL.$backup_lock).'" name="'.esc_attr($lock_status, 'wpvivid').'" onclick="wpvivid_set_backup_lock(\''.__($key, 'wpvivid').'\', \''.__($lock_status, 'wpvivid').'\');" style="vertical-align:middle; cursor:pointer;"/>
4818
  </span>
4819
  | <span>'.__('Type:', 'wpvivid').'</span><span>'.__($value['type'], 'wpvivid').'</span>
4820
+ |<span title="Backup log"><a href="#" onclick="wpvivid_read_log(\''.__('wpvivid_view_backup_log').'\', \''.__($key).'\');"><img src="'.esc_url(WPVIVID_PLUGIN_URL.'/admin/partials/images/Log.png').'" style="vertical-align:middle;cursor:pointer;"/>'.__('Log', 'wpvivid').'</a></span>
4821
  |<span title="Restore Website from The Backup"><a href="#" onclick="wpvivid_initialize_restore(\''.__($key, 'wpvivid').'\',\''.__(date('M d, Y H:i',$value['create_time']), 'wpvivid').'\');"><img src="'.esc_url(WPVIVID_PLUGIN_URL. '/admin/partials/images/Restore.png').'" style="vertical-align:middle;cursor:pointer;"/>'.__('Restore', 'wpvivid').'</a></span>
4822
  </div>
4823
  </div>
4824
  </td>
4825
  <td class="tablelistcolumn">
4826
+ <div style="float:left;padding:10px 10px 10px 0px;">'.$remote_pic_html.'</div>
 
 
 
 
4827
  </td>
4828
  <td class="tablelistcolumn">
4829
  <div id="wpvivid_file_part_'.__($key, 'wpvivid').'" style="float:left;padding:10px 10px 10px 0px;">
4843
  return $html;
4844
  }
4845
 
4846
+ public function wpvivid_add_remote_storage_list($html)
4847
+ {
4848
  $html = '';
4849
  $remoteslist=WPvivid_Setting::get_all_remote_options();
4850
  $default_remote_storage='';
4867
  $check_status='';
4868
  }
4869
  $storage_type = $value['type'];
4870
+ $storage_type=apply_filters('wpvivid_storage_provider_tran', $storage_type);
4871
  $html .= '<tr>
4872
  <td>'.__($i++, 'wpvivid').'</td>
4873
  <td><input type="checkbox" name="remote_storage" value="'.esc_attr($key, 'wpvivid').'" '.esc_attr($check_status, 'wpvivid').' /></td>
4874
  <td>'.__($storage_type, 'wpvivid').'</td>
4875
  <td class="row-title"><label for="tablecell">'.__($value['name'], 'wpvivid').'</label></td>
4876
+ <td>
4877
+ <div style="float: left;"><img src="'.esc_url(WPVIVID_PLUGIN_URL.'/admin/partials/images/Edit.png').'" onclick="click_retrieve_remote_storage(\''.__($key, 'wpvivid').'\',\''.__($value['type'], 'wpvivid').'\',\''.__($value['name'], 'wpvivid').'\');" style="vertical-align:middle; cursor:pointer;" title="Edit the remote storage"/></div>
4878
+ <div><img src="'.esc_url(WPVIVID_PLUGIN_URL.'/admin/partials/images/Delete.png').'" onclick="wpvivid_delete_remote_storage(\''.__($key, 'wpvivid').'\');" style="vertical-align:middle; cursor:pointer;" title="Remove the remote storage"/></div>
4879
  </td>
4880
  </tr>';
 
4881
  }
4882
  return $html;
4883
  }
4910
  }
4911
  $html .= '<img src="' . esc_url(WPVIVID_PLUGIN_URL . $pic) . '" style="vertical-align:middle; " title="' . $title . '"/>';
4912
  }
4913
+ $html.='<img onclick="wpvivid_click_switch_page(\'wrap\', \'wpvivid_tab_remote_storage\', true);" src="'.esc_url(WPVIVID_PLUGIN_URL.'/admin/partials/images/add-storages.png').'" style="vertical-align:middle;" title="Add a storage"/>';
4914
  }
4915
  return $html;
4916
  }
4923
  {
4924
  foreach ($out_of_date['remote_options'] as $value)
4925
  {
4926
+ $out_of_date_remote=apply_filters('wpvivid_get_out_of_date_remote',$out_of_date_remote, $value);
 
 
 
 
 
 
 
 
 
 
4927
  }
4928
  }
4929
  return $out_of_date_remote;
includes/customclass/class-wpvivid-amazons3-plus.php CHANGED
@@ -21,7 +21,10 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
21
  {
22
  add_action('wpvivid_add_storage_tab',array($this,'wpvivid_add_storage_tab_amazons3'), 11);
23
  add_action('wpvivid_add_storage_page',array($this,'wpvivid_add_storage_page_amazons3'), 11);
 
24
  add_filter('wpvivid_remote_pic',array($this,'wpvivid_remote_pic_amazons3'),11);
 
 
25
  }
26
  else
27
  {
@@ -33,7 +36,7 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
33
  {
34
  ?>
35
  <div class="storage-providers" remote_type="amazons3" onclick="select_remote_storage(event, 'storage_account_amazons3');">
36
- <img src="<?php echo esc_url(WPVIVID_PLUGIN_URL.'/admin/partials/images/storage-ftp.png'); ?>" style="vertical-align:middle;"/><?php _e('Amazon S3', 'wpvivid'); ?>
37
  </div>
38
  <?php
39
  }
@@ -44,16 +47,16 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
44
  <div id="storage_account_amazons3" class="storage-account-page" style="display:none;">
45
  <h2><span><?php _e( 'Enter Your Amazon S3 Account ','wpvivid'); ?></span></h2>
46
  <div class="storage-account-form">
47
- <input type="text" option="amazons3" name="name" placeholder="Custom an unique name: Example: Amazon S3-001" class="regular-text" />
48
  </div>
49
  <div class="storage-account-form">
50
- <input type="text" option="amazons3" name="access" placeholder="Amazon S3 access key" class="regular-text"/>
51
  </div>
52
  <div class="storage-account-form">
53
- <input type="password" option="amazons3" name="secret" placeholder="Amazon S3 secret key" class="regular-text"/>
54
  </div>
55
  <div class="storage-account-form">
56
- <input type="text" option="amazons3" name="s3Path" placeholder="Amazon S3 path(Example: s3://test/test)" class="regular-text"/>
57
  </div>
58
  <div class="remote-storage-set-default-block">
59
  <label>
@@ -76,6 +79,38 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
76
  <?php
77
  }
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  public function wpvivid_remote_pic_amazons3($remote){
80
  $remote['amazons3']['default_pic'] = '/admin/partials/images/storage-amazon-s3(gray).png';
81
  $remote['amazons3']['selected_pic'] = '/admin/partials/images/storage-amazon-s3.png';
@@ -85,13 +120,6 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
85
 
86
  public function test_connect()
87
  {
88
- $ret=$this->check_options();
89
-
90
- if($ret['result']!=WPVIVID_SUCCESS)
91
- {
92
- return $ret;
93
- }
94
-
95
  $amazons3 = $this -> getS3();
96
  if(is_array($amazons3) && $amazons3['result'] === WPVIVID_FAILED)
97
  return $amazons3;
@@ -110,7 +138,7 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
110
  return array('result'=>WPVIVID_SUCCESS);
111
  }
112
 
113
- private function check_options()
114
  {
115
  $ret['result']=WPVIVID_FAILED;
116
  if(!isset($this->options['name']))
@@ -127,6 +155,16 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
127
  return $ret;
128
  }
129
 
 
 
 
 
 
 
 
 
 
 
130
  if(!isset($this->options['access']))
131
  {
132
  $ret['error']="Warning: The access key for Amazon S3 is required.";
@@ -170,6 +208,7 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
170
  }
171
 
172
  $ret['result']=WPVIVID_SUCCESS;
 
173
  return $ret;
174
  }
175
 
@@ -255,7 +294,7 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
255
  }
256
  $chunks[] = $chunk_id;
257
  $upload_job['job_data'][basename($file)]['upload_chunks'] = $chunks;
258
- WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3,'0','Uploadding '.basename($file).'.',$upload_job['job_data']);
259
 
260
  $offset = (($i + 1) * $this -> upload_chunk_size) > $this -> current_file_size ? $this -> current_file_size : (($i + 1) * $this -> upload_chunk_size);
261
  if((time() - $this -> last_time) >3)
@@ -291,7 +330,7 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
291
  }
292
  if(!$result && $i == (WPVIVID_REMOTE_CONNECT_RETRY_TIMES - 1))
293
  {
294
- return array('result'=>WPVIVID_FAILED,'error'=>'Uploading '.$file.' to Dropbox server failed. '.$file.' might be deleted or network doesn\'t work properly. Please verify the file and confirm the network connection and try again later.');
295
  }
296
  sleep(WPVIVID_REMOTE_CONNECT_RETRY_INTERVAL);
297
  }
@@ -344,7 +383,7 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
344
  if(md5_file($file_path) != $file_md5)
345
  {
346
  @unlink($file_path);
347
- return array('result' => WPVIVID_FAILED, 'error' =>'file md5 is not matched');
348
  }
349
  return array('result' => WPVIVID_SUCCESS);
350
  }
@@ -429,4 +468,20 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
429
  }
430
  return $endpoint;
431
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
432
  }
21
  {
22
  add_action('wpvivid_add_storage_tab',array($this,'wpvivid_add_storage_tab_amazons3'), 11);
23
  add_action('wpvivid_add_storage_page',array($this,'wpvivid_add_storage_page_amazons3'), 11);
24
+ add_action('wpvivid_edit_remote_page',array($this,'wpvivid_edit_storage_page_amazons3'), 11);
25
  add_filter('wpvivid_remote_pic',array($this,'wpvivid_remote_pic_amazons3'),11);
26
+ add_filter('wpvivid_get_out_of_date_remote',array($this,'wpvivid_get_out_of_date_amazons3'),10,2);
27
+ add_filter('wpvivid_storage_provider_tran',array($this,'wpvivid_storage_provider_amazons3'),10);
28
  }
29
  else
30
  {
36
  {
37
  ?>
38
  <div class="storage-providers" remote_type="amazons3" onclick="select_remote_storage(event, 'storage_account_amazons3');">
39
+ <img src="<?php echo esc_url(WPVIVID_PLUGIN_URL.'/admin/partials/images/storage-amazon-s3.png'); ?>" style="vertical-align:middle;"/><?php _e('Amazon S3', 'wpvivid'); ?>
40
  </div>
41
  <?php
42
  }
47
  <div id="storage_account_amazons3" class="storage-account-page" style="display:none;">
48
  <h2><span><?php _e( 'Enter Your Amazon S3 Account ','wpvivid'); ?></span></h2>
49
  <div class="storage-account-form">
50
+ <input type="text" autocomplete="off" option="amazons3" name="name" placeholder="Custom an unique name: Example: Amazon S3-001" class="regular-text" onkeyup="value=value.replace(/[^a-zA-Z0-9\-_]/g,'')" />
51
  </div>
52
  <div class="storage-account-form">
53
+ <input type="text" autocomplete="off" option="amazons3" name="access" placeholder="Amazon S3 access key" class="regular-text"/>
54
  </div>
55
  <div class="storage-account-form">
56
+ <input type="password" autocomplete="new-password" option="amazons3" name="secret" placeholder="Amazon S3 secret key" class="regular-text"/>
57
  </div>
58
  <div class="storage-account-form">
59
+ <input type="text" autocomplete="off" option="amazons3" name="s3Path" placeholder="Amazon S3 path(Example: s3://test/test)" class="regular-text"/>
60
  </div>
61
  <div class="remote-storage-set-default-block">
62
  <label>
79
  <?php
80
  }
81
 
82
+ public function wpvivid_edit_storage_page_amazons3()
83
+ {
84
+ ?>
85
+ <div id="remote_storage_edit_amazons3" class="postbox storage-account-block remote-storage-edit" style="display:none;">
86
+ <h2><span><?php _e( 'Enter Your Amazon S3 Account ','wpvivid'); ?></span></h2>
87
+ <div class="storage-account-form">
88
+ <input type="text" option="edit-amazons3" name="name" placeholder="Custom an unique name: Example: Amazon S3-001" class="regular-text" onkeyup="value=value.replace(/[^a-zA-Z0-9\-_]/g,'')" />
89
+ </div>
90
+ <div class="storage-account-form">
91
+ <input type="text" option="edit-amazons3" name="access" placeholder="Amazon S3 access key" class="regular-text"/>
92
+ </div>
93
+ <div class="storage-account-form">
94
+ <input type="password" option="edit-amazons3" name="secret" placeholder="Amazon S3 secret key" class="regular-text"/>
95
+ </div>
96
+ <div class="storage-account-form">
97
+ <input type="text" option="edit-amazons3" name="s3Path" placeholder="Amazon S3 path(Example: s3://test/test)" class="regular-text"/>
98
+ </div>
99
+ <div class="remote-storage-amazons3-storage-class">
100
+ <label>
101
+ <input type="checkbox" option="edit-amazons3" name="classMode"/><?php _e('Storage class: Standard (infrequent access).', 'wpvivid'); ?>
102
+ </label>
103
+ </div>
104
+ <div class="remote-storage-amazons3-encryption">
105
+ <label>
106
+ <input type="checkbox" option="edit-amazons3" name="sse"/><?php _e('Server-side encryption.', 'wpvivid'); ?>
107
+ </label>
108
+ </div>
109
+ <div class=""><input class="button-primary storage-account-button" option="edit-remote" type="button" name="amazons3" value="<?php _e( 'Save Changes', 'wpvivid' ); ?>" /></div>
110
+ </div>
111
+ <?php
112
+ }
113
+
114
  public function wpvivid_remote_pic_amazons3($remote){
115
  $remote['amazons3']['default_pic'] = '/admin/partials/images/storage-amazon-s3(gray).png';
116
  $remote['amazons3']['selected_pic'] = '/admin/partials/images/storage-amazon-s3.png';
120
 
121
  public function test_connect()
122
  {
 
 
 
 
 
 
 
123
  $amazons3 = $this -> getS3();
124
  if(is_array($amazons3) && $amazons3['result'] === WPVIVID_FAILED)
125
  return $amazons3;
138
  return array('result'=>WPVIVID_SUCCESS);
139
  }
140
 
141
+ public function sanitize_options($skip_name='')
142
  {
143
  $ret['result']=WPVIVID_FAILED;
144
  if(!isset($this->options['name']))
155
  return $ret;
156
  }
157
 
158
+ $remoteslist=WPvivid_Setting::get_all_remote_options();
159
+ foreach ($remoteslist as $key=>$value)
160
+ {
161
+ if(isset($value['name'])&&$value['name'] == $this->options['name']&&$skip_name!=$value['name'])
162
+ {
163
+ $ret['error']="Warning: The alias already exists in storage list.";
164
+ return $ret;
165
+ }
166
+ }
167
+
168
  if(!isset($this->options['access']))
169
  {
170
  $ret['error']="Warning: The access key for Amazon S3 is required.";
208
  }
209
 
210
  $ret['result']=WPVIVID_SUCCESS;
211
+ $ret['options']=$this->options;
212
  return $ret;
213
  }
214
 
294
  }
295
  $chunks[] = $chunk_id;
296
  $upload_job['job_data'][basename($file)]['upload_chunks'] = $chunks;
297
+ WPvivid_taskmanager::update_backup_sub_task_progress($task_id,'upload',WPVIVID_REMOTE_AMAZONS3,'0','Uploading '.basename($file).'.',$upload_job['job_data']);
298
 
299
  $offset = (($i + 1) * $this -> upload_chunk_size) > $this -> current_file_size ? $this -> current_file_size : (($i + 1) * $this -> upload_chunk_size);
300
  if((time() - $this -> last_time) >3)
330
  }
331
  if(!$result && $i == (WPVIVID_REMOTE_CONNECT_RETRY_TIMES - 1))
332
  {
333
+ return array('result'=>WPVIVID_FAILED,'error'=>'Uploading '.$file.' to Amazon S3 server failed. '.$file.' might be deleted or network doesn\'t work properly. Please verify the file and confirm the network connection and try again later.');
334
  }
335
  sleep(WPVIVID_REMOTE_CONNECT_RETRY_INTERVAL);
336
  }
383
  if(md5_file($file_path) != $file_md5)
384
  {
385
  @unlink($file_path);
386
+ return array('result' => WPVIVID_FAILED, 'error' =>'file md5 is not matched.');
387
  }
388
  return array('result' => WPVIVID_SUCCESS);
389
  }
468
  }
469
  return $endpoint;
470
  }
471
+
472
+ public function wpvivid_get_out_of_date_amazons3($out_of_date_remote, $remote)
473
+ {
474
+ if($remote['type'] == WPVIVID_REMOTE_AMAZONS3){
475
+ $out_of_date_remote = $remote['s3Path'];
476
+ }
477
+ return $out_of_date_remote;
478
+ }
479
+
480
+ public function wpvivid_storage_provider_amazons3($storage_type)
481
+ {
482
+ if($storage_type == WPVIVID_REMOTE_AMAZONS3){
483
+ $storage_type = 'Amazon S3';
484
+ }
485
+ return $storage_type;
486
+ }
487
  }
includes/customclass/class-wpvivid-extend-sftp.php CHANGED
@@ -3,10 +3,7 @@
3
  if (!defined('WPVIVID_PLUGIN_DIR')){
4
  die;
5
  }
6
- if(!class_exists('Net_SFTP'))
7
- {
8
- include_once WPVIVID_PLUGIN_DIR . '/includes/phpseclib/Net/SFTP.php';
9
- }
10
  class WPvivid_Net_SFTP extends Net_SFTP
11
  {
12
  function get($remote_file, $local_file = false, $offset = 0, $length = -1, $callback = null)
3
  if (!defined('WPVIVID_PLUGIN_DIR')){
4
  die;
5
  }
6
+ include_once WPVIVID_PLUGIN_DIR.'/vendor/autoload.php';
 
 
 
7
  class WPvivid_Net_SFTP extends Net_SFTP
8
  {
9
  function get($remote_file, $local_file = false, $offset = 0, $length = -1, $callback = null)
includes/customclass/class-wpvivid-ftpclass.php CHANGED
@@ -3,13 +3,6 @@
3
  if (!defined('WPVIVID_PLUGIN_DIR')){
4
  die;
5
  }
6
- /**
7
- * WPvivid addon: yes
8
- * Addon Name: WPvivid_FTPClass
9
- * Description: Premium
10
- * Version: 0.9.4
11
- * Interface Name: WPvivid_FTPClass
12
- */
13
 
14
  define('WPVIVID_REMOTE_FTP','ftp');
15
 
@@ -25,7 +18,10 @@ class WPvivid_FTPClass extends WPvivid_Remote{
25
  {
26
  add_action('wpvivid_add_storage_tab',array($this,'wpvivid_add_storage_tab_ftp'), 9);
27
  add_action('wpvivid_add_storage_page',array($this,'wpvivid_add_storage_page_ftp'), 9);
 
28
  add_filter('wpvivid_remote_pic',array($this,'wpvivid_remote_pic_ftp'),9);
 
 
29
  }else{
30
  $this->options = $options;
31
  }
@@ -46,19 +42,19 @@ class WPvivid_FTPClass extends WPvivid_Remote{
46
  <div id="storage_account_ftp" class="storage-account-page">
47
  <h2><span><?php _e( 'Enter Your FTP Account ','wpvivid'); ?></span></h2>
48
  <div class="storage-account-form">
49
- <input type="text" option="ftp" name="name" placeholder="Custom an unique name: Example: FTP-001" class="regular-text"/>
50
  </div>
51
  <div class="storage-account-form">
52
- <input type="text" option="ftp" name="host" placeholder="FTP server" class="regular-text"/>
53
  </div>
54
  <div class="storage-account-form">
55
- <input type="text" option="ftp" name="username" placeholder="FTP login" class="regular-text"/>
56
  </div>
57
  <div class="storage-account-form">
58
- <input type="password" option="ftp" name="password" placeholder="FTP password" class="regular-text"/>
59
  </div>
60
  <div class="storage-account-form">
61
- <input type="text" option="ftp" name="path" placeholder="Directory path( /wpvivid )" class="regular-text"/>
62
  </div>
63
  <div class="remote-storage-set-default-block">
64
  <label>
@@ -76,6 +72,36 @@ class WPvivid_FTPClass extends WPvivid_Remote{
76
  <?php
77
  }
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  public function wpvivid_remote_pic_ftp($remote){
80
  $remote['ftp']['default_pic'] = '/admin/partials/images/storage-ftp(gray).png';
81
  $remote['ftp']['selected_pic'] = '/admin/partials/images/storage-ftp.png';
@@ -85,13 +111,6 @@ class WPvivid_FTPClass extends WPvivid_Remote{
85
 
86
  public function test_connect()
87
  {
88
- $ret=$this->check_options();
89
-
90
- if($ret['result']!=WPVIVID_SUCCESS)
91
- {
92
- return $ret;
93
- }
94
-
95
  $host = $this->options['host'];
96
  $username = $this->options['username'];
97
  $password = $this->options['password'];
@@ -105,12 +124,12 @@ class WPvivid_FTPClass extends WPvivid_Remote{
105
  return $this->do_chdir($conn,$path);
106
  }
107
 
108
- private function check_options()
109
  {
110
  $ret['result']=WPVIVID_FAILED;
111
  if(!isset($this->options['name']))
112
  {
113
- $ret['error']="Warning: An alias for remote storage is required.";
114
  return $ret;
115
  }
116
 
@@ -118,10 +137,20 @@ class WPvivid_FTPClass extends WPvivid_Remote{
118
 
119
  if(empty($this->options['name']))
120
  {
121
- $ret['error']="Warning: An alias for remote storage is required.";
122
  return $ret;
123
  }
124
 
 
 
 
 
 
 
 
 
 
 
125
  if(!isset($this->options['host']))
126
  {
127
  $ret['error']="Warning: The FTP server is required.";
@@ -179,6 +208,7 @@ class WPvivid_FTPClass extends WPvivid_Remote{
179
  }
180
 
181
  $ret['result']=WPVIVID_SUCCESS;
 
182
  return $ret;
183
  }
184
 
@@ -259,7 +289,7 @@ class WPvivid_FTPClass extends WPvivid_Remote{
259
  }
260
  $this ->last_time = time();
261
  $this -> last_size = 0;
262
-
263
  $remote_file = trailingslashit($path).basename($file);
264
  if(!file_exists($file))
265
  return array('result'=>WPVIVID_FAILED,'error'=>$file.' not found. The file might has been moved, renamed or deleted. Please back it up again.');
@@ -374,11 +404,6 @@ class WPvivid_FTPClass extends WPvivid_Remote{
374
  ftp_close($conn);
375
  fclose($local_handle);
376
 
377
- // if($this->current_task!==false)
378
- // {
379
- // $progress= 100;
380
- // WPvivid_taskmanager::update_download_task( $this->current_task,$progress,basename($remote_file),'completed');
381
- // }
382
  return array('result'=>WPVIVID_SUCCESS);
383
  }
384
 
@@ -403,4 +428,20 @@ class WPvivid_FTPClass extends WPvivid_Remote{
403
  $remote_collection[WPVIVID_REMOTE_FTP] = 'WPvivid_FTPClass';
404
  return $remote_collection;
405
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
406
  }
3
  if (!defined('WPVIVID_PLUGIN_DIR')){
4
  die;
5
  }
 
 
 
 
 
 
 
6
 
7
  define('WPVIVID_REMOTE_FTP','ftp');
8
 
18
  {
19
  add_action('wpvivid_add_storage_tab',array($this,'wpvivid_add_storage_tab_ftp'), 9);
20
  add_action('wpvivid_add_storage_page',array($this,'wpvivid_add_storage_page_ftp'), 9);
21
+ add_action('wpvivid_edit_remote_page',array($this,'wpvivid_edit_storage_page_ftp'), 9);
22
  add_filter('wpvivid_remote_pic',array($this,'wpvivid_remote_pic_ftp'),9);
23
+ add_filter('wpvivid_get_out_of_date_remote',array($this,'wpvivid_get_out_of_date_ftp'),10,2);
24
+ add_filter('wpvivid_storage_provider_tran',array($this,'wpvivid_storage_provider_ftp'),10);
25
  }else{
26
  $this->options = $options;
27
  }
42
  <div id="storage_account_ftp" class="storage-account-page">
43
  <h2><span><?php _e( 'Enter Your FTP Account ','wpvivid'); ?></span></h2>
44
  <div class="storage-account-form">
45
+ <input type="text" autocomplete="off" option="ftp" name="name" placeholder="Custom an unique name: Example: FTP-001" class="regular-text" onkeyup="value=value.replace(/[^a-zA-Z0-9\-_]/g,'')" />
46
  </div>
47
  <div class="storage-account-form">
48
+ <input type="text" autocomplete="off" option="ftp" name="host" placeholder="FTP server" class="regular-text"/>
49
  </div>
50
  <div class="storage-account-form">
51
+ <input type="text" autocomplete="off" option="ftp" name="username" placeholder="FTP login" class="regular-text" />
52
  </div>
53
  <div class="storage-account-form">
54
+ <input type="password" autocomplete="new-password" option="ftp" name="password" placeholder="FTP password" class="regular-text" />
55
  </div>
56
  <div class="storage-account-form">
57
+ <input type="text" autocomplete="off" option="ftp" name="path" placeholder="Directory path( /wpvivid )" class="regular-text"/>
58
  </div>
59
  <div class="remote-storage-set-default-block">
60
  <label>
72
  <?php
73
  }
74
 
75
+ public function wpvivid_edit_storage_page_ftp()
76
+ {
77
+ ?>
78
+ <div id="remote_storage_edit_ftp" class="postbox storage-account-block remote-storage-edit" style="display:none;">
79
+ <h2><span><?php _e( 'Enter Your FTP Account ','wpvivid'); ?></span></h2>
80
+ <div class="storage-account-form">
81
+ <input type="text" option="edit-ftp" name="name" placeholder="Custom an unique name: Example: FTP-001" class="regular-text" onkeyup="value=value.replace(/[^a-zA-Z0-9\-_]/g,'')" />
82
+ </div>
83
+ <div class="storage-account-form">
84
+ <input type="text" option="edit-ftp" name="host" placeholder="FTP server" class="regular-text"/>
85
+ </div>
86
+ <div class="storage-account-form">
87
+ <input type="text" option="edit-ftp" name="username" placeholder="FTP login" class="regular-text"/>
88
+ </div>
89
+ <div class="storage-account-form">
90
+ <input type="password" option="edit-ftp" name="password" placeholder="FTP password" class="regular-text"/>
91
+ </div>
92
+ <div class="storage-account-form">
93
+ <input type="text" option="edit-ftp" name="path" placeholder="Directory path( /wpvivid )" class="regular-text"/>
94
+ </div>
95
+ <div class="remote-storage-ftp-passive-block">
96
+ <label>
97
+ <input type="checkbox" option="edit-ftp" name="passive" checked><?php _e('Uncheck this to enable FTP active mode.', 'wpvivid'); ?>
98
+ </label>
99
+ </div>
100
+ <div class=""><input class="button-primary storage-account-button" option="edit-remote" type="button" name="ftp" value="<?php _e( 'Save Changes', 'wpvivid' ); ?>" /></div>
101
+ </div>
102
+ <?php
103
+ }
104
+
105
  public function wpvivid_remote_pic_ftp($remote){
106
  $remote['ftp']['default_pic'] = '/admin/partials/images/storage-ftp(gray).png';
107
  $remote['ftp']['selected_pic'] = '/admin/partials/images/storage-ftp.png';
111
 
112
  public function test_connect()
113
  {
 
 
 
 
 
 
 
114
  $host = $this->options['host'];
115
  $username = $this->options['username'];
116
  $password = $this->options['password'];
124
  return $this->do_chdir($conn,$path);
125
  }
126
 
127
+ public function sanitize_options($skip_name='')
128
  {
129
  $ret['result']=WPVIVID_FAILED;
130
  if(!isset($this->options['name']))
131
  {
132
+ $ret['error']=__('Warning: An alias for remote storage is required.','wpvivid');
133
  return $ret;
134
  }
135
 
137
 
138
  if(empty($this->options['name']))
139
  {
140
+ $ret['error']=__('Warning: An alias for remote storage is required.','wpvivid');
141
  return $ret;
142
  }
143
 
144
+ $remoteslist=WPvivid_Setting::get_all_remote_options();
145
+ foreach ($remoteslist as $key=>$value)
146
+ {
147
+ if(isset($value['name'])&&$value['name'] == $this->options['name']&&$skip_name!=$value['name'])
148
+ {
149
+ $ret['error']="Warning: The alias already exists in storage list.";
150
+ return $ret;
151
+ }
152
+ }
153
+
154
  if(!isset($this->options['host']))
155
  {
156
  $ret['error']="Warning: The FTP server is required.";
208
  }
209
 
210
  $ret['result']=WPVIVID_SUCCESS;
211
+ $ret['options']=$this->options;
212
  return $ret;
213
  }
214
 
289
  }
290
  $this ->last_time = time();
291
  $this -> last_size = 0;
292
+ $wpvivid_pulgin->wpvivid_log->WriteLog('Start uploading '.basename($file),'notice');
293
  $remote_file = trailingslashit($path).basename($file);
294
  if(!file_exists($file))
295
  return array('result'=>WPVIVID_FAILED,'error'=>$file.' not found. The file might has been moved, renamed or deleted. Please back it up again.');
404
  ftp_close($conn);
405
  fclose($local_handle);
406
 
 
 
 
 
 
407
  return array('result'=>WPVIVID_SUCCESS);
408
  }
409
 
428
  $remote_collection[WPVIVID_REMOTE_FTP] = 'WPvivid_FTPClass';
429
  return $remote_collection;
430
  }
431
+
432
+ public function wpvivid_get_out_of_date_ftp($out_of_date_remote, $remote)
433
+ {
434
+ if($remote['type'] == WPVIVID_REMOTE_FTP){
435
+ $out_of_date_remote = $remote['path'];
436
+ }
437
+ return $out_of_date_remote;
438
+ }
439
+
440
+ public function wpvivid_storage_provider_ftp($storage_type)
441
+ {
442
+ if($storage_type == WPVIVID_REMOTE_FTP){
443
+ $storage_type = 'FTP';
444
+ }
445
+ return $storage_type;
446
+ }
447
  }
includes/customclass/class-wpvivid-sftpclass.php CHANGED
@@ -5,12 +5,6 @@ if (!defined('WPVIVID_PLUGIN_DIR')){
5
  }
6
 
7
  define('WPVIVID_REMOTE_SFTP','sftp');
8
-
9
- set_include_path(WPVIVID_PLUGIN_DIR . '/includes/phpseclib'. PATH_SEPARATOR . get_include_path());
10
- include_once WPVIVID_PLUGIN_DIR . '/includes/phpseclib/Net/SCP.php';
11
- include_once WPVIVID_PLUGIN_DIR . '/includes/phpseclib/Net/SFTP.php';
12
- include_once WPVIVID_PLUGIN_DIR . '/includes/phpseclib/Net/SSH2.php';
13
- include_once WPVIVID_PLUGIN_DIR . '/includes/customclass/class-wpvivid-extend-sftp.php';
14
  require_once WPVIVID_PLUGIN_DIR .'/includes/customclass/class-wpvivid-remote.php';
15
 
16
  class WPvivid_SFTPClass extends WPvivid_Remote{
@@ -26,7 +20,10 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
26
  {
27
  add_action('wpvivid_add_storage_tab',array($this,'wpvivid_add_storage_tab_sftp'), 10);
28
  add_action('wpvivid_add_storage_page',array($this,'wpvivid_add_storage_page_sftp'), 10);
 
29
  add_filter('wpvivid_remote_pic',array($this,'wpvivid_remote_pic_sftp'),10);
 
 
30
  }
31
  else
32
  {
@@ -38,7 +35,7 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
38
  {
39
  ?>
40
  <div class="storage-providers" remote_type="sftp" onclick="select_remote_storage(event, 'storage_account_sftp');">
41
- <img src="<?php echo esc_url(WPVIVID_PLUGIN_URL.'/admin/partials/images/storage-ftp.png'); ?>" style="vertical-align:middle;"/><?php _e('SFTP', 'wpvivid'); ?>
42
  </div>
43
  <?php
44
  }
@@ -49,22 +46,22 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
49
  <div id="storage_account_sftp" class="storage-account-page" style="display:none;">
50
  <h2><span><?php _e( 'Enter Your SFTP Account ','wpvivid'); ?></span></h2>
51
  <div class="storage-account-form">
52
- <input type="text" option="sftp" name="name" placeholder="Custom an unique name: e.g.SFTP-001" class="regular-text"/>
53
  </div>
54
  <div class="storage-account-form">
55
- <input type="text" option="sftp" name="host" placeholder="Server IP Address" class="regular-text"/>
56
  </div>
57
  <div class="storage-account-form">
58
- <input type="text" option="sftp" name="username" placeholder="User Name" class="regular-text"/>
59
  </div>
60
  <div class="storage-account-form">
61
- <input type="password" option="sftp" name="password" placeholder="Root Password" class="regular-text"/>
62
  </div>
63
  <div class="storage-account-form">
64
- <input type="text" option="sftp" name="port" placeholder="Port" class="regular-text" onkeyup="value=value.replace(/\D/g,'')" />
65
  </div>
66
  <div class="storage-account-form">
67
- <input type="text" option="sftp" name="path" placeholder="Absolute path must exist(Example: /var/)" class="regular-text"/>
68
  </div>
69
  <div class="remote-storage-set-default-block">
70
  <label>
@@ -77,7 +74,36 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
77
  <?php
78
  }
79
 
80
- public function wpvivid_remote_pic_sftp($remote){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  $remote['sftp']['default_pic'] = '/admin/partials/images/storage-sftp(gray).png';
82
  $remote['sftp']['selected_pic'] = '/admin/partials/images/storage-sftp.png';
83
  $remote['sftp']['title'] = 'SFTP';
@@ -86,13 +112,6 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
86
 
87
  public function test_connect()
88
  {
89
- $ret=$this->check_options();
90
-
91
- if($ret['result']!=WPVIVID_SUCCESS)
92
- {
93
- return $ret;
94
- }
95
-
96
  $host = $this->options['host'];
97
  $username = $this->options['username'];
98
  $password = $this->options['password'];
@@ -119,7 +138,7 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
119
  }
120
  }
121
 
122
- private function check_options()
123
  {
124
  $ret['result']=WPVIVID_FAILED;
125
  if(!isset($this->options['name']))
@@ -136,6 +155,16 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
136
  return $ret;
137
  }
138
 
 
 
 
 
 
 
 
 
 
 
139
  if(!isset($this->options['host']))
140
  {
141
  $ret['error']="Warning: The IP Address is required.";
@@ -207,11 +236,13 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
207
  }
208
 
209
  $ret['result']=WPVIVID_SUCCESS;
 
210
  return $ret;
211
  }
212
 
213
  function do_connect($host,$username,$password,$port)
214
  {
 
215
  $conn = new WPvivid_Net_SFTP($host,$port,$this -> timeout);
216
  $conn -> setTimeout($this->timeout);
217
  $ret = $conn->login($username,$password);
@@ -419,4 +450,20 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
419
  $remote['options'] = $this -> options;
420
  return $this -> delete($remote,$files);
421
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
422
  }
5
  }
6
 
7
  define('WPVIVID_REMOTE_SFTP','sftp');
 
 
 
 
 
 
8
  require_once WPVIVID_PLUGIN_DIR .'/includes/customclass/class-wpvivid-remote.php';
9
 
10
  class WPvivid_SFTPClass extends WPvivid_Remote{
20
  {
21
  add_action('wpvivid_add_storage_tab',array($this,'wpvivid_add_storage_tab_sftp'), 10);
22
  add_action('wpvivid_add_storage_page',array($this,'wpvivid_add_storage_page_sftp'), 10);
23
+ add_action('wpvivid_edit_remote_page',array($this,'wpvivid_edit_storage_page_sftp'), 10);
24
  add_filter('wpvivid_remote_pic',array($this,'wpvivid_remote_pic_sftp'),10);
25
+ add_filter('wpvivid_get_out_of_date_remote',array($this,'wpvivid_get_out_of_date_sftp'),10,2);
26
+ add_filter('wpvivid_storage_provider_tran',array($this,'wpvivid_storage_provider_sftp'),10);
27
  }
28
  else
29
  {
35
  {
36
  ?>
37
  <div class="storage-providers" remote_type="sftp" onclick="select_remote_storage(event, 'storage_account_sftp');">
38
+ <img src="<?php echo esc_url(WPVIVID_PLUGIN_URL.'/admin/partials/images/storage-sftp.png'); ?>" style="vertical-align:middle;"/><?php _e('SFTP', 'wpvivid'); ?>
39
  </div>
40
  <?php
41
  }
46
  <div id="storage_account_sftp" class="storage-account-page" style="display:none;">
47
  <h2><span><?php _e( 'Enter Your SFTP Account ','wpvivid'); ?></span></h2>
48
  <div class="storage-account-form">
49
+ <input type="text" autocomplete="off" option="sftp" name="name" placeholder="Custom an unique name: e.g.SFTP-001" class="regular-text" onkeyup="value=value.replace(/[^a-zA-Z0-9\-_]/g,'')" />
50
  </div>
51
  <div class="storage-account-form">
52
+ <input type="text" autocomplete="off" option="sftp" name="host" placeholder="Server IP Address" class="regular-text"/>
53
  </div>
54
  <div class="storage-account-form">
55
+ <input type="text" autocomplete="off" option="sftp" name="username" placeholder="User Name" class="regular-text"/>
56
  </div>
57
  <div class="storage-account-form">
58
+ <input type="password" autocomplete="new-password" option="sftp" name="password" placeholder="Root Password" class="regular-text"/>
59
  </div>
60
  <div class="storage-account-form">
61
+ <input type="text" autocomplete="off" option="sftp" name="port" placeholder="Port" class="regular-text" onkeyup="value=value.replace(/\D/g,'')" />
62
  </div>
63
  <div class="storage-account-form">
64
+ <input type="text" autocomplete="off" option="sftp" name="path" placeholder="Absolute path must exist(Example: /var/)" class="regular-text"/>
65
  </div>
66
  <div class="remote-storage-set-default-block">
67
  <label>
74
  <?php
75
  }
76
 
77
+ public function wpvivid_edit_storage_page_sftp()
78
+ {
79
+ ?>
80
+ <div id="remote_storage_edit_sftp" class="postbox storage-account-block remote-storage-edit" style="display:none;">
81
+ <h2><span><?php _e( 'Enter Your SFTP Account ','wpvivid'); ?></span></h2>
82
+ <div class="storage-account-form">
83
+ <input type="text" option="edit-sftp" name="name" placeholder="Custom an unique name: e.g.SFTP-001" class="regular-text" onkeyup="value=value.replace(/[^a-zA-Z0-9\-_]/g,'')" />
84
+ </div>
85
+ <div class="storage-account-form">
86
+ <input type="text" option="edit-sftp" name="host" placeholder="Server IP Address" class="regular-text"/>
87
+ </div>
88
+ <div class="storage-account-form">
89
+ <input type="text" option="edit-sftp" name="username" placeholder="User Name" class="regular-text"/>
90
+ </div>
91
+ <div class="storage-account-form">
92
+ <input type="password" option="edit-sftp" name="password" placeholder="Root Password" class="regular-text"/>
93
+ </div>
94
+ <div class="storage-account-form">
95
+ <input type="text" option="edit-sftp" name="port" placeholder="Port" class="regular-text" onkeyup="value=value.replace(/\D/g,'')" />
96
+ </div>
97
+ <div class="storage-account-form">
98
+ <input type="text" option="edit-sftp" name="path" placeholder="Absolute path must exist(Example: /var/)" class="regular-text"/>
99
+ </div>
100
+ <div class=""><input class="button-primary storage-account-button" option="edit-remote" type="button" name="sftp" value="<?php _e( 'Save Changes', 'wpvivid' ); ?>" /></div>
101
+ </div>
102
+ <?php
103
+ }
104
+
105
+ public function wpvivid_remote_pic_sftp($remote)
106
+ {
107
  $remote['sftp']['default_pic'] = '/admin/partials/images/storage-sftp(gray).png';
108
  $remote['sftp']['selected_pic'] = '/admin/partials/images/storage-sftp.png';
109
  $remote['sftp']['title'] = 'SFTP';
112
 
113
  public function test_connect()
114
  {
 
 
 
 
 
 
 
115
  $host = $this->options['host'];
116
  $username = $this->options['username'];
117
  $password = $this->options['password'];
138
  }
139
  }
140
 
141
+ public function sanitize_options($skip_name='')
142
  {
143
  $ret['result']=WPVIVID_FAILED;
144
  if(!isset($this->options['name']))
155
  return $ret;
156
  }
157
 
158
+ $remoteslist=WPvivid_Setting::get_all_remote_options();
159
+ foreach ($remoteslist as $key=>$value)
160
+ {
161
+ if(isset($value['name'])&&$value['name'] == $this->options['name']&&$skip_name!=$value['name'])
162
+ {
163
+ $ret['error']="Warning: The alias already exists in storage list.";
164
+ return $ret;
165
+ }
166
+ }
167
+
168
  if(!isset($this->options['host']))
169
  {
170
  $ret['error']="Warning: The IP Address is required.";
236
  }
237
 
238
  $ret['result']=WPVIVID_SUCCESS;
239
+ $ret['options']=$this->options;
240
  return $ret;
241
  }
242
 
243
  function do_connect($host,$username,$password,$port)
244
  {
245
+ include_once WPVIVID_PLUGIN_DIR . '/includes/customclass/class-wpvivid-extend-sftp.php';
246
  $conn = new WPvivid_Net_SFTP($host,$port,$this -> timeout);
247
  $conn -> setTimeout($this->timeout);
248
  $ret = $conn->login($username,$password);
450
  $remote['options'] = $this -> options;
451
  return $this -> delete($remote,$files);
452
  }
453
+
454
+ public function wpvivid_get_out_of_date_sftp($out_of_date_remote, $remote)
455
+ {
456
+ if($remote['type'] == WPVIVID_REMOTE_SFTP){
457
+ $out_of_date_remote = $remote['path'];
458
+ }
459
+ return $out_of_date_remote;
460
+ }
461
+
462
+ public function wpvivid_storage_provider_sftp($storage_type)
463
+ {
464
+ if($storage_type == WPVIVID_REMOTE_SFTP){
465
+ $storage_type = 'SFTP';
466
+ }
467
+ return $storage_type;
468
+ }
469
  }
readme.txt CHANGED
@@ -1,59 +1,54 @@
1
- === WordPress Backup/Restore by WPvivid ===
2
  Contributors: wpvivid
3
- Tags: backup, cloud backup, restore, database backup, wordpress backup, backups, custom backups, s3, FTP, SFTP
4
  Requires at least: 4.5
5
- Tested up to: 5.0.2
6
  Requires PHP: 5.3
7
- Stable tag: 0.9.7
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
11
- Free, simple and easy to use backup/restore plugin for WordPress. Create manual and scheduled backups. Back up to Amazon S3, FTP and SFTP. Restore with one click.
12
 
13
  == Description ==
14
- WPvivid Backup/Restore is a WordPress backup plugin that provides stable backup and restore functionality yet simple interface and configuration to help everyone back up with minimal effort and cost.
15
- The plugin makes WordPress backup and restoration super easy. It creates both manual and automated backups, stores them into remote storage and restores directly from WordPress admin dashboard with a single click.
16
- Backing up to remote storage in the cloud can avoid server-wide risks, WPvivid Backup/Restore currently offers support for Amazon S3, FTP, SFTP. More options will be covered soon.
17
-
18
- == Why should you back up your WordPress site? ==
19
- WordPress is surely a great and secure platform but that does not mean it can protect your site from all threats. You can permanently lose your site because of a number of unexpected reasons, such as attacks from malicious hackers, business stoppage of your hosting, incorrect settings by yourself and a lot more. Imagine what you can do if a disaster happens to your site some day? Nothing then proves to be easier and more cost-efficient than a backup that you can use to restore everything back to normal.
20
-
21
- == Why WPvivid Backup/Restore? ==
22
-
23
- = 1. Not only Backup but also Restore =
24
- Not only does the plugin backup, it also restores your site with one click ease.
25
- = 2. Backup to Local as well as Cloud =
26
- You will have the option of backing up to your hosting server and cloud storage.
27
- = 3. Flexible Backup Types =
28
- WPvivid Backup/Restore provides you with flexible backup types including backing up the entire site, only files, only database. Save you storage space and time.
29
- = 4. Faster Backup with Higher Rate of Backup Success =
30
- When backing up your site, the plugin splits a large backup into several smaller-sized files which are easier and faster to handle.
31
- = 5. Simple UI and Configuration =
32
- WPvivid Backup/Restore requires very little configuration to implement its features and has a simple user interface where all its functionalities are well organized, to make sure everyone can find and perform functions with no effort.
33
- = 6. More Web Hosts Tested =
34
- WPvivid Backup/Restore has been well tested to work perfectly with a large number of web hosting, which include pretty much all the most used hosting service providers like Hostgator, Bluehost, GoDaddy, Namecheap and more.
35
- = 7.Multiple Support Channels =
36
- Free and responsive expert support is available to all users via multiple channels: the support forum for WPvivid Backup/Restore on WordPress.org, support email, and FAQs.
37
-
38
- == Feature Spotlight ==
39
- * One click backup and restore
40
- * Create manual and scheduled backups
41
- * Back up to cloud, Amazon S3, FTP, SFTP
42
- * Back up to your hosting server
43
- * Customize backup content (All files, database or entire site)
44
- * Exclude larger files from a backup
45
- * Smart archiving feature for different hosting types
46
- * Customize the name of a local storage directory
47
- * No limit to the backup size
48
- * Split the large size files when backing up
49
- * Download backups to your computer
50
- * Set how many backups to be kept in your storage
51
- * Lock a backup to ensure it from auto deletion
52
- * Sweep junk file off your server disk
53
  * Live progress
54
- * Instant email report
55
- * Thorough log files
56
- * Responsive design - compatible with smartphones, tablets, PC
57
 
58
  == Minimum Requirements ==
59
  * PHP version 5.3
@@ -62,35 +57,35 @@ Free and responsive expert support is available to all users via multiple channe
62
  * Character Encoding UTF-8
63
 
64
  == Support ==
65
- We offer responsive and completely free support through 3 channels to ensure your issues get received and resolved in the first time:
66
- = Forum Support: = The support forum for WPvivid Backup/Restore on WordPress.org is an optimal place to post your issues and get faster answers.
67
- = Email Support: = For the information that you would like to only let us know, then the email support would be a great way to go. Just drop us a mail at wpvivid.com@gmail.com and we will back to you soon.
68
- = FAQs: = For regular questions regarding the usage of the plugin, please check out our FAQs section on the page, you can easily find an answer for the most part.
69
 
70
  == Installation and Uninstallation ==
71
 
72
- = Install and Activate WPvivid Backup/Restore: =
73
  1.Go to your sites admin dashboard.
74
- 2.Navigate to Plugin Menu and search for WPvivid Backup/Restore.
75
  3.Click Install Now then click Activate Plugin.
76
 
77
- = Uninstall WPvivid Backup/Restore: =
78
  1.Click Deactivate from the Plugin Menu.
79
  2.Click Delete.
80
- Sometimes this could not fully remove the plugin due to the setting of local file permissions or WordPress configuration on your host. When this occurs, you will need to manually remove the installation files from /wp-content/plugins/ folder.
81
 
82
  == Privacy Policy and GDPR Compliance ==
83
- WPvivid Backup/Restore is created and operated with full respect and protection of users personal information, and is in full compliance with General Data Protection Regulation(GDPR). Check out the following content to know the details:
84
  = What personal data can WPvivid Backup/Restore access and how is the data processed? =
85
- WPvivid Backup/Restore currently only has a free version and is available to download from WordPress plugin repository. Thus, all the data related to the updates of the versions as well as the support forum for the plugin on WordPress.org is held by WordPress.org.
86
  In addition, the implementations of all backups and restores of your site happen completely on your website server, there are no data come across any of our servers in the whole process.
87
  The only personal data currently we can access are the contact data when you contact us by email, which may include your name, email address and other contact details. The data will only be used for the purposes of handling and resolving your enquiry.
88
- = How does WPvivid Backup/Restore help users create a GDPR compliant backup? =
89
- In order to help users create a GDPR compliant backup, WPvivid Backup/Restore comes with multiple features including selection for backup content, backup and restore logs, and email report. Moreover, as the plugin itself does not collect any personal data, you do not need to sign a Data Processing Agreement (DPA) with us.
90
- However, if you upload your backups to cloud storage with WPvivid Backup/Restore , the personal data is transferred to that storage provider. You'll need to sign a Data Processing Agreement with that provider.
 
91
 
92
  == License ==
93
- WPvivid Backup/Restore is licensed under GPL version 3 or later.
94
  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details:[https://www.gnu.org/licenses/gpl-3.0.en.html](https://www.gnu.org/licenses/gpl-3.0.en.html).
95
 
96
  == Screenshots ==
@@ -100,30 +95,22 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
100
  4. Configure remote storage
101
 
102
  == Frequently Asked Questions ==
103
- = What can WPvivid Backup/Restore do? =
104
- WPvivid Backup/Restore enables you to perform manual and scheduled backups of your WordPress site, send them to cloud storage and restores them directly from the site's admin dashboard.
105
- = Where to download? =
106
- The plugin is available to download directly from the plugin repository on WordPress.org.
107
- = What is required to install WPvivid Backup/Restore? =
108
- To successfully install WPvivid Backup/Restore, make sure the value of upload_max_filesize in the php configuration is large than the size of WPvivid Backup/Restore installation package.
109
- = How many cloud storage options does WPvivid Backup/Restore support? =
110
- Currently WPvivid Backup/Restore supports connection to SFTP, FTP and Amazon S3. Pretty much all other popular cloud storage like Google Drive, Google Cloud, Dropbox, Microsoft Azure and more will be covered soon.
111
- = What is the largest website size can the plugin back up? =
112
- Technically, there is no limit to the backup size WPvivid Backup/Restore can run. As long as your hosting server allows for creating a large size of backup, WPvivid Backup/Restore can back it up successfully.
113
- = What data on website is backed up by WPvivid Backup/Restore? =
114
- A complete backup includes everything on your website database and directories including database, plugins, themes, files, uploads, and WordPress core files. However, you can also choose to back up only WordPress files or only database.
115
- = Do I need to pay for restore feature? =
116
- Never. Restore feature on WPvivid Backup/Restore is completely free.
117
- = How do I upgrade to the latest version? =
118
- Once a new version is released, an updating message will be sent to you on WordPress admin dashboard. Click the update link in the message body to upgrade to the latest version.
119
- = How much server resources does WPvivid Backup/Restore consume? =
120
- WPvivid Backup/Restore is a lightweight plugin that does not use much disk space on your server, this should be said with the exception of the space used to store backups when you choose to backup to your hosting server. WPvivid Backup/Restore only consumes little CPU when perform tasks.
121
- = Do I need to pay for support? Where can I get a support? =
122
- Never. We provide free and responsive support for WPvivid Backup/Restore through multiple channels, including the support forum for WPvivid Backup/Restore on WordPress.org, our elaborate FAQs as well as email support. Typically, our support team will reply you within 24 hours during the normal business days. It will be extremely helpful if you can also attach the detailed error description, any relevant plugins, as well as the error logs which are available to download on the plugin's Website Info page.
123
- = Does WPvivid Backup/Restore delete all its settings when it is uninstalled? =
124
- Yes. Deleting WPvivid Backup/Restore will also delete its settings on your site. However, in case you may need to use the settings again, use Export/Import settings features on the plugin's Setting page to keep it on your computer.
125
- = Does WPvivid Backup/Restore delete all its backups when it is uninstalled? =
126
- No. When WPvivid Backup/Restore is uninstalled, the backups in local will not be deleted as well, neither do the logs.
127
  = What does the error "Error: Backup error: Allowed memory size of xxxxxxxxxx bytes exhausted (tried to allocate xxxxxxxxxx bytes), task id: wpvivid-xxxxxxxxxxxxx." mean? =
128
  This error often occurs while creating a backup for a website with an oversized database. In this case, the size of database is larger than the value of memory limit in php.ini file. As a result, there will be no sufficient memory to compress the database.
129
  To avoid that, please try using the solutions below to modify memory limit in php.ini file, and make sure the value is larger than the database size:
@@ -132,28 +119,32 @@ Please try to contact your web hosting provider for changing PHP memory limit, o
132
  2. Upgrade your web hosting plan.
133
 
134
  == Contact us ==
135
- Communication always makes life easier. We have the most approachable and friendly staff out there ready to talk with you and help you out. Do let us know how we can help, and what we can do more. Use the support forum for WPvivid Backup/Restore on WordPress.org or email us at wpvivid.com@gmail.com, you can also reach us with a direct message on [Twitter](https://twitter.com/WPvividcom).
136
 
137
  == Changelog ==
 
 
 
 
138
  = 0.9.7 =
139
  - Fixed data type errors caused by the last update. The errors would cause the failure of running of scheduled backup tasks. We highly recommend you upgrade.
140
- - Fixed a bug where the last backup information was not displayed in the backup schedule list.
141
  - Changed a few error messages that appear during the backup process.
142
- - Optimized the code of the plugin.
143
  = 0.9.6 =
144
- - Optimized the code of the plugin.
145
  - A more lightweight Amazon S3 library has been used, so that you do not need to fill in Region field while configuring a S3 storage account.
146
  = 0.9.5 =
147
- - Refined descriptions on the user interface.
148
- - Fixed a few interface errors.
149
  - Fixed a bug where backups were runnable in some cases during the process of a restoration.
150
  = 0.9.4 =
151
  - Added support for responsive design. Now the plugin is compatible with smartphones, tablets and PC.
152
  - Fixed some UI bugs.
153
  = 0.9.3 =
154
- - Fixed some display errors on the user interface.
155
  - Fixed a bug where backups could not be completed in exceptional cases.
156
  = 0.9.2 =
157
  Fixed image path display error.
158
  = 0.9.1 =
159
- Initial release of WPvivid Backup/Restore plugin. Now you see it.
1
+ === WP Automatic Cloud Backup by WPvivid ===
2
  Contributors: wpvivid
3
+ Tags: backup, cloud backup, automatic backup, restore, database backup, wordpress backup, backups, custom backups, s3, Dropbox, OneDrive, Google Drive, FTP, SFTP
4
  Requires at least: 4.5
5
+ Tested up to: 5.1
6
  Requires PHP: 5.3
7
+ Stable tag: 0.9.8
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
11
+ Automatically back up WordPress to Cloud Storage (Dropbox, Amazon S3, Microsoft OneDrive, Google Drive etc), one-click restore. All free.
12
 
13
  == Description ==
14
+ Automatically back up WordPress to Cloud Storage (Dropbox, Amazon S3, Microsoft OneDrive, Google Drive etc), one-click restore. All free.
15
+
16
+ == Core Features ==
17
+
18
+ = 1. Automatic Backup =
19
+ Back up your site automatically once a schedule is set up.
20
+ = 2. One-Click Restore =
21
+ Restore a backup of your site with single click.
22
+ = 3. Easy Site Migration =
23
+ Coming soon...
24
+
25
+ == Free Cloud Backup ==
26
+
27
+ Dropbox, Google Drive, Microsoft OneDrive, Amazon S3, SFTP, FTP and more are coming soon.
28
+
29
+ == Features Spotlight ==
30
+ * Manual Backup
31
+ * Filter Large Files
32
+ * Large Database Support
33
+ * Optimization for Web hosting
34
+ * Backup Limits
35
+ * Backup Splitting
36
+ * No Limit to Backup Size
37
+ * Backup to Localhost
38
+ * Clean Junk Files
39
+ * Schedule Automated Backups
40
+ * Customize Backup Content
41
+ * Download Backup
42
+ * Instant Email Report
43
+ * Log Files
44
+ * Responsive Design
45
+ * WordPress MU Support
46
+
47
+ == Other Amazing Features ==
48
+ * Customize name of a local storage directory
49
+ * Lock a backup to keep it safe from auto deletion
 
 
 
50
  * Live progress
51
+ * More basic features will be continuously added
 
 
52
 
53
  == Minimum Requirements ==
54
  * PHP version 5.3
57
  * Character Encoding UTF-8
58
 
59
  == Support ==
60
+ We offer free support in 3 channels:
61
+ = Forum Support: = Post questions to get faster answers in WordPress.org support forum for the plugin.
62
+ = Email Support: = Leave us a message at our [contact page](https://wpvivid.com/contact-us) and we will back to you soon.
63
+ = FAQs: = Check out our FAQs section on the page, you can easily find an answer for the most part.
64
 
65
  == Installation and Uninstallation ==
66
 
67
+ = Installation =
68
  1.Go to your sites admin dashboard.
69
+ 2.Navigate to Plugin Menu and simply search for WPvivid.
70
  3.Click Install Now then click Activate Plugin.
71
 
72
+ = Uninstallation =
73
  1.Click Deactivate from the Plugin Menu.
74
  2.Click Delete.
 
75
 
76
  == Privacy Policy and GDPR Compliance ==
77
+ WP Automatic Cloud Backup by WPvivid is created and operated with full respect and protection of users personal information, and is in full compliance with General Data Protection Regulation(GDPR). Check out the following content to know the details:
78
  = What personal data can WPvivid Backup/Restore access and how is the data processed? =
79
+ The plugin currently only has a free version and is available to download from WordPress plugin repository. Thus, all the data related to the updates of the versions as well as the support forum for the plugin on WordPress.org is held by WordPress.org.
80
  In addition, the implementations of all backups and restores of your site happen completely on your website server, there are no data come across any of our servers in the whole process.
81
  The only personal data currently we can access are the contact data when you contact us by email, which may include your name, email address and other contact details. The data will only be used for the purposes of handling and resolving your enquiry.
82
+ = How does WP Automatic Cloud Backup by WPvivid help users create a GDPR compliant backup? =
83
+ In order to help users create a GDPR compliant backup, the plugin comes with multiple features including selection for backup content, backup and restore logs, and email report. Moreover, as the plugin itself does not collect any personal data, you do not need to sign a Data Processing Agreement (DPA) with us.
84
+ However, if you upload your backups to cloud storage with WP Automatic Cloud Backup by WPvivid, the personal data is transferred to that storage provider. You'll need to sign a Data Processing Agreement with that provider.
85
+ Check out the [privacy policy](https://wpvivid.com/privacy-policy) involving the use of Google Drive, Dropbox and Microsoft OneDrive.
86
 
87
  == License ==
88
+ WP Automatic Cloud Backup by WPvivid is licensed under GPL version 3 or later.
89
  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details:[https://www.gnu.org/licenses/gpl-3.0.en.html](https://www.gnu.org/licenses/gpl-3.0.en.html).
90
 
91
  == Screenshots ==
95
  4. Configure remote storage
96
 
97
  == Frequently Asked Questions ==
98
+ = What does WP Automatic Cloud Backup by WPvivid do? =
99
+ WP Automatic Cloud Backup by WPvivid enables you to perform manual and scheduled backups of your WordPress site, back up to cloud storage and restore backups directly from the site's admin dashboard.
100
+ = How many cloud options does it support? Are they free to access? =
101
+ Dropbox, Google Drive, Amazon S3, Microsoft OneDrive, FTP, SFTP and more are coming soon.
102
+
103
+ Yes, all the cloud access is free.
104
+ = Is restore feature free? =
105
+ Yes, absolutely.
106
+ = Is upgrade free? How do I upgrade to the newest version? =
107
+ Yes. You’ll be notified in your WP admin menu once a new upgrade is available.
108
+ = Does the plugin also migrate my site? =
109
+ Not yet, the migration feature will be launched soon.
110
+ = Do you provide support for the free version? Where? =
111
+ Yes, absolutely. Find it in WordPress.org support forum for the plugin, through [email](https://wpvivid.com/contact-us), and by browsing through FAQs.
112
+ = Will the plugin work on my host? =
113
+ Basically, yes. The plugin has been optimized to improve backup success rate for many shared/webhostings. We’ve also tested a large number of web hosts (e.g. godady.com siteground.com bluehost.com etc.) without any issues.
 
 
 
 
 
 
 
 
114
  = What does the error "Error: Backup error: Allowed memory size of xxxxxxxxxx bytes exhausted (tried to allocate xxxxxxxxxx bytes), task id: wpvivid-xxxxxxxxxxxxx." mean? =
115
  This error often occurs while creating a backup for a website with an oversized database. In this case, the size of database is larger than the value of memory limit in php.ini file. As a result, there will be no sufficient memory to compress the database.
116
  To avoid that, please try using the solutions below to modify memory limit in php.ini file, and make sure the value is larger than the database size:
119
  2. Upgrade your web hosting plan.
120
 
121
  == Contact us ==
122
+ Feel free to let us know how we can help using the support forum for the plugin on WordPress.org or our [contact form](https://wpvivid.com/contact-us). You can also reach us with a direct message on [Twitter](https://twitter.com/WPvividcom).
123
 
124
  == Changelog ==
125
+ = 0.9.8 =
126
+ - Added support for Google Drive, Micosoft OneDrive, Dropbox cloud storage.
127
+ - Fixed a bug where restoring a backup from cloud storage would fail because of failure of downloading the backup from cloud storage to localhost.
128
+ - Optimized code of the plugin.
129
  = 0.9.7 =
130
  - Fixed data type errors caused by the last update. The errors would cause the failure of running of scheduled backup tasks. We highly recommend you upgrade.
131
+ - Fixed a bug where the last backup information was not displayed in backup schedule list.
132
  - Changed a few error messages that appear during the backup process.
133
+ - Optimized code of the plugin.
134
  = 0.9.6 =
135
+ - Optimized code of the plugin.
136
  - A more lightweight Amazon S3 library has been used, so that you do not need to fill in Region field while configuring a S3 storage account.
137
  = 0.9.5 =
138
+ - Refined descriptions on user interface.
139
+ - Fixed a few UI bugs.
140
  - Fixed a bug where backups were runnable in some cases during the process of a restoration.
141
  = 0.9.4 =
142
  - Added support for responsive design. Now the plugin is compatible with smartphones, tablets and PC.
143
  - Fixed some UI bugs.
144
  = 0.9.3 =
145
+ - Fixed some display errors on user interface.
146
  - Fixed a bug where backups could not be completed in exceptional cases.
147
  = 0.9.2 =
148
  Fixed image path display error.
149
  = 0.9.1 =
150
+ Initial release of the plugin. Now you see it.
vendor/autoload.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload.php @generated by Composer
4
+
5
+ require_once __DIR__ . '/composer/autoload_real.php';
6
+
7
+ return ComposerAutoloaderInit07ef8280f25e8eb2f189bfede845a386::getLoader();
vendor/composer/ClassLoader.php ADDED
@@ -0,0 +1,445 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Composer.
5
+ *
6
+ * (c) Nils Adermann <naderman@naderman.de>
7
+ * Jordi Boggiano <j.boggiano@seld.be>
8
+ *
9
+ * For the full copyright and license information, please view the LICENSE
10
+ * file that was distributed with this source code.
11
+ */
12
+
13
+ namespace Composer\Autoload;
14
+
15
+ /**
16
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
17
+ *
18
+ * $loader = new \Composer\Autoload\ClassLoader();
19
+ *
20
+ * // register classes with namespaces
21
+ * $loader->add('Symfony\Component', __DIR__.'/component');
22
+ * $loader->add('Symfony', __DIR__.'/framework');
23
+ *
24
+ * // activate the autoloader
25
+ * $loader->register();
26
+ *
27
+ * // to enable searching the include path (eg. for PEAR packages)
28
+ * $loader->setUseIncludePath(true);
29
+ *
30
+ * In this example, if you try to use a class in the Symfony\Component
31
+ * namespace or one of its children (Symfony\Component\Console for instance),
32
+ * the autoloader will first look for the class under the component/
33
+ * directory, and it will then fallback to the framework/ directory if not
34
+ * found before giving up.
35
+ *
36
+ * This class is loosely based on the Symfony UniversalClassLoader.
37
+ *
38
+ * @author Fabien Potencier <fabien@symfony.com>
39
+ * @author Jordi Boggiano <j.boggiano@seld.be>
40
+ * @see http://www.php-fig.org/psr/psr-0/
41
+ * @see http://www.php-fig.org/psr/psr-4/
42
+ */
43
+ class ClassLoader
44
+ {
45
+ // PSR-4
46
+ private $prefixLengthsPsr4 = array();
47
+ private $prefixDirsPsr4 = array();
48
+ private $fallbackDirsPsr4 = array();
49
+
50
+ // PSR-0
51
+ private $prefixesPsr0 = array();
52
+ private $fallbackDirsPsr0 = array();
53
+
54
+ private $useIncludePath = false;
55
+ private $classMap = array();
56
+ private $classMapAuthoritative = false;
57
+ private $missingClasses = array();
58
+ private $apcuPrefix;
59
+
60
+ public function getPrefixes()
61
+ {
62
+ if (!empty($this->prefixesPsr0)) {
63
+ return call_user_func_array('array_merge', $this->prefixesPsr0);
64
+ }
65
+
66
+ return array();
67
+ }
68
+
69
+ public function getPrefixesPsr4()
70
+ {
71
+ return $this->prefixDirsPsr4;
72
+ }
73
+
74
+ public function getFallbackDirs()
75
+ {
76
+ return $this->fallbackDirsPsr0;
77
+ }
78
+
79
+ public function getFallbackDirsPsr4()
80
+ {
81
+ return $this->fallbackDirsPsr4;
82
+ }
83
+
84
+ public function getClassMap()
85
+ {
86
+ return $this->classMap;
87
+ }
88
+
89
+ /**
90
+ * @param array $classMap Class to filename map
91
+ */
92
+ public function addClassMap(array $classMap)
93
+ {
94
+ if ($this->classMap) {
95
+ $this->classMap = array_merge($this->classMap, $classMap);
96
+ } else {
97
+ $this->classMap = $classMap;
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Registers a set of PSR-0 directories for a given prefix, either
103
+ * appending or prepending to the ones previously set for this prefix.
104
+ *
105
+ * @param string $prefix The prefix
106
+ * @param array|string $paths The PSR-0 root directories
107
+ * @param bool $prepend Whether to prepend the directories
108
+ */
109
+ public function add($prefix, $paths, $prepend = false)
110
+ {
111
+ if (!$prefix) {
112
+ if ($prepend) {
113
+ $this->fallbackDirsPsr0 = array_merge(
114
+ (array) $paths,
115
+ $this->fallbackDirsPsr0
116
+ );
117
+ } else {
118
+ $this->fallbackDirsPsr0 = array_merge(
119
+ $this->fallbackDirsPsr0,
120
+ (array) $paths
121
+ );
122
+ }
123
+
124
+ return;
125
+ }
126
+
127
+ $first = $prefix[0];
128
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
129
+ $this->prefixesPsr0[$first][$prefix] = (array) $paths;
130
+
131
+ return;
132
+ }
133
+ if ($prepend) {
134
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
135
+ (array) $paths,
136
+ $this->prefixesPsr0[$first][$prefix]
137
+ );
138
+ } else {
139
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
140
+ $this->prefixesPsr0[$first][$prefix],
141
+ (array) $paths
142
+ );
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Registers a set of PSR-4 directories for a given namespace, either
148
+ * appending or prepending to the ones previously set for this namespace.
149
+ *
150
+ * @param string $prefix The prefix/namespace, with trailing '\\'
151
+ * @param array|string $paths The PSR-4 base directories
152
+ * @param bool $prepend Whether to prepend the directories
153
+ *
154
+ * @throws \InvalidArgumentException
155
+ */
156
+ public function addPsr4($prefix, $paths, $prepend = false)
157
+ {
158
+ if (!$prefix) {
159
+ // Register directories for the root namespace.
160
+ if ($prepend) {
161
+ $this->fallbackDirsPsr4 = array_merge(
162
+ (array) $paths,
163
+ $this->fallbackDirsPsr4
164
+ );
165
+ } else {
166
+ $this->fallbackDirsPsr4 = array_merge(
167
+ $this->fallbackDirsPsr4,
168
+ (array) $paths
169
+ );
170
+ }
171
+ } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
172
+ // Register directories for a new namespace.
173
+ $length = strlen($prefix);
174
+ if ('\\' !== $prefix[$length - 1]) {
175
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
176
+ }
177
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
178
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
179
+ } elseif ($prepend) {
180
+ // Prepend directories for an already registered namespace.
181
+ $this->prefixDirsPsr4[$prefix] = array_merge(
182
+ (array) $paths,
183
+ $this->prefixDirsPsr4[$prefix]
184
+ );
185
+ } else {
186
+ // Append directories for an already registered namespace.
187
+ $this->prefixDirsPsr4[$prefix] = array_merge(
188
+ $this->prefixDirsPsr4[$prefix],
189
+ (array) $paths
190
+ );
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Registers a set of PSR-0 directories for a given prefix,
196
+ * replacing any others previously set for this prefix.
197
+ *
198
+ * @param string $prefix The prefix
199
+ * @param array|string $paths The PSR-0 base directories
200
+ */
201
+ public function set($prefix, $paths)
202
+ {
203
+ if (!$prefix) {
204
+ $this->fallbackDirsPsr0 = (array) $paths;
205
+ } else {
206
+ $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
207
+ }
208
+ }
209
+
210
+ /**
211
+ * Registers a set of PSR-4 directories for a given namespace,
212
+ * replacing any others previously set for this namespace.
213
+ *
214
+ * @param string $prefix The prefix/namespace, with trailing '\\'
215
+ * @param array|string $paths The PSR-4 base directories
216
+ *
217
+ * @throws \InvalidArgumentException
218
+ */
219
+ public function setPsr4($prefix, $paths)
220
+ {
221
+ if (!$prefix) {
222
+ $this->fallbackDirsPsr4 = (array) $paths;
223
+ } else {
224
+ $length = strlen($prefix);
225
+ if ('\\' !== $prefix[$length - 1]) {
226
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
227
+ }
228
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
229
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
230
+ }
231
+ }
232
+
233
+ /**
234
+ * Turns on searching the include path for class files.
235
+ *
236
+ * @param bool $useIncludePath
237
+ */
238
+ public function setUseIncludePath($useIncludePath)
239
+ {
240
+ $this->useIncludePath = $useIncludePath;
241
+ }
242
+
243
+ /**
244
+ * Can be used to check if the autoloader uses the include path to check
245
+ * for classes.
246
+ *
247
+ * @return bool
248
+ */
249
+ public function getUseIncludePath()
250
+ {
251
+ return $this->useIncludePath;
252
+ }
253
+
254
+ /**
255
+ * Turns off searching the prefix and fallback directories for classes
256
+ * that have not been registered with the class map.
257
+ *
258
+ * @param bool $classMapAuthoritative
259
+ */
260
+ public function setClassMapAuthoritative($classMapAuthoritative)
261
+ {
262
+ $this->classMapAuthoritative = $classMapAuthoritative;
263
+ }
264
+
265
+ /**
266
+ * Should class lookup fail if not found in the current class map?
267
+ *
268
+ * @return bool
269
+ */
270
+ public function isClassMapAuthoritative()
271
+ {
272
+ return $this->classMapAuthoritative;
273
+ }
274
+
275
+ /**
276
+ * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
277
+ *
278
+ * @param string|null $apcuPrefix
279
+ */
280
+ public function setApcuPrefix($apcuPrefix)
281
+ {
282
+ $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
283
+ }
284
+
285
+ /**
286
+ * The APCu prefix in use, or null if APCu caching is not enabled.
287
+ *
288
+ * @return string|null
289
+ */
290
+ public function getApcuPrefix()
291
+ {
292
+ return $this->apcuPrefix;
293
+ }
294
+
295
+ /**
296
+ * Registers this instance as an autoloader.
297
+ *
298
+ * @param bool $prepend Whether to prepend the autoloader or not
299
+ */
300
+ public function register($prepend = false)
301
+ {
302
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
303
+ }
304
+
305
+ /**
306
+ * Unregisters this instance as an autoloader.
307
+ */
308
+ public function unregister()
309
+ {
310
+ spl_autoload_unregister(array($this, 'loadClass'));
311
+ }
312
+
313
+ /**
314
+ * Loads the given class or interface.
315
+ *
316
+ * @param string $class The name of the class
317
+ * @return bool|null True if loaded, null otherwise
318
+ */
319
+ public function loadClass($class)
320
+ {
321
+ if ($file = $this->findFile($class)) {
322
+ includeFile($file);
323
+
324
+ return true;
325
+ }
326
+ }
327
+
328
+ /**
329
+ * Finds the path to the file where the class is defined.
330
+ *
331
+ * @param string $class The name of the class
332
+ *
333
+ * @return string|false The path if found, false otherwise
334
+ */
335
+ public function findFile($class)
336
+ {
337
+ // class map lookup
338
+ if (isset($this->classMap[$class])) {
339
+ return $this->classMap[$class];
340
+ }
341
+ if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
342
+ return false;
343
+ }
344
+ if (null !== $this->apcuPrefix) {
345
+ $file = apcu_fetch($this->apcuPrefix.$class, $hit);
346
+ if ($hit) {
347
+ return $file;
348
+ }
349
+ }
350
+
351
+ $file = $this->findFileWithExtension($class, '.php');
352
+
353
+ // Search for Hack files if we are running on HHVM
354
+ if (false === $file && defined('HHVM_VERSION')) {
355
+ $file = $this->findFileWithExtension($class, '.hh');
356
+ }
357
+
358
+ if (null !== $this->apcuPrefix) {
359
+ apcu_add($this->apcuPrefix.$class, $file);
360
+ }
361
+
362
+ if (false === $file) {
363
+ // Remember that this class does not exist.
364
+ $this->missingClasses[$class] = true;
365
+ }
366
+
367
+ return $file;
368
+ }
369
+
370
+ private function findFileWithExtension($class, $ext)
371
+ {
372
+ // PSR-4 lookup
373
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
374
+
375
+ $first = $class[0];
376
+ if (isset($this->prefixLengthsPsr4[$first])) {
377
+ $subPath = $class;
378
+ while (false !== $lastPos = strrpos($subPath, '\\')) {
379
+ $subPath = substr($subPath, 0, $lastPos);
380
+ $search = $subPath . '\\';
381
+ if (isset($this->prefixDirsPsr4[$search])) {
382
+ $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
383
+ foreach ($this->prefixDirsPsr4[$search] as $dir) {
384
+ if (file_exists($file = $dir . $pathEnd)) {
385
+ return $file;
386
+ }
387
+ }
388
+ }
389
+ }
390
+ }
391
+
392
+ // PSR-4 fallback dirs
393
+ foreach ($this->fallbackDirsPsr4 as $dir) {
394
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
395
+ return $file;
396
+ }
397
+ }
398
+
399
+ // PSR-0 lookup
400
+ if (false !== $pos = strrpos($class, '\\')) {
401
+ // namespaced class name
402
+ $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
403
+ . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
404
+ } else {
405
+ // PEAR-like class name
406
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
407
+ }
408
+
409
+ if (isset($this->prefixesPsr0[$first])) {
410
+ foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
411
+ if (0 === strpos($class, $prefix)) {
412
+ foreach ($dirs as $dir) {
413
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
414
+ return $file;
415
+ }
416
+ }
417
+ }
418
+ }
419
+ }
420
+
421
+ // PSR-0 fallback dirs
422
+ foreach ($this->fallbackDirsPsr0 as $dir) {
423
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
424
+ return $file;
425
+ }
426
+ }
427
+
428
+ // PSR-0 include paths.
429
+ if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
430
+ return $file;
431
+ }
432
+
433
+ return false;
434
+ }
435
+ }
436
+
437
+ /**
438
+ * Scope isolated include.
439
+ *
440
+ * Prevents access to $this/self from included files.
441
+ */
442
+ function includeFile($file)
443
+ {
444
+ include $file;
445
+ }
vendor/composer/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Copyright (c) Nils Adermann, Jordi Boggiano
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished
9
+ to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+
vendor/composer/autoload_classmap.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_classmap.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ 'Google_Service_Exception' => $baseDir . '/includes/lib/google-api-php-client/src/Google/Service/Exception.php',
10
+ 'Google_Service_Resource' => $baseDir . '/includes/lib/google-api-php-client/src/Google/Service/Resource.php',
11
+ );
vendor/composer/autoload_files.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_files.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
10
+ 'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
11
+ 'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
12
+ '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
13
+ 'decc78cc4436b1292c6c0d151b19445c' => $vendorDir . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
14
+ '3919eeb97e98d4648304477f8ef734ba' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
15
+ );
vendor/composer/autoload_namespaces.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_namespaces.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ 'System' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'),
10
+ 'Net' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'),
11
+ 'Math' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'),
12
+ 'Google_Service_' => array($vendorDir . '/google/apiclient-services/src'),
13
+ 'Google_' => array($baseDir . '/includes/lib/google-api-php-client/src'),
14
+ 'File' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'),
15
+ 'Crypt' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'),
16
+ );
vendor/composer/autoload_psr4.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_psr4.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
10
+ 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
11
+ 'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'),
12
+ 'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
13
+ 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
14
+ 'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'),
15
+ 'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
16
+ 'Google\\Auth\\' => array($vendorDir . '/google/auth/src'),
17
+ 'Firebase\\JWT\\' => array($vendorDir . '/firebase/php-jwt/src'),
18
+ );
vendor/composer/autoload_real.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_real.php @generated by Composer
4
+
5
+ class ComposerAutoloaderInit07ef8280f25e8eb2f189bfede845a386
6
+ {
7
+ private static $loader;
8
+
9
+ public static function loadClassLoader($class)
10
+ {
11
+ if ('Composer\Autoload\ClassLoader' === $class) {
12
+ require __DIR__ . '/ClassLoader.php';
13
+ }
14
+ }
15
+
16
+ public static function getLoader()
17
+ {
18
+ if (null !== self::$loader) {
19
+ return self::$loader;
20
+ }
21
+
22
+ spl_autoload_register(array('ComposerAutoloaderInit07ef8280f25e8eb2f189bfede845a386', 'loadClassLoader'), true, true);
23
+ self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit07ef8280f25e8eb2f189bfede845a386', 'loadClassLoader'));
25
+
26
+ $includePaths = require __DIR__ . '/include_paths.php';
27
+ $includePaths[] = get_include_path();
28
+ set_include_path(implode(PATH_SEPARATOR, $includePaths));
29
+
30
+ $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
31
+ if ($useStaticLoader) {
32
+ require_once __DIR__ . '/autoload_static.php';
33
+
34
+ call_user_func(\Composer\Autoload\ComposerStaticInit07ef8280f25e8eb2f189bfede845a386::getInitializer($loader));
35
+ } else {
36
+ $map = require __DIR__ . '/autoload_namespaces.php';
37
+ foreach ($map as $namespace => $path) {
38
+ $loader->set($namespace, $path);
39
+ }
40
+
41
+ $map = require __DIR__ . '/autoload_psr4.php';
42
+ foreach ($map as $namespace => $path) {
43
+ $loader->setPsr4($namespace, $path);
44
+ }
45
+
46
+ $classMap = require __DIR__ . '/autoload_classmap.php';
47
+ if ($classMap) {
48
+ $loader->addClassMap($classMap);
49
+ }
50
+ }
51
+
52
+ $loader->register(true);
53
+
54
+ if ($useStaticLoader) {
55
+ $includeFiles = Composer\Autoload\ComposerStaticInit07ef8280f25e8eb2f189bfede845a386::$files;
56
+ } else {
57
+ $includeFiles = require __DIR__ . '/autoload_files.php';
58
+ }
59
+ foreach ($includeFiles as $fileIdentifier => $file) {
60
+ composerRequire07ef8280f25e8eb2f189bfede845a386($fileIdentifier, $file);
61
+ }
62
+
63
+ return $loader;
64
+ }
65
+ }
66
+
67
+ function composerRequire07ef8280f25e8eb2f189bfede845a386($fileIdentifier, $file)
68
+ {
69
+ if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
70
+ require $file;
71
+
72
+ $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
73
+ }
74
+ }
vendor/composer/autoload_static.php ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_static.php @generated by Composer
4
+
5
+ namespace Composer\Autoload;
6
+
7
+ class ComposerStaticInit07ef8280f25e8eb2f189bfede845a386
8
+ {
9
+ public static $files = array (
10
+ '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
11
+ 'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
12
+ 'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/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 (
19
+ 'P' =>
20
+ array (
21
+ 'Psr\\Log\\' => 8,
22
+ 'Psr\\Http\\Message\\' => 17,
23
+ 'Psr\\Cache\\' => 10,
24
+ ),
25
+ 'M' =>
26
+ array (
27
+ 'Monolog\\' => 8,
28
+ ),
29
+ 'G' =>
30
+ array (
31
+ 'GuzzleHttp\\Psr7\\' => 16,
32
+ 'GuzzleHttp\\Promise\\' => 19,
33
+ 'GuzzleHttp\\' => 11,
34
+ 'Google\\Auth\\' => 12,
35
+ ),
36
+ 'F' =>
37
+ array (
38
+ 'Firebase\\JWT\\' => 13,
39
+ ),
40
+ );
41
+
42
+ public static $prefixDirsPsr4 = array (
43
+ 'Psr\\Log\\' =>
44
+ array (
45
+ 0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
46
+ ),
47
+ 'Psr\\Http\\Message\\' =>
48
+ array (
49
+ 0 => __DIR__ . '/..' . '/psr/http-message/src',
50
+ ),
51
+ 'Psr\\Cache\\' =>
52
+ array (
53
+ 0 => __DIR__ . '/..' . '/psr/cache/src',
54
+ ),
55
+ 'Monolog\\' =>
56
+ array (
57
+ 0 => __DIR__ . '/..' . '/monolog/monolog/src/Monolog',
58
+ ),
59
+ 'GuzzleHttp\\Psr7\\' =>
60
+ array (
61
+ 0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src',
62
+ ),
63
+ 'GuzzleHttp\\Promise\\' =>
64
+ array (
65
+ 0 => __DIR__ . '/..' . '/guzzlehttp/promises/src',
66
+ ),
67
+ 'GuzzleHttp\\' =>
68
+ array (
69
+ 0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src',
70
+ ),
71
+ 'Google\\Auth\\' =>
72
+ array (
73
+ 0 => __DIR__ . '/..' . '/google/auth/src',
74
+ ),
75
+ 'Firebase\\JWT\\' =>
76
+ array (
77
+ 0 => __DIR__ . '/..' . '/firebase/php-jwt/src',
78
+ ),
79
+ );
80
+
81
+ public static $prefixesPsr0 = array (
82
+ 'S' =>
83
+ array (
84
+ 'System' =>
85
+ array (
86
+ 0 => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib',
87
+ ),
88
+ ),
89
+ 'N' =>
90
+ array (
91
+ 'Net' =>
92
+ array (
93
+ 0 => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib',
94
+ ),
95
+ ),
96
+ 'M' =>
97
+ array (
98
+ 'Math' =>
99
+ array (
100
+ 0 => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib',
101
+ ),
102
+ ),
103
+ 'G' =>
104
+ array (
105
+ 'Google_Service_' =>
106
+ array (
107
+ 0 => __DIR__ . '/..' . '/google/apiclient-services/src',
108
+ ),
109
+ 'Google_' =>
110
+ array (
111
+ 0 => __DIR__ . '/../..' . '/includes/lib/google-api-php-client/src',
112
+ ),
113
+ ),
114
+ 'F' =>
115
+ array (
116
+ 'File' =>
117
+ array (
118
+ 0 => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib',
119
+ ),
120
+ ),
121
+ 'C' =>
122
+ array (
123
+ 'Crypt' =>
124
+ array (
125
+ 0 => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib',
126
+ ),
127
+ ),
128
+ );
129
+
130
+ public static $classMap = array (
131
+ 'Google_Service_Exception' => __DIR__ . '/../..' . '/includes/lib/google-api-php-client/src/Google/Service/Exception.php',
132
+ 'Google_Service_Resource' => __DIR__ . '/../..' . '/includes/lib/google-api-php-client/src/Google/Service/Resource.php',
133
+ );
134
+
135
+ public static function getInitializer(ClassLoader $loader)
136
+ {
137
+ return \Closure::bind(function () use ($loader) {
138
+ $loader->prefixLengthsPsr4 = ComposerStaticInit07ef8280f25e8eb2f189bfede845a386::$prefixLengthsPsr4;
139
+ $loader->prefixDirsPsr4 = ComposerStaticInit07ef8280f25e8eb2f189bfede845a386::$prefixDirsPsr4;
140
+ $loader->prefixesPsr0 = ComposerStaticInit07ef8280f25e8eb2f189bfede845a386::$prefixesPsr0;
141
+ $loader->classMap = ComposerStaticInit07ef8280f25e8eb2f189bfede845a386::$classMap;
142
+
143
+ }, null, ClassLoader::class);
144
+ }
145
+ }
vendor/composer/include_paths.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // include_paths.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ $vendorDir . '/phpseclib/phpseclib/phpseclib',
10
+ );
vendor/composer/installed.json ADDED
@@ -0,0 +1,699 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "name": "firebase/php-jwt",
4
+ "version": "v5.0.0",
5
+ "version_normalized": "5.0.0.0",
6
+ "source": {
7
+ "type": "git",
8
+ "url": "https://github.com/firebase/php-jwt.git",
9
+ "reference": "9984a4d3a32ae7673d6971ea00bae9d0a1abba0e"
10
+ },
11
+ "dist": {
12
+ "type": "zip",
13
+ "url": "https://api.github.com/repos/firebase/php-jwt/zipball/9984a4d3a32ae7673d6971ea00bae9d0a1abba0e",
14
+ "reference": "9984a4d3a32ae7673d6971ea00bae9d0a1abba0e",
15
+ "shasum": ""
16
+ },
17
+ "require": {
18
+ "php": ">=5.3.0"
19
+ },
20
+ "require-dev": {
21
+ "phpunit/phpunit": " 4.8.35"
22
+ },
23
+ "time": "2017-06-27T22:17:23+00:00",
24
+ "type": "library",
25
+ "installation-source": "dist",
26
+ "autoload": {
27
+ "psr-4": {
28
+ "Firebase\\JWT\\": "src"
29
+ }
30
+ },
31
+ "notification-url": "https://packagist.org/downloads/",
32
+ "license": [
33
+ "BSD-3-Clause"
34
+ ],
35
+ "authors": [
36
+ {
37
+ "name": "Neuman Vong",
38
+ "email": "neuman+pear@twilio.com",
39
+ "role": "Developer"
40
+ },
41
+ {
42
+ "name": "Anant Narayanan",
43
+ "email": "anant@php.net",
44
+ "role": "Developer"
45
+ }
46
+ ],
47
+ "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
48
+ "homepage": "https://github.com/firebase/php-jwt"
49
+ },
50
+ {
51
+ "name": "google/apiclient-services",
52
+ "version": "v0.85",
53
+ "version_normalized": "0.85.0.0",
54
+ "source": {
55
+ "type": "git",
56
+ "url": "https://github.com/googleapis/google-api-php-client-services.git",
57
+ "reference": "66bf538d26b40fec0ae3cda79eea64fe2b0cc6de"
58
+ },
59
+ "dist": {
60
+ "type": "zip",
61
+ "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/66bf538d26b40fec0ae3cda79eea64fe2b0cc6de",
62
+ "reference": "66bf538d26b40fec0ae3cda79eea64fe2b0cc6de",
63
+ "shasum": ""
64
+ },
65
+ "require": {
66
+ "php": ">=5.4"
67
+ },
68
+ "require-dev": {
69
+ "phpunit/phpunit": "~4.8"
70
+ },
71
+ "time": "2019-02-07T00:23:12+00:00",
72
+ "type": "library",
73
+ "installation-source": "dist",
74
+ "autoload": {
75
+ "psr-0": {
76
+ "Google_Service_": "src"
77
+ }
78
+ },
79
+ "notification-url": "https://packagist.org/downloads/",
80
+ "license": [
81
+ "Apache-2.0"
82
+ ],
83
+ "description": "Client library for Google APIs",
84
+ "homepage": "http://developers.google.com/api-client-library/php",
85
+ "keywords": [
86
+ "google"
87
+ ]
88
+ },
89
+ {
90
+ "name": "google/auth",
91
+ "version": "v1.4.0",
92
+ "version_normalized": "1.4.0.0",
93
+ "source": {
94
+ "type": "git",
95
+ "url": "https://github.com/googleapis/google-auth-library-php.git",
96
+ "reference": "196237248e636a3554a7d9e4dfddeb97f450ab5c"
97
+ },
98
+ "dist": {
99
+ "type": "zip",
100
+ "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/196237248e636a3554a7d9e4dfddeb97f450ab5c",
101
+ "reference": "196237248e636a3554a7d9e4dfddeb97f450ab5c",
102
+ "shasum": ""
103
+ },
104
+ "require": {
105
+ "firebase/php-jwt": "~2.0|~3.0|~4.0|~5.0",
106
+ "guzzlehttp/guzzle": "~5.3.1|~6.0",
107
+ "guzzlehttp/psr7": "^1.2",
108
+ "php": ">=5.4",
109
+ "psr/cache": "^1.0",
110
+ "psr/http-message": "^1.0"
111
+ },
112
+ "require-dev": {
113
+ "friendsofphp/php-cs-fixer": "^1.11",
114
+ "guzzlehttp/promises": "0.1.1|^1.3",
115
+ "phpunit/phpunit": "^4.8.36|^5.7",
116
+ "sebastian/comparator": ">=1.2.3"
117
+ },
118
+ "time": "2018-09-17T20:29:21+00:00",
119
+ "type": "library",
120
+ "installation-source": "dist",
121
+ "autoload": {
122
+ "psr-4": {
123
+ "Google\\Auth\\": "src"
124
+ }
125
+ },
126
+ "notification-url": "https://packagist.org/downloads/",
127
+ "license": [
128
+ "Apache-2.0"
129
+ ],
130
+ "description": "Google Auth Library for PHP",
131
+ "homepage": "http://github.com/google/google-auth-library-php",
132
+ "keywords": [
133
+ "Authentication",
134
+ "google",
135
+ "oauth2"
136
+ ]
137
+ },
138
+ {
139
+ "name": "guzzlehttp/guzzle",
140
+ "version": "6.3.3",
141
+ "version_normalized": "6.3.3.0",
142
+ "source": {
143
+ "type": "git",
144
+ "url": "https://github.com/guzzle/guzzle.git",
145
+ "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba"
146
+ },
147
+ "dist": {
148
+ "type": "zip",
149
+ "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba",
150
+ "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba",
151
+ "shasum": ""
152
+ },
153
+ "require": {
154
+ "guzzlehttp/promises": "^1.0",
155
+ "guzzlehttp/psr7": "^1.4",
156
+ "php": ">=5.5"
157
+ },
158
+ "require-dev": {
159
+ "ext-curl": "*",
160
+ "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
161
+ "psr/log": "^1.0"
162
+ },
163
+ "suggest": {
164
+ "psr/log": "Required for using the Log middleware"
165
+ },
166
+ "time": "2018-04-22T15:46:56+00:00",
167
+ "type": "library",
168
+ "extra": {
169
+ "branch-alias": {
170
+ "dev-master": "6.3-dev"
171
+ }
172
+ },
173
+ "installation-source": "dist",
174
+ "autoload": {
175
+ "files": [
176
+ "src/functions_include.php"
177
+ ],
178
+ "psr-4": {
179
+ "GuzzleHttp\\": "src/"
180
+ }
181
+ },
182
+ "notification-url": "https://packagist.org/downloads/",
183
+ "license": [
184
+ "MIT"
185
+ ],
186
+ "authors": [
187
+ {
188
+ "name": "Michael Dowling",
189
+ "email": "mtdowling@gmail.com",
190
+ "homepage": "https://github.com/mtdowling"
191
+ }
192
+ ],
193
+ "description": "Guzzle is a PHP HTTP client library",
194
+ "homepage": "http://guzzlephp.org/",
195
+ "keywords": [
196
+ "client",
197
+ "curl",
198
+ "framework",
199
+ "http",
200
+ "http client",
201
+ "rest",
202
+ "web service"
203
+ ]
204
+ },
205
+ {
206
+ "name": "guzzlehttp/promises",
207
+ "version": "v1.3.1",
208
+ "version_normalized": "1.3.1.0",
209
+ "source": {
210
+ "type": "git",
211
+ "url": "https://github.com/guzzle/promises.git",
212
+ "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646"
213
+ },
214
+ "dist": {
215
+ "type": "zip",
216
+ "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646",
217
+ "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646",
218
+ "shasum": ""
219
+ },
220
+ "require": {
221
+ "php": ">=5.5.0"
222
+ },
223
+ "require-dev": {
224
+ "phpunit/phpunit": "^4.0"
225
+ },
226
+ "time": "2016-12-20T10:07:11+00:00",
227
+ "type": "library",
228
+ "extra": {
229
+ "branch-alias": {
230
+ "dev-master": "1.4-dev"
231
+ }
232
+ },
233
+ "installation-source": "dist",
234
+ "autoload": {
235
+ "psr-4": {
236
+ "GuzzleHttp\\Promise\\": "src/"
237
+ },
238
+ "files": [
239
+ "src/functions_include.php"
240
+ ]
241
+ },
242
+ "notification-url": "https://packagist.org/downloads/",
243
+ "license": [
244
+ "MIT"
245
+ ],
246
+ "authors": [
247
+ {
248
+ "name": "Michael Dowling",
249
+ "email": "mtdowling@gmail.com",
250
+ "homepage": "https://github.com/mtdowling"
251
+ }
252
+ ],
253
+ "description": "Guzzle promises library",
254
+ "keywords": [
255
+ "promise"
256
+ ]
257
+ },
258
+ {
259
+ "name": "guzzlehttp/psr7",
260
+ "version": "1.5.2",
261
+ "version_normalized": "1.5.2.0",
262
+ "source": {
263
+ "type": "git",
264
+ "url": "https://github.com/guzzle/psr7.git",
265
+ "reference": "9f83dded91781a01c63574e387eaa769be769115"
266
+ },
267
+ "dist": {
268
+ "type": "zip",
269
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/9f83dded91781a01c63574e387eaa769be769115",
270
+ "reference": "9f83dded91781a01c63574e387eaa769be769115",
271
+ "shasum": ""
272
+ },
273
+ "require": {
274
+ "php": ">=5.4.0",
275
+ "psr/http-message": "~1.0",
276
+ "ralouphie/getallheaders": "^2.0.5"
277
+ },
278
+ "provide": {
279
+ "psr/http-message-implementation": "1.0"
280
+ },
281
+ "require-dev": {
282
+ "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8"
283
+ },
284
+ "time": "2018-12-04T20:46:45+00:00",
285
+ "type": "library",
286
+ "extra": {
287
+ "branch-alias": {
288
+ "dev-master": "1.5-dev"
289
+ }
290
+ },
291
+ "installation-source": "dist",
292
+ "autoload": {
293
+ "psr-4": {
294
+ "GuzzleHttp\\Psr7\\": "src/"
295
+ },
296
+ "files": [
297
+ "src/functions_include.php"
298
+ ]
299
+ },
300
+ "notification-url": "https://packagist.org/downloads/",
301
+ "license": [
302
+ "MIT"
303
+ ],
304
+ "authors": [
305
+ {
306
+ "name": "Michael Dowling",
307
+ "email": "mtdowling@gmail.com",
308
+ "homepage": "https://github.com/mtdowling"
309
+ },
310
+ {
311
+ "name": "Tobias Schultze",
312
+ "homepage": "https://github.com/Tobion"
313
+ }
314
+ ],
315
+ "description": "PSR-7 message implementation that also provides common utility methods",
316
+ "keywords": [
317
+ "http",
318
+ "message",
319
+ "psr-7",
320
+ "request",
321
+ "response",
322
+ "stream",
323
+ "uri",
324
+ "url"
325
+ ]
326
+ },
327
+ {
328
+ "name": "monolog/monolog",
329
+ "version": "1.24.0",
330
+ "version_normalized": "1.24.0.0",
331
+ "source": {
332
+ "type": "git",
333
+ "url": "https://github.com/Seldaek/monolog.git",
334
+ "reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266"
335
+ },
336
+ "dist": {
337
+ "type": "zip",
338
+ "url": "https://api.github.com/repos/Seldaek/monolog/zipball/bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
339
+ "reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
340
+ "shasum": ""
341
+ },
342
+ "require": {
343
+ "php": ">=5.3.0",
344
+ "psr/log": "~1.0"
345
+ },
346
+ "provide": {
347
+ "psr/log-implementation": "1.0.0"
348
+ },
349
+ "require-dev": {
350
+ "aws/aws-sdk-php": "^2.4.9 || ^3.0",
351
+ "doctrine/couchdb": "~1.0@dev",
352
+ "graylog2/gelf-php": "~1.0",
353
+ "jakub-onderka/php-parallel-lint": "0.9",
354
+ "php-amqplib/php-amqplib": "~2.4",
355
+ "php-console/php-console": "^3.1.3",
356
+ "phpunit/phpunit": "~4.5",
357
+ "phpunit/phpunit-mock-objects": "2.3.0",
358
+ "ruflin/elastica": ">=0.90 <3.0",
359
+ "sentry/sentry": "^0.13",
360
+ "swiftmailer/swiftmailer": "^5.3|^6.0"
361
+ },
362
+ "suggest": {
363
+ "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
364
+ "doctrine/couchdb": "Allow sending log messages to a CouchDB server",
365
+ "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
366
+ "ext-mongo": "Allow sending log messages to a MongoDB server",
367
+ "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
368
+ "mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver",
369
+ "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
370
+ "php-console/php-console": "Allow sending log messages to Google Chrome",
371
+ "rollbar/rollbar": "Allow sending log messages to Rollbar",
372
+ "ruflin/elastica": "Allow sending log messages to an Elastic Search server",
373
+ "sentry/sentry": "Allow sending log messages to a Sentry server"
374
+ },
375
+ "time": "2018-11-05T09:00:11+00:00",
376
+ "type": "library",
377
+ "extra": {
378
+ "branch-alias": {
379
+ "dev-master": "2.0.x-dev"
380
+ }
381
+ },
382
+ "installation-source": "dist",
383
+ "autoload": {
384
+ "psr-4": {
385
+ "Monolog\\": "src/Monolog"
386
+ }
387
+ },
388
+ "notification-url": "https://packagist.org/downloads/",
389
+ "license": [
390
+ "MIT"
391
+ ],
392
+ "authors": [
393
+ {
394
+ "name": "Jordi Boggiano",
395
+ "email": "j.boggiano@seld.be",
396
+ "homepage": "http://seld.be"
397
+ }
398
+ ],
399
+ "description": "Sends your logs to files, sockets, inboxes, databases and various web services",
400
+ "homepage": "http://github.com/Seldaek/monolog",
401
+ "keywords": [
402
+ "log",
403
+ "logging",
404
+ "psr-3"
405
+ ]
406
+ },
407
+ {
408
+ "name": "phpseclib/phpseclib",
409
+ "version": "1.0.14",
410
+ "version_normalized": "1.0.14.0",
411
+ "source": {
412
+ "type": "git",
413
+ "url": "https://github.com/phpseclib/phpseclib.git",
414
+ "reference": "7432a6959afe98b9e93153d0034b0f62ad890d31"
415
+ },
416
+ "dist": {
417
+ "type": "zip",
418
+ "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/7432a6959afe98b9e93153d0034b0f62ad890d31",
419
+ "reference": "7432a6959afe98b9e93153d0034b0f62ad890d31",
420
+ "shasum": ""
421
+ },
422
+ "require": {
423
+ "php": ">=5.0.0"
424
+ },
425
+ "require-dev": {
426
+ "phing/phing": "~2.7",
427
+ "phpunit/phpunit": "^4.8.35|^5.7|^6.0",
428
+ "sami/sami": "~2.0",
429
+ "squizlabs/php_codesniffer": "~2.0"
430
+ },
431
+ "suggest": {
432
+ "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.",
433
+ "ext-mcrypt": "Install the Mcrypt extension in order to speed up a wide variety of cryptographic operations.",
434
+ "pear-pear/PHP_Compat": "Install PHP_Compat to get phpseclib working on PHP < 5.0.0."
435
+ },
436
+ "time": "2019-01-27T19:35:10+00:00",
437
+ "type": "library",
438
+ "installation-source": "dist",
439
+ "autoload": {
440
+ "psr-0": {
441
+ "Crypt": "phpseclib/",
442
+ "File": "phpseclib/",
443
+ "Math": "phpseclib/",
444
+ "Net": "phpseclib/",
445
+ "System": "phpseclib/"
446
+ },
447
+ "files": [
448
+ "phpseclib/bootstrap.php",
449
+ "phpseclib/Crypt/Random.php"
450
+ ]
451
+ },
452
+ "notification-url": "https://packagist.org/downloads/",
453
+ "include-path": [
454
+ "phpseclib/"
455
+ ],
456
+ "license": [
457
+ "MIT"
458
+ ],
459
+ "authors": [
460
+ {
461
+ "name": "Jim Wigginton",
462
+ "email": "terrafrost@php.net",
463
+ "role": "Lead Developer"
464
+ },
465
+ {
466
+ "name": "Patrick Monnerat",
467
+ "email": "pm@datasphere.ch",
468
+ "role": "Developer"
469
+ },
470
+ {
471
+ "name": "Andreas Fischer",
472
+ "email": "bantu@phpbb.com",
473
+ "role": "Developer"
474
+ },
475
+ {
476
+ "name": "Hans-Jürgen Petrich",
477
+ "email": "petrich@tronic-media.com",
478
+ "role": "Developer"
479
+ },
480
+ {
481
+ "name": "Graham Campbell",
482
+ "email": "graham@alt-three.com",
483
+ "role": "Developer"
484
+ }
485
+ ],
486
+ "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.",
487
+ "homepage": "http://phpseclib.sourceforge.net",
488
+ "keywords": [
489
+ "BigInteger",
490
+ "aes",
491
+ "asn.1",
492
+ "asn1",
493
+ "blowfish",
494
+ "crypto",
495
+ "cryptography",
496
+ "encryption",
497
+ "rsa",
498
+ "security",
499
+ "sftp",
500
+ "signature",
501
+ "signing",
502
+ "ssh",
503
+ "twofish",
504
+ "x.509",
505
+ "x509"
506
+ ]
507
+ },
508
+ {
509
+ "name": "psr/cache",
510
+ "version": "1.0.1",
511
+ "version_normalized": "1.0.1.0",
512
+ "source": {
513
+ "type": "git",
514
+ "url": "https://github.com/php-fig/cache.git",
515
+ "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8"
516
+ },
517
+ "dist": {
518
+ "type": "zip",
519
+ "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8",
520
+ "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8",
521
+ "shasum": ""
522
+ },
523
+ "require": {
524
+ "php": ">=5.3.0"
525
+ },
526
+ "time": "2016-08-06T20:24:11+00:00",
527
+ "type": "library",
528
+ "extra": {
529
+ "branch-alias": {
530
+ "dev-master": "1.0.x-dev"
531
+ }
532
+ },
533
+ "installation-source": "dist",
534
+ "autoload": {
535
+ "psr-4": {
536
+ "Psr\\Cache\\": "src/"
537
+ }
538
+ },
539
+ "notification-url": "https://packagist.org/downloads/",
540
+ "license": [
541
+ "MIT"
542
+ ],
543
+ "authors": [
544
+ {
545
+ "name": "PHP-FIG",
546
+ "homepage": "http://www.php-fig.org/"
547
+ }
548
+ ],
549
+ "description": "Common interface for caching libraries",
550
+ "keywords": [
551
+ "cache",
552
+ "psr",
553
+ "psr-6"
554
+ ]
555
+ },
556
+ {
557
+ "name": "psr/http-message",
558
+ "version": "1.0.1",
559
+ "version_normalized": "1.0.1.0",
560
+ "source": {
561
+ "type": "git",
562
+ "url": "https://github.com/php-fig/http-message.git",
563
+ "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
564
+ },
565
+ "dist": {
566
+ "type": "zip",
567
+ "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
568
+ "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
569
+ "shasum": ""
570
+ },
571
+ "require": {
572
+ "php": ">=5.3.0"
573
+ },
574
+ "time": "2016-08-06T14:39:51+00:00",
575
+ "type": "library",
576
+ "extra": {
577
+ "branch-alias": {
578
+ "dev-master": "1.0.x-dev"
579
+ }
580
+ },
581
+ "installation-source": "dist",
582
+ "autoload": {
583
+ "psr-4": {
584
+ "Psr\\Http\\Message\\": "src/"
585
+ }
586
+ },
587
+ "notification-url": "https://packagist.org/downloads/",
588
+ "license": [
589
+ "MIT"
590
+ ],
591
+ "authors": [
592
+ {
593
+ "name": "PHP-FIG",
594
+ "homepage": "http://www.php-fig.org/"
595
+ }
596
+ ],
597
+ "description": "Common interface for HTTP messages",
598
+ "homepage": "https://github.com/php-fig/http-message",
599
+ "keywords": [
600
+ "http",
601
+ "http-message",
602
+ "psr",
603
+ "psr-7",
604
+ "request",
605
+ "response"
606
+ ]
607
+ },
608
+ {
609
+ "name": "psr/log",
610
+ "version": "1.1.0",
611
+ "version_normalized": "1.1.0.0",
612
+ "source": {
613
+ "type": "git",
614
+ "url": "https://github.com/php-fig/log.git",
615
+ "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd"
616
+ },
617
+ "dist": {
618
+ "type": "zip",
619
+ "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
620
+ "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
621
+ "shasum": ""
622
+ },
623
+ "require": {
624
+ "php": ">=5.3.0"
625
+ },
626
+ "time": "2018-11-20T15:27:04+00:00",
627
+ "type": "library",
628
+ "extra": {
629
+ "branch-alias": {
630
+ "dev-master": "1.0.x-dev"
631
+ }
632
+ },
633
+ "installation-source": "dist",
634
+ "autoload": {
635
+ "psr-4": {
636
+ "Psr\\Log\\": "Psr/Log/"
637
+ }
638
+ },
639
+ "notification-url": "https://packagist.org/downloads/",
640
+ "license": [
641
+ "MIT"
642
+ ],
643
+ "authors": [
644
+ {
645
+ "name": "PHP-FIG",
646
+ "homepage": "http://www.php-fig.org/"
647
+ }
648
+ ],
649
+ "description": "Common interface for logging libraries",
650
+ "homepage": "https://github.com/php-fig/log",
651
+ "keywords": [
652
+ "log",
653
+ "psr",
654
+ "psr-3"
655
+ ]
656
+ },
657
+ {
658
+ "name": "ralouphie/getallheaders",
659
+ "version": "2.0.5",
660
+ "version_normalized": "2.0.5.0",
661
+ "source": {
662
+ "type": "git",
663
+ "url": "https://github.com/ralouphie/getallheaders.git",
664
+ "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa"
665
+ },
666
+ "dist": {
667
+ "type": "zip",
668
+ "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/5601c8a83fbba7ef674a7369456d12f1e0d0eafa",
669
+ "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa",
670
+ "shasum": ""
671
+ },
672
+ "require": {
673
+ "php": ">=5.3"
674
+ },
675
+ "require-dev": {
676
+ "phpunit/phpunit": "~3.7.0",
677
+ "satooshi/php-coveralls": ">=1.0"
678
+ },
679
+ "time": "2016-02-11T07:05:27+00:00",
680
+ "type": "library",
681
+ "installation-source": "dist",
682
+ "autoload": {
683
+ "files": [
684
+ "src/getallheaders.php"
685
+ ]
686
+ },
687
+ "notification-url": "https://packagist.org/downloads/",
688
+ "license": [
689
+ "MIT"
690
+ ],
691
+ "authors": [
692
+ {
693
+ "name": "Ralph Khattar",
694
+ "email": "ralph.khattar@gmail.com"
695
+ }
696
+ ],
697
+ "description": "A polyfill for getallheaders."
698
+ }
699
+ ]
vendor/firebase/php-jwt/LICENSE ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2011, Neuman Vong
2
+
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ * Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+
11
+ * Redistributions in binary form must reproduce the above
12
+ copyright notice, this list of conditions and the following
13
+ disclaimer in the documentation and/or other materials provided
14
+ with the distribution.
15
+
16
+ * Neither the name of Neuman Vong nor the names of other
17
+ contributors may be used to endorse or promote products derived
18
+ from this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
vendor/firebase/php-jwt/README.md ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [![Build Status](https://travis-ci.org/firebase/php-jwt.png?branch=master)](https://travis-ci.org/firebase/php-jwt)
2
+ [![Latest Stable Version](https://poser.pugx.org/firebase/php-jwt/v/stable)](https://packagist.org/packages/firebase/php-jwt)
3
+ [![Total Downloads](https://poser.pugx.org/firebase/php-jwt/downloads)](https://packagist.org/packages/firebase/php-jwt)
4
+ [![License](https://poser.pugx.org/firebase/php-jwt/license)](https://packagist.org/packages/firebase/php-jwt)
5
+
6
+ PHP-JWT
7
+ =======
8
+ A simple library to encode and decode JSON Web Tokens (JWT) in PHP, conforming to [RFC 7519](https://tools.ietf.org/html/rfc7519).
9
+
10
+ Installation
11
+ ------------
12
+
13
+ Use composer to manage your dependencies and download PHP-JWT:
14
+
15
+ ```bash
16
+ composer require firebase/php-jwt
17
+ ```
18
+
19
+ Example
20
+ -------
21
+ ```php
22
+ <?php
23
+ use \Firebase\JWT\JWT;
24
+
25
+ $key = "example_key";
26
+ $token = array(
27
+ "iss" => "http://example.org",
28
+ "aud" => "http://example.com",
29
+ "iat" => 1356999524,
30
+ "nbf" => 1357000000
31
+ );
32
+
33
+ /**
34
+ * IMPORTANT:
35
+ * You must specify supported algorithms for your application. See
36
+ * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40
37
+ * for a list of spec-compliant algorithms.
38
+ */
39
+ $jwt = JWT::encode($token, $key);
40
+ $decoded = JWT::decode($jwt, $key, array('HS256'));
41
+
42
+ print_r($decoded);
43
+
44
+ /*
45
+ NOTE: This will now be an object instead of an associative array. To get
46
+ an associative array, you will need to cast it as such:
47
+ */
48
+
49
+ $decoded_array = (array) $decoded;
50
+
51
+ /**
52
+ * You can add a leeway to account for when there is a clock skew times between
53
+ * the signing and verifying servers. It is recommended that this leeway should
54
+ * not be bigger than a few minutes.
55
+ *
56
+ * Source: http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html#nbfDef
57
+ */
58
+ JWT::$leeway = 60; // $leeway in seconds
59
+ $decoded = JWT::decode($jwt, $key, array('HS256'));
60
+
61
+ ?>
62
+ ```
63
+ Example with RS256 (openssl)
64
+ ----------------------------
65
+ ```php
66
+ <?php
67
+ use \Firebase\JWT\JWT;
68
+
69
+ $privateKey = <<<EOD
70
+ -----BEGIN RSA PRIVATE KEY-----
71
+ MIICXAIBAAKBgQC8kGa1pSjbSYZVebtTRBLxBz5H4i2p/llLCrEeQhta5kaQu/Rn
72
+ vuER4W8oDH3+3iuIYW4VQAzyqFpwuzjkDI+17t5t0tyazyZ8JXw+KgXTxldMPEL9
73
+ 5+qVhgXvwtihXC1c5oGbRlEDvDF6Sa53rcFVsYJ4ehde/zUxo6UvS7UrBQIDAQAB
74
+ AoGAb/MXV46XxCFRxNuB8LyAtmLDgi/xRnTAlMHjSACddwkyKem8//8eZtw9fzxz
75
+ bWZ/1/doQOuHBGYZU8aDzzj59FZ78dyzNFoF91hbvZKkg+6wGyd/LrGVEB+Xre0J
76
+ Nil0GReM2AHDNZUYRv+HYJPIOrB0CRczLQsgFJ8K6aAD6F0CQQDzbpjYdx10qgK1
77
+ cP59UHiHjPZYC0loEsk7s+hUmT3QHerAQJMZWC11Qrn2N+ybwwNblDKv+s5qgMQ5
78
+ 5tNoQ9IfAkEAxkyffU6ythpg/H0Ixe1I2rd0GbF05biIzO/i77Det3n4YsJVlDck
79
+ ZkcvY3SK2iRIL4c9yY6hlIhs+K9wXTtGWwJBAO9Dskl48mO7woPR9uD22jDpNSwe
80
+ k90OMepTjzSvlhjbfuPN1IdhqvSJTDychRwn1kIJ7LQZgQ8fVz9OCFZ/6qMCQGOb
81
+ qaGwHmUK6xzpUbbacnYrIM6nLSkXgOAwv7XXCojvY614ILTK3iXiLBOxPu5Eu13k
82
+ eUz9sHyD6vkgZzjtxXECQAkp4Xerf5TGfQXGXhxIX52yH+N2LtujCdkQZjXAsGdm
83
+ B2zNzvrlgRmgBrklMTrMYgm1NPcW+bRLGcwgW2PTvNM=
84
+ -----END RSA PRIVATE KEY-----
85
+ EOD;
86
+
87
+ $publicKey = <<<EOD
88
+ -----BEGIN PUBLIC KEY-----
89
+ MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8kGa1pSjbSYZVebtTRBLxBz5H
90
+ 4i2p/llLCrEeQhta5kaQu/RnvuER4W8oDH3+3iuIYW4VQAzyqFpwuzjkDI+17t5t
91
+ 0tyazyZ8JXw+KgXTxldMPEL95+qVhgXvwtihXC1c5oGbRlEDvDF6Sa53rcFVsYJ4
92
+ ehde/zUxo6UvS7UrBQIDAQAB
93
+ -----END PUBLIC KEY-----
94
+ EOD;
95
+
96
+ $token = array(
97
+ "iss" => "example.org",
98
+ "aud" => "example.com",
99
+ "iat" => 1356999524,
100
+ "nbf" => 1357000000
101
+ );
102
+
103
+ $jwt = JWT::encode($token, $privateKey, 'RS256');
104
+ echo "Encode:\n" . print_r($jwt, true) . "\n";
105
+
106
+ $decoded = JWT::decode($jwt, $publicKey, array('RS256'));
107
+
108
+ /*
109
+ NOTE: This will now be an object instead of an associative array. To get
110
+ an associative array, you will need to cast it as such:
111
+ */
112
+
113
+ $decoded_array = (array) $decoded;
114
+ echo "Decode:\n" . print_r($decoded_array, true) . "\n";
115
+ ?>
116
+ ```
117
+
118
+ Changelog
119
+ ---------
120
+
121
+ #### 5.0.0 / 2017-06-26
122
+ - Support RS384 and RS512.
123
+ See [#117](https://github.com/firebase/php-jwt/pull/117). Thanks [@joostfaassen](https://github.com/joostfaassen)!
124
+ - Add an example for RS256 openssl.
125
+ See [#125](https://github.com/firebase/php-jwt/pull/125). Thanks [@akeeman](https://github.com/akeeman)!
126
+ - Detect invalid Base64 encoding in signature.
127
+ See [#162](https://github.com/firebase/php-jwt/pull/162). Thanks [@psignoret](https://github.com/psignoret)!
128
+ - Update `JWT::verify` to handle OpenSSL errors.
129
+ See [#159](https://github.com/firebase/php-jwt/pull/159). Thanks [@bshaffer](https://github.com/bshaffer)!
130
+ - Add `array` type hinting to `decode` method
131
+ See [#101](https://github.com/firebase/php-jwt/pull/101). Thanks [@hywak](https://github.com/hywak)!
132
+ - Add all JSON error types.
133
+ See [#110](https://github.com/firebase/php-jwt/pull/110). Thanks [@gbalduzzi](https://github.com/gbalduzzi)!
134
+ - Bugfix 'kid' not in given key list.
135
+ See [#129](https://github.com/firebase/php-jwt/pull/129). Thanks [@stampycode](https://github.com/stampycode)!
136
+ - Miscellaneous cleanup, documentation and test fixes.
137
+ See [#107](https://github.com/firebase/php-jwt/pull/107), [#115](https://github.com/firebase/php-jwt/pull/115),
138
+ [#160](https://github.com/firebase/php-jwt/pull/160), [#161](https://github.com/firebase/php-jwt/pull/161), and
139
+ [#165](https://github.com/firebase/php-jwt/pull/165). Thanks [@akeeman](https://github.com/akeeman),
140
+ [@chinedufn](https://github.com/chinedufn), and [@bshaffer](https://github.com/bshaffer)!
141
+
142
+ #### 4.0.0 / 2016-07-17
143
+ - Add support for late static binding. See [#88](https://github.com/firebase/php-jwt/pull/88) for details. Thanks to [@chappy84](https://github.com/chappy84)!
144
+ - Use static `$timestamp` instead of `time()` to improve unit testing. See [#93](https://github.com/firebase/php-jwt/pull/93) for details. Thanks to [@josephmcdermott](https://github.com/josephmcdermott)!
145
+ - Fixes to exceptions classes. See [#81](https://github.com/firebase/php-jwt/pull/81) for details. Thanks to [@Maks3w](https://github.com/Maks3w)!
146
+ - Fixes to PHPDoc. See [#76](https://github.com/firebase/php-jwt/pull/76) for details. Thanks to [@akeeman](https://github.com/akeeman)!
147
+
148
+ #### 3.0.0 / 2015-07-22
149
+ - Minimum PHP version updated from `5.2.0` to `5.3.0`.
150
+ - Add `\Firebase\JWT` namespace. See
151
+ [#59](https://github.com/firebase/php-jwt/pull/59) for details. Thanks to
152
+ [@Dashron](https://github.com/Dashron)!
153
+ - Require a non-empty key to decode and verify a JWT. See
154
+ [#60](https://github.com/firebase/php-jwt/pull/60) for details. Thanks to
155
+ [@sjones608](https://github.com/sjones608)!
156
+ - Cleaner documentation blocks in the code. See
157
+ [#62](https://github.com/firebase/php-jwt/pull/62) for details. Thanks to
158
+ [@johanderuijter](https://github.com/johanderuijter)!
159
+
160
+ #### 2.2.0 / 2015-06-22
161
+ - Add support for adding custom, optional JWT headers to `JWT::encode()`. See
162
+ [#53](https://github.com/firebase/php-jwt/pull/53/files) for details. Thanks to
163
+ [@mcocaro](https://github.com/mcocaro)!
164
+
165
+ #### 2.1.0 / 2015-05-20
166
+ - Add support for adding a leeway to `JWT:decode()` that accounts for clock skew
167
+ between signing and verifying entities. Thanks to [@lcabral](https://github.com/lcabral)!
168
+ - Add support for passing an object implementing the `ArrayAccess` interface for
169
+ `$keys` argument in `JWT::decode()`. Thanks to [@aztech-dev](https://github.com/aztech-dev)!
170
+
171
+ #### 2.0.0 / 2015-04-01
172
+ - **Note**: It is strongly recommended that you update to > v2.0.0 to address
173
+ known security vulnerabilities in prior versions when both symmetric and
174
+ asymmetric keys are used together.
175
+ - Update signature for `JWT::decode(...)` to require an array of supported
176
+ algorithms to use when verifying token signatures.
177
+
178
+
179
+ Tests
180
+ -----
181
+ Run the tests using phpunit:
182
+
183
+ ```bash
184
+ $ pear install PHPUnit
185
+ $ phpunit --configuration phpunit.xml.dist
186
+ PHPUnit 3.7.10 by Sebastian Bergmann.
187
+ .....
188
+ Time: 0 seconds, Memory: 2.50Mb
189
+ OK (5 tests, 5 assertions)
190
+ ```
191
+
192
+ New Lines in private keys
193
+ -----
194
+
195
+ If your private key contains `\n` characters, be sure to wrap it in double quotes `""`
196
+ and not single quotes `''` in order to properly interpret the escaped characters.
197
+
198
+ License
199
+ -------
200
+ [3-Clause BSD](http://opensource.org/licenses/BSD-3-Clause).
vendor/firebase/php-jwt/composer.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "firebase/php-jwt",
3
+ "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
4
+ "homepage": "https://github.com/firebase/php-jwt",
5
+ "authors": [
6
+ {
7
+ "name": "Neuman Vong",
8
+ "email": "neuman+pear@twilio.com",
9
+ "role": "Developer"
10
+ },
11
+ {
12
+ "name": "Anant Narayanan",
13
+ "email": "anant@php.net",
14
+ "role": "Developer"
15
+ }
16
+ ],
17
+ "license": "BSD-3-Clause",
18
+ "require": {
19
+ "php": ">=5.3.0"
20
+ },
21
+ "autoload": {
22
+ "psr-4": {
23
+ "Firebase\\JWT\\": "src"
24
+ }
25
+ },
26
+ "require-dev": {
27
+ "phpunit/phpunit": " 4.8.35"
28
+ }
29
+ }
vendor/firebase/php-jwt/src/BeforeValidException.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Firebase\JWT;
3
+
4
+ class BeforeValidException extends \UnexpectedValueException
5
+ {
6
+
7
+ }
vendor/firebase/php-jwt/src/ExpiredException.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Firebase\JWT;
3
+
4
+ class ExpiredException extends \UnexpectedValueException
5
+ {
6
+
7
+ }
vendor/firebase/php-jwt/src/JWT.php ADDED
@@ -0,0 +1,379 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Firebase\JWT;
4
+ use \DomainException;
5
+ use \InvalidArgumentException;
6
+ use \UnexpectedValueException;
7
+ use \DateTime;
8
+
9
+ /**
10
+ * JSON Web Token implementation, based on this spec:
11
+ * https://tools.ietf.org/html/rfc7519
12
+ *
13
+ * PHP version 5
14
+ *
15
+ * @category Authentication
16
+ * @package Authentication_JWT
17
+ * @author Neuman Vong <neuman@twilio.com>
18
+ * @author Anant Narayanan <anant@php.net>
19
+ * @license http://opensource.org/licenses/BSD-3-Clause 3-clause BSD
20
+ * @link https://github.com/firebase/php-jwt
21
+ */
22
+ class JWT
23
+ {
24
+
25
+ /**
26
+ * When checking nbf, iat or expiration times,
27
+ * we want to provide some extra leeway time to
28
+ * account for clock skew.
29
+ */
30
+ public static $leeway = 0;
31
+
32
+ /**
33
+ * Allow the current timestamp to be specified.
34
+ * Useful for fixing a value within unit testing.
35
+ *
36
+ * Will default to PHP time() value if null.
37
+ */
38
+ public static $timestamp = null;
39
+
40
+ public static $supported_algs = array(
41
+ 'HS256' => array('hash_hmac', 'SHA256'),
42
+ 'HS512' => array('hash_hmac', 'SHA512'),
43
+ 'HS384' => array('hash_hmac', 'SHA384'),
44
+ 'RS256' => array('openssl', 'SHA256'),
45
+ 'RS384' => array('openssl', 'SHA384'),
46
+ 'RS512' => array('openssl', 'SHA512'),
47
+ );
48
+
49
+ /**
50
+ * Decodes a JWT string into a PHP object.
51
+ *
52
+ * @param string $jwt The JWT
53
+ * @param string|array $key The key, or map of keys.
54
+ * If the algorithm used is asymmetric, this is the public key
55
+ * @param array $allowed_algs List of supported verification algorithms
56
+ * Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
57
+ *
58
+ * @return object The JWT's payload as a PHP object
59
+ *
60
+ * @throws UnexpectedValueException Provided JWT was invalid
61
+ * @throws SignatureInvalidException Provided JWT was invalid because the signature verification failed
62
+ * @throws BeforeValidException Provided JWT is trying to be used before it's eligible as defined by 'nbf'
63
+ * @throws BeforeValidException Provided JWT is trying to be used before it's been created as defined by 'iat'
64
+ * @throws ExpiredException Provided JWT has since expired, as defined by the 'exp' claim
65
+ *
66
+ * @uses jsonDecode
67
+ * @uses urlsafeB64Decode
68
+ */
69
+ public static function decode($jwt, $key, array $allowed_algs = array())
70
+ {
71
+ $timestamp = is_null(static::$timestamp) ? time() : static::$timestamp;
72
+
73
+ if (empty($key)) {
74
+ throw new InvalidArgumentException('Key may not be empty');
75
+ }
76
+ $tks = explode('.', $jwt);
77
+ if (count($tks) != 3) {
78
+ throw new UnexpectedValueException('Wrong number of segments');
79
+ }
80
+ list($headb64, $bodyb64, $cryptob64) = $tks;
81
+ if (null === ($header = static::jsonDecode(static::urlsafeB64Decode($headb64)))) {
82
+ throw new UnexpectedValueException('Invalid header encoding');
83
+ }
84
+ if (null === $payload = static::jsonDecode(static::urlsafeB64Decode($bodyb64))) {
85
+ throw new UnexpectedValueException('Invalid claims encoding');
86
+ }
87
+ if (false === ($sig = static::urlsafeB64Decode($cryptob64))) {
88
+ throw new UnexpectedValueException('Invalid signature encoding');
89
+ }
90
+ if (empty($header->alg)) {
91
+ throw new UnexpectedValueException('Empty algorithm');
92
+ }
93
+ if (empty(static::$supported_algs[$header->alg])) {
94
+ throw new UnexpectedValueException('Algorithm not supported');
95
+ }
96
+ if (!in_array($header->alg, $allowed_algs)) {
97
+ throw new UnexpectedValueException('Algorithm not allowed');
98
+ }
99
+ if (is_array($key) || $key instanceof \ArrayAccess) {
100
+ if (isset($header->kid)) {
101
+ if (!isset($key[$header->kid])) {
102
+ throw new UnexpectedValueException('"kid" invalid, unable to lookup correct key');
103
+ }
104
+ $key = $key[$header->kid];
105
+ } else {
106
+ throw new UnexpectedValueException('"kid" empty, unable to lookup correct key');
107
+ }
108
+ }
109
+
110
+ // Check the signature
111
+ if (!static::verify("$headb64.$bodyb64", $sig, $key, $header->alg)) {
112
+ throw new SignatureInvalidException('Signature verification failed');
113
+ }
114
+
115
+ // Check if the nbf if it is defined. This is the time that the
116
+ // token can actually be used. If it's not yet that time, abort.
117
+ if (isset($payload->nbf) && $payload->nbf > ($timestamp + static::$leeway)) {
118
+ throw new BeforeValidException(
119
+ 'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->nbf)
120
+ );
121
+ }
122
+
123
+ // Check that this token has been created before 'now'. This prevents
124
+ // using tokens that have been created for later use (and haven't
125
+ // correctly used the nbf claim).
126
+ if (isset($payload->iat) && $payload->iat > ($timestamp + static::$leeway)) {
127
+ throw new BeforeValidException(
128
+ 'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->iat)
129
+ );
130
+ }
131
+
132
+ // Check if this token has expired.
133
+ if (isset($payload->exp) && ($timestamp - static::$leeway) >= $payload->exp) {
134
+ throw new ExpiredException('Expired token');
135
+ }
136
+
137
+ return $payload;
138
+ }
139
+
140
+ /**
141
+ * Converts and signs a PHP object or array into a JWT string.
142
+ *
143
+ * @param object|array $payload PHP object or array
144
+ * @param string $key The secret key.
145
+ * If the algorithm used is asymmetric, this is the private key
146
+ * @param string $alg The signing algorithm.
147
+ * Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
148
+ * @param mixed $keyId
149
+ * @param array $head An array with header elements to attach
150
+ *
151
+ * @return string A signed JWT
152
+ *
153
+ * @uses jsonEncode
154
+ * @uses urlsafeB64Encode
155
+ */
156
+ public static function encode($payload, $key, $alg = 'HS256', $keyId = null, $head = null)
157
+ {
158
+ $header = array('typ' => 'JWT', 'alg' => $alg);
159
+ if ($keyId !== null) {
160
+ $header['kid'] = $keyId;
161
+ }
162
+ if ( isset($head) && is_array($head) ) {
163
+ $header = array_merge($head, $header);
164
+ }
165
+ $segments = array();
166
+ $segments[] = static::urlsafeB64Encode(static::jsonEncode($header));
167
+ $segments[] = static::urlsafeB64Encode(static::jsonEncode($payload));
168
+ $signing_input = implode('.', $segments);
169
+
170
+ $signature = static::sign($signing_input, $key, $alg);
171
+ $segments[] = static::urlsafeB64Encode($signature);
172
+
173
+ return implode('.', $segments);
174
+ }
175
+
176
+ /**
177
+ * Sign a string with a given key and algorithm.
178
+ *
179
+ * @param string $msg The message to sign
180
+ * @param string|resource $key The secret key
181
+ * @param string $alg The signing algorithm.
182
+ * Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
183
+ *
184
+ * @return string An encrypted message
185
+ *
186
+ * @throws DomainException Unsupported algorithm was specified
187
+ */
188
+ public static function sign($msg, $key, $alg = 'HS256')
189
+ {
190
+ if (empty(static::$supported_algs[$alg])) {
191
+ throw new DomainException('Algorithm not supported');
192
+ }
193
+ list($function, $algorithm) = static::$supported_algs[$alg];
194
+ switch($function) {
195
+ case 'hash_hmac':
196
+ return hash_hmac($algorithm, $msg, $key, true);
197
+ case 'openssl':
198
+ $signature = '';
199
+ $success = openssl_sign($msg, $signature, $key, $algorithm);
200
+ if (!$success) {
201
+ throw new DomainException("OpenSSL unable to sign data");
202
+ } else {
203
+ return $signature;
204
+ }
205
+ }
206
+ }
207
+
208
+ /**
209
+ * Verify a signature with the message, key and method. Not all methods
210
+ * are symmetric, so we must have a separate verify and sign method.
211
+ *
212
+ * @param string $msg The original message (header and body)
213
+ * @param string $signature The original signature
214
+ * @param string|resource $key For HS*, a string key works. for RS*, must be a resource of an openssl public key
215
+ * @param string $alg The algorithm
216
+ *
217
+ * @return bool
218
+ *
219
+ * @throws DomainException Invalid Algorithm or OpenSSL failure
220
+ */
221
+ private static function verify($msg, $signature, $key, $alg)
222
+ {
223
+ if (empty(static::$supported_algs[$alg])) {
224
+ throw new DomainException('Algorithm not supported');
225
+ }
226
+
227
+ list($function, $algorithm) = static::$supported_algs[$alg];
228
+ switch($function) {
229
+ case 'openssl':
230
+ $success = openssl_verify($msg, $signature, $key, $algorithm);
231
+ if ($success === 1) {
232
+ return true;
233
+ } elseif ($success === 0) {
234
+ return false;
235
+ }
236
+ // returns 1 on success, 0 on failure, -1 on error.
237
+ throw new DomainException(
238
+ 'OpenSSL error: ' . openssl_error_string()
239
+ );
240
+ case 'hash_hmac':
241
+ default:
242
+ $hash = hash_hmac($algorithm, $msg, $key, true);
243
+ if (function_exists('hash_equals')) {
244
+ return hash_equals($signature, $hash);
245
+ }
246
+ $len = min(static::safeStrlen($signature), static::safeStrlen($hash));
247
+
248
+ $status = 0;
249
+ for ($i = 0; $i < $len; $i++) {
250
+ $status |= (ord($signature[$i]) ^ ord($hash[$i]));
251
+ }
252
+ $status |= (static::safeStrlen($signature) ^ static::safeStrlen($hash));
253
+
254
+ return ($status === 0);
255
+ }
256
+ }
257
+
258
+ /**
259
+ * Decode a JSON string into a PHP object.
260
+ *
261
+ * @param string $input JSON string
262
+ *
263
+ * @return object Object representation of JSON string
264
+ *
265
+ * @throws DomainException Provided string was invalid JSON
266
+ */
267
+ public static function jsonDecode($input)
268
+ {
269
+ if (version_compare(PHP_VERSION, '5.4.0', '>=') && !(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) {
270
+ /** In PHP >=5.4.0, json_decode() accepts an options parameter, that allows you
271
+ * to specify that large ints (like Steam Transaction IDs) should be treated as
272
+ * strings, rather than the PHP default behaviour of converting them to floats.
273
+ */
274
+ $obj = json_decode($input, false, 512, JSON_BIGINT_AS_STRING);
275
+ } else {
276
+ /** Not all servers will support that, however, so for older versions we must
277
+ * manually detect large ints in the JSON string and quote them (thus converting
278
+ *them to strings) before decoding, hence the preg_replace() call.
279
+ */
280
+ $max_int_length = strlen((string) PHP_INT_MAX) - 1;
281
+ $json_without_bigints = preg_replace('/:\s*(-?\d{'.$max_int_length.',})/', ': "$1"', $input);
282
+ $obj = json_decode($json_without_bigints);
283
+ }
284
+
285
+ if (function_exists('json_last_error') && $errno = json_last_error()) {
286
+ static::handleJsonError($errno);
287
+ } elseif ($obj === null && $input !== 'null') {
288
+ throw new DomainException('Null result with non-null input');
289
+ }
290
+ return $obj;
291
+ }
292
+
293
+ /**
294
+ * Encode a PHP object into a JSON string.
295
+ *
296
+ * @param object|array $input A PHP object or array
297
+ *
298
+ * @return string JSON representation of the PHP object or array
299
+ *
300
+ * @throws DomainException Provided object could not be encoded to valid JSON
301
+ */
302
+ public static function jsonEncode($input)
303
+ {
304
+ $json = json_encode($input);
305
+ if (function_exists('json_last_error') && $errno = json_last_error()) {
306
+ static::handleJsonError($errno);
307
+ } elseif ($json === 'null' && $input !== null) {
308
+ throw new DomainException('Null result with non-null input');
309
+ }
310
+ return $json;
311
+ }
312
+
313
+ /**
314
+ * Decode a string with URL-safe Base64.
315
+ *
316
+ * @param string $input A Base64 encoded string
317
+ *
318
+ * @return string A decoded string
319
+ */
320
+ public static function urlsafeB64Decode($input)
321
+ {
322
+ $remainder = strlen($input) % 4;
323
+ if ($remainder) {
324
+ $padlen = 4 - $remainder;
325
+ $input .= str_repeat('=', $padlen);
326
+ }
327
+ return base64_decode(strtr($input, '-_', '+/'));
328
+ }
329
+
330
+ /**
331
+ * Encode a string with URL-safe Base64.
332
+ *
333
+ * @param string $input The string you want encoded
334
+ *
335
+ * @return string The base64 encode of what you passed in
336
+ */
337
+ public static function urlsafeB64Encode($input)
338
+ {
339
+ return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
340
+ }
341
+
342
+ /**
343
+ * Helper method to create a JSON error.
344
+ *
345
+ * @param int $errno An error number from json_last_error()
346
+ *
347
+ * @return void
348
+ */
349
+ private static function handleJsonError($errno)
350
+ {
351
+ $messages = array(
352
+ JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
353
+ JSON_ERROR_STATE_MISMATCH => 'Invalid or malformed JSON',
354
+ JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
355
+ JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON',
356
+ JSON_ERROR_UTF8 => 'Malformed UTF-8 characters' //PHP >= 5.3.3
357
+ );
358
+ throw new DomainException(
359
+ isset($messages[$errno])
360
+ ? $messages[$errno]
361
+ : 'Unknown JSON error: ' . $errno
362
+ );
363
+ }
364
+
365
+ /**
366
+ * Get the number of bytes in cryptographic strings.
367
+ *
368
+ * @param string
369
+ *
370
+ * @return int
371
+ */
372
+ private static function safeStrlen($str)
373
+ {
374
+ if (function_exists('mb_strlen')) {
375
+ return mb_strlen($str, '8bit');
376
+ }
377
+ return strlen($str);
378
+ }
379
+ }
vendor/firebase/php-jwt/src/SignatureInvalidException.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Firebase\JWT;
3
+
4
+ class SignatureInvalidException extends \UnexpectedValueException
5
+ {
6
+
7
+ }
vendor/google/apiclient-services/LICENSE ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
203
+
vendor/google/apiclient-services/README.md ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Google PHP API Client Services
2
+ ==============================
3
+
4
+ ## Requirements
5
+
6
+ [Google API PHP Client](https://github.com/googleapis/google-api-php-client/releases)
7
+
8
+ ## Usage in v2 of Google API PHP Client
9
+
10
+ This library is automatically updated daily with new API changes, and tagged weekly.
11
+ It is installed as part of the
12
+ [Google API PHP Client](https://github.com/googleapis/google-api-php-client/releases)
13
+ library via Composer, which will pull down the most recent tag.
14
+
15
+ ## Usage in v1
16
+
17
+ If you are currently using the [`v1-master`](https://github.com/googleapis/google-api-php-client/tree/v1-master)
18
+ branch of the client library, but want to use the latest API services, you can
19
+ do so by requiring this library directly into your project via the same composer command:
20
+
21
+ ```sh
22
+ composer require google/apiclient-services:dev-master
23
+ ```
vendor/google/apiclient-services/composer.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "google/apiclient-services",
3
+ "type": "library",
4
+ "description": "Client library for Google APIs",
5
+ "keywords": ["google"],
6
+ "homepage": "http://developers.google.com/api-client-library/php",
7
+ "license": "Apache-2.0",
8
+ "require": {
9
+ "php": ">=5.4"
10
+ },
11
+ "require-dev": {
12
+ "phpunit/phpunit": "~4.8"
13
+ },
14
+ "autoload": {
15
+ "psr-0": {
16
+ "Google_Service_": "src"
17
+ }
18
+ }
19
+ }
vendor/google/apiclient-services/src/Google/Service/Drive.php ADDED
@@ -0,0 +1,950 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ /**
19
+ * Service definition for Drive (v3).
20
+ *
21
+ * <p>
22
+ * Manages files in Drive including uploading, downloading, searching, detecting
23
+ * changes, and updating sharing permissions.</p>
24
+ *
25
+ * <p>
26
+ * For more information about this service, see the API
27
+ * <a href="https://developers.google.com/drive/" target="_blank">Documentation</a>
28
+ * </p>
29
+ *
30
+ * @author Google, Inc.
31
+ */
32
+ class Google_Service_Drive extends Google_Service
33
+ {
34
+ /** See, edit, create, and delete all of your Google Drive files. */
35
+ const DRIVE =
36
+ "https://www.googleapis.com/auth/drive";
37
+ /** View and manage its own configuration data in your Google Drive. */
38
+ const DRIVE_APPDATA =
39
+ "https://www.googleapis.com/auth/drive.appdata";
40
+ /** View and manage Google Drive files and folders that you have opened or created with this app. */
41
+ const DRIVE_FILE =
42
+ "https://www.googleapis.com/auth/drive.file";
43
+ /** View and manage metadata of files in your Google Drive. */
44
+ const DRIVE_METADATA =
45
+ "https://www.googleapis.com/auth/drive.metadata";
46
+ /** View metadata for files in your Google Drive. */
47
+ const DRIVE_METADATA_READONLY =
48
+ "https://www.googleapis.com/auth/drive.metadata.readonly";
49
+ /** View the photos, videos and albums in your Google Photos. */
50
+ const DRIVE_PHOTOS_READONLY =
51
+ "https://www.googleapis.com/auth/drive.photos.readonly";
52
+ /** See and download all your Google Drive files. */
53
+ const DRIVE_READONLY =
54
+ "https://www.googleapis.com/auth/drive.readonly";
55
+ /** Modify your Google Apps Script scripts' behavior. */
56
+ const DRIVE_SCRIPTS =
57
+ "https://www.googleapis.com/auth/drive.scripts";
58
+
59
+ public $about;
60
+ public $changes;
61
+ public $channels;
62
+ public $comments;
63
+ public $files;
64
+ public $permissions;
65
+ public $replies;
66
+ public $revisions;
67
+ public $teamdrives;
68
+
69
+ /**
70
+ * Constructs the internal representation of the Drive service.
71
+ *
72
+ * @param Google_Client $client
73
+ */
74
+ public function __construct(Google_Client $client)
75
+ {
76
+ parent::__construct($client);
77
+ $this->rootUrl = 'https://www.googleapis.com/';
78
+ $this->servicePath = 'drive/v3/';
79
+ $this->version = 'v3';
80
+ $this->serviceName = 'drive';
81
+
82
+ $this->about = new Google_Service_Drive_Resource_About(
83
+ $this,
84
+ $this->serviceName,
85
+ 'about',
86
+ array(
87
+ 'methods' => array(
88
+ 'get' => array(
89
+ 'path' => 'about',
90
+ 'httpMethod' => 'GET',
91
+ 'parameters' => array(),
92
+ ),
93
+ )
94
+ )
95
+ );
96
+ $this->changes = new Google_Service_Drive_Resource_Changes(
97
+ $this,
98
+ $this->serviceName,
99
+ 'changes',
100
+ array(
101
+ 'methods' => array(
102
+ 'getStartPageToken' => array(
103
+ 'path' => 'changes/startPageToken',
104
+ 'httpMethod' => 'GET',
105
+ 'parameters' => array(
106
+ 'supportsTeamDrives' => array(
107
+ 'location' => 'query',
108
+ 'type' => 'boolean',
109
+ ),
110
+ 'teamDriveId' => array(
111
+ 'location' => 'query',
112
+ 'type' => 'string',
113
+ ),
114
+ ),
115
+ ),'list' => array(
116
+ 'path' => 'changes',
117
+ 'httpMethod' => 'GET',
118
+ 'parameters' => array(
119
+ 'pageToken' => array(
120
+ 'location' => 'query',
121
+ 'type' => 'string',
122
+ 'required' => true,
123
+ ),
124
+ 'includeCorpusRemovals' => array(
125
+ 'location' => 'query',
126
+ 'type' => 'boolean',
127
+ ),
128
+ 'includeRemoved' => array(
129
+ 'location' => 'query',
130
+ 'type' => 'boolean',
131
+ ),
132
+ 'includeTeamDriveItems' => array(
133
+ 'location' => 'query',
134
+ 'type' => 'boolean',
135
+ ),
136
+ 'pageSize' => array(
137
+ 'location' => 'query',
138
+ 'type' => 'integer',
139
+ ),
140
+ 'restrictToMyDrive' => array(
141
+ 'location' => 'query',
142
+ 'type' => 'boolean',
143
+ ),
144
+ 'spaces' => array(
145
+ 'location' => 'query',
146
+ 'type' => 'string',
147
+ ),
148
+ 'supportsTeamDrives' => array(
149
+ 'location' => 'query',
150
+ 'type' => 'boolean',
151
+ ),
152
+ 'teamDriveId' => array(
153
+ 'location' => 'query',
154
+ 'type' => 'string',
155
+ ),
156
+ ),
157
+ ),'watch' => array(
158
+ 'path' => 'changes/watch',
159
+ 'httpMethod' => 'POST',
160
+ 'parameters' => array(
161
+ 'pageToken' => array(
162
+ 'location' => 'query',
163
+ 'type' => 'string',
164
+ 'required' => true,
165
+ ),
166
+ 'includeCorpusRemovals' => array(
167
+ 'location' => 'query',
168
+ 'type' => 'boolean',
169
+ ),
170
+ 'includeRemoved' => array(
171
+ 'location' => 'query',
172
+ 'type' => 'boolean',
173
+ ),
174
+ 'includeTeamDriveItems' => array(
175
+ 'location' => 'query',
176
+ 'type' => 'boolean',
177
+ ),
178
+ 'pageSize' => array(
179
+ 'location' => 'query',
180
+ 'type' => 'integer',
181
+ ),
182
+ 'restrictToMyDrive' => array(
183
+ 'location' => 'query',
184
+ 'type' => 'boolean',
185
+ ),
186
+ 'spaces' => array(
187
+ 'location' => 'query',
188
+ 'type' => 'string',
189
+ ),
190
+ 'supportsTeamDrives' => array(
191
+ 'location' => 'query',
192
+ 'type' => 'boolean',
193
+ ),
194
+ 'teamDriveId' => array(
195
+ 'location' => 'query',
196
+ 'type' => 'string',
197
+ ),
198
+ ),
199
+ ),
200
+ )
201
+ )
202
+ );
203
+ $this->channels = new Google_Service_Drive_Resource_Channels(
204
+ $this,
205
+ $this->serviceName,
206
+ 'channels',
207
+ array(
208
+ 'methods' => array(
209
+ 'stop' => array(
210
+ 'path' => 'channels/stop',
211
+ 'httpMethod' => 'POST',
212
+ 'parameters' => array(),
213
+ ),
214
+ )
215
+ )
216
+ );
217
+ $this->comments = new Google_Service_Drive_Resource_Comments(
218
+ $this,
219
+ $this->serviceName,
220
+ 'comments',
221
+ array(
222
+ 'methods' => array(
223
+ 'create' => array(
224
+ 'path' => 'files/{fileId}/comments',
225
+ 'httpMethod' => 'POST',
226
+ 'parameters' => array(
227
+ 'fileId' => array(
228
+ 'location' => 'path',
229
+ 'type' => 'string',
230
+ 'required' => true,
231
+ ),
232
+ ),
233
+ ),'delete' => array(
234
+ 'path' => 'files/{fileId}/comments/{commentId}',
235
+ 'httpMethod' => 'DELETE',
236
+ 'parameters' => array(
237
+ 'fileId' => array(
238
+ 'location' => 'path',
239
+ 'type' => 'string',
240
+ 'required' => true,
241
+ ),
242
+ 'commentId' => array(
243
+ 'location' => 'path',
244
+ 'type' => 'string',
245
+ 'required' => true,
246
+ ),
247
+ ),
248
+ ),'get' => array(
249
+ 'path' => 'files/{fileId}/comments/{commentId}',
250
+ 'httpMethod' => 'GET',
251
+ 'parameters' => array(
252
+ 'fileId' => array(
253
+ 'location' => 'path',
254
+ 'type' => 'string',
255
+ 'required' => true,
256
+ ),
257
+ 'commentId' => array(
258
+ 'location' => 'path',
259
+ 'type' => 'string',
260
+ 'required' => true,
261
+ ),
262
+ 'includeDeleted' => array(
263
+ 'location' => 'query',
264
+ 'type' => 'boolean',
265
+ ),
266
+ ),
267
+ ),'list' => array(
268
+ 'path' => 'files/{fileId}/comments',
269
+ 'httpMethod' => 'GET',
270
+ 'parameters' => array(
271
+ 'fileId' => array(
272
+ 'location' => 'path',
273
+ 'type' => 'string',
274
+ 'required' => true,
275
+ ),
276
+ 'includeDeleted' => array(
277
+ 'location' => 'query',
278
+ 'type' => 'boolean',
279
+ ),
280
+ 'pageSize' => array(
281
+ 'location' => 'query',
282
+ 'type' => 'integer',
283
+ ),
284
+ 'pageToken' => array(
285
+ 'location' => 'query',
286
+ 'type' => 'string',
287
+ ),
288
+ 'startModifiedTime' => array(
289
+ 'location' => 'query',
290
+ 'type' => 'string',
291
+ ),
292
+ ),
293
+ ),'update' => array(
294
+ 'path' => 'files/{fileId}/comments/{commentId}',
295
+ 'httpMethod' => 'PATCH',
296
+ 'parameters' => array(
297
+ 'fileId' => array(
298
+ 'location' => 'path',
299
+ 'type' => 'string',
300
+ 'required' => true,
301
+ ),
302
+ 'commentId' => array(
303
+ 'location' => 'path',
304
+ 'type' => 'string',
305
+ 'required' => true,
306
+ ),
307
+ ),
308
+ ),
309
+ )
310
+ )
311
+ );
312
+ $this->files = new Google_Service_Drive_Resource_Files(
313
+ $this,
314
+ $this->serviceName,
315
+ 'files',
316
+ array(
317
+ 'methods' => array(
318
+ 'copy' => array(
319
+ 'path' => 'files/{fileId}/copy',
320
+ 'httpMethod' => 'POST',
321
+ 'parameters' => array(
322
+ 'fileId' => array(
323
+ 'location' => 'path',
324
+ 'type' => 'string',
325
+ 'required' => true,
326
+ ),
327
+ 'ignoreDefaultVisibility' => array(
328
+ 'location' => 'query',
329
+ 'type' => 'boolean',
330
+ ),
331
+ 'keepRevisionForever' => array(
332
+ 'location' => 'query',
333
+ 'type' => 'boolean',
334
+ ),
335
+ 'ocrLanguage' => array(
336
+ 'location' => 'query',
337
+ 'type' => 'string',
338
+ ),
339
+ 'supportsTeamDrives' => array(
340
+ 'location' => 'query',
341
+ 'type' => 'boolean',
342
+ ),
343
+ ),
344
+ ),'create' => array(
345
+ 'path' => 'files',
346
+ 'httpMethod' => 'POST',
347
+ 'parameters' => array(
348
+ 'ignoreDefaultVisibility' => array(
349
+ 'location' => 'query',
350
+ 'type' => 'boolean',
351
+ ),
352
+ 'keepRevisionForever' => array(
353
+ 'location' => 'query',
354
+ 'type' => 'boolean',
355
+ ),
356
+ 'ocrLanguage' => array(
357
+ 'location' => 'query',
358
+ 'type' => 'string',
359
+ ),
360
+ 'supportsTeamDrives' => array(
361
+ 'location' => 'query',
362
+ 'type' => 'boolean',
363
+ ),
364
+ 'useContentAsIndexableText' => array(
365
+ 'location' => 'query',
366
+ 'type' => 'boolean',
367
+ ),
368
+ ),
369
+ ),'delete' => array(
370
+ 'path' => 'files/{fileId}',
371
+ 'httpMethod' => 'DELETE',
372
+ 'parameters' => array(
373
+ 'fileId' => array(
374
+ 'location' => 'path',
375
+ 'type' => 'string',
376
+ 'required' => true,
377
+ ),
378
+ 'supportsTeamDrives' => array(
379
+ 'location' => 'query',
380
+ 'type' => 'boolean',
381
+ ),
382
+ ),
383
+ ),'emptyTrash' => array(
384
+ 'path' => 'files/trash',
385
+ 'httpMethod' => 'DELETE',
386
+ 'parameters' => array(),
387
+ ),'export' => array(
388
+ 'path' => 'files/{fileId}/export',
389
+ 'httpMethod' => 'GET',
390
+ 'parameters' => array(
391
+ 'fileId' => array(
392
+ 'location' => 'path',
393
+ 'type' => 'string',
394
+ 'required' => true,
395
+ ),
396
+ 'mimeType' => array(
397
+ 'location' => 'query',
398
+ 'type' => 'string',
399
+ 'required' => true,
400
+ ),
401
+ ),
402
+ ),'generateIds' => array(
403
+ 'path' => 'files/generateIds',
404
+ 'httpMethod' => 'GET',
405
+ 'parameters' => array(
406
+ 'count' => array(
407
+ 'location' => 'query',
408
+ 'type' => 'integer',
409
+ ),
410
+ 'space' => array(
411
+ 'location' => 'query',
412
+ 'type' => 'string',
413
+ ),
414
+ ),
415
+ ),'get' => array(
416
+ 'path' => 'files/{fileId}',
417
+ 'httpMethod' => 'GET',
418
+ 'parameters' => array(
419
+ 'fileId' => array(
420
+ 'location' => 'path',
421
+ 'type' => 'string',
422
+ 'required' => true,
423
+ ),
424
+ 'acknowledgeAbuse' => array(
425
+ 'location' => 'query',
426
+ 'type' => 'boolean',
427
+ ),
428
+ 'supportsTeamDrives' => array(
429
+ 'location' => 'query',
430
+ 'type' => 'boolean',
431
+ ),
432
+ ),
433
+ ),'list' => array(
434
+ 'path' => 'files',
435
+ 'httpMethod' => 'GET',
436
+ 'parameters' => array(
437
+ 'corpora' => array(
438
+ 'location' => 'query',
439
+ 'type' => 'string',
440
+ ),
441
+ 'corpus' => array(
442
+ 'location' => 'query',
443
+ 'type' => 'string',
444
+ ),
445
+ 'includeTeamDriveItems' => array(
446
+ 'location' => 'query',
447
+ 'type' => 'boolean',
448
+ ),
449
+ 'orderBy' => array(
450
+ 'location' => 'query',
451
+ 'type' => 'string',
452
+ ),
453
+ 'pageSize' => array(
454
+ 'location' => 'query',
455
+ 'type' => 'integer',
456
+ ),
457
+ 'pageToken' => array(
458
+ 'location' => 'query',
459
+ 'type' => 'string',
460
+ ),
461
+ 'q' => array(
462
+ 'location' => 'query',
463
+ 'type' => 'string',
464
+ ),
465
+ 'spaces' => array(
466
+ 'location' => 'query',
467
+ 'type' => 'string',
468
+ ),
469
+ 'supportsTeamDrives' => array(
470
+ 'location' => 'query',
471
+ 'type' => 'boolean',
472
+ ),
473
+ 'teamDriveId' => array(
474
+ 'location' => 'query',
475
+ 'type' => 'string',
476
+ ),
477
+ ),
478
+ ),'update' => array(
479
+ 'path' => 'files/{fileId}',
480
+ 'httpMethod' => 'PATCH',
481
+ 'parameters' => array(
482
+ 'fileId' => array(
483
+ 'location' => 'path',
484
+ 'type' => 'string',
485
+ 'required' => true,
486
+ ),
487
+ 'addParents' => array(
488
+ 'location' => 'query',
489
+ 'type' => 'string',
490
+ ),
491
+ 'keepRevisionForever' => array(
492
+ 'location' => 'query',
493
+ 'type' => 'boolean',
494
+ ),
495
+ 'ocrLanguage' => array(
496
+ 'location' => 'query',
497
+ 'type' => 'string',
498
+ ),
499
+ 'removeParents' => array(
500
+ 'location' => 'query',
501
+ 'type' => 'string',
502
+ ),
503
+ 'supportsTeamDrives' => array(
504
+ 'location' => 'query',
505
+ 'type' => 'boolean',
506
+ ),
507
+ 'useContentAsIndexableText' => array(
508
+ 'location' => 'query',
509
+ 'type' => 'boolean',
510
+ ),
511
+ ),
512
+ ),'watch' => array(
513
+ 'path' => 'files/{fileId}/watch',
514
+ 'httpMethod' => 'POST',
515
+ 'parameters' => array(
516
+ 'fileId' => array(
517
+ 'location' => 'path',
518
+ 'type' => 'string',
519
+ 'required' => true,
520
+ ),
521
+ 'acknowledgeAbuse' => array(
522
+ 'location' => 'query',
523
+ 'type' => 'boolean',
524
+ ),
525
+ 'supportsTeamDrives' => array(
526
+ 'location' => 'query',
527
+ 'type' => 'boolean',
528
+ ),
529
+ ),
530
+ ),
531
+ )
532
+ )
533
+ );
534
+ $this->permissions = new Google_Service_Drive_Resource_Permissions(
535
+ $this,
536
+ $this->serviceName,
537
+ 'permissions',
538
+ array(
539
+ 'methods' => array(
540
+ 'create' => array(
541
+ 'path' => 'files/{fileId}/permissions',
542
+ 'httpMethod' => 'POST',
543
+ 'parameters' => array(
544
+ 'fileId' => array(
545
+ 'location' => 'path',
546
+ 'type' => 'string',
547
+ 'required' => true,
548
+ ),
549
+ 'emailMessage' => array(
550
+ 'location' => 'query',
551
+ 'type' => 'string',
552
+ ),
553
+ 'sendNotificationEmail' => array(
554
+ 'location' => 'query',
555
+ 'type' => 'boolean',
556
+ ),
557
+ 'supportsTeamDrives' => array(
558
+ 'location' => 'query',
559
+ 'type' => 'boolean',
560
+ ),
561
+ 'transferOwnership' => array(
562
+ 'location' => 'query',
563
+ 'type' => 'boolean',
564
+ ),
565
+ 'useDomainAdminAccess' => array(
566
+ 'location' => 'query',
567
+ 'type' => 'boolean',
568
+ ),
569
+ ),
570
+ ),'delete' => array(
571
+ 'path' => 'files/{fileId}/permissions/{permissionId}',
572
+ 'httpMethod' => 'DELETE',
573
+ 'parameters' => array(
574
+ 'fileId' => array(
575
+ 'location' => 'path',
576
+ 'type' => 'string',
577
+ 'required' => true,
578
+ ),
579
+ 'permissionId' => array(
580
+ 'location' => 'path',
581
+ 'type' => 'string',
582
+ 'required' => true,
583
+ ),
584
+ 'supportsTeamDrives' => array(
585
+ 'location' => 'query',
586
+ 'type' => 'boolean',
587
+ ),
588
+ 'useDomainAdminAccess' => array(
589
+ 'location' => 'query',
590
+ 'type' => 'boolean',
591
+ ),
592
+ ),
593
+ ),'get' => array(
594
+ 'path' => 'files/{fileId}/permissions/{permissionId}',
595
+ 'httpMethod' => 'GET',
596
+ 'parameters' => array(
597
+ 'fileId' => array(
598
+ 'location' => 'path',
599
+ 'type' => 'string',
600
+ 'required' => true,
601
+ ),
602
+ 'permissionId' => array(
603
+ 'location' => 'path',
604
+ 'type' => 'string',
605
+ 'required' => true,
606
+ ),
607
+ 'supportsTeamDrives' => array(
608
+ 'location' => 'query',
609
+ 'type' => 'boolean',
610
+ ),
611
+ 'useDomainAdminAccess' => array(
612
+ 'location' => 'query',
613
+ 'type' => 'boolean',
614
+ ),
615
+ ),
616
+ ),'list' => array(
617
+ 'path' => 'files/{fileId}/permissions',
618
+ 'httpMethod' => 'GET',
619
+ 'parameters' => array(
620
+ 'fileId' => array(
621
+ 'location' => 'path',
622
+ 'type' => 'string',
623
+ 'required' => true,
624
+ ),
625
+ 'pageSize' => array(
626
+ 'location' => 'query',
627
+ 'type' => 'integer',
628
+ ),
629
+ 'pageToken' => array(
630
+ 'location' => 'query',
631
+ 'type' => 'string',
632
+ ),
633
+ 'supportsTeamDrives' => array(
634
+ 'location' => 'query',
635
+ 'type' => 'boolean',
636
+ ),
637
+ 'useDomainAdminAccess' => array(
638
+ 'location' => 'query',
639
+ 'type' => 'boolean',
640
+ ),
641
+ ),
642
+ ),'update' => array(
643
+ 'path' => 'files/{fileId}/permissions/{permissionId}',
644
+ 'httpMethod' => 'PATCH',
645
+ 'parameters' => array(
646
+ 'fileId' => array(
647
+ 'location' => 'path',
648
+ 'type' => 'string',
649
+ 'required' => true,
650
+ ),
651
+ 'permissionId' => array(
652
+ 'location' => 'path',
653
+ 'type' => 'string',
654
+ 'required' => true,
655
+ ),
656
+ 'removeExpiration' => array(
657
+ 'location' => 'query',
658
+ 'type' => 'boolean',
659
+ ),
660
+ 'supportsTeamDrives' => array(
661
+ 'location' => 'query',
662
+ 'type' => 'boolean',
663
+ ),
664
+ 'transferOwnership' => array(
665
+ 'location' => 'query',
666
+ 'type' => 'boolean',
667
+ ),
668
+ 'useDomainAdminAccess' => array(
669
+ 'location' => 'query',
670
+ 'type' => 'boolean',
671
+ ),
672
+ ),
673
+ ),
674
+ )
675
+ )
676
+ );
677
+ $this->replies = new Google_Service_Drive_Resource_Replies(
678
+ $this,
679
+ $this->serviceName,
680
+ 'replies',
681
+ array(
682
+ 'methods' => array(
683
+ 'create' => array(
684
+ 'path' => 'files/{fileId}/comments/{commentId}/replies',
685
+ 'httpMethod' => 'POST',
686
+ 'parameters' => array(
687
+ 'fileId' => array(
688
+ 'location' => 'path',
689
+ 'type' => 'string',
690
+ 'required' => true,
691
+ ),
692
+ 'commentId' => array(
693
+ 'location' => 'path',
694
+ 'type' => 'string',
695
+ 'required' => true,
696
+ ),
697
+ ),
698
+ ),'delete' => array(
699
+ 'path' => 'files/{fileId}/comments/{commentId}/replies/{replyId}',
700
+ 'httpMethod' => 'DELETE',
701
+ 'parameters' => array(
702
+ 'fileId' => array(
703
+ 'location' => 'path',
704
+ 'type' => 'string',
705
+ 'required' => true,
706
+ ),
707
+ 'commentId' => array(
708
+ 'location' => 'path',
709
+ 'type' => 'string',
710
+ 'required' => true,
711
+ ),
712
+ 'replyId' => array(
713
+ 'location' => 'path',
714
+ 'type' => 'string',
715
+ 'required' => true,
716
+ ),
717
+ ),
718
+ ),'get' => array(
719
+ 'path' => 'files/{fileId}/comments/{commentId}/replies/{replyId}',
720
+ 'httpMethod' => 'GET',
721
+ 'parameters' => array(
722
+ 'fileId' => array(
723
+ 'location' => 'path',
724
+ 'type' => 'string',
725
+ 'required' => true,
726
+ ),
727
+ 'commentId' => array(
728
+ 'location' => 'path',
729
+ 'type' => 'string',
730
+ 'required' => true,
731
+ ),
732
+ 'replyId' => array(
733
+ 'location' => 'path',
734
+ 'type' => 'string',
735
+ 'required' => true,
736
+ ),
737
+ 'includeDeleted' => array(
738
+ 'location' => 'query',
739
+ 'type' => 'boolean',
740
+ ),
741
+ ),
742
+ ),'list' => array(
743
+ 'path' => 'files/{fileId}/comments/{commentId}/replies',
744
+ 'httpMethod' => 'GET',
745
+ 'parameters' => array(
746
+ 'fileId' => array(
747
+ 'location' => 'path',
748
+ 'type' => 'string',
749
+ 'required' => true,
750
+ ),
751
+ 'commentId' => array(
752
+ 'location' => 'path',
753
+ 'type' => 'string',
754
+ 'required' => true,
755
+ ),
756
+ 'includeDeleted' => array(
757
+ 'location' => 'query',
758
+ 'type' => 'boolean',
759
+ ),
760
+ 'pageSize' => array(
761
+ 'location' => 'query',
762
+ 'type' => 'integer',
763
+ ),
764
+ 'pageToken' => array(
765
+ 'location' => 'query',
766
+ 'type' => 'string',
767
+ ),
768
+ ),
769
+ ),'update' => array(
770
+ 'path' => 'files/{fileId}/comments/{commentId}/replies/{replyId}',
771
+ 'httpMethod' => 'PATCH',
772
+ 'parameters' => array(
773
+ 'fileId' => array(
774
+ 'location' => 'path',
775
+ 'type' => 'string',
776
+ 'required' => true,
777
+ ),
778
+ 'commentId' => array(
779
+ 'location' => 'path',
780
+ 'type' => 'string',
781
+ 'required' => true,
782
+ ),
783
+ 'replyId' => array(
784
+ 'location' => 'path',
785
+ 'type' => 'string',
786
+ 'required' => true,
787
+ ),
788
+ ),
789
+ ),
790
+ )
791
+ )
792
+ );
793
+ $this->revisions = new Google_Service_Drive_Resource_Revisions(
794
+ $this,
795
+ $this->serviceName,
796
+ 'revisions',
797
+ array(
798
+ 'methods' => array(
799
+ 'delete' => array(
800
+ 'path' => 'files/{fileId}/revisions/{revisionId}',
801
+ 'httpMethod' => 'DELETE',
802
+ 'parameters' => array(
803
+ 'fileId' => array(
804
+ 'location' => 'path',
805
+ 'type' => 'string',
806
+ 'required' => true,
807
+ ),
808
+ 'revisionId' => array(
809
+ 'location' => 'path',
810
+ 'type' => 'string',
811
+ 'required' => true,
812
+ ),
813
+ ),
814
+ ),'get' => array(
815
+ 'path' => 'files/{fileId}/revisions/{revisionId}',
816
+ 'httpMethod' => 'GET',
817
+ 'parameters' => array(
818
+ 'fileId' => array(
819
+ 'location' => 'path',
820
+ 'type' => 'string',
821
+ 'required' => true,
822
+ ),
823
+ 'revisionId' => array(
824
+ 'location' => 'path',
825
+ 'type' => 'string',
826
+ 'required' => true,
827
+ ),
828
+ 'acknowledgeAbuse' => array(
829
+ 'location' => 'query',
830
+ 'type' => 'boolean',
831
+ ),
832
+ ),
833
+ ),'list' => array(
834
+ 'path' => 'files/{fileId}/revisions',
835
+ 'httpMethod' => 'GET',
836
+ 'parameters' => array(
837
+ 'fileId' => array(
838
+ 'location' => 'path',
839
+ 'type' => 'string',
840
+ 'required' => true,
841
+ ),
842
+ 'pageSize' => array(
843
+ 'location' => 'query',
844
+ 'type' => 'integer',
845
+ ),
846
+ 'pageToken' => array(
847
+ 'location' => 'query',
848
+ 'type' => 'string',
849
+ ),
850
+ ),
851
+ ),'update' => array(
852
+ 'path' => 'files/{fileId}/revisions/{revisionId}',
853
+ 'httpMethod' => 'PATCH',
854
+ 'parameters' => array(
855
+ 'fileId' => array(
856
+ 'location' => 'path',
857
+ 'type' => 'string',
858
+ 'required' => true,
859
+ ),
860
+ 'revisionId' => array(
861
+ 'location' => 'path',
862
+ 'type' => 'string',
863
+ 'required' => true,
864
+ ),
865
+ ),
866
+ ),
867
+ )
868
+ )
869
+ );
870
+ $this->teamdrives = new Google_Service_Drive_Resource_Teamdrives(
871
+ $this,
872
+ $this->serviceName,
873
+ 'teamdrives',
874
+ array(
875
+ 'methods' => array(
876
+ 'create' => array(
877
+ 'path' => 'teamdrives',
878
+ 'httpMethod' => 'POST',
879
+ 'parameters' => array(
880
+ 'requestId' => array(
881
+ 'location' => 'query',
882
+ 'type' => 'string',
883
+ 'required' => true,
884
+ ),
885
+ ),
886
+ ),'delete' => array(
887
+ 'path' => 'teamdrives/{teamDriveId}',
888
+ 'httpMethod' => 'DELETE',
889
+ 'parameters' => array(
890
+ 'teamDriveId' => array(
891
+ 'location' => 'path',
892
+ 'type' => 'string',
893
+ 'required' => true,
894
+ ),
895
+ ),
896
+ ),'get' => array(
897
+ 'path' => 'teamdrives/{teamDriveId}',
898
+ 'httpMethod' => 'GET',
899
+ 'parameters' => array(
900
+ 'teamDriveId' => array(
901
+ 'location' => 'path',
902
+ 'type' => 'string',
903
+ 'required' => true,
904
+ ),
905
+ 'useDomainAdminAccess' => array(
906
+ 'location' => 'query',
907
+ 'type' => 'boolean',
908
+ ),
909
+ ),
910
+ ),'list' => array(
911
+ 'path' => 'teamdrives',
912
+ 'httpMethod' => 'GET',
913
+ 'parameters' => array(
914
+ 'pageSize' => array(
915
+ 'location' => 'query',
916
+ 'type' => 'integer',
917
+ ),
918
+ 'pageToken' => array(
919
+ 'location' => 'query',
920
+ 'type' => 'string',
921
+ ),
922
+ 'q' => array(
923
+ 'location' => 'query',
924
+ 'type' => 'string',
925
+ ),
926
+ 'useDomainAdminAccess' => array(
927
+ 'location' => 'query',
928
+ 'type' => 'boolean',
929
+ ),
930
+ ),
931
+ ),'update' => array(
932
+ 'path' => 'teamdrives/{teamDriveId}',
933
+ 'httpMethod' => 'PATCH',
934
+ 'parameters' => array(
935
+ 'teamDriveId' => array(
936
+ 'location' => 'path',
937
+ 'type' => 'string',
938
+ 'required' => true,
939
+ ),
940
+ 'useDomainAdminAccess' => array(
941
+ 'location' => 'query',
942
+ 'type' => 'boolean',
943
+ ),
944
+ ),
945
+ ),
946
+ )
947
+ )
948
+ );
949
+ }
950
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/About.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_About extends Google_Collection
19
+ {
20
+ protected $collection_key = 'teamDriveThemes';
21
+ public $appInstalled;
22
+ public $canCreateTeamDrives;
23
+ public $exportFormats;
24
+ public $folderColorPalette;
25
+ public $importFormats;
26
+ public $kind;
27
+ public $maxImportSizes;
28
+ public $maxUploadSize;
29
+ protected $storageQuotaType = 'Google_Service_Drive_AboutStorageQuota';
30
+ protected $storageQuotaDataType = '';
31
+ protected $teamDriveThemesType = 'Google_Service_Drive_AboutTeamDriveThemes';
32
+ protected $teamDriveThemesDataType = 'array';
33
+ protected $userType = 'Google_Service_Drive_User';
34
+ protected $userDataType = '';
35
+
36
+ public function setAppInstalled($appInstalled)
37
+ {
38
+ $this->appInstalled = $appInstalled;
39
+ }
40
+ public function getAppInstalled()
41
+ {
42
+ return $this->appInstalled;
43
+ }
44
+ public function setCanCreateTeamDrives($canCreateTeamDrives)
45
+ {
46
+ $this->canCreateTeamDrives = $canCreateTeamDrives;
47
+ }
48
+ public function getCanCreateTeamDrives()
49
+ {
50
+ return $this->canCreateTeamDrives;
51
+ }
52
+ public function setExportFormats($exportFormats)
53
+ {
54
+ $this->exportFormats = $exportFormats;
55
+ }
56
+ public function getExportFormats()
57
+ {
58
+ return $this->exportFormats;
59
+ }
60
+ public function setFolderColorPalette($folderColorPalette)
61
+ {
62
+ $this->folderColorPalette = $folderColorPalette;
63
+ }
64
+ public function getFolderColorPalette()
65
+ {
66
+ return $this->folderColorPalette;
67
+ }
68
+ public function setImportFormats($importFormats)
69
+ {
70
+ $this->importFormats = $importFormats;
71
+ }
72
+ public function getImportFormats()
73
+ {
74
+ return $this->importFormats;
75
+ }
76
+ public function setKind($kind)
77
+ {
78
+ $this->kind = $kind;
79
+ }
80
+ public function getKind()
81
+ {
82
+ return $this->kind;
83
+ }
84
+ public function setMaxImportSizes($maxImportSizes)
85
+ {
86
+ $this->maxImportSizes = $maxImportSizes;
87
+ }
88
+ public function getMaxImportSizes()
89
+ {
90
+ return $this->maxImportSizes;
91
+ }
92
+ public function setMaxUploadSize($maxUploadSize)
93
+ {
94
+ $this->maxUploadSize = $maxUploadSize;
95
+ }
96
+ public function getMaxUploadSize()
97
+ {
98
+ return $this->maxUploadSize;
99
+ }
100
+ /**
101
+ * @param Google_Service_Drive_AboutStorageQuota
102
+ */
103
+ public function setStorageQuota(Google_Service_Drive_AboutStorageQuota $storageQuota)
104
+ {
105
+ $this->storageQuota = $storageQuota;
106
+ }
107
+ /**
108
+ * @return Google_Service_Drive_AboutStorageQuota
109
+ */
110
+ public function getStorageQuota()
111
+ {
112
+ return $this->storageQuota;
113
+ }
114
+ /**
115
+ * @param Google_Service_Drive_AboutTeamDriveThemes
116
+ */
117
+ public function setTeamDriveThemes($teamDriveThemes)
118
+ {
119
+ $this->teamDriveThemes = $teamDriveThemes;
120
+ }
121
+ /**
122
+ * @return Google_Service_Drive_AboutTeamDriveThemes
123
+ */
124
+ public function getTeamDriveThemes()
125
+ {
126
+ return $this->teamDriveThemes;
127
+ }
128
+ /**
129
+ * @param Google_Service_Drive_User
130
+ */
131
+ public function setUser(Google_Service_Drive_User $user)
132
+ {
133
+ $this->user = $user;
134
+ }
135
+ /**
136
+ * @return Google_Service_Drive_User
137
+ */
138
+ public function getUser()
139
+ {
140
+ return $this->user;
141
+ }
142
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/AboutStorageQuota.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_AboutStorageQuota extends Google_Model
19
+ {
20
+ public $limit;
21
+ public $usage;
22
+ public $usageInDrive;
23
+ public $usageInDriveTrash;
24
+
25
+ public function setLimit($limit)
26
+ {
27
+ $this->limit = $limit;
28
+ }
29
+ public function getLimit()
30
+ {
31
+ return $this->limit;
32
+ }
33
+ public function setUsage($usage)
34
+ {
35
+ $this->usage = $usage;
36
+ }
37
+ public function getUsage()
38
+ {
39
+ return $this->usage;
40
+ }
41
+ public function setUsageInDrive($usageInDrive)
42
+ {
43
+ $this->usageInDrive = $usageInDrive;
44
+ }
45
+ public function getUsageInDrive()
46
+ {
47
+ return $this->usageInDrive;
48
+ }
49
+ public function setUsageInDriveTrash($usageInDriveTrash)
50
+ {
51
+ $this->usageInDriveTrash = $usageInDriveTrash;
52
+ }
53
+ public function getUsageInDriveTrash()
54
+ {
55
+ return $this->usageInDriveTrash;
56
+ }
57
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/AboutTeamDriveThemes.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_AboutTeamDriveThemes extends Google_Model
19
+ {
20
+ public $backgroundImageLink;
21
+ public $colorRgb;
22
+ public $id;
23
+
24
+ public function setBackgroundImageLink($backgroundImageLink)
25
+ {
26
+ $this->backgroundImageLink = $backgroundImageLink;
27
+ }
28
+ public function getBackgroundImageLink()
29
+ {
30
+ return $this->backgroundImageLink;
31
+ }
32
+ public function setColorRgb($colorRgb)
33
+ {
34
+ $this->colorRgb = $colorRgb;
35
+ }
36
+ public function getColorRgb()
37
+ {
38
+ return $this->colorRgb;
39
+ }
40
+ public function setId($id)
41
+ {
42
+ $this->id = $id;
43
+ }
44
+ public function getId()
45
+ {
46
+ return $this->id;
47
+ }
48
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/Change.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_Change extends Google_Model
19
+ {
20
+ protected $fileType = 'Google_Service_Drive_DriveFile';
21
+ protected $fileDataType = '';
22
+ public $fileId;
23
+ public $kind;
24
+ public $removed;
25
+ protected $teamDriveType = 'Google_Service_Drive_TeamDrive';
26
+ protected $teamDriveDataType = '';
27
+ public $teamDriveId;
28
+ public $time;
29
+ public $type;
30
+
31
+ /**
32
+ * @param Google_Service_Drive_DriveFile
33
+ */
34
+ public function setFile(Google_Service_Drive_DriveFile $file)
35
+ {
36
+ $this->file = $file;
37
+ }
38
+ /**
39
+ * @return Google_Service_Drive_DriveFile
40
+ */
41
+ public function getFile()
42
+ {
43
+ return $this->file;
44
+ }
45
+ public function setFileId($fileId)
46
+ {
47
+ $this->fileId = $fileId;
48
+ }
49
+ public function getFileId()
50
+ {
51
+ return $this->fileId;
52
+ }
53
+ public function setKind($kind)
54
+ {
55
+ $this->kind = $kind;
56
+ }
57
+ public function getKind()
58
+ {
59
+ return $this->kind;
60
+ }
61
+ public function setRemoved($removed)
62
+ {
63
+ $this->removed = $removed;
64
+ }
65
+ public function getRemoved()
66
+ {
67
+ return $this->removed;
68
+ }
69
+ /**
70
+ * @param Google_Service_Drive_TeamDrive
71
+ */
72
+ public function setTeamDrive(Google_Service_Drive_TeamDrive $teamDrive)
73
+ {
74
+ $this->teamDrive = $teamDrive;
75
+ }
76
+ /**
77
+ * @return Google_Service_Drive_TeamDrive
78
+ */
79
+ public function getTeamDrive()
80
+ {
81
+ return $this->teamDrive;
82
+ }
83
+ public function setTeamDriveId($teamDriveId)
84
+ {
85
+ $this->teamDriveId = $teamDriveId;
86
+ }
87
+ public function getTeamDriveId()
88
+ {
89
+ return $this->teamDriveId;
90
+ }
91
+ public function setTime($time)
92
+ {
93
+ $this->time = $time;
94
+ }
95
+ public function getTime()
96
+ {
97
+ return $this->time;
98
+ }
99
+ public function setType($type)
100
+ {
101
+ $this->type = $type;
102
+ }
103
+ public function getType()
104
+ {
105
+ return $this->type;
106
+ }
107
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/ChangeList.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_ChangeList extends Google_Collection
19
+ {
20
+ protected $collection_key = 'changes';
21
+ protected $changesType = 'Google_Service_Drive_Change';
22
+ protected $changesDataType = 'array';
23
+ public $kind;
24
+ public $newStartPageToken;
25
+ public $nextPageToken;
26
+
27
+ /**
28
+ * @param Google_Service_Drive_Change
29
+ */
30
+ public function setChanges($changes)
31
+ {
32
+ $this->changes = $changes;
33
+ }
34
+ /**
35
+ * @return Google_Service_Drive_Change
36
+ */
37
+ public function getChanges()
38
+ {
39
+ return $this->changes;
40
+ }
41
+ public function setKind($kind)
42
+ {
43
+ $this->kind = $kind;
44
+ }
45
+ public function getKind()
46
+ {
47
+ return $this->kind;
48
+ }
49
+ public function setNewStartPageToken($newStartPageToken)
50
+ {
51
+ $this->newStartPageToken = $newStartPageToken;
52
+ }
53
+ public function getNewStartPageToken()
54
+ {
55
+ return $this->newStartPageToken;
56
+ }
57
+ public function setNextPageToken($nextPageToken)
58
+ {
59
+ $this->nextPageToken = $nextPageToken;
60
+ }
61
+ public function getNextPageToken()
62
+ {
63
+ return $this->nextPageToken;
64
+ }
65
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/Channel.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_Channel extends Google_Model
19
+ {
20
+ public $address;
21
+ public $expiration;
22
+ public $id;
23
+ public $kind;
24
+ public $params;
25
+ public $payload;
26
+ public $resourceId;
27
+ public $resourceUri;
28
+ public $token;
29
+ public $type;
30
+
31
+ public function setAddress($address)
32
+ {
33
+ $this->address = $address;
34
+ }
35
+ public function getAddress()
36
+ {
37
+ return $this->address;
38
+ }
39
+ public function setExpiration($expiration)
40
+ {
41
+ $this->expiration = $expiration;
42
+ }
43
+ public function getExpiration()
44
+ {
45
+ return $this->expiration;
46
+ }
47
+ public function setId($id)
48
+ {
49
+ $this->id = $id;
50
+ }
51
+ public function getId()
52
+ {
53
+ return $this->id;
54
+ }
55
+ public function setKind($kind)
56
+ {
57
+ $this->kind = $kind;
58
+ }
59
+ public function getKind()
60
+ {
61
+ return $this->kind;
62
+ }
63
+ public function setParams($params)
64
+ {
65
+ $this->params = $params;
66
+ }
67
+ public function getParams()
68
+ {
69
+ return $this->params;
70
+ }
71
+ public function setPayload($payload)
72
+ {
73
+ $this->payload = $payload;
74
+ }
75
+ public function getPayload()
76
+ {
77
+ return $this->payload;
78
+ }
79
+ public function setResourceId($resourceId)
80
+ {
81
+ $this->resourceId = $resourceId;
82
+ }
83
+ public function getResourceId()
84
+ {
85
+ return $this->resourceId;
86
+ }
87
+ public function setResourceUri($resourceUri)
88
+ {
89
+ $this->resourceUri = $resourceUri;
90
+ }
91
+ public function getResourceUri()
92
+ {
93
+ return $this->resourceUri;
94
+ }
95
+ public function setToken($token)
96
+ {
97
+ $this->token = $token;
98
+ }
99
+ public function getToken()
100
+ {
101
+ return $this->token;
102
+ }
103
+ public function setType($type)
104
+ {
105
+ $this->type = $type;
106
+ }
107
+ public function getType()
108
+ {
109
+ return $this->type;
110
+ }
111
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/Comment.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_Comment extends Google_Collection
19
+ {
20
+ protected $collection_key = 'replies';
21
+ public $anchor;
22
+ protected $authorType = 'Google_Service_Drive_User';
23
+ protected $authorDataType = '';
24
+ public $content;
25
+ public $createdTime;
26
+ public $deleted;
27
+ public $htmlContent;
28
+ public $id;
29
+ public $kind;
30
+ public $modifiedTime;
31
+ protected $quotedFileContentType = 'Google_Service_Drive_CommentQuotedFileContent';
32
+ protected $quotedFileContentDataType = '';
33
+ protected $repliesType = 'Google_Service_Drive_Reply';
34
+ protected $repliesDataType = 'array';
35
+ public $resolved;
36
+
37
+ public function setAnchor($anchor)
38
+ {
39
+ $this->anchor = $anchor;
40
+ }
41
+ public function getAnchor()
42
+ {
43
+ return $this->anchor;
44
+ }
45
+ /**
46
+ * @param Google_Service_Drive_User
47
+ */
48
+ public function setAuthor(Google_Service_Drive_User $author)
49
+ {
50
+ $this->author = $author;
51
+ }
52
+ /**
53
+ * @return Google_Service_Drive_User
54
+ */
55
+ public function getAuthor()
56
+ {
57
+ return $this->author;
58
+ }
59
+ public function setContent($content)
60
+ {
61
+ $this->content = $content;
62
+ }
63
+ public function getContent()
64
+ {
65
+ return $this->content;
66
+ }
67
+ public function setCreatedTime($createdTime)
68
+ {
69
+ $this->createdTime = $createdTime;
70
+ }
71
+ public function getCreatedTime()
72
+ {
73
+ return $this->createdTime;
74
+ }
75
+ public function setDeleted($deleted)
76
+ {
77
+ $this->deleted = $deleted;
78
+ }
79
+ public function getDeleted()
80
+ {
81
+ return $this->deleted;
82
+ }
83
+ public function setHtmlContent($htmlContent)
84
+ {
85
+ $this->htmlContent = $htmlContent;
86
+ }
87
+ public function getHtmlContent()
88
+ {
89
+ return $this->htmlContent;
90
+ }
91
+ public function setId($id)
92
+ {
93
+ $this->id = $id;
94
+ }
95
+ public function getId()
96
+ {
97
+ return $this->id;
98
+ }
99
+ public function setKind($kind)
100
+ {
101
+ $this->kind = $kind;
102
+ }
103
+ public function getKind()
104
+ {
105
+ return $this->kind;
106
+ }
107
+ public function setModifiedTime($modifiedTime)
108
+ {
109
+ $this->modifiedTime = $modifiedTime;
110
+ }
111
+ public function getModifiedTime()
112
+ {
113
+ return $this->modifiedTime;
114
+ }
115
+ /**
116
+ * @param Google_Service_Drive_CommentQuotedFileContent
117
+ */
118
+ public function setQuotedFileContent(Google_Service_Drive_CommentQuotedFileContent $quotedFileContent)
119
+ {
120
+ $this->quotedFileContent = $quotedFileContent;
121
+ }
122
+ /**
123
+ * @return Google_Service_Drive_CommentQuotedFileContent
124
+ */
125
+ public function getQuotedFileContent()
126
+ {
127
+ return $this->quotedFileContent;
128
+ }
129
+ /**
130
+ * @param Google_Service_Drive_Reply
131
+ */
132
+ public function setReplies($replies)
133
+ {
134
+ $this->replies = $replies;
135
+ }
136
+ /**
137
+ * @return Google_Service_Drive_Reply
138
+ */
139
+ public function getReplies()
140
+ {
141
+ return $this->replies;
142
+ }
143
+ public function setResolved($resolved)
144
+ {
145
+ $this->resolved = $resolved;
146
+ }
147
+ public function getResolved()
148
+ {
149
+ return $this->resolved;
150
+ }
151
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/CommentList.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_CommentList extends Google_Collection
19
+ {
20
+ protected $collection_key = 'comments';
21
+ protected $commentsType = 'Google_Service_Drive_Comment';
22
+ protected $commentsDataType = 'array';
23
+ public $kind;
24
+ public $nextPageToken;
25
+
26
+ /**
27
+ * @param Google_Service_Drive_Comment
28
+ */
29
+ public function setComments($comments)
30
+ {
31
+ $this->comments = $comments;
32
+ }
33
+ /**
34
+ * @return Google_Service_Drive_Comment
35
+ */
36
+ public function getComments()
37
+ {
38
+ return $this->comments;
39
+ }
40
+ public function setKind($kind)
41
+ {
42
+ $this->kind = $kind;
43
+ }
44
+ public function getKind()
45
+ {
46
+ return $this->kind;
47
+ }
48
+ public function setNextPageToken($nextPageToken)
49
+ {
50
+ $this->nextPageToken = $nextPageToken;
51
+ }
52
+ public function getNextPageToken()
53
+ {
54
+ return $this->nextPageToken;
55
+ }
56
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/CommentQuotedFileContent.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_CommentQuotedFileContent extends Google_Model
19
+ {
20
+ public $mimeType;
21
+ public $value;
22
+
23
+ public function setMimeType($mimeType)
24
+ {
25
+ $this->mimeType = $mimeType;
26
+ }
27
+ public function getMimeType()
28
+ {
29
+ return $this->mimeType;
30
+ }
31
+ public function setValue($value)
32
+ {
33
+ $this->value = $value;
34
+ }
35
+ public function getValue()
36
+ {
37
+ return $this->value;
38
+ }
39
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/DriveFile.php ADDED
@@ -0,0 +1,571 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_DriveFile extends Google_Collection
19
+ {
20
+ protected $collection_key = 'spaces';
21
+ public $appProperties;
22
+ protected $capabilitiesType = 'Google_Service_Drive_DriveFileCapabilities';
23
+ protected $capabilitiesDataType = '';
24
+ protected $contentHintsType = 'Google_Service_Drive_DriveFileContentHints';
25
+ protected $contentHintsDataType = '';
26
+ public $copyRequiresWriterPermission;
27
+ public $createdTime;
28
+ public $description;
29
+ public $explicitlyTrashed;
30
+ public $exportLinks;
31
+ public $fileExtension;
32
+ public $folderColorRgb;
33
+ public $fullFileExtension;
34
+ public $hasAugmentedPermissions;
35
+ public $hasThumbnail;
36
+ public $headRevisionId;
37
+ public $iconLink;
38
+ public $id;
39
+ protected $imageMediaMetadataType = 'Google_Service_Drive_DriveFileImageMediaMetadata';
40
+ protected $imageMediaMetadataDataType = '';
41
+ public $isAppAuthorized;
42
+ public $kind;
43
+ protected $lastModifyingUserType = 'Google_Service_Drive_User';
44
+ protected $lastModifyingUserDataType = '';
45
+ public $md5Checksum;
46
+ public $mimeType;
47
+ public $modifiedByMe;
48
+ public $modifiedByMeTime;
49
+ public $modifiedTime;
50
+ public $name;
51
+ public $originalFilename;
52
+ public $ownedByMe;
53
+ protected $ownersType = 'Google_Service_Drive_User';
54
+ protected $ownersDataType = 'array';
55
+ public $parents;
56
+ public $permissionIds;
57
+ protected $permissionsType = 'Google_Service_Drive_Permission';
58
+ protected $permissionsDataType = 'array';
59
+ public $properties;
60
+ public $quotaBytesUsed;
61
+ public $shared;
62
+ public $sharedWithMeTime;
63
+ protected $sharingUserType = 'Google_Service_Drive_User';
64
+ protected $sharingUserDataType = '';
65
+ public $size;
66
+ public $spaces;
67
+ public $starred;
68
+ public $teamDriveId;
69
+ public $thumbnailLink;
70
+ public $thumbnailVersion;
71
+ public $trashed;
72
+ public $trashedTime;
73
+ protected $trashingUserType = 'Google_Service_Drive_User';
74
+ protected $trashingUserDataType = '';
75
+ public $version;
76
+ protected $videoMediaMetadataType = 'Google_Service_Drive_DriveFileVideoMediaMetadata';
77
+ protected $videoMediaMetadataDataType = '';
78
+ public $viewedByMe;
79
+ public $viewedByMeTime;
80
+ public $viewersCanCopyContent;
81
+ public $webContentLink;
82
+ public $webViewLink;
83
+ public $writersCanShare;
84
+
85
+ public function setAppProperties($appProperties)
86
+ {
87
+ $this->appProperties = $appProperties;
88
+ }
89
+ public function getAppProperties()
90
+ {
91
+ return $this->appProperties;
92
+ }
93
+ /**
94
+ * @param Google_Service_Drive_DriveFileCapabilities
95
+ */
96
+ public function setCapabilities(Google_Service_Drive_DriveFileCapabilities $capabilities)
97
+ {
98
+ $this->capabilities = $capabilities;
99
+ }
100
+ /**
101
+ * @return Google_Service_Drive_DriveFileCapabilities
102
+ */
103
+ public function getCapabilities()
104
+ {
105
+ return $this->capabilities;
106
+ }
107
+ /**
108
+ * @param Google_Service_Drive_DriveFileContentHints
109
+ */
110
+ public function setContentHints(Google_Service_Drive_DriveFileContentHints $contentHints)
111
+ {
112
+ $this->contentHints = $contentHints;
113
+ }
114
+ /**
115
+ * @return Google_Service_Drive_DriveFileContentHints
116
+ */
117
+ public function getContentHints()
118
+ {
119
+ return $this->contentHints;
120
+ }
121
+ public function setCopyRequiresWriterPermission($copyRequiresWriterPermission)
122
+ {
123
+ $this->copyRequiresWriterPermission = $copyRequiresWriterPermission;
124
+ }
125
+ public function getCopyRequiresWriterPermission()
126
+ {
127
+ return $this->copyRequiresWriterPermission;
128
+ }
129
+ public function setCreatedTime($createdTime)
130
+ {
131
+ $this->createdTime = $createdTime;
132
+ }
133
+ public function getCreatedTime()
134
+ {
135
+ return $this->createdTime;
136
+ }
137
+ public function setDescription($description)
138
+ {
139
+ $this->description = $description;
140
+ }
141
+ public function getDescription()
142
+ {
143
+ return $this->description;
144
+ }
145
+ public function setExplicitlyTrashed($explicitlyTrashed)
146
+ {
147
+ $this->explicitlyTrashed = $explicitlyTrashed;
148
+ }
149
+ public function getExplicitlyTrashed()
150
+ {
151
+ return $this->explicitlyTrashed;
152
+ }
153
+ public function setExportLinks($exportLinks)
154
+ {
155
+ $this->exportLinks = $exportLinks;
156
+ }
157
+ public function getExportLinks()
158
+ {
159
+ return $this->exportLinks;
160
+ }
161
+ public function setFileExtension($fileExtension)
162
+ {
163
+ $this->fileExtension = $fileExtension;
164
+ }
165
+ public function getFileExtension()
166
+ {
167
+ return $this->fileExtension;
168
+ }
169
+ public function setFolderColorRgb($folderColorRgb)
170
+ {
171
+ $this->folderColorRgb = $folderColorRgb;
172
+ }
173
+ public function getFolderColorRgb()
174
+ {
175
+ return $this->folderColorRgb;
176
+ }
177
+ public function setFullFileExtension($fullFileExtension)
178
+ {
179
+ $this->fullFileExtension = $fullFileExtension;
180
+ }
181
+ public function getFullFileExtension()
182
+ {
183
+ return $this->fullFileExtension;
184
+ }
185
+ public function setHasAugmentedPermissions($hasAugmentedPermissions)
186
+ {
187
+ $this->hasAugmentedPermissions = $hasAugmentedPermissions;
188
+ }
189
+ public function getHasAugmentedPermissions()
190
+ {
191
+ return $this->hasAugmentedPermissions;
192
+ }
193
+ public function setHasThumbnail($hasThumbnail)
194
+ {
195
+ $this->hasThumbnail = $hasThumbnail;
196
+ }
197
+ public function getHasThumbnail()
198
+ {
199
+ return $this->hasThumbnail;
200
+ }
201
+ public function setHeadRevisionId($headRevisionId)
202
+ {
203
+ $this->headRevisionId = $headRevisionId;
204
+ }
205
+ public function getHeadRevisionId()
206
+ {
207
+ return $this->headRevisionId;
208
+ }
209
+ public function setIconLink($iconLink)
210
+ {
211
+ $this->iconLink = $iconLink;
212
+ }
213
+ public function getIconLink()
214
+ {
215
+ return $this->iconLink;
216
+ }
217
+ public function setId($id)
218
+ {
219
+ $this->id = $id;
220
+ }
221
+ public function getId()
222
+ {
223
+ return $this->id;
224
+ }
225
+ /**
226
+ * @param Google_Service_Drive_DriveFileImageMediaMetadata
227
+ */
228
+ public function setImageMediaMetadata(Google_Service_Drive_DriveFileImageMediaMetadata $imageMediaMetadata)
229
+ {
230
+ $this->imageMediaMetadata = $imageMediaMetadata;
231
+ }
232
+ /**
233
+ * @return Google_Service_Drive_DriveFileImageMediaMetadata
234
+ */
235
+ public function getImageMediaMetadata()
236
+ {
237
+ return $this->imageMediaMetadata;
238
+ }
239
+ public function setIsAppAuthorized($isAppAuthorized)
240
+ {
241
+ $this->isAppAuthorized = $isAppAuthorized;
242
+ }
243
+ public function getIsAppAuthorized()
244
+ {
245
+ return $this->isAppAuthorized;
246
+ }
247
+ public function setKind($kind)
248
+ {
249
+ $this->kind = $kind;
250
+ }
251
+ public function getKind()
252
+ {
253
+ return $this->kind;
254
+ }
255
+ /**
256
+ * @param Google_Service_Drive_User
257
+ */
258
+ public function setLastModifyingUser(Google_Service_Drive_User $lastModifyingUser)
259
+ {
260
+ $this->lastModifyingUser = $lastModifyingUser;
261
+ }
262
+ /**
263
+ * @return Google_Service_Drive_User
264
+ */
265
+ public function getLastModifyingUser()
266
+ {
267
+ return $this->lastModifyingUser;
268
+ }
269
+ public function setMd5Checksum($md5Checksum)
270
+ {
271
+ $this->md5Checksum = $md5Checksum;
272
+ }
273
+ public function getMd5Checksum()
274
+ {
275
+ return $this->md5Checksum;
276
+ }
277
+ public function setMimeType($mimeType)
278
+ {
279
+ $this->mimeType = $mimeType;
280
+ }
281
+ public function getMimeType()
282
+ {
283
+ return $this->mimeType;
284
+ }
285
+ public function setModifiedByMe($modifiedByMe)
286
+ {
287
+ $this->modifiedByMe = $modifiedByMe;
288
+ }
289
+ public function getModifiedByMe()
290
+ {
291
+ return $this->modifiedByMe;
292
+ }
293
+ public function setModifiedByMeTime($modifiedByMeTime)
294
+ {
295
+ $this->modifiedByMeTime = $modifiedByMeTime;
296
+ }
297
+ public function getModifiedByMeTime()
298
+ {
299
+ return $this->modifiedByMeTime;
300
+ }
301
+ public function setModifiedTime($modifiedTime)
302
+ {
303
+ $this->modifiedTime = $modifiedTime;
304
+ }
305
+ public function getModifiedTime()
306
+ {
307
+ return $this->modifiedTime;
308
+ }
309
+ public function setName($name)
310
+ {
311
+ $this->name = $name;
312
+ }
313
+ public function getName()
314
+ {
315
+ return $this->name;
316
+ }
317
+ public function setOriginalFilename($originalFilename)
318
+ {
319
+ $this->originalFilename = $originalFilename;
320
+ }
321
+ public function getOriginalFilename()
322
+ {
323
+ return $this->originalFilename;
324
+ }
325
+ public function setOwnedByMe($ownedByMe)
326
+ {
327
+ $this->ownedByMe = $ownedByMe;
328
+ }
329
+ public function getOwnedByMe()
330
+ {
331
+ return $this->ownedByMe;
332
+ }
333
+ /**
334
+ * @param Google_Service_Drive_User
335
+ */
336
+ public function setOwners($owners)
337
+ {
338
+ $this->owners = $owners;
339
+ }
340
+ /**
341
+ * @return Google_Service_Drive_User
342
+ */
343
+ public function getOwners()
344
+ {
345
+ return $this->owners;
346
+ }
347
+ public function setParents($parents)
348
+ {
349
+ $this->parents = $parents;
350
+ }
351
+ public function getParents()
352
+ {
353
+ return $this->parents;
354
+ }
355
+ public function setPermissionIds($permissionIds)
356
+ {
357
+ $this->permissionIds = $permissionIds;
358
+ }
359
+ public function getPermissionIds()
360
+ {
361
+ return $this->permissionIds;
362
+ }
363
+ /**
364
+ * @param Google_Service_Drive_Permission
365
+ */
366
+ public function setPermissions($permissions)
367
+ {
368
+ $this->permissions = $permissions;
369
+ }
370
+ /**
371
+ * @return Google_Service_Drive_Permission
372
+ */
373
+ public function getPermissions()
374
+ {
375
+ return $this->permissions;
376
+ }
377
+ public function setProperties($properties)
378
+ {
379
+ $this->properties = $properties;
380
+ }
381
+ public function getProperties()
382
+ {
383
+ return $this->properties;
384
+ }
385
+ public function setQuotaBytesUsed($quotaBytesUsed)
386
+ {
387
+ $this->quotaBytesUsed = $quotaBytesUsed;
388
+ }
389
+ public function getQuotaBytesUsed()
390
+ {
391
+ return $this->quotaBytesUsed;
392
+ }
393
+ public function setShared($shared)
394
+ {
395
+ $this->shared = $shared;
396
+ }
397
+ public function getShared()
398
+ {
399
+ return $this->shared;
400
+ }
401
+ public function setSharedWithMeTime($sharedWithMeTime)
402
+ {
403
+ $this->sharedWithMeTime = $sharedWithMeTime;
404
+ }
405
+ public function getSharedWithMeTime()
406
+ {
407
+ return $this->sharedWithMeTime;
408
+ }
409
+ /**
410
+ * @param Google_Service_Drive_User
411
+ */
412
+ public function setSharingUser(Google_Service_Drive_User $sharingUser)
413
+ {
414
+ $this->sharingUser = $sharingUser;
415
+ }
416
+ /**
417
+ * @return Google_Service_Drive_User
418
+ */
419
+ public function getSharingUser()
420
+ {
421
+ return $this->sharingUser;
422
+ }
423
+ public function setSize($size)
424
+ {
425
+ $this->size = $size;
426
+ }
427
+ public function getSize()
428
+ {
429
+ return $this->size;
430
+ }
431
+ public function setSpaces($spaces)
432
+ {
433
+ $this->spaces = $spaces;
434
+ }
435
+ public function getSpaces()
436
+ {
437
+ return $this->spaces;
438
+ }
439
+ public function setStarred($starred)
440
+ {
441
+ $this->starred = $starred;
442
+ }
443
+ public function getStarred()
444
+ {
445
+ return $this->starred;
446
+ }
447
+ public function setTeamDriveId($teamDriveId)
448
+ {
449
+ $this->teamDriveId = $teamDriveId;
450
+ }
451
+ public function getTeamDriveId()
452
+ {
453
+ return $this->teamDriveId;
454
+ }
455
+ public function setThumbnailLink($thumbnailLink)
456
+ {
457
+ $this->thumbnailLink = $thumbnailLink;
458
+ }
459
+ public function getThumbnailLink()
460
+ {
461
+ return $this->thumbnailLink;
462
+ }
463
+ public function setThumbnailVersion($thumbnailVersion)
464
+ {
465
+ $this->thumbnailVersion = $thumbnailVersion;
466
+ }
467
+ public function getThumbnailVersion()
468
+ {
469
+ return $this->thumbnailVersion;
470
+ }
471
+ public function setTrashed($trashed)
472
+ {
473
+ $this->trashed = $trashed;
474
+ }
475
+ public function getTrashed()
476
+ {
477
+ return $this->trashed;
478
+ }
479
+ public function setTrashedTime($trashedTime)
480
+ {
481
+ $this->trashedTime = $trashedTime;
482
+ }
483
+ public function getTrashedTime()
484
+ {
485
+ return $this->trashedTime;
486
+ }
487
+ /**
488
+ * @param Google_Service_Drive_User
489
+ */
490
+ public function setTrashingUser(Google_Service_Drive_User $trashingUser)
491
+ {
492
+ $this->trashingUser = $trashingUser;
493
+ }
494
+ /**
495
+ * @return Google_Service_Drive_User
496
+ */
497
+ public function getTrashingUser()
498
+ {
499
+ return $this->trashingUser;
500
+ }
501
+ public function setVersion($version)
502
+ {
503
+ $this->version = $version;
504
+ }
505
+ public function getVersion()
506
+ {
507
+ return $this->version;
508
+ }
509
+ /**
510
+ * @param Google_Service_Drive_DriveFileVideoMediaMetadata
511
+ */
512
+ public function setVideoMediaMetadata(Google_Service_Drive_DriveFileVideoMediaMetadata $videoMediaMetadata)
513
+ {
514
+ $this->videoMediaMetadata = $videoMediaMetadata;
515
+ }
516
+ /**
517
+ * @return Google_Service_Drive_DriveFileVideoMediaMetadata
518
+ */
519
+ public function getVideoMediaMetadata()
520
+ {
521
+ return $this->videoMediaMetadata;
522
+ }
523
+ public function setViewedByMe($viewedByMe)
524
+ {
525
+ $this->viewedByMe = $viewedByMe;
526
+ }
527
+ public function getViewedByMe()
528
+ {
529
+ return $this->viewedByMe;
530
+ }
531
+ public function setViewedByMeTime($viewedByMeTime)
532
+ {
533
+ $this->viewedByMeTime = $viewedByMeTime;
534
+ }
535
+ public function getViewedByMeTime()
536
+ {
537
+ return $this->viewedByMeTime;
538
+ }
539
+ public function setViewersCanCopyContent($viewersCanCopyContent)
540
+ {
541
+ $this->viewersCanCopyContent = $viewersCanCopyContent;
542
+ }
543
+ public function getViewersCanCopyContent()
544
+ {
545
+ return $this->viewersCanCopyContent;
546
+ }
547
+ public function setWebContentLink($webContentLink)
548
+ {
549
+ $this->webContentLink = $webContentLink;
550
+ }
551
+ public function getWebContentLink()
552
+ {
553
+ return $this->webContentLink;
554
+ }
555
+ public function setWebViewLink($webViewLink)
556
+ {
557
+ $this->webViewLink = $webViewLink;
558
+ }
559
+ public function getWebViewLink()
560
+ {
561
+ return $this->webViewLink;
562
+ }
563
+ public function setWritersCanShare($writersCanShare)
564
+ {
565
+ $this->writersCanShare = $writersCanShare;
566
+ }
567
+ public function getWritersCanShare()
568
+ {
569
+ return $this->writersCanShare;
570
+ }
571
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/DriveFileCapabilities.php ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_DriveFileCapabilities extends Google_Model
19
+ {
20
+ public $canAddChildren;
21
+ public $canChangeCopyRequiresWriterPermission;
22
+ public $canChangeViewersCanCopyContent;
23
+ public $canComment;
24
+ public $canCopy;
25
+ public $canDelete;
26
+ public $canDeleteChildren;
27
+ public $canDownload;
28
+ public $canEdit;
29
+ public $canListChildren;
30
+ public $canMoveChildrenOutOfTeamDrive;
31
+ public $canMoveChildrenWithinTeamDrive;
32
+ public $canMoveItemIntoTeamDrive;
33
+ public $canMoveItemOutOfTeamDrive;
34
+ public $canMoveItemWithinTeamDrive;
35
+ public $canMoveTeamDriveItem;
36
+ public $canReadRevisions;
37
+ public $canReadTeamDrive;
38
+ public $canRemoveChildren;
39
+ public $canRename;
40
+ public $canShare;
41
+ public $canTrash;
42
+ public $canTrashChildren;
43
+ public $canUntrash;
44
+
45
+ public function setCanAddChildren($canAddChildren)
46
+ {
47
+ $this->canAddChildren = $canAddChildren;
48
+ }
49
+ public function getCanAddChildren()
50
+ {
51
+ return $this->canAddChildren;
52
+ }
53
+ public function setCanChangeCopyRequiresWriterPermission($canChangeCopyRequiresWriterPermission)
54
+ {
55
+ $this->canChangeCopyRequiresWriterPermission = $canChangeCopyRequiresWriterPermission;
56
+ }
57
+ public function getCanChangeCopyRequiresWriterPermission()
58
+ {
59
+ return $this->canChangeCopyRequiresWriterPermission;
60
+ }
61
+ public function setCanChangeViewersCanCopyContent($canChangeViewersCanCopyContent)
62
+ {
63
+ $this->canChangeViewersCanCopyContent = $canChangeViewersCanCopyContent;
64
+ }
65
+ public function getCanChangeViewersCanCopyContent()
66
+ {
67
+ return $this->canChangeViewersCanCopyContent;
68
+ }
69
+ public function setCanComment($canComment)
70
+ {
71
+ $this->canComment = $canComment;
72
+ }
73
+ public function getCanComment()
74
+ {
75
+ return $this->canComment;
76
+ }
77
+ public function setCanCopy($canCopy)
78
+ {
79
+ $this->canCopy = $canCopy;
80
+ }
81
+ public function getCanCopy()
82
+ {
83
+ return $this->canCopy;
84
+ }
85
+ public function setCanDelete($canDelete)
86
+ {
87
+ $this->canDelete = $canDelete;
88
+ }
89
+ public function getCanDelete()
90
+ {
91
+ return $this->canDelete;
92
+ }
93
+ public function setCanDeleteChildren($canDeleteChildren)
94
+ {
95
+ $this->canDeleteChildren = $canDeleteChildren;
96
+ }
97
+ public function getCanDeleteChildren()
98
+ {
99
+ return $this->canDeleteChildren;
100
+ }
101
+ public function setCanDownload($canDownload)
102
+ {
103
+ $this->canDownload = $canDownload;
104
+ }
105
+ public function getCanDownload()
106
+ {
107
+ return $this->canDownload;
108
+ }
109
+ public function setCanEdit($canEdit)
110
+ {
111
+ $this->canEdit = $canEdit;
112
+ }
113
+ public function getCanEdit()
114
+ {
115
+ return $this->canEdit;
116
+ }
117
+ public function setCanListChildren($canListChildren)
118
+ {
119
+ $this->canListChildren = $canListChildren;
120
+ }
121
+ public function getCanListChildren()
122
+ {
123
+ return $this->canListChildren;
124
+ }
125
+ public function setCanMoveChildrenOutOfTeamDrive($canMoveChildrenOutOfTeamDrive)
126
+ {
127
+ $this->canMoveChildrenOutOfTeamDrive = $canMoveChildrenOutOfTeamDrive;
128
+ }
129
+ public function getCanMoveChildrenOutOfTeamDrive()
130
+ {
131
+ return $this->canMoveChildrenOutOfTeamDrive;
132
+ }
133
+ public function setCanMoveChildrenWithinTeamDrive($canMoveChildrenWithinTeamDrive)
134
+ {
135
+ $this->canMoveChildrenWithinTeamDrive = $canMoveChildrenWithinTeamDrive;
136
+ }
137
+ public function getCanMoveChildrenWithinTeamDrive()
138
+ {
139
+ return $this->canMoveChildrenWithinTeamDrive;
140
+ }
141
+ public function setCanMoveItemIntoTeamDrive($canMoveItemIntoTeamDrive)
142
+ {
143
+ $this->canMoveItemIntoTeamDrive = $canMoveItemIntoTeamDrive;
144
+ }
145
+ public function getCanMoveItemIntoTeamDrive()
146
+ {
147
+ return $this->canMoveItemIntoTeamDrive;
148
+ }
149
+ public function setCanMoveItemOutOfTeamDrive($canMoveItemOutOfTeamDrive)
150
+ {
151
+ $this->canMoveItemOutOfTeamDrive = $canMoveItemOutOfTeamDrive;
152
+ }
153
+ public function getCanMoveItemOutOfTeamDrive()
154
+ {
155
+ return $this->canMoveItemOutOfTeamDrive;
156
+ }
157
+ public function setCanMoveItemWithinTeamDrive($canMoveItemWithinTeamDrive)
158
+ {
159
+ $this->canMoveItemWithinTeamDrive = $canMoveItemWithinTeamDrive;
160
+ }
161
+ public function getCanMoveItemWithinTeamDrive()
162
+ {
163
+ return $this->canMoveItemWithinTeamDrive;
164
+ }
165
+ public function setCanMoveTeamDriveItem($canMoveTeamDriveItem)
166
+ {
167
+ $this->canMoveTeamDriveItem = $canMoveTeamDriveItem;
168
+ }
169
+ public function getCanMoveTeamDriveItem()
170
+ {
171
+ return $this->canMoveTeamDriveItem;
172
+ }
173
+ public function setCanReadRevisions($canReadRevisions)
174
+ {
175
+ $this->canReadRevisions = $canReadRevisions;
176
+ }
177
+ public function getCanReadRevisions()
178
+ {
179
+ return $this->canReadRevisions;
180
+ }
181
+ public function setCanReadTeamDrive($canReadTeamDrive)
182
+ {
183
+ $this->canReadTeamDrive = $canReadTeamDrive;
184
+ }
185
+ public function getCanReadTeamDrive()
186
+ {
187
+ return $this->canReadTeamDrive;
188
+ }
189
+ public function setCanRemoveChildren($canRemoveChildren)
190
+ {
191
+ $this->canRemoveChildren = $canRemoveChildren;
192
+ }
193
+ public function getCanRemoveChildren()
194
+ {
195
+ return $this->canRemoveChildren;
196
+ }
197
+ public function setCanRename($canRename)
198
+ {
199
+ $this->canRename = $canRename;
200
+ }
201
+ public function getCanRename()
202
+ {
203
+ return $this->canRename;
204
+ }
205
+ public function setCanShare($canShare)
206
+ {
207
+ $this->canShare = $canShare;
208
+ }
209
+ public function getCanShare()
210
+ {
211
+ return $this->canShare;
212
+ }
213
+ public function setCanTrash($canTrash)
214
+ {
215
+ $this->canTrash = $canTrash;
216
+ }
217
+ public function getCanTrash()
218
+ {
219
+ return $this->canTrash;
220
+ }
221
+ public function setCanTrashChildren($canTrashChildren)
222
+ {
223
+ $this->canTrashChildren = $canTrashChildren;
224
+ }
225
+ public function getCanTrashChildren()
226
+ {
227
+ return $this->canTrashChildren;
228
+ }
229
+ public function setCanUntrash($canUntrash)
230
+ {
231
+ $this->canUntrash = $canUntrash;
232
+ }
233
+ public function getCanUntrash()
234
+ {
235
+ return $this->canUntrash;
236
+ }
237
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/DriveFileContentHints.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_DriveFileContentHints extends Google_Model
19
+ {
20
+ public $indexableText;
21
+ protected $thumbnailType = 'Google_Service_Drive_DriveFileContentHintsThumbnail';
22
+ protected $thumbnailDataType = '';
23
+
24
+ public function setIndexableText($indexableText)
25
+ {
26
+ $this->indexableText = $indexableText;
27
+ }
28
+ public function getIndexableText()
29
+ {
30
+ return $this->indexableText;
31
+ }
32
+ /**
33
+ * @param Google_Service_Drive_DriveFileContentHintsThumbnail
34
+ */
35
+ public function setThumbnail(Google_Service_Drive_DriveFileContentHintsThumbnail $thumbnail)
36
+ {
37
+ $this->thumbnail = $thumbnail;
38
+ }
39
+ /**
40
+ * @return Google_Service_Drive_DriveFileContentHintsThumbnail
41
+ */
42
+ public function getThumbnail()
43
+ {
44
+ return $this->thumbnail;
45
+ }
46
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/DriveFileContentHintsThumbnail.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_DriveFileContentHintsThumbnail extends Google_Model
19
+ {
20
+ public $image;
21
+ public $mimeType;
22
+
23
+ public function setImage($image)
24
+ {
25
+ $this->image = $image;
26
+ }
27
+ public function getImage()
28
+ {
29
+ return $this->image;
30
+ }
31
+ public function setMimeType($mimeType)
32
+ {
33
+ $this->mimeType = $mimeType;
34
+ }
35
+ public function getMimeType()
36
+ {
37
+ return $this->mimeType;
38
+ }
39
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/DriveFileImageMediaMetadata.php ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_DriveFileImageMediaMetadata extends Google_Model
19
+ {
20
+ public $aperture;
21
+ public $cameraMake;
22
+ public $cameraModel;
23
+ public $colorSpace;
24
+ public $exposureBias;
25
+ public $exposureMode;
26
+ public $exposureTime;
27
+ public $flashUsed;
28
+ public $focalLength;
29
+ public $height;
30
+ public $isoSpeed;
31
+ public $lens;
32
+ protected $locationType = 'Google_Service_Drive_DriveFileImageMediaMetadataLocation';
33
+ protected $locationDataType = '';
34
+ public $maxApertureValue;
35
+ public $meteringMode;
36
+ public $rotation;
37
+ public $sensor;
38
+ public $subjectDistance;
39
+ public $time;
40
+ public $whiteBalance;
41
+ public $width;
42
+
43
+ public function setAperture($aperture)
44
+ {
45
+ $this->aperture = $aperture;
46
+ }
47
+ public function getAperture()
48
+ {
49
+ return $this->aperture;
50
+ }
51
+ public function setCameraMake($cameraMake)
52
+ {
53
+ $this->cameraMake = $cameraMake;
54
+ }
55
+ public function getCameraMake()
56
+ {
57
+ return $this->cameraMake;
58
+ }
59
+ public function setCameraModel($cameraModel)
60
+ {
61
+ $this->cameraModel = $cameraModel;
62
+ }
63
+ public function getCameraModel()
64
+ {
65
+ return $this->cameraModel;
66
+ }
67
+ public function setColorSpace($colorSpace)
68
+ {
69
+ $this->colorSpace = $colorSpace;
70
+ }
71
+ public function getColorSpace()
72
+ {
73
+ return $this->colorSpace;
74
+ }
75
+ public function setExposureBias($exposureBias)
76
+ {
77
+ $this->exposureBias = $exposureBias;
78
+ }
79
+ public function getExposureBias()
80
+ {
81
+ return $this->exposureBias;
82
+ }
83
+ public function setExposureMode($exposureMode)
84
+ {
85
+ $this->exposureMode = $exposureMode;
86
+ }
87
+ public function getExposureMode()
88
+ {
89
+ return $this->exposureMode;
90
+ }
91
+ public function setExposureTime($exposureTime)
92
+ {
93
+ $this->exposureTime = $exposureTime;
94
+ }
95
+ public function getExposureTime()
96
+ {
97
+ return $this->exposureTime;
98
+ }
99
+ public function setFlashUsed($flashUsed)
100
+ {
101
+ $this->flashUsed = $flashUsed;
102
+ }
103
+ public function getFlashUsed()
104
+ {
105
+ return $this->flashUsed;
106
+ }
107
+ public function setFocalLength($focalLength)
108
+ {
109
+ $this->focalLength = $focalLength;
110
+ }
111
+ public function getFocalLength()
112
+ {
113
+ return $this->focalLength;
114
+ }
115
+ public function setHeight($height)
116
+ {
117
+ $this->height = $height;
118
+ }
119
+ public function getHeight()
120
+ {
121
+ return $this->height;
122
+ }
123
+ public function setIsoSpeed($isoSpeed)
124
+ {
125
+ $this->isoSpeed = $isoSpeed;
126
+ }
127
+ public function getIsoSpeed()
128
+ {
129
+ return $this->isoSpeed;
130
+ }
131
+ public function setLens($lens)
132
+ {
133
+ $this->lens = $lens;
134
+ }
135
+ public function getLens()
136
+ {
137
+ return $this->lens;
138
+ }
139
+ /**
140
+ * @param Google_Service_Drive_DriveFileImageMediaMetadataLocation
141
+ */
142
+ public function setLocation(Google_Service_Drive_DriveFileImageMediaMetadataLocation $location)
143
+ {
144
+ $this->location = $location;
145
+ }
146
+ /**
147
+ * @return Google_Service_Drive_DriveFileImageMediaMetadataLocation
148
+ */
149
+ public function getLocation()
150
+ {
151
+ return $this->location;
152
+ }
153
+ public function setMaxApertureValue($maxApertureValue)
154
+ {
155
+ $this->maxApertureValue = $maxApertureValue;
156
+ }
157
+ public function getMaxApertureValue()
158
+ {
159
+ return $this->maxApertureValue;
160
+ }
161
+ public function setMeteringMode($meteringMode)
162
+ {
163
+ $this->meteringMode = $meteringMode;
164
+ }
165
+ public function getMeteringMode()
166
+ {
167
+ return $this->meteringMode;
168
+ }
169
+ public function setRotation($rotation)
170
+ {
171
+ $this->rotation = $rotation;
172
+ }
173
+ public function getRotation()
174
+ {
175
+ return $this->rotation;
176
+ }
177
+ public function setSensor($sensor)
178
+ {
179
+ $this->sensor = $sensor;
180
+ }
181
+ public function getSensor()
182
+ {
183
+ return $this->sensor;
184
+ }
185
+ public function setSubjectDistance($subjectDistance)
186
+ {
187
+ $this->subjectDistance = $subjectDistance;
188
+ }
189
+ public function getSubjectDistance()
190
+ {
191
+ return $this->subjectDistance;
192
+ }
193
+ public function setTime($time)
194
+ {
195
+ $this->time = $time;
196
+ }
197
+ public function getTime()
198
+ {
199
+ return $this->time;
200
+ }
201
+ public function setWhiteBalance($whiteBalance)
202
+ {
203
+ $this->whiteBalance = $whiteBalance;
204
+ }
205
+ public function getWhiteBalance()
206
+ {
207
+ return $this->whiteBalance;
208
+ }
209
+ public function setWidth($width)
210
+ {
211
+ $this->width = $width;
212
+ }
213
+ public function getWidth()
214
+ {
215
+ return $this->width;
216
+ }
217
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/DriveFileImageMediaMetadataLocation.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_DriveFileImageMediaMetadataLocation extends Google_Model
19
+ {
20
+ public $altitude;
21
+ public $latitude;
22
+ public $longitude;
23
+
24
+ public function setAltitude($altitude)
25
+ {
26
+ $this->altitude = $altitude;
27
+ }
28
+ public function getAltitude()
29
+ {
30
+ return $this->altitude;
31
+ }
32
+ public function setLatitude($latitude)
33
+ {
34
+ $this->latitude = $latitude;
35
+ }
36
+ public function getLatitude()
37
+ {
38
+ return $this->latitude;
39
+ }
40
+ public function setLongitude($longitude)
41
+ {
42
+ $this->longitude = $longitude;
43
+ }
44
+ public function getLongitude()
45
+ {
46
+ return $this->longitude;
47
+ }
48
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/DriveFileVideoMediaMetadata.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_DriveFileVideoMediaMetadata extends Google_Model
19
+ {
20
+ public $durationMillis;
21
+ public $height;
22
+ public $width;
23
+
24
+ public function setDurationMillis($durationMillis)
25
+ {
26
+ $this->durationMillis = $durationMillis;
27
+ }
28
+ public function getDurationMillis()
29
+ {
30
+ return $this->durationMillis;
31
+ }
32
+ public function setHeight($height)
33
+ {
34
+ $this->height = $height;
35
+ }
36
+ public function getHeight()
37
+ {
38
+ return $this->height;
39
+ }
40
+ public function setWidth($width)
41
+ {
42
+ $this->width = $width;
43
+ }
44
+ public function getWidth()
45
+ {
46
+ return $this->width;
47
+ }
48
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/FileList.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_FileList extends Google_Collection
19
+ {
20
+ protected $collection_key = 'files';
21
+ protected $filesType = 'Google_Service_Drive_DriveFile';
22
+ protected $filesDataType = 'array';
23
+ public $incompleteSearch;
24
+ public $kind;
25
+ public $nextPageToken;
26
+
27
+ /**
28
+ * @param Google_Service_Drive_DriveFile
29
+ */
30
+ public function setFiles($files)
31
+ {
32
+ $this->files = $files;
33
+ }
34
+ /**
35
+ * @return Google_Service_Drive_DriveFile
36
+ */
37
+ public function getFiles()
38
+ {
39
+ return $this->files;
40
+ }
41
+ public function setIncompleteSearch($incompleteSearch)
42
+ {
43
+ $this->incompleteSearch = $incompleteSearch;
44
+ }
45
+ public function getIncompleteSearch()
46
+ {
47
+ return $this->incompleteSearch;
48
+ }
49
+ public function setKind($kind)
50
+ {
51
+ $this->kind = $kind;
52
+ }
53
+ public function getKind()
54
+ {
55
+ return $this->kind;
56
+ }
57
+ public function setNextPageToken($nextPageToken)
58
+ {
59
+ $this->nextPageToken = $nextPageToken;
60
+ }
61
+ public function getNextPageToken()
62
+ {
63
+ return $this->nextPageToken;
64
+ }
65
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/GeneratedIds.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_GeneratedIds extends Google_Collection
19
+ {
20
+ protected $collection_key = 'ids';
21
+ public $ids;
22
+ public $kind;
23
+ public $space;
24
+
25
+ public function setIds($ids)
26
+ {
27
+ $this->ids = $ids;
28
+ }
29
+ public function getIds()
30
+ {
31
+ return $this->ids;
32
+ }
33
+ public function setKind($kind)
34
+ {
35
+ $this->kind = $kind;
36
+ }
37
+ public function getKind()
38
+ {
39
+ return $this->kind;
40
+ }
41
+ public function setSpace($space)
42
+ {
43
+ $this->space = $space;
44
+ }
45
+ public function getSpace()
46
+ {
47
+ return $this->space;
48
+ }
49
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/Permission.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_Permission extends Google_Collection
19
+ {
20
+ protected $collection_key = 'teamDrivePermissionDetails';
21
+ public $allowFileDiscovery;
22
+ public $deleted;
23
+ public $displayName;
24
+ public $domain;
25
+ public $emailAddress;
26
+ public $expirationTime;
27
+ public $id;
28
+ public $kind;
29
+ public $photoLink;
30
+ public $role;
31
+ protected $teamDrivePermissionDetailsType = 'Google_Service_Drive_PermissionTeamDrivePermissionDetails';
32
+ protected $teamDrivePermissionDetailsDataType = 'array';
33
+ public $type;
34
+
35
+ public function setAllowFileDiscovery($allowFileDiscovery)
36
+ {
37
+ $this->allowFileDiscovery = $allowFileDiscovery;
38
+ }
39
+ public function getAllowFileDiscovery()
40
+ {
41
+ return $this->allowFileDiscovery;
42
+ }
43
+ public function setDeleted($deleted)
44
+ {
45
+ $this->deleted = $deleted;
46
+ }
47
+ public function getDeleted()
48
+ {
49
+ return $this->deleted;
50
+ }
51
+ public function setDisplayName($displayName)
52
+ {
53
+ $this->displayName = $displayName;
54
+ }
55
+ public function getDisplayName()
56
+ {
57
+ return $this->displayName;
58
+ }
59
+ public function setDomain($domain)
60
+ {
61
+ $this->domain = $domain;
62
+ }
63
+ public function getDomain()
64
+ {
65
+ return $this->domain;
66
+ }
67
+ public function setEmailAddress($emailAddress)
68
+ {
69
+ $this->emailAddress = $emailAddress;
70
+ }
71
+ public function getEmailAddress()
72
+ {
73
+ return $this->emailAddress;
74
+ }
75
+ public function setExpirationTime($expirationTime)
76
+ {
77
+ $this->expirationTime = $expirationTime;
78
+ }
79
+ public function getExpirationTime()
80
+ {
81
+ return $this->expirationTime;
82
+ }
83
+ public function setId($id)
84
+ {
85
+ $this->id = $id;
86
+ }
87
+ public function getId()
88
+ {
89
+ return $this->id;
90
+ }
91
+ public function setKind($kind)
92
+ {
93
+ $this->kind = $kind;
94
+ }
95
+ public function getKind()
96
+ {
97
+ return $this->kind;
98
+ }
99
+ public function setPhotoLink($photoLink)
100
+ {
101
+ $this->photoLink = $photoLink;
102
+ }
103
+ public function getPhotoLink()
104
+ {
105
+ return $this->photoLink;
106
+ }
107
+ public function setRole($role)
108
+ {
109
+ $this->role = $role;
110
+ }
111
+ public function getRole()
112
+ {
113
+ return $this->role;
114
+ }
115
+ /**
116
+ * @param Google_Service_Drive_PermissionTeamDrivePermissionDetails
117
+ */
118
+ public function setTeamDrivePermissionDetails($teamDrivePermissionDetails)
119
+ {
120
+ $this->teamDrivePermissionDetails = $teamDrivePermissionDetails;
121
+ }
122
+ /**
123
+ * @return Google_Service_Drive_PermissionTeamDrivePermissionDetails
124
+ */
125
+ public function getTeamDrivePermissionDetails()
126
+ {
127
+ return $this->teamDrivePermissionDetails;
128
+ }
129
+ public function setType($type)
130
+ {
131
+ $this->type = $type;
132
+ }
133
+ public function getType()
134
+ {
135
+ return $this->type;
136
+ }
137
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/PermissionList.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_PermissionList extends Google_Collection
19
+ {
20
+ protected $collection_key = 'permissions';
21
+ public $kind;
22
+ public $nextPageToken;
23
+ protected $permissionsType = 'Google_Service_Drive_Permission';
24
+ protected $permissionsDataType = 'array';
25
+
26
+ public function setKind($kind)
27
+ {
28
+ $this->kind = $kind;
29
+ }
30
+ public function getKind()
31
+ {
32
+ return $this->kind;
33
+ }
34
+ public function setNextPageToken($nextPageToken)
35
+ {
36
+ $this->nextPageToken = $nextPageToken;
37
+ }
38
+ public function getNextPageToken()
39
+ {
40
+ return $this->nextPageToken;
41
+ }
42
+ /**
43
+ * @param Google_Service_Drive_Permission
44
+ */
45
+ public function setPermissions($permissions)
46
+ {
47
+ $this->permissions = $permissions;
48
+ }
49
+ /**
50
+ * @return Google_Service_Drive_Permission
51
+ */
52
+ public function getPermissions()
53
+ {
54
+ return $this->permissions;
55
+ }
56
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/PermissionTeamDrivePermissionDetails.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_PermissionTeamDrivePermissionDetails extends Google_Model
19
+ {
20
+ public $inherited;
21
+ public $inheritedFrom;
22
+ public $role;
23
+ public $teamDrivePermissionType;
24
+
25
+ public function setInherited($inherited)
26
+ {
27
+ $this->inherited = $inherited;
28
+ }
29
+ public function getInherited()
30
+ {
31
+ return $this->inherited;
32
+ }
33
+ public function setInheritedFrom($inheritedFrom)
34
+ {
35
+ $this->inheritedFrom = $inheritedFrom;
36
+ }
37
+ public function getInheritedFrom()
38
+ {
39
+ return $this->inheritedFrom;
40
+ }
41
+ public function setRole($role)
42
+ {
43
+ $this->role = $role;
44
+ }
45
+ public function getRole()
46
+ {
47
+ return $this->role;
48
+ }
49
+ public function setTeamDrivePermissionType($teamDrivePermissionType)
50
+ {
51
+ $this->teamDrivePermissionType = $teamDrivePermissionType;
52
+ }
53
+ public function getTeamDrivePermissionType()
54
+ {
55
+ return $this->teamDrivePermissionType;
56
+ }
57
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/Reply.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_Reply extends Google_Model
19
+ {
20
+ public $action;
21
+ protected $authorType = 'Google_Service_Drive_User';
22
+ protected $authorDataType = '';
23
+ public $content;
24
+ public $createdTime;
25
+ public $deleted;
26
+ public $htmlContent;
27
+ public $id;
28
+ public $kind;
29
+ public $modifiedTime;
30
+
31
+ public function setAction($action)
32
+ {
33
+ $this->action = $action;
34
+ }
35
+ public function getAction()
36
+ {
37
+ return $this->action;
38
+ }
39
+ /**
40
+ * @param Google_Service_Drive_User
41
+ */
42
+ public function setAuthor(Google_Service_Drive_User $author)
43
+ {
44
+ $this->author = $author;
45
+ }
46
+ /**
47
+ * @return Google_Service_Drive_User
48
+ */
49
+ public function getAuthor()
50
+ {
51
+ return $this->author;
52
+ }
53
+ public function setContent($content)
54
+ {
55
+ $this->content = $content;
56
+ }
57
+ public function getContent()
58
+ {
59
+ return $this->content;
60
+ }
61
+ public function setCreatedTime($createdTime)
62
+ {
63
+ $this->createdTime = $createdTime;
64
+ }
65
+ public function getCreatedTime()
66
+ {
67
+ return $this->createdTime;
68
+ }
69
+ public function setDeleted($deleted)
70
+ {
71
+ $this->deleted = $deleted;
72
+ }
73
+ public function getDeleted()
74
+ {
75
+ return $this->deleted;
76
+ }
77
+ public function setHtmlContent($htmlContent)
78
+ {
79
+ $this->htmlContent = $htmlContent;
80
+ }
81
+ public function getHtmlContent()
82
+ {
83
+ return $this->htmlContent;
84
+ }
85
+ public function setId($id)
86
+ {
87
+ $this->id = $id;
88
+ }
89
+ public function getId()
90
+ {
91
+ return $this->id;
92
+ }
93
+ public function setKind($kind)
94
+ {
95
+ $this->kind = $kind;
96
+ }
97
+ public function getKind()
98
+ {
99
+ return $this->kind;
100
+ }
101
+ public function setModifiedTime($modifiedTime)
102
+ {
103
+ $this->modifiedTime = $modifiedTime;
104
+ }
105
+ public function getModifiedTime()
106
+ {
107
+ return $this->modifiedTime;
108
+ }
109
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/ReplyList.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_ReplyList extends Google_Collection
19
+ {
20
+ protected $collection_key = 'replies';
21
+ public $kind;
22
+ public $nextPageToken;
23
+ protected $repliesType = 'Google_Service_Drive_Reply';
24
+ protected $repliesDataType = 'array';
25
+
26
+ public function setKind($kind)
27
+ {
28
+ $this->kind = $kind;
29
+ }
30
+ public function getKind()
31
+ {
32
+ return $this->kind;
33
+ }
34
+ public function setNextPageToken($nextPageToken)
35
+ {
36
+ $this->nextPageToken = $nextPageToken;
37
+ }
38
+ public function getNextPageToken()
39
+ {
40
+ return $this->nextPageToken;
41
+ }
42
+ /**
43
+ * @param Google_Service_Drive_Reply
44
+ */
45
+ public function setReplies($replies)
46
+ {
47
+ $this->replies = $replies;
48
+ }
49
+ /**
50
+ * @return Google_Service_Drive_Reply
51
+ */
52
+ public function getReplies()
53
+ {
54
+ return $this->replies;
55
+ }
56
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/Resource/About.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ /**
19
+ * The "about" collection of methods.
20
+ * Typical usage is:
21
+ * <code>
22
+ * $driveService = new Google_Service_Drive(...);
23
+ * $about = $driveService->about;
24
+ * </code>
25
+ */
26
+ class Google_Service_Drive_Resource_About extends Google_Service_Resource
27
+ {
28
+ /**
29
+ * Gets information about the user, the user's Drive, and system capabilities.
30
+ * (about.get)
31
+ *
32
+ * @param array $optParams Optional parameters.
33
+ * @return Google_Service_Drive_About
34
+ */
35
+ public function get($optParams = array())
36
+ {
37
+ $params = array();
38
+ $params = array_merge($params, $optParams);
39
+ return $this->call('get', array($params), "Google_Service_Drive_About");
40
+ }
41
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Changes.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ /**
19
+ * The "changes" collection of methods.
20
+ * Typical usage is:
21
+ * <code>
22
+ * $driveService = new Google_Service_Drive(...);
23
+ * $changes = $driveService->changes;
24
+ * </code>
25
+ */
26
+ class Google_Service_Drive_Resource_Changes extends Google_Service_Resource
27
+ {
28
+ /**
29
+ * Gets the starting pageToken for listing future changes.
30
+ * (changes.getStartPageToken)
31
+ *
32
+ * @param array $optParams Optional parameters.
33
+ *
34
+ * @opt_param bool supportsTeamDrives Whether the requesting application
35
+ * supports Team Drives.
36
+ * @opt_param string teamDriveId The ID of the Team Drive for which the starting
37
+ * pageToken for listing future changes from that Team Drive will be returned.
38
+ * @return Google_Service_Drive_StartPageToken
39
+ */
40
+ public function getStartPageToken($optParams = array())
41
+ {
42
+ $params = array();
43
+ $params = array_merge($params, $optParams);
44
+ return $this->call('getStartPageToken', array($params), "Google_Service_Drive_StartPageToken");
45
+ }
46
+ /**
47
+ * Lists the changes for a user or Team Drive. (changes.listChanges)
48
+ *
49
+ * @param string $pageToken The token for continuing a previous list request on
50
+ * the next page. This should be set to the value of 'nextPageToken' from the
51
+ * previous response or to the response from the getStartPageToken method.
52
+ * @param array $optParams Optional parameters.
53
+ *
54
+ * @opt_param bool includeCorpusRemovals Whether changes should include the file
55
+ * resource if the file is still accessible by the user at the time of the
56
+ * request, even when a file was removed from the list of changes and there will
57
+ * be no further change entries for this file.
58
+ * @opt_param bool includeRemoved Whether to include changes indicating that
59
+ * items have been removed from the list of changes, for example by deletion or
60
+ * loss of access.
61
+ * @opt_param bool includeTeamDriveItems Whether Team Drive files or changes
62
+ * should be included in results.
63
+ * @opt_param int pageSize The maximum number of changes to return per page.
64
+ * @opt_param bool restrictToMyDrive Whether to restrict the results to changes
65
+ * inside the My Drive hierarchy. This omits changes to files such as those in
66
+ * the Application Data folder or shared files which have not been added to My
67
+ * Drive.
68
+ * @opt_param string spaces A comma-separated list of spaces to query within the
69
+ * user corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.
70
+ * @opt_param bool supportsTeamDrives Whether the requesting application
71
+ * supports Team Drives.
72
+ * @opt_param string teamDriveId The Team Drive from which changes will be
73
+ * returned. If specified the change IDs will be reflective of the Team Drive;
74
+ * use the combined Team Drive ID and change ID as an identifier.
75
+ * @return Google_Service_Drive_ChangeList
76
+ */
77
+ public function listChanges($pageToken, $optParams = array())
78
+ {
79
+ $params = array('pageToken' => $pageToken);
80
+ $params = array_merge($params, $optParams);
81
+ return $this->call('list', array($params), "Google_Service_Drive_ChangeList");
82
+ }
83
+ /**
84
+ * Subscribes to changes for a user. (changes.watch)
85
+ *
86
+ * @param string $pageToken The token for continuing a previous list request on
87
+ * the next page. This should be set to the value of 'nextPageToken' from the
88
+ * previous response or to the response from the getStartPageToken method.
89
+ * @param Google_Service_Drive_Channel $postBody
90
+ * @param array $optParams Optional parameters.
91
+ *
92
+ * @opt_param bool includeCorpusRemovals Whether changes should include the file
93
+ * resource if the file is still accessible by the user at the time of the
94
+ * request, even when a file was removed from the list of changes and there will
95
+ * be no further change entries for this file.
96
+ * @opt_param bool includeRemoved Whether to include changes indicating that
97
+ * items have been removed from the list of changes, for example by deletion or
98
+ * loss of access.
99
+ * @opt_param bool includeTeamDriveItems Whether Team Drive files or changes
100
+ * should be included in results.
101
+ * @opt_param int pageSize The maximum number of changes to return per page.
102
+ * @opt_param bool restrictToMyDrive Whether to restrict the results to changes
103
+ * inside the My Drive hierarchy. This omits changes to files such as those in
104
+ * the Application Data folder or shared files which have not been added to My
105
+ * Drive.
106
+ * @opt_param string spaces A comma-separated list of spaces to query within the
107
+ * user corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.
108
+ * @opt_param bool supportsTeamDrives Whether the requesting application
109
+ * supports Team Drives.
110
+ * @opt_param string teamDriveId The Team Drive from which changes will be
111
+ * returned. If specified the change IDs will be reflective of the Team Drive;
112
+ * use the combined Team Drive ID and change ID as an identifier.
113
+ * @return Google_Service_Drive_Channel
114
+ */
115
+ public function watch($pageToken, Google_Service_Drive_Channel $postBody, $optParams = array())
116
+ {
117
+ $params = array('pageToken' => $pageToken, 'postBody' => $postBody);
118
+ $params = array_merge($params, $optParams);
119
+ return $this->call('watch', array($params), "Google_Service_Drive_Channel");
120
+ }
121
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Channels.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ /**
19
+ * The "channels" collection of methods.
20
+ * Typical usage is:
21
+ * <code>
22
+ * $driveService = new Google_Service_Drive(...);
23
+ * $channels = $driveService->channels;
24
+ * </code>
25
+ */
26
+ class Google_Service_Drive_Resource_Channels extends Google_Service_Resource
27
+ {
28
+ /**
29
+ * Stop watching resources through this channel (channels.stop)
30
+ *
31
+ * @param Google_Service_Drive_Channel $postBody
32
+ * @param array $optParams Optional parameters.
33
+ */
34
+ public function stop(Google_Service_Drive_Channel $postBody, $optParams = array())
35
+ {
36
+ $params = array('postBody' => $postBody);
37
+ $params = array_merge($params, $optParams);
38
+ return $this->call('stop', array($params));
39
+ }
40
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Comments.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ /**
19
+ * The "comments" collection of methods.
20
+ * Typical usage is:
21
+ * <code>
22
+ * $driveService = new Google_Service_Drive(...);
23
+ * $comments = $driveService->comments;
24
+ * </code>
25
+ */
26
+ class Google_Service_Drive_Resource_Comments extends Google_Service_Resource
27
+ {
28
+ /**
29
+ * Creates a new comment on a file. (comments.create)
30
+ *
31
+ * @param string $fileId The ID of the file.
32
+ * @param Google_Service_Drive_Comment $postBody
33
+ * @param array $optParams Optional parameters.
34
+ * @return Google_Service_Drive_Comment
35
+ */
36
+ public function create($fileId, Google_Service_Drive_Comment $postBody, $optParams = array())
37
+ {
38
+ $params = array('fileId' => $fileId, 'postBody' => $postBody);
39
+ $params = array_merge($params, $optParams);
40
+ return $this->call('create', array($params), "Google_Service_Drive_Comment");
41
+ }
42
+ /**
43
+ * Deletes a comment. (comments.delete)
44
+ *
45
+ * @param string $fileId The ID of the file.
46
+ * @param string $commentId The ID of the comment.
47
+ * @param array $optParams Optional parameters.
48
+ */
49
+ public function delete($fileId, $commentId, $optParams = array())
50
+ {
51
+ $params = array('fileId' => $fileId, 'commentId' => $commentId);
52
+ $params = array_merge($params, $optParams);
53
+ return $this->call('delete', array($params));
54
+ }
55
+ /**
56
+ * Gets a comment by ID. (comments.get)
57
+ *
58
+ * @param string $fileId The ID of the file.
59
+ * @param string $commentId The ID of the comment.
60
+ * @param array $optParams Optional parameters.
61
+ *
62
+ * @opt_param bool includeDeleted Whether to return deleted comments. Deleted
63
+ * comments will not include their original content.
64
+ * @return Google_Service_Drive_Comment
65
+ */
66
+ public function get($fileId, $commentId, $optParams = array())
67
+ {
68
+ $params = array('fileId' => $fileId, 'commentId' => $commentId);
69
+ $params = array_merge($params, $optParams);
70
+ return $this->call('get', array($params), "Google_Service_Drive_Comment");
71
+ }
72
+ /**
73
+ * Lists a file's comments. (comments.listComments)
74
+ *
75
+ * @param string $fileId The ID of the file.
76
+ * @param array $optParams Optional parameters.
77
+ *
78
+ * @opt_param bool includeDeleted Whether to include deleted comments. Deleted
79
+ * comments will not include their original content.
80
+ * @opt_param int pageSize The maximum number of comments to return per page.
81
+ * @opt_param string pageToken The token for continuing a previous list request
82
+ * on the next page. This should be set to the value of 'nextPageToken' from the
83
+ * previous response.
84
+ * @opt_param string startModifiedTime The minimum value of 'modifiedTime' for
85
+ * the result comments (RFC 3339 date-time).
86
+ * @return Google_Service_Drive_CommentList
87
+ */
88
+ public function listComments($fileId, $optParams = array())
89
+ {
90
+ $params = array('fileId' => $fileId);
91
+ $params = array_merge($params, $optParams);
92
+ return $this->call('list', array($params), "Google_Service_Drive_CommentList");
93
+ }
94
+ /**
95
+ * Updates a comment with patch semantics. (comments.update)
96
+ *
97
+ * @param string $fileId The ID of the file.
98
+ * @param string $commentId The ID of the comment.
99
+ * @param Google_Service_Drive_Comment $postBody
100
+ * @param array $optParams Optional parameters.
101
+ * @return Google_Service_Drive_Comment
102
+ */
103
+ public function update($fileId, $commentId, Google_Service_Drive_Comment $postBody, $optParams = array())
104
+ {
105
+ $params = array('fileId' => $fileId, 'commentId' => $commentId, 'postBody' => $postBody);
106
+ $params = array_merge($params, $optParams);
107
+ return $this->call('update', array($params), "Google_Service_Drive_Comment");
108
+ }
109
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Files.php ADDED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ /**
19
+ * The "files" collection of methods.
20
+ * Typical usage is:
21
+ * <code>
22
+ * $driveService = new Google_Service_Drive(...);
23
+ * $files = $driveService->files;
24
+ * </code>
25
+ */
26
+ class Google_Service_Drive_Resource_Files extends Google_Service_Resource
27
+ {
28
+ /**
29
+ * Creates a copy of a file and applies any requested updates with patch
30
+ * semantics. (files.copy)
31
+ *
32
+ * @param string $fileId The ID of the file.
33
+ * @param Google_Service_Drive_DriveFile $postBody
34
+ * @param array $optParams Optional parameters.
35
+ *
36
+ * @opt_param bool ignoreDefaultVisibility Whether to ignore the domain's
37
+ * default visibility settings for the created file. Domain administrators can
38
+ * choose to make all uploaded files visible to the domain by default; this
39
+ * parameter bypasses that behavior for the request. Permissions are still
40
+ * inherited from parent folders.
41
+ * @opt_param bool keepRevisionForever Whether to set the 'keepForever' field in
42
+ * the new head revision. This is only applicable to files with binary content
43
+ * in Drive.
44
+ * @opt_param string ocrLanguage A language hint for OCR processing during image
45
+ * import (ISO 639-1 code).
46
+ * @opt_param bool supportsTeamDrives Whether the requesting application
47
+ * supports Team Drives.
48
+ * @return Google_Service_Drive_DriveFile
49
+ */
50
+ public function copy($fileId, Google_Service_Drive_DriveFile $postBody, $optParams = array())
51
+ {
52
+ $params = array('fileId' => $fileId, 'postBody' => $postBody);
53
+ $params = array_merge($params, $optParams);
54
+ return $this->call('copy', array($params), "Google_Service_Drive_DriveFile");
55
+ }
56
+ /**
57
+ * Creates a new file. (files.create)
58
+ *
59
+ * @param Google_Service_Drive_DriveFile $postBody
60
+ * @param array $optParams Optional parameters.
61
+ *
62
+ * @opt_param bool ignoreDefaultVisibility Whether to ignore the domain's
63
+ * default visibility settings for the created file. Domain administrators can
64
+ * choose to make all uploaded files visible to the domain by default; this
65
+ * parameter bypasses that behavior for the request. Permissions are still
66
+ * inherited from parent folders.
67
+ * @opt_param bool keepRevisionForever Whether to set the 'keepForever' field in
68
+ * the new head revision. This is only applicable to files with binary content
69
+ * in Drive.
70
+ * @opt_param string ocrLanguage A language hint for OCR processing during image
71
+ * import (ISO 639-1 code).
72
+ * @opt_param bool supportsTeamDrives Whether the requesting application
73
+ * supports Team Drives.
74
+ * @opt_param bool useContentAsIndexableText Whether to use the uploaded content
75
+ * as indexable text.
76
+ * @return Google_Service_Drive_DriveFile
77
+ */
78
+ public function create(Google_Service_Drive_DriveFile $postBody, $optParams = array())
79
+ {
80
+ $params = array('postBody' => $postBody);
81
+ $params = array_merge($params, $optParams);
82
+ return $this->call('create', array($params), "Google_Service_Drive_DriveFile");
83
+ }
84
+ /**
85
+ * Permanently deletes a file owned by the user without moving it to the trash.
86
+ * If the file belongs to a Team Drive the user must be an organizer on the
87
+ * parent. If the target is a folder, all descendants owned by the user are also
88
+ * deleted. (files.delete)
89
+ *
90
+ * @param string $fileId The ID of the file.
91
+ * @param array $optParams Optional parameters.
92
+ *
93
+ * @opt_param bool supportsTeamDrives Whether the requesting application
94
+ * supports Team Drives.
95
+ */
96
+ public function delete($fileId, $optParams = array())
97
+ {
98
+ $params = array('fileId' => $fileId);
99
+ $params = array_merge($params, $optParams);
100
+ return $this->call('delete', array($params));
101
+ }
102
+ /**
103
+ * Permanently deletes all of the user's trashed files. (files.emptyTrash)
104
+ *
105
+ * @param array $optParams Optional parameters.
106
+ */
107
+ public function emptyTrash($optParams = array())
108
+ {
109
+ $params = array();
110
+ $params = array_merge($params, $optParams);
111
+ return $this->call('emptyTrash', array($params));
112
+ }
113
+ /**
114
+ * Exports a Google Doc to the requested MIME type and returns the exported
115
+ * content. Please note that the exported content is limited to 10MB.
116
+ * (files.export)
117
+ *
118
+ * @param string $fileId The ID of the file.
119
+ * @param string $mimeType The MIME type of the format requested for this
120
+ * export.
121
+ * @param array $optParams Optional parameters.
122
+ */
123
+ public function export($fileId, $mimeType, $optParams = array())
124
+ {
125
+ $params = array('fileId' => $fileId, 'mimeType' => $mimeType);
126
+ $params = array_merge($params, $optParams);
127
+ return $this->call('export', array($params));
128
+ }
129
+ /**
130
+ * Generates a set of file IDs which can be provided in create requests.
131
+ * (files.generateIds)
132
+ *
133
+ * @param array $optParams Optional parameters.
134
+ *
135
+ * @opt_param int count The number of IDs to return.
136
+ * @opt_param string space The space in which the IDs can be used to create new
137
+ * files. Supported values are 'drive' and 'appDataFolder'.
138
+ * @return Google_Service_Drive_GeneratedIds
139
+ */
140
+ public function generateIds($optParams = array())
141
+ {
142
+ $params = array();
143
+ $params = array_merge($params, $optParams);
144
+ return $this->call('generateIds', array($params), "Google_Service_Drive_GeneratedIds");
145
+ }
146
+ /**
147
+ * Gets a file's metadata or content by ID. (files.get)
148
+ *
149
+ * @param string $fileId The ID of the file.
150
+ * @param array $optParams Optional parameters.
151
+ *
152
+ * @opt_param bool acknowledgeAbuse Whether the user is acknowledging the risk
153
+ * of downloading known malware or other abusive files. This is only applicable
154
+ * when alt=media.
155
+ * @opt_param bool supportsTeamDrives Whether the requesting application
156
+ * supports Team Drives.
157
+ * @return Google_Service_Drive_DriveFile
158
+ */
159
+ public function get($fileId, $optParams = array())
160
+ {
161
+ $params = array('fileId' => $fileId);
162
+ $params = array_merge($params, $optParams);
163
+ return $this->call('get', array($params), "Google_Service_Drive_DriveFile");
164
+ }
165
+ /**
166
+ * Lists or searches files. (files.listFiles)
167
+ *
168
+ * @param array $optParams Optional parameters.
169
+ *
170
+ * @opt_param string corpora Comma-separated list of bodies of items
171
+ * (files/documents) to which the query applies. Supported bodies are 'user',
172
+ * 'domain', 'teamDrive' and 'allTeamDrives'. 'allTeamDrives' must be combined
173
+ * with 'user'; all other values must be used in isolation. Prefer 'user' or
174
+ * 'teamDrive' to 'allTeamDrives' for efficiency.
175
+ * @opt_param string corpus The source of files to list. Deprecated: use
176
+ * 'corpora' instead.
177
+ * @opt_param bool includeTeamDriveItems Whether Team Drive items should be
178
+ * included in results.
179
+ * @opt_param string orderBy A comma-separated list of sort keys. Valid keys are
180
+ * 'createdTime', 'folder', 'modifiedByMeTime', 'modifiedTime', 'name',
181
+ * 'name_natural', 'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred',
182
+ * and 'viewedByMeTime'. Each key sorts ascending by default, but may be
183
+ * reversed with the 'desc' modifier. Example usage:
184
+ * ?orderBy=folder,modifiedTime desc,name. Please note that there is a current
185
+ * limitation for users with approximately one million files in which the
186
+ * requested sort order is ignored.
187
+ * @opt_param int pageSize The maximum number of files to return per page.
188
+ * Partial or empty result pages are possible even before the end of the files
189
+ * list has been reached.
190
+ * @opt_param string pageToken The token for continuing a previous list request
191
+ * on the next page. This should be set to the value of 'nextPageToken' from the
192
+ * previous response.
193
+ * @opt_param string q A query for filtering the file results. See the "Search
194
+ * for Files" guide for supported syntax.
195
+ * @opt_param string spaces A comma-separated list of spaces to query within the
196
+ * corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.
197
+ * @opt_param bool supportsTeamDrives Whether the requesting application
198
+ * supports Team Drives.
199
+ * @opt_param string teamDriveId ID of Team Drive to search.
200
+ * @return Google_Service_Drive_FileList
201
+ */
202
+ public function listFiles($optParams = array())
203
+ {
204
+ $params = array();
205
+ $params = array_merge($params, $optParams);
206
+ return $this->call('list', array($params), "Google_Service_Drive_FileList");
207
+ }
208
+ /**
209
+ * Updates a file's metadata and/or content with patch semantics. (files.update)
210
+ *
211
+ * @param string $fileId The ID of the file.
212
+ * @param Google_Service_Drive_DriveFile $postBody
213
+ * @param array $optParams Optional parameters.
214
+ *
215
+ * @opt_param string addParents A comma-separated list of parent IDs to add.
216
+ * @opt_param bool keepRevisionForever Whether to set the 'keepForever' field in
217
+ * the new head revision. This is only applicable to files with binary content
218
+ * in Drive.
219
+ * @opt_param string ocrLanguage A language hint for OCR processing during image
220
+ * import (ISO 639-1 code).
221
+ * @opt_param string removeParents A comma-separated list of parent IDs to
222
+ * remove.
223
+ * @opt_param bool supportsTeamDrives Whether the requesting application
224
+ * supports Team Drives.
225
+ * @opt_param bool useContentAsIndexableText Whether to use the uploaded content
226
+ * as indexable text.
227
+ * @return Google_Service_Drive_DriveFile
228
+ */
229
+ public function update($fileId, Google_Service_Drive_DriveFile $postBody, $optParams = array())
230
+ {
231
+ $params = array('fileId' => $fileId, 'postBody' => $postBody);
232
+ $params = array_merge($params, $optParams);
233
+ return $this->call('update', array($params), "Google_Service_Drive_DriveFile");
234
+ }
235
+ /**
236
+ * Subscribes to changes to a file (files.watch)
237
+ *
238
+ * @param string $fileId The ID of the file.
239
+ * @param Google_Service_Drive_Channel $postBody
240
+ * @param array $optParams Optional parameters.
241
+ *
242
+ * @opt_param bool acknowledgeAbuse Whether the user is acknowledging the risk
243
+ * of downloading known malware or other abusive files. This is only applicable
244
+ * when alt=media.
245
+ * @opt_param bool supportsTeamDrives Whether the requesting application
246
+ * supports Team Drives.
247
+ * @return Google_Service_Drive_Channel
248
+ */
249
+ public function watch($fileId, Google_Service_Drive_Channel $postBody, $optParams = array())
250
+ {
251
+ $params = array('fileId' => $fileId, 'postBody' => $postBody);
252
+ $params = array_merge($params, $optParams);
253
+ return $this->call('watch', array($params), "Google_Service_Drive_Channel");
254
+ }
255
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Permissions.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ /**
19
+ * The "permissions" collection of methods.
20
+ * Typical usage is:
21
+ * <code>
22
+ * $driveService = new Google_Service_Drive(...);
23
+ * $permissions = $driveService->permissions;
24
+ * </code>
25
+ */
26
+ class Google_Service_Drive_Resource_Permissions extends Google_Service_Resource
27
+ {
28
+ /**
29
+ * Creates a permission for a file or Team Drive. (permissions.create)
30
+ *
31
+ * @param string $fileId The ID of the file or Team Drive.
32
+ * @param Google_Service_Drive_Permission $postBody
33
+ * @param array $optParams Optional parameters.
34
+ *
35
+ * @opt_param string emailMessage A plain text custom message to include in the
36
+ * notification email.
37
+ * @opt_param bool sendNotificationEmail Whether to send a notification email
38
+ * when sharing to users or groups. This defaults to true for users and groups,
39
+ * and is not allowed for other requests. It must not be disabled for ownership
40
+ * transfers.
41
+ * @opt_param bool supportsTeamDrives Whether the requesting application
42
+ * supports Team Drives.
43
+ * @opt_param bool transferOwnership Whether to transfer ownership to the
44
+ * specified user and downgrade the current owner to a writer. This parameter is
45
+ * required as an acknowledgement of the side effect.
46
+ * @opt_param bool useDomainAdminAccess Issue the request as a domain
47
+ * administrator; if set to true, then the requester will be granted access if
48
+ * they are an administrator of the domain to which the item belongs.
49
+ * @return Google_Service_Drive_Permission
50
+ */
51
+ public function create($fileId, Google_Service_Drive_Permission $postBody, $optParams = array())
52
+ {
53
+ $params = array('fileId' => $fileId, 'postBody' => $postBody);
54
+ $params = array_merge($params, $optParams);
55
+ return $this->call('create', array($params), "Google_Service_Drive_Permission");
56
+ }
57
+ /**
58
+ * Deletes a permission. (permissions.delete)
59
+ *
60
+ * @param string $fileId The ID of the file or Team Drive.
61
+ * @param string $permissionId The ID of the permission.
62
+ * @param array $optParams Optional parameters.
63
+ *
64
+ * @opt_param bool supportsTeamDrives Whether the requesting application
65
+ * supports Team Drives.
66
+ * @opt_param bool useDomainAdminAccess Issue the request as a domain
67
+ * administrator; if set to true, then the requester will be granted access if
68
+ * they are an administrator of the domain to which the item belongs.
69
+ */
70
+ public function delete($fileId, $permissionId, $optParams = array())
71
+ {
72
+ $params = array('fileId' => $fileId, 'permissionId' => $permissionId);
73
+ $params = array_merge($params, $optParams);
74
+ return $this->call('delete', array($params));
75
+ }
76
+ /**
77
+ * Gets a permission by ID. (permissions.get)
78
+ *
79
+ * @param string $fileId The ID of the file.
80
+ * @param string $permissionId The ID of the permission.
81
+ * @param array $optParams Optional parameters.
82
+ *
83
+ * @opt_param bool supportsTeamDrives Whether the requesting application
84
+ * supports Team Drives.
85
+ * @opt_param bool useDomainAdminAccess Issue the request as a domain
86
+ * administrator; if set to true, then the requester will be granted access if
87
+ * they are an administrator of the domain to which the item belongs.
88
+ * @return Google_Service_Drive_Permission
89
+ */
90
+ public function get($fileId, $permissionId, $optParams = array())
91
+ {
92
+ $params = array('fileId' => $fileId, 'permissionId' => $permissionId);
93
+ $params = array_merge($params, $optParams);
94
+ return $this->call('get', array($params), "Google_Service_Drive_Permission");
95
+ }
96
+ /**
97
+ * Lists a file's or Team Drive's permissions. (permissions.listPermissions)
98
+ *
99
+ * @param string $fileId The ID of the file or Team Drive.
100
+ * @param array $optParams Optional parameters.
101
+ *
102
+ * @opt_param int pageSize The maximum number of permissions to return per page.
103
+ * When not set for files in a Team Drive, at most 100 results will be returned.
104
+ * When not set for files that are not in a Team Drive, the entire list will be
105
+ * returned.
106
+ * @opt_param string pageToken The token for continuing a previous list request
107
+ * on the next page. This should be set to the value of 'nextPageToken' from the
108
+ * previous response.
109
+ * @opt_param bool supportsTeamDrives Whether the requesting application
110
+ * supports Team Drives.
111
+ * @opt_param bool useDomainAdminAccess Issue the request as a domain
112
+ * administrator; if set to true, then the requester will be granted access if
113
+ * they are an administrator of the domain to which the item belongs.
114
+ * @return Google_Service_Drive_PermissionList
115
+ */
116
+ public function listPermissions($fileId, $optParams = array())
117
+ {
118
+ $params = array('fileId' => $fileId);
119
+ $params = array_merge($params, $optParams);
120
+ return $this->call('list', array($params), "Google_Service_Drive_PermissionList");
121
+ }
122
+ /**
123
+ * Updates a permission with patch semantics. (permissions.update)
124
+ *
125
+ * @param string $fileId The ID of the file or Team Drive.
126
+ * @param string $permissionId The ID of the permission.
127
+ * @param Google_Service_Drive_Permission $postBody
128
+ * @param array $optParams Optional parameters.
129
+ *
130
+ * @opt_param bool removeExpiration Whether to remove the expiration date.
131
+ * @opt_param bool supportsTeamDrives Whether the requesting application
132
+ * supports Team Drives.
133
+ * @opt_param bool transferOwnership Whether to transfer ownership to the
134
+ * specified user and downgrade the current owner to a writer. This parameter is
135
+ * required as an acknowledgement of the side effect.
136
+ * @opt_param bool useDomainAdminAccess Issue the request as a domain
137
+ * administrator; if set to true, then the requester will be granted access if
138
+ * they are an administrator of the domain to which the item belongs.
139
+ * @return Google_Service_Drive_Permission
140
+ */
141
+ public function update($fileId, $permissionId, Google_Service_Drive_Permission $postBody, $optParams = array())
142
+ {
143
+ $params = array('fileId' => $fileId, 'permissionId' => $permissionId, 'postBody' => $postBody);
144
+ $params = array_merge($params, $optParams);
145
+ return $this->call('update', array($params), "Google_Service_Drive_Permission");
146
+ }
147
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Replies.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ /**
19
+ * The "replies" collection of methods.
20
+ * Typical usage is:
21
+ * <code>
22
+ * $driveService = new Google_Service_Drive(...);
23
+ * $replies = $driveService->replies;
24
+ * </code>
25
+ */
26
+ class Google_Service_Drive_Resource_Replies extends Google_Service_Resource
27
+ {
28
+ /**
29
+ * Creates a new reply to a comment. (replies.create)
30
+ *
31
+ * @param string $fileId The ID of the file.
32
+ * @param string $commentId The ID of the comment.
33
+ * @param Google_Service_Drive_Reply $postBody
34
+ * @param array $optParams Optional parameters.
35
+ * @return Google_Service_Drive_Reply
36
+ */
37
+ public function create($fileId, $commentId, Google_Service_Drive_Reply $postBody, $optParams = array())
38
+ {
39
+ $params = array('fileId' => $fileId, 'commentId' => $commentId, 'postBody' => $postBody);
40
+ $params = array_merge($params, $optParams);
41
+ return $this->call('create', array($params), "Google_Service_Drive_Reply");
42
+ }
43
+ /**
44
+ * Deletes a reply. (replies.delete)
45
+ *
46
+ * @param string $fileId The ID of the file.
47
+ * @param string $commentId The ID of the comment.
48
+ * @param string $replyId The ID of the reply.
49
+ * @param array $optParams Optional parameters.
50
+ */
51
+ public function delete($fileId, $commentId, $replyId, $optParams = array())
52
+ {
53
+ $params = array('fileId' => $fileId, 'commentId' => $commentId, 'replyId' => $replyId);
54
+ $params = array_merge($params, $optParams);
55
+ return $this->call('delete', array($params));
56
+ }
57
+ /**
58
+ * Gets a reply by ID. (replies.get)
59
+ *
60
+ * @param string $fileId The ID of the file.
61
+ * @param string $commentId The ID of the comment.
62
+ * @param string $replyId The ID of the reply.
63
+ * @param array $optParams Optional parameters.
64
+ *
65
+ * @opt_param bool includeDeleted Whether to return deleted replies. Deleted
66
+ * replies will not include their original content.
67
+ * @return Google_Service_Drive_Reply
68
+ */
69
+ public function get($fileId, $commentId, $replyId, $optParams = array())
70
+ {
71
+ $params = array('fileId' => $fileId, 'commentId' => $commentId, 'replyId' => $replyId);
72
+ $params = array_merge($params, $optParams);
73
+ return $this->call('get', array($params), "Google_Service_Drive_Reply");
74
+ }
75
+ /**
76
+ * Lists a comment's replies. (replies.listReplies)
77
+ *
78
+ * @param string $fileId The ID of the file.
79
+ * @param string $commentId The ID of the comment.
80
+ * @param array $optParams Optional parameters.
81
+ *
82
+ * @opt_param bool includeDeleted Whether to include deleted replies. Deleted
83
+ * replies will not include their original content.
84
+ * @opt_param int pageSize The maximum number of replies to return per page.
85
+ * @opt_param string pageToken The token for continuing a previous list request
86
+ * on the next page. This should be set to the value of 'nextPageToken' from the
87
+ * previous response.
88
+ * @return Google_Service_Drive_ReplyList
89
+ */
90
+ public function listReplies($fileId, $commentId, $optParams = array())
91
+ {
92
+ $params = array('fileId' => $fileId, 'commentId' => $commentId);
93
+ $params = array_merge($params, $optParams);
94
+ return $this->call('list', array($params), "Google_Service_Drive_ReplyList");
95
+ }
96
+ /**
97
+ * Updates a reply with patch semantics. (replies.update)
98
+ *
99
+ * @param string $fileId The ID of the file.
100
+ * @param string $commentId The ID of the comment.
101
+ * @param string $replyId The ID of the reply.
102
+ * @param Google_Service_Drive_Reply $postBody
103
+ * @param array $optParams Optional parameters.
104
+ * @return Google_Service_Drive_Reply
105
+ */
106
+ public function update($fileId, $commentId, $replyId, Google_Service_Drive_Reply $postBody, $optParams = array())
107
+ {
108
+ $params = array('fileId' => $fileId, 'commentId' => $commentId, 'replyId' => $replyId, 'postBody' => $postBody);
109
+ $params = array_merge($params, $optParams);
110
+ return $this->call('update', array($params), "Google_Service_Drive_Reply");
111
+ }
112
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Revisions.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ /**
19
+ * The "revisions" collection of methods.
20
+ * Typical usage is:
21
+ * <code>
22
+ * $driveService = new Google_Service_Drive(...);
23
+ * $revisions = $driveService->revisions;
24
+ * </code>
25
+ */
26
+ class Google_Service_Drive_Resource_Revisions extends Google_Service_Resource
27
+ {
28
+ /**
29
+ * Permanently deletes a revision. This method is only applicable to files with
30
+ * binary content in Drive. (revisions.delete)
31
+ *
32
+ * @param string $fileId The ID of the file.
33
+ * @param string $revisionId The ID of the revision.
34
+ * @param array $optParams Optional parameters.
35
+ */
36
+ public function delete($fileId, $revisionId, $optParams = array())
37
+ {
38
+ $params = array('fileId' => $fileId, 'revisionId' => $revisionId);
39
+ $params = array_merge($params, $optParams);
40
+ return $this->call('delete', array($params));
41
+ }
42
+ /**
43
+ * Gets a revision's metadata or content by ID. (revisions.get)
44
+ *
45
+ * @param string $fileId The ID of the file.
46
+ * @param string $revisionId The ID of the revision.
47
+ * @param array $optParams Optional parameters.
48
+ *
49
+ * @opt_param bool acknowledgeAbuse Whether the user is acknowledging the risk
50
+ * of downloading known malware or other abusive files. This is only applicable
51
+ * when alt=media.
52
+ * @return Google_Service_Drive_Revision
53
+ */
54
+ public function get($fileId, $revisionId, $optParams = array())
55
+ {
56
+ $params = array('fileId' => $fileId, 'revisionId' => $revisionId);
57
+ $params = array_merge($params, $optParams);
58
+ return $this->call('get', array($params), "Google_Service_Drive_Revision");
59
+ }
60
+ /**
61
+ * Lists a file's revisions. (revisions.listRevisions)
62
+ *
63
+ * @param string $fileId The ID of the file.
64
+ * @param array $optParams Optional parameters.
65
+ *
66
+ * @opt_param int pageSize The maximum number of revisions to return per page.
67
+ * @opt_param string pageToken The token for continuing a previous list request
68
+ * on the next page. This should be set to the value of 'nextPageToken' from the
69
+ * previous response.
70
+ * @return Google_Service_Drive_RevisionList
71
+ */
72
+ public function listRevisions($fileId, $optParams = array())
73
+ {
74
+ $params = array('fileId' => $fileId);
75
+ $params = array_merge($params, $optParams);
76
+ return $this->call('list', array($params), "Google_Service_Drive_RevisionList");
77
+ }
78
+ /**
79
+ * Updates a revision with patch semantics. (revisions.update)
80
+ *
81
+ * @param string $fileId The ID of the file.
82
+ * @param string $revisionId The ID of the revision.
83
+ * @param Google_Service_Drive_Revision $postBody
84
+ * @param array $optParams Optional parameters.
85
+ * @return Google_Service_Drive_Revision
86
+ */
87
+ public function update($fileId, $revisionId, Google_Service_Drive_Revision $postBody, $optParams = array())
88
+ {
89
+ $params = array('fileId' => $fileId, 'revisionId' => $revisionId, 'postBody' => $postBody);
90
+ $params = array_merge($params, $optParams);
91
+ return $this->call('update', array($params), "Google_Service_Drive_Revision");
92
+ }
93
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/Resource/Teamdrives.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ /**
19
+ * The "teamdrives" collection of methods.
20
+ * Typical usage is:
21
+ * <code>
22
+ * $driveService = new Google_Service_Drive(...);
23
+ * $teamdrives = $driveService->teamdrives;
24
+ * </code>
25
+ */
26
+ class Google_Service_Drive_Resource_Teamdrives extends Google_Service_Resource
27
+ {
28
+ /**
29
+ * Creates a new Team Drive. (teamdrives.create)
30
+ *
31
+ * @param string $requestId An ID, such as a random UUID, which uniquely
32
+ * identifies this user's request for idempotent creation of a Team Drive. A
33
+ * repeated request by the same user and with the same request ID will avoid
34
+ * creating duplicates by attempting to create the same Team Drive. If the Team
35
+ * Drive already exists a 409 error will be returned.
36
+ * @param Google_Service_Drive_TeamDrive $postBody
37
+ * @param array $optParams Optional parameters.
38
+ * @return Google_Service_Drive_TeamDrive
39
+ */
40
+ public function create($requestId, Google_Service_Drive_TeamDrive $postBody, $optParams = array())
41
+ {
42
+ $params = array('requestId' => $requestId, 'postBody' => $postBody);
43
+ $params = array_merge($params, $optParams);
44
+ return $this->call('create', array($params), "Google_Service_Drive_TeamDrive");
45
+ }
46
+ /**
47
+ * Permanently deletes a Team Drive for which the user is an organizer. The Team
48
+ * Drive cannot contain any untrashed items. (teamdrives.delete)
49
+ *
50
+ * @param string $teamDriveId The ID of the Team Drive
51
+ * @param array $optParams Optional parameters.
52
+ */
53
+ public function delete($teamDriveId, $optParams = array())
54
+ {
55
+ $params = array('teamDriveId' => $teamDriveId);
56
+ $params = array_merge($params, $optParams);
57
+ return $this->call('delete', array($params));
58
+ }
59
+ /**
60
+ * Gets a Team Drive's metadata by ID. (teamdrives.get)
61
+ *
62
+ * @param string $teamDriveId The ID of the Team Drive
63
+ * @param array $optParams Optional parameters.
64
+ *
65
+ * @opt_param bool useDomainAdminAccess Issue the request as a domain
66
+ * administrator; if set to true, then the requester will be granted access if
67
+ * they are an administrator of the domain to which the Team Drive belongs.
68
+ * @return Google_Service_Drive_TeamDrive
69
+ */
70
+ public function get($teamDriveId, $optParams = array())
71
+ {
72
+ $params = array('teamDriveId' => $teamDriveId);
73
+ $params = array_merge($params, $optParams);
74
+ return $this->call('get', array($params), "Google_Service_Drive_TeamDrive");
75
+ }
76
+ /**
77
+ * Lists the user's Team Drives. (teamdrives.listTeamdrives)
78
+ *
79
+ * @param array $optParams Optional parameters.
80
+ *
81
+ * @opt_param int pageSize Maximum number of Team Drives to return.
82
+ * @opt_param string pageToken Page token for Team Drives.
83
+ * @opt_param string q Query string for searching Team Drives.
84
+ * @opt_param bool useDomainAdminAccess Issue the request as a domain
85
+ * administrator; if set to true, then all Team Drives of the domain in which
86
+ * the requester is an administrator are returned.
87
+ * @return Google_Service_Drive_TeamDriveList
88
+ */
89
+ public function listTeamdrives($optParams = array())
90
+ {
91
+ $params = array();
92
+ $params = array_merge($params, $optParams);
93
+ return $this->call('list', array($params), "Google_Service_Drive_TeamDriveList");
94
+ }
95
+ /**
96
+ * Updates a Team Drive's metadata (teamdrives.update)
97
+ *
98
+ * @param string $teamDriveId The ID of the Team Drive
99
+ * @param Google_Service_Drive_TeamDrive $postBody
100
+ * @param array $optParams Optional parameters.
101
+ *
102
+ * @opt_param bool useDomainAdminAccess Issue the request as a domain
103
+ * administrator; if set to true, then the requester will be granted access if
104
+ * they are an administrator of the domain to which the Team Drive belongs.
105
+ * @return Google_Service_Drive_TeamDrive
106
+ */
107
+ public function update($teamDriveId, Google_Service_Drive_TeamDrive $postBody, $optParams = array())
108
+ {
109
+ $params = array('teamDriveId' => $teamDriveId, 'postBody' => $postBody);
110
+ $params = array_merge($params, $optParams);
111
+ return $this->call('update', array($params), "Google_Service_Drive_TeamDrive");
112
+ }
113
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/Revision.php ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_Revision extends Google_Model
19
+ {
20
+ public $exportLinks;
21
+ public $id;
22
+ public $keepForever;
23
+ public $kind;
24
+ protected $lastModifyingUserType = 'Google_Service_Drive_User';
25
+ protected $lastModifyingUserDataType = '';
26
+ public $md5Checksum;
27
+ public $mimeType;
28
+ public $modifiedTime;
29
+ public $originalFilename;
30
+ public $publishAuto;
31
+ public $published;
32
+ public $publishedOutsideDomain;
33
+ public $size;
34
+
35
+ public function setExportLinks($exportLinks)
36
+ {
37
+ $this->exportLinks = $exportLinks;
38
+ }
39
+ public function getExportLinks()
40
+ {
41
+ return $this->exportLinks;
42
+ }
43
+ public function setId($id)
44
+ {
45
+ $this->id = $id;
46
+ }
47
+ public function getId()
48
+ {
49
+ return $this->id;
50
+ }
51
+ public function setKeepForever($keepForever)
52
+ {
53
+ $this->keepForever = $keepForever;
54
+ }
55
+ public function getKeepForever()
56
+ {
57
+ return $this->keepForever;
58
+ }
59
+ public function setKind($kind)
60
+ {
61
+ $this->kind = $kind;
62
+ }
63
+ public function getKind()
64
+ {
65
+ return $this->kind;
66
+ }
67
+ /**
68
+ * @param Google_Service_Drive_User
69
+ */
70
+ public function setLastModifyingUser(Google_Service_Drive_User $lastModifyingUser)
71
+ {
72
+ $this->lastModifyingUser = $lastModifyingUser;
73
+ }
74
+ /**
75
+ * @return Google_Service_Drive_User
76
+ */
77
+ public function getLastModifyingUser()
78
+ {
79
+ return $this->lastModifyingUser;
80
+ }
81
+ public function setMd5Checksum($md5Checksum)
82
+ {
83
+ $this->md5Checksum = $md5Checksum;
84
+ }
85
+ public function getMd5Checksum()
86
+ {
87
+ return $this->md5Checksum;
88
+ }
89
+ public function setMimeType($mimeType)
90
+ {
91
+ $this->mimeType = $mimeType;
92
+ }
93
+ public function getMimeType()
94
+ {
95
+ return $this->mimeType;
96
+ }
97
+ public function setModifiedTime($modifiedTime)
98
+ {
99
+ $this->modifiedTime = $modifiedTime;
100
+ }
101
+ public function getModifiedTime()
102
+ {
103
+ return $this->modifiedTime;
104
+ }
105
+ public function setOriginalFilename($originalFilename)
106
+ {
107
+ $this->originalFilename = $originalFilename;
108
+ }
109
+ public function getOriginalFilename()
110
+ {
111
+ return $this->originalFilename;
112
+ }
113
+ public function setPublishAuto($publishAuto)
114
+ {
115
+ $this->publishAuto = $publishAuto;
116
+ }
117
+ public function getPublishAuto()
118
+ {
119
+ return $this->publishAuto;
120
+ }
121
+ public function setPublished($published)
122
+ {
123
+ $this->published = $published;
124
+ }
125
+ public function getPublished()
126
+ {
127
+ return $this->published;
128
+ }
129
+ public function setPublishedOutsideDomain($publishedOutsideDomain)
130
+ {
131
+ $this->publishedOutsideDomain = $publishedOutsideDomain;
132
+ }
133
+ public function getPublishedOutsideDomain()
134
+ {
135
+ return $this->publishedOutsideDomain;
136
+ }
137
+ public function setSize($size)
138
+ {
139
+ $this->size = $size;
140
+ }
141
+ public function getSize()
142
+ {
143
+ return $this->size;
144
+ }
145
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/RevisionList.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_RevisionList extends Google_Collection
19
+ {
20
+ protected $collection_key = 'revisions';
21
+ public $kind;
22
+ public $nextPageToken;
23
+ protected $revisionsType = 'Google_Service_Drive_Revision';
24
+ protected $revisionsDataType = 'array';
25
+
26
+ public function setKind($kind)
27
+ {
28
+ $this->kind = $kind;
29
+ }
30
+ public function getKind()
31
+ {
32
+ return $this->kind;
33
+ }
34
+ public function setNextPageToken($nextPageToken)
35
+ {
36
+ $this->nextPageToken = $nextPageToken;
37
+ }
38
+ public function getNextPageToken()
39
+ {
40
+ return $this->nextPageToken;
41
+ }
42
+ /**
43
+ * @param Google_Service_Drive_Revision
44
+ */
45
+ public function setRevisions($revisions)
46
+ {
47
+ $this->revisions = $revisions;
48
+ }
49
+ /**
50
+ * @return Google_Service_Drive_Revision
51
+ */
52
+ public function getRevisions()
53
+ {
54
+ return $this->revisions;
55
+ }
56
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/StartPageToken.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_StartPageToken extends Google_Model
19
+ {
20
+ public $kind;
21
+ public $startPageToken;
22
+
23
+ public function setKind($kind)
24
+ {
25
+ $this->kind = $kind;
26
+ }
27
+ public function getKind()
28
+ {
29
+ return $this->kind;
30
+ }
31
+ public function setStartPageToken($startPageToken)
32
+ {
33
+ $this->startPageToken = $startPageToken;
34
+ }
35
+ public function getStartPageToken()
36
+ {
37
+ return $this->startPageToken;
38
+ }
39
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/TeamDrive.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_TeamDrive extends Google_Model
19
+ {
20
+ protected $backgroundImageFileType = 'Google_Service_Drive_TeamDriveBackgroundImageFile';
21
+ protected $backgroundImageFileDataType = '';
22
+ public $backgroundImageLink;
23
+ protected $capabilitiesType = 'Google_Service_Drive_TeamDriveCapabilities';
24
+ protected $capabilitiesDataType = '';
25
+ public $colorRgb;
26
+ public $createdTime;
27
+ public $id;
28
+ public $kind;
29
+ public $name;
30
+ protected $restrictionsType = 'Google_Service_Drive_TeamDriveRestrictions';
31
+ protected $restrictionsDataType = '';
32
+ public $themeId;
33
+
34
+ /**
35
+ * @param Google_Service_Drive_TeamDriveBackgroundImageFile
36
+ */
37
+ public function setBackgroundImageFile(Google_Service_Drive_TeamDriveBackgroundImageFile $backgroundImageFile)
38
+ {
39
+ $this->backgroundImageFile = $backgroundImageFile;
40
+ }
41
+ /**
42
+ * @return Google_Service_Drive_TeamDriveBackgroundImageFile
43
+ */
44
+ public function getBackgroundImageFile()
45
+ {
46
+ return $this->backgroundImageFile;
47
+ }
48
+ public function setBackgroundImageLink($backgroundImageLink)
49
+ {
50
+ $this->backgroundImageLink = $backgroundImageLink;
51
+ }
52
+ public function getBackgroundImageLink()
53
+ {
54
+ return $this->backgroundImageLink;
55
+ }
56
+ /**
57
+ * @param Google_Service_Drive_TeamDriveCapabilities
58
+ */
59
+ public function setCapabilities(Google_Service_Drive_TeamDriveCapabilities $capabilities)
60
+ {
61
+ $this->capabilities = $capabilities;
62
+ }
63
+ /**
64
+ * @return Google_Service_Drive_TeamDriveCapabilities
65
+ */
66
+ public function getCapabilities()
67
+ {
68
+ return $this->capabilities;
69
+ }
70
+ public function setColorRgb($colorRgb)
71
+ {
72
+ $this->colorRgb = $colorRgb;
73
+ }
74
+ public function getColorRgb()
75
+ {
76
+ return $this->colorRgb;
77
+ }
78
+ public function setCreatedTime($createdTime)
79
+ {
80
+ $this->createdTime = $createdTime;
81
+ }
82
+ public function getCreatedTime()
83
+ {
84
+ return $this->createdTime;
85
+ }
86
+ public function setId($id)
87
+ {
88
+ $this->id = $id;
89
+ }
90
+ public function getId()
91
+ {
92
+ return $this->id;
93
+ }
94
+ public function setKind($kind)
95
+ {
96
+ $this->kind = $kind;
97
+ }
98
+ public function getKind()
99
+ {
100
+ return $this->kind;
101
+ }
102
+ public function setName($name)
103
+ {
104
+ $this->name = $name;
105
+ }
106
+ public function getName()
107
+ {
108
+ return $this->name;
109
+ }
110
+ /**
111
+ * @param Google_Service_Drive_TeamDriveRestrictions
112
+ */
113
+ public function setRestrictions(Google_Service_Drive_TeamDriveRestrictions $restrictions)
114
+ {
115
+ $this->restrictions = $restrictions;
116
+ }
117
+ /**
118
+ * @return Google_Service_Drive_TeamDriveRestrictions
119
+ */
120
+ public function getRestrictions()
121
+ {
122
+ return $this->restrictions;
123
+ }
124
+ public function setThemeId($themeId)
125
+ {
126
+ $this->themeId = $themeId;
127
+ }
128
+ public function getThemeId()
129
+ {
130
+ return $this->themeId;
131
+ }
132
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/TeamDriveBackgroundImageFile.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_TeamDriveBackgroundImageFile extends Google_Model
19
+ {
20
+ public $id;
21
+ public $width;
22
+ public $xCoordinate;
23
+ public $yCoordinate;
24
+
25
+ public function setId($id)
26
+ {
27
+ $this->id = $id;
28
+ }
29
+ public function getId()
30
+ {
31
+ return $this->id;
32
+ }
33
+ public function setWidth($width)
34
+ {
35
+ $this->width = $width;
36
+ }
37
+ public function getWidth()
38
+ {
39
+ return $this->width;
40
+ }
41
+ public function setXCoordinate($xCoordinate)
42
+ {
43
+ $this->xCoordinate = $xCoordinate;
44
+ }
45
+ public function getXCoordinate()
46
+ {
47
+ return $this->xCoordinate;
48
+ }
49
+ public function setYCoordinate($yCoordinate)
50
+ {
51
+ $this->yCoordinate = $yCoordinate;
52
+ }
53
+ public function getYCoordinate()
54
+ {
55
+ return $this->yCoordinate;
56
+ }
57
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/TeamDriveCapabilities.php ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_TeamDriveCapabilities extends Google_Model
19
+ {
20
+ public $canAddChildren;
21
+ public $canChangeCopyRequiresWriterPermissionRestriction;
22
+ public $canChangeDomainUsersOnlyRestriction;
23
+ public $canChangeTeamDriveBackground;
24
+ public $canChangeTeamMembersOnlyRestriction;
25
+ public $canComment;
26
+ public $canCopy;
27
+ public $canDeleteChildren;
28
+ public $canDeleteTeamDrive;
29
+ public $canDownload;
30
+ public $canEdit;
31
+ public $canListChildren;
32
+ public $canManageMembers;
33
+ public $canReadRevisions;
34
+ public $canRemoveChildren;
35
+ public $canRename;
36
+ public $canRenameTeamDrive;
37
+ public $canShare;
38
+ public $canTrashChildren;
39
+
40
+ public function setCanAddChildren($canAddChildren)
41
+ {
42
+ $this->canAddChildren = $canAddChildren;
43
+ }
44
+ public function getCanAddChildren()
45
+ {
46
+ return $this->canAddChildren;
47
+ }
48
+ public function setCanChangeCopyRequiresWriterPermissionRestriction($canChangeCopyRequiresWriterPermissionRestriction)
49
+ {
50
+ $this->canChangeCopyRequiresWriterPermissionRestriction = $canChangeCopyRequiresWriterPermissionRestriction;
51
+ }
52
+ public function getCanChangeCopyRequiresWriterPermissionRestriction()
53
+ {
54
+ return $this->canChangeCopyRequiresWriterPermissionRestriction;
55
+ }
56
+ public function setCanChangeDomainUsersOnlyRestriction($canChangeDomainUsersOnlyRestriction)
57
+ {
58
+ $this->canChangeDomainUsersOnlyRestriction = $canChangeDomainUsersOnlyRestriction;
59
+ }
60
+ public function getCanChangeDomainUsersOnlyRestriction()
61
+ {
62
+ return $this->canChangeDomainUsersOnlyRestriction;
63
+ }
64
+ public function setCanChangeTeamDriveBackground($canChangeTeamDriveBackground)
65
+ {
66
+ $this->canChangeTeamDriveBackground = $canChangeTeamDriveBackground;
67
+ }
68
+ public function getCanChangeTeamDriveBackground()
69
+ {
70
+ return $this->canChangeTeamDriveBackground;
71
+ }
72
+ public function setCanChangeTeamMembersOnlyRestriction($canChangeTeamMembersOnlyRestriction)
73
+ {
74
+ $this->canChangeTeamMembersOnlyRestriction = $canChangeTeamMembersOnlyRestriction;
75
+ }
76
+ public function getCanChangeTeamMembersOnlyRestriction()
77
+ {
78
+ return $this->canChangeTeamMembersOnlyRestriction;
79
+ }
80
+ public function setCanComment($canComment)
81
+ {
82
+ $this->canComment = $canComment;
83
+ }
84
+ public function getCanComment()
85
+ {
86
+ return $this->canComment;
87
+ }
88
+ public function setCanCopy($canCopy)
89
+ {
90
+ $this->canCopy = $canCopy;
91
+ }
92
+ public function getCanCopy()
93
+ {
94
+ return $this->canCopy;
95
+ }
96
+ public function setCanDeleteChildren($canDeleteChildren)
97
+ {
98
+ $this->canDeleteChildren = $canDeleteChildren;
99
+ }
100
+ public function getCanDeleteChildren()
101
+ {
102
+ return $this->canDeleteChildren;
103
+ }
104
+ public function setCanDeleteTeamDrive($canDeleteTeamDrive)
105
+ {
106
+ $this->canDeleteTeamDrive = $canDeleteTeamDrive;
107
+ }
108
+ public function getCanDeleteTeamDrive()
109
+ {
110
+ return $this->canDeleteTeamDrive;
111
+ }
112
+ public function setCanDownload($canDownload)
113
+ {
114
+ $this->canDownload = $canDownload;
115
+ }
116
+ public function getCanDownload()
117
+ {
118
+ return $this->canDownload;
119
+ }
120
+ public function setCanEdit($canEdit)
121
+ {
122
+ $this->canEdit = $canEdit;
123
+ }
124
+ public function getCanEdit()
125
+ {
126
+ return $this->canEdit;
127
+ }
128
+ public function setCanListChildren($canListChildren)
129
+ {
130
+ $this->canListChildren = $canListChildren;
131
+ }
132
+ public function getCanListChildren()
133
+ {
134
+ return $this->canListChildren;
135
+ }
136
+ public function setCanManageMembers($canManageMembers)
137
+ {
138
+ $this->canManageMembers = $canManageMembers;
139
+ }
140
+ public function getCanManageMembers()
141
+ {
142
+ return $this->canManageMembers;
143
+ }
144
+ public function setCanReadRevisions($canReadRevisions)
145
+ {
146
+ $this->canReadRevisions = $canReadRevisions;
147
+ }
148
+ public function getCanReadRevisions()
149
+ {
150
+ return $this->canReadRevisions;
151
+ }
152
+ public function setCanRemoveChildren($canRemoveChildren)
153
+ {
154
+ $this->canRemoveChildren = $canRemoveChildren;
155
+ }
156
+ public function getCanRemoveChildren()
157
+ {
158
+ return $this->canRemoveChildren;
159
+ }
160
+ public function setCanRename($canRename)
161
+ {
162
+ $this->canRename = $canRename;
163
+ }
164
+ public function getCanRename()
165
+ {
166
+ return $this->canRename;
167
+ }
168
+ public function setCanRenameTeamDrive($canRenameTeamDrive)
169
+ {
170
+ $this->canRenameTeamDrive = $canRenameTeamDrive;
171
+ }
172
+ public function getCanRenameTeamDrive()
173
+ {
174
+ return $this->canRenameTeamDrive;
175
+ }
176
+ public function setCanShare($canShare)
177
+ {
178
+ $this->canShare = $canShare;
179
+ }
180
+ public function getCanShare()
181
+ {
182
+ return $this->canShare;
183
+ }
184
+ public function setCanTrashChildren($canTrashChildren)
185
+ {
186
+ $this->canTrashChildren = $canTrashChildren;
187
+ }
188
+ public function getCanTrashChildren()
189
+ {
190
+ return $this->canTrashChildren;
191
+ }
192
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/TeamDriveList.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_TeamDriveList extends Google_Collection
19
+ {
20
+ protected $collection_key = 'teamDrives';
21
+ public $kind;
22
+ public $nextPageToken;
23
+ protected $teamDrivesType = 'Google_Service_Drive_TeamDrive';
24
+ protected $teamDrivesDataType = 'array';
25
+
26
+ public function setKind($kind)
27
+ {
28
+ $this->kind = $kind;
29
+ }
30
+ public function getKind()
31
+ {
32
+ return $this->kind;
33
+ }
34
+ public function setNextPageToken($nextPageToken)
35
+ {
36
+ $this->nextPageToken = $nextPageToken;
37
+ }
38
+ public function getNextPageToken()
39
+ {
40
+ return $this->nextPageToken;
41
+ }
42
+ /**
43
+ * @param Google_Service_Drive_TeamDrive
44
+ */
45
+ public function setTeamDrives($teamDrives)
46
+ {
47
+ $this->teamDrives = $teamDrives;
48
+ }
49
+ /**
50
+ * @return Google_Service_Drive_TeamDrive
51
+ */
52
+ public function getTeamDrives()
53
+ {
54
+ return $this->teamDrives;
55
+ }
56
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/TeamDriveRestrictions.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_TeamDriveRestrictions extends Google_Model
19
+ {
20
+ public $adminManagedRestrictions;
21
+ public $copyRequiresWriterPermission;
22
+ public $domainUsersOnly;
23
+ public $teamMembersOnly;
24
+
25
+ public function setAdminManagedRestrictions($adminManagedRestrictions)
26
+ {
27
+ $this->adminManagedRestrictions = $adminManagedRestrictions;
28
+ }
29
+ public function getAdminManagedRestrictions()
30
+ {
31
+ return $this->adminManagedRestrictions;
32
+ }
33
+ public function setCopyRequiresWriterPermission($copyRequiresWriterPermission)
34
+ {
35
+ $this->copyRequiresWriterPermission = $copyRequiresWriterPermission;
36
+ }
37
+ public function getCopyRequiresWriterPermission()
38
+ {
39
+ return $this->copyRequiresWriterPermission;
40
+ }
41
+ public function setDomainUsersOnly($domainUsersOnly)
42
+ {
43
+ $this->domainUsersOnly = $domainUsersOnly;
44
+ }
45
+ public function getDomainUsersOnly()
46
+ {
47
+ return $this->domainUsersOnly;
48
+ }
49
+ public function setTeamMembersOnly($teamMembersOnly)
50
+ {
51
+ $this->teamMembersOnly = $teamMembersOnly;
52
+ }
53
+ public function getTeamMembersOnly()
54
+ {
55
+ return $this->teamMembersOnly;
56
+ }
57
+ }
vendor/google/apiclient-services/src/Google/Service/Drive/User.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
+ * use this file except in compliance with the License. You may obtain a copy of
7
+ * the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations under
15
+ * the License.
16
+ */
17
+
18
+ class Google_Service_Drive_User extends Google_Model
19
+ {
20
+ public $displayName;
21
+ public $emailAddress;
22
+ public $kind;
23
+ public $me;
24
+ public $permissionId;
25
+ public $photoLink;
26
+
27
+ public function setDisplayName($displayName)
28
+ {
29
+ $this->displayName = $displayName;
30
+ }
31
+ public function getDisplayName()
32
+ {
33
+ return $this->displayName;
34
+ }
35
+ public function setEmailAddress($emailAddress)
36
+ {
37
+ $this->emailAddress = $emailAddress;
38
+ }
39
+ public function getEmailAddress()
40
+ {
41
+ return $this->emailAddress;
42
+ }
43
+ public function setKind($kind)
44
+ {
45
+ $this->kind = $kind;
46
+ }
47
+ public function getKind()
48
+ {
49
+ return $this->kind;
50
+ }
51
+ public function setMe($me)
52
+ {
53
+ $this->me = $me;
54
+ }
55
+ public function getMe()
56
+ {
57
+ return $this->me;
58
+ }
59
+ public function setPermissionId($permissionId)
60
+ {
61
+ $this->permissionId = $permissionId;
62
+ }
63
+ public function getPermissionId()
64
+ {
65
+ return $this->permissionId;
66
+ }
67
+ public function setPhotoLink($photoLink)
68
+ {
69
+ $this->photoLink = $photoLink;
70
+ }
71
+ public function getPhotoLink()
72
+ {
73
+ return $this->photoLink;
74
+ }
75
+ }
vendor/google/auth/.editorconfig ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # EditorConfig is awesome: http://EditorConfig.org
2
+
3
+ # top-most EditorConfig file
4
+ root = true
5
+ charset = utf-8
6
+
7
+ # Get rid of whitespace to avoid diffs with a bunch of EOL changes
8
+ trim_trailing_whitespace = true
9
+
10
+ # Unix-style newlines with a newline ending every file
11
+ [*]
12
+ end_of_line = lf
13
+ insert_final_newline = true
14
+
15
+ # PHP-Files
16
+ [*.php]
17
+ indent_style = space
18
+ indent_size = 4
vendor/google/auth/.gitignore ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ *~
2
+ vendor
3
+ composer.lock
4
+
5
+ # IntelliJ
6
+ .idea
7
+ *.iml
vendor/google/auth/.php_cs ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file represents the configuration for Code Sniffing PSR-2-related
4
+ * automatic checks of coding guidelines
5
+ * Install @fabpot's great php-cs-fixer tool via
6
+ *
7
+ * $ composer global require fabpot/php-cs-fixer
8
+ *
9
+ * And then simply run
10
+ *
11
+ * $ php-cs-fixer fix --config-file .php_cs
12
+ *
13
+ * inside the root directory.
14
+ *
15
+ * http://www.php-fig.org/psr/psr-2/
16
+ * http://cs.sensiolabs.org
17
+ */
18
+
19
+ if (PHP_SAPI !== 'cli') {
20
+ die('This script supports command line usage only. Please check your command.');
21
+ }
22
+ // Define in which folders to search and which folders to exclude
23
+ // Exclude some directories that are excluded by Git anyways to speed up the sniffing
24
+ $finder = Symfony\CS\Finder\DefaultFinder::create()
25
+ ->exclude('vendor')
26
+ ->in(__DIR__);
27
+
28
+ // Return a Code Sniffing configuration using
29
+ // all sniffers needed for PSR-2
30
+ // and additionally:
31
+ // - Remove leading slashes in use clauses.
32
+ // - PHP single-line arrays should not have trailing comma.
33
+ // - Single-line whitespace before closing semicolon are prohibited.
34
+ // - Remove unused use statements in the PHP source code
35
+ // - Ensure Concatenation to have at least one whitespace around
36
+ // - Remove trailing whitespace at the end of blank lines.
37
+ return Symfony\CS\Config\Config::create()
38
+ ->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
39
+ ->fixers([
40
+ 'remove_leading_slash_use',
41
+ 'single_array_no_trailing_comma',
42
+ 'spaces_before_semicolon',
43
+ 'unused_use',
44
+ 'concat_with_spaces',
45
+ 'whitespacy_lines',
46
+ 'ordered_use',
47
+ 'single_quote',
48
+ 'duplicate_semicolon',
49
+ 'extra_empty_lines',
50
+ 'phpdoc_no_package',
51
+ 'phpdoc_scalar',
52
+ 'no_empty_lines_after_phpdocs'
53
+ ])
54
+ ->finder($finder);
vendor/google/auth/.travis.yml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ language: php
2
+
3
+ branches:
4
+ only: [master]
5
+
6
+ sudo: false
7
+
8
+ php:
9
+ - 5.4
10
+ - 5.5
11
+ - 5.6
12
+ - 7.0
13
+ - 7.1
14
+ - 7.2
15
+
16
+ env:
17
+ -
18
+ - COMPOSER_ARGS="--prefer-lowest"
19
+ matrix:
20
+ include:
21
+ - php: "7.2"
22
+ env: RUN_CS_FIXER=true
23
+
24
+ before_script:
25
+ - composer update $COMPOSER_ARGS
26
+
27
+ script:
28
+ - if [ "${RUN_CS_FIXER}" = "true" ]; then
29
+ vendor/bin/php-cs-fixer fix --dry-run --diff --config-file=.php_cs .;
30
+ else
31
+ vendor/bin/phpunit;
32
+ fi
vendor/google/auth/CHANGELOG.md ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## 1.4.0 (09/17/2018)
2
+
3
+ ### Changes
4
+
5
+ * Add support for insecure credentials (#208)
6
+
7
+ ## 1.3.3 (08/27/2018)
8
+
9
+ ### Changes
10
+
11
+ * Add retry and increase timeout for GCE credentials (#195)
12
+ * [Docs] Fix spelling (#204)
13
+ * Update token url (#206)
14
+
15
+ ## 1.3.2 (07/23/2018)
16
+
17
+ ### Changes
18
+
19
+ * Only emits a warning for gcloud credentials (#202)
20
+
21
+ ## 1.3.1 (07/19/2018)
22
+
23
+ ### Changes
24
+
25
+ * Added a warning for 3 legged OAuth credentials (#199)
26
+ * [Code cleanup] Removed useless else after return (#193)
27
+
28
+ ## 1.3.0 (06/04/2018)
29
+
30
+ ### Changes
31
+
32
+ * Fixes usage of deprecated env var for GAE Flex (#189)
33
+ * fix - guzzlehttp/psr7 dependency version definition (#190)
34
+ * Added SystemV shared memory based CacheItemPool (#191)
35
+
36
+ ## 1.2.1 (24/01/2018)
37
+
38
+ ### Changes
39
+
40
+ * Fixes array merging bug in Guzzle5HttpHandler (#186)
41
+ * Fixes constructor argument bug in Subscriber & Middleware (#184)
42
+
43
+ ## 1.2.0 (6/12/2017)
44
+
45
+ ### Changes
46
+
47
+ * Adds async method to HTTP handlers (#176)
48
+ * Misc bug fixes and improvements (#177, #175, #178)
49
+
50
+ ## 1.1.0 (10/10/2017)
51
+
52
+ ### Changes
53
+
54
+ * Supports additional claims in JWT tokens (#171)
55
+ * Adds makeHttpClient for creating authorized Guzzle clients (#162)
56
+ * Misc bug fixes/improvements (#168, #161, #167, #170, #143)
57
+
58
+ ## 1.0.1 (31/07/2017)
59
+
60
+ ### Changes
61
+
62
+ * Adds support for Firebase 5.0 (#159)
63
+
64
+ ## 1.0.0 (12/06/2017)
65
+
66
+ ### Changes
67
+
68
+ * Adds hashing and shortening to enforce max key length ([@bshaffer])
69
+ * Fix for better PSR-6 compliance - verifies a hit before getting the cache item ([@bshaffer])
70
+ * README fixes ([@bshaffer])
71
+ * Change authorization header key to lowercase ([@stanley-cheung])
72
+
73
+ ## 0.4.0 (23/04/2015)
74
+
75
+ ### Changes
76
+
77
+ * Export callback function to update auth metadata ([@stanley-cheung][])
78
+ * Adds an implementation of User Refresh Token auth ([@stanley-cheung][])
79
+
80
+ [@bshaffer]: https://github.com/bshaffer
81
+ [@stanley-cheung]: https://github.com/stanley-cheung
vendor/google/auth/CODE_OF_CONDUCT.md ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project,
4
+ and in the interest of fostering an open and welcoming community,
5
+ we pledge to respect all people who contribute through reporting issues,
6
+ posting feature requests, updating documentation,
7
+ submitting pull requests or patches, and other activities.
8
+
9
+ We are committed to making participation in this project
10
+ a harassment-free experience for everyone,
11
+ regardless of level of experience, gender, gender identity and expression,
12
+ sexual orientation, disability, personal appearance,
13
+ body size, race, ethnicity, age, religion, or nationality.
14
+
15
+ Examples of unacceptable behavior by participants include:
16
+
17
+ * The use of sexualized language or imagery
18
+ * Personal attacks
19
+ * Trolling or insulting/derogatory comments
20
+ * Public or private harassment
21
+ * Publishing other's private information,
22
+ such as physical or electronic
23
+ addresses, without explicit permission
24
+ * Other unethical or unprofessional conduct.
25
+
26
+ Project maintainers have the right and responsibility to remove, edit, or reject
27
+ comments, commits, code, wiki edits, issues, and other contributions
28
+ that are not aligned to this Code of Conduct.
29
+ By adopting this Code of Conduct,
30
+ project maintainers commit themselves to fairly and consistently
31
+ applying these principles to every aspect of managing this project.
32
+ Project maintainers who do not follow or enforce the Code of Conduct
33
+ may be permanently removed from the project team.
34
+
35
+ This code of conduct applies both within project spaces and in public spaces
36
+ when an individual is representing the project or its community.
37
+
38
+ Instances of abusive, harassing, or otherwise unacceptable behavior
39
+ may be reported by opening an issue
40
+ or contacting one or more of the project maintainers.
41
+
42
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0,
43
+ available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
vendor/google/auth/CONTRIBUTING.md ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # How to become a contributor and submit your own code
2
+
3
+ ## Contributor License Agreements
4
+
5
+ We'd love to accept your sample apps and patches! Before we can take them, we
6
+ have to jump a couple of legal hurdles.
7
+
8
+ Please fill out either the individual or corporate Contributor License Agreement
9
+ (CLA).
10
+
11
+ * If you are an individual writing original source code and you're sure you
12
+ own the intellectual property, then you'll need to sign an [individual CLA]
13
+ (http://code.google.com/legal/individual-cla-v1.0.html).
14
+ * If you work for a company that wants to allow you to contribute your work,
15
+ then you'll need to sign a [corporate CLA]
16
+ (http://code.google.com/legal/corporate-cla-v1.0.html).
17
+
18
+ Follow either of the two links above to access the appropriate CLA and
19
+ instructions for how to sign and return it. Once we receive it, we'll be able to
20
+ accept your pull requests.
21
+
22
+ ## Issue reporting
23
+
24
+ * Check that the issue has not already been reported.
25
+ * Check that the issue has not already been fixed in the latest code
26
+ (a.k.a. `master`).
27
+ * Be clear, concise and precise in your description of the problem.
28
+ * Open an issue with a descriptive title and a summary in grammatically correct,
29
+ complete sentences.
30
+ * Include any relevant code to the issue summary.
31
+
32
+ ## Pull requests
33
+
34
+ * Read [how to properly contribute to open source projects on Github][2].
35
+ * Fork the project.
36
+ * Use a topic/feature branch to easily amend a pull request later, if necessary.
37
+ * Write [good commit messages][3].
38
+ * Use the same coding conventions as the rest of the project.
39
+ * Commit and push until you are happy with your contribution.
40
+ * Make sure to add tests for it. This is important so I don't break it
41
+ in a future version unintentionally.
42
+ * Add an entry to the [Changelog](CHANGELOG.md) accordingly. See [changelog entry format](#changelog-entry-format).
43
+ * Please try not to mess with the Rakefile, version, or history. If you want to
44
+ have your own version, or is otherwise necessary, that is fine, but please
45
+ isolate to its own commit so I can cherry-pick around it.
46
+ * Make sure the test suite is passing and the code you wrote doesn't produce
47
+ phpunit or phplint offenses.
48
+ * [Squash related commits together][5].
49
+ * Open a [pull request][4] that relates to *only* one subject with a clear title
50
+ and description in grammatically correct, complete sentences.
51
+
52
+ ### Changelog entry format
53
+
54
+ Here are a few examples:
55
+
56
+ ```
57
+ * ADC Support for User Refresh Tokens (@tbetbetbe[])
58
+ * [#16](https://github.com/google/google-auth-library-php/issues/16): ADC Support for User Refresh Tokens ([@tbetbetbe][])
59
+ ```
60
+
61
+ * Mark it up in [Markdown syntax][6].
62
+ * The entry line should start with `* ` (an asterisk and a space).
63
+ * If the change has a related GitHub issue (e.g. a bug fix for a reported issue), put a link to the issue as `[#16](https://github.com/google/google-auth-library-php/issues/16): `.
64
+ * Describe the brief of the change. The sentence should end with a punctuation.
65
+ * At the end of the entry, add an implicit link to your GitHub user page as `([@username][])`.
66
+ * If this is your first contribution to google-auth-library-php project, add a link definition for the implicit link to the bottom of the changelog as `[@username]: https://github.com/username`.
67
+
68
+ [1]: https://github.com/google/google-auth-php-library/issues
69
+ [2]: http://gun.io/blog/how-to-github-fork-branch-and-pull-request
70
+ [3]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
71
+ [4]: https://help.github.com/articles/using-pull-requests
72
+ [5]: http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html
73
+ [6]: http://daringfireball.net/projects/markdown/syntax
vendor/google/auth/COPYING ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2015 Google Inc.
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
vendor/google/auth/LICENSE ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
203
+
vendor/google/auth/README.md ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Google Auth Library for PHP
2
+
3
+ <dl>
4
+ <dt>Homepage</dt><dd><a href="http://www.github.com/google/google-auth-library-php">http://www.github.com/google/google-auth-library-php</a></dd>
5
+ <dt>Authors</dt>
6
+ <dd><a href="mailto:temiola@google.com">Tim Emiola</a></dd>
7
+ <dd><a href="mailto:stanleycheung@google.com">Stanley Cheung</a></dd>
8
+ <dd><a href="mailto:betterbrent@google.com">Brent Shaffer</a></dd>
9
+ <dt>Copyright</dt><dd>Copyright © 2015 Google, Inc.</dd>
10
+ <dt>License</dt><dd>Apache 2.0</dd>
11
+ </dl>
12
+
13
+ ## Description
14
+
15
+ This is Google's officially supported PHP client library for using OAuth 2.0
16
+ authorization and authentication with Google APIs.
17
+
18
+ ### Installing via Composer
19
+
20
+ The recommended way to install the google auth library is through
21
+ [Composer](http://getcomposer.org).
22
+
23
+ ```bash
24
+ # Install Composer
25
+ curl -sS https://getcomposer.org/installer | php
26
+ ```
27
+
28
+ Next, run the Composer command to install the latest stable version:
29
+
30
+ ```bash
31
+ composer.phar require google/auth
32
+ ```
33
+
34
+ ## Application Default Credentials
35
+
36
+ This library provides an implementation of
37
+ [application default credentials][application default credentials] for PHP.
38
+
39
+ The Application Default Credentials provide a simple way to get authorization
40
+ credentials for use in calling Google APIs.
41
+
42
+ They are best suited for cases when the call needs to have the same identity
43
+ and authorization level for the application independent of the user. This is
44
+ the recommended approach to authorize calls to Cloud APIs, particularly when
45
+ you're building an application that uses Google Compute Engine.
46
+
47
+ #### Download your Service Account Credentials JSON file
48
+
49
+ To use `Application Default Credentials`, You first need to download a set of
50
+ JSON credentials for your project. Go to **APIs & Auth** > **Credentials** in
51
+ the [Google Developers Console][developer console] and select
52
+ **Service account** from the **Add credentials** dropdown.
53
+
54
+ > This file is your *only copy* of these credentials. It should never be
55
+ > committed with your source code, and should be stored securely.
56
+
57
+ Once downloaded, store the path to this file in the
58
+ `GOOGLE_APPLICATION_CREDENTIALS` environment variable.
59
+
60
+ ```php
61
+ putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/my/credentials.json');
62
+ ```
63
+
64
+ > PHP's `putenv` function is just one way to set an environment variable.
65
+ > Consider using `.htaccess` or apache configuration files as well.
66
+
67
+ #### Enable the API you want to use
68
+
69
+ Before making your API call, you must be sure the API you're calling has been
70
+ enabled. Go to **APIs & Auth** > **APIs** in the
71
+ [Google Developers Console][developer console] and enable the APIs you'd like to
72
+ call. For the example below, you must enable the `Drive API`.
73
+
74
+ #### Call the APIs
75
+
76
+ As long as you update the environment variable below to point to *your* JSON
77
+ credentials file, the following code should output a list of your Drive files.
78
+
79
+ ```php
80
+ use Google\Auth\ApplicationDefaultCredentials;
81
+ use GuzzleHttp\Client;
82
+ use GuzzleHttp\HandlerStack;
83
+
84
+ // specify the path to your application credentials
85
+ putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/my/credentials.json');
86
+
87
+ // define the scopes for your API call
88
+ $scopes = ['https://www.googleapis.com/auth/drive.readonly'];
89
+
90
+ // create middleware
91
+ $middleware = ApplicationDefaultCredentials::getMiddleware($scopes);
92
+ $stack = HandlerStack::create();
93
+ $stack->push($middleware);
94
+
95
+ // create the HTTP client
96
+ $client = new Client([
97
+ 'handler' => $stack,
98
+ 'base_uri' => 'https://www.googleapis.com',
99
+ 'auth' => 'google_auth' // authorize all requests
100
+ ]);
101
+
102
+ // make the request
103
+ $response = $client->get('drive/v2/files');
104
+
105
+ // show the result!
106
+ print_r((string) $response->getBody());
107
+ ```
108
+
109
+ ##### Guzzle 5 Compatibility
110
+
111
+ If you are using [Guzzle 5][Guzzle 5], replace the `create middleware` and
112
+ `create the HTTP Client` steps with the following:
113
+
114
+ ```php
115
+ // create the HTTP client
116
+ $client = new Client([
117
+ 'base_url' => 'https://www.googleapis.com',
118
+ 'auth' => 'google_auth' // authorize all requests
119
+ ]);
120
+
121
+ // create subscriber
122
+ $subscriber = ApplicationDefaultCredentials::getSubscriber($scopes);
123
+ $client->getEmitter()->attach($subscriber);
124
+
125
+ ```
126
+
127
+ ## License
128
+
129
+ This library is licensed under Apache 2.0. Full license text is
130
+ available in [COPYING][copying].
131
+
132
+ ## Contributing
133
+
134
+ See [CONTRIBUTING][contributing].
135
+
136
+ ## Support
137
+
138
+ Please
139
+ [report bugs at the project on Github](https://github.com/google/google-auth-library-php/issues). Don't
140
+ hesitate to
141
+ [ask questions](http://stackoverflow.com/questions/tagged/google-auth-library-php)
142
+ about the client or APIs on [StackOverflow](http://stackoverflow.com).
143
+
144
+ [google-apis-php-client]: https://github.com/google/google-api-php-client
145
+ [application default credentials]: https://developers.google.com/accounts/docs/application-default-credentials
146
+ [contributing]: https://github.com/google/google-auth-library-php/tree/master/CONTRIBUTING.md
147
+ [copying]: https://github.com/google/google-auth-library-php/tree/master/COPYING
148
+ [Guzzle]: https://github.com/guzzle/guzzle
149
+ [Guzzle 5]: http://docs.guzzlephp.org/en/5.3
150
+ [developer console]: https://console.developers.google.com
vendor/google/auth/autoload.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ function oauth2client_php_autoload($className)
19
+ {
20
+ $classPath = explode('_', $className);
21
+ if ($classPath[0] != 'Google') {
22
+ return;
23
+ }
24
+ if (count($classPath) > 3) {
25
+ // Maximum class file path depth in this project is 3.
26
+ $classPath = array_slice($classPath, 0, 3);
27
+ }
28
+ $filePath = dirname(__FILE__) . '/src/' . implode('/', $classPath) . '.php';
29
+ if (file_exists($filePath)) {
30
+ require_once $filePath;
31
+ }
32
+ }
33
+
34
+ spl_autoload_register('oauth2client_php_autoload');
vendor/google/auth/composer.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "google/auth",
3
+ "type": "library",
4
+ "description": "Google Auth Library for PHP",
5
+ "keywords": ["google", "oauth2", "authentication"],
6
+ "homepage": "http://github.com/google/google-auth-library-php",
7
+ "license": "Apache-2.0",
8
+ "require": {
9
+ "php": ">=5.4",
10
+ "firebase/php-jwt": "~2.0|~3.0|~4.0|~5.0",
11
+ "guzzlehttp/guzzle": "~5.3.1|~6.0",
12
+ "guzzlehttp/psr7": "^1.2",
13
+ "psr/http-message": "^1.0",
14
+ "psr/cache": "^1.0"
15
+ },
16
+ "require-dev": {
17
+ "guzzlehttp/promises": "0.1.1|^1.3",
18
+ "friendsofphp/php-cs-fixer": "^1.11",
19
+ "phpunit/phpunit": "^4.8.36|^5.7",
20
+ "sebastian/comparator": ">=1.2.3"
21
+ },
22
+ "autoload": {
23
+ "psr-4": {
24
+ "Google\\Auth\\": "src"
25
+ }
26
+ }
27
+ }
vendor/google/auth/phpunit.xml.dist ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <phpunit bootstrap="tests/bootstrap.php" colors="true">
3
+ <php>
4
+ <env name="SUPPRESS_GCLOUD_CREDS_WARNING" value="true" force="true"/>
5
+ </php>
6
+ <testsuites>
7
+ <testsuite name="google-auth-tests">
8
+ <directory suffix="Test.php">tests</directory>
9
+ </testsuite>
10
+ </testsuites>
11
+ <filter>
12
+ <whitelist>
13
+ <directory suffix=".php">src</directory>
14
+ <exclude>
15
+ <directory suffix="Interface.php">src/</directory>
16
+ </exclude>
17
+ </whitelist>
18
+ </filter>
19
+ </phpunit>
vendor/google/auth/src/ApplicationDefaultCredentials.php ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2015 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
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
29
+ * authorizing a request to a Google service.
30
+ *
31
+ * Application Default Credentials are described here:
32
+ * https://developers.google.com/accounts/docs/application-default-credentials
33
+ *
34
+ * This class implements the search for the application default credentials as
35
+ * described in the link.
36
+ *
37
+ * It provides three factory methods:
38
+ * - #get returns the computed credentials object
39
+ * - #getSubscriber returns an AuthTokenSubscriber built from the credentials object
40
+ * - #getMiddleware returns an AuthTokenMiddleware built from the credentials object
41
+ *
42
+ * This allows it to be used as follows with GuzzleHttp\Client:
43
+ *
44
+ * use Google\Auth\ApplicationDefaultCredentials;
45
+ * use GuzzleHttp\Client;
46
+ * use GuzzleHttp\HandlerStack;
47
+ *
48
+ * $middleware = ApplicationDefaultCredentials::getMiddleware(
49
+ * 'https://www.googleapis.com/auth/taskqueue'
50
+ * );
51
+ * $stack = HandlerStack::create();
52
+ * $stack->push($middleware);
53
+ *
54
+ * $client = new Client([
55
+ * 'handler' => $stack,
56
+ * 'base_uri' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
57
+ * 'auth' => 'google_auth' // authorize all requests
58
+ * ]);
59
+ *
60
+ * $res = $client->get('myproject/taskqueues/myqueue');
61
+ */
62
+ class ApplicationDefaultCredentials
63
+ {
64
+ /**
65
+ * Obtains an AuthTokenSubscriber that uses the default FetchAuthTokenInterface
66
+ * implementation to use in this environment.
67
+ *
68
+ * If supplied, $scope is used to in creating the credentials instance if
69
+ * this does not fallback to the compute engine defaults.
70
+ *
71
+ * @param string|array scope the scope of the access request, expressed
72
+ * either as an Array or as a space-delimited String.
73
+ * @param callable $httpHandler callback which delivers psr7 request
74
+ * @param array $cacheConfig configuration for the cache when it's present
75
+ * @param CacheItemPoolInterface $cache an implementation of CacheItemPoolInterface
76
+ *
77
+ * @return AuthTokenSubscriber
78
+ *
79
+ * @throws DomainException if no implementation can be obtained.
80
+ */
81
+ public static function getSubscriber(
82
+ $scope = null,
83
+ callable $httpHandler = null,
84
+ array $cacheConfig = null,
85
+ CacheItemPoolInterface $cache = null
86
+ ) {
87
+ $creds = self::getCredentials($scope, $httpHandler, $cacheConfig, $cache);
88
+
89
+ return new AuthTokenSubscriber($creds, $httpHandler);
90
+ }
91
+
92
+ /**
93
+ * Obtains an AuthTokenMiddleware that uses the default FetchAuthTokenInterface
94
+ * implementation to use in this environment.
95
+ *
96
+ * If supplied, $scope is used to in creating the credentials instance if
97
+ * this does not fallback to the compute engine defaults.
98
+ *
99
+ * @param string|array scope the scope of the access request, expressed
100
+ * either as an Array or as a space-delimited String.
101
+ * @param callable $httpHandler callback which delivers psr7 request
102
+ * @param array $cacheConfig configuration for the cache when it's present
103
+ * @param CacheItemPoolInterface $cache
104
+ *
105
+ * @return AuthTokenMiddleware
106
+ *
107
+ * @throws DomainException if no implementation can be obtained.
108
+ */
109
+ public static function getMiddleware(
110
+ $scope = null,
111
+ callable $httpHandler = null,
112
+ array $cacheConfig = null,
113
+ CacheItemPoolInterface $cache = null
114
+ ) {
115
+ $creds = self::getCredentials($scope, $httpHandler, $cacheConfig, $cache);
116
+
117
+ return new AuthTokenMiddleware($creds, $httpHandler);
118
+ }
119
+
120
+ /**
121
+ * Obtains the default FetchAuthTokenInterface implementation to use
122
+ * in this environment.
123
+ *
124
+ * If supplied, $scope is used to in creating the credentials instance if
125
+ * this does not fallback to the Compute Engine defaults.
126
+ *
127
+ * @param string|array scope the scope of the access request, expressed
128
+ * either as an Array or as a space-delimited String.
129
+ * @param callable $httpHandler callback which delivers psr7 request
130
+ * @param array $cacheConfig configuration for the cache when it's present
131
+ * @param CacheItemPoolInterface $cache
132
+ *
133
+ * @return CredentialsLoader
134
+ *
135
+ * @throws DomainException if no implementation can be obtained.
136
+ */
137
+ public static function getCredentials(
138
+ $scope = null,
139
+ callable $httpHandler = null,
140
+ array $cacheConfig = null,
141
+ CacheItemPoolInterface $cache = null
142
+ ) {
143
+ $creds = null;
144
+ $jsonKey = CredentialsLoader::fromEnv()
145
+ ?: CredentialsLoader::fromWellKnownFile();
146
+
147
+ if (!is_null($jsonKey)) {
148
+ $creds = CredentialsLoader::makeCredentials($scope, $jsonKey);
149
+ } elseif (AppIdentityCredentials::onAppEngine() && !GCECredentials::onAppEngineFlexible()) {
150
+ $creds = new AppIdentityCredentials($scope);
151
+ } elseif (GCECredentials::onGce($httpHandler)) {
152
+ $creds = new GCECredentials();
153
+ }
154
+
155
+ if (is_null($creds)) {
156
+ throw new \DomainException(self::notFound());
157
+ }
158
+ if (!is_null($cache)) {
159
+ $creds = new FetchAuthTokenCache($creds, $cacheConfig, $cache);
160
+ }
161
+ return $creds;
162
+ }
163
+
164
+ private static function notFound()
165
+ {
166
+ $msg = 'Could not load the default credentials. Browse to ';
167
+ $msg .= 'https://developers.google.com';
168
+ $msg .= '/accounts/docs/application-default-credentials';
169
+ $msg .= ' for more information';
170
+
171
+ return $msg;
172
+ }
173
+ }
vendor/google/auth/src/Cache/InvalidArgumentException.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2016 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
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
+ {
24
+ }
vendor/google/auth/src/Cache/Item.php ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2016 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ namespace Google\Auth\Cache;
19
+
20
+ use Psr\Cache\CacheItemInterface;
21
+
22
+ /**
23
+ * A cache item.
24
+ */
25
+ final class Item implements CacheItemInterface
26
+ {
27
+ /**
28
+ * @var string
29
+ */
30
+ private $key;
31
+
32
+ /**
33
+ * @var mixed
34
+ */
35
+ private $value;
36
+
37
+ /**
38
+ * @var \DateTime
39
+ */
40
+ private $expiration;
41
+
42
+ /**
43
+ * @var bool
44
+ */
45
+ private $isHit = false;
46
+
47
+ /**
48
+ * @param string $key
49
+ */
50
+ public function __construct($key)
51
+ {
52
+ $this->key = $key;
53
+ }
54
+
55
+ /**
56
+ * {@inheritdoc}
57
+ */
58
+ public function getKey()
59
+ {
60
+ return $this->key;
61
+ }
62
+
63
+ /**
64
+ * {@inheritdoc}
65
+ */
66
+ public function get()
67
+ {
68
+ return $this->isHit() ? $this->value : null;
69
+ }
70
+
71
+ /**
72
+ * {@inheritdoc}
73
+ */
74
+ public function isHit()
75
+ {
76
+ if (!$this->isHit) {
77
+ return false;
78
+ }
79
+
80
+ if ($this->expiration === null) {
81
+ return true;
82
+ }
83
+
84
+ return new \DateTime() < $this->expiration;
85
+ }
86
+
87
+ /**
88
+ * {@inheritdoc}
89
+ */
90
+ public function set($value)
91
+ {
92
+ $this->isHit = true;
93
+ $this->value = $value;
94
+
95
+ return $this;
96
+ }
97
+
98
+ /**
99
+ * {@inheritdoc}
100
+ */
101
+ public function expiresAt($expiration)
102
+ {
103
+ if ($this->isValidExpiration($expiration)) {
104
+ $this->expiration = $expiration;
105
+
106
+ return $this;
107
+ }
108
+
109
+ $implementationMessage = interface_exists('DateTimeInterface')
110
+ ? 'implement interface DateTimeInterface'
111
+ : 'be an instance of DateTime';
112
+
113
+ $error = sprintf(
114
+ 'Argument 1 passed to %s::expiresAt() must %s, %s given',
115
+ get_class($this),
116
+ $implementationMessage,
117
+ gettype($expiration)
118
+ );
119
+
120
+ $this->handleError($error);
121
+ }
122
+
123
+ /**
124
+ * {@inheritdoc}
125
+ */
126
+ public function expiresAfter($time)
127
+ {
128
+ if (is_int($time)) {
129
+ $this->expiration = new \DateTime("now + $time seconds");
130
+ } elseif ($time instanceof \DateInterval) {
131
+ $this->expiration = (new \DateTime())->add($time);
132
+ } elseif ($time === null) {
133
+ $this->expiration = $time;
134
+ } else {
135
+ $message = 'Argument 1 passed to %s::expiresAfter() must be an ' .
136
+ 'instance of DateInterval or of the type integer, %s given';
137
+ $error = sprintf($message, get_class($this), gettype($time));
138
+
139
+ $this->handleError($error);
140
+ }
141
+
142
+ return $this;
143
+ }
144
+
145
+ /**
146
+ * Handles an error.
147
+ *
148
+ * @param string $error
149
+ * @throws \TypeError
150
+ */
151
+ private function handleError($error)
152
+ {
153
+ if (class_exists('TypeError')) {
154
+ throw new \TypeError($error);
155
+ }
156
+
157
+ trigger_error($error, E_USER_ERROR);
158
+ }
159
+
160
+ /**
161
+ * Determines if an expiration is valid based on the rules defined by PSR6.
162
+ *
163
+ * @param mixed $expiration
164
+ * @return bool
165
+ */
166
+ private function isValidExpiration($expiration)
167
+ {
168
+ if ($expiration === null) {
169
+ return true;
170
+ }
171
+
172
+ // We test for two types here due to the fact the DateTimeInterface
173
+ // was not introduced until PHP 5.5. Checking for the DateTime type as
174
+ // well allows us to support 5.4.
175
+ if ($expiration instanceof \DateTimeInterface) {
176
+ return true;
177
+ }
178
+
179
+ if ($expiration instanceof \DateTime) {
180
+ return true;
181
+ }
182
+
183
+ return false;
184
+ }
185
+ }
vendor/google/auth/src/Cache/MemoryCacheItemPool.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2016 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
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.
25
+ */
26
+ final class MemoryCacheItemPool implements CacheItemPoolInterface
27
+ {
28
+ /**
29
+ * @var CacheItemInterface[]
30
+ */
31
+ private $items;
32
+
33
+ /**
34
+ * @var CacheItemInterface[]
35
+ */
36
+ private $deferredItems;
37
+
38
+ /**
39
+ * {@inheritdoc}
40
+ */
41
+ public function getItem($key)
42
+ {
43
+ return current($this->getItems([$key]));
44
+ }
45
+
46
+ /**
47
+ * {@inheritdoc}
48
+ */
49
+ public function getItems(array $keys = [])
50
+ {
51
+ $items = [];
52
+
53
+ foreach ($keys as $key) {
54
+ $items[$key] = $this->hasItem($key) ? clone $this->items[$key] : new Item($key);
55
+ }
56
+
57
+ return $items;
58
+ }
59
+
60
+ /**
61
+ * {@inheritdoc}
62
+ */
63
+ public function hasItem($key)
64
+ {
65
+ $this->isValidKey($key);
66
+
67
+ return isset($this->items[$key]) && $this->items[$key]->isHit();
68
+ }
69
+
70
+ /**
71
+ * {@inheritdoc}
72
+ */
73
+ public function clear()
74
+ {
75
+ $this->items = [];
76
+ $this->deferredItems = [];
77
+
78
+ return true;
79
+ }
80
+
81
+ /**
82
+ * {@inheritdoc}
83
+ */
84
+ public function deleteItem($key)
85
+ {
86
+ return $this->deleteItems([$key]);
87
+ }
88
+
89
+ /**
90
+ * {@inheritdoc}
91
+ */
92
+ public function deleteItems(array $keys)
93
+ {
94
+ array_walk($keys, [$this, 'isValidKey']);
95
+
96
+ foreach ($keys as $key) {
97
+ unset($this->items[$key]);
98
+ }
99
+
100
+ return true;
101
+ }
102
+
103
+ /**
104
+ * {@inheritdoc}
105
+ */
106
+ public function save(CacheItemInterface $item)
107
+ {
108
+ $this->items[$item->getKey()] = $item;
109
+
110
+ return true;
111
+ }
112
+
113
+ /**
114
+ * {@inheritdoc}
115
+ */
116
+ public function saveDeferred(CacheItemInterface $item)
117
+ {
118
+ $this->deferredItems[$item->getKey()] = $item;
119
+
120
+ return true;
121
+ }
122
+
123
+ /**
124
+ * {@inheritdoc}
125
+ */
126
+ public function commit()
127
+ {
128
+ foreach ($this->deferredItems as $item) {
129
+ $this->save($item);
130
+ }
131
+
132
+ $this->deferredItems = [];
133
+
134
+ return true;
135
+ }
136
+
137
+ /**
138
+ * Determines if the provided key is valid.
139
+ *
140
+ * @param string $key
141
+ * @return bool
142
+ * @throws InvalidArgumentException
143
+ */
144
+ private function isValidKey($key)
145
+ {
146
+ $invalidCharacters = '{}()/\\\\@:';
147
+
148
+ if (!is_string($key) || preg_match("#[$invalidCharacters]#", $key)) {
149
+ throw new InvalidArgumentException('The provided key is not valid: ' . var_export($key, true));
150
+ }
151
+
152
+ return true;
153
+ }
154
+ }
vendor/google/auth/src/Cache/SysVCacheItemPool.php ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2018 Google Inc. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
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.
24
+ *
25
+ * This CacheItemPool implementation can be used among multiple processes, but
26
+ * it doesn't provide any locking mechanism. If multiple processes write to
27
+ * this ItemPool, you have to avoid race condition manually in your code.
28
+ */
29
+ class SysVCacheItemPool implements CacheItemPoolInterface
30
+ {
31
+ const VAR_KEY = 1;
32
+
33
+ const DEFAULT_PROJ = 'A';
34
+
35
+ const DEFAULT_MEMSIZE = 10000;
36
+
37
+ const DEFAULT_PERM = 0600;
38
+
39
+ /** @var int */
40
+ private $sysvKey;
41
+
42
+ /**
43
+ * @var CacheItemInterface[]
44
+ */
45
+ private $items;
46
+
47
+ /**
48
+ * @var CacheItemInterface[]
49
+ */
50
+ private $deferredItems;
51
+
52
+ /**
53
+ * @var array
54
+ */
55
+ private $options;
56
+
57
+ /**
58
+ * Save the current items.
59
+ *
60
+ * @return bool true when success, false upon failure
61
+ */
62
+ private function saveCurrentItems()
63
+ {
64
+ $shmid = shm_attach(
65
+ $this->sysvKey,
66
+ $this->options['memsize'],
67
+ $this->options['perm']
68
+ );
69
+ if ($shmid !== false) {
70
+ $ret = shm_put_var(
71
+ $shmid,
72
+ $this->options['variableKey'],
73
+ $this->items
74
+ );
75
+ shm_detach($shmid);
76
+ return $ret;
77
+ }
78
+ return false;
79
+ }
80
+
81
+ /**
82
+ * Load the items from the shared memory.
83
+ *
84
+ * @return bool true when success, false upon failure
85
+ */
86
+ private function loadItems()
87
+ {
88
+ $shmid = shm_attach(
89
+ $this->sysvKey,
90
+ $this->options['memsize'],
91
+ $this->options['perm']
92
+ );
93
+ if ($shmid !== false) {
94
+ $data = @shm_get_var($shmid, $this->options['variableKey']);
95
+ if (!empty($data)) {
96
+ $this->items = $data;
97
+ } else {
98
+ $this->items = [];
99
+ }
100
+ shm_detach($shmid);
101
+ return true;
102
+ }
103
+ return false;
104
+ }
105
+
106
+ /**
107
+ * Create a SystemV shared memory based CacheItemPool.
108
+ *
109
+ * @param array $options [optional] {
110
+ * Configuration options.
111
+ *
112
+ * @type int $variableKey The variable key for getting the data from
113
+ * the shared memory. **Defaults to** 1.
114
+ * @type string $proj The project identifier for ftok. This needs to
115
+ * be a one character string. **Defaults to** 'A'.
116
+ * @type int $memsize The memory size in bytes for shm_attach.
117
+ * **Defaults to** 10000.
118
+ * @type int $perm The permission for shm_attach. **Defaults to** 0600.
119
+ */
120
+ public function __construct($options = [])
121
+ {
122
+ if (! extension_loaded('sysvshm')) {
123
+ throw \RuntimeException(
124
+ 'sysvshm extension is required to use this ItemPool');
125
+ }
126
+ $this->options = $options + [
127
+ 'variableKey' => self::VAR_KEY,
128
+ 'proj' => self::DEFAULT_PROJ,
129
+ 'memsize' => self::DEFAULT_MEMSIZE,
130
+ 'perm' => self::DEFAULT_PERM
131
+ ];
132
+ $this->items = [];
133
+ $this->deferredItems = [];
134
+ $this->sysvKey = ftok(__FILE__, $this->options['proj']);
135
+ $this->loadItems();
136
+ }
137
+
138
+ /**
139
+ * {@inheritdoc}
140
+ */
141
+ public function getItem($key)
142
+ {
143
+ $this->loadItems();
144
+ return current($this->getItems([$key]));
145
+ }
146
+
147
+ /**
148
+ * {@inheritdoc}
149
+ */
150
+ public function getItems(array $keys = [])
151
+ {
152
+ $this->loadItems();
153
+ $items = [];
154
+ foreach ($keys as $key) {
155
+ $items[$key] = $this->hasItem($key) ?
156
+ clone $this->items[$key] :
157
+ new Item($key);
158
+ }
159
+ return $items;
160
+ }
161
+
162
+ /**
163
+ * {@inheritdoc}
164
+ */
165
+ public function hasItem($key)
166
+ {
167
+ $this->loadItems();
168
+ return isset($this->items[$key]) && $this->items[$key]->isHit();
169
+ }
170
+
171
+ /**
172
+ * {@inheritdoc}
173
+ */
174
+ public function clear()
175
+ {
176
+ $this->items = [];
177
+ $this->deferredItems = [];
178
+ return $this->saveCurrentItems();
179
+ }
180
+
181
+ /**
182
+ * {@inheritdoc}
183
+ */
184
+ public function deleteItem($key)
185
+ {
186
+ return $this->deleteItems([$key]);
187
+ }
188
+
189
+ /**
190
+ * {@inheritdoc}
191
+ */
192
+ public function deleteItems(array $keys)
193
+ {
194
+ foreach ($keys as $key) {
195
+ unset($this->items[$key]);
196
+ }
197
+ return $this->saveCurrentItems();
198
+ }
199
+
200
+ /**
201
+ * {@inheritdoc}
202
+ */
203
+ public function save(CacheItemInterface $item)
204
+ {
205
+ $this->items[$item->getKey()] = $item;
206
+ return $this->saveCurrentItems();
207
+ }
208
+
209
+ /**
210
+ * {@inheritdoc}
211
+ */
212
+ public function saveDeferred(CacheItemInterface $item)
213
+ {
214
+ $this->deferredItems[$item->getKey()] = $item;
215
+ return true;
216
+ }
217
+
218
+ /**
219
+ * {@inheritdoc}
220
+ */
221
+ public function commit()
222
+ {
223
+ foreach ($this->deferredItems as $item) {
224
+ if ($this->save($item) === false) {
225
+ return false;
226
+ }
227
+ }
228
+ $this->deferredItems = [];
229
+ return true;
230
+ }
231
+ }
vendor/google/auth/src/CacheTrait.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2015 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ namespace Google\Auth;
19
+
20
+ trait CacheTrait
21
+ {
22
+ private $maxKeyLength = 64;
23
+
24
+ /**
25
+ * Gets the cached value if it is present in the cache when that is
26
+ * available.
27
+ */
28
+ private function getCachedValue($k)
29
+ {
30
+ if (is_null($this->cache)) {
31
+ return;
32
+ }
33
+
34
+ $key = $this->getFullCacheKey($k);
35
+ if (is_null($key)) {
36
+ return;
37
+ }
38
+
39
+ $cacheItem = $this->cache->getItem($key);
40
+ if ($cacheItem->isHit()) {
41
+ return $cacheItem->get();
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Saves the value in the cache when that is available.
47
+ */
48
+ private function setCachedValue($k, $v)
49
+ {
50
+ if (is_null($this->cache)) {
51
+ return;
52
+ }
53
+
54
+ $key = $this->getFullCacheKey($k);
55
+ if (is_null($key)) {
56
+ return;
57
+ }
58
+
59
+ $cacheItem = $this->cache->getItem($key);
60
+ $cacheItem->set($v);
61
+ $cacheItem->expiresAfter($this->cacheConfig['lifetime']);
62
+ return $this->cache->save($cacheItem);
63
+ }
64
+
65
+ private function getFullCacheKey($key)
66
+ {
67
+ if (is_null($key)) {
68
+ return;
69
+ }
70
+
71
+ $key = $this->cacheConfig['prefix'] . $key;
72
+
73
+ // ensure we do not have illegal characters
74
+ $key = preg_replace('|[^a-zA-Z0-9_\.!]|', '', $key);
75
+
76
+ // Hash keys if they exceed $maxKeyLength (defaults to 64)
77
+ if ($this->maxKeyLength && strlen($key) > $this->maxKeyLength) {
78
+ $key = substr(hash('sha256', $key), 0, $this->maxKeyLength);
79
+ }
80
+
81
+ return $key;
82
+ }
83
+ }
vendor/google/auth/src/Credentials/AppIdentityCredentials.php ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2015 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ namespace Google\Auth\Credentials;
19
+
20
+ /*
21
+ * The AppIdentityService class is automatically defined on App Engine,
22
+ * so including this dependency is not necessary, and will result in a
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.
30
+ *
31
+ * It can be used to authorize requests using the AuthTokenMiddleware or
32
+ * AuthTokenSubscriber, but will only succeed if being run on App Engine:
33
+ *
34
+ * use Google\Auth\Credentials\AppIdentityCredentials;
35
+ * use Google\Auth\Middleware\AuthTokenMiddleware;
36
+ * use GuzzleHttp\Client;
37
+ * use GuzzleHttp\HandlerStack;
38
+ *
39
+ * $gae = new AppIdentityCredentials('https://www.googleapis.com/auth/books');
40
+ * $middleware = new AuthTokenMiddleware($gae);
41
+ * $stack = HandlerStack::create();
42
+ * $stack->push($middleware);
43
+ *
44
+ * $client = new Client([
45
+ * 'handler' => $stack,
46
+ * 'base_uri' => 'https://www.googleapis.com/books/v1',
47
+ * 'auth' => 'google_auth'
48
+ * ]);
49
+ *
50
+ * $res = $client->get('volumes?q=Henry+David+Thoreau&country=US');
51
+ */
52
+ class AppIdentityCredentials extends CredentialsLoader
53
+ {
54
+ /**
55
+ * Result of fetchAuthToken.
56
+ *
57
+ * @array
58
+ */
59
+ protected $lastReceivedToken;
60
+
61
+ /**
62
+ * Array of OAuth2 scopes to be requested.
63
+ */
64
+ private $scope;
65
+
66
+ public function __construct($scope = array())
67
+ {
68
+ $this->scope = $scope;
69
+ }
70
+
71
+ /**
72
+ * Determines if this an App Engine instance, by accessing the
73
+ * SERVER_SOFTWARE environment variable (prod) or the APPENGINE_RUNTIME
74
+ * environment variable (dev).
75
+ *
76
+ * @return true if this an App Engine Instance, false otherwise
77
+ */
78
+ public static function onAppEngine()
79
+ {
80
+ $appEngineProduction = isset($_SERVER['SERVER_SOFTWARE']) &&
81
+ 0 === strpos($_SERVER['SERVER_SOFTWARE'], 'Google App Engine');
82
+ if ($appEngineProduction) {
83
+ return true;
84
+ }
85
+ $appEngineDevAppServer = isset($_SERVER['APPENGINE_RUNTIME']) &&
86
+ $_SERVER['APPENGINE_RUNTIME'] == 'php';
87
+ if ($appEngineDevAppServer) {
88
+ return true;
89
+ }
90
+ return false;
91
+ }
92
+
93
+ /**
94
+ * Implements FetchAuthTokenInterface#fetchAuthToken.
95
+ *
96
+ * Fetches the auth tokens using the AppIdentityService if available.
97
+ * As the AppIdentityService uses protobufs to fetch the access token,
98
+ * the GuzzleHttp\ClientInterface instance passed in will not be used.
99
+ *
100
+ * @param callable $httpHandler callback which delivers psr7 request
101
+ *
102
+ * @return array the auth metadata:
103
+ * array(2) {
104
+ * ["access_token"]=>
105
+ * string(3) "xyz"
106
+ * ["expiration_time"]=>
107
+ * string(10) "1444339905"
108
+ * }
109
+ *
110
+ * @throws \Exception
111
+ */
112
+ public function fetchAuthToken(callable $httpHandler = null)
113
+ {
114
+ if (!self::onAppEngine()) {
115
+ return array();
116
+ }
117
+
118
+ if (!class_exists('google\appengine\api\app_identity\AppIdentityService')) {
119
+ throw new \Exception(
120
+ 'This class must be run in App Engine, or you must include the AppIdentityService '
121
+ . 'mock class defined in tests/mocks/AppIdentityService.php'
122
+ );
123
+ }
124
+
125
+ // AppIdentityService expects an array when multiple scopes are supplied
126
+ $scope = is_array($this->scope) ? $this->scope : explode(' ', $this->scope);
127
+
128
+ $token = AppIdentityService::getAccessToken($scope);
129
+ $this->lastReceivedToken = $token;
130
+
131
+ return $token;
132
+ }
133
+
134
+ /**
135
+ * @return array|null
136
+ */
137
+ public function getLastReceivedToken()
138
+ {
139
+ if ($this->lastReceivedToken) {
140
+ return [
141
+ 'access_token' => $this->lastReceivedToken['access_token'],
142
+ 'expires_at' => $this->lastReceivedToken['expiration_time'],
143
+ ];
144
+ }
145
+
146
+ return null;
147
+ }
148
+
149
+ /**
150
+ * Caching is handled by the underlying AppIdentityService, return empty string
151
+ * to prevent caching.
152
+ *
153
+ * @return string
154
+ */
155
+ public function getCacheKey()
156
+ {
157
+ return '';
158
+ }
159
+ }
vendor/google/auth/src/Credentials/GCECredentials.php ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2015 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
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.
29
+ *
30
+ * It can be used to authorize requests using the AuthTokenMiddleware, but will
31
+ * only succeed if being run on GCE:
32
+ *
33
+ * use Google\Auth\Credentials\GCECredentials;
34
+ * use Google\Auth\Middleware\AuthTokenMiddleware;
35
+ * use GuzzleHttp\Client;
36
+ * use GuzzleHttp\HandlerStack;
37
+ *
38
+ * $gce = new GCECredentials();
39
+ * $middleware = new AuthTokenMiddleware($gce);
40
+ * $stack = HandlerStack::create();
41
+ * $stack->push($middleware);
42
+ *
43
+ * $client = new Client([
44
+ * 'handler' => $stack,
45
+ * 'base_uri' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
46
+ * 'auth' => 'google_auth'
47
+ * ]);
48
+ *
49
+ * $res = $client->get('myproject/taskqueues/myqueue');
50
+ */
51
+ class GCECredentials extends CredentialsLoader
52
+ {
53
+ const cacheKey = 'GOOGLE_AUTH_PHP_GCE';
54
+ /**
55
+ * The metadata IP address on appengine instances.
56
+ *
57
+ * The IP is used instead of the domain 'metadata' to avoid slow responses
58
+ * when not on Compute Engine.
59
+ */
60
+ const METADATA_IP = '169.254.169.254';
61
+
62
+ /**
63
+ * The metadata path of the default token.
64
+ */
65
+ const TOKEN_URI_PATH = 'v1/instance/service-accounts/default/token';
66
+
67
+ /**
68
+ * The header whose presence indicates GCE presence.
69
+ */
70
+ const FLAVOR_HEADER = 'Metadata-Flavor';
71
+
72
+ /**
73
+ * Note: the explicit `timeout` and `tries` below is a workaround. The underlying
74
+ * issue is that resolving an unknown host on some networks will take
75
+ * 20-30 seconds; making this timeout short fixes the issue, but
76
+ * could lead to false negatives in the event that we are on GCE, but
77
+ * the metadata resolution was particularly slow. The latter case is
78
+ * "unlikely" since the expected 4-nines time is about 0.5 seconds.
79
+ * This allows us to limit the total ping maximum timeout to 1.5 seconds
80
+ * for developer desktop scenarios.
81
+ */
82
+ const MAX_COMPUTE_PING_TRIES = 3;
83
+ const COMPUTE_PING_CONNECTION_TIMEOUT_S = 0.5;
84
+
85
+ /**
86
+ * Flag used to ensure that the onGCE test is only done once;.
87
+ *
88
+ * @var bool
89
+ */
90
+ private $hasCheckedOnGce = false;
91
+
92
+ /**
93
+ * Flag that stores the value of the onGCE check.
94
+ *
95
+ * @var bool
96
+ */
97
+ private $isOnGce = false;
98
+
99
+ /**
100
+ * Result of fetchAuthToken.
101
+ */
102
+ protected $lastReceivedToken;
103
+
104
+ /**
105
+ * The full uri for accessing the default token.
106
+ *
107
+ * @return string
108
+ */
109
+ public static function getTokenUri()
110
+ {
111
+ $base = 'http://' . self::METADATA_IP . '/computeMetadata/';
112
+
113
+ return $base . self::TOKEN_URI_PATH;
114
+ }
115
+
116
+ /**
117
+ * Determines if this an App Engine Flexible instance, by accessing the
118
+ * GAE_INSTANCE environment variable.
119
+ *
120
+ * @return true if this an App Engine Flexible Instance, false otherwise
121
+ */
122
+ public static function onAppEngineFlexible()
123
+ {
124
+ return substr(getenv('GAE_INSTANCE'), 0, 4) === 'aef-';
125
+ }
126
+
127
+ /**
128
+ * Determines if this a GCE instance, by accessing the expected metadata
129
+ * host.
130
+ * If $httpHandler is not specified a the default HttpHandler is used.
131
+ *
132
+ * @param callable $httpHandler callback which delivers psr7 request
133
+ *
134
+ * @return true if this a GCEInstance false otherwise
135
+ */
136
+ public static function onGce(callable $httpHandler = null)
137
+ {
138
+ if (is_null($httpHandler)) {
139
+ $httpHandler = HttpHandlerFactory::build();
140
+ }
141
+ $checkUri = 'http://' . self::METADATA_IP;
142
+ for ($i = 1; $i <= self::MAX_COMPUTE_PING_TRIES; $i++) {
143
+ try {
144
+ // Comment from: oauth2client/client.py
145
+ //
146
+ // Note: the explicit `timeout` below is a workaround. The underlying
147
+ // issue is that resolving an unknown host on some networks will take
148
+ // 20-30 seconds; making this timeout short fixes the issue, but
149
+ // could lead to false negatives in the event that we are on GCE, but
150
+ // the metadata resolution was particularly slow. The latter case is
151
+ // "unlikely".
152
+ $resp = $httpHandler(
153
+ new Request('GET', $checkUri),
154
+ ['timeout' => self::COMPUTE_PING_CONNECTION_TIMEOUT_S]
155
+ );
156
+
157
+ return $resp->getHeaderLine(self::FLAVOR_HEADER) == 'Google';
158
+ } catch (ClientException $e) {
159
+ } catch (ServerException $e) {
160
+ } catch (RequestException $e) {
161
+ }
162
+ $httpHandler = HttpHandlerFactory::build();
163
+ }
164
+ return false;
165
+ }
166
+
167
+ /**
168
+ * Implements FetchAuthTokenInterface#fetchAuthToken.
169
+ *
170
+ * Fetches the auth tokens from the GCE metadata host if it is available.
171
+ * If $httpHandler is not specified a the default HttpHandler is used.
172
+ *
173
+ * @param callable $httpHandler callback which delivers psr7 request
174
+ *
175
+ * @return array the response
176
+ *
177
+ * @throws \Exception
178
+ */
179
+ public function fetchAuthToken(callable $httpHandler = null)
180
+ {
181
+ if (is_null($httpHandler)) {
182
+ $httpHandler = HttpHandlerFactory::build();
183
+ }
184
+ if (!$this->hasCheckedOnGce) {
185
+ $this->isOnGce = self::onGce($httpHandler);
186
+ }
187
+ if (!$this->isOnGce) {
188
+ return array(); // return an empty array with no access token
189
+ }
190
+ $resp = $httpHandler(
191
+ new Request(
192
+ 'GET',
193
+ self::getTokenUri(),
194
+ [self::FLAVOR_HEADER => 'Google']
195
+ )
196
+ );
197
+ $body = (string)$resp->getBody();
198
+
199
+ // Assume it's JSON; if it's not throw an exception
200
+ if (null === $json = json_decode($body, true)) {
201
+ throw new \Exception('Invalid JSON response');
202
+ }
203
+
204
+ // store this so we can retrieve it later
205
+ $this->lastReceivedToken = $json;
206
+ $this->lastReceivedToken['expires_at'] = time() + $json['expires_in'];
207
+
208
+ return $json;
209
+ }
210
+
211
+ /**
212
+ * @return string
213
+ */
214
+ public function getCacheKey()
215
+ {
216
+ return self::cacheKey;
217
+ }
218
+
219
+ /**
220
+ * @return array|null
221
+ */
222
+ public function getLastReceivedToken()
223
+ {
224
+ if ($this->lastReceivedToken) {
225
+ return [
226
+ 'access_token' => $this->lastReceivedToken['access_token'],
227
+ 'expires_at' => $this->lastReceivedToken['expires_at'],
228
+ ];
229
+ }
230
+
231
+ return null;
232
+ }
233
+ }
vendor/google/auth/src/Credentials/IAMCredentials.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2015 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ namespace Google\Auth\Credentials;
19
+
20
+ /**
21
+ * Authenticates requests using IAM credentials.
22
+ */
23
+ class IAMCredentials
24
+ {
25
+ const SELECTOR_KEY = 'x-goog-iam-authority-selector';
26
+ const TOKEN_KEY = 'x-goog-iam-authorization-token';
27
+
28
+ /**
29
+ * @var string
30
+ */
31
+ private $selector;
32
+
33
+ /**
34
+ * @var string
35
+ */
36
+ private $token;
37
+
38
+ /**
39
+ * @param $selector string the IAM selector
40
+ * @param $token string the IAM token
41
+ */
42
+ public function __construct($selector, $token)
43
+ {
44
+ if (!is_string($selector)) {
45
+ throw new \InvalidArgumentException(
46
+ 'selector must be a string');
47
+ }
48
+ if (!is_string($token)) {
49
+ throw new \InvalidArgumentException(
50
+ 'token must be a string');
51
+ }
52
+
53
+ $this->selector = $selector;
54
+ $this->token = $token;
55
+ }
56
+
57
+ /**
58
+ * export a callback function which updates runtime metadata.
59
+ *
60
+ * @return array updateMetadata function
61
+ */
62
+ public function getUpdateMetadataFunc()
63
+ {
64
+ return array($this, 'updateMetadata');
65
+ }
66
+
67
+ /**
68
+ * Updates metadata with the appropriate header metadata.
69
+ *
70
+ * @param array $metadata metadata hashmap
71
+ * @param string $unusedAuthUri optional auth uri
72
+ * @param callable $httpHandler callback which delivers psr7 request
73
+ * Note: this param is unused here, only included here for
74
+ * consistency with other credentials class
75
+ *
76
+ * @return array updated metadata hashmap
77
+ */
78
+ public function updateMetadata(
79
+ $metadata,
80
+ $unusedAuthUri = null,
81
+ callable $httpHandler = null
82
+ ) {
83
+ $metadata_copy = $metadata;
84
+ $metadata_copy[self::SELECTOR_KEY] = $this->selector;
85
+ $metadata_copy[self::TOKEN_KEY] = $this->token;
86
+
87
+ return $metadata_copy;
88
+ }
89
+ }
vendor/google/auth/src/Credentials/InsecureCredentials.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2018 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
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.
24
+ * This is useful for APIs which do not require authentication, for local
25
+ * service emulators, and for testing.
26
+ */
27
+ class InsecureCredentials implements FetchAuthTokenInterface
28
+ {
29
+ /**
30
+ * @var array
31
+ */
32
+ private $token = [
33
+ 'access_token' => ''
34
+ ];
35
+
36
+ /**
37
+ * Fetches the auth token. In this case it returns an empty string.
38
+ *
39
+ * @param callable $httpHandler
40
+ * @return array
41
+ */
42
+ public function fetchAuthToken(callable $httpHandler = null)
43
+ {
44
+ return $this->token;
45
+ }
46
+
47
+ /**
48
+ * Returns the cache key. In this case it returns a null value, disabling
49
+ * caching.
50
+ *
51
+ * @return string|null
52
+ */
53
+ public function getCacheKey()
54
+ {
55
+ return null;
56
+ }
57
+
58
+ /**
59
+ * Fetches the last received token. In this case, it returns the same empty string
60
+ * auth token.
61
+ *
62
+ * @return array
63
+ */
64
+ public function getLastReceivedToken()
65
+ {
66
+ return $this->token;
67
+ }
68
+ }
vendor/google/auth/src/Credentials/ServiceAccountCredentials.php ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2015 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
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
25
+ * account.
26
+ *
27
+ * (cf https://developers.google.com/accounts/docs/OAuth2ServiceAccount)
28
+ *
29
+ * It's initialized using the json key file that's downloadable from developer
30
+ * console, which should contain a private_key and client_email fields that it
31
+ * uses.
32
+ *
33
+ * Use it with AuthTokenMiddleware to authorize http requests:
34
+ *
35
+ * use Google\Auth\Credentials\ServiceAccountCredentials;
36
+ * use Google\Auth\Middleware\AuthTokenMiddleware;
37
+ * use GuzzleHttp\Client;
38
+ * use GuzzleHttp\HandlerStack;
39
+ *
40
+ * $sa = new ServiceAccountCredentials(
41
+ * 'https://www.googleapis.com/auth/taskqueue',
42
+ * '/path/to/your/json/key_file.json'
43
+ * );
44
+ * $middleware = new AuthTokenMiddleware($sa);
45
+ * $stack = HandlerStack::create();
46
+ * $stack->push($middleware);
47
+ *
48
+ * $client = new Client([
49
+ * 'handler' => $stack,
50
+ * 'base_uri' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
51
+ * 'auth' => 'google_auth' // authorize all requests
52
+ * ]);
53
+ *
54
+ * $res = $client->get('myproject/taskqueues/myqueue');
55
+ */
56
+ class ServiceAccountCredentials extends CredentialsLoader
57
+ {
58
+ /**
59
+ * The OAuth2 instance used to conduct authorization.
60
+ *
61
+ * @var OAuth2
62
+ */
63
+ protected $auth;
64
+
65
+ /**
66
+ * Create a new ServiceAccountCredentials.
67
+ *
68
+ * @param string|array $scope the scope of the access request, expressed
69
+ * either as an Array or as a space-delimited String.
70
+ * @param string|array $jsonKey JSON credential file path or JSON credentials
71
+ * as an associative array
72
+ * @param string $sub an email address account to impersonate, in situations when
73
+ * the service account has been delegated domain wide access.
74
+ */
75
+ public function __construct(
76
+ $scope,
77
+ $jsonKey,
78
+ $sub = null
79
+ ) {
80
+ if (is_string($jsonKey)) {
81
+ if (!file_exists($jsonKey)) {
82
+ throw new \InvalidArgumentException('file does not exist');
83
+ }
84
+ $jsonKeyStream = file_get_contents($jsonKey);
85
+ if (!$jsonKey = json_decode($jsonKeyStream, true)) {
86
+ throw new \LogicException('invalid json for auth config');
87
+ }
88
+ }
89
+ if (!array_key_exists('client_email', $jsonKey)) {
90
+ throw new \InvalidArgumentException(
91
+ 'json key is missing the client_email field');
92
+ }
93
+ if (!array_key_exists('private_key', $jsonKey)) {
94
+ throw new \InvalidArgumentException(
95
+ 'json key is missing the private_key field');
96
+ }
97
+ $this->auth = new OAuth2([
98
+ 'audience' => self::TOKEN_CREDENTIAL_URI,
99
+ 'issuer' => $jsonKey['client_email'],
100
+ 'scope' => $scope,
101
+ 'signingAlgorithm' => 'RS256',
102
+ 'signingKey' => $jsonKey['private_key'],
103
+ 'sub' => $sub,
104
+ 'tokenCredentialUri' => self::TOKEN_CREDENTIAL_URI,
105
+ ]);
106
+ }
107
+
108
+ /**
109
+ * @param callable $httpHandler
110
+ *
111
+ * @return array
112
+ */
113
+ public function fetchAuthToken(callable $httpHandler = null)
114
+ {
115
+ return $this->auth->fetchAuthToken($httpHandler);
116
+ }
117
+
118
+ /**
119
+ * @return string
120
+ */
121
+ public function getCacheKey()
122
+ {
123
+ $key = $this->auth->getIssuer() . ':' . $this->auth->getCacheKey();
124
+ if ($sub = $this->auth->getSub()) {
125
+ $key .= ':' . $sub;
126
+ }
127
+
128
+ return $key;
129
+ }
130
+
131
+ /**
132
+ * @return array
133
+ */
134
+ public function getLastReceivedToken()
135
+ {
136
+ return $this->auth->getLastReceivedToken();
137
+ }
138
+
139
+ /**
140
+ * Updates metadata with the authorization token.
141
+ *
142
+ * @param array $metadata metadata hashmap
143
+ * @param string $authUri optional auth uri
144
+ * @param callable $httpHandler callback which delivers psr7 request
145
+ *
146
+ * @return array updated metadata hashmap
147
+ */
148
+ public function updateMetadata(
149
+ $metadata,
150
+ $authUri = null,
151
+ callable $httpHandler = null
152
+ ) {
153
+ // scope exists. use oauth implementation
154
+ $scope = $this->auth->getScope();
155
+ if (!is_null($scope)) {
156
+ return parent::updateMetadata($metadata, $authUri, $httpHandler);
157
+ }
158
+
159
+ // no scope found. create jwt with the auth uri
160
+ $credJson = array(
161
+ 'private_key' => $this->auth->getSigningKey(),
162
+ 'client_email' => $this->auth->getIssuer(),
163
+ );
164
+ $jwtCreds = new ServiceAccountJwtAccessCredentials($credJson);
165
+
166
+ return $jwtCreds->updateMetadata($metadata, $authUri, $httpHandler);
167
+ }
168
+
169
+ /**
170
+ * @param string $sub an email address account to impersonate, in situations when
171
+ * the service account has been delegated domain wide access.
172
+ */
173
+ public function setSub($sub)
174
+ {
175
+ $this->auth->setSub($sub);
176
+ }
177
+ }
vendor/google/auth/src/Credentials/ServiceAccountJwtAccessCredentials.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2015 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
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
25
+ * JWT Access.
26
+ *
27
+ * This class allows authorizing requests for service accounts directly
28
+ * from credentials from a json key file downloaded from the developer
29
+ * console (via 'Generate new Json Key'). It is not part of any OAuth2
30
+ * flow, rather it creates a JWT and sends that as a credential.
31
+ */
32
+ class ServiceAccountJwtAccessCredentials extends CredentialsLoader
33
+ {
34
+ /**
35
+ * The OAuth2 instance used to conduct authorization.
36
+ *
37
+ * @var OAuth2
38
+ */
39
+ protected $auth;
40
+
41
+ /**
42
+ * Create a new ServiceAccountJwtAccessCredentials.
43
+ *
44
+ * @param string|array $jsonKey JSON credential file path or JSON credentials
45
+ * as an associative array
46
+ */
47
+ public function __construct($jsonKey)
48
+ {
49
+ if (is_string($jsonKey)) {
50
+ if (!file_exists($jsonKey)) {
51
+ throw new \InvalidArgumentException('file does not exist');
52
+ }
53
+ $jsonKeyStream = file_get_contents($jsonKey);
54
+ if (!$jsonKey = json_decode($jsonKeyStream, true)) {
55
+ throw new \LogicException('invalid json for auth config');
56
+ }
57
+ }
58
+ if (!array_key_exists('client_email', $jsonKey)) {
59
+ throw new \InvalidArgumentException(
60
+ 'json key is missing the client_email field');
61
+ }
62
+ if (!array_key_exists('private_key', $jsonKey)) {
63
+ throw new \InvalidArgumentException(
64
+ 'json key is missing the private_key field');
65
+ }
66
+ $this->auth = new OAuth2([
67
+ 'issuer' => $jsonKey['client_email'],
68
+ 'sub' => $jsonKey['client_email'],
69
+ 'signingAlgorithm' => 'RS256',
70
+ 'signingKey' => $jsonKey['private_key'],
71
+ ]);
72
+ }
73
+
74
+ /**
75
+ * Updates metadata with the authorization token.
76
+ *
77
+ * @param array $metadata metadata hashmap
78
+ * @param string $authUri optional auth uri
79
+ * @param callable $httpHandler callback which delivers psr7 request
80
+ *
81
+ * @return array updated metadata hashmap
82
+ */
83
+ public function updateMetadata(
84
+ $metadata,
85
+ $authUri = null,
86
+ callable $httpHandler = null
87
+ ) {
88
+ if (empty($authUri)) {
89
+ return $metadata;
90
+ }
91
+
92
+ $this->auth->setAudience($authUri);
93
+
94
+ return parent::updateMetadata($metadata, $authUri, $httpHandler);
95
+ }
96
+
97
+ /**
98
+ * Implements FetchAuthTokenInterface#fetchAuthToken.
99
+ *
100
+ * @param callable $httpHandler
101
+ *
102
+ * @return array|void
103
+ */
104
+ public function fetchAuthToken(callable $httpHandler = null)
105
+ {
106
+ $audience = $this->auth->getAudience();
107
+ if (empty($audience)) {
108
+ return null;
109
+ }
110
+
111
+ $access_token = $this->auth->toJwt();
112
+
113
+ return array('access_token' => $access_token);
114
+ }
115
+
116
+ /**
117
+ * @return string
118
+ */
119
+ public function getCacheKey()
120
+ {
121
+ return $this->auth->getCacheKey();
122
+ }
123
+
124
+ /**
125
+ * @return array
126
+ */
127
+ public function getLastReceivedToken()
128
+ {
129
+ return $this->auth->getLastReceivedToken();
130
+ }
131
+ }
vendor/google/auth/src/Credentials/UserRefreshCredentials.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2015 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
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.
25
+ *
26
+ * This class allows authorizing requests from user refresh tokens.
27
+ *
28
+ * This the end of the result of a 3LO flow. E.g, the end result of
29
+ * 'gcloud auth login' saves a file with these contents in well known
30
+ * location
31
+ *
32
+ * @see [Application Default Credentials](http://goo.gl/mkAHpZ)
33
+ */
34
+ class UserRefreshCredentials extends CredentialsLoader
35
+ {
36
+ const CLOUD_SDK_CLIENT_ID =
37
+ '764086051850-6qr4p6gpi6hn506pt8ejuq83di341hur.apps.googleusercontent.com';
38
+
39
+ const SUPPRESS_CLOUD_SDK_CREDS_WARNING_ENV = 'SUPPRESS_GCLOUD_CREDS_WARNING';
40
+
41
+ /**
42
+ * The OAuth2 instance used to conduct authorization.
43
+ *
44
+ * @var OAuth2
45
+ */
46
+ protected $auth;
47
+
48
+ /**
49
+ * Create a new UserRefreshCredentials.
50
+ *
51
+ * @param string|array $scope the scope of the access request, expressed
52
+ * either as an Array or as a space-delimited String.
53
+ * @param string|array $jsonKey JSON credential file path or JSON credentials
54
+ * as an associative array
55
+ */
56
+ public function __construct(
57
+ $scope,
58
+ $jsonKey
59
+ ) {
60
+ if (is_string($jsonKey)) {
61
+ if (!file_exists($jsonKey)) {
62
+ throw new \InvalidArgumentException('file does not exist');
63
+ }
64
+ $jsonKeyStream = file_get_contents($jsonKey);
65
+ if (!$jsonKey = json_decode($jsonKeyStream, true)) {
66
+ throw new \LogicException('invalid json for auth config');
67
+ }
68
+ }
69
+ if (!array_key_exists('client_id', $jsonKey)) {
70
+ throw new \InvalidArgumentException(
71
+ 'json key is missing the client_id field');
72
+ }
73
+ if (!array_key_exists('client_secret', $jsonKey)) {
74
+ throw new \InvalidArgumentException(
75
+ 'json key is missing the client_secret field');
76
+ }
77
+ if (!array_key_exists('refresh_token', $jsonKey)) {
78
+ throw new \InvalidArgumentException(
79
+ 'json key is missing the refresh_token field');
80
+ }
81
+ $this->auth = new OAuth2([
82
+ 'clientId' => $jsonKey['client_id'],
83
+ 'clientSecret' => $jsonKey['client_secret'],
84
+ 'refresh_token' => $jsonKey['refresh_token'],
85
+ 'scope' => $scope,
86
+ 'tokenCredentialUri' => self::TOKEN_CREDENTIAL_URI,
87
+ ]);
88
+ if ($jsonKey['client_id'] === self::CLOUD_SDK_CLIENT_ID
89
+ && getenv(self::SUPPRESS_CLOUD_SDK_CREDS_WARNING_ENV) !== 'true') {
90
+ trigger_error(
91
+ 'Your application has authenticated using end user credentials '
92
+ . 'from Google Cloud SDK. We recommend that most server '
93
+ . 'applications use service accounts instead. If your '
94
+ . 'application continues to use end user credentials '
95
+ . 'from Cloud SDK, you might receive a "quota exceeded" '
96
+ . 'or "API not enabled" error. For more information about '
97
+ . 'service accounts, see '
98
+ . 'https://cloud.google.com/docs/authentication/. '
99
+ . 'To disable this warning, set '
100
+ . self::SUPPRESS_CLOUD_SDK_CREDS_WARNING_ENV
101
+ . ' environment variable to "true".',
102
+ E_USER_WARNING);
103
+ }
104
+ }
105
+
106
+ /**
107
+ * @param callable $httpHandler
108
+ *
109
+ * @return array
110
+ */
111
+ public function fetchAuthToken(callable $httpHandler = null)
112
+ {
113
+ return $this->auth->fetchAuthToken($httpHandler);
114
+ }
115
+
116
+ /**
117
+ * @return string
118
+ */
119
+ public function getCacheKey()
120
+ {
121
+ return $this->auth->getClientId() . ':' . $this->auth->getCacheKey();
122
+ }
123
+
124
+ /**
125
+ * @return array
126
+ */
127
+ public function getLastReceivedToken()
128
+ {
129
+ return $this->auth->getLastReceivedToken();
130
+ }
131
+ }
vendor/google/auth/src/CredentialsLoader.php ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2015 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
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
26
+ * credentials files on the file system.
27
+ */
28
+ abstract class CredentialsLoader implements FetchAuthTokenInterface
29
+ {
30
+ const TOKEN_CREDENTIAL_URI = 'https://oauth2.googleapis.com/token';
31
+ const ENV_VAR = 'GOOGLE_APPLICATION_CREDENTIALS';
32
+ const WELL_KNOWN_PATH = 'gcloud/application_default_credentials.json';
33
+ const NON_WINDOWS_WELL_KNOWN_PATH_BASE = '.config';
34
+ const AUTH_METADATA_KEY = 'authorization';
35
+
36
+ /**
37
+ * @param string $cause
38
+ * @return string
39
+ */
40
+ private static function unableToReadEnv($cause)
41
+ {
42
+ $msg = 'Unable to read the credential file specified by ';
43
+ $msg .= ' GOOGLE_APPLICATION_CREDENTIALS: ';
44
+ $msg .= $cause;
45
+
46
+ return $msg;
47
+ }
48
+
49
+ /**
50
+ * @return bool
51
+ */
52
+ private static function isOnWindows()
53
+ {
54
+ return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
55
+ }
56
+
57
+ /**
58
+ * Load a JSON key from the path specified in the environment.
59
+ *
60
+ * Load a JSON key from the path specified in the environment
61
+ * variable GOOGLE_APPLICATION_CREDENTIALS. Return null if
62
+ * GOOGLE_APPLICATION_CREDENTIALS is not specified.
63
+ *
64
+ * @return array JSON key | null
65
+ */
66
+ public static function fromEnv()
67
+ {
68
+ $path = getenv(self::ENV_VAR);
69
+ if (empty($path)) {
70
+ return;
71
+ }
72
+ if (!file_exists($path)) {
73
+ $cause = 'file ' . $path . ' does not exist';
74
+ throw new \DomainException(self::unableToReadEnv($cause));
75
+ }
76
+ $jsonKey = file_get_contents($path);
77
+ return json_decode($jsonKey, true);
78
+ }
79
+
80
+ /**
81
+ * Load a JSON key from a well known path.
82
+ *
83
+ * The well known path is OS dependent:
84
+ * - windows: %APPDATA%/gcloud/application_default_credentials.json
85
+ * - others: $HOME/.config/gcloud/application_default_credentials.json
86
+ *
87
+ * If the file does not exists, this returns null.
88
+ *
89
+ * @return array JSON key | null
90
+ */
91
+ public static function fromWellKnownFile()
92
+ {
93
+ $rootEnv = self::isOnWindows() ? 'APPDATA' : 'HOME';
94
+ $path = [getenv($rootEnv)];
95
+ if (!self::isOnWindows()) {
96
+ $path[] = self::NON_WINDOWS_WELL_KNOWN_PATH_BASE;
97
+ }
98
+ $path[] = self::WELL_KNOWN_PATH;
99
+ $path = implode(DIRECTORY_SEPARATOR, $path);
100
+ if (!file_exists($path)) {
101
+ return;
102
+ }
103
+ $jsonKey = file_get_contents($path);
104
+ return json_decode($jsonKey, true);
105
+ }
106
+
107
+ /**
108
+ * Create a new Credentials instance.
109
+ *
110
+ * @param string|array $scope the scope of the access request, expressed
111
+ * either as an Array or as a space-delimited String.
112
+ * @param array $jsonKey the JSON credentials.
113
+ *
114
+ * @return ServiceAccountCredentials|UserRefreshCredentials
115
+ */
116
+ public static function makeCredentials($scope, array $jsonKey)
117
+ {
118
+ if (!array_key_exists('type', $jsonKey)) {
119
+ throw new \InvalidArgumentException('json key is missing the type field');
120
+ }
121
+
122
+ if ($jsonKey['type'] == 'service_account') {
123
+ return new ServiceAccountCredentials($scope, $jsonKey);
124
+ }
125
+
126
+ if ($jsonKey['type'] == 'authorized_user') {
127
+ return new UserRefreshCredentials($scope, $jsonKey);
128
+ }
129
+
130
+ throw new \InvalidArgumentException('invalid value in the type field');
131
+ }
132
+
133
+ /**
134
+ * Create an authorized HTTP Client from an instance of FetchAuthTokenInterface.
135
+ *
136
+ * @param FetchAuthTokenInterface $fetcher is used to fetch the auth token
137
+ * @param array $httpClientOptoins (optional) Array of request options to apply.
138
+ * @param callable $httpHandler (optional) http client to fetch the token.
139
+ * @param callable $tokenCallback (optional) function to be called when a new token is fetched.
140
+ *
141
+ * @return \GuzzleHttp\Client
142
+ */
143
+ public static function makeHttpClient(
144
+ FetchAuthTokenInterface $fetcher,
145
+ array $httpClientOptions = [],
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,
157
+ $httpHandler,
158
+ $tokenCallback
159
+ );
160
+ $client->getEmitter()->attach($subscriber);
161
+ return $client;
162
+ case '6':
163
+ $middleware = new Middleware\AuthTokenMiddleware(
164
+ $fetcher,
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);
175
+ default:
176
+ throw new \Exception('Version not supported');
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Create a new instance of InsecureCredentials.
182
+ *
183
+ * @return InsecureCredentials
184
+ */
185
+ public static function makeInsecureCredentials()
186
+ {
187
+ return new InsecureCredentials();
188
+ }
189
+
190
+ /**
191
+ * export a callback function which updates runtime metadata.
192
+ *
193
+ * @return array updateMetadata function
194
+ */
195
+ public function getUpdateMetadataFunc()
196
+ {
197
+ return array($this, 'updateMetadata');
198
+ }
199
+
200
+ /**
201
+ * Updates metadata with the authorization token.
202
+ *
203
+ * @param array $metadata metadata hashmap
204
+ * @param string $authUri optional auth uri
205
+ * @param callable $httpHandler callback which delivers psr7 request
206
+ *
207
+ * @return array updated metadata hashmap
208
+ */
209
+ public function updateMetadata(
210
+ $metadata,
211
+ $authUri = null,
212
+ callable $httpHandler = null
213
+ ) {
214
+ $result = $this->fetchAuthToken($httpHandler);
215
+ if (!isset($result['access_token'])) {
216
+ return $metadata;
217
+ }
218
+ $metadata_copy = $metadata;
219
+ $metadata_copy[self::AUTH_METADATA_KEY] = array('Bearer ' . $result['access_token']);
220
+
221
+ return $metadata_copy;
222
+ }
223
+ }
vendor/google/auth/src/FetchAuthTokenCache.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
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
24
+ * FetchAuthTokenInterface
25
+ */
26
+ class FetchAuthTokenCache implements FetchAuthTokenInterface
27
+ {
28
+ use CacheTrait;
29
+
30
+ /**
31
+ * @var FetchAuthTokenInterface
32
+ */
33
+ private $fetcher;
34
+
35
+ /**
36
+ * @var array
37
+ */
38
+ private $cacheConfig;
39
+
40
+ /**
41
+ * @var CacheItemPoolInterface
42
+ */
43
+ private $cache;
44
+
45
+ public function __construct(
46
+ FetchAuthTokenInterface $fetcher,
47
+ array $cacheConfig = null,
48
+ CacheItemPoolInterface $cache
49
+ ) {
50
+ $this->fetcher = $fetcher;
51
+ $this->cache = $cache;
52
+ $this->cacheConfig = array_merge([
53
+ 'lifetime' => 1500,
54
+ 'prefix' => '',
55
+ ], (array) $cacheConfig);
56
+ }
57
+
58
+ /**
59
+ * Implements FetchAuthTokenInterface#fetchAuthToken.
60
+ *
61
+ * Checks the cache for a valid auth token and fetches the auth tokens
62
+ * from the supplied fetcher.
63
+ *
64
+ * @param callable $httpHandler callback which delivers psr7 request
65
+ *
66
+ * @return array the response
67
+ *
68
+ * @throws \Exception
69
+ */
70
+ public function fetchAuthToken(callable $httpHandler = null)
71
+ {
72
+ // Use the cached value if its available.
73
+ //
74
+ // TODO: correct caching; update the call to setCachedValue to set the expiry
75
+ // to the value returned with the auth token.
76
+ //
77
+ // TODO: correct caching; enable the cache to be cleared.
78
+ $cacheKey = $this->fetcher->getCacheKey();
79
+ $cached = $this->getCachedValue($cacheKey);
80
+ if (!empty($cached)) {
81
+ return ['access_token' => $cached];
82
+ }
83
+
84
+ $auth_token = $this->fetcher->fetchAuthToken($httpHandler);
85
+
86
+ if (isset($auth_token['access_token'])) {
87
+ $this->setCachedValue($cacheKey, $auth_token['access_token']);
88
+ }
89
+
90
+ return $auth_token;
91
+ }
92
+
93
+ /**
94
+ * @return string
95
+ */
96
+ public function getCacheKey()
97
+ {
98
+ return $this->getFullCacheKey($this->fetcher->getCacheKey());
99
+ }
100
+
101
+ /**
102
+ * @return array|null
103
+ */
104
+ public function getLastReceivedToken()
105
+ {
106
+ return $this->fetcher->getLastReceivedToken();
107
+ }
108
+ }
vendor/google/auth/src/FetchAuthTokenInterface.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2015 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ namespace Google\Auth;
19
+
20
+ /**
21
+ * An interface implemented by objects that can fetch auth tokens.
22
+ */
23
+ interface FetchAuthTokenInterface
24
+ {
25
+ /**
26
+ * Fetches the auth tokens based on the current state.
27
+ *
28
+ * @param callable $httpHandler callback which delivers psr7 request
29
+ *
30
+ * @return array a hash of auth tokens
31
+ */
32
+ public function fetchAuthToken(callable $httpHandler = null);
33
+
34
+ /**
35
+ * Obtains a key that can used to cache the results of #fetchAuthToken.
36
+ *
37
+ * If the value is empty, the auth token is not cached.
38
+ *
39
+ * @return string a key that may be used to cache the auth token.
40
+ */
41
+ public function getCacheKey();
42
+
43
+ /**
44
+ * Returns an associative array with the token and
45
+ * expiration time.
46
+ *
47
+ * @return null|array {
48
+ * The last received access token.
49
+ *
50
+ * @var string $access_token The access token string.
51
+ * @var int $expires_at The time the token expires as a UNIX timestamp.
52
+ * }
53
+ */
54
+ public function getLastReceivedToken();
55
+ }
vendor/google/auth/src/HttpHandler/Guzzle5HttpHandler.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 Google Inc. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
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
+ {
30
+ /**
31
+ * @var ClientInterface
32
+ */
33
+ private $client;
34
+
35
+ /**
36
+ * @param ClientInterface $client
37
+ */
38
+ public function __construct(ClientInterface $client)
39
+ {
40
+ $this->client = $client;
41
+ }
42
+
43
+ /**
44
+ * Accepts a PSR-7 Request and an array of options and returns a PSR-7 response.
45
+ *
46
+ * @param RequestInterface $request
47
+ * @param array $options
48
+ *
49
+ * @return ResponseInterface
50
+ */
51
+ public function __invoke(RequestInterface $request, array $options = [])
52
+ {
53
+ $response = $this->client->send(
54
+ $this->createGuzzle5Request($request, $options)
55
+ );
56
+
57
+ return $this->createPsr7Response($response);
58
+ }
59
+
60
+ /**
61
+ * Accepts a PSR-7 request and an array of options and returns a PromiseInterface
62
+ *
63
+ * @param RequestInterface $request
64
+ * @param array $options
65
+ *
66
+ * @return Promise
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
+
74
+ $futureResponse = $this->client->send(
75
+ $this->createGuzzle5Request(
76
+ $request,
77
+ ['future' => true] + $options
78
+ )
79
+ );
80
+
81
+ $promise = new Promise(
82
+ function () use ($futureResponse) {
83
+ try {
84
+ $futureResponse->wait();
85
+ } catch (Exception $e) {
86
+ // The promise is already delivered when the exception is
87
+ // thrown, so don't rethrow it.
88
+ }
89
+ },
90
+ [$futureResponse, 'cancel']
91
+ );
92
+
93
+ $futureResponse->then([$promise, 'resolve'], [$promise, 'reject']);
94
+
95
+ return $promise->then(
96
+ function (Guzzle5ResponseInterface $response) {
97
+ // Adapt the Guzzle 5 Response to a PSR-7 Response.
98
+ return $this->createPsr7Response($response);
99
+ },
100
+ function (Exception $e) {
101
+ return new RejectedPromise($e);
102
+ }
103
+ );
104
+ }
105
+
106
+ private function createGuzzle5Request(RequestInterface $request, array $options)
107
+ {
108
+ return $this->client->createRequest(
109
+ $request->getMethod(),
110
+ $request->getUri(),
111
+ array_merge_recursive([
112
+ 'headers' => $request->getHeaders(),
113
+ 'body' => $request->getBody(),
114
+ ], $options)
115
+ );
116
+ }
117
+
118
+ private function createPsr7Response(Guzzle5ResponseInterface $response)
119
+ {
120
+ return new Response(
121
+ $response->getStatusCode(),
122
+ $response->getHeaders() ?: [],
123
+ $response->getBody(),
124
+ $response->getProtocolVersion(),
125
+ $response->getReasonPhrase()
126
+ );
127
+ }
128
+ }
vendor/google/auth/src/HttpHandler/Guzzle6HttpHandler.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ {
11
+ /**
12
+ * @var ClientInterface
13
+ */
14
+ private $client;
15
+
16
+ /**
17
+ * @param ClientInterface $client
18
+ */
19
+ public function __construct(ClientInterface $client)
20
+ {
21
+ $this->client = $client;
22
+ }
23
+
24
+ /**
25
+ * Accepts a PSR-7 request and an array of options and returns a PSR-7 response.
26
+ *
27
+ * @param RequestInterface $request
28
+ * @param array $options
29
+ *
30
+ * @return ResponseInterface
31
+ */
32
+ public function __invoke(RequestInterface $request, array $options = [])
33
+ {
34
+ return $this->client->send($request, $options);
35
+ }
36
+
37
+ /**
38
+ * Accepts a PSR-7 request and an array of options and returns a PromiseInterface
39
+ *
40
+ * @param RequestInterface $request
41
+ * @param array $options
42
+ *
43
+ * @return \GuzzleHttp\Promise\Promise
44
+ */
45
+ public function async(RequestInterface $request, array $options = [])
46
+ {
47
+ return $this->client->sendAsync($request, $options);
48
+ }
49
+ }
vendor/google/auth/src/HttpHandler/HttpHandlerFactory.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2015 Google Inc. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
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
+ {
24
+ /**
25
+ * Builds out a default http handler for the installed version of guzzle.
26
+ *
27
+ * @param ClientInterface $client
28
+ *
29
+ * @return Guzzle5HttpHandler|Guzzle6HttpHandler
30
+ *
31
+ * @throws \Exception
32
+ */
33
+ public static function build(ClientInterface $client = null)
34
+ {
35
+ $version = ClientInterface::VERSION;
36
+ $client = $client ?: new Client();
37
+
38
+ switch ($version[0]) {
39
+ case '5':
40
+ return new Guzzle5HttpHandler($client);
41
+ case '6':
42
+ return new Guzzle6HttpHandler($client);
43
+ default:
44
+ throw new \Exception('Version not supported');
45
+ }
46
+ }
47
+ }
vendor/google/auth/src/Middleware/AuthTokenMiddleware.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2015 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
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
25
+ * provided by an object implementing FetchAuthTokenInterface.
26
+ *
27
+ * The FetchAuthTokenInterface#fetchAuthToken is used to obtain a hash; one of
28
+ * the values value in that hash is added as the authorization header.
29
+ *
30
+ * Requests will be accessed with the authorization header:
31
+ *
32
+ * 'authorization' 'Bearer <value of auth_token>'
33
+ */
34
+ class AuthTokenMiddleware
35
+ {
36
+ /**
37
+ * @var callback
38
+ */
39
+ private $httpHandler;
40
+
41
+ /**
42
+ * @var FetchAuthTokenInterface
43
+ */
44
+ private $fetcher;
45
+
46
+ /**
47
+ * @var callable
48
+ */
49
+ private $tokenCallback;
50
+
51
+ /**
52
+ * Creates a new AuthTokenMiddleware.
53
+ *
54
+ * @param FetchAuthTokenInterface $fetcher is used to fetch the auth token
55
+ * @param callable $httpHandler (optional) callback which delivers psr7 request
56
+ * @param callable $tokenCallback (optional) function to be called when a new token is fetched.
57
+ */
58
+ public function __construct(
59
+ FetchAuthTokenInterface $fetcher,
60
+ callable $httpHandler = null,
61
+ callable $tokenCallback = null
62
+ ) {
63
+ $this->fetcher = $fetcher;
64
+ $this->httpHandler = $httpHandler;
65
+ $this->tokenCallback = $tokenCallback;
66
+ }
67
+
68
+ /**
69
+ * Updates the request with an Authorization header when auth is 'google_auth'.
70
+ *
71
+ * use Google\Auth\Middleware\AuthTokenMiddleware;
72
+ * use Google\Auth\OAuth2;
73
+ * use GuzzleHttp\Client;
74
+ * use GuzzleHttp\HandlerStack;
75
+ *
76
+ * $config = [..<oauth config param>.];
77
+ * $oauth2 = new OAuth2($config)
78
+ * $middleware = new AuthTokenMiddleware($oauth2);
79
+ * $stack = HandlerStack::create();
80
+ * $stack->push($middleware);
81
+ *
82
+ * $client = new Client([
83
+ * 'handler' => $stack,
84
+ * 'base_uri' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
85
+ * 'auth' => 'google_auth' // authorize all requests
86
+ * ]);
87
+ *
88
+ * $res = $client->get('myproject/taskqueues/myqueue');
89
+ *
90
+ * @param callable $handler
91
+ *
92
+ * @return \Closure
93
+ */
94
+ public function __invoke(callable $handler)
95
+ {
96
+ return function (RequestInterface $request, array $options) use ($handler) {
97
+ // Requests using "auth"="google_auth" will be authorized.
98
+ if (!isset($options['auth']) || $options['auth'] !== 'google_auth') {
99
+ return $handler($request, $options);
100
+ }
101
+
102
+ $request = $request->withHeader('authorization', 'Bearer ' . $this->fetchToken());
103
+
104
+ return $handler($request, $options);
105
+ };
106
+ }
107
+
108
+ /**
109
+ * Call fetcher to fetch the token.
110
+ *
111
+ * @return string
112
+ */
113
+ private function fetchToken()
114
+ {
115
+ $auth_tokens = $this->fetcher->fetchAuthToken($this->httpHandler);
116
+
117
+ if (array_key_exists('access_token', $auth_tokens)) {
118
+ // notify the callback if applicable
119
+ if ($this->tokenCallback) {
120
+ call_user_func($this->tokenCallback, $this->fetcher->getCacheKey(), $auth_tokens['access_token']);
121
+ }
122
+
123
+ return $auth_tokens['access_token'];
124
+ }
125
+ }
126
+ }
vendor/google/auth/src/Middleware/ScopedAccessTokenMiddleware.php ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2015 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
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
26
+ * header provided by a closure.
27
+ *
28
+ * The closure returns an access token, taking the scope, either a single
29
+ * string or an array of strings, as its value. If provided, a cache will be
30
+ * used to preserve the access token for a given lifetime.
31
+ *
32
+ * Requests will be accessed with the authorization header:
33
+ *
34
+ * 'authorization' 'Bearer <value of auth_token>'
35
+ */
36
+ class ScopedAccessTokenMiddleware
37
+ {
38
+ use CacheTrait;
39
+
40
+ const DEFAULT_CACHE_LIFETIME = 1500;
41
+
42
+ /**
43
+ * @var CacheItemPoolInterface
44
+ */
45
+ private $cache;
46
+
47
+ /**
48
+ * @var array configuration
49
+ */
50
+ private $cacheConfig;
51
+
52
+ /**
53
+ * @var callable
54
+ */
55
+ private $tokenFunc;
56
+
57
+ /**
58
+ * @var array|string
59
+ */
60
+ private $scopes;
61
+
62
+ /**
63
+ * Creates a new ScopedAccessTokenMiddleware.
64
+ *
65
+ * @param callable $tokenFunc a token generator function
66
+ * @param array|string $scopes the token authentication scopes
67
+ * @param array $cacheConfig configuration for the cache when it's present
68
+ * @param CacheItemPoolInterface $cache an implementation of CacheItemPoolInterface
69
+ */
70
+ public function __construct(
71
+ callable $tokenFunc,
72
+ $scopes,
73
+ array $cacheConfig = null,
74
+ CacheItemPoolInterface $cache = null
75
+ ) {
76
+ $this->tokenFunc = $tokenFunc;
77
+ if (!(is_string($scopes) || is_array($scopes))) {
78
+ throw new \InvalidArgumentException(
79
+ 'wants scope should be string or array');
80
+ }
81
+ $this->scopes = $scopes;
82
+
83
+ if (!is_null($cache)) {
84
+ $this->cache = $cache;
85
+ $this->cacheConfig = array_merge([
86
+ 'lifetime' => self::DEFAULT_CACHE_LIFETIME,
87
+ 'prefix' => '',
88
+ ], $cacheConfig);
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Updates the request with an Authorization header when auth is 'scoped'.
94
+ *
95
+ * E.g this could be used to authenticate using the AppEngine
96
+ * AppIdentityService.
97
+ *
98
+ * use google\appengine\api\app_identity\AppIdentityService;
99
+ * use Google\Auth\Middleware\ScopedAccessTokenMiddleware;
100
+ * use GuzzleHttp\Client;
101
+ * use GuzzleHttp\HandlerStack;
102
+ *
103
+ * $scope = 'https://www.googleapis.com/auth/taskqueue'
104
+ * $middleware = new ScopedAccessTokenMiddleware(
105
+ * 'AppIdentityService::getAccessToken',
106
+ * $scope,
107
+ * [ 'prefix' => 'Google\Auth\ScopedAccessToken::' ],
108
+ * $cache = new Memcache()
109
+ * );
110
+ * $stack = HandlerStack::create();
111
+ * $stack->push($middleware);
112
+ *
113
+ * $client = new Client([
114
+ * 'handler' => $stack,
115
+ * 'base_url' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
116
+ * 'auth' => 'scoped' // authorize all requests
117
+ * ]);
118
+ *
119
+ * $res = $client->get('myproject/taskqueues/myqueue');
120
+ *
121
+ * @param callable $handler
122
+ *
123
+ * @return \Closure
124
+ */
125
+ public function __invoke(callable $handler)
126
+ {
127
+ return function (RequestInterface $request, array $options) use ($handler) {
128
+ // Requests using "auth"="scoped" will be authorized.
129
+ if (!isset($options['auth']) || $options['auth'] !== 'scoped') {
130
+ return $handler($request, $options);
131
+ }
132
+
133
+ $request = $request->withHeader('authorization', 'Bearer ' . $this->fetchToken());
134
+
135
+ return $handler($request, $options);
136
+ };
137
+ }
138
+
139
+ /**
140
+ * @return string
141
+ */
142
+ private function getCacheKey()
143
+ {
144
+ $key = null;
145
+
146
+ if (is_string($this->scopes)) {
147
+ $key .= $this->scopes;
148
+ } elseif (is_array($this->scopes)) {
149
+ $key .= implode(':', $this->scopes);
150
+ }
151
+
152
+ return $key;
153
+ }
154
+
155
+ /**
156
+ * Determine if token is available in the cache, if not call tokenFunc to
157
+ * fetch it.
158
+ *
159
+ * @return string
160
+ */
161
+ private function fetchToken()
162
+ {
163
+ $cacheKey = $this->getCacheKey();
164
+ $cached = $this->getCachedValue($cacheKey);
165
+
166
+ if (!empty($cached)) {
167
+ return $cached;
168
+ }
169
+
170
+ $token = call_user_func($this->tokenFunc, $this->scopes);
171
+ $this->setCachedValue($cacheKey, $token);
172
+
173
+ return $token;
174
+ }
175
+ }
vendor/google/auth/src/Middleware/SimpleMiddleware.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2015 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
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
25
+ * access.
26
+ *
27
+ * Requests are accessed using the Simple API access developer key.
28
+ */
29
+ class SimpleMiddleware
30
+ {
31
+ /**
32
+ * @var array
33
+ */
34
+ private $config;
35
+
36
+ /**
37
+ * Create a new Simple plugin.
38
+ *
39
+ * The configuration array expects one option
40
+ * - key: required, otherwise InvalidArgumentException is thrown
41
+ *
42
+ * @param array $config Configuration array
43
+ */
44
+ public function __construct(array $config)
45
+ {
46
+ if (!isset($config['key'])) {
47
+ throw new \InvalidArgumentException('requires a key to have been set');
48
+ }
49
+
50
+ $this->config = array_merge(['key' => null], $config);
51
+ }
52
+
53
+ /**
54
+ * Updates the request query with the developer key if auth is set to simple.
55
+ *
56
+ * use Google\Auth\Middleware\SimpleMiddleware;
57
+ * use GuzzleHttp\Client;
58
+ * use GuzzleHttp\HandlerStack;
59
+ *
60
+ * $my_key = 'is not the same as yours';
61
+ * $middleware = new SimpleMiddleware(['key' => $my_key]);
62
+ * $stack = HandlerStack::create();
63
+ * $stack->push($middleware);
64
+ *
65
+ * $client = new Client([
66
+ * 'handler' => $stack,
67
+ * 'base_uri' => 'https://www.googleapis.com/discovery/v1/',
68
+ * 'auth' => 'simple'
69
+ * ]);
70
+ *
71
+ * $res = $client->get('drive/v2/rest');
72
+ *
73
+ * @param callable $handler
74
+ *
75
+ * @return \Closure
76
+ */
77
+ public function __invoke(callable $handler)
78
+ {
79
+ return function (RequestInterface $request, array $options) use ($handler) {
80
+ // Requests using "auth"="scoped" will be authorized.
81
+ if (!isset($options['auth']) || $options['auth'] !== 'simple') {
82
+ return $handler($request, $options);
83
+ }
84
+
85
+ $query = Psr7\parse_query($request->getUri()->getQuery());
86
+ $params = array_merge($query, $this->config);
87
+ $uri = $request->getUri()->withQuery(Psr7\build_query($params));
88
+ $request = $request->withUri($uri);
89
+
90
+ return $handler($request, $options);
91
+ };
92
+ }
93
+ }
vendor/google/auth/src/OAuth2.php ADDED
@@ -0,0 +1,1345 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2015 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
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.
30
+ *
31
+ * It primary supports
32
+ * - service account authorization
33
+ * - authorization where a user already has an access token
34
+ */
35
+ class OAuth2 implements FetchAuthTokenInterface
36
+ {
37
+ const DEFAULT_EXPIRY_SECONDS = 3600; // 1 hour
38
+ const DEFAULT_SKEW_SECONDS = 60; // 1 minute
39
+ const JWT_URN = 'urn:ietf:params:oauth:grant-type:jwt-bearer';
40
+
41
+ /**
42
+ * TODO: determine known methods from the keys of JWT::methods.
43
+ */
44
+ public static $knownSigningAlgorithms = array(
45
+ 'HS256',
46
+ 'HS512',
47
+ 'HS384',
48
+ 'RS256',
49
+ );
50
+
51
+ /**
52
+ * The well known grant types.
53
+ *
54
+ * @var array
55
+ */
56
+ public static $knownGrantTypes = array(
57
+ 'authorization_code',
58
+ 'refresh_token',
59
+ 'password',
60
+ 'client_credentials',
61
+ );
62
+
63
+ /**
64
+ * - authorizationUri
65
+ * The authorization server's HTTP endpoint capable of
66
+ * authenticating the end-user and obtaining authorization.
67
+ *
68
+ * @var UriInterface
69
+ */
70
+ private $authorizationUri;
71
+
72
+ /**
73
+ * - tokenCredentialUri
74
+ * The authorization server's HTTP endpoint capable of issuing
75
+ * tokens and refreshing expired tokens.
76
+ *
77
+ * @var UriInterface
78
+ */
79
+ private $tokenCredentialUri;
80
+
81
+ /**
82
+ * The redirection URI used in the initial request.
83
+ *
84
+ * @var string
85
+ */
86
+ private $redirectUri;
87
+
88
+ /**
89
+ * A unique identifier issued to the client to identify itself to the
90
+ * authorization server.
91
+ *
92
+ * @var string
93
+ */
94
+ private $clientId;
95
+
96
+ /**
97
+ * A shared symmetric secret issued by the authorization server, which is
98
+ * used to authenticate the client.
99
+ *
100
+ * @var string
101
+ */
102
+ private $clientSecret;
103
+
104
+ /**
105
+ * The resource owner's username.
106
+ *
107
+ * @var string
108
+ */
109
+ private $username;
110
+
111
+ /**
112
+ * The resource owner's password.
113
+ *
114
+ * @var string
115
+ */
116
+ private $password;
117
+
118
+ /**
119
+ * The scope of the access request, expressed either as an Array or as a
120
+ * space-delimited string.
121
+ *
122
+ * @var string
123
+ */
124
+ private $scope;
125
+
126
+ /**
127
+ * An arbitrary string designed to allow the client to maintain state.
128
+ *
129
+ * @var string
130
+ */
131
+ private $state;
132
+
133
+ /**
134
+ * The authorization code issued to this client.
135
+ *
136
+ * Only used by the authorization code access grant type.
137
+ *
138
+ * @var string
139
+ */
140
+ private $code;
141
+
142
+ /**
143
+ * The issuer ID when using assertion profile.
144
+ *
145
+ * @var string
146
+ */
147
+ private $issuer;
148
+
149
+ /**
150
+ * The target audience for assertions.
151
+ *
152
+ * @var string
153
+ */
154
+ private $audience;
155
+
156
+ /**
157
+ * The target sub when issuing assertions.
158
+ *
159
+ * @var string
160
+ */
161
+ private $sub;
162
+
163
+ /**
164
+ * The number of seconds assertions are valid for.
165
+ *
166
+ * @var int
167
+ */
168
+ private $expiry;
169
+
170
+ /**
171
+ * The signing key when using assertion profile.
172
+ *
173
+ * @var string
174
+ */
175
+ private $signingKey;
176
+
177
+ /**
178
+ * The signing algorithm when using an assertion profile.
179
+ *
180
+ * @var string
181
+ */
182
+ private $signingAlgorithm;
183
+
184
+ /**
185
+ * The refresh token associated with the access token to be refreshed.
186
+ *
187
+ * @var string
188
+ */
189
+ private $refreshToken;
190
+
191
+ /**
192
+ * The current access token.
193
+ *
194
+ * @var string
195
+ */
196
+ private $accessToken;
197
+
198
+ /**
199
+ * The current ID token.
200
+ *
201
+ * @var string
202
+ */
203
+ private $idToken;
204
+
205
+ /**
206
+ * The lifetime in seconds of the current access token.
207
+ *
208
+ * @var int
209
+ */
210
+ private $expiresIn;
211
+
212
+ /**
213
+ * The expiration time of the access token as a number of seconds since the
214
+ * unix epoch.
215
+ *
216
+ * @var int
217
+ */
218
+ private $expiresAt;
219
+
220
+ /**
221
+ * The issue time of the access token as a number of seconds since the unix
222
+ * epoch.
223
+ *
224
+ * @var int
225
+ */
226
+ private $issuedAt;
227
+
228
+ /**
229
+ * The current grant type.
230
+ *
231
+ * @var string
232
+ */
233
+ private $grantType;
234
+
235
+ /**
236
+ * When using an extension grant type, this is the set of parameters used by
237
+ * that extension.
238
+ */
239
+ private $extensionParams;
240
+
241
+ /**
242
+ * When using the toJwt function, these claims will be added to the JWT
243
+ * payload.
244
+ */
245
+ private $additionalClaims;
246
+
247
+ /**
248
+ * Create a new OAuthCredentials.
249
+ *
250
+ * The configuration array accepts various options
251
+ *
252
+ * - authorizationUri
253
+ * The authorization server's HTTP endpoint capable of
254
+ * authenticating the end-user and obtaining authorization.
255
+ *
256
+ * - tokenCredentialUri
257
+ * The authorization server's HTTP endpoint capable of issuing
258
+ * tokens and refreshing expired tokens.
259
+ *
260
+ * - clientId
261
+ * A unique identifier issued to the client to identify itself to the
262
+ * authorization server.
263
+ *
264
+ * - clientSecret
265
+ * A shared symmetric secret issued by the authorization server,
266
+ * which is used to authenticate the client.
267
+ *
268
+ * - scope
269
+ * The scope of the access request, expressed either as an Array
270
+ * or as a space-delimited String.
271
+ *
272
+ * - state
273
+ * An arbitrary string designed to allow the client to maintain state.
274
+ *
275
+ * - redirectUri
276
+ * The redirection URI used in the initial request.
277
+ *
278
+ * - username
279
+ * The resource owner's username.
280
+ *
281
+ * - password
282
+ * The resource owner's password.
283
+ *
284
+ * - issuer
285
+ * Issuer ID when using assertion profile
286
+ *
287
+ * - audience
288
+ * Target audience for assertions
289
+ *
290
+ * - expiry
291
+ * Number of seconds assertions are valid for
292
+ *
293
+ * - signingKey
294
+ * Signing key when using assertion profile
295
+ *
296
+ * - refreshToken
297
+ * The refresh token associated with the access token
298
+ * to be refreshed.
299
+ *
300
+ * - accessToken
301
+ * The current access token for this client.
302
+ *
303
+ * - idToken
304
+ * The current ID token for this client.
305
+ *
306
+ * - extensionParams
307
+ * When using an extension grant type, this is the set of parameters used
308
+ * by that extension.
309
+ *
310
+ * @param array $config Configuration array
311
+ */
312
+ public function __construct(array $config)
313
+ {
314
+ $opts = array_merge([
315
+ 'expiry' => self::DEFAULT_EXPIRY_SECONDS,
316
+ 'extensionParams' => [],
317
+ 'authorizationUri' => null,
318
+ 'redirectUri' => null,
319
+ 'tokenCredentialUri' => null,
320
+ 'state' => null,
321
+ 'username' => null,
322
+ 'password' => null,
323
+ 'clientId' => null,
324
+ 'clientSecret' => null,
325
+ 'issuer' => null,
326
+ 'sub' => null,
327
+ 'audience' => null,
328
+ 'signingKey' => null,
329
+ 'signingAlgorithm' => null,
330
+ 'scope' => null,
331
+ 'additionalClaims' => [],
332
+ ], $config);
333
+
334
+ $this->setAuthorizationUri($opts['authorizationUri']);
335
+ $this->setRedirectUri($opts['redirectUri']);
336
+ $this->setTokenCredentialUri($opts['tokenCredentialUri']);
337
+ $this->setState($opts['state']);
338
+ $this->setUsername($opts['username']);
339
+ $this->setPassword($opts['password']);
340
+ $this->setClientId($opts['clientId']);
341
+ $this->setClientSecret($opts['clientSecret']);
342
+ $this->setIssuer($opts['issuer']);
343
+ $this->setSub($opts['sub']);
344
+ $this->setExpiry($opts['expiry']);
345
+ $this->setAudience($opts['audience']);
346
+ $this->setSigningKey($opts['signingKey']);
347
+ $this->setSigningAlgorithm($opts['signingAlgorithm']);
348
+ $this->setScope($opts['scope']);
349
+ $this->setExtensionParams($opts['extensionParams']);
350
+ $this->setAdditionalClaims($opts['additionalClaims']);
351
+ $this->updateToken($opts);
352
+ }
353
+
354
+ /**
355
+ * Verifies the idToken if present.
356
+ *
357
+ * - if none is present, return null
358
+ * - if present, but invalid, raises DomainException.
359
+ * - otherwise returns the payload in the idtoken as a PHP object.
360
+ *
361
+ * if $publicKey is null, the key is decoded without being verified.
362
+ *
363
+ * @param string $publicKey The public key to use to authenticate the token
364
+ * @param array $allowed_algs List of supported verification algorithms
365
+ *
366
+ * @return null|object
367
+ */
368
+ public function verifyIdToken($publicKey = null, $allowed_algs = array())
369
+ {
370
+ $idToken = $this->getIdToken();
371
+ if (is_null($idToken)) {
372
+ return null;
373
+ }
374
+
375
+ $resp = $this->jwtDecode($idToken, $publicKey, $allowed_algs);
376
+ if (!property_exists($resp, 'aud')) {
377
+ throw new \DomainException('No audience found the id token');
378
+ }
379
+ if ($resp->aud != $this->getAudience()) {
380
+ throw new \DomainException('Wrong audience present in the id token');
381
+ }
382
+
383
+ return $resp;
384
+ }
385
+
386
+ /**
387
+ * Obtains the encoded jwt from the instance data.
388
+ *
389
+ * @param array $config array optional configuration parameters
390
+ *
391
+ * @return string
392
+ */
393
+ public function toJwt(array $config = [])
394
+ {
395
+ if (is_null($this->getSigningKey())) {
396
+ throw new \DomainException('No signing key available');
397
+ }
398
+ if (is_null($this->getSigningAlgorithm())) {
399
+ throw new \DomainException('No signing algorithm specified');
400
+ }
401
+ $now = time();
402
+
403
+ $opts = array_merge([
404
+ 'skew' => self::DEFAULT_SKEW_SECONDS,
405
+ ], $config);
406
+
407
+ $assertion = [
408
+ 'iss' => $this->getIssuer(),
409
+ 'aud' => $this->getAudience(),
410
+ 'exp' => ($now + $this->getExpiry()),
411
+ 'iat' => ($now - $opts['skew']),
412
+ ];
413
+ foreach ($assertion as $k => $v) {
414
+ if (is_null($v)) {
415
+ throw new \DomainException($k . ' should not be null');
416
+ }
417
+ }
418
+ if (!(is_null($this->getScope()))) {
419
+ $assertion['scope'] = $this->getScope();
420
+ }
421
+ if (!(is_null($this->getSub()))) {
422
+ $assertion['sub'] = $this->getSub();
423
+ }
424
+ $assertion += $this->getAdditionalClaims();
425
+
426
+ return $this->jwtEncode($assertion, $this->getSigningKey(),
427
+ $this->getSigningAlgorithm());
428
+ }
429
+
430
+ /**
431
+ * Generates a request for token credentials.
432
+ *
433
+ * @return RequestInterface the authorization Url.
434
+ */
435
+ public function generateCredentialsRequest()
436
+ {
437
+ $uri = $this->getTokenCredentialUri();
438
+ if (is_null($uri)) {
439
+ throw new \DomainException('No token credential URI was set.');
440
+ }
441
+
442
+ $grantType = $this->getGrantType();
443
+ $params = array('grant_type' => $grantType);
444
+ switch ($grantType) {
445
+ case 'authorization_code':
446
+ $params['code'] = $this->getCode();
447
+ $params['redirect_uri'] = $this->getRedirectUri();
448
+ $this->addClientCredentials($params);
449
+ break;
450
+ case 'password':
451
+ $params['username'] = $this->getUsername();
452
+ $params['password'] = $this->getPassword();
453
+ $this->addClientCredentials($params);
454
+ break;
455
+ case 'refresh_token':
456
+ $params['refresh_token'] = $this->getRefreshToken();
457
+ $this->addClientCredentials($params);
458
+ break;
459
+ case self::JWT_URN:
460
+ $params['assertion'] = $this->toJwt();
461
+ break;
462
+ default:
463
+ if (!is_null($this->getRedirectUri())) {
464
+ # Grant type was supposed to be 'authorization_code', as there
465
+ # is a redirect URI.
466
+ throw new \DomainException('Missing authorization code');
467
+ }
468
+ unset($params['grant_type']);
469
+ if (!is_null($grantType)) {
470
+ $params['grant_type'] = $grantType;
471
+ }
472
+ $params = array_merge($params, $this->getExtensionParams());
473
+ }
474
+
475
+ $headers = [
476
+ 'Cache-Control' => 'no-store',
477
+ 'Content-Type' => 'application/x-www-form-urlencoded',
478
+ ];
479
+
480
+ return new Request(
481
+ 'POST',
482
+ $uri,
483
+ $headers,
484
+ Psr7\build_query($params)
485
+ );
486
+ }
487
+
488
+ /**
489
+ * Fetches the auth tokens based on the current state.
490
+ *
491
+ * @param callable $httpHandler callback which delivers psr7 request
492
+ *
493
+ * @return array the response
494
+ */
495
+ public function fetchAuthToken(callable $httpHandler = null)
496
+ {
497
+ if (is_null($httpHandler)) {
498
+ $httpHandler = HttpHandlerFactory::build();
499
+ }
500
+
501
+ $response = $httpHandler($this->generateCredentialsRequest());
502
+ $credentials = $this->parseTokenResponse($response);
503
+ $this->updateToken($credentials);
504
+
505
+ return $credentials;
506
+ }
507
+
508
+ /**
509
+ * Obtains a key that can used to cache the results of #fetchAuthToken.
510
+ *
511
+ * The key is derived from the scopes.
512
+ *
513
+ * @return string a key that may be used to cache the auth token.
514
+ */
515
+ public function getCacheKey()
516
+ {
517
+ if (is_string($this->scope)) {
518
+ return $this->scope;
519
+ }
520
+
521
+ if (is_array($this->scope)) {
522
+ return implode(':', $this->scope);
523
+ }
524
+
525
+ // If scope has not set, return null to indicate no caching.
526
+ return null;
527
+ }
528
+
529
+ /**
530
+ * Parses the fetched tokens.
531
+ *
532
+ * @param ResponseInterface $resp the response.
533
+ *
534
+ * @return array the tokens parsed from the response body.
535
+ *
536
+ * @throws \Exception
537
+ */
538
+ public function parseTokenResponse(ResponseInterface $resp)
539
+ {
540
+ $body = (string)$resp->getBody();
541
+ if ($resp->hasHeader('Content-Type') &&
542
+ $resp->getHeaderLine('Content-Type') == 'application/x-www-form-urlencoded'
543
+ ) {
544
+ $res = array();
545
+ parse_str($body, $res);
546
+
547
+ return $res;
548
+ }
549
+
550
+ // Assume it's JSON; if it's not throw an exception
551
+ if (null === $res = json_decode($body, true)) {
552
+ throw new \Exception('Invalid JSON response');
553
+ }
554
+
555
+ return $res;
556
+ }
557
+
558
+ /**
559
+ * Updates an OAuth 2.0 client.
560
+ *
561
+ * @example
562
+ * client.updateToken([
563
+ * 'refresh_token' => 'n4E9O119d',
564
+ * 'access_token' => 'FJQbwq9',
565
+ * 'expires_in' => 3600
566
+ * ])
567
+ *
568
+ * @param array $config
569
+ * The configuration parameters related to the token.
570
+ *
571
+ * - refresh_token
572
+ * The refresh token associated with the access token
573
+ * to be refreshed.
574
+ *
575
+ * - access_token
576
+ * The current access token for this client.
577
+ *
578
+ * - id_token
579
+ * The current ID token for this client.
580
+ *
581
+ * - expires_in
582
+ * The time in seconds until access token expiration.
583
+ *
584
+ * - expires_at
585
+ * The time as an integer number of seconds since the Epoch
586
+ *
587
+ * - issued_at
588
+ * The timestamp that the token was issued at.
589
+ */
590
+ public function updateToken(array $config)
591
+ {
592
+ $opts = array_merge([
593
+ 'extensionParams' => [],
594
+ 'access_token' => null,
595
+ 'id_token' => null,
596
+ 'expires_in' => null,
597
+ 'expires_at' => null,
598
+ 'issued_at' => null,
599
+ ], $config);
600
+
601
+ $this->setExpiresAt($opts['expires_at']);
602
+ $this->setExpiresIn($opts['expires_in']);
603
+ // By default, the token is issued at `Time.now` when `expiresIn` is set,
604
+ // but this can be used to supply a more precise time.
605
+ if (!is_null($opts['issued_at'])) {
606
+ $this->setIssuedAt($opts['issued_at']);
607
+ }
608
+
609
+ $this->setAccessToken($opts['access_token']);
610
+ $this->setIdToken($opts['id_token']);
611
+ // The refresh token should only be updated if a value is explicitly
612
+ // passed in, as some access token responses do not include a refresh
613
+ // token.
614
+ if (array_key_exists('refresh_token', $opts)) {
615
+ $this->setRefreshToken($opts['refresh_token']);
616
+ }
617
+ }
618
+
619
+ /**
620
+ * Builds the authorization Uri that the user should be redirected to.
621
+ *
622
+ * @param array $config configuration options that customize the return url
623
+ *
624
+ * @return UriInterface the authorization Url.
625
+ *
626
+ * @throws InvalidArgumentException
627
+ */
628
+ public function buildFullAuthorizationUri(array $config = [])
629
+ {
630
+ if (is_null($this->getAuthorizationUri())) {
631
+ throw new InvalidArgumentException(
632
+ 'requires an authorizationUri to have been set');
633
+ }
634
+
635
+ $params = array_merge([
636
+ 'response_type' => 'code',
637
+ 'access_type' => 'offline',
638
+ 'client_id' => $this->clientId,
639
+ 'redirect_uri' => $this->redirectUri,
640
+ 'state' => $this->state,
641
+ 'scope' => $this->getScope(),
642
+ ], $config);
643
+
644
+ // Validate the auth_params
645
+ if (is_null($params['client_id'])) {
646
+ throw new InvalidArgumentException(
647
+ 'missing the required client identifier');
648
+ }
649
+ if (is_null($params['redirect_uri'])) {
650
+ throw new InvalidArgumentException('missing the required redirect URI');
651
+ }
652
+ if (!empty($params['prompt']) && !empty($params['approval_prompt'])) {
653
+ throw new InvalidArgumentException(
654
+ 'prompt and approval_prompt are mutually exclusive');
655
+ }
656
+
657
+ // Construct the uri object; return it if it is valid.
658
+ $result = clone $this->authorizationUri;
659
+ $existingParams = Psr7\parse_query($result->getQuery());
660
+
661
+ $result = $result->withQuery(
662
+ Psr7\build_query(array_merge($existingParams, $params))
663
+ );
664
+
665
+ if ($result->getScheme() != 'https') {
666
+ throw new InvalidArgumentException(
667
+ 'Authorization endpoint must be protected by TLS');
668
+ }
669
+
670
+ return $result;
671
+ }
672
+
673
+ /**
674
+ * Sets the authorization server's HTTP endpoint capable of authenticating
675
+ * the end-user and obtaining authorization.
676
+ *
677
+ * @param string $uri
678
+ */
679
+ public function setAuthorizationUri($uri)
680
+ {
681
+ $this->authorizationUri = $this->coerceUri($uri);
682
+ }
683
+
684
+ /**
685
+ * Gets the authorization server's HTTP endpoint capable of authenticating
686
+ * the end-user and obtaining authorization.
687
+ *
688
+ * @return UriInterface
689
+ */
690
+ public function getAuthorizationUri()
691
+ {
692
+ return $this->authorizationUri;
693
+ }
694
+
695
+ /**
696
+ * Gets the authorization server's HTTP endpoint capable of issuing tokens
697
+ * and refreshing expired tokens.
698
+ *
699
+ * @return string
700
+ */
701
+ public function getTokenCredentialUri()
702
+ {
703
+ return $this->tokenCredentialUri;
704
+ }
705
+
706
+ /**
707
+ * Sets the authorization server's HTTP endpoint capable of issuing tokens
708
+ * and refreshing expired tokens.
709
+ *
710
+ * @param string $uri
711
+ */
712
+ public function setTokenCredentialUri($uri)
713
+ {
714
+ $this->tokenCredentialUri = $this->coerceUri($uri);
715
+ }
716
+
717
+ /**
718
+ * Gets the redirection URI used in the initial request.
719
+ *
720
+ * @return string
721
+ */
722
+ public function getRedirectUri()
723
+ {
724
+ return $this->redirectUri;
725
+ }
726
+
727
+ /**
728
+ * Sets the redirection URI used in the initial request.
729
+ *
730
+ * @param string $uri
731
+ */
732
+ public function setRedirectUri($uri)
733
+ {
734
+ if (is_null($uri)) {
735
+ $this->redirectUri = null;
736
+
737
+ return;
738
+ }
739
+ // redirect URI must be absolute
740
+ if (!$this->isAbsoluteUri($uri)) {
741
+ // "postmessage" is a reserved URI string in Google-land
742
+ // @see https://developers.google.com/identity/sign-in/web/server-side-flow
743
+ if ('postmessage' !== (string)$uri) {
744
+ throw new InvalidArgumentException(
745
+ 'Redirect URI must be absolute');
746
+ }
747
+ }
748
+ $this->redirectUri = (string)$uri;
749
+ }
750
+
751
+ /**
752
+ * Gets the scope of the access requests as a space-delimited String.
753
+ *
754
+ * @return string
755
+ */
756
+ public function getScope()
757
+ {
758
+ if (is_null($this->scope)) {
759
+ return $this->scope;
760
+ }
761
+
762
+ return implode(' ', $this->scope);
763
+ }
764
+
765
+ /**
766
+ * Sets the scope of the access request, expressed either as an Array or as
767
+ * a space-delimited String.
768
+ *
769
+ * @param string|array $scope
770
+ *
771
+ * @throws InvalidArgumentException
772
+ */
773
+ public function setScope($scope)
774
+ {
775
+ if (is_null($scope)) {
776
+ $this->scope = null;
777
+ } elseif (is_string($scope)) {
778
+ $this->scope = explode(' ', $scope);
779
+ } elseif (is_array($scope)) {
780
+ foreach ($scope as $s) {
781
+ $pos = strpos($s, ' ');
782
+ if ($pos !== false) {
783
+ throw new InvalidArgumentException(
784
+ 'array scope values should not contain spaces');
785
+ }
786
+ }
787
+ $this->scope = $scope;
788
+ } else {
789
+ throw new InvalidArgumentException(
790
+ 'scopes should be a string or array of strings');
791
+ }
792
+ }
793
+
794
+ /**
795
+ * Gets the current grant type.
796
+ *
797
+ * @return string
798
+ */
799
+ public function getGrantType()
800
+ {
801
+ if (!is_null($this->grantType)) {
802
+ return $this->grantType;
803
+ }
804
+
805
+ // Returns the inferred grant type, based on the current object instance
806
+ // state.
807
+ if (!is_null($this->code)) {
808
+ return 'authorization_code';
809
+ }
810
+
811
+ if (!is_null($this->refreshToken)) {
812
+ return 'refresh_token';
813
+ }
814
+
815
+ if (!is_null($this->username) && !is_null($this->password)) {
816
+ return 'password';
817
+ }
818
+
819
+ if (!is_null($this->issuer) && !is_null($this->signingKey)) {
820
+ return self::JWT_URN;
821
+ }
822
+
823
+ return null;
824
+ }
825
+
826
+ /**
827
+ * Sets the current grant type.
828
+ *
829
+ * @param $grantType
830
+ *
831
+ * @throws InvalidArgumentException
832
+ */
833
+ public function setGrantType($grantType)
834
+ {
835
+ if (in_array($grantType, self::$knownGrantTypes)) {
836
+ $this->grantType = $grantType;
837
+ } else {
838
+ // validate URI
839
+ if (!$this->isAbsoluteUri($grantType)) {
840
+ throw new InvalidArgumentException(
841
+ 'invalid grant type');
842
+ }
843
+ $this->grantType = (string)$grantType;
844
+ }
845
+ }
846
+
847
+ /**
848
+ * Gets an arbitrary string designed to allow the client to maintain state.
849
+ *
850
+ * @return string
851
+ */
852
+ public function getState()
853
+ {
854
+ return $this->state;
855
+ }
856
+
857
+ /**
858
+ * Sets an arbitrary string designed to allow the client to maintain state.
859
+ *
860
+ * @param string $state
861
+ */
862
+ public function setState($state)
863
+ {
864
+ $this->state = $state;
865
+ }
866
+
867
+ /**
868
+ * Gets the authorization code issued to this client.
869
+ */
870
+ public function getCode()
871
+ {
872
+ return $this->code;
873
+ }
874
+
875
+ /**
876
+ * Sets the authorization code issued to this client.
877
+ *
878
+ * @param string $code
879
+ */
880
+ public function setCode($code)
881
+ {
882
+ $this->code = $code;
883
+ }
884
+
885
+ /**
886
+ * Gets the resource owner's username.
887
+ */
888
+ public function getUsername()
889
+ {
890
+ return $this->username;
891
+ }
892
+
893
+ /**
894
+ * Sets the resource owner's username.
895
+ *
896
+ * @param string $username
897
+ */
898
+ public function setUsername($username)
899
+ {
900
+ $this->username = $username;
901
+ }
902
+
903
+ /**
904
+ * Gets the resource owner's password.
905
+ */
906
+ public function getPassword()
907
+ {
908
+ return $this->password;
909
+ }
910
+
911
+ /**
912
+ * Sets the resource owner's password.
913
+ *
914
+ * @param $password
915
+ */
916
+ public function setPassword($password)
917
+ {
918
+ $this->password = $password;
919
+ }
920
+
921
+ /**
922
+ * Sets a unique identifier issued to the client to identify itself to the
923
+ * authorization server.
924
+ */
925
+ public function getClientId()
926
+ {
927
+ return $this->clientId;
928
+ }
929
+
930
+ /**
931
+ * Sets a unique identifier issued to the client to identify itself to the
932
+ * authorization server.
933
+ *
934
+ * @param $clientId
935
+ */
936
+ public function setClientId($clientId)
937
+ {
938
+ $this->clientId = $clientId;
939
+ }
940
+
941
+ /**
942
+ * Gets a shared symmetric secret issued by the authorization server, which
943
+ * is used to authenticate the client.
944
+ */
945
+ public function getClientSecret()
946
+ {
947
+ return $this->clientSecret;
948
+ }
949
+
950
+ /**
951
+ * Sets a shared symmetric secret issued by the authorization server, which
952
+ * is used to authenticate the client.
953
+ *
954
+ * @param $clientSecret
955
+ */
956
+ public function setClientSecret($clientSecret)
957
+ {
958
+ $this->clientSecret = $clientSecret;
959
+ }
960
+
961
+ /**
962
+ * Gets the Issuer ID when using assertion profile.
963
+ */
964
+ public function getIssuer()
965
+ {
966
+ return $this->issuer;
967
+ }
968
+
969
+ /**
970
+ * Sets the Issuer ID when using assertion profile.
971
+ *
972
+ * @param string $issuer
973
+ */
974
+ public function setIssuer($issuer)
975
+ {
976
+ $this->issuer = $issuer;
977
+ }
978
+
979
+ /**
980
+ * Gets the target sub when issuing assertions.
981
+ */
982
+ public function getSub()
983
+ {
984
+ return $this->sub;
985
+ }
986
+
987
+ /**
988
+ * Sets the target sub when issuing assertions.
989
+ *
990
+ * @param string $sub
991
+ */
992
+ public function setSub($sub)
993
+ {
994
+ $this->sub = $sub;
995
+ }
996
+
997
+ /**
998
+ * Gets the target audience when issuing assertions.
999
+ */
1000
+ public function getAudience()
1001
+ {
1002
+ return $this->audience;
1003
+ }
1004
+
1005
+ /**
1006
+ * Sets the target audience when issuing assertions.
1007
+ *
1008
+ * @param string $audience
1009
+ */
1010
+ public function setAudience($audience)
1011
+ {
1012
+ $this->audience = $audience;
1013
+ }
1014
+
1015
+ /**
1016
+ * Gets the signing key when using an assertion profile.
1017
+ */
1018
+ public function getSigningKey()
1019
+ {
1020
+ return $this->signingKey;
1021
+ }
1022
+
1023
+ /**
1024
+ * Sets the signing key when using an assertion profile.
1025
+ *
1026
+ * @param string $signingKey
1027
+ */
1028
+ public function setSigningKey($signingKey)
1029
+ {
1030
+ $this->signingKey = $signingKey;
1031
+ }
1032
+
1033
+ /**
1034
+ * Gets the signing algorithm when using an assertion profile.
1035
+ *
1036
+ * @return string
1037
+ */
1038
+ public function getSigningAlgorithm()
1039
+ {
1040
+ return $this->signingAlgorithm;
1041
+ }
1042
+
1043
+ /**
1044
+ * Sets the signing algorithm when using an assertion profile.
1045
+ *
1046
+ * @param string $signingAlgorithm
1047
+ */
1048
+ public function setSigningAlgorithm($signingAlgorithm)
1049
+ {
1050
+ if (is_null($signingAlgorithm)) {
1051
+ $this->signingAlgorithm = null;
1052
+ } elseif (!in_array($signingAlgorithm, self::$knownSigningAlgorithms)) {
1053
+ throw new InvalidArgumentException('unknown signing algorithm');
1054
+ } else {
1055
+ $this->signingAlgorithm = $signingAlgorithm;
1056
+ }
1057
+ }
1058
+
1059
+ /**
1060
+ * Gets the set of parameters used by extension when using an extension
1061
+ * grant type.
1062
+ */
1063
+ public function getExtensionParams()
1064
+ {
1065
+ return $this->extensionParams;
1066
+ }
1067
+
1068
+ /**
1069
+ * Sets the set of parameters used by extension when using an extension
1070
+ * grant type.
1071
+ *
1072
+ * @param $extensionParams
1073
+ */
1074
+ public function setExtensionParams($extensionParams)
1075
+ {
1076
+ $this->extensionParams = $extensionParams;
1077
+ }
1078
+
1079
+ /**
1080
+ * Gets the number of seconds assertions are valid for.
1081
+ */
1082
+ public function getExpiry()
1083
+ {
1084
+ return $this->expiry;
1085
+ }
1086
+
1087
+ /**
1088
+ * Sets the number of seconds assertions are valid for.
1089
+ *
1090
+ * @param int $expiry
1091
+ */
1092
+ public function setExpiry($expiry)
1093
+ {
1094
+ $this->expiry = $expiry;
1095
+ }
1096
+
1097
+ /**
1098
+ * Gets the lifetime of the access token in seconds.
1099
+ */
1100
+ public function getExpiresIn()
1101
+ {
1102
+ return $this->expiresIn;
1103
+ }
1104
+
1105
+ /**
1106
+ * Sets the lifetime of the access token in seconds.
1107
+ *
1108
+ * @param int $expiresIn
1109
+ */
1110
+ public function setExpiresIn($expiresIn)
1111
+ {
1112
+ if (is_null($expiresIn)) {
1113
+ $this->expiresIn = null;
1114
+ $this->issuedAt = null;
1115
+ } else {
1116
+ $this->issuedAt = time();
1117
+ $this->expiresIn = (int)$expiresIn;
1118
+ }
1119
+ }
1120
+
1121
+ /**
1122
+ * Gets the time the current access token expires at.
1123
+ *
1124
+ * @return int
1125
+ */
1126
+ public function getExpiresAt()
1127
+ {
1128
+ if (!is_null($this->expiresAt)) {
1129
+ return $this->expiresAt;
1130
+ }
1131
+
1132
+ if (!is_null($this->issuedAt) && !is_null($this->expiresIn)) {
1133
+ return $this->issuedAt + $this->expiresIn;
1134
+ }
1135
+
1136
+ return null;
1137
+ }
1138
+
1139
+ /**
1140
+ * Returns true if the acccess token has expired.
1141
+ *
1142
+ * @return bool
1143
+ */
1144
+ public function isExpired()
1145
+ {
1146
+ $expiration = $this->getExpiresAt();
1147
+ $now = time();
1148
+
1149
+ return !is_null($expiration) && $now >= $expiration;
1150
+ }
1151
+
1152
+ /**
1153
+ * Sets the time the current access token expires at.
1154
+ *
1155
+ * @param int $expiresAt
1156
+ */
1157
+ public function setExpiresAt($expiresAt)
1158
+ {
1159
+ $this->expiresAt = $expiresAt;
1160
+ }
1161
+
1162
+ /**
1163
+ * Gets the time the current access token was issued at.
1164
+ */
1165
+ public function getIssuedAt()
1166
+ {
1167
+ return $this->issuedAt;
1168
+ }
1169
+
1170
+ /**
1171
+ * Sets the time the current access token was issued at.
1172
+ *
1173
+ * @param int $issuedAt
1174
+ */
1175
+ public function setIssuedAt($issuedAt)
1176
+ {
1177
+ $this->issuedAt = $issuedAt;
1178
+ }
1179
+
1180
+ /**
1181
+ * Gets the current access token.
1182
+ */
1183
+ public function getAccessToken()
1184
+ {
1185
+ return $this->accessToken;
1186
+ }
1187
+
1188
+ /**
1189
+ * Sets the current access token.
1190
+ *
1191
+ * @param string $accessToken
1192
+ */
1193
+ public function setAccessToken($accessToken)
1194
+ {
1195
+ $this->accessToken = $accessToken;
1196
+ }
1197
+
1198
+ /**
1199
+ * Gets the current ID token.
1200
+ */
1201
+ public function getIdToken()
1202
+ {
1203
+ return $this->idToken;
1204
+ }
1205
+
1206
+ /**
1207
+ * Sets the current ID token.
1208
+ *
1209
+ * @param $idToken
1210
+ */
1211
+ public function setIdToken($idToken)
1212
+ {
1213
+ $this->idToken = $idToken;
1214
+ }
1215
+
1216
+ /**
1217
+ * Gets the refresh token associated with the current access token.
1218
+ */
1219
+ public function getRefreshToken()
1220
+ {
1221
+ return $this->refreshToken;
1222
+ }
1223
+
1224
+ /**
1225
+ * Sets the refresh token associated with the current access token.
1226
+ *
1227
+ * @param $refreshToken
1228
+ */
1229
+ public function setRefreshToken($refreshToken)
1230
+ {
1231
+ $this->refreshToken = $refreshToken;
1232
+ }
1233
+
1234
+ /**
1235
+ * Sets additional claims to be included in the JWT token
1236
+ *
1237
+ * @param array $additionalClaims
1238
+ */
1239
+ public function setAdditionalClaims(array $additionalClaims)
1240
+ {
1241
+ $this->additionalClaims = $additionalClaims;
1242
+ }
1243
+
1244
+ /**
1245
+ * Gets the additional claims to be included in the JWT token.
1246
+ *
1247
+ * @return array
1248
+ */
1249
+ public function getAdditionalClaims()
1250
+ {
1251
+ return $this->additionalClaims;
1252
+ }
1253
+
1254
+ /**
1255
+ * The expiration of the last received token.
1256
+ *
1257
+ * @return array
1258
+ */
1259
+ public function getLastReceivedToken()
1260
+ {
1261
+ if ($token = $this->getAccessToken()) {
1262
+ return [
1263
+ 'access_token' => $token,
1264
+ 'expires_at' => $this->getExpiresAt(),
1265
+ ];
1266
+ }
1267
+
1268
+ return null;
1269
+ }
1270
+
1271
+ /**
1272
+ * @todo handle uri as array
1273
+ *
1274
+ * @param string $uri
1275
+ *
1276
+ * @return null|UriInterface
1277
+ */
1278
+ private function coerceUri($uri)
1279
+ {
1280
+ if (is_null($uri)) {
1281
+ return;
1282
+ }
1283
+
1284
+ return Psr7\uri_for($uri);
1285
+ }
1286
+
1287
+ /**
1288
+ * @param string $idToken
1289
+ * @param string|array|null $publicKey
1290
+ * @param array $allowedAlgs
1291
+ *
1292
+ * @return object
1293
+ */
1294
+ private function jwtDecode($idToken, $publicKey, $allowedAlgs)
1295
+ {
1296
+ if (class_exists('Firebase\JWT\JWT')) {
1297
+ return \Firebase\JWT\JWT::decode($idToken, $publicKey, $allowedAlgs);
1298
+ }
1299
+
1300
+ return \JWT::decode($idToken, $publicKey, $allowedAlgs);
1301
+ }
1302
+
1303
+ private function jwtEncode($assertion, $signingKey, $signingAlgorithm)
1304
+ {
1305
+ if (class_exists('Firebase\JWT\JWT')) {
1306
+ return \Firebase\JWT\JWT::encode($assertion, $signingKey,
1307
+ $signingAlgorithm);
1308
+ }
1309
+
1310
+ return \JWT::encode($assertion, $signingKey, $signingAlgorithm);
1311
+ }
1312
+
1313
+ /**
1314
+ * Determines if the URI is absolute based on its scheme and host or path
1315
+ * (RFC 3986).
1316
+ *
1317
+ * @param string $uri
1318
+ *
1319
+ * @return bool
1320
+ */
1321
+ private function isAbsoluteUri($uri)
1322
+ {
1323
+ $uri = $this->coerceUri($uri);
1324
+
1325
+ return $uri->getScheme() && ($uri->getHost() || $uri->getPath());
1326
+ }
1327
+
1328
+ /**
1329
+ * @param array $params
1330
+ *
1331
+ * @return array
1332
+ */
1333
+ private function addClientCredentials(&$params)
1334
+ {
1335
+ $clientId = $this->getClientId();
1336
+ $clientSecret = $this->getClientSecret();
1337
+
1338
+ if ($clientId && $clientSecret) {
1339
+ $params['client_id'] = $clientId;
1340
+ $params['client_secret'] = $clientSecret;
1341
+ }
1342
+
1343
+ return $params;
1344
+ }
1345
+ }
vendor/google/auth/src/Subscriber/AuthTokenSubscriber.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2015 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
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
27
+ * provided by an object implementing FetchAuthTokenInterface.
28
+ *
29
+ * The FetchAuthTokenInterface#fetchAuthToken is used to obtain a hash; one of
30
+ * the values value in that hash is added as the authorization header.
31
+ *
32
+ * Requests will be accessed with the authorization header:
33
+ *
34
+ * 'authorization' 'Bearer <value of auth_token>'
35
+ */
36
+ class AuthTokenSubscriber implements SubscriberInterface
37
+ {
38
+ /**
39
+ * @var callable
40
+ */
41
+ private $httpHandler;
42
+
43
+ /**
44
+ * @var FetchAuthTokenInterface
45
+ */
46
+ private $fetcher;
47
+
48
+ /**
49
+ * @var callable
50
+ */
51
+ private $tokenCallback;
52
+
53
+ /**
54
+ * Creates a new AuthTokenSubscriber.
55
+ *
56
+ * @param FetchAuthTokenInterface $fetcher is used to fetch the auth token
57
+ * @param callable $httpHandler (optional) http client to fetch the token.
58
+ * @param callable $tokenCallback (optional) function to be called when a new token is fetched.
59
+ */
60
+ public function __construct(
61
+ FetchAuthTokenInterface $fetcher,
62
+ callable $httpHandler = null,
63
+ callable $tokenCallback = null
64
+ ) {
65
+ $this->fetcher = $fetcher;
66
+ $this->httpHandler = $httpHandler;
67
+ $this->tokenCallback = $tokenCallback;
68
+ }
69
+
70
+ /**
71
+ * @return array
72
+ */
73
+ public function getEvents()
74
+ {
75
+ return ['before' => ['onBefore', RequestEvents::SIGN_REQUEST]];
76
+ }
77
+
78
+ /**
79
+ * Updates the request with an Authorization header when auth is 'fetched_auth_token'.
80
+ *
81
+ * use GuzzleHttp\Client;
82
+ * use Google\Auth\OAuth2;
83
+ * use Google\Auth\Subscriber\AuthTokenSubscriber;
84
+ *
85
+ * $config = [..<oauth config param>.];
86
+ * $oauth2 = new OAuth2($config)
87
+ * $subscriber = new AuthTokenSubscriber($oauth2);
88
+ *
89
+ * $client = new Client([
90
+ * 'base_url' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
91
+ * 'defaults' => ['auth' => 'google_auth']
92
+ * ]);
93
+ * $client->getEmitter()->attach($subscriber);
94
+ *
95
+ * $res = $client->get('myproject/taskqueues/myqueue');
96
+ *
97
+ * @param BeforeEvent $event
98
+ */
99
+ public function onBefore(BeforeEvent $event)
100
+ {
101
+ // Requests using "auth"="google_auth" will be authorized.
102
+ $request = $event->getRequest();
103
+ if ($request->getConfig()['auth'] != 'google_auth') {
104
+ return;
105
+ }
106
+
107
+ // Fetch the auth token.
108
+ $auth_tokens = $this->fetcher->fetchAuthToken($this->httpHandler);
109
+ if (array_key_exists('access_token', $auth_tokens)) {
110
+ $request->setHeader('authorization', 'Bearer ' . $auth_tokens['access_token']);
111
+
112
+ // notify the callback if applicable
113
+ if ($this->tokenCallback) {
114
+ call_user_func($this->tokenCallback, $this->fetcher->getCacheKey(), $auth_tokens['access_token']);
115
+ }
116
+ }
117
+ }
118
+ }
vendor/google/auth/src/Subscriber/ScopedAccessTokenSubscriber.php ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2015 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
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
28
+ * header provided by a closure.
29
+ *
30
+ * The closure returns an access token, taking the scope, either a single
31
+ * string or an array of strings, as its value. If provided, a cache will be
32
+ * used to preserve the access token for a given lifetime.
33
+ *
34
+ * Requests will be accessed with the authorization header:
35
+ *
36
+ * 'authorization' 'Bearer <access token obtained from the closure>'
37
+ */
38
+ class ScopedAccessTokenSubscriber implements SubscriberInterface
39
+ {
40
+ use CacheTrait;
41
+
42
+ const DEFAULT_CACHE_LIFETIME = 1500;
43
+
44
+ /**
45
+ * @var CacheItemPoolInterface
46
+ */
47
+ private $cache;
48
+
49
+ /**
50
+ * @var callable The access token generator function
51
+ */
52
+ private $tokenFunc;
53
+
54
+ /**
55
+ * @var array|string The scopes used to generate the token
56
+ */
57
+ private $scopes;
58
+
59
+ /**
60
+ * @var array
61
+ */
62
+ private $cacheConfig;
63
+
64
+ /**
65
+ * Creates a new ScopedAccessTokenSubscriber.
66
+ *
67
+ * @param callable $tokenFunc a token generator function
68
+ * @param array|string $scopes the token authentication scopes
69
+ * @param array $cacheConfig configuration for the cache when it's present
70
+ * @param CacheItemPoolInterface $cache an implementation of CacheItemPoolInterface
71
+ */
72
+ public function __construct(
73
+ callable $tokenFunc,
74
+ $scopes,
75
+ array $cacheConfig = null,
76
+ CacheItemPoolInterface $cache = null
77
+ ) {
78
+ $this->tokenFunc = $tokenFunc;
79
+ if (!(is_string($scopes) || is_array($scopes))) {
80
+ throw new \InvalidArgumentException(
81
+ 'wants scope should be string or array');
82
+ }
83
+ $this->scopes = $scopes;
84
+
85
+ if (!is_null($cache)) {
86
+ $this->cache = $cache;
87
+ $this->cacheConfig = array_merge([
88
+ 'lifetime' => self::DEFAULT_CACHE_LIFETIME,
89
+ 'prefix' => '',
90
+ ], $cacheConfig);
91
+ }
92
+ }
93
+
94
+ /**
95
+ * @return array
96
+ */
97
+ public function getEvents()
98
+ {
99
+ return ['before' => ['onBefore', RequestEvents::SIGN_REQUEST]];
100
+ }
101
+
102
+ /**
103
+ * Updates the request with an Authorization header when auth is 'scoped'.
104
+ *
105
+ * E.g this could be used to authenticate using the AppEngine
106
+ * AppIdentityService.
107
+ *
108
+ * use google\appengine\api\app_identity\AppIdentityService;
109
+ * use Google\Auth\Subscriber\ScopedAccessTokenSubscriber;
110
+ * use GuzzleHttp\Client;
111
+ *
112
+ * $scope = 'https://www.googleapis.com/auth/taskqueue'
113
+ * $subscriber = new ScopedAccessToken(
114
+ * 'AppIdentityService::getAccessToken',
115
+ * $scope,
116
+ * ['prefix' => 'Google\Auth\ScopedAccessToken::'],
117
+ * $cache = new Memcache()
118
+ * );
119
+ *
120
+ * $client = new Client([
121
+ * 'base_url' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
122
+ * 'defaults' => ['auth' => 'scoped']
123
+ * ]);
124
+ * $client->getEmitter()->attach($subscriber);
125
+ *
126
+ * $res = $client->get('myproject/taskqueues/myqueue');
127
+ *
128
+ * @param BeforeEvent $event
129
+ */
130
+ public function onBefore(BeforeEvent $event)
131
+ {
132
+ // Requests using "auth"="scoped" will be authorized.
133
+ $request = $event->getRequest();
134
+ if ($request->getConfig()['auth'] != 'scoped') {
135
+ return;
136
+ }
137
+ $auth_header = 'Bearer ' . $this->fetchToken();
138
+ $request->setHeader('authorization', $auth_header);
139
+ }
140
+
141
+ /**
142
+ * @return string
143
+ */
144
+ private function getCacheKey()
145
+ {
146
+ $key = null;
147
+
148
+ if (is_string($this->scopes)) {
149
+ $key .= $this->scopes;
150
+ } elseif (is_array($this->scopes)) {
151
+ $key .= implode(':', $this->scopes);
152
+ }
153
+
154
+ return $key;
155
+ }
156
+
157
+ /**
158
+ * Determine if token is available in the cache, if not call tokenFunc to
159
+ * fetch it.
160
+ *
161
+ * @return string
162
+ */
163
+ private function fetchToken()
164
+ {
165
+ $cacheKey = $this->getCacheKey();
166
+ $cached = $this->getCachedValue($cacheKey);
167
+
168
+ if (!empty($cached)) {
169
+ return $cached;
170
+ }
171
+
172
+ $token = call_user_func($this->tokenFunc, $this->scopes);
173
+ $this->setCachedValue($cacheKey, $token);
174
+
175
+ return $token;
176
+ }
177
+ }
vendor/google/auth/src/Subscriber/SimpleSubscriber.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2015 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
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
26
+ * access.
27
+ *
28
+ * Requests are accessed using the Simple API access developer key.
29
+ */
30
+ class SimpleSubscriber implements SubscriberInterface
31
+ {
32
+ /**
33
+ * @var array
34
+ */
35
+ private $config;
36
+
37
+ /**
38
+ * Create a new Simple plugin.
39
+ *
40
+ * The configuration array expects one option
41
+ * - key: required, otherwise InvalidArgumentException is thrown
42
+ *
43
+ * @param array $config Configuration array
44
+ */
45
+ public function __construct(array $config)
46
+ {
47
+ if (!isset($config['key'])) {
48
+ throw new \InvalidArgumentException('requires a key to have been set');
49
+ }
50
+
51
+ $this->config = array_merge([], $config);
52
+ }
53
+
54
+ /**
55
+ * @return array
56
+ */
57
+ public function getEvents()
58
+ {
59
+ return ['before' => ['onBefore', RequestEvents::SIGN_REQUEST]];
60
+ }
61
+
62
+ /**
63
+ * Updates the request query with the developer key if auth is set to simple.
64
+ *
65
+ * use Google\Auth\Subscriber\SimpleSubscriber;
66
+ * use GuzzleHttp\Client;
67
+ *
68
+ * $my_key = 'is not the same as yours';
69
+ * $subscriber = new SimpleSubscriber(['key' => $my_key]);
70
+ *
71
+ * $client = new Client([
72
+ * 'base_url' => 'https://www.googleapis.com/discovery/v1/',
73
+ * 'defaults' => ['auth' => 'simple']
74
+ * ]);
75
+ * $client->getEmitter()->attach($subscriber);
76
+ *
77
+ * $res = $client->get('drive/v2/rest');
78
+ *
79
+ * @param BeforeEvent $event
80
+ */
81
+ public function onBefore(BeforeEvent $event)
82
+ {
83
+ // Requests using "auth"="simple" with the developer key.
84
+ $request = $event->getRequest();
85
+ if ($request->getConfig()['auth'] != 'simple') {
86
+ return;
87
+ }
88
+ $request->getQuery()->overwriteWith($this->config);
89
+ }
90
+ }
vendor/guzzlehttp/guzzle/CHANGELOG.md ADDED
@@ -0,0 +1,1287 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Change Log
2
+
3
+ ## 6.3.3 - 2018-04-22
4
+
5
+ * Fix: Default headers when decode_content is specified
6
+
7
+
8
+ ## 6.3.2 - 2018-03-26
9
+
10
+ * Fix: Release process
11
+
12
+
13
+ ## 6.3.1 - 2018-03-26
14
+
15
+ * Bug fix: Parsing 0 epoch expiry times in cookies [#2014](https://github.com/guzzle/guzzle/pull/2014)
16
+ * Improvement: Better ConnectException detection [#2012](https://github.com/guzzle/guzzle/pull/2012)
17
+ * Bug fix: Malformed domain that contains a "/" [#1999](https://github.com/guzzle/guzzle/pull/1999)
18
+ * Bug fix: Undefined offset when a cookie has no first key-value pair [#1998](https://github.com/guzzle/guzzle/pull/1998)
19
+ * Improvement: Support PHPUnit 6 [#1953](https://github.com/guzzle/guzzle/pull/1953)
20
+ * Bug fix: Support empty headers [#1915](https://github.com/guzzle/guzzle/pull/1915)
21
+ * Bug fix: Ignore case during header modifications [#1916](https://github.com/guzzle/guzzle/pull/1916)
22
+
23
+ + Minor code cleanups, documentation fixes and clarifications.
24
+
25
+
26
+ ## 6.3.0 - 2017-06-22
27
+
28
+ * Feature: force IP resolution (ipv4 or ipv6) [#1608](https://github.com/guzzle/guzzle/pull/1608), [#1659](https://github.com/guzzle/guzzle/pull/1659)
29
+ * Improvement: Don't include summary in exception message when body is empty [#1621](https://github.com/guzzle/guzzle/pull/1621)
30
+ * Improvement: Handle `on_headers` option in MockHandler [#1580](https://github.com/guzzle/guzzle/pull/1580)
31
+ * Improvement: Added SUSE Linux CA path [#1609](https://github.com/guzzle/guzzle/issues/1609)
32
+ * Improvement: Use class reference for getting the name of the class instead of using hardcoded strings [#1641](https://github.com/guzzle/guzzle/pull/1641)
33
+ * Feature: Added `read_timeout` option [#1611](https://github.com/guzzle/guzzle/pull/1611)
34
+ * Bug fix: PHP 7.x fixes [#1685](https://github.com/guzzle/guzzle/pull/1685), [#1686](https://github.com/guzzle/guzzle/pull/1686), [#1811](https://github.com/guzzle/guzzle/pull/1811)
35
+ * Deprecation: BadResponseException instantiation without a response [#1642](https://github.com/guzzle/guzzle/pull/1642)
36
+ * Feature: Added NTLM auth [#1569](https://github.com/guzzle/guzzle/pull/1569)
37
+ * Feature: Track redirect HTTP status codes [#1711](https://github.com/guzzle/guzzle/pull/1711)
38
+ * Improvement: Check handler type during construction [#1745](https://github.com/guzzle/guzzle/pull/1745)
39
+ * Improvement: Always include the Content-Length if there's a body [#1721](https://github.com/guzzle/guzzle/pull/1721)
40
+ * Feature: Added convenience method to access a cookie by name [#1318](https://github.com/guzzle/guzzle/pull/1318)
41
+ * Bug fix: Fill `CURLOPT_CAPATH` and `CURLOPT_CAINFO` properly [#1684](https://github.com/guzzle/guzzle/pull/1684)
42
+ * Improvement: Use `\GuzzleHttp\Promise\rejection_for` function instead of object init [#1827](https://github.com/guzzle/guzzle/pull/1827)
43
+
44
+
45
+ + Minor code cleanups, documentation fixes and clarifications.
46
+
47
+ ## 6.2.3 - 2017-02-28
48
+
49
+ * Fix deprecations with guzzle/psr7 version 1.4
50
+
51
+ ## 6.2.2 - 2016-10-08
52
+
53
+ * Allow to pass nullable Response to delay callable
54
+ * Only add scheme when host is present
55
+ * Fix drain case where content-length is the literal string zero
56
+ * Obfuscate in-URL credentials in exceptions
57
+
58
+ ## 6.2.1 - 2016-07-18
59
+
60
+ * Address HTTP_PROXY security vulnerability, CVE-2016-5385:
61
+ https://httpoxy.org/
62
+ * Fixing timeout bug with StreamHandler:
63
+ https://github.com/guzzle/guzzle/pull/1488
64
+ * Only read up to `Content-Length` in PHP StreamHandler to avoid timeouts when
65
+ a server does not honor `Connection: close`.
66
+ * Ignore URI fragment when sending requests.
67
+
68
+ ## 6.2.0 - 2016-03-21
69
+
70
+ * Feature: added `GuzzleHttp\json_encode` and `GuzzleHttp\json_decode`.
71
+ https://github.com/guzzle/guzzle/pull/1389
72
+ * Bug fix: Fix sleep calculation when waiting for delayed requests.
73
+ https://github.com/guzzle/guzzle/pull/1324
74
+ * Feature: More flexible history containers.
75
+ https://github.com/guzzle/guzzle/pull/1373
76
+ * Bug fix: defer sink stream opening in StreamHandler.
77
+ https://github.com/guzzle/guzzle/pull/1377
78
+ * Bug fix: do not attempt to escape cookie values.
79
+ https://github.com/guzzle/guzzle/pull/1406
80
+ * Feature: report original content encoding and length on decoded responses.
81
+ https://github.com/guzzle/guzzle/pull/1409
82
+ * Bug fix: rewind seekable request bodies before dispatching to cURL.
83
+ https://github.com/guzzle/guzzle/pull/1422
84
+ * Bug fix: provide an empty string to `http_build_query` for HHVM workaround.
85
+ https://github.com/guzzle/guzzle/pull/1367
86
+
87
+ ## 6.1.1 - 2015-11-22
88
+
89
+ * Bug fix: Proxy::wrapSync() now correctly proxies to the appropriate handler
90
+ https://github.com/guzzle/guzzle/commit/911bcbc8b434adce64e223a6d1d14e9a8f63e4e4
91
+ * Feature: HandlerStack is now more generic.
92
+ https://github.com/guzzle/guzzle/commit/f2102941331cda544745eedd97fc8fd46e1ee33e
93
+ * Bug fix: setting verify to false in the StreamHandler now disables peer
94
+ verification. https://github.com/guzzle/guzzle/issues/1256
95
+ * Feature: Middleware now uses an exception factory, including more error
96
+ context. https://github.com/guzzle/guzzle/pull/1282
97
+ * Feature: better support for disabled functions.
98
+ https://github.com/guzzle/guzzle/pull/1287
99
+ * Bug fix: fixed regression where MockHandler was not using `sink`.
100
+ https://github.com/guzzle/guzzle/pull/1292
101
+
102
+ ## 6.1.0 - 2015-09-08
103
+
104
+ * Feature: Added the `on_stats` request option to provide access to transfer
105
+ statistics for requests. https://github.com/guzzle/guzzle/pull/1202
106
+ * Feature: Added the ability to persist session cookies in CookieJars.
107
+ https://github.com/guzzle/guzzle/pull/1195
108
+ * Feature: Some compatibility updates for Google APP Engine
109
+ https://github.com/guzzle/guzzle/pull/1216
110
+ * Feature: Added support for NO_PROXY to prevent the use of a proxy based on
111
+ a simple set of rules. https://github.com/guzzle/guzzle/pull/1197
112
+ * Feature: Cookies can now contain square brackets.
113
+ https://github.com/guzzle/guzzle/pull/1237
114
+ * Bug fix: Now correctly parsing `=` inside of quotes in Cookies.
115
+ https://github.com/guzzle/guzzle/pull/1232
116
+ * Bug fix: Cusotm cURL options now correctly override curl options of the
117
+ same name. https://github.com/guzzle/guzzle/pull/1221
118
+ * Bug fix: Content-Type header is now added when using an explicitly provided
119
+ multipart body. https://github.com/guzzle/guzzle/pull/1218
120
+ * Bug fix: Now ignoring Set-Cookie headers that have no name.
121
+ * Bug fix: Reason phrase is no longer cast to an int in some cases in the
122
+ cURL handler. https://github.com/guzzle/guzzle/pull/1187
123
+ * Bug fix: Remove the Authorization header when redirecting if the Host
124
+ header changes. https://github.com/guzzle/guzzle/pull/1207
125
+ * Bug fix: Cookie path matching fixes
126
+ https://github.com/guzzle/guzzle/issues/1129
127
+ * Bug fix: Fixing the cURL `body_as_string` setting
128
+ https://github.com/guzzle/guzzle/pull/1201
129
+ * Bug fix: quotes are no longer stripped when parsing cookies.
130
+ https://github.com/guzzle/guzzle/issues/1172
131
+ * Bug fix: `form_params` and `query` now always uses the `&` separator.
132
+ https://github.com/guzzle/guzzle/pull/1163
133
+ * Bug fix: Adding a Content-Length to PHP stream wrapper requests if not set.
134
+ https://github.com/guzzle/guzzle/pull/1189
135
+
136
+ ## 6.0.2 - 2015-07-04
137
+
138
+ * Fixed a memory leak in the curl handlers in which references to callbacks
139
+ were not being removed by `curl_reset`.
140
+ * Cookies are now extracted properly before redirects.
141
+ * Cookies now allow more character ranges.
142
+ * Decoded Content-Encoding responses are now modified to correctly reflect
143
+ their state if the encoding was automatically removed by a handler. This
144
+ means that the `Content-Encoding` header may be removed an the
145
+ `Content-Length` modified to reflect the message size after removing the
146
+ encoding.
147
+ * Added a more explicit error message when trying to use `form_params` and
148
+ `multipart` in the same request.
149
+ * Several fixes for HHVM support.
150
+ * Functions are now conditionally required using an additional level of
151
+ indirection to help with global Composer installations.
152
+
153
+ ## 6.0.1 - 2015-05-27
154
+
155
+ * Fixed a bug with serializing the `query` request option where the `&`
156
+ separator was missing.
157
+ * Added a better error message for when `body` is provided as an array. Please
158
+ use `form_params` or `multipart` instead.
159
+ * Various doc fixes.
160
+
161
+ ## 6.0.0 - 2015-05-26
162
+
163
+ * See the UPGRADING.md document for more information.
164
+ * Added `multipart` and `form_params` request options.
165
+ * Added `synchronous` request option.
166
+ * Added the `on_headers` request option.
167
+ * Fixed `expect` handling.
168
+ * No longer adding default middlewares in the client ctor. These need to be
169
+ present on the provided handler in order to work.
170
+ * Requests are no longer initiated when sending async requests with the
171
+ CurlMultiHandler. This prevents unexpected recursion from requests completing
172
+ while ticking the cURL loop.
173
+ * Removed the semantics of setting `default` to `true`. This is no longer
174
+ required now that the cURL loop is not ticked for async requests.
175
+ * Added request and response logging middleware.
176
+ * No longer allowing self signed certificates when using the StreamHandler.
177
+ * Ensuring that `sink` is valid if saving to a file.
178
+ * Request exceptions now include a "handler context" which provides handler
179
+ specific contextual information.
180
+ * Added `GuzzleHttp\RequestOptions` to allow request options to be applied
181
+ using constants.
182
+ * `$maxHandles` has been removed from CurlMultiHandler.
183
+ * `MultipartPostBody` is now part of the `guzzlehttp/psr7` package.
184
+
185
+ ## 5.3.0 - 2015-05-19
186
+
187
+ * Mock now supports `save_to`
188
+ * Marked `AbstractRequestEvent::getTransaction()` as public.
189
+ * Fixed a bug in which multiple headers using different casing would overwrite
190
+ previous headers in the associative array.
191
+ * Added `Utils::getDefaultHandler()`
192
+ * Marked `GuzzleHttp\Client::getDefaultUserAgent` as deprecated.
193
+ * URL scheme is now always lowercased.
194
+
195
+ ## 6.0.0-beta.1
196
+
197
+ * Requires PHP >= 5.5
198
+ * Updated to use PSR-7
199
+ * Requires immutable messages, which basically means an event based system
200
+ owned by a request instance is no longer possible.
201
+ * Utilizing the [Guzzle PSR-7 package](https://github.com/guzzle/psr7).
202
+ * Removed the dependency on `guzzlehttp/streams`. These stream abstractions
203
+ are available in the `guzzlehttp/psr7` package under the `GuzzleHttp\Psr7`
204
+ namespace.
205
+ * Added middleware and handler system
206
+ * Replaced the Guzzle event and subscriber system with a middleware system.
207
+ * No longer depends on RingPHP, but rather places the HTTP handlers directly
208
+ in Guzzle, operating on PSR-7 messages.
209
+ * Retry logic is now encapsulated in `GuzzleHttp\Middleware::retry`, which
210
+ means the `guzzlehttp/retry-subscriber` is now obsolete.
211
+ * Mocking responses is now handled using `GuzzleHttp\Handler\MockHandler`.
212
+ * Asynchronous responses
213
+ * No longer supports the `future` request option to send an async request.
214
+ Instead, use one of the `*Async` methods of a client (e.g., `requestAsync`,
215
+ `getAsync`, etc.).
216
+ * Utilizing `GuzzleHttp\Promise` instead of React's promise library to avoid
217
+ recursion required by chaining and forwarding react promises. See
218
+ https://github.com/guzzle/promises
219
+ * Added `requestAsync` and `sendAsync` to send request asynchronously.
220
+ * Added magic methods for `getAsync()`, `postAsync()`, etc. to send requests
221
+ asynchronously.
222
+ * Request options
223
+ * POST and form updates
224
+ * Added the `form_fields` and `form_files` request options.
225
+ * Removed the `GuzzleHttp\Post` namespace.
226
+ * The `body` request option no longer accepts an array for POST requests.
227
+ * The `exceptions` request option has been deprecated in favor of the
228
+ `http_errors` request options.
229
+ * The `save_to` request option has been deprecated in favor of `sink` request
230
+ option.
231
+ * Clients no longer accept an array of URI template string and variables for
232
+ URI variables. You will need to expand URI templates before passing them
233
+ into a client constructor or request method.
234
+ * Client methods `get()`, `post()`, `put()`, `patch()`, `options()`, etc. are
235
+ now magic methods that will send synchronous requests.
236
+ * Replaced `Utils.php` with plain functions in `functions.php`.
237
+ * Removed `GuzzleHttp\Collection`.
238
+ * Removed `GuzzleHttp\BatchResults`. Batched pool results are now returned as
239
+ an array.
240
+ * Removed `GuzzleHttp\Query`. Query string handling is now handled using an
241
+ associative array passed into the `query` request option. The query string
242
+ is serialized using PHP's `http_build_query`. If you need more control, you
243
+ can pass the query string in as a string.
244
+ * `GuzzleHttp\QueryParser` has been replaced with the
245
+ `GuzzleHttp\Psr7\parse_query`.
246
+
247
+ ## 5.2.0 - 2015-01-27
248
+
249
+ * Added `AppliesHeadersInterface` to make applying headers to a request based
250
+ on the body more generic and not specific to `PostBodyInterface`.
251
+ * Reduced the number of stack frames needed to send requests.
252
+ * Nested futures are now resolved in the client rather than the RequestFsm
253
+ * Finishing state transitions is now handled in the RequestFsm rather than the
254
+ RingBridge.
255
+ * Added a guard in the Pool class to not use recursion for request retries.
256
+
257
+ ## 5.1.0 - 2014-12-19
258
+
259
+ * Pool class no longer uses recursion when a request is intercepted.
260
+ * The size of a Pool can now be dynamically adjusted using a callback.
261
+ See https://github.com/guzzle/guzzle/pull/943.
262
+ * Setting a request option to `null` when creating a request with a client will
263
+ ensure that the option is not set. This allows you to overwrite default
264
+ request options on a per-request basis.
265
+ See https://github.com/guzzle/guzzle/pull/937.
266
+ * Added the ability to limit which protocols are allowed for redirects by
267
+ specifying a `protocols` array in the `allow_redirects` request option.
268
+ * Nested futures due to retries are now resolved when waiting for synchronous
269
+ responses. See https://github.com/guzzle/guzzle/pull/947.
270
+ * `"0"` is now an allowed URI path. See
271
+ https://github.com/guzzle/guzzle/pull/935.
272
+ * `Query` no longer typehints on the `$query` argument in the constructor,
273
+ allowing for strings and arrays.
274
+ * Exceptions thrown in the `end` event are now correctly wrapped with Guzzle
275
+ specific exceptions if necessary.
276
+
277
+ ## 5.0.3 - 2014-11-03
278
+
279
+ This change updates query strings so that they are treated as un-encoded values
280
+ by default where the value represents an un-encoded value to send over the
281
+ wire. A Query object then encodes the value before sending over the wire. This
282
+ means that even value query string values (e.g., ":") are url encoded. This
283
+ makes the Query class match PHP's http_build_query function. However, if you
284
+ want to send requests over the wire using valid query string characters that do
285
+ not need to be encoded, then you can provide a string to Url::setQuery() and
286
+ pass true as the second argument to specify that the query string is a raw
287
+ string that should not be parsed or encoded (unless a call to getQuery() is
288
+ subsequently made, forcing the query-string to be converted into a Query
289
+ object).
290
+
291
+ ## 5.0.2 - 2014-10-30
292
+
293
+ * Added a trailing `\r\n` to multipart/form-data payloads. See
294
+ https://github.com/guzzle/guzzle/pull/871
295
+ * Added a `GuzzleHttp\Pool::send()` convenience method to match the docs.
296
+ * Status codes are now returned as integers. See
297
+ https://github.com/guzzle/guzzle/issues/881
298
+ * No longer overwriting an existing `application/x-www-form-urlencoded` header
299
+ when sending POST requests, allowing for customized headers. See
300
+ https://github.com/guzzle/guzzle/issues/877
301
+ * Improved path URL serialization.
302
+
303
+ * No longer double percent-encoding characters in the path or query string if
304
+ they are already encoded.
305
+ * Now properly encoding the supplied path to a URL object, instead of only
306
+ encoding ' ' and '?'.
307
+ * Note: This has been changed in 5.0.3 to now encode query string values by
308
+ default unless the `rawString` argument is provided when setting the query
309
+ string on a URL: Now allowing many more characters to be present in the
310
+ query string without being percent encoded. See http://tools.ietf.org/html/rfc3986#appendix-A
311
+
312
+ ## 5.0.1 - 2014-10-16
313
+
314
+ Bugfix release.
315
+
316
+ * Fixed an issue where connection errors still returned response object in
317
+ error and end events event though the response is unusable. This has been
318
+ corrected so that a response is not returned in the `getResponse` method of
319
+ these events if the response did not complete. https://github.com/guzzle/guzzle/issues/867
320
+ * Fixed an issue where transfer statistics were not being populated in the
321
+ RingBridge. https://github.com/guzzle/guzzle/issues/866
322
+
323
+ ## 5.0.0 - 2014-10-12
324
+
325
+ Adding support for non-blocking responses and some minor API cleanup.
326
+
327
+ ### New Features
328
+
329
+ * Added support for non-blocking responses based on `guzzlehttp/guzzle-ring`.
330
+ * Added a public API for creating a default HTTP adapter.
331
+ * Updated the redirect plugin to be non-blocking so that redirects are sent
332
+ concurrently. Other plugins like this can now be updated to be non-blocking.
333
+ * Added a "progress" event so that you can get upload and download progress
334
+ events.
335
+ * Added `GuzzleHttp\Pool` which implements FutureInterface and transfers
336
+ requests concurrently using a capped pool size as efficiently as possible.
337
+ * Added `hasListeners()` to EmitterInterface.
338
+ * Removed `GuzzleHttp\ClientInterface::sendAll` and marked
339
+ `GuzzleHttp\Client::sendAll` as deprecated (it's still there, just not the
340
+ recommended way).
341
+
342
+ ### Breaking changes
343
+
344
+ The breaking changes in this release are relatively minor. The biggest thing to
345
+ look out for is that request and response objects no longer implement fluent
346
+ interfaces.
347
+
348
+ * Removed the fluent interfaces (i.e., `return $this`) from requests,
349
+ responses, `GuzzleHttp\Collection`, `GuzzleHttp\Url`,
350
+ `GuzzleHttp\Query`, `GuzzleHttp\Post\PostBody`, and
351
+ `GuzzleHttp\Cookie\SetCookie`. This blog post provides a good outline of
352
+ why I did this: http://ocramius.github.io/blog/fluent-interfaces-are-evil/.
353
+ This also makes the Guzzle message interfaces compatible with the current
354
+ PSR-7 message proposal.
355
+ * Removed "functions.php", so that Guzzle is truly PSR-4 compliant. Except
356
+ for the HTTP request functions from function.php, these functions are now
357
+ implemented in `GuzzleHttp\Utils` using camelCase. `GuzzleHttp\json_decode`
358
+ moved to `GuzzleHttp\Utils::jsonDecode`. `GuzzleHttp\get_path` moved to
359
+ `GuzzleHttp\Utils::getPath`. `GuzzleHttp\set_path` moved to
360
+ `GuzzleHttp\Utils::setPath`. `GuzzleHttp\batch` should now be
361
+ `GuzzleHttp\Pool::batch`, which returns an `objectStorage`. Using functions.php
362
+ caused problems for many users: they aren't PSR-4 compliant, require an
363
+ explicit include, and needed an if-guard to ensure that the functions are not
364
+ declared multiple times.
365
+ * Rewrote adapter layer.
366
+ * Removing all classes from `GuzzleHttp\Adapter`, these are now
367
+ implemented as callables that are stored in `GuzzleHttp\Ring\Client`.
368
+ * Removed the concept of "parallel adapters". Sending requests serially or
369
+ concurrently is now handled using a single adapter.
370
+ * Moved `GuzzleHttp\Adapter\Transaction` to `GuzzleHttp\Transaction`. The
371
+ Transaction object now exposes the request, response, and client as public
372
+ properties. The getters and setters have been removed.
373
+ * Removed the "headers" event. This event was only useful for changing the
374
+ body a response once the headers of the response were known. You can implement
375
+ a similar behavior in a number of ways. One example might be to use a
376
+ FnStream that has access to the transaction being sent. For example, when the
377
+ first byte is written, you could check if the response headers match your
378
+ expectations, and if so, change the actual stream body that is being
379
+ written to.
380
+ * Removed the `asArray` parameter from
381
+ `GuzzleHttp\Message\MessageInterface::getHeader`. If you want to get a header
382
+ value as an array, then use the newly added `getHeaderAsArray()` method of
383
+ `MessageInterface`. This change makes the Guzzle interfaces compatible with
384
+ the PSR-7 interfaces.
385
+ * `GuzzleHttp\Message\MessageFactory` no longer allows subclasses to add
386
+ custom request options using double-dispatch (this was an implementation
387
+ detail). Instead, you should now provide an associative array to the
388
+ constructor which is a mapping of the request option name mapping to a
389
+ function that applies the option value to a request.
390
+ * Removed the concept of "throwImmediately" from exceptions and error events.
391
+ This control mechanism was used to stop a transfer of concurrent requests
392
+ from completing. This can now be handled by throwing the exception or by
393
+ cancelling a pool of requests or each outstanding future request individually.
394
+ * Updated to "GuzzleHttp\Streams" 3.0.
395
+ * `GuzzleHttp\Stream\StreamInterface::getContents()` no longer accepts a
396
+ `maxLen` parameter. This update makes the Guzzle streams project
397
+ compatible with the current PSR-7 proposal.
398
+ * `GuzzleHttp\Stream\Stream::__construct`,
399
+ `GuzzleHttp\Stream\Stream::factory`, and
400
+ `GuzzleHttp\Stream\Utils::create` no longer accept a size in the second
401
+ argument. They now accept an associative array of options, including the
402
+ "size" key and "metadata" key which can be used to provide custom metadata.
403
+
404
+ ## 4.2.2 - 2014-09-08
405
+
406
+ * Fixed a memory leak in the CurlAdapter when reusing cURL handles.
407
+ * No longer using `request_fulluri` in stream adapter proxies.
408
+ * Relative redirects are now based on the last response, not the first response.
409
+
410
+ ## 4.2.1 - 2014-08-19
411
+
412
+ * Ensuring that the StreamAdapter does not always add a Content-Type header
413
+ * Adding automated github releases with a phar and zip
414
+
415
+ ## 4.2.0 - 2014-08-17
416
+
417
+ * Now merging in default options using a case-insensitive comparison.
418
+ Closes https://github.com/guzzle/guzzle/issues/767
419
+ * Added the ability to automatically decode `Content-Encoding` response bodies
420
+ using the `decode_content` request option. This is set to `true` by default
421
+ to decode the response body if it comes over the wire with a
422
+ `Content-Encoding`. Set this value to `false` to disable decoding the
423
+ response content, and pass a string to provide a request `Accept-Encoding`
424
+ header and turn on automatic response decoding. This feature now allows you
425
+ to pass an `Accept-Encoding` header in the headers of a request but still
426
+ disable automatic response decoding.
427
+ Closes https://github.com/guzzle/guzzle/issues/764
428
+ * Added the ability to throw an exception immediately when transferring
429
+ requests in parallel. Closes https://github.com/guzzle/guzzle/issues/760
430
+ * Updating guzzlehttp/streams dependency to ~2.1
431
+ * No longer utilizing the now deprecated namespaced methods from the stream
432
+ package.
433
+
434
+ ## 4.1.8 - 2014-08-14
435
+
436
+ * Fixed an issue in the CurlFactory that caused setting the `stream=false`
437
+ request option to throw an exception.
438
+ See: https://github.com/guzzle/guzzle/issues/769
439
+ * TransactionIterator now calls rewind on the inner iterator.
440
+ See: https://github.com/guzzle/guzzle/pull/765
441
+ * You can now set the `Content-Type` header to `multipart/form-data`
442
+ when creating POST requests to force multipart bodies.
443
+ See https://github.com/guzzle/guzzle/issues/768
444
+
445
+ ## 4.1.7 - 2014-08-07
446
+
447
+ * Fixed an error in the HistoryPlugin that caused the same request and response
448
+ to be logged multiple times when an HTTP protocol error occurs.
449
+ * Ensuring that cURL does not add a default Content-Type when no Content-Type
450
+ has been supplied by the user. This prevents the adapter layer from modifying
451
+ the request that is sent over the wire after any listeners may have already
452
+ put the request in a desired state (e.g., signed the request).
453
+ * Throwing an exception when you attempt to send requests that have the
454
+ "stream" set to true in parallel using the MultiAdapter.
455
+ * Only calling curl_multi_select when there are active cURL handles. This was
456
+ previously changed and caused performance problems on some systems due to PHP
457
+ always selecting until the maximum select timeout.
458
+ * Fixed a bug where multipart/form-data POST fields were not correctly
459
+ aggregated (e.g., values with "&").
460
+
461
+ ## 4.1.6 - 2014-08-03
462
+
463
+ * Added helper methods to make it easier to represent messages as strings,
464
+ including getting the start line and getting headers as a string.
465
+
466
+ ## 4.1.5 - 2014-08-02
467
+
468
+ * Automatically retrying cURL "Connection died, retrying a fresh connect"
469
+ errors when possible.
470
+ * cURL implementation cleanup
471
+ * Allowing multiple event subscriber listeners to be registered per event by
472
+ passing an array of arrays of listener configuration.
473
+
474
+ ## 4.1.4 - 2014-07-22
475
+
476
+ * Fixed a bug that caused multi-part POST requests with more than one field to
477
+ serialize incorrectly.
478
+ * Paths can now be set to "0"
479
+ * `ResponseInterface::xml` now accepts a `libxml_options` option and added a
480
+ missing default argument that was required when parsing XML response bodies.
481
+ * A `save_to` stream is now created lazily, which means that files are not
482
+ created on disk unless a request succeeds.
483
+
484
+ ## 4.1.3 - 2014-07-15
485
+
486
+ * Various fixes to multipart/form-data POST uploads
487
+ * Wrapping function.php in an if-statement to ensure Guzzle can be used
488
+ globally and in a Composer install
489
+ * Fixed an issue with generating and merging in events to an event array
490
+ * POST headers are only applied before sending a request to allow you to change
491
+ the query aggregator used before uploading
492
+ * Added much more robust query string parsing
493
+ * Fixed various parsing and normalization issues with URLs
494
+ * Fixing an issue where multi-valued headers were not being utilized correctly
495
+ in the StreamAdapter
496
+
497
+ ## 4.1.2 - 2014-06-18
498
+
499
+ * Added support for sending payloads with GET requests
500
+
501
+ ## 4.1.1 - 2014-06-08
502
+
503
+ * Fixed an issue related to using custom message factory options in subclasses
504
+ * Fixed an issue with nested form fields in a multi-part POST
505
+ * Fixed an issue with using the `json` request option for POST requests
506
+ * Added `ToArrayInterface` to `GuzzleHttp\Cookie\CookieJar`
507
+
508
+ ## 4.1.0 - 2014-05-27
509
+
510
+ * Added a `json` request option to easily serialize JSON payloads.
511
+ * Added a `GuzzleHttp\json_decode()` wrapper to safely parse JSON.
512
+ * Added `setPort()` and `getPort()` to `GuzzleHttp\Message\RequestInterface`.
513
+ * Added the ability to provide an emitter to a client in the client constructor.
514
+ * Added the ability to persist a cookie session using $_SESSION.
515
+ * Added a trait that can be used to add event listeners to an iterator.
516
+ * Removed request method constants from RequestInterface.
517
+ * Fixed warning when invalid request start-lines are received.
518
+ * Updated MessageFactory to work with custom request option methods.
519
+ * Updated cacert bundle to latest build.
520
+
521
+ 4.0.2 (2014-04-16)
522
+ ------------------
523
+
524
+ * Proxy requests using the StreamAdapter now properly use request_fulluri (#632)
525
+ * Added the ability to set scalars as POST fields (#628)
526
+
527
+ ## 4.0.1 - 2014-04-04
528
+
529
+ * The HTTP status code of a response is now set as the exception code of
530
+ RequestException objects.
531
+ * 303 redirects will now correctly switch from POST to GET requests.
532
+ * The default parallel adapter of a client now correctly uses the MultiAdapter.
533
+ * HasDataTrait now initializes the internal data array as an empty array so
534
+ that the toArray() method always returns an array.
535
+
536
+ ## 4.0.0 - 2014-03-29
537
+
538
+ * For more information on the 4.0 transition, see:
539
+ http://mtdowling.com/blog/2014/03/15/guzzle-4-rc/
540
+ * For information on changes and upgrading, see:
541
+ https://github.com/guzzle/guzzle/blob/master/UPGRADING.md#3x-to-40
542
+ * Added `GuzzleHttp\batch()` as a convenience function for sending requests in
543
+ parallel without needing to write asynchronous code.
544
+ * Restructured how events are added to `GuzzleHttp\ClientInterface::sendAll()`.
545
+ You can now pass a callable or an array of associative arrays where each
546
+ associative array contains the "fn", "priority", and "once" keys.
547
+
548
+ ## 4.0.0.rc-2 - 2014-03-25
549
+
550
+ * Removed `getConfig()` and `setConfig()` from clients to avoid confusion
551
+ around whether things like base_url, message_factory, etc. should be able to
552
+ be retrieved or modified.
553
+ * Added `getDefaultOption()` and `setDefaultOption()` to ClientInterface
554
+ * functions.php functions were renamed using snake_case to match PHP idioms
555
+ * Added support for `HTTP_PROXY`, `HTTPS_PROXY`, and
556
+ `GUZZLE_CURL_SELECT_TIMEOUT` environment variables
557
+ * Added the ability to specify custom `sendAll()` event priorities
558
+ * Added the ability to specify custom stream context options to the stream
559
+ adapter.
560
+ * Added a functions.php function for `get_path()` and `set_path()`
561
+ * CurlAdapter and MultiAdapter now use a callable to generate curl resources
562
+ * MockAdapter now properly reads a body and emits a `headers` event
563
+ * Updated Url class to check if a scheme and host are set before adding ":"
564
+ and "//". This allows empty Url (e.g., "") to be serialized as "".
565
+ * Parsing invalid XML no longer emits warnings
566
+ * Curl classes now properly throw AdapterExceptions
567
+ * Various performance optimizations
568
+ * Streams are created with the faster `Stream\create()` function
569
+ * Marked deprecation_proxy() as internal
570
+ * Test server is now a collection of static methods on a class
571
+
572
+ ## 4.0.0-rc.1 - 2014-03-15
573
+
574
+ * See https://github.com/guzzle/guzzle/blob/master/UPGRADING.md#3x-to-40
575
+
576
+ ## 3.8.1 - 2014-01-28
577
+
578
+ * Bug: Always using GET requests when redirecting from a 303 response
579
+ * Bug: CURLOPT_SSL_VERIFYHOST is now correctly set to false when setting `$certificateAuthority` to false in
580
+ `Guzzle\Http\ClientInterface::setSslVerification()`
581
+ * Bug: RedirectPlugin now uses strict RFC 3986 compliance when combining a base URL with a relative URL
582
+ * Bug: The body of a request can now be set to `"0"`
583
+ * Sending PHP stream requests no longer forces `HTTP/1.0`
584
+ * Adding more information to ExceptionCollection exceptions so that users have more context, including a stack trace of
585
+ each sub-exception
586
+ * Updated the `$ref` attribute in service descriptions to merge over any existing parameters of a schema (rather than
587
+ clobbering everything).
588
+ * Merging URLs will now use the query string object from the relative URL (thus allowing custom query aggregators)
589
+ * Query strings are now parsed in a way that they do no convert empty keys with no value to have a dangling `=`.
590
+ For example `foo&bar=baz` is now correctly parsed and recognized as `foo&bar=baz` rather than `foo=&bar=baz`.
591
+ * Now properly escaping the regular expression delimiter when matching Cookie domains.
592
+ * Network access is now disabled when loading XML documents
593
+
594
+ ## 3.8.0 - 2013-12-05
595
+
596
+ * Added the ability to define a POST name for a file
597
+ * JSON response parsing now properly walks additionalProperties
598
+ * cURL error code 18 is now retried automatically in the BackoffPlugin
599
+ * Fixed a cURL error when URLs contain fragments
600
+ * Fixed an issue in the BackoffPlugin retry event where it was trying to access all exceptions as if they were
601
+ CurlExceptions
602
+ * CURLOPT_PROGRESS function fix for PHP 5.5 (69fcc1e)
603
+ * Added the ability for Guzzle to work with older versions of cURL that do not support `CURLOPT_TIMEOUT_MS`
604
+ * Fixed a bug that was encountered when parsing empty header parameters
605
+ * UriTemplate now has a `setRegex()` method to match the docs
606
+ * The `debug` request parameter now checks if it is truthy rather than if it exists
607
+ * Setting the `debug` request parameter to true shows verbose cURL output instead of using the LogPlugin
608
+ * Added the ability to combine URLs using strict RFC 3986 compliance
609
+ * Command objects can now return the validation errors encountered by the command
610
+ * Various fixes to cache revalidation (#437 and 29797e5)
611
+ * Various fixes to the AsyncPlugin
612
+ * Cleaned up build scripts
613
+
614
+ ## 3.7.4 - 2013-10-02
615
+
616
+ * Bug fix: 0 is now an allowed value in a description parameter that has a default value (#430)
617
+ * Bug fix: SchemaFormatter now returns an integer when formatting to a Unix timestamp
618
+ (see https://github.com/aws/aws-sdk-php/issues/147)
619
+ * Bug fix: Cleaned up and fixed URL dot segment removal to properly resolve internal dots
620
+ * Minimum PHP version is now properly specified as 5.3.3 (up from 5.3.2) (#420)
621
+ * Updated the bundled cacert.pem (#419)
622
+ * OauthPlugin now supports adding authentication to headers or query string (#425)
623
+
624
+ ## 3.7.3 - 2013-09-08
625
+
626
+ * Added the ability to get the exception associated with a request/command when using `MultiTransferException` and
627
+ `CommandTransferException`.
628
+ * Setting `additionalParameters` of a response to false is now honored when parsing responses with a service description
629
+ * Schemas are only injected into response models when explicitly configured.
630
+ * No longer guessing Content-Type based on the path of a request. Content-Type is now only guessed based on the path of
631
+ an EntityBody.
632
+ * Bug fix: ChunkedIterator can now properly chunk a \Traversable as well as an \Iterator.
633
+ * Bug fix: FilterIterator now relies on `\Iterator` instead of `\Traversable`.
634
+ * Bug fix: Gracefully handling malformed responses in RequestMediator::writeResponseBody()
635
+ * Bug fix: Replaced call to canCache with canCacheRequest in the CallbackCanCacheStrategy of the CachePlugin
636
+ * Bug fix: Visiting XML attributes first before visiting XML children when serializing requests
637
+ * Bug fix: Properly parsing headers that contain commas contained in quotes
638
+ * Bug fix: mimetype guessing based on a filename is now case-insensitive
639
+
640
+ ## 3.7.2 - 2013-08-02
641
+
642
+ * Bug fix: Properly URL encoding paths when using the PHP-only version of the UriTemplate expander
643
+ See https://github.com/guzzle/guzzle/issues/371
644
+ * Bug fix: Cookie domains are now matched correctly according to RFC 6265
645
+ See https://github.com/guzzle/guzzle/issues/377
646
+ * Bug fix: GET parameters are now used when calculating an OAuth signature
647
+ * Bug fix: Fixed an issue with cache revalidation where the If-None-Match header was being double quoted
648
+ * `Guzzle\Common\AbstractHasDispatcher::dispatch()` now returns the event that was dispatched
649
+ * `Guzzle\Http\QueryString::factory()` now guesses the most appropriate query aggregator to used based on the input.
650
+ See https://github.com/guzzle/guzzle/issues/379
651
+ * Added a way to add custom domain objects to service description parsing using the `operation.parse_class` event. See
652
+ https://github.com/guzzle/guzzle/pull/380
653
+ * cURL multi cleanup and optimizations
654
+
655
+ ## 3.7.1 - 2013-07-05
656
+
657
+ * Bug fix: Setting default options on a client now works
658
+ * Bug fix: Setting options on HEAD requests now works. See #352
659
+ * Bug fix: Moving stream factory before send event to before building the stream. See #353
660
+ * Bug fix: Cookies no longer match on IP addresses per RFC 6265
661
+ * Bug fix: Correctly parsing header parameters that are in `<>` and quotes
662
+ * Added `cert` and `ssl_key` as request options
663
+ * `Host` header can now diverge from the host part of a URL if the header is set manually
664
+ * `Guzzle\Service\Command\LocationVisitor\Request\XmlVisitor` was rewritten to change from using SimpleXML to XMLWriter
665
+ * OAuth parameters are only added via the plugin if they aren't already set
666
+ * Exceptions are now thrown when a URL cannot be parsed
667
+ * Returning `false` if `Guzzle\Http\EntityBody::getContentMd5()` fails
668
+ * Not setting a `Content-MD5` on a command if calculating the Content-MD5 fails via the CommandContentMd5Plugin
669
+
670
+ ## 3.7.0 - 2013-06-10
671
+
672
+ * See UPGRADING.md for more information on how to upgrade.
673
+ * Requests now support the ability to specify an array of $options when creating a request to more easily modify a
674
+ request. You can pass a 'request.options' configuration setting to a client to apply default request options to
675
+ every request created by a client (e.g. default query string variables, headers, curl options, etc.).
676
+ * Added a static facade class that allows you to use Guzzle with static methods and mount the class to `\Guzzle`.
677
+ See `Guzzle\Http\StaticClient::mount`.
678
+ * Added `command.request_options` to `Guzzle\Service\Command\AbstractCommand` to pass request options to requests
679
+ created by a command (e.g. custom headers, query string variables, timeout settings, etc.).
680
+ * Stream size in `Guzzle\Stream\PhpStreamRequestFactory` will now be set if Content-Length is returned in the
681
+ headers of a response
682
+ * Added `Guzzle\Common\Collection::setPath($path, $value)` to set a value into an array using a nested key
683
+ (e.g. `$collection->setPath('foo/baz/bar', 'test'); echo $collection['foo']['bar']['bar'];`)
684
+ * ServiceBuilders now support storing and retrieving arbitrary data
685
+ * CachePlugin can now purge all resources for a given URI
686
+ * CachePlugin can automatically purge matching cached items when a non-idempotent request is sent to a resource
687
+ * CachePlugin now uses the Vary header to determine if a resource is a cache hit
688
+ * `Guzzle\Http\Message\Response` now implements `\Serializable`
689
+ * Added `Guzzle\Cache\CacheAdapterFactory::fromCache()` to more easily create cache adapters
690
+ * `Guzzle\Service\ClientInterface::execute()` now accepts an array, single command, or Traversable
691
+ * Fixed a bug in `Guzzle\Http\Message\Header\Link::addLink()`
692
+ * Better handling of calculating the size of a stream in `Guzzle\Stream\Stream` using fstat() and caching the size
693
+ * `Guzzle\Common\Exception\ExceptionCollection` now creates a more readable exception message
694
+ * Fixing BC break: Added back the MonologLogAdapter implementation rather than extending from PsrLog so that older
695
+ Symfony users can still use the old version of Monolog.
696
+ * Fixing BC break: Added the implementation back in for `Guzzle\Http\Message\AbstractMessage::getTokenizedHeader()`.
697
+ Now triggering an E_USER_DEPRECATED warning when used. Use `$message->getHeader()->parseParams()`.
698
+ * Several performance improvements to `Guzzle\Common\Collection`
699
+ * Added an `$options` argument to the end of the following methods of `Guzzle\Http\ClientInterface`:
700
+ createRequest, head, delete, put, patch, post, options, prepareRequest
701
+ * Added an `$options` argument to the end of `Guzzle\Http\Message\Request\RequestFactoryInterface::createRequest()`
702
+ * Added an `applyOptions()` method to `Guzzle\Http\Message\Request\RequestFactoryInterface`
703
+ * Changed `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $body = null)` to
704
+ `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $options = array())`. You can still pass in a
705
+ resource, string, or EntityBody into the $options parameter to specify the download location of the response.
706
+ * Changed `Guzzle\Common\Collection::__construct($data)` to no longer accepts a null value for `$data` but a
707
+ default `array()`
708
+ * Added `Guzzle\Stream\StreamInterface::isRepeatable`
709
+ * Removed `Guzzle\Http\ClientInterface::setDefaultHeaders(). Use
710
+ $client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`. or
711
+ $client->getConfig()->setPath('request.options/headers', array('header_name' => 'value'))`.
712
+ * Removed `Guzzle\Http\ClientInterface::getDefaultHeaders(). Use $client->getConfig()->getPath('request.options/headers')`.
713
+ * Removed `Guzzle\Http\ClientInterface::expandTemplate()`
714
+ * Removed `Guzzle\Http\ClientInterface::setRequestFactory()`
715
+ * Removed `Guzzle\Http\ClientInterface::getCurlMulti()`
716
+ * Removed `Guzzle\Http\Message\RequestInterface::canCache`
717
+ * Removed `Guzzle\Http\Message\RequestInterface::setIsRedirect`
718
+ * Removed `Guzzle\Http\Message\RequestInterface::isRedirect`
719
+ * Made `Guzzle\Http\Client::expandTemplate` and `getUriTemplate` protected methods.
720
+ * You can now enable E_USER_DEPRECATED warnings to see if you are using a deprecated method by setting
721
+ `Guzzle\Common\Version::$emitWarnings` to true.
722
+ * Marked `Guzzle\Http\Message\Request::isResponseBodyRepeatable()` as deprecated. Use
723
+ `$request->getResponseBody()->isRepeatable()` instead.
724
+ * Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use
725
+ `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead.
726
+ * Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use
727
+ `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead.
728
+ * Marked `Guzzle\Http\Message\Request::setIsRedirect()` as deprecated. Use the HistoryPlugin instead.
729
+ * Marked `Guzzle\Http\Message\Request::isRedirect()` as deprecated. Use the HistoryPlugin instead.
730
+ * Marked `Guzzle\Cache\CacheAdapterFactory::factory()` as deprecated
731
+ * Marked 'command.headers', 'command.response_body' and 'command.on_complete' as deprecated for AbstractCommand.
732
+ These will work through Guzzle 4.0
733
+ * Marked 'request.params' for `Guzzle\Http\Client` as deprecated. Use [request.options][params].
734
+ * Marked `Guzzle\Service\Client::enableMagicMethods()` as deprecated. Magic methods can no longer be disabled on a Guzzle\Service\Client.
735
+ * Marked `Guzzle\Service\Client::getDefaultHeaders()` as deprecated. Use $client->getConfig()->getPath('request.options/headers')`.
736
+ * Marked `Guzzle\Service\Client::setDefaultHeaders()` as deprecated. Use $client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`.
737
+ * Marked `Guzzle\Parser\Url\UrlParser` as deprecated. Just use PHP's `parse_url()` and percent encode your UTF-8.
738
+ * Marked `Guzzle\Common\Collection::inject()` as deprecated.
739
+ * Marked `Guzzle\Plugin\CurlAuth\CurlAuthPlugin` as deprecated. Use `$client->getConfig()->setPath('request.options/auth', array('user', 'pass', 'Basic|Digest');`
740
+ * CacheKeyProviderInterface and DefaultCacheKeyProvider are no longer used. All of this logic is handled in a
741
+ CacheStorageInterface. These two objects and interface will be removed in a future version.
742
+ * Always setting X-cache headers on cached responses
743
+ * Default cache TTLs are now handled by the CacheStorageInterface of a CachePlugin
744
+ * `CacheStorageInterface::cache($key, Response $response, $ttl = null)` has changed to `cache(RequestInterface
745
+ $request, Response $response);`
746
+ * `CacheStorageInterface::fetch($key)` has changed to `fetch(RequestInterface $request);`
747
+ * `CacheStorageInterface::delete($key)` has changed to `delete(RequestInterface $request);`
748
+ * Added `CacheStorageInterface::purge($url)`
749
+ * `DefaultRevalidation::__construct(CacheKeyProviderInterface $cacheKey, CacheStorageInterface $cache, CachePlugin
750
+ $plugin)` has changed to `DefaultRevalidation::__construct(CacheStorageInterface $cache,
751
+ CanCacheStrategyInterface $canCache = null)`
752
+ * Added `RevalidationInterface::shouldRevalidate(RequestInterface $request, Response $response)`
753
+
754
+ ## 3.6.0 - 2013-05-29
755
+
756
+ * ServiceDescription now implements ToArrayInterface
757
+ * Added command.hidden_params to blacklist certain headers from being treated as additionalParameters
758
+ * Guzzle can now correctly parse incomplete URLs
759
+ * Mixed casing of headers are now forced to be a single consistent casing across all values for that header.
760
+ * Messages internally use a HeaderCollection object to delegate handling case-insensitive header resolution
761
+ * Removed the whole changedHeader() function system of messages because all header changes now go through addHeader().
762
+ * Specific header implementations can be created for complex headers. When a message creates a header, it uses a
763
+ HeaderFactory which can map specific headers to specific header classes. There is now a Link header and
764
+ CacheControl header implementation.
765
+ * Removed from interface: Guzzle\Http\ClientInterface::setUriTemplate
766
+ * Removed from interface: Guzzle\Http\ClientInterface::setCurlMulti()
767
+ * Removed Guzzle\Http\Message\Request::receivedRequestHeader() and implemented this functionality in
768
+ Guzzle\Http\Curl\RequestMediator
769
+ * Removed the optional $asString parameter from MessageInterface::getHeader(). Just cast the header to a string.
770
+ * Removed the optional $tryChunkedTransfer option from Guzzle\Http\Message\EntityEnclosingRequestInterface
771
+ * Removed the $asObjects argument from Guzzle\Http\Message\MessageInterface::getHeaders()
772
+ * Removed Guzzle\Parser\ParserRegister::get(). Use getParser()
773
+ * Removed Guzzle\Parser\ParserRegister::set(). Use registerParser().
774
+ * All response header helper functions return a string rather than mixing Header objects and strings inconsistently
775
+ * Removed cURL blacklist support. This is no longer necessary now that Expect, Accept, etc. are managed by Guzzle
776
+ directly via interfaces
777
+ * Removed the injecting of a request object onto a response object. The methods to get and set a request still exist
778
+ but are a no-op until removed.
779
+ * Most classes that used to require a `Guzzle\Service\Command\CommandInterface` typehint now request a
780
+ `Guzzle\Service\Command\ArrayCommandInterface`.
781
+ * Added `Guzzle\Http\Message\RequestInterface::startResponse()` to the RequestInterface to handle injecting a response
782
+ on a request while the request is still being transferred
783
+ * The ability to case-insensitively search for header values
784
+ * Guzzle\Http\Message\Header::hasExactHeader
785
+ * Guzzle\Http\Message\Header::raw. Use getAll()
786
+ * Deprecated cache control specific methods on Guzzle\Http\Message\AbstractMessage. Use the CacheControl header object
787
+ instead.
788
+ * `Guzzle\Service\Command\CommandInterface` now extends from ToArrayInterface and ArrayAccess
789
+ * Added the ability to cast Model objects to a string to view debug information.
790
+
791
+ ## 3.5.0 - 2013-05-13
792
+
793
+ * Bug: Fixed a regression so that request responses are parsed only once per oncomplete event rather than multiple times
794
+ * Bug: Better cleanup of one-time events across the board (when an event is meant to fire once, it will now remove
795
+ itself from the EventDispatcher)
796
+ * Bug: `Guzzle\Log\MessageFormatter` now properly writes "total_time" and "connect_time" values
797
+ * Bug: Cloning an EntityEnclosingRequest now clones the EntityBody too
798
+ * Bug: Fixed an undefined index error when parsing nested JSON responses with a sentAs parameter that reference a
799
+ non-existent key
800
+ * Bug: All __call() method arguments are now required (helps with mocking frameworks)
801
+ * Deprecating Response::getRequest() and now using a shallow clone of a request object to remove a circular reference
802
+ to help with refcount based garbage collection of resources created by sending a request
803
+ * Deprecating ZF1 cache and log adapters. These will be removed in the next major version.
804
+ * Deprecating `Response::getPreviousResponse()` (method signature still exists, but it's deprecated). Use the
805
+ HistoryPlugin for a history.
806
+ * Added a `responseBody` alias for the `response_body` location
807
+ * Refactored internals to no longer rely on Response::getRequest()
808
+ * HistoryPlugin can now be cast to a string
809
+ * HistoryPlugin now logs transactions rather than requests and responses to more accurately keep track of the requests
810
+ and responses that are sent over the wire
811
+ * Added `getEffectiveUrl()` and `getRedirectCount()` to Response objects
812
+
813
+ ## 3.4.3 - 2013-04-30
814
+
815
+ * Bug fix: Fixing bug introduced in 3.4.2 where redirect responses are duplicated on the final redirected response
816
+ * Added a check to re-extract the temp cacert bundle from the phar before sending each request
817
+
818
+ ## 3.4.2 - 2013-04-29
819
+
820
+ * Bug fix: Stream objects now work correctly with "a" and "a+" modes
821
+ * Bug fix: Removing `Transfer-Encoding: chunked` header when a Content-Length is present
822
+ * Bug fix: AsyncPlugin no longer forces HEAD requests
823
+ * Bug fix: DateTime timezones are now properly handled when using the service description schema formatter
824
+ * Bug fix: CachePlugin now properly handles stale-if-error directives when a request to the origin server fails
825
+ * Setting a response on a request will write to the custom request body from the response body if one is specified
826
+ * LogPlugin now writes to php://output when STDERR is undefined
827
+ * Added the ability to set multiple POST files for the same key in a single call
828
+ * application/x-www-form-urlencoded POSTs now use the utf-8 charset by default
829
+ * Added the ability to queue CurlExceptions to the MockPlugin
830
+ * Cleaned up how manual responses are queued on requests (removed "queued_response" and now using request.before_send)
831
+ * Configuration loading now allows remote files
832
+
833
+ ## 3.4.1 - 2013-04-16
834
+
835
+ * Large refactoring to how CurlMulti handles work. There is now a proxy that sits in front of a pool of CurlMulti
836
+ handles. This greatly simplifies the implementation, fixes a couple bugs, and provides a small performance boost.
837
+ * Exceptions are now properly grouped when sending requests in parallel
838
+ * Redirects are now properly aggregated when a multi transaction fails
839
+ * Redirects now set the response on the original object even in the event of a failure
840
+ * Bug fix: Model names are now properly set even when using $refs
841
+ * Added support for PHP 5.5's CurlFile to prevent warnings with the deprecated @ syntax
842
+ * Added support for oauth_callback in OAuth signatures
843
+ * Added support for oauth_verifier in OAuth signatures
844
+ * Added support to attempt to retrieve a command first literally, then ucfirst, the with inflection
845
+
846
+ ## 3.4.0 - 2013-04-11
847
+
848
+ * Bug fix: URLs are now resolved correctly based on http://tools.ietf.org/html/rfc3986#section-5.2. #289
849
+ * Bug fix: Absolute URLs with a path in a service description will now properly override the base URL. #289
850
+ * Bug fix: Parsing a query string with a single PHP array value will now result in an array. #263
851
+ * Bug fix: Better normalization of the User-Agent header to prevent duplicate headers. #264.
852
+ * Bug fix: Added `number` type to service descriptions.
853
+ * Bug fix: empty parameters are removed from an OAuth signature
854
+ * Bug fix: Revalidating a cache entry prefers the Last-Modified over the Date header
855
+ * Bug fix: Fixed "array to string" error when validating a union of types in a service description
856
+ * Bug fix: Removed code that attempted to determine the size of a stream when data is written to the stream
857
+ * Bug fix: Not including an `oauth_token` if the value is null in the OauthPlugin.
858
+ * Bug fix: Now correctly aggregating successful requests and failed requests in CurlMulti when a redirect occurs.
859
+ * The new default CURLOPT_TIMEOUT setting has been increased to 150 seconds so that Guzzle works on poor connections.
860
+ * Added a feature to EntityEnclosingRequest::setBody() that will automatically set the Content-Type of the request if
861
+ the Content-Type can be determined based on the entity body or the path of the request.
862
+ * Added the ability to overwrite configuration settings in a client when grabbing a throwaway client from a builder.
863
+ * Added support for a PSR-3 LogAdapter.
864
+ * Added a `command.after_prepare` event
865
+ * Added `oauth_callback` parameter to the OauthPlugin
866
+ * Added the ability to create a custom stream class when using a stream factory
867
+ * Added a CachingEntityBody decorator
868
+ * Added support for `additionalParameters` in service descriptions to define how custom parameters are serialized.
869
+ * The bundled SSL certificate is now provided in the phar file and extracted when running Guzzle from a phar.
870
+ * You can now send any EntityEnclosingRequest with POST fields or POST files and cURL will handle creating bodies
871
+ * POST requests using a custom entity body are now treated exactly like PUT requests but with a custom cURL method. This
872
+ means that the redirect behavior of POST requests with custom bodies will not be the same as POST requests that use
873
+ POST fields or files (the latter is only used when emulating a form POST in the browser).
874
+ * Lots of cleanup to CurlHandle::factory and RequestFactory::createRequest
875
+
876
+ ## 3.3.1 - 2013-03-10
877
+
878
+ * Added the ability to create PHP streaming responses from HTTP requests
879
+ * Bug fix: Running any filters when parsing response headers with service descriptions
880
+ * Bug fix: OauthPlugin fixes to allow for multi-dimensional array signing, and sorting parameters before signing
881
+ * Bug fix: Removed the adding of default empty arrays and false Booleans to responses in order to be consistent across
882
+ response location visitors.
883
+ * Bug fix: Removed the possibility of creating configuration files with circular dependencies
884
+ * RequestFactory::create() now uses the key of a POST file when setting the POST file name
885
+ * Added xmlAllowEmpty to serialize an XML body even if no XML specific parameters are set
886
+
887
+ ## 3.3.0 - 2013-03-03
888
+
889
+ * A large number of performance optimizations have been made
890
+ * Bug fix: Added 'wb' as a valid write mode for streams
891
+ * Bug fix: `Guzzle\Http\Message\Response::json()` now allows scalar values to be returned
892
+ * Bug fix: Fixed bug in `Guzzle\Http\Message\Response` where wrapping quotes were stripped from `getEtag()`
893
+ * BC: Removed `Guzzle\Http\Utils` class
894
+ * BC: Setting a service description on a client will no longer modify the client's command factories.
895
+ * BC: Emitting IO events from a RequestMediator is now a parameter that must be set in a request's curl options using
896
+ the 'emit_io' key. This was previously set under a request's parameters using 'curl.emit_io'
897
+ * BC: `Guzzle\Stream\Stream::getWrapper()` and `Guzzle\Stream\Stream::getSteamType()` are no longer converted to
898
+ lowercase
899
+ * Operation parameter objects are now lazy loaded internally
900
+ * Added ErrorResponsePlugin that can throw errors for responses defined in service description operations' errorResponses
901
+ * Added support for instantiating responseType=class responseClass classes. Classes must implement
902
+ `Guzzle\Service\Command\ResponseClassInterface`
903
+ * Added support for additionalProperties for top-level parameters in responseType=model responseClasses. These
904
+ additional properties also support locations and can be used to parse JSON responses where the outermost part of the
905
+ JSON is an array
906
+ * Added support for nested renaming of JSON models (rename sentAs to name)
907
+ * CachePlugin
908
+ * Added support for stale-if-error so that the CachePlugin can now serve stale content from the cache on error
909
+ * Debug headers can now added to cached response in the CachePlugin
910
+
911
+ ## 3.2.0 - 2013-02-14
912
+
913
+ * CurlMulti is no longer reused globally. A new multi object is created per-client. This helps to isolate clients.
914
+ * URLs with no path no longer contain a "/" by default
915
+ * Guzzle\Http\QueryString does no longer manages the leading "?". This is now handled in Guzzle\Http\Url.
916
+ * BadResponseException no longer includes the full request and response message
917
+ * Adding setData() to Guzzle\Service\Description\ServiceDescriptionInterface
918
+ * Adding getResponseBody() to Guzzle\Http\Message\RequestInterface
919
+ * Various updates to classes to use ServiceDescriptionInterface type hints rather than ServiceDescription
920
+ * Header values can now be normalized into distinct values when multiple headers are combined with a comma separated list
921
+ * xmlEncoding can now be customized for the XML declaration of a XML service description operation
922
+ * Guzzle\Http\QueryString now uses Guzzle\Http\QueryAggregator\QueryAggregatorInterface objects to add custom value
923
+ aggregation and no longer uses callbacks
924
+ * The URL encoding implementation of Guzzle\Http\QueryString can now be customized
925
+ * Bug fix: Filters were not always invoked for array service description parameters
926
+ * Bug fix: Redirects now use a target response body rather than a temporary response body
927
+ * Bug fix: The default exponential backoff BackoffPlugin was not giving when the request threshold was exceeded
928
+ * Bug fix: Guzzle now takes the first found value when grabbing Cache-Control directives
929
+
930
+ ## 3.1.2 - 2013-01-27
931
+
932
+ * Refactored how operation responses are parsed. Visitors now include a before() method responsible for parsing the
933
+ response body. For example, the XmlVisitor now parses the XML response into an array in the before() method.
934
+ * Fixed an issue where cURL would not automatically decompress responses when the Accept-Encoding header was sent
935
+ * CURLOPT_SSL_VERIFYHOST is never set to 1 because it is deprecated (see 5e0ff2ef20f839e19d1eeb298f90ba3598784444)
936
+ * Fixed a bug where redirect responses were not chained correctly using getPreviousResponse()
937
+ * Setting default headers on a client after setting the user-agent will not erase the user-agent setting
938
+
939
+ ## 3.1.1 - 2013-01-20
940
+
941
+ * Adding wildcard support to Guzzle\Common\Collection::getPath()
942
+ * Adding alias support to ServiceBuilder configs
943
+ * Adding Guzzle\Service\Resource\CompositeResourceIteratorFactory and cleaning up factory interface
944
+
945
+ ## 3.1.0 - 2013-01-12
946
+
947
+ * BC: CurlException now extends from RequestException rather than BadResponseException
948
+ * BC: Renamed Guzzle\Plugin\Cache\CanCacheStrategyInterface::canCache() to canCacheRequest() and added CanCacheResponse()
949
+ * Added getData to ServiceDescriptionInterface
950
+ * Added context array to RequestInterface::setState()
951
+ * Bug: Removing hard dependency on the BackoffPlugin from Guzzle\Http
952
+ * Bug: Adding required content-type when JSON request visitor adds JSON to a command
953
+ * Bug: Fixing the serialization of a service description with custom data
954
+ * Made it easier to deal with exceptions thrown when transferring commands or requests in parallel by providing
955
+ an array of successful and failed responses
956
+ * Moved getPath from Guzzle\Service\Resource\Model to Guzzle\Common\Collection
957
+ * Added Guzzle\Http\IoEmittingEntityBody
958
+ * Moved command filtration from validators to location visitors
959
+ * Added `extends` attributes to service description parameters
960
+ * Added getModels to ServiceDescriptionInterface
961
+
962
+ ## 3.0.7 - 2012-12-19
963
+
964
+ * Fixing phar detection when forcing a cacert to system if null or true
965
+ * Allowing filename to be passed to `Guzzle\Http\Message\Request::setResponseBody()`
966
+ * Cleaning up `Guzzle\Common\Collection::inject` method
967
+ * Adding a response_body location to service descriptions
968
+
969
+ ## 3.0.6 - 2012-12-09
970
+
971
+ * CurlMulti performance improvements
972
+ * Adding setErrorResponses() to Operation
973
+ * composer.json tweaks
974
+
975
+ ## 3.0.5 - 2012-11-18
976
+
977
+ * Bug: Fixing an infinite recursion bug caused from revalidating with the CachePlugin
978
+ * Bug: Response body can now be a string containing "0"
979
+ * Bug: Using Guzzle inside of a phar uses system by default but now allows for a custom cacert
980
+ * Bug: QueryString::fromString now properly parses query string parameters that contain equal signs
981
+ * Added support for XML attributes in service description responses
982
+ * DefaultRequestSerializer now supports array URI parameter values for URI template expansion
983
+ * Added better mimetype guessing to requests and post files
984
+
985
+ ## 3.0.4 - 2012-11-11
986
+
987
+ * Bug: Fixed a bug when adding multiple cookies to a request to use the correct glue value
988
+ * Bug: Cookies can now be added that have a name, domain, or value set to "0"
989
+ * Bug: Using the system cacert bundle when using the Phar
990
+ * Added json and xml methods to Response to make it easier to parse JSON and XML response data into data structures
991
+ * Enhanced cookie jar de-duplication
992
+ * Added the ability to enable strict cookie jars that throw exceptions when invalid cookies are added
993
+ * Added setStream to StreamInterface to actually make it possible to implement custom rewind behavior for entity bodies
994
+ * Added the ability to create any sort of hash for a stream rather than just an MD5 hash
995
+
996
+ ## 3.0.3 - 2012-11-04
997
+
998
+ * Implementing redirects in PHP rather than cURL
999
+ * Added PECL URI template extension and using as default parser if available
1000
+ * Bug: Fixed Content-Length parsing of Response factory
1001
+ * Adding rewind() method to entity bodies and streams. Allows for custom rewinding of non-repeatable streams.
1002
+ * Adding ToArrayInterface throughout library
1003
+ * Fixing OauthPlugin to create unique nonce values per request
1004
+
1005
+ ## 3.0.2 - 2012-10-25
1006
+
1007
+ * Magic methods are enabled by default on clients
1008
+ * Magic methods return the result of a command
1009
+ * Service clients no longer require a base_url option in the factory
1010
+ * Bug: Fixed an issue with URI templates where null template variables were being expanded
1011
+
1012
+ ## 3.0.1 - 2012-10-22
1013
+
1014
+ * Models can now be used like regular collection objects by calling filter, map, etc.
1015
+ * Models no longer require a Parameter structure or initial data in the constructor
1016
+ * Added a custom AppendIterator to get around a PHP bug with the `\AppendIterator`
1017
+
1018
+ ## 3.0.0 - 2012-10-15
1019
+
1020
+ * Rewrote service description format to be based on Swagger
1021
+ * Now based on JSON schema
1022
+ * Added nested input structures and nested response models
1023
+ * Support for JSON and XML input and output models
1024
+ * Renamed `commands` to `operations`
1025
+ * Removed dot class notation
1026
+ * Removed custom types
1027
+ * Broke the project into smaller top-level namespaces to be more component friendly
1028
+ * Removed support for XML configs and descriptions. Use arrays or JSON files.
1029
+ * Removed the Validation component and Inspector
1030
+ * Moved all cookie code to Guzzle\Plugin\Cookie
1031
+ * Magic methods on a Guzzle\Service\Client now return the command un-executed.
1032
+ * Calling getResult() or getResponse() on a command will lazily execute the command if needed.
1033
+ * Now shipping with cURL's CA certs and using it by default
1034
+ * Added previousResponse() method to response objects
1035
+ * No longer sending Accept and Accept-Encoding headers on every request
1036
+ * Only sending an Expect header by default when a payload is greater than 1MB
1037
+ * Added/moved client options:
1038
+ * curl.blacklist to curl.option.blacklist
1039
+ * Added ssl.certificate_authority
1040
+ * Added a Guzzle\Iterator component
1041
+ * Moved plugins from Guzzle\Http\Plugin to Guzzle\Plugin
1042
+ * Added a more robust backoff retry strategy (replaced the ExponentialBackoffPlugin)
1043
+ * Added a more robust caching plugin
1044
+ * Added setBody to response objects
1045
+ * Updating LogPlugin to use a more flexible MessageFormatter
1046
+ * Added a completely revamped build process
1047
+ * Cleaning up Collection class and removing default values from the get method
1048
+ * Fixed ZF2 cache adapters
1049
+
1050
+ ## 2.8.8 - 2012-10-15
1051
+
1052
+ * Bug: Fixed a cookie issue that caused dot prefixed domains to not match where popular browsers did
1053
+
1054
+ ## 2.8.7 - 2012-09-30
1055
+
1056
+ * Bug: Fixed config file aliases for JSON includes
1057
+ * Bug: Fixed cookie bug on a request object by using CookieParser to parse cookies on requests
1058
+ * Bug: Removing the path to a file when sending a Content-Disposition header on a POST upload
1059
+ * Bug: Hardening request and response parsing to account for missing parts
1060
+ * Bug: Fixed PEAR packaging
1061
+ * Bug: Fixed Request::getInfo
1062
+ * Bug: Fixed cases where CURLM_CALL_MULTI_PERFORM return codes were causing curl transactions to fail
1063
+ * Adding the ability for the namespace Iterator factory to look in multiple directories
1064
+ * Added more getters/setters/removers from service descriptions
1065
+ * Added the ability to remove POST fields from OAuth signatures
1066
+ * OAuth plugin now supports 2-legged OAuth
1067
+
1068
+ ## 2.8.6 - 2012-09-05
1069
+
1070
+ * Added the ability to modify and build service descriptions
1071
+ * Added the use of visitors to apply parameters to locations in service descriptions using the dynamic command
1072
+ * Added a `json` parameter location
1073
+ * Now allowing dot notation for classes in the CacheAdapterFactory
1074
+ * Using the union of two arrays rather than an array_merge when extending service builder services and service params
1075
+ * Ensuring that a service is a string before doing strpos() checks on it when substituting services for references
1076
+ in service builder config files.
1077
+ * Services defined in two different config files that include one another will by default replace the previously
1078
+ defined service, but you can now create services that extend themselves and merge their settings over the previous
1079
+ * The JsonLoader now supports aliasing filenames with different filenames. This allows you to alias something like
1080
+ '_default' with a default JSON configuration file.
1081
+
1082
+ ## 2.8.5 - 2012-08-29
1083
+
1084
+ * Bug: Suppressed empty arrays from URI templates
1085
+ * Bug: Added the missing $options argument from ServiceDescription::factory to enable caching
1086
+ * Added support for HTTP responses that do not contain a reason phrase in the start-line
1087
+ * AbstractCommand commands are now invokable
1088
+ * Added a way to get the data used when signing an Oauth request before a request is sent
1089
+
1090
+ ## 2.8.4 - 2012-08-15
1091
+
1092
+ * Bug: Custom delay time calculations are no longer ignored in the ExponentialBackoffPlugin
1093
+ * Added the ability to transfer entity bodies as a string rather than streamed. This gets around curl error 65. Set `body_as_string` in a request's curl options to enable.
1094
+ * Added a StreamInterface, EntityBodyInterface, and added ftell() to Guzzle\Common\Stream
1095
+ * Added an AbstractEntityBodyDecorator and a ReadLimitEntityBody decorator to transfer only a subset of a decorated stream
1096
+ * Stream and EntityBody objects will now return the file position to the previous position after a read required operation (e.g. getContentMd5())
1097
+ * Added additional response status codes
1098
+ * Removed SSL information from the default User-Agent header
1099
+ * DELETE requests can now send an entity body
1100
+ * Added an EventDispatcher to the ExponentialBackoffPlugin and added an ExponentialBackoffLogger to log backoff retries
1101
+ * Added the ability of the MockPlugin to consume mocked request bodies
1102
+ * LogPlugin now exposes request and response objects in the extras array
1103
+
1104
+ ## 2.8.3 - 2012-07-30
1105
+
1106
+ * Bug: Fixed a case where empty POST requests were sent as GET requests
1107
+ * Bug: Fixed a bug in ExponentialBackoffPlugin that caused fatal errors when retrying an EntityEnclosingRequest that does not have a body
1108
+ * Bug: Setting the response body of a request to null after completing a request, not when setting the state of a request to new
1109
+ * Added multiple inheritance to service description commands
1110
+ * Added an ApiCommandInterface and added `getParamNames()` and `hasParam()`
1111
+ * Removed the default 2mb size cutoff from the Md5ValidatorPlugin so that it now defaults to validating everything
1112
+ * Changed CurlMulti::perform to pass a smaller timeout to CurlMulti::executeHandles
1113
+
1114
+ ## 2.8.2 - 2012-07-24
1115
+
1116
+ * Bug: Query string values set to 0 are no longer dropped from the query string
1117
+ * Bug: A Collection object is no longer created each time a call is made to `Guzzle\Service\Command\AbstractCommand::getRequestHeaders()`
1118
+ * Bug: `+` is now treated as an encoded space when parsing query strings
1119
+ * QueryString and Collection performance improvements
1120
+ * Allowing dot notation for class paths in filters attribute of a service descriptions
1121
+
1122
+ ## 2.8.1 - 2012-07-16
1123
+
1124
+ * Loosening Event Dispatcher dependency
1125
+ * POST redirects can now be customized using CURLOPT_POSTREDIR
1126
+
1127
+ ## 2.8.0 - 2012-07-15
1128
+
1129
+ * BC: Guzzle\Http\Query
1130
+ * Query strings with empty variables will always show an equal sign unless the variable is set to QueryString::BLANK (e.g. ?acl= vs ?acl)
1131
+ * Changed isEncodingValues() and isEncodingFields() to isUrlEncoding()
1132
+ * Changed setEncodeValues(bool) and setEncodeFields(bool) to useUrlEncoding(bool)
1133
+ * Changed the aggregation functions of QueryString to be static methods
1134
+ * Can now use fromString() with querystrings that have a leading ?
1135
+ * cURL configuration values can be specified in service descriptions using `curl.` prefixed parameters
1136
+ * Content-Length is set to 0 before emitting the request.before_send event when sending an empty request body
1137
+ * Cookies are no longer URL decoded by default
1138
+ * Bug: URI template variables set to null are no longer expanded
1139
+
1140
+ ## 2.7.2 - 2012-07-02
1141
+
1142
+ * BC: Moving things to get ready for subtree splits. Moving Inflection into Common. Moving Guzzle\Http\Parser to Guzzle\Parser.
1143
+ * BC: Removing Guzzle\Common\Batch\Batch::count() and replacing it with isEmpty()
1144
+ * CachePlugin now allows for a custom request parameter function to check if a request can be cached
1145
+ * Bug fix: CachePlugin now only caches GET and HEAD requests by default
1146
+ * Bug fix: Using header glue when transferring headers over the wire
1147
+ * Allowing deeply nested arrays for composite variables in URI templates
1148
+ * Batch divisors can now return iterators or arrays
1149
+
1150
+ ## 2.7.1 - 2012-06-26
1151
+
1152
+ * Minor patch to update version number in UA string
1153
+ * Updating build process
1154
+
1155
+ ## 2.7.0 - 2012-06-25
1156
+
1157
+ * BC: Inflection classes moved to Guzzle\Inflection. No longer static methods. Can now inject custom inflectors into classes.
1158
+ * BC: Removed magic setX methods from commands
1159
+ * BC: Magic methods mapped to service description commands are now inflected in the command factory rather than the client __call() method
1160
+ * Verbose cURL options are no longer enabled by default. Set curl.debug to true on a client to enable.
1161
+ * Bug: Now allowing colons in a response start-line (e.g. HTTP/1.1 503 Service Unavailable: Back-end server is at capacity)
1162
+ * Guzzle\Service\Resource\ResourceIteratorApplyBatched now internally uses the Guzzle\Common\Batch namespace
1163
+ * Added Guzzle\Service\Plugin namespace and a PluginCollectionPlugin
1164
+ * Added the ability to set POST fields and files in a service description
1165
+ * Guzzle\Http\EntityBody::factory() now accepts objects with a __toString() method
1166
+ * Adding a command.before_prepare event to clients
1167
+ * Added BatchClosureTransfer and BatchClosureDivisor
1168
+ * BatchTransferException now includes references to the batch divisor and transfer strategies
1169
+ * Fixed some tests so that they pass more reliably
1170
+ * Added Guzzle\Common\Log\ArrayLogAdapter
1171
+
1172
+ ## 2.6.6 - 2012-06-10
1173
+
1174
+ * BC: Removing Guzzle\Http\Plugin\BatchQueuePlugin
1175
+ * BC: Removing Guzzle\Service\Command\CommandSet
1176
+ * Adding generic batching system (replaces the batch queue plugin and command set)
1177
+ * Updating ZF cache and log adapters and now using ZF's composer repository
1178
+ * Bug: Setting the name of each ApiParam when creating through an ApiCommand
1179
+ * Adding result_type, result_doc, deprecated, and doc_url to service descriptions
1180
+ * Bug: Changed the default cookie header casing back to 'Cookie'
1181
+
1182
+ ## 2.6.5 - 2012-06-03
1183
+
1184
+ * BC: Renaming Guzzle\Http\Message\RequestInterface::getResourceUri() to getResource()
1185
+ * BC: Removing unused AUTH_BASIC and AUTH_DIGEST constants from
1186
+ * BC: Guzzle\Http\Cookie is now used to manage Set-Cookie data, not Cookie data
1187
+ * BC: Renaming methods in the CookieJarInterface
1188
+ * Moving almost all cookie logic out of the CookiePlugin and into the Cookie or CookieJar implementations
1189
+ * Making the default glue for HTTP headers ';' instead of ','
1190
+ * Adding a removeValue to Guzzle\Http\Message\Header
1191
+ * Adding getCookies() to request interface.
1192
+ * Making it easier to add event subscribers to HasDispatcherInterface classes. Can now directly call addSubscriber()
1193
+
1194
+ ## 2.6.4 - 2012-05-30
1195
+
1196
+ * BC: Cleaning up how POST files are stored in EntityEnclosingRequest objects. Adding PostFile class.
1197
+ * BC: Moving ApiCommand specific functionality from the Inspector and on to the ApiCommand
1198
+ * Bug: Fixing magic method command calls on clients
1199
+ * Bug: Email constraint only validates strings
1200
+ * Bug: Aggregate POST fields when POST files are present in curl handle
1201
+ * Bug: Fixing default User-Agent header
1202
+ * Bug: Only appending or prepending parameters in commands if they are specified
1203
+ * Bug: Not requiring response reason phrases or status codes to match a predefined list of codes
1204
+ * Allowing the use of dot notation for class namespaces when using instance_of constraint
1205
+ * Added any_match validation constraint
1206
+ * Added an AsyncPlugin
1207
+ * Passing request object to the calculateWait method of the ExponentialBackoffPlugin
1208
+ * Allowing the result of a command object to be changed
1209
+ * Parsing location and type sub values when instantiating a service description rather than over and over at runtime
1210
+
1211
+ ## 2.6.3 - 2012-05-23
1212
+
1213
+ * [BC] Guzzle\Common\FromConfigInterface no longer requires any config options.
1214
+ * [BC] Refactoring how POST files are stored on an EntityEnclosingRequest. They are now separate from POST fields.
1215
+ * You can now use an array of data when creating PUT request bodies in the request factory.
1216
+ * Removing the requirement that HTTPS requests needed a Cache-Control: public directive to be cacheable.
1217
+ * [Http] Adding support for Content-Type in multipart POST uploads per upload
1218
+ * [Http] Added support for uploading multiple files using the same name (foo[0], foo[1])
1219
+ * Adding more POST data operations for easier manipulation of POST data.
1220
+ * You can now set empty POST fields.
1221
+ * The body of a request is only shown on EntityEnclosingRequest objects that do not use POST files.
1222
+ * Split the Guzzle\Service\Inspector::validateConfig method into two methods. One to initialize when a command is created, and one to validate.
1223
+ * CS updates
1224
+
1225
+ ## 2.6.2 - 2012-05-19
1226
+
1227
+ * [Http] Better handling of nested scope requests in CurlMulti. Requests are now always prepares in the send() method rather than the addRequest() method.
1228
+
1229
+ ## 2.6.1 - 2012-05-19
1230
+
1231
+ * [BC] Removing 'path' support in service descriptions. Use 'uri'.
1232
+ * [BC] Guzzle\Service\Inspector::parseDocBlock is now protected. Adding getApiParamsForClass() with cache.
1233
+ * [BC] Removing Guzzle\Common\NullObject. Use https://github.com/mtdowling/NullObject if you need it.
1234
+ * [BC] Removing Guzzle\Common\XmlElement.
1235
+ * All commands, both dynamic and concrete, have ApiCommand objects.
1236
+ * Adding a fix for CurlMulti so that if all of the connections encounter some sort of curl error, then the loop exits.
1237
+ * Adding checks to EntityEnclosingRequest so that empty POST files and fields are ignored.
1238
+ * Making the method signature of Guzzle\Service\Builder\ServiceBuilder::factory more flexible.
1239
+
1240
+ ## 2.6.0 - 2012-05-15
1241
+
1242
+ * [BC] Moving Guzzle\Service\Builder to Guzzle\Service\Builder\ServiceBuilder
1243
+ * [BC] Executing a Command returns the result of the command rather than the command
1244
+ * [BC] Moving all HTTP parsing logic to Guzzle\Http\Parsers. Allows for faster C implementations if needed.
1245
+ * [BC] Changing the Guzzle\Http\Message\Response::setProtocol() method to accept a protocol and version in separate args.
1246
+ * [BC] Moving ResourceIterator* to Guzzle\Service\Resource
1247
+ * [BC] Completely refactored ResourceIterators to iterate over a cloned command object
1248
+ * [BC] Moved Guzzle\Http\UriTemplate to Guzzle\Http\Parser\UriTemplate\UriTemplate
1249
+ * [BC] Guzzle\Guzzle is now deprecated
1250
+ * Moving Guzzle\Common\Guzzle::inject to Guzzle\Common\Collection::inject
1251
+ * Adding Guzzle\Version class to give version information about Guzzle
1252
+ * Adding Guzzle\Http\Utils class to provide getDefaultUserAgent() and getHttpDate()
1253
+ * Adding Guzzle\Curl\CurlVersion to manage caching curl_version() data
1254
+ * ServiceDescription and ServiceBuilder are now cacheable using similar configs
1255
+ * Changing the format of XML and JSON service builder configs. Backwards compatible.
1256
+ * Cleaned up Cookie parsing
1257
+ * Trimming the default Guzzle User-Agent header
1258
+ * Adding a setOnComplete() method to Commands that is called when a command completes
1259
+ * Keeping track of requests that were mocked in the MockPlugin
1260
+ * Fixed a caching bug in the CacheAdapterFactory
1261
+ * Inspector objects can be injected into a Command object
1262
+ * Refactoring a lot of code and tests to be case insensitive when dealing with headers
1263
+ * Adding Guzzle\Http\Message\HeaderComparison for easy comparison of HTTP headers using a DSL
1264
+ * Adding the ability to set global option overrides to service builder configs
1265
+ * Adding the ability to include other service builder config files from within XML and JSON files
1266
+ * Moving the parseQuery method out of Url and on to QueryString::fromString() as a static factory method.
1267
+
1268
+ ## 2.5.0 - 2012-05-08
1269
+
1270
+ * Major performance improvements
1271
+ * [BC] Simplifying Guzzle\Common\Collection. Please check to see if you are using features that are now deprecated.
1272
+ * [BC] Using a custom validation system that allows a flyweight implementation for much faster validation. No longer using Symfony2 Validation component.
1273
+ * [BC] No longer supporting "{{ }}" for injecting into command or UriTemplates. Use "{}"
1274
+ * Added the ability to passed parameters to all requests created by a client
1275
+ * Added callback functionality to the ExponentialBackoffPlugin
1276
+ * Using microtime in ExponentialBackoffPlugin to allow more granular backoff strategies.
1277
+ * Rewinding request stream bodies when retrying requests
1278
+ * Exception is thrown when JSON response body cannot be decoded
1279
+ * Added configurable magic method calls to clients and commands. This is off by default.
1280
+ * Fixed a defect that added a hash to every parsed URL part
1281
+ * Fixed duplicate none generation for OauthPlugin.
1282
+ * Emitting an event each time a client is generated by a ServiceBuilder
1283
+ * Using an ApiParams object instead of a Collection for parameters of an ApiCommand
1284
+ * cache.* request parameters should be renamed to params.cache.*
1285
+ * Added the ability to set arbitrary curl options on requests (disable_wire, progress, etc.). See CurlHandle.
1286
+ * Added the ability to disable type validation of service descriptions
1287
+ * ServiceDescriptions and ServiceBuilders are now Serializable
vendor/guzzlehttp/guzzle/LICENSE ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2011-2018 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
vendor/guzzlehttp/guzzle/README.md ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Guzzle, PHP HTTP client
2
+ =======================
3
+
4
+ [![Latest Version](https://img.shields.io/github/release/guzzle/guzzle.svg?style=flat-square)](https://github.com/guzzle/guzzle/releases)
5
+ [![Build Status](https://img.shields.io/travis/guzzle/guzzle.svg?style=flat-square)](https://travis-ci.org/guzzle/guzzle)
6
+ [![Total Downloads](https://img.shields.io/packagist/dt/guzzlehttp/guzzle.svg?style=flat-square)](https://packagist.org/packages/guzzlehttp/guzzle)
7
+
8
+ Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and
9
+ trivial to integrate with web services.
10
+
11
+ - Simple interface for building query strings, POST requests, streaming large
12
+ uploads, streaming large downloads, using HTTP cookies, uploading JSON data,
13
+ etc...
14
+ - Can send both synchronous and asynchronous requests using the same interface.
15
+ - Uses PSR-7 interfaces for requests, responses, and streams. This allows you
16
+ to utilize other PSR-7 compatible libraries with Guzzle.
17
+ - Abstracts away the underlying HTTP transport, allowing you to write
18
+ environment and transport agnostic code; i.e., no hard dependency on cURL,
19
+ PHP streams, sockets, or non-blocking event loops.
20
+ - Middleware system allows you to augment and compose client behavior.
21
+
22
+ ```php
23
+ $client = new \GuzzleHttp\Client();
24
+ $res = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle');
25
+ echo $res->getStatusCode();
26
+ // 200
27
+ echo $res->getHeaderLine('content-type');
28
+ // 'application/json; charset=utf8'
29
+ echo $res->getBody();
30
+ // '{"id": 1420053, "name": "guzzle", ...}'
31
+
32
+ // Send an asynchronous request.
33
+ $request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org');
34
+ $promise = $client->sendAsync($request)->then(function ($response) {
35
+ echo 'I completed! ' . $response->getBody();
36
+ });
37
+ $promise->wait();
38
+ ```
39
+
40
+ ## Help and docs
41
+
42
+ - [Documentation](http://guzzlephp.org/)
43
+ - [Stack Overflow](http://stackoverflow.com/questions/tagged/guzzle)
44
+ - [Gitter](https://gitter.im/guzzle/guzzle)
45
+
46
+
47
+ ## Installing Guzzle
48
+
49
+ The recommended way to install Guzzle is through
50
+ [Composer](http://getcomposer.org).
51
+
52
+ ```bash
53
+ # Install Composer
54
+ curl -sS https://getcomposer.org/installer | php
55
+ ```
56
+
57
+ Next, run the Composer command to install the latest stable version of Guzzle:
58
+
59
+ ```bash
60
+ php composer.phar require guzzlehttp/guzzle
61
+ ```
62
+
63
+ After installing, you need to require Composer's autoloader:
64
+
65
+ ```php
66
+ require 'vendor/autoload.php';
67
+ ```
68
+
69
+ You can then later update Guzzle using composer:
70
+
71
+ ```bash
72
+ composer.phar update
73
+ ```
74
+
75
+
76
+ ## Version Guidance
77
+
78
+ | Version | Status | Packagist | Namespace | Repo | Docs | PSR-7 | PHP Version |
79
+ |---------|------------|---------------------|--------------|---------------------|---------------------|-------|-------------|
80
+ | 3.x | EOL | `guzzle/guzzle` | `Guzzle` | [v3][guzzle-3-repo] | [v3][guzzle-3-docs] | No | >= 5.3.3 |
81
+ | 4.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v4][guzzle-4-repo] | N/A | No | >= 5.4 |
82
+ | 5.x | Maintained | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No | >= 5.4 |
83
+ | 6.x | Latest | `guzzlehttp/guzzle` | `GuzzleHttp` | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes | >= 5.5 |
84
+
85
+ [guzzle-3-repo]: https://github.com/guzzle/guzzle3
86
+ [guzzle-4-repo]: https://github.com/guzzle/guzzle/tree/4.x
87
+ [guzzle-5-repo]: https://github.com/guzzle/guzzle/tree/5.3
88
+ [guzzle-6-repo]: https://github.com/guzzle/guzzle
89
+ [guzzle-3-docs]: http://guzzle3.readthedocs.org/en/latest/
90
+ [guzzle-5-docs]: http://guzzle.readthedocs.org/en/5.3/
91
+ [guzzle-6-docs]: http://guzzle.readthedocs.org/en/latest/
vendor/guzzlehttp/guzzle/UPGRADING.md ADDED
@@ -0,0 +1,1203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Guzzle Upgrade Guide
2
+ ====================
3
+
4
+ 5.0 to 6.0
5
+ ----------
6
+
7
+ Guzzle now uses [PSR-7](http://www.php-fig.org/psr/psr-7/) for HTTP messages.
8
+ Due to the fact that these messages are immutable, this prompted a refactoring
9
+ of Guzzle to use a middleware based system rather than an event system. Any
10
+ HTTP message interaction (e.g., `GuzzleHttp\Message\Request`) need to be
11
+ updated to work with the new immutable PSR-7 request and response objects. Any
12
+ event listeners or subscribers need to be updated to become middleware
13
+ functions that wrap handlers (or are injected into a
14
+ `GuzzleHttp\HandlerStack`).
15
+
16
+ - Removed `GuzzleHttp\BatchResults`
17
+ - Removed `GuzzleHttp\Collection`
18
+ - Removed `GuzzleHttp\HasDataTrait`
19
+ - Removed `GuzzleHttp\ToArrayInterface`
20
+ - The `guzzlehttp/streams` dependency has been removed. Stream functionality
21
+ is now present in the `GuzzleHttp\Psr7` namespace provided by the
22
+ `guzzlehttp/psr7` package.
23
+ - Guzzle no longer uses ReactPHP promises and now uses the
24
+ `guzzlehttp/promises` library. We use a custom promise library for three
25
+ significant reasons:
26
+ 1. React promises (at the time of writing this) are recursive. Promise
27
+ chaining and promise resolution will eventually blow the stack. Guzzle
28
+ promises are not recursive as they use a sort of trampolining technique.
29
+ Note: there has been movement in the React project to modify promises to
30
+ no longer utilize recursion.
31
+ 2. Guzzle needs to have the ability to synchronously block on a promise to
32
+ wait for a result. Guzzle promises allows this functionality (and does
33
+ not require the use of recursion).
34
+ 3. Because we need to be able to wait on a result, doing so using React
35
+ promises requires wrapping react promises with RingPHP futures. This
36
+ overhead is no longer needed, reducing stack sizes, reducing complexity,
37
+ and improving performance.
38
+ - `GuzzleHttp\Mimetypes` has been moved to a function in
39
+ `GuzzleHttp\Psr7\mimetype_from_extension` and
40
+ `GuzzleHttp\Psr7\mimetype_from_filename`.
41
+ - `GuzzleHttp\Query` and `GuzzleHttp\QueryParser` have been removed. Query
42
+ strings must now be passed into request objects as strings, or provided to
43
+ the `query` request option when creating requests with clients. The `query`
44
+ option uses PHP's `http_build_query` to convert an array to a string. If you
45
+ need a different serialization technique, you will need to pass the query
46
+ string in as a string. There are a couple helper functions that will make
47
+ working with query strings easier: `GuzzleHttp\Psr7\parse_query` and
48
+ `GuzzleHttp\Psr7\build_query`.
49
+ - Guzzle no longer has a dependency on RingPHP. Due to the use of a middleware
50
+ system based on PSR-7, using RingPHP and it's middleware system as well adds
51
+ more complexity than the benefits it provides. All HTTP handlers that were
52
+ present in RingPHP have been modified to work directly with PSR-7 messages
53
+ and placed in the `GuzzleHttp\Handler` namespace. This significantly reduces
54
+ complexity in Guzzle, removes a dependency, and improves performance. RingPHP
55
+ will be maintained for Guzzle 5 support, but will no longer be a part of
56
+ Guzzle 6.
57
+ - As Guzzle now uses a middleware based systems the event system and RingPHP
58
+ integration has been removed. Note: while the event system has been removed,
59
+ it is possible to add your own type of event system that is powered by the
60
+ middleware system.
61
+ - Removed the `Event` namespace.
62
+ - Removed the `Subscriber` namespace.
63
+ - Removed `Transaction` class
64
+ - Removed `RequestFsm`
65
+ - Removed `RingBridge`
66
+ - `GuzzleHttp\Subscriber\Cookie` is now provided by
67
+ `GuzzleHttp\Middleware::cookies`
68
+ - `GuzzleHttp\Subscriber\HttpError` is now provided by
69
+ `GuzzleHttp\Middleware::httpError`
70
+ - `GuzzleHttp\Subscriber\History` is now provided by
71
+ `GuzzleHttp\Middleware::history`
72
+ - `GuzzleHttp\Subscriber\Mock` is now provided by
73
+ `GuzzleHttp\Handler\MockHandler`
74
+ - `GuzzleHttp\Subscriber\Prepare` is now provided by
75
+ `GuzzleHttp\PrepareBodyMiddleware`
76
+ - `GuzzleHttp\Subscriber\Redirect` is now provided by
77
+ `GuzzleHttp\RedirectMiddleware`
78
+ - Guzzle now uses `Psr\Http\Message\UriInterface` (implements in
79
+ `GuzzleHttp\Psr7\Uri`) for URI support. `GuzzleHttp\Url` is now gone.
80
+ - Static functions in `GuzzleHttp\Utils` have been moved to namespaced
81
+ functions under the `GuzzleHttp` namespace. This requires either a Composer
82
+ based autoloader or you to include functions.php.
83
+ - `GuzzleHttp\ClientInterface::getDefaultOption` has been renamed to
84
+ `GuzzleHttp\ClientInterface::getConfig`.
85
+ - `GuzzleHttp\ClientInterface::setDefaultOption` has been removed.
86
+ - The `json` and `xml` methods of response objects has been removed. With the
87
+ migration to strictly adhering to PSR-7 as the interface for Guzzle messages,
88
+ adding methods to message interfaces would actually require Guzzle messages
89
+ to extend from PSR-7 messages rather then work with them directly.
90
+
91
+ ## Migrating to middleware
92
+
93
+ The change to PSR-7 unfortunately required significant refactoring to Guzzle
94
+ due to the fact that PSR-7 messages are immutable. Guzzle 5 relied on an event
95
+ system from plugins. The event system relied on mutability of HTTP messages and
96
+ side effects in order to work. With immutable messages, you have to change your
97
+ workflow to become more about either returning a value (e.g., functional
98
+ middlewares) or setting a value on an object. Guzzle v6 has chosen the
99
+ functional middleware approach.
100
+
101
+ Instead of using the event system to listen for things like the `before` event,
102
+ you now create a stack based middleware function that intercepts a request on
103
+ the way in and the promise of the response on the way out. This is a much
104
+ simpler and more predictable approach than the event system and works nicely
105
+ with PSR-7 middleware. Due to the use of promises, the middleware system is
106
+ also asynchronous.
107
+
108
+ v5:
109
+
110
+ ```php
111
+ use GuzzleHttp\Event\BeforeEvent;
112
+ $client = new GuzzleHttp\Client();
113
+ // Get the emitter and listen to the before event.
114
+ $client->getEmitter()->on('before', function (BeforeEvent $e) {
115
+ // Guzzle v5 events relied on mutation
116
+ $e->getRequest()->setHeader('X-Foo', 'Bar');
117
+ });
118
+ ```
119
+
120
+ v6:
121
+
122
+ In v6, you can modify the request before it is sent using the `mapRequest`
123
+ middleware. The idiomatic way in v6 to modify the request/response lifecycle is
124
+ to setup a handler middleware stack up front and inject the handler into a
125
+ client.
126
+
127
+ ```php
128
+ use GuzzleHttp\Middleware;
129
+ // Create a handler stack that has all of the default middlewares attached
130
+ $handler = GuzzleHttp\HandlerStack::create();
131
+ // Push the handler onto the handler stack
132
+ $handler->push(Middleware::mapRequest(function (RequestInterface $request) {
133
+ // Notice that we have to return a request object
134
+ return $request->withHeader('X-Foo', 'Bar');
135
+ }));
136
+ // Inject the handler into the client
137
+ $client = new GuzzleHttp\Client(['handler' => $handler]);
138
+ ```
139
+
140
+ ## POST Requests
141
+
142
+ This version added the [`form_params`](http://guzzle.readthedocs.org/en/latest/request-options.html#form_params)
143
+ and `multipart` request options. `form_params` is an associative array of
144
+ strings or array of strings and is used to serialize an
145
+ `application/x-www-form-urlencoded` POST request. The
146
+ [`multipart`](http://guzzle.readthedocs.org/en/latest/request-options.html#multipart)
147
+ option is now used to send a multipart/form-data POST request.
148
+
149
+ `GuzzleHttp\Post\PostFile` has been removed. Use the `multipart` option to add
150
+ POST files to a multipart/form-data request.
151
+
152
+ The `body` option no longer accepts an array to send POST requests. Please use
153
+ `multipart` or `form_params` instead.
154
+
155
+ The `base_url` option has been renamed to `base_uri`.
156
+
157
+ 4.x to 5.0
158
+ ----------
159
+
160
+ ## Rewritten Adapter Layer
161
+
162
+ Guzzle now uses [RingPHP](http://ringphp.readthedocs.org/en/latest) to send
163
+ HTTP requests. The `adapter` option in a `GuzzleHttp\Client` constructor
164
+ is still supported, but it has now been renamed to `handler`. Instead of
165
+ passing a `GuzzleHttp\Adapter\AdapterInterface`, you must now pass a PHP
166
+ `callable` that follows the RingPHP specification.
167
+
168
+ ## Removed Fluent Interfaces
169
+
170
+ [Fluent interfaces were removed](http://ocramius.github.io/blog/fluent-interfaces-are-evil)
171
+ from the following classes:
172
+
173
+ - `GuzzleHttp\Collection`
174
+ - `GuzzleHttp\Url`
175
+ - `GuzzleHttp\Query`
176
+ - `GuzzleHttp\Post\PostBody`
177
+ - `GuzzleHttp\Cookie\SetCookie`
178
+
179
+ ## Removed functions.php
180
+
181
+ Removed "functions.php", so that Guzzle is truly PSR-4 compliant. The following
182
+ functions can be used as replacements.
183
+
184
+ - `GuzzleHttp\json_decode` -> `GuzzleHttp\Utils::jsonDecode`
185
+ - `GuzzleHttp\get_path` -> `GuzzleHttp\Utils::getPath`
186
+ - `GuzzleHttp\Utils::setPath` -> `GuzzleHttp\set_path`
187
+ - `GuzzleHttp\Pool::batch` -> `GuzzleHttp\batch`. This function is, however,
188
+ deprecated in favor of using `GuzzleHttp\Pool::batch()`.
189
+
190
+ The "procedural" global client has been removed with no replacement (e.g.,
191
+ `GuzzleHttp\get()`, `GuzzleHttp\post()`, etc.). Use a `GuzzleHttp\Client`
192
+ object as a replacement.
193
+
194
+ ## `throwImmediately` has been removed
195
+
196
+ The concept of "throwImmediately" has been removed from exceptions and error
197
+ events. This control mechanism was used to stop a transfer of concurrent
198
+ requests from completing. This can now be handled by throwing the exception or
199
+ by cancelling a pool of requests or each outstanding future request
200
+ individually.
201
+
202
+ ## headers event has been removed
203
+
204
+ Removed the "headers" event. This event was only useful for changing the
205
+ body a response once the headers of the response were known. You can implement
206
+ a similar behavior in a number of ways. One example might be to use a
207
+ FnStream that has access to the transaction being sent. For example, when the
208
+ first byte is written, you could check if the response headers match your
209
+ expectations, and if so, change the actual stream body that is being
210
+ written to.
211
+
212
+ ## Updates to HTTP Messages
213
+
214
+ Removed the `asArray` parameter from
215
+ `GuzzleHttp\Message\MessageInterface::getHeader`. If you want to get a header
216
+ value as an array, then use the newly added `getHeaderAsArray()` method of
217
+ `MessageInterface`. This change makes the Guzzle interfaces compatible with
218
+ the PSR-7 interfaces.
219
+
220
+ 3.x to 4.0
221
+ ----------
222
+
223
+ ## Overarching changes:
224
+
225
+ - Now requires PHP 5.4 or greater.
226
+ - No longer requires cURL to send requests.
227
+ - Guzzle no longer wraps every exception it throws. Only exceptions that are
228
+ recoverable are now wrapped by Guzzle.
229
+ - Various namespaces have been removed or renamed.
230
+ - No longer requiring the Symfony EventDispatcher. A custom event dispatcher
231
+ based on the Symfony EventDispatcher is
232
+ now utilized in `GuzzleHttp\Event\EmitterInterface` (resulting in significant
233
+ speed and functionality improvements).
234
+
235
+ Changes per Guzzle 3.x namespace are described below.
236
+
237
+ ## Batch
238
+
239
+ The `Guzzle\Batch` namespace has been removed. This is best left to
240
+ third-parties to implement on top of Guzzle's core HTTP library.
241
+
242
+ ## Cache
243
+
244
+ The `Guzzle\Cache` namespace has been removed. (Todo: No suitable replacement
245
+ has been implemented yet, but hoping to utilize a PSR cache interface).
246
+
247
+ ## Common
248
+
249
+ - Removed all of the wrapped exceptions. It's better to use the standard PHP
250
+ library for unrecoverable exceptions.
251
+ - `FromConfigInterface` has been removed.
252
+ - `Guzzle\Common\Version` has been removed. The VERSION constant can be found
253
+ at `GuzzleHttp\ClientInterface::VERSION`.
254
+
255
+ ### Collection
256
+
257
+ - `getAll` has been removed. Use `toArray` to convert a collection to an array.
258
+ - `inject` has been removed.
259
+ - `keySearch` has been removed.
260
+ - `getPath` no longer supports wildcard expressions. Use something better like
261
+ JMESPath for this.
262
+ - `setPath` now supports appending to an existing array via the `[]` notation.
263
+
264
+ ### Events
265
+
266
+ Guzzle no longer requires Symfony's EventDispatcher component. Guzzle now uses
267
+ `GuzzleHttp\Event\Emitter`.
268
+
269
+ - `Symfony\Component\EventDispatcher\EventDispatcherInterface` is replaced by
270
+ `GuzzleHttp\Event\EmitterInterface`.
271
+ - `Symfony\Component\EventDispatcher\EventDispatcher` is replaced by
272
+ `GuzzleHttp\Event\Emitter`.
273
+ - `Symfony\Component\EventDispatcher\Event` is replaced by
274
+ `GuzzleHttp\Event\Event`, and Guzzle now has an EventInterface in
275
+ `GuzzleHttp\Event\EventInterface`.
276
+ - `AbstractHasDispatcher` has moved to a trait, `HasEmitterTrait`, and
277
+ `HasDispatcherInterface` has moved to `HasEmitterInterface`. Retrieving the
278
+ event emitter of a request, client, etc. now uses the `getEmitter` method
279
+ rather than the `getDispatcher` method.
280
+
281
+ #### Emitter
282
+
283
+ - Use the `once()` method to add a listener that automatically removes itself
284
+ the first time it is invoked.
285
+ - Use the `listeners()` method to retrieve a list of event listeners rather than
286
+ the `getListeners()` method.
287
+ - Use `emit()` instead of `dispatch()` to emit an event from an emitter.
288
+ - Use `attach()` instead of `addSubscriber()` and `detach()` instead of
289
+ `removeSubscriber()`.
290
+
291
+ ```php
292
+ $mock = new Mock();
293
+ // 3.x
294
+ $request->getEventDispatcher()->addSubscriber($mock);
295
+ $request->getEventDispatcher()->removeSubscriber($mock);
296
+ // 4.x
297
+ $request->getEmitter()->attach($mock);
298
+ $request->getEmitter()->detach($mock);
299
+ ```
300
+
301
+ Use the `on()` method to add a listener rather than the `addListener()` method.
302
+
303
+ ```php
304
+ // 3.x
305
+ $request->getEventDispatcher()->addListener('foo', function (Event $event) { /* ... */ } );
306
+ // 4.x
307
+ $request->getEmitter()->on('foo', function (Event $event, $name) { /* ... */ } );
308
+ ```
309
+
310
+ ## Http
311
+
312
+ ### General changes
313
+
314
+ - The cacert.pem certificate has been moved to `src/cacert.pem`.
315
+ - Added the concept of adapters that are used to transfer requests over the
316
+ wire.
317
+ - Simplified the event system.
318
+ - Sending requests in parallel is still possible, but batching is no longer a
319
+ concept of the HTTP layer. Instead, you must use the `complete` and `error`
320
+ events to asynchronously manage parallel request transfers.
321
+ - `Guzzle\Http\Url` has moved to `GuzzleHttp\Url`.
322
+ - `Guzzle\Http\QueryString` has moved to `GuzzleHttp\Query`.
323
+ - QueryAggregators have been rewritten so that they are simply callable
324
+ functions.
325
+ - `GuzzleHttp\StaticClient` has been removed. Use the functions provided in
326
+ `functions.php` for an easy to use static client instance.
327
+ - Exceptions in `GuzzleHttp\Exception` have been updated to all extend from
328
+ `GuzzleHttp\Exception\TransferException`.
329
+
330
+ ### Client
331
+
332
+ Calling methods like `get()`, `post()`, `head()`, etc. no longer create and
333
+ return a request, but rather creates a request, sends the request, and returns
334
+ the response.
335
+
336
+ ```php
337
+ // 3.0
338
+ $request = $client->get('/');
339
+ $response = $request->send();
340
+
341
+ // 4.0
342
+ $response = $client->get('/');
343
+
344
+ // or, to mirror the previous behavior
345
+ $request = $client->createRequest('GET', '/');
346
+ $response = $client->send($request);
347
+ ```
348
+
349
+ `GuzzleHttp\ClientInterface` has changed.
350
+
351
+ - The `send` method no longer accepts more than one request. Use `sendAll` to
352
+ send multiple requests in parallel.
353
+ - `setUserAgent()` has been removed. Use a default request option instead. You
354
+ could, for example, do something like:
355
+ `$client->setConfig('defaults/headers/User-Agent', 'Foo/Bar ' . $client::getDefaultUserAgent())`.
356
+ - `setSslVerification()` has been removed. Use default request options instead,
357
+ like `$client->setConfig('defaults/verify', true)`.
358
+
359
+ `GuzzleHttp\Client` has changed.
360
+
361
+ - The constructor now accepts only an associative array. You can include a
362
+ `base_url` string or array to use a URI template as the base URL of a client.
363
+ You can also specify a `defaults` key that is an associative array of default
364
+ request options. You can pass an `adapter` to use a custom adapter,
365
+ `batch_adapter` to use a custom adapter for sending requests in parallel, or
366
+ a `message_factory` to change the factory used to create HTTP requests and
367
+ responses.
368
+ - The client no longer emits a `client.create_request` event.
369
+ - Creating requests with a client no longer automatically utilize a URI
370
+ template. You must pass an array into a creational method (e.g.,
371
+ `createRequest`, `get`, `put`, etc.) in order to expand a URI template.
372
+
373
+ ### Messages
374
+
375
+ Messages no longer have references to their counterparts (i.e., a request no
376
+ longer has a reference to it's response, and a response no loger has a
377
+ reference to its request). This association is now managed through a
378
+ `GuzzleHttp\Adapter\TransactionInterface` object. You can get references to
379
+ these transaction objects using request events that are emitted over the
380
+ lifecycle of a request.
381
+
382
+ #### Requests with a body
383
+
384
+ - `GuzzleHttp\Message\EntityEnclosingRequest` and
385
+ `GuzzleHttp\Message\EntityEnclosingRequestInterface` have been removed. The
386
+ separation between requests that contain a body and requests that do not
387
+ contain a body has been removed, and now `GuzzleHttp\Message\RequestInterface`
388
+ handles both use cases.
389
+ - Any method that previously accepts a `GuzzleHttp\Response` object now accept a
390
+ `GuzzleHttp\Message\ResponseInterface`.
391
+ - `GuzzleHttp\Message\RequestFactoryInterface` has been renamed to
392
+ `GuzzleHttp\Message\MessageFactoryInterface`. This interface is used to create
393
+ both requests and responses and is implemented in
394
+ `GuzzleHttp\Message\MessageFactory`.
395
+ - POST field and file methods have been removed from the request object. You
396
+ must now use the methods made available to `GuzzleHttp\Post\PostBodyInterface`
397
+ to control the format of a POST body. Requests that are created using a
398
+ standard `GuzzleHttp\Message\MessageFactoryInterface` will automatically use
399
+ a `GuzzleHttp\Post\PostBody` body if the body was passed as an array or if
400
+ the method is POST and no body is provided.
401
+
402
+ ```php
403
+ $request = $client->createRequest('POST', '/');
404
+ $request->getBody()->setField('foo', 'bar');
405
+ $request->getBody()->addFile(new PostFile('file_key', fopen('/path/to/content', 'r')));
406
+ ```
407
+
408
+ #### Headers
409
+
410
+ - `GuzzleHttp\Message\Header` has been removed. Header values are now simply
411
+ represented by an array of values or as a string. Header values are returned
412
+ as a string by default when retrieving a header value from a message. You can
413
+ pass an optional argument of `true` to retrieve a header value as an array
414
+ of strings instead of a single concatenated string.
415
+ - `GuzzleHttp\PostFile` and `GuzzleHttp\PostFileInterface` have been moved to
416
+ `GuzzleHttp\Post`. This interface has been simplified and now allows the
417
+ addition of arbitrary headers.
418
+ - Custom headers like `GuzzleHttp\Message\Header\Link` have been removed. Most
419
+ of the custom headers are now handled separately in specific
420
+ subscribers/plugins, and `GuzzleHttp\Message\HeaderValues::parseParams()` has
421
+ been updated to properly handle headers that contain parameters (like the
422
+ `Link` header).
423
+
424
+ #### Responses
425
+
426
+ - `GuzzleHttp\Message\Response::getInfo()` and
427
+ `GuzzleHttp\Message\Response::setInfo()` have been removed. Use the event
428
+ system to retrieve this type of information.
429
+ - `GuzzleHttp\Message\Response::getRawHeaders()` has been removed.
430
+ - `GuzzleHttp\Message\Response::getMessage()` has been removed.
431
+ - `GuzzleHttp\Message\Response::calculateAge()` and other cache specific
432
+ methods have moved to the CacheSubscriber.
433
+ - Header specific helper functions like `getContentMd5()` have been removed.
434
+ Just use `getHeader('Content-MD5')` instead.
435
+ - `GuzzleHttp\Message\Response::setRequest()` and
436
+ `GuzzleHttp\Message\Response::getRequest()` have been removed. Use the event
437
+ system to work with request and response objects as a transaction.
438
+ - `GuzzleHttp\Message\Response::getRedirectCount()` has been removed. Use the
439
+ Redirect subscriber instead.
440
+ - `GuzzleHttp\Message\Response::isSuccessful()` and other related methods have
441
+ been removed. Use `getStatusCode()` instead.
442
+
443
+ #### Streaming responses
444
+
445
+ Streaming requests can now be created by a client directly, returning a
446
+ `GuzzleHttp\Message\ResponseInterface` object that contains a body stream
447
+ referencing an open PHP HTTP stream.
448
+
449
+ ```php
450
+ // 3.0
451
+ use Guzzle\Stream\PhpStreamRequestFactory;
452
+ $request = $client->get('/');
453
+ $factory = new PhpStreamRequestFactory();
454
+ $stream = $factory->fromRequest($request);
455
+ $data = $stream->read(1024);
456
+
457
+ // 4.0
458
+ $response = $client->get('/', ['stream' => true]);
459
+ // Read some data off of the stream in the response body
460
+ $data = $response->getBody()->read(1024);
461
+ ```
462
+
463
+ #### Redirects
464
+
465
+ The `configureRedirects()` method has been removed in favor of a
466
+ `allow_redirects` request option.
467
+
468
+ ```php
469
+ // Standard redirects with a default of a max of 5 redirects
470
+ $request = $client->createRequest('GET', '/', ['allow_redirects' => true]);
471
+
472
+ // Strict redirects with a custom number of redirects
473
+ $request = $client->createRequest('GET', '/', [
474
+ 'allow_redirects' => ['max' => 5, 'strict' => true]
475
+ ]);
476
+ ```
477
+
478
+ #### EntityBody
479
+
480
+ EntityBody interfaces and classes have been removed or moved to
481
+ `GuzzleHttp\Stream`. All classes and interfaces that once required
482
+ `GuzzleHttp\EntityBodyInterface` now require
483
+ `GuzzleHttp\Stream\StreamInterface`. Creating a new body for a request no
484
+ longer uses `GuzzleHttp\EntityBody::factory` but now uses
485
+ `GuzzleHttp\Stream\Stream::factory` or even better:
486
+ `GuzzleHttp\Stream\create()`.
487
+
488
+ - `Guzzle\Http\EntityBodyInterface` is now `GuzzleHttp\Stream\StreamInterface`
489
+ - `Guzzle\Http\EntityBody` is now `GuzzleHttp\Stream\Stream`
490
+ - `Guzzle\Http\CachingEntityBody` is now `GuzzleHttp\Stream\CachingStream`
491
+ - `Guzzle\Http\ReadLimitEntityBody` is now `GuzzleHttp\Stream\LimitStream`
492
+ - `Guzzle\Http\IoEmittyinEntityBody` has been removed.
493
+
494
+ #### Request lifecycle events
495
+
496
+ Requests previously submitted a large number of requests. The number of events
497
+ emitted over the lifecycle of a request has been significantly reduced to make
498
+ it easier to understand how to extend the behavior of a request. All events
499
+ emitted during the lifecycle of a request now emit a custom
500
+ `GuzzleHttp\Event\EventInterface` object that contains context providing
501
+ methods and a way in which to modify the transaction at that specific point in
502
+ time (e.g., intercept the request and set a response on the transaction).
503
+
504
+ - `request.before_send` has been renamed to `before` and now emits a
505
+ `GuzzleHttp\Event\BeforeEvent`
506
+ - `request.complete` has been renamed to `complete` and now emits a
507
+ `GuzzleHttp\Event\CompleteEvent`.
508
+ - `request.sent` has been removed. Use `complete`.
509
+ - `request.success` has been removed. Use `complete`.
510
+ - `error` is now an event that emits a `GuzzleHttp\Event\ErrorEvent`.
511
+ - `request.exception` has been removed. Use `error`.
512
+ - `request.receive.status_line` has been removed.
513
+ - `curl.callback.progress` has been removed. Use a custom `StreamInterface` to
514
+ maintain a status update.
515
+ - `curl.callback.write` has been removed. Use a custom `StreamInterface` to
516
+ intercept writes.
517
+ - `curl.callback.read` has been removed. Use a custom `StreamInterface` to
518
+ intercept reads.
519
+
520
+ `headers` is a new event that is emitted after the response headers of a
521
+ request have been received before the body of the response is downloaded. This
522
+ event emits a `GuzzleHttp\Event\HeadersEvent`.
523
+
524
+ You can intercept a request and inject a response using the `intercept()` event
525
+ of a `GuzzleHttp\Event\BeforeEvent`, `GuzzleHttp\Event\CompleteEvent`, and
526
+ `GuzzleHttp\Event\ErrorEvent` event.
527
+
528
+ See: http://docs.guzzlephp.org/en/latest/events.html
529
+
530
+ ## Inflection
531
+
532
+ The `Guzzle\Inflection` namespace has been removed. This is not a core concern
533
+ of Guzzle.
534
+
535
+ ## Iterator
536
+
537
+ The `Guzzle\Iterator` namespace has been removed.
538
+
539
+ - `Guzzle\Iterator\AppendIterator`, `Guzzle\Iterator\ChunkedIterator`, and
540
+ `Guzzle\Iterator\MethodProxyIterator` are nice, but not a core requirement of
541
+ Guzzle itself.
542
+ - `Guzzle\Iterator\FilterIterator` is no longer needed because an equivalent
543
+ class is shipped with PHP 5.4.
544
+ - `Guzzle\Iterator\MapIterator` is not really needed when using PHP 5.5 because
545
+ it's easier to just wrap an iterator in a generator that maps values.
546
+
547
+ For a replacement of these iterators, see https://github.com/nikic/iter
548
+
549
+ ## Log
550
+
551
+ The LogPlugin has moved to https://github.com/guzzle/log-subscriber. The
552
+ `Guzzle\Log` namespace has been removed. Guzzle now relies on
553
+ `Psr\Log\LoggerInterface` for all logging. The MessageFormatter class has been
554
+ moved to `GuzzleHttp\Subscriber\Log\Formatter`.
555
+
556
+ ## Parser
557
+
558
+ The `Guzzle\Parser` namespace has been removed. This was previously used to
559
+ make it possible to plug in custom parsers for cookies, messages, URI
560
+ templates, and URLs; however, this level of complexity is not needed in Guzzle
561
+ so it has been removed.
562
+
563
+ - Cookie: Cookie parsing logic has been moved to
564
+ `GuzzleHttp\Cookie\SetCookie::fromString`.
565
+ - Message: Message parsing logic for both requests and responses has been moved
566
+ to `GuzzleHttp\Message\MessageFactory::fromMessage`. Message parsing is only
567
+ used in debugging or deserializing messages, so it doesn't make sense for
568
+ Guzzle as a library to add this level of complexity to parsing messages.
569
+ - UriTemplate: URI template parsing has been moved to
570
+ `GuzzleHttp\UriTemplate`. The Guzzle library will automatically use the PECL
571
+ URI template library if it is installed.
572
+ - Url: URL parsing is now performed in `GuzzleHttp\Url::fromString` (previously
573
+ it was `Guzzle\Http\Url::factory()`). If custom URL parsing is necessary,
574
+ then developers are free to subclass `GuzzleHttp\Url`.
575
+
576
+ ## Plugin
577
+
578
+ The `Guzzle\Plugin` namespace has been renamed to `GuzzleHttp\Subscriber`.
579
+ Several plugins are shipping with the core Guzzle library under this namespace.
580
+
581
+ - `GuzzleHttp\Subscriber\Cookie`: Replaces the old CookiePlugin. Cookie jar
582
+ code has moved to `GuzzleHttp\Cookie`.
583
+ - `GuzzleHttp\Subscriber\History`: Replaces the old HistoryPlugin.
584
+ - `GuzzleHttp\Subscriber\HttpError`: Throws errors when a bad HTTP response is
585
+ received.
586
+ - `GuzzleHttp\Subscriber\Mock`: Replaces the old MockPlugin.
587
+ - `GuzzleHttp\Subscriber\Prepare`: Prepares the body of a request just before
588
+ sending. This subscriber is attached to all requests by default.
589
+ - `GuzzleHttp\Subscriber\Redirect`: Replaces the RedirectPlugin.
590
+
591
+ The following plugins have been removed (third-parties are free to re-implement
592
+ these if needed):
593
+
594
+ - `GuzzleHttp\Plugin\Async` has been removed.
595
+ - `GuzzleHttp\Plugin\CurlAuth` has been removed.
596
+ - `GuzzleHttp\Plugin\ErrorResponse\ErrorResponsePlugin` has been removed. This
597
+ functionality should instead be implemented with event listeners that occur
598
+ after normal response parsing occurs in the guzzle/command package.
599
+
600
+ The following plugins are not part of the core Guzzle package, but are provided
601
+ in separate repositories:
602
+
603
+ - `Guzzle\Http\Plugin\BackoffPlugin` has been rewritten to be much simpler
604
+ to build custom retry policies using simple functions rather than various
605
+ chained classes. See: https://github.com/guzzle/retry-subscriber
606
+ - `Guzzle\Http\Plugin\Cache\CachePlugin` has moved to
607
+ https://github.com/guzzle/cache-subscriber
608
+ - `Guzzle\Http\Plugin\Log\LogPlugin` has moved to
609
+ https://github.com/guzzle/log-subscriber
610
+ - `Guzzle\Http\Plugin\Md5\Md5Plugin` has moved to
611
+ https://github.com/guzzle/message-integrity-subscriber
612
+ - `Guzzle\Http\Plugin\Mock\MockPlugin` has moved to
613
+ `GuzzleHttp\Subscriber\MockSubscriber`.
614
+ - `Guzzle\Http\Plugin\Oauth\OauthPlugin` has moved to
615
+ https://github.com/guzzle/oauth-subscriber
616
+
617
+ ## Service
618
+
619
+ The service description layer of Guzzle has moved into two separate packages:
620
+
621
+ - http://github.com/guzzle/command Provides a high level abstraction over web
622
+ services by representing web service operations using commands.
623
+ - http://github.com/guzzle/guzzle-services Provides an implementation of
624
+ guzzle/command that provides request serialization and response parsing using
625
+ Guzzle service descriptions.
626
+
627
+ ## Stream
628
+
629
+ Stream have moved to a separate package available at
630
+ https://github.com/guzzle/streams.
631
+
632
+ `Guzzle\Stream\StreamInterface` has been given a large update to cleanly take
633
+ on the responsibilities of `Guzzle\Http\EntityBody` and
634
+ `Guzzle\Http\EntityBodyInterface` now that they have been removed. The number
635
+ of methods implemented by the `StreamInterface` has been drastically reduced to
636
+ allow developers to more easily extend and decorate stream behavior.
637
+
638
+ ## Removed methods from StreamInterface
639
+
640
+ - `getStream` and `setStream` have been removed to better encapsulate streams.
641
+ - `getMetadata` and `setMetadata` have been removed in favor of
642
+ `GuzzleHttp\Stream\MetadataStreamInterface`.
643
+ - `getWrapper`, `getWrapperData`, `getStreamType`, and `getUri` have all been
644
+ removed. This data is accessible when
645
+ using streams that implement `GuzzleHttp\Stream\MetadataStreamInterface`.
646
+ - `rewind` has been removed. Use `seek(0)` for a similar behavior.
647
+
648
+ ## Renamed methods
649
+
650
+ - `detachStream` has been renamed to `detach`.
651
+ - `feof` has been renamed to `eof`.
652
+ - `ftell` has been renamed to `tell`.
653
+ - `readLine` has moved from an instance method to a static class method of
654
+ `GuzzleHttp\Stream\Stream`.
655
+
656
+ ## Metadata streams
657
+
658
+ `GuzzleHttp\Stream\MetadataStreamInterface` has been added to denote streams
659
+ that contain additional metadata accessible via `getMetadata()`.
660
+ `GuzzleHttp\Stream\StreamInterface::getMetadata` and
661
+ `GuzzleHttp\Stream\StreamInterface::setMetadata` have been removed.
662
+
663
+ ## StreamRequestFactory
664
+
665
+ The entire concept of the StreamRequestFactory has been removed. The way this
666
+ was used in Guzzle 3 broke the actual interface of sending streaming requests
667
+ (instead of getting back a Response, you got a StreamInterface). Streaming
668
+ PHP requests are now implemented through the `GuzzleHttp\Adapter\StreamAdapter`.
669
+
670
+ 3.6 to 3.7
671
+ ----------
672
+
673
+ ### Deprecations
674
+
675
+ - You can now enable E_USER_DEPRECATED warnings to see if you are using any deprecated methods.:
676
+
677
+ ```php
678
+ \Guzzle\Common\Version::$emitWarnings = true;
679
+ ```
680
+
681
+ The following APIs and options have been marked as deprecated:
682
+
683
+ - Marked `Guzzle\Http\Message\Request::isResponseBodyRepeatable()` as deprecated. Use `$request->getResponseBody()->isRepeatable()` instead.
684
+ - Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead.
685
+ - Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead.
686
+ - Marked `Guzzle\Http\Message\Request::setIsRedirect()` as deprecated. Use the HistoryPlugin instead.
687
+ - Marked `Guzzle\Http\Message\Request::isRedirect()` as deprecated. Use the HistoryPlugin instead.
688
+ - Marked `Guzzle\Cache\CacheAdapterFactory::factory()` as deprecated
689
+ - Marked `Guzzle\Service\Client::enableMagicMethods()` as deprecated. Magic methods can no longer be disabled on a Guzzle\Service\Client.
690
+ - Marked `Guzzle\Parser\Url\UrlParser` as deprecated. Just use PHP's `parse_url()` and percent encode your UTF-8.
691
+ - Marked `Guzzle\Common\Collection::inject()` as deprecated.
692
+ - Marked `Guzzle\Plugin\CurlAuth\CurlAuthPlugin` as deprecated. Use
693
+ `$client->getConfig()->setPath('request.options/auth', array('user', 'pass', 'Basic|Digest|NTLM|Any'));` or
694
+ `$client->setDefaultOption('auth', array('user', 'pass', 'Basic|Digest|NTLM|Any'));`
695
+
696
+ 3.7 introduces `request.options` as a parameter for a client configuration and as an optional argument to all creational
697
+ request methods. When paired with a client's configuration settings, these options allow you to specify default settings
698
+ for various aspects of a request. Because these options make other previous configuration options redundant, several
699
+ configuration options and methods of a client and AbstractCommand have been deprecated.
700
+
701
+ - Marked `Guzzle\Service\Client::getDefaultHeaders()` as deprecated. Use `$client->getDefaultOption('headers')`.
702
+ - Marked `Guzzle\Service\Client::setDefaultHeaders()` as deprecated. Use `$client->setDefaultOption('headers/{header_name}', 'value')`.
703
+ - Marked 'request.params' for `Guzzle\Http\Client` as deprecated. Use `$client->setDefaultOption('params/{param_name}', 'value')`
704
+ - Marked 'command.headers', 'command.response_body' and 'command.on_complete' as deprecated for AbstractCommand. These will work through Guzzle 4.0
705
+
706
+ $command = $client->getCommand('foo', array(
707
+ 'command.headers' => array('Test' => '123'),
708
+ 'command.response_body' => '/path/to/file'
709
+ ));
710
+
711
+ // Should be changed to:
712
+
713
+ $command = $client->getCommand('foo', array(
714
+ 'command.request_options' => array(
715
+ 'headers' => array('Test' => '123'),
716
+ 'save_as' => '/path/to/file'
717
+ )
718
+ ));
719
+
720
+ ### Interface changes
721
+
722
+ Additions and changes (you will need to update any implementations or subclasses you may have created):
723
+
724
+ - Added an `$options` argument to the end of the following methods of `Guzzle\Http\ClientInterface`:
725
+ createRequest, head, delete, put, patch, post, options, prepareRequest
726
+ - Added an `$options` argument to the end of `Guzzle\Http\Message\Request\RequestFactoryInterface::createRequest()`
727
+ - Added an `applyOptions()` method to `Guzzle\Http\Message\Request\RequestFactoryInterface`
728
+ - Changed `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $body = null)` to
729
+ `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $options = array())`. You can still pass in a
730
+ resource, string, or EntityBody into the $options parameter to specify the download location of the response.
731
+ - Changed `Guzzle\Common\Collection::__construct($data)` to no longer accepts a null value for `$data` but a
732
+ default `array()`
733
+ - Added `Guzzle\Stream\StreamInterface::isRepeatable`
734
+ - Made `Guzzle\Http\Client::expandTemplate` and `getUriTemplate` protected methods.
735
+
736
+ The following methods were removed from interfaces. All of these methods are still available in the concrete classes
737
+ that implement them, but you should update your code to use alternative methods:
738
+
739
+ - Removed `Guzzle\Http\ClientInterface::setDefaultHeaders(). Use
740
+ `$client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`. or
741
+ `$client->getConfig()->setPath('request.options/headers', array('header_name' => 'value'))` or
742
+ `$client->setDefaultOption('headers/{header_name}', 'value')`. or
743
+ `$client->setDefaultOption('headers', array('header_name' => 'value'))`.
744
+ - Removed `Guzzle\Http\ClientInterface::getDefaultHeaders(). Use `$client->getConfig()->getPath('request.options/headers')`.
745
+ - Removed `Guzzle\Http\ClientInterface::expandTemplate()`. This is an implementation detail.
746
+ - Removed `Guzzle\Http\ClientInterface::setRequestFactory()`. This is an implementation detail.
747
+ - Removed `Guzzle\Http\ClientInterface::getCurlMulti()`. This is a very specific implementation detail.
748
+ - Removed `Guzzle\Http\Message\RequestInterface::canCache`. Use the CachePlugin.
749
+ - Removed `Guzzle\Http\Message\RequestInterface::setIsRedirect`. Use the HistoryPlugin.
750
+ - Removed `Guzzle\Http\Message\RequestInterface::isRedirect`. Use the HistoryPlugin.
751
+
752
+ ### Cache plugin breaking changes
753
+
754
+ - CacheKeyProviderInterface and DefaultCacheKeyProvider are no longer used. All of this logic is handled in a
755
+ CacheStorageInterface. These two objects and interface will be removed in a future version.
756
+ - Always setting X-cache headers on cached responses
757
+ - Default cache TTLs are now handled by the CacheStorageInterface of a CachePlugin
758
+ - `CacheStorageInterface::cache($key, Response $response, $ttl = null)` has changed to `cache(RequestInterface
759
+ $request, Response $response);`
760
+ - `CacheStorageInterface::fetch($key)` has changed to `fetch(RequestInterface $request);`
761
+ - `CacheStorageInterface::delete($key)` has changed to `delete(RequestInterface $request);`
762
+ - Added `CacheStorageInterface::purge($url)`
763
+ - `DefaultRevalidation::__construct(CacheKeyProviderInterface $cacheKey, CacheStorageInterface $cache, CachePlugin
764
+ $plugin)` has changed to `DefaultRevalidation::__construct(CacheStorageInterface $cache,
765
+ CanCacheStrategyInterface $canCache = null)`
766
+ - Added `RevalidationInterface::shouldRevalidate(RequestInterface $request, Response $response)`
767
+
768
+ 3.5 to 3.6
769
+ ----------
770
+
771
+ * Mixed casing of headers are now forced to be a single consistent casing across all values for that header.
772
+ * Messages internally use a HeaderCollection object to delegate handling case-insensitive header resolution
773
+ * Removed the whole changedHeader() function system of messages because all header changes now go through addHeader().
774
+ For example, setHeader() first removes the header using unset on a HeaderCollection and then calls addHeader().
775
+ Keeping the Host header and URL host in sync is now handled by overriding the addHeader method in Request.
776
+ * Specific header implementations can be created for complex headers. When a message creates a header, it uses a
777
+ HeaderFactory which can map specific headers to specific header classes. There is now a Link header and
778
+ CacheControl header implementation.
779
+ * Moved getLinks() from Response to just be used on a Link header object.
780
+
781
+ If you previously relied on Guzzle\Http\Message\Header::raw(), then you will need to update your code to use the
782
+ HeaderInterface (e.g. toArray(), getAll(), etc.).
783
+
784
+ ### Interface changes
785
+
786
+ * Removed from interface: Guzzle\Http\ClientInterface::setUriTemplate
787
+ * Removed from interface: Guzzle\Http\ClientInterface::setCurlMulti()
788
+ * Removed Guzzle\Http\Message\Request::receivedRequestHeader() and implemented this functionality in
789
+ Guzzle\Http\Curl\RequestMediator
790
+ * Removed the optional $asString parameter from MessageInterface::getHeader(). Just cast the header to a string.
791
+ * Removed the optional $tryChunkedTransfer option from Guzzle\Http\Message\EntityEnclosingRequestInterface
792
+ * Removed the $asObjects argument from Guzzle\Http\Message\MessageInterface::getHeaders()
793
+
794
+ ### Removed deprecated functions
795
+
796
+ * Removed Guzzle\Parser\ParserRegister::get(). Use getParser()
797
+ * Removed Guzzle\Parser\ParserRegister::set(). Use registerParser().
798
+
799
+ ### Deprecations
800
+
801
+ * The ability to case-insensitively search for header values
802
+ * Guzzle\Http\Message\Header::hasExactHeader
803
+ * Guzzle\Http\Message\Header::raw. Use getAll()
804
+ * Deprecated cache control specific methods on Guzzle\Http\Message\AbstractMessage. Use the CacheControl header object
805
+ instead.
806
+
807
+ ### Other changes
808
+
809
+ * All response header helper functions return a string rather than mixing Header objects and strings inconsistently
810
+ * Removed cURL blacklist support. This is no longer necessary now that Expect, Accept, etc. are managed by Guzzle
811
+ directly via interfaces
812
+ * Removed the injecting of a request object onto a response object. The methods to get and set a request still exist
813
+ but are a no-op until removed.
814
+ * Most classes that used to require a `Guzzle\Service\Command\CommandInterface` typehint now request a
815
+ `Guzzle\Service\Command\ArrayCommandInterface`.
816
+ * Added `Guzzle\Http\Message\RequestInterface::startResponse()` to the RequestInterface to handle injecting a response
817
+ on a request while the request is still being transferred
818
+ * `Guzzle\Service\Command\CommandInterface` now extends from ToArrayInterface and ArrayAccess
819
+
820
+ 3.3 to 3.4
821
+ ----------
822
+
823
+ Base URLs of a client now follow the rules of http://tools.ietf.org/html/rfc3986#section-5.2.2 when merging URLs.
824
+
825
+ 3.2 to 3.3
826
+ ----------
827
+
828
+ ### Response::getEtag() quote stripping removed
829
+
830
+ `Guzzle\Http\Message\Response::getEtag()` no longer strips quotes around the ETag response header
831
+
832
+ ### Removed `Guzzle\Http\Utils`
833
+
834
+ The `Guzzle\Http\Utils` class was removed. This class was only used for testing.
835
+
836
+ ### Stream wrapper and type
837
+
838
+ `Guzzle\Stream\Stream::getWrapper()` and `Guzzle\Stream\Stream::getStreamType()` are no longer converted to lowercase.
839
+
840
+ ### curl.emit_io became emit_io
841
+
842
+ Emitting IO events from a RequestMediator is now a parameter that must be set in a request's curl options using the
843
+ 'emit_io' key. This was previously set under a request's parameters using 'curl.emit_io'
844
+
845
+ 3.1 to 3.2
846
+ ----------
847
+
848
+ ### CurlMulti is no longer reused globally
849
+
850
+ Before 3.2, the same CurlMulti object was reused globally for each client. This can cause issue where plugins added
851
+ to a single client can pollute requests dispatched from other clients.
852
+
853
+ If you still wish to reuse the same CurlMulti object with each client, then you can add a listener to the
854
+ ServiceBuilder's `service_builder.create_client` event to inject a custom CurlMulti object into each client as it is
855
+ created.
856
+
857
+ ```php
858
+ $multi = new Guzzle\Http\Curl\CurlMulti();
859
+ $builder = Guzzle\Service\Builder\ServiceBuilder::factory('/path/to/config.json');
860
+ $builder->addListener('service_builder.create_client', function ($event) use ($multi) {
861
+ $event['client']->setCurlMulti($multi);
862
+ }
863
+ });
864
+ ```
865
+
866
+ ### No default path
867
+
868
+ URLs no longer have a default path value of '/' if no path was specified.
869
+
870
+ Before:
871
+
872
+ ```php
873
+ $request = $client->get('http://www.foo.com');
874
+ echo $request->getUrl();
875
+ // >> http://www.foo.com/
876
+ ```
877
+
878
+ After:
879
+
880
+ ```php
881
+ $request = $client->get('http://www.foo.com');
882
+ echo $request->getUrl();
883
+ // >> http://www.foo.com
884
+ ```
885
+
886
+ ### Less verbose BadResponseException
887
+
888
+ The exception message for `Guzzle\Http\Exception\BadResponseException` no longer contains the full HTTP request and
889
+ response information. You can, however, get access to the request and response object by calling `getRequest()` or
890
+ `getResponse()` on the exception object.
891
+
892
+ ### Query parameter aggregation
893
+
894
+ Multi-valued query parameters are no longer aggregated using a callback function. `Guzzle\Http\Query` now has a
895
+ setAggregator() method that accepts a `Guzzle\Http\QueryAggregator\QueryAggregatorInterface` object. This object is
896
+ responsible for handling the aggregation of multi-valued query string variables into a flattened hash.
897
+
898
+ 2.8 to 3.x
899
+ ----------
900
+
901
+ ### Guzzle\Service\Inspector
902
+
903
+ Change `\Guzzle\Service\Inspector::fromConfig` to `\Guzzle\Common\Collection::fromConfig`
904
+
905
+ **Before**
906
+
907
+ ```php
908
+ use Guzzle\Service\Inspector;
909
+
910
+ class YourClient extends \Guzzle\Service\Client
911
+ {
912
+ public static function factory($config = array())
913
+ {
914
+ $default = array();
915
+ $required = array('base_url', 'username', 'api_key');
916
+ $config = Inspector::fromConfig($config, $default, $required);
917
+
918
+ $client = new self(
919
+ $config->get('base_url'),
920
+ $config->get('username'),
921
+ $config->get('api_key')
922
+ );
923
+ $client->setConfig($config);
924
+
925
+ $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json'));
926
+
927
+ return $client;
928
+ }
929
+ ```
930
+
931
+ **After**
932
+
933
+ ```php
934
+ use Guzzle\Common\Collection;
935
+
936
+ class YourClient extends \Guzzle\Service\Client
937
+ {
938
+ public static function factory($config = array())
939
+ {
940
+ $default = array();
941
+ $required = array('base_url', 'username', 'api_key');
942
+ $config = Collection::fromConfig($config, $default, $required);
943
+
944
+ $client = new self(
945
+ $config->get('base_url'),
946
+ $config->get('username'),
947
+ $config->get('api_key')
948
+ );
949
+ $client->setConfig($config);
950
+
951
+ $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json'));
952
+
953
+ return $client;
954
+ }
955
+ ```
956
+
957
+ ### Convert XML Service Descriptions to JSON
958
+
959
+ **Before**
960
+
961
+ ```xml
962
+ <?xml version="1.0" encoding="UTF-8"?>
963
+ <client>
964
+ <commands>
965
+ <!-- Groups -->
966
+ <command name="list_groups" method="GET" uri="groups.json">
967
+ <doc>Get a list of groups</doc>
968
+ </command>
969
+ <command name="search_groups" method="GET" uri='search.json?query="{{query}} type:group"'>
970
+ <doc>Uses a search query to get a list of groups</doc>
971
+ <param name="query" type="string" required="true" />
972
+ </command>
973
+ <command name="create_group" method="POST" uri="groups.json">
974
+ <doc>Create a group</doc>
975
+ <param name="data" type="array" location="body" filters="json_encode" doc="Group JSON"/>
976
+ <param name="Content-Type" location="header" static="application/json"/>
977
+ </command>
978
+ <command name="delete_group" method="DELETE" uri="groups/{{id}}.json">
979
+ <doc>Delete a group by ID</doc>
980
+ <param name="id" type="integer" required="true"/>
981
+ </command>
982
+ <command name="get_group" method="GET" uri="groups/{{id}}.json">
983
+ <param name="id" type="integer" required="true"/>
984
+ </command>
985
+ <command name="update_group" method="PUT" uri="groups/{{id}}.json">
986
+ <doc>Update a group</doc>
987
+ <param name="id" type="integer" required="true"/>
988
+ <param name="data" type="array" location="body" filters="json_encode" doc="Group JSON"/>
989
+ <param name="Content-Type" location="header" static="application/json"/>
990
+ </command>
991
+ </commands>
992
+ </client>
993
+ ```
994
+
995
+ **After**
996
+
997
+ ```json
998
+ {
999
+ "name": "Zendesk REST API v2",
1000
+ "apiVersion": "2012-12-31",
1001
+ "description":"Provides access to Zendesk views, groups, tickets, ticket fields, and users",
1002
+ "operations": {
1003
+ "list_groups": {
1004
+ "httpMethod":"GET",
1005
+ "uri": "groups.json",
1006
+ "summary": "Get a list of groups"
1007
+ },
1008
+ "search_groups":{
1009
+ "httpMethod":"GET",
1010
+ "uri": "search.json?query=\"{query} type:group\"",
1011
+ "summary": "Uses a search query to get a list of groups",
1012
+ "parameters":{
1013
+ "query":{
1014
+ "location": "uri",
1015
+ "description":"Zendesk Search Query",
1016
+ "type": "string",
1017
+ "required": true
1018
+ }
1019
+ }
1020
+ },
1021
+ "create_group": {
1022
+ "httpMethod":"POST",
1023
+ "uri": "groups.json",
1024
+ "summary": "Create a group",
1025
+ "parameters":{
1026
+ "data": {
1027
+ "type": "array",
1028
+ "location": "body",
1029
+ "description":"Group JSON",
1030
+ "filters": "json_encode",
1031
+ "required": true
1032
+ },
1033
+ "Content-Type":{
1034
+ "type": "string",
1035
+ "location":"header",
1036
+ "static": "application/json"
1037
+ }
1038
+ }
1039
+ },
1040
+ "delete_group": {
1041
+ "httpMethod":"DELETE",
1042
+ "uri": "groups/{id}.json",
1043
+ "summary": "Delete a group",
1044
+ "parameters":{
1045
+ "id":{
1046
+ "location": "uri",
1047
+ "description":"Group to delete by ID",
1048
+ "type": "integer",
1049
+ "required": true
1050
+ }
1051
+ }
1052
+ },
1053
+ "get_group": {
1054
+ "httpMethod":"GET",
1055
+ "uri": "groups/{id}.json",
1056
+ "summary": "Get a ticket",
1057
+ "parameters":{
1058
+ "id":{
1059
+ "location": "uri",
1060
+ "description":"Group to get by ID",
1061
+ "type": "integer",
1062
+ "required": true
1063
+ }
1064
+ }
1065
+ },
1066
+ "update_group": {
1067
+ "httpMethod":"PUT",
1068
+ "uri": "groups/{id}.json",
1069
+ "summary": "Update a group",
1070
+ "parameters":{
1071
+ "id": {
1072
+ "location": "uri",
1073
+ "description":"Group to update by ID",
1074
+ "type": "integer",
1075
+ "required": true
1076
+ },
1077
+ "data": {
1078
+ "type": "array",
1079
+ "location": "body",
1080
+ "description":"Group JSON",
1081
+ "filters": "json_encode",
1082
+ "required": true
1083
+ },
1084
+ "Content-Type":{
1085
+ "type": "string",
1086
+ "location":"header",
1087
+ "static": "application/json"
1088
+ }
1089
+ }
1090
+ }
1091
+ }
1092
+ ```
1093
+
1094
+ ### Guzzle\Service\Description\ServiceDescription
1095
+
1096
+ Commands are now called Operations
1097
+
1098
+ **Before**
1099
+
1100
+ ```php
1101
+ use Guzzle\Service\Description\ServiceDescription;
1102
+
1103
+ $sd = new ServiceDescription();
1104
+ $sd->getCommands(); // @returns ApiCommandInterface[]
1105
+ $sd->hasCommand($name);
1106
+ $sd->getCommand($name); // @returns ApiCommandInterface|null
1107
+ $sd->addCommand($command); // @param ApiCommandInterface $command
1108
+ ```
1109
+
1110
+ **After**
1111
+
1112
+ ```php
1113
+ use Guzzle\Service\Description\ServiceDescription;
1114
+
1115
+ $sd = new ServiceDescription();
1116
+ $sd->getOperations(); // @returns OperationInterface[]
1117
+ $sd->hasOperation($name);
1118
+ $sd->getOperation($name); // @returns OperationInterface|null
1119
+ $sd->addOperation($operation); // @param OperationInterface $operation
1120
+ ```
1121
+
1122
+ ### Guzzle\Common\Inflection\Inflector
1123
+
1124
+ Namespace is now `Guzzle\Inflection\Inflector`
1125
+
1126
+ ### Guzzle\Http\Plugin
1127
+
1128
+ Namespace is now `Guzzle\Plugin`. Many other changes occur within this namespace and are detailed in their own sections below.
1129
+
1130
+ ### Guzzle\Http\Plugin\LogPlugin and Guzzle\Common\Log
1131
+
1132
+ Now `Guzzle\Plugin\Log\LogPlugin` and `Guzzle\Log` respectively.
1133
+
1134
+ **Before**
1135
+
1136
+ ```php
1137
+ use Guzzle\Common\Log\ClosureLogAdapter;
1138
+ use Guzzle\Http\Plugin\LogPlugin;
1139
+
1140
+ /** @var \Guzzle\Http\Client */
1141
+ $client;
1142
+
1143
+ // $verbosity is an integer indicating desired message verbosity level
1144
+ $client->addSubscriber(new LogPlugin(new ClosureLogAdapter(function($m) { echo $m; }, $verbosity = LogPlugin::LOG_VERBOSE);
1145
+ ```
1146
+
1147
+ **After**
1148
+
1149
+ ```php
1150
+ use Guzzle\Log\ClosureLogAdapter;
1151
+ use Guzzle\Log\MessageFormatter;
1152
+ use Guzzle\Plugin\Log\LogPlugin;
1153
+
1154
+ /** @var \Guzzle\Http\Client */
1155
+ $client;
1156
+
1157
+ // $format is a string indicating desired message format -- @see MessageFormatter
1158
+ $client->addSubscriber(new LogPlugin(new ClosureLogAdapter(function($m) { echo $m; }, $format = MessageFormatter::DEBUG_FORMAT);
1159
+ ```
1160
+
1161
+ ### Guzzle\Http\Plugin\CurlAuthPlugin
1162
+
1163
+ Now `Guzzle\Plugin\CurlAuth\CurlAuthPlugin`.
1164
+
1165
+ ### Guzzle\Http\Plugin\ExponentialBackoffPlugin
1166
+
1167
+ Now `Guzzle\Plugin\Backoff\BackoffPlugin`, and other changes.
1168
+
1169
+ **Before**
1170
+
1171
+ ```php
1172
+ use Guzzle\Http\Plugin\ExponentialBackoffPlugin;
1173
+
1174
+ $backoffPlugin = new ExponentialBackoffPlugin($maxRetries, array_merge(
1175
+ ExponentialBackoffPlugin::getDefaultFailureCodes(), array(429)
1176
+ ));
1177
+
1178
+ $client->addSubscriber($backoffPlugin);
1179
+ ```
1180
+
1181
+ **After**
1182
+
1183
+ ```php
1184
+ use Guzzle\Plugin\Backoff\BackoffPlugin;
1185
+ use Guzzle\Plugin\Backoff\HttpBackoffStrategy;
1186
+
1187
+ // Use convenient factory method instead -- see implementation for ideas of what
1188
+ // you can do with chaining backoff strategies
1189
+ $backoffPlugin = BackoffPlugin::getExponentialBackoff($maxRetries, array_merge(
1190
+ HttpBackoffStrategy::getDefaultFailureCodes(), array(429)
1191
+ ));
1192
+ $client->addSubscriber($backoffPlugin);
1193
+ ```
1194
+
1195
+ ### Known Issues
1196
+
1197
+ #### [BUG] Accept-Encoding header behavior changed unintentionally.
1198
+
1199
+ (See #217) (Fixed in 09daeb8c666fb44499a0646d655a8ae36456575e)
1200
+
1201
+ In version 2.8 setting the `Accept-Encoding` header would set the CURLOPT_ENCODING option, which permitted cURL to
1202
+ properly handle gzip/deflate compressed responses from the server. In versions affected by this bug this does not happen.
1203
+ See issue #217 for a workaround, or use a version containing the fix.
vendor/guzzlehttp/guzzle/composer.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "guzzlehttp/guzzle",
3
+ "type": "library",
4
+ "description": "Guzzle is a PHP HTTP client library",
5
+ "keywords": ["framework", "http", "rest", "web service", "curl", "client", "HTTP client"],
6
+ "homepage": "http://guzzlephp.org/",
7
+ "license": "MIT",
8
+ "authors": [
9
+ {
10
+ "name": "Michael Dowling",
11
+ "email": "mtdowling@gmail.com",
12
+ "homepage": "https://github.com/mtdowling"
13
+ }
14
+ ],
15
+ "require": {
16
+ "php": ">=5.5",
17
+ "guzzlehttp/psr7": "^1.4",
18
+ "guzzlehttp/promises": "^1.0"
19
+ },
20
+ "require-dev": {
21
+ "ext-curl": "*",
22
+ "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
23
+ "psr/log": "^1.0"
24
+ },
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": {
37
+ "psr/log": "Required for using the Log middleware"
38
+ },
39
+ "extra": {
40
+ "branch-alias": {
41
+ "dev-master": "6.3-dev"
42
+ }
43
+ }
44
+ }
vendor/guzzlehttp/guzzle/src/Client.php ADDED
@@ -0,0 +1,422 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 = [])
13
+ * @method ResponseInterface head(string|UriInterface $uri, array $options = [])
14
+ * @method ResponseInterface put(string|UriInterface $uri, array $options = [])
15
+ * @method ResponseInterface post(string|UriInterface $uri, array $options = [])
16
+ * @method ResponseInterface patch(string|UriInterface $uri, array $options = [])
17
+ * @method ResponseInterface delete(string|UriInterface $uri, array $options = [])
18
+ * @method Promise\PromiseInterface getAsync(string|UriInterface $uri, array $options = [])
19
+ * @method Promise\PromiseInterface headAsync(string|UriInterface $uri, array $options = [])
20
+ * @method Promise\PromiseInterface putAsync(string|UriInterface $uri, array $options = [])
21
+ * @method Promise\PromiseInterface postAsync(string|UriInterface $uri, array $options = [])
22
+ * @method Promise\PromiseInterface patchAsync(string|UriInterface $uri, array $options = [])
23
+ * @method Promise\PromiseInterface deleteAsync(string|UriInterface $uri, array $options = [])
24
+ */
25
+ class Client implements ClientInterface
26
+ {
27
+ /** @var array Default request options */
28
+ private $config;
29
+
30
+ /**
31
+ * Clients accept an array of constructor parameters.
32
+ *
33
+ * Here's an example of creating a client using a base_uri and an array of
34
+ * default request options to apply to each request:
35
+ *
36
+ * $client = new Client([
37
+ * 'base_uri' => 'http://www.foo.com/1.0/',
38
+ * 'timeout' => 0,
39
+ * 'allow_redirects' => false,
40
+ * 'proxy' => '192.168.16.1:10'
41
+ * ]);
42
+ *
43
+ * Client configuration settings include the following options:
44
+ *
45
+ * - handler: (callable) Function that transfers HTTP requests over the
46
+ * wire. The function is called with a Psr7\Http\Message\RequestInterface
47
+ * and array of transfer options, and must return a
48
+ * GuzzleHttp\Promise\PromiseInterface that is fulfilled with a
49
+ * Psr7\Http\Message\ResponseInterface on success. "handler" is a
50
+ * constructor only option that cannot be overridden in per/request
51
+ * options. If no handler is provided, a default handler will be created
52
+ * that enables all of the request options below by attaching all of the
53
+ * default middleware to the handler.
54
+ * - base_uri: (string|UriInterface) Base URI of the client that is merged
55
+ * into relative URIs. Can be a string or instance of UriInterface.
56
+ * - **: any request option
57
+ *
58
+ * @param array $config Client configuration settings.
59
+ *
60
+ * @see \GuzzleHttp\RequestOptions for a list of available request options.
61
+ */
62
+ public function __construct(array $config = [])
63
+ {
64
+ if (!isset($config['handler'])) {
65
+ $config['handler'] = HandlerStack::create();
66
+ } elseif (!is_callable($config['handler'])) {
67
+ throw new \InvalidArgumentException('handler must be a callable');
68
+ }
69
+
70
+ // Convert the base_uri to a UriInterface
71
+ if (isset($config['base_uri'])) {
72
+ $config['base_uri'] = Psr7\uri_for($config['base_uri']);
73
+ }
74
+
75
+ $this->configureDefaults($config);
76
+ }
77
+
78
+ public function __call($method, $args)
79
+ {
80
+ if (count($args) < 1) {
81
+ throw new \InvalidArgumentException('Magic request methods require a URI and optional options array');
82
+ }
83
+
84
+ $uri = $args[0];
85
+ $opts = isset($args[1]) ? $args[1] : [];
86
+
87
+ return substr($method, -5) === 'Async'
88
+ ? $this->requestAsync(substr($method, 0, -5), $uri, $opts)
89
+ : $this->request($method, $uri, $opts);
90
+ }
91
+
92
+ public function sendAsync(RequestInterface $request, array $options = [])
93
+ {
94
+ // Merge the base URI into the request URI if needed.
95
+ $options = $this->prepareDefaults($options);
96
+
97
+ return $this->transfer(
98
+ $request->withUri($this->buildUri($request->getUri(), $options), $request->hasHeader('Host')),
99
+ $options
100
+ );
101
+ }
102
+
103
+ public function send(RequestInterface $request, array $options = [])
104
+ {
105
+ $options[RequestOptions::SYNCHRONOUS] = true;
106
+ return $this->sendAsync($request, $options)->wait();
107
+ }
108
+
109
+ public function requestAsync($method, $uri = '', array $options = [])
110
+ {
111
+ $options = $this->prepareDefaults($options);
112
+ // Remove request modifying parameter because it can be done up-front.
113
+ $headers = isset($options['headers']) ? $options['headers'] : [];
114
+ $body = isset($options['body']) ? $options['body'] : null;
115
+ $version = isset($options['version']) ? $options['version'] : '1.1';
116
+ // Merge the URI into the base URI.
117
+ $uri = $this->buildUri($uri, $options);
118
+ if (is_array($body)) {
119
+ $this->invalidBody();
120
+ }
121
+ $request = new Psr7\Request($method, $uri, $headers, $body, $version);
122
+ // Remove the option so that they are not doubly-applied.
123
+ unset($options['headers'], $options['body'], $options['version']);
124
+
125
+ return $this->transfer($request, $options);
126
+ }
127
+
128
+ public function request($method, $uri = '', array $options = [])
129
+ {
130
+ $options[RequestOptions::SYNCHRONOUS] = true;
131
+ return $this->requestAsync($method, $uri, $options)->wait();
132
+ }
133
+
134
+ public function getConfig($option = null)
135
+ {
136
+ return $option === null
137
+ ? $this->config
138
+ : (isset($this->config[$option]) ? $this->config[$option] : null);
139
+ }
140
+
141
+ private function buildUri($uri, array $config)
142
+ {
143
+ // for BC we accept null which would otherwise fail in uri_for
144
+ $uri = Psr7\uri_for($uri === null ? '' : $uri);
145
+
146
+ if (isset($config['base_uri'])) {
147
+ $uri = Psr7\UriResolver::resolve(Psr7\uri_for($config['base_uri']), $uri);
148
+ }
149
+
150
+ return $uri->getScheme() === '' && $uri->getHost() !== '' ? $uri->withScheme('http') : $uri;
151
+ }
152
+
153
+ /**
154
+ * Configures the default options for a client.
155
+ *
156
+ * @param array $config
157
+ */
158
+ private function configureDefaults(array $config)
159
+ {
160
+ $defaults = [
161
+ 'allow_redirects' => RedirectMiddleware::$defaultSettings,
162
+ 'http_errors' => true,
163
+ 'decode_content' => true,
164
+ 'verify' => true,
165
+ 'cookies' => false
166
+ ];
167
+
168
+ // Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set.
169
+
170
+ // We can only trust the HTTP_PROXY environment variable in a CLI
171
+ // process due to the fact that PHP has no reliable mechanism to
172
+ // get environment variables that start with "HTTP_".
173
+ if (php_sapi_name() == 'cli' && getenv('HTTP_PROXY')) {
174
+ $defaults['proxy']['http'] = getenv('HTTP_PROXY');
175
+ }
176
+
177
+ if ($proxy = getenv('HTTPS_PROXY')) {
178
+ $defaults['proxy']['https'] = $proxy;
179
+ }
180
+
181
+ if ($noProxy = getenv('NO_PROXY')) {
182
+ $cleanedNoProxy = str_replace(' ', '', $noProxy);
183
+ $defaults['proxy']['no'] = explode(',', $cleanedNoProxy);
184
+ }
185
+
186
+ $this->config = $config + $defaults;
187
+
188
+ if (!empty($config['cookies']) && $config['cookies'] === true) {
189
+ $this->config['cookies'] = new CookieJar();
190
+ }
191
+
192
+ // Add the default user-agent header.
193
+ if (!isset($this->config['headers'])) {
194
+ $this->config['headers'] = ['User-Agent' => default_user_agent()];
195
+ } else {
196
+ // Add the User-Agent header if one was not already set.
197
+ foreach (array_keys($this->config['headers']) as $name) {
198
+ if (strtolower($name) === 'user-agent') {
199
+ return;
200
+ }
201
+ }
202
+ $this->config['headers']['User-Agent'] = default_user_agent();
203
+ }
204
+ }
205
+
206
+ /**
207
+ * Merges default options into the array.
208
+ *
209
+ * @param array $options Options to modify by reference
210
+ *
211
+ * @return array
212
+ */
213
+ private function prepareDefaults($options)
214
+ {
215
+ $defaults = $this->config;
216
+
217
+ if (!empty($defaults['headers'])) {
218
+ // Default headers are only added if they are not present.
219
+ $defaults['_conditional'] = $defaults['headers'];
220
+ unset($defaults['headers']);
221
+ }
222
+
223
+ // Special handling for headers is required as they are added as
224
+ // conditional headers and as headers passed to a request ctor.
225
+ if (array_key_exists('headers', $options)) {
226
+ // Allows default headers to be unset.
227
+ if ($options['headers'] === null) {
228
+ $defaults['_conditional'] = null;
229
+ unset($options['headers']);
230
+ } elseif (!is_array($options['headers'])) {
231
+ throw new \InvalidArgumentException('headers must be an array');
232
+ }
233
+ }
234
+
235
+ // Shallow merge defaults underneath options.
236
+ $result = $options + $defaults;
237
+
238
+ // Remove null values.
239
+ foreach ($result as $k => $v) {
240
+ if ($v === null) {
241
+ unset($result[$k]);
242
+ }
243
+ }
244
+
245
+ return $result;
246
+ }
247
+
248
+ /**
249
+ * Transfers the given request and applies request options.
250
+ *
251
+ * The URI of the request is not modified and the request options are used
252
+ * as-is without merging in default options.
253
+ *
254
+ * @param RequestInterface $request
255
+ * @param array $options
256
+ *
257
+ * @return Promise\PromiseInterface
258
+ */
259
+ private function transfer(RequestInterface $request, array $options)
260
+ {
261
+ // save_to -> sink
262
+ if (isset($options['save_to'])) {
263
+ $options['sink'] = $options['save_to'];
264
+ unset($options['save_to']);
265
+ }
266
+
267
+ // exceptions -> http_errors
268
+ if (isset($options['exceptions'])) {
269
+ $options['http_errors'] = $options['exceptions'];
270
+ unset($options['exceptions']);
271
+ }
272
+
273
+ $request = $this->applyOptions($request, $options);
274
+ $handler = $options['handler'];
275
+
276
+ try {
277
+ return Promise\promise_for($handler($request, $options));
278
+ } catch (\Exception $e) {
279
+ return Promise\rejection_for($e);
280
+ }
281
+ }
282
+
283
+ /**
284
+ * Applies the array of request options to a request.
285
+ *
286
+ * @param RequestInterface $request
287
+ * @param array $options
288
+ *
289
+ * @return RequestInterface
290
+ */
291
+ private function applyOptions(RequestInterface $request, array &$options)
292
+ {
293
+ $modify = [
294
+ 'set_headers' => [],
295
+ ];
296
+
297
+ if (isset($options['headers'])) {
298
+ $modify['set_headers'] = $options['headers'];
299
+ unset($options['headers']);
300
+ }
301
+
302
+ if (isset($options['form_params'])) {
303
+ if (isset($options['multipart'])) {
304
+ throw new \InvalidArgumentException('You cannot use '
305
+ . 'form_params and multipart at the same time. Use the '
306
+ . 'form_params option if you want to send application/'
307
+ . 'x-www-form-urlencoded requests, and the multipart '
308
+ . 'option to send multipart/form-data requests.');
309
+ }
310
+ $options['body'] = http_build_query($options['form_params'], '', '&');
311
+ unset($options['form_params']);
312
+ // Ensure that we don't have the header in different case and set the new value.
313
+ $options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']);
314
+ $options['_conditional']['Content-Type'] = 'application/x-www-form-urlencoded';
315
+ }
316
+
317
+ if (isset($options['multipart'])) {
318
+ $options['body'] = new Psr7\MultipartStream($options['multipart']);
319
+ unset($options['multipart']);
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']);
327
+ $options['_conditional']['Content-Type'] = 'application/json';
328
+ }
329
+
330
+ if (!empty($options['decode_content'])
331
+ && $options['decode_content'] !== true
332
+ ) {
333
+ // Ensure that we don't have the header in different case and set the new value.
334
+ $options['_conditional'] = Psr7\_caseless_remove(['Accept-Encoding'], $options['_conditional']);
335
+ $modify['set_headers']['Accept-Encoding'] = $options['decode_content'];
336
+ }
337
+
338
+ if (isset($options['body'])) {
339
+ if (is_array($options['body'])) {
340
+ $this->invalidBody();
341
+ }
342
+ $modify['body'] = Psr7\stream_for($options['body']);
343
+ unset($options['body']);
344
+ }
345
+
346
+ if (!empty($options['auth']) && is_array($options['auth'])) {
347
+ $value = $options['auth'];
348
+ $type = isset($value[2]) ? strtolower($value[2]) : 'basic';
349
+ switch ($type) {
350
+ case 'basic':
351
+ // Ensure that we don't have the header in different case and set the new value.
352
+ $modify['set_headers'] = Psr7\_caseless_remove(['Authorization'], $modify['set_headers']);
353
+ $modify['set_headers']['Authorization'] = 'Basic '
354
+ . base64_encode("$value[0]:$value[1]");
355
+ break;
356
+ case 'digest':
357
+ // @todo: Do not rely on curl
358
+ $options['curl'][CURLOPT_HTTPAUTH] = CURLAUTH_DIGEST;
359
+ $options['curl'][CURLOPT_USERPWD] = "$value[0]:$value[1]";
360
+ break;
361
+ case 'ntlm':
362
+ $options['curl'][CURLOPT_HTTPAUTH] = CURLAUTH_NTLM;
363
+ $options['curl'][CURLOPT_USERPWD] = "$value[0]:$value[1]";
364
+ break;
365
+ }
366
+ }
367
+
368
+ if (isset($options['query'])) {
369
+ $value = $options['query'];
370
+ if (is_array($value)) {
371
+ $value = http_build_query($value, null, '&', PHP_QUERY_RFC3986);
372
+ }
373
+ if (!is_string($value)) {
374
+ throw new \InvalidArgumentException('query must be a string or array');
375
+ }
376
+ $modify['query'] = $value;
377
+ unset($options['query']);
378
+ }
379
+
380
+ // Ensure that sink is not an invalid value.
381
+ if (isset($options['sink'])) {
382
+ // TODO: Add more sink validation?
383
+ if (is_bool($options['sink'])) {
384
+ throw new \InvalidArgumentException('sink must not be a boolean');
385
+ }
386
+ }
387
+
388
+ $request = Psr7\modify_request($request, $modify);
389
+ if ($request->getBody() instanceof Psr7\MultipartStream) {
390
+ // Use a multipart/form-data POST if a Content-Type is not set.
391
+ // Ensure that we don't have the header in different case and set the new value.
392
+ $options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']);
393
+ $options['_conditional']['Content-Type'] = 'multipart/form-data; boundary='
394
+ . $request->getBody()->getBoundary();
395
+ }
396
+
397
+ // Merge in conditional headers if they are not present.
398
+ if (isset($options['_conditional'])) {
399
+ // Build up the changes so it's in a single clone of the message.
400
+ $modify = [];
401
+ foreach ($options['_conditional'] as $k => $v) {
402
+ if (!$request->hasHeader($k)) {
403
+ $modify['set_headers'][$k] = $v;
404
+ }
405
+ }
406
+ $request = Psr7\modify_request($request, $modify);
407
+ // Don't pass this internal value along to middleware/handlers.
408
+ unset($options['_conditional']);
409
+ }
410
+
411
+ return $request;
412
+ }
413
+
414
+ private function invalidBody()
415
+ {
416
+ throw new \InvalidArgumentException('Passing in the "body" request '
417
+ . 'option as an array to send a POST request has been deprecated. '
418
+ . 'Please use the "form_params" request option to send a '
419
+ . 'application/x-www-form-urlencoded request, or the "multipart" '
420
+ . 'request option to send a multipart/form-data request.');
421
+ }
422
+ }
vendor/guzzlehttp/guzzle/src/ClientInterface.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.
12
+ */
13
+ interface ClientInterface
14
+ {
15
+ const VERSION = '6.3.3';
16
+
17
+ /**
18
+ * Send an HTTP request.
19
+ *
20
+ * @param RequestInterface $request Request to send
21
+ * @param array $options Request options to apply to the given
22
+ * request and to the transfer.
23
+ *
24
+ * @return ResponseInterface
25
+ * @throws GuzzleException
26
+ */
27
+ public function send(RequestInterface $request, array $options = []);
28
+
29
+ /**
30
+ * Asynchronously send an HTTP request.
31
+ *
32
+ * @param RequestInterface $request Request to send
33
+ * @param array $options Request options to apply to the given
34
+ * request and to the transfer.
35
+ *
36
+ * @return PromiseInterface
37
+ */
38
+ public function sendAsync(RequestInterface $request, array $options = []);
39
+
40
+ /**
41
+ * Create and send an HTTP request.
42
+ *
43
+ * Use an absolute path to override the base path of the client, or a
44
+ * relative path to append to the base path of the client. The URL can
45
+ * contain the query string as well.
46
+ *
47
+ * @param string $method HTTP method.
48
+ * @param string|UriInterface $uri URI object or string.
49
+ * @param array $options Request options to apply.
50
+ *
51
+ * @return ResponseInterface
52
+ * @throws GuzzleException
53
+ */
54
+ public function request($method, $uri, array $options = []);
55
+
56
+ /**
57
+ * Create and send an asynchronous HTTP request.
58
+ *
59
+ * Use an absolute path to override the base path of the client, or a
60
+ * relative path to append to the base path of the client. The URL can
61
+ * contain the query string as well. Use an array to provide a URL
62
+ * template and additional variables to use in the URL template expansion.
63
+ *
64
+ * @param string $method HTTP method
65
+ * @param string|UriInterface $uri URI object or string.
66
+ * @param array $options Request options to apply.
67
+ *
68
+ * @return PromiseInterface
69
+ */
70
+ public function requestAsync($method, $uri, array $options = []);
71
+
72
+ /**
73
+ * Get a client configuration option.
74
+ *
75
+ * These options include default request options of the client, a "handler"
76
+ * (if utilized by the concrete client), and a "base_uri" if utilized by
77
+ * the concrete client.
78
+ *
79
+ * @param string|null $option The config option to retrieve.
80
+ *
81
+ * @return mixed
82
+ */
83
+ public function getConfig($option = null);
84
+ }
vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php ADDED
@@ -0,0 +1,314 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
9
+ */
10
+ class CookieJar implements CookieJarInterface
11
+ {
12
+ /** @var SetCookie[] Loaded cookie data */
13
+ private $cookies = [];
14
+
15
+ /** @var bool */
16
+ private $strictMode;
17
+
18
+ /**
19
+ * @param bool $strictMode Set to true to throw exceptions when invalid
20
+ * cookies are added to the cookie jar.
21
+ * @param array $cookieArray Array of SetCookie objects or a hash of
22
+ * arrays that can be used with the SetCookie
23
+ * constructor
24
+ */
25
+ public function __construct($strictMode = false, $cookieArray = [])
26
+ {
27
+ $this->strictMode = $strictMode;
28
+
29
+ foreach ($cookieArray as $cookie) {
30
+ if (!($cookie instanceof SetCookie)) {
31
+ $cookie = new SetCookie($cookie);
32
+ }
33
+ $this->setCookie($cookie);
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Create a new Cookie jar from an associative array and domain.
39
+ *
40
+ * @param array $cookies Cookies to create the jar from
41
+ * @param string $domain Domain to set the cookies to
42
+ *
43
+ * @return self
44
+ */
45
+ public static function fromArray(array $cookies, $domain)
46
+ {
47
+ $cookieJar = new self();
48
+ foreach ($cookies as $name => $value) {
49
+ $cookieJar->setCookie(new SetCookie([
50
+ 'Domain' => $domain,
51
+ 'Name' => $name,
52
+ 'Value' => $value,
53
+ 'Discard' => true
54
+ ]));
55
+ }
56
+
57
+ return $cookieJar;
58
+ }
59
+
60
+ /**
61
+ * @deprecated
62
+ */
63
+ public static function getCookieValue($value)
64
+ {
65
+ return $value;
66
+ }
67
+
68
+ /**
69
+ * Evaluate if this cookie should be persisted to storage
70
+ * that survives between requests.
71
+ *
72
+ * @param SetCookie $cookie Being evaluated.
73
+ * @param bool $allowSessionCookies If we should persist session cookies
74
+ * @return bool
75
+ */
76
+ public static function shouldPersist(
77
+ SetCookie $cookie,
78
+ $allowSessionCookies = false
79
+ ) {
80
+ if ($cookie->getExpires() || $allowSessionCookies) {
81
+ if (!$cookie->getDiscard()) {
82
+ return true;
83
+ }
84
+ }
85
+
86
+ return false;
87
+ }
88
+
89
+ /**
90
+ * Finds and returns the cookie based on the name
91
+ *
92
+ * @param string $name cookie name to search for
93
+ * @return SetCookie|null cookie that was found or null if not found
94
+ */
95
+ public function getCookieByName($name)
96
+ {
97
+ // don't allow a null name
98
+ if ($name === null) {
99
+ return null;
100
+ }
101
+ foreach ($this->cookies as $cookie) {
102
+ if ($cookie->getName() !== null && strcasecmp($cookie->getName(), $name) === 0) {
103
+ return $cookie;
104
+ }
105
+ }
106
+ }
107
+
108
+ public function toArray()
109
+ {
110
+ return array_map(function (SetCookie $cookie) {
111
+ return $cookie->toArray();
112
+ }, $this->getIterator()->getArrayCopy());
113
+ }
114
+
115
+ public function clear($domain = null, $path = null, $name = null)
116
+ {
117
+ if (!$domain) {
118
+ $this->cookies = [];
119
+ return;
120
+ } elseif (!$path) {
121
+ $this->cookies = array_filter(
122
+ $this->cookies,
123
+ function (SetCookie $cookie) use ($path, $domain) {
124
+ return !$cookie->matchesDomain($domain);
125
+ }
126
+ );
127
+ } elseif (!$name) {
128
+ $this->cookies = array_filter(
129
+ $this->cookies,
130
+ function (SetCookie $cookie) use ($path, $domain) {
131
+ return !($cookie->matchesPath($path) &&
132
+ $cookie->matchesDomain($domain));
133
+ }
134
+ );
135
+ } else {
136
+ $this->cookies = array_filter(
137
+ $this->cookies,
138
+ function (SetCookie $cookie) use ($path, $domain, $name) {
139
+ return !($cookie->getName() == $name &&
140
+ $cookie->matchesPath($path) &&
141
+ $cookie->matchesDomain($domain));
142
+ }
143
+ );
144
+ }
145
+ }
146
+
147
+ public function clearSessionCookies()
148
+ {
149
+ $this->cookies = array_filter(
150
+ $this->cookies,
151
+ function (SetCookie $cookie) {
152
+ return !$cookie->getDiscard() && $cookie->getExpires();
153
+ }
154
+ );
155
+ }
156
+
157
+ public function setCookie(SetCookie $cookie)
158
+ {
159
+ // If the name string is empty (but not 0), ignore the set-cookie
160
+ // string entirely.
161
+ $name = $cookie->getName();
162
+ if (!$name && $name !== '0') {
163
+ return false;
164
+ }
165
+
166
+ // Only allow cookies with set and valid domain, name, value
167
+ $result = $cookie->validate();
168
+ if ($result !== true) {
169
+ if ($this->strictMode) {
170
+ throw new \RuntimeException('Invalid cookie: ' . $result);
171
+ } else {
172
+ $this->removeCookieIfEmpty($cookie);
173
+ return false;
174
+ }
175
+ }
176
+
177
+ // Resolve conflicts with previously set cookies
178
+ foreach ($this->cookies as $i => $c) {
179
+
180
+ // Two cookies are identical, when their path, and domain are
181
+ // identical.
182
+ if ($c->getPath() != $cookie->getPath() ||
183
+ $c->getDomain() != $cookie->getDomain() ||
184
+ $c->getName() != $cookie->getName()
185
+ ) {
186
+ continue;
187
+ }
188
+
189
+ // The previously set cookie is a discard cookie and this one is
190
+ // not so allow the new cookie to be set
191
+ if (!$cookie->getDiscard() && $c->getDiscard()) {
192
+ unset($this->cookies[$i]);
193
+ continue;
194
+ }
195
+
196
+ // If the new cookie's expiration is further into the future, then
197
+ // replace the old cookie
198
+ if ($cookie->getExpires() > $c->getExpires()) {
199
+ unset($this->cookies[$i]);
200
+ continue;
201
+ }
202
+
203
+ // If the value has changed, we better change it
204
+ if ($cookie->getValue() !== $c->getValue()) {
205
+ unset($this->cookies[$i]);
206
+ continue;
207
+ }
208
+
209
+ // The cookie exists, so no need to continue
210
+ return false;
211
+ }
212
+
213
+ $this->cookies[] = $cookie;
214
+
215
+ return true;
216
+ }
217
+
218
+ public function count()
219
+ {
220
+ return count($this->cookies);
221
+ }
222
+
223
+ public function getIterator()
224
+ {
225
+ return new \ArrayIterator(array_values($this->cookies));
226
+ }
227
+
228
+ public function extractCookies(
229
+ RequestInterface $request,
230
+ ResponseInterface $response
231
+ ) {
232
+ if ($cookieHeader = $response->getHeader('Set-Cookie')) {
233
+ foreach ($cookieHeader as $cookie) {
234
+ $sc = SetCookie::fromString($cookie);
235
+ if (!$sc->getDomain()) {
236
+ $sc->setDomain($request->getUri()->getHost());
237
+ }
238
+ if (0 !== strpos($sc->getPath(), '/')) {
239
+ $sc->setPath($this->getCookiePathFromRequest($request));
240
+ }
241
+ $this->setCookie($sc);
242
+ }
243
+ }
244
+ }
245
+
246
+ /**
247
+ * Computes cookie path following RFC 6265 section 5.1.4
248
+ *
249
+ * @link https://tools.ietf.org/html/rfc6265#section-5.1.4
250
+ *
251
+ * @param RequestInterface $request
252
+ * @return string
253
+ */
254
+ private function getCookiePathFromRequest(RequestInterface $request)
255
+ {
256
+ $uriPath = $request->getUri()->getPath();
257
+ if ('' === $uriPath) {
258
+ return '/';
259
+ }
260
+ if (0 !== strpos($uriPath, '/')) {
261
+ return '/';
262
+ }
263
+ if ('/' === $uriPath) {
264
+ return '/';
265
+ }
266
+ if (0 === $lastSlashPos = strrpos($uriPath, '/')) {
267
+ return '/';
268
+ }
269
+
270
+ return substr($uriPath, 0, $lastSlashPos);
271
+ }
272
+
273
+ public function withCookieHeader(RequestInterface $request)
274
+ {
275
+ $values = [];
276
+ $uri = $request->getUri();
277
+ $scheme = $uri->getScheme();
278
+ $host = $uri->getHost();
279
+ $path = $uri->getPath() ?: '/';
280
+
281
+ foreach ($this->cookies as $cookie) {
282
+ if ($cookie->matchesPath($path) &&
283
+ $cookie->matchesDomain($host) &&
284
+ !$cookie->isExpired() &&
285
+ (!$cookie->getSecure() || $scheme === 'https')
286
+ ) {
287
+ $values[] = $cookie->getName() . '='
288
+ . $cookie->getValue();
289
+ }
290
+ }
291
+
292
+ return $values
293
+ ? $request->withHeader('Cookie', implode('; ', $values))
294
+ : $request;
295
+ }
296
+
297
+ /**
298
+ * If a cookie already exists and the server asks to set it again with a
299
+ * null value, the cookie must be deleted.
300
+ *
301
+ * @param SetCookie $cookie
302
+ */
303
+ private function removeCookieIfEmpty(SetCookie $cookie)
304
+ {
305
+ $cookieValue = $cookie->getValue();
306
+ if ($cookieValue === null || $cookieValue === '') {
307
+ $this->clear(
308
+ $cookie->getDomain(),
309
+ $cookie->getPath(),
310
+ $cookie->getName()
311
+ );
312
+ }
313
+ }
314
+ }
vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.
9
+ *
10
+ * It extracts cookies from HTTP requests, and returns them in HTTP responses.
11
+ * CookieJarInterface instances automatically expire contained cookies when
12
+ * necessary. Subclasses are also responsible for storing and retrieving
13
+ * cookies from a file, database, etc.
14
+ *
15
+ * @link http://docs.python.org/2/library/cookielib.html Inspiration
16
+ */
17
+ interface CookieJarInterface extends \Countable, \IteratorAggregate
18
+ {
19
+ /**
20
+ * Create a request with added cookie headers.
21
+ *
22
+ * If no matching cookies are found in the cookie jar, then no Cookie
23
+ * header is added to the request and the same request is returned.
24
+ *
25
+ * @param RequestInterface $request Request object to modify.
26
+ *
27
+ * @return RequestInterface returns the modified request.
28
+ */
29
+ public function withCookieHeader(RequestInterface $request);
30
+
31
+ /**
32
+ * Extract cookies from an HTTP response and store them in the CookieJar.
33
+ *
34
+ * @param RequestInterface $request Request that was sent
35
+ * @param ResponseInterface $response Response that was received
36
+ */
37
+ public function extractCookies(
38
+ RequestInterface $request,
39
+ ResponseInterface $response
40
+ );
41
+
42
+ /**
43
+ * Sets a cookie in the cookie jar.
44
+ *
45
+ * @param SetCookie $cookie Cookie to set.
46
+ *
47
+ * @return bool Returns true on success or false on failure
48
+ */
49
+ public function setCookie(SetCookie $cookie);
50
+
51
+ /**
52
+ * Remove cookies currently held in the cookie jar.
53
+ *
54
+ * Invoking this method without arguments will empty the whole cookie jar.
55
+ * If given a $domain argument only cookies belonging to that domain will
56
+ * be removed. If given a $domain and $path argument, cookies belonging to
57
+ * the specified path within that domain are removed. If given all three
58
+ * arguments, then the cookie with the specified name, path and domain is
59
+ * removed.
60
+ *
61
+ * @param string $domain Clears cookies matching a domain
62
+ * @param string $path Clears cookies matching a domain and path
63
+ * @param string $name Clears cookies matching a domain, path, and name
64
+ *
65
+ * @return CookieJarInterface
66
+ */
67
+ public function clear($domain = null, $path = null, $name = null);
68
+
69
+ /**
70
+ * Discard all sessions cookies.
71
+ *
72
+ * Removes cookies that don't have an expire field or a have a discard
73
+ * field set to true. To be called when the user agent shuts down according
74
+ * to RFC 2965.
75
+ */
76
+ public function clearSessionCookies();
77
+
78
+ /**
79
+ * Converts the cookie jar to an array.
80
+ *
81
+ * @return array
82
+ */
83
+ public function toArray();
84
+ }
vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ /**
5
+ * Persists non-session cookies using a JSON formatted file
6
+ */
7
+ class FileCookieJar extends CookieJar
8
+ {
9
+ /** @var string filename */
10
+ private $filename;
11
+
12
+ /** @var bool Control whether to persist session cookies or not. */
13
+ private $storeSessionCookies;
14
+
15
+ /**
16
+ * Create a new FileCookieJar object
17
+ *
18
+ * @param string $cookieFile File to store the cookie data
19
+ * @param bool $storeSessionCookies Set to true to store session cookies
20
+ * in the cookie jar.
21
+ *
22
+ * @throws \RuntimeException if the file cannot be found or created
23
+ */
24
+ public function __construct($cookieFile, $storeSessionCookies = false)
25
+ {
26
+ $this->filename = $cookieFile;
27
+ $this->storeSessionCookies = $storeSessionCookies;
28
+
29
+ if (file_exists($cookieFile)) {
30
+ $this->load($cookieFile);
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Saves the file when shutting down
36
+ */
37
+ public function __destruct()
38
+ {
39
+ $this->save($this->filename);
40
+ }
41
+
42
+ /**
43
+ * Saves the cookies to a file.
44
+ *
45
+ * @param string $filename File to save
46
+ * @throws \RuntimeException if the file cannot be found or created
47
+ */
48
+ public function save($filename)
49
+ {
50
+ $json = [];
51
+ foreach ($this as $cookie) {
52
+ /** @var SetCookie $cookie */
53
+ if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) {
54
+ $json[] = $cookie->toArray();
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
+ }
62
+ }
63
+
64
+ /**
65
+ * Load cookies from a JSON formatted file.
66
+ *
67
+ * Old cookies are kept unless overwritten by newly loaded ones.
68
+ *
69
+ * @param string $filename Cookie file to load.
70
+ * @throws \RuntimeException if the file cannot be loaded.
71
+ */
72
+ public function load($filename)
73
+ {
74
+ $json = file_get_contents($filename);
75
+ if (false === $json) {
76
+ throw new \RuntimeException("Unable to load file {$filename}");
77
+ } elseif ($json === '') {
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));
85
+ }
86
+ } elseif (strlen($data)) {
87
+ throw new \RuntimeException("Invalid cookie file: {$filename}");
88
+ }
89
+ }
90
+ }
vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ /**
5
+ * Persists cookies in the client session
6
+ */
7
+ class SessionCookieJar extends CookieJar
8
+ {
9
+ /** @var string session key */
10
+ private $sessionKey;
11
+
12
+ /** @var bool Control whether to persist session cookies or not. */
13
+ private $storeSessionCookies;
14
+
15
+ /**
16
+ * Create a new SessionCookieJar object
17
+ *
18
+ * @param string $sessionKey Session key name to store the cookie
19
+ * data in session
20
+ * @param bool $storeSessionCookies Set to true to store session cookies
21
+ * in the cookie jar.
22
+ */
23
+ public function __construct($sessionKey, $storeSessionCookies = false)
24
+ {
25
+ $this->sessionKey = $sessionKey;
26
+ $this->storeSessionCookies = $storeSessionCookies;
27
+ $this->load();
28
+ }
29
+
30
+ /**
31
+ * Saves cookies to session when shutting down
32
+ */
33
+ public function __destruct()
34
+ {
35
+ $this->save();
36
+ }
37
+
38
+ /**
39
+ * Save cookies to the client session
40
+ */
41
+ public function save()
42
+ {
43
+ $json = [];
44
+ foreach ($this as $cookie) {
45
+ /** @var SetCookie $cookie */
46
+ if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) {
47
+ $json[] = $cookie->toArray();
48
+ }
49
+ }
50
+
51
+ $_SESSION[$this->sessionKey] = json_encode($json);
52
+ }
53
+
54
+ /**
55
+ * Load the contents of the client session into the data array
56
+ */
57
+ protected function load()
58
+ {
59
+ if (!isset($_SESSION[$this->sessionKey])) {
60
+ return;
61
+ }
62
+ $data = json_decode($_SESSION[$this->sessionKey], true);
63
+ if (is_array($data)) {
64
+ foreach ($data as $cookie) {
65
+ $this->setCookie(new SetCookie($cookie));
66
+ }
67
+ } elseif (strlen($data)) {
68
+ throw new \RuntimeException("Invalid cookie data");
69
+ }
70
+ }
71
+ }
vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php ADDED
@@ -0,0 +1,403 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ /**
5
+ * Set-Cookie object
6
+ */
7
+ class SetCookie
8
+ {
9
+ /** @var array */
10
+ private static $defaults = [
11
+ 'Name' => null,
12
+ 'Value' => null,
13
+ 'Domain' => null,
14
+ 'Path' => '/',
15
+ 'Max-Age' => null,
16
+ 'Expires' => null,
17
+ 'Secure' => false,
18
+ 'Discard' => false,
19
+ 'HttpOnly' => false
20
+ ];
21
+
22
+ /** @var array Cookie data */
23
+ private $data;
24
+
25
+ /**
26
+ * Create a new SetCookie object from a string
27
+ *
28
+ * @param string $cookie Set-Cookie header string
29
+ *
30
+ * @return self
31
+ */
32
+ public static function fromString($cookie)
33
+ {
34
+ // Create the default return array
35
+ $data = self::$defaults;
36
+ // Explode the cookie string using a series of semicolons
37
+ $pieces = array_filter(array_map('trim', explode(';', $cookie)));
38
+ // The name of the cookie (first kvp) must exist and include an equal sign.
39
+ if (empty($pieces[0]) || !strpos($pieces[0], '=')) {
40
+ return new self($data);
41
+ }
42
+
43
+ // Add the cookie pieces into the parsed data array
44
+ foreach ($pieces as $part) {
45
+ $cookieParts = explode('=', $part, 2);
46
+ $key = trim($cookieParts[0]);
47
+ $value = isset($cookieParts[1])
48
+ ? trim($cookieParts[1], " \n\r\t\0\x0B")
49
+ : true;
50
+
51
+ // Only check for non-cookies when cookies have been found
52
+ if (empty($data['Name'])) {
53
+ $data['Name'] = $key;
54
+ $data['Value'] = $value;
55
+ } else {
56
+ foreach (array_keys(self::$defaults) as $search) {
57
+ if (!strcasecmp($search, $key)) {
58
+ $data[$search] = $value;
59
+ continue 2;
60
+ }
61
+ }
62
+ $data[$key] = $value;
63
+ }
64
+ }
65
+
66
+ return new self($data);
67
+ }
68
+
69
+ /**
70
+ * @param array $data Array of cookie data provided by a Cookie parser
71
+ */
72
+ public function __construct(array $data = [])
73
+ {
74
+ $this->data = array_replace(self::$defaults, $data);
75
+ // Extract the Expires value and turn it into a UNIX timestamp if needed
76
+ if (!$this->getExpires() && $this->getMaxAge()) {
77
+ // Calculate the Expires date
78
+ $this->setExpires(time() + $this->getMaxAge());
79
+ } elseif ($this->getExpires() && !is_numeric($this->getExpires())) {
80
+ $this->setExpires($this->getExpires());
81
+ }
82
+ }
83
+
84
+ public function __toString()
85
+ {
86
+ $str = $this->data['Name'] . '=' . $this->data['Value'] . '; ';
87
+ foreach ($this->data as $k => $v) {
88
+ if ($k !== 'Name' && $k !== 'Value' && $v !== null && $v !== false) {
89
+ if ($k === 'Expires') {
90
+ $str .= 'Expires=' . gmdate('D, d M Y H:i:s \G\M\T', $v) . '; ';
91
+ } else {
92
+ $str .= ($v === true ? $k : "{$k}={$v}") . '; ';
93
+ }
94
+ }
95
+ }
96
+
97
+ return rtrim($str, '; ');
98
+ }
99
+
100
+ public function toArray()
101
+ {
102
+ return $this->data;
103
+ }
104
+
105
+ /**
106
+ * Get the cookie name
107
+ *
108
+ * @return string
109
+ */
110
+ public function getName()
111
+ {
112
+ return $this->data['Name'];
113
+ }
114
+
115
+ /**
116
+ * Set the cookie name
117
+ *
118
+ * @param string $name Cookie name
119
+ */
120
+ public function setName($name)
121
+ {
122
+ $this->data['Name'] = $name;
123
+ }
124
+
125
+ /**
126
+ * Get the cookie value
127
+ *
128
+ * @return string
129
+ */
130
+ public function getValue()
131
+ {
132
+ return $this->data['Value'];
133
+ }
134
+
135
+ /**
136
+ * Set the cookie value
137
+ *
138
+ * @param string $value Cookie value
139
+ */
140
+ public function setValue($value)
141
+ {
142
+ $this->data['Value'] = $value;
143
+ }
144
+
145
+ /**
146
+ * Get the domain
147
+ *
148
+ * @return string|null
149
+ */
150
+ public function getDomain()
151
+ {
152
+ return $this->data['Domain'];
153
+ }
154
+
155
+ /**
156
+ * Set the domain of the cookie
157
+ *
158
+ * @param string $domain
159
+ */
160
+ public function setDomain($domain)
161
+ {
162
+ $this->data['Domain'] = $domain;
163
+ }
164
+
165
+ /**
166
+ * Get the path
167
+ *
168
+ * @return string
169
+ */
170
+ public function getPath()
171
+ {
172
+ return $this->data['Path'];
173
+ }
174
+
175
+ /**
176
+ * Set the path of the cookie
177
+ *
178
+ * @param string $path Path of the cookie
179
+ */
180
+ public function setPath($path)
181
+ {
182
+ $this->data['Path'] = $path;
183
+ }
184
+
185
+ /**
186
+ * Maximum lifetime of the cookie in seconds
187
+ *
188
+ * @return int|null
189
+ */
190
+ public function getMaxAge()
191
+ {
192
+ return $this->data['Max-Age'];
193
+ }
194
+
195
+ /**
196
+ * Set the max-age of the cookie
197
+ *
198
+ * @param int $maxAge Max age of the cookie in seconds
199
+ */
200
+ public function setMaxAge($maxAge)
201
+ {
202
+ $this->data['Max-Age'] = $maxAge;
203
+ }
204
+
205
+ /**
206
+ * The UNIX timestamp when the cookie Expires
207
+ *
208
+ * @return mixed
209
+ */
210
+ public function getExpires()
211
+ {
212
+ return $this->data['Expires'];
213
+ }
214
+
215
+ /**
216
+ * Set the unix timestamp for which the cookie will expire
217
+ *
218
+ * @param int $timestamp Unix timestamp
219
+ */
220
+ public function setExpires($timestamp)
221
+ {
222
+ $this->data['Expires'] = is_numeric($timestamp)
223
+ ? (int) $timestamp
224
+ : strtotime($timestamp);
225
+ }
226
+
227
+ /**
228
+ * Get whether or not this is a secure cookie
229
+ *
230
+ * @return null|bool
231
+ */
232
+ public function getSecure()
233
+ {
234
+ return $this->data['Secure'];
235
+ }
236
+
237
+ /**
238
+ * Set whether or not the cookie is secure
239
+ *
240
+ * @param bool $secure Set to true or false if secure
241
+ */
242
+ public function setSecure($secure)
243
+ {
244
+ $this->data['Secure'] = $secure;
245
+ }
246
+
247
+ /**
248
+ * Get whether or not this is a session cookie
249
+ *
250
+ * @return null|bool
251
+ */
252
+ public function getDiscard()
253
+ {
254
+ return $this->data['Discard'];
255
+ }
256
+
257
+ /**
258
+ * Set whether or not this is a session cookie
259
+ *
260
+ * @param bool $discard Set to true or false if this is a session cookie
261
+ */
262
+ public function setDiscard($discard)
263
+ {
264
+ $this->data['Discard'] = $discard;
265
+ }
266
+
267
+ /**
268
+ * Get whether or not this is an HTTP only cookie
269
+ *
270
+ * @return bool
271
+ */
272
+ public function getHttpOnly()
273
+ {
274
+ return $this->data['HttpOnly'];
275
+ }
276
+
277
+ /**
278
+ * Set whether or not this is an HTTP only cookie
279
+ *
280
+ * @param bool $httpOnly Set to true or false if this is HTTP only
281
+ */
282
+ public function setHttpOnly($httpOnly)
283
+ {
284
+ $this->data['HttpOnly'] = $httpOnly;
285
+ }
286
+
287
+ /**
288
+ * Check if the cookie matches a path value.
289
+ *
290
+ * A request-path path-matches a given cookie-path if at least one of
291
+ * the following conditions holds:
292
+ *
293
+ * - The cookie-path and the request-path are identical.
294
+ * - The cookie-path is a prefix of the request-path, and the last
295
+ * character of the cookie-path is %x2F ("/").
296
+ * - The cookie-path is a prefix of the request-path, and the first
297
+ * character of the request-path that is not included in the cookie-
298
+ * path is a %x2F ("/") character.
299
+ *
300
+ * @param string $requestPath Path to check against
301
+ *
302
+ * @return bool
303
+ */
304
+ public function matchesPath($requestPath)
305
+ {
306
+ $cookiePath = $this->getPath();
307
+
308
+ // Match on exact matches or when path is the default empty "/"
309
+ if ($cookiePath === '/' || $cookiePath == $requestPath) {
310
+ return true;
311
+ }
312
+
313
+ // Ensure that the cookie-path is a prefix of the request path.
314
+ if (0 !== strpos($requestPath, $cookiePath)) {
315
+ return false;
316
+ }
317
+
318
+ // Match if the last character of the cookie-path is "/"
319
+ if (substr($cookiePath, -1, 1) === '/') {
320
+ return true;
321
+ }
322
+
323
+ // Match if the first character not included in cookie path is "/"
324
+ return substr($requestPath, strlen($cookiePath), 1) === '/';
325
+ }
326
+
327
+ /**
328
+ * Check if the cookie matches a domain value
329
+ *
330
+ * @param string $domain Domain to check against
331
+ *
332
+ * @return bool
333
+ */
334
+ public function matchesDomain($domain)
335
+ {
336
+ // Remove the leading '.' as per spec in RFC 6265.
337
+ // http://tools.ietf.org/html/rfc6265#section-5.2.3
338
+ $cookieDomain = ltrim($this->getDomain(), '.');
339
+
340
+ // Domain not set or exact match.
341
+ if (!$cookieDomain || !strcasecmp($domain, $cookieDomain)) {
342
+ return true;
343
+ }
344
+
345
+ // Matching the subdomain according to RFC 6265.
346
+ // http://tools.ietf.org/html/rfc6265#section-5.1.3
347
+ if (filter_var($domain, FILTER_VALIDATE_IP)) {
348
+ return false;
349
+ }
350
+
351
+ return (bool) preg_match('/\.' . preg_quote($cookieDomain, '/') . '$/', $domain);
352
+ }
353
+
354
+ /**
355
+ * Check if the cookie is expired
356
+ *
357
+ * @return bool
358
+ */
359
+ public function isExpired()
360
+ {
361
+ return $this->getExpires() !== null && time() > $this->getExpires();
362
+ }
363
+
364
+ /**
365
+ * Check if the cookie is valid according to RFC 6265
366
+ *
367
+ * @return bool|string Returns true if valid or an error message if invalid
368
+ */
369
+ public function validate()
370
+ {
371
+ // Names must not be empty, but can be 0
372
+ $name = $this->getName();
373
+ if (empty($name) && !is_numeric($name)) {
374
+ return 'The cookie name must not be empty';
375
+ }
376
+
377
+ // Check if any of the invalid characters are present in the cookie name
378
+ if (preg_match(
379
+ '/[\x00-\x20\x22\x28-\x29\x2c\x2f\x3a-\x40\x5c\x7b\x7d\x7f]/',
380
+ $name
381
+ )) {
382
+ return 'Cookie name must not contain invalid characters: ASCII '
383
+ . 'Control characters (0-31;127), space, tab and the '
384
+ . 'following characters: ()<>@,;:\"/?={}';
385
+ }
386
+
387
+ // Value must not be empty, but can be 0
388
+ $value = $this->getValue();
389
+ if (empty($value) && !is_numeric($value)) {
390
+ return 'The cookie value must not be empty';
391
+ }
392
+
393
+ // Domains must not be empty, but can be 0
394
+ // A "0" is not a valid internet domain, but may be used as server name
395
+ // in a private network.
396
+ $domain = $this->getDomain();
397
+ if (empty($domain) && !is_numeric($domain)) {
398
+ return 'The cookie domain must not be empty';
399
+ }
400
+
401
+ return true;
402
+ }
403
+ }
vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)
9
+ */
10
+ class BadResponseException extends RequestException
11
+ {
12
+ public function __construct(
13
+ $message,
14
+ RequestInterface $request,
15
+ ResponseInterface $response = null,
16
+ \Exception $previous = null,
17
+ array $handlerContext = []
18
+ ) {
19
+ if (null === $response) {
20
+ @trigger_error(
21
+ 'Instantiating the ' . __CLASS__ . ' class without a Response is deprecated since version 6.3 and will be removed in 7.0.',
22
+ E_USER_DEPRECATED
23
+ );
24
+ }
25
+ parent::__construct($message, $request, $response, $previous, $handlerContext);
26
+ }
27
+ }
vendor/guzzlehttp/guzzle/src/Exception/ClientException.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ /**
5
+ * Exception when a client error is encountered (4xx codes)
6
+ */
7
+ class ClientException extends BadResponseException {}
vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ use Psr\Http\Message\RequestInterface;
5
+
6
+ /**
7
+ * Exception thrown when a connection cannot be established.
8
+ *
9
+ * Note that no response is present for a ConnectException
10
+ */
11
+ class ConnectException extends RequestException
12
+ {
13
+ public function __construct(
14
+ $message,
15
+ RequestInterface $request,
16
+ \Exception $previous = null,
17
+ array $handlerContext = []
18
+ ) {
19
+ parent::__construct($message, $request, null, $previous, $handlerContext);
20
+ }
21
+
22
+ /**
23
+ * @return null
24
+ */
25
+ public function getResponse()
26
+ {
27
+ return null;
28
+ }
29
+
30
+ /**
31
+ * @return bool
32
+ */
33
+ public function hasResponse()
34
+ {
35
+ return false;
36
+ }
37
+ }
vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ /**
5
+ * @method string getMessage()
6
+ * @method \Throwable|null getPrevious()
7
+ * @method mixed getCode()
8
+ * @method string getFile()
9
+ * @method int getLine()
10
+ * @method array getTrace()
11
+ * @method string getTraceAsString()
12
+ */
13
+ interface GuzzleException {}
vendor/guzzlehttp/guzzle/src/Exception/RequestException.php ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
11
+ */
12
+ class RequestException extends TransferException
13
+ {
14
+ /** @var RequestInterface */
15
+ private $request;
16
+
17
+ /** @var ResponseInterface */
18
+ private $response;
19
+
20
+ /** @var array */
21
+ private $handlerContext;
22
+
23
+ public function __construct(
24
+ $message,
25
+ RequestInterface $request,
26
+ ResponseInterface $response = null,
27
+ \Exception $previous = null,
28
+ array $handlerContext = []
29
+ ) {
30
+ // Set the code of the exception if the response is set and not future.
31
+ $code = $response && !($response instanceof PromiseInterface)
32
+ ? $response->getStatusCode()
33
+ : 0;
34
+ parent::__construct($message, $code, $previous);
35
+ $this->request = $request;
36
+ $this->response = $response;
37
+ $this->handlerContext = $handlerContext;
38
+ }
39
+
40
+ /**
41
+ * Wrap non-RequestExceptions with a RequestException
42
+ *
43
+ * @param RequestInterface $request
44
+ * @param \Exception $e
45
+ *
46
+ * @return RequestException
47
+ */
48
+ public static function wrapException(RequestInterface $request, \Exception $e)
49
+ {
50
+ return $e instanceof RequestException
51
+ ? $e
52
+ : new RequestException($e->getMessage(), $request, null, $e);
53
+ }
54
+
55
+ /**
56
+ * Factory method to create a new exception with a normalized error message
57
+ *
58
+ * @param RequestInterface $request Request
59
+ * @param ResponseInterface $response Response received
60
+ * @param \Exception $previous Previous exception
61
+ * @param array $ctx Optional handler context.
62
+ *
63
+ * @return self
64
+ */
65
+ public static function create(
66
+ RequestInterface $request,
67
+ ResponseInterface $response = null,
68
+ \Exception $previous = null,
69
+ array $ctx = []
70
+ ) {
71
+ if (!$response) {
72
+ return new self(
73
+ 'Error completing request',
74
+ $request,
75
+ null,
76
+ $previous,
77
+ $ctx
78
+ );
79
+ }
80
+
81
+ $level = (int) floor($response->getStatusCode() / 100);
82
+ if ($level === 4) {
83
+ $label = 'Client error';
84
+ $className = ClientException::class;
85
+ } elseif ($level === 5) {
86
+ $label = 'Server error';
87
+ $className = ServerException::class;
88
+ } else {
89
+ $label = 'Unsuccessful request';
90
+ $className = __CLASS__;
91
+ }
92
+
93
+ $uri = $request->getUri();
94
+ $uri = static::obfuscateUri($uri);
95
+
96
+ // Client Error: `GET /` resulted in a `404 Not Found` response:
97
+ // <html> ... (truncated)
98
+ $message = sprintf(
99
+ '%s: `%s %s` resulted in a `%s %s` response',
100
+ $label,
101
+ $request->getMethod(),
102
+ $uri,
103
+ $response->getStatusCode(),
104
+ $response->getReasonPhrase()
105
+ );
106
+
107
+ $summary = static::getResponseBodySummary($response);
108
+
109
+ if ($summary !== null) {
110
+ $message .= ":\n{$summary}\n";
111
+ }
112
+
113
+ return new $className($message, $request, $response, $previous, $ctx);
114
+ }
115
+
116
+ /**
117
+ * Get a short summary of the response
118
+ *
119
+ * Will return `null` if the response is not printable.
120
+ *
121
+ * @param ResponseInterface $response
122
+ *
123
+ * @return string|null
124
+ */
125
+ public static function getResponseBodySummary(ResponseInterface $response)
126
+ {
127
+ $body = $response->getBody();
128
+
129
+ if (!$body->isSeekable()) {
130
+ return null;
131
+ }
132
+
133
+ $size = $body->getSize();
134
+
135
+ if ($size === 0) {
136
+ return null;
137
+ }
138
+
139
+ $summary = $body->read(120);
140
+ $body->rewind();
141
+
142
+ if ($size > 120) {
143
+ $summary .= ' (truncated...)';
144
+ }
145
+
146
+ // Matches any printable character, including unicode characters:
147
+ // letters, marks, numbers, punctuation, spacing, and separators.
148
+ if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/', $summary)) {
149
+ return null;
150
+ }
151
+
152
+ return $summary;
153
+ }
154
+
155
+ /**
156
+ * Obfuscates URI if there is an username and a password present
157
+ *
158
+ * @param UriInterface $uri
159
+ *
160
+ * @return UriInterface
161
+ */
162
+ private static function obfuscateUri($uri)
163
+ {
164
+ $userInfo = $uri->getUserInfo();
165
+
166
+ if (false !== ($pos = strpos($userInfo, ':'))) {
167
+ return $uri->withUserInfo(substr($userInfo, 0, $pos), '***');
168
+ }
169
+
170
+ return $uri;
171
+ }
172
+
173
+ /**
174
+ * Get the request that caused the exception
175
+ *
176
+ * @return RequestInterface
177
+ */
178
+ public function getRequest()
179
+ {
180
+ return $this->request;
181
+ }
182
+
183
+ /**
184
+ * Get the associated response
185
+ *
186
+ * @return ResponseInterface|null
187
+ */
188
+ public function getResponse()
189
+ {
190
+ return $this->response;
191
+ }
192
+
193
+ /**
194
+ * Check if a response was received
195
+ *
196
+ * @return bool
197
+ */
198
+ public function hasResponse()
199
+ {
200
+ return $this->response !== null;
201
+ }
202
+
203
+ /**
204
+ * Get contextual information about the error from the underlying handler.
205
+ *
206
+ * The contents of this array will vary depending on which handler you are
207
+ * using. It may also be just an empty array. Relying on this data will
208
+ * couple you to a specific handler, but can give more debug information
209
+ * when needed.
210
+ *
211
+ * @return array
212
+ */
213
+ public function getHandlerContext()
214
+ {
215
+ return $this->handlerContext;
216
+ }
217
+ }
vendor/guzzlehttp/guzzle/src/Exception/SeekException.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.
8
+ */
9
+ class SeekException extends \RuntimeException implements GuzzleException
10
+ {
11
+ private $stream;
12
+
13
+ public function __construct(StreamInterface $stream, $pos = 0, $msg = '')
14
+ {
15
+ $this->stream = $stream;
16
+ $msg = $msg ?: 'Could not seek the stream to position ' . $pos;
17
+ parent::__construct($msg);
18
+ }
19
+
20
+ /**
21
+ * @return StreamInterface
22
+ */
23
+ public function getStream()
24
+ {
25
+ return $this->stream;
26
+ }
27
+ }
vendor/guzzlehttp/guzzle/src/Exception/ServerException.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ /**
5
+ * Exception when a server error is encountered (5xx codes)
6
+ */
7
+ class ServerException extends BadResponseException {}
vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ class TooManyRedirectsException extends RequestException {}
vendor/guzzlehttp/guzzle/src/Exception/TransferException.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ class TransferException extends \RuntimeException implements GuzzleException {}
vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php ADDED
@@ -0,0 +1,565 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
14
+ */
15
+ class CurlFactory implements CurlFactoryInterface
16
+ {
17
+ /** @var array */
18
+ private $handles = [];
19
+
20
+ /** @var int Total number of idle handles to keep in cache */
21
+ private $maxHandles;
22
+
23
+ /**
24
+ * @param int $maxHandles Maximum number of idle handles.
25
+ */
26
+ public function __construct($maxHandles)
27
+ {
28
+ $this->maxHandles = $maxHandles;
29
+ }
30
+
31
+ public function create(RequestInterface $request, array $options)
32
+ {
33
+ if (isset($options['curl']['body_as_string'])) {
34
+ $options['_body_as_string'] = $options['curl']['body_as_string'];
35
+ unset($options['curl']['body_as_string']);
36
+ }
37
+
38
+ $easy = new EasyHandle;
39
+ $easy->request = $request;
40
+ $easy->options = $options;
41
+ $conf = $this->getDefaultConf($easy);
42
+ $this->applyMethod($easy, $conf);
43
+ $this->applyHandlerOptions($easy, $conf);
44
+ $this->applyHeaders($easy, $conf);
45
+ unset($conf['_headers']);
46
+
47
+ // Add handler options from the request configuration options
48
+ if (isset($options['curl'])) {
49
+ $conf = array_replace($conf, $options['curl']);
50
+ }
51
+
52
+ $conf[CURLOPT_HEADERFUNCTION] = $this->createHeaderFn($easy);
53
+ $easy->handle = $this->handles
54
+ ? array_pop($this->handles)
55
+ : curl_init();
56
+ curl_setopt_array($easy->handle, $conf);
57
+
58
+ return $easy;
59
+ }
60
+
61
+ public function release(EasyHandle $easy)
62
+ {
63
+ $resource = $easy->handle;
64
+ unset($easy->handle);
65
+
66
+ if (count($this->handles) >= $this->maxHandles) {
67
+ curl_close($resource);
68
+ } else {
69
+ // Remove all callback functions as they can hold onto references
70
+ // and are not cleaned up by curl_reset. Using curl_setopt_array
71
+ // does not work for some reason, so removing each one
72
+ // individually.
73
+ curl_setopt($resource, CURLOPT_HEADERFUNCTION, null);
74
+ curl_setopt($resource, CURLOPT_READFUNCTION, null);
75
+ curl_setopt($resource, CURLOPT_WRITEFUNCTION, null);
76
+ curl_setopt($resource, CURLOPT_PROGRESSFUNCTION, null);
77
+ curl_reset($resource);
78
+ $this->handles[] = $resource;
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Completes a cURL transaction, either returning a response promise or a
84
+ * rejected promise.
85
+ *
86
+ * @param callable $handler
87
+ * @param EasyHandle $easy
88
+ * @param CurlFactoryInterface $factory Dictates how the handle is released
89
+ *
90
+ * @return \GuzzleHttp\Promise\PromiseInterface
91
+ */
92
+ public static function finish(
93
+ callable $handler,
94
+ EasyHandle $easy,
95
+ CurlFactoryInterface $factory
96
+ ) {
97
+ if (isset($easy->options['on_stats'])) {
98
+ self::invokeStats($easy);
99
+ }
100
+
101
+ if (!$easy->response || $easy->errno) {
102
+ return self::finishError($handler, $easy, $factory);
103
+ }
104
+
105
+ // Return the response if it is present and there is no error.
106
+ $factory->release($easy);
107
+
108
+ // Rewind the body of the response if possible.
109
+ $body = $easy->response->getBody();
110
+ if ($body->isSeekable()) {
111
+ $body->rewind();
112
+ }
113
+
114
+ return new FulfilledPromise($easy->response);
115
+ }
116
+
117
+ private static function invokeStats(EasyHandle $easy)
118
+ {
119
+ $curlStats = curl_getinfo($easy->handle);
120
+ $stats = new TransferStats(
121
+ $easy->request,
122
+ $easy->response,
123
+ $curlStats['total_time'],
124
+ $easy->errno,
125
+ $curlStats
126
+ );
127
+ call_user_func($easy->options['on_stats'], $stats);
128
+ }
129
+
130
+ private static function finishError(
131
+ callable $handler,
132
+ EasyHandle $easy,
133
+ CurlFactoryInterface $factory
134
+ ) {
135
+ // Get error information and release the handle to the factory.
136
+ $ctx = [
137
+ 'errno' => $easy->errno,
138
+ 'error' => curl_error($easy->handle),
139
+ ] + curl_getinfo($easy->handle);
140
+ $factory->release($easy);
141
+
142
+ // Retry when nothing is present or when curl failed to rewind.
143
+ if (empty($easy->options['_err_message'])
144
+ && (!$easy->errno || $easy->errno == 65)
145
+ ) {
146
+ return self::retryFailedRewind($handler, $easy, $ctx);
147
+ }
148
+
149
+ return self::createRejection($easy, $ctx);
150
+ }
151
+
152
+ private static function createRejection(EasyHandle $easy, array $ctx)
153
+ {
154
+ static $connectionErrors = [
155
+ CURLE_OPERATION_TIMEOUTED => true,
156
+ CURLE_COULDNT_RESOLVE_HOST => true,
157
+ CURLE_COULDNT_CONNECT => true,
158
+ CURLE_SSL_CONNECT_ERROR => true,
159
+ CURLE_GOT_NOTHING => true,
160
+ ];
161
+
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,
169
+ $easy->response,
170
+ $easy->onHeadersException,
171
+ $ctx
172
+ )
173
+ );
174
+ }
175
+
176
+ $message = sprintf(
177
+ 'cURL error %s: %s (%s)',
178
+ $ctx['errno'],
179
+ $ctx['error'],
180
+ 'see http://curl.haxx.se/libcurl/c/libcurl-errors.html'
181
+ );
182
+
183
+ // Create a connection exception if it was a specific error code.
184
+ $error = isset($connectionErrors[$easy->errno])
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)
192
+ {
193
+ $conf = [
194
+ '_headers' => $easy->request->getHeaders(),
195
+ CURLOPT_CUSTOMREQUEST => $easy->request->getMethod(),
196
+ CURLOPT_URL => (string) $easy->request->getUri()->withFragment(''),
197
+ CURLOPT_RETURNTRANSFER => false,
198
+ CURLOPT_HEADER => false,
199
+ CURLOPT_CONNECTTIMEOUT => 150,
200
+ ];
201
+
202
+ if (defined('CURLOPT_PROTOCOLS')) {
203
+ $conf[CURLOPT_PROTOCOLS] = CURLPROTO_HTTP | CURLPROTO_HTTPS;
204
+ }
205
+
206
+ $version = $easy->request->getProtocolVersion();
207
+ if ($version == 1.1) {
208
+ $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1;
209
+ } elseif ($version == 2.0) {
210
+ $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2_0;
211
+ } else {
212
+ $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0;
213
+ }
214
+
215
+ return $conf;
216
+ }
217
+
218
+ private function applyMethod(EasyHandle $easy, array &$conf)
219
+ {
220
+ $body = $easy->request->getBody();
221
+ $size = $body->getSize();
222
+
223
+ if ($size === null || $size > 0) {
224
+ $this->applyBody($easy->request, $easy->options, $conf);
225
+ return;
226
+ }
227
+
228
+ $method = $easy->request->getMethod();
229
+ if ($method === 'PUT' || $method === 'POST') {
230
+ // See http://tools.ietf.org/html/rfc7230#section-3.3.2
231
+ if (!$easy->request->hasHeader('Content-Length')) {
232
+ $conf[CURLOPT_HTTPHEADER][] = 'Content-Length: 0';
233
+ }
234
+ } elseif ($method === 'HEAD') {
235
+ $conf[CURLOPT_NOBODY] = true;
236
+ unset(
237
+ $conf[CURLOPT_WRITEFUNCTION],
238
+ $conf[CURLOPT_READFUNCTION],
239
+ $conf[CURLOPT_FILE],
240
+ $conf[CURLOPT_INFILE]
241
+ );
242
+ }
243
+ }
244
+
245
+ private function applyBody(RequestInterface $request, array $options, array &$conf)
246
+ {
247
+ $size = $request->hasHeader('Content-Length')
248
+ ? (int) $request->getHeaderLine('Content-Length')
249
+ : null;
250
+
251
+ // Send the body as a string if the size is less than 1MB OR if the
252
+ // [curl][body_as_string] request value is set.
253
+ if (($size !== null && $size < 1000000) ||
254
+ !empty($options['_body_as_string'])
255
+ ) {
256
+ $conf[CURLOPT_POSTFIELDS] = (string) $request->getBody();
257
+ // Don't duplicate the Content-Length header
258
+ $this->removeHeader('Content-Length', $conf);
259
+ $this->removeHeader('Transfer-Encoding', $conf);
260
+ } else {
261
+ $conf[CURLOPT_UPLOAD] = true;
262
+ if ($size !== null) {
263
+ $conf[CURLOPT_INFILESIZE] = $size;
264
+ $this->removeHeader('Content-Length', $conf);
265
+ }
266
+ $body = $request->getBody();
267
+ if ($body->isSeekable()) {
268
+ $body->rewind();
269
+ }
270
+ $conf[CURLOPT_READFUNCTION] = function ($ch, $fd, $length) use ($body) {
271
+ return $body->read($length);
272
+ };
273
+ }
274
+
275
+ // If the Expect header is not present, prevent curl from adding it
276
+ if (!$request->hasHeader('Expect')) {
277
+ $conf[CURLOPT_HTTPHEADER][] = 'Expect:';
278
+ }
279
+
280
+ // cURL sometimes adds a content-type by default. Prevent this.
281
+ if (!$request->hasHeader('Content-Type')) {
282
+ $conf[CURLOPT_HTTPHEADER][] = 'Content-Type:';
283
+ }
284
+ }
285
+
286
+ private function applyHeaders(EasyHandle $easy, array &$conf)
287
+ {
288
+ foreach ($conf['_headers'] as $name => $values) {
289
+ foreach ($values as $value) {
290
+ $value = (string) $value;
291
+ if ($value === '') {
292
+ // cURL requires a special format for empty headers.
293
+ // See https://github.com/guzzle/guzzle/issues/1882 for more details.
294
+ $conf[CURLOPT_HTTPHEADER][] = "$name;";
295
+ } else {
296
+ $conf[CURLOPT_HTTPHEADER][] = "$name: $value";
297
+ }
298
+ }
299
+ }
300
+
301
+ // Remove the Accept header if one was not set
302
+ if (!$easy->request->hasHeader('Accept')) {
303
+ $conf[CURLOPT_HTTPHEADER][] = 'Accept:';
304
+ }
305
+ }
306
+
307
+ /**
308
+ * Remove a header from the options array.
309
+ *
310
+ * @param string $name Case-insensitive header to remove
311
+ * @param array $options Array of options to modify
312
+ */
313
+ private function removeHeader($name, array &$options)
314
+ {
315
+ foreach (array_keys($options['_headers']) as $key) {
316
+ if (!strcasecmp($key, $name)) {
317
+ unset($options['_headers'][$key]);
318
+ return;
319
+ }
320
+ }
321
+ }
322
+
323
+ private function applyHandlerOptions(EasyHandle $easy, array &$conf)
324
+ {
325
+ $options = $easy->options;
326
+ if (isset($options['verify'])) {
327
+ if ($options['verify'] === false) {
328
+ unset($conf[CURLOPT_CAINFO]);
329
+ $conf[CURLOPT_SSL_VERIFYHOST] = 0;
330
+ $conf[CURLOPT_SSL_VERIFYPEER] = false;
331
+ } else {
332
+ $conf[CURLOPT_SSL_VERIFYHOST] = 2;
333
+ $conf[CURLOPT_SSL_VERIFYPEER] = true;
334
+ if (is_string($options['verify'])) {
335
+ // Throw an error if the file/folder/link path is not valid or doesn't exist.
336
+ if (!file_exists($options['verify'])) {
337
+ throw new \InvalidArgumentException(
338
+ "SSL CA bundle not found: {$options['verify']}"
339
+ );
340
+ }
341
+ // If it's a directory or a link to a directory use CURLOPT_CAPATH.
342
+ // If not, it's probably a file, or a link to a file, so use CURLOPT_CAINFO.
343
+ if (is_dir($options['verify']) ||
344
+ (is_link($options['verify']) && is_dir(readlink($options['verify'])))) {
345
+ $conf[CURLOPT_CAPATH] = $options['verify'];
346
+ } else {
347
+ $conf[CURLOPT_CAINFO] = $options['verify'];
348
+ }
349
+ }
350
+ }
351
+ }
352
+
353
+ if (!empty($options['decode_content'])) {
354
+ $accept = $easy->request->getHeaderLine('Accept-Encoding');
355
+ if ($accept) {
356
+ $conf[CURLOPT_ENCODING] = $accept;
357
+ } else {
358
+ $conf[CURLOPT_ENCODING] = '';
359
+ // Don't let curl send the header over the wire
360
+ $conf[CURLOPT_HTTPHEADER][] = 'Accept-Encoding:';
361
+ }
362
+ }
363
+
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(
371
+ 'Directory %s does not exist for sink value of %s',
372
+ dirname($sink),
373
+ $sink
374
+ ));
375
+ } else {
376
+ $sink = new LazyOpenStream($sink, 'w+');
377
+ }
378
+ $easy->sink = $sink;
379
+ $conf[CURLOPT_WRITEFUNCTION] = function ($ch, $write) use ($sink) {
380
+ return $sink->write($write);
381
+ };
382
+ } else {
383
+ // Use a default temp stream if no sink was set.
384
+ $conf[CURLOPT_FILE] = fopen('php://temp', 'w+');
385
+ $easy->sink = Psr7\stream_for($conf[CURLOPT_FILE]);
386
+ }
387
+ $timeoutRequiresNoSignal = false;
388
+ if (isset($options['timeout'])) {
389
+ $timeoutRequiresNoSignal |= $options['timeout'] < 1;
390
+ $conf[CURLOPT_TIMEOUT_MS] = $options['timeout'] * 1000;
391
+ }
392
+
393
+ // CURL default value is CURL_IPRESOLVE_WHATEVER
394
+ if (isset($options['force_ip_resolve'])) {
395
+ if ('v4' === $options['force_ip_resolve']) {
396
+ $conf[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4;
397
+ } elseif ('v6' === $options['force_ip_resolve']) {
398
+ $conf[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V6;
399
+ }
400
+ }
401
+
402
+ if (isset($options['connect_timeout'])) {
403
+ $timeoutRequiresNoSignal |= $options['connect_timeout'] < 1;
404
+ $conf[CURLOPT_CONNECTTIMEOUT_MS] = $options['connect_timeout'] * 1000;
405
+ }
406
+
407
+ if ($timeoutRequiresNoSignal && strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
408
+ $conf[CURLOPT_NOSIGNAL] = true;
409
+ }
410
+
411
+ if (isset($options['proxy'])) {
412
+ if (!is_array($options['proxy'])) {
413
+ $conf[CURLOPT_PROXY] = $options['proxy'];
414
+ } else {
415
+ $scheme = $easy->request->getUri()->getScheme();
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
+ }
423
+ }
424
+ }
425
+ }
426
+
427
+ if (isset($options['cert'])) {
428
+ $cert = $options['cert'];
429
+ if (is_array($cert)) {
430
+ $conf[CURLOPT_SSLCERTPASSWD] = $cert[1];
431
+ $cert = $cert[0];
432
+ }
433
+ if (!file_exists($cert)) {
434
+ throw new \InvalidArgumentException(
435
+ "SSL certificate not found: {$cert}"
436
+ );
437
+ }
438
+ $conf[CURLOPT_SSLCERT] = $cert;
439
+ }
440
+
441
+ if (isset($options['ssl_key'])) {
442
+ $sslKey = $options['ssl_key'];
443
+ if (is_array($sslKey)) {
444
+ $conf[CURLOPT_SSLKEYPASSWD] = $sslKey[1];
445
+ $sslKey = $sslKey[0];
446
+ }
447
+ if (!file_exists($sslKey)) {
448
+ throw new \InvalidArgumentException(
449
+ "SSL private key not found: {$sslKey}"
450
+ );
451
+ }
452
+ $conf[CURLOPT_SSLKEY] = $sslKey;
453
+ }
454
+
455
+ if (isset($options['progress'])) {
456
+ $progress = $options['progress'];
457
+ if (!is_callable($progress)) {
458
+ throw new \InvalidArgumentException(
459
+ 'progress client option must be callable'
460
+ );
461
+ }
462
+ $conf[CURLOPT_NOPROGRESS] = false;
463
+ $conf[CURLOPT_PROGRESSFUNCTION] = function () use ($progress) {
464
+ $args = func_get_args();
465
+ // PHP 5.5 pushed the handle onto the start of the args
466
+ if (is_resource($args[0])) {
467
+ array_shift($args);
468
+ }
469
+ call_user_func_array($progress, $args);
470
+ };
471
+ }
472
+
473
+ if (!empty($options['debug'])) {
474
+ $conf[CURLOPT_STDERR] = \GuzzleHttp\debug_resource($options['debug']);
475
+ $conf[CURLOPT_VERBOSE] = true;
476
+ }
477
+ }
478
+
479
+ /**
480
+ * This function ensures that a response was set on a transaction. If one
481
+ * was not set, then the request is retried if possible. This error
482
+ * typically means you are sending a payload, curl encountered a
483
+ * "Connection died, retrying a fresh connect" error, tried to rewind the
484
+ * stream, and then encountered a "necessary data rewind wasn't possible"
485
+ * error, causing the request to be sent through curl_multi_info_read()
486
+ * without an error status.
487
+ */
488
+ private static function retryFailedRewind(
489
+ callable $handler,
490
+ EasyHandle $easy,
491
+ array $ctx
492
+ ) {
493
+ try {
494
+ // Only rewind if the body has been read from.
495
+ $body = $easy->request->getBody();
496
+ if ($body->tell() > 0) {
497
+ $body->rewind();
498
+ }
499
+ } catch (\RuntimeException $e) {
500
+ $ctx['error'] = 'The connection unexpectedly failed without '
501
+ . 'providing an error. The request would have been retried, '
502
+ . 'but attempting to rewind the request body failed. '
503
+ . 'Exception: ' . $e;
504
+ return self::createRejection($easy, $ctx);
505
+ }
506
+
507
+ // Retry no more than 3 times before giving up.
508
+ if (!isset($easy->options['_curl_retries'])) {
509
+ $easy->options['_curl_retries'] = 1;
510
+ } elseif ($easy->options['_curl_retries'] == 2) {
511
+ $ctx['error'] = 'The cURL request was retried 3 times '
512
+ . 'and did not succeed. The most likely reason for the failure '
513
+ . 'is that cURL was unable to rewind the body of the request '
514
+ . 'and subsequent retries resulted in the same error. Turn on '
515
+ . 'the debug option to see what went wrong. See '
516
+ . 'https://bugs.php.net/bug.php?id=47204 for more information.';
517
+ return self::createRejection($easy, $ctx);
518
+ } else {
519
+ $easy->options['_curl_retries']++;
520
+ }
521
+
522
+ return $handler($easy->request, $easy->options);
523
+ }
524
+
525
+ private function createHeaderFn(EasyHandle $easy)
526
+ {
527
+ if (isset($easy->options['on_headers'])) {
528
+ $onHeaders = $easy->options['on_headers'];
529
+
530
+ if (!is_callable($onHeaders)) {
531
+ throw new \InvalidArgumentException('on_headers must be callable');
532
+ }
533
+ } else {
534
+ $onHeaders = null;
535
+ }
536
+
537
+ return function ($ch, $h) use (
538
+ $onHeaders,
539
+ $easy,
540
+ &$startingResponse
541
+ ) {
542
+ $value = trim($h);
543
+ if ($value === '') {
544
+ $startingResponse = true;
545
+ $easy->createResponse();
546
+ if ($onHeaders !== null) {
547
+ try {
548
+ $onHeaders($easy->response);
549
+ } catch (\Exception $e) {
550
+ // Associate the exception with the handle and trigger
551
+ // a curl header write error by returning 0.
552
+ $easy->onHeadersException = $e;
553
+ return -1;
554
+ }
555
+ }
556
+ } elseif ($startingResponse) {
557
+ $startingResponse = false;
558
+ $easy->headers = [$value];
559
+ } else {
560
+ $easy->headers[] = $value;
561
+ }
562
+ return strlen($h);
563
+ };
564
+ }
565
+ }
vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Handler;
3
+
4
+ use Psr\Http\Message\RequestInterface;
5
+
6
+ interface CurlFactoryInterface
7
+ {
8
+ /**
9
+ * Creates a cURL handle resource.
10
+ *
11
+ * @param RequestInterface $request Request
12
+ * @param array $options Transfer options
13
+ *
14
+ * @return EasyHandle
15
+ * @throws \RuntimeException when an option cannot be applied
16
+ */
17
+ public function create(RequestInterface $request, array $options);
18
+
19
+ /**
20
+ * Release an easy handle, allowing it to be reused or closed.
21
+ *
22
+ * This function must call unset on the easy handle's "handle" property.
23
+ *
24
+ * @param EasyHandle $easy
25
+ */
26
+ public function release(EasyHandle $easy);
27
+ }
vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.
9
+ *
10
+ * When using the CurlHandler, custom curl options can be specified as an
11
+ * associative array of curl option constants mapping to values in the
12
+ * **curl** key of the "client" key of the request.
13
+ */
14
+ class CurlHandler
15
+ {
16
+ /** @var CurlFactoryInterface */
17
+ private $factory;
18
+
19
+ /**
20
+ * Accepts an associative array of options:
21
+ *
22
+ * - factory: Optional curl factory used to create cURL handles.
23
+ *
24
+ * @param array $options Array of options to use with the handler
25
+ */
26
+ public function __construct(array $options = [])
27
+ {
28
+ $this->factory = isset($options['handle_factory'])
29
+ ? $options['handle_factory']
30
+ : new CurlFactory(3);
31
+ }
32
+
33
+ public function __invoke(RequestInterface $request, array $options)
34
+ {
35
+ if (isset($options['delay'])) {
36
+ usleep($options['delay'] * 1000);
37
+ }
38
+
39
+ $easy = $this->factory->create($request, $options);
40
+ curl_exec($easy->handle);
41
+ $easy->errno = curl_errno($easy->handle);
42
+
43
+ return CurlFactory::finish($this, $easy, $this->factory);
44
+ }
45
+ }
vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.
11
+ *
12
+ * When using the CurlMultiHandler, custom curl options can be specified as an
13
+ * associative array of curl option constants mapping to values in the
14
+ * **curl** key of the provided request options.
15
+ *
16
+ * @property resource $_mh Internal use only. Lazy loaded multi-handle.
17
+ */
18
+ class CurlMultiHandler
19
+ {
20
+ /** @var CurlFactoryInterface */
21
+ private $factory;
22
+ private $selectTimeout;
23
+ private $active;
24
+ private $handles = [];
25
+ private $delays = [];
26
+
27
+ /**
28
+ * This handler accepts the following options:
29
+ *
30
+ * - handle_factory: An optional factory used to create curl handles
31
+ * - select_timeout: Optional timeout (in seconds) to block before timing
32
+ * out while selecting curl handles. Defaults to 1 second.
33
+ *
34
+ * @param array $options
35
+ */
36
+ public function __construct(array $options = [])
37
+ {
38
+ $this->factory = isset($options['handle_factory'])
39
+ ? $options['handle_factory'] : new CurlFactory(50);
40
+ $this->selectTimeout = isset($options['select_timeout'])
41
+ ? $options['select_timeout'] : 1;
42
+ }
43
+
44
+ public function __get($name)
45
+ {
46
+ if ($name === '_mh') {
47
+ return $this->_mh = curl_multi_init();
48
+ }
49
+
50
+ throw new \BadMethodCallException();
51
+ }
52
+
53
+ public function __destruct()
54
+ {
55
+ if (isset($this->_mh)) {
56
+ curl_multi_close($this->_mh);
57
+ unset($this->_mh);
58
+ }
59
+ }
60
+
61
+ public function __invoke(RequestInterface $request, array $options)
62
+ {
63
+ $easy = $this->factory->create($request, $options);
64
+ $id = (int) $easy->handle;
65
+
66
+ $promise = new Promise(
67
+ [$this, 'execute'],
68
+ function () use ($id) {
69
+ return $this->cancel($id);
70
+ }
71
+ );
72
+
73
+ $this->addRequest(['easy' => $easy, 'deferred' => $promise]);
74
+
75
+ return $promise;
76
+ }
77
+
78
+ /**
79
+ * Ticks the curl event loop.
80
+ */
81
+ public function tick()
82
+ {
83
+ // Add any delayed handles if needed.
84
+ if ($this->delays) {
85
+ $currentTime = microtime(true);
86
+ foreach ($this->delays as $id => $delay) {
87
+ if ($currentTime >= $delay) {
88
+ unset($this->delays[$id]);
89
+ curl_multi_add_handle(
90
+ $this->_mh,
91
+ $this->handles[$id]['easy']->handle
92
+ );
93
+ }
94
+ }
95
+ }
96
+
97
+ // Step through the task queue which may add additional requests.
98
+ P\queue()->run();
99
+
100
+ if ($this->active &&
101
+ curl_multi_select($this->_mh, $this->selectTimeout) === -1
102
+ ) {
103
+ // Perform a usleep if a select returns -1.
104
+ // See: https://bugs.php.net/bug.php?id=61141
105
+ usleep(250);
106
+ }
107
+
108
+ while (curl_multi_exec($this->_mh, $this->active) === CURLM_CALL_MULTI_PERFORM);
109
+
110
+ $this->processMessages();
111
+ }
112
+
113
+ /**
114
+ * Runs until all outstanding connections have completed.
115
+ */
116
+ public function execute()
117
+ {
118
+ $queue = P\queue();
119
+
120
+ while ($this->handles || !$queue->isEmpty()) {
121
+ // If there are no transfers, then sleep for the next delay
122
+ if (!$this->active && $this->delays) {
123
+ usleep($this->timeToNext());
124
+ }
125
+ $this->tick();
126
+ }
127
+ }
128
+
129
+ private function addRequest(array $entry)
130
+ {
131
+ $easy = $entry['easy'];
132
+ $id = (int) $easy->handle;
133
+ $this->handles[$id] = $entry;
134
+ if (empty($easy->options['delay'])) {
135
+ curl_multi_add_handle($this->_mh, $easy->handle);
136
+ } else {
137
+ $this->delays[$id] = microtime(true) + ($easy->options['delay'] / 1000);
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Cancels a handle from sending and removes references to it.
143
+ *
144
+ * @param int $id Handle ID to cancel and remove.
145
+ *
146
+ * @return bool True on success, false on failure.
147
+ */
148
+ private function cancel($id)
149
+ {
150
+ // Cannot cancel if it has been processed.
151
+ if (!isset($this->handles[$id])) {
152
+ return false;
153
+ }
154
+
155
+ $handle = $this->handles[$id]['easy']->handle;
156
+ unset($this->delays[$id], $this->handles[$id]);
157
+ curl_multi_remove_handle($this->_mh, $handle);
158
+ curl_close($handle);
159
+
160
+ return true;
161
+ }
162
+
163
+ private function processMessages()
164
+ {
165
+ while ($done = curl_multi_info_read($this->_mh)) {
166
+ $id = (int) $done['handle'];
167
+ curl_multi_remove_handle($this->_mh, $done['handle']);
168
+
169
+ if (!isset($this->handles[$id])) {
170
+ // Probably was cancelled.
171
+ continue;
172
+ }
173
+
174
+ $entry = $this->handles[$id];
175
+ unset($this->handles[$id], $this->delays[$id]);
176
+ $entry['easy']->errno = $done['result'];
177
+ $entry['deferred']->resolve(
178
+ CurlFactory::finish(
179
+ $this,
180
+ $entry['easy'],
181
+ $this->factory
182
+ )
183
+ );
184
+ }
185
+ }
186
+
187
+ private function timeToNext()
188
+ {
189
+ $currentTime = microtime(true);
190
+ $nextTime = PHP_INT_MAX;
191
+ foreach ($this->delays as $time) {
192
+ if ($time < $nextTime) {
193
+ $nextTime = $time;
194
+ }
195
+ }
196
+
197
+ return max(0, $nextTime - $currentTime) * 1000000;
198
+ }
199
+ }
vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.
11
+ *
12
+ * @internal
13
+ */
14
+ final class EasyHandle
15
+ {
16
+ /** @var resource cURL resource */
17
+ public $handle;
18
+
19
+ /** @var StreamInterface Where data is being written */
20
+ public $sink;
21
+
22
+ /** @var array Received HTTP headers so far */
23
+ public $headers = [];
24
+
25
+ /** @var ResponseInterface Received response (if any) */
26
+ public $response;
27
+
28
+ /** @var RequestInterface Request being sent */
29
+ public $request;
30
+
31
+ /** @var array Request options */
32
+ public $options = [];
33
+
34
+ /** @var int cURL error number (if any) */
35
+ public $errno = 0;
36
+
37
+ /** @var \Exception Exception during on_headers (if any) */
38
+ public $onHeadersException;
39
+
40
+ /**
41
+ * Attach a response to the easy handle based on the received headers.
42
+ *
43
+ * @throws \RuntimeException if no headers have been received.
44
+ */
45
+ public function createResponse()
46
+ {
47
+ if (empty($this->headers)) {
48
+ throw new \RuntimeException('No headers have been received');
49
+ }
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'])
58
+ ) {
59
+ $headers['x-encoded-content-encoding']
60
+ = $headers[$normalizedKeys['content-encoding']];
61
+ unset($headers[$normalizedKeys['content-encoding']]);
62
+ if (isset($normalizedKeys['content-length'])) {
63
+ $headers['x-encoded-content-length']
64
+ = $headers[$normalizedKeys['content-length']];
65
+
66
+ $bodyLength = (int) $this->sink->getSize();
67
+ if ($bodyLength) {
68
+ $headers[$normalizedKeys['content-length']] = $bodyLength;
69
+ } else {
70
+ unset($headers[$normalizedKeys['content-length']]);
71
+ }
72
+ }
73
+ }
74
+
75
+ // Attach a response to the easy handle with the parsed headers.
76
+ $this->response = new Response(
77
+ $startLine[1],
78
+ $headers,
79
+ $this->sink,
80
+ substr($startLine[0], 5),
81
+ isset($startLine[2]) ? (string) $startLine[2] : null
82
+ );
83
+ }
84
+
85
+ public function __get($name)
86
+ {
87
+ $msg = $name === 'handle'
88
+ ? 'The EasyHandle has been released'
89
+ : 'Invalid property: ' . $name;
90
+ throw new \BadMethodCallException($msg);
91
+ }
92
+ }
vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.
14
+ */
15
+ class MockHandler implements \Countable
16
+ {
17
+ private $queue = [];
18
+ private $lastRequest;
19
+ private $lastOptions;
20
+ private $onFulfilled;
21
+ private $onRejected;
22
+
23
+ /**
24
+ * Creates a new MockHandler that uses the default handler stack list of
25
+ * middlewares.
26
+ *
27
+ * @param array $queue Array of responses, callables, or exceptions.
28
+ * @param callable $onFulfilled Callback to invoke when the return value is fulfilled.
29
+ * @param callable $onRejected Callback to invoke when the return value is rejected.
30
+ *
31
+ * @return HandlerStack
32
+ */
33
+ public static function createWithMiddleware(
34
+ array $queue = null,
35
+ callable $onFulfilled = null,
36
+ callable $onRejected = null
37
+ ) {
38
+ return HandlerStack::create(new self($queue, $onFulfilled, $onRejected));
39
+ }
40
+
41
+ /**
42
+ * The passed in value must be an array of
43
+ * {@see Psr7\Http\Message\ResponseInterface} objects, Exceptions,
44
+ * callables, or Promises.
45
+ *
46
+ * @param array $queue
47
+ * @param callable $onFulfilled Callback to invoke when the return value is fulfilled.
48
+ * @param callable $onRejected Callback to invoke when the return value is rejected.
49
+ */
50
+ public function __construct(
51
+ array $queue = null,
52
+ callable $onFulfilled = null,
53
+ callable $onRejected = null
54
+ ) {
55
+ $this->onFulfilled = $onFulfilled;
56
+ $this->onRejected = $onRejected;
57
+
58
+ if ($queue) {
59
+ call_user_func_array([$this, 'append'], $queue);
60
+ }
61
+ }
62
+
63
+ public function __invoke(RequestInterface $request, array $options)
64
+ {
65
+ if (!$this->queue) {
66
+ throw new \OutOfBoundsException('Mock queue is empty');
67
+ }
68
+
69
+ if (isset($options['delay'])) {
70
+ usleep($options['delay'] * 1000);
71
+ }
72
+
73
+ $this->lastRequest = $request;
74
+ $this->lastOptions = $options;
75
+ $response = array_shift($this->queue);
76
+
77
+ if (isset($options['on_headers'])) {
78
+ if (!is_callable($options['on_headers'])) {
79
+ throw new \InvalidArgumentException('on_headers must be callable');
80
+ }
81
+ try {
82
+ $options['on_headers']($response);
83
+ } catch (\Exception $e) {
84
+ $msg = 'An error was encountered during the on_headers event';
85
+ $response = new RequestException($msg, $request, $response, $e);
86
+ }
87
+ }
88
+
89
+ if (is_callable($response)) {
90
+ $response = call_user_func($response, $request, $options);
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) {
99
+ $this->invokeStats($request, $options, $value);
100
+ if ($this->onFulfilled) {
101
+ call_user_func($this->onFulfilled, $value);
102
+ }
103
+ if (isset($options['sink'])) {
104
+ $contents = (string) $value->getBody();
105
+ $sink = $options['sink'];
106
+
107
+ if (is_resource($sink)) {
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
+ }
115
+
116
+ return $value;
117
+ },
118
+ function ($reason) use ($request, $options) {
119
+ $this->invokeStats($request, $options, null, $reason);
120
+ if ($this->onRejected) {
121
+ call_user_func($this->onRejected, $reason);
122
+ }
123
+ return \GuzzleHttp\Promise\rejection_for($reason);
124
+ }
125
+ );
126
+ }
127
+
128
+ /**
129
+ * Adds one or more variadic requests, exceptions, callables, or promises
130
+ * to the queue.
131
+ */
132
+ public function append()
133
+ {
134
+ foreach (func_get_args() as $value) {
135
+ if ($value instanceof ResponseInterface
136
+ || $value instanceof \Exception
137
+ || $value instanceof PromiseInterface
138
+ || is_callable($value)
139
+ ) {
140
+ $this->queue[] = $value;
141
+ } else {
142
+ throw new \InvalidArgumentException('Expected a response or '
143
+ . 'exception. Found ' . \GuzzleHttp\describe_type($value));
144
+ }
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Get the last received request.
150
+ *
151
+ * @return RequestInterface
152
+ */
153
+ public function getLastRequest()
154
+ {
155
+ return $this->lastRequest;
156
+ }
157
+
158
+ /**
159
+ * Get the last received request options.
160
+ *
161
+ * @return array
162
+ */
163
+ public function getLastOptions()
164
+ {
165
+ return $this->lastOptions;
166
+ }
167
+
168
+ /**
169
+ * Returns the number of remaining items in the queue.
170
+ *
171
+ * @return int
172
+ */
173
+ public function count()
174
+ {
175
+ return count($this->queue);
176
+ }
177
+
178
+ private function invokeStats(
179
+ RequestInterface $request,
180
+ array $options,
181
+ ResponseInterface $response = null,
182
+ $reason = null
183
+ ) {
184
+ if (isset($options['on_stats'])) {
185
+ $stats = new TransferStats($request, $response, 0, $reason);
186
+ call_user_func($options['on_stats'], $stats);
187
+ }
188
+ }
189
+ }
vendor/guzzlehttp/guzzle/src/Handler/Proxy.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.
9
+ */
10
+ class Proxy
11
+ {
12
+ /**
13
+ * Sends synchronous requests to a specific handler while sending all other
14
+ * requests to another handler.
15
+ *
16
+ * @param callable $default Handler used for normal responses
17
+ * @param callable $sync Handler used for synchronous responses.
18
+ *
19
+ * @return callable Returns the composed handler.
20
+ */
21
+ public static function wrapSync(
22
+ callable $default,
23
+ callable $sync
24
+ ) {
25
+ return function (RequestInterface $request, array $options) use ($default, $sync) {
26
+ return empty($options[RequestOptions::SYNCHRONOUS])
27
+ ? $default($request, $options)
28
+ : $sync($request, $options);
29
+ };
30
+ }
31
+
32
+ /**
33
+ * Sends streaming requests to a streaming compatible handler while sending
34
+ * all other requests to a default handler.
35
+ *
36
+ * This, for example, could be useful for taking advantage of the
37
+ * performance benefits of curl while still supporting true streaming
38
+ * through the StreamHandler.
39
+ *
40
+ * @param callable $default Handler used for non-streaming responses
41
+ * @param callable $streaming Handler used for streaming responses
42
+ *
43
+ * @return callable Returns the composed handler.
44
+ */
45
+ public static function wrapStreaming(
46
+ callable $default,
47
+ callable $streaming
48
+ ) {
49
+ return function (RequestInterface $request, array $options) use ($default, $streaming) {
50
+ return empty($options['stream'])
51
+ ? $default($request, $options)
52
+ : $streaming($request, $options);
53
+ };
54
+ }
55
+ }
vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php ADDED
@@ -0,0 +1,532 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.
16
+ */
17
+ class StreamHandler
18
+ {
19
+ private $lastHeaders = [];
20
+
21
+ /**
22
+ * Sends an HTTP request.
23
+ *
24
+ * @param RequestInterface $request Request to send.
25
+ * @param array $options Request transfer options.
26
+ *
27
+ * @return PromiseInterface
28
+ */
29
+ public function __invoke(RequestInterface $request, array $options)
30
+ {
31
+ // Sleep if there is a delay specified.
32
+ if (isset($options['delay'])) {
33
+ usleep($options['delay'] * 1000);
34
+ }
35
+
36
+ $startTime = isset($options['on_stats']) ? microtime(true) : null;
37
+
38
+ try {
39
+ // Does not support the expect header.
40
+ $request = $request->withoutHeader('Expect');
41
+
42
+ // Append a content-length header if body size is zero to match
43
+ // cURL's behavior.
44
+ if (0 === $request->getBody()->getSize()) {
45
+ $request = $request->withHeader('Content-Length', 0);
46
+ }
47
+
48
+ return $this->createResponse(
49
+ $request,
50
+ $options,
51
+ $this->createStream($request, $options),
52
+ $startTime
53
+ );
54
+ } catch (\InvalidArgumentException $e) {
55
+ throw $e;
56
+ } catch (\Exception $e) {
57
+ // Determine if the error was a networking error.
58
+ $message = $e->getMessage();
59
+ // This list can probably get more comprehensive.
60
+ if (strpos($message, 'getaddrinfo') // DNS lookup failed
61
+ || strpos($message, 'Connection refused')
62
+ || strpos($message, "couldn't connect to host") // error on HHVM
63
+ || strpos($message, "connection attempt failed")
64
+ ) {
65
+ $e = new ConnectException($e->getMessage(), $request, $e);
66
+ }
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
+
74
+ private function invokeStats(
75
+ array $options,
76
+ RequestInterface $request,
77
+ $startTime,
78
+ ResponseInterface $response = null,
79
+ $error = null
80
+ ) {
81
+ if (isset($options['on_stats'])) {
82
+ $stats = new TransferStats(
83
+ $request,
84
+ $response,
85
+ microtime(true) - $startTime,
86
+ $error,
87
+ []
88
+ );
89
+ call_user_func($options['on_stats'], $stats);
90
+ }
91
+ }
92
+
93
+ private function createResponse(
94
+ RequestInterface $request,
95
+ array $options,
96
+ $stream,
97
+ $startTime
98
+ ) {
99
+ $hdrs = $this->lastHeaders;
100
+ $this->lastHeaders = [];
101
+ $parts = explode(' ', array_shift($hdrs), 3);
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;
109
+
110
+ if (strcasecmp('HEAD', $request->getMethod())) {
111
+ $sink = $this->createSink($stream, $options);
112
+ }
113
+
114
+ $response = new Psr7\Response($status, $headers, $sink, $ver, $reason);
115
+
116
+ if (isset($options['on_headers'])) {
117
+ try {
118
+ $options['on_headers']($response);
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
+
126
+ // Do not drain when the request is a HEAD request because they have
127
+ // no body.
128
+ if ($sink !== $stream) {
129
+ $this->drain(
130
+ $stream,
131
+ $sink,
132
+ $response->getHeaderLine('Content-Length')
133
+ );
134
+ }
135
+
136
+ $this->invokeStats($options, $request, $startTime, $response, null);
137
+
138
+ return new FulfilledPromise($response);
139
+ }
140
+
141
+ private function createSink(StreamInterface $stream, array $options)
142
+ {
143
+ if (!empty($options['stream'])) {
144
+ return $stream;
145
+ }
146
+
147
+ $sink = isset($options['sink'])
148
+ ? $options['sink']
149
+ : fopen('php://temp', 'r+');
150
+
151
+ return is_string($sink)
152
+ ? new Psr7\LazyOpenStream($sink, 'w+')
153
+ : Psr7\stream_for($sink);
154
+ }
155
+
156
+ private function checkDecode(array $options, array $headers, $stream)
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') {
164
+ $stream = new Psr7\InflateStream(
165
+ Psr7\stream_for($stream)
166
+ );
167
+ $headers['x-encoded-content-encoding']
168
+ = $headers[$normalizedKeys['content-encoding']];
169
+ // Remove content-encoding header
170
+ unset($headers[$normalizedKeys['content-encoding']]);
171
+ // Fix content-length header
172
+ if (isset($normalizedKeys['content-length'])) {
173
+ $headers['x-encoded-content-length']
174
+ = $headers[$normalizedKeys['content-length']];
175
+
176
+ $length = (int) $stream->getSize();
177
+ if ($length === 0) {
178
+ unset($headers[$normalizedKeys['content-length']]);
179
+ } else {
180
+ $headers[$normalizedKeys['content-length']] = [$length];
181
+ }
182
+ }
183
+ }
184
+ }
185
+ }
186
+
187
+ return [$stream, $headers];
188
+ }
189
+
190
+ /**
191
+ * Drains the source stream into the "sink" client option.
192
+ *
193
+ * @param StreamInterface $source
194
+ * @param StreamInterface $sink
195
+ * @param string $contentLength Header specifying the amount of
196
+ * data to read.
197
+ *
198
+ * @return StreamInterface
199
+ * @throws \RuntimeException when the sink option is invalid.
200
+ */
201
+ private function drain(
202
+ StreamInterface $source,
203
+ StreamInterface $sink,
204
+ $contentLength
205
+ ) {
206
+ // If a content-length header is provided, then stop reading once
207
+ // that number of bytes has been read. This can prevent infinitely
208
+ // reading from a stream when dealing with servers that do not honor
209
+ // Connection: Close headers.
210
+ Psr7\copy_to_stream(
211
+ $source,
212
+ $sink,
213
+ (strlen($contentLength) > 0 && (int) $contentLength > 0) ? (int) $contentLength : -1
214
+ );
215
+
216
+ $sink->seek(0);
217
+ $source->close();
218
+
219
+ return $sink;
220
+ }
221
+
222
+ /**
223
+ * Create a resource and check to ensure it was created successfully
224
+ *
225
+ * @param callable $callback Callable that returns stream resource
226
+ *
227
+ * @return resource
228
+ * @throws \RuntimeException on error
229
+ */
230
+ private function createResource(callable $callback)
231
+ {
232
+ $errors = null;
233
+ set_error_handler(function ($_, $msg, $file, $line) use (&$errors) {
234
+ $errors[] = [
235
+ 'message' => $msg,
236
+ 'file' => $file,
237
+ 'line' => $line
238
+ ];
239
+ return true;
240
+ });
241
+
242
+ $resource = $callback();
243
+ restore_error_handler();
244
+
245
+ if (!$resource) {
246
+ $message = 'Error creating resource: ';
247
+ foreach ($errors as $err) {
248
+ foreach ($err as $key => $value) {
249
+ $message .= "[$key] $value" . PHP_EOL;
250
+ }
251
+ }
252
+ throw new \RuntimeException(trim($message));
253
+ }
254
+
255
+ return $resource;
256
+ }
257
+
258
+ private function createStream(RequestInterface $request, array $options)
259
+ {
260
+ static $methods;
261
+ if (!$methods) {
262
+ $methods = array_flip(get_class_methods(__CLASS__));
263
+ }
264
+
265
+ // HTTP/1.1 streams using the PHP stream wrapper require a
266
+ // Connection: close header
267
+ if ($request->getProtocolVersion() == '1.1'
268
+ && !$request->hasHeader('Connection')
269
+ ) {
270
+ $request = $request->withHeader('Connection', 'close');
271
+ }
272
+
273
+ // Ensure SSL is verified by default
274
+ if (!isset($options['verify'])) {
275
+ $options['verify'] = true;
276
+ }
277
+
278
+ $params = [];
279
+ $context = $this->getDefaultContext($request);
280
+
281
+ if (isset($options['on_headers']) && !is_callable($options['on_headers'])) {
282
+ throw new \InvalidArgumentException('on_headers must be callable');
283
+ }
284
+
285
+ if (!empty($options)) {
286
+ foreach ($options as $key => $value) {
287
+ $method = "add_{$key}";
288
+ if (isset($methods[$method])) {
289
+ $this->{$method}($request, $context, $value, $params);
290
+ }
291
+ }
292
+ }
293
+
294
+ if (isset($options['stream_context'])) {
295
+ if (!is_array($options['stream_context'])) {
296
+ throw new \InvalidArgumentException('stream_context must be an array');
297
+ }
298
+ $context = array_replace_recursive(
299
+ $context,
300
+ $options['stream_context']
301
+ );
302
+ }
303
+
304
+ // Microsoft NTLM authentication only supported with curl handler
305
+ if (isset($options['auth'])
306
+ && is_array($options['auth'])
307
+ && isset($options['auth'][2])
308
+ && 'ntlm' == $options['auth'][2]
309
+ ) {
310
+ throw new \InvalidArgumentException('Microsoft NTLM authentication only supported with curl handler');
311
+ }
312
+
313
+ $uri = $this->resolveHost($request, $options);
314
+
315
+ $context = $this->createResource(
316
+ function () use ($context, $params) {
317
+ return stream_context_create($context, $params);
318
+ }
319
+ );
320
+
321
+ return $this->createResource(
322
+ function () use ($uri, &$http_response_header, $context, $options) {
323
+ $resource = fopen((string) $uri, 'r', null, $context);
324
+ $this->lastHeaders = $http_response_header;
325
+
326
+ if (isset($options['read_timeout'])) {
327
+ $readTimeout = $options['read_timeout'];
328
+ $sec = (int) $readTimeout;
329
+ $usec = ($readTimeout - $sec) * 100000;
330
+ stream_set_timeout($resource, $sec, $usec);
331
+ }
332
+
333
+ return $resource;
334
+ }
335
+ );
336
+ }
337
+
338
+ private function resolveHost(RequestInterface $request, array $options)
339
+ {
340
+ $uri = $request->getUri();
341
+
342
+ if (isset($options['force_ip_resolve']) && !filter_var($uri->getHost(), FILTER_VALIDATE_IP)) {
343
+ if ('v4' === $options['force_ip_resolve']) {
344
+ $records = dns_get_record($uri->getHost(), DNS_A);
345
+ if (!isset($records[0]['ip'])) {
346
+ throw new ConnectException(sprintf("Could not resolve IPv4 address for host '%s'", $uri->getHost()), $request);
347
+ }
348
+ $uri = $uri->withHost($records[0]['ip']);
349
+ } elseif ('v6' === $options['force_ip_resolve']) {
350
+ $records = dns_get_record($uri->getHost(), DNS_AAAA);
351
+ if (!isset($records[0]['ipv6'])) {
352
+ throw new ConnectException(sprintf("Could not resolve IPv6 address for host '%s'", $uri->getHost()), $request);
353
+ }
354
+ $uri = $uri->withHost('[' . $records[0]['ipv6'] . ']');
355
+ }
356
+ }
357
+
358
+ return $uri;
359
+ }
360
+
361
+ private function getDefaultContext(RequestInterface $request)
362
+ {
363
+ $headers = '';
364
+ foreach ($request->getHeaders() as $name => $value) {
365
+ foreach ($value as $val) {
366
+ $headers .= "$name: $val\r\n";
367
+ }
368
+ }
369
+
370
+ $context = [
371
+ 'http' => [
372
+ 'method' => $request->getMethod(),
373
+ 'header' => $headers,
374
+ 'protocol_version' => $request->getProtocolVersion(),
375
+ 'ignore_errors' => true,
376
+ 'follow_location' => 0,
377
+ ],
378
+ ];
379
+
380
+ $body = (string) $request->getBody();
381
+
382
+ if (!empty($body)) {
383
+ $context['http']['content'] = $body;
384
+ // Prevent the HTTP handler from adding a Content-Type header.
385
+ if (!$request->hasHeader('Content-Type')) {
386
+ $context['http']['header'] .= "Content-Type:\r\n";
387
+ }
388
+ }
389
+
390
+ $context['http']['header'] = rtrim($context['http']['header']);
391
+
392
+ return $context;
393
+ }
394
+
395
+ private function add_proxy(RequestInterface $request, &$options, $value, &$params)
396
+ {
397
+ if (!is_array($value)) {
398
+ $options['http']['proxy'] = $value;
399
+ } else {
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
+ )
407
+ ) {
408
+ $options['http']['proxy'] = $value[$scheme];
409
+ }
410
+ }
411
+ }
412
+ }
413
+
414
+ private function add_timeout(RequestInterface $request, &$options, $value, &$params)
415
+ {
416
+ if ($value > 0) {
417
+ $options['http']['timeout'] = $value;
418
+ }
419
+ }
420
+
421
+ private function add_verify(RequestInterface $request, &$options, $value, &$params)
422
+ {
423
+ if ($value === true) {
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;
431
+ if (!file_exists($value)) {
432
+ throw new \RuntimeException("SSL CA bundle not found: $value");
433
+ }
434
+ } elseif ($value === false) {
435
+ $options['ssl']['verify_peer'] = false;
436
+ $options['ssl']['verify_peer_name'] = false;
437
+ return;
438
+ } else {
439
+ throw new \InvalidArgumentException('Invalid verify request option');
440
+ }
441
+
442
+ $options['ssl']['verify_peer'] = true;
443
+ $options['ssl']['verify_peer_name'] = true;
444
+ $options['ssl']['allow_self_signed'] = false;
445
+ }
446
+
447
+ private function add_cert(RequestInterface $request, &$options, $value, &$params)
448
+ {
449
+ if (is_array($value)) {
450
+ $options['ssl']['passphrase'] = $value[1];
451
+ $value = $value[0];
452
+ }
453
+
454
+ if (!file_exists($value)) {
455
+ throw new \RuntimeException("SSL certificate not found: {$value}");
456
+ }
457
+
458
+ $options['ssl']['local_cert'] = $value;
459
+ }
460
+
461
+ private function add_progress(RequestInterface $request, &$options, $value, &$params)
462
+ {
463
+ $this->addNotification(
464
+ $params,
465
+ function ($code, $a, $b, $c, $transferred, $total) use ($value) {
466
+ if ($code == STREAM_NOTIFY_PROGRESS) {
467
+ $value($total, $transferred, null, null);
468
+ }
469
+ }
470
+ );
471
+ }
472
+
473
+ private function add_debug(RequestInterface $request, &$options, $value, &$params)
474
+ {
475
+ if ($value === false) {
476
+ return;
477
+ }
478
+
479
+ static $map = [
480
+ STREAM_NOTIFY_CONNECT => 'CONNECT',
481
+ STREAM_NOTIFY_AUTH_REQUIRED => 'AUTH_REQUIRED',
482
+ STREAM_NOTIFY_AUTH_RESULT => 'AUTH_RESULT',
483
+ STREAM_NOTIFY_MIME_TYPE_IS => 'MIME_TYPE_IS',
484
+ STREAM_NOTIFY_FILE_SIZE_IS => 'FILE_SIZE_IS',
485
+ STREAM_NOTIFY_REDIRECTED => 'REDIRECTED',
486
+ STREAM_NOTIFY_PROGRESS => 'PROGRESS',
487
+ STREAM_NOTIFY_FAILURE => 'FAILURE',
488
+ STREAM_NOTIFY_COMPLETED => 'COMPLETED',
489
+ STREAM_NOTIFY_RESOLVE => 'RESOLVE',
490
+ ];
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,
498
+ function () use ($ident, $value, $map, $args) {
499
+ $passed = func_get_args();
500
+ $code = array_shift($passed);
501
+ fprintf($value, '<%s> [%s] ', $ident, $map[$code]);
502
+ foreach (array_filter($passed) as $i => $v) {
503
+ fwrite($value, $args[$i] . ': "' . $v . '" ');
504
+ }
505
+ fwrite($value, "\n");
506
+ }
507
+ );
508
+ }
509
+
510
+ private function addNotification(array &$params, callable $notify)
511
+ {
512
+ // Wrap the existing function if needed.
513
+ if (!isset($params['notification'])) {
514
+ $params['notification'] = $notify;
515
+ } else {
516
+ $params['notification'] = $this->callArray([
517
+ $params['notification'],
518
+ $notify
519
+ ]);
520
+ }
521
+ }
522
+
523
+ private function callArray(array $functions)
524
+ {
525
+ return function () use ($functions) {
526
+ $args = func_get_args();
527
+ foreach ($functions as $fn) {
528
+ call_user_func_array($fn, $args);
529
+ }
530
+ };
531
+ }
532
+ }
vendor/guzzlehttp/guzzle/src/HandlerStack.php ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
8
+ * an HTTP handler function.
9
+ */
10
+ class HandlerStack
11
+ {
12
+ /** @var callable */
13
+ private $handler;
14
+
15
+ /** @var array */
16
+ private $stack = [];
17
+
18
+ /** @var callable|null */
19
+ private $cached;
20
+
21
+ /**
22
+ * Creates a default handler stack that can be used by clients.
23
+ *
24
+ * The returned handler will wrap the provided handler or use the most
25
+ * appropriate default handler for your system. The returned HandlerStack has
26
+ * support for cookies, redirects, HTTP error exceptions, and preparing a body
27
+ * before sending.
28
+ *
29
+ * The returned handler stack can be passed to a client in the "handler"
30
+ * option.
31
+ *
32
+ * @param callable $handler HTTP handler function to use with the stack. If no
33
+ * handler is provided, the best handler for your
34
+ * system will be utilized.
35
+ *
36
+ * @return HandlerStack
37
+ */
38
+ public static function create(callable $handler = null)
39
+ {
40
+ $stack = new self($handler ?: choose_handler());
41
+ $stack->push(Middleware::httpErrors(), 'http_errors');
42
+ $stack->push(Middleware::redirect(), 'allow_redirects');
43
+ $stack->push(Middleware::cookies(), 'cookies');
44
+ $stack->push(Middleware::prepareBody(), 'prepare_body');
45
+
46
+ return $stack;
47
+ }
48
+
49
+ /**
50
+ * @param callable $handler Underlying HTTP handler.
51
+ */
52
+ public function __construct(callable $handler = null)
53
+ {
54
+ $this->handler = $handler;
55
+ }
56
+
57
+ /**
58
+ * Invokes the handler stack as a composed handler
59
+ *
60
+ * @param RequestInterface $request
61
+ * @param array $options
62
+ */
63
+ public function __invoke(RequestInterface $request, array $options)
64
+ {
65
+ $handler = $this->resolve();
66
+
67
+ return $handler($request, $options);
68
+ }
69
+
70
+ /**
71
+ * Dumps a string representation of the stack.
72
+ *
73
+ * @return string
74
+ */
75
+ public function __toString()
76
+ {
77
+ $depth = 0;
78
+ $stack = [];
79
+ if ($this->handler) {
80
+ $stack[] = "0) Handler: " . $this->debugCallable($this->handler);
81
+ }
82
+
83
+ $result = '';
84
+ foreach (array_reverse($this->stack) as $tuple) {
85
+ $depth++;
86
+ $str = "{$depth}) Name: '{$tuple[1]}', ";
87
+ $str .= "Function: " . $this->debugCallable($tuple[0]);
88
+ $result = "> {$str}\n{$result}";
89
+ $stack[] = $str;
90
+ }
91
+
92
+ foreach (array_keys($stack) as $k) {
93
+ $result .= "< {$stack[$k]}\n";
94
+ }
95
+
96
+ return $result;
97
+ }
98
+
99
+ /**
100
+ * Set the HTTP handler that actually returns a promise.
101
+ *
102
+ * @param callable $handler Accepts a request and array of options and
103
+ * returns a Promise.
104
+ */
105
+ public function setHandler(callable $handler)
106
+ {
107
+ $this->handler = $handler;
108
+ $this->cached = null;
109
+ }
110
+
111
+ /**
112
+ * Returns true if the builder has a handler.
113
+ *
114
+ * @return bool
115
+ */
116
+ public function hasHandler()
117
+ {
118
+ return (bool) $this->handler;
119
+ }
120
+
121
+ /**
122
+ * Unshift a middleware to the bottom of the stack.
123
+ *
124
+ * @param callable $middleware Middleware function
125
+ * @param string $name Name to register for this middleware.
126
+ */
127
+ public function unshift(callable $middleware, $name = null)
128
+ {
129
+ array_unshift($this->stack, [$middleware, $name]);
130
+ $this->cached = null;
131
+ }
132
+
133
+ /**
134
+ * Push a middleware to the top of the stack.
135
+ *
136
+ * @param callable $middleware Middleware function
137
+ * @param string $name Name to register for this middleware.
138
+ */
139
+ public function push(callable $middleware, $name = '')
140
+ {
141
+ $this->stack[] = [$middleware, $name];
142
+ $this->cached = null;
143
+ }
144
+
145
+ /**
146
+ * Add a middleware before another middleware by name.
147
+ *
148
+ * @param string $findName Middleware to find
149
+ * @param callable $middleware Middleware function
150
+ * @param string $withName Name to register for this middleware.
151
+ */
152
+ public function before($findName, callable $middleware, $withName = '')
153
+ {
154
+ $this->splice($findName, $withName, $middleware, true);
155
+ }
156
+
157
+ /**
158
+ * Add a middleware after another middleware by name.
159
+ *
160
+ * @param string $findName Middleware to find
161
+ * @param callable $middleware Middleware function
162
+ * @param string $withName Name to register for this middleware.
163
+ */
164
+ public function after($findName, callable $middleware, $withName = '')
165
+ {
166
+ $this->splice($findName, $withName, $middleware, false);
167
+ }
168
+
169
+ /**
170
+ * Remove a middleware by instance or name from the stack.
171
+ *
172
+ * @param callable|string $remove Middleware to remove by instance or name.
173
+ */
174
+ public function remove($remove)
175
+ {
176
+ $this->cached = null;
177
+ $idx = is_callable($remove) ? 0 : 1;
178
+ $this->stack = array_values(array_filter(
179
+ $this->stack,
180
+ function ($tuple) use ($idx, $remove) {
181
+ return $tuple[$idx] !== $remove;
182
+ }
183
+ ));
184
+ }
185
+
186
+ /**
187
+ * Compose the middleware and handler into a single callable function.
188
+ *
189
+ * @return callable
190
+ */
191
+ public function resolve()
192
+ {
193
+ if (!$this->cached) {
194
+ if (!($prev = $this->handler)) {
195
+ throw new \LogicException('No handler has been specified');
196
+ }
197
+
198
+ foreach (array_reverse($this->stack) as $fn) {
199
+ $prev = $fn[0]($prev);
200
+ }
201
+
202
+ $this->cached = $prev;
203
+ }
204
+
205
+ return $this->cached;
206
+ }
207
+
208
+ /**
209
+ * @param $name
210
+ * @return int
211
+ */
212
+ private function findByName($name)
213
+ {
214
+ foreach ($this->stack as $k => $v) {
215
+ if ($v[1] === $name) {
216
+ return $k;
217
+ }
218
+ }
219
+
220
+ throw new \InvalidArgumentException("Middleware not found: $name");
221
+ }
222
+
223
+ /**
224
+ * Splices a function into the middleware list at a specific position.
225
+ *
226
+ * @param $findName
227
+ * @param $withName
228
+ * @param callable $middleware
229
+ * @param $before
230
+ */
231
+ private function splice($findName, $withName, callable $middleware, $before)
232
+ {
233
+ $this->cached = null;
234
+ $idx = $this->findByName($findName);
235
+ $tuple = [$middleware, $withName];
236
+
237
+ if ($before) {
238
+ if ($idx === 0) {
239
+ array_unshift($this->stack, $tuple);
240
+ } else {
241
+ $replacement = [$tuple, $this->stack[$idx]];
242
+ array_splice($this->stack, $idx, 1, $replacement);
243
+ }
244
+ } elseif ($idx === count($this->stack) - 1) {
245
+ $this->stack[] = $tuple;
246
+ } else {
247
+ $replacement = [$this->stack[$idx], $tuple];
248
+ array_splice($this->stack, $idx, 1, $replacement);
249
+ }
250
+ }
251
+
252
+ /**
253
+ * Provides a debug string for a given callable.
254
+ *
255
+ * @param array|callable $fn Function to write as a string.
256
+ *
257
+ * @return string
258
+ */
259
+ private function debugCallable($fn)
260
+ {
261
+ if (is_string($fn)) {
262
+ return "callable({$fn})";
263
+ }
264
+
265
+ if (is_array($fn)) {
266
+ return is_string($fn[0])
267
+ ? "callable({$fn[0]}::{$fn[1]})"
268
+ : "callable(['" . get_class($fn[0]) . "', '{$fn[1]}'])";
269
+ }
270
+
271
+ return 'callable(' . spl_object_hash($fn) . ')';
272
+ }
273
+ }
vendor/guzzlehttp/guzzle/src/MessageFormatter.php ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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,
10
+ * and other transactional data.
11
+ *
12
+ * The following variable substitutions are supported:
13
+ *
14
+ * - {request}: Full HTTP request message
15
+ * - {response}: Full HTTP response message
16
+ * - {ts}: ISO 8601 date in GMT
17
+ * - {date_iso_8601} ISO 8601 date in GMT
18
+ * - {date_common_log} Apache common log date using the configured timezone.
19
+ * - {host}: Host of the request
20
+ * - {method}: Method of the request
21
+ * - {uri}: URI of the request
22
+ * - {version}: Protocol version
23
+ * - {target}: Request target of the request (path + query + fragment)
24
+ * - {hostname}: Hostname of the machine that sent the request
25
+ * - {code}: Status code of the response (if available)
26
+ * - {phrase}: Reason phrase of the response (if available)
27
+ * - {error}: Any error messages (if available)
28
+ * - {req_header_*}: Replace `*` with the lowercased name of a request header to add to the message
29
+ * - {res_header_*}: Replace `*` with the lowercased name of a response header to add to the message
30
+ * - {req_headers}: Request headers
31
+ * - {res_headers}: Response headers
32
+ * - {req_body}: Request body
33
+ * - {res_body}: Response body
34
+ */
35
+ class MessageFormatter
36
+ {
37
+ /**
38
+ * Apache Common Log Format.
39
+ * @link http://httpd.apache.org/docs/2.4/logs.html#common
40
+ * @var string
41
+ */
42
+ const CLF = "{hostname} {req_header_User-Agent} - [{date_common_log}] \"{method} {target} HTTP/{version}\" {code} {res_header_Content-Length}";
43
+ const DEBUG = ">>>>>>>>\n{request}\n<<<<<<<<\n{response}\n--------\n{error}";
44
+ const SHORT = '[{ts}] "{method} {target} HTTP/{version}" {code}';
45
+
46
+ /** @var string Template used to format log messages */
47
+ private $template;
48
+
49
+ /**
50
+ * @param string $template Log message template
51
+ */
52
+ public function __construct($template = self::CLF)
53
+ {
54
+ $this->template = $template ?: self::CLF;
55
+ }
56
+
57
+ /**
58
+ * Returns a formatted message string.
59
+ *
60
+ * @param RequestInterface $request Request that was sent
61
+ * @param ResponseInterface $response Response that was received
62
+ * @param \Exception $error Exception that was received
63
+ *
64
+ * @return string
65
+ */
66
+ public function format(
67
+ RequestInterface $request,
68
+ ResponseInterface $response = null,
69
+ \Exception $error = null
70
+ ) {
71
+ $cache = [];
72
+
73
+ return preg_replace_callback(
74
+ '/{\s*([A-Za-z_\-\.0-9]+)\s*}/',
75
+ function (array $matches) use ($request, $response, $error, &$cache) {
76
+ if (isset($cache[$matches[1]])) {
77
+ return $cache[$matches[1]];
78
+ }
79
+
80
+ $result = '';
81
+ switch ($matches[1]) {
82
+ case 'request':
83
+ $result = Psr7\str($request);
84
+ break;
85
+ case 'response':
86
+ $result = $response ? Psr7\str($response) : '';
87
+ break;
88
+ case 'req_headers':
89
+ $result = trim($request->getMethod()
90
+ . ' ' . $request->getRequestTarget())
91
+ . ' HTTP/' . $request->getProtocolVersion() . "\r\n"
92
+ . $this->headers($request);
93
+ break;
94
+ case 'res_headers':
95
+ $result = $response ?
96
+ sprintf(
97
+ 'HTTP/%s %d %s',
98
+ $response->getProtocolVersion(),
99
+ $response->getStatusCode(),
100
+ $response->getReasonPhrase()
101
+ ) . "\r\n" . $this->headers($response)
102
+ : 'NULL';
103
+ break;
104
+ case 'req_body':
105
+ $result = $request->getBody();
106
+ break;
107
+ case 'res_body':
108
+ $result = $response ? $response->getBody() : 'NULL';
109
+ break;
110
+ case 'ts':
111
+ case 'date_iso_8601':
112
+ $result = gmdate('c');
113
+ break;
114
+ case 'date_common_log':
115
+ $result = date('d/M/Y:H:i:s O');
116
+ break;
117
+ case 'method':
118
+ $result = $request->getMethod();
119
+ break;
120
+ case 'version':
121
+ $result = $request->getProtocolVersion();
122
+ break;
123
+ case 'uri':
124
+ case 'url':
125
+ $result = $request->getUri();
126
+ break;
127
+ case 'target':
128
+ $result = $request->getRequestTarget();
129
+ break;
130
+ case 'req_version':
131
+ $result = $request->getProtocolVersion();
132
+ break;
133
+ case 'res_version':
134
+ $result = $response
135
+ ? $response->getProtocolVersion()
136
+ : 'NULL';
137
+ break;
138
+ case 'host':
139
+ $result = $request->getHeaderLine('Host');
140
+ break;
141
+ case 'hostname':
142
+ $result = gethostname();
143
+ break;
144
+ case 'code':
145
+ $result = $response ? $response->getStatusCode() : 'NULL';
146
+ break;
147
+ case 'phrase':
148
+ $result = $response ? $response->getReasonPhrase() : 'NULL';
149
+ break;
150
+ case 'error':
151
+ $result = $error ? $error->getMessage() : 'NULL';
152
+ break;
153
+ default:
154
+ // handle prefixed dynamic headers
155
+ if (strpos($matches[1], 'req_header_') === 0) {
156
+ $result = $request->getHeaderLine(substr($matches[1], 11));
157
+ } elseif (strpos($matches[1], 'res_header_') === 0) {
158
+ $result = $response
159
+ ? $response->getHeaderLine(substr($matches[1], 11))
160
+ : 'NULL';
161
+ }
162
+ }
163
+
164
+ $cache[$matches[1]] = $result;
165
+ return $result;
166
+ },
167
+ $this->template
168
+ );
169
+ }
170
+
171
+ private function headers(MessageInterface $message)
172
+ {
173
+ $result = '';
174
+ foreach ($message->getHeaders() as $name => $values) {
175
+ $result .= $name . ': ' . implode(', ', $values) . "\r\n";
176
+ }
177
+
178
+ return trim($result);
179
+ }
180
+ }
vendor/guzzlehttp/guzzle/src/Middleware.php ADDED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.
14
+ */
15
+ final class Middleware
16
+ {
17
+ /**
18
+ * Middleware that adds cookies to requests.
19
+ *
20
+ * The options array must be set to a CookieJarInterface in order to use
21
+ * cookies. This is typically handled for you by a client.
22
+ *
23
+ * @return callable Returns a function that accepts the next handler.
24
+ */
25
+ public static function cookies()
26
+ {
27
+ return function (callable $handler) {
28
+ return function ($request, array $options) use ($handler) {
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);
36
+ return $handler($request, $options)
37
+ ->then(
38
+ function ($response) use ($cookieJar, $request) {
39
+ $cookieJar->extractCookies($request, $response);
40
+ return $response;
41
+ }
42
+ );
43
+ };
44
+ };
45
+ }
46
+
47
+ /**
48
+ * Middleware that throws exceptions for 4xx or 5xx responses when the
49
+ * "http_error" request option is set to true.
50
+ *
51
+ * @return callable Returns a function that accepts the next handler.
52
+ */
53
+ public static function httpErrors()
54
+ {
55
+ return function (callable $handler) {
56
+ return function ($request, array $options) use ($handler) {
57
+ if (empty($options['http_errors'])) {
58
+ return $handler($request, $options);
59
+ }
60
+ return $handler($request, $options)->then(
61
+ function (ResponseInterface $response) use ($request, $handler) {
62
+ $code = $response->getStatusCode();
63
+ if ($code < 400) {
64
+ return $response;
65
+ }
66
+ throw RequestException::create($request, $response);
67
+ }
68
+ );
69
+ };
70
+ };
71
+ }
72
+
73
+ /**
74
+ * Middleware that pushes history data to an ArrayAccess container.
75
+ *
76
+ * @param array|\ArrayAccess $container Container to hold the history (by reference).
77
+ *
78
+ * @return callable Returns a function that accepts the next handler.
79
+ * @throws \InvalidArgumentException if container is not an array or ArrayAccess.
80
+ */
81
+ public static function history(&$container)
82
+ {
83
+ if (!is_array($container) && !$container instanceof \ArrayAccess) {
84
+ throw new \InvalidArgumentException('history container must be an array or object implementing ArrayAccess');
85
+ }
86
+
87
+ return function (callable $handler) use (&$container) {
88
+ return function ($request, array $options) use ($handler, &$container) {
89
+ return $handler($request, $options)->then(
90
+ function ($value) use ($request, &$container, $options) {
91
+ $container[] = [
92
+ 'request' => $request,
93
+ 'response' => $value,
94
+ 'error' => null,
95
+ 'options' => $options
96
+ ];
97
+ return $value;
98
+ },
99
+ function ($reason) use ($request, &$container, $options) {
100
+ $container[] = [
101
+ 'request' => $request,
102
+ 'response' => null,
103
+ 'error' => $reason,
104
+ 'options' => $options
105
+ ];
106
+ return \GuzzleHttp\Promise\rejection_for($reason);
107
+ }
108
+ );
109
+ };
110
+ };
111
+ }
112
+
113
+ /**
114
+ * Middleware that invokes a callback before and after sending a request.
115
+ *
116
+ * The provided listener cannot modify or alter the response. It simply
117
+ * "taps" into the chain to be notified before returning the promise. The
118
+ * before listener accepts a request and options array, and the after
119
+ * listener accepts a request, options array, and response promise.
120
+ *
121
+ * @param callable $before Function to invoke before forwarding the request.
122
+ * @param callable $after Function invoked after forwarding.
123
+ *
124
+ * @return callable Returns a function that accepts the next handler.
125
+ */
126
+ public static function tap(callable $before = null, callable $after = null)
127
+ {
128
+ return function (callable $handler) use ($before, $after) {
129
+ return function ($request, array $options) use ($handler, $before, $after) {
130
+ if ($before) {
131
+ $before($request, $options);
132
+ }
133
+ $response = $handler($request, $options);
134
+ if ($after) {
135
+ $after($request, $options, $response);
136
+ }
137
+ return $response;
138
+ };
139
+ };
140
+ }
141
+
142
+ /**
143
+ * Middleware that handles request redirects.
144
+ *
145
+ * @return callable Returns a function that accepts the next handler.
146
+ */
147
+ public static function redirect()
148
+ {
149
+ return function (callable $handler) {
150
+ return new RedirectMiddleware($handler);
151
+ };
152
+ }
153
+
154
+ /**
155
+ * Middleware that retries requests based on the boolean result of
156
+ * invoking the provided "decider" function.
157
+ *
158
+ * If no delay function is provided, a simple implementation of exponential
159
+ * backoff will be utilized.
160
+ *
161
+ * @param callable $decider Function that accepts the number of retries,
162
+ * a request, [response], and [exception] and
163
+ * returns true if the request is to be retried.
164
+ * @param callable $delay Function that accepts the number of retries and
165
+ * returns the number of milliseconds to delay.
166
+ *
167
+ * @return callable Returns a function that accepts the next handler.
168
+ */
169
+ public static function retry(callable $decider, callable $delay = null)
170
+ {
171
+ return function (callable $handler) use ($decider, $delay) {
172
+ return new RetryMiddleware($decider, $handler, $delay);
173
+ };
174
+ }
175
+
176
+ /**
177
+ * Middleware that logs requests, responses, and errors using a message
178
+ * formatter.
179
+ *
180
+ * @param LoggerInterface $logger Logs messages.
181
+ * @param MessageFormatter $formatter Formatter used to create message strings.
182
+ * @param string $logLevel Level at which to log requests.
183
+ *
184
+ * @return callable Returns a function that accepts the next handler.
185
+ */
186
+ public static function log(LoggerInterface $logger, MessageFormatter $formatter, $logLevel = LogLevel::INFO)
187
+ {
188
+ return function (callable $handler) use ($logger, $formatter, $logLevel) {
189
+ return function ($request, array $options) use ($handler, $logger, $formatter, $logLevel) {
190
+ return $handler($request, $options)->then(
191
+ function ($response) use ($logger, $request, $formatter, $logLevel) {
192
+ $message = $formatter->format($request, $response);
193
+ $logger->log($logLevel, $message);
194
+ return $response;
195
+ },
196
+ function ($reason) use ($logger, $request, $formatter) {
197
+ $response = $reason instanceof RequestException
198
+ ? $reason->getResponse()
199
+ : null;
200
+ $message = $formatter->format($request, $response, $reason);
201
+ $logger->notice($message);
202
+ return \GuzzleHttp\Promise\rejection_for($reason);
203
+ }
204
+ );
205
+ };
206
+ };
207
+ }
208
+
209
+ /**
210
+ * This middleware adds a default content-type if possible, a default
211
+ * content-length or transfer-encoding header, and the expect header.
212
+ *
213
+ * @return callable
214
+ */
215
+ public static function prepareBody()
216
+ {
217
+ return function (callable $handler) {
218
+ return new PrepareBodyMiddleware($handler);
219
+ };
220
+ }
221
+
222
+ /**
223
+ * Middleware that applies a map function to the request before passing to
224
+ * the next handler.
225
+ *
226
+ * @param callable $fn Function that accepts a RequestInterface and returns
227
+ * a RequestInterface.
228
+ * @return callable
229
+ */
230
+ public static function mapRequest(callable $fn)
231
+ {
232
+ return function (callable $handler) use ($fn) {
233
+ return function ($request, array $options) use ($handler, $fn) {
234
+ return $handler($fn($request), $options);
235
+ };
236
+ };
237
+ }
238
+
239
+ /**
240
+ * Middleware that applies a map function to the resolved promise's
241
+ * response.
242
+ *
243
+ * @param callable $fn Function that accepts a ResponseInterface and
244
+ * returns a ResponseInterface.
245
+ * @return callable
246
+ */
247
+ public static function mapResponse(callable $fn)
248
+ {
249
+ return function (callable $handler) use ($fn) {
250
+ return function ($request, array $options) use ($handler, $fn) {
251
+ return $handler($request, $options)->then($fn);
252
+ };
253
+ };
254
+ }
255
+ }
vendor/guzzlehttp/guzzle/src/Pool.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.
10
+ *
11
+ * The pool will read from an iterator until it is cancelled or until the
12
+ * iterator is consumed. When a request is yielded, the request is sent after
13
+ * applying the "request_options" request options (if provided in the ctor).
14
+ *
15
+ * When a function is yielded by the iterator, the function is provided the
16
+ * "request_options" array that should be merged on top of any existing
17
+ * options, and the function MUST then return a wait-able promise.
18
+ */
19
+ class Pool implements PromisorInterface
20
+ {
21
+ /** @var EachPromise */
22
+ private $each;
23
+
24
+ /**
25
+ * @param ClientInterface $client Client used to send the requests.
26
+ * @param array|\Iterator $requests Requests or functions that return
27
+ * requests to send concurrently.
28
+ * @param array $config Associative array of options
29
+ * - concurrency: (int) Maximum number of requests to send concurrently
30
+ * - options: Array of request options to apply to each request.
31
+ * - fulfilled: (callable) Function to invoke when a request completes.
32
+ * - rejected: (callable) Function to invoke when a request is rejected.
33
+ */
34
+ public function __construct(
35
+ ClientInterface $client,
36
+ $requests,
37
+ array $config = []
38
+ ) {
39
+ // Backwards compatibility.
40
+ if (isset($config['pool_size'])) {
41
+ $config['concurrency'] = $config['pool_size'];
42
+ } elseif (!isset($config['concurrency'])) {
43
+ $config['concurrency'] = 25;
44
+ }
45
+
46
+ if (isset($config['options'])) {
47
+ $opts = $config['options'];
48
+ unset($config['options']);
49
+ } else {
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) {
57
+ yield $key => $client->sendAsync($rfn, $opts);
58
+ } elseif (is_callable($rfn)) {
59
+ yield $key => $rfn($opts);
60
+ } else {
61
+ throw new \InvalidArgumentException('Each value yielded by '
62
+ . 'the iterator must be a Psr7\Http\Message\RequestInterface '
63
+ . 'or a callable that returns a promise that fulfills '
64
+ . 'with a Psr7\Message\Http\ResponseInterface object.');
65
+ }
66
+ }
67
+ };
68
+
69
+ $this->each = new EachPromise($requests(), $config);
70
+ }
71
+
72
+ public function promise()
73
+ {
74
+ return $this->each->promise();
75
+ }
76
+
77
+ /**
78
+ * Sends multiple requests concurrently and returns an array of responses
79
+ * and exceptions that uses the same ordering as the provided requests.
80
+ *
81
+ * IMPORTANT: This method keeps every request and response in memory, and
82
+ * as such, is NOT recommended when sending a large number or an
83
+ * indeterminate number of requests concurrently.
84
+ *
85
+ * @param ClientInterface $client Client used to send the requests
86
+ * @param array|\Iterator $requests Requests to send concurrently.
87
+ * @param array $options Passes through the options available in
88
+ * {@see GuzzleHttp\Pool::__construct}
89
+ *
90
+ * @return array Returns an array containing the response or an exception
91
+ * in the same order that the requests were sent.
92
+ * @throws \InvalidArgumentException if the event format is incorrect.
93
+ */
94
+ public static function batch(
95
+ ClientInterface $client,
96
+ $requests,
97
+ array $options = []
98
+ ) {
99
+ $res = [];
100
+ self::cmpCallback($options, 'fulfilled', $res);
101
+ self::cmpCallback($options, 'rejected', $res);
102
+ $pool = new static($client, $requests, $options);
103
+ $pool->promise()->wait();
104
+ ksort($res);
105
+
106
+ return $res;
107
+ }
108
+
109
+ private static function cmpCallback(array &$options, $name, array &$results)
110
+ {
111
+ if (!isset($options[$name])) {
112
+ $options[$name] = function ($v, $k) use (&$results) {
113
+ $results[$k] = $v;
114
+ };
115
+ } else {
116
+ $currentFn = $options[$name];
117
+ $options[$name] = function ($v, $k) use (&$results, $currentFn) {
118
+ $currentFn($v, $k);
119
+ $results[$k] = $v;
120
+ };
121
+ }
122
+ }
123
+ }
vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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,
10
+ * Content-Type, and Expect headers.
11
+ */
12
+ class PrepareBodyMiddleware
13
+ {
14
+ /** @var callable */
15
+ private $nextHandler;
16
+
17
+ /**
18
+ * @param callable $nextHandler Next handler to invoke.
19
+ */
20
+ public function __construct(callable $nextHandler)
21
+ {
22
+ $this->nextHandler = $nextHandler;
23
+ }
24
+
25
+ /**
26
+ * @param RequestInterface $request
27
+ * @param array $options
28
+ *
29
+ * @return PromiseInterface
30
+ */
31
+ public function __invoke(RequestInterface $request, array $options)
32
+ {
33
+ $fn = $this->nextHandler;
34
+
35
+ // Don't do anything if the request has no body.
36
+ if ($request->getBody()->getSize() === 0) {
37
+ return $fn($request, $options);
38
+ }
39
+
40
+ $modify = [];
41
+
42
+ // Add a default content-type if possible.
43
+ if (!$request->hasHeader('Content-Type')) {
44
+ if ($uri = $request->getBody()->getMetadata('uri')) {
45
+ if ($type = Psr7\mimetype_from_filename($uri)) {
46
+ $modify['set_headers']['Content-Type'] = $type;
47
+ }
48
+ }
49
+ }
50
+
51
+ // Add a default content-length or transfer-encoding header.
52
+ if (!$request->hasHeader('Content-Length')
53
+ && !$request->hasHeader('Transfer-Encoding')
54
+ ) {
55
+ $size = $request->getBody()->getSize();
56
+ if ($size !== null) {
57
+ $modify['set_headers']['Content-Length'] = $size;
58
+ } else {
59
+ $modify['set_headers']['Transfer-Encoding'] = 'chunked';
60
+ }
61
+ }
62
+
63
+ // Add the expect header if needed.
64
+ $this->addExpectHeader($request, $options, $modify);
65
+
66
+ return $fn(Psr7\modify_request($request, $modify), $options);
67
+ }
68
+
69
+ private function addExpectHeader(
70
+ RequestInterface $request,
71
+ array $options,
72
+ array &$modify
73
+ ) {
74
+ // Determine if the Expect header should be used
75
+ if ($request->hasHeader('Expect')) {
76
+ return;
77
+ }
78
+
79
+ $expect = isset($options['expect']) ? $options['expect'] : null;
80
+
81
+ // Return if disabled or if you're not using HTTP/1.1 or HTTP/2.0
82
+ if ($expect === false || $request->getProtocolVersion() < 1.1) {
83
+ return;
84
+ }
85
+
86
+ // The expect header is unconditionally enabled
87
+ if ($expect === true) {
88
+ $modify['set_headers']['Expect'] = '100-Continue';
89
+ return;
90
+ }
91
+
92
+ // By default, send the expect header when the payload is > 1mb
93
+ if ($expect === null) {
94
+ $expect = 1048576;
95
+ }
96
+
97
+ // Always add if the body cannot be rewound, the size cannot be
98
+ // determined, or the size is greater than the cutoff threshold
99
+ $body = $request->getBody();
100
+ $size = $body->getSize();
101
+
102
+ if ($size === null || $size >= (int) $expect || !$body->isSeekable()) {
103
+ $modify['set_headers']['Expect'] = '100-Continue';
104
+ }
105
+ }
106
+ }
vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.
14
+ *
15
+ * Apply this middleware like other middleware using
16
+ * {@see GuzzleHttp\Middleware::redirect()}.
17
+ */
18
+ class RedirectMiddleware
19
+ {
20
+ const HISTORY_HEADER = 'X-Guzzle-Redirect-History';
21
+
22
+ const STATUS_HISTORY_HEADER = 'X-Guzzle-Redirect-Status-History';
23
+
24
+ public static $defaultSettings = [
25
+ 'max' => 5,
26
+ 'protocols' => ['http', 'https'],
27
+ 'strict' => false,
28
+ 'referer' => false,
29
+ 'track_redirects' => false,
30
+ ];
31
+
32
+ /** @var callable */
33
+ private $nextHandler;
34
+
35
+ /**
36
+ * @param callable $nextHandler Next handler to invoke.
37
+ */
38
+ public function __construct(callable $nextHandler)
39
+ {
40
+ $this->nextHandler = $nextHandler;
41
+ }
42
+
43
+ /**
44
+ * @param RequestInterface $request
45
+ * @param array $options
46
+ *
47
+ * @return PromiseInterface
48
+ */
49
+ public function __invoke(RequestInterface $request, array $options)
50
+ {
51
+ $fn = $this->nextHandler;
52
+
53
+ if (empty($options['allow_redirects'])) {
54
+ return $fn($request, $options);
55
+ }
56
+
57
+ if ($options['allow_redirects'] === true) {
58
+ $options['allow_redirects'] = self::$defaultSettings;
59
+ } elseif (!is_array($options['allow_redirects'])) {
60
+ throw new \InvalidArgumentException('allow_redirects must be true, false, or array');
61
+ } else {
62
+ // Merge the default settings with the provided settings
63
+ $options['allow_redirects'] += self::$defaultSettings;
64
+ }
65
+
66
+ if (empty($options['allow_redirects']['max'])) {
67
+ return $fn($request, $options);
68
+ }
69
+
70
+ return $fn($request, $options)
71
+ ->then(function (ResponseInterface $response) use ($request, $options) {
72
+ return $this->checkRedirect($request, $options, $response);
73
+ });
74
+ }
75
+
76
+ /**
77
+ * @param RequestInterface $request
78
+ * @param array $options
79
+ * @param ResponseInterface|PromiseInterface $response
80
+ *
81
+ * @return ResponseInterface|PromiseInterface
82
+ */
83
+ public function checkRedirect(
84
+ RequestInterface $request,
85
+ array $options,
86
+ ResponseInterface $response
87
+ ) {
88
+ if (substr($response->getStatusCode(), 0, 1) != '3'
89
+ || !$response->hasHeader('Location')
90
+ ) {
91
+ return $response;
92
+ }
93
+
94
+ $this->guardMax($request, $options);
95
+ $nextRequest = $this->modifyRequest($request, $options, $response);
96
+
97
+ if (isset($options['allow_redirects']['on_redirect'])) {
98
+ call_user_func(
99
+ $options['allow_redirects']['on_redirect'],
100
+ $request,
101
+ $response,
102
+ $nextRequest->getUri()
103
+ );
104
+ }
105
+
106
+ /** @var PromiseInterface|ResponseInterface $promise */
107
+ $promise = $this($nextRequest, $options);
108
+
109
+ // Add headers to be able to track history of redirects.
110
+ if (!empty($options['allow_redirects']['track_redirects'])) {
111
+ return $this->withTracking(
112
+ $promise,
113
+ (string) $nextRequest->getUri(),
114
+ $response->getStatusCode()
115
+ );
116
+ }
117
+
118
+ return $promise;
119
+ }
120
+
121
+ private function withTracking(PromiseInterface $promise, $uri, $statusCode)
122
+ {
123
+ return $promise->then(
124
+ function (ResponseInterface $response) use ($uri, $statusCode) {
125
+ // Note that we are pushing to the front of the list as this
126
+ // would be an earlier response than what is currently present
127
+ // in the history header.
128
+ $historyHeader = $response->getHeader(self::HISTORY_HEADER);
129
+ $statusHeader = $response->getHeader(self::STATUS_HISTORY_HEADER);
130
+ array_unshift($historyHeader, $uri);
131
+ array_unshift($statusHeader, $statusCode);
132
+ return $response->withHeader(self::HISTORY_HEADER, $historyHeader)
133
+ ->withHeader(self::STATUS_HISTORY_HEADER, $statusHeader);
134
+ }
135
+ );
136
+ }
137
+
138
+ private function guardMax(RequestInterface $request, array &$options)
139
+ {
140
+ $current = isset($options['__redirect_count'])
141
+ ? $options['__redirect_count']
142
+ : 0;
143
+ $options['__redirect_count'] = $current + 1;
144
+ $max = $options['allow_redirects']['max'];
145
+
146
+ if ($options['__redirect_count'] > $max) {
147
+ throw new TooManyRedirectsException(
148
+ "Will not follow more than {$max} redirects",
149
+ $request
150
+ );
151
+ }
152
+ }
153
+
154
+ /**
155
+ * @param RequestInterface $request
156
+ * @param array $options
157
+ * @param ResponseInterface $response
158
+ *
159
+ * @return RequestInterface
160
+ */
161
+ public function modifyRequest(
162
+ RequestInterface $request,
163
+ array $options,
164
+ ResponseInterface $response
165
+ ) {
166
+ // Request modifications to apply.
167
+ $modify = [];
168
+ $protocols = $options['allow_redirects']['protocols'];
169
+
170
+ // Use a GET request if this is an entity enclosing request and we are
171
+ // not forcing RFC compliance, but rather emulating what all browsers
172
+ // would do.
173
+ $statusCode = $response->getStatusCode();
174
+ if ($statusCode == 303 ||
175
+ ($statusCode <= 302 && $request->getBody() && !$options['allow_redirects']['strict'])
176
+ ) {
177
+ $modify['method'] = 'GET';
178
+ $modify['body'] = '';
179
+ }
180
+
181
+ $modify['uri'] = $this->redirectUri($request, $response, $protocols);
182
+ Psr7\rewind_body($request);
183
+
184
+ // Add the Referer header if it is told to do so and only
185
+ // add the header if we are not redirecting from https to http.
186
+ if ($options['allow_redirects']['referer']
187
+ && $modify['uri']->getScheme() === $request->getUri()->getScheme()
188
+ ) {
189
+ $uri = $request->getUri()->withUserInfo('', '');
190
+ $modify['set_headers']['Referer'] = (string) $uri;
191
+ } else {
192
+ $modify['remove_headers'][] = 'Referer';
193
+ }
194
+
195
+ // Remove Authorization header if host is different.
196
+ if ($request->getUri()->getHost() !== $modify['uri']->getHost()) {
197
+ $modify['remove_headers'][] = 'Authorization';
198
+ }
199
+
200
+ return Psr7\modify_request($request, $modify);
201
+ }
202
+
203
+ /**
204
+ * Set the appropriate URL on the request based on the location header
205
+ *
206
+ * @param RequestInterface $request
207
+ * @param ResponseInterface $response
208
+ * @param array $protocols
209
+ *
210
+ * @return UriInterface
211
+ */
212
+ private function redirectUri(
213
+ RequestInterface $request,
214
+ ResponseInterface $response,
215
+ array $protocols
216
+ ) {
217
+ $location = Psr7\UriResolver::resolve(
218
+ $request->getUri(),
219
+ new Psr7\Uri($response->getHeaderLine('Location'))
220
+ );
221
+
222
+ // Ensure that the redirect URI is allowed based on the protocols.
223
+ if (!in_array($location->getScheme(), $protocols)) {
224
+ throw new BadResponseException(
225
+ sprintf(
226
+ 'Redirect URI, %s, does not use one of the allowed redirect protocols: %s',
227
+ $location,
228
+ implode(', ', $protocols)
229
+ ),
230
+ $request,
231
+ $response
232
+ );
233
+ }
234
+
235
+ return $location;
236
+ }
237
+ }
vendor/guzzlehttp/guzzle/src/RequestOptions.php ADDED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ /**
5
+ * This class contains a list of built-in Guzzle request options.
6
+ *
7
+ * More documentation for each option can be found at http://guzzlephp.org/.
8
+ *
9
+ * @link http://docs.guzzlephp.org/en/v6/request-options.html
10
+ */
11
+ final class RequestOptions
12
+ {
13
+ /**
14
+ * allow_redirects: (bool|array) Controls redirect behavior. Pass false
15
+ * to disable redirects, pass true to enable redirects, pass an
16
+ * associative to provide custom redirect settings. Defaults to "false".
17
+ * This option only works if your handler has the RedirectMiddleware. When
18
+ * passing an associative array, you can provide the following key value
19
+ * pairs:
20
+ *
21
+ * - max: (int, default=5) maximum number of allowed redirects.
22
+ * - strict: (bool, default=false) Set to true to use strict redirects
23
+ * meaning redirect POST requests with POST requests vs. doing what most
24
+ * browsers do which is redirect POST requests with GET requests
25
+ * - referer: (bool, default=true) Set to false to disable the Referer
26
+ * header.
27
+ * - protocols: (array, default=['http', 'https']) Allowed redirect
28
+ * protocols.
29
+ * - on_redirect: (callable) PHP callable that is invoked when a redirect
30
+ * is encountered. The callable is invoked with the request, the redirect
31
+ * response that was received, and the effective URI. Any return value
32
+ * from the on_redirect function is ignored.
33
+ */
34
+ const ALLOW_REDIRECTS = 'allow_redirects';
35
+
36
+ /**
37
+ * auth: (array) Pass an array of HTTP authentication parameters to use
38
+ * with the request. The array must contain the username in index [0],
39
+ * the password in index [1], and you can optionally provide a built-in
40
+ * authentication type in index [2]. Pass null to disable authentication
41
+ * for a request.
42
+ */
43
+ const AUTH = 'auth';
44
+
45
+ /**
46
+ * body: (resource|string|null|int|float|StreamInterface|callable|\Iterator)
47
+ * Body to send in the request.
48
+ */
49
+ const BODY = 'body';
50
+
51
+ /**
52
+ * cert: (string|array) Set to a string to specify the path to a file
53
+ * containing a PEM formatted SSL client side certificate. If a password
54
+ * is required, then set cert to an array containing the path to the PEM
55
+ * file in the first array element followed by the certificate password
56
+ * in the second array element.
57
+ */
58
+ const CERT = 'cert';
59
+
60
+ /**
61
+ * cookies: (bool|GuzzleHttp\Cookie\CookieJarInterface, default=false)
62
+ * Specifies whether or not cookies are used in a request or what cookie
63
+ * jar to use or what cookies to send. This option only works if your
64
+ * handler has the `cookie` middleware. Valid values are `false` and
65
+ * an instance of {@see GuzzleHttp\Cookie\CookieJarInterface}.
66
+ */
67
+ const COOKIES = 'cookies';
68
+
69
+ /**
70
+ * connect_timeout: (float, default=0) Float describing the number of
71
+ * seconds to wait while trying to connect to a server. Use 0 to wait
72
+ * indefinitely (the default behavior).
73
+ */
74
+ const CONNECT_TIMEOUT = 'connect_timeout';
75
+
76
+ /**
77
+ * debug: (bool|resource) Set to true or set to a PHP stream returned by
78
+ * fopen() enable debug output with the HTTP handler used to send a
79
+ * request.
80
+ */
81
+ const DEBUG = 'debug';
82
+
83
+ /**
84
+ * decode_content: (bool, default=true) Specify whether or not
85
+ * Content-Encoding responses (gzip, deflate, etc.) are automatically
86
+ * decoded.
87
+ */
88
+ const DECODE_CONTENT = 'decode_content';
89
+
90
+ /**
91
+ * delay: (int) The amount of time to delay before sending in milliseconds.
92
+ */
93
+ const DELAY = 'delay';
94
+
95
+ /**
96
+ * expect: (bool|integer) Controls the behavior of the
97
+ * "Expect: 100-Continue" header.
98
+ *
99
+ * Set to `true` to enable the "Expect: 100-Continue" header for all
100
+ * requests that sends a body. Set to `false` to disable the
101
+ * "Expect: 100-Continue" header for all requests. Set to a number so that
102
+ * the size of the payload must be greater than the number in order to send
103
+ * the Expect header. Setting to a number will send the Expect header for
104
+ * all requests in which the size of the payload cannot be determined or
105
+ * where the body is not rewindable.
106
+ *
107
+ * By default, Guzzle will add the "Expect: 100-Continue" header when the
108
+ * size of the body of a request is greater than 1 MB and a request is
109
+ * using HTTP/1.1.
110
+ */
111
+ const EXPECT = 'expect';
112
+
113
+ /**
114
+ * form_params: (array) Associative array of form field names to values
115
+ * where each value is a string or array of strings. Sets the Content-Type
116
+ * header to application/x-www-form-urlencoded when no Content-Type header
117
+ * is already present.
118
+ */
119
+ const FORM_PARAMS = 'form_params';
120
+
121
+ /**
122
+ * headers: (array) Associative array of HTTP headers. Each value MUST be
123
+ * a string or array of strings.
124
+ */
125
+ const HEADERS = 'headers';
126
+
127
+ /**
128
+ * http_errors: (bool, default=true) Set to false to disable exceptions
129
+ * when a non- successful HTTP response is received. By default,
130
+ * exceptions will be thrown for 4xx and 5xx responses. This option only
131
+ * works if your handler has the `httpErrors` middleware.
132
+ */
133
+ const HTTP_ERRORS = 'http_errors';
134
+
135
+ /**
136
+ * json: (mixed) Adds JSON data to a request. The provided value is JSON
137
+ * encoded and a Content-Type header of application/json will be added to
138
+ * the request if no Content-Type header is already present.
139
+ */
140
+ const JSON = 'json';
141
+
142
+ /**
143
+ * multipart: (array) Array of associative arrays, each containing a
144
+ * required "name" key mapping to the form field, name, a required
145
+ * "contents" key mapping to a StreamInterface|resource|string, an
146
+ * optional "headers" associative array of custom headers, and an
147
+ * optional "filename" key mapping to a string to send as the filename in
148
+ * the part. If no "filename" key is present, then no "filename" attribute
149
+ * will be added to the part.
150
+ */
151
+ const MULTIPART = 'multipart';
152
+
153
+ /**
154
+ * on_headers: (callable) A callable that is invoked when the HTTP headers
155
+ * of the response have been received but the body has not yet begun to
156
+ * download.
157
+ */
158
+ const ON_HEADERS = 'on_headers';
159
+
160
+ /**
161
+ * on_stats: (callable) allows you to get access to transfer statistics of
162
+ * a request and access the lower level transfer details of the handler
163
+ * associated with your client. ``on_stats`` is a callable that is invoked
164
+ * when a handler has finished sending a request. The callback is invoked
165
+ * with transfer statistics about the request, the response received, or
166
+ * the error encountered. Included in the data is the total amount of time
167
+ * taken to send the request.
168
+ */
169
+ const ON_STATS = 'on_stats';
170
+
171
+ /**
172
+ * progress: (callable) Defines a function to invoke when transfer
173
+ * progress is made. The function accepts the following positional
174
+ * arguments: the total number of bytes expected to be downloaded, the
175
+ * number of bytes downloaded so far, the number of bytes expected to be
176
+ * uploaded, the number of bytes uploaded so far.
177
+ */
178
+ const PROGRESS = 'progress';
179
+
180
+ /**
181
+ * proxy: (string|array) Pass a string to specify an HTTP proxy, or an
182
+ * array to specify different proxies for different protocols (where the
183
+ * key is the protocol and the value is a proxy string).
184
+ */
185
+ const PROXY = 'proxy';
186
+
187
+ /**
188
+ * query: (array|string) Associative array of query string values to add
189
+ * to the request. This option uses PHP's http_build_query() to create
190
+ * the string representation. Pass a string value if you need more
191
+ * control than what this method provides
192
+ */
193
+ const QUERY = 'query';
194
+
195
+ /**
196
+ * sink: (resource|string|StreamInterface) Where the data of the
197
+ * response is written to. Defaults to a PHP temp stream. Providing a
198
+ * string will write data to a file by the given name.
199
+ */
200
+ const SINK = 'sink';
201
+
202
+ /**
203
+ * synchronous: (bool) Set to true to inform HTTP handlers that you intend
204
+ * on waiting on the response. This can be useful for optimizations. Note
205
+ * that a promise is still returned if you are using one of the async
206
+ * client methods.
207
+ */
208
+ const SYNCHRONOUS = 'synchronous';
209
+
210
+ /**
211
+ * ssl_key: (array|string) Specify the path to a file containing a private
212
+ * SSL key in PEM format. If a password is required, then set to an array
213
+ * containing the path to the SSL key in the first array element followed
214
+ * by the password required for the certificate in the second element.
215
+ */
216
+ const SSL_KEY = 'ssl_key';
217
+
218
+ /**
219
+ * stream: Set to true to attempt to stream a response rather than
220
+ * download it all up-front.
221
+ */
222
+ const STREAM = 'stream';
223
+
224
+ /**
225
+ * verify: (bool|string, default=true) Describes the SSL certificate
226
+ * verification behavior of a request. Set to true to enable SSL
227
+ * certificate verification using the system CA bundle when available
228
+ * (the default). Set to false to disable certificate verification (this
229
+ * is insecure!). Set to a string to provide the path to a CA bundle on
230
+ * disk to enable verification using a custom certificate.
231
+ */
232
+ const VERIFY = 'verify';
233
+
234
+ /**
235
+ * timeout: (float, default=0) Float describing the timeout of the
236
+ * request in seconds. Use 0 to wait indefinitely (the default behavior).
237
+ */
238
+ const TIMEOUT = 'timeout';
239
+
240
+ /**
241
+ * read_timeout: (float, default=default_socket_timeout ini setting) Float describing
242
+ * the body read timeout, for stream requests.
243
+ */
244
+ const READ_TIMEOUT = 'read_timeout';
245
+
246
+ /**
247
+ * version: (float) Specifies the HTTP protocol version to attempt to use.
248
+ */
249
+ const VERSION = 'version';
250
+
251
+ /**
252
+ * force_ip_resolve: (bool) Force client to use only ipv4 or ipv6 protocol
253
+ */
254
+ const FORCE_IP_RESOLVE = 'force_ip_resolve';
255
+ }
vendor/guzzlehttp/guzzle/src/RetryMiddleware.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
12
+ * invoking the provided "decider" function.
13
+ */
14
+ class RetryMiddleware
15
+ {
16
+ /** @var callable */
17
+ private $nextHandler;
18
+
19
+ /** @var callable */
20
+ private $decider;
21
+
22
+ /**
23
+ * @param callable $decider Function that accepts the number of retries,
24
+ * a request, [response], and [exception] and
25
+ * returns true if the request is to be
26
+ * retried.
27
+ * @param callable $nextHandler Next handler to invoke.
28
+ * @param callable $delay Function that accepts the number of retries
29
+ * and [response] and returns the number of
30
+ * milliseconds to delay.
31
+ */
32
+ public function __construct(
33
+ callable $decider,
34
+ callable $nextHandler,
35
+ callable $delay = null
36
+ ) {
37
+ $this->decider = $decider;
38
+ $this->nextHandler = $nextHandler;
39
+ $this->delay = $delay ?: __CLASS__ . '::exponentialDelay';
40
+ }
41
+
42
+ /**
43
+ * Default exponential backoff delay function.
44
+ *
45
+ * @param $retries
46
+ *
47
+ * @return int
48
+ */
49
+ public static function exponentialDelay($retries)
50
+ {
51
+ return (int) pow(2, $retries - 1);
52
+ }
53
+
54
+ /**
55
+ * @param RequestInterface $request
56
+ * @param array $options
57
+ *
58
+ * @return PromiseInterface
59
+ */
60
+ public function __invoke(RequestInterface $request, array $options)
61
+ {
62
+ if (!isset($options['retries'])) {
63
+ $options['retries'] = 0;
64
+ }
65
+
66
+ $fn = $this->nextHandler;
67
+ return $fn($request, $options)
68
+ ->then(
69
+ $this->onFulfilled($request, $options),
70
+ $this->onRejected($request, $options)
71
+ );
72
+ }
73
+
74
+ private function onFulfilled(RequestInterface $req, array $options)
75
+ {
76
+ return function ($value) use ($req, $options) {
77
+ if (!call_user_func(
78
+ $this->decider,
79
+ $options['retries'],
80
+ $req,
81
+ $value,
82
+ null
83
+ )) {
84
+ return $value;
85
+ }
86
+ return $this->doRetry($req, $options, $value);
87
+ };
88
+ }
89
+
90
+ private function onRejected(RequestInterface $req, array $options)
91
+ {
92
+ return function ($reason) use ($req, $options) {
93
+ if (!call_user_func(
94
+ $this->decider,
95
+ $options['retries'],
96
+ $req,
97
+ null,
98
+ $reason
99
+ )) {
100
+ return \GuzzleHttp\Promise\rejection_for($reason);
101
+ }
102
+ return $this->doRetry($req, $options);
103
+ };
104
+ }
105
+
106
+ private function doRetry(RequestInterface $request, array $options, ResponseInterface $response = null)
107
+ {
108
+ $options['delay'] = call_user_func($this->delay, ++$options['retries'], $response);
109
+
110
+ return $this($request, $options);
111
+ }
112
+ }
vendor/guzzlehttp/guzzle/src/TransferStats.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
10
+ * or after a network error.
11
+ */
12
+ final class TransferStats
13
+ {
14
+ private $request;
15
+ private $response;
16
+ private $transferTime;
17
+ private $handlerStats;
18
+ private $handlerErrorData;
19
+
20
+ /**
21
+ * @param RequestInterface $request Request that was sent.
22
+ * @param ResponseInterface $response Response received (if any)
23
+ * @param null $transferTime Total handler transfer time.
24
+ * @param mixed $handlerErrorData Handler error data.
25
+ * @param array $handlerStats Handler specific stats.
26
+ */
27
+ public function __construct(
28
+ RequestInterface $request,
29
+ ResponseInterface $response = null,
30
+ $transferTime = null,
31
+ $handlerErrorData = null,
32
+ $handlerStats = []
33
+ ) {
34
+ $this->request = $request;
35
+ $this->response = $response;
36
+ $this->transferTime = $transferTime;
37
+ $this->handlerErrorData = $handlerErrorData;
38
+ $this->handlerStats = $handlerStats;
39
+ }
40
+
41
+ /**
42
+ * @return RequestInterface
43
+ */
44
+ public function getRequest()
45
+ {
46
+ return $this->request;
47
+ }
48
+
49
+ /**
50
+ * Returns the response that was received (if any).
51
+ *
52
+ * @return ResponseInterface|null
53
+ */
54
+ public function getResponse()
55
+ {
56
+ return $this->response;
57
+ }
58
+
59
+ /**
60
+ * Returns true if a response was received.
61
+ *
62
+ * @return bool
63
+ */
64
+ public function hasResponse()
65
+ {
66
+ return $this->response !== null;
67
+ }
68
+
69
+ /**
70
+ * Gets handler specific error data.
71
+ *
72
+ * This might be an exception, a integer representing an error code, or
73
+ * anything else. Relying on this value assumes that you know what handler
74
+ * you are using.
75
+ *
76
+ * @return mixed
77
+ */
78
+ public function getHandlerErrorData()
79
+ {
80
+ return $this->handlerErrorData;
81
+ }
82
+
83
+ /**
84
+ * Get the effective URI the request was sent to.
85
+ *
86
+ * @return UriInterface
87
+ */
88
+ public function getEffectiveUri()
89
+ {
90
+ return $this->request->getUri();
91
+ }
92
+
93
+ /**
94
+ * Get the estimated time the request was being transferred by the handler.
95
+ *
96
+ * @return float Time in seconds.
97
+ */
98
+ public function getTransferTime()
99
+ {
100
+ return $this->transferTime;
101
+ }
102
+
103
+ /**
104
+ * Gets an array of all of the handler specific transfer data.
105
+ *
106
+ * @return array
107
+ */
108
+ public function getHandlerStats()
109
+ {
110
+ return $this->handlerStats;
111
+ }
112
+
113
+ /**
114
+ * Get a specific handler statistic from the handler by name.
115
+ *
116
+ * @param string $stat Handler specific transfer stat to retrieve.
117
+ *
118
+ * @return mixed|null
119
+ */
120
+ public function getHandlerStat($stat)
121
+ {
122
+ return isset($this->handlerStats[$stat])
123
+ ? $this->handlerStats[$stat]
124
+ : null;
125
+ }
126
+ }
vendor/guzzlehttp/guzzle/src/UriTemplate.php ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ /**
5
+ * Expands URI templates. Userland implementation of PECL uri_template.
6
+ *
7
+ * @link http://tools.ietf.org/html/rfc6570
8
+ */
9
+ class UriTemplate
10
+ {
11
+ /** @var string URI template */
12
+ private $template;
13
+
14
+ /** @var array Variables to use in the template expansion */
15
+ private $variables;
16
+
17
+ /** @var array Hash for quick operator lookups */
18
+ private static $operatorHash = [
19
+ '' => ['prefix' => '', 'joiner' => ',', 'query' => false],
20
+ '+' => ['prefix' => '', 'joiner' => ',', 'query' => false],
21
+ '#' => ['prefix' => '#', 'joiner' => ',', 'query' => false],
22
+ '.' => ['prefix' => '.', 'joiner' => '.', 'query' => false],
23
+ '/' => ['prefix' => '/', 'joiner' => '/', 'query' => false],
24
+ ';' => ['prefix' => ';', 'joiner' => ';', 'query' => true],
25
+ '?' => ['prefix' => '?', 'joiner' => '&', 'query' => true],
26
+ '&' => ['prefix' => '&', 'joiner' => '&', 'query' => true]
27
+ ];
28
+
29
+ /** @var array Delimiters */
30
+ private static $delims = [':', '/', '?', '#', '[', ']', '@', '!', '$',
31
+ '&', '\'', '(', ')', '*', '+', ',', ';', '='];
32
+
33
+ /** @var array Percent encoded delimiters */
34
+ private static $delimsPct = ['%3A', '%2F', '%3F', '%23', '%5B', '%5D',
35
+ '%40', '%21', '%24', '%26', '%27', '%28', '%29', '%2A', '%2B', '%2C',
36
+ '%3B', '%3D'];
37
+
38
+ public function expand($template, array $variables)
39
+ {
40
+ if (false === strpos($template, '{')) {
41
+ return $template;
42
+ }
43
+
44
+ $this->template = $template;
45
+ $this->variables = $variables;
46
+
47
+ return preg_replace_callback(
48
+ '/\{([^\}]+)\}/',
49
+ [$this, 'expandMatch'],
50
+ $this->template
51
+ );
52
+ }
53
+
54
+ /**
55
+ * Parse an expression into parts
56
+ *
57
+ * @param string $expression Expression to parse
58
+ *
59
+ * @return array Returns an associative array of parts
60
+ */
61
+ private function parseExpression($expression)
62
+ {
63
+ $result = [];
64
+
65
+ if (isset(self::$operatorHash[$expression[0]])) {
66
+ $result['operator'] = $expression[0];
67
+ $expression = substr($expression, 1);
68
+ } else {
69
+ $result['operator'] = '';
70
+ }
71
+
72
+ foreach (explode(',', $expression) as $value) {
73
+ $value = trim($value);
74
+ $varspec = [];
75
+ if ($colonPos = strpos($value, ':')) {
76
+ $varspec['value'] = substr($value, 0, $colonPos);
77
+ $varspec['modifier'] = ':';
78
+ $varspec['position'] = (int) substr($value, $colonPos + 1);
79
+ } elseif (substr($value, -1) === '*') {
80
+ $varspec['modifier'] = '*';
81
+ $varspec['value'] = substr($value, 0, -1);
82
+ } else {
83
+ $varspec['value'] = (string) $value;
84
+ $varspec['modifier'] = '';
85
+ }
86
+ $result['values'][] = $varspec;
87
+ }
88
+
89
+ return $result;
90
+ }
91
+
92
+ /**
93
+ * Process an expansion
94
+ *
95
+ * @param array $matches Matches met in the preg_replace_callback
96
+ *
97
+ * @return string Returns the replacement string
98
+ */
99
+ private function expandMatch(array $matches)
100
+ {
101
+ static $rfc1738to3986 = ['+' => '%20', '%7e' => '~'];
102
+
103
+ $replacements = [];
104
+ $parsed = self::parseExpression($matches[1]);
105
+ $prefix = self::$operatorHash[$parsed['operator']]['prefix'];
106
+ $joiner = self::$operatorHash[$parsed['operator']]['joiner'];
107
+ $useQuery = self::$operatorHash[$parsed['operator']]['query'];
108
+
109
+ foreach ($parsed['values'] as $value) {
110
+ if (!isset($this->variables[$value['value']])) {
111
+ continue;
112
+ }
113
+
114
+ $variable = $this->variables[$value['value']];
115
+ $actuallyUseQuery = $useQuery;
116
+ $expanded = '';
117
+
118
+ if (is_array($variable)) {
119
+ $isAssoc = $this->isAssoc($variable);
120
+ $kvp = [];
121
+ foreach ($variable as $key => $var) {
122
+ if ($isAssoc) {
123
+ $key = rawurlencode($key);
124
+ $isNestedArray = is_array($var);
125
+ } else {
126
+ $isNestedArray = false;
127
+ }
128
+
129
+ if (!$isNestedArray) {
130
+ $var = rawurlencode($var);
131
+ if ($parsed['operator'] === '+' ||
132
+ $parsed['operator'] === '#'
133
+ ) {
134
+ $var = $this->decodeReserved($var);
135
+ }
136
+ }
137
+
138
+ if ($value['modifier'] === '*') {
139
+ if ($isAssoc) {
140
+ if ($isNestedArray) {
141
+ // Nested arrays must allow for deeply nested
142
+ // structures.
143
+ $var = strtr(
144
+ http_build_query([$key => $var]),
145
+ $rfc1738to3986
146
+ );
147
+ } else {
148
+ $var = $key . '=' . $var;
149
+ }
150
+ } elseif ($key > 0 && $actuallyUseQuery) {
151
+ $var = $value['value'] . '=' . $var;
152
+ }
153
+ }
154
+
155
+ $kvp[$key] = $var;
156
+ }
157
+
158
+ if (empty($variable)) {
159
+ $actuallyUseQuery = false;
160
+ } elseif ($value['modifier'] === '*') {
161
+ $expanded = implode($joiner, $kvp);
162
+ if ($isAssoc) {
163
+ // Don't prepend the value name when using the explode
164
+ // modifier with an associative array.
165
+ $actuallyUseQuery = false;
166
+ }
167
+ } else {
168
+ if ($isAssoc) {
169
+ // When an associative array is encountered and the
170
+ // explode modifier is not set, then the result must be
171
+ // a comma separated list of keys followed by their
172
+ // respective values.
173
+ foreach ($kvp as $k => &$v) {
174
+ $v = $k . ',' . $v;
175
+ }
176
+ }
177
+ $expanded = implode(',', $kvp);
178
+ }
179
+ } else {
180
+ if ($value['modifier'] === ':') {
181
+ $variable = substr($variable, 0, $value['position']);
182
+ }
183
+ $expanded = rawurlencode($variable);
184
+ if ($parsed['operator'] === '+' || $parsed['operator'] === '#') {
185
+ $expanded = $this->decodeReserved($expanded);
186
+ }
187
+ }
188
+
189
+ if ($actuallyUseQuery) {
190
+ if (!$expanded && $joiner !== '&') {
191
+ $expanded = $value['value'];
192
+ } else {
193
+ $expanded = $value['value'] . '=' . $expanded;
194
+ }
195
+ }
196
+
197
+ $replacements[] = $expanded;
198
+ }
199
+
200
+ $ret = implode($joiner, $replacements);
201
+ if ($ret && $prefix) {
202
+ return $prefix . $ret;
203
+ }
204
+
205
+ return $ret;
206
+ }
207
+
208
+ /**
209
+ * Determines if an array is associative.
210
+ *
211
+ * This makes the assumption that input arrays are sequences or hashes.
212
+ * This assumption is a tradeoff for accuracy in favor of speed, but it
213
+ * should work in almost every case where input is supplied for a URI
214
+ * template.
215
+ *
216
+ * @param array $array Array to check
217
+ *
218
+ * @return bool
219
+ */
220
+ private function isAssoc(array $array)
221
+ {
222
+ return $array && array_keys($array)[0] !== 0;
223
+ }
224
+
225
+ /**
226
+ * Removes percent encoding on reserved characters (used with + and #
227
+ * modifiers).
228
+ *
229
+ * @param string $string String to fix
230
+ *
231
+ * @return string
232
+ */
233
+ private function decodeReserved($string)
234
+ {
235
+ return str_replace(self::$delimsPct, self::$delims, $string);
236
+ }
237
+ }
vendor/guzzlehttp/guzzle/src/functions.php ADDED
@@ -0,0 +1,333 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
11
+ *
12
+ * @param string $template URI template
13
+ * @param array $variables Template variables
14
+ *
15
+ * @return string
16
+ */
17
+ function uri_template($template, array $variables)
18
+ {
19
+ if (extension_loaded('uri_template')) {
20
+ // @codeCoverageIgnoreStart
21
+ return \uri_template($template, $variables);
22
+ // @codeCoverageIgnoreEnd
23
+ }
24
+
25
+ static $uriTemplate;
26
+ if (!$uriTemplate) {
27
+ $uriTemplate = new UriTemplate();
28
+ }
29
+
30
+ return $uriTemplate->expand($template, $variables);
31
+ }
32
+
33
+ /**
34
+ * Debug function used to describe the provided value type and class.
35
+ *
36
+ * @param mixed $input
37
+ *
38
+ * @return string Returns a string containing the type of the variable and
39
+ * if a class is provided, the class name.
40
+ */
41
+ function describe_type($input)
42
+ {
43
+ switch (gettype($input)) {
44
+ case 'object':
45
+ return 'object(' . get_class($input) . ')';
46
+ case 'array':
47
+ return 'array(' . count($input) . ')';
48
+ default:
49
+ ob_start();
50
+ var_dump($input);
51
+ // normalize float vs double
52
+ return str_replace('double(', 'float(', rtrim(ob_get_clean()));
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Parses an array of header lines into an associative array of headers.
58
+ *
59
+ * @param array $lines Header lines array of strings in the following
60
+ * format: "Name: Value"
61
+ * @return array
62
+ */
63
+ function headers_from_lines($lines)
64
+ {
65
+ $headers = [];
66
+
67
+ foreach ($lines as $line) {
68
+ $parts = explode(':', $line, 2);
69
+ $headers[trim($parts[0])][] = isset($parts[1])
70
+ ? trim($parts[1])
71
+ : null;
72
+ }
73
+
74
+ return $headers;
75
+ }
76
+
77
+ /**
78
+ * Returns a debug stream based on the provided variable.
79
+ *
80
+ * @param mixed $value Optional value
81
+ *
82
+ * @return resource
83
+ */
84
+ function debug_resource($value = null)
85
+ {
86
+ if (is_resource($value)) {
87
+ return $value;
88
+ } elseif (defined('STDOUT')) {
89
+ return STDOUT;
90
+ }
91
+
92
+ return fopen('php://output', 'w');
93
+ }
94
+
95
+ /**
96
+ * Chooses and creates a default handler to use based on the environment.
97
+ *
98
+ * The returned handler is not wrapped by any default middlewares.
99
+ *
100
+ * @throws \RuntimeException if no viable Handler is available.
101
+ * @return callable Returns the best handler for the given system.
102
+ */
103
+ function choose_handler()
104
+ {
105
+ $handler = null;
106
+ if (function_exists('curl_multi_exec') && function_exists('curl_exec')) {
107
+ $handler = Proxy::wrapSync(new CurlMultiHandler(), new CurlHandler());
108
+ } elseif (function_exists('curl_exec')) {
109
+ $handler = new CurlHandler();
110
+ } elseif (function_exists('curl_multi_exec')) {
111
+ $handler = new CurlMultiHandler();
112
+ }
113
+
114
+ if (ini_get('allow_url_fopen')) {
115
+ $handler = $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
+
123
+ return $handler;
124
+ }
125
+
126
+ /**
127
+ * Get the default User-Agent string to use with Guzzle
128
+ *
129
+ * @return string
130
+ */
131
+ function default_user_agent()
132
+ {
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
+ }
140
+ $defaultAgent .= ' PHP/' . PHP_VERSION;
141
+ }
142
+
143
+ return $defaultAgent;
144
+ }
145
+
146
+ /**
147
+ * Returns the default cacert bundle for the current system.
148
+ *
149
+ * First, the openssl.cafile and curl.cainfo php.ini settings are checked.
150
+ * If those settings are not configured, then the common locations for
151
+ * bundles found on Red Hat, CentOS, Fedora, Ubuntu, Debian, FreeBSD, OS X
152
+ * and Windows are checked. If any of these file locations are found on
153
+ * disk, they will be utilized.
154
+ *
155
+ * Note: the result of this function is cached for subsequent calls.
156
+ *
157
+ * @return string
158
+ * @throws \RuntimeException if no bundle can be found.
159
+ */
160
+ function default_ca_bundle()
161
+ {
162
+ static $cached = null;
163
+ static $cafiles = [
164
+ // Red Hat, CentOS, Fedora (provided by the ca-certificates package)
165
+ '/etc/pki/tls/certs/ca-bundle.crt',
166
+ // Ubuntu, Debian (provided by the ca-certificates package)
167
+ '/etc/ssl/certs/ca-certificates.crt',
168
+ // FreeBSD (provided by the ca_root_nss package)
169
+ '/usr/local/share/certs/ca-root-nss.crt',
170
+ // SLES 12 (provided by the ca-certificates package)
171
+ '/var/lib/ca-certificates/ca-bundle.pem',
172
+ // OS X provided by homebrew (using the default path)
173
+ '/usr/local/etc/openssl/cert.pem',
174
+ // Google app engine
175
+ '/etc/ca-certificates.crt',
176
+ // Windows?
177
+ 'C:\\windows\\system32\\curl-ca-bundle.crt',
178
+ 'C:\\windows\\curl-ca-bundle.crt',
179
+ ];
180
+
181
+ if ($cached) {
182
+ return $cached;
183
+ }
184
+
185
+ if ($ca = ini_get('openssl.cafile')) {
186
+ return $cached = $ca;
187
+ }
188
+
189
+ if ($ca = ini_get('curl.cainfo')) {
190
+ return $cached = $ca;
191
+ }
192
+
193
+ foreach ($cafiles as $filename) {
194
+ if (file_exists($filename)) {
195
+ return $cached = $filename;
196
+ }
197
+ }
198
+
199
+ throw new \RuntimeException(<<< EOT
200
+ No system CA bundle could be found in any of the the common system locations.
201
+ PHP versions earlier than 5.6 are not properly configured to use the system's
202
+ CA bundle by default. In order to verify peer certificates, you will need to
203
+ supply the path on disk to a certificate bundle to the 'verify' request
204
+ option: http://docs.guzzlephp.org/en/latest/clients.html#verify. If you do not
205
+ need a specific certificate bundle, then Mozilla provides a commonly used CA
206
+ bundle which can be downloaded here (provided by the maintainer of cURL):
207
+ https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt. Once
208
+ you have a CA bundle available on disk, you can set the 'openssl.cafile' PHP
209
+ ini setting to point to the path to the file, allowing you to omit the 'verify'
210
+ request option. See http://curl.haxx.se/docs/sslcerts.html for more
211
+ information.
212
+ EOT
213
+ );
214
+ }
215
+
216
+ /**
217
+ * Creates an associative array of lowercase header names to the actual
218
+ * header casing.
219
+ *
220
+ * @param array $headers
221
+ *
222
+ * @return array
223
+ */
224
+ function normalize_header_keys(array $headers)
225
+ {
226
+ $result = [];
227
+ foreach (array_keys($headers) as $key) {
228
+ $result[strtolower($key)] = $key;
229
+ }
230
+
231
+ return $result;
232
+ }
233
+
234
+ /**
235
+ * Returns true if the provided host matches any of the no proxy areas.
236
+ *
237
+ * This method will strip a port from the host if it is present. Each pattern
238
+ * can be matched with an exact match (e.g., "foo.com" == "foo.com") or a
239
+ * partial match: (e.g., "foo.com" == "baz.foo.com" and ".foo.com" ==
240
+ * "baz.foo.com", but ".foo.com" != "foo.com").
241
+ *
242
+ * Areas are matched in the following cases:
243
+ * 1. "*" (without quotes) always matches any hosts.
244
+ * 2. An exact match.
245
+ * 3. The area starts with "." and the area is the last part of the host. e.g.
246
+ * '.mit.edu' will match any host that ends with '.mit.edu'.
247
+ *
248
+ * @param string $host Host to check against the patterns.
249
+ * @param array $noProxyArray An array of host patterns.
250
+ *
251
+ * @return bool
252
+ */
253
+ function is_host_in_noproxy($host, array $noProxyArray)
254
+ {
255
+ if (strlen($host) === 0) {
256
+ throw new \InvalidArgumentException('Empty host provided');
257
+ }
258
+
259
+ // Strip port if present.
260
+ if (strpos($host, ':')) {
261
+ $host = explode($host, ':', 2)[0];
262
+ }
263
+
264
+ foreach ($noProxyArray as $area) {
265
+ // Always match on wildcards.
266
+ if ($area === '*') {
267
+ return true;
268
+ } elseif (empty($area)) {
269
+ // Don't match on empty values.
270
+ continue;
271
+ } elseif ($area === $host) {
272
+ // Exact matches.
273
+ return true;
274
+ } else {
275
+ // Special match if the area when prefixed with ".". Remove any
276
+ // existing leading "." and add a new leading ".".
277
+ $area = '.' . ltrim($area, '.');
278
+ if (substr($host, -(strlen($area))) === $area) {
279
+ return true;
280
+ }
281
+ }
282
+ }
283
+
284
+ return false;
285
+ }
286
+
287
+ /**
288
+ * Wrapper for json_decode that throws when an error occurs.
289
+ *
290
+ * @param string $json JSON data to parse
291
+ * @param bool $assoc When true, returned objects will be converted
292
+ * into associative arrays.
293
+ * @param int $depth User specified recursion depth.
294
+ * @param int $options Bitmask of JSON decode options.
295
+ *
296
+ * @return mixed
297
+ * @throws \InvalidArgumentException if the JSON cannot be decoded.
298
+ * @link http://www.php.net/manual/en/function.json-decode.php
299
+ */
300
+ function json_decode($json, $assoc = false, $depth = 512, $options = 0)
301
+ {
302
+ $data = \json_decode($json, $assoc, $depth, $options);
303
+ if (JSON_ERROR_NONE !== json_last_error()) {
304
+ throw new \InvalidArgumentException(
305
+ 'json_decode error: ' . json_last_error_msg()
306
+ );
307
+ }
308
+
309
+ return $data;
310
+ }
311
+
312
+ /**
313
+ * Wrapper for JSON encoding that throws when an error occurs.
314
+ *
315
+ * @param mixed $value The value being encoded
316
+ * @param int $options JSON encode option bitmask
317
+ * @param int $depth Set the maximum depth. Must be greater than zero.
318
+ *
319
+ * @return string
320
+ * @throws \InvalidArgumentException if the JSON cannot be encoded.
321
+ * @link http://www.php.net/manual/en/function.json-encode.php
322
+ */
323
+ function json_encode($value, $options = 0, $depth = 512)
324
+ {
325
+ $json = \json_encode($value, $options, $depth);
326
+ if (JSON_ERROR_NONE !== json_last_error()) {
327
+ throw new \InvalidArgumentException(
328
+ 'json_encode error: ' . json_last_error_msg()
329
+ );
330
+ }
331
+
332
+ return $json;
333
+ }
vendor/guzzlehttp/guzzle/src/functions_include.php ADDED
@@ -0,0 +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
+ }
vendor/guzzlehttp/promises/CHANGELOG.md ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CHANGELOG
2
+
3
+
4
+ ## 1.3.1 - 2016-12-20
5
+
6
+ ### Fixed
7
+
8
+ - `wait()` foreign promise compatibility
9
+
10
+
11
+ ## 1.3.0 - 2016-11-18
12
+
13
+ ### Added
14
+
15
+ - Adds support for custom task queues.
16
+
17
+ ### Fixed
18
+
19
+ - Fixed coroutine promise memory leak.
20
+
21
+
22
+ ## 1.2.0 - 2016-05-18
23
+
24
+ ### Changed
25
+
26
+ - Update to now catch `\Throwable` on PHP 7+
27
+
28
+
29
+ ## 1.1.0 - 2016-03-07
30
+
31
+ ### Changed
32
+
33
+ - Update EachPromise to prevent recurring on a iterator when advancing, as this
34
+ could trigger fatal generator errors.
35
+ - Update Promise to allow recursive waiting without unwrapping exceptions.
36
+
37
+
38
+ ## 1.0.3 - 2015-10-15
39
+
40
+ ### Changed
41
+
42
+ - Update EachPromise to immediately resolve when the underlying promise iterator
43
+ is empty. Previously, such a promise would throw an exception when its `wait`
44
+ function was called.
45
+
46
+
47
+ ## 1.0.2 - 2015-05-15
48
+
49
+ ### Changed
50
+
51
+ - Conditionally require functions.php.
52
+
53
+
54
+ ## 1.0.1 - 2015-06-24
55
+
56
+ ### Changed
57
+
58
+ - Updating EachPromise to call next on the underlying promise iterator as late
59
+ as possible to ensure that generators that generate new requests based on
60
+ callbacks are not iterated until after callbacks are invoked.
61
+
62
+
63
+ ## 1.0.0 - 2015-05-12
64
+
65
+ - Initial release
vendor/guzzlehttp/promises/LICENSE ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2015-2016 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
vendor/guzzlehttp/promises/Makefile ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ all: clean test
2
+
3
+ test:
4
+ vendor/bin/phpunit
5
+
6
+ coverage:
7
+ vendor/bin/phpunit --coverage-html=artifacts/coverage
8
+
9
+ view-coverage:
10
+ open artifacts/coverage/index.html
11
+
12
+ clean:
13
+ rm -rf artifacts/*
vendor/guzzlehttp/promises/README.md ADDED
@@ -0,0 +1,504 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Guzzle Promises
2
+
3
+ [Promises/A+](https://promisesaplus.com/) implementation that handles promise
4
+ chaining and resolution iteratively, allowing for "infinite" promise chaining
5
+ while keeping the stack size constant. Read [this blog post](https://blog.domenic.me/youre-missing-the-point-of-promises/)
6
+ for a general introduction to promises.
7
+
8
+ - [Features](#features)
9
+ - [Quick start](#quick-start)
10
+ - [Synchronous wait](#synchronous-wait)
11
+ - [Cancellation](#cancellation)
12
+ - [API](#api)
13
+ - [Promise](#promise)
14
+ - [FulfilledPromise](#fulfilledpromise)
15
+ - [RejectedPromise](#rejectedpromise)
16
+ - [Promise interop](#promise-interop)
17
+ - [Implementation notes](#implementation-notes)
18
+
19
+
20
+ # Features
21
+
22
+ - [Promises/A+](https://promisesaplus.com/) implementation.
23
+ - Promise resolution and chaining is handled iteratively, allowing for
24
+ "infinite" promise chaining.
25
+ - Promises have a synchronous `wait` method.
26
+ - Promises can be cancelled.
27
+ - Works with any object that has a `then` function.
28
+ - C# style async/await coroutine promises using
29
+ `GuzzleHttp\Promise\coroutine()`.
30
+
31
+
32
+ # Quick start
33
+
34
+ A *promise* represents the eventual result of an asynchronous operation. The
35
+ primary way of interacting with a promise is through its `then` method, which
36
+ registers callbacks to receive either a promise's eventual value or the reason
37
+ why the promise cannot be fulfilled.
38
+
39
+
40
+ ## Callbacks
41
+
42
+ Callbacks are registered with the `then` method by providing an optional
43
+ `$onFulfilled` followed by an optional `$onRejected` function.
44
+
45
+
46
+ ```php
47
+ use GuzzleHttp\Promise\Promise;
48
+
49
+ $promise = new Promise();
50
+ $promise->then(
51
+ // $onFulfilled
52
+ function ($value) {
53
+ echo 'The promise was fulfilled.';
54
+ },
55
+ // $onRejected
56
+ function ($reason) {
57
+ echo 'The promise was rejected.';
58
+ }
59
+ );
60
+ ```
61
+
62
+ *Resolving* a promise means that you either fulfill a promise with a *value* or
63
+ reject a promise with a *reason*. Resolving a promises triggers callbacks
64
+ registered with the promises's `then` method. These callbacks are triggered
65
+ only once and in the order in which they were added.
66
+
67
+
68
+ ## Resolving a promise
69
+
70
+ Promises are fulfilled using the `resolve($value)` method. Resolving a promise
71
+ with any value other than a `GuzzleHttp\Promise\RejectedPromise` will trigger
72
+ all of the onFulfilled callbacks (resolving a promise with a rejected promise
73
+ will reject the promise and trigger the `$onRejected` callbacks).
74
+
75
+ ```php
76
+ use GuzzleHttp\Promise\Promise;
77
+
78
+ $promise = new Promise();
79
+ $promise
80
+ ->then(function ($value) {
81
+ // Return a value and don't break the chain
82
+ return "Hello, " . $value;
83
+ })
84
+ // This then is executed after the first then and receives the value
85
+ // returned from the first then.
86
+ ->then(function ($value) {
87
+ echo $value;
88
+ });
89
+
90
+ // Resolving the promise triggers the $onFulfilled callbacks and outputs
91
+ // "Hello, reader".
92
+ $promise->resolve('reader.');
93
+ ```
94
+
95
+
96
+ ## Promise forwarding
97
+
98
+ Promises can be chained one after the other. Each then in the chain is a new
99
+ promise. The return value of a promise is what's forwarded to the next
100
+ promise in the chain. Returning a promise in a `then` callback will cause the
101
+ subsequent promises in the chain to only be fulfilled when the returned promise
102
+ has been fulfilled. The next promise in the chain will be invoked with the
103
+ resolved value of the promise.
104
+
105
+ ```php
106
+ use GuzzleHttp\Promise\Promise;
107
+
108
+ $promise = new Promise();
109
+ $nextPromise = new Promise();
110
+
111
+ $promise
112
+ ->then(function ($value) use ($nextPromise) {
113
+ echo $value;
114
+ return $nextPromise;
115
+ })
116
+ ->then(function ($value) {
117
+ echo $value;
118
+ });
119
+
120
+ // Triggers the first callback and outputs "A"
121
+ $promise->resolve('A');
122
+ // Triggers the second callback and outputs "B"
123
+ $nextPromise->resolve('B');
124
+ ```
125
+
126
+ ## Promise rejection
127
+
128
+ When a promise is rejected, the `$onRejected` callbacks are invoked with the
129
+ rejection reason.
130
+
131
+ ```php
132
+ use GuzzleHttp\Promise\Promise;
133
+
134
+ $promise = new Promise();
135
+ $promise->then(null, function ($reason) {
136
+ echo $reason;
137
+ });
138
+
139
+ $promise->reject('Error!');
140
+ // Outputs "Error!"
141
+ ```
142
+
143
+ ## Rejection forwarding
144
+
145
+ If an exception is thrown in an `$onRejected` callback, subsequent
146
+ `$onRejected` callbacks are invoked with the thrown exception as the reason.
147
+
148
+ ```php
149
+ use GuzzleHttp\Promise\Promise;
150
+
151
+ $promise = new Promise();
152
+ $promise->then(null, function ($reason) {
153
+ throw new \Exception($reason);
154
+ })->then(null, function ($reason) {
155
+ assert($reason->getMessage() === 'Error!');
156
+ });
157
+
158
+ $promise->reject('Error!');
159
+ ```
160
+
161
+ You can also forward a rejection down the promise chain by returning a
162
+ `GuzzleHttp\Promise\RejectedPromise` in either an `$onFulfilled` or
163
+ `$onRejected` callback.
164
+
165
+ ```php
166
+ use GuzzleHttp\Promise\Promise;
167
+ use GuzzleHttp\Promise\RejectedPromise;
168
+
169
+ $promise = new Promise();
170
+ $promise->then(null, function ($reason) {
171
+ return new RejectedPromise($reason);
172
+ })->then(null, function ($reason) {
173
+ assert($reason === 'Error!');
174
+ });
175
+
176
+ $promise->reject('Error!');
177
+ ```
178
+
179
+ If an exception is not thrown in a `$onRejected` callback and the callback
180
+ does not return a rejected promise, downstream `$onFulfilled` callbacks are
181
+ invoked using the value returned from the `$onRejected` callback.
182
+
183
+ ```php
184
+ use GuzzleHttp\Promise\Promise;
185
+ use GuzzleHttp\Promise\RejectedPromise;
186
+
187
+ $promise = new Promise();
188
+ $promise
189
+ ->then(null, function ($reason) {
190
+ return "It's ok";
191
+ })
192
+ ->then(function ($value) {
193
+ assert($value === "It's ok");
194
+ });
195
+
196
+ $promise->reject('Error!');
197
+ ```
198
+
199
+ # Synchronous wait
200
+
201
+ You can synchronously force promises to complete using a promise's `wait`
202
+ method. When creating a promise, you can provide a wait function that is used
203
+ to synchronously force a promise to complete. When a wait function is invoked
204
+ it is expected to deliver a value to the promise or reject the promise. If the
205
+ wait function does not deliver a value, then an exception is thrown. The wait
206
+ function provided to a promise constructor is invoked when the `wait` function
207
+ of the promise is called.
208
+
209
+ ```php
210
+ $promise = new Promise(function () use (&$promise) {
211
+ $promise->resolve('foo');
212
+ });
213
+
214
+ // Calling wait will return the value of the promise.
215
+ echo $promise->wait(); // outputs "foo"
216
+ ```
217
+
218
+ If an exception is encountered while invoking the wait function of a promise,
219
+ the promise is rejected with the exception and the exception is thrown.
220
+
221
+ ```php
222
+ $promise = new Promise(function () use (&$promise) {
223
+ throw new \Exception('foo');
224
+ });
225
+
226
+ $promise->wait(); // throws the exception.
227
+ ```
228
+
229
+ Calling `wait` on a promise that has been fulfilled will not trigger the wait
230
+ function. It will simply return the previously resolved value.
231
+
232
+ ```php
233
+ $promise = new Promise(function () { die('this is not called!'); });
234
+ $promise->resolve('foo');
235
+ echo $promise->wait(); // outputs "foo"
236
+ ```
237
+
238
+ Calling `wait` on a promise that has been rejected will throw an exception. If
239
+ the rejection reason is an instance of `\Exception` the reason is thrown.
240
+ Otherwise, a `GuzzleHttp\Promise\RejectionException` is thrown and the reason
241
+ can be obtained by calling the `getReason` method of the exception.
242
+
243
+ ```php
244
+ $promise = new Promise();
245
+ $promise->reject('foo');
246
+ $promise->wait();
247
+ ```
248
+
249
+ > PHP Fatal error: Uncaught exception 'GuzzleHttp\Promise\RejectionException' with message 'The promise was rejected with value: foo'
250
+
251
+
252
+ ## Unwrapping a promise
253
+
254
+ When synchronously waiting on a promise, you are joining the state of the
255
+ promise into the current state of execution (i.e., return the value of the
256
+ promise if it was fulfilled or throw an exception if it was rejected). This is
257
+ called "unwrapping" the promise. Waiting on a promise will by default unwrap
258
+ the promise state.
259
+
260
+ You can force a promise to resolve and *not* unwrap the state of the promise
261
+ by passing `false` to the first argument of the `wait` function:
262
+
263
+ ```php
264
+ $promise = new Promise();
265
+ $promise->reject('foo');
266
+ // This will not throw an exception. It simply ensures the promise has
267
+ // been resolved.
268
+ $promise->wait(false);
269
+ ```
270
+
271
+ When unwrapping a promise, the resolved value of the promise will be waited
272
+ upon until the unwrapped value is not a promise. This means that if you resolve
273
+ promise A with a promise B and unwrap promise A, the value returned by the
274
+ wait function will be the value delivered to promise B.
275
+
276
+ **Note**: when you do not unwrap the promise, no value is returned.
277
+
278
+
279
+ # Cancellation
280
+
281
+ You can cancel a promise that has not yet been fulfilled using the `cancel()`
282
+ method of a promise. When creating a promise you can provide an optional
283
+ cancel function that when invoked cancels the action of computing a resolution
284
+ of the promise.
285
+
286
+
287
+ # API
288
+
289
+
290
+ ## Promise
291
+
292
+ When creating a promise object, you can provide an optional `$waitFn` and
293
+ `$cancelFn`. `$waitFn` is a function that is invoked with no arguments and is
294
+ expected to resolve the promise. `$cancelFn` is a function with no arguments
295
+ that is expected to cancel the computation of a promise. It is invoked when the
296
+ `cancel()` method of a promise is called.
297
+
298
+ ```php
299
+ use GuzzleHttp\Promise\Promise;
300
+
301
+ $promise = new Promise(
302
+ function () use (&$promise) {
303
+ $promise->resolve('waited');
304
+ },
305
+ function () {
306
+ // do something that will cancel the promise computation (e.g., close
307
+ // a socket, cancel a database query, etc...)
308
+ }
309
+ );
310
+
311
+ assert('waited' === $promise->wait());
312
+ ```
313
+
314
+ A promise has the following methods:
315
+
316
+ - `then(callable $onFulfilled, callable $onRejected) : PromiseInterface`
317
+
318
+ Appends fulfillment and rejection handlers to the promise, and returns a new promise resolving to the return value of the called handler.
319
+
320
+ - `otherwise(callable $onRejected) : PromiseInterface`
321
+
322
+ Appends a rejection handler callback to the promise, and returns a new promise resolving to the return value of the callback if it is called, or to its original fulfillment value if the promise is instead fulfilled.
323
+
324
+ - `wait($unwrap = true) : mixed`
325
+
326
+ Synchronously waits on the promise to complete.
327
+
328
+ `$unwrap` controls whether or not the value of the promise is returned for a
329
+ fulfilled promise or if an exception is thrown if the promise is rejected.
330
+ This is set to `true` by default.
331
+
332
+ - `cancel()`
333
+
334
+ Attempts to cancel the promise if possible. The promise being cancelled and
335
+ the parent most ancestor that has not yet been resolved will also be
336
+ cancelled. Any promises waiting on the cancelled promise to resolve will also
337
+ be cancelled.
338
+
339
+ - `getState() : string`
340
+
341
+ Returns the state of the promise. One of `pending`, `fulfilled`, or
342
+ `rejected`.
343
+
344
+ - `resolve($value)`
345
+
346
+ Fulfills the promise with the given `$value`.
347
+
348
+ - `reject($reason)`
349
+
350
+ Rejects the promise with the given `$reason`.
351
+
352
+
353
+ ## FulfilledPromise
354
+
355
+ A fulfilled promise can be created to represent a promise that has been
356
+ fulfilled.
357
+
358
+ ```php
359
+ use GuzzleHttp\Promise\FulfilledPromise;
360
+
361
+ $promise = new FulfilledPromise('value');
362
+
363
+ // Fulfilled callbacks are immediately invoked.
364
+ $promise->then(function ($value) {
365
+ echo $value;
366
+ });
367
+ ```
368
+
369
+
370
+ ## RejectedPromise
371
+
372
+ A rejected promise can be created to represent a promise that has been
373
+ rejected.
374
+
375
+ ```php
376
+ use GuzzleHttp\Promise\RejectedPromise;
377
+
378
+ $promise = new RejectedPromise('Error');
379
+
380
+ // Rejected callbacks are immediately invoked.
381
+ $promise->then(null, function ($reason) {
382
+ echo $reason;
383
+ });
384
+ ```
385
+
386
+
387
+ # Promise interop
388
+
389
+ This library works with foreign promises that have a `then` method. This means
390
+ you can use Guzzle promises with [React promises](https://github.com/reactphp/promise)
391
+ for example. When a foreign promise is returned inside of a then method
392
+ callback, promise resolution will occur recursively.
393
+
394
+ ```php
395
+ // Create a React promise
396
+ $deferred = new React\Promise\Deferred();
397
+ $reactPromise = $deferred->promise();
398
+
399
+ // Create a Guzzle promise that is fulfilled with a React promise.
400
+ $guzzlePromise = new \GuzzleHttp\Promise\Promise();
401
+ $guzzlePromise->then(function ($value) use ($reactPromise) {
402
+ // Do something something with the value...
403
+ // Return the React promise
404
+ return $reactPromise;
405
+ });
406
+ ```
407
+
408
+ Please note that wait and cancel chaining is no longer possible when forwarding
409
+ a foreign promise. You will need to wrap a third-party promise with a Guzzle
410
+ promise in order to utilize wait and cancel functions with foreign promises.
411
+
412
+
413
+ ## Event Loop Integration
414
+
415
+ In order to keep the stack size constant, Guzzle promises are resolved
416
+ asynchronously using a task queue. When waiting on promises synchronously, the
417
+ task queue will be automatically run to ensure that the blocking promise and
418
+ any forwarded promises are resolved. When using promises asynchronously in an
419
+ event loop, you will need to run the task queue on each tick of the loop. If
420
+ you do not run the task queue, then promises will not be resolved.
421
+
422
+ You can run the task queue using the `run()` method of the global task queue
423
+ instance.
424
+
425
+ ```php
426
+ // Get the global task queue
427
+ $queue = \GuzzleHttp\Promise\queue();
428
+ $queue->run();
429
+ ```
430
+
431
+ For example, you could use Guzzle promises with React using a periodic timer:
432
+
433
+ ```php
434
+ $loop = React\EventLoop\Factory::create();
435
+ $loop->addPeriodicTimer(0, [$queue, 'run']);
436
+ ```
437
+
438
+ *TODO*: Perhaps adding a `futureTick()` on each tick would be faster?
439
+
440
+
441
+ # Implementation notes
442
+
443
+
444
+ ## Promise resolution and chaining is handled iteratively
445
+
446
+ By shuffling pending handlers from one owner to another, promises are
447
+ resolved iteratively, allowing for "infinite" then chaining.
448
+
449
+ ```php
450
+ <?php
451
+ require 'vendor/autoload.php';
452
+
453
+ use GuzzleHttp\Promise\Promise;
454
+
455
+ $parent = new Promise();
456
+ $p = $parent;
457
+
458
+ for ($i = 0; $i < 1000; $i++) {
459
+ $p = $p->then(function ($v) {
460
+ // The stack size remains constant (a good thing)
461
+ echo xdebug_get_stack_depth() . ', ';
462
+ return $v + 1;
463
+ });
464
+ }
465
+
466
+ $parent->resolve(0);
467
+ var_dump($p->wait()); // int(1000)
468
+
469
+ ```
470
+
471
+ When a promise is fulfilled or rejected with a non-promise value, the promise
472
+ then takes ownership of the handlers of each child promise and delivers values
473
+ down the chain without using recursion.
474
+
475
+ When a promise is resolved with another promise, the original promise transfers
476
+ all of its pending handlers to the new promise. When the new promise is
477
+ eventually resolved, all of the pending handlers are delivered the forwarded
478
+ value.
479
+
480
+
481
+ ## A promise is the deferred.
482
+
483
+ Some promise libraries implement promises using a deferred object to represent
484
+ a computation and a promise object to represent the delivery of the result of
485
+ the computation. This is a nice separation of computation and delivery because
486
+ consumers of the promise cannot modify the value that will be eventually
487
+ delivered.
488
+
489
+ One side effect of being able to implement promise resolution and chaining
490
+ iteratively is that you need to be able for one promise to reach into the state
491
+ of another promise to shuffle around ownership of handlers. In order to achieve
492
+ this without making the handlers of a promise publicly mutable, a promise is
493
+ also the deferred value, allowing promises of the same parent class to reach
494
+ into and modify the private properties of promises of the same type. While this
495
+ does allow consumers of the value to modify the resolution or rejection of the
496
+ deferred, it is a small price to pay for keeping the stack size constant.
497
+
498
+ ```php
499
+ $promise = new Promise();
500
+ $promise->then(function ($value) { echo $value; });
501
+ // The promise is the deferred value, so you can deliver a value to it.
502
+ $promise->resolve('foo');
503
+ // prints "foo"
504
+ ```
vendor/guzzlehttp/promises/composer.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "guzzlehttp/promises",
3
+ "description": "Guzzle promises library",
4
+ "keywords": ["promise"],
5
+ "license": "MIT",
6
+ "authors": [
7
+ {
8
+ "name": "Michael Dowling",
9
+ "email": "mtdowling@gmail.com",
10
+ "homepage": "https://github.com/mtdowling"
11
+ }
12
+ ],
13
+ "require": {
14
+ "php": ">=5.5.0"
15
+ },
16
+ "require-dev": {
17
+ "phpunit/phpunit": "^4.0"
18
+ },
19
+ "autoload": {
20
+ "psr-4": {
21
+ "GuzzleHttp\\Promise\\": "src/"
22
+ },
23
+ "files": ["src/functions_include.php"]
24
+ },
25
+ "scripts": {
26
+ "test": "vendor/bin/phpunit",
27
+ "test-ci": "vendor/bin/phpunit --coverage-text"
28
+ },
29
+ "extra": {
30
+ "branch-alias": {
31
+ "dev-master": "1.4-dev"
32
+ }
33
+ }
34
+ }
vendor/guzzlehttp/promises/src/AggregateException.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * Exception thrown when too many errors occur in the some() or any() methods.
6
+ */
7
+ class AggregateException extends RejectionException
8
+ {
9
+ public function __construct($msg, array $reasons)
10
+ {
11
+ parent::__construct(
12
+ $reasons,
13
+ sprintf('%s; %d rejected promises', $msg, count($reasons))
14
+ );
15
+ }
16
+ }
vendor/guzzlehttp/promises/src/CancellationException.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * Exception that is set as the reason for a promise that has been cancelled.
6
+ */
7
+ class CancellationException extends RejectionException
8
+ {
9
+ }
vendor/guzzlehttp/promises/src/Coroutine.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ use Exception;
5
+ use Generator;
6
+ use Throwable;
7
+
8
+ /**
9
+ * Creates a promise that is resolved using a generator that yields values or
10
+ * promises (somewhat similar to C#'s async keyword).
11
+ *
12
+ * When called, the coroutine function will start an instance of the generator
13
+ * and returns a promise that is fulfilled with its final yielded value.
14
+ *
15
+ * Control is returned back to the generator when the yielded promise settles.
16
+ * This can lead to less verbose code when doing lots of sequential async calls
17
+ * with minimal processing in between.
18
+ *
19
+ * use GuzzleHttp\Promise;
20
+ *
21
+ * function createPromise($value) {
22
+ * return new Promise\FulfilledPromise($value);
23
+ * }
24
+ *
25
+ * $promise = Promise\coroutine(function () {
26
+ * $value = (yield createPromise('a'));
27
+ * try {
28
+ * $value = (yield createPromise($value . 'b'));
29
+ * } catch (\Exception $e) {
30
+ * // The promise was rejected.
31
+ * }
32
+ * yield $value . 'c';
33
+ * });
34
+ *
35
+ * // Outputs "abc"
36
+ * $promise->then(function ($v) { echo $v; });
37
+ *
38
+ * @param callable $generatorFn Generator function to wrap into a promise.
39
+ *
40
+ * @return Promise
41
+ * @link https://github.com/petkaantonov/bluebird/blob/master/API.md#generators inspiration
42
+ */
43
+ final class Coroutine implements PromiseInterface
44
+ {
45
+ /**
46
+ * @var PromiseInterface|null
47
+ */
48
+ private $currentPromise;
49
+
50
+ /**
51
+ * @var Generator
52
+ */
53
+ private $generator;
54
+
55
+ /**
56
+ * @var Promise
57
+ */
58
+ private $result;
59
+
60
+ public function __construct(callable $generatorFn)
61
+ {
62
+ $this->generator = $generatorFn();
63
+ $this->result = new Promise(function () {
64
+ while (isset($this->currentPromise)) {
65
+ $this->currentPromise->wait();
66
+ }
67
+ });
68
+ $this->nextCoroutine($this->generator->current());
69
+ }
70
+
71
+ public function then(
72
+ callable $onFulfilled = null,
73
+ callable $onRejected = null
74
+ ) {
75
+ return $this->result->then($onFulfilled, $onRejected);
76
+ }
77
+
78
+ public function otherwise(callable $onRejected)
79
+ {
80
+ return $this->result->otherwise($onRejected);
81
+ }
82
+
83
+ public function wait($unwrap = true)
84
+ {
85
+ return $this->result->wait($unwrap);
86
+ }
87
+
88
+ public function getState()
89
+ {
90
+ return $this->result->getState();
91
+ }
92
+
93
+ public function resolve($value)
94
+ {
95
+ $this->result->resolve($value);
96
+ }
97
+
98
+ public function reject($reason)
99
+ {
100
+ $this->result->reject($reason);
101
+ }
102
+
103
+ public function cancel()
104
+ {
105
+ $this->currentPromise->cancel();
106
+ $this->result->cancel();
107
+ }
108
+
109
+ private function nextCoroutine($yielded)
110
+ {
111
+ $this->currentPromise = promise_for($yielded)
112
+ ->then([$this, '_handleSuccess'], [$this, '_handleFailure']);
113
+ }
114
+
115
+ /**
116
+ * @internal
117
+ */
118
+ public function _handleSuccess($value)
119
+ {
120
+ unset($this->currentPromise);
121
+ try {
122
+ $next = $this->generator->send($value);
123
+ if ($this->generator->valid()) {
124
+ $this->nextCoroutine($next);
125
+ } else {
126
+ $this->result->resolve($value);
127
+ }
128
+ } catch (Exception $exception) {
129
+ $this->result->reject($exception);
130
+ } catch (Throwable $throwable) {
131
+ $this->result->reject($throwable);
132
+ }
133
+ }
134
+
135
+ /**
136
+ * @internal
137
+ */
138
+ public function _handleFailure($reason)
139
+ {
140
+ unset($this->currentPromise);
141
+ try {
142
+ $nextYield = $this->generator->throw(exception_for($reason));
143
+ // The throw was caught, so keep iterating on the coroutine
144
+ $this->nextCoroutine($nextYield);
145
+ } catch (Exception $exception) {
146
+ $this->result->reject($exception);
147
+ } catch (Throwable $throwable) {
148
+ $this->result->reject($throwable);
149
+ }
150
+ }
151
+ }
vendor/guzzlehttp/promises/src/EachPromise.php ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * Represents a promise that iterates over many promises and invokes
6
+ * side-effect functions in the process.
7
+ */
8
+ class EachPromise implements PromisorInterface
9
+ {
10
+ private $pending = [];
11
+
12
+ /** @var \Iterator */
13
+ private $iterable;
14
+
15
+ /** @var callable|int */
16
+ private $concurrency;
17
+
18
+ /** @var callable */
19
+ private $onFulfilled;
20
+
21
+ /** @var callable */
22
+ private $onRejected;
23
+
24
+ /** @var Promise */
25
+ private $aggregate;
26
+
27
+ /** @var bool */
28
+ private $mutex;
29
+
30
+ /**
31
+ * Configuration hash can include the following key value pairs:
32
+ *
33
+ * - fulfilled: (callable) Invoked when a promise fulfills. The function
34
+ * is invoked with three arguments: the fulfillment value, the index
35
+ * position from the iterable list of the promise, and the aggregate
36
+ * promise that manages all of the promises. The aggregate promise may
37
+ * be resolved from within the callback to short-circuit the promise.
38
+ * - rejected: (callable) Invoked when a promise is rejected. The
39
+ * function is invoked with three arguments: the rejection reason, the
40
+ * index position from the iterable list of the promise, and the
41
+ * aggregate promise that manages all of the promises. The aggregate
42
+ * promise may be resolved from within the callback to short-circuit
43
+ * the promise.
44
+ * - concurrency: (integer) Pass this configuration option to limit the
45
+ * allowed number of outstanding concurrently executing promises,
46
+ * creating a capped pool of promises. There is no limit by default.
47
+ *
48
+ * @param mixed $iterable Promises or values to iterate.
49
+ * @param array $config Configuration options
50
+ */
51
+ public function __construct($iterable, array $config = [])
52
+ {
53
+ $this->iterable = iter_for($iterable);
54
+
55
+ if (isset($config['concurrency'])) {
56
+ $this->concurrency = $config['concurrency'];
57
+ }
58
+
59
+ if (isset($config['fulfilled'])) {
60
+ $this->onFulfilled = $config['fulfilled'];
61
+ }
62
+
63
+ if (isset($config['rejected'])) {
64
+ $this->onRejected = $config['rejected'];
65
+ }
66
+ }
67
+
68
+ public function promise()
69
+ {
70
+ if ($this->aggregate) {
71
+ return $this->aggregate;
72
+ }
73
+
74
+ try {
75
+ $this->createPromise();
76
+ $this->iterable->rewind();
77
+ $this->refillPending();
78
+ } catch (\Throwable $e) {
79
+ $this->aggregate->reject($e);
80
+ } catch (\Exception $e) {
81
+ $this->aggregate->reject($e);
82
+ }
83
+
84
+ return $this->aggregate;
85
+ }
86
+
87
+ private function createPromise()
88
+ {
89
+ $this->mutex = false;
90
+ $this->aggregate = new Promise(function () {
91
+ reset($this->pending);
92
+ if (empty($this->pending) && !$this->iterable->valid()) {
93
+ $this->aggregate->resolve(null);
94
+ return;
95
+ }
96
+
97
+ // Consume a potentially fluctuating list of promises while
98
+ // ensuring that indexes are maintained (precluding array_shift).
99
+ while ($promise = current($this->pending)) {
100
+ next($this->pending);
101
+ $promise->wait();
102
+ if ($this->aggregate->getState() !== PromiseInterface::PENDING) {
103
+ return;
104
+ }
105
+ }
106
+ });
107
+
108
+ // Clear the references when the promise is resolved.
109
+ $clearFn = function () {
110
+ $this->iterable = $this->concurrency = $this->pending = null;
111
+ $this->onFulfilled = $this->onRejected = null;
112
+ };
113
+
114
+ $this->aggregate->then($clearFn, $clearFn);
115
+ }
116
+
117
+ private function refillPending()
118
+ {
119
+ if (!$this->concurrency) {
120
+ // Add all pending promises.
121
+ while ($this->addPending() && $this->advanceIterator());
122
+ return;
123
+ }
124
+
125
+ // Add only up to N pending promises.
126
+ $concurrency = is_callable($this->concurrency)
127
+ ? call_user_func($this->concurrency, count($this->pending))
128
+ : $this->concurrency;
129
+ $concurrency = max($concurrency - count($this->pending), 0);
130
+ // Concurrency may be set to 0 to disallow new promises.
131
+ if (!$concurrency) {
132
+ return;
133
+ }
134
+ // Add the first pending promise.
135
+ $this->addPending();
136
+ // Note this is special handling for concurrency=1 so that we do
137
+ // not advance the iterator after adding the first promise. This
138
+ // helps work around issues with generators that might not have the
139
+ // next value to yield until promise callbacks are called.
140
+ while (--$concurrency
141
+ && $this->advanceIterator()
142
+ && $this->addPending());
143
+ }
144
+
145
+ private function addPending()
146
+ {
147
+ if (!$this->iterable || !$this->iterable->valid()) {
148
+ return false;
149
+ }
150
+
151
+ $promise = promise_for($this->iterable->current());
152
+ $idx = $this->iterable->key();
153
+
154
+ $this->pending[$idx] = $promise->then(
155
+ function ($value) use ($idx) {
156
+ if ($this->onFulfilled) {
157
+ call_user_func(
158
+ $this->onFulfilled, $value, $idx, $this->aggregate
159
+ );
160
+ }
161
+ $this->step($idx);
162
+ },
163
+ function ($reason) use ($idx) {
164
+ if ($this->onRejected) {
165
+ call_user_func(
166
+ $this->onRejected, $reason, $idx, $this->aggregate
167
+ );
168
+ }
169
+ $this->step($idx);
170
+ }
171
+ );
172
+
173
+ return true;
174
+ }
175
+
176
+ private function advanceIterator()
177
+ {
178
+ // Place a lock on the iterator so that we ensure to not recurse,
179
+ // preventing fatal generator errors.
180
+ if ($this->mutex) {
181
+ return false;
182
+ }
183
+
184
+ $this->mutex = true;
185
+
186
+ try {
187
+ $this->iterable->next();
188
+ $this->mutex = false;
189
+ return true;
190
+ } catch (\Throwable $e) {
191
+ $this->aggregate->reject($e);
192
+ $this->mutex = false;
193
+ return false;
194
+ } catch (\Exception $e) {
195
+ $this->aggregate->reject($e);
196
+ $this->mutex = false;
197
+ return false;
198
+ }
199
+ }
200
+
201
+ private function step($idx)
202
+ {
203
+ // If the promise was already resolved, then ignore this step.
204
+ if ($this->aggregate->getState() !== PromiseInterface::PENDING) {
205
+ return;
206
+ }
207
+
208
+ unset($this->pending[$idx]);
209
+
210
+ // Only refill pending promises if we are not locked, preventing the
211
+ // EachPromise to recursively invoke the provided iterator, which
212
+ // cause a fatal error: "Cannot resume an already running generator"
213
+ if ($this->advanceIterator() && !$this->checkIfFinished()) {
214
+ // Add more pending promises if possible.
215
+ $this->refillPending();
216
+ }
217
+ }
218
+
219
+ private function checkIfFinished()
220
+ {
221
+ if (!$this->pending && !$this->iterable->valid()) {
222
+ // Resolve the promise if there's nothing left to do.
223
+ $this->aggregate->resolve(null);
224
+ return true;
225
+ }
226
+
227
+ return false;
228
+ }
229
+ }
vendor/guzzlehttp/promises/src/FulfilledPromise.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * A promise that has been fulfilled.
6
+ *
7
+ * Thenning off of this promise will invoke the onFulfilled callback
8
+ * immediately and ignore other callbacks.
9
+ */
10
+ class FulfilledPromise implements PromiseInterface
11
+ {
12
+ private $value;
13
+
14
+ public function __construct($value)
15
+ {
16
+ if (method_exists($value, 'then')) {
17
+ throw new \InvalidArgumentException(
18
+ 'You cannot create a FulfilledPromise with a promise.');
19
+ }
20
+
21
+ $this->value = $value;
22
+ }
23
+
24
+ public function then(
25
+ callable $onFulfilled = null,
26
+ callable $onRejected = null
27
+ ) {
28
+ // Return itself if there is no onFulfilled function.
29
+ if (!$onFulfilled) {
30
+ return $this;
31
+ }
32
+
33
+ $queue = queue();
34
+ $p = new Promise([$queue, 'run']);
35
+ $value = $this->value;
36
+ $queue->add(static function () use ($p, $value, $onFulfilled) {
37
+ if ($p->getState() === self::PENDING) {
38
+ try {
39
+ $p->resolve($onFulfilled($value));
40
+ } catch (\Throwable $e) {
41
+ $p->reject($e);
42
+ } catch (\Exception $e) {
43
+ $p->reject($e);
44
+ }
45
+ }
46
+ });
47
+
48
+ return $p;
49
+ }
50
+
51
+ public function otherwise(callable $onRejected)
52
+ {
53
+ return $this->then(null, $onRejected);
54
+ }
55
+
56
+ public function wait($unwrap = true, $defaultDelivery = null)
57
+ {
58
+ return $unwrap ? $this->value : null;
59
+ }
60
+
61
+ public function getState()
62
+ {
63
+ return self::FULFILLED;
64
+ }
65
+
66
+ public function resolve($value)
67
+ {
68
+ if ($value !== $this->value) {
69
+ throw new \LogicException("Cannot resolve a fulfilled promise");
70
+ }
71
+ }
72
+
73
+ public function reject($reason)
74
+ {
75
+ throw new \LogicException("Cannot reject a fulfilled promise");
76
+ }
77
+
78
+ public function cancel()
79
+ {
80
+ // pass
81
+ }
82
+ }
vendor/guzzlehttp/promises/src/Promise.php ADDED
@@ -0,0 +1,280 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * Promises/A+ implementation that avoids recursion when possible.
6
+ *
7
+ * @link https://promisesaplus.com/
8
+ */
9
+ class Promise implements PromiseInterface
10
+ {
11
+ private $state = self::PENDING;
12
+ private $result;
13
+ private $cancelFn;
14
+ private $waitFn;
15
+ private $waitList;
16
+ private $handlers = [];
17
+
18
+ /**
19
+ * @param callable $waitFn Fn that when invoked resolves the promise.
20
+ * @param callable $cancelFn Fn that when invoked cancels the promise.
21
+ */
22
+ public function __construct(
23
+ callable $waitFn = null,
24
+ callable $cancelFn = null
25
+ ) {
26
+ $this->waitFn = $waitFn;
27
+ $this->cancelFn = $cancelFn;
28
+ }
29
+
30
+ public function then(
31
+ callable $onFulfilled = null,
32
+ callable $onRejected = null
33
+ ) {
34
+ if ($this->state === self::PENDING) {
35
+ $p = new Promise(null, [$this, 'cancel']);
36
+ $this->handlers[] = [$p, $onFulfilled, $onRejected];
37
+ $p->waitList = $this->waitList;
38
+ $p->waitList[] = $this;
39
+ return $p;
40
+ }
41
+
42
+ // Return a fulfilled promise and immediately invoke any callbacks.
43
+ if ($this->state === self::FULFILLED) {
44
+ return $onFulfilled
45
+ ? promise_for($this->result)->then($onFulfilled)
46
+ : promise_for($this->result);
47
+ }
48
+
49
+ // It's either cancelled or rejected, so return a rejected promise
50
+ // and immediately invoke any callbacks.
51
+ $rejection = rejection_for($this->result);
52
+ return $onRejected ? $rejection->then(null, $onRejected) : $rejection;
53
+ }
54
+
55
+ public function otherwise(callable $onRejected)
56
+ {
57
+ return $this->then(null, $onRejected);
58
+ }
59
+
60
+ public function wait($unwrap = true)
61
+ {
62
+ $this->waitIfPending();
63
+
64
+ $inner = $this->result instanceof PromiseInterface
65
+ ? $this->result->wait($unwrap)
66
+ : $this->result;
67
+
68
+ if ($unwrap) {
69
+ if ($this->result instanceof PromiseInterface
70
+ || $this->state === self::FULFILLED
71
+ ) {
72
+ return $inner;
73
+ } else {
74
+ // It's rejected so "unwrap" and throw an exception.
75
+ throw exception_for($inner);
76
+ }
77
+ }
78
+ }
79
+
80
+ public function getState()
81
+ {
82
+ return $this->state;
83
+ }
84
+
85
+ public function cancel()
86
+ {
87
+ if ($this->state !== self::PENDING) {
88
+ return;
89
+ }
90
+
91
+ $this->waitFn = $this->waitList = null;
92
+
93
+ if ($this->cancelFn) {
94
+ $fn = $this->cancelFn;
95
+ $this->cancelFn = null;
96
+ try {
97
+ $fn();
98
+ } catch (\Throwable $e) {
99
+ $this->reject($e);
100
+ } catch (\Exception $e) {
101
+ $this->reject($e);
102
+ }
103
+ }
104
+
105
+ // Reject the promise only if it wasn't rejected in a then callback.
106
+ if ($this->state === self::PENDING) {
107
+ $this->reject(new CancellationException('Promise has been cancelled'));
108
+ }
109
+ }
110
+
111
+ public function resolve($value)
112
+ {
113
+ $this->settle(self::FULFILLED, $value);
114
+ }
115
+
116
+ public function reject($reason)
117
+ {
118
+ $this->settle(self::REJECTED, $reason);
119
+ }
120
+
121
+ private function settle($state, $value)
122
+ {
123
+ if ($this->state !== self::PENDING) {
124
+ // Ignore calls with the same resolution.
125
+ if ($state === $this->state && $value === $this->result) {
126
+ return;
127
+ }
128
+ throw $this->state === $state
129
+ ? new \LogicException("The promise is already {$state}.")
130
+ : new \LogicException("Cannot change a {$this->state} promise to {$state}");
131
+ }
132
+
133
+ if ($value === $this) {
134
+ throw new \LogicException('Cannot fulfill or reject a promise with itself');
135
+ }
136
+
137
+ // Clear out the state of the promise but stash the handlers.
138
+ $this->state = $state;
139
+ $this->result = $value;
140
+ $handlers = $this->handlers;
141
+ $this->handlers = null;
142
+ $this->waitList = $this->waitFn = null;
143
+ $this->cancelFn = null;
144
+
145
+ if (!$handlers) {
146
+ return;
147
+ }
148
+
149
+ // If the value was not a settled promise or a thenable, then resolve
150
+ // it in the task queue using the correct ID.
151
+ if (!method_exists($value, 'then')) {
152
+ $id = $state === self::FULFILLED ? 1 : 2;
153
+ // It's a success, so resolve the handlers in the queue.
154
+ queue()->add(static function () use ($id, $value, $handlers) {
155
+ foreach ($handlers as $handler) {
156
+ self::callHandler($id, $value, $handler);
157
+ }
158
+ });
159
+ } elseif ($value instanceof Promise
160
+ && $value->getState() === self::PENDING
161
+ ) {
162
+ // We can just merge our handlers onto the next promise.
163
+ $value->handlers = array_merge($value->handlers, $handlers);
164
+ } else {
165
+ // Resolve the handlers when the forwarded promise is resolved.
166
+ $value->then(
167
+ static function ($value) use ($handlers) {
168
+ foreach ($handlers as $handler) {
169
+ self::callHandler(1, $value, $handler);
170
+ }
171
+ },
172
+ static function ($reason) use ($handlers) {
173
+ foreach ($handlers as $handler) {
174
+ self::callHandler(2, $reason, $handler);
175
+ }
176
+ }
177
+ );
178
+ }
179
+ }
180
+
181
+ /**
182
+ * Call a stack of handlers using a specific callback index and value.
183
+ *
184
+ * @param int $index 1 (resolve) or 2 (reject).
185
+ * @param mixed $value Value to pass to the callback.
186
+ * @param array $handler Array of handler data (promise and callbacks).
187
+ *
188
+ * @return array Returns the next group to resolve.
189
+ */
190
+ private static function callHandler($index, $value, array $handler)
191
+ {
192
+ /** @var PromiseInterface $promise */
193
+ $promise = $handler[0];
194
+
195
+ // The promise may have been cancelled or resolved before placing
196
+ // this thunk in the queue.
197
+ if ($promise->getState() !== self::PENDING) {
198
+ return;
199
+ }
200
+
201
+ try {
202
+ if (isset($handler[$index])) {
203
+ $promise->resolve($handler[$index]($value));
204
+ } elseif ($index === 1) {
205
+ // Forward resolution values as-is.
206
+ $promise->resolve($value);
207
+ } else {
208
+ // Forward rejections down the chain.
209
+ $promise->reject($value);
210
+ }
211
+ } catch (\Throwable $reason) {
212
+ $promise->reject($reason);
213
+ } catch (\Exception $reason) {
214
+ $promise->reject($reason);
215
+ }
216
+ }
217
+
218
+ private function waitIfPending()
219
+ {
220
+ if ($this->state !== self::PENDING) {
221
+ return;
222
+ } elseif ($this->waitFn) {
223
+ $this->invokeWaitFn();
224
+ } elseif ($this->waitList) {
225
+ $this->invokeWaitList();
226
+ } else {
227
+ // If there's not wait function, then reject the promise.
228
+ $this->reject('Cannot wait on a promise that has '
229
+ . 'no internal wait function. You must provide a wait '
230
+ . 'function when constructing the promise to be able to '
231
+ . 'wait on a promise.');
232
+ }
233
+
234
+ queue()->run();
235
+
236
+ if ($this->state === self::PENDING) {
237
+ $this->reject('Invoking the wait callback did not resolve the promise');
238
+ }
239
+ }
240
+
241
+ private function invokeWaitFn()
242
+ {
243
+ try {
244
+ $wfn = $this->waitFn;
245
+ $this->waitFn = null;
246
+ $wfn(true);
247
+ } catch (\Exception $reason) {
248
+ if ($this->state === self::PENDING) {
249
+ // The promise has not been resolved yet, so reject the promise
250
+ // with the exception.
251
+ $this->reject($reason);
252
+ } else {
253
+ // The promise was already resolved, so there's a problem in
254
+ // the application.
255
+ throw $reason;
256
+ }
257
+ }
258
+ }
259
+
260
+ private function invokeWaitList()
261
+ {
262
+ $waitList = $this->waitList;
263
+ $this->waitList = null;
264
+
265
+ foreach ($waitList as $result) {
266
+ while (true) {
267
+ $result->waitIfPending();
268
+
269
+ if ($result->result instanceof Promise) {
270
+ $result = $result->result;
271
+ } else {
272
+ if ($result->result instanceof PromiseInterface) {
273
+ $result->result->wait(false);
274
+ }
275
+ break;
276
+ }
277
+ }
278
+ }
279
+ }
280
+ }
vendor/guzzlehttp/promises/src/PromiseInterface.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Promise;
3
+
4
+ /**
5
+ * A promise represents the eventual result of an asynchronous operation.
6
+ *
7
+ * The primary way of interacting with a promise is through its then method,
8
+ * which registers callbacks to receive either a promise’s eventual value or
9
+ * the reason why the promise cannot be fulfilled.
10
+ *
11
+ * @link https://promisesaplus.com/
12
+ */
13
+ interface PromiseInterface
14
+ {
15
+ const PENDING = 'pending';
16
+ const FULFILLED = 'fulfilled';
17
+ const REJECTED = 'rejected';
18
+
19
+ /**
20
+ * Appends fulfillment and rejection handlers to the promise, and returns
21
+ * a new promise resolving to the return value of the called handler.
22
+ *
23
+ * @param callable $onFulfilled Invoked when the promise fulfills.
24
+ * @param callable $onRejected Invoked when the promise is rejected.
25
+ *
26
+ * @return PromiseInterface
27
+ */
28
+ public function then(
29
+ callable $onFulfilled = null,
30
+ callable $onRejected = null
31
+ );
32
+
33
+ /**
34
+ * Appends a rejection handler callback to the promise, and returns a new
35
+ * promise resolving to the return value of the callback if it is called,
36
+ * or to its original fulfillment value if the promise is instead
37
+ * fulfilled.
38
+ *
39
+ * @param callable $onRejected Invoked when the promise is rejected.
40
+ *
41
+ * @return PromiseInterface
42
+ */
43
+ public function otherwise(callable $onRejected);
44
+
45
+ /**
46
+ * Get the state of the promise ("pending", "rejected", or "fulfilled").
47
+ *
48
+ * The three states can be checked against the constants defined on
49
+ * PromiseInterface: PENDING, FULFILLED, and REJECTED.
50
+ *
51
+ * @return string
52
+ */
53
+ public function getState();
54
+
55
+ /**
56
+ * Resolve the promise with the given value.
57
+ *
58
+ * @param mixed $value
59
+ * @throws \RuntimeException if the promise is already resolved.
60
+ */
61
+ public function resolve($value);
62
+
63
+ /**
64
+ * Reject the promise with the given reason.
65
+ *
66
+ * @param mixed $reason
67
+ * @throws \RuntimeException if the promise is already resolved.
68
+ */
69
+ public function reject($reason);
70
+
71
+ /**
72
+ * Cancels the promise if possible.
73
+ *
74
+ * @link https://github.com/promises-aplus/cancellation-spec/issues/7
75
+ */
76
+ public function cancel();
77
+
78
+ /**
79
+ * Waits until the promise completes if possible.
80
+ *
81
+ * Pass $unwrap as true to unwrap the result of the promise, either
82
+ * returning the resolved value or throwing the rejected exception.
83
+ *
84
+ * If the promise cannot be waited on, then the promise will be rejected.
85
+ *
86
+ * @param bool $unwrap
87
+ *
88
+ * @return mixed
89
+ * @throws \LogicException if the promise has no wait function or if the
90
+ * promise does not settle after waiting.
91
+ */
92
+ public function wait($unwrap = true);
93
+ }
vendor/guzzlehttp/promises/src/PromisorInterface.php ADDED
@@ -0,0 +1,15 @@
 
1
+ <?php