Version Description
- Admin Panel "Manual Backup" JS error fix on WordPress 5.5 version.
Download this release
Release Info
Developer | BackupGuard |
Plugin | WordPress Backup and Migrate Plugin – Backup Guard |
Version | 1.4.3 |
Comparing to | |
See all releases |
Code changes from version 1.4.2 to 1.4.3
- README.txt +4 -1
- backup.php +2 -2
- com/core/functions.php +562 -562
- public/ajax/modalManualBackup.php +123 -123
- public/css/bgstyle.less.css +1 -1
- public/js/sgbackup.js +13 -5
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
|
9 |
-
Stable tag: 1.4.
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
@@ -167,6 +167,9 @@ When you are facing an issue of any kind with any of our products, the first thi
|
|
167 |
6. Site backup customization
|
168 |
|
169 |
== Changelog ==
|
|
|
|
|
|
|
170 |
= 1.4.2 =
|
171 |
* Design changes in the Admin Panel of the plugin
|
172 |
* Download via PHP fix
|
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
|
9 |
+
Stable tag: 1.4.3
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
167 |
6. Site backup customization
|
168 |
|
169 |
== Changelog ==
|
170 |
+
= 1.4.3 =
|
171 |
+
* Admin Panel "Manual Backup" JS error fix on WordPress 5.5 version.
|
172 |
+
|
173 |
= 1.4.2 =
|
174 |
* Design changes in the Admin Panel of the plugin
|
175 |
* Download via PHP fix
|
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 |
* 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.
|
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.3
|
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.3');
|
20 |
}
|
21 |
|
22 |
if (!defined('SG_BACKUP_GUARD_MAIN_FILE')) {
|
com/core/functions.php
CHANGED
@@ -2,751 +2,751 @@
|
|
2 |
|
3 |
function backupGuardGetCapabilities()
|
4 |
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
}
|
19 |
|
20 |
function convertToReadableSize($size)
|
21 |
{
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
}
|
32 |
|
33 |
function backupGuardgetSealPopup()
|
34 |
{
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
}
|
60 |
|
61 |
function backupGuardConvertDateTimezone($date, $dateFormat = "Y-m-d H:i:s", $timezone = "UTC")
|
62 |
{
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
|
72 |
-
|
73 |
-
|
74 |
|
75 |
-
|
76 |
}
|
77 |
|
78 |
function backupGuardRemoveSlashes($value)
|
79 |
{
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
|
88 |
-
|
89 |
-
|
90 |
}
|
91 |
|
92 |
function backupGuardSanitizeTextField($value)
|
93 |
{
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
|
106 |
-
|
107 |
-
|
108 |
}
|
109 |
|
110 |
function backupGuardIsMultisite()
|
111 |
{
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
}
|
119 |
|
120 |
function backupGuardGetBanner($env, $type="plugin", $userType = null)
|
121 |
{
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
}
|
126 |
|
127 |
function backupGuardGetFilenameOptions($options)
|
128 |
{
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
|
167 |
-
|
168 |
}
|
169 |
|
170 |
function backupGuardGenerateToken()
|
171 |
{
|
172 |
-
|
173 |
}
|
174 |
|
175 |
// Parse a URL and return its components
|
176 |
function backupGuardParseUrl($url)
|
177 |
{
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
|
186 |
-
|
187 |
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
|
193 |
-
|
194 |
}
|
195 |
|
196 |
function backupGuardIsReloadEnabled()
|
197 |
{
|
198 |
-
|
199 |
-
|
200 |
}
|
201 |
|
202 |
function backupGuardGetBackupOptions($options)
|
203 |
{
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
}
|
278 |
|
279 |
function backupGuardLoadStateData()
|
280 |
{
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
|
288 |
-
|
289 |
}
|
290 |
|
291 |
function backupGuardValidateApiCall($token)
|
292 |
{
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
|
297 |
-
|
298 |
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
|
311 |
-
|
312 |
}
|
313 |
|
314 |
function backupGuardScanBackupsDirectory($path)
|
315 |
{
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
}
|
331 |
|
332 |
function backupGuardSymlinksCleanup($dir)
|
333 |
{
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
}
|
355 |
|
356 |
function backupGuardRealFilesize($filename)
|
357 |
{
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
}
|
389 |
|
390 |
function backupGuardFormattedDuration($startTs, $endTs)
|
391 |
{
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
|
406 |
-
|
407 |
}
|
408 |
|
409 |
function backupGuardDeleteDirectory($dirName)
|
410 |
{
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
}
|
440 |
|
441 |
function backupGuardDownloadFile($file, $type = 'application/octet-stream')
|
442 |
{
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
|
455 |
-
|
456 |
}
|
457 |
|
458 |
function backupGuardDownloadViaPhp($backupName, $fileName)
|
459 |
{
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
}
|
479 |
|
480 |
function backupGuardMakeSymlinkFolder($filename)
|
481 |
{
|
482 |
-
|
483 |
|
484 |
-
|
485 |
-
|
486 |
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
|
512 |
-
|
513 |
-
|
514 |
|
515 |
-
|
516 |
}
|
517 |
|
518 |
function backupGuardDownloadFileSymlink($safedir, $filename)
|
519 |
{
|
520 |
-
|
521 |
-
|
522 |
|
523 |
-
|
524 |
-
|
525 |
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
}
|
539 |
|
540 |
function backupGuardGetCurrentUrlScheme()
|
541 |
{
|
542 |
-
|
543 |
}
|
544 |
|
545 |
function backupGuardValidateLicense()
|
546 |
{
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
|
558 |
-
|
559 |
|
560 |
-
|
561 |
|
562 |
-
|
563 |
-
|
564 |
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
|
578 |
-
|
579 |
}
|
580 |
|
581 |
//returns true if string $haystack ends with string $needle or $needle is an empty string
|
582 |
function backupGuardStringEndsWith($haystack, $needle)
|
583 |
{
|
584 |
-
|
585 |
|
586 |
-
|
587 |
-
|
588 |
}
|
589 |
//returns true if string $haystack starts with string $needle
|
590 |
function backupGuardStringStartsWith($haystack, $needle)
|
591 |
{
|
592 |
-
|
593 |
-
|
594 |
}
|
595 |
|
596 |
function backupGuardGetDbTables(){
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
}
|
623 |
|
624 |
function backupGuardGetBackupTablesHTML($defaultChecked = false){
|
625 |
-
|
626 |
-
|
627 |
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
<span class="sg-checkbox-label-text"><?php _backupGuardT('Backup database'); ?></span>
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
<span class="sg-checkbox-label-text"><?php echo basename($table['name']);?></span>
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
|
664 |
-
|
665 |
|
666 |
-
|
667 |
|
668 |
}
|
669 |
|
670 |
function backupGuardIsAccountGold()
|
671 |
{
|
672 |
-
|
673 |
}
|
674 |
|
675 |
function backupGuardGetProductName()
|
676 |
{
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
}
|
702 |
|
703 |
function backupGuardGetFileSelectiveRestore()
|
704 |
{
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
}
|
725 |
|
726 |
function checkAllMissedTables()
|
727 |
{
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
FROM information_schema.TABLES
|
736 |
WHERE (TABLE_SCHEMA = '".DB_NAME."') AND (TABLE_NAME = '$table')"
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
}
|
746 |
|
747 |
function backupGuardIncludeFile($filePath)
|
748 |
{
|
749 |
if (file_exists($filePath)) {
|
750 |
-
|
751 |
}
|
752 |
}
|
2 |
|
3 |
function backupGuardGetCapabilities()
|
4 |
{
|
5 |
+
switch (SG_PRODUCT_IDENTIFIER) {
|
6 |
+
case 'backup-guard-en':
|
7 |
+
case 'backup-guard-wp-platinum':
|
8 |
+
case 'backup-guard-en-regular':
|
9 |
+
case 'backup-guard-en-extended':
|
10 |
+
return BACKUP_GUARD_CAPABILITIES_PLATINUM;
|
11 |
+
case 'backup-guard-wp-gold':
|
12 |
+
return BACKUP_GUARD_CAPABILITIES_GOLD;
|
13 |
+
case 'backup-guard-wp-silver':
|
14 |
+
return BACKUP_GUARD_CAPABILITIES_SILVER;
|
15 |
+
case 'backup-guard-wp-free':
|
16 |
+
return BACKUP_GUARD_CAPABILITIES_FREE;
|
17 |
+
}
|
18 |
}
|
19 |
|
20 |
function convertToReadableSize($size)
|
21 |
{
|
22 |
+
if (!$size) {
|
23 |
+
return '';
|
24 |
+
}
|
25 |
|
26 |
+
$base = log($size) / log(1000);
|
27 |
+
$suffix = array("", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB");
|
28 |
+
$f_base = floor($base);
|
29 |
|
30 |
+
return round(pow(1000, $base - floor($base)), 1) . $suffix[$f_base];
|
31 |
}
|
32 |
|
33 |
function backupGuardgetSealPopup()
|
34 |
{
|
35 |
+
$currentDate = time();
|
36 |
+
$sgShouldShowPopup = SGConfig::get('SG_SHOULD_SHOW_POPUP') == null ? true : SGConfig::get('SG_SHOULD_SHOW_POPUP');
|
37 |
+
$sgPluginInstallUpdateDate = SGConfig::get('SG_PLUGIN_INSTALL_UPDATE_DATE') == null ? time() : SGConfig::get('SG_PLUGIN_INSTALL_UPDATE_DATE');
|
38 |
+
|
39 |
+
// check ig plugin is active for free days show poup
|
40 |
+
if (($currentDate - $sgPluginInstallUpdateDate >= SG_PLUGIN_ACTIVE_INTERVAL) && $sgShouldShowPopup) {
|
41 |
+
?>
|
42 |
+
<script>
|
43 |
+
window.SGPMPopupLoader=window.SGPMPopupLoader||{ids:[],popups:{},call:function(w,d,s,l,id){
|
44 |
+
w['sgp']=w['sgp']||function(){(w['sgp'].q=w['sgp'].q||[]).push(arguments[0]);};
|
45 |
+
var sg1=d.createElement(s),sg0=d.getElementsByTagName(s)[0];
|
46 |
+
if(SGPMPopupLoader && SGPMPopupLoader.ids && SGPMPopupLoader.ids.length > 0){SGPMPopupLoader.ids.push(id); return;}
|
47 |
+
SGPMPopupLoader.ids.push(id);
|
48 |
+
sg1.onload = function(){SGPMPopup.openSGPMPopup();}; sg1.async=true; sg1.src=l;
|
49 |
+
sg0.parentNode.insertBefore(sg1,sg0);
|
50 |
+
return {};
|
51 |
+
}};
|
52 |
+
SGPMPopupLoader.call(window,document,'script','https://popupmaker.com/assets/lib/SGPMPopup.min.js','7c685e17');
|
53 |
+
</script>
|
54 |
+
<?php
|
55 |
+
SGConfig::set('SG_SHOULD_SHOW_POPUP', 0);
|
56 |
+
}
|
57 |
+
|
58 |
+
return;
|
59 |
}
|
60 |
|
61 |
function backupGuardConvertDateTimezone($date, $dateFormat = "Y-m-d H:i:s", $timezone = "UTC")
|
62 |
{
|
63 |
+
if (in_array($timezone, timezone_identifiers_list())) {
|
64 |
+
$date = date_create($date);
|
65 |
+
$timezone = timezone_open($timezone);
|
66 |
+
date_timezone_set($date, $timezone);
|
67 |
|
68 |
+
if (!$dateFormat) {
|
69 |
+
$dateFormat = "Y-m-d H:i:s";
|
70 |
+
}
|
71 |
|
72 |
+
return date_format($date, $dateFormat);
|
73 |
+
}
|
74 |
|
75 |
+
return $date;
|
76 |
}
|
77 |
|
78 |
function backupGuardRemoveSlashes($value)
|
79 |
{
|
80 |
+
if (SG_ENV_ADAPTER == SG_ENV_WORDPRESS) {
|
81 |
+
return wp_unslash($value);
|
82 |
+
}
|
83 |
+
else {
|
84 |
+
if (is_array($value)) {
|
85 |
+
return array_map('stripslashes', $value);
|
86 |
+
}
|
87 |
|
88 |
+
return stripslashes($value);
|
89 |
+
}
|
90 |
}
|
91 |
|
92 |
function backupGuardSanitizeTextField($value)
|
93 |
{
|
94 |
+
if (SG_ENV_ADAPTER == SG_ENV_WORDPRESS) {
|
95 |
+
if (is_array($value)) {
|
96 |
+
return array_map('sanitize_text_field', $value);
|
97 |
+
}
|
98 |
|
99 |
+
return sanitize_text_field($value);
|
100 |
+
}
|
101 |
+
else {
|
102 |
+
if (is_array($value)) {
|
103 |
+
return array_map('strip_tags', $value);
|
104 |
+
}
|
105 |
|
106 |
+
return strip_tags($value);
|
107 |
+
}
|
108 |
}
|
109 |
|
110 |
function backupGuardIsMultisite()
|
111 |
{
|
112 |
+
if (SG_ENV_ADAPTER == SG_ENV_WORDPRESS) {
|
113 |
+
return defined('BG_IS_MULTISITE')?BG_IS_MULTISITE:is_multisite();
|
114 |
+
}
|
115 |
+
else {
|
116 |
+
return false;
|
117 |
+
}
|
118 |
}
|
119 |
|
120 |
function backupGuardGetBanner($env, $type="plugin", $userType = null)
|
121 |
{
|
122 |
+
require_once(SG_LIB_PATH.'BackupGuard/Client.php');
|
123 |
+
$client = new BackupGuard\Client();
|
124 |
+
return $client->getBanner(strtolower($env), $type, $userType);
|
125 |
}
|
126 |
|
127 |
function backupGuardGetFilenameOptions($options)
|
128 |
{
|
129 |
+
$selectedPaths = explode(',', $options['SG_BACKUP_FILE_PATHS']);
|
130 |
+
$pathsToExclude = explode(',', $options['SG_BACKUP_FILE_PATHS_EXCLUDE']);
|
131 |
+
|
132 |
+
$opt = '';
|
133 |
+
|
134 |
+
if (SG_ENV_ADAPTER == SG_ENV_WORDPRESS) {
|
135 |
+
$opt .= 'opt(';
|
136 |
+
|
137 |
+
if ($options['SG_BACKUP_TYPE'] == SG_BACKUP_TYPE_CUSTOM) {
|
138 |
+
if ($options['SG_ACTION_BACKUP_DATABASE_AVAILABLE']) {
|
139 |
+
$opt .= 'db_';
|
140 |
+
}
|
141 |
+
|
142 |
+
if ($options['SG_ACTION_BACKUP_FILES_AVAILABLE']) {
|
143 |
+
if (in_array('wp-content', $selectedPaths)) {
|
144 |
+
$opt .= 'wpc_';
|
145 |
+
}
|
146 |
+
if (!in_array('wp-content/plugins', $pathsToExclude)) {
|
147 |
+
$opt .= 'plg_';
|
148 |
+
}
|
149 |
+
if (!in_array('wp-content/themes', $pathsToExclude)) {
|
150 |
+
$opt .= 'thm_';
|
151 |
+
}
|
152 |
+
if (!in_array('wp-content/uploads', $pathsToExclude)) {
|
153 |
+
$opt .= 'upl_';
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
|
158 |
+
}
|
159 |
+
else {
|
160 |
+
$opt .= 'full';
|
161 |
+
}
|
162 |
+
|
163 |
+
$opt = trim($opt, "_");
|
164 |
+
$opt .= ')_';
|
165 |
+
}
|
166 |
|
167 |
+
return $opt;
|
168 |
}
|
169 |
|
170 |
function backupGuardGenerateToken()
|
171 |
{
|
172 |
+
return md5(time());
|
173 |
}
|
174 |
|
175 |
// Parse a URL and return its components
|
176 |
function backupGuardParseUrl($url)
|
177 |
{
|
178 |
+
$urlComponents = parse_url($url);
|
179 |
+
$domain = $urlComponents['host'];
|
180 |
+
$port = '';
|
181 |
|
182 |
+
if (isset($urlComponents['port']) && strlen($urlComponents['port'])) {
|
183 |
+
$port = ":".$urlComponents['port'];
|
184 |
+
}
|
185 |
|
186 |
+
$domain = preg_replace("/(www|\dww|w\dw|ww\d)\./", "", $domain);
|
187 |
|
188 |
+
$path = "";
|
189 |
+
if (isset($urlComponents['path'])) {
|
190 |
+
$path = $urlComponents['path'];
|
191 |
+
}
|
192 |
|
193 |
+
return $domain.$port.$path;
|
194 |
}
|
195 |
|
196 |
function backupGuardIsReloadEnabled()
|
197 |
{
|
198 |
+
// Check if reloads option is turned on
|
199 |
+
return SGConfig::get('SG_BACKUP_WITH_RELOADINGS')?true:false;
|
200 |
}
|
201 |
|
202 |
function backupGuardGetBackupOptions($options)
|
203 |
{
|
204 |
+
$backupOptions = array(
|
205 |
+
'SG_BACKUP_UPLOAD_TO_STORAGES' => '',
|
206 |
+
'SG_BACKUP_FILE_PATHS_EXCLUDE' => '',
|
207 |
+
'SG_BACKUP_FILE_PATHS' => ''
|
208 |
+
);
|
209 |
+
|
210 |
+
if (isset($options['sg-custom-backup-name']) && $options['sg-custom-backup-name']) {
|
211 |
+
SGConfig::set("SG_CUSTOM_BACKUP_NAME", $options['sg-custom-backup-name']);
|
212 |
+
}
|
213 |
+
else {
|
214 |
+
SGConfig::set("SG_CUSTOM_BACKUP_NAME", '');
|
215 |
+
}
|
216 |
+
|
217 |
+
//If background mode
|
218 |
+
$isBackgroundMode = !empty($options['backgroundMode']) ? 1 : 0;
|
219 |
+
|
220 |
+
if ($isBackgroundMode) {
|
221 |
+
$backupOptions['SG_BACKUP_IN_BACKGROUND_MODE'] = $isBackgroundMode;
|
222 |
+
}
|
223 |
+
|
224 |
+
//If cloud backup
|
225 |
+
if (!empty($options['backupCloud']) && count($options['backupStorages'])) {
|
226 |
+
$clouds = $options['backupStorages'];
|
227 |
+
$backupOptions['SG_BACKUP_UPLOAD_TO_STORAGES'] = implode(',', $clouds);
|
228 |
+
}
|
229 |
+
|
230 |
+
$backupOptions['SG_BACKUP_TYPE'] = $options['backupType'];
|
231 |
+
|
232 |
+
if ($options['backupType'] == SG_BACKUP_TYPE_FULL) {
|
233 |
+
$backupOptions['SG_ACTION_BACKUP_DATABASE_AVAILABLE']= 1;
|
234 |
+
$backupOptions['SG_ACTION_BACKUP_FILES_AVAILABLE'] = 1;
|
235 |
+
$backupOptions['SG_BACKUP_FILE_PATHS_EXCLUDE'] = SG_BACKUP_FILE_PATHS_EXCLUDE;
|
236 |
+
$backupOptions['SG_BACKUP_FILE_PATHS'] = 'wp-content';
|
237 |
+
}
|
238 |
+
else if ($options['backupType'] == SG_BACKUP_TYPE_CUSTOM) {
|
239 |
+
//If database backup
|
240 |
+
$isDatabaseBackup = !empty($options['backupDatabase']) ? 1 : 0;
|
241 |
+
$backupOptions['SG_ACTION_BACKUP_DATABASE_AVAILABLE'] = $isDatabaseBackup;
|
242 |
+
|
243 |
+
//If db backup
|
244 |
+
if($options['backupDBType']){
|
245 |
+
$tablesToBackup = implode(',', $options['table']);
|
246 |
+
$backupOptions['SG_BACKUP_TABLES_TO_BACKUP'] = $tablesToBackup;
|
247 |
+
}
|
248 |
+
|
249 |
+
//If files backup
|
250 |
+
if (!empty($options['backupFiles']) && count($options['directory'])) {
|
251 |
+
$backupFiles = explode(',', SG_BACKUP_FILE_PATHS);
|
252 |
+
$filesToExclude = @array_diff($backupFiles, $options['directory']);
|
253 |
+
|
254 |
+
if (in_array('wp-content', $options['directory'])) {
|
255 |
+
$options['directory'] = array('wp-content');
|
256 |
+
}
|
257 |
+
else {
|
258 |
+
$filesToExclude = array_diff($filesToExclude, array('wp-content'));
|
259 |
+
}
|
260 |
+
|
261 |
+
$filesToExclude = implode(',', $filesToExclude);
|
262 |
+
if (strlen($filesToExclude)) {
|
263 |
+
$filesToExclude = ','.$filesToExclude;
|
264 |
+
}
|
265 |
+
|
266 |
+
$backupOptions['SG_BACKUP_FILE_PATHS_EXCLUDE'] = SG_BACKUP_FILE_PATHS_EXCLUDE.$filesToExclude;
|
267 |
+
$options['directory'] = backupGuardSanitizeTextField($options['directory']);
|
268 |
+
$backupOptions['SG_BACKUP_FILE_PATHS'] = implode(',', $options['directory']);
|
269 |
+
$backupOptions['SG_ACTION_BACKUP_FILES_AVAILABLE'] = 1;
|
270 |
+
}
|
271 |
+
else {
|
272 |
+
$backupOptions['SG_ACTION_BACKUP_FILES_AVAILABLE'] = 0;
|
273 |
+
$backupOptions['SG_BACKUP_FILE_PATHS'] = 0;
|
274 |
+
}
|
275 |
+
}
|
276 |
+
return $backupOptions;
|
277 |
}
|
278 |
|
279 |
function backupGuardLoadStateData()
|
280 |
{
|
281 |
+
if (file_exists(SG_BACKUP_DIRECTORY.SG_STATE_FILE_NAME)) {
|
282 |
+
$sgState = new SGState();
|
283 |
+
$stateFile = file_get_contents(SG_BACKUP_DIRECTORY.SG_STATE_FILE_NAME);
|
284 |
+
$sgState = $sgState->factory($stateFile);
|
285 |
+
return $sgState;
|
286 |
+
}
|
287 |
|
288 |
+
return false;
|
289 |
}
|
290 |
|
291 |
function backupGuardValidateApiCall($token)
|
292 |
{
|
293 |
+
if (!strlen($token)) {
|
294 |
+
exit();
|
295 |
+
}
|
296 |
|
297 |
+
$statePath = SG_BACKUP_DIRECTORY.SG_STATE_FILE_NAME;
|
298 |
|
299 |
+
if (!file_exists($statePath)) {
|
300 |
+
exit();
|
301 |
+
}
|
302 |
|
303 |
+
$state = file_get_contents($statePath);
|
304 |
+
$state = json_decode($state, true);
|
305 |
+
$stateToken = $state['token'];
|
306 |
|
307 |
+
if ($stateToken != $token) {
|
308 |
+
exit();
|
309 |
+
}
|
310 |
|
311 |
+
return true;
|
312 |
}
|
313 |
|
314 |
function backupGuardScanBackupsDirectory($path)
|
315 |
{
|
316 |
+
$backups = scandir($path);
|
317 |
+
$backupFolders = array();
|
318 |
+
foreach ($backups as $key => $backup) {
|
319 |
+
if ($backup == "." || $backup == "..") {
|
320 |
+
continue;
|
321 |
+
}
|
322 |
|
323 |
+
if (is_dir($path.$backup)) {
|
324 |
+
$backupFolders[$backup] = filemtime($path.$backup);
|
325 |
+
}
|
326 |
+
}
|
327 |
+
// Sort(from low to high) backups by creation date
|
328 |
+
asort($backupFolders);
|
329 |
+
return $backupFolders;
|
330 |
}
|
331 |
|
332 |
function backupGuardSymlinksCleanup($dir)
|
333 |
{
|
334 |
+
if (is_dir($dir)) {
|
335 |
+
$objects = scandir($dir);
|
336 |
+
foreach ($objects as $object) {
|
337 |
+
if ($object == "." || $object == "..") {
|
338 |
+
continue;
|
339 |
+
}
|
340 |
+
|
341 |
+
if (filetype($dir.$object) != "dir") {
|
342 |
+
@unlink($dir.$object);
|
343 |
+
}
|
344 |
+
else {
|
345 |
+
backupGuardSymlinksCleanup($dir.$object.'/');
|
346 |
+
@rmdir($dir.$object);
|
347 |
+
}
|
348 |
+
}
|
349 |
+
}
|
350 |
+
else if (file_exists($dir)) {
|
351 |
+
@unlink($dir);
|
352 |
+
}
|
353 |
+
return;
|
354 |
}
|
355 |
|
356 |
function backupGuardRealFilesize($filename)
|
357 |
{
|
358 |
+
$fp = fopen($filename, 'r');
|
359 |
+
$return = false;
|
360 |
+
if (is_resource($fp))
|
361 |
+
{
|
362 |
+
if (PHP_INT_SIZE < 8) // 32 bit
|
363 |
+
{
|
364 |
+
if (0 === fseek($fp, 0, SEEK_END))
|
365 |
+
{
|
366 |
+
$return = 0.0;
|
367 |
+
$step = 0x7FFFFFFF;
|
368 |
+
while ($step > 0)
|
369 |
+
{
|
370 |
+
if (0 === fseek($fp, - $step, SEEK_CUR))
|
371 |
+
{
|
372 |
+
$return += floatval($step);
|
373 |
+
}
|
374 |
+
else
|
375 |
+
{
|
376 |
+
$step >>= 1;
|
377 |
+
}
|
378 |
+
}
|
379 |
+
}
|
380 |
+
}
|
381 |
+
else if (0 === fseek($fp, 0, SEEK_END)) // 64 bit
|
382 |
+
{
|
383 |
+
$return = ftell($fp);
|
384 |
+
}
|
385 |
+
}
|
386 |
+
|
387 |
+
return $return;
|
388 |
}
|
389 |
|
390 |
function backupGuardFormattedDuration($startTs, $endTs)
|
391 |
{
|
392 |
+
$unit = 'seconds';
|
393 |
+
$duration = $endTs-$startTs;
|
394 |
+
if ($duration>=60 && $duration<3600)
|
395 |
+
{
|
396 |
+
$duration /= 60.0;
|
397 |
+
$unit = 'minutes';
|
398 |
+
}
|
399 |
+
else if ($duration>=3600)
|
400 |
+
{
|
401 |
+
$duration /= 3600.0;
|
402 |
+
$unit = 'hours';
|
403 |
+
}
|
404 |
+
$duration = number_format($duration, 2, '.', '');
|
405 |
|
406 |
+
return $duration.' '.$unit;
|
407 |
}
|
408 |
|
409 |
function backupGuardDeleteDirectory($dirName)
|
410 |
{
|
411 |
+
$dirHandle = null;
|
412 |
+
if (is_dir($dirName))
|
413 |
+
{
|
414 |
+
$dirHandle = opendir($dirName);
|
415 |
+
}
|
416 |
+
|
417 |
+
if (!$dirHandle)
|
418 |
+
{
|
419 |
+
return false;
|
420 |
+
}
|
421 |
+
|
422 |
+
while ($file = readdir($dirHandle))
|
423 |
+
{
|
424 |
+
if ($file != "." && $file != "..")
|
425 |
+
{
|
426 |
+
if (!is_dir($dirName."/".$file))
|
427 |
+
{
|
428 |
+
@unlink($dirName."/".$file);
|
429 |
+
}
|
430 |
+
else
|
431 |
+
{
|
432 |
+
backupGuardDeleteDirectory($dirName.'/'.$file);
|
433 |
+
}
|
434 |
+
}
|
435 |
+
}
|
436 |
+
|
437 |
+
closedir($dirHandle);
|
438 |
+
return @rmdir($dirName);
|
439 |
}
|
440 |
|
441 |
function backupGuardDownloadFile($file, $type = 'application/octet-stream')
|
442 |
{
|
443 |
+
$file = backupGuardRemoveSlashes($file);
|
444 |
+
if (file_exists($file)) {
|
445 |
+
header('Content-Description: File Transfer');
|
446 |
+
header('Content-Type: '.$type);
|
447 |
+
header('Content-Disposition: attachment; filename="'.basename($file).'";');
|
448 |
+
header('Expires: 0');
|
449 |
+
header('Cache-Control: must-revalidate');
|
450 |
+
header('Pragma: public');
|
451 |
+
header('Content-Length: ' . filesize($file));
|
452 |
+
readfile($file);
|
453 |
+
}
|
454 |
|
455 |
+
exit;
|
456 |
}
|
457 |
|
458 |
function backupGuardDownloadViaPhp($backupName, $fileName)
|
459 |
{
|
460 |
+
$str = backupGuardMakeSymlinkFolder($fileName);
|
461 |
+
@copy(SG_BACKUP_DIRECTORY.$backupName.'/'.$fileName, SG_SYMLINK_PATH.$str.'/'.$fileName);
|
462 |
+
|
463 |
+
if (file_exists(SG_SYMLINK_PATH.$str.'/'.$fileName)) {
|
464 |
+
$remoteGet = wp_remote_get(SG_SYMLINK_URL.$str.'/'.$fileName);
|
465 |
+
if (!is_wp_error($remoteGet)) {
|
466 |
+
$content = wp_remote_retrieve_body($remoteGet);
|
467 |
+
header('Pragma: public');
|
468 |
+
header('Expires: 0');
|
469 |
+
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
470 |
+
header('Cache-Control: private', false);
|
471 |
+
header('Content-Type: application/octet-stream');
|
472 |
+
header('Content-Disposition: attachment; filename='.$fileName.';');
|
473 |
+
header('Content-Transfer-Encoding: binary');
|
474 |
+
echo $content;
|
475 |
+
exit;
|
476 |
+
}
|
477 |
+
}
|
478 |
}
|
479 |
|
480 |
function backupGuardMakeSymlinkFolder($filename)
|
481 |
{
|
482 |
+
$filename = backupGuardRemoveSlashes($filename);
|
483 |
|
484 |
+
$downloaddir = SG_SYMLINK_PATH;
|
485 |
+
$downloadURL = SG_SYMLINK_URL;
|
486 |
|
487 |
+
if (!file_exists($downloaddir)) {
|
488 |
+
mkdir($downloaddir, 0777);
|
489 |
+
}
|
490 |
|
491 |
+
$letters = 'abcdefghijklmnopqrstuvwxyz';
|
492 |
+
srand((double) microtime() * 1000000);
|
493 |
+
$string = '';
|
494 |
|
495 |
+
for ($i = 1; $i <= rand(4,12); $i++) {
|
496 |
+
$q = rand(1,24);
|
497 |
+
$string = $string.$letters[$q];
|
498 |
+
}
|
499 |
|
500 |
+
$handle = opendir($downloaddir);
|
501 |
+
while ($dir = readdir($handle)) {
|
502 |
+
if ($dir == "." || $dir == "..") {
|
503 |
+
continue;
|
504 |
+
}
|
505 |
|
506 |
+
if (is_dir($downloaddir.$dir)) {
|
507 |
+
@unlink($downloaddir . $dir . "/" . $filename);
|
508 |
+
@rmdir($downloaddir . $dir);
|
509 |
+
}
|
510 |
+
}
|
511 |
|
512 |
+
closedir($handle);
|
513 |
+
mkdir($downloaddir . $string, 0777);
|
514 |
|
515 |
+
return $string;
|
516 |
}
|
517 |
|
518 |
function backupGuardDownloadFileSymlink($safedir, $filename)
|
519 |
{
|
520 |
+
$downloaddir = SG_SYMLINK_PATH;
|
521 |
+
$downloadURL = SG_SYMLINK_URL;
|
522 |
|
523 |
+
$safedir = backupGuardRemoveSlashes($safedir);
|
524 |
+
$string = backupGuardMakeSymlinkFolder($filename);
|
525 |
|
526 |
+
$res = @symlink($safedir . $filename, $downloaddir . $string . "/" . $filename);
|
527 |
+
if ($res) {
|
528 |
+
header('Content-Description: File Transfer');
|
529 |
+
header('Content-Type: application/octet-stream');
|
530 |
+
header('Content-Disposition: attachment;filename="'.$filename.'"');
|
531 |
+
header('Content-Transfer-Encoding: binary');
|
532 |
+
header("Location: " . $downloadURL . $string . "/" . $filename);
|
533 |
+
}
|
534 |
+
else{
|
535 |
+
wp_die(_backupGuardT("Symlink / shortcut creation failed! Seems your server configurations don't allow symlink creation, so we're unable to provide you the direct download url. You can download your backup using any FTP client. All backups and related stuff we locate '/wp-content/uploads/backup-guard' directory. If you need this functionality, you should check out your server configurations and make sure you don't have any limitation related to symlink creation.", true));
|
536 |
+
}
|
537 |
+
exit;
|
538 |
}
|
539 |
|
540 |
function backupGuardGetCurrentUrlScheme()
|
541 |
{
|
542 |
+
return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')?'https':'http';
|
543 |
}
|
544 |
|
545 |
function backupGuardValidateLicense()
|
546 |
{
|
547 |
+
$pluginCapabilities = backupGuardGetCapabilities();
|
548 |
+
if ($pluginCapabilities == BACKUP_GUARD_CAPABILITIES_FREE) {
|
549 |
+
return true;
|
550 |
+
}
|
551 |
|
552 |
+
//only check once per day
|
553 |
+
$ts = (int)SGConfig::get('SG_LICENSE_CHECK_TS');
|
554 |
+
if (time() - $ts < SG_LICENSE_CHECK_TIMEOUT) {
|
555 |
+
return true;
|
556 |
+
}
|
557 |
|
558 |
+
require_once(SG_LIB_PATH.'SGAuthClient.php');
|
559 |
|
560 |
+
$url = site_url();
|
561 |
|
562 |
+
$auth = SGAuthClient::getInstance();
|
563 |
+
$res = $auth->validateUrl($url);
|
564 |
|
565 |
+
if ($res === -1) { //login is required
|
566 |
+
backup_guard_login_page();
|
567 |
+
return false;
|
568 |
+
}
|
569 |
+
else if ($res === false) { //invalid license
|
570 |
+
backup_guard_link_license_page();
|
571 |
+
return false;
|
572 |
+
}
|
573 |
+
else {
|
574 |
+
SGConfig::set('SG_LICENSE_CHECK_TS', time(), true);
|
575 |
+
SGConfig::set('SG_LICENSE_KEY', $res, true);
|
576 |
+
}
|
577 |
|
578 |
+
return true;
|
579 |
}
|
580 |
|
581 |
//returns true if string $haystack ends with string $needle or $needle is an empty string
|
582 |
function backupGuardStringEndsWith($haystack, $needle)
|
583 |
{
|
584 |
+
$length = strlen($needle);
|
585 |
|
586 |
+
return $length === 0 ||
|
587 |
+
(substr($haystack, -$length) === $needle);
|
588 |
}
|
589 |
//returns true if string $haystack starts with string $needle
|
590 |
function backupGuardStringStartsWith($haystack, $needle)
|
591 |
{
|
592 |
+
$length = strlen($needle);
|
593 |
+
return (substr($haystack, 0, $length) === $needle);
|
594 |
}
|
595 |
|
596 |
function backupGuardGetDbTables(){
|
597 |
+
$sgdb = SGDatabase::getInstance();
|
598 |
+
$tables = $sgdb->query("SHOW TABLES");
|
599 |
+
$tablesKey = 'Tables_in_'.SG_DB_NAME;
|
600 |
+
$tableNames = array();
|
601 |
+
$customTablesToExclude = str_replace(' ', '', SGConfig::get('SG_TABLES_TO_EXCLUDE'));
|
602 |
+
$tablesToExclude = explode(',', $customTablesToExclude);
|
603 |
+
foreach ($tables as $table):
|
604 |
+
$tableName = $table[$tablesKey];
|
605 |
+
if($tableName != SG_ACTION_TABLE_NAME && $tableName != SG_CONFIG_TABLE_NAME && $tableName != SG_SCHEDULE_TABLE_NAME){
|
606 |
+
array_push($tableNames, array('name'=>$tableName,
|
607 |
+
'current'=> backupGuardStringStartsWith($tableName, SG_ENV_DB_PREFIX)? 'true':'false',
|
608 |
+
'disabled'=>in_array($tableName,$tablesToExclude)? 'disabled':''
|
609 |
+
));
|
610 |
+
}
|
611 |
+
endforeach;
|
612 |
+
usort($tableNames, function ($name1, $name2){
|
613 |
+
if(backupGuardStringStartsWith($name1['name'], SG_ENV_DB_PREFIX)){
|
614 |
+
if(backupGuardStringStartsWith($name2['name'], SG_ENV_DB_PREFIX)){
|
615 |
+
return 0;
|
616 |
+
}
|
617 |
+
return -1;
|
618 |
+
}
|
619 |
+
return 1;
|
620 |
+
});
|
621 |
+
return $tableNames;
|
622 |
}
|
623 |
|
624 |
function backupGuardGetBackupTablesHTML($defaultChecked = false){
|
625 |
+
$tables = backupGuardGetDbTables();
|
626 |
+
?>
|
627 |
|
628 |
+
<div class="checkbox">
|
629 |
+
<label for="custombackupdb-chbx">
|
630 |
+
<input type="checkbox" class="sg-custom-option" name="backupDatabase" id="custombackupdb-chbx" <?php echo $defaultChecked?'checked':'' ?>>
|
631 |
<span class="sg-checkbox-label-text"><?php _backupGuardT('Backup database'); ?></span>
|
632 |
+
</label>
|
633 |
+
<div class="col-md-12 sg-checkbox sg-backup-db-options">
|
634 |
+
<div class="checkbox">
|
635 |
+
<label for="custombackupdbfull-radio" class="sg-backup-db-mode" title="<?php _backupGuardT('Backup all tables found in the database')?>">
|
636 |
+
<input type="radio" name="backupDBType" id="custombackupdbfull-radio" value="0" checked>
|
637 |
+
<?php _backupGuardT('Full'); ?>
|
638 |
+
</label>
|
639 |
+
<label for="custombackupdbcurent-radio" class="sg-backup-db-mode" title="<?php echo _backupGuardT('Backup tables related to the current WordPress installation. Only tables with', true).' '.SG_ENV_DB_PREFIX.' '._backupGuardT('will be backed up', true)?>">
|
640 |
+
<input type="radio" name="backupDBType" id="custombackupdbcurent-radio" value="1">
|
641 |
+
<?php _backupGuardT('Only WordPress'); ?>
|
642 |
+
</label>
|
643 |
+
<label for="custombackupdbcustom-radio" class="sg-backup-db-mode" title="<?php _backupGuardT('Select tables you want to include in your backup') ?>">
|
644 |
+
<input type="radio" name="backupDBType" id="custombackupdbcustom-radio" value="2">
|
645 |
+
<?php _backupGuardT('Custom'); ?>
|
646 |
+
</label>
|
647 |
+
<!--Tables-->
|
648 |
+
<div class="col-md-12 sg-custom-backup-tables">
|
649 |
+
<?php foreach ($tables as $table): ?>
|
650 |
+
<div class="checkbox">
|
651 |
+
<label for="<?php echo $table['name']?>">
|
652 |
+
<input type="checkbox" name="table[]" current="<?php echo $table['current'] ?>" <?php echo $table['disabled'] ?> id="<?php echo $table['name']?>" value="<?php echo $table['name'];?>">
|
653 |
<span class="sg-checkbox-label-text"><?php echo basename($table['name']);?></span>
|
654 |
+
<?php if($table['disabled']) {?>
|
655 |
+
<span class="sg-disableText"><?php _backupGuardT('(excluded from settings)') ?></span>
|
656 |
+
<?php } ?>
|
657 |
+
</label>
|
658 |
+
</div>
|
659 |
+
<?php endforeach;?>
|
660 |
+
</div>
|
661 |
+
</div>
|
662 |
+
</div>
|
663 |
|
664 |
+
</div>
|
665 |
|
666 |
+
<?php
|
667 |
|
668 |
}
|
669 |
|
670 |
function backupGuardIsAccountGold()
|
671 |
{
|
672 |
+
return strpos("gold", SG_PRODUCT_IDENTIFIER)!== false;
|
673 |
}
|
674 |
|
675 |
function backupGuardGetProductName()
|
676 |
{
|
677 |
+
$name = '';
|
678 |
+
switch (SG_PRODUCT_IDENTIFIER) {
|
679 |
+
case 'backup-guard-wp-silver':
|
680 |
+
$name = 'Silver';
|
681 |
+
break;
|
682 |
+
case 'backup-guard-wp-platinum':
|
683 |
+
$name = 'Platinum';
|
684 |
+
break;
|
685 |
+
case 'backup-guard-en':
|
686 |
+
case 'backup-guard-en-regular':
|
687 |
+
$name = 'Regular';
|
688 |
+
break;
|
689 |
+
case 'backup-guard-en-extended':
|
690 |
+
$name = 'Extended';
|
691 |
+
break;
|
692 |
+
case 'backup-guard-wp-gold':
|
693 |
+
$name = 'Gold';
|
694 |
+
break;
|
695 |
+
case 'backup-guard-wp-free':
|
696 |
+
$name = 'Free';
|
697 |
+
break;
|
698 |
+
}
|
699 |
+
|
700 |
+
return $name;
|
701 |
}
|
702 |
|
703 |
function backupGuardGetFileSelectiveRestore()
|
704 |
{
|
705 |
+
?>
|
706 |
+
<div class="col-md-12 sg-checkbox sg-restore-files-options">
|
707 |
+
<div class="checkbox">
|
708 |
+
<label for="restorefilesfull-radio" class="sg-restore-files-mode" >
|
709 |
+
<input type="radio" name="restoreFilesType" checked id="restorefilesfull-radio" value="0">
|
710 |
+
<?php _backupGuardT('Full'); ?>
|
711 |
+
</label>
|
712 |
+
|
713 |
+
<label for="restorefilescustom-radio" class="sg-restore-files-mode">
|
714 |
+
<input type="radio" name="restoreFilesType" id="restorefilescustom-radio" value="1">
|
715 |
+
<?php _backupGuardT('Custom'); ?>
|
716 |
+
</label>
|
717 |
+
<!--Files-->
|
718 |
+
<div class="col-md-12 sg-file-selective-restore">
|
719 |
+
<div id="fileSystemTreeContainer"></div>
|
720 |
+
</div>
|
721 |
+
</div>
|
722 |
+
</div>
|
723 |
+
<?php
|
724 |
}
|
725 |
|
726 |
function checkAllMissedTables()
|
727 |
{
|
728 |
+
$sgdb = SGDatabase::getInstance();
|
729 |
+
$allTables = array(SG_CONFIG_TABLE_NAME, SG_SCHEDULE_TABLE_NAME, SG_ACTION_TABLE_NAME);
|
730 |
+
$missedTables = array();
|
731 |
+
$status = true;
|
732 |
+
|
733 |
+
foreach ($allTables as $table) {
|
734 |
+
$query = $sgdb->query("SELECT count(*) as isExists
|
735 |
FROM information_schema.TABLES
|
736 |
WHERE (TABLE_SCHEMA = '".DB_NAME."') AND (TABLE_NAME = '$table')"
|
737 |
+
);
|
738 |
+
|
739 |
+
if (empty($query[0]['isExists'])) {
|
740 |
+
$status = false;
|
741 |
+
}
|
742 |
+
}
|
743 |
+
|
744 |
+
return $status;
|
745 |
}
|
746 |
|
747 |
function backupGuardIncludeFile($filePath)
|
748 |
{
|
749 |
if (file_exists($filePath)) {
|
750 |
+
include_once($filePath);
|
751 |
}
|
752 |
}
|
public/ajax/modalManualBackup.php
CHANGED
@@ -1,138 +1,138 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
|
12 |
-
|
13 |
?>
|
14 |
<div class="modal-dialog">
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
<span class="sg-checkbox-label-text"><?php _backupGuardT('Backup files'); ?></span>
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
<span class="sg-checkbox-label-text"><?php echo basename($directory);?></span>
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
<span class="sg-checkbox-label-text"><?php _backupGuardT('Upload to cloud'); ?></span>
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
<span class="sg-checkbox-label-text"><?php echo 'FTP' ?></span>
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
<span class="sg-checkbox-label-text"><?php echo 'Dropbox' ?></span>
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
<span class="sg-checkbox-label-text"><?php echo 'Google Drive' ?></span>
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
<span class="sg-checkbox-label-text"><?php echo (backupGuardIsAccountGold()? 'Amazon ':'').'S3' ?></span>
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
<span class="sg-checkbox-label-text"><?php echo 'One Drive' ?></span>
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
<span class="sg-checkbox-label-text"><?php _backupGuardT('Background mode'); ?></span>
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
</div>
|
1 |
<?php
|
2 |
+
require_once(dirname(__FILE__).'/../boot.php');
|
3 |
|
4 |
+
$directories = SG_BACKUP_FILE_PATHS;
|
5 |
+
$directories = explode(',', $directories);
|
6 |
+
$dropbox = SGConfig::get('SG_DROPBOX_ACCESS_TOKEN');
|
7 |
+
$gdrive = SGConfig::get('SG_GOOGLE_DRIVE_REFRESH_TOKEN');
|
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 |
?>
|
14 |
<div class="modal-dialog">
|
15 |
+
<div class="modal-content">
|
16 |
+
<div class="modal-header">
|
17 |
+
<div id="sg-modal-manual-backup-header">
|
18 |
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
19 |
+
<h4 class="modal-title"><?php ($backupType == SG_BACKUP_METHOD_MIGRATE)?_backupGuardT("Prepare migration package"):_backupGuardT("Manual Backup") ?></h4>
|
20 |
+
</div>
|
21 |
+
</div>
|
22 |
+
<form class="form-horizontal" method="post" id="manualBackup">
|
23 |
+
<div class="modal-body sg-modal-body">
|
24 |
+
<!-- Multiple Radios -->
|
25 |
+
<div class="form-group">
|
26 |
+
<div class="col-md-12">
|
27 |
+
<input type="text" name="sg-custom-backup-name" id="sg-custom-backup-name" class="sg-backup-input" placeholder="Custom backup name (optional)">
|
28 |
+
</div>
|
29 |
+
<div class="col-md-12">
|
30 |
+
<div class="radio">
|
31 |
+
<label for="fullbackup-radio">
|
32 |
+
<input type="radio" name="backupType" id="fullbackup-radio" value="1" checked="checked">
|
33 |
+
<?php _backupGuardT('Full backup'); ?>
|
34 |
+
</label>
|
35 |
+
</div>
|
36 |
+
<div class="radio">
|
37 |
+
<label for="custombackup-radio">
|
38 |
+
<input type="radio" name="backupType" id="custombackup-radio" value="2">
|
39 |
+
<?php _backupGuardT('Custom backup'); ?>
|
40 |
+
</label>
|
41 |
+
</div>
|
42 |
+
<div class="col-md-12 sg-custom-backup">
|
43 |
+
<?php backupGuardGetBackupTablesHTML(); ?>
|
44 |
+
<div class="checkbox sg-no-padding-top">
|
45 |
+
<label for="custombackupfiles-chbx">
|
46 |
+
<input type="checkbox" class="sg-custom-option" name="backupFiles" id="custombackupfiles-chbx">
|
47 |
<span class="sg-checkbox-label-text"><?php _backupGuardT('Backup files'); ?></span>
|
48 |
+
</label>
|
49 |
+
<!--Files-->
|
50 |
+
<div class="col-md-12 sg-checkbox sg-custom-backup-files">
|
51 |
+
<?php foreach ($directories as $directory): ?>
|
52 |
+
<div class="checkbox">
|
53 |
+
<label for="<?php echo 'sg'.$directory?>">
|
54 |
+
<input type="checkbox" name="directory[]" id="<?php echo 'sg'.$directory;?>" value="<?php echo $directory;?>">
|
55 |
<span class="sg-checkbox-label-text"><?php echo basename($directory);?></span>
|
56 |
+
</label>
|
57 |
+
</div>
|
58 |
+
<?php endforeach;?>
|
59 |
+
</div>
|
60 |
+
</div>
|
61 |
+
</div>
|
62 |
+
<div class="clearfix"></div>
|
63 |
+
<?php if(SGBoot::isFeatureAvailable('STORAGE')): ?>
|
64 |
+
<!--Cloud-->
|
65 |
+
<div class="checkbox sg-no-padding-top">
|
66 |
+
<label for="custombackupcloud-chbx">
|
67 |
+
<input type="checkbox" name="backupCloud" id="custombackupcloud-chbx">
|
68 |
<span class="sg-checkbox-label-text"><?php _backupGuardT('Upload to cloud'); ?></span>
|
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).'"':''?>>
|
75 |
+
<input type="checkbox" name="backupStorages[]" id="cloud-ftp" value="<?php echo SG_STORAGE_FTP ?>" <?php echo empty($ftp)?'disabled="disabled"':''?>>
|
76 |
<span class="sg-checkbox-label-text"><?php echo 'FTP' ?></span>
|
77 |
+
</label>
|
78 |
+
</div>
|
79 |
+
<?php endif; ?>
|
80 |
+
<?php if(SGBoot::isFeatureAvailable('DROPBOX')): ?>
|
81 |
+
<div class="checkbox">
|
82 |
+
<label for="cloud-dropbox" <?php echo empty($dropbox)?'data-toggle="tooltip" data-placement="right" title="'._backupGuardT('Dropbox is not active.',true).'"':''?>>
|
83 |
+
<input type="checkbox" name="backupStorages[]" id="cloud-dropbox" value="<?php echo SG_STORAGE_DROPBOX ?>"
|
84 |
+
<?php echo empty($dropbox)?'disabled="disabled"':''?>>
|
85 |
<span class="sg-checkbox-label-text"><?php echo 'Dropbox' ?></span>
|
86 |
+
</label>
|
87 |
+
</div>
|
88 |
+
<?php endif; ?>
|
89 |
+
<?php if(SGBoot::isFeatureAvailable('GOOGLE_DRIVE')): ?>
|
90 |
+
<div class="checkbox">
|
91 |
+
<label for="cloud-gdrive" <?php echo empty($gdrive)?'data-toggle="tooltip" data-placement="right" title="'._backupGuardT('Google Drive is not active.',true).'"':''?>>
|
92 |
+
<input type="checkbox" name="backupStorages[]" id="cloud-gdrive" value="<?php echo SG_STORAGE_GOOGLE_DRIVE?>"
|
93 |
+
<?php echo empty($gdrive)?'disabled="disabled"':''?>>
|
94 |
<span class="sg-checkbox-label-text"><?php echo 'Google Drive' ?></span>
|
95 |
+
</label>
|
96 |
+
</div>
|
97 |
+
<?php endif; ?>
|
98 |
+
<?php if(SGBoot::isFeatureAvailable('AMAZON')): ?>
|
99 |
+
<div class="checkbox">
|
100 |
+
<label for="cloud-amazon" <?php echo empty($amazon)?'data-toggle="tooltip" data-placement="right" title="'._backupGuardT((backupGuardIsAccountGold()? 'Amazon ':'').'S3 is not active.',true).'"':''?>>
|
101 |
+
<input type="checkbox" name="backupStorages[]" id="cloud-amazon" value="<?php echo SG_STORAGE_AMAZON?>"
|
102 |
+
<?php echo empty($amazon)?'disabled="disabled"':''?>>
|
103 |
<span class="sg-checkbox-label-text"><?php echo (backupGuardIsAccountGold()? 'Amazon ':'').'S3' ?></span>
|
104 |
+
</label>
|
105 |
+
</div>
|
106 |
+
<?php endif; ?>
|
107 |
+
<?php if(SGBoot::isFeatureAvailable('ONE_DRIVE')): ?>
|
108 |
+
<div class="checkbox">
|
109 |
+
<label for="cloud-one-drive" <?php echo empty($oneDrive)?'data-toggle="tooltip" data-placement="right" title="'._backupGuardT('One Drive is not active.', true).'"':''?>>
|
110 |
+
<input type="checkbox" name="backupStorages[]" id="cloud-one-drive" value="<?php echo SG_STORAGE_ONE_DRIVE?>" <?php echo empty($oneDrive)?'disabled="disabled"':''?>>
|
111 |
<span class="sg-checkbox-label-text"><?php echo 'One Drive' ?></span>
|
112 |
+
</label>
|
113 |
+
</div>
|
114 |
+
<?php endif;?>
|
115 |
+
</div>
|
116 |
+
<div class="clearfix"></div>
|
117 |
+
</div>
|
118 |
+
<?php endif; ?>
|
119 |
+
<!-- Background mode -->
|
120 |
+
<?php if(SGBoot::isFeatureAvailable('BACKGROUND_MODE')): ?>
|
121 |
+
<div class="checkbox">
|
122 |
+
<label for="background-chbx">
|
123 |
+
<input type="checkbox" name="backgroundMode" id="background-chbx">
|
124 |
<span class="sg-checkbox-label-text"><?php _backupGuardT('Background mode'); ?></span>
|
125 |
+
</label>
|
126 |
+
</div>
|
127 |
+
<?php endif; ?>
|
128 |
+
</div>
|
129 |
+
</div>
|
130 |
+
</div>
|
131 |
+
<div class="modal-footer">
|
132 |
+
<input type="text" name="backup-type" value="<?php echo $backupType?>" hidden>
|
133 |
+
<span class="modal-close-button" data-dismiss="modal">Close</span>
|
134 |
+
<button type="button" onclick="sgBackup.manualBackup()" class="btn btn-success"><?php _backupGuardT('Backup')?></button>
|
135 |
+
</div>
|
136 |
+
</form>
|
137 |
+
</div>
|
138 |
</div>
|
public/css/bgstyle.less.css
CHANGED
@@ -8159,4 +8159,4 @@ input.sg-backup-input[readonly] {
|
|
8159 |
display: inline-block;
|
8160 |
margin-left: 5px;
|
8161 |
margin-top: 3px;
|
8162 |
-
}
|
8159 |
display: inline-block;
|
8160 |
margin-left: 5px;
|
8161 |
margin-top: 3px;
|
8162 |
+
}
|
public/js/sgbackup.js
CHANGED
@@ -529,13 +529,21 @@ sgBackup.checkBackupCreation = function(){
|
|
529 |
var sgBackupCreationHandler = new sgRequestHandler('checkBackupCreation', {token: BG_BACKUP_STRINGS.nonce});
|
530 |
sgBackupCreationHandler.dataType = 'html';
|
531 |
sgBackupCreationHandler.callback = function(response) {
|
532 |
-
var
|
533 |
-
if (result && result.status == 'cleaned') {
|
534 |
-
sgBackup.manualBackup();
|
535 |
-
}
|
536 |
-
else {
|
537 |
jQuery('#sg-modal').modal('hide');
|
538 |
location.reload();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
539 |
}
|
540 |
};
|
541 |
sgBackupCreationHandler.run();
|
529 |
var sgBackupCreationHandler = new sgRequestHandler('checkBackupCreation', {token: BG_BACKUP_STRINGS.nonce});
|
530 |
sgBackupCreationHandler.dataType = 'html';
|
531 |
sgBackupCreationHandler.callback = function(response) {
|
532 |
+
var hideAndReload = function () {
|
|
|
|
|
|
|
|
|
533 |
jQuery('#sg-modal').modal('hide');
|
534 |
location.reload();
|
535 |
+
};
|
536 |
+
if (response.length) {
|
537 |
+
var result = jQuery.parseJSON(response);
|
538 |
+
if (result && result.status == 'cleaned') {
|
539 |
+
sgBackup.manualBackup();
|
540 |
+
}
|
541 |
+
else {
|
542 |
+
hideAndReload();
|
543 |
+
}
|
544 |
+
}
|
545 |
+
else {
|
546 |
+
hideAndReload();
|
547 |
}
|
548 |
};
|
549 |
sgBackupCreationHandler.run();
|