PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 2.0.3
JetBackup – Backup, Restore & Migrate v2.0.3
3.1.22.3 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.8.1 1.4.9 1.5.0 1.5.1 1.5.1.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.10 1.6.11 1.6.12 1.6.13 1.6.15 1.6.5.1 1.6.8.8 1.6.9 1.6.9.1 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7.5 2.0.8.7 2.0.9.11 2.0.9.14 2.0.9.15 2.0.9.6 2.0.9.7 2.0.9.9 3.1.10.7 3.1.11.1 3.1.12.3 3.1.13.4 3.1.14.17 3.1.15.4 3.1.16.1 3.1.17.5 3.1.18.10 3.1.18.8 3.1.18.9 3.1.19.8 3.1.20.3 3.1.21.3 3.1.7.9 3.1.9.2 trunk 1.1.90 1.1.91 1.2.0 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2
backup / public / ajax / schedule.php
backup / public / ajax Last commit date
cancelBackup.php 3 years ago cancelDownload.php 3 years ago checkBackupCreation.php 3 years ago checkFreeMigration.php 3 years ago checkPHPVersionCompatibility.php 3 years ago checkRestoreCreation.php 3 years ago chooseProfile.php 3 years ago cloudDropbox.php 3 years ago curlChecker.php 3 years ago deleteBackup.php 3 years ago downloadBackup.php 3 years ago getAction.php 3 years ago getBackupContent.php 3 years ago getRunningActions.php 3 years ago hideNotice.php 3 years ago importBackup.php 3 years ago isBgUserExists.php 3 years ago isFeatureAvailable.php 3 years ago manualBackup.php 3 years ago modalImport.php 3 years ago modalManualBackup.php 3 years ago modalManualRestore.php 3 years ago modalPrivacy.php 3 years ago modalReview.php 3 years ago modalTerms.php 3 years ago resetStatus.php 3 years ago restore.php 3 years ago reviewBannerActions.php 3 years ago schedule.php 3 years ago setReviewPopupState.php 3 years ago settings.php 3 years ago
schedule.php
140 lines
1 <?php
2
3 require_once dirname(__FILE__) . '/../boot.php';
4 require_once SG_BACKUP_PATH . 'SGBackupSchedule.php';
5
6 $error = array();
7 $success = array('success' => 1);
8
9 if (backupGuardIsAjax() && count($_POST)) {
10 $_POST = backupGuardRemoveSlashes($_POST);
11
12 if (isset($_POST['remove'])) {
13 if (isset($_POST['id'])) {
14 SGBackupSchedule::remove((int)$_POST['id']);
15 } else {
16 SGBackupSchedule::remove();
17 }
18
19 die(json_encode($success));
20 }
21
22 //Check if cron available
23 if (!SGSchedule::isCronAvailable()) {
24 array_push($error, _backupGuardT('Cron is not available on your hosting.', true));
25 die(json_encode($error));
26 }
27
28 $options = $_POST;
29 $cronOptions = array(
30 'SG_BACKUP_IN_BACKGROUND_MODE' => 0,
31 'SG_BACKUP_UPLOAD_TO_STORAGES' => '',
32 'SG_ACTION_BACKUP_DATABASE_AVAILABLE' => 0,
33 'SG_ACTION_BACKUP_FILES_AVAILABLE' => '',
34 'SG_BACKUP_FILE_PATHS_EXCLUDE' => '',
35 'SG_BACKUP_FILE_PATHS' => '',
36 );
37
38 $cronLabel = '';
39 //Check if schedule name is not empaty
40 if (isset($options['sg-schedule-label'])) {
41 $label = trim($options['sg-schedule-label']);
42 $label = backupGuardSanitizeTextField($label);
43 if (empty($label)) {
44 array_push($error, _backupGuardT('Label field is required.', true));
45 die(json_encode($error));
46 } else {
47 $cronLabel = $label;
48 }
49 } else {
50 array_push($error, _backupGuardT('Label field is required.', true));
51 die(json_encode($error));
52 }
53
54 //If background mode
55 $isBackgroundMode = isset($options['backgroundMode']) ? 1 : 0;
56 $cronOptions['SG_BACKUP_IN_BACKGROUND_MODE'] = $isBackgroundMode;
57
58 //If cloud backup
59 if (isset($options['backupCloud']) && count($options['backupStorages'])) {
60 $clouds = backupGuardSanitizeTextField($options['backupStorages']);
61 $cronOptions['SG_BACKUP_UPLOAD_TO_STORAGES'] = implode(',', $clouds);
62 }
63
64 $cronOptions['SG_BACKUP_TYPE'] = $options['backupType'];
65 if ($options['backupType'] == SG_BACKUP_TYPE_FULL) {
66 $cronOptions['SG_BACKUP_FILE_PATHS_EXCLUDE'] = SG_BACKUP_FILE_PATHS_EXCLUDE;
67 $cronOptions['SG_BACKUP_FILE_PATHS'] = 'wp-content';
68 $cronOptions['SG_ACTION_BACKUP_DATABASE_AVAILABLE'] = 1;
69 $cronOptions['SG_ACTION_BACKUP_FILES_AVAILABLE'] = 1;
70 } else if ($options['backupType'] == SG_BACKUP_TYPE_CUSTOM) {
71 //If database backup
72 $isDatabaseBackup = isset($options['backupDatabase']) ? 1 : 0;
73 $cronOptions['SG_ACTION_BACKUP_DATABASE_AVAILABLE'] = $isDatabaseBackup;
74
75 //If db backup
76 if (!empty($options['backupDBType'])) {
77 $tablesToBackup = implode(',', $options['table']);
78 $backupOptions['SG_BACKUP_TABLES_TO_BACKUP'] = $tablesToBackup;
79 }
80 //If files backup
81 if (isset($options['backupFiles']) && count($options['directory'])) {
82 $backupFiles = explode(',', SG_BACKUP_FILE_PATHS);
83 $options['directory'] = backupGuardSanitizeTextField($options['directory']);
84 $filesToExclude = @array_diff($backupFiles, $options['directory']);
85
86 if (in_array('wp-content', $options['directory'])) {
87 $options['directory'] = array('wp-content');
88 } else {
89 $filesToExclude = array_diff($filesToExclude, array('wp-content'));
90 }
91
92 $filesToExclude = implode(',', $filesToExclude);
93 if (strlen($filesToExclude)) {
94 $filesToExclude = ',' . $filesToExclude;
95 }
96
97 $cronOptions['SG_BACKUP_FILE_PATHS_EXCLUDE'] = SG_BACKUP_FILE_PATHS_EXCLUDE . $filesToExclude;
98 $cronOptions['SG_ACTION_BACKUP_FILES_AVAILABLE'] = 1;
99 $cronOptions['SG_BACKUP_FILE_PATHS'] = implode(',', $options['directory']);
100 } else {
101 $cronOptions['SG_ACTION_BACKUP_FILES_AVAILABLE'] = 0;
102 $cronOptions['SG_BACKUP_FILE_PATHS'] = 0;
103 }
104 } else {
105 array_push($error, _backupGuardT('Invalid backup type', true));
106 die(json_encode($error));
107 }
108
109 $scheduleIntervalDay = '';
110 $scheduleIntervalMonth = '';
111 if ($options['scheduleInterval'] == BG_SCHEDULE_INTERVAL_WEEKLY && isset($options['sg-schedule-day-of-week'])) {
112 $scheduleIntervalDay = (int)$options['sg-schedule-day-of-week'];
113 } else if ($options['scheduleInterval'] == BG_SCHEDULE_INTERVAL_MONTHLY && isset($options['sg-schedule-day-of-month'])) {
114 $scheduleIntervalDay = (int)$options['sg-schedule-day-of-month'];
115 } else if ($options['scheduleInterval'] == BG_SCHEDULE_INTERVAL_YEARLY && isset($options['sg-schedule-day-of-month']) && isset($options['sg-schedule-month-of-year'])) {
116 $scheduleIntervalDay = (int)$options['sg-schedule-day-of-month'];
117 $scheduleIntervalMonth = (int)$options['sg-schedule-month-of-year'];
118 }
119
120 try {
121 $cronTab = array(
122 'monthOfInterval' => $scheduleIntervalMonth,
123 'dayOfInterval' => $scheduleIntervalDay,
124 'intervalHour' => isset($options['scheduleHour']) ? $options['scheduleHour'] : '',
125 'interval' => $options['scheduleInterval']
126 );
127
128 if (isset($options['sg-schedule-id'])) {
129 SGBackupSchedule::remove($options['sg-schedule-id']);
130 }
131
132 SGBackupSchedule::create($cronTab, $cronOptions, $cronLabel);
133
134 die(json_encode($success));
135 } catch (SGException $exception) {
136 array_push($error, $exception->getMessage());
137 die(json_encode($error));
138 }
139 }
140