PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 1.6.15
JetBackup – Backup, Restore & Migrate v1.6.15
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 / include / functions.php
backup / public / include Last commit date
footer-new.php 3 years ago footer.php 3 years ago functions.php 3 years ago header-new.php 3 years ago header.php 3 years ago modal.php 10 years ago sidebar.php 3 years ago
functions.php
369 lines
1 <?php
2
3 function backupGuardShouldShowDiscountNotice()
4 {
5 if (SGConfig::get("SG_HIDE_DISCOUNT_NOTICE")) {
6 return false;
7 }
8
9 return true;
10 }
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));
19 $currentTime = strtotime($timeDate->format('Y-m-d H:i:s'));
20
21 $startDate = strtotime($startDate);
22 $finishDate = strtotime($endDate);
23
24 return ($currentTime > $startDate && $currentTime < $finishDate);
25 }
26
27 function _backupGuardT($key, $return = false)
28 {
29 if (SG_ENV_ADAPTER == SG_ENV_WORDPRESS) {
30 if ($return) {
31 return __($key, "backup-guard-pro");
32 } else {
33 _e($key, "backup-guard-pro");
34 }
35 } else {
36 if ($return) {
37 return $key;
38 } else {
39 echo $key;
40 }
41 }
42 }
43
44 function backupGuardIsAjax()
45 {
46 return (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
47 }
48
49 function selectElement($data, $attributes = array(), $firstOption = '', $selectedKey = '')
50 {
51 $attrString = '';
52 foreach ($attributes as $attributeKey => $attributeValue) {
53 $attrString .= " " . $attributeKey . '="' . $attributeValue . '"';
54 }
55 $select = '<select' . $attrString . '>';
56 if ($firstOption) {
57 $select .= '<option value="0">' . $firstOption . '</option>';
58 }
59 foreach ($data as $key => $val) {
60 $selected = $selectedKey == $key ? ' selected="selected"' : '';
61 $select .= '<option value="' . $key . '"' . $selected . '>' . $val . '</option>';
62 }
63 $select .= '</select>';
64
65 return $select;
66 }
67
68 function backupGuardParseBackupOptions($options)
69 {
70
71 $scheduleOptions = array(
72 'interval' => '',
73 'monthOfInterval' => '',
74 'dayOfInterval' => '',
75 'intervalHour' => '',
76 'isBackgroundMode' => false,
77 'isDatabaseSelected' => false,
78 'isFilesSelected' => false,
79 'isCustomBackup' => false,
80 'selectedDirectories' => array(),
81 'excludeDirectories' => array(),
82 'selectedClouds' => array(),
83 'label' => ''
84 );
85
86 if (isset($options['schedule_options'])) {
87 $scheduleExecutionOptions = json_decode($options['schedule_options'], true);
88
89 $scheduleOptions['interval'] = $scheduleExecutionOptions['interval'];
90 $scheduleOptions['monthOfInterval'] = $scheduleExecutionOptions['monthOfInterval'];
91 $scheduleOptions['dayOfInterval'] = $scheduleExecutionOptions['dayOfInterval'];
92 $scheduleOptions['intervalHour'] = $scheduleExecutionOptions['intervalHour'];
93 }
94
95 if (isset($options['backup_options'])) {
96 $backupOptions = json_decode($options['backup_options'], true);
97
98 $scheduleOptions['isBackgroundMode'] = $backupOptions['SG_BACKUP_IN_BACKGROUND_MODE'] ? true : false;
99 $scheduleOptions['isDatabaseSelected'] = $backupOptions['SG_ACTION_BACKUP_DATABASE_AVAILABLE'] ? true : false;
100 $scheduleOptions['isFilesSelected'] = $backupOptions['SG_ACTION_BACKUP_FILES_AVAILABLE'] ? true : false;
101 $backupType = $backupOptions['SG_BACKUP_TYPE'];
102
103 $scheduleOptions['isCustomBackup'] = $backupType == SG_BACKUP_TYPE_FULL ? false : true;
104
105 if ($scheduleOptions['isCustomBackup']) {
106 $scheduleOptions['selectedDirectories'] = explode(',', $backupOptions['SG_BACKUP_FILE_PATHS']);
107 if ($scheduleOptions['isFilesSelected']) {
108 $scheduleOptions['excludeDirectories'] = explode(',', $backupOptions['SG_BACKUP_FILE_PATHS_EXCLUDE']);
109 }
110 }
111
112 if (strlen($backupOptions['SG_BACKUP_UPLOAD_TO_STORAGES'])) {
113 $scheduleOptions['selectedClouds'] = explode(',', $backupOptions['SG_BACKUP_UPLOAD_TO_STORAGES']);
114 }
115 }
116
117 if (isset($options['label'])) {
118 $scheduleOptions['label'] = $options['label'];
119 }
120
121 return $scheduleOptions;
122 }
123
124 function backupGuardFilterStatusesByActionType($currentBackup, $currentOptions)
125 {
126 $filteredStatuses = array();
127 if ($currentBackup['type'] == SG_ACTION_TYPE_RESTORE) {
128 $filteredStatuses[] = SG_ACTION_TYPE_RESTORE . SG_ACTION_STATUS_IN_PROGRESS_FILES;
129 $filteredStatuses[] = SG_ACTION_TYPE_RESTORE . SG_ACTION_STATUS_IN_PROGRESS_DB;
130 } else {
131 $currentOptions = backupGuardActiveOptionToType($currentOptions);
132 if ($currentOptions['backupDatabase']) {
133 $filteredStatuses[] = $currentOptions['backupDatabase'];
134 }
135 if ($currentOptions['backupFiles']) {
136 $filteredStatuses[] = $currentOptions['backupFiles'];
137 }
138 if ($currentOptions['ftp']) {
139 $filteredStatuses[] = $currentOptions['ftp'];
140 }
141 if ($currentOptions['dropbox']) {
142 $filteredStatuses[] = $currentOptions['dropbox'];
143 }
144 if ($currentOptions['gdrive']) {
145 $filteredStatuses[] = $currentOptions['gdrive'];
146 }
147 if ($currentOptions['amazon']) {
148 $filteredStatuses[] = $currentOptions['amazon'];
149 }
150 if ($currentOptions['oneDrive']) {
151 $filteredStatuses[] = $currentOptions['oneDrive'];
152 }
153 if ($currentOptions['pCloud']) {
154 $filteredStatuses[] = $currentOptions['pCloud'];
155 }
156 if ($currentOptions['box']) {
157 $filteredStatuses[] = $currentOptions['box'];
158 }
159 if ($currentOptions['backupGuard']) {
160 $filteredStatuses[] = $currentOptions['backupGuard'];
161 }
162 }
163
164 return $filteredStatuses;
165 }
166
167 function backupGuardActiveOptionToType($activeOption)
168 {
169 $activeOptions = array();
170 $activeOption = json_decode($activeOption, true);
171 $activeOptions['backupDatabase'] = !empty($activeOption['SG_ACTION_BACKUP_DATABASE_AVAILABLE']) ? SG_ACTION_STATUS_IN_PROGRESS_DB : 0;
172 $activeOptions['backupFiles'] = !empty($activeOption['SG_ACTION_BACKUP_FILES_AVAILABLE']) ? SG_ACTION_STATUS_IN_PROGRESS_FILES : 0;
173
174 $storages = explode(',', @$activeOption['SG_BACKUP_UPLOAD_TO_STORAGES']);
175 $activeOptions['ftp'] = 0;
176 $activeOptions['dropbox'] = 0;
177 $activeOptions['gdrive'] = 0;
178 $activeOptions['amazon'] = 0;
179 $activeOptions['oneDrive'] = 0;
180 $activeOptions['pCloud'] = 0;
181 $activeOptions['box'] = 0;
182 $activeOptions['backupGuard'] = 0;
183 foreach ($storages as $storage) {
184 switch ($storage) {
185 case SG_STORAGE_FTP:
186 $activeOptions['ftp'] = SG_ACTION_TYPE_UPLOAD . SG_STORAGE_FTP;
187 break;
188 case SG_STORAGE_DROPBOX:
189 $activeOptions['dropbox'] = SG_ACTION_TYPE_UPLOAD . SG_STORAGE_DROPBOX;
190 break;
191 case SG_STORAGE_GOOGLE_DRIVE:
192 $activeOptions['gdrive'] = SG_ACTION_TYPE_UPLOAD . SG_STORAGE_GOOGLE_DRIVE;
193 break;
194 case SG_STORAGE_AMAZON:
195 $activeOptions['amazon'] = SG_ACTION_TYPE_UPLOAD . SG_STORAGE_AMAZON;
196 break;
197 case SG_STORAGE_ONE_DRIVE:
198 $activeOptions['oneDrive'] = SG_ACTION_TYPE_UPLOAD . SG_STORAGE_ONE_DRIVE;
199 break;
200 case SG_STORAGE_P_CLOUD:
201 $activeOptions['pCloud'] = SG_ACTION_TYPE_UPLOAD . SG_STORAGE_P_CLOUD;
202 break;
203 case SG_STORAGE_BOX:
204 $activeOptions['box'] = SG_ACTION_TYPE_UPLOAD . SG_STORAGE_BOX;
205 break;
206 case SG_STORAGE_BACKUP_GUARD:
207 $activeOptions['backupGuard'] = SG_ACTION_TYPE_UPLOAD . SG_STORAGE_BACKUP_GUARD;
208 break;
209 }
210 }
211
212 return $activeOptions;
213 }
214
215 function backupGuardConvertToBytes($from)
216 {
217 $number = substr($from, 0, -2);
218 switch (strtoupper(substr($from, -2))) {
219 case "KB":
220 return $number * 1024;
221 case "MB":
222 return $number * pow(1024, 2);
223 case "GB":
224 return $number * pow(1024, 3);
225 case "TB":
226 return $number * pow(1024, 4);
227 case "PB":
228 return $number * pow(1024, 5);
229 default:
230 return $from;
231 }
232 }
233
234 function backupGuardGetRunningActions()
235 {
236 $runningActions = SGBackup::getRunningActions();
237 $isAnyActiveActions = count($runningActions);
238 if ($isAnyActiveActions) {
239 return $runningActions;
240 }
241
242 return false;
243 }
244
245 function backupGuardShouldUpdate()
246 {
247 $currentVersion = SG_BACKUP_GUARD_VERSION;
248 $oldVersion = SGConfig::get('SG_BACKUP_GUARD_VERSION', true);
249
250 if (!$oldVersion) {
251 return true;
252 }
253
254 if ($currentVersion !== $oldVersion) {
255 SGConfig::set('SG_BACKUP_GUARD_VERSION', $currentVersion, true);
256 SGConfig::set('SG_HIDE_DISCOUNT_NOTICE', '0', true);
257 SGBoot::didUpdatePluginVersion();
258
259 return SG_FORCE_DB_TABLES_RESET;
260 }
261
262 if (!checkAllMissedTables()) {
263 return true;
264 }
265
266 return false;
267 }
268
269 function backupGuardGetDatabaseEngine()
270 {
271 global $wpdb;
272 $dbName = $wpdb->dbname;
273 $engine = 'InnoDB';
274 $engineCheckSql = "SELECT ENGINE FROM information_schema.TABLES WHERE TABLE_SCHEMA = '$dbName'";
275 $result = $wpdb->get_results($engineCheckSql, ARRAY_A);
276 if (!empty($result)) {
277 $engineCheckSql = "SHOW TABLE STATUS WHERE Name = '" . $wpdb->prefix . "users' AND Engine = 'MyISAM'";
278 $result = $wpdb->get_results($engineCheckSql, ARRAY_A);
279 if (isset($result[0]['Engine']) && $result[0]['Engine'] == 'MyISAM') {
280 $engine = 'MyISAM';
281 }
282 }
283
284 return $engine;
285 }
286
287 function backupGuardShouldActivateExtension($extension)
288 {
289 $extensionAdapter = SGExtension::getInstance();
290
291 if (!$extensionAdapter->isExtensionAvailable($extension) || SGConfig::get($extension) || !$extensionAdapter->isExtensionAlreadyInPluginsFolder($extension) || $extensionAdapter->isExtensionActive($extension)) {
292 return false;
293 }
294
295 return true;
296 }
297
298 function backupGuardShouldInstallExtension($extension)
299 {
300 $extensionAdapter = SGExtension::getInstance();
301
302 if (!$extensionAdapter->isExtensionAvailable($extension) || SGConfig::get($extension) || $extensionAdapter->isExtensionAlreadyInPluginsFolder($extension) || $extensionAdapter->isExtensionActive($extension)) {
303 return false;
304 }
305
306 return true;
307 }
308
309 function backupGuardLoggedMessage()
310 {
311 $pluginCapabilities = backupGuardGetCapabilities();
312 if ($pluginCapabilities == BACKUP_GUARD_CAPABILITIES_FREE) {
313 return '';
314 }
315
316 $user = SGConfig::get('SG_LOGGED_USER');
317 if (!$user) {
318 return '';
319 }
320
321 $user = unserialize($user);
322 if (!$user || empty($user['firstname'])) {
323 return '';
324 }
325
326 $html = '<span class="bg-logged-msg-container">';
327 $html .= 'Package: ' . backupGuardGetProductName() . ' | Version: ' . SG_BACKUP_GUARD_VERSION;
328 $html .= ' | Welcome, <b>' . $user['firstname'] . '</b>! ';
329 $html .= '(<a href="javascript:void(0)" onclick="sgBackup.logout()">Log Out</a>)</span>';
330
331 return $html;
332 }
333
334 function modifyCronJobsByTimezone()
335 {
336 $allSchedules = SGBackupSchedule::getAllSchedules(false);
337
338 foreach ($allSchedules as $schedule) {
339 $id = $schedule['id'];
340 $cronTab = json_decode($schedule['schedule_options'], true);
341 $cronOptions = json_decode($schedule['backup_options'], true);
342 $cronLabel = $schedule['label'];
343
344 SGBackupSchedule::create($cronTab, $cronOptions, $cronLabel);
345 SGBackupSchedule::remove($id);
346 }
347 }
348
349 if (!function_exists('dd')) {
350 function dd()
351 {
352 $args = func_get_args();
353
354 foreach ($args as $arg) {
355 ob_start();
356 print_r($arg);
357 $output = ob_get_clean();
358
359 // Add formatting
360 $output = preg_replace("/\]\=\>\n(\s+)/m", "] => ", $output);
361 $output = '<pre style="background: #FFFEEF; color: #000; border: 1px dashed #888; padding: 10px; margin: 10px 0; text-align: left;">' . $output . '</pre>';
362
363 echo $output;
364 }
365
366 exit;
367 }
368 }
369