WordPress Backup and Migrate Plugin – Backup Guard - Version 1.4.8.1

Version Description

  • Code improvement
Download this release

Release Info

Developer BackupGuard
Plugin Icon 128x128 WordPress Backup and Migrate Plugin – Backup Guard
Version 1.4.8.1
Comparing to
See all releases

Code changes from version 1.4.8 to 1.4.8.1

Files changed (49) hide show
  1. BackupGuard.php +101 -18
  2. README.txt +4 -1
  3. backup.php +2 -2
  4. com/config/config.php +7 -1
  5. com/config/config.wordpress.free.php +2 -0
  6. com/config/config.wordpress.php +5 -0
  7. com/core/SGBoot.php +1 -1
  8. com/core/SGPing.php +2 -2
  9. com/core/backup/SGBackup.php +20 -57
  10. com/core/backup/SGBackupFiles.php +5 -0
  11. com/core/backup/SGBackupStorage.php +19 -8
  12. com/core/functions.php +16 -1
  13. com/core/storage/BackupGuardStorage.php +373 -0
  14. com/core/storage/SGDropboxStorage.php +4 -2
  15. com/core/storage/SGStorage.php +1 -1
  16. com/lib/BackupGuard/Client.php +404 -1
  17. com/lib/BackupGuard/Helper.php +13 -1
  18. com/lib/Request/SGRequestAdapterWordpress.php +5 -4
  19. com/lib/SGAuthClient.php +34 -0
  20. com/lib/SGCallback.php +1 -4
  21. com/lib/SGFileEntry.php +13 -1
  22. com/lib/SGReloader.php +1 -1
  23. com/lib/SGState.php +14 -14
  24. com/lib/SGUploadState.php +27 -0
  25. public/ajax/bgLogin.php +58 -0
  26. public/ajax/chooseProfile.php +22 -0
  27. public/ajax/createCloudUser.php +31 -0
  28. public/ajax/dismissDiscountNotice.php +1 -1
  29. public/ajax/isBgUserExists.php +27 -0
  30. public/ajax/modalBackupGuardDetails.php +87 -0
  31. public/ajax/modalImport.php +8 -1
  32. public/ajax/modalManualBackup.php +9 -0
  33. public/cloud.php +56 -6
  34. public/css/bgstyle.less.css +39 -10
  35. public/css/styles.css +7 -0
  36. public/img/backup-cloud-icon.png +0 -0
  37. public/img/backup-icons-old.png +0 -0
  38. public/img/backup-icons.png +0 -0
  39. public/img/halloween.png +0 -0
  40. public/img/halloweenPopup.png +0 -0
  41. public/img/halloweenPopupClose.png +0 -0
  42. public/include/functions.php +9 -4
  43. public/js/jquery.validate.min.js +51 -0
  44. public/js/main.js +7 -0
  45. public/js/popup.js +55 -16
  46. public/js/sgbackup.js +27 -7
  47. public/js/sgcloud.js +381 -171
  48. public/js/sgschedule.js +1 -0
  49. public/schedule.php +10 -0
BackupGuard.php CHANGED
@@ -210,8 +210,9 @@ function backup_guard_cloud_page()
210
  {
211
  if (backupGuardValidateLicense()) {
212
  wp_enqueue_style('backup-guard-switch-css', plugin_dir_url(__FILE__).'public/css/bootstrap-switch.min.css');
213
- wp_enqueue_script('backup-guard-switch-js', plugin_dir_url(__FILE__).'public/js/bootstrap-switch.min.js', array('jquery'), '1.0.0', true);
214
- wp_enqueue_script('backup-guard-cloud-js', plugin_dir_url(__FILE__).'public/js/sgcloud.js', array('jquery', 'backup-guard-switch-js'), '1.0.0', true);
 
215
 
216
  // Localize the script with new data
217
  wp_localize_script('backup-guard-cloud-js', 'BG_CLOUD_STRINGS', array(
@@ -356,6 +357,15 @@ add_action( 'wp_ajax_backup_guard_getFileDownloadProgress', 'backup_guard_get_fi
356
  add_action( 'wp_ajax_backup_guard_modalCreateSchedule', 'backup_guard_create_schedule');
357
  add_action( 'wp_ajax_backup_guard_getBackupContent', 'backup_guard_get_backup_content');
358
 
 
 
 
 
 
 
 
 
 
359
  function backup_guard_get_file_download_progress()
360
  {
361
  check_ajax_referer('backupGuardAjaxNonce', 'token');
@@ -477,11 +487,17 @@ function backup_guard_register_ajax_callbacks()
477
  add_action('wp_ajax_backup_guard_storeSurveyResult', 'backup_guard_store_survey_result');
478
  add_action('wp_ajax_backup_guard_reviewDontShow', 'backup_guard_review_dont_show');
479
  add_action('wp_ajax_backup_guard_review_later', 'backup_guard_review_later');
480
- add_action('wp_ajax_backup_guard_closeFreeBanner', 'closeFreeBanner');
 
 
 
 
 
 
481
  }
482
  }
483
 
484
- function closeFreeBanner()
485
  {
486
  check_ajax_referer('backupGuardAjaxNonce', 'token');
487
  SGConfig::set('SG_CLOSE_FREE_BANNER', 1);
@@ -502,6 +518,36 @@ function backup_guard_review_later()
502
  wp_die();
503
  }
504
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
505
  function backup_guard_store_survey_result()
506
  {
507
  check_ajax_referer('backupGuardAjaxNonce', 'token');
@@ -869,23 +915,60 @@ function backup_guard_discount_notice()
869
  $capabilities = backupGuardGetCapabilities();
870
  $upgradeUrl = BG_UPGRADE_URL;
871
  ?>
 
 
 
 
 
872
  <div class="backup-guard-discount-notice updated notice is-dismissible">
873
- <div class="sgbg-col sgbg-col1"></div>
874
- <div class="sgbg-col sgbg-col2"></div>
875
- <div class="sgbg-col sgbg-col3">
876
- <div class="sgbg-text-col-1">
877
- -50%
878
- </div>
879
- <div class="sgbg-text-col-2">
880
- <div class="sgbg-discount-text-1">Discount</div>
881
- <div class="sgbg-discount-text-2">All Backup Guard Solutions</div>
882
- </div>
883
- </div>
884
- <div class="sgbg-col sgbg-col4">
885
- <a href="https://backup-guard.com/products/backup-wordpress" target="_blank"><button class="sgbg-button">Click Here</button></a>
886
- </div>
 
 
 
 
887
  </div>
888
  <style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
889
  .backup-guard-discount-notice.updated.notice.is-dismissible {
890
  padding: 0;
891
  border-left-color: #FFFFFF !important;
210
  {
211
  if (backupGuardValidateLicense()) {
212
  wp_enqueue_style('backup-guard-switch-css', plugin_dir_url(__FILE__).'public/css/bootstrap-switch.min.css');
213
+ wp_enqueue_script('backup-guard-switch-js', plugin_dir_url(__FILE__).'public/js/bootstrap-switch.min.js', array('jquery'), SG_BACKUP_GUARD_VERSION, true);
214
+ wp_enqueue_script('backup-guard-jquery-validate-js', plugin_dir_url(__FILE__).'public/js/jquery.validate.min.js', array('jquery', 'backup-guard-switch-js'), SG_BACKUP_GUARD_VERSION, true);
215
+ wp_enqueue_script('backup-guard-cloud-js', plugin_dir_url(__FILE__).'public/js/sgcloud.js', array('jquery', 'backup-guard-switch-js'), SG_BACKUP_GUARD_VERSION, true);
216
 
217
  // Localize the script with new data
218
  wp_localize_script('backup-guard-cloud-js', 'BG_CLOUD_STRINGS', array(
357
  add_action( 'wp_ajax_backup_guard_modalCreateSchedule', 'backup_guard_create_schedule');
358
  add_action( 'wp_ajax_backup_guard_getBackupContent', 'backup_guard_get_backup_content');
359
 
360
+ add_action( 'wp_ajax_backup_guard_modalBackupGuardDetails', 'backup_guard_get_backup_guard_modal');
361
+
362
+ function backup_guard_get_backup_guard_modal()
363
+ {
364
+ check_ajax_referer('backupGuardAjaxNonce', 'token');
365
+ require_once(SG_PUBLIC_AJAX_PATH.'modalBackupGuardDetails.php');
366
+ exit();
367
+ }
368
+
369
  function backup_guard_get_file_download_progress()
370
  {
371
  check_ajax_referer('backupGuardAjaxNonce', 'token');
487
  add_action('wp_ajax_backup_guard_storeSurveyResult', 'backup_guard_store_survey_result');
488
  add_action('wp_ajax_backup_guard_reviewDontShow', 'backup_guard_review_dont_show');
489
  add_action('wp_ajax_backup_guard_review_later', 'backup_guard_review_later');
490
+ add_action('wp_ajax_backup_guard_closeFreeBanner', 'wp_ajax_backup_guard_close_free_banner');
491
+ // related to cloud
492
+ add_action('wp_ajax_backup_guard_isBgUserExists', 'backup_guard_is_bg_user_exists');
493
+ add_action('wp_ajax_backup_guard_createCloudUser', 'backup_guard_create_cloud_user');
494
+ add_action('wp_ajax_backup_guard_bgAutoLogin', 'backup_guard_bg_auto_login');
495
+ add_action('wp_ajax_backup_guard_bgLogin', 'backup_guard_bg_login');
496
+ add_action('wp_ajax_backup_guard_chooseProfile', 'backup_guard_choose_profile');
497
  }
498
  }
499
 
500
+ function wp_ajax_backup_guard_close_free_banner()
501
  {
502
  check_ajax_referer('backupGuardAjaxNonce', 'token');
503
  SGConfig::set('SG_CLOSE_FREE_BANNER', 1);
518
  wp_die();
519
  }
520
 
521
+ function backup_guard_choose_profile()
522
+ {
523
+ check_ajax_referer('backupGuardAjaxNonce', 'token');
524
+ require_once(SG_PUBLIC_AJAX_PATH.'chooseProfile.php');
525
+ }
526
+
527
+ function backup_guard_bg_login()
528
+ {
529
+ check_ajax_referer('backupGuardAjaxNonce', 'token');
530
+ require_once(SG_PUBLIC_AJAX_PATH.'bgLogin.php');
531
+ }
532
+
533
+ function backup_guard_bg_auto_login()
534
+ {
535
+ check_ajax_referer('backupGuardAjaxNonce', 'token');
536
+ require_once(SG_PUBLIC_AJAX_PATH.'bgAutoLogin.php');
537
+ }
538
+
539
+ function backup_guard_create_cloud_user()
540
+ {
541
+ check_ajax_referer('backupGuardAjaxNonce', 'token');
542
+ require_once(SG_PUBLIC_AJAX_PATH.'createCloudUser.php');
543
+ }
544
+
545
+ function backup_guard_is_bg_user_exists()
546
+ {
547
+ check_ajax_referer('backupGuardAjaxNonce', 'token');
548
+ require_once(SG_PUBLIC_AJAX_PATH.'isBgUserExists.php');
549
+ }
550
+
551
  function backup_guard_store_survey_result()
552
  {
553
  check_ajax_referer('backupGuardAjaxNonce', 'token');
915
  $capabilities = backupGuardGetCapabilities();
916
  $upgradeUrl = BG_UPGRADE_URL;
917
  ?>
918
+ <div style="visibility: hidden;height: 0;">
919
+ <div id="sg-halloween-popup-content-wrapper">
920
+ <div class="sgbg-halloween-close-popup"></div>
921
+ </div>
922
+ </div>
923
  <div class="backup-guard-discount-notice updated notice is-dismissible">
924
+ <a href="<?php echo SG_BACKUP_SITE_PRICING_URL; ?>" target="_blank">
925
+ <div class="sgbg-banner-content">
926
+ </div>
927
+ </a>
928
+ <!-- <div class="sgbg-col sgbg-col1"></div>-->
929
+ <!-- <div class="sgbg-col sgbg-col2"></div>-->
930
+ <!-- <div class="sgbg-col sgbg-col3">-->
931
+ <!-- <div class="sgbg-text-col-1">-->
932
+ <!-- -50%-->
933
+ <!-- </div>-->
934
+ <!-- <div class="sgbg-text-col-2">-->
935
+ <!-- <div class="sgbg-discount-text-1">Discount</div>-->
936
+ <!-- <div class="sgbg-discount-text-2">All Backup Guard Solutions</div>-->
937
+ <!-- </div>-->
938
+ <!-- </div>-->
939
+ <!-- <div class="sgbg-col sgbg-col4">-->
940
+ <!-- <a href="https://backup-guard.com/products/backup-wordpress" target="_blank"><button class="sgbg-button">Click Here</button></a>-->
941
+ <!-- </div>-->
942
  </div>
943
  <style>
944
+ #sg-halloween-popup-content-wrapper {
945
+ position: relative;
946
+ width: 834px;
947
+ height: 685px;
948
+ max-width: 100%;
949
+ max-height: 100%;
950
+ background-image: url("<?php echo SG_IMAGE_URL ?>halloweenPopup.png");
951
+ background-repeat: no-repeat;
952
+ background-size: 100% 100%;
953
+ background-position: top center;
954
+ }
955
+ .sgbg-banner-content {
956
+ height: 160px;
957
+ background-image: url("<?php echo SG_IMAGE_URL ?>halloween.png");
958
+ background-size: cover;
959
+ background-repeat: no-repeat;
960
+ }
961
+ .sgbg-halloween-close-popup {
962
+ position: absolute;
963
+ top: 102px;
964
+ right: 122px;
965
+ background-size: contain;
966
+ width: 20px;
967
+ height: 21px;
968
+ background-repeat: no-repeat;
969
+ background-image: url("<?php echo SG_IMAGE_URL ?>halloweenPopupClose.png");
970
+ cursor: pointer;
971
+ }
972
  .backup-guard-discount-notice.updated.notice.is-dismissible {
973
  padding: 0;
974
  border-left-color: #FFFFFF !important;
README.txt CHANGED
@@ -6,7 +6,7 @@ Donate link: https://backup-guard.com/products/backup-wordpress
6
  Tags: backup, wordpress backup plugin, backup plugin, database backup, migrate, back up
7
  Requires at least: 3.8
8
  Tested up to: 5.5.1
9
- Stable tag: 1.4.8
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -168,6 +168,9 @@ When you are facing an issue of any kind with any of our products, the first thi
168
 
169
  == Changelog ==
170
 
 
 
 
171
  = 1.4.8 =
172
  * Bug fixed related to Dropbox connection issue
173
  * Improvement for Import section
6
  Tags: backup, wordpress backup plugin, backup plugin, database backup, migrate, back up
7
  Requires at least: 3.8
8
  Tested up to: 5.5.1
9
+ Stable tag: 1.4.8.1
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
168
 
169
  == Changelog ==
170
 
171
+ = 1.4.8.1 =
172
+ * Code improvement
173
+
174
  = 1.4.8 =
175
  * Bug fixed related to Dropbox connection issue
176
  * Improvement for Import section
backup.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Backup
5
  * Plugin URI: https://backup-guard.com/products/backup-wordpress
6
  * Description: Backup Guard is the most complete site backup and restore plugin. We offer the easiest way to backup, restore or migrate your site. You can backup your files, database or both.
7
- * Version: 1.4.8
8
  * Author: BackupGuard
9
  * Author URI: https://backup-guard.com/products/backup-wordpress
10
  * License: GPL-2.0+
@@ -16,7 +16,7 @@ if (function_exists('activate_backup_guard')) {
16
  }
17
 
18
  if (!defined('SG_BACKUP_GUARD_VERSION')) {
19
- define('SG_BACKUP_GUARD_VERSION', '1.4.8');
20
  }
21
 
22
  if (!defined('SG_BACKUP_GUARD_MAIN_FILE')) {
4
  * Plugin Name: Backup
5
  * Plugin URI: https://backup-guard.com/products/backup-wordpress
6
  * Description: Backup Guard is the most complete site backup and restore plugin. We offer the easiest way to backup, restore or migrate your site. You can backup your files, database or both.
7
+ * Version: 1.4.8.1
8
  * Author: BackupGuard
9
  * Author URI: https://backup-guard.com/products/backup-wordpress
10
  * License: GPL-2.0+
16
  }
17
 
18
  if (!defined('SG_BACKUP_GUARD_VERSION')) {
19
+ define('SG_BACKUP_GUARD_VERSION', '1.4.8.1');
20
  }
21
 
22
  if (!defined('SG_BACKUP_GUARD_MAIN_FILE')) {
com/config/config.php CHANGED
@@ -178,6 +178,8 @@ define('SG_SCHEDULE_TABLE_NAME', SG_ENV_DB_PREFIX.'sg_schedule');
178
 
179
  define('SG_SSH_KEY_FILE_FOLDER_NAME', 'sshKeyFolder/');
180
 
 
 
181
  define('SG_MIGRATION_SERVICE_URL', 'https://backup-guard.com/services/migrate-wordpress');
182
  define('BACKUP_GUARD_PRIVACY_POLICY_URL', "https://backup-guard.com/privacy");
183
  define('BACKUP_GUARD_TERMS_OF_SERVICE_URL', 'https://backup-guard.com/terms');
@@ -207,4 +209,8 @@ define('BG_SCHEDULE_INTERVAL_WEEKLY', 2);
207
  define('BG_SCHEDULE_INTERVAL_MONTHLY', 3);
208
  define('BG_SCHEDULE_INTERVAL_YEARLY', 4);
209
 
210
- define("BACKUP_GUARD_TEXTDOMAIN", "backup-guard-pro");
 
 
 
 
178
 
179
  define('SG_SSH_KEY_FILE_FOLDER_NAME', 'sshKeyFolder/');
180
 
181
+ define('SG_SHOW_BACKUPGUARD_CLOUD', 0);
182
+ define('SG_FORGOT_PASSWORD_URL', 'https://backup-guard.com/admin/users/forgotPassword');
183
  define('SG_MIGRATION_SERVICE_URL', 'https://backup-guard.com/services/migrate-wordpress');
184
  define('BACKUP_GUARD_PRIVACY_POLICY_URL', "https://backup-guard.com/privacy");
185
  define('BACKUP_GUARD_TERMS_OF_SERVICE_URL', 'https://backup-guard.com/terms');
209
  define('BG_SCHEDULE_INTERVAL_MONTHLY', 3);
210
  define('BG_SCHEDULE_INTERVAL_YEARLY', 4);
211
 
212
+ define('BACKUP_GUARD_TEXTDOMAIN', 'backup-guard-pro');
213
+
214
+ define('BACKUP_GUARD_ONE_MB', 1000000);
215
+
216
+ define('BACKUP_GUARD_CLOUD_UPGRADE_URL', 'http://backup-guard.com/admin/billing/process/2');
com/config/config.wordpress.free.php CHANGED
@@ -29,11 +29,13 @@ define('SG_STORAGE_DROPBOX', 2);
29
  define('SG_STORAGE_GOOGLE_DRIVE', 3);
30
  define('SG_STORAGE_AMAZON', 4);
31
  define('SG_STORAGE_ONE_DRIVE', 5);
 
32
 
33
  define('SG_STORAGE_DROPBOX_KEY', 'n3yhajm64h88m9t');
34
  define('SG_STORAGE_DROPBOX_SECRET', 's8crjkls7f9wqtd');
35
  define('SG_STORAGE_DROPBOX_CLIENT_ID', 'backup-guard');
36
  define('SG_STORAGE_DROPBOX_REDIRECT_URI', 'https://backup-guard.com/dropbox/');
 
37
 
38
  define('SG_PRODUCT_IDENTIFIER', 'backup-guard-wp-free');
39
 
29
  define('SG_STORAGE_GOOGLE_DRIVE', 3);
30
  define('SG_STORAGE_AMAZON', 4);
31
  define('SG_STORAGE_ONE_DRIVE', 5);
32
+ define('SG_STORAGE_BACKUP_GUARD', 6);
33
 
34
  define('SG_STORAGE_DROPBOX_KEY', 'n3yhajm64h88m9t');
35
  define('SG_STORAGE_DROPBOX_SECRET', 's8crjkls7f9wqtd');
36
  define('SG_STORAGE_DROPBOX_CLIENT_ID', 'backup-guard');
37
  define('SG_STORAGE_DROPBOX_REDIRECT_URI', 'https://backup-guard.com/dropbox/');
38
+ define('SG_FEATURE_BACKUP_GUARD', 1);
39
 
40
  define('SG_PRODUCT_IDENTIFIER', 'backup-guard-wp-free');
41
 
com/config/config.wordpress.php CHANGED
@@ -28,6 +28,11 @@ define('SG_NOTICE_TEMPLATES_PATH', realpath(SG_APP_PATH.'../public/templates/not
28
  define('SG_BACKUPGUARD_CLIENT_ID', 'wordpress');
29
  define('SG_BACKUPGUARD_CLIENT_SECRET', 'AAPQEgsyQrt6wqDBk7fpa24NP6W43evtayxXmUqS');
30
 
 
 
 
 
 
31
  //Backup
32
  $wpContent = basename(WP_CONTENT_DIR);
33
  $wpPlugins = basename(WP_PLUGIN_DIR);
28
  define('SG_BACKUPGUARD_CLIENT_ID', 'wordpress');
29
  define('SG_BACKUPGUARD_CLIENT_SECRET', 'AAPQEgsyQrt6wqDBk7fpa24NP6W43evtayxXmUqS');
30
 
31
+ define('SG_BACKUPGUARD_UPLOAD_CLIENT_ID', 'backupguard');
32
+ define('SG_BACKUPGUARD_UPLOAD_CLIENT_SECRET', 'e9503d56b06b95241abf68eaa0d13194aae9503e');
33
+
34
+ define('SG_BACKUPGUARD_UPLOAD_SCOPE', 'create_backups');
35
+
36
  //Backup
37
  $wpContent = basename(WP_CONTENT_DIR);
38
  $wpPlugins = basename(WP_PLUGIN_DIR);
com/core/SGBoot.php CHANGED
@@ -266,7 +266,7 @@ class SGBoot
266
 
267
  public static function isFeatureAvailable($feature)
268
  {
269
- return (SGConfig::get('SG_FEATURE_'.strtoupper($feature))===1?true:false);
270
  }
271
 
272
  private static function prepare()
266
 
267
  public static function isFeatureAvailable($feature)
268
  {
269
+ return ((int)SGConfig::get('SG_FEATURE_'.strtoupper($feature))===1?true:false);
270
  }
271
 
272
  private static function prepare()
com/core/SGPing.php CHANGED
@@ -2,9 +2,9 @@
2
 
3
  class SGPing
4
  {
5
- public static $lastUpdateTs;
6
 
7
- public static function shouldUpdate()
8
  {
9
  if ((int)time()-self::$lastUpdateTs < SG_PING_DATE_UPDATE_FREQUENCY) {
10
  return false;
2
 
3
  class SGPing
4
  {
5
+ private static $lastUpdateTs;
6
 
7
+ private static function shouldUpdate()
8
  {
9
  if ((int)time()-self::$lastUpdateTs < SG_PING_DATE_UPDATE_FREQUENCY) {
10
  return false;
com/core/backup/SGBackup.php CHANGED
@@ -140,11 +140,11 @@ class SGBackup implements SGIBackupDelegate
140
  return array();
141
  }
142
 
143
- public function downloadBackupArchiveFromCloud($archive, $storage, $size)
144
  {
145
  $result = false;
146
  if (SGBoot::isFeatureAvailable('DOWNLOAD_FROM_CLOUD')) {
147
- $result = SGBackupStorage::getInstance()->downloadBackupArchiveFromCloud($storage, $archive, $size);
148
  }
149
 
150
  return $result;
@@ -343,19 +343,13 @@ class SGBackup implements SGIBackupDelegate
343
  $this->prepareBackupLogFile(SG_BACKUP_DIRECTORY.$this->fileName, true);
344
  $this->setBackupPaths();
345
  $this->prepareAdditionalConfigurations();
346
-
347
- $method = SGConfig::get('SG_RELOAD_METHOD');
348
- if ($method != $reloadMethod) {
349
- SGConfig::set('SG_RELOAD_METHOD', $reloadMethod);
350
- $reloadMethod = $this->reloadMethodNameByMethodId($reloadMethod);
351
- SGBackupLog::write("Reload method changed to ".$reloadMethod);
352
- }
353
  }
354
 
355
  SGPing::update();
356
-
357
- try
358
- {
 
359
  if ($this->databaseBackupAvailable) {
360
  $this->backupDatabase->setFilePath($this->databaseBackupPath);
361
  $this->backupDatabase->setPendingStorageUploads($this->pendingStorageUploads);
@@ -375,7 +369,6 @@ class SGBackup implements SGIBackupDelegate
375
  }
376
  }
377
 
378
- $rootDirectory = rtrim(SGConfig::get('SG_APP_ROOT_DIRECTORY'), '/').'/';
379
  $path = substr($this->databaseBackupPath, strlen($rootDirectory));
380
  $this->backupFiles->addDontExclude($this->databaseBackupPath);
381
  $backupItems = $options['SG_BACKUP_FILE_PATHS'];
@@ -394,6 +387,14 @@ class SGBackup implements SGIBackupDelegate
394
  }
395
 
396
  if ($this->state->getType() == SG_STATE_TYPE_FILE) {
 
 
 
 
 
 
 
 
397
  $this->backupFiles->setPendingStorageUploads($this->pendingStorageUploads);
398
  $this->backupFiles->backup($this->filesBackupPath, $options, $this->state);
399
  $this->didFinishBackup();
@@ -410,19 +411,15 @@ class SGBackup implements SGIBackupDelegate
410
  // Clear temporary files
411
  $this->clear();
412
  }
413
- catch (SGException $exception)
414
- {
415
- if ($exception instanceof SGExceptionSkip)
416
- {
417
  $this->setCurrentActionStatusCancelled();
418
  }
419
- else
420
- {
421
  SGBackupLog::writeExceptionObject($exception);
422
 
423
  if ($this->state->getType() != SG_STATE_TYPE_UPLOAD) {
424
- if ($this->databaseBackupAvailable)
425
- {
426
  $this->backupDatabase->cancel();
427
  }
428
 
@@ -516,6 +513,7 @@ class SGBackup implements SGIBackupDelegate
516
  {
517
  @unlink(dirname($this->filesBackupPath).'/'.SG_REPORT_FILE_NAME);
518
 
 
519
  @unlink(SG_BACKUP_DIRECTORY.SG_STATE_FILE_NAME);
520
  @unlink(SG_BACKUP_DIRECTORY.SG_RELOADER_STATE_FILE_NAME);
521
  @unlink(SG_PING_FILE_PATH);
@@ -1328,45 +1326,10 @@ class SGBackup implements SGIBackupDelegate
1328
  private static function deleteBackupFromCloud($storages, $backupName)
1329
  {
1330
  foreach ($storages as $storage) {
1331
- $storageId = 0;
1332
  $storage = (int)$storage;
1333
- switch ($storage) {
1334
- case SG_STORAGE_FTP:
1335
- $ftp = SGConfig::get('SG_STORAGE_FTP_CONNECTED');
1336
- if ($ftp) {
1337
- $storageId = SG_STORAGE_FTP;
1338
- }
1339
- break;
1340
- case SG_STORAGE_DROPBOX:
1341
- $dropbox = SGConfig::get('SG_DROPBOX_ACCESS_TOKEN');
1342
- if ($dropbox) {
1343
- $storageId = SG_STORAGE_DROPBOX;
1344
- }
1345
- break;
1346
- case SG_STORAGE_GOOGLE_DRIVE:
1347
- $gdrive = SGConfig::get('SG_GOOGLE_DRIVE_REFRESH_TOKEN');
1348
- if ($gdrive) {
1349
- $storageId = SG_STORAGE_GOOGLE_DRIVE;
1350
- }
1351
- break;
1352
- case SG_STORAGE_AMAZON:
1353
- $amazon = SGConfig::get('SG_STORAGE_AMAZON_CONNECTED');
1354
- if ($amazon) {
1355
- $storageId = SG_STORAGE_AMAZON;
1356
- }
1357
- break;
1358
- case SG_STORAGE_ONE_DRIVE:
1359
- $oneDrive = SGConfig::get('SG_ONE_DRIVE_REFRESH_TOKEN');
1360
- if ($oneDrive) {
1361
- $storageId = SG_STORAGE_ONE_DRIVE;
1362
- }
1363
- break;
1364
- default:
1365
- return;
1366
- }
1367
 
1368
  $sgBackupStorage = SGBackupStorage::getInstance();
1369
- $sgBackupStorage->deleteBackupFromStorage($storageId, $backupName);
1370
  }
1371
  }
1372
 
140
  return array();
141
  }
142
 
143
+ public function downloadBackupArchiveFromCloud($archive, $storage, $size, $backupId = null)
144
  {
145
  $result = false;
146
  if (SGBoot::isFeatureAvailable('DOWNLOAD_FROM_CLOUD')) {
147
+ $result = SGBackupStorage::getInstance()->downloadBackupArchiveFromCloud($storage, $archive, $size, $backupId);
148
  }
149
 
150
  return $result;
343
  $this->prepareBackupLogFile(SG_BACKUP_DIRECTORY.$this->fileName, true);
344
  $this->setBackupPaths();
345
  $this->prepareAdditionalConfigurations();
 
 
 
 
 
 
 
346
  }
347
 
348
  SGPing::update();
349
+
350
+ try {
351
+ $rootDirectory = rtrim(SGConfig::get('SG_APP_ROOT_DIRECTORY'), '/').'/';
352
+
353
  if ($this->databaseBackupAvailable) {
354
  $this->backupDatabase->setFilePath($this->databaseBackupPath);
355
  $this->backupDatabase->setPendingStorageUploads($this->pendingStorageUploads);
369
  }
370
  }
371
 
 
372
  $path = substr($this->databaseBackupPath, strlen($rootDirectory));
373
  $this->backupFiles->addDontExclude($this->databaseBackupPath);
374
  $backupItems = $options['SG_BACKUP_FILE_PATHS'];
387
  }
388
 
389
  if ($this->state->getType() == SG_STATE_TYPE_FILE) {
390
+ $treeFilePath = SG_BACKUP_DIRECTORY.$this->fileName.'/'.SG_TREE_FILE_NAME;
391
+ $treeFilePathWithoutRootDir = substr($treeFilePath, strlen($rootDirectory));
392
+ $this->backupFiles->addDontExclude($treeFilePath);
393
+ $backupItems = $options['SG_BACKUP_FILE_PATHS'];
394
+ $allItems = $backupItems?explode(',', $backupItems):array();
395
+ $allItems[] = $treeFilePathWithoutRootDir;
396
+ $options['SG_BACKUP_FILE_PATHS'] = implode(',', $allItems);
397
+
398
  $this->backupFiles->setPendingStorageUploads($this->pendingStorageUploads);
399
  $this->backupFiles->backup($this->filesBackupPath, $options, $this->state);
400
  $this->didFinishBackup();
411
  // Clear temporary files
412
  $this->clear();
413
  }
414
+ catch (SGException $exception) {
415
+ if ($exception instanceof SGExceptionSkip) {
 
 
416
  $this->setCurrentActionStatusCancelled();
417
  }
418
+ else {
 
419
  SGBackupLog::writeExceptionObject($exception);
420
 
421
  if ($this->state->getType() != SG_STATE_TYPE_UPLOAD) {
422
+ if ($this->databaseBackupAvailable) {
 
423
  $this->backupDatabase->cancel();
424
  }
425
 
513
  {
514
  @unlink(dirname($this->filesBackupPath).'/'.SG_REPORT_FILE_NAME);
515
 
516
+ @unlink(SG_BACKUP_DIRECTORY.$this->fileName.'/'.SG_TREE_FILE_NAME);
517
  @unlink(SG_BACKUP_DIRECTORY.SG_STATE_FILE_NAME);
518
  @unlink(SG_BACKUP_DIRECTORY.SG_RELOADER_STATE_FILE_NAME);
519
  @unlink(SG_PING_FILE_PATH);
1326
  private static function deleteBackupFromCloud($storages, $backupName)
1327
  {
1328
  foreach ($storages as $storage) {
 
1329
  $storage = (int)$storage;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1330
 
1331
  $sgBackupStorage = SGBackupStorage::getInstance();
1332
+ $sgBackupStorage->deleteBackupFromStorage($storage, $backupName);
1333
  }
1334
  }
1335
 
com/core/backup/SGBackupFiles.php CHANGED
@@ -327,6 +327,8 @@ class SGBackupFiles implements SGArchiveDelegate
327
  {
328
  $entries = array();
329
 
 
 
330
  foreach ($allItems as $item) {
331
  $path = $this->rootDirectory.$item;
332
  $this->addDirectoryEntriesInFileTree($path, $entries);
@@ -397,9 +399,12 @@ class SGBackupFiles implements SGArchiveDelegate
397
  }
398
  else {
399
  if (is_readable($path)) {
 
 
400
  $fileEntry = new SGFileEntry();
401
  $fileEntry->setName(basename($path));
402
  $fileEntry->setPath($path);
 
403
 
404
  $this->numberOfEntries++;
405
  array_push($entries, $fileEntry->toArray());
327
  {
328
  $entries = array();
329
 
330
+ file_put_contents(dirname($this->filePath).'/'.SG_TREE_FILE_NAME, "");
331
+
332
  foreach ($allItems as $item) {
333
  $path = $this->rootDirectory.$item;
334
  $this->addDirectoryEntriesInFileTree($path, $entries);
399
  }
400
  else {
401
  if (is_readable($path)) {
402
+ $dateModified = filemtime($path);
403
+
404
  $fileEntry = new SGFileEntry();
405
  $fileEntry->setName(basename($path));
406
  $fileEntry->setPath($path);
407
+ $fileEntry->setDateModified($dateModified);
408
 
409
  $this->numberOfEntries++;
410
  array_push($entries, $fileEntry->toArray());
com/core/backup/SGBackupStorage.php CHANGED
@@ -5,6 +5,7 @@ backupGuardIncludeFile(SG_STORAGE_PATH.'SGDropboxStorage.php');
5
  backupGuardIncludeFile(SG_STORAGE_PATH.'SGOneDriveStorage.php');
6
  backupGuardIncludeFile(SG_STORAGE_PATH.'SGFTPManager.php');
7
  backupGuardIncludeFile(SG_STORAGE_PATH.'SGAmazonStorage.php');
 
8
 
9
  class SGBackupStorage implements SGIStorageDelegate
10
  {
@@ -82,6 +83,11 @@ class SGBackupStorage implements SGIStorageDelegate
82
  return $this->token;
83
  }
84
 
 
 
 
 
 
85
  public static function getInstance()
86
  {
87
  if (!self::$instance)
@@ -116,10 +122,10 @@ class SGBackupStorage implements SGIStorageDelegate
116
  return $listOfFiles;
117
  }
118
 
119
- public function downloadBackupArchiveFromCloud($storageId, $archive, $size)
120
  {
121
  $storage = $this->storageObjectById($storageId, $storageName);
122
- $result = $storage->downloadFile($archive, $size);
123
 
124
  return $result?true:false;
125
  }
@@ -152,7 +158,8 @@ class SGBackupStorage implements SGIStorageDelegate
152
  $type = $row['subtype'];
153
  $backupName = $row['name'];
154
  }
155
- else{
 
156
  $this->actionId = $this->state->getActionId();
157
  $this->currentUploadChunksCount = $this->state->getCurrentUploadChunksCount();
158
  $type = $this->state->getStorageType();
@@ -233,6 +240,12 @@ class SGBackupStorage implements SGIStorageDelegate
233
  $storageClassName = "SGOneDriveStorage";
234
  }
235
  break;
 
 
 
 
 
 
236
  }
237
 
238
  if (!$storageClassName) {
@@ -281,13 +294,11 @@ class SGBackupStorage implements SGIStorageDelegate
281
 
282
  private function updateProgress($progress = null)
283
  {
284
- if (!$progress)
285
- {
286
- $progress = $this->currentUploadChunksCount*100.0/$this->totalUploadChunksCount;
287
  }
288
 
289
- if ($progress>=$this->nextProgressUpdate)
290
- {
291
  $this->nextProgressUpdate += $this->progressUpdateInterval;
292
 
293
  $progress = max($progress, 0);
5
  backupGuardIncludeFile(SG_STORAGE_PATH.'SGOneDriveStorage.php');
6
  backupGuardIncludeFile(SG_STORAGE_PATH.'SGFTPManager.php');
7
  backupGuardIncludeFile(SG_STORAGE_PATH.'SGAmazonStorage.php');
8
+ backupGuardIncludeFile(SG_STORAGE_PATH.'BackupGuardStorage.php');
9
 
10
  class SGBackupStorage implements SGIStorageDelegate
11
  {
83
  return $this->token;
84
  }
85
 
86
+ public function getProgress()
87
+ {
88
+ return $this->nextProgressUpdate;
89
+ }
90
+
91
  public static function getInstance()
92
  {
93
  if (!self::$instance)
122
  return $listOfFiles;
123
  }
124
 
125
+ public function downloadBackupArchiveFromCloud($storageId, $archive, $size, $backupId = null)
126
  {
127
  $storage = $this->storageObjectById($storageId, $storageName);
128
+ $result = $storage->downloadFile($archive, $size, $backupId);
129
 
130
  return $result?true:false;
131
  }
158
  $type = $row['subtype'];
159
  $backupName = $row['name'];
160
  }
161
+ else {
162
+ $this->nextProgressUpdate = $this->state->getProgress()?$this->state->getProgress():$this->progressUpdateInterval;
163
  $this->actionId = $this->state->getActionId();
164
  $this->currentUploadChunksCount = $this->state->getCurrentUploadChunksCount();
165
  $type = $this->state->getStorageType();
240
  $storageClassName = "SGOneDriveStorage";
241
  }
242
  break;
243
+ case SG_STORAGE_BACKUP_GUARD:
244
+ if (SGBoot::isFeatureAvailable('BACKUP_GUARD') && SG_SHOW_BACKUPGUARD_CLOUD) {
245
+ $storageName = 'BackupGuard';
246
+ $storageClassName = "BackupGuard\Storage";
247
+ }
248
+ break;
249
  }
250
 
251
  if (!$storageClassName) {
294
 
295
  private function updateProgress($progress = null)
296
  {
297
+ if (!$progress) {
298
+ $progress = (int)ceil($this->currentUploadChunksCount*100.0/$this->totalUploadChunksCount);
 
299
  }
300
 
301
+ if ($progress >= $this->nextProgressUpdate) {
 
302
  $this->nextProgressUpdate += $this->progressUpdateInterval;
303
 
304
  $progress = max($progress, 0);
com/core/functions.php CHANGED
@@ -1,5 +1,20 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  function backupGuardGetCapabilities()
4
  {
5
  switch (SG_PRODUCT_IDENTIFIER) {
@@ -20,7 +35,7 @@ function backupGuardGetCapabilities()
20
  function convertToReadableSize($size)
21
  {
22
  if (!$size) {
23
- return '';
24
  }
25
 
26
  $base = log($size) / log(1000);
1
  <?php
2
 
3
+ function backupGuardGetSiteUrl()
4
+ {
5
+ if (SG_ENV_ADAPTER == SG_ENV_WORDPRESS) {
6
+ return get_site_url();
7
+ }
8
+ else {
9
+ return sprintf(
10
+ "%s://%s%s",
11
+ isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http',
12
+ $_SERVER['SERVER_NAME'],
13
+ $_SERVER['REQUEST_URI']
14
+ );
15
+ }
16
+ }
17
+
18
  function backupGuardGetCapabilities()
19
  {
20
  switch (SG_PRODUCT_IDENTIFIER) {
35
  function convertToReadableSize($size)
36
  {
37
  if (!$size) {
38
+ return '0';
39
  }
40
 
41
  $base = log($size) / log(1000);
com/core/storage/BackupGuardStorage.php ADDED
@@ -0,0 +1,373 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace BackupGuard;
3
+
4
+ use \SGConfig;
5
+ use \SGExceptionForbidden;
6
+ require_once(SG_STORAGE_PATH.'SGStorage.php');
7
+ require_once(SG_LIB_PATH.'BackupGuard/Client.php');
8
+
9
+ class Storage extends \SGStorage
10
+ {
11
+ private $client = null;
12
+ private $accessToken = '';
13
+ private $refreshToken = '';
14
+
15
+ public function init()
16
+ {
17
+ $this->client = new Client();
18
+ $this->client->setUploadAccessToken(SGConfig::get('SG_BACKUPGUARD_UPLOAD_ACCESS_TOKEN'));
19
+ }
20
+
21
+ public function setAccessToken($accessToken)
22
+ {
23
+ $this->accessToken = $accessToken;
24
+ }
25
+
26
+ private function getRefreshToken()
27
+ {
28
+ return SGConfig::get('SG_BACKUPGUARD_UPLOAD_REFRESH_TOKEN', true);
29
+ }
30
+
31
+ private function getProfileId()
32
+ {
33
+ return SGConfig::get("BACKUP_GUARD_PROFILE_ID");
34
+ }
35
+
36
+ private function getAccessToken(&$expirationTs = 0)
37
+ {
38
+ $expirationTs = (int)SGConfig::get('SG_BACKUPGUARD_UPLOAD_ACCESS_TOKEN_EXPIRES');
39
+ return SGConfig::get('SG_BACKUPGUARD_UPLOAD_ACCESS_TOKEN');
40
+ }
41
+
42
+ public function connect()
43
+ {
44
+ if ($this->isConnected()) {
45
+ return;
46
+ }
47
+
48
+ $args = func_get_args();
49
+ if (!count($args)) {
50
+ throw new SGExceptionForbidden('Invalid credentials');
51
+ }
52
+
53
+ $email = $args[0];
54
+ $password = $args[1];
55
+ $tmp = isset($args[2])?$args[2]:false;
56
+
57
+ if (!$email || !$password) {
58
+ throw new SGExceptionForbidden('Invalid credentials');
59
+ }
60
+
61
+ if ($tmp) {
62
+ $tokens = $this->client->createAccessToken(
63
+ SG_BACKUPGUARD_UPLOAD_CLIENT_ID,
64
+ SG_BACKUPGUARD_UPLOAD_CLIENT_SECRET,
65
+ $email,
66
+ $password
67
+ );
68
+ }
69
+ else {
70
+ $tokens = $this->client->createUploadAccessToken(
71
+ SG_BACKUPGUARD_UPLOAD_CLIENT_ID,
72
+ SG_BACKUPGUARD_UPLOAD_CLIENT_SECRET,
73
+ $email,
74
+ $password,
75
+ SG_BACKUPGUARD_UPLOAD_SCOPE
76
+ );
77
+ }
78
+
79
+ if (empty($tokens)) {
80
+ throw new SGExceptionForbidden('Invalid credentials');
81
+ }
82
+
83
+ $this->setTokens(
84
+ $tokens['access_token'],
85
+ time()+Config::TOKEN_EXPIRES,
86
+ $tokens['refresh_token'],
87
+ $tmp
88
+ );
89
+
90
+ return $tokens['access_token'];
91
+ }
92
+
93
+ private function setTokens($accessToken = '', $accessTokenExpires = 0, $refreshToken = '', $tmp = false)
94
+ {
95
+ $this->accessToken = $accessToken;
96
+ $this->refreshToken = $refreshToken;
97
+
98
+ if (!$tmp) {
99
+ SGConfig::set('SG_BACKUPGUARD_UPLOAD_ACCESS_TOKEN', $accessToken);
100
+ SGConfig::set('SG_BACKUPGUARD_UPLOAD_ACCESS_TOKEN_EXPIRES', $accessTokenExpires);
101
+ SGConfig::set('SG_BACKUPGUARD_UPLOAD_REFRESH_TOKEN', $refreshToken);
102
+
103
+ $this->client->setUploadAccessToken($accessToken);
104
+ }
105
+ }
106
+
107
+ public function connectOffline()
108
+ {
109
+ if ($this->isConnected()) {
110
+ return;
111
+ }
112
+
113
+ $refreshToken = $this->getRefreshToken();
114
+
115
+ if (!$refreshToken) {
116
+ throw new \SGExceptionNotFound('Refresh token not found');
117
+ }
118
+
119
+ // refresh access token using the refresh token
120
+ $tokens = $this->client->refreshAccessToken(SG_BACKUPGUARD_UPLOAD_CLIENT_ID, SG_BACKUPGUARD_UPLOAD_CLIENT_SECRET, $refreshToken);
121
+
122
+ // set the new access token
123
+ $this->setTokens(
124
+ $tokens['access_token'],
125
+ time()+Config::TOKEN_EXPIRES,
126
+ $tokens['refresh_token']
127
+ );
128
+
129
+ $this->connected = true;
130
+ }
131
+
132
+ public function checkConnected()
133
+ {
134
+ $accessToken = $this->getAccessToken($expirationTs);
135
+ // to avoid case where token can expire in the middle of upload
136
+ $this->connected = ($accessToken&&$expirationTs>=(time()+60))?true:false;
137
+
138
+ if ($this->connected) {
139
+ $this->client->setUploadAccessToken(SGConfig::get('SG_BACKUPGUARD_UPLOAD_ACCESS_TOKEN'));
140
+ }
141
+ }
142
+
143
+ public function getListOfFiles()
144
+ {
145
+ if (!$this->isConnected()) {
146
+ $this->connectOffline();
147
+ }
148
+
149
+ $profileId = $this->getProfileId();
150
+
151
+ if ($profileId) {
152
+ $list = $this->client->getAllBackups($profileId);
153
+ return $list;
154
+ }
155
+
156
+ return array();
157
+ }
158
+
159
+ public function createFolder($folderName)
160
+ {
161
+
162
+ }
163
+
164
+ public function downloadFile($filePath, $size, $backupId = null)
165
+ {
166
+ $offset = 0;
167
+ $result = false;
168
+ $chunk = 2000000; // 2MB
169
+ $loaclFilePath = SG_BACKUP_DIRECTORY.basename($filePath);
170
+ $serverFilePath = $filePath;
171
+
172
+ $fp = @fopen($loaclFilePath, 'ab');
173
+
174
+ while ($size > $offset) {
175
+ if (!file_exists($loaclFilePath)) {
176
+ $result = false;
177
+ break;
178
+ }
179
+
180
+ $data = $this->client->downloadFile($backupId, $serverFilePath, $offset, $chunk);
181
+
182
+ if (strlen($data)) {
183
+ fwrite($fp, $data);
184
+ }
185
+ else {
186
+ break;
187
+ }
188
+
189
+ $offset += $chunk;
190
+ $result = true;
191
+ }
192
+
193
+ return $result;
194
+ }
195
+
196
+ private function saveStateData($fileOffset, $uploadId, $backupId, $profileId)
197
+ {
198
+ $token = $this->delegate->getToken();
199
+ $actionId = $this->delegate->getActionId();
200
+ $pendingStorageUploads = $this->delegate->getPendingStorageUploads();
201
+ $currentUploadChunksCount = $this->delegate->getCurrentUploadChunksCount();
202
+ $progress = $this->delegate->getProgress();
203
+
204
+ $this->state->setCurrentUploadChunksCount($currentUploadChunksCount);
205
+ $this->state->setStorageType(SG_STORAGE_BACKUP_GUARD);
206
+ $this->state->setPendingStorageUploads($pendingStorageUploads);
207
+ $this->state->setToken($token);
208
+ $this->state->setActionId($actionId);
209
+ $this->state->setAction(SG_STATE_ACTION_UPLOADING_BACKUP);
210
+ $this->state->setProgress($progress);
211
+
212
+ $this->state->setOffset($fileOffset);
213
+ $this->state->setUploadId($uploadId);
214
+ $this->state->setBackupId($backupId);
215
+ $this->state->setProfileId($profileId);
216
+
217
+ $this->state->save();
218
+ }
219
+
220
+ public function uploadFile($filePath)
221
+ {
222
+ if (!$this->isConnected()) {
223
+ throw new SGExceptionForbidden('Permission denied. Authentication required.');
224
+ }
225
+
226
+ if (!file_exists($filePath) || !is_readable($filePath)) {
227
+ throw new \SGExceptionNotFound('File does not exist or is not readable: '.$filePath);
228
+ }
229
+
230
+ $chunkSizeBytes = 2000000;
231
+ $fileSize = backupGuardRealFilesize($filePath);
232
+ $backupFileName = $this->state->getBackupFileName().'.sgbp';
233
+
234
+ $this->delegate->willStartUpload((int)ceil($fileSize/$chunkSizeBytes));
235
+
236
+ $handle = fopen($filePath, "rb");
237
+ $byteOffset = $this->state->getOffset();
238
+ fseek($handle, $byteOffset);
239
+
240
+ if ($this->state->getAction() == SG_STATE_ACTION_PREPARING_STATE_FILE) {
241
+
242
+ $profileId = $this->getProfileId();
243
+ if ($profileId) {
244
+ $result = $this->client->createBackup($profileId, $backupFileName);
245
+ if (count($result)) {
246
+ $profileId = $result['profile_id'];
247
+ $backupId = $result['backup_id'];
248
+ }
249
+ else {
250
+ throw new SGExceptionForbidden('Something went wrong. Unable to create backup.');
251
+ }
252
+ }
253
+ else {
254
+ throw new SGExceptionForbidden('Something went wrong. Unable to create profile.');
255
+ }
256
+
257
+ $data = fread($handle, $chunkSizeBytes);
258
+ $result = $this->client->createUploadSession($backupId, $data);
259
+ if (count($result)) {
260
+ $uploadId = $result['upload_id'];
261
+ $offset = $result['offset'];
262
+ }
263
+ else {
264
+ throw new SGExceptionForbidden('Something went wrong. Unable to start upload session.');
265
+ }
266
+
267
+ $byteOffset += strlen($data);
268
+ }
269
+ else {
270
+ $uploadId = $this->state->getUploadId();
271
+ $backupId = $this->state->getBackupId();
272
+ $profileId = $this->state->getProfileId();
273
+ }
274
+
275
+ \SGPing::update();
276
+
277
+ while ($byteOffset < $fileSize) {
278
+ $data = fread($handle, $chunkSizeBytes);
279
+ $result = $this->client->resumeUploadSession($backupId, $uploadId, $byteOffset, $data);
280
+ if (count($result)) {
281
+ $uploadId = $result['upload_id'];
282
+ $offset = $result['offset'];
283
+ }
284
+ else {
285
+ throw new SGExceptionForbidden('Something went wrong. Unable to start upload session.');
286
+ }
287
+
288
+ if (!$this->delegate->shouldUploadNextChunk()) {
289
+ fclose($handle);
290
+ return;
291
+ }
292
+
293
+ \SGPing::update();
294
+ $byteOffset += strlen($data);
295
+ $shouldReload = $this->shouldReload();
296
+ if ($shouldReload && backupGuardIsReloadEnabled()) {
297
+ $this->saveStateData($byteOffset, $uploadId, $backupId, $profileId);
298
+ @fclose($handle);
299
+ $this->reload();
300
+ }
301
+ }
302
+
303
+ $path = $backupFileName;
304
+
305
+ $this->client->finalizeUpload($backupId, $uploadId, $path);
306
+ $this->client->finalizeBackup($backupId);
307
+ fclose($handle);
308
+ }
309
+
310
+ public function deleteFile($fileName)
311
+ {
312
+
313
+ }
314
+
315
+ public function deleteFolder($folderName)
316
+ {
317
+
318
+ }
319
+
320
+ public function fileExists($path)
321
+ {
322
+
323
+ }
324
+
325
+ public function checkCloudAccount()
326
+ {
327
+ $this->client->setAccessToken($this->accessToken);
328
+ $account = $this->client->checkCloudAccount();
329
+ return $account;
330
+ }
331
+
332
+ public function getProfiles()
333
+ {
334
+ $profiles = array();
335
+
336
+ try {
337
+ $profiles = $this->client->getProfiles();
338
+ }
339
+ catch (UnauthorizedException $exp) {
340
+ $this->connected = false;
341
+ $this->connectOffline();
342
+ $profiles = $this->getProfiles();
343
+ }
344
+ catch (Exception $exp) {
345
+ $profileId = $this->createProfile();
346
+ $profiles[] = array(
347
+ 'id' => $profileId,
348
+ 'name' => $profileName
349
+ );
350
+ }
351
+
352
+ return $profiles;
353
+ }
354
+
355
+ public function createProfile($name = null)
356
+ {
357
+ $profileName = $name?$name:backupGuardGetSiteUrl();
358
+ try {
359
+ $result = $this->client->createProfile($profileName);
360
+ $profileId = $result['profile_id'];
361
+ }
362
+ catch (UnauthorizedException $exp) {
363
+ $this->connected = false;
364
+ $this->connectOffline();
365
+ $profileId = $this->createProfile();
366
+ }
367
+ catch (Exception $exp) {
368
+ $profileId = 0;
369
+ }
370
+
371
+ return $profileId;
372
+ }
373
+ }
com/core/storage/SGDropboxStorage.php CHANGED
@@ -130,7 +130,7 @@ class SGDropboxStorage extends SGStorage
130
  private $fd = null;
131
  private $filePath = '';
132
 
133
- public function downloadFile($file, $size)
134
  {
135
  if (!$file) {
136
  return false;
@@ -176,7 +176,9 @@ class SGDropboxStorage extends SGStorage
176
  $actionId = $this->delegate->getActionId();
177
  $pendingStorageUploads = $this->delegate->getPendingStorageUploads();
178
  $currentUploadChunksCount = $this->delegate->getCurrentUploadChunksCount();
179
-
 
 
180
  $this->state->setCurrentUploadChunksCount($currentUploadChunksCount);
181
  $this->state->setStorageType(SG_STORAGE_DROPBOX);
182
  $this->state->setPendingStorageUploads($pendingStorageUploads);
130
  private $fd = null;
131
  private $filePath = '';
132
 
133
+ public function downloadFile($file, $size, $backupId = null)
134
  {
135
  if (!$file) {
136
  return false;
176
  $actionId = $this->delegate->getActionId();
177
  $pendingStorageUploads = $this->delegate->getPendingStorageUploads();
178
  $currentUploadChunksCount = $this->delegate->getCurrentUploadChunksCount();
179
+ $progress = $this->delegate->getProgress();
180
+
181
+ $this->state->setProgress($progress);
182
  $this->state->setCurrentUploadChunksCount($currentUploadChunksCount);
183
  $this->state->setStorageType(SG_STORAGE_DROPBOX);
184
  $this->state->setPendingStorageUploads($pendingStorageUploads);
com/core/storage/SGStorage.php CHANGED
@@ -37,7 +37,7 @@ abstract class SGStorage
37
  abstract public function createFolder($folderName);
38
 
39
  /* Download file from Storage*/
40
- abstract public function downloadFile($filePath, $size);
41
 
42
  /* Upload local file to Storage */
43
  abstract public function uploadFile($filePath);
37
  abstract public function createFolder($folderName);
38
 
39
  /* Download file from Storage*/
40
+ abstract public function downloadFile($filePath, $size, $backupId = null);
41
 
42
  /* Upload local file to Storage */
43
  abstract public function uploadFile($filePath);
com/lib/BackupGuard/Client.php CHANGED
@@ -1,16 +1,19 @@
1
  <?php
2
 
3
  namespace BackupGuard;
 
4
 
5
  require_once(dirname(__FILE__).'/Helper.php');
6
 
7
  class Client
8
  {
9
  private $accessToken = null;
 
10
 
11
- public function __construct($accessToken = null)
12
  {
13
  $this->setAccessToken($accessToken);
 
14
  }
15
 
16
  public function getAccessToken()
@@ -18,11 +21,21 @@ class Client
18
  return $this->accessToken;
19
  }
20
 
 
 
 
 
 
21
  public function setAccessToken($accessToken)
22
  {
23
  $this->accessToken = $accessToken;
24
  }
25
 
 
 
 
 
 
26
  public function createAccessToken($clientId, $clientSecret, $email, $password)
27
  {
28
  $response = Helper::sendPostRequest(
@@ -294,4 +307,394 @@ class Client
294
 
295
  return $response->getBodyParam('survey');
296
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  }
1
  <?php
2
 
3
  namespace BackupGuard;
4
+ use \SGConfig;
5
 
6
  require_once(dirname(__FILE__).'/Helper.php');
7
 
8
  class Client
9
  {
10
  private $accessToken = null;
11
+ private $uploadAccessToken = null;
12
 
13
+ public function __construct($accessToken = null, $uploadAccessToken = null)
14
  {
15
  $this->setAccessToken($accessToken);
16
+ $this->setUploadAccessToken($uploadAccessToken);
17
  }
18
 
19
  public function getAccessToken()
21
  return $this->accessToken;
22
  }
23
 
24
+ public function getUploadAccessToken()
25
+ {
26
+ return $this->uploadAccessToken;
27
+ }
28
+
29
  public function setAccessToken($accessToken)
30
  {
31
  $this->accessToken = $accessToken;
32
  }
33
 
34
+ public function setUploadAccessToken($uploadAccessToken)
35
+ {
36
+ $this->uploadAccessToken = $uploadAccessToken;
37
+ }
38
+
39
  public function createAccessToken($clientId, $clientSecret, $email, $password)
40
  {
41
  $response = Helper::sendPostRequest(
307
 
308
  return $response->getBodyParam('survey');
309
  }
310
+
311
+ public function createProfile($profileName, $master = 1, $profileType = 4)
312
+ {
313
+ Helper::requiredParam('profile_type', $profileType);
314
+ Helper::requiredParam('profile_name', $profileName);
315
+
316
+ $params = array(
317
+ 'profile_type' => $profileType,
318
+ 'profile_name' => $profileName,
319
+ 'master' => $master
320
+ );
321
+
322
+ $response = Helper::sendPostRequest(
323
+ '/backups',
324
+ $params,
325
+ array(
326
+ 'access_token' => $this->getUploadAccessToken()
327
+ )
328
+ );
329
+
330
+ Helper::validateResponse($response);
331
+
332
+ $profileId = $response->getBodyParam('profile_id');
333
+ $backupId = $response->getBodyParam('backup_id');
334
+
335
+ return array(
336
+ 'profile_id' => $profileId,
337
+ 'backup_id' => $backupId
338
+ );
339
+ }
340
+
341
+ public function createBackup($profileId, $backupName, $master = 0)
342
+ {
343
+ Helper::requiredParam('profile_id', $profileId);
344
+ Helper::requiredParam('backup_name', $backupName);
345
+ if (\SGConfig::get('BACKUP_GUARD_CREATE_MASTER')) {
346
+ $master = 1;
347
+ SGConfig::set('BACKUP_GUARD_CREATE_MASTER', 0);
348
+ }
349
+
350
+ $params = array(
351
+ 'profile_id' => $profileId,
352
+ 'master' => $master
353
+ );
354
+
355
+ $response = Helper::sendPostRequest(
356
+ '/backups',
357
+ $params,
358
+ array(
359
+ 'access_token' => $this->getUploadAccessToken()
360
+ )
361
+ );
362
+
363
+ Helper::validateResponse($response);
364
+
365
+ $profileId = $response->getBodyParam('profile_id');
366
+ $backupId = $response->getBodyParam('backup_id');
367
+
368
+ return array(
369
+ 'profile_id' => $profileId,
370
+ 'backup_id' => $backupId
371
+ );
372
+ }
373
+
374
+ public function getBackupChanges($profileId, $files)
375
+ {
376
+ Helper::requiredParam('profile_id', $profileId);
377
+ Helper::requiredParam('files', $files);
378
+
379
+ $params = array(
380
+ 'profile_id' => $profileId,
381
+ 'files' => $files
382
+ );
383
+
384
+ $response = Helper::sendPostRequest(
385
+ '/backups/get_changes',
386
+ $params
387
+ );
388
+
389
+ Helper::validateResponse($response);
390
+
391
+ return $response->getBodyParam('files');
392
+ }
393
+
394
+ public function finalizeBackup($backupId)
395
+ {
396
+ Helper::requiredParam('backup_id', $backupId);
397
+
398
+ $params = array(
399
+ 'backup_id' => $backupId
400
+ );
401
+
402
+ $response = Helper::sendPostRequest(
403
+ '/backups/finalize',
404
+ $params,
405
+ array(
406
+ 'access_token' => $this->getUploadAccessToken()
407
+ )
408
+ );
409
+
410
+ Helper::validateResponse($response);
411
+
412
+ return;
413
+ }
414
+
415
+ public function getBackupContents($backupId, $root, $recursive)
416
+ {
417
+ Helper::requiredParam('backup_id', $backupId);
418
+
419
+ $params = array(
420
+ 'backup_id' => $backupId,
421
+ 'root' => $root,
422
+ 'recursive' => $recursive
423
+ );
424
+
425
+ $response = Helper::sendGetRequest(
426
+ '/backups/ls',
427
+ $params
428
+ );
429
+
430
+ Helper::validateResponse($response);
431
+
432
+ return $response->getBodyParam('files');
433
+ }
434
+
435
+ public function getAllBackups($profileId)
436
+ {
437
+ Helper::requiredParam('profile_id', $profileId);
438
+
439
+ $response = Helper::sendGetRequest(
440
+ '/backups/'.$profileId,
441
+ array(),
442
+ array(
443
+ 'access_token' => $this->getUploadAccessToken()
444
+ )
445
+ );
446
+
447
+ Helper::validateResponse($response);
448
+
449
+ return $response->getBodyParam('backups');
450
+ }
451
+
452
+ public function createUploadSession($backupId, $data)
453
+ {
454
+ Helper::requiredParam('backup_id', $backupId);
455
+
456
+ $response = Helper::sendRequest(
457
+ '/upload/'.$backupId,
458
+ 'PUT',
459
+ $data,
460
+ array(
461
+ 'access_token' => $this->getUploadAccessToken()
462
+ )
463
+ );
464
+
465
+ Helper::validateResponse($response);
466
+
467
+ $uploadId = $response->getBodyParam('upload_id');
468
+ $offset = $response->getBodyParam('offset');
469
+
470
+ return array(
471
+ 'upload_id' => $uploadId,
472
+ 'offset' => $offset
473
+ );
474
+ }
475
+
476
+ public function resumeUploadSession($backupId, $uploadId, $offset, $data)
477
+ {
478
+ Helper::requiredParam('backup_id', $backupId);
479
+ Helper::requiredParam('upload_id', $uploadId);
480
+ Helper::requiredParam('offset', $offset);
481
+
482
+ $response = Helper::sendRequest(
483
+ '/upload/'.$backupId.'/'.$uploadId.'/'.$offset,
484
+ 'PUT',
485
+ $data,
486
+ array(
487
+ 'access_token' => $this->getUploadAccessToken()
488
+ )
489
+ );
490
+
491
+ Helper::validateResponse($response);
492
+
493
+ $uploadId = $response->getBodyParam('upload_id');
494
+ $offset = $response->getBodyParam('offset');
495
+
496
+ return array(
497
+ 'upload_id' => $uploadId,
498
+ 'offset' => $offset
499
+ );
500
+ }
501
+
502
+ public function finalizeUpload($backupId, $uploadId, $path, $db = 0)
503
+ {
504
+ Helper::requiredParam('backup_id', $backupId);
505
+ Helper::requiredParam('upload_id', $uploadId);
506
+ Helper::requiredParam('path', $path);
507
+
508
+ $params = array(
509
+ 'upload_id' => $uploadId,
510
+ 'path' => $path,
511
+ 'db' => $db
512
+ );
513
+
514
+ $response = Helper::sendPostRequest(
515
+ '/upload/'.$backupId.'/finalize',
516
+ $params,
517
+ array(
518
+ 'access_token' => $this->getUploadAccessToken()
519
+ )
520
+ );
521
+
522
+ Helper::validateResponse($response);
523
+
524
+ return;
525
+ }
526
+
527
+ public function createFolder($backupId, $path)
528
+ {
529
+ Helper::requiredParam('backup_id', $backupId);
530
+ Helper::requiredParam('path', $path);
531
+
532
+ $params = array(
533
+ 'backup_id' => $backupId
534
+ );
535
+
536
+ $response = Helper::sendGetRequest(
537
+ '/files/folder',
538
+ $params
539
+ );
540
+
541
+ Helper::validateResponse($response);
542
+
543
+ return;
544
+ }
545
+
546
+ public function downloadFile($backupId, $path, $offset, $limit)
547
+ {
548
+ Helper::requiredParam('backup_id', $backupId);
549
+ Helper::requiredParam('path', $path);
550
+ Helper::requiredParam('offset', $offset);
551
+ Helper::requiredParam('limit', $limit);
552
+
553
+ $params = array(
554
+ 'backup_id' => $backupId,
555
+ 'path' => $path,
556
+ 'offset' => $offset,
557
+ 'limit' => $limit
558
+ );
559
+
560
+ $response = Helper::sendPostRequest(
561
+ '/files',
562
+ $params,
563
+ array(
564
+ 'access_token' => $this->getUploadAccessToken()
565
+ )
566
+ );
567
+
568
+ Helper::validateResponse($response);
569
+
570
+ return $response->getBody();
571
+ }
572
+
573
+ public function checkCloudAccount()
574
+ {
575
+ Helper::requiredParam('access_token', $this->getAccessToken());
576
+
577
+ $response = Helper::sendGetRequest(
578
+ '/users/cloud',
579
+ array(),
580
+ array(
581
+ 'access_token' => $this->getAccessToken()
582
+ )
583
+ );
584
+
585
+ Helper::validateResponse($response);
586
+
587
+ $trial = $response->getBodyParam('trial');
588
+ $usedStorage = $response->getBodyParam('used_storage');
589
+ $lastPaymentDate = $response->getBodyParam('last_payment_date');
590
+ $paymentFrequency = $response->getBodyParam('payment_frequency');
591
+ $package = $response->getBodyParam('package');
592
+
593
+ return array(
594
+ 'trial' => $trial,
595
+ 'usedStorage' => $usedStorage,
596
+ 'lastPaymentDate' => $lastPaymentDate,
597
+ 'paymentFrequency' => $paymentFrequency,
598
+ 'package' => $package
599
+ );
600
+ }
601
+
602
+ public function checkEmailExists($email)
603
+ {
604
+ Helper::requiredParam('email', $email);
605
+
606
+ $response = Helper::sendGetRequest(
607
+ '/users/email/'.$email,
608
+ array()
609
+ );
610
+
611
+ Helper::validateResponse($response);
612
+
613
+ return $response->getBodyParam('found');
614
+ }
615
+
616
+ public function addCloudAccountToUser()
617
+ {
618
+ Helper::requiredParam('access_token', $this->getAccessToken());
619
+
620
+ $response = Helper::sendPostRequest(
621
+ '/users/cloud',
622
+ array(),
623
+ array(
624
+ 'access_token' => $this->getAccessToken()
625
+ )
626
+ );
627
+
628
+ Helper::validateResponse($response);
629
+
630
+ return;
631
+ }
632
+
633
+ public function createCloudUser($email, $firstname, $lastname)
634
+ {
635
+ Helper::requiredParam('email', $email);
636
+ Helper::requiredParam('firstname', $firstname);
637
+ Helper::requiredParam('lastname', $lastname);
638
+
639
+ $response = Helper::sendPostRequest(
640
+ '/users',
641
+ array(
642
+ 'email' => $email,
643
+ 'firstname' => $firstname,
644
+ 'lastname' => $lastname
645
+ )
646
+ );
647
+
648
+ Helper::validateResponse($response);
649
+
650
+ $email = $response->getBodyParam('email');
651
+ $password = $response->getBodyParam('password');
652
+
653
+ return array(
654
+ 'password' => $password,
655
+ 'email' => $email
656
+ );
657
+ }
658
+
659
+ public function createUploadAccessToken($clientId, $clientSecret, $email, $password, $scope)
660
+ {
661
+ $response = Helper::sendPostRequest(
662
+ '/token',
663
+ array(
664
+ 'grant_type' => 'password',
665
+ 'scope' => $scope,
666
+ 'client_id' => $clientId,
667
+ 'client_secret' => $clientSecret,
668
+ 'email' => $email,
669
+ 'password' => $password
670
+ )
671
+ );
672
+
673
+ Helper::validateResponse($response);
674
+
675
+ $accessToken = $response->getBodyParam('access_token');
676
+ $refreshToken = $response->getBodyParam('refresh_token');
677
+
678
+ return array(
679
+ 'access_token' => $accessToken,
680
+ 'refresh_token' => $refreshToken
681
+ );
682
+ }
683
+
684
+ public function getProfiles()
685
+ {
686
+ Helper::requiredParam('access_token', $this->getUploadAccessToken());
687
+
688
+ $response = Helper::sendGetRequest(
689
+ '/profiles',
690
+ array(),
691
+ array(
692
+ 'access_token' => $this->getUploadAccessToken()
693
+ )
694
+ );
695
+
696
+ Helper::validateResponse($response);
697
+
698
+ return $response->getBodyParam('profiles');
699
+ }
700
  }
com/lib/BackupGuard/Helper.php CHANGED
@@ -19,7 +19,7 @@ class Helper
19
  {
20
  public static function requiredParam($name, $var)
21
  {
22
- if (empty($var)) {
23
  throw new BadRequestException("Missing required argument: ".$name, 400);
24
  }
25
  }
@@ -72,6 +72,18 @@ class Helper
72
  return $request->sendGetRequest();
73
  }
74
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  public static function validateResponse($response)
76
  {
77
  if (!$response instanceof \SGResponse) {
19
  {
20
  public static function requiredParam($name, $var)
21
  {
22
+ if (is_null($var)) {
23
  throw new BadRequestException("Missing required argument: ".$name, 400);
24
  }
25
  }
72
  return $request->sendGetRequest();
73
  }
74
 
75
+ public static function sendRequest($path, $type, $params = array(), $headers = array())
76
+ {
77
+ $url = Config::URL.$path;
78
+
79
+ $request = \SGRequest::getInstance();
80
+ $request->setUrl($url);
81
+ $request->setHeaders($headers);
82
+ $request->setParams($params);
83
+ $request->setGetWithQueryParams(false);
84
+ return $request->sendRequest($type);
85
+ }
86
+
87
  public static function validateResponse($response)
88
  {
89
  if (!$response instanceof \SGResponse) {
com/lib/Request/SGRequestAdapterWordpress.php CHANGED
@@ -54,7 +54,8 @@ class SGRequestAdapterWordpress implements SGIRequestAdapter
54
  $args = array(
55
  'headers' => $this->headers,
56
  'sslverify' => false,
57
- 'stream' => $this->stream
 
58
  );
59
 
60
  if (!function_exists("curl_init")) {
@@ -72,7 +73,7 @@ class SGRequestAdapterWordpress implements SGIRequestAdapter
72
  // $body = http_build_query($this->params, '', '&');
73
  $body = $this->params;
74
  }
75
-
76
  $args = $this->getRequestArgs();
77
  $args['body'] = $body;
78
 
@@ -143,11 +144,11 @@ class SGRequestAdapterWordpress implements SGIRequestAdapter
143
  {
144
  $body = null;
145
 
146
- if (count($this->params)) {
147
  // $body = http_build_query($this->params, '', '&');
148
  $body = $this->params;
149
  }
150
-
151
  $args = $this->getRequestArgs();
152
  $args['body'] = $body;
153
  $args['method'] = $type;
54
  $args = array(
55
  'headers' => $this->headers,
56
  'sslverify' => false,
57
+ 'stream' => $this->stream,
58
+ 'timeout' => 30
59
  );
60
 
61
  if (!function_exists("curl_init")) {
73
  // $body = http_build_query($this->params, '', '&');
74
  $body = $this->params;
75
  }
76
+
77
  $args = $this->getRequestArgs();
78
  $args['body'] = $body;
79
 
144
  {
145
  $body = null;
146
 
147
+ if ($this->params) {
148
  // $body = http_build_query($this->params, '', '&');
149
  $body = $this->params;
150
  }
151
+
152
  $args = $this->getRequestArgs();
153
  $args['body'] = $body;
154
  $args['method'] = $type;
com/lib/SGAuthClient.php CHANGED
@@ -8,12 +8,18 @@ class SGAuthClient
8
  private $client = null;
9
  private $accessToken = '';
10
  private $accessTokenExpires = 0;
 
 
 
11
 
12
  private function __construct()
13
  {
14
  $this->accessToken = SGConfig::get('SG_BACKUPGUARD_ACCESS_TOKEN', true);
15
  $this->accessTokenExpires = SGConfig::get('SG_BACKUPGUARD_ACCESS_TOKEN_EXPIRES', true);
16
 
 
 
 
17
  $this->client = new BackupGuard\Client($this->accessToken);
18
  }
19
 
@@ -36,6 +42,11 @@ class SGAuthClient
36
  return $this->accessToken;
37
  }
38
 
 
 
 
 
 
39
  public function login($email, $password)
40
  {
41
  try {
@@ -268,4 +279,27 @@ class SGAuthClient
268
 
269
  return $result;
270
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  }
8
  private $client = null;
9
  private $accessToken = '';
10
  private $accessTokenExpires = 0;
11
+
12
+ private $uploadAccessToken = '';
13
+ private $uploadAccessTokenExpires = 0;
14
 
15
  private function __construct()
16
  {
17
  $this->accessToken = SGConfig::get('SG_BACKUPGUARD_ACCESS_TOKEN', true);
18
  $this->accessTokenExpires = SGConfig::get('SG_BACKUPGUARD_ACCESS_TOKEN_EXPIRES', true);
19
 
20
+ $this->uploadAccessToken = SGConfig::get('SG_BACKUPGUARD_UPLOAD_ACCESS_TOKEN', true);
21
+ $this->uploadAccessTokenExpires = SGConfig::get('SG_BACKUPGUARD_UPLOAD_ACCESS_TOKEN_EXPIRES', true);
22
+
23
  $this->client = new BackupGuard\Client($this->accessToken);
24
  }
25
 
42
  return $this->accessToken;
43
  }
44
 
45
+ public function getUploadAccessToken()
46
+ {
47
+ return $this->uploadAccessToken;
48
+ }
49
+
50
  public function login($email, $password)
51
  {
52
  try {
279
 
280
  return $result;
281
  }
282
+
283
+ public function createUploadAccessToken($email, $password)
284
+ {
285
+ $tokens = $this->client->createUploadAccessToken(
286
+ SG_BACKUPGUARD_UPLOAD_CLIENT_ID,
287
+ SG_BACKUPGUARD_UPLOAD_CLIENT_SECRET,
288
+ $email,
289
+ $password,
290
+ SG_BACKUPGUARD_UPLOAD_SCOPE
291
+ );
292
+
293
+ $refreshToken = $tokens['refresh_token'];
294
+ $this->uploadAccessToken = $tokens['access_token'];
295
+ $this->uploadAccessTokenExpires = time()+BackupGuard\Config::TOKEN_EXPIRES;
296
+ $this->client->setUploadAccessToken($this->uploadAccessToken);
297
+
298
+ SGConfig::set('SG_BACKUPGUARD_UPLOAD_ACCESS_TOKEN', $this->uploadAccessToken, true);
299
+ SGConfig::set('SG_BACKUPGUARD_UPLOAD_ACCESS_TOKEN_EXPIRES', $this->uploadAccessTokenExpires, true);
300
+
301
+ SGConfig::set('SG_BACKUPGUARD_UPLOAD_REFRESH_TOKEN', $refreshToken, true);
302
+
303
+ return $tokens['access_token'];
304
+ }
305
  }
com/lib/SGCallback.php CHANGED
@@ -1,8 +1,5 @@
1
  <?php
2
 
3
- /**
4
- *
5
- */
6
  class SGCallback
7
  {
8
  private $className;
@@ -42,7 +39,7 @@ class SGCallback
42
  $obj->$methodName($this->params);
43
  }
44
 
45
- public function toString()
46
  {
47
  return json_encode(array(
48
  'class' => $this->className,
1
  <?php
2
 
 
 
 
3
  class SGCallback
4
  {
5
  private $className;
39
  $obj->$methodName($this->params);
40
  }
41
 
42
+ public function __toString()
43
  {
44
  return json_encode(array(
45
  'class' => $this->className,
com/lib/SGFileEntry.php CHANGED
@@ -10,6 +10,7 @@ class SGFileEntry implements SGEntry
10
  private $name;
11
  private $type;
12
  private $path;
 
13
 
14
  public function __construct()
15
  {
@@ -41,12 +42,23 @@ class SGFileEntry implements SGEntry
41
  $this->path = $path;
42
  }
43
 
 
 
 
 
 
 
 
 
 
 
44
  public function toArray()
45
  {
46
  $fileEntry = array(
47
  'name' => $this->getName(),
48
  'path' => $this->getPath(),
49
- 'type' => $this->getType()
 
50
  );
51
 
52
  return $fileEntry;
10
  private $name;
11
  private $type;
12
  private $path;
13
+ private $dateModified;
14
 
15
  public function __construct()
16
  {
42
  $this->path = $path;
43
  }
44
 
45
+ public function setDateModified($date)
46
+ {
47
+ $this->dateModified = $date;
48
+ }
49
+
50
+ public function getDateModified()
51
+ {
52
+ return $this->dateModified;
53
+ }
54
+
55
  public function toArray()
56
  {
57
  $fileEntry = array(
58
  'name' => $this->getName(),
59
  'path' => $this->getPath(),
60
+ 'type' => $this->getType(),
61
+ 'date_modified' => $this->getDateModified()
62
  );
63
 
64
  return $fileEntry;
com/lib/SGReloader.php CHANGED
@@ -40,7 +40,7 @@ class SGReloader
40
 
41
  public static function registerCallback(SGCallback $callback)
42
  {
43
- self::saveState($callback->toString());
44
  }
45
 
46
  public static function reset()
40
 
41
  public static function registerCallback(SGCallback $callback)
42
  {
43
+ self::saveState((string)$callback);
44
  }
45
 
46
  public static function reset()
com/lib/SGState.php CHANGED
@@ -7,20 +7,20 @@ require_once(SG_LIB_PATH.'SGMigrateState.php');
7
 
8
  class SGState
9
  {
10
- public $inprogress = false;
11
- public $type = '';
12
- public $token = '';
13
- public $action = '';
14
- public $actionId = null;
15
- public $actionStartTs = 0;
16
- public $backupFileName = '';
17
- public $backupFilePath = '';
18
- public $progress = 0;
19
- public $warningsFound = false;
20
- public $pendingStorageUploads = array();
21
- public $restoreMode = '';
22
- public $restoreFiles = array();
23
- public $offset = 0;
24
 
25
  function __construct()
26
  {
7
 
8
  class SGState
9
  {
10
+ protected $inprogress = false;
11
+ protected $type = '';
12
+ protected $token = '';
13
+ protected $action = '';
14
+ protected $actionId = null;
15
+ protected $actionStartTs = 0;
16
+ protected $backupFileName = '';
17
+ protected $backupFilePath = '';
18
+ protected $progress = 0;
19
+ protected $warningsFound = false;
20
+ protected $pendingStorageUploads = array();
21
+ protected $restoreMode = '';
22
+ protected $restoreFiles = array();
23
+ protected $offset = 0;
24
 
25
  function __construct()
26
  {
com/lib/SGUploadState.php CHANGED
@@ -10,12 +10,34 @@ class SGUploadState extends SGState
10
  private $uploadId = 0;
11
  private $parts = array();
12
  private $storageType = null;
 
 
13
 
14
  function __construct()
15
  {
16
  $this->type = SG_STATE_TYPE_UPLOAD;
17
  }
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  public function setActiveDirectory($activeDirectory)
20
  {
21
  $this->activeDirectory = $activeDirectory;
@@ -85,6 +107,9 @@ class SGUploadState extends SGState
85
  $this->uploadId = $stateJson['uploadId'];
86
  $this->actionId = $stateJson['actionId'];
87
  $this->progress = $stateJson['progress'];
 
 
 
88
  $this->storageType = $stateJson['storageType'];
89
  $this->actionStartTs = $stateJson['actionStartTs'];
90
  $this->warningsFound = $stateJson['warningsFound'];
@@ -109,6 +134,8 @@ class SGUploadState extends SGState
109
  'uploadId' => $this->uploadId,
110
  'actionId' => $this->actionId,
111
  'progress' => $this->progress,
 
 
112
  'inprogress' => $this->inprogress,
113
  'storageType' => $this->storageType,
114
  'actionStartTs' => $this->actionStartTs,
10
  private $uploadId = 0;
11
  private $parts = array();
12
  private $storageType = null;
13
+ private $backupId = null;
14
+ private $profileId = null;
15
 
16
  function __construct()
17
  {
18
  $this->type = SG_STATE_TYPE_UPLOAD;
19
  }
20
 
21
+ public function setBackupId($backupId)
22
+ {
23
+ $this->backupId = $backupId;
24
+ }
25
+
26
+ public function getBackupId()
27
+ {
28
+ return $this->backupId;
29
+ }
30
+
31
+ public function setProfileId($profileId)
32
+ {
33
+ $this->profileId = $profileId;
34
+ }
35
+
36
+ public function getProfileId()
37
+ {
38
+ return $this->profileId;
39
+ }
40
+
41
  public function setActiveDirectory($activeDirectory)
42
  {
43
  $this->activeDirectory = $activeDirectory;
107
  $this->uploadId = $stateJson['uploadId'];
108
  $this->actionId = $stateJson['actionId'];
109
  $this->progress = $stateJson['progress'];
110
+ $this->backupId = $stateJson['backupId'];
111
+ $this->profileId = $stateJson['profileId'];
112
+ $this->inprogress = $stateJson['inprogress'];
113
  $this->storageType = $stateJson['storageType'];
114
  $this->actionStartTs = $stateJson['actionStartTs'];
115
  $this->warningsFound = $stateJson['warningsFound'];
134
  'uploadId' => $this->uploadId,
135
  'actionId' => $this->actionId,
136
  'progress' => $this->progress,
137
+ 'backupId' => $this->backupId,
138
+ 'profileId' => $this->profileId,
139
  'inprogress' => $this->inprogress,
140
  'storageType' => $this->storageType,
141
  'actionStartTs' => $this->actionStartTs,
public/ajax/bgLogin.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once(dirname(__FILE__).'/../boot.php');
4
+ require_once(SG_STORAGE_PATH.'BackupGuardStorage.php');
5
+ require_once(SG_LIB_PATH.'SGAuthClient.php');
6
+
7
+ function BackupGuardLogouCloudUser() {
8
+ SGConfig::set('SG_BACKUPGUARD_UPLOAD_ACCESS_TOKEN', '');
9
+ SGConfig::set('SG_BACKUPGUARD_UPLOAD_ACCESS_TOKEN_EXPIRES','');
10
+ SGConfig::set('SG_BACKUPGUARD_UPLOAD_REFRESH_TOKEN','');
11
+ SGConfig::set('SG_BACKUPGUARD_CLOUD_ACCOUNT', '');
12
+ SGConfig::set('SG_BACKUPGUARD_CLOUD_ACCOUNT_EMAIL', '');
13
+ SGConfig::set('BACKUP_GUARD_PROFILE_ID', '');
14
+ }
15
+ if(backupGuardIsAjax() && count($_POST)) {
16
+ $_POST = backupGuardRemoveSlashes($_POST);
17
+ $_POST = backupGuardSanitizeTextField($_POST);
18
+
19
+ if(isset($_POST['cancel'])) {
20
+
21
+ BackupGuardLogouCloudUser();
22
+ die('{"success":"success"}');
23
+ }
24
+
25
+ try {
26
+ BackupGuardLogouCloudUser();
27
+ $email = $_POST['email'];
28
+ $password = sha1($_POST['password']);
29
+
30
+ if (!$email || !$password) {
31
+ die('{"error":"Invalid arguments"}');
32
+ }
33
+
34
+ $bgStorage = new BackupGuard\Storage();
35
+
36
+ $accessToken = $bgStorage->connect($email, $password, true);
37
+ if ($accessToken) {
38
+ try {
39
+ $account = $bgStorage->checkCloudAccount();
40
+ SGConfig::set('SG_BACKUPGUARD_CLOUD_ACCOUNT', serialize($account));
41
+ }
42
+ catch(Exception $exp) {
43
+ $bgStorage->addCloudAccountToUser();
44
+ }
45
+
46
+ $bgStorage->connect($email, $password);
47
+ $profiles = $bgStorage->getProfiles();
48
+ }
49
+ }
50
+ catch(Exception $exp) {
51
+ die('{"error":"'.$exp->getMessage().'"}');
52
+ }
53
+
54
+ SGConfig::set('SG_BACKUPGUARD_CLOUD_ACCOUNT_EMAIL', $email);
55
+ die(json_encode(array(
56
+ 'profiles' => $profiles
57
+ )));
58
+ }
public/ajax/chooseProfile.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once(dirname(__FILE__).'/../boot.php');
4
+ require_once(SG_STORAGE_PATH.'BackupGuardStorage.php');
5
+
6
+ if(backupGuardIsAjax() && count($_POST)) {
7
+ $_POST = backupGuardRemoveSlashes($_POST);
8
+ $_POST = backupGuardSanitizeTextField($_POST);
9
+
10
+ if (isset($_POST['profileId']) && $_POST['profileId']) {
11
+ $profileId = $_POST['profileId'];
12
+ }
13
+ else {
14
+ $profileName = @$_POST['profileName'];
15
+ $bgStorage = new BackupGuard\Storage();
16
+ $profileId = $bgStorage->createProfile($profileName);
17
+ }
18
+
19
+ SGConfig::set('BACKUP_GUARD_PROFILE_ID', $profileId);
20
+ SGConfig::set('BACKUP_GUARD_CREATE_MASTER', 1);
21
+ die('{"success":"success"}');
22
+ }
public/ajax/createCloudUser.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once(dirname(__FILE__).'/../boot.php');
4
+ require_once(SG_LIB_PATH.'BackupGuard/Client.php');
5
+ require_once(SG_LIB_PATH.'SGAuthClient.php');
6
+
7
+ if(backupGuardIsAjax() && count($_POST)) {
8
+ $_POST = backupGuardRemoveSlashes($_POST);
9
+ $_POST = backupGuardSanitizeTextField($_POST);
10
+
11
+ $email = $_POST['email'];
12
+ $firstname = $_POST['firstname'];
13
+ $lastname = $_POST['lastname'];
14
+
15
+ $client = new BackupGuard\Client();
16
+ try {
17
+ $user = $client->createCloudUser($email, $firstname, $lastname);
18
+ if ($user) {
19
+ $email = $user['email'];
20
+ $password = $user['password'];
21
+
22
+ $auth = SGAuthClient::getInstance();
23
+ $auth->createUploadAccessToken($email, $password);
24
+ }
25
+ }
26
+ catch (Exception $exp) {
27
+ die('{"error":"error"}');
28
+ }
29
+
30
+ die('{"success":"success"}');
31
+ }
public/ajax/dismissDiscountNotice.php CHANGED
@@ -2,4 +2,4 @@
2
 
3
  require_once(dirname(__FILE__).'/../boot.php');
4
 
5
- SGConfig::set('SG_HIDE_DISCOUNT_NOTICE', 1);
2
 
3
  require_once(dirname(__FILE__).'/../boot.php');
4
 
5
+ SGConfig::set('SG_HIDE_HALLOWEEN_DISCOUNT_NOTICE', 1);
public/ajax/isBgUserExists.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once(dirname(__FILE__).'/../boot.php');
4
+ require_once(SG_LIB_PATH.'BackupGuard/Client.php');
5
+
6
+ if(backupGuardIsAjax() && count($_POST)) {
7
+ $_POST = backupGuardRemoveSlashes($_POST);
8
+ $_POST = backupGuardSanitizeTextField($_POST);
9
+ $messages = array();
10
+
11
+ $email = $_POST['email'];
12
+ if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
13
+ $messages['validationError'] = 'error';
14
+ $messages['message'] = 'Invalid email';
15
+ echo json_encode($messages);
16
+ die();
17
+ }
18
+
19
+ $client = new BackupGuard\Client();
20
+ $found = $client->checkEmailExists($email);
21
+
22
+ if (!$found) {
23
+ die('{"user":"notFound"}');
24
+ }
25
+
26
+ die('{"success":"success"}');
27
+ }
public/ajax/modalBackupGuardDetails.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ global $current_user;
3
+ $websiteName = get_bloginfo();
4
+ ?>
5
+
6
+ <div class="modal-dialog">
7
+ <div class="modal-content">
8
+ <div class="modal-header">
9
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
10
+ <h4 class="modal-title"><?php _backupGuardT('BackupGuard')?></h4>
11
+ </div>
12
+ <form class="form-horizontal" id="backupGuardDetailsModal" data-sgform="ajax">
13
+ <div class="modal-body sg-modal-body">
14
+ <div class="hide sgbg-connection-message bg-invalid-login">
15
+ Invalid login info. Please try again.
16
+ </div>
17
+ <div class="hide sgbg-connection-message bg-email-confirmation">
18
+ We've sent you a confirmation e-mail. Please activate your account to get started. If you didn't receive it, please <a href="<?php echo SG_BACKUP_SUPPORT_URL; ?>" target="_blank">contact us</a>.
19
+ </div>
20
+ <div class="sgbg-connection-message bg-welcome-message">
21
+ Please enter your BackupGuard e-mail address. If you don't have an account yet, we will create it for you.
22
+ </div>
23
+ <div class="hide sgbg-connection-message bg-loggin-form-message">
24
+ Account found. Please enter your password to continue. <a href="<?php echo SG_FORGOT_PASSWORD_URL; ?>" target="_blank">Forgot your password?</a>
25
+ </div>
26
+ <div class="hide sgbg-connection-message bg-register-form-message">
27
+ No account was found with the provided e-mail address. Please enter your full name to create a new account.
28
+ </div>
29
+ <div class="hide sgbg-connection-message bg-create-form-message">
30
+ Now we need to setup your website's profile. Please enter a new profile name for your website.
31
+ </div>
32
+ <div class="col-md-12">
33
+ <div id="bg-email-container" class="form-group">
34
+ <label class="col-md-3 control-label" for="email"><?php _backupGuardT('Email')?></label>
35
+ <div class="col-md-8">
36
+ <input id="email" name="email" type="text" class="form-control input-md sg-backup-input sg-backup-input-email" placeholder="<?php _backupGuardT('Email')?>" autocomplete="off">
37
+ </div>
38
+ </div>
39
+ <div id="bg-firstname-container" class="form-group hidden">
40
+ <label class="col-md-3 control-label" for="firstname"><?php _backupGuardT('First Name')?></label>
41
+ <div class="col-md-8">
42
+ <input id="firstname" name="firstname" type="text" class="form-control input-md sg-backup-input" placeholder="<?php _backupGuardT('First Name')?>" value="<?php echo $current_user->user_firstname?>" autocomplete="off">
43
+ </div>
44
+ </div>
45
+ <div id="bg-lastname-container" class="form-group hidden">
46
+ <label class="col-md-3 control-label" for="lastname"><?php _backupGuardT('Last Name')?></label>
47
+ <div class="col-md-8">
48
+ <input id="lastname" name="lastname" type="text" class="form-control input-md sg-backup-input" placeholder="<?php _backupGuardT('Last Name')?>" value="<?php echo $current_user->user_lastname?>" autocomplete="off">
49
+ </div>
50
+ </div>
51
+
52
+ <div id="bg-password-container" class="form-group hidden">
53
+ <label class="col-md-3 control-label" for="password"><?php _backupGuardT('Password')?></label>
54
+ <div class="col-md-8">
55
+ <input id="password" name="password" type="password" class="form-control input-md sg-backup-input" placeholder="<?php _backupGuardT('Password')?>" autocomplete="off">
56
+ </div>
57
+ </div>
58
+ <div id="bg-profiles-container" class="form-group hidden">
59
+ <div class="row bg-select-profile hidden">
60
+ <label class="col-md-3 control-label" for="password"><?php _backupGuardT('Profiles')?></label>
61
+ <div class="col-md-8">
62
+ <select id="bg-profiles" name="bg-profiles" class="form-control input-md">
63
+ <option value="0"><?php _backupGuardT('Create New')?></option>
64
+ </select>
65
+ </div>
66
+ </div>
67
+ <br>
68
+ <div id="bg-profile-name-container" class="row">
69
+ <label class="col-md-3 control-label" for="bg-profile-name"><?php _backupGuardT('Profile name')?></label>
70
+ <div class="col-md-8">
71
+ <input id="bg-profile-name" name="bg-profile-name" type="text" class="form-control input-md sg-backup-input" placeholder="<?php _backupGuardT('Profile name')?>" value="<?php echo esc_attr($websiteName); ?>">
72
+ </div>
73
+ </div>
74
+ </div>
75
+ </div>
76
+ <div class="clearfix"></div>
77
+ </div>
78
+ <div class="modal-footer">
79
+ <span id="bg-close-button" class="modal-close-button" data-dismiss="modal"><?php _backupGuardT('Close')?></span>
80
+ <button id="bg-connect-account" type="button" class="btn btn-success" onclick="sgBackup.backupGuardConnect()"><?php _backupGuardT('Connect')?></button>
81
+ <button id="bg-login" type="button" class="btn btn-success hidden" onclick="sgBackup.backupGuardLogin()"><?php _backupGuardT('Login')?></button>
82
+ <button id="bg-create-account" type="button" class="btn btn-success hidden" onclick="sgBackup.createCloudUser()"><?php _backupGuardT('Create Account')?></button>
83
+ <button id="bg-choose-profile" type="button" class="btn btn-success hidden" onclick="sgBackup.chooseProfile()"><?php _backupGuardT('Choose')?></button>
84
+ </div>
85
+ </form>
86
+ </div>
87
+ </div>
public/ajax/modalImport.php CHANGED
@@ -7,6 +7,7 @@
7
  $ftp = SGConfig::get('SG_STORAGE_FTP_CONNECTED');
8
  $amazon = SGConfig::get('SG_AMAZON_KEY');
9
  $oneDrive = SGConfig::get('SG_ONE_DRIVE_REFRESH_TOKEN');
 
10
  ?>
11
  <div class="modal-dialog">
12
  <div class="modal-content">
@@ -25,12 +26,18 @@
25
  <td><?php _backupGuardT('Local PC')?></td>
26
  </tr>
27
  <?php if (SGBoot::isFeatureAvailable('DOWNLOAD_FROM_CLOUD')): ?>
 
 
 
 
 
 
 
28
  <tr>
29
  <td class="file-select-radio"><input name="storage-radio" type="radio" value="<?php echo SG_STORAGE_FTP?>" <?php echo empty($ftp)?'disabled="disabled"':''?>></td>
30
  <td><span class="btn-xs sg-status-icon sg-status-31 active">&nbsp;</span></td>
31
  <td><?php echo 'FTP' ?></td>
32
  </tr>
33
-
34
  <tr>
35
  <td class="file-select-radio"><input name="storage-radio" type="radio" value="<?php echo SG_STORAGE_DROPBOX?>" <?php echo empty($dropbox)?'disabled="disabled"':''?>></td>
36
  <td><span class="btn-xs sg-status-icon sg-status-32 active">&nbsp;</span></td>
7
  $ftp = SGConfig::get('SG_STORAGE_FTP_CONNECTED');
8
  $amazon = SGConfig::get('SG_AMAZON_KEY');
9
  $oneDrive = SGConfig::get('SG_ONE_DRIVE_REFRESH_TOKEN');
10
+ $backupGuard = SGConfig::get('SG_BACKUPGUARD_UPLOAD_ACCESS_TOKEN');
11
  ?>
12
  <div class="modal-dialog">
13
  <div class="modal-content">
26
  <td><?php _backupGuardT('Local PC')?></td>
27
  </tr>
28
  <?php if (SGBoot::isFeatureAvailable('DOWNLOAD_FROM_CLOUD')): ?>
29
+ <?php if (SGBoot::isFeatureAvailable('BACKUP_GUARD') && SG_SHOW_BACKUPGUARD_CLOUD): ?>
30
+ <tr>
31
+ <td class="file-select-radio"><input name="storage-radio" type="radio" value="<?php echo SG_STORAGE_BACKUP_GUARD?>" <?php echo empty($backupGuard)?'disabled="disabled"':''?>></td>
32
+ <td><span class="btn-xs sg-status-icon sg-status-36 active">&nbsp;</span></td>
33
+ <td><?php echo 'BackupGuard' ?></td>
34
+ </tr>
35
+ <?php endif; ?>
36
  <tr>
37
  <td class="file-select-radio"><input name="storage-radio" type="radio" value="<?php echo SG_STORAGE_FTP?>" <?php echo empty($ftp)?'disabled="disabled"':''?>></td>
38
  <td><span class="btn-xs sg-status-icon sg-status-31 active">&nbsp;</span></td>
39
  <td><?php echo 'FTP' ?></td>
40
  </tr>
 
41
  <tr>
42
  <td class="file-select-radio"><input name="storage-radio" type="radio" value="<?php echo SG_STORAGE_DROPBOX?>" <?php echo empty($dropbox)?'disabled="disabled"':''?>></td>
43
  <td><span class="btn-xs sg-status-icon sg-status-32 active">&nbsp;</span></td>
public/ajax/modalManualBackup.php CHANGED
@@ -8,6 +8,7 @@
8
  $ftp = SGConfig::get('SG_STORAGE_FTP_CONNECTED');
9
  $amazon = SGConfig::get('SG_AMAZON_KEY');
10
  $oneDrive = SGConfig::get('SG_ONE_DRIVE_REFRESH_TOKEN');
 
11
 
12
  $backupType = (int)@$_GET['backupType'];
13
  ?>
@@ -69,6 +70,14 @@
69
  </label>
70
  <!--Storages-->
71
  <div class="col-md-12 sg-checkbox sg-custom-backup-cloud">
 
 
 
 
 
 
 
 
72
  <?php if(SGBoot::isFeatureAvailable('FTP')): ?>
73
  <div class="checkbox">
74
  <label for="cloud-ftp" <?php echo empty($ftp)?'data-toggle="tooltip" data-placement="right" title="'._backupGuardT('FTP is not active.',true).'"':''?>>
8
  $ftp = SGConfig::get('SG_STORAGE_FTP_CONNECTED');
9
  $amazon = SGConfig::get('SG_AMAZON_KEY');
10
  $oneDrive = SGConfig::get('SG_ONE_DRIVE_REFRESH_TOKEN');
11
+ $backupGuard = SGConfig::get('SG_BACKUPGUARD_UPLOAD_ACCESS_TOKEN');
12
 
13
  $backupType = (int)@$_GET['backupType'];
14
  ?>
70
  </label>
71
  <!--Storages-->
72
  <div class="col-md-12 sg-checkbox sg-custom-backup-cloud">
73
+ <?php if(SGBoot::isFeatureAvailable('BACKUP_GUARD') && SG_SHOW_BACKUPGUARD_CLOUD): ?>
74
+ <div class="checkbox">
75
+ <label for="cloud-backup-guard" <?php echo empty($backupGuard)?'data-toggle="tooltip" data-placement="right" title="'._backupGuardT('BackupGuard is not active.',true).'"':''?>>
76
+ <input type="checkbox" name="backupStorages[]" id="cloud-backup-guard" value="<?php echo SG_STORAGE_BACKUP_GUARD ?>" <?php echo empty($backupGuard)?'disabled="disabled"':''?>>
77
+ <span class="sg-checkbox-label-text"><?php echo 'BackupGuard' ?></span>
78
+ </label>
79
+ </div>
80
+ <?php endif; ?>
81
  <?php if(SGBoot::isFeatureAvailable('FTP')): ?>
82
  <div class="checkbox">
83
  <label for="cloud-ftp" <?php echo empty($ftp)?'data-toggle="tooltip" data-placement="right" title="'._backupGuardT('FTP is not active.',true).'"':''?>>
public/cloud.php CHANGED
@@ -11,7 +11,35 @@ $dropboxUsername = SGConfig::get('SG_DROPBOX_CONNECTION_STRING');
11
  $amazonInfo = SGConfig::get('SG_AMAZON_BUCKET');
12
 
13
  $oneDriveInfo = SGConfig::get('SG_ONE_DRIVE_CONNECTION_STRING');
 
14
  $contentClassName = getBackupPageContentClassName('cloud');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  ?>
16
  <div id="sg-backup-page-content-cloud" class="sg-backup-page-content <?php echo $contentClassName; ?>">
17
  <div class="row sg-cloud-container">
@@ -21,7 +49,7 @@ $contentClassName = getBackupPageContentClassName('cloud');
21
  <div><h1 class="sg-backup-page-title"><?php _backupGuardT('Cloud settings')?></h1></div>
22
  <?php if (SGBoot::isFeatureAvailable('SUBDIRECTORIES')): ?>
23
  <div class="form-group form-inline">
24
- <label class="col-md-3 sg-control-label">
25
  <?php _backupGuardT('Destination folder')?>
26
  </label>
27
  <div class="col-md-3">
@@ -30,10 +58,32 @@ $contentClassName = getBackupPageContentClassName('cloud');
30
  </div>
31
  </div>
32
  <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  <!-- Dropbox -->
34
  <?php if (SGBoot::isFeatureAvailable('DROPBOX')): ?>
35
  <div class="form-group">
36
- <label class="col-md-3 sg-control-label">
37
  <div class="sg-cloud-icon-wrapper">
38
  <span class="sg-cloud-icon sg-cloud-dropbox"></span>
39
  </div>
@@ -55,7 +105,7 @@ $contentClassName = getBackupPageContentClassName('cloud');
55
  <!-- Google Drive -->
56
  <?php if (SGBoot::isFeatureAvailable('GOOGLE_DRIVE')): ?>
57
  <div class="form-group">
58
- <label class="col-md-3 sg-control-label">
59
  <div class="sg-cloud-icon-wrapper">
60
  <span class="sg-cloud-icon sg-cloud-google-drive"></span>
61
  </div>
@@ -77,7 +127,7 @@ $contentClassName = getBackupPageContentClassName('cloud');
77
  <!-- FTP -->
78
  <?php if (SGBoot::isFeatureAvailable('FTP')): ?>
79
  <div class="form-group">
80
- <label class="col-md-3 sg-control-label sg-user-info">
81
  <div class="sg-cloud-icon-wrapper">
82
  <span class="sg-cloud-icon sg-cloud-ftp"></span>
83
  </div>
@@ -100,7 +150,7 @@ $contentClassName = getBackupPageContentClassName('cloud');
100
  <!-- Amazon S3 -->
101
  <?php if (SGBoot::isFeatureAvailable('AMAZON')): ?>
102
  <div class="form-group">
103
- <label class="col-md-3 sg-control-label">
104
  <div class="sg-cloud-icon-wrapper">
105
  <span class="sg-cloud-icon sg-cloud-amazon"></span>
106
  </div>
@@ -123,7 +173,7 @@ $contentClassName = getBackupPageContentClassName('cloud');
123
  <!-- One Drive -->
124
  <?php if (SGBoot::isFeatureAvailable('ONE_DRIVE')): ?>
125
  <div class="form-group">
126
- <label class="col-md-3 sg-control-label">
127
  <div class="sg-cloud-icon-wrapper">
128
  <span class="sg-cloud-icon sg-cloud-one-drive"></span>
129
  </div>
11
  $amazonInfo = SGConfig::get('SG_AMAZON_BUCKET');
12
 
13
  $oneDriveInfo = SGConfig::get('SG_ONE_DRIVE_CONNECTION_STRING');
14
+
15
  $contentClassName = getBackupPageContentClassName('cloud');
16
+
17
+
18
+ $backupGuardCloudAccount = SGConfig::get('SG_BACKUPGUARD_CLOUD_ACCOUNT')?unserialize(SGConfig::get('SG_BACKUPGUARD_CLOUD_ACCOUNT')):'';
19
+ $backupGuardCloudAccountEmail = SGConfig::get('SG_BACKUPGUARD_CLOUD_ACCOUNT_EMAIL');
20
+
21
+ $backupGuardConnectionString = "<span>". _backupGuardT('Connect now and get 1 GB storage space for FREE', true)."</span>";
22
+
23
+ if (!empty($backupGuardCloudAccount)) {
24
+ $usedSpace = $backupGuardCloudAccount['usedStorage'];
25
+ $storage = $backupGuardCloudAccount['package']['storage'];
26
+ $availableSpaceInpercents = $usedSpace*100/$storage;
27
+
28
+ if ($availableSpaceInpercents < 25) {
29
+ $usedSpaceTextColor = "green";
30
+ }
31
+ else if ((25 <= $availableSpaceInpercents) && ($availableSpaceInpercents < 50)) {
32
+ $usedSpaceTextColor = "black";
33
+ }
34
+ else if ((50 <= $availableSpaceInpercents) && ($availableSpaceInpercents <= 75)) {
35
+ $usedSpaceTextColor = "orange";
36
+ }
37
+ else if ($availableSpaceInpercents >= 75) {
38
+ $usedSpaceTextColor = "red";
39
+ }
40
+
41
+ $backupGuardConnectionString = $backupGuardCloudAccountEmail.' | <span style="color: '.$usedSpaceTextColor.';">'.convertToReadableSize($usedSpace*BACKUP_GUARD_ONE_MB).' / '.convertToReadableSize($storage*BACKUP_GUARD_ONE_MB).'</span> | <a target="_blank" href="'.BACKUP_GUARD_CLOUD_UPGRADE_URL.'">Upgrade for more space</a>';
42
+ }
43
  ?>
44
  <div id="sg-backup-page-content-cloud" class="sg-backup-page-content <?php echo $contentClassName; ?>">
45
  <div class="row sg-cloud-container">
49
  <div><h1 class="sg-backup-page-title"><?php _backupGuardT('Cloud settings')?></h1></div>
50
  <?php if (SGBoot::isFeatureAvailable('SUBDIRECTORIES')): ?>
51
  <div class="form-group form-inline">
52
+ <label class="col-md-5 sg-control-label">
53
  <?php _backupGuardT('Destination folder')?>
54
  </label>
55
  <div class="col-md-3">
58
  </div>
59
  </div>
60
  <?php endif; ?>
61
+ <!-- BackupGuard -->
62
+ <?php if (SGBoot::isFeatureAvailable('BACKUP_GUARD') && SG_SHOW_BACKUPGUARD_CLOUD): ?>
63
+ <div class="form-group">
64
+ <label class="col-md-5 sg-control-label sg-user-info">
65
+ <div class="sg-cloud-icon-wrapper">
66
+ <span class="sg-cloud-icon sg-cloud-backup-guard"></span>
67
+ </div>
68
+ <div class="sg-cloud-label-with-info">
69
+ <span><?php echo 'BackupGuard' ?></span>
70
+ <span class="sg-backupguard-user sg-helper-block">
71
+ <?php echo $backupGuardConnectionString ?>
72
+ </span>
73
+ </div>
74
+ </label>
75
+ <div class="col-md-3">
76
+ <label class="sg-switch-container">
77
+ <input type="checkbox" data-on-text="<?php _backupGuardT('ON')?>" data-off-text="<?php _backupGuardT('OFF')?>" data-storage="BACKUP_GUARD" data-remote="bgLogin" class="sg-switch" <?php echo !empty($backupGuardCloudAccount)?'checked="checked"':''?>>
78
+ <a id="backup-guard-details" href="javascript:void(0)" class="hide" data-toggle="modal" data-modal-name="backup-guard-details" data-remote="modalBackupGuardDetails"></a>
79
+ </label>
80
+ </div>
81
+ </div>
82
+ <?php endif; ?>
83
  <!-- Dropbox -->
84
  <?php if (SGBoot::isFeatureAvailable('DROPBOX')): ?>
85
  <div class="form-group">
86
+ <label class="col-md-5 sg-control-label">
87
  <div class="sg-cloud-icon-wrapper">
88
  <span class="sg-cloud-icon sg-cloud-dropbox"></span>
89
  </div>
105
  <!-- Google Drive -->
106
  <?php if (SGBoot::isFeatureAvailable('GOOGLE_DRIVE')): ?>
107
  <div class="form-group">
108
+ <label class="col-md-5 sg-control-label">
109
  <div class="sg-cloud-icon-wrapper">
110
  <span class="sg-cloud-icon sg-cloud-google-drive"></span>
111
  </div>
127
  <!-- FTP -->
128
  <?php if (SGBoot::isFeatureAvailable('FTP')): ?>
129
  <div class="form-group">
130
+ <label class="col-md-5 sg-control-label sg-user-info">
131
  <div class="sg-cloud-icon-wrapper">
132
  <span class="sg-cloud-icon sg-cloud-ftp"></span>
133
  </div>
150
  <!-- Amazon S3 -->
151
  <?php if (SGBoot::isFeatureAvailable('AMAZON')): ?>
152
  <div class="form-group">
153
+ <label class="col-md-5 sg-control-label">
154
  <div class="sg-cloud-icon-wrapper">
155
  <span class="sg-cloud-icon sg-cloud-amazon"></span>
156
  </div>
173
  <!-- One Drive -->
174
  <?php if (SGBoot::isFeatureAvailable('ONE_DRIVE')): ?>
175
  <div class="form-group">
176
+ <label class="col-md-5 sg-control-label">
177
  <div class="sg-cloud-icon-wrapper">
178
  <span class="sg-cloud-icon sg-cloud-one-drive"></span>
179
  </div>
public/css/bgstyle.less.css CHANGED
@@ -6416,6 +6416,7 @@
6416
  .sg-wrapper-less .modal-header {
6417
  padding: 20px;
6418
  min-height: 16.42857143px;
 
6419
  }
6420
  .sg-wrapper-less .modal-header .close {
6421
  margin-top: -2px;
@@ -7899,26 +7900,32 @@
7899
  height: 20px;
7900
  background-image: url('../img/backup-icons.png');
7901
  background-repeat: no-repeat;
7902
- background-size: 180px 40px;
7903
  }
7904
  @media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min--moz-device-pixel-ratio: 1.5), only screen and (min-resolution: 240dpi) {
7905
  .sg-wrapper-less .sg-status-icon {
7906
- background-image: url('../img/backup-icons@2x.png');
7907
  }
7908
  }
 
 
 
 
 
 
7909
  .sg-wrapper-less .sg-status-35 {
7910
  background-position: -123px 1px;
7911
  width: 28px;
7912
  }
7913
  .sg-wrapper-less .sg-status-35.active {
7914
- background-position: -123px -20px;
7915
  width: 28px;
7916
  }
7917
  .sg-wrapper-less .sg-status-34 {
7918
  background-position: -96px 1px;
7919
  }
7920
  .sg-wrapper-less .sg-status-34.active {
7921
- background-position: -96px -20px;
7922
  }
7923
  .sg-wrapper-less .sg-status-1 {
7924
  background-position: 0px 1px;
@@ -7926,32 +7933,31 @@
7926
  width: 16px;
7927
  }
7928
  .sg-wrapper-less .sg-status-1.active {
7929
- background-position: 0px -20px;
7930
  }
7931
  .sg-wrapper-less .sg-status-2 {
7932
  background-position: -23px 0px;
7933
- background-size: 180px 42px;
7934
  }
7935
  .sg-wrapper-less .sg-status-2.active {
7936
- background-position: -23px -22px;
7937
  }
7938
  .sg-wrapper-less .sg-status-31 {
7939
  background-position: -72px 1px
7940
  }
7941
  .sg-wrapper-less .sg-status-31.active {
7942
- background-position: -72px -20px;
7943
  }
7944
  .sg-wrapper-less .sg-status-32 {
7945
  background-position: -47px 1px;
7946
  }
7947
  .sg-wrapper-less .sg-status-32.active {
7948
- background-position: -47px -20px;
7949
  }
7950
  .sg-wrapper-less .sg-status-33 {
7951
  background-position: -158px 1px;
7952
  }
7953
  .sg-wrapper-less .sg-status-33.active {
7954
- background-position: -159px -20px;
7955
  }
7956
  .sg-wrapper-less .sg-status-22 {
7957
  background-position: -180px -20px;
@@ -8301,4 +8307,27 @@ a#sg-logo:focus {
8301
 
8302
  .sgbg-send-usage-data-wrapper span.bootstrap-switch-handle-on.bootstrap-switch-primary {
8303
  background: #007cba;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8304
  }
6416
  .sg-wrapper-less .modal-header {
6417
  padding: 20px;
6418
  min-height: 16.42857143px;
6419
+ background: #f8f8f8;
6420
  }
6421
  .sg-wrapper-less .modal-header .close {
6422
  margin-top: -2px;
7900
  height: 20px;
7901
  background-image: url('../img/backup-icons.png');
7902
  background-repeat: no-repeat;
7903
+ background-size: 205px 40px;
7904
  }
7905
  @media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min--moz-device-pixel-ratio: 1.5), only screen and (min-resolution: 240dpi) {
7906
  .sg-wrapper-less .sg-status-icon {
7907
+ background-image: url('../img/backup-icons.png');
7908
  }
7909
  }
7910
+ .sg-wrapper-less .sg-status-36 {
7911
+ background-position: -184px 0px;
7912
+ }
7913
+ .sg-wrapper-less .sg-status-36.active {
7914
+ background-position: -184px -21px;
7915
+ }
7916
  .sg-wrapper-less .sg-status-35 {
7917
  background-position: -123px 1px;
7918
  width: 28px;
7919
  }
7920
  .sg-wrapper-less .sg-status-35.active {
7921
+ background-position: -123px -21px;
7922
  width: 28px;
7923
  }
7924
  .sg-wrapper-less .sg-status-34 {
7925
  background-position: -96px 1px;
7926
  }
7927
  .sg-wrapper-less .sg-status-34.active {
7928
+ background-position: -96px -21px;
7929
  }
7930
  .sg-wrapper-less .sg-status-1 {
7931
  background-position: 0px 1px;
7933
  width: 16px;
7934
  }
7935
  .sg-wrapper-less .sg-status-1.active {
7936
+ background-position: 0px -21px;
7937
  }
7938
  .sg-wrapper-less .sg-status-2 {
7939
  background-position: -23px 0px;
 
7940
  }
7941
  .sg-wrapper-less .sg-status-2.active {
7942
+ background-position: -23px -21px;
7943
  }
7944
  .sg-wrapper-less .sg-status-31 {
7945
  background-position: -72px 1px
7946
  }
7947
  .sg-wrapper-less .sg-status-31.active {
7948
+ background-position: -72px -21px;
7949
  }
7950
  .sg-wrapper-less .sg-status-32 {
7951
  background-position: -47px 1px;
7952
  }
7953
  .sg-wrapper-less .sg-status-32.active {
7954
+ background-position: -47px -21px;
7955
  }
7956
  .sg-wrapper-less .sg-status-33 {
7957
  background-position: -158px 1px;
7958
  }
7959
  .sg-wrapper-less .sg-status-33.active {
7960
+ background-position: -159px -21px;
7961
  }
7962
  .sg-wrapper-less .sg-status-22 {
7963
  background-position: -180px -20px;
8307
 
8308
  .sgbg-send-usage-data-wrapper span.bootstrap-switch-handle-on.bootstrap-switch-primary {
8309
  background: #007cba;
8310
+ }
8311
+
8312
+ .bg-invalid-login {
8313
+ color: red;
8314
+ }
8315
+
8316
+ #backupGuardDetailsModal .control-label {
8317
+ text-align: left !important;
8318
+ }
8319
+
8320
+ #backupGuardDetailsModal label.error {
8321
+ color: red;
8322
+ font-size: 14px;
8323
+ margin-top: 4px;
8324
+ font-weight: normal;
8325
+ }
8326
+
8327
+ #backupGuardDetailsModal button {
8328
+ outline: none;
8329
+ }
8330
+
8331
+ .bg-email-confirmation {
8332
+ color: #000;
8333
  }
public/css/styles.css CHANGED
@@ -440,6 +440,9 @@ label.sg-user-info {
440
  margin-right: 18px;
441
  }
442
 
 
 
 
443
  .sg-cloud-dropbox {
444
  background-image: url("../img/cloud-dropbox.png");
445
  }
@@ -475,6 +478,10 @@ label.sg-user-info {
475
  font-weight: normal;
476
  }
477
 
 
 
 
 
478
  .sg-schedule-icon {
479
  text-decoration: none !important;
480
  background-repeat: no-repeat;
440
  margin-right: 18px;
441
  }
442
 
443
+ .sg-cloud-backup-guard {
444
+ background-image: url("../img/backup-cloud-icon.png");
445
+ }
446
  .sg-cloud-dropbox {
447
  background-image: url("../img/cloud-dropbox.png");
448
  }
478
  font-weight: normal;
479
  }
480
 
481
+ .sg-cloud-label-with-info {
482
+ display: inline-block;
483
+ }
484
+
485
  .sg-schedule-icon {
486
  text-decoration: none !important;
487
  background-repeat: no-repeat;
public/img/backup-cloud-icon.png ADDED
Binary file
public/img/backup-icons-old.png ADDED
Binary file
public/img/backup-icons.png CHANGED
Binary file
public/img/halloween.png ADDED
Binary file
public/img/halloweenPopup.png ADDED
Binary file
public/img/halloweenPopupClose.png ADDED
Binary file
public/include/functions.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  function backupGuardShouldShowDiscountNotice()
4
  {
5
- if (SGConfig::get("SG_HIDE_DISCOUNT_NOTICE")) {
6
  return false;
7
  }
8
 
@@ -11,8 +11,8 @@ function backupGuardShouldShowDiscountNotice()
11
 
12
  function checkDueDateDiscount()
13
  {
14
- $startDate = '2019-11-27';
15
- $endDate = '2019-12-02';
16
 
17
  $timezone = 'Asia/Yerevan';
18
  $timeDate = new DateTime('now', new DateTimeZone($timezone));
@@ -141,6 +141,7 @@ function backupGuardFilterStatusesByActionType($currentBackup, $currentOptions)
141
  if ($currentOptions['gdrive']) $filteredStatuses[] = $currentOptions['gdrive'];
142
  if ($currentOptions['amazon']) $filteredStatuses[] = $currentOptions['amazon'];
143
  if ($currentOptions['oneDrive']) $filteredStatuses[] = $currentOptions['oneDrive'];
 
144
  }
145
  return $filteredStatuses;
146
  }
@@ -157,6 +158,7 @@ function backupGuardActiveOptionToType($activeOption)
157
  $activeOptions['gdrive'] = 0;
158
  $activeOptions['amazon'] = 0;
159
  $activeOptions['oneDrive'] = 0;
 
160
  foreach ($storages as $key => $storage) {
161
  switch ($storage) {
162
  case SG_STORAGE_FTP:
@@ -174,6 +176,9 @@ function backupGuardActiveOptionToType($activeOption)
174
  case SG_STORAGE_ONE_DRIVE:
175
  $activeOptions['oneDrive'] = SG_ACTION_TYPE_UPLOAD.SG_STORAGE_ONE_DRIVE;
176
  break;
 
 
 
177
  }
178
  }
179
 
@@ -219,7 +224,7 @@ function backupGuardShouldUpdate()
219
 
220
  if ($currentVersion !== $oldVersion) {
221
  SGConfig::set('SG_BACKUP_GUARD_VERSION', $currentVersion, true);
222
- SGConfig::set('SG_HIDE_DISCOUNT_NOTICE', '0', true);
223
  SGBoot::didUpdatePluginVersion();
224
  return SG_FORCE_DB_TABLES_RESET;
225
  }
2
 
3
  function backupGuardShouldShowDiscountNotice()
4
  {
5
+ if (SGConfig::get("SG_HIDE_HALLOWEEN_DISCOUNT_NOTICE")) {
6
  return false;
7
  }
8
 
11
 
12
  function checkDueDateDiscount()
13
  {
14
+ $startDate = '2020-10-27';
15
+ $endDate = '2020-11-02';
16
 
17
  $timezone = 'Asia/Yerevan';
18
  $timeDate = new DateTime('now', new DateTimeZone($timezone));
141
  if ($currentOptions['gdrive']) $filteredStatuses[] = $currentOptions['gdrive'];
142
  if ($currentOptions['amazon']) $filteredStatuses[] = $currentOptions['amazon'];
143
  if ($currentOptions['oneDrive']) $filteredStatuses[] = $currentOptions['oneDrive'];
144
+ if ($currentOptions['backupGuard']) $filteredStatuses[] = $currentOptions['backupGuard'];
145
  }
146
  return $filteredStatuses;
147
  }
158
  $activeOptions['gdrive'] = 0;
159
  $activeOptions['amazon'] = 0;
160
  $activeOptions['oneDrive'] = 0;
161
+ $activeOptions['backupGuard'] = 0;
162
  foreach ($storages as $key => $storage) {
163
  switch ($storage) {
164
  case SG_STORAGE_FTP:
176
  case SG_STORAGE_ONE_DRIVE:
177
  $activeOptions['oneDrive'] = SG_ACTION_TYPE_UPLOAD.SG_STORAGE_ONE_DRIVE;
178
  break;
179
+ case SG_STORAGE_BACKUP_GUARD:
180
+ $activeOptions['backupGuard'] = SG_ACTION_TYPE_UPLOAD.SG_STORAGE_BACKUP_GUARD;
181
+ break;
182
  }
183
  }
184
 
224
 
225
  if ($currentVersion !== $oldVersion) {
226
  SGConfig::set('SG_BACKUP_GUARD_VERSION', $currentVersion, true);
227
+ SGConfig::set('SG_HIDE_HALLOWEEN_DISCOUNT_NOTICE', '0', true);
228
  SGBoot::didUpdatePluginVersion();
229
  return SG_FORCE_DB_TABLES_RESET;
230
  }
public/js/jquery.validate.min.js ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * jQuery Validation Plugin 1.9.0
3
+ *
4
+ * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
5
+ * http://docs.jquery.com/Plugins/Validation
6
+ *
7
+ * Copyright (c) 2006 - 2011 Jörn Zaefferer
8
+ *
9
+ * Dual licensed under the MIT and GPL licenses:
10
+ * http://www.opensource.org/licenses/mit-license.php
11
+ * http://www.gnu.org/licenses/gpl.html
12
+ */
13
+ (function(c){c.extend(c.fn,{validate:function(a){if(this.length){var b=c.data(this[0],"validator");if(b)return b;this.attr("novalidate","novalidate");b=new c.validator(a,this[0]);c.data(this[0],"validator",b);if(b.settings.onsubmit){a=this.find("input, button");a.filter(".cancel").click(function(){b.cancelSubmit=true});b.settings.submitHandler&&a.filter(":submit").click(function(){b.submitButton=this});this.submit(function(d){function e(){if(b.settings.submitHandler){if(b.submitButton)var f=c("<input type='hidden'/>").attr("name",
14
+ b.submitButton.name).val(b.submitButton.value).appendTo(b.currentForm);b.settings.submitHandler.call(b,b.currentForm);b.submitButton&&f.remove();return false}return true}b.settings.debug&&d.preventDefault();if(b.cancelSubmit){b.cancelSubmit=false;return e()}if(b.form()){if(b.pendingRequest){b.formSubmitted=true;return false}return e()}else{b.focusInvalid();return false}})}return b}else a&&a.debug&&window.console&&console.warn("nothing selected, can't validate, returning nothing")},valid:function(){if(c(this[0]).is("form"))return this.validate().form();
15
+ else{var a=true,b=c(this[0].form).validate();this.each(function(){a&=b.element(this)});return a}},removeAttrs:function(a){var b={},d=this;c.each(a.split(/\s/),function(e,f){b[f]=d.attr(f);d.removeAttr(f)});return b},rules:function(a,b){var d=this[0];if(a){var e=c.data(d.form,"validator").settings,f=e.rules,g=c.validator.staticRules(d);switch(a){case "add":c.extend(g,c.validator.normalizeRule(b));f[d.name]=g;if(b.messages)e.messages[d.name]=c.extend(e.messages[d.name],b.messages);break;case "remove":if(!b){delete f[d.name];
16
+ return g}var h={};c.each(b.split(/\s/),function(j,i){h[i]=g[i];delete g[i]});return h}}d=c.validator.normalizeRules(c.extend({},c.validator.metadataRules(d),c.validator.classRules(d),c.validator.attributeRules(d),c.validator.staticRules(d)),d);if(d.required){e=d.required;delete d.required;d=c.extend({required:e},d)}return d}});c.extend(c.expr[":"],{blank:function(a){return!c.trim(""+a.value)},filled:function(a){return!!c.trim(""+a.value)},unchecked:function(a){return!a.checked}});c.validator=function(a,
17
+ b){this.settings=c.extend(true,{},c.validator.defaults,a);this.currentForm=b;this.init()};c.validator.format=function(a,b){if(arguments.length==1)return function(){var d=c.makeArray(arguments);d.unshift(a);return c.validator.format.apply(this,d)};if(arguments.length>2&&b.constructor!=Array)b=c.makeArray(arguments).slice(1);if(b.constructor!=Array)b=[b];c.each(b,function(d,e){a=a.replace(RegExp("\\{"+d+"\\}","g"),e)});return a};c.extend(c.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",
18
+ validClass:"valid",errorElement:"label",focusInvalid:true,errorContainer:c([]),errorLabelContainer:c([]),onsubmit:true,ignore:":hidden",ignoreTitle:false,onfocusin:function(a){this.lastActive=a;if(this.settings.focusCleanup&&!this.blockFocusCleanup){this.settings.unhighlight&&this.settings.unhighlight.call(this,a,this.settings.errorClass,this.settings.validClass);this.addWrapper(this.errorsFor(a)).hide()}},onfocusout:function(a){if(!this.checkable(a)&&(a.name in this.submitted||!this.optional(a)))this.element(a)},
19
+ onkeyup:function(a){if(a.name in this.submitted||a==this.lastElement)this.element(a)},onclick:function(a){if(a.name in this.submitted)this.element(a);else a.parentNode.name in this.submitted&&this.element(a.parentNode)},highlight:function(a,b,d){a.type==="radio"?this.findByName(a.name).addClass(b).removeClass(d):c(a).addClass(b).removeClass(d)},unhighlight:function(a,b,d){a.type==="radio"?this.findByName(a.name).removeClass(b).addClass(d):c(a).removeClass(b).addClass(d)}},setDefaults:function(a){c.extend(c.validator.defaults,
20
+ a)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",accept:"Please enter a value with a valid extension.",maxlength:c.validator.format("Please enter no more than {0} characters."),
21
+ minlength:c.validator.format("Please enter at least {0} characters."),rangelength:c.validator.format("Please enter a value between {0} and {1} characters long."),range:c.validator.format("Please enter a value between {0} and {1}."),max:c.validator.format("Please enter a value less than or equal to {0}."),min:c.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:false,prototype:{init:function(){function a(e){var f=c.data(this[0].form,"validator"),g="on"+e.type.replace(/^validate/,
22
+ "");f.settings[g]&&f.settings[g].call(f,this[0],e)}this.labelContainer=c(this.settings.errorLabelContainer);this.errorContext=this.labelContainer.length&&this.labelContainer||c(this.currentForm);this.containers=c(this.settings.errorContainer).add(this.settings.errorLabelContainer);this.submitted={};this.valueCache={};this.pendingRequest=0;this.pending={};this.invalid={};this.reset();var b=this.groups={};c.each(this.settings.groups,function(e,f){c.each(f.split(/\s/),function(g,h){b[h]=e})});var d=
23
+ this.settings.rules;c.each(d,function(e,f){d[e]=c.validator.normalizeRule(f)});c(this.currentForm).validateDelegate("[type='text'], [type='password'], [type='file'], select, textarea, [type='number'], [type='search'] ,[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'] ","focusin focusout keyup",a).validateDelegate("[type='radio'], [type='checkbox'], select, option","click",
24
+ a);this.settings.invalidHandler&&c(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler)},form:function(){this.checkForm();c.extend(this.submitted,this.errorMap);this.invalid=c.extend({},this.errorMap);this.valid()||c(this.currentForm).triggerHandler("invalid-form",[this]);this.showErrors();return this.valid()},checkForm:function(){this.prepareForm();for(var a=0,b=this.currentElements=this.elements();b[a];a++)this.check(b[a]);return this.valid()},element:function(a){this.lastElement=
25
+ a=this.validationTargetFor(this.clean(a));this.prepareElement(a);this.currentElements=c(a);var b=this.check(a);if(b)delete this.invalid[a.name];else this.invalid[a.name]=true;if(!this.numberOfInvalids())this.toHide=this.toHide.add(this.containers);this.showErrors();return b},showErrors:function(a){if(a){c.extend(this.errorMap,a);this.errorList=[];for(var b in a)this.errorList.push({message:a[b],element:this.findByName(b)[0]});this.successList=c.grep(this.successList,function(d){return!(d.name in a)})}this.settings.showErrors?
26
+ this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){c.fn.resetForm&&c(this.currentForm).resetForm();this.submitted={};this.lastElement=null;this.prepareForm();this.hideErrors();this.elements().removeClass(this.settings.errorClass)},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(a){var b=0,d;for(d in a)b++;return b},hideErrors:function(){this.addWrapper(this.toHide).hide()},valid:function(){return this.size()==
27
+ 0},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{c(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(a){}},findLastActive:function(){var a=this.lastActive;return a&&c.grep(this.errorList,function(b){return b.element.name==a.name}).length==1&&a},elements:function(){var a=this,b={};return c(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){!this.name&&
28
+ a.settings.debug&&window.console&&console.error("%o has no name assigned",this);if(this.name in b||!a.objectLength(c(this).rules()))return false;return b[this.name]=true})},clean:function(a){return c(a)[0]},errors:function(){return c(this.settings.errorElement+"."+this.settings.errorClass,this.errorContext)},reset:function(){this.successList=[];this.errorList=[];this.errorMap={};this.toShow=c([]);this.toHide=c([]);this.currentElements=c([])},prepareForm:function(){this.reset();this.toHide=this.errors().add(this.containers)},
29
+ prepareElement:function(a){this.reset();this.toHide=this.errorsFor(a)},check:function(a){a=this.validationTargetFor(this.clean(a));var b=c(a).rules(),d=false,e;for(e in b){var f={method:e,parameters:b[e]};try{var g=c.validator.methods[e].call(this,a.value.replace(/\r/g,""),a,f.parameters);if(g=="dependency-mismatch")d=true;else{d=false;if(g=="pending"){this.toHide=this.toHide.not(this.errorsFor(a));return}if(!g){this.formatAndAdd(a,f);return false}}}catch(h){this.settings.debug&&window.console&&console.log("exception occured when checking element "+
30
+ a.id+", check the '"+f.method+"' method",h);throw h;}}if(!d){this.objectLength(b)&&this.successList.push(a);return true}},customMetaMessage:function(a,b){if(c.metadata){var d=this.settings.meta?c(a).metadata()[this.settings.meta]:c(a).metadata();return d&&d.messages&&d.messages[b]}},customMessage:function(a,b){var d=this.settings.messages[a];return d&&(d.constructor==String?d:d[b])},findDefined:function(){for(var a=0;a<arguments.length;a++)if(arguments[a]!==undefined)return arguments[a]},defaultMessage:function(a,
31
+ b){return this.findDefined(this.customMessage(a.name,b),this.customMetaMessage(a,b),!this.settings.ignoreTitle&&a.title||undefined,c.validator.messages[b],"<strong>Warning: No message defined for "+a.name+"</strong>")},formatAndAdd:function(a,b){var d=this.defaultMessage(a,b.method),e=/\$?\{(\d+)\}/g;if(typeof d=="function")d=d.call(this,b.parameters,a);else if(e.test(d))d=jQuery.format(d.replace(e,"{$1}"),b.parameters);this.errorList.push({message:d,element:a});this.errorMap[a.name]=d;this.submitted[a.name]=
32
+ d},addWrapper:function(a){if(this.settings.wrapper)a=a.add(a.parent(this.settings.wrapper));return a},defaultShowErrors:function(){for(var a=0;this.errorList[a];a++){var b=this.errorList[a];this.settings.highlight&&this.settings.highlight.call(this,b.element,this.settings.errorClass,this.settings.validClass);this.showLabel(b.element,b.message)}if(this.errorList.length)this.toShow=this.toShow.add(this.containers);if(this.settings.success)for(a=0;this.successList[a];a++)this.showLabel(this.successList[a]);
33
+ if(this.settings.unhighlight){a=0;for(b=this.validElements();b[a];a++)this.settings.unhighlight.call(this,b[a],this.settings.errorClass,this.settings.validClass)}this.toHide=this.toHide.not(this.toShow);this.hideErrors();this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return c(this.errorList).map(function(){return this.element})},showLabel:function(a,b){var d=this.errorsFor(a);if(d.length){d.removeClass(this.settings.validClass).addClass(this.settings.errorClass);
34
+ d.attr("generated")&&d.html(b)}else{d=c("<"+this.settings.errorElement+"/>").attr({"for":this.idOrName(a),generated:true}).addClass(this.settings.errorClass).html(b||"");if(this.settings.wrapper)d=d.hide().show().wrap("<"+this.settings.wrapper+"/>").parent();this.labelContainer.append(d).length||(this.settings.errorPlacement?this.settings.errorPlacement(d,c(a)):d.insertAfter(a))}if(!b&&this.settings.success){d.text("");typeof this.settings.success=="string"?d.addClass(this.settings.success):this.settings.success(d)}this.toShow=
35
+ this.toShow.add(d)},errorsFor:function(a){var b=this.idOrName(a);return this.errors().filter(function(){return c(this).attr("for")==b})},idOrName:function(a){return this.groups[a.name]||(this.checkable(a)?a.name:a.id||a.name)},validationTargetFor:function(a){if(this.checkable(a))a=this.findByName(a.name).not(this.settings.ignore)[0];return a},checkable:function(a){return/radio|checkbox/i.test(a.type)},findByName:function(a){var b=this.currentForm;return c(document.getElementsByName(a)).map(function(d,
36
+ e){return e.form==b&&e.name==a&&e||null})},getLength:function(a,b){switch(b.nodeName.toLowerCase()){case "select":return c("option:selected",b).length;case "input":if(this.checkable(b))return this.findByName(b.name).filter(":checked").length}return a.length},depend:function(a,b){return this.dependTypes[typeof a]?this.dependTypes[typeof a](a,b):true},dependTypes:{"boolean":function(a){return a},string:function(a,b){return!!c(a,b.form).length},"function":function(a,b){return a(b)}},optional:function(a){return!c.validator.methods.required.call(this,
37
+ c.trim(a.value),a)&&"dependency-mismatch"},startRequest:function(a){if(!this.pending[a.name]){this.pendingRequest++;this.pending[a.name]=true}},stopRequest:function(a,b){this.pendingRequest--;if(this.pendingRequest<0)this.pendingRequest=0;delete this.pending[a.name];if(b&&this.pendingRequest==0&&this.formSubmitted&&this.form()){c(this.currentForm).submit();this.formSubmitted=false}else if(!b&&this.pendingRequest==0&&this.formSubmitted){c(this.currentForm).triggerHandler("invalid-form",[this]);this.formSubmitted=
38
+ false}},previousValue:function(a){return c.data(a,"previousValue")||c.data(a,"previousValue",{old:null,valid:true,message:this.defaultMessage(a,"remote")})}},classRuleSettings:{required:{required:true},email:{email:true},url:{url:true},date:{date:true},dateISO:{dateISO:true},dateDE:{dateDE:true},number:{number:true},numberDE:{numberDE:true},digits:{digits:true},creditcard:{creditcard:true}},addClassRules:function(a,b){a.constructor==String?this.classRuleSettings[a]=b:c.extend(this.classRuleSettings,
39
+ a)},classRules:function(a){var b={};(a=c(a).attr("class"))&&c.each(a.split(" "),function(){this in c.validator.classRuleSettings&&c.extend(b,c.validator.classRuleSettings[this])});return b},attributeRules:function(a){var b={};a=c(a);for(var d in c.validator.methods){var e;if(e=d==="required"&&typeof c.fn.prop==="function"?a.prop(d):a.attr(d))b[d]=e;else if(a[0].getAttribute("type")===d)b[d]=true}b.maxlength&&/-1|2147483647|524288/.test(b.maxlength)&&delete b.maxlength;return b},metadataRules:function(a){if(!c.metadata)return{};
40
+ var b=c.data(a.form,"validator").settings.meta;return b?c(a).metadata()[b]:c(a).metadata()},staticRules:function(a){var b={},d=c.data(a.form,"validator");if(d.settings.rules)b=c.validator.normalizeRule(d.settings.rules[a.name])||{};return b},normalizeRules:function(a,b){c.each(a,function(d,e){if(e===false)delete a[d];else if(e.param||e.depends){var f=true;switch(typeof e.depends){case "string":f=!!c(e.depends,b.form).length;break;case "function":f=e.depends.call(b,b)}if(f)a[d]=e.param!==undefined?
41
+ e.param:true;else delete a[d]}});c.each(a,function(d,e){a[d]=c.isFunction(e)?e(b):e});c.each(["minlength","maxlength","min","max"],function(){if(a[this])a[this]=Number(a[this])});c.each(["rangelength","range"],function(){if(a[this])a[this]=[Number(a[this][0]),Number(a[this][1])]});if(c.validator.autoCreateRanges){if(a.min&&a.max){a.range=[a.min,a.max];delete a.min;delete a.max}if(a.minlength&&a.maxlength){a.rangelength=[a.minlength,a.maxlength];delete a.minlength;delete a.maxlength}}a.messages&&delete a.messages;
42
+ return a},normalizeRule:function(a){if(typeof a=="string"){var b={};c.each(a.split(/\s/),function(){b[this]=true});a=b}return a},addMethod:function(a,b,d){c.validator.methods[a]=b;c.validator.messages[a]=d!=undefined?d:c.validator.messages[a];b.length<3&&c.validator.addClassRules(a,c.validator.normalizeRule(a))},methods:{required:function(a,b,d){if(!this.depend(d,b))return"dependency-mismatch";switch(b.nodeName.toLowerCase()){case "select":return(a=c(b).val())&&a.length>0;case "input":if(this.checkable(b))return this.getLength(a,
43
+ b)>0;default:return c.trim(a).length>0}},remote:function(a,b,d){if(this.optional(b))return"dependency-mismatch";var e=this.previousValue(b);this.settings.messages[b.name]||(this.settings.messages[b.name]={});e.originalMessage=this.settings.messages[b.name].remote;this.settings.messages[b.name].remote=e.message;d=typeof d=="string"&&{url:d}||d;if(this.pending[b.name])return"pending";if(e.old===a)return e.valid;e.old=a;var f=this;this.startRequest(b);var g={};g[b.name]=a;c.ajax(c.extend(true,{url:d,
44
+ mode:"abort",port:"validate"+b.name,dataType:"json",data:g,success:function(h){f.settings.messages[b.name].remote=e.originalMessage;var j=h===true;if(j){var i=f.formSubmitted;f.prepareElement(b);f.formSubmitted=i;f.successList.push(b);f.showErrors()}else{i={};h=h||f.defaultMessage(b,"remote");i[b.name]=e.message=c.isFunction(h)?h(a):h;f.showErrors(i)}e.valid=j;f.stopRequest(b,j)}},d));return"pending"},minlength:function(a,b,d){return this.optional(b)||this.getLength(c.trim(a),b)>=d},maxlength:function(a,
45
+ b,d){return this.optional(b)||this.getLength(c.trim(a),b)<=d},rangelength:function(a,b,d){a=this.getLength(c.trim(a),b);return this.optional(b)||a>=d[0]&&a<=d[1]},min:function(a,b,d){return this.optional(b)||a>=d},max:function(a,b,d){return this.optional(b)||a<=d},range:function(a,b,d){return this.optional(b)||a>=d[0]&&a<=d[1]},email:function(a,b){return this.optional(b)||/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(a)},
46
+ url:function(a,b){return this.optional(b)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(a)},
47
+ date:function(a,b){return this.optional(b)||!/Invalid|NaN/.test(new Date(a))},dateISO:function(a,b){return this.optional(b)||/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(a)},number:function(a,b){return this.optional(b)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(a)},digits:function(a,b){return this.optional(b)||/^\d+$/.test(a)},creditcard:function(a,b){if(this.optional(b))return"dependency-mismatch";if(/[^0-9 -]+/.test(a))return false;var d=0,e=0,f=false;a=a.replace(/\D/g,"");for(var g=a.length-1;g>=
48
+ 0;g--){e=a.charAt(g);e=parseInt(e,10);if(f)if((e*=2)>9)e-=9;d+=e;f=!f}return d%10==0},accept:function(a,b,d){d=typeof d=="string"?d.replace(/,/g,"|"):"png|jpe?g|gif";return this.optional(b)||a.match(RegExp(".("+d+")$","i"))},equalTo:function(a,b,d){d=c(d).unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){c(b).valid()});return a==d.val()}}});c.format=c.validator.format})(jQuery);
49
+ (function(c){var a={};if(c.ajaxPrefilter)c.ajaxPrefilter(function(d,e,f){e=d.port;if(d.mode=="abort"){a[e]&&a[e].abort();a[e]=f}});else{var b=c.ajax;c.ajax=function(d){var e=("port"in d?d:c.ajaxSettings).port;if(("mode"in d?d:c.ajaxSettings).mode=="abort"){a[e]&&a[e].abort();return a[e]=b.apply(this,arguments)}return b.apply(this,arguments)}}})(jQuery);
50
+ (function(c){!jQuery.event.special.focusin&&!jQuery.event.special.focusout&&document.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(e){e=c.event.fix(e);e.type=b;return c.event.handle.call(this,e)}c.event.special[b]={setup:function(){this.addEventListener(a,d,true)},teardown:function(){this.removeEventListener(a,d,true)},handler:function(e){arguments[0]=c.event.fix(e);arguments[0].type=b;return c.event.handle.apply(this,arguments)}}});c.extend(c.fn,{validateDelegate:function(a,
51
+ b,d){return this.bind(b,function(e){var f=c(e.target);if(f.is(a))return d.apply(f,arguments)})}})})(jQuery);
public/js/main.js CHANGED
@@ -190,6 +190,13 @@ sgBackup.initModals = function(){
190
  token: BG_BACKUP_STRINGS.nonce
191
  });
192
 
 
 
 
 
 
 
 
193
  ajaxHandler.type = 'GET';
194
  ajaxHandler.dataType = 'html';
195
  ajaxHandler.callback = function(data, error) {
190
  token: BG_BACKUP_STRINGS.nonce
191
  });
192
 
193
+ if (modalName == 'backup-guard-details') {
194
+ modal.modal({
195
+ backdrop: 'static',
196
+ keyboard: false
197
+ });
198
+ }
199
+
200
  ajaxHandler.type = 'GET';
201
  ajaxHandler.dataType = 'html';
202
  ajaxHandler.callback = function(data, error) {
public/js/popup.js CHANGED
@@ -1492,27 +1492,66 @@ SGPopup.openSGPopup = function() {
1492
  }
1493
  };
1494
 
1495
- var hiddenDivId = 'sg-backup-review-wrapper';
1496
- var popupConfigObj = new PopupConfig();
1497
- popupConfigObj.magicCall('setContentPadding', 0);
1498
- popupConfigObj.magicCall('setContentBorderRadius', 4);
1499
- popupConfigObj.magicCall('setContentBorderRadiusType', 'px');
1500
- popupConfigObj.magicCall('setContentBorderWidth', 5);
1501
- popupConfigObj.magicCall('setContentBorderColor', '#506274');
1502
- popupConfigObj.magicCall('setShadowSpread', 1);
1503
- popupConfigObj.magicCall('setContentShadowBlur', 4);
1504
- popupConfigObj.magicCall('setContentShadowColor', '#cccccc');
1505
- popupConfigObj.magicCall('setMinWidth', 400);
1506
- popupConfigObj.magicCall('setSrcElement', hiddenDivId);
1507
- popupConfigObj.magicCall('setOverlayColor', 'black');
1508
- popupConfigObj.magicCall('setOverlayOpacity', 40);
1509
- var config = popupConfigObj.combineConfigObj();
1510
-
1511
  jQuery(document).ready(function() {
1512
  if (!jQuery('#'+hiddenDivId).length) {
1513
  return false;
1514
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1515
  var popup = new SGPopup(config);
1516
  window.backupGuardReviewPopup = popup;
1517
  popup.open();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1518
  });
1492
  }
1493
  };
1494
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1495
  jQuery(document).ready(function() {
1496
  if (!jQuery('#'+hiddenDivId).length) {
1497
  return false;
1498
  }
1499
+ var hiddenDivId = 'sg-backup-review-wrapper';
1500
+ var popupConfigObj = new PopupConfig();
1501
+ popupConfigObj.magicCall('setContentPadding', 0);
1502
+ popupConfigObj.magicCall('setContentBorderRadius', 4);
1503
+ popupConfigObj.magicCall('setContentBorderRadiusType', 'px');
1504
+ popupConfigObj.magicCall('setContentBorderWidth', 5);
1505
+ popupConfigObj.magicCall('setContentBorderColor', '#506274');
1506
+ popupConfigObj.magicCall('setShadowSpread', 1);
1507
+ popupConfigObj.magicCall('setContentShadowBlur', 4);
1508
+ popupConfigObj.magicCall('setContentShadowColor', '#cccccc');
1509
+ popupConfigObj.magicCall('setMinWidth', 400);
1510
+ popupConfigObj.magicCall('setSrcElement', hiddenDivId);
1511
+ popupConfigObj.magicCall('setOverlayColor', 'black');
1512
+ popupConfigObj.magicCall('setOverlayOpacity', 40);
1513
+ var config = popupConfigObj.combineConfigObj();
1514
+
1515
  var popup = new SGPopup(config);
1516
  window.backupGuardReviewPopup = popup;
1517
  popup.open();
1518
+ });
1519
+
1520
+ jQuery(document).ready(function () {
1521
+ var hiddenDivId = 'sg-halloween-popup-content-wrapper';
1522
+ if (!jQuery('#'+hiddenDivId).length) {
1523
+ return false;
1524
+ }
1525
+
1526
+ var popupConfigObj = new PopupConfig();
1527
+ popupConfigObj.magicCall('setContentPadding', 0);
1528
+ popupConfigObj.magicCall('setContentBorderRadius', 4);
1529
+ popupConfigObj.magicCall('setContentBorderRadiusType', 'px');
1530
+ popupConfigObj.magicCall('setContentBorderWidth', 0);
1531
+ popupConfigObj.magicCall('setOverlayColor', 'white');
1532
+ popupConfigObj.magicCall('setContentBorderColor', '#506274');
1533
+ popupConfigObj.magicCall('setShadowSpread', 1);
1534
+ popupConfigObj.magicCall('setContentShadowBlur', 4);
1535
+ popupConfigObj.magicCall('setContentBackgroundColor', 'rgba(1,1,1,0)');
1536
+ popupConfigObj.magicCall('setContentShadowColor', '');
1537
+ popupConfigObj.magicCall('setMinWidth', 400);
1538
+ popupConfigObj.magicCall('setSrcElement', hiddenDivId);
1539
+ popupConfigObj.magicCall('setOverlayColor', 'black');
1540
+ popupConfigObj.magicCall('setOverlayOpacity', 40);
1541
+ var config = popupConfigObj.combineConfigObj();
1542
+
1543
+ var popup = new SGPopup(config);
1544
+ window.backupGuardHalloweenPopup = popup;
1545
+ popup.open();
1546
+
1547
+ jQuery('.sgbg-halloween-close-popup').bind('click', function () {
1548
+ window.backupGuardHalloweenPopup.close();
1549
+ jQuery('.backup-guard-discount-notice').remove();
1550
+ var sgNoticeClosedHandler = new sgRequestHandler('dismiss_discount_notice', {token: BG_BACKUP_STRINGS.nonce});
1551
+ sgNoticeClosedHandler.run();
1552
+ });
1553
+
1554
+ jQuery('#sg-halloween-popup-content-wrapper').bind('click', function () {
1555
+ window.open('https://backup-guard.com/products/backup-wordpress#pricing')
1556
+ });
1557
  });
public/js/sgbackup.js CHANGED
@@ -7,6 +7,7 @@ SG_STORAGE_DROPBOX = 2;
7
  SG_STORAGE_GOOGLE_DRIVE = 3;
8
  SG_STORAGE_AMAZON = 4;
9
  SG_STORAGE_ONE_DRIVE = 5;
 
10
 
11
  jQuery(document).on('change', '.btn-file :file', function() {
12
  var input = jQuery(this),
@@ -294,6 +295,9 @@ sgBackup.listStorage = function(importFrom) {
294
  case SG_STORAGE_ONE_DRIVE:
295
  cloudName = "OneDrive";
296
  break;
 
 
 
297
  default:
298
  cloudName = '';
299
  }
@@ -307,8 +311,16 @@ sgBackup.listStorage = function(importFrom) {
307
  }
308
  else {
309
  jQuery.each(response, function( key, value ) {
 
 
 
 
 
 
 
 
310
  content += '<tr>';
311
- content += '<td class="file-select-radio"><input type="radio" file-name="'+value.name+'" name="select-archive-to-download" size="'+value.size+'" storage="'+importFrom+'" value="'+value.path+'"></td>';
312
  content += '<td>'+value.name+'</td>';
313
  content += '<td>'+sgBackup.convertBytesToMegabytes(value.size)+'</td>';
314
  content += '<td>'+value.date+'</td>';
@@ -339,7 +351,8 @@ sgBackup.initFileUpload = function(){
339
  var name = target.attr('file-name');
340
  var storage = target.attr('storage');
341
  var size = target.attr('size');
342
- sgBackup.downloadFromCloud(path, name, storage, size);
 
343
  }
344
  });
345
  };
@@ -423,7 +436,7 @@ sgBackup.downloadFromCloud = function (path, name, storage, size) {
423
  jQuery('#sg-modal .modal-header').prepend(sgAlert);
424
  return false;
425
  }
426
-
427
  var downloadFromCloudHandler = new sgRequestHandler('downloadFromCloud', {
428
  path: path,
429
  storage: storage,
@@ -617,6 +630,7 @@ sgBackup.initManualBackupTooltips = function(){
617
  jQuery('[for=cloud-gdrive]').tooltip();
618
  jQuery('[for=cloud-one-drive]').tooltip();
619
  jQuery('[for=cloud-amazon]').tooltip();
 
620
 
621
  jQuery('a[data-toggle=tooltip]').tooltip();
622
  };
@@ -752,18 +766,24 @@ sgBackup.statusUpdate = function(tooltip, response, progressInPercents){
752
  }
753
  else if(response.type == '3'){
754
  var cloudIcon = jQuery('.sg-status-'+response.type+response.subtype);
755
- if(response.subtype == '1'){
756
  tooltipText = 'Uploading to FTP - '+progressInPercents;
757
  }
758
- else if(response.subtype == '2'){
759
  tooltipText = 'Uploading to Dropbox - '+progressInPercents;
760
  }
761
- else if(response.subtype == '3'){
762
  tooltipText = 'Uploading to Google Drive - '+progressInPercents;
763
  }
764
- else if(response.subtype == '4') {
765
  tooltipText = 'Uploading to Amazon S3 - '+progressInPercents;
766
  }
 
 
 
 
 
 
767
  cloudIcon.prevAll('[class*=sg-status]').addClass('active');
768
  }
769
  tooltip.attr('data-original-title',tooltipText);
7
  SG_STORAGE_GOOGLE_DRIVE = 3;
8
  SG_STORAGE_AMAZON = 4;
9
  SG_STORAGE_ONE_DRIVE = 5;
10
+ SG_STORAGE_BACKUP_GUARD = 6;
11
 
12
  jQuery(document).on('change', '.btn-file :file', function() {
13
  var input = jQuery(this),
295
  case SG_STORAGE_ONE_DRIVE:
296
  cloudName = "OneDrive";
297
  break;
298
+ case SG_STORAGE_BACKUP_GUARD:
299
+ cloudName = "BackupGuard";
300
+ break;
301
  default:
302
  cloudName = '';
303
  }
311
  }
312
  else {
313
  jQuery.each(response, function( key, value ) {
314
+
315
+ var backupId = 0;
316
+
317
+ if (typeof value.id != 'undefined') {
318
+ backupId = value.id;
319
+ value.path = value.name;
320
+ }
321
+
322
  content += '<tr>';
323
+ content += '<td class="file-select-radio"><input type="radio" file-name="'+value.name+'" name="select-archive-to-download" size="'+value.size+'" backup-id="'+value.id+'" storage="'+importFrom+'" value="'+value.path+'"></td>';
324
  content += '<td>'+value.name+'</td>';
325
  content += '<td>'+sgBackup.convertBytesToMegabytes(value.size)+'</td>';
326
  content += '<td>'+value.date+'</td>';
351
  var name = target.attr('file-name');
352
  var storage = target.attr('storage');
353
  var size = target.attr('size');
354
+ var backupId = target.attr('backup-id');
355
+ sgBackup.downloadFromCloud(path, name, storage, size, backupId);
356
  }
357
  });
358
  };
436
  jQuery('#sg-modal .modal-header').prepend(sgAlert);
437
  return false;
438
  }
439
+
440
  var downloadFromCloudHandler = new sgRequestHandler('downloadFromCloud', {
441
  path: path,
442
  storage: storage,
630
  jQuery('[for=cloud-gdrive]').tooltip();
631
  jQuery('[for=cloud-one-drive]').tooltip();
632
  jQuery('[for=cloud-amazon]').tooltip();
633
+ jQuery('[for=cloud-backup-guard]').tooltip();
634
 
635
  jQuery('a[data-toggle=tooltip]').tooltip();
636
  };
766
  }
767
  else if(response.type == '3'){
768
  var cloudIcon = jQuery('.sg-status-'+response.type+response.subtype);
769
+ if(response.subtype == SG_STORAGE_FTP){
770
  tooltipText = 'Uploading to FTP - '+progressInPercents;
771
  }
772
+ else if(response.subtype == SG_STORAGE_DROPBOX){
773
  tooltipText = 'Uploading to Dropbox - '+progressInPercents;
774
  }
775
+ else if(response.subtype == SG_STORAGE_GOOGLE_DRIVE){
776
  tooltipText = 'Uploading to Google Drive - '+progressInPercents;
777
  }
778
+ else if(response.subtype == SG_STORAGE_AMAZON) {
779
  tooltipText = 'Uploading to Amazon S3 - '+progressInPercents;
780
  }
781
+ else if(response.subtype == SG_STORAGE_ONE_DRIVE) {
782
+ tooltipText = 'Uploading to OneDrive - '+progressInPercents;
783
+ }
784
+ else if(response.subtype == SG_STORAGE_BACKUP_GUARD) {
785
+ tooltipText = 'Uploading to BackupGuard - '+progressInPercents;
786
+ }
787
  cloudIcon.prevAll('[class*=sg-status]').addClass('active');
788
  }
789
  tooltip.attr('data-original-title',tooltipText);
public/js/sgcloud.js CHANGED
@@ -1,73 +1,74 @@
1
  jQuery(document).ready( function() {
2
- sgBackup.initCloudSwitchButtons();
3
- sgBackup.initCloudFolderSettings();
4
  });
5
 
6
  jQuery(document).on('change', '.btn-file :file', function() {
7
- var input = jQuery(this),
8
- numFiles = input.get(0).files ? input.get(0).files.length : 1,
9
- label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
10
- input.trigger('fileselect', [numFiles, label]);
11
  });
12
 
13
  sgBackup.initSFTPKeyFileSelection = function() {
14
- isFileSelected = false;
15
- jQuery('.btn-file :file').off('fileselect').on('fileselect', function(event, numFiles, label){
16
- var input = jQuery(this).parents('.input-group').find(':text'),
17
- log = numFiles > 1 ? numFiles + ' files selected' : label;
18
-
19
- if (input.length) {
20
- input.val(log);
21
- isFileSelected = true;
22
- }
23
- else {
24
- if(log) alert(log);
25
- }
26
- });
27
  }
28
 
29
  sgBackup.importKeyFile = function(isFileSelected){
30
- jQuery('.alert').remove();
31
- if(!isFileSelected){
32
- var alert = sgBackup.alertGenerator(BG_CLOUD_STRINGS.invalidImportFile, 'alert-danger');
33
- jQuery('#sg-modal .modal-header').prepend(alert);
34
- return false;
35
- }
36
 
37
- var sguploadFile = new FormData(),
38
- url = "importKeyFile",
39
- sgAllowedFileSize = jQuery('.sg-backup-upload-input').attr('data-max-file-size'),
40
- sgFile = jQuery('input[name=sg-ssh-key-file]')[0].files[0];
41
- sguploadFile.append('sg-ssh-key-file', sgFile);
42
- if(sgFile.size > sgAllowedFileSize){
43
- var alert = sgBackup.alertGenerator(BG_CLOUD_STRINGS.invalidFileSize, 'alert-danger');
44
- jQuery('#sg-modal .modal-header').prepend(alert);
45
- return false;
46
- }
47
 
48
- var ajaxHandler = new sgRequestHandler(url, sguploadFile, {
49
- contentType: false,
50
- token: BG_BACKUP_STRINGS.nonce,
51
- cache: false,
52
- xhr: function() { // Custom XMLHttpRequest
53
- var myXhr = jQuery.ajaxSettings.xhr();
54
- if(myXhr.upload){ // Check if upload property exists
55
- myXhr.upload.addEventListener('progress', sgBackup.fileUploadProgress, false); // For handling the progress of the upload
56
- }
57
- return myXhr;
58
- },
59
- processData: false
60
- });
61
 
62
- ajaxHandler.callback = function(response, error){
63
- jQuery('.alert').remove();
64
- if(typeof response.success == 'undefined'){
65
- //if error
66
- var alert = sgBackup.alertGenerator(response, 'alert-danger');
67
- jQuery('#sg-modal .modal-header').prepend(alert);
68
- }
69
- };
70
- ajaxHandler.run();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  }
72
 
73
  sgBackup.initCloudSwitchButtons = function(){
@@ -77,7 +78,7 @@ sgBackup.initCloudSwitchButtons = function(){
77
  var storage = jQuery(this).attr('data-storage'),
78
  url = jQuery(this).attr('data-remote');
79
  var that = jQuery(this);
80
- //If switch is on
81
  if(state) {
82
  jQuery('.alert').remove();
83
  if(storage == 'DROPBOX' || storage == 'GOOGLE_DRIVE' || storage == 'ONE_DRIVE') {
@@ -117,11 +118,19 @@ sgBackup.initCloudSwitchButtons = function(){
117
  sgBackup.isAmazonConnected = false;
118
  jQuery('#amazon-settings').click();
119
  }
 
 
 
 
 
120
  }
121
  else {
122
  var ajaxHandler = new sgRequestHandler(url, {cancel: true,token: BG_BACKUP_STRINGS.nonce });
123
  ajaxHandler.callback = function(response){
124
  jQuery('.sg-'+storage+'-user').remove();
 
 
 
125
  };
126
  ajaxHandler.run();
127
  }
@@ -129,131 +138,131 @@ sgBackup.initCloudSwitchButtons = function(){
129
  };
130
 
131
  sgBackup.storeAmazonSettings = function(){
132
- var error = [];
133
- //Validation
134
- jQuery('.alert').remove();
135
- var amazonForm = jQuery('form[data-type=storeAmazonSettings]');
136
- amazonForm.find('input').each(function(){
137
- if(jQuery(this).val()<=0){
138
-
139
- if(jQuery(this)[0].id == "customBucketRegion" && jQuery("#bucketType").val() != "custom"){
140
- return;
141
- }
142
- var errorTxt = jQuery(this).closest('div').parent().find('label').html().slice(0,-2);
143
- error.push(errorTxt+' field is required.');
144
- }
145
- });
146
 
147
- //If any error show it and abort ajax
148
- if(error.length){
149
- var alert = sgBackup.alertGenerator(error, 'alert-danger');
150
- jQuery('#sg-modal .modal-header').prepend(alert);
151
- return false;
152
- }
 
153
 
154
- //Before Ajax call
155
- jQuery('.modal-footer .btn-primary').attr('disabled','disabled');
156
- jQuery('.modal-footer .btn-primary').html(BG_CLOUD_STRINGS.connectionInProgress);
 
 
 
157
 
158
- //Get user credentials
159
- var amazonBucket = jQuery('#amazonBucket').val();
160
- var amazonAccessKey = jQuery('#amazonAccessKey').val();
161
- var amazonSecretAccessKey = jQuery('#amazonSecretAccessKey').val();
162
- var region = jQuery('#amazonBucketRegion').val();
163
 
164
- //On Success
165
- var ajaxHandler = new sgRequestHandler('cloudAmazon',amazonForm.serialize());
166
- ajaxHandler.dataIsObject = false;
167
- ajaxHandler.callback = function(response){
168
- jQuery('.alert').remove();
169
- if(typeof response.success !== 'undefined'){
170
- sgBackup.isAmazonConnected = true;
171
- jQuery('input[data-storage=AMAZON]').bootstrapSwitch('state',true);
172
- jQuery('#sg-modal').modal('hide');
173
- }
174
- else{
175
- //if error
176
- var alert = sgBackup.alertGenerator(response, 'alert-danger');
177
- jQuery('#sg-modal .modal-header').prepend(alert);
178
-
179
- //Before Ajax call
180
- jQuery('.modal-footer .btn-primary').removeAttr('disabled');
181
- jQuery('.modal-footer .btn-primary').html('Save');
182
- }
183
- };
184
- ajaxHandler.run();
 
 
 
 
 
 
185
  };
186
 
187
  sgBackup.storeFtpSettings = function(){
188
- var error = [];
189
- //Validation
190
- jQuery('.alert').remove();
191
- var ftpForm = jQuery('form[data-type=storeFtpSettings]');
192
- ftpForm.find('input[type=text]').each(function(){
193
- if(jQuery(this).val()<=0){
194
- if (jQuery(this).attr('name') != 'sg-key-file') {
195
- var errorTxt = jQuery(this).closest('div').parent().find('label').html().slice(0,-2);
196
- }
197
- else {
198
- var errorTxt = jQuery(this).closest('div').parent().parent().find('label').html().slice(0,-2);
199
- }
200
 
201
 
202
- if(!jQuery('#sg-connect-with-key-file').is(':checked') && errorTxt == 'Private key') {
203
- return true;
204
- }
205
 
206
- if(jQuery('#sg-connect-with-key-file').is(':checked') && errorTxt == 'Password') {
207
- return true;
208
- }
209
 
210
- error.push(errorTxt+' field is required.');
211
- }
212
- });
213
 
214
- //If any error show it and abort ajax
215
- if(error.length){
216
- var alert = sgBackup.alertGenerator(error, 'alert-danger');
217
- jQuery('#sg-modal .modal-header').prepend(alert);
218
- return false;
219
- }
220
 
221
- //Before Ajax call
222
- jQuery('.modal-footer .btn-primary').attr('disabled','disabled');
223
- jQuery('.modal-footer .btn-primary').html('Connecting...');
224
 
225
- //Get user credentials
226
- var ftpHost = jQuery('#ftpHost').val();
227
- var ftpUser = jQuery('#ftpUser').val();
228
- var ftpPort = jQuery('#ftpPort').val();
229
- var ftpString = ftpUser+'@'+ftpHost+':'+ftpPort;
230
 
231
- if (jQuery("#sg-connect-with-key-file").is(":checked")) {
232
- sgBackup.importKeyFile(isFileSelected);
233
- }
234
 
235
- //On Success
236
- var ajaxHandler = new sgRequestHandler('cloudFtp',ftpForm.serialize());
237
- ajaxHandler.dataIsObject = false;
238
- ajaxHandler.callback = function(response){
239
- jQuery('.alert').remove();
240
- if(typeof response.success !== 'undefined'){
241
- sgBackup.isFtpConnected = true;
242
- jQuery('input[data-storage=FTP]').bootstrapSwitch('state',true);
243
- jQuery('#sg-modal').modal('hide');
244
- sgBackup.addUserInfo(ftpString);
245
- }
246
- else{
247
- //if error
248
- var alert = sgBackup.alertGenerator(response, 'alert-danger');
249
- jQuery('#sg-modal .modal-header').prepend(alert);
250
-
251
- //Before Ajax call
252
- jQuery('.modal-footer .btn-primary').removeAttr('disabled');
253
- jQuery('.modal-footer .btn-primary').html('Save');
254
- }
255
- };
256
- ajaxHandler.run();
257
  };
258
  sgBackup.initCloudFolderSettings = function(){
259
  jQuery('#cloudFolder').on('input', function(){
@@ -295,14 +304,215 @@ sgBackup.initCloudFolderSettings = function(){
295
  jQuery('.sg-cloud-container').before(alert);
296
  saveBtn.fadeOut();
297
  }
298
- }
299
 
300
  isFeatureAvailable.run();
301
  });
302
  };
303
 
304
  sgBackup.addUserInfo = function(info){
305
- jQuery('.sg-user-info .sg-helper-block').remove();
306
- jQuery('.sg-user-info br').remove();
307
- jQuery('.sg-user-info').append('<br/><span class="text-muted sg-user-email sg-helper-block">'+info+'</span>');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  };
1
  jQuery(document).ready( function() {
2
+ sgBackup.initCloudSwitchButtons();
3
+ sgBackup.initCloudFolderSettings();
4
  });
5
 
6
  jQuery(document).on('change', '.btn-file :file', function() {
7
+ var input = jQuery(this),
8
+ numFiles = input.get(0).files ? input.get(0).files.length : 1,
9
+ label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
10
+ input.trigger('fileselect', [numFiles, label]);
11
  });
12
 
13
  sgBackup.initSFTPKeyFileSelection = function() {
14
+ isFileSelected = false;
15
+ jQuery('.btn-file :file').off('fileselect').on('fileselect', function(event, numFiles, label){
16
+ var input = jQuery(this).parents('.input-group').find(':text'),
17
+ log = numFiles > 1 ? numFiles + ' files selected' : label;
18
+
19
+ if (input.length) {
20
+ input.val(log);
21
+ isFileSelected = true;
22
+ }
23
+ else {
24
+ if(log) alert(log);
25
+ }
26
+ });
27
  }
28
 
29
  sgBackup.importKeyFile = function(isFileSelected){
 
 
 
 
 
 
30
 
31
+ jQuery('.alert').remove();
32
+ if(!isFileSelected){
33
+ var alert = sgBackup.alertGenerator(BG_CLOUD_STRINGS.invalidImportFile, 'alert-danger');
34
+ jQuery('#sg-modal .modal-header').prepend(alert);
35
+ return false;
36
+ }
 
 
 
 
37
 
38
+ var sguploadFile = new FormData(),
39
+ url = "importKeyFile",
40
+ sgAllowedFileSize = jQuery('.sg-backup-upload-input').attr('data-max-file-size'),
41
+ sgFile = jQuery('input[name=sg-ssh-key-file]')[0].files[0];
42
+ sguploadFile.append('sg-ssh-key-file', sgFile);
43
+ if(sgFile.size > sgAllowedFileSize){
44
+ var alert = sgBackup.alertGenerator(BG_CLOUD_STRINGS.invalidFileSize, 'alert-danger');
45
+ jQuery('#sg-modal .modal-header').prepend(alert);
46
+ return false;
47
+ }
 
 
 
48
 
49
+ var ajaxHandler = new sgRequestHandler(url, sguploadFile, {
50
+ contentType: false,
51
+ token: BG_BACKUP_STRINGS.nonce,
52
+ cache: false,
53
+ xhr: function() { /* Custom XMLHttpRequest */
54
+ var myXhr = jQuery.ajaxSettings.xhr();
55
+ if(myXhr.upload){ /* Check if upload property exists */
56
+ myXhr.upload.addEventListener('progress', sgBackup.fileUploadProgress, false); /* For handling the progress of the upload */
57
+ }
58
+ return myXhr;
59
+ },
60
+ processData: false
61
+ });
62
+
63
+ ajaxHandler.callback = function(response, error){
64
+ jQuery('.alert').remove();
65
+ if(typeof response.success == 'undefined'){
66
+ /* if error */
67
+ var alert = sgBackup.alertGenerator(response, 'alert-danger');
68
+ jQuery('#sg-modal .modal-header').prepend(alert);
69
+ }
70
+ };
71
+ ajaxHandler.run();
72
  }
73
 
74
  sgBackup.initCloudSwitchButtons = function(){
78
  var storage = jQuery(this).attr('data-storage'),
79
  url = jQuery(this).attr('data-remote');
80
  var that = jQuery(this);
81
+ /* If switch is on */
82
  if(state) {
83
  jQuery('.alert').remove();
84
  if(storage == 'DROPBOX' || storage == 'GOOGLE_DRIVE' || storage == 'ONE_DRIVE') {
118
  sgBackup.isAmazonConnected = false;
119
  jQuery('#amazon-settings').click();
120
  }
121
+ else if (storage == 'BACKUP_GUARD') {
122
+ jQuery('input[data-storage=BACKUP_GUARD]').bootstrapSwitch('indeterminate',true);
123
+ sgBackup.isBackupGuardConnected = false;
124
+ jQuery('#backup-guard-details').click();
125
+ }
126
  }
127
  else {
128
  var ajaxHandler = new sgRequestHandler(url, {cancel: true,token: BG_BACKUP_STRINGS.nonce });
129
  ajaxHandler.callback = function(response){
130
  jQuery('.sg-'+storage+'-user').remove();
131
+ if (typeof storage == 'string') {
132
+ location.reload();
133
+ }
134
  };
135
  ajaxHandler.run();
136
  }
138
  };
139
 
140
  sgBackup.storeAmazonSettings = function(){
141
+ var error = [];
142
+ /* Validation */
143
+ jQuery('.alert').remove();
144
+ var amazonForm = jQuery('form[data-type=storeAmazonSettings]');
145
+ amazonForm.find('input').each(function(){
146
+ if(jQuery(this).val()<=0){
 
 
 
 
 
 
 
 
147
 
148
+ if(jQuery(this)[0].id == "customBucketRegion" && jQuery("#bucketType").val() != "custom"){
149
+ return;
150
+ }
151
+ var errorTxt = jQuery(this).closest('div').parent().find('label').html().slice(0,-2);
152
+ error.push(errorTxt+' field is required.');
153
+ }
154
+ });
155
 
156
+ /* If any error show it and abort ajax */
157
+ if(error.length){
158
+ var alert = sgBackup.alertGenerator(error, 'alert-danger');
159
+ jQuery('#sg-modal .modal-header').prepend(alert);
160
+ return false;
161
+ }
162
 
163
+ /* Before Ajax call */
164
+ jQuery('.modal-footer .btn-primary').attr('disabled','disabled');
165
+ jQuery('.modal-footer .btn-primary').html(BG_CLOUD_STRINGS.connectionInProgress);
 
 
166
 
167
+ /* Get user credentials */
168
+ var amazonBucket = jQuery('#amazonBucket').val();
169
+ var amazonAccessKey = jQuery('#amazonAccessKey').val();
170
+ var amazonSecretAccessKey = jQuery('#amazonSecretAccessKey').val();
171
+ var region = jQuery('#amazonBucketRegion').val();
172
+
173
+ /* On Success */
174
+ var ajaxHandler = new sgRequestHandler('cloudAmazon',amazonForm.serialize());
175
+ ajaxHandler.dataIsObject = false;
176
+ ajaxHandler.callback = function(response){
177
+ jQuery('.alert').remove();
178
+ if(typeof response.success !== 'undefined'){
179
+ sgBackup.isAmazonConnected = true;
180
+ jQuery('input[data-storage=AMAZON]').bootstrapSwitch('state',true);
181
+ jQuery('#sg-modal').modal('hide');
182
+ }
183
+ else{
184
+ /* if error */
185
+ var alert = sgBackup.alertGenerator(response, 'alert-danger');
186
+ jQuery('#sg-modal .modal-header').prepend(alert);
187
+
188
+ /* Before Ajax call */
189
+ jQuery('.modal-footer .btn-primary').removeAttr('disabled');
190
+ jQuery('.modal-footer .btn-primary').html('Save');
191
+ }
192
+ };
193
+ ajaxHandler.run();
194
  };
195
 
196
  sgBackup.storeFtpSettings = function(){
197
+ var error = [];
198
+ /* Validation */
199
+ jQuery('.alert').remove();
200
+ var ftpForm = jQuery('form[data-type=storeFtpSettings]');
201
+ ftpForm.find('input[type=text]').each(function(){
202
+ if(jQuery(this).val()<=0){
203
+ if (jQuery(this).attr('name') != 'sg-key-file') {
204
+ var errorTxt = jQuery(this).closest('div').parent().find('label').html().slice(0,-2);
205
+ }
206
+ else {
207
+ var errorTxt = jQuery(this).closest('div').parent().parent().find('label').html().slice(0,-2);
208
+ }
209
 
210
 
211
+ if(!jQuery('#sg-connect-with-key-file').is(':checked') && errorTxt == 'Private key') {
212
+ return true;
213
+ }
214
 
215
+ if(jQuery('#sg-connect-with-key-file').is(':checked') && errorTxt == 'Password') {
216
+ return true;
217
+ }
218
 
219
+ error.push(errorTxt+' field is required.');
220
+ }
221
+ });
222
 
223
+ /* If any error show it and abort ajax */
224
+ if(error.length){
225
+ var alert = sgBackup.alertGenerator(error, 'alert-danger');
226
+ jQuery('#sg-modal .modal-header').prepend(alert);
227
+ return false;
228
+ }
229
 
230
+ /* Before Ajax call */
231
+ jQuery('.modal-footer .btn-primary').attr('disabled','disabled');
232
+ jQuery('.modal-footer .btn-primary').html('Connecting...');
233
 
234
+ /* Get user credentials */
235
+ var ftpHost = jQuery('#ftpHost').val();
236
+ var ftpUser = jQuery('#ftpUser').val();
237
+ var ftpPort = jQuery('#ftpPort').val();
238
+ var ftpString = ftpUser+'@'+ftpHost+':'+ftpPort;
239
 
240
+ if (jQuery("#sg-connect-with-key-file").is(":checked")) {
241
+ sgBackup.importKeyFile(isFileSelected);
242
+ }
243
 
244
+ /* On Success */
245
+ var ajaxHandler = new sgRequestHandler('cloudFtp',ftpForm.serialize());
246
+ ajaxHandler.dataIsObject = false;
247
+ ajaxHandler.callback = function(response){
248
+ jQuery('.alert').remove();
249
+ if(typeof response.success !== 'undefined'){
250
+ sgBackup.isFtpConnected = true;
251
+ jQuery('input[data-storage=FTP]').bootstrapSwitch('state',true);
252
+ jQuery('#sg-modal').modal('hide');
253
+ sgBackup.addUserInfo(ftpString);
254
+ }
255
+ else{
256
+ /* if error */
257
+ var alert = sgBackup.alertGenerator(response, 'alert-danger');
258
+ jQuery('#sg-modal .modal-header').prepend(alert);
259
+
260
+ /* Before Ajax call */
261
+ jQuery('.modal-footer .btn-primary').removeAttr('disabled');
262
+ jQuery('.modal-footer .btn-primary').html('Save');
263
+ }
264
+ };
265
+ ajaxHandler.run();
266
  };
267
  sgBackup.initCloudFolderSettings = function(){
268
  jQuery('#cloudFolder').on('input', function(){
304
  jQuery('.sg-cloud-container').before(alert);
305
  saveBtn.fadeOut();
306
  }
307
+ };
308
 
309
  isFeatureAvailable.run();
310
  });
311
  };
312
 
313
  sgBackup.addUserInfo = function(info){
314
+ jQuery('.sg-user-info .sg-helper-block').remove();
315
+ jQuery('.sg-user-info br').remove();
316
+ jQuery('.sg-user-info').append('<br/><span class="text-muted sg-user-email sg-helper-block">'+info+'</span>');
317
+ };
318
+
319
+ sgBackup.backupCloudConnectCallback;
320
+
321
+ sgBackup.validateForm = function () {
322
+ var validateObj = {
323
+ rules: {
324
+ email: {
325
+ required: true,
326
+ email: true
327
+ },
328
+ password: {
329
+ required: true,
330
+ },
331
+ firstname: {
332
+ required: true,
333
+ },
334
+ lastname: {
335
+ required: true,
336
+ },
337
+ }
338
+ };
339
+ validateObj.submitHandler = function () {
340
+ var callBack = sgBackup.backupCloudConnectCallback;
341
+ callBack();
342
+ };
343
+ var form = jQuery('#backupGuardDetailsModal');
344
+ form.validate(validateObj);
345
+ form.submit();
346
+ };
347
+
348
+ sgBackup.bgCloudLoginForm = function (mode) {
349
+ var selectors = ['#bg-password-container', '#bg-login'];
350
+ for (var i in selectors) {
351
+ var selector = selectors[i];
352
+ if (mode == 'show') {
353
+ jQuery(selector).removeClass('hidden');
354
+ }
355
+ else {
356
+ jQuery(selector).addClass('hidden');
357
+ }
358
+ }
359
+
360
+ jQuery('#bg-connect-account').addClass('hidden');
361
+ };
362
+
363
+ sgBackup.bgCloudRegisterForm = function (mode) {
364
+ var selectors = ['#bg-firstname-container', '#bg-lastname-container', '#bg-create-account'];
365
+ for (var i in selectors) {
366
+ var selector = selectors[i];
367
+ if (mode == 'show') {
368
+ jQuery(selector).removeClass('hidden');
369
+ }
370
+ else {
371
+ jQuery(selector).addClass('hidden');
372
+ }
373
+ }
374
+
375
+ jQuery('#bg-connect-account').addClass('hidden');
376
+ };
377
+
378
+ sgBackup.backupGuardConnectRequest = function () {
379
+ sgBackup.showAjaxSpinner('.sg-modal-body');
380
+ var email = jQuery("#email").val();
381
+ var isUserExistsHandler = new sgRequestHandler('isBgUserExists', {email: email, token: BG_BACKUP_STRINGS.nonce});
382
+ isUserExistsHandler.callback = function(response) {
383
+ sgBackup.hideAjaxSpinner();
384
+
385
+ sgBackup.hideConnectionMessages();
386
+
387
+ if (response.validationError == 'error') {
388
+ jQuery('.bg-invalid-login').removeClass('hide');
389
+ return true;
390
+ }
391
+ else {
392
+ jQuery('.sg-backup-input-email').prop('readonly', true);
393
+ }
394
+ if (typeof response.success != 'undefined') {
395
+ jQuery('.bg-loggin-form-message').removeClass('hide');
396
+ sgBackup.bgCloudLoginForm('show');
397
+ }
398
+ else if (response.user == 'notFound') {
399
+ jQuery('.bg-register-form-message').removeClass('hide');
400
+ sgBackup.bgCloudRegisterForm('show')
401
+ }
402
+ };
403
+ isUserExistsHandler.run();
404
+ };
405
+
406
+ sgBackup.backupGuardConnect = function() {
407
+
408
+ sgBackup.backupCloudConnectCallback = sgBackup.backupGuardConnectRequest;
409
+ sgBackup.validateForm();
410
+ };
411
+
412
+ sgBackup.hideConnectionMessages = function ()
413
+ {
414
+ jQuery('.sgbg-connection-message').addClass('hide');
415
+ };
416
+
417
+ sgBackup.backupGuardLoginRequest = function ()
418
+ {
419
+ sgBackup.showAjaxSpinner('.sg-modal-body');
420
+ sgBackup.backupCloudConnectCallback = this;
421
+
422
+ var email = jQuery("#email").val();
423
+ var password = jQuery("#password").val();
424
+
425
+ var loginHandler = new sgRequestHandler('bgLogin', {email: email, password: password, token: BG_BACKUP_STRINGS.nonce});
426
+ loginHandler.callback = function(response) {
427
+ sgBackup.hideAjaxSpinner();
428
+ if (typeof response.profiles != 'undefined') {
429
+ jQuery('#bg-email-container').hide();
430
+ jQuery('#bg-password-container').hide();
431
+ jQuery('#bg-close-button').hide();
432
+ jQuery('#bg-login').hide();
433
+ sgBackup.hideConnectionMessages();
434
+ jQuery('.bg-create-form-message').removeClass('hide');
435
+
436
+ jQuery('#bg-choose-profile').removeClass('hidden');
437
+ jQuery('#bg-profiles-container').removeClass('hidden');
438
+
439
+ if (response.profiles.length) {
440
+ jQuery('.bg-select-profile').removeClass('hidden');
441
+ }
442
+ jQuery.each(response.profiles, function(key, value) {
443
+ jQuery('#bg-profiles').append('<option value="'+value['id']+'">'+value['name']+'</option>');
444
+ });
445
+
446
+ jQuery('#bg-profiles').on("change", function () {
447
+ var profileId = jQuery(this).val();
448
+ if (profileId === "0") {
449
+ jQuery('#bg-profile-name-container').show();
450
+ }
451
+ else {
452
+ jQuery('#bg-profile-name-container').hide();
453
+ }
454
+ });
455
+ }
456
+ else {
457
+ jQuery('.bg-invalid-login').removeClass('hide');
458
+ }
459
+ };
460
+ loginHandler.run();
461
+ };
462
+
463
+ sgBackup.backupGuardLogin = function() {
464
+ sgBackup.backupCloudConnectCallback = sgBackup.backupGuardLoginRequest;
465
+ sgBackup.validateForm();
466
+ };
467
+
468
+ sgBackup.chooseProfileRequest = function () {
469
+ sgBackup.showAjaxSpinner('.sg-modal-body');
470
+ var profileId = jQuery("#bg-profiles").val();
471
+ // var profileName = "";
472
+
473
+ if (profileId === "0") {
474
+ var profileName = jQuery("#bg-profile-name").val();
475
+ }
476
+ else {
477
+ var profileName = jQuery("#bg-profiles option:selected").text();
478
+ }
479
+
480
+ var chooseProfile = new sgRequestHandler('chooseProfile', {profileId: profileId, profileName: profileName, token: BG_BACKUP_STRINGS.nonce});
481
+ chooseProfile.callback = function(response) {
482
+ sgBackup.hideAjaxSpinner();
483
+ if (typeof response.success != 'undefined') {
484
+ location.reload();
485
+ }
486
+ };
487
+ chooseProfile.run();
488
+ };
489
+
490
+ sgBackup.chooseProfile = function() {
491
+ sgBackup.backupCloudConnectCallback = sgBackup.chooseProfileRequest;
492
+ sgBackup.validateForm();
493
+ };
494
+
495
+ sgBackup.createCloudUserRequest = function () {
496
+ sgBackup.showAjaxSpinner('.sg-modal-body');
497
+ var lastname = jQuery("#lastname").val();
498
+ var email = jQuery("#email").val();
499
+ var firstname = jQuery("#firstname").val();
500
+
501
+ var createCloudUserHandler = new sgRequestHandler('createCloudUser', {email: email, lastname: lastname, firstname: firstname, token: BG_BACKUP_STRINGS.nonce});
502
+ createCloudUserHandler.callback = function(response) {
503
+ sgBackup.hideAjaxSpinner();
504
+ if (typeof response.success != 'undefined') {
505
+ sgBackup.bgCloudLoginForm('show');
506
+ sgBackup.bgCloudRegisterForm();
507
+ sgBackup.hideConnectionMessages();
508
+
509
+ jQuery('.bg-email-confirmation').removeClass('hide');
510
+ }
511
+ };
512
+ createCloudUserHandler.run();
513
+ };
514
+
515
+ sgBackup.createCloudUser = function() {
516
+ sgBackup.backupCloudConnectCallback = sgBackup.createCloudUserRequest;
517
+ sgBackup.validateForm();
518
  };
public/js/sgschedule.js CHANGED
@@ -210,4 +210,5 @@ sgBackup.initManualBackupTooltips = function(){
210
  jQuery('[for=cloud-gdrive]').tooltip();
211
  jQuery('[for=cloud-one-drive]').tooltip();
212
  jQuery('[for=cloud-amazon]').tooltip();
 
213
  }
210
  jQuery('[for=cloud-gdrive]').tooltip();
211
  jQuery('[for=cloud-one-drive]').tooltip();
212
  jQuery('[for=cloud-amazon]').tooltip();
213
+ jQuery('[for=cloud-backup-guard]').tooltip();
214
  }
public/schedule.php CHANGED
@@ -4,6 +4,7 @@ $id = '';
4
  $directories = SG_BACKUP_FILE_PATHS;
5
  $directories = explode(',', $directories);
6
  $dropbox = SGConfig::get('SG_DROPBOX_ACCESS_TOKEN');
 
7
 
8
  $intervalSelectElement = array(
9
  BG_SCHEDULE_INTERVAL_HOURLY => 'Hour',
@@ -16,6 +17,7 @@ $sgb = new SGBackup();
16
  $scheduleParams = $sgb->getScheduleParamsById(SG_SCHEDULER_DEFAULT_ID);
17
  $scheduleParams = backupGuardParseBackupOptions($scheduleParams);
18
  ?>
 
19
  <div id="sg-backup-page-content-schedule" class="sg-backup-page-content <?php echo $contentClassName; ?>">
20
  <div class="row sg-schedule-container">
21
  <div class="col-md-12">
@@ -103,6 +105,14 @@ $scheduleParams = backupGuardParseBackupOptions($scheduleParams);
103
  </label>
104
  <!--Storages-->
105
  <div class="col-md-12 sg-checkbox sg-custom-backup-cloud <?php echo count($scheduleParams['selectedClouds'])?'sg-open':'';?>">
 
 
 
 
 
 
 
 
106
  <?php if(SGBoot::isFeatureAvailable('FTP')): ?>
107
  <div class="checkbox">
108
  <label for="cloud-ftp" <?php echo empty($ftp)?'data-toggle="tooltip" data-placement="right" title="'._backupGuardT('FTP is not active.',true).'"':''?>>
4
  $directories = SG_BACKUP_FILE_PATHS;
5
  $directories = explode(',', $directories);
6
  $dropbox = SGConfig::get('SG_DROPBOX_ACCESS_TOKEN');
7
+ $backupGuard = SGConfig::get('SG_BACKUPGUARD_UPLOAD_ACCESS_TOKEN');
8
 
9
  $intervalSelectElement = array(
10
  BG_SCHEDULE_INTERVAL_HOURLY => 'Hour',
17
  $scheduleParams = $sgb->getScheduleParamsById(SG_SCHEDULER_DEFAULT_ID);
18
  $scheduleParams = backupGuardParseBackupOptions($scheduleParams);
19
  ?>
20
+
21
  <div id="sg-backup-page-content-schedule" class="sg-backup-page-content <?php echo $contentClassName; ?>">
22
  <div class="row sg-schedule-container">
23
  <div class="col-md-12">
105
  </label>
106
  <!--Storages-->
107
  <div class="col-md-12 sg-checkbox sg-custom-backup-cloud <?php echo count($scheduleParams['selectedClouds'])?'sg-open':'';?>">
108
+ <?php if(SGBoot::isFeatureAvailable('BACKUP_GUARD') && SG_SHOW_BACKUPGUARD_CLOUD): ?>
109
+ <div class="checkbox">
110
+ <label for="cloud-backup-guard" <?php echo empty($backupGuard)?'data-toggle="tooltip" data-placement="right" title="'._backupGuardT('BackupGuard is not active.',true).'"':''?>>
111
+ <input type="checkbox" name="backupStorages[]" id="cloud-backup-guard" value="<?php echo SG_STORAGE_BACKUP_GUARD ?>" <?php echo in_array(SG_STORAGE_BACKUP_GUARD, $scheduleParams['selectedClouds'])?'checked="checked"':''?> <?php echo empty($backupGuard)?'disabled="disabled"':''?>>
112
+ <?php echo 'BackupGuard' ?>
113
+ </label>
114
+ </div>
115
+ <?php endif; ?>
116
  <?php if(SGBoot::isFeatureAvailable('FTP')): ?>
117
  <div class="checkbox">
118
  <label for="cloud-ftp" <?php echo empty($ftp)?'data-toggle="tooltip" data-placement="right" title="'._backupGuardT('FTP is not active.',true).'"':''?>>