Version Description
Release Date: July 17th, 2018
- Bug fix: Fixed and improved php-cli detection.
- Bug fix: Fixed "Undefined index 'plugins'" bug.
- Update: Cleaned up codebase to pass PHP CodeSniffer.
Download this release
Release Info
Developer | boldgrid |
Plugin | Total Upkeep – WordPress Backup Plugin plus Restore & Migrate by BoldGrid |
Version | 1.6.4 |
Comparing to | |
See all releases |
Code changes from version 1.6.3 to 1.6.4
- admin/class-boldgrid-backup-admin-archive-actions.php +36 -32
- admin/class-boldgrid-backup-admin-archive-browser.php +33 -26
- admin/class-boldgrid-backup-admin-archive-details.php +26 -25
- admin/class-boldgrid-backup-admin-archive-fail.php +11 -11
- admin/class-boldgrid-backup-admin-archive-log.php +17 -17
- admin/class-boldgrid-backup-admin-archive.php +15 -16
- admin/class-boldgrid-backup-admin-archives-all.php +24 -25
- admin/class-boldgrid-backup-admin-archives.php +25 -20
- admin/class-boldgrid-backup-admin-auto-rollback.php +81 -66
- admin/class-boldgrid-backup-admin-backup-dir.php +70 -27
- admin/class-boldgrid-backup-admin-compressor.php +9 -8
- admin/class-boldgrid-backup-admin-compressors.php +8 -9
- admin/class-boldgrid-backup-admin-config.php +22 -23
- admin/class-boldgrid-backup-admin-core-files.php +12 -14
- admin/class-boldgrid-backup-admin-core.php +181 -157
- admin/class-boldgrid-backup-admin-cron.php +94 -106
- admin/class-boldgrid-backup-admin-crypt.php +10 -10
- admin/class-boldgrid-backup-admin-db-dump.php +9 -10
- admin/class-boldgrid-backup-admin-db-get.php +20 -13
- admin/class-boldgrid-backup-admin-db-import.php +28 -22
- admin/class-boldgrid-backup-admin-db-omit.php +35 -34
- admin/class-boldgrid-backup-admin-email.php +30 -11
- admin/class-boldgrid-backup-admin-filelist.php +9 -11
- admin/class-boldgrid-backup-admin-folder-exclusion.php +57 -44
- admin/class-boldgrid-backup-admin-go-pro.php +27 -20
- admin/class-boldgrid-backup-admin-home-dir.php +6 -7
- admin/class-boldgrid-backup-admin-in-progress.php +31 -23
- admin/class-boldgrid-backup-admin-jobs.php +16 -15
- admin/class-boldgrid-backup-admin-notice.php +32 -32
- admin/class-boldgrid-backup-admin-remote.php +12 -12
- admin/class-boldgrid-backup-admin-restore-git.php +14 -8
- admin/class-boldgrid-backup-admin-restore-helper.php +31 -31
- admin/class-boldgrid-backup-admin-scheduler.php +11 -10
- admin/class-boldgrid-backup-admin-settings.php +74 -84
- admin/class-boldgrid-backup-admin-test.php +48 -36
- admin/class-boldgrid-backup-admin-time.php +28 -29
- admin/class-boldgrid-backup-admin-tools.php +10 -11
- admin/class-boldgrid-backup-admin-upload.php +16 -10
- admin/class-boldgrid-backup-admin-utility.php +49 -46
- admin/class-boldgrid-backup-admin-wp-cron.php +31 -36
- admin/class-boldgrid-backup-admin-xhprof.php +13 -12
- admin/class-boldgrid-backup-admin.php +25 -18
- admin/compressor/{pcl_zip.php → class-boldgrid-backup-admin-compressor-pcl-zip.php} +57 -49
- admin/compressor/{php_zip.php → class-boldgrid-backup-admin-compressor-php-zip.php} +37 -35
- admin/index.php +6 -0
- admin/js/boldgrid-backup-admin-archive-actions.js +4 -4
- admin/js/boldgrid-backup-admin-archive-details.js +3 -3
- admin/js/boldgrid-backup-admin-folder-exclude.js +10 -10
- admin/js/boldgrid-backup-admin-ftp-settings.js +3 -3
- admin/js/boldgrid-backup-admin-home.js +1 -1
- admin/js/boldgrid-backup-admin-settings.js +1 -1
- admin/js/boldgrid-backup-admin-table-include.js +6 -6
- admin/js/boldgrid-backup-admin-zip-browser.js +4 -4
- admin/js/boldgrid-backup-admin.js +3 -3
- admin/partials/archive-details/browser-entry.php +7 -4
- admin/partials/archive-details/browser.php +8 -6
- admin/partials/archive-details/db.php +19 -8
- admin/partials/archive-details/details.php +21 -17
- admin/partials/archive-details/not-found.php +9 -5
- admin/partials/archive-details/only-remote.php +15 -7
- admin/partials/archive-details/remote-storage.php +29 -9
- admin/partials/archives/add-new.php +24 -11
- admin/partials/archives/note-pre-backup.php +28 -12
- admin/partials/boldgrid-backup-admin-archive-details.php +35 -23
- admin/partials/boldgrid-backup-admin-backup-button.php +13 -5
- admin/partials/boldgrid-backup-admin-backup-modal.php +13 -8
- admin/partials/boldgrid-backup-admin-backup.php +37 -24
- admin/partials/boldgrid-backup-admin-home.php +18 -14
- admin/partials/boldgrid-backup-admin-mail-restore.php +12 -5
- admin/partials/boldgrid-backup-admin-nav.php +15 -7
- admin/partials/boldgrid-backup-admin-settings.php +54 -41
- admin/partials/boldgrid-backup-admin-test.php +37 -26
- admin/partials/boldgrid-backup-admin-tools.php +15 -11
- admin/partials/remote/ftp.php +36 -22
- admin/partials/settings/auto-updates.php +94 -57
- admin/partials/settings/backup-directory.php +24 -7
- admin/partials/settings/compressor.php +30 -16
- admin/partials/settings/connect-key.php +24 -9
- admin/partials/settings/days-of-week.php +75 -17
- admin/partials/settings/db.php +17 -8
- admin/partials/settings/folders.php +34 -21
- admin/partials/settings/notifications.php +15 -5
- admin/partials/settings/premium-message.php +34 -9
- admin/partials/settings/retention.php +14 -7
- admin/partials/settings/scheduler.php +12 -4
- admin/partials/settings/storage-location.php +14 -9
- admin/partials/settings/storage.php +35 -14
- admin/partials/settings/time-of-day.php +36 -24
- admin/partials/tools/local-remote.php +110 -34
- admin/remote/{ftp-hooks.php → class-boldgrid-backup-admin-ftp-hooks.php} +51 -41
- admin/remote/{ftp-page.php → class-boldgrid-backup-admin-ftp-page.php} +30 -28
- admin/remote/{ftp.php → class-boldgrid-backup-admin-ftp.php} +146 -114
- admin/remote/{sftp.php → class-boldgrid-backup-admin-sftp.php} +83 -73
- admin/storage/{local.php → class-boldgrid-backup-admin-storage-local.php} +12 -12
- boldgrid-backup-cron.php +16 -12
- boldgrid-backup.php +35 -20
- cron/{url-helper.php → class-boldgrid-backup-url-helper.php} +105 -96
- cron/cli-support.php +13 -2
- cron/{run_jobs.php → run-jobs.php} +5 -3
- includes/class-boldgrid-backup-activator.php +15 -10
- includes/class-boldgrid-backup-deactivator.php +7 -5
- includes/class-boldgrid-backup-i18n.php +14 -11
- includes/class-boldgrid-backup-loader.php +35 -24
- includes/class-boldgrid-backup.php +39 -32
- includes/config/config.plugin.php +24 -18
- includes/config/config.sample.php +11 -5
- includes/config/index.php +6 -0
- includes/index.php +6 -0
- index.php +6 -0
- readme.txt +9 -1
- vendor/autoload.php +1 -1
- vendor/boldgrid/library/README.md +9 -0
- vendor/boldgrid/library/src/Library/Api/Availability.php +1 -3
- vendor/boldgrid/library/src/Library/Key.php +2 -3
- vendor/boldgrid/library/src/Library/License.php +1 -1
- vendor/boldgrid/library/src/Library/Notice/ClaimPremiumKey.php +7 -1
- vendor/boldgrid/library/src/Library/Notice/KeyPrompt.php +1 -1
- vendor/boldgrid/library/src/Library/Views/KeyPrompt.php +4 -4
- vendor/boldgrid/library/src/library.global.php +5 -5
- vendor/composer/autoload_real.php +7 -7
- vendor/composer/autoload_static.php +3 -3
- vendor/composer/installed.json +12 -12
- vendor/ifsnop/mysqldump-php/.scrutinizer.yml +132 -40
- vendor/ifsnop/mysqldump-php/README.md +4 -0
- vendor/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php +281 -214
- vendor/ifsnop/mysqldump-php/tests/delete_users.sh +3 -0
- vendor/ifsnop/mysqldump-php/tests/test.php +21 -0
- vendor/ifsnop/mysqldump-php/tests/test.sh +33 -4
- vendor/ifsnop/mysqldump-php/tests/test011.src.sql +2 -1
admin/class-boldgrid-backup-admin-archive-actions.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
* BoldGrid Backup Admin Archive Actions Class.
|
17 |
*
|
18 |
-
* @since 1.
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Archive_Actions {
|
21 |
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
25 |
-
* @since
|
26 |
* @access private
|
27 |
* @var Boldgrid_Backup_Admin_Core
|
28 |
*/
|
@@ -31,7 +31,7 @@ class Boldgrid_Backup_Admin_Archive_Actions {
|
|
31 |
/**
|
32 |
* Constructor.
|
33 |
*
|
34 |
-
* @since 1.
|
35 |
*
|
36 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
37 |
*/
|
@@ -42,33 +42,34 @@ class Boldgrid_Backup_Admin_Archive_Actions {
|
|
42 |
/**
|
43 |
* Enqueue scripts.
|
44 |
*
|
45 |
-
* @since 1.
|
46 |
*/
|
47 |
public function enqueue_scripts() {
|
48 |
-
$access_type
|
49 |
-
$archive_nonce
|
50 |
-
$delete_confirm_text =
|
51 |
-
'Please confirm the deletion of the archive file:'
|
52 |
'boldgrid-backup'
|
53 |
-
);
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
'boldgrid-backup'
|
59 |
);
|
60 |
|
61 |
$handle = 'boldgrid-backup-admin-archive-actions';
|
62 |
-
wp_register_script(
|
|
|
63 |
plugin_dir_url( __FILE__ ) . 'js/' . $handle . '.js',
|
64 |
array( 'jquery' ),
|
65 |
BOLDGRID_BACKUP_VERSION,
|
66 |
false
|
67 |
);
|
68 |
$translation = array(
|
69 |
-
'accessType'
|
70 |
-
'archiveNonce'
|
71 |
-
'deleteConfirmText'
|
72 |
'restoreConfirmText' => $restore_confirm_text,
|
73 |
);
|
74 |
wp_localize_script( $handle, 'BoldGridBackupAdminArchiveActions', $translation );
|
@@ -78,9 +79,9 @@ class Boldgrid_Backup_Admin_Archive_Actions {
|
|
78 |
/**
|
79 |
* Return a link to delete an archive.
|
80 |
*
|
81 |
-
* @since 1.
|
82 |
*
|
83 |
-
* @param string $filename
|
84 |
* @return string
|
85 |
*/
|
86 |
public function get_delete_link( $filename ) {
|
@@ -89,7 +90,8 @@ class Boldgrid_Backup_Admin_Archive_Actions {
|
|
89 |
if ( empty( $archive ) ) {
|
90 |
$link = '';
|
91 |
} else {
|
92 |
-
$link = sprintf(
|
|
|
93 |
<form method="post" id="delete-action" >
|
94 |
<input type="hidden" name="delete_now" value="1" />
|
95 |
<input type="hidden" name="archive_key" value="%2$s" />
|
@@ -112,9 +114,9 @@ class Boldgrid_Backup_Admin_Archive_Actions {
|
|
112 |
/**
|
113 |
* Return a link to download an archive.
|
114 |
*
|
115 |
-
* @since 1.
|
116 |
*
|
117 |
-
* @param string $filename
|
118 |
* @return string
|
119 |
*/
|
120 |
public function get_download_button( $filename ) {
|
@@ -123,7 +125,8 @@ class Boldgrid_Backup_Admin_Archive_Actions {
|
|
123 |
if ( empty( $archive ) ) {
|
124 |
$button = '';
|
125 |
} else {
|
126 |
-
$button = sprintf(
|
|
|
127 |
<a
|
128 |
id="backup-archive-download-%1$s"
|
129 |
class="button button-primary action-download"
|
@@ -146,10 +149,10 @@ class Boldgrid_Backup_Admin_Archive_Actions {
|
|
146 |
/**
|
147 |
* Return a link to restore an archive.
|
148 |
*
|
149 |
-
* @since 1.
|
150 |
*
|
151 |
-
* @param string $filename
|
152 |
-
* @param array $args
|
153 |
* @return string
|
154 |
*/
|
155 |
public function get_restore_button( $filename, $args = array() ) {
|
@@ -164,7 +167,8 @@ class Boldgrid_Backup_Admin_Archive_Actions {
|
|
164 |
if ( empty( $archive ) ) {
|
165 |
$button = '';
|
166 |
} else {
|
167 |
-
$button = sprintf(
|
|
|
168 |
<a
|
169 |
data-restore-now="1"
|
170 |
data-archive-key="%2$s"
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-archive-actions.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.5.4
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
* BoldGrid Backup Admin Archive Actions Class.
|
17 |
*
|
18 |
+
* @since 1.6.0
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Archive_Actions {
|
21 |
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
25 |
+
* @since 1.6.0
|
26 |
* @access private
|
27 |
* @var Boldgrid_Backup_Admin_Core
|
28 |
*/
|
31 |
/**
|
32 |
* Constructor.
|
33 |
*
|
34 |
+
* @since 1.6.0
|
35 |
*
|
36 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
37 |
*/
|
42 |
/**
|
43 |
* Enqueue scripts.
|
44 |
*
|
45 |
+
* @since 1.6.0
|
46 |
*/
|
47 |
public function enqueue_scripts() {
|
48 |
+
$access_type = get_filesystem_method();
|
49 |
+
$archive_nonce = wp_create_nonce( 'archive_auth' );
|
50 |
+
$delete_confirm_text = __(
|
51 |
+
'Please confirm the deletion of the archive file:',
|
52 |
'boldgrid-backup'
|
53 |
+
) . PHP_EOL;
|
54 |
+
|
55 |
+
// translators: 1: Archive filename.
|
56 |
+
$restore_confirm_text = __(
|
57 |
+
"Please confirm the restoration of this WordPress installation from the archive file:\n\"%s\"\n\nPlease be aware that you may get logged-out if your session token does not exist in the database restored.",
|
58 |
'boldgrid-backup'
|
59 |
);
|
60 |
|
61 |
$handle = 'boldgrid-backup-admin-archive-actions';
|
62 |
+
wp_register_script(
|
63 |
+
$handle,
|
64 |
plugin_dir_url( __FILE__ ) . 'js/' . $handle . '.js',
|
65 |
array( 'jquery' ),
|
66 |
BOLDGRID_BACKUP_VERSION,
|
67 |
false
|
68 |
);
|
69 |
$translation = array(
|
70 |
+
'accessType' => $access_type,
|
71 |
+
'archiveNonce' => $archive_nonce,
|
72 |
+
'deleteConfirmText' => $delete_confirm_text,
|
73 |
'restoreConfirmText' => $restore_confirm_text,
|
74 |
);
|
75 |
wp_localize_script( $handle, 'BoldGridBackupAdminArchiveActions', $translation );
|
79 |
/**
|
80 |
* Return a link to delete an archive.
|
81 |
*
|
82 |
+
* @since 1.6.0
|
83 |
*
|
84 |
+
* @param string $filename Filename.
|
85 |
* @return string
|
86 |
*/
|
87 |
public function get_delete_link( $filename ) {
|
90 |
if ( empty( $archive ) ) {
|
91 |
$link = '';
|
92 |
} else {
|
93 |
+
$link = sprintf(
|
94 |
+
'
|
95 |
<form method="post" id="delete-action" >
|
96 |
<input type="hidden" name="delete_now" value="1" />
|
97 |
<input type="hidden" name="archive_key" value="%2$s" />
|
114 |
/**
|
115 |
* Return a link to download an archive.
|
116 |
*
|
117 |
+
* @since 1.6.0
|
118 |
*
|
119 |
+
* @param string $filename Filename.
|
120 |
* @return string
|
121 |
*/
|
122 |
public function get_download_button( $filename ) {
|
125 |
if ( empty( $archive ) ) {
|
126 |
$button = '';
|
127 |
} else {
|
128 |
+
$button = sprintf(
|
129 |
+
'
|
130 |
<a
|
131 |
id="backup-archive-download-%1$s"
|
132 |
class="button button-primary action-download"
|
149 |
/**
|
150 |
* Return a link to restore an archive.
|
151 |
*
|
152 |
+
* @since 1.6.0
|
153 |
*
|
154 |
+
* @param string $filename Filename.
|
155 |
+
* @param array $args Arguments for the link/button.
|
156 |
* @return string
|
157 |
*/
|
158 |
public function get_restore_button( $filename, $args = array() ) {
|
167 |
if ( empty( $archive ) ) {
|
168 |
$button = '';
|
169 |
} else {
|
170 |
+
$button = sprintf(
|
171 |
+
'
|
172 |
<a
|
173 |
data-restore-now="1"
|
174 |
data-archive-key="%2$s"
|
admin/class-boldgrid-backup-admin-archive-browser.php
CHANGED
@@ -1,24 +1,29 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.2
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Archive_Browser {
|
21 |
-
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
@@ -45,7 +50,7 @@ class Boldgrid_Backup_Admin_Archive_Browser {
|
|
45 |
* Many of the ajax handlers in this method require the same
|
46 |
* current_user_can() and check_ajax_referer() checks.
|
47 |
*
|
48 |
-
* @since 1.
|
49 |
*/
|
50 |
public function authorize() {
|
51 |
if ( ! current_user_can( 'update_plugins' ) ) {
|
@@ -53,7 +58,7 @@ class Boldgrid_Backup_Admin_Archive_Browser {
|
|
53 |
}
|
54 |
|
55 |
if ( ! check_ajax_referer( 'boldgrid_backup_remote_storage_upload', 'security', false ) ) {
|
56 |
-
wp_send_json_error( __( 'Invalid nonce.', 'boldgrid-backup' ) );
|
57 |
}
|
58 |
}
|
59 |
|
@@ -63,7 +68,7 @@ class Boldgrid_Backup_Admin_Archive_Browser {
|
|
63 |
* When a user clicks to "View details" of a database dump, this
|
64 |
* method will create a table showing all the tables in that backup.
|
65 |
*
|
66 |
-
* @since 1.
|
67 |
*
|
68 |
* @param string $filepath Zip file.
|
69 |
* @param string $file Sql file name.
|
@@ -71,12 +76,13 @@ class Boldgrid_Backup_Admin_Archive_Browser {
|
|
71 |
*/
|
72 |
public function get_sql_details( $filepath, $file ) {
|
73 |
$tables_with_records = $this->core->db_dump->get_insert_count( $filepath, $file );
|
74 |
-
$prefixed_tables
|
75 |
|
76 |
-
$in_backup
|
77 |
$in_current = __( '# Records in current database', 'boldgrid-backup' );
|
78 |
|
79 |
-
$return = sprintf(
|
|
|
80 |
<table class="wp-list-table fixed striped widefat">
|
81 |
<thead>
|
82 |
<tr>
|
@@ -133,13 +139,12 @@ class Boldgrid_Backup_Admin_Archive_Browser {
|
|
133 |
|
134 |
$dump_file = $this->core->get_dump_file( $filepath );
|
135 |
|
136 |
-
|
|
|
|
|
|
|
|
|
137 |
$no_show = array(
|
138 |
-
/*
|
139 |
-
* If this is our database dump file, skip over it. We have another
|
140 |
-
* section of the archive details page that will help with restoring
|
141 |
-
* a dump file.
|
142 |
-
*/
|
143 |
basename( $dump_file ),
|
144 |
basename( $this->core->archive->log_filepath ),
|
145 |
);
|
@@ -150,7 +155,7 @@ class Boldgrid_Backup_Admin_Archive_Browser {
|
|
150 |
|
151 |
$contents = $zip->browse( $filepath, $dir );
|
152 |
|
153 |
-
$tr
|
154 |
$empty_directory = '<tr><td colspan="3">' . __( 'Empty directory', 'boldgrid-backup' ) . '</td></tr>';
|
155 |
|
156 |
$table = sprintf(
|
@@ -200,7 +205,7 @@ class Boldgrid_Backup_Admin_Archive_Browser {
|
|
200 |
|
201 |
$filename = ! empty( $_POST['filename'] ) ? sanitize_file_name( $_POST['filename'] ) : false;
|
202 |
$filepath = $this->core->backup_dir->get_path_to( $filename );
|
203 |
-
$file
|
204 |
if ( empty( $filepath ) || empty( $file ) ) {
|
205 |
wp_send_json_error( __( 'Invalid file / filepath.', 'boldgrid-backup' ) );
|
206 |
}
|
@@ -227,28 +232,30 @@ class Boldgrid_Backup_Admin_Archive_Browser {
|
|
227 |
* This handles an ajax call for restoring a dump from the archive details
|
228 |
* page.
|
229 |
*
|
230 |
-
* @since 1.
|
231 |
*/
|
232 |
public function wp_ajax_restore_db() {
|
233 |
$this->authorize();
|
234 |
|
235 |
$filename = ! empty( $_POST['filename'] ) ? sanitize_file_name( $_POST['filename'] ) : false;
|
236 |
$filepath = $this->core->backup_dir->get_path_to( $filename );
|
237 |
-
$file
|
238 |
if ( empty( $filepath ) || empty( $file ) ) {
|
239 |
wp_send_json_error( __( 'Invalid file / filepath.', 'boldgrid-backup' ) );
|
240 |
}
|
241 |
|
242 |
$importer = new Boldgrid_Backup_Admin_Db_Import( $this->core );
|
243 |
-
$success
|
244 |
|
245 |
if ( ! $success ) {
|
246 |
$this->core->notice->add_user_notice(
|
|
|
247 |
sprintf( __( 'Error, unable to import database %1$s from %2$s.', 'boldgrid-backup' ), $file, $filepath ),
|
248 |
$this->core->notice->lang['dis_error']
|
249 |
);
|
250 |
} else {
|
251 |
$this->core->notice->add_user_notice(
|
|
|
252 |
sprintf( __( 'Success! Database %1$s imported from %2$s.', 'boldgrid-backup' ), $file, $filepath ),
|
253 |
$this->core->notice->lang['dis_success']
|
254 |
);
|
@@ -261,14 +268,14 @@ class Boldgrid_Backup_Admin_Archive_Browser {
|
|
261 |
* This method handles the ajax call of "View details" for a database on the
|
262 |
* archive details page.
|
263 |
*
|
264 |
-
* @since 1.
|
265 |
*/
|
266 |
public function wp_ajax_view_db() {
|
267 |
$this->authorize();
|
268 |
|
269 |
$filename = ! empty( $_POST['filename'] ) ? sanitize_file_name( $_POST['filename'] ) : false;
|
270 |
$filepath = $this->core->backup_dir->get_path_to( $filename );
|
271 |
-
$file
|
272 |
if ( empty( $filename ) || empty( $filepath ) || empty( $file ) ) {
|
273 |
wp_send_json_error( __( 'Invalid file / filepath.', 'boldgrid-backup' ) );
|
274 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-archive-browser.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.5.2
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
+
*/
|
14 |
+
|
15 |
+
/*
|
16 |
+
* AJAX callback functions in this class have their nonce verified by authorize() in this class.
|
17 |
+
*
|
18 |
+
* phpcs:disable WordPress.VIP, WordPress.CSRF.NonceVerification.NoNonceVerification, WordPress.Security.NonceVerification.NoNonceVerification
|
19 |
*/
|
20 |
|
21 |
/**
|
22 |
+
* Class: Boldgrid_Backup_Admin_Archive_Browser
|
23 |
*
|
24 |
* @since 1.5.2
|
25 |
*/
|
26 |
class Boldgrid_Backup_Admin_Archive_Browser {
|
|
|
27 |
/**
|
28 |
* The core class object.
|
29 |
*
|
50 |
* Many of the ajax handlers in this method require the same
|
51 |
* current_user_can() and check_ajax_referer() checks.
|
52 |
*
|
53 |
+
* @since 1.6.0
|
54 |
*/
|
55 |
public function authorize() {
|
56 |
if ( ! current_user_can( 'update_plugins' ) ) {
|
58 |
}
|
59 |
|
60 |
if ( ! check_ajax_referer( 'boldgrid_backup_remote_storage_upload', 'security', false ) ) {
|
61 |
+
wp_send_json_error( __( 'Invalid nonce; security check failed.', 'boldgrid-backup' ) );
|
62 |
}
|
63 |
}
|
64 |
|
68 |
* When a user clicks to "View details" of a database dump, this
|
69 |
* method will create a table showing all the tables in that backup.
|
70 |
*
|
71 |
+
* @since 1.6.0
|
72 |
*
|
73 |
* @param string $filepath Zip file.
|
74 |
* @param string $file Sql file name.
|
76 |
*/
|
77 |
public function get_sql_details( $filepath, $file ) {
|
78 |
$tables_with_records = $this->core->db_dump->get_insert_count( $filepath, $file );
|
79 |
+
$prefixed_tables = $this->core->db_get->prefixed_count();
|
80 |
|
81 |
+
$in_backup = __( '# Records in this backup', 'boldgrid-backup' );
|
82 |
$in_current = __( '# Records in current database', 'boldgrid-backup' );
|
83 |
|
84 |
+
$return = sprintf(
|
85 |
+
'
|
86 |
<table class="wp-list-table fixed striped widefat">
|
87 |
<thead>
|
88 |
<tr>
|
139 |
|
140 |
$dump_file = $this->core->get_dump_file( $filepath );
|
141 |
|
142 |
+
/*
|
143 |
+
* An array of files not to show in the archive browser.
|
144 |
+
* If this is our database dump file, skip over it. We have another section of the archive
|
145 |
+
* details page that will help with restoring a dump file.
|
146 |
+
*/
|
147 |
$no_show = array(
|
|
|
|
|
|
|
|
|
|
|
148 |
basename( $dump_file ),
|
149 |
basename( $this->core->archive->log_filepath ),
|
150 |
);
|
155 |
|
156 |
$contents = $zip->browse( $filepath, $dir );
|
157 |
|
158 |
+
$tr = '';
|
159 |
$empty_directory = '<tr><td colspan="3">' . __( 'Empty directory', 'boldgrid-backup' ) . '</td></tr>';
|
160 |
|
161 |
$table = sprintf(
|
205 |
|
206 |
$filename = ! empty( $_POST['filename'] ) ? sanitize_file_name( $_POST['filename'] ) : false;
|
207 |
$filepath = $this->core->backup_dir->get_path_to( $filename );
|
208 |
+
$file = ! empty( $_POST['file'] ) ? trim( strip_tags( $_POST['file'] ) ) : false;
|
209 |
if ( empty( $filepath ) || empty( $file ) ) {
|
210 |
wp_send_json_error( __( 'Invalid file / filepath.', 'boldgrid-backup' ) );
|
211 |
}
|
232 |
* This handles an ajax call for restoring a dump from the archive details
|
233 |
* page.
|
234 |
*
|
235 |
+
* @since 1.6.0
|
236 |
*/
|
237 |
public function wp_ajax_restore_db() {
|
238 |
$this->authorize();
|
239 |
|
240 |
$filename = ! empty( $_POST['filename'] ) ? sanitize_file_name( $_POST['filename'] ) : false;
|
241 |
$filepath = $this->core->backup_dir->get_path_to( $filename );
|
242 |
+
$file = ! empty( $_POST['file'] ) ? trim( strip_tags( $_POST['file'] ) ) : false;
|
243 |
if ( empty( $filepath ) || empty( $file ) ) {
|
244 |
wp_send_json_error( __( 'Invalid file / filepath.', 'boldgrid-backup' ) );
|
245 |
}
|
246 |
|
247 |
$importer = new Boldgrid_Backup_Admin_Db_Import( $this->core );
|
248 |
+
$success = $importer->import_from_archive( $filepath, $file );
|
249 |
|
250 |
if ( ! $success ) {
|
251 |
$this->core->notice->add_user_notice(
|
252 |
+
// translators: 1: Filename 2: File path.
|
253 |
sprintf( __( 'Error, unable to import database %1$s from %2$s.', 'boldgrid-backup' ), $file, $filepath ),
|
254 |
$this->core->notice->lang['dis_error']
|
255 |
);
|
256 |
} else {
|
257 |
$this->core->notice->add_user_notice(
|
258 |
+
// translators: 1: Filename 2: File path.
|
259 |
sprintf( __( 'Success! Database %1$s imported from %2$s.', 'boldgrid-backup' ), $file, $filepath ),
|
260 |
$this->core->notice->lang['dis_success']
|
261 |
);
|
268 |
* This method handles the ajax call of "View details" for a database on the
|
269 |
* archive details page.
|
270 |
*
|
271 |
+
* @since 1.6.0
|
272 |
*/
|
273 |
public function wp_ajax_view_db() {
|
274 |
$this->authorize();
|
275 |
|
276 |
$filename = ! empty( $_POST['filename'] ) ? sanitize_file_name( $_POST['filename'] ) : false;
|
277 |
$filepath = $this->core->backup_dir->get_path_to( $filename );
|
278 |
+
$file = ! empty( $_POST['file'] ) ? trim( strip_tags( $_POST['file'] ) ) : false;
|
279 |
if ( empty( $filename ) || empty( $filepath ) || empty( $file ) ) {
|
280 |
wp_send_json_error( __( 'Invalid file / filepath.', 'boldgrid-backup' ) );
|
281 |
}
|
admin/class-boldgrid-backup-admin-archive-details.php
CHANGED
@@ -1,24 +1,25 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
|
|
|
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Archive_Details {
|
21 |
-
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
@@ -31,7 +32,7 @@ class Boldgrid_Backup_Admin_Archive_Details {
|
|
31 |
/**
|
32 |
* An array of remote storage locations.
|
33 |
*
|
34 |
-
* @since
|
35 |
* @access public
|
36 |
* @var array
|
37 |
*/
|
@@ -53,7 +54,7 @@ class Boldgrid_Backup_Admin_Archive_Details {
|
|
53 |
*
|
54 |
* @since 1.6.0
|
55 |
*
|
56 |
-
* @param string $filename
|
57 |
* @return string
|
58 |
*/
|
59 |
public function get_url( $filename ) {
|
@@ -63,7 +64,7 @@ class Boldgrid_Backup_Admin_Archive_Details {
|
|
63 |
/**
|
64 |
* Enqueue scripts.
|
65 |
*
|
66 |
-
* @since 1.
|
67 |
*/
|
68 |
public function enqueue_scripts() {
|
69 |
wp_enqueue_style(
|
@@ -81,8 +82,8 @@ class Boldgrid_Backup_Admin_Archive_Details {
|
|
81 |
BOLDGRID_BACKUP_VERSION
|
82 |
);
|
83 |
$translations = array(
|
84 |
-
'uploading'
|
85 |
-
'uploaded'
|
86 |
'failUpload' => __( 'Unable to upload backup file.', 'boldgrid-backup' ),
|
87 |
);
|
88 |
wp_localize_script( 'boldgrid-backup-admin-archive-details', 'boldgrid_backup_archive_details', $translations );
|
@@ -95,13 +96,13 @@ class Boldgrid_Backup_Admin_Archive_Details {
|
|
95 |
BOLDGRID_BACKUP_VERSION
|
96 |
);
|
97 |
$unknown_error = __( 'An unknown error has occurred.', 'boldgrid-backup' );
|
98 |
-
$translations
|
99 |
-
'loading'
|
100 |
-
'home'
|
101 |
-
'restoring'
|
102 |
-
'confirmDbRestore'
|
103 |
'unknownBrowseError' => __( 'An unknown error has occurred when trying to get a listing of the files in this archive.', 'boldgrid-backup' ),
|
104 |
-
'unknownError'
|
105 |
'unknownErrorNotice' => sprintf( '<div class="%1$s"><p>%2$s</p></div>', $this->core->notice->lang['dis_error'], $unknown_error ),
|
106 |
);
|
107 |
wp_localize_script( 'boldgrid-backup-admin-zip-browser', 'boldgrid_backup_zip_browser', $translations );
|
@@ -123,7 +124,7 @@ class Boldgrid_Backup_Admin_Archive_Details {
|
|
123 |
* @since 1.5.1
|
124 |
*/
|
125 |
public function render_archive() {
|
126 |
-
if ( ! empty( $_POST['delete_now'] ) ) {
|
127 |
$this->core->delete_archive_file();
|
128 |
}
|
129 |
|
@@ -132,19 +133,19 @@ class Boldgrid_Backup_Admin_Archive_Details {
|
|
132 |
|
133 |
$archive_found = false;
|
134 |
|
135 |
-
$filename = ! empty( $_GET['filename'] ) ? sanitize_file_name( $_GET['filename'] ) : false;
|
136 |
if ( ! $filename ) {
|
137 |
-
|
138 |
return;
|
139 |
}
|
140 |
|
141 |
// Get our archive.
|
142 |
$archive = $this->core->archive->get_by_name( $filename );
|
143 |
if ( $archive ) {
|
144 |
-
$log
|
145 |
-
$archive
|
146 |
$archive_found = true;
|
147 |
-
$dump_file
|
148 |
} else {
|
149 |
$archive = array(
|
150 |
'filename' => $filename,
|
@@ -168,7 +169,7 @@ class Boldgrid_Backup_Admin_Archive_Details {
|
|
168 |
* The nonce can be added to an ajax request's data via:
|
169 |
* 'security' : $( '#_wpnonce' ).val()
|
170 |
*
|
171 |
-
* @since 1.
|
172 |
*/
|
173 |
public function validate_nonce() {
|
174 |
return check_ajax_referer( 'boldgrid_backup_remote_storage_upload', 'security', false );
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-archive-details.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
// phpcs:disable WordPress.VIP
|
16 |
+
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Archive_Details
|
19 |
*
|
20 |
* @since 1.5.1
|
21 |
*/
|
22 |
class Boldgrid_Backup_Admin_Archive_Details {
|
|
|
23 |
/**
|
24 |
* The core class object.
|
25 |
*
|
32 |
/**
|
33 |
* An array of remote storage locations.
|
34 |
*
|
35 |
+
* @since 1.6.0
|
36 |
* @access public
|
37 |
* @var array
|
38 |
*/
|
54 |
*
|
55 |
* @since 1.6.0
|
56 |
*
|
57 |
+
* @param string $filename Filename.
|
58 |
* @return string
|
59 |
*/
|
60 |
public function get_url( $filename ) {
|
64 |
/**
|
65 |
* Enqueue scripts.
|
66 |
*
|
67 |
+
* @since 1.6.0
|
68 |
*/
|
69 |
public function enqueue_scripts() {
|
70 |
wp_enqueue_style(
|
82 |
BOLDGRID_BACKUP_VERSION
|
83 |
);
|
84 |
$translations = array(
|
85 |
+
'uploading' => __( 'Uploading', 'boldgrid-backup' ),
|
86 |
+
'uploaded' => __( 'Uploaded', 'boldgrid-backup' ),
|
87 |
'failUpload' => __( 'Unable to upload backup file.', 'boldgrid-backup' ),
|
88 |
);
|
89 |
wp_localize_script( 'boldgrid-backup-admin-archive-details', 'boldgrid_backup_archive_details', $translations );
|
96 |
BOLDGRID_BACKUP_VERSION
|
97 |
);
|
98 |
$unknown_error = __( 'An unknown error has occurred.', 'boldgrid-backup' );
|
99 |
+
$translations = array(
|
100 |
+
'loading' => __( 'Loading', 'boldgrid-backup' ),
|
101 |
+
'home' => __( 'Home', 'boldgrid-backup' ),
|
102 |
+
'restoring' => __( 'Restoring', 'boldgrid-backup' ),
|
103 |
+
'confirmDbRestore' => __( 'Are you sure you want to restore this database backup?', 'boldgrid-backup' ),
|
104 |
'unknownBrowseError' => __( 'An unknown error has occurred when trying to get a listing of the files in this archive.', 'boldgrid-backup' ),
|
105 |
+
'unknownError' => $unknown_error,
|
106 |
'unknownErrorNotice' => sprintf( '<div class="%1$s"><p>%2$s</p></div>', $this->core->notice->lang['dis_error'], $unknown_error ),
|
107 |
);
|
108 |
wp_localize_script( 'boldgrid-backup-admin-zip-browser', 'boldgrid_backup_zip_browser', $translations );
|
124 |
* @since 1.5.1
|
125 |
*/
|
126 |
public function render_archive() {
|
127 |
+
if ( ! empty( $_POST['delete_now'] ) ) { // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
128 |
$this->core->delete_archive_file();
|
129 |
}
|
130 |
|
133 |
|
134 |
$archive_found = false;
|
135 |
|
136 |
+
$filename = ! empty( $_GET['filename'] ) ? sanitize_file_name( $_GET['filename'] ) : false; // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
137 |
if ( ! $filename ) {
|
138 |
+
esc_html_e( 'No archive specified.', 'boldgrid-backup' );
|
139 |
return;
|
140 |
}
|
141 |
|
142 |
// Get our archive.
|
143 |
$archive = $this->core->archive->get_by_name( $filename );
|
144 |
if ( $archive ) {
|
145 |
+
$log = $this->core->archive_log->get_by_zip( $archive['filepath'] );
|
146 |
+
$archive = array_merge( $log, $archive );
|
147 |
$archive_found = true;
|
148 |
+
$dump_file = $this->core->get_dump_file( $archive['filepath'] );
|
149 |
} else {
|
150 |
$archive = array(
|
151 |
'filename' => $filename,
|
169 |
* The nonce can be added to an ajax request's data via:
|
170 |
* 'security' : $( '#_wpnonce' ).val()
|
171 |
*
|
172 |
+
* @since 1.6.0
|
173 |
*/
|
174 |
public function validate_nonce() {
|
175 |
return check_ajax_referer( 'boldgrid_backup_remote_storage_upload', 'security', false );
|
admin/class-boldgrid-backup-admin-archive-fail.php
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
@@ -40,7 +40,7 @@ class Boldgrid_Backup_Admin_Archive_Fail {
|
|
40 |
/**
|
41 |
* Generic lang string stating unable to backup.
|
42 |
*
|
43 |
-
* @since
|
44 |
* @access public
|
45 |
* @var string
|
46 |
*/
|
@@ -85,7 +85,7 @@ class Boldgrid_Backup_Admin_Archive_Fail {
|
|
85 |
* # NO .10 MB shutdown function fails early on when calling
|
86 |
* error_get_last().
|
87 |
*/
|
88 |
-
$mb
|
89 |
$this->memory = str_repeat( '0', ( 0.35 * $mb ) );
|
90 |
}
|
91 |
|
@@ -105,7 +105,7 @@ class Boldgrid_Backup_Admin_Archive_Fail {
|
|
105 |
/**
|
106 |
* Create a "backup failed" email and schedule it to be sent via jobs.
|
107 |
*
|
108 |
-
* @since 1.
|
109 |
*
|
110 |
* @param string $message Error message.
|
111 |
*/
|
@@ -118,8 +118,8 @@ class Boldgrid_Backup_Admin_Archive_Fail {
|
|
118 |
$email_body = $this->core->email->fill_generic_template( $message, false );
|
119 |
|
120 |
$args = array(
|
121 |
-
'action'
|
122 |
-
'action_data'
|
123 |
'message' => $email_body,
|
124 |
),
|
125 |
'action_title' => __( 'Send warning email because backup failed', 'boldgrid-backup' ),
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-archive-fail.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.5.2
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_Archive_Fail
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
40 |
/**
|
41 |
* Generic lang string stating unable to backup.
|
42 |
*
|
43 |
+
* @since 1.6.0
|
44 |
* @access public
|
45 |
* @var string
|
46 |
*/
|
85 |
* # NO .10 MB shutdown function fails early on when calling
|
86 |
* error_get_last().
|
87 |
*/
|
88 |
+
$mb = 1000000;
|
89 |
$this->memory = str_repeat( '0', ( 0.35 * $mb ) );
|
90 |
}
|
91 |
|
105 |
/**
|
106 |
* Create a "backup failed" email and schedule it to be sent via jobs.
|
107 |
*
|
108 |
+
* @since 1.6.0
|
109 |
*
|
110 |
* @param string $message Error message.
|
111 |
*/
|
118 |
$email_body = $this->core->email->fill_generic_template( $message, false );
|
119 |
|
120 |
$args = array(
|
121 |
+
'action' => 'boldgrid_backup_cron_fail_email',
|
122 |
+
'action_data' => array(
|
123 |
'message' => $email_body,
|
124 |
),
|
125 |
'action_title' => __( 'Send warning email because backup failed', 'boldgrid-backup' ),
|
admin/class-boldgrid-backup-admin-archive-log.php
CHANGED
@@ -1,24 +1,23 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Archive_Log {
|
21 |
-
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
@@ -44,7 +43,7 @@ class Boldgrid_Backup_Admin_Archive_Log {
|
|
44 |
*
|
45 |
* @since 1.5.1
|
46 |
*
|
47 |
-
* @param string $zip_filepath
|
48 |
* @return bool
|
49 |
*/
|
50 |
public function delete_by_zip( $zip_filepath ) {
|
@@ -63,7 +62,7 @@ class Boldgrid_Backup_Admin_Archive_Log {
|
|
63 |
*
|
64 |
* @since 1.5.1
|
65 |
*
|
66 |
-
* @param string $zip_filepath
|
67 |
* @return array
|
68 |
*/
|
69 |
public function get_by_zip( $zip_filepath ) {
|
@@ -89,7 +88,7 @@ class Boldgrid_Backup_Admin_Archive_Log {
|
|
89 |
*
|
90 |
* @since 1.5.1
|
91 |
*
|
92 |
-
* @param string $zip_filepath
|
93 |
* @return bool
|
94 |
*/
|
95 |
public function path_from_zip( $zip_filepath ) {
|
@@ -103,11 +102,11 @@ class Boldgrid_Backup_Admin_Archive_Log {
|
|
103 |
*
|
104 |
* @since 1.6.0
|
105 |
*
|
106 |
-
* @param array $info
|
107 |
*/
|
108 |
public function post_restore( $info ) {
|
109 |
$path_backup_dir = $this->path_from_zip( $info['filepath'] );
|
110 |
-
$path_abspath
|
111 |
|
112 |
// If this backup did not restore a log file to ABSPATH, then we can abort.
|
113 |
if ( ! $this->core->wp_filesystem->exists( $path_abspath ) ) {
|
@@ -128,9 +127,9 @@ class Boldgrid_Backup_Admin_Archive_Log {
|
|
128 |
* extract backup.log from backup.zip if it exists. This was, we have all
|
129 |
* of the meta data about the backup.
|
130 |
*
|
131 |
-
* @since 1.
|
132 |
*
|
133 |
-
* @param string $filepath
|
134 |
*/
|
135 |
public function restore_by_zip( $filepath ) {
|
136 |
$log_filepath = $this->path_from_zip( $filepath );
|
@@ -141,7 +140,7 @@ class Boldgrid_Backup_Admin_Archive_Log {
|
|
141 |
}
|
142 |
|
143 |
// Extract the log file to ABSPATH.
|
144 |
-
$zip
|
145 |
$status = $zip->extract_one( $filepath, $log_filename );
|
146 |
if ( ! $status ) {
|
147 |
return false;
|
@@ -158,7 +157,7 @@ class Boldgrid_Backup_Admin_Archive_Log {
|
|
158 |
*
|
159 |
* @since 1.5.1
|
160 |
*
|
161 |
-
* @param $info
|
162 |
* @return bool
|
163 |
*/
|
164 |
public function write( $info ) {
|
@@ -173,7 +172,7 @@ class Boldgrid_Backup_Admin_Archive_Log {
|
|
173 |
return false;
|
174 |
}
|
175 |
|
176 |
-
$written = $this->core->wp_filesystem->put_contents( $log_filepath,
|
177 |
if ( ! $written ) {
|
178 |
return false;
|
179 |
}
|
@@ -183,6 +182,7 @@ class Boldgrid_Backup_Admin_Archive_Log {
|
|
183 |
if ( 0 === $archive ) {
|
184 |
return false;
|
185 |
}
|
|
|
186 |
/*
|
187 |
* The log file is being added to the root of the archive. If the user
|
188 |
* restores the archive, the log will be restored to the ABSPATH. The
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-archive-log.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_Archive_Log
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Archive_Log {
|
|
|
21 |
/**
|
22 |
* The core class object.
|
23 |
*
|
43 |
*
|
44 |
* @since 1.5.1
|
45 |
*
|
46 |
+
* @param string $zip_filepath Archive file path.
|
47 |
* @return bool
|
48 |
*/
|
49 |
public function delete_by_zip( $zip_filepath ) {
|
62 |
*
|
63 |
* @since 1.5.1
|
64 |
*
|
65 |
+
* @param string $zip_filepath Archive file path.
|
66 |
* @return array
|
67 |
*/
|
68 |
public function get_by_zip( $zip_filepath ) {
|
88 |
*
|
89 |
* @since 1.5.1
|
90 |
*
|
91 |
+
* @param string $zip_filepath Archive file path.
|
92 |
* @return bool
|
93 |
*/
|
94 |
public function path_from_zip( $zip_filepath ) {
|
102 |
*
|
103 |
* @since 1.6.0
|
104 |
*
|
105 |
+
* @param array $info Archive information.
|
106 |
*/
|
107 |
public function post_restore( $info ) {
|
108 |
$path_backup_dir = $this->path_from_zip( $info['filepath'] );
|
109 |
+
$path_abspath = ABSPATH . basename( $path_backup_dir );
|
110 |
|
111 |
// If this backup did not restore a log file to ABSPATH, then we can abort.
|
112 |
if ( ! $this->core->wp_filesystem->exists( $path_abspath ) ) {
|
127 |
* extract backup.log from backup.zip if it exists. This was, we have all
|
128 |
* of the meta data about the backup.
|
129 |
*
|
130 |
+
* @since 1.6.0
|
131 |
*
|
132 |
+
* @param string $filepath Archive file path.
|
133 |
*/
|
134 |
public function restore_by_zip( $filepath ) {
|
135 |
$log_filepath = $this->path_from_zip( $filepath );
|
140 |
}
|
141 |
|
142 |
// Extract the log file to ABSPATH.
|
143 |
+
$zip = new Boldgrid_Backup_Admin_Compressor_Pcl_Zip( $this->core );
|
144 |
$status = $zip->extract_one( $filepath, $log_filename );
|
145 |
if ( ! $status ) {
|
146 |
return false;
|
157 |
*
|
158 |
* @since 1.5.1
|
159 |
*
|
160 |
+
* @param array $info Archive information.
|
161 |
* @return bool
|
162 |
*/
|
163 |
public function write( $info ) {
|
172 |
return false;
|
173 |
}
|
174 |
|
175 |
+
$written = $this->core->wp_filesystem->put_contents( $log_filepath, wp_json_encode( $info ) );
|
176 |
if ( ! $written ) {
|
177 |
return false;
|
178 |
}
|
182 |
if ( 0 === $archive ) {
|
183 |
return false;
|
184 |
}
|
185 |
+
|
186 |
/*
|
187 |
* The log file is being added to the root of the archive. If the user
|
188 |
* restores the archive, the log will be restored to the ABSPATH. The
|
admin/class-boldgrid-backup-admin-archive.php
CHANGED
@@ -1,24 +1,23 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.3
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Archive {
|
21 |
-
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
@@ -127,9 +126,9 @@ class Boldgrid_Backup_Admin_Archive {
|
|
127 |
*
|
128 |
* Please see @return for more information on what an archive actually is.
|
129 |
*
|
130 |
-
* @since 1.
|
131 |
*
|
132 |
-
* @param string $filename
|
133 |
* @return array {
|
134 |
* Details about an archive.
|
135 |
*
|
@@ -188,7 +187,7 @@ class Boldgrid_Backup_Admin_Archive {
|
|
188 |
*
|
189 |
* @since 1.6.0
|
190 |
*
|
191 |
-
* @param string $filepath
|
192 |
*/
|
193 |
public function init( $filepath ) {
|
194 |
|
@@ -237,7 +236,7 @@ class Boldgrid_Backup_Admin_Archive {
|
|
237 |
*
|
238 |
* @since 1.5.3
|
239 |
*
|
240 |
-
* @param string $filepath
|
241 |
* @return bool
|
242 |
*/
|
243 |
public function is_archive( $filepath ) {
|
@@ -264,7 +263,7 @@ class Boldgrid_Backup_Admin_Archive {
|
|
264 |
*
|
265 |
* @since 1.6.0
|
266 |
*
|
267 |
-
* @param string $filename
|
268 |
* @return bool
|
269 |
*/
|
270 |
public function is_site_archive( $filename ) {
|
@@ -330,12 +329,12 @@ class Boldgrid_Backup_Admin_Archive {
|
|
330 |
* @since 1.6.0
|
331 |
*/
|
332 |
public function reset() {
|
333 |
-
$this->filename
|
334 |
-
$this->filepath
|
335 |
$this->log_filepath = null;
|
336 |
$this->log_filename = null;
|
337 |
-
$this->log
|
338 |
-
$this->compressor
|
339 |
}
|
340 |
|
341 |
/**
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-archive.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.5.3
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_Archive
|
17 |
*
|
18 |
* @since 1.5.3
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Archive {
|
|
|
21 |
/**
|
22 |
* The core class object.
|
23 |
*
|
126 |
*
|
127 |
* Please see @return for more information on what an archive actually is.
|
128 |
*
|
129 |
+
* @since 1.6.0
|
130 |
*
|
131 |
+
* @param string $filename Filename.
|
132 |
* @return array {
|
133 |
* Details about an archive.
|
134 |
*
|
187 |
*
|
188 |
* @since 1.6.0
|
189 |
*
|
190 |
+
* @param string $filepath File path.
|
191 |
*/
|
192 |
public function init( $filepath ) {
|
193 |
|
236 |
*
|
237 |
* @since 1.5.3
|
238 |
*
|
239 |
+
* @param string $filepath File path.
|
240 |
* @return bool
|
241 |
*/
|
242 |
public function is_archive( $filepath ) {
|
263 |
*
|
264 |
* @since 1.6.0
|
265 |
*
|
266 |
+
* @param string $filename Filename.
|
267 |
* @return bool
|
268 |
*/
|
269 |
public function is_site_archive( $filename ) {
|
329 |
* @since 1.6.0
|
330 |
*/
|
331 |
public function reset() {
|
332 |
+
$this->filename = null;
|
333 |
+
$this->filepath = null;
|
334 |
$this->log_filepath = null;
|
335 |
$this->log_filename = null;
|
336 |
+
$this->log = array();
|
337 |
+
$this->compressor = null;
|
338 |
}
|
339 |
|
340 |
/**
|
admin/class-boldgrid-backup-admin-archives-all.php
CHANGED
@@ -1,28 +1,27 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
-
* @since 1.
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Archives_All {
|
21 |
-
|
22 |
/**
|
23 |
* An array of all archives.
|
24 |
*
|
25 |
-
* @since
|
26 |
* @access public
|
27 |
* @var array
|
28 |
*/
|
@@ -31,7 +30,7 @@ class Boldgrid_Backup_Admin_Archives_All {
|
|
31 |
/**
|
32 |
* The core class object.
|
33 |
*
|
34 |
-
* @since
|
35 |
* @access private
|
36 |
* @var Boldgrid_Backup_Admin_Core
|
37 |
*/
|
@@ -40,7 +39,7 @@ class Boldgrid_Backup_Admin_Archives_All {
|
|
40 |
/**
|
41 |
* Whether or not we have initialized all backups.
|
42 |
*
|
43 |
-
* @since
|
44 |
* @access public
|
45 |
* @var bool
|
46 |
*/
|
@@ -49,7 +48,7 @@ class Boldgrid_Backup_Admin_Archives_All {
|
|
49 |
/**
|
50 |
* Local server title, such as "Web server".
|
51 |
*
|
52 |
-
* @since
|
53 |
* @access public
|
54 |
* @var string
|
55 |
*/
|
@@ -58,7 +57,7 @@ class Boldgrid_Backup_Admin_Archives_All {
|
|
58 |
/**
|
59 |
* An array of data about remote locations and how many backups at each.
|
60 |
*
|
61 |
-
* @since
|
62 |
* @access public
|
63 |
* @var array
|
64 |
*/
|
@@ -91,7 +90,7 @@ class Boldgrid_Backup_Admin_Archives_All {
|
|
91 |
/**
|
92 |
* Constructor.
|
93 |
*
|
94 |
-
* @since 1.
|
95 |
*
|
96 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
97 |
*/
|
@@ -104,9 +103,9 @@ class Boldgrid_Backup_Admin_Archives_All {
|
|
104 |
/**
|
105 |
* Add a backup to the list of all backups.
|
106 |
*
|
107 |
-
* @since 1.
|
108 |
*
|
109 |
-
* @param array $backup
|
110 |
*/
|
111 |
public function add( $backup ) {
|
112 |
$in_all = false;
|
@@ -121,7 +120,7 @@ class Boldgrid_Backup_Admin_Archives_All {
|
|
121 |
if ( $backup['filename'] === $all_backup['filename'] ) {
|
122 |
|
123 |
// Once we found our backup, flag that we found it.
|
124 |
-
$in_all
|
125 |
$all_backup['locations'][] = $backup['locations'][0];
|
126 |
}
|
127 |
}
|
@@ -137,8 +136,8 @@ class Boldgrid_Backup_Admin_Archives_All {
|
|
137 |
*
|
138 |
* @since 1.6.0
|
139 |
*
|
140 |
-
* @param array $archive
|
141 |
-
* @param string $location_type
|
142 |
* @return bool
|
143 |
*/
|
144 |
public function has_location_type( $archive, $location_type ) {
|
@@ -154,7 +153,7 @@ class Boldgrid_Backup_Admin_Archives_All {
|
|
154 |
/**
|
155 |
* Init the $location_count property.
|
156 |
*
|
157 |
-
* @since 1.
|
158 |
*/
|
159 |
public function init_location_count() {
|
160 |
|
@@ -183,7 +182,7 @@ class Boldgrid_Backup_Admin_Archives_All {
|
|
183 |
/**
|
184 |
* Init and get a list of all backups (local and remote).
|
185 |
*
|
186 |
-
* @since 1.
|
187 |
*/
|
188 |
public function init() {
|
189 |
if ( $this->is_init ) {
|
@@ -194,12 +193,12 @@ class Boldgrid_Backup_Admin_Archives_All {
|
|
194 |
|
195 |
foreach ( $archives as $archive ) {
|
196 |
$this->all[] = array(
|
197 |
-
'filename'
|
198 |
'last_modified' => $archive['lastmodunix'],
|
199 |
-
'size'
|
200 |
-
'locations'
|
201 |
array(
|
202 |
-
'title'
|
203 |
'on_web_server' => true,
|
204 |
),
|
205 |
),
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-archives-all.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.6.0
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_Archives_All
|
17 |
*
|
18 |
+
* @since 1.6.0
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Archives_All {
|
|
|
21 |
/**
|
22 |
* An array of all archives.
|
23 |
*
|
24 |
+
* @since 1.6.0
|
25 |
* @access public
|
26 |
* @var array
|
27 |
*/
|
30 |
/**
|
31 |
* The core class object.
|
32 |
*
|
33 |
+
* @since 1.6.0
|
34 |
* @access private
|
35 |
* @var Boldgrid_Backup_Admin_Core
|
36 |
*/
|
39 |
/**
|
40 |
* Whether or not we have initialized all backups.
|
41 |
*
|
42 |
+
* @since 1.6.0
|
43 |
* @access public
|
44 |
* @var bool
|
45 |
*/
|
48 |
/**
|
49 |
* Local server title, such as "Web server".
|
50 |
*
|
51 |
+
* @since 1.6.0
|
52 |
* @access public
|
53 |
* @var string
|
54 |
*/
|
57 |
/**
|
58 |
* An array of data about remote locations and how many backups at each.
|
59 |
*
|
60 |
+
* @since 1.6.0
|
61 |
* @access public
|
62 |
* @var array
|
63 |
*/
|
90 |
/**
|
91 |
* Constructor.
|
92 |
*
|
93 |
+
* @since 1.6.0
|
94 |
*
|
95 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
96 |
*/
|
103 |
/**
|
104 |
* Add a backup to the list of all backups.
|
105 |
*
|
106 |
+
* @since 1.6.0
|
107 |
*
|
108 |
+
* @param array $backup Backup archive information.
|
109 |
*/
|
110 |
public function add( $backup ) {
|
111 |
$in_all = false;
|
120 |
if ( $backup['filename'] === $all_backup['filename'] ) {
|
121 |
|
122 |
// Once we found our backup, flag that we found it.
|
123 |
+
$in_all = true;
|
124 |
$all_backup['locations'][] = $backup['locations'][0];
|
125 |
}
|
126 |
}
|
136 |
*
|
137 |
* @since 1.6.0
|
138 |
*
|
139 |
+
* @param array $archive Archive information.
|
140 |
+
* @param string $location_type Location type.
|
141 |
* @return bool
|
142 |
*/
|
143 |
public function has_location_type( $archive, $location_type ) {
|
153 |
/**
|
154 |
* Init the $location_count property.
|
155 |
*
|
156 |
+
* @since 1.6.0
|
157 |
*/
|
158 |
public function init_location_count() {
|
159 |
|
182 |
/**
|
183 |
* Init and get a list of all backups (local and remote).
|
184 |
*
|
185 |
+
* @since 1.6.0
|
186 |
*/
|
187 |
public function init() {
|
188 |
if ( $this->is_init ) {
|
193 |
|
194 |
foreach ( $archives as $archive ) {
|
195 |
$this->all[] = array(
|
196 |
+
'filename' => $archive['filename'],
|
197 |
'last_modified' => $archive['lastmodunix'],
|
198 |
+
'size' => $archive['filesize'],
|
199 |
+
'locations' => array(
|
200 |
array(
|
201 |
+
'title' => $this->local_title,
|
202 |
'on_web_server' => true,
|
203 |
),
|
204 |
),
|
admin/class-boldgrid-backup-admin-archives.php
CHANGED
@@ -1,28 +1,27 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
* @copyright BoldGrid.com
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
-
* @since 1.
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Archives {
|
21 |
-
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
25 |
-
* @since
|
26 |
* @access private
|
27 |
* @var Boldgrid_Backup_Admin_Core
|
28 |
*/
|
@@ -31,7 +30,7 @@ class Boldgrid_Backup_Admin_Archives {
|
|
31 |
/**
|
32 |
* Constructor.
|
33 |
*
|
34 |
-
* @since 1.
|
35 |
*
|
36 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
37 |
*/
|
@@ -44,7 +43,7 @@ class Boldgrid_Backup_Admin_Archives {
|
|
44 |
*
|
45 |
* @since 1.6.0
|
46 |
*
|
47 |
-
* @param $location
|
48 |
* A location.
|
49 |
*
|
50 |
* @type string $title Such as "Web Server".
|
@@ -67,7 +66,7 @@ class Boldgrid_Backup_Admin_Archives {
|
|
67 |
*
|
68 |
* @since 1.6.0
|
69 |
*
|
70 |
-
* @param string $type
|
71 |
* @return string
|
72 |
*/
|
73 |
public function get_location_type_title( $type ) {
|
@@ -90,6 +89,7 @@ class Boldgrid_Backup_Admin_Archives {
|
|
90 |
*
|
91 |
* @since 1.6.0
|
92 |
*
|
|
|
93 |
* @return string
|
94 |
*/
|
95 |
public function get_locations( $archive ) {
|
@@ -122,14 +122,14 @@ class Boldgrid_Backup_Admin_Archives {
|
|
122 |
* Returns a string such as:
|
123 |
* All (5) | Web Server (4) | Remote (2)
|
124 |
*
|
125 |
-
* @since 1.
|
126 |
*
|
127 |
* @return string
|
128 |
*/
|
129 |
public function get_mine_count() {
|
130 |
$this->core->archives_all->init();
|
131 |
|
132 |
-
// An array of locations, each array item simliar to: <a>All<a/> (5)
|
133 |
$locations = array();
|
134 |
|
135 |
foreach ( $this->core->archives_all->location_count as $location => $count ) {
|
@@ -139,7 +139,8 @@ class Boldgrid_Backup_Admin_Archives {
|
|
139 |
|
140 |
$title = $this->get_location_type_title( $location );
|
141 |
|
142 |
-
$locations[] = sprintf(
|
|
|
143 |
%3$s %1$s %4$s (%2$s)
|
144 |
',
|
145 |
/* 1 */ $title,
|
@@ -155,7 +156,8 @@ class Boldgrid_Backup_Admin_Archives {
|
|
155 |
$markup = '<p class="subsubsub">' . implode( ' | ', $locations ) . '</p>';
|
156 |
|
157 |
// Create help text to go along with help icon.
|
158 |
-
$markup .= sprintf(
|
|
|
159 |
<p class="help" data-id="mine-count">
|
160 |
%1$s
|
161 |
</p>',
|
@@ -170,18 +172,19 @@ class Boldgrid_Backup_Admin_Archives {
|
|
170 |
*
|
171 |
* This table is displayed on the Backup Archives page.
|
172 |
*
|
173 |
-
* @since 1.
|
174 |
*
|
175 |
* @return string
|
176 |
*/
|
177 |
public function get_table() {
|
178 |
$this->core->archives_all->init();
|
179 |
-
$backup
|
180 |
$view_details = __( 'View details', 'boldgrid-backup' );
|
181 |
|
182 |
$table = $this->get_mine_count();
|
183 |
|
184 |
-
$table .= sprintf(
|
|
|
185 |
<table class="wp-list-table widefat fixed striped pages">
|
186 |
<thead>
|
187 |
<td>%1$s</td>
|
@@ -198,7 +201,8 @@ class Boldgrid_Backup_Admin_Archives {
|
|
198 |
// dirlist -> lastmodunix -> mtime (last_modified in unix time).
|
199 |
$this->core->time->init( $archive['last_modified'], 'utc' );
|
200 |
|
201 |
-
$table .= sprintf(
|
|
|
202 |
<tr>
|
203 |
<td>
|
204 |
%2$s
|
@@ -228,7 +232,8 @@ class Boldgrid_Backup_Admin_Archives {
|
|
228 |
';
|
229 |
|
230 |
if ( empty( $this->core->archives_all->all ) ) {
|
231 |
-
$table = sprintf(
|
|
|
232 |
<p>%1$s</p>',
|
233 |
__( 'You currently do not have any backups.', 'boldgrid-backup' )
|
234 |
);
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-archives.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.6.0
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
* @copyright BoldGrid.com
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_Archives
|
17 |
*
|
18 |
+
* @since 1.6.0
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Archives {
|
|
|
21 |
/**
|
22 |
* The core class object.
|
23 |
*
|
24 |
+
* @since 1.6.0
|
25 |
* @access private
|
26 |
* @var Boldgrid_Backup_Admin_Core
|
27 |
*/
|
30 |
/**
|
31 |
* Constructor.
|
32 |
*
|
33 |
+
* @since 1.6.0
|
34 |
*
|
35 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
36 |
*/
|
43 |
*
|
44 |
* @since 1.6.0
|
45 |
*
|
46 |
+
* @param array $location {
|
47 |
* A location.
|
48 |
*
|
49 |
* @type string $title Such as "Web Server".
|
66 |
*
|
67 |
* @since 1.6.0
|
68 |
*
|
69 |
+
* @param string $type Location type.
|
70 |
* @return string
|
71 |
*/
|
72 |
public function get_location_type_title( $type ) {
|
89 |
*
|
90 |
* @since 1.6.0
|
91 |
*
|
92 |
+
* @param array $archive Archive information.
|
93 |
* @return string
|
94 |
*/
|
95 |
public function get_locations( $archive ) {
|
122 |
* Returns a string such as:
|
123 |
* All (5) | Web Server (4) | Remote (2)
|
124 |
*
|
125 |
+
* @since 1.6.0
|
126 |
*
|
127 |
* @return string
|
128 |
*/
|
129 |
public function get_mine_count() {
|
130 |
$this->core->archives_all->init();
|
131 |
|
132 |
+
// An array of locations, each array item simliar to: <a>All<a/> (5).
|
133 |
$locations = array();
|
134 |
|
135 |
foreach ( $this->core->archives_all->location_count as $location => $count ) {
|
139 |
|
140 |
$title = $this->get_location_type_title( $location );
|
141 |
|
142 |
+
$locations[] = sprintf(
|
143 |
+
'
|
144 |
%3$s %1$s %4$s (%2$s)
|
145 |
',
|
146 |
/* 1 */ $title,
|
156 |
$markup = '<p class="subsubsub">' . implode( ' | ', $locations ) . '</p>';
|
157 |
|
158 |
// Create help text to go along with help icon.
|
159 |
+
$markup .= sprintf(
|
160 |
+
'
|
161 |
<p class="help" data-id="mine-count">
|
162 |
%1$s
|
163 |
</p>',
|
172 |
*
|
173 |
* This table is displayed on the Backup Archives page.
|
174 |
*
|
175 |
+
* @since 1.6.0
|
176 |
*
|
177 |
* @return string
|
178 |
*/
|
179 |
public function get_table() {
|
180 |
$this->core->archives_all->init();
|
181 |
+
$backup = __( 'Backup', 'boldgrid-backup' );
|
182 |
$view_details = __( 'View details', 'boldgrid-backup' );
|
183 |
|
184 |
$table = $this->get_mine_count();
|
185 |
|
186 |
+
$table .= sprintf(
|
187 |
+
'
|
188 |
<table class="wp-list-table widefat fixed striped pages">
|
189 |
<thead>
|
190 |
<td>%1$s</td>
|
201 |
// dirlist -> lastmodunix -> mtime (last_modified in unix time).
|
202 |
$this->core->time->init( $archive['last_modified'], 'utc' );
|
203 |
|
204 |
+
$table .= sprintf(
|
205 |
+
'
|
206 |
<tr>
|
207 |
<td>
|
208 |
%2$s
|
232 |
';
|
233 |
|
234 |
if ( empty( $this->core->archives_all->all ) ) {
|
235 |
+
$table = sprintf(
|
236 |
+
'
|
237 |
<p>%1$s</p>',
|
238 |
__( 'You currently do not have any backups.', 'boldgrid-backup' )
|
239 |
);
|
admin/class-boldgrid-backup-admin-auto-rollback.php
CHANGED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.5.2
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
|
|
|
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* We hook into "the upgrader_process_complete" (run when the download process
|
19 |
* for a plugin install or update finishes). If the user has enabled auto
|
@@ -47,7 +49,6 @@
|
|
47 |
* @since 1.5.1
|
48 |
*/
|
49 |
class Boldgrid_Backup_Admin_Auto_Rollback {
|
50 |
-
|
51 |
/**
|
52 |
* The core class object.
|
53 |
*
|
@@ -116,13 +117,13 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
116 |
*
|
117 |
* @since 1.5.1
|
118 |
*
|
119 |
-
* @param Boldgrid_Backup_Admin_Core $core
|
120 |
*/
|
121 |
public function __construct( $core ) {
|
122 |
$this->core = $core;
|
123 |
|
124 |
$this->updating_core = 'update-core.php' === $this->core->pagenow &&
|
125 |
-
! empty( $_GET['action'] ) && 'do-core-upgrade' === $_GET['action'];
|
126 |
|
127 |
$this->on_update_page = in_array( $this->core->pagenow, $this->update_pages, true );
|
128 |
}
|
@@ -153,7 +154,7 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
153 |
return;
|
154 |
}
|
155 |
|
156 |
-
$archives
|
157 |
$archive_count = count( $archives );
|
158 |
|
159 |
// If there are no archives, then abort.
|
@@ -207,14 +208,14 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
207 |
false
|
208 |
);
|
209 |
|
210 |
-
$access_type
|
211 |
-
$archive_nonce
|
212 |
$localize_script_data = array(
|
213 |
-
'archiveNonce'
|
214 |
-
'accessType'
|
215 |
'updateProtectionActivated' => $this->core->elements['update_protection_activated'],
|
216 |
-
'backupCreated'
|
217 |
-
'errorText'
|
218 |
'There was an error processing your request. Please reload the page and try again.',
|
219 |
'boldgrid-backup'
|
220 |
),
|
@@ -251,9 +252,9 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
251 |
);
|
252 |
|
253 |
$translations = array(
|
254 |
-
'update_data'
|
255 |
-
'in_progress_notice'
|
256 |
-
'nonce'
|
257 |
'is_rollback_enabled' => $this->is_enabled(),
|
258 |
);
|
259 |
wp_localize_script( $handle, 'boldgridBackupCustomizer', $translations );
|
@@ -352,7 +353,7 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
352 |
$localize_script_data = array(
|
353 |
// Generally used as the title attr of a disable update button.
|
354 |
'backupInProgress' => __( 'Your website is currently being backed up. You can perform updates when the backup is complete.', 'boldgrid-backup' ),
|
355 |
-
'waitClass'
|
356 |
);
|
357 |
|
358 |
wp_localize_script( $handle, 'boldgrid_backup_admin_update_selectors', $localize_script_data );
|
@@ -373,14 +374,13 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
373 |
* @return null
|
374 |
*/
|
375 |
public function notice_countdown_show() {
|
376 |
-
|
377 |
// Process GET / POST info.
|
378 |
-
$action
|
379 |
-
$restore_now = ! empty( $_POST['restore_now'] );
|
380 |
|
381 |
$pending_rollback = get_site_option( 'boldgrid_backup_pending_rollback' );
|
382 |
-
$deadline
|
383 |
-
$deadline_passed
|
384 |
|
385 |
if ( $this->on_update_page ) {
|
386 |
$this->enqueue_rollback_scripts();
|
@@ -422,7 +422,7 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
422 |
return;
|
423 |
}
|
424 |
|
425 |
-
$archives
|
426 |
$archive_count = count( $archives );
|
427 |
|
428 |
/*
|
@@ -465,8 +465,6 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
465 |
*/
|
466 |
$notice_markup = $this->notice_countdown_get();
|
467 |
do_action( 'boldgrid_backup_notice', $notice_markup, 'notice notice-warning is-dismissible boldgrid-backup-countdown' );
|
468 |
-
|
469 |
-
return;
|
470 |
}
|
471 |
|
472 |
/**
|
@@ -478,10 +476,10 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
478 |
* @access private
|
479 |
*
|
480 |
* @param array $args {
|
481 |
-
*
|
482 |
*
|
483 |
-
*
|
484 |
-
*
|
485 |
* }
|
486 |
* @return string The resulting markup.
|
487 |
*/
|
@@ -489,28 +487,28 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
489 |
|
490 |
// By default we will restore the newest backup.
|
491 |
if ( empty( $args ) ) {
|
492 |
-
$key
|
493 |
$archives = $this->core->get_archive_list();
|
494 |
-
$args
|
495 |
-
'restore_key'
|
496 |
'restore_filename' => $archives[ $key ]['filename'],
|
497 |
);
|
498 |
}
|
499 |
|
500 |
$pending_rollback = get_site_option( 'boldgrid_backup_pending_rollback' );
|
501 |
-
$deadline
|
502 |
|
503 |
$update_trigger = $this->notice_trigger_get();
|
504 |
$update_trigger = ! empty( $update_trigger ) ? sprintf( '<p>%1$s</p>', $update_trigger ) : '';
|
505 |
|
506 |
$nonce = wp_nonce_field( 'boldgrid_rollback_notice', 'cancel_rollback_auth', true, false );
|
507 |
|
508 |
-
$button_args
|
509 |
'button_text' => __( 'Rollback Site Now', 'boldgrid-backup' ),
|
510 |
);
|
511 |
$restore_button = $this->core->archive_actions->get_restore_button( $args['restore_filename'], $button_args );
|
512 |
|
513 |
-
$iso_time
|
514 |
$rollback_deadline = sprintf( '<input type="hidden" id="rollback-deadline" value="%1$s" />', $iso_time );
|
515 |
|
516 |
$notice_markup = '
|
@@ -528,7 +526,15 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
528 |
</p>
|
529 |
|
530 |
<p>
|
531 |
-
' .
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
532 |
</p>
|
533 |
|
534 |
<p>
|
@@ -596,8 +602,8 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
596 |
*/
|
597 |
public function notice_trigger_get() {
|
598 |
$pending_rollback = get_site_option( 'boldgrid_backup_pending_rollback' );
|
599 |
-
$notice
|
600 |
-
$li
|
601 |
|
602 |
if ( empty( $pending_rollback['update_trigger'] ) ) {
|
603 |
return false;
|
@@ -612,22 +618,31 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
612 |
switch ( $trigger['type'] ) {
|
613 |
case 'core':
|
614 |
$wordpress_version = get_bloginfo( 'version' );
|
615 |
-
$notice
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
616 |
break;
|
617 |
case 'theme':
|
618 |
foreach ( $trigger['themes'] as $theme ) {
|
619 |
$data = wp_get_theme( $theme );
|
620 |
$li[] = sprintf( '<strong>%1$s</strong> to version %2$s', $data->get( 'Name' ), $data->get( 'Version' ) );
|
621 |
}
|
622 |
-
$notice
|
623 |
$notice .= implode( '<br />', $li );
|
624 |
break;
|
625 |
case 'plugin':
|
626 |
-
|
|
|
|
|
627 |
$data = $this->core->utility->get_plugin_data( $plugin );
|
628 |
$li[] = sprintf( '<strong>%1$s</strong> to version %2$s', $data['Name'], $data['Version'] );
|
629 |
}
|
630 |
-
$notice
|
631 |
$notice .= implode( '<br />', $li );
|
632 |
break;
|
633 |
}
|
@@ -679,7 +694,6 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
679 |
* @global string $pagenow
|
680 |
*/
|
681 |
public function notice_backup_show() {
|
682 |
-
|
683 |
/*
|
684 |
* This method is hooked into admin_notices. If we don't have auto_rollback
|
685 |
* enabled, then we can abort right now.
|
@@ -693,15 +707,15 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
693 |
$configs = array(
|
694 |
array(
|
695 |
'pagenow' => 'plugins.php',
|
696 |
-
'check'
|
697 |
),
|
698 |
array(
|
699 |
'pagenow' => 'themes.php',
|
700 |
-
'check'
|
701 |
),
|
702 |
array(
|
703 |
'pagenow' => 'update-core.php',
|
704 |
-
'check'
|
705 |
),
|
706 |
);
|
707 |
|
@@ -758,7 +772,7 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
758 |
* 1.6.0 so that we can uniquely identify this notice on the page.
|
759 |
*/
|
760 |
$backup_button = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-backup-button.php';
|
761 |
-
$notice
|
762 |
do_action( 'boldgrid_backup_notice', $notice . $backup_button, 'notice notice-warning is-dismissible boldgrid-backup-protect-now' );
|
763 |
}
|
764 |
|
@@ -771,12 +785,12 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
771 |
*
|
772 |
* @link https://developer.wordpress.org/reference/hooks/upgrader_process_complete/
|
773 |
* @see Boldgrid_Backup_Admin_Cron::add_restore_cron().
|
|
|
774 |
*
|
775 |
-
* @param object $upgrader_object Plugin_Upgrader Object
|
776 |
-
* @param array $options
|
777 |
*/
|
778 |
public function notice_deadline_show( $upgrader_object, $options ) {
|
779 |
-
|
780 |
/*
|
781 |
* This method is ran both when a plugin/theme/WP is updated, and when
|
782 |
* a plugin is simply uploaded. As of 1.6.0, this plugin does not offer
|
@@ -806,11 +820,10 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
806 |
return;
|
807 |
}
|
808 |
|
809 |
-
//
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
printf( '<div class="hidden" id="rollback-deadline">%1$s</div>', $iso_time );
|
814 |
}
|
815 |
|
816 |
/**
|
@@ -818,7 +831,9 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
818 |
*
|
819 |
* @since 1.5.3
|
820 |
*
|
821 |
-
* @
|
|
|
|
|
822 |
*/
|
823 |
public function set_update_trigger( $options ) {
|
824 |
if ( empty( $options ) || ! is_array( $options ) ) {
|
@@ -858,6 +873,7 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
858 |
$message .= '<p>';
|
859 |
|
860 |
$message .= sprintf(
|
|
|
861 |
__( 'You last made a backup %1$s ago.', 'boldgrid-backup' ),
|
862 |
human_time_diff( $pending_rollback['lastmodunix'], time() )
|
863 |
) . ' ';
|
@@ -875,7 +891,8 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
875 |
}
|
876 |
|
877 |
// Customize our message for the "update theme" feature within the customizer.
|
878 |
-
$path =
|
|
|
879 |
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'customize.php' === substr( $path, -1 * strlen( 'customize.php' ) ) ) {
|
880 |
$message .= $theme_message;
|
881 |
}
|
@@ -883,7 +900,7 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
883 |
$message .= '</p>';
|
884 |
|
885 |
$message = array(
|
886 |
-
'html'
|
887 |
'class' => 'notice notice-success is-dismissible boldgrid-backup-protected',
|
888 |
);
|
889 |
|
@@ -902,13 +919,12 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
902 |
* @since 1.5.3
|
903 |
*/
|
904 |
public function notice_activated_show() {
|
905 |
-
|
906 |
/*
|
907 |
* If we're in the middle of upgrading something, such as:
|
908 |
* update-core.php?action=do-theme-upgrade
|
909 |
* Then there's no need to show a message.
|
910 |
*/
|
911 |
-
if ( ! empty( $_GET['action'] ) ) {
|
912 |
return;
|
913 |
}
|
914 |
|
@@ -976,8 +992,7 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
976 |
}
|
977 |
|
978 |
// Convert the deadline to ISO time (in ISO 8601 format).
|
979 |
-
|
980 |
-
wp_die( $iso_time );
|
981 |
}
|
982 |
|
983 |
/**
|
@@ -1020,12 +1035,12 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
1020 |
if ( ! empty( $pending_rollback ) ) {
|
1021 |
// You're protected, go ahead and update.
|
1022 |
$message = $this->notice_activated_get();
|
1023 |
-
$notice
|
1024 |
} else {
|
1025 |
// You're not protected, make a backup first.
|
1026 |
-
$notice
|
1027 |
$backup_button = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-backup-button.php';
|
1028 |
-
$notice
|
1029 |
}
|
1030 |
|
1031 |
wp_send_json_success( $notice );
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-auto-rollback.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.5.2
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
// phpcs:disable WordPress.VIP
|
16 |
+
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Auto_Rollback
|
19 |
*
|
20 |
* We hook into "the upgrader_process_complete" (run when the download process
|
21 |
* for a plugin install or update finishes). If the user has enabled auto
|
49 |
* @since 1.5.1
|
50 |
*/
|
51 |
class Boldgrid_Backup_Admin_Auto_Rollback {
|
|
|
52 |
/**
|
53 |
* The core class object.
|
54 |
*
|
117 |
*
|
118 |
* @since 1.5.1
|
119 |
*
|
120 |
+
* @param Boldgrid_Backup_Admin_Core $core Boldgrid_Backup_Admin_Core object.
|
121 |
*/
|
122 |
public function __construct( $core ) {
|
123 |
$this->core = $core;
|
124 |
|
125 |
$this->updating_core = 'update-core.php' === $this->core->pagenow &&
|
126 |
+
! empty( $_GET['action'] ) && 'do-core-upgrade' === $_GET['action']; // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
127 |
|
128 |
$this->on_update_page = in_array( $this->core->pagenow, $this->update_pages, true );
|
129 |
}
|
154 |
return;
|
155 |
}
|
156 |
|
157 |
+
$archives = $this->core->get_archive_list();
|
158 |
$archive_count = count( $archives );
|
159 |
|
160 |
// If there are no archives, then abort.
|
208 |
false
|
209 |
);
|
210 |
|
211 |
+
$access_type = get_filesystem_method();
|
212 |
+
$archive_nonce = wp_create_nonce( 'archive_auth' );
|
213 |
$localize_script_data = array(
|
214 |
+
'archiveNonce' => $archive_nonce,
|
215 |
+
'accessType' => $access_type,
|
216 |
'updateProtectionActivated' => $this->core->elements['update_protection_activated'],
|
217 |
+
'backupCreated' => $this->core->lang['backup_created'],
|
218 |
+
'errorText' => esc_html__(
|
219 |
'There was an error processing your request. Please reload the page and try again.',
|
220 |
'boldgrid-backup'
|
221 |
),
|
252 |
);
|
253 |
|
254 |
$translations = array(
|
255 |
+
'update_data' => wp_get_update_data(),
|
256 |
+
'in_progress_notice' => $this->core->in_progress->get_notice_markup(),
|
257 |
+
'nonce' => wp_create_nonce( 'boldgrid_backup_customizer' ),
|
258 |
'is_rollback_enabled' => $this->is_enabled(),
|
259 |
);
|
260 |
wp_localize_script( $handle, 'boldgridBackupCustomizer', $translations );
|
353 |
$localize_script_data = array(
|
354 |
// Generally used as the title attr of a disable update button.
|
355 |
'backupInProgress' => __( 'Your website is currently being backed up. You can perform updates when the backup is complete.', 'boldgrid-backup' ),
|
356 |
+
'waitClass' => 'bgbu-wait',
|
357 |
);
|
358 |
|
359 |
wp_localize_script( $handle, 'boldgrid_backup_admin_update_selectors', $localize_script_data );
|
374 |
* @return null
|
375 |
*/
|
376 |
public function notice_countdown_show() {
|
|
|
377 |
// Process GET / POST info.
|
378 |
+
$action = ! empty( $_GET['action'] ) ? sanitize_key( $_GET['action'] ) : null; // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
379 |
+
$restore_now = ! empty( $_POST['restore_now'] ); // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
380 |
|
381 |
$pending_rollback = get_site_option( 'boldgrid_backup_pending_rollback' );
|
382 |
+
$deadline = ! empty( $pending_rollback['deadline'] ) ? $pending_rollback['deadline'] : null;
|
383 |
+
$deadline_passed = ! empty( $deadline ) && $deadline <= time();
|
384 |
|
385 |
if ( $this->on_update_page ) {
|
386 |
$this->enqueue_rollback_scripts();
|
422 |
return;
|
423 |
}
|
424 |
|
425 |
+
$archives = $this->core->get_archive_list();
|
426 |
$archive_count = count( $archives );
|
427 |
|
428 |
/*
|
465 |
*/
|
466 |
$notice_markup = $this->notice_countdown_get();
|
467 |
do_action( 'boldgrid_backup_notice', $notice_markup, 'notice notice-warning is-dismissible boldgrid-backup-countdown' );
|
|
|
|
|
468 |
}
|
469 |
|
470 |
/**
|
476 |
* @access private
|
477 |
*
|
478 |
* @param array $args {
|
479 |
+
* An array of arguments.
|
480 |
*
|
481 |
+
* @type int $restore_key Key index used for restoration.
|
482 |
+
* @type string $restore_filename Filename of the backup archive to be restored.
|
483 |
* }
|
484 |
* @return string The resulting markup.
|
485 |
*/
|
487 |
|
488 |
// By default we will restore the newest backup.
|
489 |
if ( empty( $args ) ) {
|
490 |
+
$key = 0;
|
491 |
$archives = $this->core->get_archive_list();
|
492 |
+
$args = array(
|
493 |
+
'restore_key' => $key,
|
494 |
'restore_filename' => $archives[ $key ]['filename'],
|
495 |
);
|
496 |
}
|
497 |
|
498 |
$pending_rollback = get_site_option( 'boldgrid_backup_pending_rollback' );
|
499 |
+
$deadline = ! empty( $pending_rollback['deadline'] ) ? sprintf( '(<em>%1$s</em>)', date( 'g:i a', $this->core->utility->time( $pending_rollback['deadline'] ) ) ) : '';
|
500 |
|
501 |
$update_trigger = $this->notice_trigger_get();
|
502 |
$update_trigger = ! empty( $update_trigger ) ? sprintf( '<p>%1$s</p>', $update_trigger ) : '';
|
503 |
|
504 |
$nonce = wp_nonce_field( 'boldgrid_rollback_notice', 'cancel_rollback_auth', true, false );
|
505 |
|
506 |
+
$button_args = array(
|
507 |
'button_text' => __( 'Rollback Site Now', 'boldgrid-backup' ),
|
508 |
);
|
509 |
$restore_button = $this->core->archive_actions->get_restore_button( $args['restore_filename'], $button_args );
|
510 |
|
511 |
+
$iso_time = ! empty( $pending_rollback['deadline'] ) ? date( 'c', $pending_rollback['deadline'] ) : null;
|
512 |
$rollback_deadline = sprintf( '<input type="hidden" id="rollback-deadline" value="%1$s" />', $iso_time );
|
513 |
|
514 |
$notice_markup = '
|
526 |
</p>
|
527 |
|
528 |
<p>
|
529 |
+
' .
|
530 |
+
sprintf(
|
531 |
+
// translators: 1: URL address.
|
532 |
+
__(
|
533 |
+
'<strong>Update Protection</strong> for <em>future updates</em> can be configured on your <a href="%1$s">Settings</a> page.',
|
534 |
+
'boldgrid-backup'
|
535 |
+
),
|
536 |
+
admin_url( 'admin.php?page=boldgrid-backup-settings§ion=section_updates' )
|
537 |
+
) . '
|
538 |
</p>
|
539 |
|
540 |
<p>
|
602 |
*/
|
603 |
public function notice_trigger_get() {
|
604 |
$pending_rollback = get_site_option( 'boldgrid_backup_pending_rollback' );
|
605 |
+
$notice = false;
|
606 |
+
$li = array();
|
607 |
|
608 |
if ( empty( $pending_rollback['update_trigger'] ) ) {
|
609 |
return false;
|
618 |
switch ( $trigger['type'] ) {
|
619 |
case 'core':
|
620 |
$wordpress_version = get_bloginfo( 'version' );
|
621 |
+
$notice = sprintf(
|
622 |
+
// translators: 1: WordPress version string.
|
623 |
+
__(
|
624 |
+
'WordPress was recently updated to version %1$s.',
|
625 |
+
'boldgrid-backup'
|
626 |
+
),
|
627 |
+
$wordpress_version
|
628 |
+
);
|
629 |
break;
|
630 |
case 'theme':
|
631 |
foreach ( $trigger['themes'] as $theme ) {
|
632 |
$data = wp_get_theme( $theme );
|
633 |
$li[] = sprintf( '<strong>%1$s</strong> to version %2$s', $data->get( 'Name' ), $data->get( 'Version' ) );
|
634 |
}
|
635 |
+
$notice = __( 'The following theme(s) were recently updated:', 'boldgrid-backup' ) . '<br />';
|
636 |
$notice .= implode( '<br />', $li );
|
637 |
break;
|
638 |
case 'plugin':
|
639 |
+
$plugins = ! empty( $trigger['plugins'] ) ? $trigger['plugins'] : array( $trigger['plugin'] );
|
640 |
+
|
641 |
+
foreach ( $plugins as $plugin ) {
|
642 |
$data = $this->core->utility->get_plugin_data( $plugin );
|
643 |
$li[] = sprintf( '<strong>%1$s</strong> to version %2$s', $data['Name'], $data['Version'] );
|
644 |
}
|
645 |
+
$notice = __( 'The following plugin(s) were recently updated:', 'boldgrid-backup' ) . '<br />';
|
646 |
$notice .= implode( '<br />', $li );
|
647 |
break;
|
648 |
}
|
694 |
* @global string $pagenow
|
695 |
*/
|
696 |
public function notice_backup_show() {
|
|
|
697 |
/*
|
698 |
* This method is hooked into admin_notices. If we don't have auto_rollback
|
699 |
* enabled, then we can abort right now.
|
707 |
$configs = array(
|
708 |
array(
|
709 |
'pagenow' => 'plugins.php',
|
710 |
+
'check' => 'plugins',
|
711 |
),
|
712 |
array(
|
713 |
'pagenow' => 'themes.php',
|
714 |
+
'check' => 'themes',
|
715 |
),
|
716 |
array(
|
717 |
'pagenow' => 'update-core.php',
|
718 |
+
'check' => 'total',
|
719 |
),
|
720 |
);
|
721 |
|
772 |
* 1.6.0 so that we can uniquely identify this notice on the page.
|
773 |
*/
|
774 |
$backup_button = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-backup-button.php';
|
775 |
+
$notice = $this->notice_backup_get();
|
776 |
do_action( 'boldgrid_backup_notice', $notice . $backup_button, 'notice notice-warning is-dismissible boldgrid-backup-protect-now' );
|
777 |
}
|
778 |
|
785 |
*
|
786 |
* @link https://developer.wordpress.org/reference/hooks/upgrader_process_complete/
|
787 |
* @see Boldgrid_Backup_Admin_Cron::add_restore_cron().
|
788 |
+
* @link https://pastebin.com/ah4E048B
|
789 |
*
|
790 |
+
* @param object $upgrader_object Plugin_Upgrader Object.
|
791 |
+
* @param array $options Options array.
|
792 |
*/
|
793 |
public function notice_deadline_show( $upgrader_object, $options ) {
|
|
|
794 |
/*
|
795 |
* This method is ran both when a plugin/theme/WP is updated, and when
|
796 |
* a plugin is simply uploaded. As of 1.6.0, this plugin does not offer
|
820 |
return;
|
821 |
}
|
822 |
|
823 |
+
// Print a hidden div with the time (in ISO 8601 format), so that JavaScript can read it.
|
824 |
+
?>
|
825 |
+
<div class="hidden" id="rollback-deadline"><?php echo esc_html( date( 'c', $deadline ) ); ?></div>
|
826 |
+
<?php
|
|
|
827 |
}
|
828 |
|
829 |
/**
|
831 |
*
|
832 |
* @since 1.5.3
|
833 |
*
|
834 |
+
* @link https://pastebin.com/ah4E048B
|
835 |
+
*
|
836 |
+
* @param array $options Option array.
|
837 |
*/
|
838 |
public function set_update_trigger( $options ) {
|
839 |
if ( empty( $options ) || ! is_array( $options ) ) {
|
873 |
$message .= '<p>';
|
874 |
|
875 |
$message .= sprintf(
|
876 |
+
// translators: 1: Time difference.
|
877 |
__( 'You last made a backup %1$s ago.', 'boldgrid-backup' ),
|
878 |
human_time_diff( $pending_rollback['lastmodunix'], time() )
|
879 |
) . ' ';
|
891 |
}
|
892 |
|
893 |
// Customize our message for the "update theme" feature within the customizer.
|
894 |
+
$path = wp_parse_url( wp_get_referer(), PHP_URL_PATH );
|
895 |
+
|
896 |
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'customize.php' === substr( $path, -1 * strlen( 'customize.php' ) ) ) {
|
897 |
$message .= $theme_message;
|
898 |
}
|
900 |
$message .= '</p>';
|
901 |
|
902 |
$message = array(
|
903 |
+
'html' => $message,
|
904 |
'class' => 'notice notice-success is-dismissible boldgrid-backup-protected',
|
905 |
);
|
906 |
|
919 |
* @since 1.5.3
|
920 |
*/
|
921 |
public function notice_activated_show() {
|
|
|
922 |
/*
|
923 |
* If we're in the middle of upgrading something, such as:
|
924 |
* update-core.php?action=do-theme-upgrade
|
925 |
* Then there's no need to show a message.
|
926 |
*/
|
927 |
+
if ( ! empty( $_GET['action'] ) ) { // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
928 |
return;
|
929 |
}
|
930 |
|
992 |
}
|
993 |
|
994 |
// Convert the deadline to ISO time (in ISO 8601 format).
|
995 |
+
wp_die( esc_html( date( 'c', $deadline ) ) );
|
|
|
996 |
}
|
997 |
|
998 |
/**
|
1035 |
if ( ! empty( $pending_rollback ) ) {
|
1036 |
// You're protected, go ahead and update.
|
1037 |
$message = $this->notice_activated_get();
|
1038 |
+
$notice = sprintf( '<div class="%1$s">%2$s</div>', $message['class'], $message['html'] );
|
1039 |
} else {
|
1040 |
// You're not protected, make a backup first.
|
1041 |
+
$notice = $this->notice_backup_get();
|
1042 |
$backup_button = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-backup-button.php';
|
1043 |
+
$notice = '<div class="notice notice-warning is-dismissible boldgrid-backup-protect-now">' . $notice . $backup_button . '</div>';
|
1044 |
}
|
1045 |
|
1046 |
wp_send_json_success( $notice );
|
admin/class-boldgrid-backup-admin-backup-dir.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
@@ -12,13 +12,14 @@
|
|
12 |
* @author BoldGrid.com <wpb@boldgrid.com>
|
13 |
*/
|
14 |
|
|
|
|
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Backup_Dir {
|
21 |
-
|
22 |
/**
|
23 |
* Backup directory.
|
24 |
*
|
@@ -59,7 +60,7 @@ class Boldgrid_Backup_Admin_Backup_Dir {
|
|
59 |
*
|
60 |
* @since 1.5.1
|
61 |
*
|
62 |
-
* @param Boldgrid_Backup_Admin_Core $core
|
63 |
*/
|
64 |
public function __construct( $core ) {
|
65 |
$this->core = $core;
|
@@ -70,30 +71,33 @@ class Boldgrid_Backup_Admin_Backup_Dir {
|
|
70 |
*
|
71 |
* @since 1.5.1
|
72 |
*
|
73 |
-
* @param string $backup_dir
|
74 |
* @return mixed False on failure, trailingslashed $backup_dir on success.
|
75 |
*/
|
76 |
public function create( $backup_dir ) {
|
77 |
$check_permissions = __( 'Please ensure your backup directory exists and has the proper read, write, and modify permissions.', 'boldgrid-backup' );
|
78 |
|
|
|
79 |
$cannot_create = __( 'Unable to create necessary file: %1$s<br />%2$s', 'boldgrid-backup' );
|
|
|
|
|
80 |
$cannot_write = __( 'Unable to write to necessary file: %1$s<br />%2$s', 'boldgrid-backup' );
|
81 |
|
82 |
$backup_dir = untrailingslashit( $backup_dir );
|
83 |
|
84 |
-
$htaccess_path
|
85 |
$index_html_path = $backup_dir . DIRECTORY_SEPARATOR . 'index.html';
|
86 |
-
$index_php_path
|
87 |
|
88 |
$files = array(
|
89 |
array(
|
90 |
-
'type'
|
91 |
-
'path'
|
92 |
'chmod' => 0700,
|
93 |
),
|
94 |
array(
|
95 |
-
'type'
|
96 |
-
'path'
|
97 |
'contents' => "<IfModule mod_access_compat.c>\nOrder Allow,Deny\nDeny from all\n</IfModule>\nOptions -Indexes\n",
|
98 |
),
|
99 |
array(
|
@@ -120,7 +124,7 @@ class Boldgrid_Backup_Admin_Backup_Dir {
|
|
120 |
switch ( $file['type'] ) {
|
121 |
case 'dir':
|
122 |
if ( ! $this->core->wp_filesystem->exists( $file['path'] ) ) {
|
123 |
-
$chmod
|
124 |
$created = $this->core->wp_filesystem->mkdir( $file['path'], $chmod );
|
125 |
if ( ! $created ) {
|
126 |
$this->errors[] = sprintf( $cannot_create, $file['path'], $check_permissions );
|
@@ -188,7 +192,7 @@ class Boldgrid_Backup_Admin_Backup_Dir {
|
|
188 |
$dirs[] = $this->core->config->get_home_directory();
|
189 |
|
190 |
if ( $this->core->test->is_windows() ) {
|
191 |
-
// C:\Users\user\AppData\Local
|
192 |
$dirs[] = $this->core->config->get_home_directory() . DIRECTORY_SEPARATOR . 'AppData' . DIRECTORY_SEPARATOR . 'Local';
|
193 |
|
194 |
if ( ! empty( $_SERVER['DOCUMENT_ROOT'] ) ) {
|
@@ -203,7 +207,7 @@ class Boldgrid_Backup_Admin_Backup_Dir {
|
|
203 |
* there won't be downloadable.
|
204 |
*/
|
205 |
$app_data = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'App_Data';
|
206 |
-
$dirs[]
|
207 |
}
|
208 |
}
|
209 |
|
@@ -218,9 +222,9 @@ class Boldgrid_Backup_Admin_Backup_Dir {
|
|
218 |
*
|
219 |
* Returns backup_dir/$file.
|
220 |
*
|
221 |
-
* @since 1.
|
222 |
*
|
223 |
-
* @param string $file
|
224 |
* @return string
|
225 |
*/
|
226 |
public function get_path_to( $file ) {
|
@@ -254,7 +258,7 @@ class Boldgrid_Backup_Admin_Backup_Dir {
|
|
254 |
* Create the directory and all applicable files needed within for security,
|
255 |
* such as .htaccess / etc.
|
256 |
*/
|
257 |
-
$possible_dir
|
258 |
$backup_directory = $this->create( $possible_dir );
|
259 |
if ( ! $backup_directory ) {
|
260 |
continue;
|
@@ -298,7 +302,7 @@ class Boldgrid_Backup_Admin_Backup_Dir {
|
|
298 |
*
|
299 |
* @since 1.5.1
|
300 |
*
|
301 |
-
* @param string $file
|
302 |
* @param bool $use_abspath Bool determining whether or not to use the
|
303 |
* backup directory in its absolute path.
|
304 |
* @return bool
|
@@ -316,7 +320,9 @@ class Boldgrid_Backup_Admin_Backup_Dir {
|
|
316 |
*
|
317 |
* Make sure it exists, it's writable, etc.
|
318 |
*
|
319 |
-
* @
|
|
|
|
|
320 |
* @return bool
|
321 |
*/
|
322 |
public function is_valid( $backup_dir ) {
|
@@ -328,23 +334,52 @@ class Boldgrid_Backup_Admin_Backup_Dir {
|
|
328 |
$perms = $this->core->test->extensive_dir_test( $backup_dir );
|
329 |
|
330 |
if ( ! $perms['exists'] ) {
|
331 |
-
$this->errors[] = sprintf(
|
|
|
|
|
|
|
|
|
332 |
}
|
333 |
|
334 |
if ( ! $perms['read'] ) {
|
335 |
-
$this->errors[] = sprintf(
|
|
|
|
|
|
|
|
|
336 |
}
|
337 |
|
338 |
if ( ! $perms['rename'] ) {
|
339 |
-
$this->errors[] = sprintf(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
340 |
}
|
341 |
|
342 |
if ( ! $perms['delete'] ) {
|
343 |
-
$this->errors[] = sprintf(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
}
|
345 |
|
346 |
if ( ! $perms['dirlist'] ) {
|
347 |
-
$this->errors[] = sprintf(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
348 |
}
|
349 |
|
350 |
/*
|
@@ -354,11 +389,15 @@ class Boldgrid_Backup_Admin_Backup_Dir {
|
|
354 |
* In the above example, we will create /home/user/.htaccess to prevent
|
355 |
* browsing of backups, and this would prevent all traffic to the ABSPATH.
|
356 |
*/
|
357 |
-
$backup_dir
|
358 |
$abspath_in_dir = 0 === strpos( ABSPATH, $backup_dir );
|
359 |
if ( $abspath_in_dir ) {
|
360 |
$this->errors[] = sprintf(
|
361 |
-
|
|
|
|
|
|
|
|
|
362 |
ABSPATH,
|
363 |
$backup_dir
|
364 |
);
|
@@ -371,6 +410,10 @@ class Boldgrid_Backup_Admin_Backup_Dir {
|
|
371 |
* Even in a Windows environment, wp_filesystem->dirlist retrieves paths
|
372 |
* with a / instead of \. Fix $without_abspath so we can properly check if
|
373 |
* files are in the backup directory.
|
|
|
|
|
|
|
|
|
374 |
*/
|
375 |
public function set( $backup_directory ) {
|
376 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-backup-dir.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
12 |
* @author BoldGrid.com <wpb@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
// phpcs:disable WordPress.VIP
|
16 |
+
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Backup_Dir
|
19 |
*
|
20 |
* @since 1.5.1
|
21 |
*/
|
22 |
class Boldgrid_Backup_Admin_Backup_Dir {
|
|
|
23 |
/**
|
24 |
* Backup directory.
|
25 |
*
|
60 |
*
|
61 |
* @since 1.5.1
|
62 |
*
|
63 |
+
* @param Boldgrid_Backup_Admin_Core $core Boldgrid_Backup_Admin_Core object.
|
64 |
*/
|
65 |
public function __construct( $core ) {
|
66 |
$this->core = $core;
|
71 |
*
|
72 |
* @since 1.5.1
|
73 |
*
|
74 |
+
* @param string $backup_dir Backup directory path.
|
75 |
* @return mixed False on failure, trailingslashed $backup_dir on success.
|
76 |
*/
|
77 |
public function create( $backup_dir ) {
|
78 |
$check_permissions = __( 'Please ensure your backup directory exists and has the proper read, write, and modify permissions.', 'boldgrid-backup' );
|
79 |
|
80 |
+
// translators: 1: File path, 2: Informational message above ($check_permissions).
|
81 |
$cannot_create = __( 'Unable to create necessary file: %1$s<br />%2$s', 'boldgrid-backup' );
|
82 |
+
|
83 |
+
// translators: 1: File path, 2: Informational message above ($check_permissions).
|
84 |
$cannot_write = __( 'Unable to write to necessary file: %1$s<br />%2$s', 'boldgrid-backup' );
|
85 |
|
86 |
$backup_dir = untrailingslashit( $backup_dir );
|
87 |
|
88 |
+
$htaccess_path = $backup_dir . DIRECTORY_SEPARATOR . '.htaccess';
|
89 |
$index_html_path = $backup_dir . DIRECTORY_SEPARATOR . 'index.html';
|
90 |
+
$index_php_path = $backup_dir . DIRECTORY_SEPARATOR . 'index.php';
|
91 |
|
92 |
$files = array(
|
93 |
array(
|
94 |
+
'type' => 'dir',
|
95 |
+
'path' => $backup_dir,
|
96 |
'chmod' => 0700,
|
97 |
),
|
98 |
array(
|
99 |
+
'type' => 'file',
|
100 |
+
'path' => $htaccess_path,
|
101 |
'contents' => "<IfModule mod_access_compat.c>\nOrder Allow,Deny\nDeny from all\n</IfModule>\nOptions -Indexes\n",
|
102 |
),
|
103 |
array(
|
124 |
switch ( $file['type'] ) {
|
125 |
case 'dir':
|
126 |
if ( ! $this->core->wp_filesystem->exists( $file['path'] ) ) {
|
127 |
+
$chmod = ! empty( $file['chmod'] ) ? $file['chmod'] : false;
|
128 |
$created = $this->core->wp_filesystem->mkdir( $file['path'], $chmod );
|
129 |
if ( ! $created ) {
|
130 |
$this->errors[] = sprintf( $cannot_create, $file['path'], $check_permissions );
|
192 |
$dirs[] = $this->core->config->get_home_directory();
|
193 |
|
194 |
if ( $this->core->test->is_windows() ) {
|
195 |
+
// Example: "C:\Users\user\AppData\Local".
|
196 |
$dirs[] = $this->core->config->get_home_directory() . DIRECTORY_SEPARATOR . 'AppData' . DIRECTORY_SEPARATOR . 'Local';
|
197 |
|
198 |
if ( ! empty( $_SERVER['DOCUMENT_ROOT'] ) ) {
|
207 |
* there won't be downloadable.
|
208 |
*/
|
209 |
$app_data = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'App_Data';
|
210 |
+
$dirs[] = str_replace( '\\\\', '\\', $app_data );
|
211 |
}
|
212 |
}
|
213 |
|
222 |
*
|
223 |
* Returns backup_dir/$file.
|
224 |
*
|
225 |
+
* @since 1.6.0
|
226 |
*
|
227 |
+
* @param string $file Filename.
|
228 |
* @return string
|
229 |
*/
|
230 |
public function get_path_to( $file ) {
|
258 |
* Create the directory and all applicable files needed within for security,
|
259 |
* such as .htaccess / etc.
|
260 |
*/
|
261 |
+
$possible_dir .= DIRECTORY_SEPARATOR . 'boldgrid_backup';
|
262 |
$backup_directory = $this->create( $possible_dir );
|
263 |
if ( ! $backup_directory ) {
|
264 |
continue;
|
302 |
*
|
303 |
* @since 1.5.1
|
304 |
*
|
305 |
+
* @param string $file Filename.
|
306 |
* @param bool $use_abspath Bool determining whether or not to use the
|
307 |
* backup directory in its absolute path.
|
308 |
* @return bool
|
320 |
*
|
321 |
* Make sure it exists, it's writable, etc.
|
322 |
*
|
323 |
+
* @since 1.5.1
|
324 |
+
*
|
325 |
+
* @param string $backup_dir Backup directory path.
|
326 |
* @return bool
|
327 |
*/
|
328 |
public function is_valid( $backup_dir ) {
|
334 |
$perms = $this->core->test->extensive_dir_test( $backup_dir );
|
335 |
|
336 |
if ( ! $perms['exists'] ) {
|
337 |
+
$this->errors[] = sprintf(
|
338 |
+
// translators: 1: Backup directory path.
|
339 |
+
__( 'Backup Directory does not exists: %1$s', 'boldgrid-backup' ),
|
340 |
+
$backup_dir
|
341 |
+
);
|
342 |
}
|
343 |
|
344 |
if ( ! $perms['read'] ) {
|
345 |
+
$this->errors[] = sprintf(
|
346 |
+
// translators: 1: Backup directory path.
|
347 |
+
__( 'Backup Directory does not have read permission: %1$s', 'boldgrid-backup' ),
|
348 |
+
$backup_dir
|
349 |
+
);
|
350 |
}
|
351 |
|
352 |
if ( ! $perms['rename'] ) {
|
353 |
+
$this->errors[] = sprintf(
|
354 |
+
// translators: 1: Backup directory path.
|
355 |
+
__(
|
356 |
+
'Backup Directory does not have permission to rename files: %1$s',
|
357 |
+
'boldgrid-backup'
|
358 |
+
),
|
359 |
+
$backup_dir
|
360 |
+
);
|
361 |
}
|
362 |
|
363 |
if ( ! $perms['delete'] ) {
|
364 |
+
$this->errors[] = sprintf(
|
365 |
+
// translators: 1: Backup directory path.
|
366 |
+
__(
|
367 |
+
'Backup Directory does not have permission to delete files: %1$s',
|
368 |
+
'boldgrid-backup'
|
369 |
+
),
|
370 |
+
$backup_dir
|
371 |
+
);
|
372 |
}
|
373 |
|
374 |
if ( ! $perms['dirlist'] ) {
|
375 |
+
$this->errors[] = sprintf(
|
376 |
+
// translators: 1: Backup directory path.
|
377 |
+
__(
|
378 |
+
'Backup Directory does not have permission to retrieve directory listing: %1$s',
|
379 |
+
'boldgrid-backup'
|
380 |
+
),
|
381 |
+
$backup_dir
|
382 |
+
);
|
383 |
}
|
384 |
|
385 |
/*
|
389 |
* In the above example, we will create /home/user/.htaccess to prevent
|
390 |
* browsing of backups, and this would prevent all traffic to the ABSPATH.
|
391 |
*/
|
392 |
+
$backup_dir = Boldgrid_Backup_Admin_Utility::trailingslashit( $backup_dir );
|
393 |
$abspath_in_dir = 0 === strpos( ABSPATH, $backup_dir );
|
394 |
if ( $abspath_in_dir ) {
|
395 |
$this->errors[] = sprintf(
|
396 |
+
// translators: 1: WordPress installation directory path, 2: Backup directory path.
|
397 |
+
__(
|
398 |
+
'Your <strong>WordPress directory</strong> <em>%1$s</em> cannot be within your <strong>backup directory</strong> %2$s.',
|
399 |
+
'boldgrid-backup'
|
400 |
+
),
|
401 |
ABSPATH,
|
402 |
$backup_dir
|
403 |
);
|
410 |
* Even in a Windows environment, wp_filesystem->dirlist retrieves paths
|
411 |
* with a / instead of \. Fix $without_abspath so we can properly check if
|
412 |
* files are in the backup directory.
|
413 |
+
*
|
414 |
+
* @since 1.5.2
|
415 |
+
*
|
416 |
+
* @param string $backup_directory Backup directory.
|
417 |
*/
|
418 |
public function set( $backup_directory ) {
|
419 |
|
admin/class-boldgrid-backup-admin-compressor.php
CHANGED
@@ -1,24 +1,23 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Compressor {
|
21 |
-
|
22 |
/**
|
23 |
* An instance of Boldgrid_Backup_Admin_Core.
|
24 |
*
|
@@ -42,7 +41,7 @@ class Boldgrid_Backup_Admin_Compressor {
|
|
42 |
*
|
43 |
* @global $wp_filesystem
|
44 |
*
|
45 |
-
* @param Boldgrid_Backup_Admin_Core $core
|
46 |
*/
|
47 |
public function __construct( $core ) {
|
48 |
global $wp_filesystem;
|
@@ -58,7 +57,9 @@ class Boldgrid_Backup_Admin_Compressor {
|
|
58 |
*
|
59 |
* @since 1.5.1
|
60 |
*
|
61 |
-
* @
|
|
|
|
|
62 |
* @param array $info {
|
63 |
* An array of data about the backup archive we are generating.
|
64 |
*
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-compressor.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_Compressor
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Compressor {
|
|
|
21 |
/**
|
22 |
* An instance of Boldgrid_Backup_Admin_Core.
|
23 |
*
|
41 |
*
|
42 |
* @global $wp_filesystem
|
43 |
*
|
44 |
+
* @param Boldgrid_Backup_Admin_Core $core Boldgrid_Backup_Admin_Core object.
|
45 |
*/
|
46 |
public function __construct( $core ) {
|
47 |
global $wp_filesystem;
|
57 |
*
|
58 |
* @since 1.5.1
|
59 |
*
|
60 |
+
* @see Boldgrid_Backup_Admin_Filelist::get_total_size()
|
61 |
+
*
|
62 |
+
* @param array $filelist A file list.
|
63 |
* @param array $info {
|
64 |
* An array of data about the backup archive we are generating.
|
65 |
*
|
admin/class-boldgrid-backup-admin-compressors.php
CHANGED
@@ -1,24 +1,23 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Compressors {
|
21 |
-
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
@@ -66,7 +65,7 @@ class Boldgrid_Backup_Admin_Compressors {
|
|
66 |
* @return string
|
67 |
*/
|
68 |
public function get() {
|
69 |
-
$settings
|
70 |
$available_compressors = $this->get_available();
|
71 |
|
72 |
/*
|
@@ -101,9 +100,9 @@ class Boldgrid_Backup_Admin_Compressors {
|
|
101 |
*/
|
102 |
public function set_php_zip() {
|
103 |
if ( Boldgrid_Backup_Admin_Compressor_Php_Zip::is_available() ) {
|
104 |
-
$settings
|
105 |
$settings['compressor'] = 'php_zip';
|
106 |
-
$settings['extractor']
|
107 |
return $this->core->settings->save( $settings );
|
108 |
}
|
109 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-compressors.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* File: Boldgrid_Backup_Admin_Compressors
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Compressors {
|
|
|
21 |
/**
|
22 |
* The core class object.
|
23 |
*
|
65 |
* @return string
|
66 |
*/
|
67 |
public function get() {
|
68 |
+
$settings = $this->core->settings->get_settings();
|
69 |
$available_compressors = $this->get_available();
|
70 |
|
71 |
/*
|
100 |
*/
|
101 |
public function set_php_zip() {
|
102 |
if ( Boldgrid_Backup_Admin_Compressor_Php_Zip::is_available() ) {
|
103 |
+
$settings = $this->core->settings->get_settings();
|
104 |
$settings['compressor'] = 'php_zip';
|
105 |
+
$settings['extractor'] = 'php_zip';
|
106 |
return $this->core->settings->save( $settings );
|
107 |
}
|
108 |
|
admin/class-boldgrid-backup-admin-config.php
CHANGED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.0
|
7 |
*
|
8 |
-
* @package
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright
|
11 |
-
* @version
|
12 |
-
* @author
|
13 |
*/
|
14 |
|
|
|
|
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.0
|
19 |
*/
|
@@ -75,7 +77,7 @@ class Boldgrid_Backup_Admin_Config {
|
|
75 |
/**
|
76 |
* Whether or not the premium plugin is activated.
|
77 |
*
|
78 |
-
* @since
|
79 |
* @access public
|
80 |
* @var bool
|
81 |
*/
|
@@ -85,7 +87,7 @@ class Boldgrid_Backup_Admin_Config {
|
|
85 |
* Whether or not we have a premium license and the premium extension is
|
86 |
* installed.
|
87 |
*
|
88 |
-
* @since
|
89 |
* @access public
|
90 |
* @var bool
|
91 |
*/
|
@@ -95,7 +97,7 @@ class Boldgrid_Backup_Admin_Config {
|
|
95 |
* Whether or not the premium extension is installed (we didn't say activated,
|
96 |
* just installed, the files exist on the server).
|
97 |
*
|
98 |
-
* @since
|
99 |
* @access public
|
100 |
* @var bool
|
101 |
*/
|
@@ -133,7 +135,7 @@ class Boldgrid_Backup_Admin_Config {
|
|
133 |
}
|
134 |
|
135 |
if ( class_exists( '\Boldgrid\Library\Library\License' ) ) {
|
136 |
-
$this->license
|
137 |
$this->is_premium = $this->license->isPremium( 'boldgrid-backup' );
|
138 |
}
|
139 |
|
@@ -166,7 +168,7 @@ class Boldgrid_Backup_Admin_Config {
|
|
166 |
} elseif ( $this->core->test->is_windows() ) {
|
167 |
// Windows.
|
168 |
$home_drive = ( ! empty( $_SERVER['HOMEDRIVE'] ) ? $_SERVER['HOMEDRIVE'] : null );
|
169 |
-
$home_path
|
170 |
|
171 |
if ( ! ( empty( $home_drive ) || empty( $home_path ) ) ) {
|
172 |
$home_dir = $home_drive . $home_path;
|
@@ -179,7 +181,7 @@ class Boldgrid_Backup_Admin_Config {
|
|
179 |
} else {
|
180 |
// Linux. Try posix_getpwuid and posix_getuid.
|
181 |
if ( function_exists( 'posix_getuid' ) && function_exists( 'posix_getpwuid' ) ) {
|
182 |
-
$user
|
183 |
$home_dir = ( ! empty( $user['dir'] ) ? $user['dir'] : null );
|
184 |
}
|
185 |
|
@@ -272,10 +274,10 @@ class Boldgrid_Backup_Admin_Config {
|
|
272 |
*/
|
273 |
public function set_lang() {
|
274 |
$this->lang = array(
|
275 |
-
'website_size'
|
276 |
'database_size' => esc_html__( 'Database Size:', 'boldgrid-backup' ),
|
277 |
-
'of'
|
278 |
-
'xmark'
|
279 |
);
|
280 |
}
|
281 |
|
@@ -351,25 +353,22 @@ class Boldgrid_Backup_Admin_Config {
|
|
351 |
* @access private
|
352 |
*
|
353 |
* @param string $compressor A name of a compressor.
|
354 |
-
* @return null
|
355 |
*/
|
356 |
private function add_compressor( $compressor = null ) {
|
357 |
if ( ! empty( $compressor ) &&
|
358 |
! in_array( $compressor, $this->available_compressors, true ) ) {
|
359 |
$this->available_compressors[] = $compressor;
|
360 |
}
|
361 |
-
|
362 |
-
return;
|
363 |
}
|
364 |
|
365 |
/**
|
366 |
* Actions to take during the admin_init hook.
|
367 |
*
|
368 |
-
* @since 1.
|
369 |
*/
|
370 |
public function admin_init() {
|
371 |
$relative_path = 'boldgrid-backup-premium/boldgrid-backup-premium.php';
|
372 |
-
$abs_path
|
373 |
|
374 |
// Function is_plugin_active only available in and after admin_init.
|
375 |
$this->is_premium_active = is_plugin_active( $relative_path );
|
@@ -416,7 +415,7 @@ class Boldgrid_Backup_Admin_Config {
|
|
416 |
}
|
417 |
|
418 |
if ( ! class_exists( 'PclZip' ) ) {
|
419 |
-
require_once
|
420 |
}
|
421 |
|
422 |
// Initialize $this->available_compressors to an empty array.
|
@@ -427,7 +426,7 @@ class Boldgrid_Backup_Admin_Config {
|
|
427 |
$this->add_compressor( 'php_zip' );
|
428 |
}
|
429 |
|
430 |
-
// PclZip
|
431 |
if ( class_exists( 'PclZip' ) ) {
|
432 |
$this->add_compressor( 'pcl_zip' );
|
433 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-config.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.0
|
7 |
*
|
8 |
+
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
+
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
// phpcs:disable WordPress.VIP
|
16 |
+
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Config
|
19 |
*
|
20 |
* @since 1.0
|
21 |
*/
|
77 |
/**
|
78 |
* Whether or not the premium plugin is activated.
|
79 |
*
|
80 |
+
* @since 1.6.0
|
81 |
* @access public
|
82 |
* @var bool
|
83 |
*/
|
87 |
* Whether or not we have a premium license and the premium extension is
|
88 |
* installed.
|
89 |
*
|
90 |
+
* @since 1.6.0
|
91 |
* @access public
|
92 |
* @var bool
|
93 |
*/
|
97 |
* Whether or not the premium extension is installed (we didn't say activated,
|
98 |
* just installed, the files exist on the server).
|
99 |
*
|
100 |
+
* @since 1.6.0
|
101 |
* @access public
|
102 |
* @var bool
|
103 |
*/
|
135 |
}
|
136 |
|
137 |
if ( class_exists( '\Boldgrid\Library\Library\License' ) ) {
|
138 |
+
$this->license = new \Boldgrid\Library\Library\License();
|
139 |
$this->is_premium = $this->license->isPremium( 'boldgrid-backup' );
|
140 |
}
|
141 |
|
168 |
} elseif ( $this->core->test->is_windows() ) {
|
169 |
// Windows.
|
170 |
$home_drive = ( ! empty( $_SERVER['HOMEDRIVE'] ) ? $_SERVER['HOMEDRIVE'] : null );
|
171 |
+
$home_path = ( ! empty( $_SERVER['HOMEPATH'] ) ? $_SERVER['HOMEPATH'] : null );
|
172 |
|
173 |
if ( ! ( empty( $home_drive ) || empty( $home_path ) ) ) {
|
174 |
$home_dir = $home_drive . $home_path;
|
181 |
} else {
|
182 |
// Linux. Try posix_getpwuid and posix_getuid.
|
183 |
if ( function_exists( 'posix_getuid' ) && function_exists( 'posix_getpwuid' ) ) {
|
184 |
+
$user = posix_getpwuid( posix_getuid() );
|
185 |
$home_dir = ( ! empty( $user['dir'] ) ? $user['dir'] : null );
|
186 |
}
|
187 |
|
274 |
*/
|
275 |
public function set_lang() {
|
276 |
$this->lang = array(
|
277 |
+
'website_size' => esc_html__( 'Website Size:', 'boldgrid-backup' ),
|
278 |
'database_size' => esc_html__( 'Database Size:', 'boldgrid-backup' ),
|
279 |
+
'of' => esc_html__( 'of', 'boldgrid-backup' ),
|
280 |
+
'xmark' => '✗',
|
281 |
);
|
282 |
}
|
283 |
|
353 |
* @access private
|
354 |
*
|
355 |
* @param string $compressor A name of a compressor.
|
|
|
356 |
*/
|
357 |
private function add_compressor( $compressor = null ) {
|
358 |
if ( ! empty( $compressor ) &&
|
359 |
! in_array( $compressor, $this->available_compressors, true ) ) {
|
360 |
$this->available_compressors[] = $compressor;
|
361 |
}
|
|
|
|
|
362 |
}
|
363 |
|
364 |
/**
|
365 |
* Actions to take during the admin_init hook.
|
366 |
*
|
367 |
+
* @since 1.6.0
|
368 |
*/
|
369 |
public function admin_init() {
|
370 |
$relative_path = 'boldgrid-backup-premium/boldgrid-backup-premium.php';
|
371 |
+
$abs_path = dirname( BOLDGRID_BACKUP_PATH ) . '/' . $relative_path;
|
372 |
|
373 |
// Function is_plugin_active only available in and after admin_init.
|
374 |
$this->is_premium_active = is_plugin_active( $relative_path );
|
415 |
}
|
416 |
|
417 |
if ( ! class_exists( 'PclZip' ) ) {
|
418 |
+
require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
|
419 |
}
|
420 |
|
421 |
// Initialize $this->available_compressors to an empty array.
|
426 |
$this->add_compressor( 'php_zip' );
|
427 |
}
|
428 |
|
429 |
+
// PclZip.
|
430 |
if ( class_exists( 'PclZip' ) ) {
|
431 |
$this->add_compressor( 'pcl_zip' );
|
432 |
}
|
admin/class-boldgrid-backup-admin-core-files.php
CHANGED
@@ -1,28 +1,27 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since 1.
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
-
* @since 1.
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Core_Files {
|
21 |
-
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
25 |
-
* @since
|
26 |
* @access private
|
27 |
* @var Boldgrid_Backup_Admin_Core
|
28 |
*/
|
@@ -35,7 +34,7 @@ class Boldgrid_Backup_Admin_Core_Files {
|
|
35 |
* # The wp-content folder is not included.
|
36 |
* # .htaccess.bgb is included, but it is not a core file.
|
37 |
*
|
38 |
-
* @since
|
39 |
* @access public
|
40 |
* @var array
|
41 |
*/
|
@@ -65,7 +64,7 @@ class Boldgrid_Backup_Admin_Core_Files {
|
|
65 |
/**
|
66 |
* Constructor.
|
67 |
*
|
68 |
-
* @since 1.
|
69 |
*
|
70 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
71 |
*/
|
@@ -76,9 +75,9 @@ class Boldgrid_Backup_Admin_Core_Files {
|
|
76 |
/**
|
77 |
* Determine if a given $file (relative to ABSPATH) is a core file.
|
78 |
*
|
79 |
-
* @since 1.
|
80 |
*
|
81 |
-
* @param string $file
|
82 |
* @return bool
|
83 |
*/
|
84 |
public function is_core_file( $file ) {
|
@@ -94,5 +93,4 @@ class Boldgrid_Backup_Admin_Core_Files {
|
|
94 |
|
95 |
return false;
|
96 |
}
|
97 |
-
|
98 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-core-files.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.6.0
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_Core_Files
|
17 |
*
|
18 |
+
* @since 1.6.0
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Core_Files {
|
|
|
21 |
/**
|
22 |
* The core class object.
|
23 |
*
|
24 |
+
* @since 1.6.0
|
25 |
* @access private
|
26 |
* @var Boldgrid_Backup_Admin_Core
|
27 |
*/
|
34 |
* # The wp-content folder is not included.
|
35 |
* # .htaccess.bgb is included, but it is not a core file.
|
36 |
*
|
37 |
+
* @since 1.6.0
|
38 |
* @access public
|
39 |
* @var array
|
40 |
*/
|
64 |
/**
|
65 |
* Constructor.
|
66 |
*
|
67 |
+
* @since 1.6.0
|
68 |
*
|
69 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
70 |
*/
|
75 |
/**
|
76 |
* Determine if a given $file (relative to ABSPATH) is a core file.
|
77 |
*
|
78 |
+
* @since 1.6.0
|
79 |
*
|
80 |
+
* @param string $file File path.
|
81 |
* @return bool
|
82 |
*/
|
83 |
public function is_core_file( $file ) {
|
93 |
|
94 |
return false;
|
95 |
}
|
|
|
96 |
}
|
admin/class-boldgrid-backup-admin-core.php
CHANGED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since
|
7 |
*
|
8 |
-
* @package
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright
|
11 |
-
* @version
|
12 |
-
* @author
|
13 |
*/
|
14 |
|
|
|
|
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.0
|
19 |
*/
|
@@ -57,7 +59,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
57 |
/**
|
58 |
* Core Files class.
|
59 |
*
|
60 |
-
* @since
|
61 |
* @access public
|
62 |
* @var Boldgrid_Backup_Admin_Core_Files
|
63 |
*/
|
@@ -92,12 +94,14 @@ class Boldgrid_Backup_Admin_Core {
|
|
92 |
*
|
93 |
* In WordPress' wp-cron.php DOING_CRON is defined as true. In several of
|
94 |
* our files, we define DOING_CRON as well. When we want to tell the
|
95 |
-
* difference between (1)wp-cron.php and (2)cron / cli, it's difficult.
|
96 |
-
* property is
|
97 |
*
|
98 |
* @todo Within our plugins, DOING_CRON should be cleaned up.
|
99 |
*
|
100 |
-
* @since 1.
|
|
|
|
|
101 |
*/
|
102 |
public $doing_wp_cron;
|
103 |
|
@@ -143,7 +147,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
143 |
/**
|
144 |
* An instance of Boldgrid_Backup_Admin_Tools.
|
145 |
*
|
146 |
-
* @since
|
147 |
* @access public
|
148 |
* @var Boldgrid_Backup_Admin_Tools
|
149 |
*/
|
@@ -235,7 +239,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
235 |
/**
|
236 |
* An instance of the Boldgrid_Backup_Admin_Archives class.
|
237 |
*
|
238 |
-
* @since
|
239 |
* @access public
|
240 |
* @var Boldgrid_Backup_Admin_Archives
|
241 |
*/
|
@@ -244,7 +248,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
244 |
/**
|
245 |
* An instance of the Boldgrid_Backup_Admin_Archives_All class.
|
246 |
*
|
247 |
-
* @since
|
248 |
* @access public
|
249 |
* @var Boldgrid_Backup_Admin_Archives_All
|
250 |
*/
|
@@ -253,7 +257,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
253 |
/**
|
254 |
* An instance of the Boldgrid_Backup_Admin_Archive_Actions class.
|
255 |
*
|
256 |
-
* @since
|
257 |
* @access public
|
258 |
* @var Boldgrid_Backup_Admin_Archive_Actions
|
259 |
*/
|
@@ -360,7 +364,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
360 |
/**
|
361 |
* An instance of the Boldgrid_Backup_Admin_Folder_Exclusion class.
|
362 |
*
|
363 |
-
* @since 1.
|
364 |
* @var Boldgrid_Backup_Admin_Folder_Exclusion
|
365 |
*/
|
366 |
public $folder_exclusion;
|
@@ -368,7 +372,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
368 |
/**
|
369 |
* An instance of the Boldgrid_Backup_Admin_Ftp class.
|
370 |
*
|
371 |
-
* @since 1.
|
372 |
* @var Boldgrid_Backup_Admin_Ftp
|
373 |
*/
|
374 |
public $ftp;
|
@@ -376,7 +380,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
376 |
/**
|
377 |
* An instance of the Boldgrid_Backup_Admin_Go_Pro class.
|
378 |
*
|
379 |
-
* @since 1.
|
380 |
* @var Boldgrid_Backup_Admin_Go_Pro
|
381 |
*/
|
382 |
public $go_pro;
|
@@ -402,7 +406,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
402 |
* Value indicating we are in the Backup Site Now callback and the user is
|
403 |
* choosing a full backup.
|
404 |
*
|
405 |
-
* @since
|
406 |
* @access public
|
407 |
* @var bool
|
408 |
*/
|
@@ -411,7 +415,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
411 |
/**
|
412 |
* Value indicating we are in the Backup Site Now callback.
|
413 |
*
|
414 |
-
* @since
|
415 |
* @access public
|
416 |
* @var bool
|
417 |
*/
|
@@ -428,7 +432,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
428 |
/**
|
429 |
* An instance of the In Progress class.
|
430 |
*
|
431 |
-
* @since 1.
|
432 |
* @var Boldgrid_Backup_Admin_In_Progress object.
|
433 |
*/
|
434 |
public $in_progress;
|
@@ -437,7 +441,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
437 |
* Value indicating whether or not we're creating a backup for update
|
438 |
* protection.
|
439 |
*
|
440 |
-
* @since 1.
|
441 |
* @var bool
|
442 |
*/
|
443 |
public $is_archiving_update_protection = false;
|
@@ -490,9 +494,10 @@ class Boldgrid_Backup_Admin_Core {
|
|
490 |
|
491 |
global $pagenow;
|
492 |
|
493 |
-
$this->doing_cron
|
494 |
-
$this->doing_ajax
|
495 |
-
$this->doing_wp_cron = ! empty( $_SERVER['SCRIPT_FILENAME'] ) &&
|
|
|
496 |
|
497 |
$this->wp_filesystem = $wp_filesystem;
|
498 |
|
@@ -740,10 +745,12 @@ class Boldgrid_Backup_Admin_Core {
|
|
740 |
// Initialize $success.
|
741 |
$success = false;
|
742 |
|
|
|
|
|
743 |
// Test getting output using available execution functions, until one is successful.
|
744 |
foreach ( $available_exec_functions as $exec_function ) {
|
745 |
switch ( $exec_function ) {
|
746 |
-
case 'exec'
|
747 |
exec( $command, $out, $return_var );
|
748 |
|
749 |
// If the exit status is int(0), then it was successful.
|
@@ -759,7 +766,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
759 |
|
760 |
break 2;
|
761 |
|
762 |
-
case 'passthru'
|
763 |
// If output buffering is enabled, then use passthru.
|
764 |
if ( ob_start() ) {
|
765 |
passthru( $command, $return_var );
|
@@ -779,7 +786,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
779 |
|
780 |
break 2;
|
781 |
|
782 |
-
case 'popen'
|
783 |
$handle = popen( $command, 'r' );
|
784 |
|
785 |
$output = fread( $handle, 4096 );
|
@@ -807,7 +814,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
807 |
|
808 |
break 2;
|
809 |
|
810 |
-
case 'proc_open'
|
811 |
// Create the descriptor spec array.
|
812 |
$descriptorspec = array(
|
813 |
0 => array(
|
@@ -855,7 +862,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
855 |
|
856 |
break 2;
|
857 |
|
858 |
-
case 'shell_exec'
|
859 |
$output = shell_exec( $command );
|
860 |
|
861 |
if ( false === strpos( $output, 'command not found' ) ) {
|
@@ -868,7 +875,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
868 |
|
869 |
break 2;
|
870 |
|
871 |
-
case 'system'
|
872 |
// If output buffering is enabled, then use system.
|
873 |
if ( ob_start() ) {
|
874 |
system( $command, $return_var );
|
@@ -888,11 +895,13 @@ class Boldgrid_Backup_Admin_Core {
|
|
888 |
|
889 |
break 2;
|
890 |
|
891 |
-
default
|
892 |
break;
|
893 |
}
|
894 |
}
|
895 |
|
|
|
|
|
896 |
// If there is output, then trim it.
|
897 |
if ( ! empty( $output ) ) {
|
898 |
$output = trim( $output );
|
@@ -913,19 +922,17 @@ class Boldgrid_Backup_Admin_Core {
|
|
913 |
* @since 1.0
|
914 |
*
|
915 |
* @global array $submenu
|
916 |
-
*
|
917 |
-
* @return null
|
918 |
*/
|
919 |
public function add_menu_items() {
|
920 |
global $submenu;
|
921 |
|
922 |
$lang = array(
|
923 |
-
'backup_archive'
|
924 |
'boldgrid_backup' => __( 'BoldGrid Backup', 'boldgrid-backup' ),
|
925 |
-
'get_premium'
|
926 |
'preflight_check' => __( 'Preflight Check', 'boldgrid-backup' ),
|
927 |
-
'settings'
|
928 |
-
'tools'
|
929 |
);
|
930 |
|
931 |
// The main slug all sub menu items are children of.
|
@@ -1037,8 +1044,6 @@ class Boldgrid_Backup_Admin_Core {
|
|
1037 |
}
|
1038 |
}
|
1039 |
}
|
1040 |
-
|
1041 |
-
return;
|
1042 |
}
|
1043 |
|
1044 |
/**
|
@@ -1075,7 +1080,6 @@ class Boldgrid_Backup_Admin_Core {
|
|
1075 |
* @return bool Status of the operation.
|
1076 |
*/
|
1077 |
private function backup_database() {
|
1078 |
-
|
1079 |
/*
|
1080 |
* If we're omitting all the tables, we can skip trying to backup the
|
1081 |
* database.
|
@@ -1099,7 +1103,13 @@ class Boldgrid_Backup_Admin_Core {
|
|
1099 |
|
1100 |
// Check if the backup directory is writable.
|
1101 |
if ( ! $wp_filesystem->is_writable( $backup_directory ) ) {
|
1102 |
-
return array(
|
|
|
|
|
|
|
|
|
|
|
|
|
1103 |
}
|
1104 |
|
1105 |
// Create a file path for the dump file.
|
@@ -1119,11 +1129,23 @@ class Boldgrid_Backup_Admin_Core {
|
|
1119 |
// Ensure file is written and is over 100 bytes.
|
1120 |
$exists = $this->test->exists( $db_dump_filepath );
|
1121 |
if ( ! $exists ) {
|
1122 |
-
return array(
|
|
|
|
|
|
|
|
|
|
|
|
|
1123 |
}
|
1124 |
$dump_file_size = $this->wp_filesystem->size( $db_dump_filepath );
|
1125 |
if ( 100 > $dump_file_size ) {
|
1126 |
-
return array(
|
|
|
|
|
|
|
|
|
|
|
|
|
1127 |
}
|
1128 |
|
1129 |
// Limit file permissions to the dump file.
|
@@ -1179,12 +1201,12 @@ class Boldgrid_Backup_Admin_Core {
|
|
1179 |
|
1180 |
// Get the WP Options for "siteurl" and "home", to restore later.
|
1181 |
$wp_siteurl = get_option( 'siteurl' );
|
1182 |
-
$wp_home
|
1183 |
|
1184 |
$this->set_time_limit();
|
1185 |
|
1186 |
$importer = new Boldgrid_Backup_Admin_Db_Import();
|
1187 |
-
$status
|
1188 |
|
1189 |
if ( ! empty( $status['error'] ) ) {
|
1190 |
do_action( 'boldgrid_backup_notice', $status['error'], 'notice notice-error is-dismissible' );
|
@@ -1205,7 +1227,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
1205 |
|
1206 |
// Get the restored "siteurl" and "home".
|
1207 |
$restored_wp_siteurl = get_option( 'siteurl' );
|
1208 |
-
$restored_wp_home
|
1209 |
|
1210 |
// If changed, then update the siteurl in the database.
|
1211 |
if ( $restored_wp_siteurl !== $wp_siteurl ) {
|
@@ -1288,16 +1310,14 @@ class Boldgrid_Backup_Admin_Core {
|
|
1288 |
$dirpath,
|
1289 |
str_replace( ABSPATH, '', $dirpath ),
|
1290 |
0,
|
1291 |
-
|
1292 |
-
* @since 1.5.4, this 4th key represetnts 'type', as in a file
|
1293 |
-
* or a directory.
|
1294 |
-
*/
|
1295 |
'd',
|
1296 |
);
|
1297 |
}
|
1298 |
|
1299 |
// Sort the dirlist array by filename.
|
1300 |
-
uasort(
|
|
|
1301 |
function ( $a, $b ) {
|
1302 |
if ( $a['name'] < $b['name'] ) {
|
1303 |
return - 1;
|
@@ -1375,7 +1395,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
1375 |
foreach ( $filelist as $fileinfo ) {
|
1376 |
|
1377 |
// @todo The user needs a way to specifiy what to skip in the backups.
|
1378 |
-
$is_node_modules
|
1379 |
$is_backup_directory = $this->backup_dir->file_in_dir( $fileinfo[1] );
|
1380 |
|
1381 |
if ( $is_node_modules || $is_backup_directory ) {
|
@@ -1426,7 +1446,8 @@ class Boldgrid_Backup_Admin_Core {
|
|
1426 |
// Create a site identifier.
|
1427 |
$site_id = Boldgrid_Backup_Admin_Utility::create_site_id();
|
1428 |
|
1429 |
-
$filename = sprintf(
|
|
|
1430 |
$site_id,
|
1431 |
$backup_identifier,
|
1432 |
date( 'Ymd-His' )
|
@@ -1494,7 +1515,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
1494 |
// Check if functional.
|
1495 |
if ( ! $this->test->run_functionality_tests() ) {
|
1496 |
// Display an error notice, if not already on the test page.
|
1497 |
-
if ( ! isset( $_GET['page'] ) || 'boldgrid-backup-test' !== $_GET['page'] ) {
|
1498 |
// Display an error notice.
|
1499 |
$this->notice->functionality_fail_notice();
|
1500 |
}
|
@@ -1507,29 +1528,29 @@ class Boldgrid_Backup_Admin_Core {
|
|
1507 |
// Close any PHP session, so that another session can open during the backup operation.
|
1508 |
session_write_close();
|
1509 |
|
1510 |
-
|
|
|
|
|
|
|
|
|
|
|
1511 |
$info = array(
|
1512 |
-
'mode'
|
1513 |
-
'dryrun'
|
1514 |
-
'compressor'
|
1515 |
-
'filesize'
|
1516 |
-
'save'
|
1517 |
-
'total_size'
|
1518 |
-
/*
|
1519 |
-
* As of 1.6.0, the folder include and exclude settings below are
|
1520 |
-
* for informational purposes only. This array cannot be filtered to
|
1521 |
-
* adjust which folders are actually included / excluded.
|
1522 |
-
*/
|
1523 |
'folder_include' => $this->folder_exclusion->from_settings( 'include' ),
|
1524 |
'folder_exclude' => $this->folder_exclusion->from_settings( 'exclude' ),
|
1525 |
-
'table_exclude'
|
1526 |
);
|
1527 |
|
1528 |
// Determine how this backup was triggered.
|
1529 |
if ( $this->pre_auto_update ) {
|
1530 |
$info['trigger'] = __( 'Auto update', 'boldgrid-bakcup' );
|
1531 |
} elseif ( $this->doing_ajax && is_user_logged_in() ) {
|
1532 |
-
$current_user
|
1533 |
$info['trigger'] = $current_user->user_login . ' (' . $current_user->user_email . ')';
|
1534 |
} elseif ( $this->doing_wp_cron ) {
|
1535 |
$info['trigger'] = 'WP cron';
|
@@ -1622,35 +1643,35 @@ class Boldgrid_Backup_Admin_Core {
|
|
1622 |
* If the is no available compressor, then return an error.
|
1623 |
*/
|
1624 |
switch ( $info['compressor'] ) {
|
1625 |
-
case 'php_zip'
|
1626 |
$compressor = new Boldgrid_Backup_Admin_Compressor_Php_Zip( $this );
|
1627 |
-
$status
|
1628 |
break;
|
1629 |
-
case 'pcl_zip'
|
1630 |
$compressor = new Boldgrid_Backup_Admin_Compressor_Pcl_Zip( $this );
|
1631 |
-
$status
|
1632 |
break;
|
1633 |
-
case 'php_bz2'
|
1634 |
// Generate a new archive file path.
|
1635 |
$info['filepath'] = $this->generate_archive_path( 'b2z' );
|
1636 |
break;
|
1637 |
-
case 'php_zlib'
|
1638 |
// Generate a new archive file path.
|
1639 |
$info['filepath'] = $this->generate_archive_path( 'zlib' );
|
1640 |
break;
|
1641 |
-
case 'php_lzf'
|
1642 |
// Generate a new archive file path.
|
1643 |
$info['filepath'] = $this->generate_archive_path( 'lzf' );
|
1644 |
break;
|
1645 |
-
case 'system_tar'
|
1646 |
// Generate a new archive file path.
|
1647 |
$info['filepath'] = $this->generate_archive_path( 'tar.gz' );
|
1648 |
break;
|
1649 |
-
case 'system_zip'
|
1650 |
// Generate a new archive file path.
|
1651 |
$info['filepath'] = $this->generate_archive_path( 'zip' );
|
1652 |
break;
|
1653 |
-
default
|
1654 |
$status = array(
|
1655 |
'error' => 'No available compressor',
|
1656 |
);
|
@@ -1686,7 +1707,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
1686 |
$time_stop = microtime( true );
|
1687 |
|
1688 |
// Calculate duration.
|
1689 |
-
$info['duration']
|
1690 |
$info['db_duration'] = number_format( ( $db_time_stop - $time_start ), 2, '.', '' );
|
1691 |
|
1692 |
/**
|
@@ -1720,8 +1741,8 @@ class Boldgrid_Backup_Admin_Core {
|
|
1720 |
|
1721 |
// Send an email.
|
1722 |
if ( $this->email->user_wants_notification( 'backup' ) && $this->doing_ajax ) {
|
1723 |
-
$email_parts
|
1724 |
-
$email_body
|
1725 |
$info['mail_success'] = $this->email->send( $email_parts['subject'], $email_body );
|
1726 |
}
|
1727 |
|
@@ -1752,12 +1773,12 @@ class Boldgrid_Backup_Admin_Core {
|
|
1752 |
* @param string $download_filename A filename to match to get info.
|
1753 |
* @param string $backup_directory Specify a directory to look within for backups.
|
1754 |
* @return array {
|
1755 |
-
*
|
1756 |
-
*
|
1757 |
-
*
|
1758 |
-
*
|
1759 |
-
*
|
1760 |
-
*
|
1761 |
* }
|
1762 |
*/
|
1763 |
public function get_archive_list( $download_filename = null, $backup_directory = null ) {
|
@@ -1786,7 +1807,8 @@ class Boldgrid_Backup_Admin_Core {
|
|
1786 |
}
|
1787 |
|
1788 |
// Sort the dirlist array by "lastmodunix" descending.
|
1789 |
-
uasort(
|
|
|
1790 |
function ( $a, $b ) {
|
1791 |
if ( $a['lastmodunix'] < $b['lastmodunix'] ) {
|
1792 |
return 1;
|
@@ -1817,12 +1839,12 @@ class Boldgrid_Backup_Admin_Core {
|
|
1817 |
// Create the return array.
|
1818 |
// @todo Should we use the data and time from the filename, or rely on lastmodunix?
|
1819 |
$archive_files[ $index ] = array(
|
1820 |
-
'filepath'
|
1821 |
-
'filename'
|
1822 |
-
'filedate'
|
1823 |
date( 'Y-m-d H:i:s', $fileinfo['lastmodunix'] ), 'n/j/Y g:i A'
|
1824 |
),
|
1825 |
-
'filesize'
|
1826 |
'lastmodunix' => $fileinfo['lastmodunix'],
|
1827 |
);
|
1828 |
|
@@ -1916,7 +1938,8 @@ class Boldgrid_Backup_Admin_Core {
|
|
1916 |
// Verify specified filename.
|
1917 |
if ( $archive_filename !== $filename ) {
|
1918 |
// Fail with a notice.
|
1919 |
-
do_action(
|
|
|
1920 |
esc_html__( 'The selected archive file was not found.', 'boldgrid-backup' ),
|
1921 |
'notice notice-error is-dismissible'
|
1922 |
);
|
@@ -1989,7 +2012,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
1989 |
* restore (the first applicable one it can find).
|
1990 |
*/
|
1991 |
$pcl_zip = new Boldgrid_Backup_Admin_Compressor_Pcl_Zip( $this );
|
1992 |
-
$sqls
|
1993 |
if ( 1 === count( $sqls ) ) {
|
1994 |
return ABSPATH . $sqls[0];
|
1995 |
}
|
@@ -2006,7 +2029,8 @@ class Boldgrid_Backup_Admin_Core {
|
|
2006 |
}
|
2007 |
|
2008 |
// Sort the dirlist array by "name" descending.
|
2009 |
-
uasort(
|
|
|
2010 |
function ( $a, $b ) {
|
2011 |
if ( $a['name'] < $b['name'] ) {
|
2012 |
return 1;
|
@@ -2020,11 +2044,13 @@ class Boldgrid_Backup_Admin_Core {
|
|
2020 |
}
|
2021 |
);
|
2022 |
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
|
|
|
|
2026 |
foreach ( $dirlist as $fileinfo ) {
|
2027 |
-
if ( 1 === preg_match( '/\.[\d]+-[\d]+\.sql$/'
|
2028 |
$db_dump_filepath = ABSPATH . $fileinfo['name'];
|
2029 |
break;
|
2030 |
}
|
@@ -2048,7 +2074,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
2048 |
$restore_ok = true;
|
2049 |
|
2050 |
// If a restoration was not requested, then abort.
|
2051 |
-
if ( empty( $_POST['restore_now'] ) ) {
|
2052 |
return array(
|
2053 |
'error' => esc_html__( 'Invalid restore_now value.', 'boldgrid-backup' ),
|
2054 |
);
|
@@ -2062,11 +2088,11 @@ class Boldgrid_Backup_Admin_Core {
|
|
2062 |
}
|
2063 |
|
2064 |
// Initialize variables.
|
2065 |
-
$archive_key
|
2066 |
$archive_filename = null;
|
2067 |
|
2068 |
// Validate archive_key.
|
2069 |
-
if ( isset( $_POST['archive_key'] ) && is_numeric( $_POST['archive_key'] ) ) {
|
2070 |
$archive_key = (int) $_POST['archive_key'];
|
2071 |
} else {
|
2072 |
return array(
|
@@ -2075,7 +2101,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
2075 |
}
|
2076 |
|
2077 |
// Validate archive_filename.
|
2078 |
-
if ( ! empty( $_POST['archive_filename'] ) ) {
|
2079 |
$archive_filename = sanitize_file_name( $_POST['archive_filename'] );
|
2080 |
} else {
|
2081 |
return array(
|
@@ -2113,13 +2139,13 @@ class Boldgrid_Backup_Admin_Core {
|
|
2113 |
|
2114 |
// Populate $info.
|
2115 |
$info = array(
|
2116 |
-
'mode'
|
2117 |
-
'dryrun'
|
2118 |
-
'filename'
|
2119 |
-
'filepath'
|
2120 |
-
'filesize'
|
2121 |
'archive_key' => $archive_key,
|
2122 |
-
'restore_ok'
|
2123 |
);
|
2124 |
|
2125 |
// Prevent this script from dying.
|
@@ -2155,8 +2181,8 @@ class Boldgrid_Backup_Admin_Core {
|
|
2155 |
|
2156 |
if ( empty( $error ) ) {
|
2157 |
$message = $unzip_status->get_error_message();
|
2158 |
-
$data
|
2159 |
-
$error
|
2160 |
}
|
2161 |
|
2162 |
return array(
|
@@ -2302,8 +2328,6 @@ class Boldgrid_Backup_Admin_Core {
|
|
2302 |
|
2303 |
// Include the home page template.
|
2304 |
include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-home.php';
|
2305 |
-
|
2306 |
-
return;
|
2307 |
}
|
2308 |
|
2309 |
/**
|
@@ -2335,7 +2359,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
2335 |
|
2336 |
$this->is_backup_now = true;
|
2337 |
|
2338 |
-
$key
|
2339 |
$this->is_backup_full = isset( $_POST[ $key ] ) && 'full' === $_POST[ $key ];
|
2340 |
|
2341 |
$this->is_archiving_update_protection = ! empty( $_POST['is_updating'] ) &&
|
@@ -2346,14 +2370,18 @@ class Boldgrid_Backup_Admin_Core {
|
|
2346 |
if ( ! $this->is_archiving_update_protection ) {
|
2347 |
$message = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-backup.php';
|
2348 |
$this->notice->add_user_notice( $message['message'], $message['class'] );
|
2349 |
-
wp_send_json_success(
|
2350 |
-
|
2351 |
-
|
|
|
|
|
2352 |
} else {
|
2353 |
update_site_option( 'boldgrid_backup_pending_rollback', $archive_info );
|
2354 |
-
wp_send_json_success(
|
2355 |
-
|
2356 |
-
|
|
|
|
|
2357 |
}
|
2358 |
}
|
2359 |
|
@@ -2440,7 +2468,9 @@ class Boldgrid_Backup_Admin_Core {
|
|
2440 |
session_write_close();
|
2441 |
|
2442 |
// Send the file. Not finding a replacement in $wp_filesystem.
|
|
|
2443 |
readfile( $filepath );
|
|
|
2444 |
|
2445 |
// Exit.
|
2446 |
wp_die();
|
@@ -2453,8 +2483,6 @@ class Boldgrid_Backup_Admin_Core {
|
|
2453 |
*
|
2454 |
* @global string $wp_version The WordPress version string.
|
2455 |
* @global wpdb $wpdb The WordPress database class object.
|
2456 |
-
*
|
2457 |
-
* @return null
|
2458 |
*/
|
2459 |
public function page_backup_test() {
|
2460 |
// Perform functionality tests.
|
@@ -2504,15 +2532,14 @@ class Boldgrid_Backup_Admin_Core {
|
|
2504 |
$cli_support = $this->test->get_cli_support();
|
2505 |
|
2506 |
// Enqueue CSS for the test page.
|
2507 |
-
wp_enqueue_style(
|
|
|
2508 |
plugin_dir_url( __FILE__ ) . 'css/boldgrid-backup-admin-test.css', array(),
|
2509 |
BOLDGRID_BACKUP_VERSION, 'all'
|
2510 |
);
|
2511 |
|
2512 |
// Load template view.
|
2513 |
include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-test.php';
|
2514 |
-
|
2515 |
-
return;
|
2516 |
}
|
2517 |
|
2518 |
/**
|
@@ -2523,26 +2550,26 @@ class Boldgrid_Backup_Admin_Core {
|
|
2523 |
public function set_lang() {
|
2524 |
$this->lang = array(
|
2525 |
// Mine count, total number of backups.
|
2526 |
-
'All'
|
2527 |
-
'backup_created'
|
2528 |
-
'Checking_credentials'
|
2529 |
-
'checkmark'
|
2530 |
-
'icon_success'
|
2531 |
-
'icon_warning'
|
2532 |
'heading_update_protection' => __( 'BoldGrid Backup - Update Protection', 'boldgrid-backup' ),
|
2533 |
// Mine count, number of backups on remote storage providers.
|
2534 |
-
'Remote'
|
2535 |
-
'spinner'
|
2536 |
-
'spinner_inline'
|
2537 |
-
'want_to'
|
2538 |
// Mine count, number of backups on local web server.
|
2539 |
-
'Web_Server'
|
2540 |
);
|
2541 |
|
2542 |
$this->elements = array(
|
2543 |
'update_protection_activated' => sprintf( '%1$s %2$s', $this->lang['icon_success'], __( 'Update protection activated!', 'boldgrid-backup' ) ),
|
2544 |
// Use on long loading pages. Javascript will remove this on page load.
|
2545 |
-
'long_checking_creds'
|
2546 |
);
|
2547 |
}
|
2548 |
|
@@ -2557,19 +2584,18 @@ class Boldgrid_Backup_Admin_Core {
|
|
2557 |
* @param int $time_limit Limit in seconds.
|
2558 |
*/
|
2559 |
public function set_time_limit( $time_limit = 900 ) {
|
2560 |
-
|
2561 |
-
|
2562 |
-
|
2563 |
-
) );
|
2564 |
}
|
2565 |
|
2566 |
/**
|
2567 |
* Handle ajax request to restore a file.
|
2568 |
*
|
2569 |
-
* @since 1.
|
2570 |
*/
|
2571 |
public function wp_ajax_restore() {
|
2572 |
-
$error
|
2573 |
$redirect_url = admin_url( 'admin.php?page=boldgrid-backup' );
|
2574 |
|
2575 |
// Validate user role.
|
@@ -2607,21 +2633,23 @@ class Boldgrid_Backup_Admin_Core {
|
|
2607 |
if ( $is_success ) {
|
2608 |
$message = array(
|
2609 |
'message' => esc_html__( 'The selected archive file has been successfully restored.', 'boldgrid-backup' ),
|
2610 |
-
'class'
|
2611 |
-
'header'
|
2612 |
);
|
2613 |
} else {
|
2614 |
$message = array(
|
2615 |
'message' => ! empty( $archive_info['error'] ) ? $archive_info['error'] : __( 'Unknown error when attempting to restore archive.', 'bolcgrid-backup' ),
|
2616 |
-
'class'
|
2617 |
-
'header'
|
2618 |
);
|
2619 |
}
|
2620 |
$this->notice->add_user_notice( $message['message'], $message['class'], $message['header'] );
|
2621 |
|
2622 |
-
wp_send_json_success(
|
2623 |
-
|
2624 |
-
|
|
|
|
|
2625 |
}
|
2626 |
|
2627 |
/**
|
@@ -2656,9 +2684,7 @@ class Boldgrid_Backup_Admin_Core {
|
|
2656 |
}
|
2657 |
|
2658 |
// Perform the backup operation.
|
2659 |
-
$
|
2660 |
-
|
2661 |
-
return;
|
2662 |
}
|
2663 |
|
2664 |
/**
|
@@ -2721,7 +2747,5 @@ class Boldgrid_Backup_Admin_Core {
|
|
2721 |
// Increment the counter.
|
2722 |
$counter --;
|
2723 |
}
|
2724 |
-
|
2725 |
-
return;
|
2726 |
}
|
2727 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-core.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.0
|
7 |
*
|
8 |
+
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
+
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
// phpcs:disable WordPress.VIP
|
16 |
+
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Core
|
19 |
*
|
20 |
* @since 1.0
|
21 |
*/
|
59 |
/**
|
60 |
* Core Files class.
|
61 |
*
|
62 |
+
* @since 1.6.0
|
63 |
* @access public
|
64 |
* @var Boldgrid_Backup_Admin_Core_Files
|
65 |
*/
|
94 |
*
|
95 |
* In WordPress' wp-cron.php DOING_CRON is defined as true. In several of
|
96 |
* our files, we define DOING_CRON as well. When we want to tell the
|
97 |
+
* difference between (1)wp-cron.php and (2)cron / cli, it's difficult.
|
98 |
+
* This property is solely to know if we're in wp-cron.php.
|
99 |
*
|
100 |
* @todo Within our plugins, DOING_CRON should be cleaned up.
|
101 |
*
|
102 |
+
* @since 1.6.0
|
103 |
+
*
|
104 |
+
* @var bool
|
105 |
*/
|
106 |
public $doing_wp_cron;
|
107 |
|
147 |
/**
|
148 |
* An instance of Boldgrid_Backup_Admin_Tools.
|
149 |
*
|
150 |
+
* @since 1.6.0
|
151 |
* @access public
|
152 |
* @var Boldgrid_Backup_Admin_Tools
|
153 |
*/
|
239 |
/**
|
240 |
* An instance of the Boldgrid_Backup_Admin_Archives class.
|
241 |
*
|
242 |
+
* @since 1.6.0
|
243 |
* @access public
|
244 |
* @var Boldgrid_Backup_Admin_Archives
|
245 |
*/
|
248 |
/**
|
249 |
* An instance of the Boldgrid_Backup_Admin_Archives_All class.
|
250 |
*
|
251 |
+
* @since 1.6.0
|
252 |
* @access public
|
253 |
* @var Boldgrid_Backup_Admin_Archives_All
|
254 |
*/
|
257 |
/**
|
258 |
* An instance of the Boldgrid_Backup_Admin_Archive_Actions class.
|
259 |
*
|
260 |
+
* @since 1.6.0
|
261 |
* @access public
|
262 |
* @var Boldgrid_Backup_Admin_Archive_Actions
|
263 |
*/
|
364 |
/**
|
365 |
* An instance of the Boldgrid_Backup_Admin_Folder_Exclusion class.
|
366 |
*
|
367 |
+
* @since 1.6.0
|
368 |
* @var Boldgrid_Backup_Admin_Folder_Exclusion
|
369 |
*/
|
370 |
public $folder_exclusion;
|
372 |
/**
|
373 |
* An instance of the Boldgrid_Backup_Admin_Ftp class.
|
374 |
*
|
375 |
+
* @since 1.6.0
|
376 |
* @var Boldgrid_Backup_Admin_Ftp
|
377 |
*/
|
378 |
public $ftp;
|
380 |
/**
|
381 |
* An instance of the Boldgrid_Backup_Admin_Go_Pro class.
|
382 |
*
|
383 |
+
* @since 1.6.0
|
384 |
* @var Boldgrid_Backup_Admin_Go_Pro
|
385 |
*/
|
386 |
public $go_pro;
|
406 |
* Value indicating we are in the Backup Site Now callback and the user is
|
407 |
* choosing a full backup.
|
408 |
*
|
409 |
+
* @since 1.6.0
|
410 |
* @access public
|
411 |
* @var bool
|
412 |
*/
|
415 |
/**
|
416 |
* Value indicating we are in the Backup Site Now callback.
|
417 |
*
|
418 |
+
* @since 1.6.0
|
419 |
* @access public
|
420 |
* @var bool
|
421 |
*/
|
432 |
/**
|
433 |
* An instance of the In Progress class.
|
434 |
*
|
435 |
+
* @since 1.6.0
|
436 |
* @var Boldgrid_Backup_Admin_In_Progress object.
|
437 |
*/
|
438 |
public $in_progress;
|
441 |
* Value indicating whether or not we're creating a backup for update
|
442 |
* protection.
|
443 |
*
|
444 |
+
* @since 1.6.0
|
445 |
* @var bool
|
446 |
*/
|
447 |
public $is_archiving_update_protection = false;
|
494 |
|
495 |
global $pagenow;
|
496 |
|
497 |
+
$this->doing_cron = ( defined( 'DOING_CRON' ) && DOING_CRON ) || isset( $_GET['doing_wp_cron'] ); // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
498 |
+
$this->doing_ajax = is_admin() && defined( 'DOING_AJAX' ) && DOING_AJAX;
|
499 |
+
$this->doing_wp_cron = ! empty( $_SERVER['SCRIPT_FILENAME'] ) &&
|
500 |
+
trailingslashit( ABSPATH ) . 'wp-cron.php' === $_SERVER['SCRIPT_FILENAME'];
|
501 |
|
502 |
$this->wp_filesystem = $wp_filesystem;
|
503 |
|
745 |
// Initialize $success.
|
746 |
$success = false;
|
747 |
|
748 |
+
// phpcs:disable WordPress.PHP.DiscouragedPHPFunctions, WordPress.WP.AlternativeFunctions
|
749 |
+
|
750 |
// Test getting output using available execution functions, until one is successful.
|
751 |
foreach ( $available_exec_functions as $exec_function ) {
|
752 |
switch ( $exec_function ) {
|
753 |
+
case 'exec':
|
754 |
exec( $command, $out, $return_var );
|
755 |
|
756 |
// If the exit status is int(0), then it was successful.
|
766 |
|
767 |
break 2;
|
768 |
|
769 |
+
case 'passthru':
|
770 |
// If output buffering is enabled, then use passthru.
|
771 |
if ( ob_start() ) {
|
772 |
passthru( $command, $return_var );
|
786 |
|
787 |
break 2;
|
788 |
|
789 |
+
case 'popen':
|
790 |
$handle = popen( $command, 'r' );
|
791 |
|
792 |
$output = fread( $handle, 4096 );
|
814 |
|
815 |
break 2;
|
816 |
|
817 |
+
case 'proc_open':
|
818 |
// Create the descriptor spec array.
|
819 |
$descriptorspec = array(
|
820 |
0 => array(
|
862 |
|
863 |
break 2;
|
864 |
|
865 |
+
case 'shell_exec':
|
866 |
$output = shell_exec( $command );
|
867 |
|
868 |
if ( false === strpos( $output, 'command not found' ) ) {
|
875 |
|
876 |
break 2;
|
877 |
|
878 |
+
case 'system':
|
879 |
// If output buffering is enabled, then use system.
|
880 |
if ( ob_start() ) {
|
881 |
system( $command, $return_var );
|
895 |
|
896 |
break 2;
|
897 |
|
898 |
+
default:
|
899 |
break;
|
900 |
}
|
901 |
}
|
902 |
|
903 |
+
// phpcs:enable WordPress.PHP.DiscouragedPHPFunctions, WordPress.WP.AlternativeFunctions
|
904 |
+
|
905 |
// If there is output, then trim it.
|
906 |
if ( ! empty( $output ) ) {
|
907 |
$output = trim( $output );
|
922 |
* @since 1.0
|
923 |
*
|
924 |
* @global array $submenu
|
|
|
|
|
925 |
*/
|
926 |
public function add_menu_items() {
|
927 |
global $submenu;
|
928 |
|
929 |
$lang = array(
|
930 |
+
'backup_archive' => __( 'Backup Archive', 'boldgrid-backup' ),
|
931 |
'boldgrid_backup' => __( 'BoldGrid Backup', 'boldgrid-backup' ),
|
932 |
+
'get_premium' => __( 'Get Premium', 'boldgrid-bacukp' ),
|
933 |
'preflight_check' => __( 'Preflight Check', 'boldgrid-backup' ),
|
934 |
+
'settings' => __( 'Settings', 'boldgrid-backup' ),
|
935 |
+
'tools' => __( 'Tools', 'boldgrid-backup' ),
|
936 |
);
|
937 |
|
938 |
// The main slug all sub menu items are children of.
|
1044 |
}
|
1045 |
}
|
1046 |
}
|
|
|
|
|
1047 |
}
|
1048 |
|
1049 |
/**
|
1080 |
* @return bool Status of the operation.
|
1081 |
*/
|
1082 |
private function backup_database() {
|
|
|
1083 |
/*
|
1084 |
* If we're omitting all the tables, we can skip trying to backup the
|
1085 |
* database.
|
1103 |
|
1104 |
// Check if the backup directory is writable.
|
1105 |
if ( ! $wp_filesystem->is_writable( $backup_directory ) ) {
|
1106 |
+
return array(
|
1107 |
+
'error' => sprintf(
|
1108 |
+
// translators: 1: Backup directory path.
|
1109 |
+
__( 'The backup directory is not writable: %1$s.', 'boldgrid-backup' ),
|
1110 |
+
$backup_directory
|
1111 |
+
),
|
1112 |
+
);
|
1113 |
}
|
1114 |
|
1115 |
// Create a file path for the dump file.
|
1129 |
// Ensure file is written and is over 100 bytes.
|
1130 |
$exists = $this->test->exists( $db_dump_filepath );
|
1131 |
if ( ! $exists ) {
|
1132 |
+
return array(
|
1133 |
+
'error' => sprintf(
|
1134 |
+
// translators: 1: MySQL dump file path.
|
1135 |
+
__( 'mysqldump file does not exist: %1$s', 'boldgrid-backup' ),
|
1136 |
+
$db_dump_filepath
|
1137 |
+
),
|
1138 |
+
);
|
1139 |
}
|
1140 |
$dump_file_size = $this->wp_filesystem->size( $db_dump_filepath );
|
1141 |
if ( 100 > $dump_file_size ) {
|
1142 |
+
return array(
|
1143 |
+
'error' => sprintf(
|
1144 |
+
// translators: 1: MySQL dump file path.
|
1145 |
+
__( 'mysqldump file was not written to: %1$s', 'boldgrid-backup' ),
|
1146 |
+
$db_dump_filepath
|
1147 |
+
),
|
1148 |
+
);
|
1149 |
}
|
1150 |
|
1151 |
// Limit file permissions to the dump file.
|
1201 |
|
1202 |
// Get the WP Options for "siteurl" and "home", to restore later.
|
1203 |
$wp_siteurl = get_option( 'siteurl' );
|
1204 |
+
$wp_home = get_option( 'home' );
|
1205 |
|
1206 |
$this->set_time_limit();
|
1207 |
|
1208 |
$importer = new Boldgrid_Backup_Admin_Db_Import();
|
1209 |
+
$status = $importer->import( $db_dump_filepath );
|
1210 |
|
1211 |
if ( ! empty( $status['error'] ) ) {
|
1212 |
do_action( 'boldgrid_backup_notice', $status['error'], 'notice notice-error is-dismissible' );
|
1227 |
|
1228 |
// Get the restored "siteurl" and "home".
|
1229 |
$restored_wp_siteurl = get_option( 'siteurl' );
|
1230 |
+
$restored_wp_home = get_option( 'home' );
|
1231 |
|
1232 |
// If changed, then update the siteurl in the database.
|
1233 |
if ( $restored_wp_siteurl !== $wp_siteurl ) {
|
1310 |
$dirpath,
|
1311 |
str_replace( ABSPATH, '', $dirpath ),
|
1312 |
0,
|
1313 |
+
// Since 1.6.0, this 4th key represetnts 'type', as in a file or a directory.
|
|
|
|
|
|
|
1314 |
'd',
|
1315 |
);
|
1316 |
}
|
1317 |
|
1318 |
// Sort the dirlist array by filename.
|
1319 |
+
uasort(
|
1320 |
+
$dirlist,
|
1321 |
function ( $a, $b ) {
|
1322 |
if ( $a['name'] < $b['name'] ) {
|
1323 |
return - 1;
|
1395 |
foreach ( $filelist as $fileinfo ) {
|
1396 |
|
1397 |
// @todo The user needs a way to specifiy what to skip in the backups.
|
1398 |
+
$is_node_modules = false !== strpos( $fileinfo[1], '/node_modules/' );
|
1399 |
$is_backup_directory = $this->backup_dir->file_in_dir( $fileinfo[1] );
|
1400 |
|
1401 |
if ( $is_node_modules || $is_backup_directory ) {
|
1446 |
// Create a site identifier.
|
1447 |
$site_id = Boldgrid_Backup_Admin_Utility::create_site_id();
|
1448 |
|
1449 |
+
$filename = sprintf(
|
1450 |
+
'boldgrid-backup-%1$s-%2$s-%3$s',
|
1451 |
$site_id,
|
1452 |
$backup_identifier,
|
1453 |
date( 'Ymd-His' )
|
1515 |
// Check if functional.
|
1516 |
if ( ! $this->test->run_functionality_tests() ) {
|
1517 |
// Display an error notice, if not already on the test page.
|
1518 |
+
if ( ! isset( $_GET['page'] ) || 'boldgrid-backup-test' !== $_GET['page'] ) { // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
1519 |
// Display an error notice.
|
1520 |
$this->notice->functionality_fail_notice();
|
1521 |
}
|
1528 |
// Close any PHP session, so that another session can open during the backup operation.
|
1529 |
session_write_close();
|
1530 |
|
1531 |
+
/*
|
1532 |
+
* Initialize return array and add "compressor" and "save" keys.
|
1533 |
+
* Since 1.6.0, the folder include and exclude settings below are
|
1534 |
+
* for informational purposes only. This array cannot be filtered to
|
1535 |
+
* adjust which folders are actually included / excluded.
|
1536 |
+
*/
|
1537 |
$info = array(
|
1538 |
+
'mode' => 'backup',
|
1539 |
+
'dryrun' => $dryrun,
|
1540 |
+
'compressor' => null,
|
1541 |
+
'filesize' => 0,
|
1542 |
+
'save' => $save,
|
1543 |
+
'total_size' => 0,
|
|
|
|
|
|
|
|
|
|
|
1544 |
'folder_include' => $this->folder_exclusion->from_settings( 'include' ),
|
1545 |
'folder_exclude' => $this->folder_exclusion->from_settings( 'exclude' ),
|
1546 |
+
'table_exclude' => $this->db_omit->get_excluded_tables(),
|
1547 |
);
|
1548 |
|
1549 |
// Determine how this backup was triggered.
|
1550 |
if ( $this->pre_auto_update ) {
|
1551 |
$info['trigger'] = __( 'Auto update', 'boldgrid-bakcup' );
|
1552 |
} elseif ( $this->doing_ajax && is_user_logged_in() ) {
|
1553 |
+
$current_user = wp_get_current_user();
|
1554 |
$info['trigger'] = $current_user->user_login . ' (' . $current_user->user_email . ')';
|
1555 |
} elseif ( $this->doing_wp_cron ) {
|
1556 |
$info['trigger'] = 'WP cron';
|
1643 |
* If the is no available compressor, then return an error.
|
1644 |
*/
|
1645 |
switch ( $info['compressor'] ) {
|
1646 |
+
case 'php_zip':
|
1647 |
$compressor = new Boldgrid_Backup_Admin_Compressor_Php_Zip( $this );
|
1648 |
+
$status = $compressor->archive_files( $filelist, $info );
|
1649 |
break;
|
1650 |
+
case 'pcl_zip':
|
1651 |
$compressor = new Boldgrid_Backup_Admin_Compressor_Pcl_Zip( $this );
|
1652 |
+
$status = $compressor->archive_files( $filelist, $info );
|
1653 |
break;
|
1654 |
+
case 'php_bz2':
|
1655 |
// Generate a new archive file path.
|
1656 |
$info['filepath'] = $this->generate_archive_path( 'b2z' );
|
1657 |
break;
|
1658 |
+
case 'php_zlib':
|
1659 |
// Generate a new archive file path.
|
1660 |
$info['filepath'] = $this->generate_archive_path( 'zlib' );
|
1661 |
break;
|
1662 |
+
case 'php_lzf':
|
1663 |
// Generate a new archive file path.
|
1664 |
$info['filepath'] = $this->generate_archive_path( 'lzf' );
|
1665 |
break;
|
1666 |
+
case 'system_tar':
|
1667 |
// Generate a new archive file path.
|
1668 |
$info['filepath'] = $this->generate_archive_path( 'tar.gz' );
|
1669 |
break;
|
1670 |
+
case 'system_zip':
|
1671 |
// Generate a new archive file path.
|
1672 |
$info['filepath'] = $this->generate_archive_path( 'zip' );
|
1673 |
break;
|
1674 |
+
default:
|
1675 |
$status = array(
|
1676 |
'error' => 'No available compressor',
|
1677 |
);
|
1707 |
$time_stop = microtime( true );
|
1708 |
|
1709 |
// Calculate duration.
|
1710 |
+
$info['duration'] = number_format( ( $time_stop - $time_start ), 2, '.', '' );
|
1711 |
$info['db_duration'] = number_format( ( $db_time_stop - $time_start ), 2, '.', '' );
|
1712 |
|
1713 |
/**
|
1741 |
|
1742 |
// Send an email.
|
1743 |
if ( $this->email->user_wants_notification( 'backup' ) && $this->doing_ajax ) {
|
1744 |
+
$email_parts = $this->email->post_archive_parts( $info );
|
1745 |
+
$email_body = $email_parts['body']['main'] . $email_parts['body']['signature'];
|
1746 |
$info['mail_success'] = $this->email->send( $email_parts['subject'], $email_body );
|
1747 |
}
|
1748 |
|
1773 |
* @param string $download_filename A filename to match to get info.
|
1774 |
* @param string $backup_directory Specify a directory to look within for backups.
|
1775 |
* @return array {
|
1776 |
+
* A numbered array of arrays containing the following indexes.
|
1777 |
+
* @type string $filepath Archive file path.
|
1778 |
+
* @type string $filename Archive filename.
|
1779 |
+
* @type string $filedate Localized file modification date.
|
1780 |
+
* @type int $filesize The archive file size in bytes.
|
1781 |
+
* @type int $lastmodunix The archive file modification time in unix seconds.
|
1782 |
* }
|
1783 |
*/
|
1784 |
public function get_archive_list( $download_filename = null, $backup_directory = null ) {
|
1807 |
}
|
1808 |
|
1809 |
// Sort the dirlist array by "lastmodunix" descending.
|
1810 |
+
uasort(
|
1811 |
+
$dirlist,
|
1812 |
function ( $a, $b ) {
|
1813 |
if ( $a['lastmodunix'] < $b['lastmodunix'] ) {
|
1814 |
return 1;
|
1839 |
// Create the return array.
|
1840 |
// @todo Should we use the data and time from the filename, or rely on lastmodunix?
|
1841 |
$archive_files[ $index ] = array(
|
1842 |
+
'filepath' => $backup_directory . '/' . $fileinfo['name'],
|
1843 |
+
'filename' => $fileinfo['name'],
|
1844 |
+
'filedate' => get_date_from_gmt(
|
1845 |
date( 'Y-m-d H:i:s', $fileinfo['lastmodunix'] ), 'n/j/Y g:i A'
|
1846 |
),
|
1847 |
+
'filesize' => $fileinfo['size'],
|
1848 |
'lastmodunix' => $fileinfo['lastmodunix'],
|
1849 |
);
|
1850 |
|
1938 |
// Verify specified filename.
|
1939 |
if ( $archive_filename !== $filename ) {
|
1940 |
// Fail with a notice.
|
1941 |
+
do_action(
|
1942 |
+
'boldgrid_backup_notice',
|
1943 |
esc_html__( 'The selected archive file was not found.', 'boldgrid-backup' ),
|
1944 |
'notice notice-error is-dismissible'
|
1945 |
);
|
2012 |
* restore (the first applicable one it can find).
|
2013 |
*/
|
2014 |
$pcl_zip = new Boldgrid_Backup_Admin_Compressor_Pcl_Zip( $this );
|
2015 |
+
$sqls = $pcl_zip->get_sqls( $filepath );
|
2016 |
if ( 1 === count( $sqls ) ) {
|
2017 |
return ABSPATH . $sqls[0];
|
2018 |
}
|
2029 |
}
|
2030 |
|
2031 |
// Sort the dirlist array by "name" descending.
|
2032 |
+
uasort(
|
2033 |
+
$dirlist,
|
2034 |
function ( $a, $b ) {
|
2035 |
if ( $a['name'] < $b['name'] ) {
|
2036 |
return 1;
|
2044 |
}
|
2045 |
);
|
2046 |
|
2047 |
+
/*
|
2048 |
+
* Find the first occurrence of a MySQL dump file.
|
2049 |
+
* Format: "*.########-######.sql".
|
2050 |
+
* An example filename: joec_wrdp2.20160919-162431.sql".
|
2051 |
+
*/
|
2052 |
foreach ( $dirlist as $fileinfo ) {
|
2053 |
+
if ( 1 === preg_match( '/\.[\d]+-[\d]+\.sql$/', $fileinfo['name'] ) ) {
|
2054 |
$db_dump_filepath = ABSPATH . $fileinfo['name'];
|
2055 |
break;
|
2056 |
}
|
2074 |
$restore_ok = true;
|
2075 |
|
2076 |
// If a restoration was not requested, then abort.
|
2077 |
+
if ( empty( $_POST['restore_now'] ) ) { // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
2078 |
return array(
|
2079 |
'error' => esc_html__( 'Invalid restore_now value.', 'boldgrid-backup' ),
|
2080 |
);
|
2088 |
}
|
2089 |
|
2090 |
// Initialize variables.
|
2091 |
+
$archive_key = null;
|
2092 |
$archive_filename = null;
|
2093 |
|
2094 |
// Validate archive_key.
|
2095 |
+
if ( isset( $_POST['archive_key'] ) && is_numeric( $_POST['archive_key'] ) ) { // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
2096 |
$archive_key = (int) $_POST['archive_key'];
|
2097 |
} else {
|
2098 |
return array(
|
2101 |
}
|
2102 |
|
2103 |
// Validate archive_filename.
|
2104 |
+
if ( ! empty( $_POST['archive_filename'] ) ) { // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
2105 |
$archive_filename = sanitize_file_name( $_POST['archive_filename'] );
|
2106 |
} else {
|
2107 |
return array(
|
2139 |
|
2140 |
// Populate $info.
|
2141 |
$info = array(
|
2142 |
+
'mode' => 'restore',
|
2143 |
+
'dryrun' => $dryrun,
|
2144 |
+
'filename' => $archive_filename,
|
2145 |
+
'filepath' => $filepath,
|
2146 |
+
'filesize' => $filesize,
|
2147 |
'archive_key' => $archive_key,
|
2148 |
+
'restore_ok' => $restore_ok,
|
2149 |
);
|
2150 |
|
2151 |
// Prevent this script from dying.
|
2181 |
|
2182 |
if ( empty( $error ) ) {
|
2183 |
$message = $unzip_status->get_error_message();
|
2184 |
+
$data = $unzip_status->get_error_data();
|
2185 |
+
$error = sprintf( '%1$s%2$s', $message, is_string( $data ) && ! empty( $data ) ? ': ' . $data : '' );
|
2186 |
}
|
2187 |
|
2188 |
return array(
|
2328 |
|
2329 |
// Include the home page template.
|
2330 |
include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-home.php';
|
|
|
|
|
2331 |
}
|
2332 |
|
2333 |
/**
|
2359 |
|
2360 |
$this->is_backup_now = true;
|
2361 |
|
2362 |
+
$key = 'folder_exclusion_type';
|
2363 |
$this->is_backup_full = isset( $_POST[ $key ] ) && 'full' === $_POST[ $key ];
|
2364 |
|
2365 |
$this->is_archiving_update_protection = ! empty( $_POST['is_updating'] ) &&
|
2370 |
if ( ! $this->is_archiving_update_protection ) {
|
2371 |
$message = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-backup.php';
|
2372 |
$this->notice->add_user_notice( $message['message'], $message['class'] );
|
2373 |
+
wp_send_json_success(
|
2374 |
+
array(
|
2375 |
+
'callback' => 'reload',
|
2376 |
+
)
|
2377 |
+
);
|
2378 |
} else {
|
2379 |
update_site_option( 'boldgrid_backup_pending_rollback', $archive_info );
|
2380 |
+
wp_send_json_success(
|
2381 |
+
array(
|
2382 |
+
'callback' => 'updateProtectionEnabled',
|
2383 |
+
)
|
2384 |
+
);
|
2385 |
}
|
2386 |
}
|
2387 |
|
2468 |
session_write_close();
|
2469 |
|
2470 |
// Send the file. Not finding a replacement in $wp_filesystem.
|
2471 |
+
// phpcs:disable
|
2472 |
readfile( $filepath );
|
2473 |
+
// phpcs:enable
|
2474 |
|
2475 |
// Exit.
|
2476 |
wp_die();
|
2483 |
*
|
2484 |
* @global string $wp_version The WordPress version string.
|
2485 |
* @global wpdb $wpdb The WordPress database class object.
|
|
|
|
|
2486 |
*/
|
2487 |
public function page_backup_test() {
|
2488 |
// Perform functionality tests.
|
2532 |
$cli_support = $this->test->get_cli_support();
|
2533 |
|
2534 |
// Enqueue CSS for the test page.
|
2535 |
+
wp_enqueue_style(
|
2536 |
+
'boldgrid-backup-admin-test',
|
2537 |
plugin_dir_url( __FILE__ ) . 'css/boldgrid-backup-admin-test.css', array(),
|
2538 |
BOLDGRID_BACKUP_VERSION, 'all'
|
2539 |
);
|
2540 |
|
2541 |
// Load template view.
|
2542 |
include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-test.php';
|
|
|
|
|
2543 |
}
|
2544 |
|
2545 |
/**
|
2550 |
public function set_lang() {
|
2551 |
$this->lang = array(
|
2552 |
// Mine count, total number of backups.
|
2553 |
+
'All' => __( 'All', 'boldgrid-backup' ),
|
2554 |
+
'backup_created' => __( 'Backup created successfully!', 'boldgrid-backup' ),
|
2555 |
+
'Checking_credentials' => __( 'Checking credentials', 'boldgrid-backup' ),
|
2556 |
+
'checkmark' => '✓',
|
2557 |
+
'icon_success' => '<span class="dashicons dashicons-yes green"></span> ',
|
2558 |
+
'icon_warning' => '<span class="dashicons dashicons-warning yellow"></span> ',
|
2559 |
'heading_update_protection' => __( 'BoldGrid Backup - Update Protection', 'boldgrid-backup' ),
|
2560 |
// Mine count, number of backups on remote storage providers.
|
2561 |
+
'Remote' => __( 'Remote', 'boldgrid-backup' ),
|
2562 |
+
'spinner' => '<span class="spinner"></span>',
|
2563 |
+
'spinner_inline' => '<span class="spinner inline"></span>',
|
2564 |
+
'want_to' => __( 'Want to store your backups on Amazon S3, restore individual files with just a click, and have access to more tools? Get <strong>BoldGrid Backup Premium</strong>!', 'boldgrid-backup' ),
|
2565 |
// Mine count, number of backups on local web server.
|
2566 |
+
'Web_Server' => __( 'Web Server', 'boldgrid-backup' ),
|
2567 |
);
|
2568 |
|
2569 |
$this->elements = array(
|
2570 |
'update_protection_activated' => sprintf( '%1$s %2$s', $this->lang['icon_success'], __( 'Update protection activated!', 'boldgrid-backup' ) ),
|
2571 |
// Use on long loading pages. Javascript will remove this on page load.
|
2572 |
+
'long_checking_creds' => sprintf( '<div class="bgbu-remove-load">%1$s %2$s</div>', $this->lang['Checking_credentials'], $this->lang['spinner_inline'] ),
|
2573 |
);
|
2574 |
}
|
2575 |
|
2584 |
* @param int $time_limit Limit in seconds.
|
2585 |
*/
|
2586 |
public function set_time_limit( $time_limit = 900 ) {
|
2587 |
+
$max_execution_time = ini_get( 'max_execution_time' );
|
2588 |
+
|
2589 |
+
set_time_limit( ( $max_execution_time > $time_limit ? $max_execution_time : $time_limit ) );
|
|
|
2590 |
}
|
2591 |
|
2592 |
/**
|
2593 |
* Handle ajax request to restore a file.
|
2594 |
*
|
2595 |
+
* @since 1.6.0
|
2596 |
*/
|
2597 |
public function wp_ajax_restore() {
|
2598 |
+
$error = __( 'Unable to restore backup: ', 'boldgrid-backup' );
|
2599 |
$redirect_url = admin_url( 'admin.php?page=boldgrid-backup' );
|
2600 |
|
2601 |
// Validate user role.
|
2633 |
if ( $is_success ) {
|
2634 |
$message = array(
|
2635 |
'message' => esc_html__( 'The selected archive file has been successfully restored.', 'boldgrid-backup' ),
|
2636 |
+
'class' => 'notice notice-success is-dismissible',
|
2637 |
+
'header' => __( 'BoldGrid Backup - Restoration complete' ),
|
2638 |
);
|
2639 |
} else {
|
2640 |
$message = array(
|
2641 |
'message' => ! empty( $archive_info['error'] ) ? $archive_info['error'] : __( 'Unknown error when attempting to restore archive.', 'bolcgrid-backup' ),
|
2642 |
+
'class' => 'notice notice-error is-dismissible',
|
2643 |
+
'header' => __( 'BoldGrid Backup - Restoration failed' ),
|
2644 |
);
|
2645 |
}
|
2646 |
$this->notice->add_user_notice( $message['message'], $message['class'], $message['header'] );
|
2647 |
|
2648 |
+
wp_send_json_success(
|
2649 |
+
array(
|
2650 |
+
'redirect_url' => $redirect_url,
|
2651 |
+
)
|
2652 |
+
);
|
2653 |
}
|
2654 |
|
2655 |
/**
|
2684 |
}
|
2685 |
|
2686 |
// Perform the backup operation.
|
2687 |
+
$this->archive_files( true );
|
|
|
|
|
2688 |
}
|
2689 |
|
2690 |
/**
|
2747 |
// Increment the counter.
|
2748 |
$counter --;
|
2749 |
}
|
|
|
|
|
2750 |
}
|
2751 |
}
|
admin/class-boldgrid-backup-admin-cron.php
CHANGED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.2
|
7 |
*
|
8 |
-
* @package
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright
|
11 |
-
* @version
|
12 |
-
* @author
|
13 |
*/
|
14 |
|
|
|
|
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.2
|
19 |
*/
|
@@ -28,12 +30,12 @@ class Boldgrid_Backup_Admin_Cron {
|
|
28 |
private $core;
|
29 |
|
30 |
/**
|
31 |
-
* Path to
|
32 |
*
|
33 |
* @since 1.5.2
|
34 |
* @var string
|
35 |
*/
|
36 |
-
public $run_jobs = 'cron/
|
37 |
|
38 |
/**
|
39 |
* A cron secret used to validate unauthenticated crontab jobs.
|
@@ -51,7 +53,7 @@ class Boldgrid_Backup_Admin_Cron {
|
|
51 |
*
|
52 |
* @var string
|
53 |
*/
|
54 |
-
public $crontab_version = '1.6.
|
55 |
|
56 |
/**
|
57 |
* Constructor.
|
@@ -75,7 +77,7 @@ class Boldgrid_Backup_Admin_Cron {
|
|
75 |
* @see BoldGrid_Backup_Admin_Core::get_backup_identifier()
|
76 |
* @see BoldGrid_Backup_Admin_Cron::get_cron_secret()
|
77 |
*
|
78 |
-
* @param array $settings
|
79 |
* @return bool Success.
|
80 |
*/
|
81 |
public function add_cron_entry( $settings = array() ) {
|
@@ -91,13 +93,13 @@ class Boldgrid_Backup_Admin_Cron {
|
|
91 |
|
92 |
// Create an array of days index names.
|
93 |
$days = array(
|
94 |
-
'dow_sunday'
|
95 |
-
'dow_monday'
|
96 |
-
'dow_tuesday'
|
97 |
'dow_wednesday' => 3,
|
98 |
-
'dow_thursday'
|
99 |
-
'dow_friday'
|
100 |
-
'dow_saturday'
|
101 |
);
|
102 |
|
103 |
// Add scheduled days to the list.
|
@@ -157,26 +159,26 @@ class Boldgrid_Backup_Admin_Cron {
|
|
157 |
*
|
158 |
* @since 1.6.0
|
159 |
*
|
160 |
-
* @param array $settings
|
161 |
* @return bool
|
162 |
*/
|
163 |
public function add_all_crons( $settings ) {
|
164 |
$success = false;
|
165 |
|
166 |
$scheduler = ! empty( $settings['scheduler'] ) ? $settings['scheduler'] : null;
|
167 |
-
$schedule
|
168 |
|
169 |
if ( 'cron' === $scheduler && $this->core->scheduler->is_available( $scheduler ) && ! empty( $schedule ) ) {
|
170 |
$this->core->scheduler->clear_all_schedules();
|
171 |
|
172 |
-
$scheduled
|
173 |
$jobs_scheduled = $this->schedule_jobs();
|
174 |
|
175 |
$success = $scheduled && $jobs_scheduled;
|
176 |
|
177 |
if ( $success ) {
|
178 |
$settings['crontab_version'] = $this->crontab_version;
|
179 |
-
$settings['cron_secret']
|
180 |
update_site_option( 'boldgrid_backup_settings', $settings );
|
181 |
}
|
182 |
}
|
@@ -196,12 +198,10 @@ class Boldgrid_Backup_Admin_Cron {
|
|
196 |
* @see Boldgrid_Backup_Admin_Test::is_windows()
|
197 |
* @see BoldGrid_Backup_Admin_Core::get_backup_identifier()
|
198 |
* @see BoldGrid_Backup_Admin_Cron::get_cron_secret()
|
199 |
-
*
|
200 |
-
* @return null
|
201 |
*/
|
202 |
public function add_restore_cron() {
|
203 |
$pending_rollback = get_site_option( 'boldgrid_backup_pending_rollback' );
|
204 |
-
$archives
|
205 |
|
206 |
// Use the first key to get info on the most recent archive.
|
207 |
$archive_key = 0;
|
@@ -264,8 +264,6 @@ class Boldgrid_Backup_Admin_Cron {
|
|
264 |
|
265 |
update_site_option( 'boldgrid_backup_pending_rollback', $pending_rollback );
|
266 |
}
|
267 |
-
|
268 |
-
return;
|
269 |
}
|
270 |
|
271 |
/**
|
@@ -457,8 +455,8 @@ class Boldgrid_Backup_Admin_Cron {
|
|
457 |
* conditionals below.
|
458 |
*
|
459 |
* As of @1.5.2, you can pass any other string to this method, such as
|
460 |
-
* "cron/
|
461 |
-
* /home/user/public_html/wp-content/plugins/boldgrid-backup/cron/
|
462 |
*
|
463 |
* As of @1.6.0 you can pass true as the $mode so that nothing else is
|
464 |
* added to the pattern and ALL crons for this site will be removed.
|
@@ -497,7 +495,7 @@ class Boldgrid_Backup_Admin_Cron {
|
|
497 |
|
498 |
foreach ( $crontab_exploded as $line ) {
|
499 |
if ( false === strpos( $line, $pattern ) ) {
|
500 |
-
$line
|
501 |
$crontab .= $line . "\n";
|
502 |
}
|
503 |
}
|
@@ -541,8 +539,8 @@ class Boldgrid_Backup_Admin_Cron {
|
|
541 |
*
|
542 |
* @since 1.6.0
|
543 |
*
|
544 |
-
* @param string $entry
|
545 |
-
* @return bool
|
546 |
*/
|
547 |
public function entry_delete( $entry ) {
|
548 |
if ( ! $this->entry_exists( $entry ) ) {
|
@@ -551,7 +549,9 @@ class Boldgrid_Backup_Admin_Cron {
|
|
551 |
|
552 |
$all_entries = $this->get_all();
|
553 |
|
554 |
-
|
|
|
|
|
555 |
unset( $all_entries[ $key ] );
|
556 |
}
|
557 |
|
@@ -565,13 +565,13 @@ class Boldgrid_Backup_Admin_Cron {
|
|
565 |
*
|
566 |
* @since 1.6.0
|
567 |
*
|
568 |
-
* @param string $entry
|
569 |
* @return bool
|
570 |
*/
|
571 |
public function entry_exists( $entry ) {
|
572 |
$all_entries = $this->get_all();
|
573 |
|
574 |
-
return false !== array_search( $entry, $all_entries );
|
575 |
}
|
576 |
|
577 |
/**
|
@@ -583,7 +583,6 @@ class Boldgrid_Backup_Admin_Cron {
|
|
583 |
* @return mixed
|
584 |
*/
|
585 |
public function get_all( $raw = false ) {
|
586 |
-
|
587 |
/*
|
588 |
* Cron is not available on Windows.
|
589 |
*
|
@@ -642,16 +641,16 @@ class Boldgrid_Backup_Admin_Cron {
|
|
642 |
public function get_schedule( $cron_line ) {
|
643 |
// Initialize $schedule.
|
644 |
$schedule = array(
|
645 |
-
'dow_sunday'
|
646 |
-
'dow_monday'
|
647 |
-
'dow_tuesday'
|
648 |
'dow_wednesday' => 0,
|
649 |
-
'dow_thursday'
|
650 |
-
'dow_friday'
|
651 |
-
'dow_saturday'
|
652 |
-
'tod_h'
|
653 |
-
'tod_m'
|
654 |
-
'tod_a'
|
655 |
);
|
656 |
|
657 |
if ( empty( $cron_line ) ) {
|
@@ -686,28 +685,28 @@ class Boldgrid_Backup_Admin_Cron {
|
|
686 |
$days = explode( ',', $matches[0][4] );
|
687 |
foreach ( $days as $day ) {
|
688 |
switch ( $day ) {
|
689 |
-
case 0
|
690 |
$schedule['dow_sunday'] = 1;
|
691 |
break;
|
692 |
-
case 1
|
693 |
$schedule['dow_monday'] = 1;
|
694 |
break;
|
695 |
-
case 2
|
696 |
$schedule['dow_tuesday'] = 1;
|
697 |
break;
|
698 |
-
case 3
|
699 |
$schedule['dow_wednesday'] = 1;
|
700 |
break;
|
701 |
-
case 4
|
702 |
$schedule['dow_thursday'] = 1;
|
703 |
break;
|
704 |
-
case 5
|
705 |
$schedule['dow_friday'] = 1;
|
706 |
break;
|
707 |
-
case 6
|
708 |
$schedule['dow_saturday'] = 1;
|
709 |
break;
|
710 |
-
default
|
711 |
break;
|
712 |
}
|
713 |
}
|
@@ -726,8 +725,7 @@ class Boldgrid_Backup_Admin_Cron {
|
|
726 |
public function print_cron_report( $archive_info ) {
|
727 |
// Validate mode.
|
728 |
if ( empty( $archive_info['mode'] ) ) {
|
729 |
-
|
730 |
-
wp_die();
|
731 |
}
|
732 |
|
733 |
$valid_modes = array(
|
@@ -737,23 +735,24 @@ class Boldgrid_Backup_Admin_Cron {
|
|
737 |
|
738 |
if ( ! in_array( $archive_info['mode'], $valid_modes, true ) ) {
|
739 |
printf(
|
|
|
740 |
esc_html__( 'Error: Invalid mode "%s".', 'boldgrid-backup' ),
|
741 |
-
$archive_info['mode']
|
742 |
);
|
743 |
wp_die();
|
744 |
}
|
745 |
|
746 |
// Create action name.
|
747 |
switch ( $archive_info['mode'] ) {
|
748 |
-
case 'backup'
|
749 |
$action_name = 'creating';
|
750 |
break;
|
751 |
|
752 |
-
case 'restore'
|
753 |
$action_name = 'restoring';
|
754 |
break;
|
755 |
|
756 |
-
default
|
757 |
$action_name = 'handling';
|
758 |
break;
|
759 |
}
|
@@ -763,96 +762,88 @@ class Boldgrid_Backup_Admin_Cron {
|
|
763 |
// Error.
|
764 |
printf(
|
765 |
esc_html__( 'There was an error $s backup archive file.', 'boldgrid-backup' ),
|
766 |
-
$action_name
|
767 |
-
);
|
768 |
-
|
769 |
-
echo PHP_EOL;
|
770 |
|
771 |
printf(
|
|
|
772 |
esc_html__( 'Error: %s', 'boldgrid-backup' ),
|
773 |
-
$archive_info['error']
|
774 |
-
);
|
775 |
-
|
776 |
-
echo PHP_EOL;
|
777 |
|
778 |
if ( isset( $archive_info['error_message'] ) ) {
|
779 |
printf(
|
|
|
780 |
esc_html__( 'Error Message: %s', 'boldgrid-backup' ),
|
781 |
-
$archive_info['error_message']
|
782 |
);
|
783 |
}
|
784 |
|
785 |
if ( isset( $archive_info['error_code'] ) ) {
|
786 |
printf(
|
787 |
' (%s)',
|
788 |
-
$archive_info['error_code']
|
789 |
-
);
|
790 |
}
|
791 |
-
|
792 |
-
echo PHP_EOL;
|
793 |
} elseif ( ! empty( $archive_info['filesize'] ) || ! empty( $archive_info['dryrun'] ) ) {
|
794 |
// Dry run.
|
795 |
if ( ! empty( $archive_info['filepath'] ) ) {
|
796 |
printf(
|
|
|
797 |
esc_html__( 'File Path: %s', 'boldgrid-backup' ),
|
798 |
-
$archive_info['filepath']
|
799 |
-
);
|
800 |
-
|
801 |
-
echo PHP_EOL;
|
802 |
}
|
803 |
|
804 |
if ( ! empty( $archive_info['filesize'] ) ) {
|
805 |
printf(
|
|
|
806 |
esc_html__( 'File Size: %s', 'boldgrid-backup' ),
|
807 |
-
Boldgrid_Backup_Admin_Utility::bytes_to_human( $archive_info['filesize'] )
|
808 |
-
);
|
809 |
-
|
810 |
-
echo PHP_EOL;
|
811 |
}
|
812 |
|
813 |
if ( ! empty( $archive_info['total_size'] ) ) {
|
814 |
printf(
|
|
|
815 |
esc_html__( 'Total size: %s', 'boldgrid-backup' ),
|
816 |
-
Boldgrid_Backup_Admin_Utility::bytes_to_human( $archive_info['total_size'] )
|
817 |
-
);
|
818 |
-
|
819 |
-
echo PHP_EOL;
|
820 |
}
|
821 |
|
822 |
if ( ! empty( $archive_info['compressor'] ) ) {
|
823 |
printf(
|
|
|
824 |
esc_html__( 'Compressor: %s', 'boldgrid-backup' ),
|
825 |
-
$archive_info['compressor']
|
826 |
-
);
|
827 |
-
|
828 |
-
echo PHP_EOL;
|
829 |
}
|
830 |
|
831 |
// Show how long the website was paused for.
|
832 |
if ( isset( $archive_info['db_duration'] ) ) {
|
833 |
-
printf(
|
834 |
-
|
|
|
|
|
835 |
}
|
836 |
|
837 |
if ( isset( $archive_info['duration'] ) ) {
|
838 |
printf(
|
|
|
839 |
esc_html__( 'Duration: %s seconds', 'boldgrid-backup' ),
|
840 |
-
$archive_info['duration']
|
841 |
-
);
|
842 |
-
|
843 |
-
echo PHP_EOL;
|
844 |
}
|
845 |
} else {
|
846 |
// Unknown error.
|
847 |
printf(
|
|
|
848 |
esc_html__(
|
849 |
'There was an unknown error %s a backup archive file.',
|
850 |
'boldgrid-backup'
|
851 |
),
|
852 |
-
$action_name
|
853 |
-
);
|
854 |
-
|
855 |
-
echo PHP_EOL;
|
856 |
}
|
857 |
}
|
858 |
|
@@ -896,12 +887,15 @@ class Boldgrid_Backup_Admin_Cron {
|
|
896 |
* @return bool
|
897 |
*/
|
898 |
public function is_valid_call() {
|
|
|
899 |
$backup_id_match = ! empty( $_GET['id'] ) &&
|
900 |
-
$this->core->get_backup_identifier() === $_GET['id'];
|
901 |
|
902 |
$cron_secret_match = ! empty( $_GET['secret'] ) &&
|
903 |
$this->get_cron_secret() === $_GET['secret'];
|
904 |
|
|
|
|
|
905 |
return current_user_can( 'update_plugins' ) || ( $backup_id_match && $cron_secret_match );
|
906 |
}
|
907 |
|
@@ -953,10 +947,7 @@ class Boldgrid_Backup_Admin_Cron {
|
|
953 |
*/
|
954 |
public function backup() {
|
955 |
if ( ! $this->is_valid_call() ) {
|
956 |
-
wp_die(
|
957 |
-
__( 'Error: Invalid request.' ),
|
958 |
-
'boldgrid-backup'
|
959 |
-
);
|
960 |
}
|
961 |
|
962 |
$archive_info = $this->core->archive_files( true );
|
@@ -975,10 +966,7 @@ class Boldgrid_Backup_Admin_Cron {
|
|
975 |
*/
|
976 |
public function restore() {
|
977 |
if ( ! $this->is_valid_call() ) {
|
978 |
-
wp_die(
|
979 |
-
__( 'Error: Invalid request.' ),
|
980 |
-
'boldgrid-backup'
|
981 |
-
);
|
982 |
}
|
983 |
|
984 |
$archive_info = array(
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-cron.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.2
|
7 |
*
|
8 |
+
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
+
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
// phpcs:disable WordPress.VIP
|
16 |
+
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Cron
|
19 |
*
|
20 |
* @since 1.2
|
21 |
*/
|
30 |
private $core;
|
31 |
|
32 |
/**
|
33 |
+
* Path to run-jobs.php
|
34 |
*
|
35 |
* @since 1.5.2
|
36 |
* @var string
|
37 |
*/
|
38 |
+
public $run_jobs = 'cron/run-jobs.php';
|
39 |
|
40 |
/**
|
41 |
* A cron secret used to validate unauthenticated crontab jobs.
|
53 |
*
|
54 |
* @var string
|
55 |
*/
|
56 |
+
public $crontab_version = '1.6.4';
|
57 |
|
58 |
/**
|
59 |
* Constructor.
|
77 |
* @see BoldGrid_Backup_Admin_Core::get_backup_identifier()
|
78 |
* @see BoldGrid_Backup_Admin_Cron::get_cron_secret()
|
79 |
*
|
80 |
+
* @param array $settings BoldGrid Backup settings.
|
81 |
* @return bool Success.
|
82 |
*/
|
83 |
public function add_cron_entry( $settings = array() ) {
|
93 |
|
94 |
// Create an array of days index names.
|
95 |
$days = array(
|
96 |
+
'dow_sunday' => 0,
|
97 |
+
'dow_monday' => 1,
|
98 |
+
'dow_tuesday' => 2,
|
99 |
'dow_wednesday' => 3,
|
100 |
+
'dow_thursday' => 4,
|
101 |
+
'dow_friday' => 5,
|
102 |
+
'dow_saturday' => 6,
|
103 |
);
|
104 |
|
105 |
// Add scheduled days to the list.
|
159 |
*
|
160 |
* @since 1.6.0
|
161 |
*
|
162 |
+
* @param array $settings BoldGrid Backup settings.
|
163 |
* @return bool
|
164 |
*/
|
165 |
public function add_all_crons( $settings ) {
|
166 |
$success = false;
|
167 |
|
168 |
$scheduler = ! empty( $settings['scheduler'] ) ? $settings['scheduler'] : null;
|
169 |
+
$schedule = ! empty( $settings['schedule'] ) ? $settings['schedule'] : null;
|
170 |
|
171 |
if ( 'cron' === $scheduler && $this->core->scheduler->is_available( $scheduler ) && ! empty( $schedule ) ) {
|
172 |
$this->core->scheduler->clear_all_schedules();
|
173 |
|
174 |
+
$scheduled = $this->add_cron_entry( $settings );
|
175 |
$jobs_scheduled = $this->schedule_jobs();
|
176 |
|
177 |
$success = $scheduled && $jobs_scheduled;
|
178 |
|
179 |
if ( $success ) {
|
180 |
$settings['crontab_version'] = $this->crontab_version;
|
181 |
+
$settings['cron_secret'] = $this->get_cron_secret();
|
182 |
update_site_option( 'boldgrid_backup_settings', $settings );
|
183 |
}
|
184 |
}
|
198 |
* @see Boldgrid_Backup_Admin_Test::is_windows()
|
199 |
* @see BoldGrid_Backup_Admin_Core::get_backup_identifier()
|
200 |
* @see BoldGrid_Backup_Admin_Cron::get_cron_secret()
|
|
|
|
|
201 |
*/
|
202 |
public function add_restore_cron() {
|
203 |
$pending_rollback = get_site_option( 'boldgrid_backup_pending_rollback' );
|
204 |
+
$archives = $this->core->get_archive_list();
|
205 |
|
206 |
// Use the first key to get info on the most recent archive.
|
207 |
$archive_key = 0;
|
264 |
|
265 |
update_site_option( 'boldgrid_backup_pending_rollback', $pending_rollback );
|
266 |
}
|
|
|
|
|
267 |
}
|
268 |
|
269 |
/**
|
455 |
* conditionals below.
|
456 |
*
|
457 |
* As of @1.5.2, you can pass any other string to this method, such as
|
458 |
+
* "cron/run-jobs.php", so that the pattern will become
|
459 |
+
* /home/user/public_html/wp-content/plugins/boldgrid-backup/cron/run-jobs.php
|
460 |
*
|
461 |
* As of @1.6.0 you can pass true as the $mode so that nothing else is
|
462 |
* added to the pattern and ALL crons for this site will be removed.
|
495 |
|
496 |
foreach ( $crontab_exploded as $line ) {
|
497 |
if ( false === strpos( $line, $pattern ) ) {
|
498 |
+
$line = trim( $line );
|
499 |
$crontab .= $line . "\n";
|
500 |
}
|
501 |
}
|
539 |
*
|
540 |
* @since 1.6.0
|
541 |
*
|
542 |
+
* @param string $entry Crontab entry.
|
543 |
+
* @return bool True if the entry does not exist or was deleted successfully.
|
544 |
*/
|
545 |
public function entry_delete( $entry ) {
|
546 |
if ( ! $this->entry_exists( $entry ) ) {
|
549 |
|
550 |
$all_entries = $this->get_all();
|
551 |
|
552 |
+
$key = array_search( $entry, $all_entries, true );
|
553 |
+
|
554 |
+
if ( false !== $key ) {
|
555 |
unset( $all_entries[ $key ] );
|
556 |
}
|
557 |
|
565 |
*
|
566 |
* @since 1.6.0
|
567 |
*
|
568 |
+
* @param string $entry Crontab entry.
|
569 |
* @return bool
|
570 |
*/
|
571 |
public function entry_exists( $entry ) {
|
572 |
$all_entries = $this->get_all();
|
573 |
|
574 |
+
return false !== array_search( $entry, $all_entries, true );
|
575 |
}
|
576 |
|
577 |
/**
|
583 |
* @return mixed
|
584 |
*/
|
585 |
public function get_all( $raw = false ) {
|
|
|
586 |
/*
|
587 |
* Cron is not available on Windows.
|
588 |
*
|
641 |
public function get_schedule( $cron_line ) {
|
642 |
// Initialize $schedule.
|
643 |
$schedule = array(
|
644 |
+
'dow_sunday' => 0,
|
645 |
+
'dow_monday' => 0,
|
646 |
+
'dow_tuesday' => 0,
|
647 |
'dow_wednesday' => 0,
|
648 |
+
'dow_thursday' => 0,
|
649 |
+
'dow_friday' => 0,
|
650 |
+
'dow_saturday' => 0,
|
651 |
+
'tod_h' => null,
|
652 |
+
'tod_m' => null,
|
653 |
+
'tod_a' => null,
|
654 |
);
|
655 |
|
656 |
if ( empty( $cron_line ) ) {
|
685 |
$days = explode( ',', $matches[0][4] );
|
686 |
foreach ( $days as $day ) {
|
687 |
switch ( $day ) {
|
688 |
+
case 0:
|
689 |
$schedule['dow_sunday'] = 1;
|
690 |
break;
|
691 |
+
case 1:
|
692 |
$schedule['dow_monday'] = 1;
|
693 |
break;
|
694 |
+
case 2:
|
695 |
$schedule['dow_tuesday'] = 1;
|
696 |
break;
|
697 |
+
case 3:
|
698 |
$schedule['dow_wednesday'] = 1;
|
699 |
break;
|
700 |
+
case 4:
|
701 |
$schedule['dow_thursday'] = 1;
|
702 |
break;
|
703 |
+
case 5:
|
704 |
$schedule['dow_friday'] = 1;
|
705 |
break;
|
706 |
+
case 6:
|
707 |
$schedule['dow_saturday'] = 1;
|
708 |
break;
|
709 |
+
default:
|
710 |
break;
|
711 |
}
|
712 |
}
|
725 |
public function print_cron_report( $archive_info ) {
|
726 |
// Validate mode.
|
727 |
if ( empty( $archive_info['mode'] ) ) {
|
728 |
+
wp_die( esc_html__( 'Error: A mode was not specified.', 'boldgrid-backup' ) );
|
|
|
729 |
}
|
730 |
|
731 |
$valid_modes = array(
|
735 |
|
736 |
if ( ! in_array( $archive_info['mode'], $valid_modes, true ) ) {
|
737 |
printf(
|
738 |
+
// translators: 1: Archive mode ("backup" or "restore").
|
739 |
esc_html__( 'Error: Invalid mode "%s".', 'boldgrid-backup' ),
|
740 |
+
$archive_info['mode'] // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
741 |
);
|
742 |
wp_die();
|
743 |
}
|
744 |
|
745 |
// Create action name.
|
746 |
switch ( $archive_info['mode'] ) {
|
747 |
+
case 'backup':
|
748 |
$action_name = 'creating';
|
749 |
break;
|
750 |
|
751 |
+
case 'restore':
|
752 |
$action_name = 'restoring';
|
753 |
break;
|
754 |
|
755 |
+
default:
|
756 |
$action_name = 'handling';
|
757 |
break;
|
758 |
}
|
762 |
// Error.
|
763 |
printf(
|
764 |
esc_html__( 'There was an error $s backup archive file.', 'boldgrid-backup' ),
|
765 |
+
$action_name // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
766 |
+
) . PHP_EOL;
|
|
|
|
|
767 |
|
768 |
printf(
|
769 |
+
// translators: 1: Error message.
|
770 |
esc_html__( 'Error: %s', 'boldgrid-backup' ),
|
771 |
+
$archive_info['error'] // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
772 |
+
) . PHP_EOL;
|
|
|
|
|
773 |
|
774 |
if ( isset( $archive_info['error_message'] ) ) {
|
775 |
printf(
|
776 |
+
// translators: 1: Error message.
|
777 |
esc_html__( 'Error Message: %s', 'boldgrid-backup' ),
|
778 |
+
$archive_info['error_message'] // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
779 |
);
|
780 |
}
|
781 |
|
782 |
if ( isset( $archive_info['error_code'] ) ) {
|
783 |
printf(
|
784 |
' (%s)',
|
785 |
+
esc_html( $archive_info['error_code'] )
|
786 |
+
) . PHP_EOL;
|
787 |
}
|
|
|
|
|
788 |
} elseif ( ! empty( $archive_info['filesize'] ) || ! empty( $archive_info['dryrun'] ) ) {
|
789 |
// Dry run.
|
790 |
if ( ! empty( $archive_info['filepath'] ) ) {
|
791 |
printf(
|
792 |
+
// translators: 1: File path.
|
793 |
esc_html__( 'File Path: %s', 'boldgrid-backup' ),
|
794 |
+
$archive_info['filepath'] // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
795 |
+
) . PHP_EOL;
|
|
|
|
|
796 |
}
|
797 |
|
798 |
if ( ! empty( $archive_info['filesize'] ) ) {
|
799 |
printf(
|
800 |
+
// translators: 1: File size.
|
801 |
esc_html__( 'File Size: %s', 'boldgrid-backup' ),
|
802 |
+
Boldgrid_Backup_Admin_Utility::bytes_to_human( $archive_info['filesize'] ) // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
803 |
+
) . PHP_EOL;
|
|
|
|
|
804 |
}
|
805 |
|
806 |
if ( ! empty( $archive_info['total_size'] ) ) {
|
807 |
printf(
|
808 |
+
// translators: 1: Total backup size.
|
809 |
esc_html__( 'Total size: %s', 'boldgrid-backup' ),
|
810 |
+
Boldgrid_Backup_Admin_Utility::bytes_to_human( $archive_info['total_size'] ) // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
811 |
+
) . PHP_EOL;
|
|
|
|
|
812 |
}
|
813 |
|
814 |
if ( ! empty( $archive_info['compressor'] ) ) {
|
815 |
printf(
|
816 |
+
// translators: 1: Compressor name.
|
817 |
esc_html__( 'Compressor: %s', 'boldgrid-backup' ),
|
818 |
+
$archive_info['compressor'] // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
819 |
+
) . PHP_EOL;
|
|
|
|
|
820 |
}
|
821 |
|
822 |
// Show how long the website was paused for.
|
823 |
if ( isset( $archive_info['db_duration'] ) ) {
|
824 |
+
printf(
|
825 |
+
esc_html( $this->core->configs['lang']['est_pause'] ),
|
826 |
+
$archive_info['db_duration'] // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
827 |
+
) . PHP_EOL;
|
828 |
}
|
829 |
|
830 |
if ( isset( $archive_info['duration'] ) ) {
|
831 |
printf(
|
832 |
+
// translators: 1: Backup duration.
|
833 |
esc_html__( 'Duration: %s seconds', 'boldgrid-backup' ),
|
834 |
+
$archive_info['duration'] // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
835 |
+
) . PHP_EOL;
|
|
|
|
|
836 |
}
|
837 |
} else {
|
838 |
// Unknown error.
|
839 |
printf(
|
840 |
+
// translators: 1: Backup action name.
|
841 |
esc_html__(
|
842 |
'There was an unknown error %s a backup archive file.',
|
843 |
'boldgrid-backup'
|
844 |
),
|
845 |
+
$action_name // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
846 |
+
) . PHP_EOL;
|
|
|
|
|
847 |
}
|
848 |
}
|
849 |
|
887 |
* @return bool
|
888 |
*/
|
889 |
public function is_valid_call() {
|
890 |
+
// phpcs:disable WordPress.CSRF.NonceVerification.NoNonceVerification
|
891 |
$backup_id_match = ! empty( $_GET['id'] ) &&
|
892 |
+
$this->core->get_backup_identifier() === sanitize_key( $_GET['id'] );
|
893 |
|
894 |
$cron_secret_match = ! empty( $_GET['secret'] ) &&
|
895 |
$this->get_cron_secret() === $_GET['secret'];
|
896 |
|
897 |
+
// phpcs:enable WordPress.CSRF.NonceVerification.NoNonceVerification
|
898 |
+
|
899 |
return current_user_can( 'update_plugins' ) || ( $backup_id_match && $cron_secret_match );
|
900 |
}
|
901 |
|
947 |
*/
|
948 |
public function backup() {
|
949 |
if ( ! $this->is_valid_call() ) {
|
950 |
+
wp_die( esc_html__( 'Error: Invalid request.', 'boldgrid-backup' ) );
|
|
|
|
|
|
|
951 |
}
|
952 |
|
953 |
$archive_info = $this->core->archive_files( true );
|
966 |
*/
|
967 |
public function restore() {
|
968 |
if ( ! $this->is_valid_call() ) {
|
969 |
+
wp_die( esc_html__( 'Error: Invalid request.', 'boldgrid-backup' ) );
|
|
|
|
|
|
|
970 |
}
|
971 |
|
972 |
$archive_info = array(
|
admin/class-boldgrid-backup-admin-crypt.php
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.6.0
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.6.0
|
19 |
*/
|
@@ -37,15 +37,15 @@ class Boldgrid_Backup_Admin_Crypt {
|
|
37 |
return $string;
|
38 |
}
|
39 |
|
40 |
-
$output
|
41 |
$encrypt_method = 'AES-256-CBC';
|
42 |
-
$key
|
43 |
-
$iv
|
44 |
|
45 |
if ( 'e' === $action ) {
|
46 |
-
$output = base64_encode( openssl_encrypt( $string, $encrypt_method, $key, 0, $iv ) );
|
47 |
} elseif ( 'd' === $action ) {
|
48 |
-
$output = openssl_decrypt( base64_decode( $string ), $encrypt_method, $key, 0, $iv );
|
49 |
}
|
50 |
|
51 |
return $output;
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-crypt.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.6.0
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_Crypt
|
17 |
*
|
18 |
* @since 1.6.0
|
19 |
*/
|
37 |
return $string;
|
38 |
}
|
39 |
|
40 |
+
$output = false;
|
41 |
$encrypt_method = 'AES-256-CBC';
|
42 |
+
$key = hash( 'sha256', AUTH_KEY );
|
43 |
+
$iv = substr( hash( 'sha256', SECURE_AUTH_KEY ), 0, 16 );
|
44 |
|
45 |
if ( 'e' === $action ) {
|
46 |
+
$output = base64_encode( openssl_encrypt( $string, $encrypt_method, $key, 0, $iv ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
|
47 |
} elseif ( 'd' === $action ) {
|
48 |
+
$output = openssl_decrypt( base64_decode( $string ), $encrypt_method, $key, 0, $iv ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode
|
49 |
}
|
50 |
|
51 |
return $output;
|
admin/class-boldgrid-backup-admin-db-dump.php
CHANGED
@@ -1,26 +1,25 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
use Ifsnop\Mysqldump as IMysqldump;
|
16 |
|
17 |
/**
|
18 |
-
*
|
19 |
*
|
20 |
* @since 1.5.1
|
21 |
*/
|
22 |
class Boldgrid_Backup_Admin_Db_Dump {
|
23 |
-
|
24 |
/**
|
25 |
* The core class object.
|
26 |
*
|
@@ -73,11 +72,11 @@ class Boldgrid_Backup_Admin_Db_Dump {
|
|
73 |
array(
|
74 |
'include-tables' => $include_tables,
|
75 |
'add-drop-table' => true,
|
76 |
-
'no-autocommit'
|
77 |
)
|
78 |
);
|
79 |
$dump->start( $file );
|
80 |
-
} catch (\Exception $e) {
|
81 |
return array( 'error' => $e->getMessage() );
|
82 |
}
|
83 |
|
@@ -140,7 +139,7 @@ class Boldgrid_Backup_Admin_Db_Dump {
|
|
140 |
* of records.
|
141 |
*/
|
142 |
$insert_command = str_replace( '\\\'', '', $line );
|
143 |
-
$exploded
|
144 |
foreach ( $exploded as $k => $v ) {
|
145 |
// Odd numbers are what was between quotes.
|
146 |
if ( 0 !== $k % 2 ) {
|
@@ -184,7 +183,7 @@ class Boldgrid_Backup_Admin_Db_Dump {
|
|
184 |
*
|
185 |
* For now, we'll go with the handy explode technique.
|
186 |
*/
|
187 |
-
$tables
|
188 |
$exploded = explode( 'INSERT INTO `', $file_contents[0]['content'] );
|
189 |
unset( $exploded[0] );
|
190 |
foreach ( $exploded as $table ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-db-dump.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
use Ifsnop\Mysqldump as IMysqldump;
|
16 |
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Db_Dump
|
19 |
*
|
20 |
* @since 1.5.1
|
21 |
*/
|
22 |
class Boldgrid_Backup_Admin_Db_Dump {
|
|
|
23 |
/**
|
24 |
* The core class object.
|
25 |
*
|
72 |
array(
|
73 |
'include-tables' => $include_tables,
|
74 |
'add-drop-table' => true,
|
75 |
+
'no-autocommit' => false,
|
76 |
)
|
77 |
);
|
78 |
$dump->start( $file );
|
79 |
+
} catch ( \Exception $e ) {
|
80 |
return array( 'error' => $e->getMessage() );
|
81 |
}
|
82 |
|
139 |
* of records.
|
140 |
*/
|
141 |
$insert_command = str_replace( '\\\'', '', $line );
|
142 |
+
$exploded = explode( '\'', $insert_command );
|
143 |
foreach ( $exploded as $k => $v ) {
|
144 |
// Odd numbers are what was between quotes.
|
145 |
if ( 0 !== $k % 2 ) {
|
183 |
*
|
184 |
* For now, we'll go with the handy explode technique.
|
185 |
*/
|
186 |
+
$tables = array();
|
187 |
$exploded = explode( 'INSERT INTO `', $file_contents[0]['content'] );
|
188 |
unset( $exploded[0] );
|
189 |
foreach ( $exploded as $table ) {
|
admin/class-boldgrid-backup-admin-db-get.php
CHANGED
@@ -1,24 +1,25 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
|
|
|
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.3
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Db_Get {
|
21 |
-
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
@@ -44,18 +45,21 @@ class Boldgrid_Backup_Admin_Db_Get {
|
|
44 |
*
|
45 |
* @since 1.5.3
|
46 |
*
|
47 |
-
* @global $wpdb
|
48 |
*
|
49 |
* @return array
|
50 |
*/
|
51 |
public function prefixed() {
|
52 |
global $wpdb;
|
|
|
53 |
$prefix_tables = array();
|
54 |
|
55 |
-
$
|
56 |
-
|
|
|
|
|
57 |
|
58 |
-
foreach ( $results as $
|
59 |
$prefix_tables[] = $v[0];
|
60 |
}
|
61 |
|
@@ -70,17 +74,20 @@ class Boldgrid_Backup_Admin_Db_Get {
|
|
70 |
*
|
71 |
* @since 1.5.3
|
72 |
*
|
|
|
|
|
73 |
* @return array
|
74 |
*/
|
75 |
public function prefixed_count() {
|
76 |
global $wpdb;
|
|
|
77 |
$return = array();
|
78 |
|
79 |
$tables = $this->prefixed();
|
80 |
|
81 |
foreach ( $tables as $table ) {
|
82 |
-
$
|
83 |
-
|
84 |
$return[ $table ] = $num;
|
85 |
}
|
86 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-db-get.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.5.3
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
// phpcs:disable WordPress.VIP
|
16 |
+
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Db_Get
|
19 |
*
|
20 |
* @since 1.5.3
|
21 |
*/
|
22 |
class Boldgrid_Backup_Admin_Db_Get {
|
|
|
23 |
/**
|
24 |
* The core class object.
|
25 |
*
|
45 |
*
|
46 |
* @since 1.5.3
|
47 |
*
|
48 |
+
* @global wpdb $wpdb The WordPress database class object.
|
49 |
*
|
50 |
* @return array
|
51 |
*/
|
52 |
public function prefixed() {
|
53 |
global $wpdb;
|
54 |
+
|
55 |
$prefix_tables = array();
|
56 |
|
57 |
+
$results = $wpdb->get_results(
|
58 |
+
"SHOW TABLES LIKE '{$wpdb->prefix}%';",
|
59 |
+
ARRAY_N
|
60 |
+
);
|
61 |
|
62 |
+
foreach ( $results as $v ) {
|
63 |
$prefix_tables[] = $v[0];
|
64 |
}
|
65 |
|
74 |
*
|
75 |
* @since 1.5.3
|
76 |
*
|
77 |
+
* @global wpdb $wpdb The WordPress database class object.
|
78 |
+
*
|
79 |
* @return array
|
80 |
*/
|
81 |
public function prefixed_count() {
|
82 |
global $wpdb;
|
83 |
+
|
84 |
$return = array();
|
85 |
|
86 |
$tables = $this->prefixed();
|
87 |
|
88 |
foreach ( $tables as $table ) {
|
89 |
+
$num = $wpdb->get_var( 'SELECT COUNT(*) FROM `' . $table . '`;' ); // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared
|
90 |
+
|
91 |
$return[ $table ] = $num;
|
92 |
}
|
93 |
|
admin/class-boldgrid-backup-admin-db-import.php
CHANGED
@@ -1,27 +1,27 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
|
|
14 |
/**
|
15 |
-
*
|
16 |
*
|
17 |
* @since 1.5.1
|
18 |
*/
|
19 |
class Boldgrid_Backup_Admin_Db_Import {
|
20 |
-
|
21 |
/**
|
22 |
* The core class object.
|
23 |
*
|
24 |
-
* @since
|
25 |
* @access private
|
26 |
* @var Boldgrid_Backup_Admin_Core
|
27 |
*/
|
@@ -30,7 +30,7 @@ class Boldgrid_Backup_Admin_Db_Import {
|
|
30 |
/**
|
31 |
* Errors.
|
32 |
*
|
33 |
-
* @since 1.
|
34 |
* @var array
|
35 |
*/
|
36 |
public $errors = array();
|
@@ -38,12 +38,11 @@ class Boldgrid_Backup_Admin_Db_Import {
|
|
38 |
/**
|
39 |
* Constructor.
|
40 |
*
|
41 |
-
* @since 1.
|
42 |
*
|
43 |
-
* @param Boldgrid_Backup_Admin_Core $core
|
44 |
*/
|
45 |
public function __construct( $core = false ) {
|
46 |
-
|
47 |
// We don't always require $core for this class.
|
48 |
if ( $core ) {
|
49 |
$this->core = $core;
|
@@ -55,13 +54,20 @@ class Boldgrid_Backup_Admin_Db_Import {
|
|
55 |
*
|
56 |
* @since 1.5.1
|
57 |
*
|
58 |
-
* @param string $file
|
59 |
-
* @return bool
|
60 |
*/
|
61 |
public function import( $file ) {
|
62 |
$lines = file( $file );
|
|
|
63 |
if ( false === $lines ) {
|
64 |
-
return array(
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
}
|
66 |
|
67 |
$success = $this->import_lines( $lines );
|
@@ -75,10 +81,10 @@ class Boldgrid_Backup_Admin_Db_Import {
|
|
75 |
* Pass in "file.zip" and "backup.sql" and we'll find "backup.sql" in the
|
76 |
* "file.zip" file and restore it.
|
77 |
*
|
78 |
-
* @since 1.
|
79 |
*
|
80 |
-
* @param string $archive_filepath
|
81 |
-
* @param string $file
|
82 |
* @return bool
|
83 |
*/
|
84 |
public function import_from_archive( $archive_filepath, $file ) {
|
@@ -108,9 +114,9 @@ class Boldgrid_Backup_Admin_Db_Import {
|
|
108 |
* The functionality in this method use to be in the main import method,
|
109 |
* however it was broken away to make more reusable.
|
110 |
*
|
111 |
-
* @since 1.
|
112 |
*
|
113 |
-
* @param array $lines
|
114 |
* @return bool
|
115 |
*/
|
116 |
public function import_lines( $lines ) {
|
@@ -118,6 +124,7 @@ class Boldgrid_Backup_Admin_Db_Import {
|
|
118 |
return false;
|
119 |
}
|
120 |
|
|
|
121 |
$db = new PDO( sprintf( 'mysql:host=%1$s;dbname=%2$s;', DB_HOST, DB_NAME ), DB_USER, DB_PASSWORD );
|
122 |
|
123 |
$templine = '';
|
@@ -151,9 +158,9 @@ class Boldgrid_Backup_Admin_Db_Import {
|
|
151 |
* file and import it. Instead of saving the .sql file then importing, it
|
152 |
* comes straight from the .zip file as a string to here.
|
153 |
*
|
154 |
-
* @since 1.
|
155 |
*
|
156 |
-
* @param string $string
|
157 |
* @return bool
|
158 |
*/
|
159 |
public function import_string( $string ) {
|
@@ -164,4 +171,3 @@ class Boldgrid_Backup_Admin_Db_Import {
|
|
164 |
return $success;
|
165 |
}
|
166 |
}
|
167 |
-
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-db-import.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
+
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_Db_Import
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Db_Import {
|
|
|
21 |
/**
|
22 |
* The core class object.
|
23 |
*
|
24 |
+
* @since 1.6.0
|
25 |
* @access private
|
26 |
* @var Boldgrid_Backup_Admin_Core
|
27 |
*/
|
30 |
/**
|
31 |
* Errors.
|
32 |
*
|
33 |
+
* @since 1.6.0
|
34 |
* @var array
|
35 |
*/
|
36 |
public $errors = array();
|
38 |
/**
|
39 |
* Constructor.
|
40 |
*
|
41 |
+
* @since 1.6.0
|
42 |
*
|
43 |
+
* @param Boldgrid_Backup_Admin_Core $core Boldgrid_Backup_Admin_Core object.
|
44 |
*/
|
45 |
public function __construct( $core = false ) {
|
|
|
46 |
// We don't always require $core for this class.
|
47 |
if ( $core ) {
|
48 |
$this->core = $core;
|
54 |
*
|
55 |
* @since 1.5.1
|
56 |
*
|
57 |
+
* @param string $file File path.
|
58 |
+
* @return bool TRUE on success.
|
59 |
*/
|
60 |
public function import( $file ) {
|
61 |
$lines = file( $file );
|
62 |
+
|
63 |
if ( false === $lines ) {
|
64 |
+
return array(
|
65 |
+
'error' => sprintf(
|
66 |
+
// translators: 1: File path.
|
67 |
+
__( 'Unable to open mysqldump, %1$s.', 'boldgrid-backup' ),
|
68 |
+
$file
|
69 |
+
),
|
70 |
+
);
|
71 |
}
|
72 |
|
73 |
$success = $this->import_lines( $lines );
|
81 |
* Pass in "file.zip" and "backup.sql" and we'll find "backup.sql" in the
|
82 |
* "file.zip" file and restore it.
|
83 |
*
|
84 |
+
* @since 1.6.0
|
85 |
*
|
86 |
+
* @param string $archive_filepath Archive file path.
|
87 |
+
* @param string $file Filename.
|
88 |
* @return bool
|
89 |
*/
|
90 |
public function import_from_archive( $archive_filepath, $file ) {
|
114 |
* The functionality in this method use to be in the main import method,
|
115 |
* however it was broken away to make more reusable.
|
116 |
*
|
117 |
+
* @since 1.6.0
|
118 |
*
|
119 |
+
* @param array $lines MySQL dump file lines.
|
120 |
* @return bool
|
121 |
*/
|
122 |
public function import_lines( $lines ) {
|
124 |
return false;
|
125 |
}
|
126 |
|
127 |
+
/* phpcs:disable WordPress.DB.RestrictedClasses */
|
128 |
$db = new PDO( sprintf( 'mysql:host=%1$s;dbname=%2$s;', DB_HOST, DB_NAME ), DB_USER, DB_PASSWORD );
|
129 |
|
130 |
$templine = '';
|
158 |
* file and import it. Instead of saving the .sql file then importing, it
|
159 |
* comes straight from the .zip file as a string to here.
|
160 |
*
|
161 |
+
* @since 1.6.0
|
162 |
*
|
163 |
+
* @param string $string MySQL dump file as a string.
|
164 |
* @return bool
|
165 |
*/
|
166 |
public function import_string( $string ) {
|
171 |
return $success;
|
172 |
}
|
173 |
}
|
|
admin/class-boldgrid-backup-admin-db-omit.php
CHANGED
@@ -1,24 +1,25 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.5.3
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
|
|
|
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.3
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Db_Omit {
|
21 |
-
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
@@ -33,7 +34,7 @@ class Boldgrid_Backup_Admin_Db_Omit {
|
|
33 |
*
|
34 |
* Usually 'full' or 'custom' backup.
|
35 |
*
|
36 |
-
* @since
|
37 |
* @access public
|
38 |
* @var string
|
39 |
*/
|
@@ -44,7 +45,7 @@ class Boldgrid_Backup_Admin_Db_Omit {
|
|
44 |
*
|
45 |
* Usually 'full' or 'custom' backup.
|
46 |
*
|
47 |
-
* @since
|
48 |
* @access public
|
49 |
* @var array
|
50 |
*/
|
@@ -65,9 +66,9 @@ class Boldgrid_Backup_Admin_Db_Omit {
|
|
65 |
* Generate a section for email alerts including information about tables
|
66 |
* excluded.
|
67 |
*
|
68 |
-
* @since 1.
|
69 |
*
|
70 |
-
* @param array $info
|
71 |
* @return string
|
72 |
*/
|
73 |
public function email_part( $info ) {
|
@@ -78,7 +79,14 @@ class Boldgrid_Backup_Admin_Db_Omit {
|
|
78 |
$body .= "\n" . __( 'DATABASE SETTINGS', 'boldgrid-backup' ) . "\n";
|
79 |
|
80 |
$tables_excluded = empty( $info['table_exclude'] ) ? __( 'None', 'boldgrid-backup' ) : implode( ',', $info['table_exclude'] );
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
}
|
83 |
|
84 |
return $body;
|
@@ -87,11 +95,12 @@ class Boldgrid_Backup_Admin_Db_Omit {
|
|
87 |
/**
|
88 |
* Enqueue scripts.
|
89 |
*
|
90 |
-
* @since 1.
|
91 |
*/
|
92 |
public function enqueue_scripts() {
|
93 |
$handle = 'boldgrid-backup-admin-table-include';
|
94 |
-
wp_register_script(
|
|
|
95 |
plugin_dir_url( __FILE__ ) . 'js/boldgrid-backup-admin-table-include.js',
|
96 |
array( 'jquery' ),
|
97 |
BOLDGRID_BACKUP_VERSION,
|
@@ -100,13 +109,6 @@ class Boldgrid_Backup_Admin_Db_Omit {
|
|
100 |
$translation = array();
|
101 |
wp_localize_script( $handle, 'BoldGridBackupAdminTableInclude', $translation );
|
102 |
wp_enqueue_script( $handle );
|
103 |
-
|
104 |
-
// Enqueue CSS for folder exclude functionality.
|
105 |
-
// wp_enqueue_style(
|
106 |
-
// $handle,
|
107 |
-
// plugin_dir_url( __FILE__ ) . 'css/boldgrid-backup-admin-folder-exclude.css', array(),
|
108 |
-
// BOLDGRID_BACKUP_VERSION
|
109 |
-
// );
|
110 |
}
|
111 |
|
112 |
/**
|
@@ -123,7 +125,6 @@ class Boldgrid_Backup_Admin_Db_Omit {
|
|
123 |
* @return array
|
124 |
*/
|
125 |
public function get_excluded_tables() {
|
126 |
-
|
127 |
/*
|
128 |
* Determine if the user is doing "backup site now" and they selected to
|
129 |
* backup all tables (full backup).
|
@@ -132,7 +133,7 @@ class Boldgrid_Backup_Admin_Db_Omit {
|
|
132 |
|
133 |
if ( $this->core->is_archiving_update_protection || $backup_now_full || $this->core->pre_auto_update ) {
|
134 |
$excluded_tables = array();
|
135 |
-
} elseif ( $this->core->is_backup_now && isset( $_POST['include_tables'] ) ) {
|
136 |
$excluded_tables = $this->get_from_post();
|
137 |
} else {
|
138 |
$settings = $this->core->settings->get_settings();
|
@@ -168,7 +169,7 @@ class Boldgrid_Backup_Admin_Db_Omit {
|
|
168 |
$exclude_tables = $this->get_excluded_tables();
|
169 |
|
170 |
foreach ( $prefixed_tables as $key => $table ) {
|
171 |
-
if ( in_array( $table, $exclude_tables ) ) {
|
172 |
unset( $prefixed_tables[ $key ] );
|
173 |
}
|
174 |
}
|
@@ -182,14 +183,14 @@ class Boldgrid_Backup_Admin_Db_Omit {
|
|
182 |
* We are submitting via post "include_tables", however we use this data to
|
183 |
* then calculate "exclude_tables".
|
184 |
*
|
185 |
-
* @since 1.
|
186 |
*
|
187 |
* @return array
|
188 |
*/
|
189 |
public function get_from_post() {
|
190 |
$exclude_tables = array();
|
191 |
|
192 |
-
$include_tables = ! empty( $_POST['include_tables'] ) ?
|
193 |
array_map( 'sanitize_text_field', $_POST['include_tables'] ) : array();
|
194 |
|
195 |
$all_tables = $this->core->db_get->prefixed();
|
@@ -200,7 +201,7 @@ class Boldgrid_Backup_Admin_Db_Omit {
|
|
200 |
* If the table we want to
|
201 |
*/
|
202 |
foreach ( $all_tables as $table ) {
|
203 |
-
if ( ! in_array( $table, $include_tables ) ) {
|
204 |
$exclude_tables[] = $table;
|
205 |
}
|
206 |
}
|
@@ -211,14 +212,14 @@ class Boldgrid_Backup_Admin_Db_Omit {
|
|
211 |
/**
|
212 |
* Get value of 'table_inclusion_type' from $_POST.
|
213 |
*
|
214 |
-
* @since 1.
|
215 |
*
|
216 |
* @return string
|
217 |
*/
|
218 |
public function get_post_type() {
|
219 |
$key = 'table_inclusion_type';
|
220 |
|
221 |
-
return ! empty( $_POST[ $key ] ) && in_array( $_POST[ $key ], $this->valid_types, true ) ?
|
222 |
sanitize_key( $_POST[ $key ] ) : null;
|
223 |
}
|
224 |
|
@@ -227,9 +228,9 @@ class Boldgrid_Backup_Admin_Db_Omit {
|
|
227 |
*
|
228 |
* If no exclude_tables are set, return an empty array.
|
229 |
*
|
230 |
-
* @since 1.
|
231 |
*
|
232 |
-
* @param array $settings
|
233 |
* @return bool
|
234 |
*/
|
235 |
public function get_settings_excluded( $settings = array() ) {
|
@@ -252,9 +253,9 @@ class Boldgrid_Backup_Admin_Db_Omit {
|
|
252 |
*
|
253 |
* Return null if we do not have a type saved in the settings.
|
254 |
*
|
255 |
-
* @since 1.
|
256 |
*
|
257 |
-
* @param array $settings
|
258 |
* @return bool
|
259 |
*/
|
260 |
public function get_settings_type( $settings = array() ) {
|
@@ -283,7 +284,7 @@ class Boldgrid_Backup_Admin_Db_Omit {
|
|
283 |
$return = '';
|
284 |
|
285 |
foreach ( $tables as $table ) {
|
286 |
-
$checked = in_array( $table, $exclude_tables ) ? '' : 'checked';
|
287 |
$return .= sprintf(
|
288 |
'<div title="%1$s"><input value="%1$s" name="include_tables[]" type="checkbox" %2$s /> %1$s</div>',
|
289 |
esc_html( $table ),
|
@@ -302,7 +303,7 @@ class Boldgrid_Backup_Admin_Db_Omit {
|
|
302 |
* @return bool
|
303 |
*/
|
304 |
public function is_omit_all() {
|
305 |
-
$exclude_tables
|
306 |
$prefixed_tables = $this->core->db_get->prefixed();
|
307 |
|
308 |
$diff = array_diff( $prefixed_tables, $exclude_tables );
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-db-omit.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.5.3
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
// phpcs:disable WordPress.VIP
|
16 |
+
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Db_Omit
|
19 |
*
|
20 |
* @since 1.5.3
|
21 |
*/
|
22 |
class Boldgrid_Backup_Admin_Db_Omit {
|
|
|
23 |
/**
|
24 |
* The core class object.
|
25 |
*
|
34 |
*
|
35 |
* Usually 'full' or 'custom' backup.
|
36 |
*
|
37 |
+
* @since 1.6.0
|
38 |
* @access public
|
39 |
* @var string
|
40 |
*/
|
45 |
*
|
46 |
* Usually 'full' or 'custom' backup.
|
47 |
*
|
48 |
+
* @since 1.6.0
|
49 |
* @access public
|
50 |
* @var array
|
51 |
*/
|
66 |
* Generate a section for email alerts including information about tables
|
67 |
* excluded.
|
68 |
*
|
69 |
+
* @since 1.6.0
|
70 |
*
|
71 |
+
* @param array $info Database table information.
|
72 |
* @return string
|
73 |
*/
|
74 |
public function email_part( $info ) {
|
79 |
$body .= "\n" . __( 'DATABASE SETTINGS', 'boldgrid-backup' ) . "\n";
|
80 |
|
81 |
$tables_excluded = empty( $info['table_exclude'] ) ? __( 'None', 'boldgrid-backup' ) : implode( ',', $info['table_exclude'] );
|
82 |
+
|
83 |
+
$body .= sprintf(
|
84 |
+
// translators: 1: Database tables excluded.
|
85 |
+
__(
|
86 |
+
'Tables Excluded: %1$s', 'boldgrid-backup'
|
87 |
+
),
|
88 |
+
$tables_excluded
|
89 |
+
) . "\n";
|
90 |
}
|
91 |
|
92 |
return $body;
|
95 |
/**
|
96 |
* Enqueue scripts.
|
97 |
*
|
98 |
+
* @since 1.6.0
|
99 |
*/
|
100 |
public function enqueue_scripts() {
|
101 |
$handle = 'boldgrid-backup-admin-table-include';
|
102 |
+
wp_register_script(
|
103 |
+
$handle,
|
104 |
plugin_dir_url( __FILE__ ) . 'js/boldgrid-backup-admin-table-include.js',
|
105 |
array( 'jquery' ),
|
106 |
BOLDGRID_BACKUP_VERSION,
|
109 |
$translation = array();
|
110 |
wp_localize_script( $handle, 'BoldGridBackupAdminTableInclude', $translation );
|
111 |
wp_enqueue_script( $handle );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
}
|
113 |
|
114 |
/**
|
125 |
* @return array
|
126 |
*/
|
127 |
public function get_excluded_tables() {
|
|
|
128 |
/*
|
129 |
* Determine if the user is doing "backup site now" and they selected to
|
130 |
* backup all tables (full backup).
|
133 |
|
134 |
if ( $this->core->is_archiving_update_protection || $backup_now_full || $this->core->pre_auto_update ) {
|
135 |
$excluded_tables = array();
|
136 |
+
} elseif ( $this->core->is_backup_now && isset( $_POST['include_tables'] ) ) { // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
137 |
$excluded_tables = $this->get_from_post();
|
138 |
} else {
|
139 |
$settings = $this->core->settings->get_settings();
|
169 |
$exclude_tables = $this->get_excluded_tables();
|
170 |
|
171 |
foreach ( $prefixed_tables as $key => $table ) {
|
172 |
+
if ( in_array( $table, $exclude_tables, true ) ) {
|
173 |
unset( $prefixed_tables[ $key ] );
|
174 |
}
|
175 |
}
|
183 |
* We are submitting via post "include_tables", however we use this data to
|
184 |
* then calculate "exclude_tables".
|
185 |
*
|
186 |
+
* @since 1.6.0
|
187 |
*
|
188 |
* @return array
|
189 |
*/
|
190 |
public function get_from_post() {
|
191 |
$exclude_tables = array();
|
192 |
|
193 |
+
$include_tables = ! empty( $_POST['include_tables'] ) ? // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
194 |
array_map( 'sanitize_text_field', $_POST['include_tables'] ) : array();
|
195 |
|
196 |
$all_tables = $this->core->db_get->prefixed();
|
201 |
* If the table we want to
|
202 |
*/
|
203 |
foreach ( $all_tables as $table ) {
|
204 |
+
if ( ! in_array( $table, $include_tables, true ) ) {
|
205 |
$exclude_tables[] = $table;
|
206 |
}
|
207 |
}
|
212 |
/**
|
213 |
* Get value of 'table_inclusion_type' from $_POST.
|
214 |
*
|
215 |
+
* @since 1.6.0
|
216 |
*
|
217 |
* @return string
|
218 |
*/
|
219 |
public function get_post_type() {
|
220 |
$key = 'table_inclusion_type';
|
221 |
|
222 |
+
return ! empty( $_POST[ $key ] ) && in_array( $_POST[ $key ], $this->valid_types, true ) ? // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
223 |
sanitize_key( $_POST[ $key ] ) : null;
|
224 |
}
|
225 |
|
228 |
*
|
229 |
* If no exclude_tables are set, return an empty array.
|
230 |
*
|
231 |
+
* @since 1.6.0
|
232 |
*
|
233 |
+
* @param array $settings BoldGrid Backup settings.
|
234 |
* @return bool
|
235 |
*/
|
236 |
public function get_settings_excluded( $settings = array() ) {
|
253 |
*
|
254 |
* Return null if we do not have a type saved in the settings.
|
255 |
*
|
256 |
+
* @since 1.6.0
|
257 |
*
|
258 |
+
* @param array $settings BoldGrid Backup settings.
|
259 |
* @return bool
|
260 |
*/
|
261 |
public function get_settings_type( $settings = array() ) {
|
284 |
$return = '';
|
285 |
|
286 |
foreach ( $tables as $table ) {
|
287 |
+
$checked = in_array( $table, $exclude_tables, true ) ? '' : 'checked';
|
288 |
$return .= sprintf(
|
289 |
'<div title="%1$s"><input value="%1$s" name="include_tables[]" type="checkbox" %2$s /> %1$s</div>',
|
290 |
esc_html( $table ),
|
303 |
* @return bool
|
304 |
*/
|
305 |
public function is_omit_all() {
|
306 |
+
$exclude_tables = $this->get_excluded_tables();
|
307 |
$prefixed_tables = $this->core->db_get->prefixed();
|
308 |
|
309 |
$diff = array_diff( $prefixed_tables, $exclude_tables );
|
admin/class-boldgrid-backup-admin-email.php
CHANGED
@@ -1,28 +1,29 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
*
|
|
|
|
|
6 |
* @since 1.5.2
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.2
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Email {
|
21 |
-
|
22 |
/**
|
23 |
* An array of ads.
|
24 |
*
|
25 |
-
* @since
|
26 |
* @access private
|
27 |
* @var array
|
28 |
*/
|
@@ -42,7 +43,7 @@ class Boldgrid_Backup_Admin_Email {
|
|
42 |
*
|
43 |
* @since 1.5.2
|
44 |
*
|
45 |
-
* @param Boldgrid_Backup_Admin_Core $core
|
46 |
*/
|
47 |
public function __construct( $core ) {
|
48 |
$this->core = $core;
|
@@ -53,7 +54,7 @@ class Boldgrid_Backup_Admin_Email {
|
|
53 |
*
|
54 |
* @since 1.5.2
|
55 |
*
|
56 |
-
* @param string $message
|
57 |
* @param bool $add_ad Allow ads to be added to the email. In some cases,
|
58 |
* like when we have bad news (something failed), we
|
59 |
* may not want to ask the user to upgrade (bad timing).
|
@@ -79,11 +80,12 @@ class Boldgrid_Backup_Admin_Email {
|
|
79 |
/**
|
80 |
* Init our ads.
|
81 |
*
|
82 |
-
* @since 1.
|
83 |
*/
|
84 |
public function init_ads() {
|
85 |
$this->ads = array(
|
86 |
'generic' => $this->core->config->get_is_premium() ? '' : sprintf(
|
|
|
87 |
__( 'Want to store your backups on Amazon S3, restore individual files with just a click, and have access to more tools? Get BoldGrid Backup Premium! - %1$s', 'boldgrid-backup' ),
|
88 |
Boldgrid_Backup_Admin_Go_Pro::$url
|
89 |
) . "\n\n",
|
@@ -95,7 +97,7 @@ class Boldgrid_Backup_Admin_Email {
|
|
95 |
*
|
96 |
* @since 1.5.2
|
97 |
*
|
98 |
-
* @param array $info
|
99 |
* @return array
|
100 |
*/
|
101 |
public function post_archive_parts( $info ) {
|
@@ -105,22 +107,37 @@ class Boldgrid_Backup_Admin_Email {
|
|
105 |
|
106 |
$site_id = Boldgrid_Backup_Admin_Utility::create_site_id();
|
107 |
|
|
|
108 |
$parts['subject'] = sprintf( __( 'Backup completed for %s', 'boldgrid-backup' ), $site_id );
|
109 |
|
110 |
$parts['body']['main'] = esc_html__( 'Hello', 'boldgrid-backup' ) . ",\n\n";
|
|
|
111 |
if ( $info['dryrun'] ) {
|
112 |
$body['main'] .= esc_html__( 'THIS OPERATION WAS A DRY-RUN TEST', 'boldgrid-backup' ) . ".\n\n";
|
113 |
}
|
|
|
|
|
114 |
$parts['body']['main'] .= sprintf( esc_html__( 'A backup archive has been created for %s', 'boldgrid-backup' ), $site_id ) . ".\n\n";
|
115 |
$parts['body']['main'] .= esc_html__( 'Backup details', 'boldgrid-backup' ) . ":\n";
|
116 |
$parts['body']['main'] .= sprintf( $this->core->configs['lang']['est_pause'], $info['db_duration'] ) . "\n";
|
|
|
|
|
117 |
$parts['body']['main'] .= sprintf( esc_html__( 'Duration: %s seconds', 'boldgrid-backup' ), $info['duration'] ) . "\n";
|
|
|
|
|
118 |
$parts['body']['main'] .= sprintf( esc_html__( 'Total size: %s', 'boldgrid-backup' ), Boldgrid_Backup_Admin_Utility::bytes_to_human( $info['total_size'] ) ) . "\n";
|
|
|
|
|
119 |
$parts['body']['main'] .= sprintf( esc_html__( 'Archive file path: %s', 'boldgrid-backup' ), $info['filepath'] ) . "\n";
|
|
|
|
|
120 |
$parts['body']['main'] .= sprintf( esc_html__( 'Archive file size: %s', 'boldgrid-backup' ), Boldgrid_Backup_Admin_Utility::bytes_to_human( $info['filesize'] ) ) . "\n";
|
|
|
|
|
121 |
$parts['body']['main'] .= sprintf( esc_html__( 'Compressor used: %s', 'boldgrid-backup' ), $info['compressor'] ) . "\n";
|
122 |
|
123 |
if ( ! empty( $info['trigger'] ) ) {
|
|
|
124 |
$parts['body']['main'] .= sprintf( esc_html__( 'Backup triggered by: %1$s', 'boldgrid-backup' ), $info['trigger'] ) . "\n";
|
125 |
}
|
126 |
|
@@ -131,6 +148,8 @@ class Boldgrid_Backup_Admin_Email {
|
|
131 |
$parts['body']['main'] .= "\n";
|
132 |
|
133 |
$parts['body']['signature'] = esc_html__( 'You can manage notifications in your WordPress admin panel, under BoldGrid Backup Settings', 'boldgrid-backup' ) . ".\n\n";
|
|
|
|
|
134 |
$parts['body']['signature'] .= sprintf( esc_html__( 'For help with restoring a BoldGrid Backup archive file, please visit: %s', 'boldgrid-backup' ), esc_url( $this->core->configs['urls']['restore'] ) ) . "\n\n";
|
135 |
|
136 |
$parts['body']['signature'] .= $this->ads['generic'];
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-email.php
|
4 |
*
|
5 |
+
* Email helper.
|
6 |
+
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.5.2
|
9 |
*
|
10 |
* @package Boldgrid_Backup
|
11 |
* @subpackage Boldgrid_Backup/admin
|
12 |
+
* @copyright BoldGrid
|
13 |
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Email
|
19 |
*
|
20 |
* @since 1.5.2
|
21 |
*/
|
22 |
class Boldgrid_Backup_Admin_Email {
|
|
|
23 |
/**
|
24 |
* An array of ads.
|
25 |
*
|
26 |
+
* @since 1.6.0
|
27 |
* @access private
|
28 |
* @var array
|
29 |
*/
|
43 |
*
|
44 |
* @since 1.5.2
|
45 |
*
|
46 |
+
* @param Boldgrid_Backup_Admin_Core $core Boldgrid_Backup_Admin_Core object.
|
47 |
*/
|
48 |
public function __construct( $core ) {
|
49 |
$this->core = $core;
|
54 |
*
|
55 |
* @since 1.5.2
|
56 |
*
|
57 |
+
* @param string $message Message to send.
|
58 |
* @param bool $add_ad Allow ads to be added to the email. In some cases,
|
59 |
* like when we have bad news (something failed), we
|
60 |
* may not want to ask the user to upgrade (bad timing).
|
80 |
/**
|
81 |
* Init our ads.
|
82 |
*
|
83 |
+
* @since 1.6.0
|
84 |
*/
|
85 |
public function init_ads() {
|
86 |
$this->ads = array(
|
87 |
'generic' => $this->core->config->get_is_premium() ? '' : sprintf(
|
88 |
+
// translators: 1: URL address.
|
89 |
__( 'Want to store your backups on Amazon S3, restore individual files with just a click, and have access to more tools? Get BoldGrid Backup Premium! - %1$s', 'boldgrid-backup' ),
|
90 |
Boldgrid_Backup_Admin_Go_Pro::$url
|
91 |
) . "\n\n",
|
97 |
*
|
98 |
* @since 1.5.2
|
99 |
*
|
100 |
+
* @param array $info Archive process information.
|
101 |
* @return array
|
102 |
*/
|
103 |
public function post_archive_parts( $info ) {
|
107 |
|
108 |
$site_id = Boldgrid_Backup_Admin_Utility::create_site_id();
|
109 |
|
110 |
+
// translators: 1: Site identifier.
|
111 |
$parts['subject'] = sprintf( __( 'Backup completed for %s', 'boldgrid-backup' ), $site_id );
|
112 |
|
113 |
$parts['body']['main'] = esc_html__( 'Hello', 'boldgrid-backup' ) . ",\n\n";
|
114 |
+
|
115 |
if ( $info['dryrun'] ) {
|
116 |
$body['main'] .= esc_html__( 'THIS OPERATION WAS A DRY-RUN TEST', 'boldgrid-backup' ) . ".\n\n";
|
117 |
}
|
118 |
+
|
119 |
+
// translators: 1: Site identifier.
|
120 |
$parts['body']['main'] .= sprintf( esc_html__( 'A backup archive has been created for %s', 'boldgrid-backup' ), $site_id ) . ".\n\n";
|
121 |
$parts['body']['main'] .= esc_html__( 'Backup details', 'boldgrid-backup' ) . ":\n";
|
122 |
$parts['body']['main'] .= sprintf( $this->core->configs['lang']['est_pause'], $info['db_duration'] ) . "\n";
|
123 |
+
|
124 |
+
// translators: 1: Backup duration.
|
125 |
$parts['body']['main'] .= sprintf( esc_html__( 'Duration: %s seconds', 'boldgrid-backup' ), $info['duration'] ) . "\n";
|
126 |
+
|
127 |
+
// translators: 1: Total backup size.
|
128 |
$parts['body']['main'] .= sprintf( esc_html__( 'Total size: %s', 'boldgrid-backup' ), Boldgrid_Backup_Admin_Utility::bytes_to_human( $info['total_size'] ) ) . "\n";
|
129 |
+
|
130 |
+
// translators: 1: Archive file path.
|
131 |
$parts['body']['main'] .= sprintf( esc_html__( 'Archive file path: %s', 'boldgrid-backup' ), $info['filepath'] ) . "\n";
|
132 |
+
|
133 |
+
// translators: 1: Archive file size.
|
134 |
$parts['body']['main'] .= sprintf( esc_html__( 'Archive file size: %s', 'boldgrid-backup' ), Boldgrid_Backup_Admin_Utility::bytes_to_human( $info['filesize'] ) ) . "\n";
|
135 |
+
|
136 |
+
// translators: 1: Archive compressor name.
|
137 |
$parts['body']['main'] .= sprintf( esc_html__( 'Compressor used: %s', 'boldgrid-backup' ), $info['compressor'] ) . "\n";
|
138 |
|
139 |
if ( ! empty( $info['trigger'] ) ) {
|
140 |
+
// translators: 1: What triggered the backup process.
|
141 |
$parts['body']['main'] .= sprintf( esc_html__( 'Backup triggered by: %1$s', 'boldgrid-backup' ), $info['trigger'] ) . "\n";
|
142 |
}
|
143 |
|
148 |
$parts['body']['main'] .= "\n";
|
149 |
|
150 |
$parts['body']['signature'] = esc_html__( 'You can manage notifications in your WordPress admin panel, under BoldGrid Backup Settings', 'boldgrid-backup' ) . ".\n\n";
|
151 |
+
|
152 |
+
// translators: 1: URL address for help restoring a backup archive file.
|
153 |
$parts['body']['signature'] .= sprintf( esc_html__( 'For help with restoring a BoldGrid Backup archive file, please visit: %s', 'boldgrid-backup' ), esc_url( $this->core->configs['urls']['restore'] ) ) . "\n\n";
|
154 |
|
155 |
$parts['body']['signature'] .= $this->ads['generic'];
|
admin/class-boldgrid-backup-admin-filelist.php
CHANGED
@@ -1,28 +1,27 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Filelist {
|
21 |
-
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
25 |
-
* @since
|
26 |
* @access private
|
27 |
* @var Boldgrid_Backup_Admin_Core
|
28 |
*/
|
@@ -36,7 +35,7 @@ class Boldgrid_Backup_Admin_Filelist {
|
|
36 |
* This array primarily exists to help get the total size of your website.
|
37 |
* We loop through this list and calculate the disk space of each item.
|
38 |
*
|
39 |
-
* @since
|
40 |
* @access public
|
41 |
* @var array
|
42 |
*/
|
@@ -67,7 +66,7 @@ class Boldgrid_Backup_Admin_Filelist {
|
|
67 |
/**
|
68 |
* Constructor.
|
69 |
*
|
70 |
-
* @since 1.
|
71 |
*
|
72 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
73 |
*/
|
@@ -78,12 +77,11 @@ class Boldgrid_Backup_Admin_Filelist {
|
|
78 |
/**
|
79 |
* Get the total size of WordPress core and the wp-content directory.
|
80 |
*
|
81 |
-
* @since 1.
|
82 |
*
|
83 |
* @return int
|
84 |
*/
|
85 |
public function get_size() {
|
86 |
-
|
87 |
/*
|
88 |
* Include wp-includes/ms-functions.php.
|
89 |
*
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-filelist.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_Filelist
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Filelist {
|
|
|
21 |
/**
|
22 |
* The core class object.
|
23 |
*
|
24 |
+
* @since 1.6.0
|
25 |
* @access private
|
26 |
* @var Boldgrid_Backup_Admin_Core
|
27 |
*/
|
35 |
* This array primarily exists to help get the total size of your website.
|
36 |
* We loop through this list and calculate the disk space of each item.
|
37 |
*
|
38 |
+
* @since 1.6.0
|
39 |
* @access public
|
40 |
* @var array
|
41 |
*/
|
66 |
/**
|
67 |
* Constructor.
|
68 |
*
|
69 |
+
* @since 1.6.0
|
70 |
*
|
71 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
72 |
*/
|
77 |
/**
|
78 |
* Get the total size of WordPress core and the wp-content directory.
|
79 |
*
|
80 |
+
* @since 1.6.0
|
81 |
*
|
82 |
* @return int
|
83 |
*/
|
84 |
public function get_size() {
|
|
|
85 |
/*
|
86 |
* Include wp-includes/ms-functions.php.
|
87 |
*
|
admin/class-boldgrid-backup-admin-folder-exclusion.php
CHANGED
@@ -1,28 +1,29 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since 1.
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
|
|
|
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
-
* @since 1.
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Folder_Exclusion {
|
21 |
-
|
22 |
/**
|
23 |
* The default exclude value.
|
24 |
*
|
25 |
-
* @since 1.
|
26 |
* @var string
|
27 |
*/
|
28 |
public $default_exclude = '.git,node_modules';
|
@@ -30,7 +31,7 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
30 |
/**
|
31 |
* The default include value.
|
32 |
*
|
33 |
-
* @since 1.
|
34 |
* @var string
|
35 |
*/
|
36 |
public $default_include = 'WPCORE,/wp-content';
|
@@ -38,7 +39,7 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
38 |
/**
|
39 |
* By default, backup all files and folders (use default settings).
|
40 |
*
|
41 |
-
* @since 1.
|
42 |
* @var string
|
43 |
*/
|
44 |
public $default_type = 'full';
|
@@ -46,7 +47,7 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
46 |
/**
|
47 |
* Our exclude value.
|
48 |
*
|
49 |
-
* @since 1.
|
50 |
* @var string|null
|
51 |
*/
|
52 |
public $exclude = null;
|
@@ -54,7 +55,7 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
54 |
/**
|
55 |
* Our include value.
|
56 |
*
|
57 |
-
* @since 1.
|
58 |
* @var string|null
|
59 |
*/
|
60 |
public $include = null;
|
@@ -62,7 +63,7 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
62 |
/**
|
63 |
* Whether or not we're in the ajax preview.
|
64 |
*
|
65 |
-
* @since 1.
|
66 |
* @var bool
|
67 |
*/
|
68 |
public $in_ajax_preview = false;
|
@@ -72,7 +73,7 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
72 |
*
|
73 |
* Usually it will be 'full' or 'custom'.
|
74 |
*
|
75 |
-
* @since 1.
|
76 |
* @var null|string
|
77 |
*/
|
78 |
public $type = null;
|
@@ -80,7 +81,7 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
80 |
/**
|
81 |
* Allowable types.
|
82 |
*
|
83 |
-
* @since 1.
|
84 |
* @var array
|
85 |
*/
|
86 |
public $types = array( 'include', 'exclude', 'type' );
|
@@ -88,7 +89,7 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
88 |
/**
|
89 |
* Valid backup types.
|
90 |
*
|
91 |
-
* @since 1.
|
92 |
* @var array
|
93 |
*/
|
94 |
public $valid_types = array( 'full', 'custom' );
|
@@ -96,7 +97,7 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
96 |
/**
|
97 |
* The core class object.
|
98 |
*
|
99 |
-
* @since
|
100 |
* @access private
|
101 |
* @var Boldgrid_Backup_Admin_Core
|
102 |
*/
|
@@ -105,7 +106,7 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
105 |
/**
|
106 |
* Constructor.
|
107 |
*
|
108 |
-
* @since 1.
|
109 |
*
|
110 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
111 |
*/
|
@@ -134,9 +135,9 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
134 |
/**
|
135 |
* Determine if we should allow a file in the backup.
|
136 |
*
|
137 |
-
* @since 1.
|
138 |
*
|
139 |
-
* @param string $file
|
140 |
* @return bool
|
141 |
*/
|
142 |
public function allow_file( $file ) {
|
@@ -186,9 +187,9 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
186 |
* Generate a section for email alerts including information about files and
|
187 |
* folders excluded.
|
188 |
*
|
189 |
-
* @since 1.
|
190 |
*
|
191 |
-
* @param array $info
|
192 |
* @return string
|
193 |
*/
|
194 |
public function email_part( $info ) {
|
@@ -202,11 +203,19 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
202 |
}
|
203 |
|
204 |
if ( $has_folder_included ) {
|
205 |
-
$body .= sprintf(
|
|
|
|
|
|
|
|
|
206 |
}
|
207 |
|
208 |
if ( $has_folder_excluded ) {
|
209 |
-
$body .= sprintf(
|
|
|
|
|
|
|
|
|
210 |
}
|
211 |
|
212 |
return $body;
|
@@ -216,7 +225,7 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
216 |
* Create our regex pattern.
|
217 |
*
|
218 |
* If the user enters wp-* for their include / exclude value, then we need
|
219 |
-
* to convert that into a
|
220 |
*
|
221 |
* When we look for matches, we want to keep it specific to one folder.
|
222 |
* For example, if we're given wp-adm*n, the expectation is that we want
|
@@ -225,12 +234,11 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
225 |
* To prevent this false positive:
|
226 |
* wp-admin/images/media-button.png
|
227 |
* wp-adm************************ng
|
228 |
-
* ... we will set the wildcard to match everything except a directory
|
229 |
-
* separator.
|
230 |
*
|
231 |
-
* @since 1.
|
232 |
*
|
233 |
-
* @param string $value
|
234 |
* @return string
|
235 |
*/
|
236 |
public function create_pattern( $value ) {
|
@@ -272,11 +280,12 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
272 |
/**
|
273 |
* Enqueue scripts.
|
274 |
*
|
275 |
-
* @since 1.
|
276 |
*/
|
277 |
public function enqueue_scripts() {
|
278 |
$handle = 'boldgrid-backup-admin-folder-exclude';
|
279 |
-
wp_register_script(
|
|
|
280 |
plugin_dir_url( __FILE__ ) . 'js/boldgrid-backup-admin-folder-exclude.js',
|
281 |
array( 'jquery' ),
|
282 |
BOLDGRID_BACKUP_VERSION,
|
@@ -285,9 +294,9 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
285 |
$translation = array(
|
286 |
'default_include' => $this->default_include,
|
287 |
'default_exclude' => $this->default_exclude,
|
288 |
-
'items'
|
289 |
-
'no_results'
|
290 |
-
'of'
|
291 |
);
|
292 |
wp_localize_script( $handle, 'BoldGridBackupAdminFolderExclude', $translation );
|
293 |
wp_enqueue_script( $handle );
|
@@ -306,10 +315,10 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
306 |
/**
|
307 |
* Get our include or exclude value from the settings.
|
308 |
*
|
309 |
-
* @since 1.
|
310 |
*
|
311 |
-
* @param string $type
|
312 |
-
* @param array $settings
|
313 |
* @return string
|
314 |
*/
|
315 |
public function from_settings( $type, $settings = false ) {
|
@@ -317,7 +326,7 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
317 |
return false;
|
318 |
}
|
319 |
|
320 |
-
$key
|
321 |
$default = 'default_' . $type;
|
322 |
|
323 |
/*
|
@@ -383,9 +392,9 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
383 |
* wp-content/file.php as a $file, it should match. If I pass in "joec" as a
|
384 |
* $value and wp-content/file.php as a $file, it should not match.
|
385 |
*
|
386 |
-
* @param string $value
|
387 |
-
* @param string $file
|
388 |
-
* wp-content/plugins/boldgrid-backup/boldgrid-backup.php
|
389 |
* @return bool
|
390 |
*/
|
391 |
public function is_match( $value, $file ) {
|
@@ -412,7 +421,11 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
412 |
}
|
413 |
|
414 |
/**
|
|
|
|
|
|
|
415 |
*
|
|
|
416 |
*/
|
417 |
public function is_using_defaults() {
|
418 |
$type = $this->from_settings( 'type' );
|
@@ -423,7 +436,7 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
423 |
/**
|
424 |
* Get our include / exclude settings from $_POST.
|
425 |
*
|
426 |
-
* @since 1.
|
427 |
*
|
428 |
* @param string $type Either include or exclude.
|
429 |
* @return string
|
@@ -465,7 +478,7 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
465 |
/**
|
466 |
* Handle the ajax request to preview the filters.
|
467 |
*
|
468 |
-
* @since 1.
|
469 |
*/
|
470 |
public function wp_ajax_preview() {
|
471 |
if ( ! check_ajax_referer( 'folder_exclusion_preview', 'security', false ) ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-folder-exclusion.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.6.0
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
// phpcs:disable WordPress.VIP, WordPress.CSRF.NonceVerification.NoNonceVerification
|
16 |
+
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Folder_Exclusion
|
19 |
*
|
20 |
+
* @since 1.6.0
|
21 |
*/
|
22 |
class Boldgrid_Backup_Admin_Folder_Exclusion {
|
|
|
23 |
/**
|
24 |
* The default exclude value.
|
25 |
*
|
26 |
+
* @since 1.6.0
|
27 |
* @var string
|
28 |
*/
|
29 |
public $default_exclude = '.git,node_modules';
|
31 |
/**
|
32 |
* The default include value.
|
33 |
*
|
34 |
+
* @since 1.6.0
|
35 |
* @var string
|
36 |
*/
|
37 |
public $default_include = 'WPCORE,/wp-content';
|
39 |
/**
|
40 |
* By default, backup all files and folders (use default settings).
|
41 |
*
|
42 |
+
* @since 1.6.0
|
43 |
* @var string
|
44 |
*/
|
45 |
public $default_type = 'full';
|
47 |
/**
|
48 |
* Our exclude value.
|
49 |
*
|
50 |
+
* @since 1.6.0
|
51 |
* @var string|null
|
52 |
*/
|
53 |
public $exclude = null;
|
55 |
/**
|
56 |
* Our include value.
|
57 |
*
|
58 |
+
* @since 1.6.0
|
59 |
* @var string|null
|
60 |
*/
|
61 |
public $include = null;
|
63 |
/**
|
64 |
* Whether or not we're in the ajax preview.
|
65 |
*
|
66 |
+
* @since 1.6.0
|
67 |
* @var bool
|
68 |
*/
|
69 |
public $in_ajax_preview = false;
|
73 |
*
|
74 |
* Usually it will be 'full' or 'custom'.
|
75 |
*
|
76 |
+
* @since 1.6.0
|
77 |
* @var null|string
|
78 |
*/
|
79 |
public $type = null;
|
81 |
/**
|
82 |
* Allowable types.
|
83 |
*
|
84 |
+
* @since 1.6.0
|
85 |
* @var array
|
86 |
*/
|
87 |
public $types = array( 'include', 'exclude', 'type' );
|
89 |
/**
|
90 |
* Valid backup types.
|
91 |
*
|
92 |
+
* @since 1.6.0
|
93 |
* @var array
|
94 |
*/
|
95 |
public $valid_types = array( 'full', 'custom' );
|
97 |
/**
|
98 |
* The core class object.
|
99 |
*
|
100 |
+
* @since 1.6.0
|
101 |
* @access private
|
102 |
* @var Boldgrid_Backup_Admin_Core
|
103 |
*/
|
106 |
/**
|
107 |
* Constructor.
|
108 |
*
|
109 |
+
* @since 1.6.0
|
110 |
*
|
111 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
112 |
*/
|
135 |
/**
|
136 |
* Determine if we should allow a file in the backup.
|
137 |
*
|
138 |
+
* @since 1.6.0
|
139 |
*
|
140 |
+
* @param string $file File path.
|
141 |
* @return bool
|
142 |
*/
|
143 |
public function allow_file( $file ) {
|
187 |
* Generate a section for email alerts including information about files and
|
188 |
* folders excluded.
|
189 |
*
|
190 |
+
* @since 1.6.0
|
191 |
*
|
192 |
+
* @param array $info File and folder settings.
|
193 |
* @return string
|
194 |
*/
|
195 |
public function email_part( $info ) {
|
203 |
}
|
204 |
|
205 |
if ( $has_folder_included ) {
|
206 |
+
$body .= sprintf(
|
207 |
+
// translators: 1: Included folder list.
|
208 |
+
esc_html__( 'Included: %1$s', 'boldgrid-backup' ),
|
209 |
+
$info['folder_include']
|
210 |
+
) . "\n";
|
211 |
}
|
212 |
|
213 |
if ( $has_folder_excluded ) {
|
214 |
+
$body .= sprintf(
|
215 |
+
// translators: 1: Excluded folder list.
|
216 |
+
esc_html__( 'Excluded: %1$s', 'boldgrid-backup' ),
|
217 |
+
$info['folder_exclude']
|
218 |
+
) . "\n";
|
219 |
}
|
220 |
|
221 |
return $body;
|
225 |
* Create our regex pattern.
|
226 |
*
|
227 |
* If the user enters wp-* for their include / exclude value, then we need
|
228 |
+
* to convert that into a proper regex pattern.
|
229 |
*
|
230 |
* When we look for matches, we want to keep it specific to one folder.
|
231 |
* For example, if we're given wp-adm*n, the expectation is that we want
|
234 |
* To prevent this false positive:
|
235 |
* wp-admin/images/media-button.png
|
236 |
* wp-adm************************ng
|
237 |
+
* ... we will set the wildcard to match everything except a directory separator.
|
|
|
238 |
*
|
239 |
+
* @since 1.6.0
|
240 |
*
|
241 |
+
* @param string $value Input string.
|
242 |
* @return string
|
243 |
*/
|
244 |
public function create_pattern( $value ) {
|
280 |
/**
|
281 |
* Enqueue scripts.
|
282 |
*
|
283 |
+
* @since 1.6.0
|
284 |
*/
|
285 |
public function enqueue_scripts() {
|
286 |
$handle = 'boldgrid-backup-admin-folder-exclude';
|
287 |
+
wp_register_script(
|
288 |
+
$handle,
|
289 |
plugin_dir_url( __FILE__ ) . 'js/boldgrid-backup-admin-folder-exclude.js',
|
290 |
array( 'jquery' ),
|
291 |
BOLDGRID_BACKUP_VERSION,
|
294 |
$translation = array(
|
295 |
'default_include' => $this->default_include,
|
296 |
'default_exclude' => $this->default_exclude,
|
297 |
+
'items' => __( 'items', 'boldgrid-backup' ),
|
298 |
+
'no_results' => __( 'No results', 'boldgrid-backup' ),
|
299 |
+
'of' => __( 'of', 'boldgrid-backup' ),
|
300 |
);
|
301 |
wp_localize_script( $handle, 'BoldGridBackupAdminFolderExclude', $translation );
|
302 |
wp_enqueue_script( $handle );
|
315 |
/**
|
316 |
* Get our include or exclude value from the settings.
|
317 |
*
|
318 |
+
* @since 1.6.0
|
319 |
*
|
320 |
+
* @param string $type Either 'include' or 'exclude'.
|
321 |
+
* @param array $settings File and folder settings.
|
322 |
* @return string
|
323 |
*/
|
324 |
public function from_settings( $type, $settings = false ) {
|
326 |
return false;
|
327 |
}
|
328 |
|
329 |
+
$key = 'folder_exclusion_' . $type;
|
330 |
$default = 'default_' . $type;
|
331 |
|
332 |
/*
|
392 |
* wp-content/file.php as a $file, it should match. If I pass in "joec" as a
|
393 |
* $value and wp-content/file.php as a $file, it should not match.
|
394 |
*
|
395 |
+
* @param string $value Input string.
|
396 |
+
* @param string $file File path relative to ABSPATH, such as:
|
397 |
+
* "wp-content/plugins/boldgrid-backup/boldgrid-backup.php".
|
398 |
* @return bool
|
399 |
*/
|
400 |
public function is_match( $value, $file ) {
|
421 |
}
|
422 |
|
423 |
/**
|
424 |
+
* Is using default settings?
|
425 |
+
*
|
426 |
+
* @since 1.6.0
|
427 |
*
|
428 |
+
* @return bool
|
429 |
*/
|
430 |
public function is_using_defaults() {
|
431 |
$type = $this->from_settings( 'type' );
|
436 |
/**
|
437 |
* Get our include / exclude settings from $_POST.
|
438 |
*
|
439 |
+
* @since 1.6.0
|
440 |
*
|
441 |
* @param string $type Either include or exclude.
|
442 |
* @return string
|
478 |
/**
|
479 |
* Handle the ajax request to preview the filters.
|
480 |
*
|
481 |
+
* @since 1.6.0
|
482 |
*/
|
483 |
public function wp_ajax_preview() {
|
484 |
if ( ! check_ajax_referer( 'folder_exclusion_preview', 'security', false ) ) {
|
admin/class-boldgrid-backup-admin-go-pro.php
CHANGED
@@ -1,28 +1,27 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since 1.
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
-
* @since 1.
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Go_Pro {
|
21 |
-
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
25 |
-
* @since
|
26 |
* @access private
|
27 |
* @var Boldgrid_Backup_Admin_Core
|
28 |
*/
|
@@ -31,16 +30,16 @@ class Boldgrid_Backup_Admin_Go_Pro {
|
|
31 |
/**
|
32 |
* Generic upgrade link.
|
33 |
*
|
34 |
-
* @since
|
35 |
* @access public
|
36 |
* @var string
|
37 |
*/
|
38 |
-
public static $url = 'https://boldgrid.com/update-backup';
|
39 |
|
40 |
/**
|
41 |
* Constructor.
|
42 |
*
|
43 |
-
* @since 1.
|
44 |
*
|
45 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
46 |
*/
|
@@ -54,10 +53,9 @@ class Boldgrid_Backup_Admin_Go_Pro {
|
|
54 |
* This method is currently used to display admin notices to help guide the
|
55 |
* user to getting a premium key and getting / activating the premium extension.
|
56 |
*
|
57 |
-
* @since 1.
|
58 |
*/
|
59 |
public function admin_notice_setup() {
|
60 |
-
|
61 |
// If the premium plugin is installed and all is good, abort!
|
62 |
if ( $this->core->config->is_premium_done ) {
|
63 |
return;
|
@@ -79,7 +77,11 @@ class Boldgrid_Backup_Admin_Go_Pro {
|
|
79 |
'id' => 'boldgrid_backup_activate_premium',
|
80 |
'show' => $is_premium && $this->core->config->is_premium_installed,
|
81 |
'message' => '<p>' . sprintf(
|
82 |
-
|
|
|
|
|
|
|
|
|
83 |
admin_url( 'plugins.php' )
|
84 |
) . '</p>',
|
85 |
),
|
@@ -87,6 +89,7 @@ class Boldgrid_Backup_Admin_Go_Pro {
|
|
87 |
'id' => 'boldgrid_backup_upgrade_premium',
|
88 |
'show' => ! $is_premium && $this->core->config->is_premium_active,
|
89 |
'message' => '<p>' . sprintf(
|
|
|
90 |
__( 'Thank you for activating the <strong>BoldGrid Backup Premium Extension</strong>! Before you can begin using all of the premium features, you must <a href="%2$s">add your premium key</a>. If you are using an Official BoldGrid Host, contact them or login to their management system to retrieve your Premium key. Otherwise, please visit <a href="%1$s" target="_blank">BoldGrid Central</a> to upgrade.', 'boldgrid-backup' ),
|
91 |
self::$url,
|
92 |
admin_url( 'admin.php?page=boldgrid-backup-settings§ion=connect_key' )
|
@@ -96,7 +99,11 @@ class Boldgrid_Backup_Admin_Go_Pro {
|
|
96 |
'id' => 'boldgrid_backup_download_premium',
|
97 |
'show' => $is_premium && ! $this->core->config->is_premium_installed,
|
98 |
'message' => '<p>' . sprintf(
|
99 |
-
|
|
|
|
|
|
|
|
|
100 |
'https://www.boldgrid.com/central'
|
101 |
) . '</p>',
|
102 |
),
|
@@ -113,13 +120,13 @@ class Boldgrid_Backup_Admin_Go_Pro {
|
|
113 |
/**
|
114 |
* Get a "Get Premium" button.
|
115 |
*
|
116 |
-
* @since 1.
|
117 |
*
|
118 |
-
* @param string $url
|
119 |
-
* @param string $text
|
120 |
* @return string
|
121 |
*/
|
122 |
-
public function get_premium_button( $url = 'https://boldgrid.com/update-backup', $text = 'Get Premium' ) {
|
123 |
return sprintf(
|
124 |
'
|
125 |
<a href="%1$s" class="button button-success" target="_blank">%2$s</a>',
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-go-pro.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.6.0
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_Go_Pro
|
17 |
*
|
18 |
+
* @since 1.6.0
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Go_Pro {
|
|
|
21 |
/**
|
22 |
* The core class object.
|
23 |
*
|
24 |
+
* @since 1.6.0
|
25 |
* @access private
|
26 |
* @var Boldgrid_Backup_Admin_Core
|
27 |
*/
|
30 |
/**
|
31 |
* Generic upgrade link.
|
32 |
*
|
33 |
+
* @since 1.6.0
|
34 |
* @access public
|
35 |
* @var string
|
36 |
*/
|
37 |
+
public static $url = 'https://www.boldgrid.com/update-backup';
|
38 |
|
39 |
/**
|
40 |
* Constructor.
|
41 |
*
|
42 |
+
* @since 1.6.0
|
43 |
*
|
44 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
45 |
*/
|
53 |
* This method is currently used to display admin notices to help guide the
|
54 |
* user to getting a premium key and getting / activating the premium extension.
|
55 |
*
|
56 |
+
* @since 1.6.0
|
57 |
*/
|
58 |
public function admin_notice_setup() {
|
|
|
59 |
// If the premium plugin is installed and all is good, abort!
|
60 |
if ( $this->core->config->is_premium_done ) {
|
61 |
return;
|
77 |
'id' => 'boldgrid_backup_activate_premium',
|
78 |
'show' => $is_premium && $this->core->config->is_premium_installed,
|
79 |
'message' => '<p>' . sprintf(
|
80 |
+
// translators: 1: URL address for the wp-admin plugins page.
|
81 |
+
__(
|
82 |
+
'You have a <strong>Premium BoldGrid Connect Key</strong> and you have the <strong>BoldGrid Backup Premium Extension installed</strong>. Please go to your <a href="%1$s">plugins page</a> and activate your premium extension!',
|
83 |
+
'boldgrid-backup'
|
84 |
+
),
|
85 |
admin_url( 'plugins.php' )
|
86 |
) . '</p>',
|
87 |
),
|
89 |
'id' => 'boldgrid_backup_upgrade_premium',
|
90 |
'show' => ! $is_premium && $this->core->config->is_premium_active,
|
91 |
'message' => '<p>' . sprintf(
|
92 |
+
// translators: 1: URL address for the upgrade page.
|
93 |
__( 'Thank you for activating the <strong>BoldGrid Backup Premium Extension</strong>! Before you can begin using all of the premium features, you must <a href="%2$s">add your premium key</a>. If you are using an Official BoldGrid Host, contact them or login to their management system to retrieve your Premium key. Otherwise, please visit <a href="%1$s" target="_blank">BoldGrid Central</a> to upgrade.', 'boldgrid-backup' ),
|
94 |
self::$url,
|
95 |
admin_url( 'admin.php?page=boldgrid-backup-settings§ion=connect_key' )
|
99 |
'id' => 'boldgrid_backup_download_premium',
|
100 |
'show' => $is_premium && ! $this->core->config->is_premium_installed,
|
101 |
'message' => '<p>' . sprintf(
|
102 |
+
// translators: 1: URL address for BoldGrid Central.
|
103 |
+
__(
|
104 |
+
'Hello there! We see that you have a <strong>Premium BoldGrid Connect Key</strong> and you have the <strong>BoldGrid Backup Plugin</strong> activated! Be sure to download the <strong>BoldGrid Backup Premium Extension</strong> from <a href="%1$s">BoldGrid Central</a> to gain access to more features!',
|
105 |
+
'boldgrid-backup'
|
106 |
+
),
|
107 |
'https://www.boldgrid.com/central'
|
108 |
) . '</p>',
|
109 |
),
|
120 |
/**
|
121 |
* Get a "Get Premium" button.
|
122 |
*
|
123 |
+
* @since 1.6.0
|
124 |
*
|
125 |
+
* @param string $url URL address for the upgrade page.
|
126 |
+
* @param string $text Button text.
|
127 |
* @return string
|
128 |
*/
|
129 |
+
public function get_premium_button( $url = 'https://www.boldgrid.com/update-backup', $text = 'Get Premium' ) {
|
130 |
return sprintf(
|
131 |
'
|
132 |
<a href="%1$s" class="button button-success" target="_blank">%2$s</a>',
|
admin/class-boldgrid-backup-admin-home-dir.php
CHANGED
@@ -1,24 +1,23 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Home_Dir {
|
21 |
-
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
@@ -33,7 +32,7 @@ class Boldgrid_Backup_Admin_Home_Dir {
|
|
33 |
*
|
34 |
* @since 1.5.1
|
35 |
*
|
36 |
-
* @param Boldgrid_Backup_Admin_Core $core
|
37 |
*/
|
38 |
public function __construct( $core ) {
|
39 |
$this->core = $core;
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-home-dir.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_Home_Dir
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Home_Dir {
|
|
|
21 |
/**
|
22 |
* The core class object.
|
23 |
*
|
32 |
*
|
33 |
* @since 1.5.1
|
34 |
*
|
35 |
+
* @param Boldgrid_Backup_Admin_Core $core Boldgrid_Backup_Admin_Core object.
|
36 |
*/
|
37 |
public function __construct( $core ) {
|
38 |
$this->core = $core;
|
admin/class-boldgrid-backup-admin-in-progress.php
CHANGED
@@ -1,28 +1,27 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since 1.
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
-
* @since 1.
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_In_Progress {
|
21 |
-
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
25 |
-
* @since
|
26 |
* @access private
|
27 |
* @var Boldgrid_Backup_Admin_Core
|
28 |
*/
|
@@ -43,7 +42,7 @@ class Boldgrid_Backup_Admin_In_Progress {
|
|
43 |
/**
|
44 |
* Constructor.
|
45 |
*
|
46 |
-
* @since 1.
|
47 |
*
|
48 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
49 |
*/
|
@@ -54,9 +53,9 @@ class Boldgrid_Backup_Admin_In_Progress {
|
|
54 |
/**
|
55 |
* Add a notice telling the user there's a backup in progress.
|
56 |
*
|
57 |
-
* @since 1.
|
58 |
*
|
59 |
-
* @param array $notices
|
60 |
* @return array
|
61 |
*/
|
62 |
public function add_notice( $notices ) {
|
@@ -74,7 +73,7 @@ class Boldgrid_Backup_Admin_In_Progress {
|
|
74 |
wp_enqueue_script( 'heartbeat' );
|
75 |
|
76 |
$elapsed = time() - $in_progress;
|
77 |
-
$limit
|
78 |
|
79 |
$notice = $this->get_notice();
|
80 |
if ( false === $notice ) {
|
@@ -86,7 +85,11 @@ class Boldgrid_Backup_Admin_In_Progress {
|
|
86 |
* help with troubleshooting.
|
87 |
*/
|
88 |
if ( $elapsed > $limit ) {
|
89 |
-
$notice['message'] .= __(
|
|
|
|
|
|
|
|
|
90 |
$this->end();
|
91 |
}
|
92 |
|
@@ -100,7 +103,7 @@ class Boldgrid_Backup_Admin_In_Progress {
|
|
100 |
*
|
101 |
* Specify that we are no longer backing up a website.
|
102 |
*
|
103 |
-
* @since 1.
|
104 |
*/
|
105 |
public function end() {
|
106 |
$settings = $this->core->settings->get_settings( true );
|
@@ -117,7 +120,7 @@ class Boldgrid_Backup_Admin_In_Progress {
|
|
117 |
*
|
118 |
* The value is the time we started the backup.
|
119 |
*
|
120 |
-
* @since
|
121 |
*
|
122 |
* @return int
|
123 |
*/
|
@@ -144,8 +147,15 @@ class Boldgrid_Backup_Admin_In_Progress {
|
|
144 |
}
|
145 |
|
146 |
$notice = array(
|
147 |
-
'class'
|
148 |
-
'message' => sprintf(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
'heading' => __( 'BoldGrid Backup - Backup in progress', 'boldgrid-backup' ),
|
150 |
);
|
151 |
|
@@ -179,8 +189,8 @@ class Boldgrid_Backup_Admin_In_Progress {
|
|
179 |
*
|
180 |
* @since 1.6.0
|
181 |
*
|
182 |
-
* @param array $response
|
183 |
-
* @param array $data
|
184 |
* @return array
|
185 |
*/
|
186 |
public function heartbeat_received( $response, $data ) {
|
@@ -205,7 +215,6 @@ class Boldgrid_Backup_Admin_In_Progress {
|
|
205 |
* @since 1.6.0
|
206 |
*/
|
207 |
public function post_dump() {
|
208 |
-
|
209 |
/*
|
210 |
* After the database has been dumped, restore the flag stating a backup
|
211 |
* is still in progress.
|
@@ -223,7 +232,6 @@ class Boldgrid_Backup_Admin_In_Progress {
|
|
223 |
* @since 1.6.0
|
224 |
*/
|
225 |
public function pre_dump() {
|
226 |
-
|
227 |
/*
|
228 |
* Cancel any "Backup in progress" statuses.
|
229 |
*
|
@@ -241,7 +249,7 @@ class Boldgrid_Backup_Admin_In_Progress {
|
|
241 |
/**
|
242 |
* Set that we are in progress of backing up a website.
|
243 |
*
|
244 |
-
* @since 1.
|
245 |
*
|
246 |
* @param int $time A unix timestamp indicating the time a backup started.
|
247 |
*/
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-in-progress.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.6.0
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_In_Progress
|
17 |
*
|
18 |
+
* @since 1.6.0
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_In_Progress {
|
|
|
21 |
/**
|
22 |
* The core class object.
|
23 |
*
|
24 |
+
* @since 1.6.0
|
25 |
* @access private
|
26 |
* @var Boldgrid_Backup_Admin_Core
|
27 |
*/
|
42 |
/**
|
43 |
* Constructor.
|
44 |
*
|
45 |
+
* @since 1.6.0
|
46 |
*
|
47 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
48 |
*/
|
53 |
/**
|
54 |
* Add a notice telling the user there's a backup in progress.
|
55 |
*
|
56 |
+
* @since 1.6.0
|
57 |
*
|
58 |
+
* @param array $notices Array of notices to display.
|
59 |
* @return array
|
60 |
*/
|
61 |
public function add_notice( $notices ) {
|
73 |
wp_enqueue_script( 'heartbeat' );
|
74 |
|
75 |
$elapsed = time() - $in_progress;
|
76 |
+
$limit = 15 * MINUTE_IN_SECONDS;
|
77 |
|
78 |
$notice = $this->get_notice();
|
79 |
if ( false === $notice ) {
|
85 |
* help with troubleshooting.
|
86 |
*/
|
87 |
if ( $elapsed > $limit ) {
|
88 |
+
$notice['message'] .= __(
|
89 |
+
' Most backups usually finish before this amount of time, so we will stop displaying this notice.',
|
90 |
+
'boldgrid-backup'
|
91 |
+
);
|
92 |
+
|
93 |
$this->end();
|
94 |
}
|
95 |
|
103 |
*
|
104 |
* Specify that we are no longer backing up a website.
|
105 |
*
|
106 |
+
* @since 1.6.0
|
107 |
*/
|
108 |
public function end() {
|
109 |
$settings = $this->core->settings->get_settings( true );
|
120 |
*
|
121 |
* The value is the time we started the backup.
|
122 |
*
|
123 |
+
* @since 1.6.0
|
124 |
*
|
125 |
* @return int
|
126 |
*/
|
147 |
}
|
148 |
|
149 |
$notice = array(
|
150 |
+
'class' => 'notice notice-warning boldgrid-backup-in-progress',
|
151 |
+
'message' => sprintf(
|
152 |
+
// translators: 1: Time difference.
|
153 |
+
__(
|
154 |
+
'BoldGrid Backup began archiving your website %1$s ago.',
|
155 |
+
'boldgrid-backup'
|
156 |
+
),
|
157 |
+
human_time_diff( $in_progress, time() )
|
158 |
+
),
|
159 |
'heading' => __( 'BoldGrid Backup - Backup in progress', 'boldgrid-backup' ),
|
160 |
);
|
161 |
|
189 |
*
|
190 |
* @since 1.6.0
|
191 |
*
|
192 |
+
* @param array $response Response.
|
193 |
+
* @param array $data Data in heartbeat.
|
194 |
* @return array
|
195 |
*/
|
196 |
public function heartbeat_received( $response, $data ) {
|
215 |
* @since 1.6.0
|
216 |
*/
|
217 |
public function post_dump() {
|
|
|
218 |
/*
|
219 |
* After the database has been dumped, restore the flag stating a backup
|
220 |
* is still in progress.
|
232 |
* @since 1.6.0
|
233 |
*/
|
234 |
public function pre_dump() {
|
|
|
235 |
/*
|
236 |
* Cancel any "Backup in progress" statuses.
|
237 |
*
|
249 |
/**
|
250 |
* Set that we are in progress of backing up a website.
|
251 |
*
|
252 |
+
* @since 1.6.0
|
253 |
*
|
254 |
* @param int $time A unix timestamp indicating the time a backup started.
|
255 |
*/
|
admin/class-boldgrid-backup-admin-jobs.php
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.5.2
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* Option $boldgrid_backup_jobs array {
|
19 |
* An array of jobs that need to be ran.
|
@@ -32,7 +32,6 @@
|
|
32 |
* @since 1.5.2
|
33 |
*/
|
34 |
class Boldgrid_Backup_Admin_Jobs {
|
35 |
-
|
36 |
/**
|
37 |
* The core class object.
|
38 |
*
|
@@ -64,7 +63,7 @@ class Boldgrid_Backup_Admin_Jobs {
|
|
64 |
*
|
65 |
* @since 1.5.2
|
66 |
*
|
67 |
-
* @param Boldgrid_Backup_Admin_Core $core
|
68 |
*/
|
69 |
public function __construct( $core ) {
|
70 |
$this->core = $core;
|
@@ -98,7 +97,7 @@ class Boldgrid_Backup_Admin_Jobs {
|
|
98 |
*
|
99 |
* @since 1.5.2
|
100 |
*
|
101 |
-
* @param int $delete_key
|
102 |
*/
|
103 |
public function delete_all_prior( $delete_key ) {
|
104 |
|
@@ -146,7 +145,7 @@ class Boldgrid_Backup_Admin_Jobs {
|
|
146 |
*
|
147 |
* @since 1.5.2
|
148 |
*
|
149 |
-
* @param array $info
|
150 |
*/
|
151 |
public function post_archive_files( $info ) {
|
152 |
/*
|
@@ -163,8 +162,8 @@ class Boldgrid_Backup_Admin_Jobs {
|
|
163 |
}
|
164 |
|
165 |
$args = array(
|
166 |
-
'filepath'
|
167 |
-
'action'
|
168 |
'action_data' => $info,
|
169 |
'post_action' => 'delete_all_prior',
|
170 |
);
|
@@ -174,6 +173,10 @@ class Boldgrid_Backup_Admin_Jobs {
|
|
174 |
|
175 |
/**
|
176 |
* Send an email after all jobs have been ran.
|
|
|
|
|
|
|
|
|
177 |
*/
|
178 |
public function post_jobs_email( $info ) {
|
179 |
$post_jobs = 0;
|
@@ -231,15 +234,13 @@ class Boldgrid_Backup_Admin_Jobs {
|
|
231 |
* @since 1.5.2
|
232 |
*
|
233 |
* @see Boldgrid_Backup_Admin_Cron::is_valid_call()
|
234 |
-
*
|
235 |
-
* @return null
|
236 |
*/
|
237 |
public function run() {
|
238 |
$this->set_jobs();
|
239 |
|
240 |
// If not logged-in, then require a matching "id".
|
241 |
if ( ! $this->core->cron->is_valid_call() ) {
|
242 |
-
wp_die(
|
243 |
}
|
244 |
|
245 |
// If there are no jobs or already running, then abort.
|
@@ -258,7 +259,7 @@ class Boldgrid_Backup_Admin_Jobs {
|
|
258 |
$status = apply_filters( $job['action'], $job['action_data'] );
|
259 |
|
260 |
$job['end_time'] = time();
|
261 |
-
$job['status']
|
262 |
$this->save_jobs();
|
263 |
|
264 |
break;
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-jobs.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.5.2
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_Jobs
|
17 |
*
|
18 |
* Option $boldgrid_backup_jobs array {
|
19 |
* An array of jobs that need to be ran.
|
32 |
* @since 1.5.2
|
33 |
*/
|
34 |
class Boldgrid_Backup_Admin_Jobs {
|
|
|
35 |
/**
|
36 |
* The core class object.
|
37 |
*
|
63 |
*
|
64 |
* @since 1.5.2
|
65 |
*
|
66 |
+
* @param Boldgrid_Backup_Admin_Core $core Boldgrid_Backup_Admin_Core Object.
|
67 |
*/
|
68 |
public function __construct( $core ) {
|
69 |
$this->core = $core;
|
97 |
*
|
98 |
* @since 1.5.2
|
99 |
*
|
100 |
+
* @param int $delete_key Archive list key index number.
|
101 |
*/
|
102 |
public function delete_all_prior( $delete_key ) {
|
103 |
|
145 |
*
|
146 |
* @since 1.5.2
|
147 |
*
|
148 |
+
* @param array $info Archive information.
|
149 |
*/
|
150 |
public function post_archive_files( $info ) {
|
151 |
/*
|
162 |
}
|
163 |
|
164 |
$args = array(
|
165 |
+
'filepath' => $info['filepath'],
|
166 |
+
'action' => 'boldgrid_backup_post_jobs_email',
|
167 |
'action_data' => $info,
|
168 |
'post_action' => 'delete_all_prior',
|
169 |
);
|
173 |
|
174 |
/**
|
175 |
* Send an email after all jobs have been ran.
|
176 |
+
*
|
177 |
+
* @since 1.5.2
|
178 |
+
*
|
179 |
+
* @param array $info Archive information.
|
180 |
*/
|
181 |
public function post_jobs_email( $info ) {
|
182 |
$post_jobs = 0;
|
234 |
* @since 1.5.2
|
235 |
*
|
236 |
* @see Boldgrid_Backup_Admin_Cron::is_valid_call()
|
|
|
|
|
237 |
*/
|
238 |
public function run() {
|
239 |
$this->set_jobs();
|
240 |
|
241 |
// If not logged-in, then require a matching "id".
|
242 |
if ( ! $this->core->cron->is_valid_call() ) {
|
243 |
+
wp_die( esc_html__( 'Error: Invalid request.', 'boldgrid-backup' ) );
|
244 |
}
|
245 |
|
246 |
// If there are no jobs or already running, then abort.
|
259 |
$status = apply_filters( $job['action'], $job['action_data'] );
|
260 |
|
261 |
$job['end_time'] = time();
|
262 |
+
$job['status'] = $status ? 'success' : 'fail';
|
263 |
$this->save_jobs();
|
264 |
|
265 |
break;
|
admin/class-boldgrid-backup-admin-notice.php
CHANGED
@@ -1,28 +1,27 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since
|
7 |
*
|
8 |
-
* @package
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright
|
11 |
-
* @version
|
12 |
-
* @author
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.2
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Notice {
|
21 |
-
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
25 |
-
* @since
|
26 |
* @access private
|
27 |
* @var Boldgrid_Backup_Admin_Core
|
28 |
*/
|
@@ -31,18 +30,18 @@ class Boldgrid_Backup_Admin_Notice {
|
|
31 |
/**
|
32 |
* Common strings used in notices.
|
33 |
*
|
34 |
-
* @since 1.
|
35 |
* @var array
|
36 |
*/
|
37 |
public $lang = array(
|
38 |
-
'dis_error'
|
39 |
'dis_success' => 'notice notice-success is-dismissible',
|
40 |
);
|
41 |
|
42 |
/**
|
43 |
* Constructor.
|
44 |
*
|
45 |
-
* @since 1.
|
46 |
*
|
47 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
48 |
*/
|
@@ -53,11 +52,11 @@ class Boldgrid_Backup_Admin_Notice {
|
|
53 |
/**
|
54 |
* Add a notice for a user.
|
55 |
*
|
56 |
-
* @since 1.
|
57 |
*
|
58 |
-
* @param string $message
|
59 |
-
* @param string $class
|
60 |
-
* @param string $heading
|
61 |
*/
|
62 |
public function add_user_notice( $message, $class, $heading = null ) {
|
63 |
$option = $this->get_user_option();
|
@@ -68,7 +67,7 @@ class Boldgrid_Backup_Admin_Notice {
|
|
68 |
|
69 |
$notices[] = array(
|
70 |
'message' => $message,
|
71 |
-
'class'
|
72 |
'heading' => $heading,
|
73 |
);
|
74 |
|
@@ -86,7 +85,7 @@ class Boldgrid_Backup_Admin_Notice {
|
|
86 |
/**
|
87 |
* Display notices for user.
|
88 |
*
|
89 |
-
* @since 1.
|
90 |
*/
|
91 |
public function display_user_notice() {
|
92 |
$option = $this->get_user_option();
|
@@ -100,14 +99,16 @@ class Boldgrid_Backup_Admin_Notice {
|
|
100 |
}
|
101 |
|
102 |
foreach ( $notices as $notice ) {
|
103 |
-
printf(
|
|
|
104 |
<div class="%1$s is-dismissible">
|
105 |
%3$s
|
106 |
%2$s
|
107 |
</div>',
|
108 |
/* 1 */ $notice['class'],
|
109 |
/* 2 */ $this->add_container( $notice['message'] ),
|
110 |
-
/* 3 */ ! empty( $notice['heading'] ) ?
|
|
|
111 |
);
|
112 |
}
|
113 |
|
@@ -127,9 +128,7 @@ class Boldgrid_Backup_Admin_Notice {
|
|
127 |
return;
|
128 |
}
|
129 |
|
130 |
-
|
131 |
-
|
132 |
-
echo $markup;
|
133 |
|
134 |
$this->displayed_messages[] = $message;
|
135 |
}
|
@@ -142,7 +141,6 @@ class Boldgrid_Backup_Admin_Notice {
|
|
142 |
* @return mixed String (html markup) of admin notice on success, false on failure.
|
143 |
*/
|
144 |
public function get_backup_complete() {
|
145 |
-
|
146 |
// Assume that this "backup complete!" notice is for the last backup made.
|
147 |
$archive_info = get_option( 'boldgrid_backup_latest_backup' );
|
148 |
if ( empty( $archive_info ) ) {
|
@@ -159,13 +157,14 @@ class Boldgrid_Backup_Admin_Notice {
|
|
159 |
/**
|
160 |
* Get the entire html markup for a notice, including the .notice container.
|
161 |
*
|
162 |
-
* @param string $class
|
163 |
-
* @param string $message
|
164 |
-
* @param string $heading
|
165 |
* @return string
|
166 |
*/
|
167 |
public function get_notice_markup( $class, $message, $heading = null ) {
|
168 |
-
return sprintf(
|
|
|
169 |
<div class="%1$s">
|
170 |
%2$s
|
171 |
%3$s
|
@@ -186,6 +185,7 @@ class Boldgrid_Backup_Admin_Notice {
|
|
186 |
public function functionality_fail_notice( $use_link = true ) {
|
187 |
if ( $use_link ) {
|
188 |
$message = sprintf(
|
|
|
189 |
esc_html__(
|
190 |
'Functionality test has failed. You can go to %1$sFunctionality Test%2$s to view a report.',
|
191 |
'boldgrid-backup'
|
@@ -203,7 +203,7 @@ class Boldgrid_Backup_Admin_Notice {
|
|
203 |
/**
|
204 |
* Get user_notices option name for current user.
|
205 |
*
|
206 |
-
* @since 1.
|
207 |
*/
|
208 |
public function get_user_option() {
|
209 |
$user_id = get_current_user_id();
|
@@ -215,9 +215,9 @@ class Boldgrid_Backup_Admin_Notice {
|
|
215 |
*
|
216 |
* If it is not within a p or div, wrap it in a p tag.
|
217 |
*
|
218 |
-
* @since 1.
|
219 |
*
|
220 |
-
* @param string $message
|
221 |
* @return string
|
222 |
*/
|
223 |
public function add_container( $message ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-notice.php
|
4 |
*
|
5 |
+
* @link http://www.boldgrid.com
|
6 |
+
* @since 1.2
|
7 |
*
|
8 |
+
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid.com
|
11 |
+
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_Notice
|
17 |
*
|
18 |
* @since 1.2
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Notice {
|
|
|
21 |
/**
|
22 |
* The core class object.
|
23 |
*
|
24 |
+
* @since 1.6.0
|
25 |
* @access private
|
26 |
* @var Boldgrid_Backup_Admin_Core
|
27 |
*/
|
30 |
/**
|
31 |
* Common strings used in notices.
|
32 |
*
|
33 |
+
* @since 1.6.0
|
34 |
* @var array
|
35 |
*/
|
36 |
public $lang = array(
|
37 |
+
'dis_error' => 'notice notice-error is-dismissible',
|
38 |
'dis_success' => 'notice notice-success is-dismissible',
|
39 |
);
|
40 |
|
41 |
/**
|
42 |
* Constructor.
|
43 |
*
|
44 |
+
* @since 1.6.0
|
45 |
*
|
46 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
47 |
*/
|
52 |
/**
|
53 |
* Add a notice for a user.
|
54 |
*
|
55 |
+
* @since 1.6.0
|
56 |
*
|
57 |
+
* @param string $message Message.
|
58 |
+
* @param string $class Class.
|
59 |
+
* @param string $heading Heading.
|
60 |
*/
|
61 |
public function add_user_notice( $message, $class, $heading = null ) {
|
62 |
$option = $this->get_user_option();
|
67 |
|
68 |
$notices[] = array(
|
69 |
'message' => $message,
|
70 |
+
'class' => $class,
|
71 |
'heading' => $heading,
|
72 |
);
|
73 |
|
85 |
/**
|
86 |
* Display notices for user.
|
87 |
*
|
88 |
+
* @since 1.6.0
|
89 |
*/
|
90 |
public function display_user_notice() {
|
91 |
$option = $this->get_user_option();
|
99 |
}
|
100 |
|
101 |
foreach ( $notices as $notice ) {
|
102 |
+
printf(
|
103 |
+
'
|
104 |
<div class="%1$s is-dismissible">
|
105 |
%3$s
|
106 |
%2$s
|
107 |
</div>',
|
108 |
/* 1 */ $notice['class'],
|
109 |
/* 2 */ $this->add_container( $notice['message'] ),
|
110 |
+
/* 3 */ ! empty( $notice['heading'] ) ?
|
111 |
+
sprintf( '<h2 class="header-notice">%1$s</h2>', $notice['heading'] ) : '' // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
112 |
);
|
113 |
}
|
114 |
|
128 |
return;
|
129 |
}
|
130 |
|
131 |
+
echo $this->get_notice_markup( $class, $message ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
|
|
|
|
132 |
|
133 |
$this->displayed_messages[] = $message;
|
134 |
}
|
141 |
* @return mixed String (html markup) of admin notice on success, false on failure.
|
142 |
*/
|
143 |
public function get_backup_complete() {
|
|
|
144 |
// Assume that this "backup complete!" notice is for the last backup made.
|
145 |
$archive_info = get_option( 'boldgrid_backup_latest_backup' );
|
146 |
if ( empty( $archive_info ) ) {
|
157 |
/**
|
158 |
* Get the entire html markup for a notice, including the .notice container.
|
159 |
*
|
160 |
+
* @param string $class Class.
|
161 |
+
* @param string $message Message.
|
162 |
+
* @param string $heading Heading.
|
163 |
* @return string
|
164 |
*/
|
165 |
public function get_notice_markup( $class, $message, $heading = null ) {
|
166 |
+
return sprintf(
|
167 |
+
'
|
168 |
<div class="%1$s">
|
169 |
%2$s
|
170 |
%3$s
|
185 |
public function functionality_fail_notice( $use_link = true ) {
|
186 |
if ( $use_link ) {
|
187 |
$message = sprintf(
|
188 |
+
// translators: 1: HTML anchor opening tag, 2: HTML anchor closing tag.
|
189 |
esc_html__(
|
190 |
'Functionality test has failed. You can go to %1$sFunctionality Test%2$s to view a report.',
|
191 |
'boldgrid-backup'
|
203 |
/**
|
204 |
* Get user_notices option name for current user.
|
205 |
*
|
206 |
+
* @since 1.6.0
|
207 |
*/
|
208 |
public function get_user_option() {
|
209 |
$user_id = get_current_user_id();
|
215 |
*
|
216 |
* If it is not within a p or div, wrap it in a p tag.
|
217 |
*
|
218 |
+
* @since 1.6.0
|
219 |
*
|
220 |
+
* @param string $message Message.
|
221 |
* @return string
|
222 |
*/
|
223 |
public function add_container( $message ) {
|
admin/class-boldgrid-backup-admin-remote.php
CHANGED
@@ -1,24 +1,23 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.5.2
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.2
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Remote {
|
21 |
-
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
@@ -33,7 +32,7 @@ class Boldgrid_Backup_Admin_Remote {
|
|
33 |
*
|
34 |
* @since 1.5.2
|
35 |
*
|
36 |
-
* @param Boldgrid_Backup_Admin_Core $core
|
37 |
*/
|
38 |
public function __construct( $core ) {
|
39 |
$this->core = $core;
|
@@ -42,7 +41,7 @@ class Boldgrid_Backup_Admin_Remote {
|
|
42 |
/**
|
43 |
* Determine if any storage locations are enabled.
|
44 |
*
|
45 |
-
* @since 1.
|
46 |
*
|
47 |
* @return bool
|
48 |
*/
|
@@ -67,22 +66,23 @@ class Boldgrid_Backup_Admin_Remote {
|
|
67 |
*
|
68 |
* @since 1.5.2
|
69 |
*
|
70 |
-
* @param string $id amazon_s3
|
71 |
* @return bool
|
72 |
*/
|
73 |
public function is_enabled( $id ) {
|
74 |
$settings = $this->core->settings->get_settings();
|
75 |
|
76 |
-
return ! empty( $settings['remote'][ $id ]['enabled'] ) && true === $settings['remote'][ $id ]['enabled']
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
* Take action after a backup has been downloaded remotely.
|
81 |
*
|
82 |
-
* @since 1.
|
|
|
|
|
83 |
*/
|
84 |
public function post_download( $filepath ) {
|
85 |
-
|
86 |
/*
|
87 |
* Restore the log file from the archive so we can get all the juicy
|
88 |
* meta data about the archive.
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-remote.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.5.2
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_Remote
|
17 |
*
|
18 |
* @since 1.5.2
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Remote {
|
|
|
21 |
/**
|
22 |
* The core class object.
|
23 |
*
|
32 |
*
|
33 |
* @since 1.5.2
|
34 |
*
|
35 |
+
* @param Boldgrid_Backup_Admin_Core $core Boldgrid_Backup_Admin_Core object.
|
36 |
*/
|
37 |
public function __construct( $core ) {
|
38 |
$this->core = $core;
|
41 |
/**
|
42 |
* Determine if any storage locations are enabled.
|
43 |
*
|
44 |
+
* @since 1.6.0
|
45 |
*
|
46 |
* @return bool
|
47 |
*/
|
66 |
*
|
67 |
* @since 1.5.2
|
68 |
*
|
69 |
+
* @param string $id A remote storage id, such as "amazon_s3".
|
70 |
* @return bool
|
71 |
*/
|
72 |
public function is_enabled( $id ) {
|
73 |
$settings = $this->core->settings->get_settings();
|
74 |
|
75 |
+
return ! empty( $settings['remote'][ $id ]['enabled'] ) && true === $settings['remote'][ $id ]['enabled'];
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
* Take action after a backup has been downloaded remotely.
|
80 |
*
|
81 |
+
* @since 1.6.0
|
82 |
+
*
|
83 |
+
* @param string $filepath A file path.
|
84 |
*/
|
85 |
public function post_download( $filepath ) {
|
|
|
86 |
/*
|
87 |
* Restore the log file from the archive so we can get all the juicy
|
88 |
* meta data about the archive.
|
admin/class-boldgrid-backup-admin-restore-git.php
CHANGED
@@ -1,24 +1,23 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Restore_Git {
|
21 |
-
|
22 |
/**
|
23 |
* Chmod .git/objects so that we can restore without file permission issues.
|
24 |
*
|
@@ -26,13 +25,20 @@ class Boldgrid_Backup_Admin_Restore_Git {
|
|
26 |
*
|
27 |
* @global $wp_filesystem
|
28 |
*
|
29 |
-
* @param string $dir
|
30 |
* @return string
|
31 |
*/
|
32 |
public function chmod_objects( $dir ) {
|
33 |
global $wp_filesystem;
|
34 |
|
35 |
-
$message = sprintf(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
$chmodded = $wp_filesystem->chmod( ABSPATH . $dir, FS_CHMOD_FILE, true );
|
38 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-restore-git.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_Restore_Git
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Restore_Git {
|
|
|
21 |
/**
|
22 |
* Chmod .git/objects so that we can restore without file permission issues.
|
23 |
*
|
25 |
*
|
26 |
* @global $wp_filesystem
|
27 |
*
|
28 |
+
* @param string $dir Directory path.
|
29 |
* @return string
|
30 |
*/
|
31 |
public function chmod_objects( $dir ) {
|
32 |
global $wp_filesystem;
|
33 |
|
34 |
+
$message = sprintf(
|
35 |
+
// translators: 1: Directory path.
|
36 |
+
__(
|
37 |
+
'A file permissions error was encountered when attempting to restore files in "%1$s".',
|
38 |
+
'boldgrid-backup'
|
39 |
+
),
|
40 |
+
ABSPATH . $dir
|
41 |
+
);
|
42 |
|
43 |
$chmodded = $wp_filesystem->chmod( ABSPATH . $dir, FS_CHMOD_FILE, true );
|
44 |
|
admin/class-boldgrid-backup-admin-restore-helper.php
CHANGED
@@ -1,24 +1,23 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Restore_Helper {
|
21 |
-
|
22 |
/**
|
23 |
* Whether or not we are doing cron.
|
24 |
*
|
@@ -36,19 +35,19 @@ class Boldgrid_Backup_Admin_Restore_Helper {
|
|
36 |
public $monitor_files = array(
|
37 |
'htaccess' => array(
|
38 |
// Filename, relative to ABSPATH.
|
39 |
-
'filename'
|
40 |
// Whether or not to make a copy of the file before restoration.
|
41 |
-
'copy'
|
42 |
// Whether or not to keep the copy after restoration.
|
43 |
'keep_copy' => true,
|
44 |
// Whether or not the file has been copied.
|
45 |
-
'copied'
|
46 |
),
|
47 |
'wpconfig' => array(
|
48 |
-
'filename'
|
49 |
-
'copy'
|
50 |
'keep_copy' => false,
|
51 |
-
'copied'
|
52 |
),
|
53 |
);
|
54 |
|
@@ -74,18 +73,19 @@ class Boldgrid_Backup_Admin_Restore_Helper {
|
|
74 |
* Action to take when the wp-config.php file has been restored.
|
75 |
*
|
76 |
* @since 1.5.1
|
|
|
|
|
77 |
*/
|
78 |
public function post_restore_wpconfig() {
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
}
|
89 |
}
|
90 |
}
|
91 |
|
@@ -96,7 +96,7 @@ class Boldgrid_Backup_Admin_Restore_Helper {
|
|
96 |
*
|
97 |
* @global wp_filesystem
|
98 |
*
|
99 |
-
* @param array $info
|
100 |
*/
|
101 |
public function post_restore( $info ) {
|
102 |
if ( $info['dryrun'] ) {
|
@@ -107,7 +107,7 @@ class Boldgrid_Backup_Admin_Restore_Helper {
|
|
107 |
|
108 |
foreach ( $this->monitor_files as $key => $file ) {
|
109 |
$original = ABSPATH . $file['filename'];
|
110 |
-
$new
|
111 |
|
112 |
// Determine if the file was restored from backup.
|
113 |
$file_restored = false;
|
@@ -139,7 +139,7 @@ class Boldgrid_Backup_Admin_Restore_Helper {
|
|
139 |
*
|
140 |
* @global wp_filesystem
|
141 |
*
|
142 |
-
* @param array $info
|
143 |
*/
|
144 |
public function pre_restore( $info ) {
|
145 |
if ( $info['dryrun'] ) {
|
@@ -150,7 +150,7 @@ class Boldgrid_Backup_Admin_Restore_Helper {
|
|
150 |
|
151 |
foreach ( $this->monitor_files as $key => $file ) {
|
152 |
$original = ABSPATH . $file['filename'];
|
153 |
-
$new
|
154 |
|
155 |
if ( $file['copy'] && $wp_filesystem->exists( $original ) ) {
|
156 |
$wp_filesystem->copy( $original, $new, true, 0644 );
|
@@ -181,8 +181,8 @@ class Boldgrid_Backup_Admin_Restore_Helper {
|
|
181 |
*
|
182 |
* The archive_key and the archive_filename must match.
|
183 |
*/
|
184 |
-
$_POST['restore_now']
|
185 |
-
$_POST['archive_key']
|
186 |
$_POST['archive_filename'] = basename( $pending_rollback['filepath'] );
|
187 |
|
188 |
return true;
|
@@ -209,7 +209,7 @@ class Boldgrid_Backup_Admin_Restore_Helper {
|
|
209 |
$zip = new ZipArchive();
|
210 |
|
211 |
if ( $zip->open( $archive_filepath ) ) {
|
212 |
-
for ( $i = 0; $i < $zip->numFiles; $i++ ) {
|
213 |
$data = $zip->statIndex( $i );
|
214 |
|
215 |
if ( empty( $data['name'] ) ) {
|
@@ -271,7 +271,7 @@ class Boldgrid_Backup_Admin_Restore_Helper {
|
|
271 |
*
|
272 |
* @since 1.5.1
|
273 |
*
|
274 |
-
* @param WP_Error $error
|
275 |
* @return mixed False if no action is taken, otherwise a string containing
|
276 |
* a description of the action.
|
277 |
*/
|
@@ -279,7 +279,7 @@ class Boldgrid_Backup_Admin_Restore_Helper {
|
|
279 |
global $wp_filesystem;
|
280 |
|
281 |
$message = $error->get_error_message();
|
282 |
-
$data
|
283 |
|
284 |
if ( __( 'Could not copy file.' ) === $message ) {
|
285 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* FIle: class-boldgrid-backup-admin-restore-helper.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_Restore_Helper
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Restore_Helper {
|
|
|
21 |
/**
|
22 |
* Whether or not we are doing cron.
|
23 |
*
|
35 |
public $monitor_files = array(
|
36 |
'htaccess' => array(
|
37 |
// Filename, relative to ABSPATH.
|
38 |
+
'filename' => '.htaccess',
|
39 |
// Whether or not to make a copy of the file before restoration.
|
40 |
+
'copy' => true,
|
41 |
// Whether or not to keep the copy after restoration.
|
42 |
'keep_copy' => true,
|
43 |
// Whether or not the file has been copied.
|
44 |
+
'copied' => false,
|
45 |
),
|
46 |
'wpconfig' => array(
|
47 |
+
'filename' => 'wp-config.php',
|
48 |
+
'copy' => true,
|
49 |
'keep_copy' => false,
|
50 |
+
'copied' => false,
|
51 |
),
|
52 |
);
|
53 |
|
73 |
* Action to take when the wp-config.php file has been restored.
|
74 |
*
|
75 |
* @since 1.5.1
|
76 |
+
*
|
77 |
+
* @see Boldgrid_Backup_Admin_Utility::fix_wpconfig()
|
78 |
*/
|
79 |
public function post_restore_wpconfig() {
|
80 |
+
if ( ! Boldgrid_Backup_Admin_Utility::fix_wpconfig() && ! $this->doing_cron ) {
|
81 |
+
do_action(
|
82 |
+
'boldgrid_backup_notice',
|
83 |
+
esc_html__(
|
84 |
+
'Could not update the WordPress configuration file.',
|
85 |
+
'boldgrid-backup'
|
86 |
+
),
|
87 |
+
'notice notice-error is-dismissible'
|
88 |
+
);
|
|
|
89 |
}
|
90 |
}
|
91 |
|
96 |
*
|
97 |
* @global wp_filesystem
|
98 |
*
|
99 |
+
* @param array $info Archive information.
|
100 |
*/
|
101 |
public function post_restore( $info ) {
|
102 |
if ( $info['dryrun'] ) {
|
107 |
|
108 |
foreach ( $this->monitor_files as $key => $file ) {
|
109 |
$original = ABSPATH . $file['filename'];
|
110 |
+
$new = $original . '.bgb';
|
111 |
|
112 |
// Determine if the file was restored from backup.
|
113 |
$file_restored = false;
|
139 |
*
|
140 |
* @global wp_filesystem
|
141 |
*
|
142 |
+
* @param array $info Archive information.
|
143 |
*/
|
144 |
public function pre_restore( $info ) {
|
145 |
if ( $info['dryrun'] ) {
|
150 |
|
151 |
foreach ( $this->monitor_files as $key => $file ) {
|
152 |
$original = ABSPATH . $file['filename'];
|
153 |
+
$new = $original . '.bgb';
|
154 |
|
155 |
if ( $file['copy'] && $wp_filesystem->exists( $original ) ) {
|
156 |
$wp_filesystem->copy( $original, $new, true, 0644 );
|
181 |
*
|
182 |
* The archive_key and the archive_filename must match.
|
183 |
*/
|
184 |
+
$_POST['restore_now'] = 1;
|
185 |
+
$_POST['archive_key'] = 0;
|
186 |
$_POST['archive_filename'] = basename( $pending_rollback['filepath'] );
|
187 |
|
188 |
return true;
|
209 |
$zip = new ZipArchive();
|
210 |
|
211 |
if ( $zip->open( $archive_filepath ) ) {
|
212 |
+
for ( $i = 0; $i < $zip->numFiles; $i++ ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName
|
213 |
$data = $zip->statIndex( $i );
|
214 |
|
215 |
if ( empty( $data['name'] ) ) {
|
271 |
*
|
272 |
* @since 1.5.1
|
273 |
*
|
274 |
+
* @param WP_Error $error WP_Error object.
|
275 |
* @return mixed False if no action is taken, otherwise a string containing
|
276 |
* a description of the action.
|
277 |
*/
|
279 |
global $wp_filesystem;
|
280 |
|
281 |
$message = $error->get_error_message();
|
282 |
+
$data = $error->get_error_data();
|
283 |
|
284 |
if ( __( 'Could not copy file.' ) === $message ) {
|
285 |
|
admin/class-boldgrid-backup-admin-scheduler.php
CHANGED
@@ -1,24 +1,23 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Scheduler {
|
21 |
-
|
22 |
/**
|
23 |
* Available schedulers.
|
24 |
*
|
@@ -58,6 +57,9 @@ class Boldgrid_Backup_Admin_Scheduler {
|
|
58 |
|
59 |
$this->core->cron->delete_cron_entries();
|
60 |
$this->core->cron->delete_cron_entries( $this->core->cron->run_jobs );
|
|
|
|
|
|
|
61 |
}
|
62 |
|
63 |
/**
|
@@ -103,7 +105,7 @@ class Boldgrid_Backup_Admin_Scheduler {
|
|
103 |
}
|
104 |
|
105 |
$is_crontab_available = $this->core->test->is_crontab_available();
|
106 |
-
$cli_support
|
107 |
|
108 |
// We schedule crontab jobs requiring fetching a url (curl or file_get_contents).
|
109 |
if ( $is_crontab_available && $cli_support['can_remote_get'] ) {
|
@@ -128,7 +130,7 @@ class Boldgrid_Backup_Admin_Scheduler {
|
|
128 |
*
|
129 |
* @since 1.5.1
|
130 |
*
|
131 |
-
* @param string
|
132 |
* @return bool
|
133 |
*/
|
134 |
public function is_available( $scheduler ) {
|
@@ -136,5 +138,4 @@ class Boldgrid_Backup_Admin_Scheduler {
|
|
136 |
|
137 |
return array_key_exists( $scheduler, $available );
|
138 |
}
|
139 |
-
|
140 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-scheduler.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_Scheduler
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Scheduler {
|
|
|
21 |
/**
|
22 |
* Available schedulers.
|
23 |
*
|
57 |
|
58 |
$this->core->cron->delete_cron_entries();
|
59 |
$this->core->cron->delete_cron_entries( $this->core->cron->run_jobs );
|
60 |
+
|
61 |
+
// Remove old run_jobs cron.
|
62 |
+
$this->core->cron->delete_cron_entries( 'cron/run_jobs.php' );
|
63 |
}
|
64 |
|
65 |
/**
|
105 |
}
|
106 |
|
107 |
$is_crontab_available = $this->core->test->is_crontab_available();
|
108 |
+
$cli_support = $this->core->test->get_cli_support();
|
109 |
|
110 |
// We schedule crontab jobs requiring fetching a url (curl or file_get_contents).
|
111 |
if ( $is_crontab_available && $cli_support['can_remote_get'] ) {
|
130 |
*
|
131 |
* @since 1.5.1
|
132 |
*
|
133 |
+
* @param string $scheduler Scheduler type ("cron" or "wp-cron").
|
134 |
* @return bool
|
135 |
*/
|
136 |
public function is_available( $scheduler ) {
|
138 |
|
139 |
return array_key_exists( $scheduler, $available );
|
140 |
}
|
|
|
141 |
}
|
admin/class-boldgrid-backup-admin-settings.php
CHANGED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.0
|
7 |
*
|
8 |
-
* @package
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright
|
11 |
-
* @version
|
12 |
-
* @author
|
13 |
*/
|
14 |
|
|
|
|
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.0
|
19 |
*/
|
@@ -30,7 +32,7 @@ class Boldgrid_Backup_Admin_Settings {
|
|
30 |
/**
|
31 |
* Whether or not we're in the middle of saving settings from $_POST.
|
32 |
*
|
33 |
-
* @since
|
34 |
* @access public
|
35 |
* @var bool
|
36 |
*/
|
@@ -47,7 +49,7 @@ class Boldgrid_Backup_Admin_Settings {
|
|
47 |
// Save the Boldgrid_Backup_Admin_Core object as a class property.
|
48 |
$this->core = $core;
|
49 |
|
50 |
-
$this->is_saving_settings = isset( $_POST['save_time'] );
|
51 |
}
|
52 |
|
53 |
/**
|
@@ -63,12 +65,12 @@ class Boldgrid_Backup_Admin_Settings {
|
|
63 |
public function get_dow_count() {
|
64 |
$count = 0;
|
65 |
|
66 |
-
if ( ! isset( $_POST ) || ! is_array( $_POST ) ) {
|
67 |
return 0;
|
68 |
}
|
69 |
|
70 |
// Loop through each $_POST value and check if the key begins with dow_.
|
71 |
-
foreach ( $_POST as $k => $v ) {
|
72 |
if ( substr( $k, 0, 4 ) === 'dow_' ) {
|
73 |
$count++;
|
74 |
}
|
@@ -103,25 +105,25 @@ class Boldgrid_Backup_Admin_Settings {
|
|
103 |
if ( ! empty( $settings['schedule'] ) ) {
|
104 |
// Update schedule format.
|
105 |
// Days of the week.
|
106 |
-
$settings['schedule']['dow_sunday']
|
107 |
! empty( $settings['schedule']['dow_sunday'] ) ? 1 : 0
|
108 |
);
|
109 |
-
$settings['schedule']['dow_monday']
|
110 |
! empty( $settings['schedule']['dow_monday'] ) ? 1 : 0
|
111 |
);
|
112 |
-
$settings['schedule']['dow_tuesday']
|
113 |
! empty( $settings['schedule']['dow_tuesday'] ) ? 1 : 0
|
114 |
);
|
115 |
$settings['schedule']['dow_wednesday'] = (
|
116 |
! empty( $settings['schedule']['dow_wednesday'] ) ? 1 : 0
|
117 |
);
|
118 |
-
$settings['schedule']['dow_thursday']
|
119 |
! empty( $settings['schedule']['dow_thursday'] ) ? 1 : 0
|
120 |
);
|
121 |
-
$settings['schedule']['dow_friday']
|
122 |
! empty( $settings['schedule']['dow_friday'] ) ? 1 : 0
|
123 |
);
|
124 |
-
$settings['schedule']['dow_saturday']
|
125 |
! empty( $settings['schedule']['dow_saturday'] ) ? 1 : 0
|
126 |
);
|
127 |
|
@@ -140,7 +142,7 @@ class Boldgrid_Backup_Admin_Settings {
|
|
140 |
);
|
141 |
|
142 |
// Notification settings.
|
143 |
-
$settings['notifications']['backup']
|
144 |
! isset( $settings['notifications']['backup'] ) ||
|
145 |
! empty( $settings['notifications']['backup'] ) ? 1 : 0
|
146 |
);
|
@@ -155,7 +157,7 @@ class Boldgrid_Backup_Admin_Settings {
|
|
155 |
}
|
156 |
|
157 |
// Other settings.
|
158 |
-
$settings['auto_backup']
|
159 |
! isset( $settings['auto_backup'] ) || ! empty( $settings['auto_backup'] ) ? 1 : 0
|
160 |
);
|
161 |
$settings['auto_rollback'] = (
|
@@ -165,13 +167,13 @@ class Boldgrid_Backup_Admin_Settings {
|
|
165 |
} else {
|
166 |
// Define defaults.
|
167 |
// Days of the week.
|
168 |
-
$settings['schedule']['dow_sunday']
|
169 |
-
$settings['schedule']['dow_monday']
|
170 |
-
$settings['schedule']['dow_tuesday']
|
171 |
$settings['schedule']['dow_wednesday'] = 0;
|
172 |
-
$settings['schedule']['dow_thursday']
|
173 |
-
$settings['schedule']['dow_friday']
|
174 |
-
$settings['schedule']['dow_saturday']
|
175 |
|
176 |
// Time of day.
|
177 |
$settings['schedule']['tod_h'] = mt_rand( 1, 5 );
|
@@ -179,32 +181,13 @@ class Boldgrid_Backup_Admin_Settings {
|
|
179 |
$settings['schedule']['tod_a'] = 'AM';
|
180 |
|
181 |
// Other settings.
|
182 |
-
$settings['retention_count']
|
183 |
-
$settings['notification_email']
|
184 |
-
$settings['notifications']['backup']
|
185 |
$settings['notifications']['restore'] = 1;
|
186 |
-
$settings['auto_backup']
|
187 |
-
$settings['auto_rollback']
|
188 |
-
}
|
189 |
-
|
190 |
-
/*
|
191 |
-
* If a cron schedule was found, then merge the settings.
|
192 |
-
*
|
193 |
-
* @todo As of 1.6.0, this feature is on hold. We need to take into
|
194 |
-
* account timezones, and possibly tell the user their settings don't
|
195 |
-
* actually match what's in the crontab.
|
196 |
-
*/
|
197 |
-
/*
|
198 |
-
// If not updating the settings, then check cron for schedule.
|
199 |
-
if ( ! isset( $_POST['save_time'] ) ) {
|
200 |
-
$cron_schedule = $this->core->cron->read_cron_entry();
|
201 |
-
}
|
202 |
-
|
203 |
-
// If a cron schedule was found, then merge the settings.
|
204 |
-
if ( ! empty( $cron_schedule ) ) {
|
205 |
-
$settings['schedule'] = array_merge( $settings['schedule'], $cron_schedule );
|
206 |
}
|
207 |
-
*/
|
208 |
|
209 |
$boldgrid_settings = get_site_option( 'boldgrid_settings' );
|
210 |
|
@@ -242,9 +225,9 @@ class Boldgrid_Backup_Admin_Settings {
|
|
242 |
*
|
243 |
* @since 1.3.2
|
244 |
*
|
245 |
-
* @param string $old_dir
|
246 |
-
* @param string $new_dir
|
247 |
-
* @return bool
|
248 |
*/
|
249 |
private function move_backups( $old_dir, $new_dir ) {
|
250 |
$fail_count = 0;
|
@@ -258,10 +241,10 @@ class Boldgrid_Backup_Admin_Settings {
|
|
258 |
|
259 |
// Loop through each archive and move it.
|
260 |
foreach ( $archives as $archive ) {
|
261 |
-
$source
|
262 |
$destination = $new_dir . $archive['filename'];
|
263 |
|
264 |
-
$success = @$this->core->wp_filesystem->move( $source, $destination );
|
265 |
|
266 |
if ( ! $success ) {
|
267 |
$fail_count++;
|
@@ -338,7 +321,7 @@ class Boldgrid_Backup_Admin_Settings {
|
|
338 |
if ( ! empty( $_POST[ $index ] ) ) {
|
339 |
// Validate by type.
|
340 |
switch ( $type ) {
|
341 |
-
case 'day'
|
342 |
// Convert to integer.
|
343 |
$_POST[ $index ] = (int) $_POST[ $index ];
|
344 |
|
@@ -348,7 +331,7 @@ class Boldgrid_Backup_Admin_Settings {
|
|
348 |
}
|
349 |
|
350 |
break;
|
351 |
-
case 'h'
|
352 |
if ( $_POST[ $index ] < 1 || $_POST[ $index ] > 12 ) {
|
353 |
// Error in input.
|
354 |
$update_error = true;
|
@@ -359,7 +342,7 @@ class Boldgrid_Backup_Admin_Settings {
|
|
359 |
$_POST[ $index ] = (int) $_POST[ $index ];
|
360 |
|
361 |
break;
|
362 |
-
case 'm'
|
363 |
if ( $_POST[ $index ] < 0 || $_POST[ $index ] > 59 ) {
|
364 |
// Error in input.
|
365 |
$update_error = true;
|
@@ -373,7 +356,7 @@ class Boldgrid_Backup_Admin_Settings {
|
|
373 |
$_POST[ $index ] = str_pad( $_POST[ $index ], 2, '0', STR_PAD_LEFT );
|
374 |
|
375 |
break;
|
376 |
-
case 'a'
|
377 |
if ( 'AM' !== $_POST[ $index ] && 'PM' !== $_POST[ $index ] ) {
|
378 |
// Error in input; unknown type.
|
379 |
$update_error = true;
|
@@ -381,7 +364,7 @@ class Boldgrid_Backup_Admin_Settings {
|
|
381 |
}
|
382 |
|
383 |
break;
|
384 |
-
default
|
385 |
// Error in input; unknown type.
|
386 |
$update_error = true;
|
387 |
break 2;
|
@@ -440,7 +423,7 @@ class Boldgrid_Backup_Admin_Settings {
|
|
440 |
unset( $settings['plugin_autoupdate'], $settings['theme_autoupdate'] );
|
441 |
|
442 |
// Get the current backup directory path.
|
443 |
-
$backup_dir_changed
|
444 |
$original_backup_directory = ! empty( $settings['backup_directory'] ) ? $settings['backup_directory'] : false;
|
445 |
|
446 |
if ( ! empty( $_POST['backup_directory'] ) ) {
|
@@ -483,9 +466,9 @@ class Boldgrid_Backup_Admin_Settings {
|
|
483 |
|
484 |
if ( $backup_dir_changed ) {
|
485 |
if ( false === $backup_directory ) {
|
486 |
-
$update_error
|
487 |
$backup_dir_changed = false;
|
488 |
-
$update_errors
|
489 |
} else {
|
490 |
$settings['backup_directory'] = $backup_directory;
|
491 |
}
|
@@ -496,8 +479,16 @@ class Boldgrid_Backup_Admin_Settings {
|
|
496 |
$backups_moved = $this->move_backups( $original_backup_directory, $backup_directory );
|
497 |
|
498 |
if ( ! $backups_moved ) {
|
499 |
-
$update_error
|
500 |
-
$update_errors[] = sprintf(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
501 |
}
|
502 |
}
|
503 |
|
@@ -508,11 +499,11 @@ class Boldgrid_Backup_Admin_Settings {
|
|
508 |
*/
|
509 |
if ( ! empty( $_POST['compressor'] ) ) {
|
510 |
$available_compressors = $this->core->compressors->get_available();
|
511 |
-
$selected_compressor
|
512 |
if ( in_array( $selected_compressor, $available_compressors, true ) ) {
|
513 |
$settings['compressor'] = $selected_compressor;
|
514 |
} else {
|
515 |
-
$update_error
|
516 |
$update_errors[] = __( 'The compressor you seleted is unavailable. Please select another.', 'boldgrid-backup' );
|
517 |
}
|
518 |
}
|
@@ -527,7 +518,7 @@ class Boldgrid_Backup_Admin_Settings {
|
|
527 |
if ( in_array( $selected_extractor, $available_compressors, true ) ) {
|
528 |
$settings['extractor'] = $selected_extractor;
|
529 |
} else {
|
530 |
-
$update_error
|
531 |
$update_errors[] = __( 'The extractor you seleted is unavailable. Please select another.', 'boldgrid-backup' );
|
532 |
}
|
533 |
}
|
@@ -540,9 +531,9 @@ class Boldgrid_Backup_Admin_Settings {
|
|
540 |
*
|
541 |
* @since 1.5.1
|
542 |
*/
|
543 |
-
$original_scheduler
|
544 |
$schedulers_available = $this->core->scheduler->get_available();
|
545 |
-
$scheduler_changed
|
546 |
if ( $scheduler_changed && array_key_exists( $_POST['scheduler'], $schedulers_available ) ) {
|
547 |
$settings['scheduler'] = $_POST['scheduler'];
|
548 |
}
|
@@ -556,13 +547,13 @@ class Boldgrid_Backup_Admin_Settings {
|
|
556 |
if ( 'wp-cron' === $scheduler ) {
|
557 |
$crons_added = $this->core->wp_cron->add_all_crons( $settings );
|
558 |
} elseif ( 'cron' === $scheduler ) {
|
559 |
-
$crons_added
|
560 |
$settings['crontab_version'] = $this->core->cron->crontab_version;
|
561 |
-
$settings['cron_secret']
|
562 |
}
|
563 |
// Take action if we tried and failed to add crons.
|
564 |
if ( isset( $crons_added ) && ! $crons_added ) {
|
565 |
-
$update_error
|
566 |
$update_errors[] = esc_html__( 'An error occurred when modifying cron jobs. Please try again.', 'boldgrid-backup' );
|
567 |
}
|
568 |
|
@@ -600,17 +591,17 @@ class Boldgrid_Backup_Admin_Settings {
|
|
600 |
*
|
601 |
* @since 1.5.3
|
602 |
*/
|
603 |
-
$settings['exclude_tables']
|
604 |
$settings['exclude_tables_type'] = $this->core->db_omit->get_post_type();
|
605 |
|
606 |
/*
|
607 |
* Save folder exclusion settings.
|
608 |
*
|
609 |
-
* @since 1.
|
610 |
*/
|
611 |
$settings['folder_exclusion_include'] = $this->core->folder_exclusion->from_post( 'include' );
|
612 |
$settings['folder_exclusion_exclude'] = $this->core->folder_exclusion->from_post( 'exclude' );
|
613 |
-
$settings['folder_exclusion_type']
|
614 |
|
615 |
// If no errors, then save the settings.
|
616 |
if ( ! $update_error ) {
|
@@ -664,8 +655,6 @@ class Boldgrid_Backup_Admin_Settings {
|
|
664 |
* Menu callback to display the Backup schedule page.
|
665 |
*
|
666 |
* @since 1.0
|
667 |
-
*
|
668 |
-
* @return null
|
669 |
*/
|
670 |
public function page_backup_settings() {
|
671 |
add_thickbox();
|
@@ -686,8 +675,9 @@ class Boldgrid_Backup_Admin_Settings {
|
|
686 |
do_action(
|
687 |
'boldgrid_backup_notice',
|
688 |
sprintf(
|
689 |
-
|
690 |
-
|
|
|
691 |
'boldgrid-backup'
|
692 |
),
|
693 |
'<a href="' . admin_url( 'admin.php?page=boldgrid-backup-test' ) . '">',
|
@@ -731,13 +721,15 @@ class Boldgrid_Backup_Admin_Settings {
|
|
731 |
}
|
732 |
|
733 |
// Enqueue CSS for the settings page.
|
734 |
-
wp_enqueue_style(
|
|
|
735 |
plugin_dir_url( __FILE__ ) . 'css/boldgrid-backup-admin-settings.css', array(),
|
736 |
BOLDGRID_BACKUP_VERSION, 'all'
|
737 |
);
|
738 |
|
739 |
// Enqueue the JS for the settings page.
|
740 |
-
wp_enqueue_script(
|
|
|
741 |
plugin_dir_url( __FILE__ ) . 'js/boldgrid-backup-admin-settings.js',
|
742 |
array( 'jquery' ),
|
743 |
BOLDGRID_BACKUP_VERSION,
|
@@ -758,8 +750,6 @@ class Boldgrid_Backup_Admin_Settings {
|
|
758 |
|
759 |
// Include the page template.
|
760 |
include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-settings.php';
|
761 |
-
|
762 |
-
return;
|
763 |
}
|
764 |
|
765 |
/**
|
@@ -767,7 +757,7 @@ class Boldgrid_Backup_Admin_Settings {
|
|
767 |
*
|
768 |
* @since 1.5.2
|
769 |
*
|
770 |
-
* @param array $settings
|
771 |
* @return bool True on success.
|
772 |
*/
|
773 |
public function save( $settings ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-settings.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.0
|
7 |
*
|
8 |
+
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
+
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
// phpcs:disable WordPress.VIP
|
16 |
+
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Settings
|
19 |
*
|
20 |
* @since 1.0
|
21 |
*/
|
32 |
/**
|
33 |
* Whether or not we're in the middle of saving settings from $_POST.
|
34 |
*
|
35 |
+
* @since 1.6.0
|
36 |
* @access public
|
37 |
* @var bool
|
38 |
*/
|
49 |
// Save the Boldgrid_Backup_Admin_Core object as a class property.
|
50 |
$this->core = $core;
|
51 |
|
52 |
+
$this->is_saving_settings = isset( $_POST['save_time'] ); // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
53 |
}
|
54 |
|
55 |
/**
|
65 |
public function get_dow_count() {
|
66 |
$count = 0;
|
67 |
|
68 |
+
if ( ! isset( $_POST ) || ! is_array( $_POST ) ) { // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
69 |
return 0;
|
70 |
}
|
71 |
|
72 |
// Loop through each $_POST value and check if the key begins with dow_.
|
73 |
+
foreach ( $_POST as $k => $v ) { // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
74 |
if ( substr( $k, 0, 4 ) === 'dow_' ) {
|
75 |
$count++;
|
76 |
}
|
105 |
if ( ! empty( $settings['schedule'] ) ) {
|
106 |
// Update schedule format.
|
107 |
// Days of the week.
|
108 |
+
$settings['schedule']['dow_sunday'] = (
|
109 |
! empty( $settings['schedule']['dow_sunday'] ) ? 1 : 0
|
110 |
);
|
111 |
+
$settings['schedule']['dow_monday'] = (
|
112 |
! empty( $settings['schedule']['dow_monday'] ) ? 1 : 0
|
113 |
);
|
114 |
+
$settings['schedule']['dow_tuesday'] = (
|
115 |
! empty( $settings['schedule']['dow_tuesday'] ) ? 1 : 0
|
116 |
);
|
117 |
$settings['schedule']['dow_wednesday'] = (
|
118 |
! empty( $settings['schedule']['dow_wednesday'] ) ? 1 : 0
|
119 |
);
|
120 |
+
$settings['schedule']['dow_thursday'] = (
|
121 |
! empty( $settings['schedule']['dow_thursday'] ) ? 1 : 0
|
122 |
);
|
123 |
+
$settings['schedule']['dow_friday'] = (
|
124 |
! empty( $settings['schedule']['dow_friday'] ) ? 1 : 0
|
125 |
);
|
126 |
+
$settings['schedule']['dow_saturday'] = (
|
127 |
! empty( $settings['schedule']['dow_saturday'] ) ? 1 : 0
|
128 |
);
|
129 |
|
142 |
);
|
143 |
|
144 |
// Notification settings.
|
145 |
+
$settings['notifications']['backup'] = (
|
146 |
! isset( $settings['notifications']['backup'] ) ||
|
147 |
! empty( $settings['notifications']['backup'] ) ? 1 : 0
|
148 |
);
|
157 |
}
|
158 |
|
159 |
// Other settings.
|
160 |
+
$settings['auto_backup'] = (
|
161 |
! isset( $settings['auto_backup'] ) || ! empty( $settings['auto_backup'] ) ? 1 : 0
|
162 |
);
|
163 |
$settings['auto_rollback'] = (
|
167 |
} else {
|
168 |
// Define defaults.
|
169 |
// Days of the week.
|
170 |
+
$settings['schedule']['dow_sunday'] = 0;
|
171 |
+
$settings['schedule']['dow_monday'] = 0;
|
172 |
+
$settings['schedule']['dow_tuesday'] = 0;
|
173 |
$settings['schedule']['dow_wednesday'] = 0;
|
174 |
+
$settings['schedule']['dow_thursday'] = 0;
|
175 |
+
$settings['schedule']['dow_friday'] = 0;
|
176 |
+
$settings['schedule']['dow_saturday'] = 0;
|
177 |
|
178 |
// Time of day.
|
179 |
$settings['schedule']['tod_h'] = mt_rand( 1, 5 );
|
181 |
$settings['schedule']['tod_a'] = 'AM';
|
182 |
|
183 |
// Other settings.
|
184 |
+
$settings['retention_count'] = 5;
|
185 |
+
$settings['notification_email'] = $this->core->config->get_admin_email();
|
186 |
+
$settings['notifications']['backup'] = 1;
|
187 |
$settings['notifications']['restore'] = 1;
|
188 |
+
$settings['auto_backup'] = 1;
|
189 |
+
$settings['auto_rollback'] = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
}
|
|
|
191 |
|
192 |
$boldgrid_settings = get_site_option( 'boldgrid_settings' );
|
193 |
|
225 |
*
|
226 |
* @since 1.3.2
|
227 |
*
|
228 |
+
* @param string $old_dir Source directory.
|
229 |
+
* @param string $new_dir Destination directory.
|
230 |
+
* @return bool TRUE on success / no backups needed to be moved.
|
231 |
*/
|
232 |
private function move_backups( $old_dir, $new_dir ) {
|
233 |
$fail_count = 0;
|
241 |
|
242 |
// Loop through each archive and move it.
|
243 |
foreach ( $archives as $archive ) {
|
244 |
+
$source = $archive['filepath'];
|
245 |
$destination = $new_dir . $archive['filename'];
|
246 |
|
247 |
+
$success = @$this->core->wp_filesystem->move( $source, $destination ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
|
248 |
|
249 |
if ( ! $success ) {
|
250 |
$fail_count++;
|
321 |
if ( ! empty( $_POST[ $index ] ) ) {
|
322 |
// Validate by type.
|
323 |
switch ( $type ) {
|
324 |
+
case 'day':
|
325 |
// Convert to integer.
|
326 |
$_POST[ $index ] = (int) $_POST[ $index ];
|
327 |
|
331 |
}
|
332 |
|
333 |
break;
|
334 |
+
case 'h':
|
335 |
if ( $_POST[ $index ] < 1 || $_POST[ $index ] > 12 ) {
|
336 |
// Error in input.
|
337 |
$update_error = true;
|
342 |
$_POST[ $index ] = (int) $_POST[ $index ];
|
343 |
|
344 |
break;
|
345 |
+
case 'm':
|
346 |
if ( $_POST[ $index ] < 0 || $_POST[ $index ] > 59 ) {
|
347 |
// Error in input.
|
348 |
$update_error = true;
|
356 |
$_POST[ $index ] = str_pad( $_POST[ $index ], 2, '0', STR_PAD_LEFT );
|
357 |
|
358 |
break;
|
359 |
+
case 'a':
|
360 |
if ( 'AM' !== $_POST[ $index ] && 'PM' !== $_POST[ $index ] ) {
|
361 |
// Error in input; unknown type.
|
362 |
$update_error = true;
|
364 |
}
|
365 |
|
366 |
break;
|
367 |
+
default:
|
368 |
// Error in input; unknown type.
|
369 |
$update_error = true;
|
370 |
break 2;
|
423 |
unset( $settings['plugin_autoupdate'], $settings['theme_autoupdate'] );
|
424 |
|
425 |
// Get the current backup directory path.
|
426 |
+
$backup_dir_changed = false;
|
427 |
$original_backup_directory = ! empty( $settings['backup_directory'] ) ? $settings['backup_directory'] : false;
|
428 |
|
429 |
if ( ! empty( $_POST['backup_directory'] ) ) {
|
466 |
|
467 |
if ( $backup_dir_changed ) {
|
468 |
if ( false === $backup_directory ) {
|
469 |
+
$update_error = true;
|
470 |
$backup_dir_changed = false;
|
471 |
+
$update_errors = array_merge( $update_errors, $this->core->backup_dir->errors );
|
472 |
} else {
|
473 |
$settings['backup_directory'] = $backup_directory;
|
474 |
}
|
479 |
$backups_moved = $this->move_backups( $original_backup_directory, $backup_directory );
|
480 |
|
481 |
if ( ! $backups_moved ) {
|
482 |
+
$update_error = true;
|
483 |
+
$update_errors[] = sprintf(
|
484 |
+
// translators: 1: Original backup directory, 2: New backup directory.
|
485 |
+
__(
|
486 |
+
'Unable to move backups from %1$s to %2$s',
|
487 |
+
'boldgrid-backup'
|
488 |
+
),
|
489 |
+
$original_backup_directory,
|
490 |
+
$backup_directory
|
491 |
+
);
|
492 |
}
|
493 |
}
|
494 |
|
499 |
*/
|
500 |
if ( ! empty( $_POST['compressor'] ) ) {
|
501 |
$available_compressors = $this->core->compressors->get_available();
|
502 |
+
$selected_compressor = $_POST['compressor'];
|
503 |
if ( in_array( $selected_compressor, $available_compressors, true ) ) {
|
504 |
$settings['compressor'] = $selected_compressor;
|
505 |
} else {
|
506 |
+
$update_error = true;
|
507 |
$update_errors[] = __( 'The compressor you seleted is unavailable. Please select another.', 'boldgrid-backup' );
|
508 |
}
|
509 |
}
|
518 |
if ( in_array( $selected_extractor, $available_compressors, true ) ) {
|
519 |
$settings['extractor'] = $selected_extractor;
|
520 |
} else {
|
521 |
+
$update_error = true;
|
522 |
$update_errors[] = __( 'The extractor you seleted is unavailable. Please select another.', 'boldgrid-backup' );
|
523 |
}
|
524 |
}
|
531 |
*
|
532 |
* @since 1.5.1
|
533 |
*/
|
534 |
+
$original_scheduler = ! empty( $settings['scheduler'] ) ? $settings['scheduler'] : false;
|
535 |
$schedulers_available = $this->core->scheduler->get_available();
|
536 |
+
$scheduler_changed = ! empty( $_POST['scheduler'] ) && $original_scheduler !== $_POST['scheduler'];
|
537 |
if ( $scheduler_changed && array_key_exists( $_POST['scheduler'], $schedulers_available ) ) {
|
538 |
$settings['scheduler'] = $_POST['scheduler'];
|
539 |
}
|
547 |
if ( 'wp-cron' === $scheduler ) {
|
548 |
$crons_added = $this->core->wp_cron->add_all_crons( $settings );
|
549 |
} elseif ( 'cron' === $scheduler ) {
|
550 |
+
$crons_added = $this->core->cron->add_all_crons( $settings );
|
551 |
$settings['crontab_version'] = $this->core->cron->crontab_version;
|
552 |
+
$settings['cron_secret'] = $this->core->cron->get_cron_secret();
|
553 |
}
|
554 |
// Take action if we tried and failed to add crons.
|
555 |
if ( isset( $crons_added ) && ! $crons_added ) {
|
556 |
+
$update_error = true;
|
557 |
$update_errors[] = esc_html__( 'An error occurred when modifying cron jobs. Please try again.', 'boldgrid-backup' );
|
558 |
}
|
559 |
|
591 |
*
|
592 |
* @since 1.5.3
|
593 |
*/
|
594 |
+
$settings['exclude_tables'] = $this->core->db_omit->get_from_post();
|
595 |
$settings['exclude_tables_type'] = $this->core->db_omit->get_post_type();
|
596 |
|
597 |
/*
|
598 |
* Save folder exclusion settings.
|
599 |
*
|
600 |
+
* @since 1.6.0
|
601 |
*/
|
602 |
$settings['folder_exclusion_include'] = $this->core->folder_exclusion->from_post( 'include' );
|
603 |
$settings['folder_exclusion_exclude'] = $this->core->folder_exclusion->from_post( 'exclude' );
|
604 |
+
$settings['folder_exclusion_type'] = $this->core->folder_exclusion->from_post( 'type' );
|
605 |
|
606 |
// If no errors, then save the settings.
|
607 |
if ( ! $update_error ) {
|
655 |
* Menu callback to display the Backup schedule page.
|
656 |
*
|
657 |
* @since 1.0
|
|
|
|
|
658 |
*/
|
659 |
public function page_backup_settings() {
|
660 |
add_thickbox();
|
675 |
do_action(
|
676 |
'boldgrid_backup_notice',
|
677 |
sprintf(
|
678 |
+
// translators: 1: HTML anchor link open tag, 2: HTML anchor closing tag.
|
679 |
+
__(
|
680 |
+
'Functionality test has failed. You can go to %1$sFunctionality Test%2$s to view a report.',
|
681 |
'boldgrid-backup'
|
682 |
),
|
683 |
'<a href="' . admin_url( 'admin.php?page=boldgrid-backup-test' ) . '">',
|
721 |
}
|
722 |
|
723 |
// Enqueue CSS for the settings page.
|
724 |
+
wp_enqueue_style(
|
725 |
+
'boldgrid-backup-admin-settings',
|
726 |
plugin_dir_url( __FILE__ ) . 'css/boldgrid-backup-admin-settings.css', array(),
|
727 |
BOLDGRID_BACKUP_VERSION, 'all'
|
728 |
);
|
729 |
|
730 |
// Enqueue the JS for the settings page.
|
731 |
+
wp_enqueue_script(
|
732 |
+
'boldgrid-backup-admin-settings',
|
733 |
plugin_dir_url( __FILE__ ) . 'js/boldgrid-backup-admin-settings.js',
|
734 |
array( 'jquery' ),
|
735 |
BOLDGRID_BACKUP_VERSION,
|
750 |
|
751 |
// Include the page template.
|
752 |
include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-settings.php';
|
|
|
|
|
753 |
}
|
754 |
|
755 |
/**
|
757 |
*
|
758 |
* @since 1.5.2
|
759 |
*
|
760 |
+
* @param array $settings BoldGrid Backup settings.
|
761 |
* @return bool True on success.
|
762 |
*/
|
763 |
public function save( $settings ) {
|
admin/class-boldgrid-backup-admin-test.php
CHANGED
@@ -1,24 +1,25 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.0
|
7 |
*
|
8 |
-
* @package
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright
|
11 |
-
* @version
|
12 |
-
* @author
|
13 |
*/
|
14 |
|
|
|
|
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.0
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Test {
|
21 |
-
|
22 |
/**
|
23 |
* Base test filename.
|
24 |
*
|
@@ -139,7 +140,7 @@ class Boldgrid_Backup_Admin_Test {
|
|
139 |
*
|
140 |
* @since 1.5.1
|
141 |
*
|
142 |
-
* @param string $path
|
143 |
* @return bool
|
144 |
*/
|
145 |
public function exists( $path ) {
|
@@ -163,22 +164,22 @@ class Boldgrid_Backup_Admin_Test {
|
|
163 |
*
|
164 |
* @since 1.5.1
|
165 |
*
|
166 |
-
* @param string $dir
|
167 |
* @return array
|
168 |
*/
|
169 |
public function extensive_dir_test( $dir ) {
|
170 |
-
$dir
|
171 |
$random_filename = $dir . $this->test_prefix . mt_rand();
|
172 |
-
$txt_filename
|
173 |
-
$info_filename
|
174 |
-
$str
|
175 |
|
176 |
$data['exists'] = $this->core->wp_filesystem->exists( $dir );
|
177 |
-
$data['read']
|
178 |
-
$data['write']
|
179 |
|
180 |
// Can we get a directory listing?
|
181 |
-
$dirlist
|
182 |
$data['dirlist'] = is_array( $dirlist );
|
183 |
|
184 |
// Determine if we have permission to rename a file.
|
@@ -205,8 +206,8 @@ class Boldgrid_Backup_Admin_Test {
|
|
205 |
*
|
206 |
* @since 1.5.2
|
207 |
*
|
208 |
-
* @param string $folder_name
|
209 |
-
* @param string $starting_dir
|
210 |
* @return bool True if folder name found.
|
211 |
*/
|
212 |
public function find_folder( $folder_name, $starting_dir = ABSPATH ) {
|
@@ -244,7 +245,7 @@ class Boldgrid_Backup_Admin_Test {
|
|
244 |
*
|
245 |
* @since 1.5.1
|
246 |
*
|
247 |
-
* @param string $dir
|
248 |
* @return bool
|
249 |
*/
|
250 |
public function delete_test_files( $dir ) {
|
@@ -292,7 +293,7 @@ class Boldgrid_Backup_Admin_Test {
|
|
292 |
*
|
293 |
* @since 1.5.1
|
294 |
*
|
295 |
-
* @param $dir
|
296 |
* @return bool
|
297 |
*/
|
298 |
public function is_writable( $dir ) {
|
@@ -346,9 +347,14 @@ class Boldgrid_Backup_Admin_Test {
|
|
346 |
return true;
|
347 |
}
|
348 |
|
349 |
-
$folders_found
|
350 |
$possible_issues = __( 'Due to possible issues node_modules folders can cause when calculating disk space, your WordPress directory size was not calculated.', 'boldgrid-backup' );
|
351 |
-
|
|
|
|
|
|
|
|
|
|
|
352 |
|
353 |
$warning = sprintf(
|
354 |
'<strong>%1$s</strong><br />
|
@@ -391,8 +397,8 @@ class Boldgrid_Backup_Admin_Test {
|
|
391 |
* To determine if crontab is available, we will BOTH write and remove
|
392 |
* a test entry from the crontab.
|
393 |
*/
|
394 |
-
$entry_added
|
395 |
-
$entry_deleted
|
396 |
$this->is_crontab_available = $entry_added && $entry_deleted;
|
397 |
|
398 |
return $this->is_crontab_available;
|
@@ -563,8 +569,8 @@ class Boldgrid_Backup_Admin_Test {
|
|
563 |
|
564 |
// Get filesystem disk space information.
|
565 |
$disk_total_space = disk_total_space( $home_dir );
|
566 |
-
$disk_free_space
|
567 |
-
$disk_used_space
|
568 |
|
569 |
// Initialize $wp_root_size.
|
570 |
$wp_root_size = false;
|
@@ -595,12 +601,14 @@ class Boldgrid_Backup_Admin_Test {
|
|
595 |
*/
|
596 |
private function get_wp_size() {
|
597 |
// Save time, use transients.
|
598 |
-
|
|
|
|
|
599 |
return $transient;
|
600 |
}
|
601 |
|
602 |
// Avoid timeout caused when node_modules exist. Return 0 bytes.
|
603 |
-
if ( empty( $_GET['skip_node_modules'] ) ) {
|
604 |
$node_modules_found = $this->node_modules_warning();
|
605 |
if ( true === $node_modules_found ) {
|
606 |
return 0;
|
@@ -686,7 +694,9 @@ class Boldgrid_Backup_Admin_Test {
|
|
686 |
*/
|
687 |
public function get_database_size() {
|
688 |
// Save some time, get transient.
|
689 |
-
|
|
|
|
|
690 |
return $transient;
|
691 |
}
|
692 |
|
@@ -694,9 +704,11 @@ class Boldgrid_Backup_Admin_Test {
|
|
694 |
global $wpdb;
|
695 |
|
696 |
// Build query.
|
697 |
-
$query =
|
698 |
-
'SELECT SUM(`data_length` + `index_length`) FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA
|
699 |
-
|
|
|
|
|
700 |
);
|
701 |
|
702 |
// Check query.
|
@@ -705,7 +717,7 @@ class Boldgrid_Backup_Admin_Test {
|
|
705 |
}
|
706 |
|
707 |
// Get the result.
|
708 |
-
$result = $wpdb->get_row( $query, ARRAY_N );
|
709 |
|
710 |
// If there was an error or nothing returned, then fail.
|
711 |
if ( empty( $result ) ) {
|
@@ -773,7 +785,7 @@ class Boldgrid_Backup_Admin_Test {
|
|
773 |
* @return bool
|
774 |
*/
|
775 |
public function is_iis() {
|
776 |
-
return
|
777 |
! empty( $_SERVER['SERVER_SOFTWARE'] ) &&
|
778 |
false !== strpos( $_SERVER['SERVER_SOFTWARE'], 'IIS' );
|
779 |
}
|
@@ -793,6 +805,6 @@ class Boldgrid_Backup_Admin_Test {
|
|
793 |
|
794 |
$has_php_cli = $this->core->wp_filesystem->exists( '/usr/local/bin/php' );
|
795 |
|
796 |
-
return
|
797 |
}
|
798 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-test.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.0
|
7 |
*
|
8 |
+
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
+
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
// phpcs:disable WordPress.VIP
|
16 |
+
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Test
|
19 |
*
|
20 |
* @since 1.0
|
21 |
*/
|
22 |
class Boldgrid_Backup_Admin_Test {
|
|
|
23 |
/**
|
24 |
* Base test filename.
|
25 |
*
|
140 |
*
|
141 |
* @since 1.5.1
|
142 |
*
|
143 |
+
* @param string $path File or directory path.
|
144 |
* @return bool
|
145 |
*/
|
146 |
public function exists( $path ) {
|
164 |
*
|
165 |
* @since 1.5.1
|
166 |
*
|
167 |
+
* @param string $dir Dircetory path.
|
168 |
* @return array
|
169 |
*/
|
170 |
public function extensive_dir_test( $dir ) {
|
171 |
+
$dir = Boldgrid_Backup_Admin_Utility::trailingslashit( $dir );
|
172 |
$random_filename = $dir . $this->test_prefix . mt_rand();
|
173 |
+
$txt_filename = $random_filename . '.txt';
|
174 |
+
$info_filename = $random_filename . '.rtf';
|
175 |
+
$str = __( 'This is a test file from BoldGrid Backup. You can delete this file.', 'boldgrid-backup' );
|
176 |
|
177 |
$data['exists'] = $this->core->wp_filesystem->exists( $dir );
|
178 |
+
$data['read'] = $this->core->wp_filesystem->is_readable( $dir );
|
179 |
+
$data['write'] = $this->core->wp_filesystem->is_writable( $dir );
|
180 |
|
181 |
// Can we get a directory listing?
|
182 |
+
$dirlist = $this->core->wp_filesystem->dirlist( $dir );
|
183 |
$data['dirlist'] = is_array( $dirlist );
|
184 |
|
185 |
// Determine if we have permission to rename a file.
|
206 |
*
|
207 |
* @since 1.5.2
|
208 |
*
|
209 |
+
* @param string $folder_name Directory folder name.
|
210 |
+
* @param string $starting_dir Start director path.
|
211 |
* @return bool True if folder name found.
|
212 |
*/
|
213 |
public function find_folder( $folder_name, $starting_dir = ABSPATH ) {
|
245 |
*
|
246 |
* @since 1.5.1
|
247 |
*
|
248 |
+
* @param string $dir Directory path.
|
249 |
* @return bool
|
250 |
*/
|
251 |
public function delete_test_files( $dir ) {
|
293 |
*
|
294 |
* @since 1.5.1
|
295 |
*
|
296 |
+
* @param string $dir Directory path.
|
297 |
* @return bool
|
298 |
*/
|
299 |
public function is_writable( $dir ) {
|
347 |
return true;
|
348 |
}
|
349 |
|
350 |
+
$folders_found = __( 'The following node_modules folder was found in your account:', 'boldgrid-backup' );
|
351 |
$possible_issues = __( 'Due to possible issues node_modules folders can cause when calculating disk space, your WordPress directory size was not calculated.', 'boldgrid-backup' );
|
352 |
+
|
353 |
+
// translators: 1: Link.
|
354 |
+
$ignore_warning = __(
|
355 |
+
'To ignore this warning and try again, please <a href="%1$s">click here</a>',
|
356 |
+
'boldgrid-backup'
|
357 |
+
);
|
358 |
|
359 |
$warning = sprintf(
|
360 |
'<strong>%1$s</strong><br />
|
397 |
* To determine if crontab is available, we will BOTH write and remove
|
398 |
* a test entry from the crontab.
|
399 |
*/
|
400 |
+
$entry_added = $this->core->cron->update_cron( $test_entry );
|
401 |
+
$entry_deleted = $this->core->cron->entry_delete( $test_entry );
|
402 |
$this->is_crontab_available = $entry_added && $entry_deleted;
|
403 |
|
404 |
return $this->is_crontab_available;
|
569 |
|
570 |
// Get filesystem disk space information.
|
571 |
$disk_total_space = disk_total_space( $home_dir );
|
572 |
+
$disk_free_space = disk_free_space( $home_dir );
|
573 |
+
$disk_used_space = $disk_total_space - $disk_free_space;
|
574 |
|
575 |
// Initialize $wp_root_size.
|
576 |
$wp_root_size = false;
|
601 |
*/
|
602 |
private function get_wp_size() {
|
603 |
// Save time, use transients.
|
604 |
+
$transient = get_transient( 'boldgrid_backup_wp_size' );
|
605 |
+
|
606 |
+
if ( false !== $transient ) {
|
607 |
return $transient;
|
608 |
}
|
609 |
|
610 |
// Avoid timeout caused when node_modules exist. Return 0 bytes.
|
611 |
+
if ( empty( $_GET['skip_node_modules'] ) ) { // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
612 |
$node_modules_found = $this->node_modules_warning();
|
613 |
if ( true === $node_modules_found ) {
|
614 |
return 0;
|
694 |
*/
|
695 |
public function get_database_size() {
|
696 |
// Save some time, get transient.
|
697 |
+
$transient = get_transient( 'boldgrid_backup_db_size' );
|
698 |
+
|
699 |
+
if ( false !== $transient ) {
|
700 |
return $transient;
|
701 |
}
|
702 |
|
704 |
global $wpdb;
|
705 |
|
706 |
// Build query.
|
707 |
+
$query = sprintf(
|
708 |
+
'SELECT SUM(`data_length` + `index_length`) FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA`=' .
|
709 |
+
"'%s'" . ' AND `TABLE_NAME` LIKE ' . "'%s'" . ' GROUP BY `TABLE_SCHEMA`;',
|
710 |
+
DB_NAME,
|
711 |
+
$wpdb->get_blog_prefix( is_multisite() ) . '%'
|
712 |
);
|
713 |
|
714 |
// Check query.
|
717 |
}
|
718 |
|
719 |
// Get the result.
|
720 |
+
$result = $wpdb->get_row( $query, ARRAY_N ); // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared
|
721 |
|
722 |
// If there was an error or nothing returned, then fail.
|
723 |
if ( empty( $result ) ) {
|
785 |
* @return bool
|
786 |
*/
|
787 |
public function is_iis() {
|
788 |
+
return $this->is_windows() &&
|
789 |
! empty( $_SERVER['SERVER_SOFTWARE'] ) &&
|
790 |
false !== strpos( $_SERVER['SERVER_SOFTWARE'], 'IIS' );
|
791 |
}
|
805 |
|
806 |
$has_php_cli = $this->core->wp_filesystem->exists( '/usr/local/bin/php' );
|
807 |
|
808 |
+
return $is_ea4 || $has_php_cli;
|
809 |
}
|
810 |
}
|
admin/class-boldgrid-backup-admin-time.php
CHANGED
@@ -1,24 +1,23 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.6.0
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.6.0
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Time {
|
21 |
-
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
@@ -35,7 +34,7 @@ class Boldgrid_Backup_Admin_Time {
|
|
35 |
* @access public
|
36 |
* @var int
|
37 |
*/
|
38 |
-
public
|
39 |
|
40 |
/**
|
41 |
* Local time (local to a user).
|
@@ -98,7 +97,6 @@ class Boldgrid_Backup_Admin_Time {
|
|
98 |
* @return mixed DateTimeZone object on success, false on failure.
|
99 |
*/
|
100 |
public function get_server_timezone() {
|
101 |
-
|
102 |
/*
|
103 |
* Determine how we are going to get the server's timezone.
|
104 |
*
|
@@ -123,8 +121,8 @@ class Boldgrid_Backup_Admin_Time {
|
|
123 |
* ------------- --------------
|
124 |
* DateTimeZone Object DateTimeZone Object
|
125 |
* ( (
|
126 |
-
|
127 |
-
|
128 |
* )
|
129 |
*/
|
130 |
$timezone = new DateTimeZone( 'EDT' );
|
@@ -153,12 +151,11 @@ class Boldgrid_Backup_Admin_Time {
|
|
153 |
*
|
154 |
* @since 1.6.0
|
155 |
*
|
156 |
-
* @param array $settings
|
157 |
-
* @param array $tz_info
|
158 |
* @return DateTime
|
159 |
*/
|
160 |
public function get_settings_date( $settings = array(), $tz_info = array() ) {
|
161 |
-
|
162 |
// Abort right away if bad data sent in.
|
163 |
if ( ! is_array( $settings ) || ! is_array( $tz_info ) ) {
|
164 |
return false;
|
@@ -167,7 +164,7 @@ class Boldgrid_Backup_Admin_Time {
|
|
167 |
$settings = empty( $settings ) ? $this->core->settings->get_settings() : $settings;
|
168 |
|
169 |
$tz_info = empty( $tz_info ) ? $this->get_timezone_info() : $tz_info;
|
170 |
-
$is_utc
|
171 |
|
172 |
$time_string = $settings['schedule']['tod_h'] . ':' . $settings['schedule']['tod_m'] . ' ' . $settings['schedule']['tod_a'];
|
173 |
|
@@ -234,7 +231,7 @@ class Boldgrid_Backup_Admin_Time {
|
|
234 |
*
|
235 |
* @since 1.6.0
|
236 |
*
|
237 |
-
* @param string $format
|
238 |
* @return string
|
239 |
*/
|
240 |
public function get_span( $format = 'M j, Y h:i a' ) {
|
@@ -298,7 +295,7 @@ class Boldgrid_Backup_Admin_Time {
|
|
298 |
* @return array
|
299 |
*/
|
300 |
public function get_timezone_info() {
|
301 |
-
$tz_string
|
302 |
$timezone_info = array();
|
303 |
|
304 |
if ( $tz_string ) {
|
@@ -309,9 +306,9 @@ class Boldgrid_Backup_Admin_Time {
|
|
309 |
}
|
310 |
|
311 |
if ( $tz ) {
|
312 |
-
$now
|
313 |
-
$formatted_gmt_offset
|
314 |
-
$tz_name
|
315 |
$timezone_info['abbr'] = $now->format( 'T' );
|
316 |
|
317 |
// This set of code is not in core.
|
@@ -330,9 +327,11 @@ class Boldgrid_Backup_Admin_Time {
|
|
330 |
$timezone_info['gmt_offset'] = $gmt_offset;
|
331 |
}
|
332 |
|
333 |
-
|
334 |
-
|
335 |
-
|
|
|
|
|
336 |
$timezone_info['abbr'] = sprintf( 'UTC%s', $formatted_gmt_offset );
|
337 |
|
338 |
/* translators: %s: UTC offset */
|
@@ -341,11 +340,11 @@ class Boldgrid_Backup_Admin_Time {
|
|
341 |
|
342 |
// This set of code is not in core.
|
343 |
$timezone_info['markup_timezone'] = sprintf( '<span title="%1$s">%2$s</span>', esc_attr( $timezone_info['description'] ), $timezone_info['abbr'] );
|
344 |
-
$timezone_info['markup_change']
|
345 |
'<a href="%1$s" title="%3$s">%2$s</a>',
|
346 |
admin_url( 'options-general.php' ),
|
347 |
__( 'Change timezone', 'boldgrid-backup' ),
|
348 |
-
|
349 |
);
|
350 |
|
351 |
return $timezone_info;
|
@@ -357,7 +356,7 @@ class Boldgrid_Backup_Admin_Time {
|
|
357 |
* @since 1.6.0
|
358 |
*
|
359 |
* @param int $time In seconds.
|
360 |
-
* @param string $type The type of type (
|
361 |
*/
|
362 |
public function init( $time, $type = 'utc' ) {
|
363 |
if ( empty( $time ) ) {
|
@@ -365,7 +364,7 @@ class Boldgrid_Backup_Admin_Time {
|
|
365 |
return;
|
366 |
}
|
367 |
|
368 |
-
$gmt_offset
|
369 |
$valid_gmt_offset = ! empty( $gmt_offset ) || is_numeric( $gmt_offset );
|
370 |
|
371 |
$this->local_timezone = 'UTC';
|
@@ -392,7 +391,7 @@ class Boldgrid_Backup_Admin_Time {
|
|
392 |
|
393 |
// Once we have the UTC time (above), we can calculate the user's local time.
|
394 |
if ( $valid_gmt_offset ) {
|
395 |
-
$this->local_time
|
396 |
$this->local_timezone .= ' ' . $gmt_offset;
|
397 |
} else {
|
398 |
$this->local_time = $this->utc_time;
|
@@ -405,8 +404,8 @@ class Boldgrid_Backup_Admin_Time {
|
|
405 |
* @since 1.6.0
|
406 |
*/
|
407 |
public function reset() {
|
408 |
-
$this->local_time
|
409 |
$this->local_timezone = null;
|
410 |
-
$this->utc_time
|
411 |
}
|
412 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File :class-boldgrid-backup-admin-time.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.6.0
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_Time
|
17 |
*
|
18 |
* @since 1.6.0
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Time {
|
|
|
21 |
/**
|
22 |
* The core class object.
|
23 |
*
|
34 |
* @access public
|
35 |
* @var int
|
36 |
*/
|
37 |
+
public $utc_time;
|
38 |
|
39 |
/**
|
40 |
* Local time (local to a user).
|
97 |
* @return mixed DateTimeZone object on success, false on failure.
|
98 |
*/
|
99 |
public function get_server_timezone() {
|
|
|
100 |
/*
|
101 |
* Determine how we are going to get the server's timezone.
|
102 |
*
|
121 |
* ------------- --------------
|
122 |
* DateTimeZone Object DateTimeZone Object
|
123 |
* ( (
|
124 |
+
* ) [timezone_type] => 2
|
125 |
+
* [timezone] => EDT
|
126 |
* )
|
127 |
*/
|
128 |
$timezone = new DateTimeZone( 'EDT' );
|
151 |
*
|
152 |
* @since 1.6.0
|
153 |
*
|
154 |
+
* @param array $settings BoldGrid Backup settings.
|
155 |
+
* @param array $tz_info Timezone information.
|
156 |
* @return DateTime
|
157 |
*/
|
158 |
public function get_settings_date( $settings = array(), $tz_info = array() ) {
|
|
|
159 |
// Abort right away if bad data sent in.
|
160 |
if ( ! is_array( $settings ) || ! is_array( $tz_info ) ) {
|
161 |
return false;
|
164 |
$settings = empty( $settings ) ? $this->core->settings->get_settings() : $settings;
|
165 |
|
166 |
$tz_info = empty( $tz_info ) ? $this->get_timezone_info() : $tz_info;
|
167 |
+
$is_utc = ! empty( $tz_info['abbr'] ) && 'UTC' === substr( $tz_info['abbr'], 0, 3 );
|
168 |
|
169 |
$time_string = $settings['schedule']['tod_h'] . ':' . $settings['schedule']['tod_m'] . ' ' . $settings['schedule']['tod_a'];
|
170 |
|
231 |
*
|
232 |
* @since 1.6.0
|
233 |
*
|
234 |
+
* @param string $format Date format.
|
235 |
* @return string
|
236 |
*/
|
237 |
public function get_span( $format = 'M j, Y h:i a' ) {
|
295 |
* @return array
|
296 |
*/
|
297 |
public function get_timezone_info() {
|
298 |
+
$tz_string = get_option( 'timezone_string' );
|
299 |
$timezone_info = array();
|
300 |
|
301 |
if ( $tz_string ) {
|
306 |
}
|
307 |
|
308 |
if ( $tz ) {
|
309 |
+
$now = new DateTime( 'now', $tz );
|
310 |
+
$formatted_gmt_offset = sprintf( 'UTC%s', $this->format_gmt_offset( $tz->getOffset( $now ) / 3600 ) );
|
311 |
+
$tz_name = str_replace( '_', ' ', $tz->getName() );
|
312 |
$timezone_info['abbr'] = $now->format( 'T' );
|
313 |
|
314 |
// This set of code is not in core.
|
327 |
$timezone_info['gmt_offset'] = $gmt_offset;
|
328 |
}
|
329 |
|
330 |
+
/*
|
331 |
+
* Not sure why WordPress is doing this. If it is -4.5, show me -4.5 and not -4.
|
332 |
+
* $formatted_gmt_offset = $this->format_gmt_offset( intval( $gmt_offset ) );.
|
333 |
+
*/
|
334 |
+
$formatted_gmt_offset = $gmt_offset;
|
335 |
$timezone_info['abbr'] = sprintf( 'UTC%s', $formatted_gmt_offset );
|
336 |
|
337 |
/* translators: %s: UTC offset */
|
340 |
|
341 |
// This set of code is not in core.
|
342 |
$timezone_info['markup_timezone'] = sprintf( '<span title="%1$s">%2$s</span>', esc_attr( $timezone_info['description'] ), $timezone_info['abbr'] );
|
343 |
+
$timezone_info['markup_change'] = sprintf(
|
344 |
'<a href="%1$s" title="%3$s">%2$s</a>',
|
345 |
admin_url( 'options-general.php' ),
|
346 |
__( 'Change timezone', 'boldgrid-backup' ),
|
347 |
+
esc_html( __( 'WordPress timezone settings can be adjusted within Settings » General', 'boldgrid-backup' ) )
|
348 |
);
|
349 |
|
350 |
return $timezone_info;
|
356 |
* @since 1.6.0
|
357 |
*
|
358 |
* @param int $time In seconds.
|
359 |
+
* @param string $type The type of type (utc, local, -5).
|
360 |
*/
|
361 |
public function init( $time, $type = 'utc' ) {
|
362 |
if ( empty( $time ) ) {
|
364 |
return;
|
365 |
}
|
366 |
|
367 |
+
$gmt_offset = get_option( 'gmt_offset' );
|
368 |
$valid_gmt_offset = ! empty( $gmt_offset ) || is_numeric( $gmt_offset );
|
369 |
|
370 |
$this->local_timezone = 'UTC';
|
391 |
|
392 |
// Once we have the UTC time (above), we can calculate the user's local time.
|
393 |
if ( $valid_gmt_offset ) {
|
394 |
+
$this->local_time = $this->utc_time + ( $gmt_offset * HOUR_IN_SECONDS );
|
395 |
$this->local_timezone .= ' ' . $gmt_offset;
|
396 |
} else {
|
397 |
$this->local_time = $this->utc_time;
|
404 |
* @since 1.6.0
|
405 |
*/
|
406 |
public function reset() {
|
407 |
+
$this->local_time = null;
|
408 |
$this->local_timezone = null;
|
409 |
+
$this->utc_time = null;
|
410 |
}
|
411 |
}
|
admin/class-boldgrid-backup-admin-tools.php
CHANGED
@@ -1,28 +1,27 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since 1.
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
-
* @since 1.
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Tools {
|
21 |
-
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
25 |
-
* @since
|
26 |
* @access private
|
27 |
* @var Boldgrid_Backup_Admin_Core
|
28 |
*/
|
@@ -31,7 +30,7 @@ class Boldgrid_Backup_Admin_Tools {
|
|
31 |
/**
|
32 |
* Constructor.
|
33 |
*
|
34 |
-
* @since 1.
|
35 |
*
|
36 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
37 |
*/
|
@@ -42,7 +41,7 @@ class Boldgrid_Backup_Admin_Tools {
|
|
42 |
/**
|
43 |
* Render the tools page.
|
44 |
*
|
45 |
-
* @since 1.
|
46 |
*/
|
47 |
public function page() {
|
48 |
wp_enqueue_style( 'bglib-ui-css' );
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-tools.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.6.0
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_Tools
|
17 |
*
|
18 |
+
* @since 1.6.0
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Tools {
|
|
|
21 |
/**
|
22 |
* The core class object.
|
23 |
*
|
24 |
+
* @since 1.6.0
|
25 |
* @access private
|
26 |
* @var Boldgrid_Backup_Admin_Core
|
27 |
*/
|
30 |
/**
|
31 |
* Constructor.
|
32 |
*
|
33 |
+
* @since 1.6.0
|
34 |
*
|
35 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
36 |
*/
|
41 |
/**
|
42 |
* Render the tools page.
|
43 |
*
|
44 |
+
* @since 1.6.0
|
45 |
*/
|
46 |
public function page() {
|
47 |
wp_enqueue_style( 'bglib-ui-css' );
|
admin/class-boldgrid-backup-admin-upload.php
CHANGED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.2.2
|
7 |
*
|
8 |
-
* @package
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright
|
11 |
-
* @version
|
12 |
-
* @author
|
13 |
*/
|
14 |
|
|
|
|
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.2.2
|
19 |
*/
|
@@ -187,7 +189,7 @@ class Boldgrid_Backup_Admin_Upload {
|
|
187 |
// Currently only "zip"; others to be added in the future.
|
188 |
// @todo Write a method to get the allowed file extensions, based on available compressors.
|
189 |
$allowed_file_ext = array(
|
190 |
-
'zip'
|
191 |
);
|
192 |
|
193 |
if ( ! in_array( $validate['ext'], $allowed_file_ext, true ) ) {
|
@@ -195,6 +197,7 @@ class Boldgrid_Backup_Admin_Upload {
|
|
195 |
do_action(
|
196 |
'boldgrid_backup_notice',
|
197 |
sprintf(
|
|
|
198 |
esc_html__(
|
199 |
'Upload file extension type %s is not allowed.',
|
200 |
'boldgrid-backup'
|
@@ -278,7 +281,8 @@ class Boldgrid_Backup_Admin_Upload {
|
|
278 |
);
|
279 |
|
280 |
// Add a filter to specify a custom upload directory (the backup directory).
|
281 |
-
add_filter(
|
|
|
282 |
array(
|
283 |
$this->core->config,
|
284 |
'custom_upload_dir',
|
@@ -288,7 +292,8 @@ class Boldgrid_Backup_Admin_Upload {
|
|
288 |
$movefile = wp_handle_upload( $_FILES['file'], $upload_overrides );
|
289 |
|
290 |
// Remove the temporary filter for a custom upload directory.
|
291 |
-
remove_filter(
|
|
|
292 |
array(
|
293 |
$this->core->config,
|
294 |
'custom_upload_dir',
|
@@ -354,6 +359,7 @@ class Boldgrid_Backup_Admin_Upload {
|
|
354 |
do_action(
|
355 |
'boldgrid_backup_notice',
|
356 |
sprintf(
|
|
|
357 |
esc_html__( 'Upload has failed; %s.', 'boldgrid-backup' ),
|
358 |
$movefile['error']
|
359 |
),
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-upload.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.2.2
|
7 |
*
|
8 |
+
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
+
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
// phpcs:disable WordPress.VIP
|
16 |
+
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Upload
|
19 |
*
|
20 |
* @since 1.2.2
|
21 |
*/
|
189 |
// Currently only "zip"; others to be added in the future.
|
190 |
// @todo Write a method to get the allowed file extensions, based on available compressors.
|
191 |
$allowed_file_ext = array(
|
192 |
+
'zip',
|
193 |
);
|
194 |
|
195 |
if ( ! in_array( $validate['ext'], $allowed_file_ext, true ) ) {
|
197 |
do_action(
|
198 |
'boldgrid_backup_notice',
|
199 |
sprintf(
|
200 |
+
// translators: 1: File extension.
|
201 |
esc_html__(
|
202 |
'Upload file extension type %s is not allowed.',
|
203 |
'boldgrid-backup'
|
281 |
);
|
282 |
|
283 |
// Add a filter to specify a custom upload directory (the backup directory).
|
284 |
+
add_filter(
|
285 |
+
'upload_dir',
|
286 |
array(
|
287 |
$this->core->config,
|
288 |
'custom_upload_dir',
|
292 |
$movefile = wp_handle_upload( $_FILES['file'], $upload_overrides );
|
293 |
|
294 |
// Remove the temporary filter for a custom upload directory.
|
295 |
+
remove_filter(
|
296 |
+
'upload_dir',
|
297 |
array(
|
298 |
$this->core->config,
|
299 |
'custom_upload_dir',
|
359 |
do_action(
|
360 |
'boldgrid_backup_notice',
|
361 |
sprintf(
|
362 |
+
// translators: 1: Error message.
|
363 |
esc_html__( 'Upload has failed; %s.', 'boldgrid-backup' ),
|
364 |
$movefile['error']
|
365 |
),
|
admin/class-boldgrid-backup-admin-utility.php
CHANGED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.0
|
7 |
*
|
8 |
-
* @package
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright
|
11 |
-
* @version
|
12 |
-
* @author
|
13 |
*/
|
14 |
|
|
|
|
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.0
|
19 |
*/
|
@@ -25,7 +27,7 @@ class Boldgrid_Backup_Admin_Utility {
|
|
25 |
*
|
26 |
* @static
|
27 |
*
|
28 |
-
* @param int $bytes
|
29 |
* @param int $decimals Number of decimal places.
|
30 |
* @return string
|
31 |
*/
|
@@ -100,7 +102,7 @@ class Boldgrid_Backup_Admin_Utility {
|
|
100 |
* Can be used in this manner:
|
101 |
* set_error_handler( array( 'Boldgrid_Backup_Admin_Utility', 'handle_error' ) );
|
102 |
* try{
|
103 |
-
*
|
104 |
* } catch( Exception $e ) {
|
105 |
$e->getMessage();
|
106 |
* }
|
@@ -108,13 +110,15 @@ class Boldgrid_Backup_Admin_Utility {
|
|
108 |
*
|
109 |
* @since 1.6.0
|
110 |
*
|
111 |
-
* @
|
|
|
|
|
112 |
* @param string $errstr Error description.
|
113 |
* @param string $errfile File in which the error occurs.
|
114 |
* @param int $errline Line number where the error is situated.
|
|
|
115 |
*/
|
116 |
public static function handle_error( $errno, $errstr, $errfile = false, $errline = false ) {
|
117 |
-
|
118 |
// A set of errors to ignore.
|
119 |
$skips = array(
|
120 |
|
@@ -167,34 +171,34 @@ class Boldgrid_Backup_Admin_Utility {
|
|
167 |
*/
|
168 |
public static function translate_zip_error( $error_code = null ) {
|
169 |
switch ( $error_code ) {
|
170 |
-
case ZipArchive::ER_EXISTS
|
171 |
$message = esc_html__( 'File already exists', 'boldgrid-backup' );
|
172 |
break;
|
173 |
-
case ZipArchive::ER_INCONS
|
174 |
$message = esc_html__( 'Zip archive inconsistent', 'boldgrid-backup' );
|
175 |
break;
|
176 |
-
case ZipArchive::ER_INVAL
|
177 |
$message = esc_html__( 'Invalid argument', 'boldgrid-backup' );
|
178 |
break;
|
179 |
-
case ZipArchive::ER_MEMORY
|
180 |
$message = esc_html__( 'Malloc failure', 'boldgrid-backup' );
|
181 |
break;
|
182 |
-
case ZipArchive::ER_NOENT
|
183 |
$message = esc_html__( 'No such file', 'boldgrid-backup' );
|
184 |
break;
|
185 |
-
case ZipArchive::ER_NOZIP
|
186 |
$message = esc_html__( 'Not a zip archive', 'boldgrid-backup' );
|
187 |
break;
|
188 |
-
case ZipArchive::ER_OPEN
|
189 |
$message = esc_html__( 'Cannot open file', 'boldgrid-backup' );
|
190 |
break;
|
191 |
-
case ZipArchive::ER_READ
|
192 |
$message = esc_html__( 'Read error', 'boldgrid-backup' );
|
193 |
break;
|
194 |
-
case ZipArchive::ER_SEEK
|
195 |
$message = esc_html__( 'Seek error', 'boldgrid-backup' );
|
196 |
break;
|
197 |
-
default
|
198 |
$message = esc_html__( 'No error code was passed', 'boldgrid-backup' );
|
199 |
break;
|
200 |
}
|
@@ -305,21 +309,11 @@ class Boldgrid_Backup_Admin_Utility {
|
|
305 |
if ( $wp_filesystem->is_dir( $filepath ) ) {
|
306 |
// Is a directory.
|
307 |
if ( ! $wp_filesystem->chmod( $filepath, 0755 ) ) {
|
308 |
-
// Error chmod 755 a directory.
|
309 |
-
error_log(
|
310 |
-
__METHOD__ . ': Error using chmod 0755 on directory "' . $filepath . '".'
|
311 |
-
);
|
312 |
-
|
313 |
return false;
|
314 |
}
|
315 |
} else {
|
316 |
// Is a file.
|
317 |
if ( ! $wp_filesystem->chmod( $filepath, 0644 ) ) {
|
318 |
-
// Error chmod 644 a file.
|
319 |
-
error_log(
|
320 |
-
__METHOD__ . ': Error using chmod 0644 on file "' . $filepath . '".'
|
321 |
-
);
|
322 |
-
|
323 |
return false;
|
324 |
}
|
325 |
}
|
@@ -360,7 +354,7 @@ class Boldgrid_Backup_Admin_Utility {
|
|
360 |
if ( $current_max < $max_execution_time ) {
|
361 |
set_time_limit( $max_execution_time );
|
362 |
|
363 |
-
if ( false === ini_set( 'max_execution_time', $max_execution_time ) ) {
|
364 |
return false;
|
365 |
}
|
366 |
}
|
@@ -377,7 +371,7 @@ class Boldgrid_Backup_Admin_Utility {
|
|
377 |
*
|
378 |
* @since 1.5.3
|
379 |
*
|
380 |
-
* @param string $plugin boldgrid-backup/boldgrid-backup.php
|
381 |
* @return array
|
382 |
*/
|
383 |
public function get_plugin_data( $plugin ) {
|
@@ -447,7 +441,7 @@ class Boldgrid_Backup_Admin_Utility {
|
|
447 |
// If the current memory limit is less than specified, then try to increase it.
|
448 |
// PHP default is "128M".
|
449 |
if ( $current_limit_int < $memory_limit_int ) {
|
450 |
-
if ( false === ini_set( 'memory_limit', $memory_limit_int ) ) {
|
451 |
return false;
|
452 |
}
|
453 |
}
|
@@ -521,7 +515,7 @@ class Boldgrid_Backup_Admin_Utility {
|
|
521 |
}
|
522 |
|
523 |
// Create a ZipArchive object.
|
524 |
-
$zip = new ZipArchive;
|
525 |
|
526 |
// Check the ZIP file for consistency.
|
527 |
$status = $zip->open( $file, ZipArchive::CHECKCONS );
|
@@ -545,9 +539,9 @@ class Boldgrid_Backup_Admin_Utility {
|
|
545 |
*
|
546 |
* @link http://php.net/manual/en/class.ziparchive.php
|
547 |
*
|
548 |
-
* @param string $zip_file
|
549 |
* @param string $locate_file A filename or path to be located.
|
550 |
-
* @param bool $is_path
|
551 |
* @return bool
|
552 |
*/
|
553 |
public static function zip_file_exists( $zip_file, $locate_file, $is_path = false ) {
|
@@ -557,7 +551,7 @@ class Boldgrid_Backup_Admin_Utility {
|
|
557 |
}
|
558 |
|
559 |
// Create a ZipArchive object.
|
560 |
-
$zip = new ZipArchive;
|
561 |
|
562 |
// Check the ZIP file for consistency.
|
563 |
$status = $zip->open( $zip_file, ZipArchive::CHECKCONS );
|
@@ -588,8 +582,11 @@ class Boldgrid_Backup_Admin_Utility {
|
|
588 |
*
|
589 |
* @global WP_Filesystem $wp_filesystem The WordPress Filesystem API global object.
|
590 |
*
|
|
|
|
|
591 |
* @param string $file Path to a directory or file.
|
592 |
-
* @param int $mode
|
|
|
593 |
* @return bool
|
594 |
*/
|
595 |
public static function chmod( $file, $mode = false ) {
|
@@ -720,6 +717,8 @@ class Boldgrid_Backup_Admin_Utility {
|
|
720 |
// Get the database prefix (blog id 1 or 0 gets the base prefix).
|
721 |
$db_prefix = $wpdb->get_blog_prefix( 1 );
|
722 |
|
|
|
|
|
723 |
// Replace the URL in wp_posts.
|
724 |
$wpdb->query(
|
725 |
$wpdb->prepare(
|
@@ -755,6 +754,8 @@ class Boldgrid_Backup_Admin_Utility {
|
|
755 |
ARRAY_N
|
756 |
);
|
757 |
|
|
|
|
|
758 |
// If there are no matches options, then return.
|
759 |
if ( ! $matched_options ) {
|
760 |
return true;
|
@@ -765,14 +766,14 @@ class Boldgrid_Backup_Admin_Utility {
|
|
765 |
$option_value = get_option( $option_name[0] );
|
766 |
|
767 |
// Replace siteurl.
|
768 |
-
$option_value =
|
769 |
$old_siteurl,
|
770 |
$new_siteurl,
|
771 |
$option_value
|
772 |
);
|
773 |
|
774 |
// Replace siteurl escaped with slashes.
|
775 |
-
$option_value =
|
776 |
addslashes( $old_siteurl ),
|
777 |
addslashes( $new_siteurl ),
|
778 |
$option_value
|
@@ -791,7 +792,7 @@ class Boldgrid_Backup_Admin_Utility {
|
|
791 |
*
|
792 |
* @static
|
793 |
*
|
794 |
-
* @param string $search
|
795 |
* @param string $replace Replace string.
|
796 |
* @param mixed $subject Input subject (array|object|string).
|
797 |
* @return mixed The input subject with recursive string replacements.
|
@@ -802,7 +803,7 @@ class Boldgrid_Backup_Admin_Utility {
|
|
802 |
} elseif ( is_array( $subject ) ) {
|
803 |
foreach ( $subject as $index => $element ) {
|
804 |
// Recurse.
|
805 |
-
$subject[ $index ] =
|
806 |
$search,
|
807 |
$replace,
|
808 |
$element
|
@@ -811,7 +812,7 @@ class Boldgrid_Backup_Admin_Utility {
|
|
811 |
} elseif ( is_object( $subject ) ) {
|
812 |
foreach ( $subject as $index => $element ) {
|
813 |
// Recurse.
|
814 |
-
$subject->$index =
|
815 |
$search,
|
816 |
$replace,
|
817 |
$element
|
@@ -827,7 +828,7 @@ class Boldgrid_Backup_Admin_Utility {
|
|
827 |
*
|
828 |
* @since 1.5.3
|
829 |
*
|
830 |
-
* @param int $time
|
831 |
* @return int
|
832 |
*/
|
833 |
public function time( $time ) {
|
@@ -848,7 +849,9 @@ class Boldgrid_Backup_Admin_Utility {
|
|
848 |
*
|
849 |
* @since 1.5.1
|
850 |
*
|
851 |
-
* @
|
|
|
|
|
852 |
* @return string
|
853 |
*/
|
854 |
public static function trailingslashit( $string ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-utility.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.0
|
7 |
*
|
8 |
+
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
+
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
// phpcs:disable WordPress.VIP
|
16 |
+
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Utility
|
19 |
*
|
20 |
* @since 1.0
|
21 |
*/
|
27 |
*
|
28 |
* @static
|
29 |
*
|
30 |
+
* @param int $bytes Number of bytes.
|
31 |
* @param int $decimals Number of decimal places.
|
32 |
* @return string
|
33 |
*/
|
102 |
* Can be used in this manner:
|
103 |
* set_error_handler( array( 'Boldgrid_Backup_Admin_Utility', 'handle_error' ) );
|
104 |
* try{
|
105 |
+
* // Try something
|
106 |
* } catch( Exception $e ) {
|
107 |
$e->getMessage();
|
108 |
* }
|
110 |
*
|
111 |
* @since 1.6.0
|
112 |
*
|
113 |
+
* @static
|
114 |
+
*
|
115 |
+
* @param int $errno Error number. (can be a PHP Error level constant).
|
116 |
* @param string $errstr Error description.
|
117 |
* @param string $errfile File in which the error occurs.
|
118 |
* @param int $errline Line number where the error is situated.
|
119 |
+
* @throws ErrorException Error exception object.
|
120 |
*/
|
121 |
public static function handle_error( $errno, $errstr, $errfile = false, $errline = false ) {
|
|
|
122 |
// A set of errors to ignore.
|
123 |
$skips = array(
|
124 |
|
171 |
*/
|
172 |
public static function translate_zip_error( $error_code = null ) {
|
173 |
switch ( $error_code ) {
|
174 |
+
case ZipArchive::ER_EXISTS:
|
175 |
$message = esc_html__( 'File already exists', 'boldgrid-backup' );
|
176 |
break;
|
177 |
+
case ZipArchive::ER_INCONS:
|
178 |
$message = esc_html__( 'Zip archive inconsistent', 'boldgrid-backup' );
|
179 |
break;
|
180 |
+
case ZipArchive::ER_INVAL:
|
181 |
$message = esc_html__( 'Invalid argument', 'boldgrid-backup' );
|
182 |
break;
|
183 |
+
case ZipArchive::ER_MEMORY:
|
184 |
$message = esc_html__( 'Malloc failure', 'boldgrid-backup' );
|
185 |
break;
|
186 |
+
case ZipArchive::ER_NOENT:
|
187 |
$message = esc_html__( 'No such file', 'boldgrid-backup' );
|
188 |
break;
|
189 |
+
case ZipArchive::ER_NOZIP:
|
190 |
$message = esc_html__( 'Not a zip archive', 'boldgrid-backup' );
|
191 |
break;
|
192 |
+
case ZipArchive::ER_OPEN:
|
193 |
$message = esc_html__( 'Cannot open file', 'boldgrid-backup' );
|
194 |
break;
|
195 |
+
case ZipArchive::ER_READ:
|
196 |
$message = esc_html__( 'Read error', 'boldgrid-backup' );
|
197 |
break;
|
198 |
+
case ZipArchive::ER_SEEK:
|
199 |
$message = esc_html__( 'Seek error', 'boldgrid-backup' );
|
200 |
break;
|
201 |
+
default:
|
202 |
$message = esc_html__( 'No error code was passed', 'boldgrid-backup' );
|
203 |
break;
|
204 |
}
|
309 |
if ( $wp_filesystem->is_dir( $filepath ) ) {
|
310 |
// Is a directory.
|
311 |
if ( ! $wp_filesystem->chmod( $filepath, 0755 ) ) {
|
|
|
|
|
|
|
|
|
|
|
312 |
return false;
|
313 |
}
|
314 |
} else {
|
315 |
// Is a file.
|
316 |
if ( ! $wp_filesystem->chmod( $filepath, 0644 ) ) {
|
|
|
|
|
|
|
|
|
|
|
317 |
return false;
|
318 |
}
|
319 |
}
|
354 |
if ( $current_max < $max_execution_time ) {
|
355 |
set_time_limit( $max_execution_time );
|
356 |
|
357 |
+
if ( false === ini_set( 'max_execution_time', $max_execution_time ) ) { // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_ini_set
|
358 |
return false;
|
359 |
}
|
360 |
}
|
371 |
*
|
372 |
* @since 1.5.3
|
373 |
*
|
374 |
+
* @param string $plugin Plugin slug ("boldgrid-backup/boldgrid-backup.php").
|
375 |
* @return array
|
376 |
*/
|
377 |
public function get_plugin_data( $plugin ) {
|
441 |
// If the current memory limit is less than specified, then try to increase it.
|
442 |
// PHP default is "128M".
|
443 |
if ( $current_limit_int < $memory_limit_int ) {
|
444 |
+
if ( false === ini_set( 'memory_limit', $memory_limit_int ) ) { // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_ini_set
|
445 |
return false;
|
446 |
}
|
447 |
}
|
515 |
}
|
516 |
|
517 |
// Create a ZipArchive object.
|
518 |
+
$zip = new ZipArchive();
|
519 |
|
520 |
// Check the ZIP file for consistency.
|
521 |
$status = $zip->open( $file, ZipArchive::CHECKCONS );
|
539 |
*
|
540 |
* @link http://php.net/manual/en/class.ziparchive.php
|
541 |
*
|
542 |
+
* @param string $zip_file Path to a ZIP file.
|
543 |
* @param string $locate_file A filename or path to be located.
|
544 |
+
* @param bool $is_path Is the input file a path.
|
545 |
* @return bool
|
546 |
*/
|
547 |
public static function zip_file_exists( $zip_file, $locate_file, $is_path = false ) {
|
551 |
}
|
552 |
|
553 |
// Create a ZipArchive object.
|
554 |
+
$zip = new ZipArchive();
|
555 |
|
556 |
// Check the ZIP file for consistency.
|
557 |
$status = $zip->open( $zip_file, ZipArchive::CHECKCONS );
|
582 |
*
|
583 |
* @global WP_Filesystem $wp_filesystem The WordPress Filesystem API global object.
|
584 |
*
|
585 |
+
* @static
|
586 |
+
*
|
587 |
* @param string $file Path to a directory or file.
|
588 |
+
* @param int $mode (Optional) The permissions as octal number, usually 0644 for files,
|
589 |
+
* 0755 for dirs.
|
590 |
* @return bool
|
591 |
*/
|
592 |
public static function chmod( $file, $mode = false ) {
|
717 |
// Get the database prefix (blog id 1 or 0 gets the base prefix).
|
718 |
$db_prefix = $wpdb->get_blog_prefix( 1 );
|
719 |
|
720 |
+
// phpcs:disable WordPress.DB.PreparedSQLPlaceholders
|
721 |
+
|
722 |
// Replace the URL in wp_posts.
|
723 |
$wpdb->query(
|
724 |
$wpdb->prepare(
|
754 |
ARRAY_N
|
755 |
);
|
756 |
|
757 |
+
// phpcs:enable WordPress.DB.PreparedSQLPlaceholders
|
758 |
+
|
759 |
// If there are no matches options, then return.
|
760 |
if ( ! $matched_options ) {
|
761 |
return true;
|
766 |
$option_value = get_option( $option_name[0] );
|
767 |
|
768 |
// Replace siteurl.
|
769 |
+
$option_value = self::str_replace_recursive(
|
770 |
$old_siteurl,
|
771 |
$new_siteurl,
|
772 |
$option_value
|
773 |
);
|
774 |
|
775 |
// Replace siteurl escaped with slashes.
|
776 |
+
$option_value = self::str_replace_recursive(
|
777 |
addslashes( $old_siteurl ),
|
778 |
addslashes( $new_siteurl ),
|
779 |
$option_value
|
792 |
*
|
793 |
* @static
|
794 |
*
|
795 |
+
* @param string $search Search string.
|
796 |
* @param string $replace Replace string.
|
797 |
* @param mixed $subject Input subject (array|object|string).
|
798 |
* @return mixed The input subject with recursive string replacements.
|
803 |
} elseif ( is_array( $subject ) ) {
|
804 |
foreach ( $subject as $index => $element ) {
|
805 |
// Recurse.
|
806 |
+
$subject[ $index ] = self::str_replace_recursive(
|
807 |
$search,
|
808 |
$replace,
|
809 |
$element
|
812 |
} elseif ( is_object( $subject ) ) {
|
813 |
foreach ( $subject as $index => $element ) {
|
814 |
// Recurse.
|
815 |
+
$subject->$index = self::str_replace_recursive(
|
816 |
$search,
|
817 |
$replace,
|
818 |
$element
|
828 |
*
|
829 |
* @since 1.5.3
|
830 |
*
|
831 |
+
* @param int $time Time in UNIX seconds.
|
832 |
* @return int
|
833 |
*/
|
834 |
public function time( $time ) {
|
849 |
*
|
850 |
* @since 1.5.1
|
851 |
*
|
852 |
+
* @static
|
853 |
+
*
|
854 |
+
* @param string $string A string.
|
855 |
* @return string
|
856 |
*/
|
857 |
public static function trailingslashit( $string ) {
|
admin/class-boldgrid-backup-admin-wp-cron.php
CHANGED
@@ -1,29 +1,28 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
* @link http://www.boldgrid.com
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_WP_Cron {
|
21 |
-
|
22 |
/**
|
23 |
-
*
|
24 |
*
|
25 |
* @since 1.5.1
|
26 |
-
* @
|
27 |
*/
|
28 |
public $days = array(
|
29 |
'sunday',
|
@@ -48,12 +47,11 @@ class Boldgrid_Backup_Admin_WP_Cron {
|
|
48 |
* Hooks.
|
49 |
*
|
50 |
* @since 1.5.1
|
51 |
-
* @access public
|
52 |
* @var array
|
53 |
*/
|
54 |
public $hooks = array(
|
55 |
-
'backup'
|
56 |
-
'restore'
|
57 |
'run_jobs' => 'boldgrid_backup_wp_cron_run_jobs',
|
58 |
);
|
59 |
|
@@ -61,7 +59,6 @@ class Boldgrid_Backup_Admin_WP_Cron {
|
|
61 |
* Schedules.
|
62 |
*
|
63 |
* @since 1.5.1
|
64 |
-
* @access public
|
65 |
* @var array
|
66 |
*/
|
67 |
public $schedules = array();
|
@@ -79,20 +76,21 @@ class Boldgrid_Backup_Admin_WP_Cron {
|
|
79 |
$this->schedules = array(
|
80 |
'every-5-minutes' => array(
|
81 |
'interval' => 5 * MINUTE_IN_SECONDS,
|
82 |
-
'display'
|
83 |
),
|
84 |
-
'weekly'
|
85 |
'interval' => 7 * DAY_IN_SECONDS,
|
86 |
-
'display'
|
87 |
),
|
|
|
88 |
/*
|
89 |
* It does not appear that crons can be added for a one time event.
|
90 |
* Add a "never" schedule. Let someone in 1,000 years have the fun
|
91 |
* of their site being restored out of nowhere wha ha ha!
|
92 |
*/
|
93 |
-
'never'
|
94 |
'interval' => 1000 * YEAR_IN_SECONDS,
|
95 |
-
'display'
|
96 |
),
|
97 |
);
|
98 |
}
|
@@ -109,17 +107,17 @@ class Boldgrid_Backup_Admin_WP_Cron {
|
|
109 |
*
|
110 |
* @since 1.6.0
|
111 |
*
|
112 |
-
* @param array $settings
|
113 |
* @return bool
|
114 |
*/
|
115 |
public function add_all_crons( $settings = array() ) {
|
116 |
$scheduler = ! empty( $settings['scheduler'] ) ? $settings['scheduler'] : null;
|
117 |
-
$schedule
|
118 |
|
119 |
if ( 'wp-cron' === $scheduler && $this->core->scheduler->is_available( $scheduler ) && ! empty( $schedule ) ) {
|
120 |
$this->core->scheduler->clear_all_schedules();
|
121 |
|
122 |
-
$scheduled
|
123 |
$jobs_scheduled = $this->schedule_jobs();
|
124 |
|
125 |
return $scheduled && $jobs_scheduled;
|
@@ -135,9 +133,9 @@ class Boldgrid_Backup_Admin_WP_Cron {
|
|
135 |
$pending_rollback = get_site_option( 'boldgrid_backup_pending_rollback' );
|
136 |
|
137 |
// Get the archive to restore.
|
138 |
-
$archives
|
139 |
-
$archive_key
|
140 |
-
$archive
|
141 |
$archive_filename = $archive['filename'];
|
142 |
|
143 |
// Remove existing restore cron jobs.
|
@@ -153,8 +151,6 @@ class Boldgrid_Backup_Admin_WP_Cron {
|
|
153 |
$pending_rollback['deadline'] = $auto_restore_time;
|
154 |
update_site_option( 'boldgrid_backup_pending_rollback', $pending_rollback );
|
155 |
}
|
156 |
-
|
157 |
-
return;
|
158 |
}
|
159 |
|
160 |
/**
|
@@ -162,7 +158,7 @@ class Boldgrid_Backup_Admin_WP_Cron {
|
|
162 |
*
|
163 |
* @since 1.5.1
|
164 |
*
|
165 |
-
* @param array An array of hooks to clear.
|
166 |
*/
|
167 |
public function clear_schedules( $hooks = array() ) {
|
168 |
if ( empty( $hooks ) ) {
|
@@ -179,7 +175,7 @@ class Boldgrid_Backup_Admin_WP_Cron {
|
|
179 |
*
|
180 |
* @since 1.5.1
|
181 |
*
|
182 |
-
* @param array $schedules
|
183 |
* @return array
|
184 |
*/
|
185 |
public function cron_schedules( $schedules ) {
|
@@ -201,10 +197,10 @@ class Boldgrid_Backup_Admin_WP_Cron {
|
|
201 |
* should return 1 minute from now. If you pass in Monday 1:09pm, that time
|
202 |
* has already passed, so return next Monday at 1:09pm.
|
203 |
*
|
204 |
-
* @param
|
205 |
-
* @param
|
206 |
-
* @param
|
207 |
-
* @param
|
208 |
* @return A timestamp on success.
|
209 |
*/
|
210 |
public function get_next_time( $d, $h, $m, $p ) {
|
@@ -239,7 +235,7 @@ class Boldgrid_Backup_Admin_WP_Cron {
|
|
239 |
|
240 |
$action_key = key( $cron[ $action ] );
|
241 |
|
242 |
-
$ours[] = sprintf( '%1$s (%2$s %3$s %4$s)', $action, $cron[ $action ][ $action_key ]['schedule'], __( 'starting','boldgrid-backup' ), date( 'Y.m.d h:i:s a e', $time ) );
|
243 |
}
|
244 |
|
245 |
return $ours;
|
@@ -272,12 +268,11 @@ class Boldgrid_Backup_Admin_WP_Cron {
|
|
272 |
*
|
273 |
* @since 1.5.1
|
274 |
*
|
275 |
-
* @param array $settings
|
276 |
-
* @param string $hook
|
277 |
* @return bool
|
278 |
*/
|
279 |
public function schedule( $settings, $hook ) {
|
280 |
-
|
281 |
/*
|
282 |
* WP Cron works off of UTC. Get our "local" time from our $settings and
|
283 |
* convert it to UTC.
|
@@ -289,7 +284,7 @@ class Boldgrid_Backup_Admin_WP_Cron {
|
|
289 |
* # Then it will get the settings from options, which is still 4am (as
|
290 |
* it hasn't been saved yet).
|
291 |
*/
|
292 |
-
$date
|
293 |
$new_timezone = new DateTimeZone( 'UTC' );
|
294 |
$date->setTimezone( $new_timezone );
|
295 |
|
@@ -343,7 +338,7 @@ class Boldgrid_Backup_Admin_WP_Cron {
|
|
343 |
|
344 |
if ( ! wp_next_scheduled( $this->hooks['run_jobs'] ) ) {
|
345 |
$scheduled = wp_schedule_event( time(), 'every-5-minutes', $this->hooks['run_jobs'] );
|
346 |
-
$success
|
347 |
}
|
348 |
|
349 |
return $success;
|
1 |
<?php
|
2 |
/**
|
3 |
+
* FIle: class-boldgrid-backup-admin-wp-cron.php
|
4 |
*
|
5 |
* @link http://www.boldgrid.com
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Admin_WP_Cron
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_WP_Cron {
|
|
|
21 |
/**
|
22 |
+
* Days of the week.
|
23 |
*
|
24 |
* @since 1.5.1
|
25 |
+
* @var array
|
26 |
*/
|
27 |
public $days = array(
|
28 |
'sunday',
|
47 |
* Hooks.
|
48 |
*
|
49 |
* @since 1.5.1
|
|
|
50 |
* @var array
|
51 |
*/
|
52 |
public $hooks = array(
|
53 |
+
'backup' => 'boldgrid_backup_wp_cron_backup',
|
54 |
+
'restore' => 'boldgrid_backup_wp_cron_restore',
|
55 |
'run_jobs' => 'boldgrid_backup_wp_cron_run_jobs',
|
56 |
);
|
57 |
|
59 |
* Schedules.
|
60 |
*
|
61 |
* @since 1.5.1
|
|
|
62 |
* @var array
|
63 |
*/
|
64 |
public $schedules = array();
|
76 |
$this->schedules = array(
|
77 |
'every-5-minutes' => array(
|
78 |
'interval' => 5 * MINUTE_IN_SECONDS,
|
79 |
+
'display' => __( 'Every 5 minutes', 'boldgrid-backup' ),
|
80 |
),
|
81 |
+
'weekly' => array(
|
82 |
'interval' => 7 * DAY_IN_SECONDS,
|
83 |
+
'display' => __( 'Weekly', 'boldgrid-backup' ),
|
84 |
),
|
85 |
+
|
86 |
/*
|
87 |
* It does not appear that crons can be added for a one time event.
|
88 |
* Add a "never" schedule. Let someone in 1,000 years have the fun
|
89 |
* of their site being restored out of nowhere wha ha ha!
|
90 |
*/
|
91 |
+
'never' => array(
|
92 |
'interval' => 1000 * YEAR_IN_SECONDS,
|
93 |
+
'display' => __( 'Never', 'boldgrid-backup' ),
|
94 |
),
|
95 |
);
|
96 |
}
|
107 |
*
|
108 |
* @since 1.6.0
|
109 |
*
|
110 |
+
* @param array $settings BoldGrid Backup settings.
|
111 |
* @return bool
|
112 |
*/
|
113 |
public function add_all_crons( $settings = array() ) {
|
114 |
$scheduler = ! empty( $settings['scheduler'] ) ? $settings['scheduler'] : null;
|
115 |
+
$schedule = ! empty( $settings['schedule'] ) ? $settings['schedule'] : null;
|
116 |
|
117 |
if ( 'wp-cron' === $scheduler && $this->core->scheduler->is_available( $scheduler ) && ! empty( $schedule ) ) {
|
118 |
$this->core->scheduler->clear_all_schedules();
|
119 |
|
120 |
+
$scheduled = $this->schedule( $settings, $this->hooks['backup'] );
|
121 |
$jobs_scheduled = $this->schedule_jobs();
|
122 |
|
123 |
return $scheduled && $jobs_scheduled;
|
133 |
$pending_rollback = get_site_option( 'boldgrid_backup_pending_rollback' );
|
134 |
|
135 |
// Get the archive to restore.
|
136 |
+
$archives = $this->core->get_archive_list();
|
137 |
+
$archive_key = 0;
|
138 |
+
$archive = $archives[ $archive_key ];
|
139 |
$archive_filename = $archive['filename'];
|
140 |
|
141 |
// Remove existing restore cron jobs.
|
151 |
$pending_rollback['deadline'] = $auto_restore_time;
|
152 |
update_site_option( 'boldgrid_backup_pending_rollback', $pending_rollback );
|
153 |
}
|
|
|
|
|
154 |
}
|
155 |
|
156 |
/**
|
158 |
*
|
159 |
* @since 1.5.1
|
160 |
*
|
161 |
+
* @param array $hooks An array of hooks to clear.
|
162 |
*/
|
163 |
public function clear_schedules( $hooks = array() ) {
|
164 |
if ( empty( $hooks ) ) {
|
175 |
*
|
176 |
* @since 1.5.1
|
177 |
*
|
178 |
+
* @param array $schedules An array of events.
|
179 |
* @return array
|
180 |
*/
|
181 |
public function cron_schedules( $schedules ) {
|
197 |
* should return 1 minute from now. If you pass in Monday 1:09pm, that time
|
198 |
* has already passed, so return next Monday at 1:09pm.
|
199 |
*
|
200 |
+
* @param string $d Day of the week.
|
201 |
+
* @param int $h Hour.
|
202 |
+
* @param int $m Minute.
|
203 |
+
* @param string $p Period (am/pm).
|
204 |
* @return A timestamp on success.
|
205 |
*/
|
206 |
public function get_next_time( $d, $h, $m, $p ) {
|
235 |
|
236 |
$action_key = key( $cron[ $action ] );
|
237 |
|
238 |
+
$ours[] = sprintf( '%1$s (%2$s %3$s %4$s)', $action, $cron[ $action ][ $action_key ]['schedule'], __( 'starting', 'boldgrid-backup' ), date( 'Y.m.d h:i:s a e', $time ) );
|
239 |
}
|
240 |
|
241 |
return $ours;
|
268 |
*
|
269 |
* @since 1.5.1
|
270 |
*
|
271 |
+
* @param array $settings BoldGrid Backup settings.
|
272 |
+
* @param string $hook Hook name.
|
273 |
* @return bool
|
274 |
*/
|
275 |
public function schedule( $settings, $hook ) {
|
|
|
276 |
/*
|
277 |
* WP Cron works off of UTC. Get our "local" time from our $settings and
|
278 |
* convert it to UTC.
|
284 |
* # Then it will get the settings from options, which is still 4am (as
|
285 |
* it hasn't been saved yet).
|
286 |
*/
|
287 |
+
$date = $this->core->time->get_settings_date( $settings );
|
288 |
$new_timezone = new DateTimeZone( 'UTC' );
|
289 |
$date->setTimezone( $new_timezone );
|
290 |
|
338 |
|
339 |
if ( ! wp_next_scheduled( $this->hooks['run_jobs'] ) ) {
|
340 |
$scheduled = wp_schedule_event( time(), 'every-5-minutes', $this->hooks['run_jobs'] );
|
341 |
+
$success = false !== $scheduled;
|
342 |
}
|
343 |
|
344 |
return $success;
|
admin/class-boldgrid-backup-admin-xhprof.php
CHANGED
@@ -1,19 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.2
|
7 |
*
|
8 |
-
* @package
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright
|
11 |
-
* @version
|
12 |
-
* @author
|
13 |
*/
|
14 |
|
|
|
|
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.2
|
19 |
*/
|
@@ -42,7 +44,8 @@ class Boldgrid_Backup_Admin_Xhprof {
|
|
42 |
// If XHprof was enabled, then register a shutdown action to disable XHProf and
|
43 |
// save the run report data to file.
|
44 |
if ( $this->xhprof_active ) {
|
45 |
-
add_action(
|
|
|
46 |
array(
|
47 |
$this,
|
48 |
'xhprof_disable',
|
@@ -60,7 +63,7 @@ class Boldgrid_Backup_Admin_Xhprof {
|
|
60 |
*/
|
61 |
private function xhprof_enable() {
|
62 |
// If the action is "heartbeat", then abort.
|
63 |
-
if ( ! empty( $_POST['action'] ) && 'heartbeat' === $_POST['action'] ) {
|
64 |
return false;
|
65 |
}
|
66 |
|
@@ -115,7 +118,7 @@ class Boldgrid_Backup_Admin_Xhprof {
|
|
115 |
|
116 |
// Save the run data to file.
|
117 |
$xhprof_runs = new XHProfRuns_Default();
|
118 |
-
$run_id
|
119 |
|
120 |
// Write the report URL to the error log.
|
121 |
error_log(
|
@@ -124,7 +127,5 @@ class Boldgrid_Backup_Admin_Xhprof {
|
|
124 |
);
|
125 |
}
|
126 |
}
|
127 |
-
|
128 |
-
return;
|
129 |
}
|
130 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-xhprof.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.2
|
7 |
*
|
8 |
+
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
+
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
// phpcs:disable WordPress.VIP, WordPress.PHP.DevelopmentFunctions
|
16 |
+
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Xhprof
|
19 |
*
|
20 |
* @since 1.2
|
21 |
*/
|
44 |
// If XHprof was enabled, then register a shutdown action to disable XHProf and
|
45 |
// save the run report data to file.
|
46 |
if ( $this->xhprof_active ) {
|
47 |
+
add_action(
|
48 |
+
'shutdown',
|
49 |
array(
|
50 |
$this,
|
51 |
'xhprof_disable',
|
63 |
*/
|
64 |
private function xhprof_enable() {
|
65 |
// If the action is "heartbeat", then abort.
|
66 |
+
if ( ! empty( $_POST['action'] ) && 'heartbeat' === $_POST['action'] ) { // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
67 |
return false;
|
68 |
}
|
69 |
|
118 |
|
119 |
// Save the run data to file.
|
120 |
$xhprof_runs = new XHProfRuns_Default();
|
121 |
+
$run_id = $xhprof_runs->save_run( $xhprof_data, 'xhprof_boldgrid_backup' );
|
122 |
|
123 |
// Write the report URL to the error log.
|
124 |
error_log(
|
127 |
);
|
128 |
}
|
129 |
}
|
|
|
|
|
130 |
}
|
131 |
}
|
admin/class-boldgrid-backup-admin.php
CHANGED
@@ -1,23 +1,26 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.0
|
7 |
*
|
8 |
-
* @package
|
9 |
* @subpackage Boldgrid_Backup/admin
|
|
|
|
|
|
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
-
*
|
14 |
*
|
15 |
* Defines the plugin name, version, and two examples hooks for how to
|
16 |
* enqueue the admin-specific stylesheet and JavaScript.
|
17 |
*
|
18 |
-
* @
|
19 |
-
* @subpackage Boldgrid_Backup/admin
|
20 |
-
* @author BoldGrid.com <wpb@boldgrid.com>
|
21 |
*/
|
22 |
class Boldgrid_Backup_Admin {
|
23 |
/**
|
@@ -69,7 +72,7 @@ class Boldgrid_Backup_Admin {
|
|
69 |
*/
|
70 |
public function __construct( $plugin_name, $version ) {
|
71 |
$this->plugin_name = $plugin_name;
|
72 |
-
$this->version
|
73 |
|
74 |
// Connect to the WordPress Filesystem API.
|
75 |
global $wp_filesystem;
|
@@ -98,22 +101,25 @@ class Boldgrid_Backup_Admin {
|
|
98 |
* between the defined hooks and the functions defined in this
|
99 |
* class.
|
100 |
*/
|
101 |
-
wp_enqueue_style(
|
102 |
-
|
|
|
|
|
103 |
|
104 |
// Enqueue JS.
|
105 |
-
wp_register_script(
|
|
|
106 |
plugin_dir_url( __FILE__ ) . 'js/boldgrid-backup-admin.js',
|
107 |
array( 'jquery' ),
|
108 |
BOLDGRID_BACKUP_VERSION,
|
109 |
false
|
110 |
);
|
111 |
|
112 |
-
$spinner
|
113 |
-
$dots
|
114 |
$translation = array(
|
115 |
-
'is_premium'
|
116 |
-
'lang'
|
117 |
'spinner_loading' => $spinner . __( 'Loading', 'boldgrid-backup' ) . $dots,
|
118 |
'get_premium_url' => Boldgrid_Backup_Admin_Go_Pro::$url,
|
119 |
);
|
@@ -127,8 +133,9 @@ class Boldgrid_Backup_Admin {
|
|
127 |
wp_enqueue_script( 'jquery-effects-bounce' );
|
128 |
|
129 |
// Enqueue CSS for the home page.
|
130 |
-
if ( isset( $_REQUEST['page'] ) && 'boldgrid-backup' === $_REQUEST['page'] ) {
|
131 |
-
wp_enqueue_style(
|
|
|
132 |
plugin_dir_url( __FILE__ ) . 'css/boldgrid-backup-admin-home.css', array(),
|
133 |
BOLDGRID_BACKUP_VERSION
|
134 |
);
|
@@ -155,7 +162,7 @@ class Boldgrid_Backup_Admin {
|
|
155 |
|
156 |
// Set the config file paths.
|
157 |
$global_config_path = $config_dir . '/config.plugin.php';
|
158 |
-
$local_config_path
|
159 |
|
160 |
// Initialize $global_configs array.
|
161 |
$global_configs = array();
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.0
|
7 |
*
|
8 |
+
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin
|
10 |
+
* @copyright BoldGrid
|
11 |
+
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
// phpcs:disable WordPress.VIP
|
16 |
+
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin
|
19 |
*
|
20 |
* Defines the plugin name, version, and two examples hooks for how to
|
21 |
* enqueue the admin-specific stylesheet and JavaScript.
|
22 |
*
|
23 |
+
* @since 1.0
|
|
|
|
|
24 |
*/
|
25 |
class Boldgrid_Backup_Admin {
|
26 |
/**
|
72 |
*/
|
73 |
public function __construct( $plugin_name, $version ) {
|
74 |
$this->plugin_name = $plugin_name;
|
75 |
+
$this->version = $version;
|
76 |
|
77 |
// Connect to the WordPress Filesystem API.
|
78 |
global $wp_filesystem;
|
101 |
* between the defined hooks and the functions defined in this
|
102 |
* class.
|
103 |
*/
|
104 |
+
wp_enqueue_style(
|
105 |
+
$this->plugin_name,
|
106 |
+
plugin_dir_url( __FILE__ ) . 'css/boldgrid-backup-admin.css', array(), $this->version
|
107 |
+
);
|
108 |
|
109 |
// Enqueue JS.
|
110 |
+
wp_register_script(
|
111 |
+
'boldgrid-backup-admin',
|
112 |
plugin_dir_url( __FILE__ ) . 'js/boldgrid-backup-admin.js',
|
113 |
array( 'jquery' ),
|
114 |
BOLDGRID_BACKUP_VERSION,
|
115 |
false
|
116 |
);
|
117 |
|
118 |
+
$spinner = '<span class="spinner inline"></span> ';
|
119 |
+
$dots = ' ...';
|
120 |
$translation = array(
|
121 |
+
'is_premium' => ( true === $this->config->get_is_premium() ? 'true' : 'false' ),
|
122 |
+
'lang' => $this->config->lang,
|
123 |
'spinner_loading' => $spinner . __( 'Loading', 'boldgrid-backup' ) . $dots,
|
124 |
'get_premium_url' => Boldgrid_Backup_Admin_Go_Pro::$url,
|
125 |
);
|
133 |
wp_enqueue_script( 'jquery-effects-bounce' );
|
134 |
|
135 |
// Enqueue CSS for the home page.
|
136 |
+
if ( isset( $_REQUEST['page'] ) && 'boldgrid-backup' === $_REQUEST['page'] ) { // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
137 |
+
wp_enqueue_style(
|
138 |
+
'boldgrid-backup-admin-home',
|
139 |
plugin_dir_url( __FILE__ ) . 'css/boldgrid-backup-admin-home.css', array(),
|
140 |
BOLDGRID_BACKUP_VERSION
|
141 |
);
|
162 |
|
163 |
// Set the config file paths.
|
164 |
$global_config_path = $config_dir . '/config.plugin.php';
|
165 |
+
$local_config_path = $config_dir . '/config.local.php';
|
166 |
|
167 |
// Initialize $global_configs array.
|
168 |
$global_configs = array();
|
admin/compressor/{pcl_zip.php → class-boldgrid-backup-admin-compressor-pcl-zip.php}
RENAMED
@@ -1,28 +1,29 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Pcl Zip Compressor.
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
-
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Compressor {
|
21 |
-
|
22 |
/**
|
23 |
* An array of errors.
|
24 |
*
|
25 |
-
* @since
|
26 |
* @access public
|
27 |
* @var array
|
28 |
*/
|
@@ -51,11 +52,11 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
|
|
51 |
*
|
52 |
* @since 1.5.1
|
53 |
*
|
54 |
-
* @param Boldgrid_Backup_Admin_Core $core
|
55 |
*/
|
56 |
public function __construct( $core ) {
|
57 |
if ( ! class_exists( 'PclZip' ) ) {
|
58 |
-
require_once
|
59 |
}
|
60 |
|
61 |
parent::__construct( $core );
|
@@ -75,30 +76,29 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
|
|
75 |
* # wp-content/plugins/
|
76 |
* # wp-content/plugins/boldgrid/
|
77 |
*
|
78 |
-
* @since 1.
|
79 |
*
|
80 |
-
* @param array $list
|
81 |
-
* @param array $contents
|
82 |
-
* @param array $filenames
|
83 |
-
* @param string $in_dir
|
84 |
* @return array An updated $contents.
|
85 |
*/
|
86 |
public function browse_add_dirs( $list, $contents, $filenames, $in_dir ) {
|
87 |
foreach ( $list as $key => $file ) {
|
88 |
|
89 |
// These variables are very similar, both exist for readability.
|
90 |
-
$top_dir
|
91 |
$next_dir = null;
|
92 |
|
93 |
if ( '.' === $in_dir ) {
|
94 |
$top_dir = explode( '/', $file['filename'] );
|
95 |
$top_dir = $top_dir[0];
|
96 |
|
97 |
-
if ( empty( $top_dir ) || in_array( $top_dir, $filenames ) ) {
|
98 |
continue;
|
99 |
}
|
100 |
} else {
|
101 |
-
|
102 |
/*
|
103 |
* Determine if file is in directory.
|
104 |
*
|
@@ -122,17 +122,17 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
|
|
122 |
$next_dir = explode( '/', $next_dir );
|
123 |
$next_dir = $in_dir . '/' . $next_dir[0];
|
124 |
|
125 |
-
if ( $next_dir === $file['filename'] || in_array( $next_dir, $filenames ) ) {
|
126 |
continue;
|
127 |
}
|
128 |
}
|
129 |
|
130 |
-
$dir
|
131 |
-
$sudo_file
|
132 |
'filename' => $dir,
|
133 |
-
'folder'
|
134 |
);
|
135 |
-
$contents[]
|
136 |
$filenames[] = $dir;
|
137 |
}
|
138 |
|
@@ -144,7 +144,9 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
|
|
144 |
*
|
145 |
* @since 1.5.1
|
146 |
*
|
147 |
-
* @
|
|
|
|
|
148 |
* @param array $info {
|
149 |
* An array of data about the backup archive we are generating.
|
150 |
*
|
@@ -190,7 +192,8 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
|
|
190 |
$new_filelist[] = $file[0];
|
191 |
}
|
192 |
|
193 |
-
$status = $archive->add(
|
|
|
194 |
PCLZIP_OPT_REMOVE_PATH, ABSPATH
|
195 |
);
|
196 |
|
@@ -220,7 +223,7 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
|
|
220 |
$status = $archive->add( $this->core->db_dump_filepath, PCLZIP_OPT_REMOVE_ALL_PATH );
|
221 |
if ( 0 === $status ) {
|
222 |
return array(
|
223 |
-
|
224 |
);
|
225 |
}
|
226 |
}
|
@@ -233,8 +236,8 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
|
|
233 |
/**
|
234 |
* Get the contents of a zip file.
|
235 |
*
|
236 |
-
* @param string $filepath
|
237 |
-
* @param string $in_dir
|
238 |
* @return array
|
239 |
*/
|
240 |
public function browse( $filepath, $in_dir = '.' ) {
|
@@ -270,7 +273,6 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
|
|
270 |
* https://pastebin.com/bjQZYcAt
|
271 |
*/
|
272 |
foreach ( $list as $key => $file ) {
|
273 |
-
|
274 |
/*
|
275 |
* Calculate the parent directory this file / folder belongs to.
|
276 |
*
|
@@ -285,7 +287,7 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
|
|
285 |
continue;
|
286 |
}
|
287 |
|
288 |
-
$contents[]
|
289 |
$filenames[] = rtrim( $file['filename'], '/' );
|
290 |
}
|
291 |
|
@@ -299,8 +301,8 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
|
|
299 |
*
|
300 |
* @since 1.5.3
|
301 |
*
|
302 |
-
* @param string $filepath /home/user/boldgrid_backup/archive.zip
|
303 |
-
* @param string $file wp-content/index.php
|
304 |
* @return bool
|
305 |
*/
|
306 |
public function extract_one( $filepath, $file ) {
|
@@ -333,8 +335,8 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
|
|
333 |
*
|
334 |
* @since 1.5.3
|
335 |
*
|
336 |
-
* @param string $filepath /home/user/boldgrid_backup/archive.zip
|
337 |
-
* @param string $file
|
338 |
* @return mixed False on failure, array on success {
|
339 |
* Accessed via $file_contentws[0].
|
340 |
*
|
@@ -428,7 +430,7 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
|
|
428 |
continue;
|
429 |
}
|
430 |
|
431 |
-
// If it's not in this format, skip it - Format: *.########-######.sql
|
432 |
if ( 1 !== preg_match( '/\.[\d]+-[\d]+\.sql$/', $filename ) ) {
|
433 |
continue;
|
434 |
}
|
@@ -444,14 +446,14 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
|
|
444 |
*
|
445 |
* @since 1.5.2
|
446 |
*
|
447 |
-
* @param
|
448 |
* @return mixed False when no messages should be displayed, String when
|
449 |
* returning a message to the user.
|
450 |
*/
|
451 |
public function parse_error_info( $error_info ) {
|
452 |
-
$parts
|
453 |
$force_php_zip = false;
|
454 |
-
$messages
|
455 |
|
456 |
// Does not exist [code -4].
|
457 |
if ( ! empty( $parts[2] ) && false !== strpos( $parts[2], 'code -4' ) ) {
|
@@ -460,6 +462,7 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
|
|
460 |
// Check for broken symlink.
|
461 |
if ( is_link( $path ) && ! $this->core->wp_filesystem->exists( $path ) ) {
|
462 |
$force_php_zip = true;
|
|
|
463 |
$messages[] = sprintf( __( 'PclZip encountered the following broken symlink and is unable to create a backup:<br />%1$s', 'boldgrid-backup' ), $parts[1] );
|
464 |
}
|
465 |
}
|
@@ -484,7 +487,7 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
|
|
484 |
*
|
485 |
* @since 1.5
|
486 |
*
|
487 |
-
* @param bool $display_errors
|
488 |
* @return bool
|
489 |
*/
|
490 |
public function test( $display_errors = true ) {
|
@@ -495,20 +498,24 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
|
|
495 |
$backup_dir = $this->core->backup_dir->get();
|
496 |
|
497 |
// Strings to help with creating test files.
|
498 |
-
$test_file_contents =
|
499 |
-
$safe_to_delete
|
500 |
-
$test_zip_file
|
501 |
-
$test_filename
|
502 |
-
$zip_filepath
|
503 |
-
$random_filename
|
504 |
-
|
505 |
-
|
|
|
|
|
506 |
%1$s.<br />
|
507 |
Please ensure your backup directory has read, write, and modify permissions.',
|
508 |
'boldgrid-backup'
|
509 |
);
|
510 |
|
511 |
-
|
|
|
|
|
512 |
%1$s<br />
|
513 |
Please ensure your backup directory has read, write, and modify permissions.',
|
514 |
'boldgrid-backup'
|
@@ -517,14 +524,14 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
|
|
517 |
$touched = $this->core->wp_filesystem->touch( $random_filename );
|
518 |
if ( ! $touched ) {
|
519 |
$this->test_errors[] = sprintf( $cannot_touch_file, $random_filename );
|
520 |
-
self::$test_result
|
521 |
return false;
|
522 |
}
|
523 |
|
524 |
$contents_put = $this->core->wp_filesystem->put_contents( $random_filename, $test_file_contents );
|
525 |
if ( ! $contents_put ) {
|
526 |
$this->test_errors[] = sprintf( $cannot_put_contents, $random_filename );
|
527 |
-
self::$test_result
|
528 |
return false;
|
529 |
}
|
530 |
|
@@ -541,6 +548,7 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
|
|
541 |
$this->core->test->delete_test_files( $backup_dir );
|
542 |
|
543 |
self::$test_result = true;
|
|
|
544 |
return true;
|
545 |
}
|
546 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-compressor-pcl-zip.php
|
4 |
+
*
|
5 |
* Pcl Zip Compressor.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.5.1
|
9 |
*
|
10 |
* @package Boldgrid_Backup
|
11 |
+
* @subpackage Boldgrid_Backup/admin/compressor
|
12 |
+
* @copyright BoldGrid
|
13 |
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Compressor_Pcl_Zip
|
19 |
*
|
20 |
* @since 1.5.1
|
21 |
*/
|
22 |
class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Compressor {
|
|
|
23 |
/**
|
24 |
* An array of errors.
|
25 |
*
|
26 |
+
* @since 1.6.0
|
27 |
* @access public
|
28 |
* @var array
|
29 |
*/
|
52 |
*
|
53 |
* @since 1.5.1
|
54 |
*
|
55 |
+
* @param Boldgrid_Backup_Admin_Core $core Boldgrid_Backup_Admin_Core object.
|
56 |
*/
|
57 |
public function __construct( $core ) {
|
58 |
if ( ! class_exists( 'PclZip' ) ) {
|
59 |
+
require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
|
60 |
}
|
61 |
|
62 |
parent::__construct( $core );
|
76 |
* # wp-content/plugins/
|
77 |
* # wp-content/plugins/boldgrid/
|
78 |
*
|
79 |
+
* @since 1.6.0
|
80 |
*
|
81 |
+
* @param array $list A list of files.
|
82 |
+
* @param array $contents Contents; not used here.
|
83 |
+
* @param array $filenames Filenames.
|
84 |
+
* @param string $in_dir Current directory.
|
85 |
* @return array An updated $contents.
|
86 |
*/
|
87 |
public function browse_add_dirs( $list, $contents, $filenames, $in_dir ) {
|
88 |
foreach ( $list as $key => $file ) {
|
89 |
|
90 |
// These variables are very similar, both exist for readability.
|
91 |
+
$top_dir = null;
|
92 |
$next_dir = null;
|
93 |
|
94 |
if ( '.' === $in_dir ) {
|
95 |
$top_dir = explode( '/', $file['filename'] );
|
96 |
$top_dir = $top_dir[0];
|
97 |
|
98 |
+
if ( empty( $top_dir ) || in_array( $top_dir, $filenames, true ) ) {
|
99 |
continue;
|
100 |
}
|
101 |
} else {
|
|
|
102 |
/*
|
103 |
* Determine if file is in directory.
|
104 |
*
|
122 |
$next_dir = explode( '/', $next_dir );
|
123 |
$next_dir = $in_dir . '/' . $next_dir[0];
|
124 |
|
125 |
+
if ( $next_dir === $file['filename'] || in_array( $next_dir, $filenames, true ) ) {
|
126 |
continue;
|
127 |
}
|
128 |
}
|
129 |
|
130 |
+
$dir = ! empty( $top_dir ) ? $top_dir : $next_dir;
|
131 |
+
$sudo_file = array(
|
132 |
'filename' => $dir,
|
133 |
+
'folder' => true,
|
134 |
);
|
135 |
+
$contents[] = $sudo_file;
|
136 |
$filenames[] = $dir;
|
137 |
}
|
138 |
|
144 |
*
|
145 |
* @since 1.5.1
|
146 |
*
|
147 |
+
* @see Boldgrid_Backup_Admin_Filelist::get_total_size()
|
148 |
+
*
|
149 |
+
* @param array $filelist File list.
|
150 |
* @param array $info {
|
151 |
* An array of data about the backup archive we are generating.
|
152 |
*
|
192 |
$new_filelist[] = $file[0];
|
193 |
}
|
194 |
|
195 |
+
$status = $archive->add(
|
196 |
+
$new_filelist,
|
197 |
PCLZIP_OPT_REMOVE_PATH, ABSPATH
|
198 |
);
|
199 |
|
223 |
$status = $archive->add( $this->core->db_dump_filepath, PCLZIP_OPT_REMOVE_ALL_PATH );
|
224 |
if ( 0 === $status ) {
|
225 |
return array(
|
226 |
+
'error' => sprintf( 'Cannot add database dump to ZIP archive file: %1$s', $archive->errorInfo() ),
|
227 |
);
|
228 |
}
|
229 |
}
|
236 |
/**
|
237 |
* Get the contents of a zip file.
|
238 |
*
|
239 |
+
* @param string $filepath File path.
|
240 |
+
* @param string $in_dir Current directory.
|
241 |
* @return array
|
242 |
*/
|
243 |
public function browse( $filepath, $in_dir = '.' ) {
|
273 |
* https://pastebin.com/bjQZYcAt
|
274 |
*/
|
275 |
foreach ( $list as $key => $file ) {
|
|
|
276 |
/*
|
277 |
* Calculate the parent directory this file / folder belongs to.
|
278 |
*
|
287 |
continue;
|
288 |
}
|
289 |
|
290 |
+
$contents[] = $file;
|
291 |
$filenames[] = rtrim( $file['filename'], '/' );
|
292 |
}
|
293 |
|
301 |
*
|
302 |
* @since 1.5.3
|
303 |
*
|
304 |
+
* @param string $filepath Archive path, such as "/home/user/boldgrid_backup/archive.zip".
|
305 |
+
* @param string $file A file path in the archive file, such as "wp-content/index.php".
|
306 |
* @return bool
|
307 |
*/
|
308 |
public function extract_one( $filepath, $file ) {
|
335 |
*
|
336 |
* @since 1.5.3
|
337 |
*
|
338 |
+
* @param string $filepath Archive path, such as "/home/user/boldgrid_backup/archive.zip".
|
339 |
+
* @param string $file A file path in the archive file, such as "wp-content/index.php".
|
340 |
* @return mixed False on failure, array on success {
|
341 |
* Accessed via $file_contentws[0].
|
342 |
*
|
430 |
continue;
|
431 |
}
|
432 |
|
433 |
+
// If it's not in this format, skip it - Format: "*.########-######.sql".
|
434 |
if ( 1 !== preg_match( '/\.[\d]+-[\d]+\.sql$/', $filename ) ) {
|
435 |
continue;
|
436 |
}
|
446 |
*
|
447 |
* @since 1.5.2
|
448 |
*
|
449 |
+
* @param string $error_info Error message.
|
450 |
* @return mixed False when no messages should be displayed, String when
|
451 |
* returning a message to the user.
|
452 |
*/
|
453 |
public function parse_error_info( $error_info ) {
|
454 |
+
$parts = explode( '\'', $error_info );
|
455 |
$force_php_zip = false;
|
456 |
+
$messages = array();
|
457 |
|
458 |
// Does not exist [code -4].
|
459 |
if ( ! empty( $parts[2] ) && false !== strpos( $parts[2], 'code -4' ) ) {
|
462 |
// Check for broken symlink.
|
463 |
if ( is_link( $path ) && ! $this->core->wp_filesystem->exists( $path ) ) {
|
464 |
$force_php_zip = true;
|
465 |
+
// translators: 1: File path.
|
466 |
$messages[] = sprintf( __( 'PclZip encountered the following broken symlink and is unable to create a backup:<br />%1$s', 'boldgrid-backup' ), $parts[1] );
|
467 |
}
|
468 |
}
|
487 |
*
|
488 |
* @since 1.5
|
489 |
*
|
490 |
+
* @param bool $display_errors Display errors; default is TRUE.
|
491 |
* @return bool
|
492 |
*/
|
493 |
public function test( $display_errors = true ) {
|
498 |
$backup_dir = $this->core->backup_dir->get();
|
499 |
|
500 |
// Strings to help with creating test files.
|
501 |
+
$test_file_contents = __( 'This is a test file from BoldGrid Backup. You can delete this file.', 'boldgrid-backup' );
|
502 |
+
$safe_to_delete = __( 'safe-to-delete', 'boldgrid-backup' );
|
503 |
+
$test_zip_file = $this->core->test->test_prefix . '-zip';
|
504 |
+
$test_filename = sprintf( '%1$s%5$s%2$s-%3$s-%4$s', $backup_dir, $test_zip_file, mt_rand(), $safe_to_delete, DIRECTORY_SEPARATOR );
|
505 |
+
$zip_filepath = $test_filename . '.zip';
|
506 |
+
$random_filename = $test_filename . '.txt';
|
507 |
+
|
508 |
+
// translators: 1: File path.
|
509 |
+
$cannot_touch_file = __(
|
510 |
+
'PclZip test failed. We were unable to create the following test file:<br />
|
511 |
%1$s.<br />
|
512 |
Please ensure your backup directory has read, write, and modify permissions.',
|
513 |
'boldgrid-backup'
|
514 |
);
|
515 |
|
516 |
+
// translators: 1: File path.
|
517 |
+
$cannot_put_contents = __(
|
518 |
+
'PclZip test failed. We were able to create the following test file, but we were unable to modify it. were unable to modify it:<br />
|
519 |
%1$s<br />
|
520 |
Please ensure your backup directory has read, write, and modify permissions.',
|
521 |
'boldgrid-backup'
|
524 |
$touched = $this->core->wp_filesystem->touch( $random_filename );
|
525 |
if ( ! $touched ) {
|
526 |
$this->test_errors[] = sprintf( $cannot_touch_file, $random_filename );
|
527 |
+
self::$test_result = false;
|
528 |
return false;
|
529 |
}
|
530 |
|
531 |
$contents_put = $this->core->wp_filesystem->put_contents( $random_filename, $test_file_contents );
|
532 |
if ( ! $contents_put ) {
|
533 |
$this->test_errors[] = sprintf( $cannot_put_contents, $random_filename );
|
534 |
+
self::$test_result = false;
|
535 |
return false;
|
536 |
}
|
537 |
|
548 |
$this->core->test->delete_test_files( $backup_dir );
|
549 |
|
550 |
self::$test_result = true;
|
551 |
+
|
552 |
return true;
|
553 |
}
|
554 |
}
|
admin/compressor/{php_zip.php → class-boldgrid-backup-admin-compressor-php-zip.php}
RENAMED
@@ -1,28 +1,29 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* PHP Zip Compressor.
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.5.1
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
-
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.1
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Compressor_Php_Zip extends Boldgrid_Backup_Admin_Compressor {
|
21 |
-
|
22 |
/**
|
23 |
* An array of directories we've added to the zip.
|
24 |
*
|
25 |
-
* @since
|
26 |
* @access public
|
27 |
* @var array
|
28 |
*/
|
@@ -54,17 +55,6 @@ class Boldgrid_Backup_Admin_Compressor_Php_Zip extends Boldgrid_Backup_Admin_Com
|
|
54 |
*/
|
55 |
public $zip;
|
56 |
|
57 |
-
/**
|
58 |
-
* Constructor.
|
59 |
-
*
|
60 |
-
* @since 1.5.1
|
61 |
-
*
|
62 |
-
* @param Boldgrid_Backup_Admin_Core $core
|
63 |
-
*/
|
64 |
-
public function __construct( $core ) {
|
65 |
-
parent::__construct( $core );
|
66 |
-
}
|
67 |
-
|
68 |
/**
|
69 |
* Add a file's directories to the zip.
|
70 |
*
|
@@ -72,13 +62,13 @@ class Boldgrid_Backup_Admin_Compressor_Php_Zip extends Boldgrid_Backup_Admin_Com
|
|
72 |
* created. For example, if you add wp-content/themes/pavilion/index.php the
|
73 |
* wp-content directory (and so forth) is not explicity added to the zip.
|
74 |
*
|
75 |
-
* @since 1.
|
76 |
*
|
77 |
-
* @param string $file
|
78 |
*/
|
79 |
public function add_dir( $file ) {
|
80 |
$add_directory = '';
|
81 |
-
$dirs
|
82 |
|
83 |
foreach ( $dirs as $key => $dir ) {
|
84 |
if ( 0 === $key ) {
|
@@ -99,7 +89,9 @@ class Boldgrid_Backup_Admin_Compressor_Php_Zip extends Boldgrid_Backup_Admin_Com
|
|
99 |
*
|
100 |
* @since 1.5.1
|
101 |
*
|
102 |
-
* @
|
|
|
|
|
103 |
* @param array $info {
|
104 |
* An array of data about the backup archive we are generating.
|
105 |
*
|
@@ -124,8 +116,8 @@ class Boldgrid_Backup_Admin_Compressor_Php_Zip extends Boldgrid_Backup_Admin_Com
|
|
124 |
|
125 |
if ( ! $status ) {
|
126 |
return array(
|
127 |
-
'error'
|
128 |
-
'error_code'
|
129 |
'error_message' => Boldgrid_Backup_Admin_Utility::translate_zip_error( $status ),
|
130 |
);
|
131 |
}
|
@@ -173,21 +165,29 @@ class Boldgrid_Backup_Admin_Compressor_Php_Zip extends Boldgrid_Backup_Admin_Com
|
|
173 |
|
174 |
$backup_dir = $this->core->backup_dir->get();
|
175 |
|
176 |
-
$test_file_contents =
|
|
|
|
|
|
|
|
|
|
|
177 |
$cannot_open_zip = __( 'Unable to create zip file: %1$s', 'boldgrid-backup' );
|
178 |
-
$cannot_close_zip = __( 'When testing ZipArchive functionality, we are able to create a zip file and add files to it, but we were unable to close the zip file.<br /><strong>Please be sure the following backup directory has modify permissions</strong>:<br />%1$s', 'boldgrid-backup' );
|
179 |
-
$safe_to_delete = __( 'safe-to-delete', 'boldgrid-backup' );
|
180 |
-
$test_zip_file = $test_zip_file = $this->core->test->test_prefix . '-zip';
|
181 |
-
$test_filename = sprintf( '%1$s%5$s%2$s-%3$s-%4$s', $backup_dir, $test_zip_file, mt_rand(), $safe_to_delete, DIRECTORY_SEPARATOR );
|
182 |
|
183 |
-
|
184 |
-
$
|
|
|
|
|
|
|
|
|
|
|
185 |
|
186 |
-
$zip
|
187 |
$status = $zip->open( $zip_filepath, ZipArchive::CREATE );
|
|
|
188 |
if ( ! $status ) {
|
189 |
$this->test_errors[] = sprintf( $cannot_open_zip, $zip_filepath );
|
190 |
-
self::$test_result
|
|
|
191 |
return false;
|
192 |
}
|
193 |
|
@@ -196,17 +196,19 @@ class Boldgrid_Backup_Admin_Compressor_Php_Zip extends Boldgrid_Backup_Admin_Com
|
|
196 |
|
197 |
$zip->addFile( $random_filename, 'test.txt' );
|
198 |
|
199 |
-
$zip_closed = @$zip->close();
|
200 |
|
201 |
$this->core->test->delete_test_files( $backup_dir );
|
202 |
|
203 |
if ( ! $zip_closed ) {
|
204 |
$this->test_errors[] = sprintf( $cannot_close_zip, $backup_dir );
|
205 |
-
self::$test_result
|
|
|
206 |
return false;
|
207 |
}
|
208 |
|
209 |
self::$test_result = true;
|
|
|
210 |
return true;
|
211 |
}
|
212 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-compressor-php-zip.php
|
4 |
+
*
|
5 |
* PHP Zip Compressor.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.5.1
|
9 |
*
|
10 |
* @package Boldgrid_Backup
|
11 |
+
* @subpackage Boldgrid_Backup/admin/compressor
|
12 |
+
* @copyright BoldGrid
|
13 |
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Compressor_Php_Zip
|
19 |
*
|
20 |
* @since 1.5.1
|
21 |
*/
|
22 |
class Boldgrid_Backup_Admin_Compressor_Php_Zip extends Boldgrid_Backup_Admin_Compressor {
|
|
|
23 |
/**
|
24 |
* An array of directories we've added to the zip.
|
25 |
*
|
26 |
+
* @since 1.6.0
|
27 |
* @access public
|
28 |
* @var array
|
29 |
*/
|
55 |
*/
|
56 |
public $zip;
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
/**
|
59 |
* Add a file's directories to the zip.
|
60 |
*
|
62 |
* created. For example, if you add wp-content/themes/pavilion/index.php the
|
63 |
* wp-content directory (and so forth) is not explicity added to the zip.
|
64 |
*
|
65 |
+
* @since 1.6.0
|
66 |
*
|
67 |
+
* @param string $file A file path.
|
68 |
*/
|
69 |
public function add_dir( $file ) {
|
70 |
$add_directory = '';
|
71 |
+
$dirs = explode( DIRECTORY_SEPARATOR, dirname( $file ) );
|
72 |
|
73 |
foreach ( $dirs as $key => $dir ) {
|
74 |
if ( 0 === $key ) {
|
89 |
*
|
90 |
* @since 1.5.1
|
91 |
*
|
92 |
+
* @see Boldgrid_Backup_Admin_Filelist::get_total_size()
|
93 |
+
*
|
94 |
+
* @param array $filelist File list.
|
95 |
* @param array $info {
|
96 |
* An array of data about the backup archive we are generating.
|
97 |
*
|
116 |
|
117 |
if ( ! $status ) {
|
118 |
return array(
|
119 |
+
'error' => 'Cannot open ZIP archive file "' . $info['filepath'] . '".',
|
120 |
+
'error_code' => $status,
|
121 |
'error_message' => Boldgrid_Backup_Admin_Utility::translate_zip_error( $status ),
|
122 |
);
|
123 |
}
|
165 |
|
166 |
$backup_dir = $this->core->backup_dir->get();
|
167 |
|
168 |
+
$test_file_contents = __(
|
169 |
+
'This is a test file from BoldGrid Backup. You can delete this file.',
|
170 |
+
'boldgrid-backup'
|
171 |
+
);
|
172 |
+
|
173 |
+
// translators: 1: A filename.
|
174 |
$cannot_open_zip = __( 'Unable to create zip file: %1$s', 'boldgrid-backup' );
|
|
|
|
|
|
|
|
|
175 |
|
176 |
+
// translators: 1: Backup directory path.
|
177 |
+
$cannot_close_zip = __( 'When testing ZipArchive functionality, we are able to create a zip file and add files to it, but we were unable to close the zip file.<br /><strong>Please be sure the following backup directory has modify permissions</strong>:<br />%1$s', 'boldgrid-backup' );
|
178 |
+
$safe_to_delete = __( 'safe-to-delete', 'boldgrid-backup' );
|
179 |
+
$test_zip_file = $this->core->test->test_prefix . '-zip';
|
180 |
+
$test_filename = sprintf( '%1$s%5$s%2$s-%3$s-%4$s', $backup_dir, $test_zip_file, mt_rand(), $safe_to_delete, DIRECTORY_SEPARATOR );
|
181 |
+
$zip_filepath = $test_filename . '.zip';
|
182 |
+
$random_filename = $test_filename . '.txt';
|
183 |
|
184 |
+
$zip = new ZipArchive();
|
185 |
$status = $zip->open( $zip_filepath, ZipArchive::CREATE );
|
186 |
+
|
187 |
if ( ! $status ) {
|
188 |
$this->test_errors[] = sprintf( $cannot_open_zip, $zip_filepath );
|
189 |
+
self::$test_result = false;
|
190 |
+
|
191 |
return false;
|
192 |
}
|
193 |
|
196 |
|
197 |
$zip->addFile( $random_filename, 'test.txt' );
|
198 |
|
199 |
+
$zip_closed = @$zip->close(); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
|
200 |
|
201 |
$this->core->test->delete_test_files( $backup_dir );
|
202 |
|
203 |
if ( ! $zip_closed ) {
|
204 |
$this->test_errors[] = sprintf( $cannot_close_zip, $backup_dir );
|
205 |
+
self::$test_result = false;
|
206 |
+
|
207 |
return false;
|
208 |
}
|
209 |
|
210 |
self::$test_result = true;
|
211 |
+
|
212 |
return true;
|
213 |
}
|
214 |
}
|
admin/index.php
CHANGED
@@ -1,2 +1,8 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
// Silence is golden.
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* File: index.php
|
4 |
+
*
|
5 |
+
* @package Boldgrid_Backup
|
6 |
+
*/
|
7 |
+
|
8 |
// Silence is golden.
|
admin/js/boldgrid-backup-admin-archive-actions.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
*
|
4 |
* @summary JavaScript to handle archive actions.
|
5 |
*
|
6 |
-
* @since 1.
|
7 |
*/
|
8 |
|
9 |
/* global ajaxurl,BoldGridBackupAdminArchiveActions,jQuery */
|
@@ -23,7 +23,7 @@ BOLDGRID.BACKUP.ACTIONS = function( $ ) {
|
|
23 |
* This function was originally in admin-home.js as of 1.0, but moved here
|
24 |
* as of 1.5.4.
|
25 |
*
|
26 |
-
* @since 1.
|
27 |
*/
|
28 |
self.onClickDelete = function( e ) {
|
29 |
var confirmResponse,
|
@@ -50,7 +50,7 @@ BOLDGRID.BACKUP.ACTIONS = function( $ ) {
|
|
50 |
* This function was originally in admin-home.js as of 1.0, but moved here
|
51 |
* as of 1.5.4.
|
52 |
*
|
53 |
-
* @since 1.
|
54 |
*/
|
55 |
self.downloadArchive = function( e ) {
|
56 |
var downloadKey,
|
@@ -109,7 +109,7 @@ BOLDGRID.BACKUP.ACTIONS = function( $ ) {
|
|
109 |
* This function was originally in admin-home.js as of 1.0, but moved here
|
110 |
* as of 1.5.4.
|
111 |
*
|
112 |
-
* @since 1.
|
113 |
*/
|
114 |
self.restoreArchiveConfirm = function() {
|
115 |
var confirmResponse,
|
3 |
*
|
4 |
* @summary JavaScript to handle archive actions.
|
5 |
*
|
6 |
+
* @since 1.6.0
|
7 |
*/
|
8 |
|
9 |
/* global ajaxurl,BoldGridBackupAdminArchiveActions,jQuery */
|
23 |
* This function was originally in admin-home.js as of 1.0, but moved here
|
24 |
* as of 1.5.4.
|
25 |
*
|
26 |
+
* @since 1.6.0
|
27 |
*/
|
28 |
self.onClickDelete = function( e ) {
|
29 |
var confirmResponse,
|
50 |
* This function was originally in admin-home.js as of 1.0, but moved here
|
51 |
* as of 1.5.4.
|
52 |
*
|
53 |
+
* @since 1.6.0
|
54 |
*/
|
55 |
self.downloadArchive = function( e ) {
|
56 |
var downloadKey,
|
109 |
* This function was originally in admin-home.js as of 1.0, but moved here
|
110 |
* as of 1.5.4.
|
111 |
*
|
112 |
+
* @since 1.6.0
|
113 |
*/
|
114 |
self.restoreArchiveConfirm = function() {
|
115 |
var confirmResponse,
|
admin/js/boldgrid-backup-admin-archive-details.js
CHANGED
@@ -71,7 +71,7 @@ BoldGrid.ArchiveDetails = function( $ ) {
|
|
71 |
/**
|
72 |
* @summary Action to take when a user clicks download.
|
73 |
*
|
74 |
-
* @since 1.
|
75 |
*/
|
76 |
self.onClickDownload = function() {
|
77 |
var $button = $( this ),
|
@@ -100,7 +100,7 @@ BoldGrid.ArchiveDetails = function( $ ) {
|
|
100 |
*
|
101 |
* This method downloads the first remote archive it finds.
|
102 |
*
|
103 |
-
* @since 1.
|
104 |
*/
|
105 |
self.onClickDownloadFirst = function() {
|
106 |
var $downloadToServer = $body.find( '.download-to-server' ),
|
@@ -122,7 +122,7 @@ BoldGrid.ArchiveDetails = function( $ ) {
|
|
122 |
*
|
123 |
* These are the "Files & Folders" and "Database" tabs.
|
124 |
*
|
125 |
-
* @since 1.
|
126 |
*/
|
127 |
self.onClickTab = function() {
|
128 |
var $dbElements = $( '[data-view-type="db"]' ),
|
71 |
/**
|
72 |
* @summary Action to take when a user clicks download.
|
73 |
*
|
74 |
+
* @since 1.6.0
|
75 |
*/
|
76 |
self.onClickDownload = function() {
|
77 |
var $button = $( this ),
|
100 |
*
|
101 |
* This method downloads the first remote archive it finds.
|
102 |
*
|
103 |
+
* @since 1.6.0
|
104 |
*/
|
105 |
self.onClickDownloadFirst = function() {
|
106 |
var $downloadToServer = $body.find( '.download-to-server' ),
|
122 |
*
|
123 |
* These are the "Files & Folders" and "Database" tabs.
|
124 |
*
|
125 |
+
* @since 1.6.0
|
126 |
*/
|
127 |
self.onClickTab = function() {
|
128 |
var $dbElements = $( '[data-view-type="db"]' ),
|
admin/js/boldgrid-backup-admin-folder-exclude.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
*
|
4 |
* @summary JavaScript for handling Folder Exclude settings..
|
5 |
*
|
6 |
-
* @since 1.
|
7 |
*
|
8 |
* @param $ The jQuery object.
|
9 |
*/
|
@@ -72,7 +72,7 @@ BoldGrid.FolderExclude = function( $ ) {
|
|
72 |
/**
|
73 |
* @summary Handle the click of the pagination button.s
|
74 |
*
|
75 |
-
* @since 1.
|
76 |
*/
|
77 |
self.onClickPagination = function() {
|
78 |
var $a = $( this ),
|
@@ -96,7 +96,7 @@ BoldGrid.FolderExclude = function( $ ) {
|
|
96 |
/**
|
97 |
* @summary Handle the click of the preview button.
|
98 |
*
|
99 |
-
* @since 1.
|
100 |
*/
|
101 |
self.onClickPreview = function() {
|
102 |
var data = {
|
@@ -140,7 +140,7 @@ BoldGrid.FolderExclude = function( $ ) {
|
|
140 |
/**
|
141 |
* @summary Handle the click of one of the samples.
|
142 |
*
|
143 |
-
* @since 1.
|
144 |
*/
|
145 |
self.onClickSample = function() {
|
146 |
var $button = $( this ),
|
@@ -159,7 +159,7 @@ BoldGrid.FolderExclude = function( $ ) {
|
|
159 |
/**
|
160 |
* @summary Action to take when backup type has been changed.
|
161 |
*
|
162 |
-
* @since 1.
|
163 |
*/
|
164 |
self.onChangeType = function() {
|
165 |
self.toggleConfig();
|
@@ -176,7 +176,7 @@ BoldGrid.FolderExclude = function( $ ) {
|
|
176 |
* .current-page input, then we do nothing. Otherwise, we prevent default
|
177 |
* action and do the pagination.
|
178 |
*
|
179 |
-
* @since 1.
|
180 |
*/
|
181 |
self.onKeyDown = function( e ) {
|
182 |
var isCurrentPage = $( e.target ).hasClass( 'current-page' );
|
@@ -193,7 +193,7 @@ BoldGrid.FolderExclude = function( $ ) {
|
|
193 |
/**
|
194 |
* @summary Handle pagination.
|
195 |
*
|
196 |
-
* @since 1.
|
197 |
*/
|
198 |
self.onSubmitPagination = function() {
|
199 |
var page = parseInt( $excludeFoldersPreview.find( '.current-page' ).val() ),
|
@@ -214,7 +214,7 @@ BoldGrid.FolderExclude = function( $ ) {
|
|
214 |
* has typed into the filter box though, filteredList will be genereated
|
215 |
* based on the filtered values.
|
216 |
*
|
217 |
-
* @since 1.
|
218 |
*
|
219 |
* @todo Possibly move this toward a template system. For now, it works.
|
220 |
*
|
@@ -281,7 +281,7 @@ BoldGrid.FolderExclude = function( $ ) {
|
|
281 |
*
|
282 |
* @todo Possibly move this toward a template system. For now, it works.
|
283 |
*
|
284 |
-
* @since 1.
|
285 |
*
|
286 |
* @param int page
|
287 |
* @param int perPage
|
@@ -350,7 +350,7 @@ BoldGrid.FolderExclude = function( $ ) {
|
|
350 |
/**
|
351 |
* @summary Toggle display of everything after the "full" or "custom" options.
|
352 |
*
|
353 |
-
* @since 1.
|
354 |
*/
|
355 |
self.toggleConfig = function() {
|
356 |
var type = $type.filter( ':checked' ).val(),
|
3 |
*
|
4 |
* @summary JavaScript for handling Folder Exclude settings..
|
5 |
*
|
6 |
+
* @since 1.6.0
|
7 |
*
|
8 |
* @param $ The jQuery object.
|
9 |
*/
|
72 |
/**
|
73 |
* @summary Handle the click of the pagination button.s
|
74 |
*
|
75 |
+
* @since 1.6.0
|
76 |
*/
|
77 |
self.onClickPagination = function() {
|
78 |
var $a = $( this ),
|
96 |
/**
|
97 |
* @summary Handle the click of the preview button.
|
98 |
*
|
99 |
+
* @since 1.6.0
|
100 |
*/
|
101 |
self.onClickPreview = function() {
|
102 |
var data = {
|
140 |
/**
|
141 |
* @summary Handle the click of one of the samples.
|
142 |
*
|
143 |
+
* @since 1.6.0
|
144 |
*/
|
145 |
self.onClickSample = function() {
|
146 |
var $button = $( this ),
|
159 |
/**
|
160 |
* @summary Action to take when backup type has been changed.
|
161 |
*
|
162 |
+
* @since 1.6.0
|
163 |
*/
|
164 |
self.onChangeType = function() {
|
165 |
self.toggleConfig();
|
176 |
* .current-page input, then we do nothing. Otherwise, we prevent default
|
177 |
* action and do the pagination.
|
178 |
*
|
179 |
+
* @since 1.6.0
|
180 |
*/
|
181 |
self.onKeyDown = function( e ) {
|
182 |
var isCurrentPage = $( e.target ).hasClass( 'current-page' );
|
193 |
/**
|
194 |
* @summary Handle pagination.
|
195 |
*
|
196 |
+
* @since 1.6.0
|
197 |
*/
|
198 |
self.onSubmitPagination = function() {
|
199 |
var page = parseInt( $excludeFoldersPreview.find( '.current-page' ).val() ),
|
214 |
* has typed into the filter box though, filteredList will be genereated
|
215 |
* based on the filtered values.
|
216 |
*
|
217 |
+
* @since 1.6.0
|
218 |
*
|
219 |
* @todo Possibly move this toward a template system. For now, it works.
|
220 |
*
|
281 |
*
|
282 |
* @todo Possibly move this toward a template system. For now, it works.
|
283 |
*
|
284 |
+
* @since 1.6.0
|
285 |
*
|
286 |
* @param int page
|
287 |
* @param int perPage
|
350 |
/**
|
351 |
* @summary Toggle display of everything after the "full" or "custom" options.
|
352 |
*
|
353 |
+
* @since 1.6.0
|
354 |
*/
|
355 |
self.toggleConfig = function() {
|
356 |
var type = $type.filter( ':checked' ).val(),
|
admin/js/boldgrid-backup-admin-ftp-settings.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
*
|
4 |
* @summary JavaScript for handling FTP Settings page.
|
5 |
*
|
6 |
-
* @since 1.
|
7 |
*
|
8 |
* @param $ The jQuery object.
|
9 |
*/
|
@@ -38,7 +38,7 @@ BoldGrid.FtpSettings = function( $ ) {
|
|
38 |
/**
|
39 |
* @summary Action to take when form has been submitted.
|
40 |
*
|
41 |
-
* @since 1.
|
42 |
*/
|
43 |
self.onSubmit = function() {
|
44 |
$saveButton.attr( 'disabled', true );
|
@@ -51,7 +51,7 @@ BoldGrid.FtpSettings = function( $ ) {
|
|
51 |
/**
|
52 |
* @summary Action to take when type has been changed.
|
53 |
*
|
54 |
-
* @since 1.
|
55 |
*/
|
56 |
self.onTypeChange = function() {
|
57 |
var suggestedPort = lang.default_port[$type.val()];
|
3 |
*
|
4 |
* @summary JavaScript for handling FTP Settings page.
|
5 |
*
|
6 |
+
* @since 1.6.0
|
7 |
*
|
8 |
* @param $ The jQuery object.
|
9 |
*/
|
38 |
/**
|
39 |
* @summary Action to take when form has been submitted.
|
40 |
*
|
41 |
+
* @since 1.6.0
|
42 |
*/
|
43 |
self.onSubmit = function() {
|
44 |
$saveButton.attr( 'disabled', true );
|
51 |
/**
|
52 |
* @summary Action to take when type has been changed.
|
53 |
*
|
54 |
+
* @since 1.6.0
|
55 |
*/
|
56 |
self.onTypeChange = function() {
|
57 |
var suggestedPort = lang.default_port[$type.val()];
|
admin/js/boldgrid-backup-admin-home.js
CHANGED
@@ -126,7 +126,7 @@ BOLDGRID.BACKUP.HOME = function( $ ) {
|
|
126 |
/**
|
127 |
* @summary Action to take when a user clicks on a mine count.
|
128 |
*
|
129 |
-
* @since 1.
|
130 |
*/
|
131 |
self.onClickCount = function() {
|
132 |
var $anchor = $( this ),
|
126 |
/**
|
127 |
* @summary Action to take when a user clicks on a mine count.
|
128 |
*
|
129 |
+
* @since 1.6.0
|
130 |
*/
|
131 |
self.onClickCount = function() {
|
132 |
var $anchor = $( this ),
|
admin/js/boldgrid-backup-admin-settings.js
CHANGED
@@ -261,7 +261,7 @@ BoldGrid.Settings = function( $ ) {
|
|
261 |
/**
|
262 |
* Handle click of the undismissBoldgridNotice link for the key prompt.
|
263 |
*
|
264 |
-
* @since 1.
|
265 |
*/
|
266 |
self.undismissBoldgridNotice = function() {
|
267 |
var data, nonce, wpHttpReferer;
|
261 |
/**
|
262 |
* Handle click of the undismissBoldgridNotice link for the key prompt.
|
263 |
*
|
264 |
+
* @since 1.6.0
|
265 |
*/
|
266 |
self.undismissBoldgridNotice = function() {
|
267 |
var data, nonce, wpHttpReferer;
|
admin/js/boldgrid-backup-admin-table-include.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
*
|
4 |
* @summary JavaScript for handling Table include settings.
|
5 |
*
|
6 |
-
* @since 1.
|
7 |
*
|
8 |
* @param $ The jQuery object.
|
9 |
*/
|
@@ -32,7 +32,7 @@ BoldGrid.TableInclude = function( $ ) {
|
|
32 |
/**
|
33 |
* @summary Action to take when the type (full / custom) has been changed.
|
34 |
*
|
35 |
-
* @since 1.
|
36 |
*/
|
37 |
self.onChangeType = function() {
|
38 |
self.toggleConfig();
|
@@ -41,7 +41,7 @@ BoldGrid.TableInclude = function( $ ) {
|
|
41 |
/**
|
42 |
* @summary Toogle all database tables so they are all backed up.
|
43 |
*
|
44 |
-
* @since 1.
|
45 |
*/
|
46 |
self.toggleAll = function() {
|
47 |
$includeTables.bgbuDrawAttention();
|
@@ -54,7 +54,7 @@ BoldGrid.TableInclude = function( $ ) {
|
|
54 |
/**
|
55 |
* @summary Toggle the area that allows you to choose which tables to backup.
|
56 |
*
|
57 |
-
* @since 1.
|
58 |
*/
|
59 |
self.toggleConfig = function() {
|
60 |
var type = $type.filter( ':checked' ).val();
|
@@ -69,7 +69,7 @@ BoldGrid.TableInclude = function( $ ) {
|
|
69 |
/**
|
70 |
* @summary Deselect all tables.
|
71 |
*
|
72 |
-
* @since 1.
|
73 |
*/
|
74 |
self.toggleNone = function() {
|
75 |
$includeTables.bgbuDrawAttention();
|
@@ -82,7 +82,7 @@ BoldGrid.TableInclude = function( $ ) {
|
|
82 |
/**
|
83 |
* @summary Toogle the status that tells the user if they're backing up all tables.
|
84 |
*
|
85 |
-
* @since 1.
|
86 |
*/
|
87 |
self.toggleStatus = function() {
|
88 |
var allIncluded = $includeTables.length === $includeTables.filter( ':checked' ).length;
|
3 |
*
|
4 |
* @summary JavaScript for handling Table include settings.
|
5 |
*
|
6 |
+
* @since 1.6.0
|
7 |
*
|
8 |
* @param $ The jQuery object.
|
9 |
*/
|
32 |
/**
|
33 |
* @summary Action to take when the type (full / custom) has been changed.
|
34 |
*
|
35 |
+
* @since 1.6.0
|
36 |
*/
|
37 |
self.onChangeType = function() {
|
38 |
self.toggleConfig();
|
41 |
/**
|
42 |
* @summary Toogle all database tables so they are all backed up.
|
43 |
*
|
44 |
+
* @since 1.6.0
|
45 |
*/
|
46 |
self.toggleAll = function() {
|
47 |
$includeTables.bgbuDrawAttention();
|
54 |
/**
|
55 |
* @summary Toggle the area that allows you to choose which tables to backup.
|
56 |
*
|
57 |
+
* @since 1.6.0
|
58 |
*/
|
59 |
self.toggleConfig = function() {
|
60 |
var type = $type.filter( ':checked' ).val();
|
69 |
/**
|
70 |
* @summary Deselect all tables.
|
71 |
*
|
72 |
+
* @since 1.6.0
|
73 |
*/
|
74 |
self.toggleNone = function() {
|
75 |
$includeTables.bgbuDrawAttention();
|
82 |
/**
|
83 |
* @summary Toogle the status that tells the user if they're backing up all tables.
|
84 |
*
|
85 |
+
* @since 1.6.0
|
86 |
*/
|
87 |
self.toggleStatus = function() {
|
88 |
var allIncluded = $includeTables.length === $includeTables.filter( ':checked' ).length;
|
admin/js/boldgrid-backup-admin-zip-browser.js
CHANGED
@@ -92,7 +92,7 @@ BoldGrid.ZipBrowser = function( $ ) {
|
|
92 |
/**
|
93 |
* @summary Handle the click of the "load archive browser" button.
|
94 |
*
|
95 |
-
* @since 1.
|
96 |
*/
|
97 |
self.onClickLoadBrowser = function() {
|
98 |
$( this ).attr( 'disabled', 'disabled' );
|
@@ -103,7 +103,7 @@ BoldGrid.ZipBrowser = function( $ ) {
|
|
103 |
/**
|
104 |
* @summary Handle the click of the "restore this database" button.
|
105 |
*
|
106 |
-
* @since 1.
|
107 |
*/
|
108 |
self.onClickRestoreDb = function() {
|
109 |
var $a = $( this ),
|
@@ -140,7 +140,7 @@ BoldGrid.ZipBrowser = function( $ ) {
|
|
140 |
/**
|
141 |
* @summary Handle the postbox-like toggle on thead th's that hide a table.
|
142 |
*
|
143 |
-
* @since 1.
|
144 |
*/
|
145 |
self.onClickToggle = function() {
|
146 |
var $toggle = $( this ),
|
@@ -158,7 +158,7 @@ BoldGrid.ZipBrowser = function( $ ) {
|
|
158 |
/**
|
159 |
* @summary Handle the click of the "View details" button for a database.
|
160 |
*
|
161 |
-
* @since 1.
|
162 |
*/
|
163 |
self.onClickViewDb = function() {
|
164 |
var $a = $( this ),
|
92 |
/**
|
93 |
* @summary Handle the click of the "load archive browser" button.
|
94 |
*
|
95 |
+
* @since 1.6.0
|
96 |
*/
|
97 |
self.onClickLoadBrowser = function() {
|
98 |
$( this ).attr( 'disabled', 'disabled' );
|
103 |
/**
|
104 |
* @summary Handle the click of the "restore this database" button.
|
105 |
*
|
106 |
+
* @since 1.6.0
|
107 |
*/
|
108 |
self.onClickRestoreDb = function() {
|
109 |
var $a = $( this ),
|
140 |
/**
|
141 |
* @summary Handle the postbox-like toggle on thead th's that hide a table.
|
142 |
*
|
143 |
+
* @since 1.6.0
|
144 |
*/
|
145 |
self.onClickToggle = function() {
|
146 |
var $toggle = $( this ),
|
158 |
/**
|
159 |
* @summary Handle the click of the "View details" button for a database.
|
160 |
*
|
161 |
+
* @since 1.6.0
|
162 |
*/
|
163 |
self.onClickViewDb = function() {
|
164 |
var $a = $( this ),
|
admin/js/boldgrid-backup-admin.js
CHANGED
@@ -57,7 +57,7 @@ BoldGrid.Backup = function( $ ) {
|
|
57 |
* # <a href="" data-toggle-target="#more_info">Show</a>
|
58 |
* # <div id="more_info" class="hidden">
|
59 |
*
|
60 |
-
* @since 1.
|
61 |
*/
|
62 |
self.onClickToggle = function() {
|
63 |
var $e = $( this ),
|
@@ -214,7 +214,7 @@ BoldGrid.Backup( jQuery );
|
|
214 |
/**
|
215 |
* @summary Draw attention to an element.
|
216 |
*
|
217 |
-
* @since 1.
|
218 |
*/
|
219 |
jQuery.fn.bgbuDrawAttention = function() {
|
220 |
var currentColor,
|
@@ -262,7 +262,7 @@ jQuery.fn.bgbuDrawAttention = function() {
|
|
262 |
* For example, if we click "restore" on a page, we want to disable all other
|
263 |
* actions within the wpwrap (IE can't restore and delete at the same time).
|
264 |
*
|
265 |
-
* @since 1.
|
266 |
*/
|
267 |
jQuery.fn.bgbuDisableActions = function() {
|
268 |
this.find( 'a, [type="submit"]' ).attr( 'disabled', 'disabled' );
|
57 |
* # <a href="" data-toggle-target="#more_info">Show</a>
|
58 |
* # <div id="more_info" class="hidden">
|
59 |
*
|
60 |
+
* @since 1.6.0
|
61 |
*/
|
62 |
self.onClickToggle = function() {
|
63 |
var $e = $( this ),
|
214 |
/**
|
215 |
* @summary Draw attention to an element.
|
216 |
*
|
217 |
+
* @since 1.6.0
|
218 |
*/
|
219 |
jQuery.fn.bgbuDrawAttention = function() {
|
220 |
var currentColor,
|
262 |
* For example, if we click "restore" on a page, we want to disable all other
|
263 |
* actions within the wpwrap (IE can't restore and delete at the same time).
|
264 |
*
|
265 |
+
* @since 1.6.0
|
266 |
*/
|
267 |
jQuery.fn.bgbuDisableActions = function() {
|
268 |
this.find( 'a, [type="submit"]' ).attr( 'disabled', 'disabled' );
|
admin/partials/archive-details/browser-entry.php
CHANGED
@@ -1,15 +1,20 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Create the <tr> for each file in the archilve.
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.5.3
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin/partials/archive-details
|
|
|
|
|
|
|
10 |
*/
|
11 |
|
12 |
-
defined( 'WPINC' )
|
13 |
|
14 |
$class = $file['folder'] ? 'folder' : 'file';
|
15 |
|
@@ -45,5 +50,3 @@ return sprintf(
|
|
45 |
$size,
|
46 |
$this->core->time->get_span()
|
47 |
);
|
48 |
-
|
49 |
-
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: browser-entry.php
|
4 |
+
*
|
5 |
* Create the <tr> for each file in the archilve.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.5.3
|
9 |
*
|
10 |
* @package Boldgrid_Backup
|
11 |
* @subpackage Boldgrid_Backup/admin/partials/archive-details
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
defined( 'WPINC' ) || die;
|
18 |
|
19 |
$class = $file['folder'] ? 'folder' : 'file';
|
20 |
|
50 |
$size,
|
51 |
$this->core->time->get_span()
|
52 |
);
|
|
|
|
admin/partials/archive-details/browser.php
CHANGED
@@ -1,15 +1,20 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Display the Archive Browser section on the Archive Details page.
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.5.3
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin/partials/archive-details
|
|
|
|
|
|
|
10 |
*/
|
11 |
|
12 |
-
defined( 'WPINC' )
|
13 |
|
14 |
$browser = '
|
15 |
<div id="zip_browser" class="hidden" data-view-type="file">
|
@@ -23,9 +28,6 @@ $browser = '
|
|
23 |
</tbody>
|
24 |
</table>
|
25 |
</div>
|
26 |
-
</div>'
|
27 |
-
;
|
28 |
|
29 |
return $browser;
|
30 |
-
|
31 |
-
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: browser.php
|
4 |
+
*
|
5 |
* Display the Archive Browser section on the Archive Details page.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.5.3
|
9 |
*
|
10 |
* @package Boldgrid_Backup
|
11 |
* @subpackage Boldgrid_Backup/admin/partials/archive-details
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
defined( 'WPINC' ) || die;
|
18 |
|
19 |
$browser = '
|
20 |
<div id="zip_browser" class="hidden" data-view-type="file">
|
28 |
</tbody>
|
29 |
</table>
|
30 |
</div>
|
31 |
+
</div>';
|
|
|
32 |
|
33 |
return $browser;
|
|
|
|
admin/partials/archive-details/db.php
CHANGED
@@ -1,15 +1,20 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Display the Database section on the Archive Details page.
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since 1.
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin/partials/archive-details
|
|
|
|
|
|
|
10 |
*/
|
11 |
|
12 |
-
defined( 'WPINC' )
|
13 |
|
14 |
$db = array(
|
15 |
'browser' => '',
|
@@ -17,20 +22,28 @@ $db = array(
|
|
17 |
);
|
18 |
|
19 |
if ( empty( $dump_file ) ) {
|
20 |
-
$db['browser'] = sprintf(
|
|
|
21 |
<div class="hidden" data-view-type="db">
|
22 |
<p>%1$s</p>
|
23 |
</div>',
|
24 |
__( 'This archive does not contain a database backup.', 'boldgrid-backup' )
|
25 |
);
|
|
|
26 |
return $db;
|
27 |
}
|
28 |
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
30 |
$basename = basename( $dump_file );
|
31 |
|
32 |
$db = array(
|
33 |
-
'browser' => sprintf(
|
|
|
34 |
<div class="hidden" data-view-type="db">
|
35 |
<input type="hidden" id="dump_filename" value="%1$s" />
|
36 |
<div id="db_details" data-rendered="false"></div>
|
@@ -46,5 +59,3 @@ $db = array(
|
|
46 |
);
|
47 |
|
48 |
return $db;
|
49 |
-
|
50 |
-
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: db.php
|
4 |
+
*
|
5 |
* Display the Database section on the Archive Details page.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
+
* @since 1.6.0
|
9 |
*
|
10 |
* @package Boldgrid_Backup
|
11 |
* @subpackage Boldgrid_Backup/admin/partials/archive-details
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
defined( 'WPINC' ) || die;
|
18 |
|
19 |
$db = array(
|
20 |
'browser' => '',
|
22 |
);
|
23 |
|
24 |
if ( empty( $dump_file ) ) {
|
25 |
+
$db['browser'] = sprintf(
|
26 |
+
'
|
27 |
<div class="hidden" data-view-type="db">
|
28 |
<p>%1$s</p>
|
29 |
</div>',
|
30 |
__( 'This archive does not contain a database backup.', 'boldgrid-backup' )
|
31 |
);
|
32 |
+
|
33 |
return $db;
|
34 |
}
|
35 |
|
36 |
+
// translators: 1: Backup archive filename.
|
37 |
+
$contains = esc_html__(
|
38 |
+
'This archive contains the following database backup: <strong>%1$s</strong>',
|
39 |
+
'boldgrid-backup'
|
40 |
+
);
|
41 |
+
|
42 |
$basename = basename( $dump_file );
|
43 |
|
44 |
$db = array(
|
45 |
+
'browser' => sprintf(
|
46 |
+
'
|
47 |
<div class="hidden" data-view-type="db">
|
48 |
<input type="hidden" id="dump_filename" value="%1$s" />
|
49 |
<div id="db_details" data-rendered="false"></div>
|
59 |
);
|
60 |
|
61 |
return $db;
|
|
|
|
admin/partials/archive-details/details.php
CHANGED
@@ -1,16 +1,22 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Render the details of a particular backup.
|
4 |
*
|
5 |
-
* @
|
|
|
6 |
*
|
7 |
* @package Boldgrid_Backup
|
8 |
-
* @subpackage Boldgrid_Backup/admin/partials
|
|
|
|
|
|
|
9 |
*
|
10 |
* @param bool $archive_found Whether or not the archive was found.
|
11 |
*/
|
12 |
|
13 |
-
defined( 'WPINC' )
|
14 |
|
15 |
$details = '';
|
16 |
|
@@ -18,39 +24,39 @@ $attribute = '<p><strong>%1$s</strong>: %2$s</p>';
|
|
18 |
|
19 |
$datas = array(
|
20 |
array(
|
21 |
-
'key'
|
22 |
'title' => __( 'Backup triggered by', 'boldgrid-backup' ),
|
23 |
),
|
24 |
array(
|
25 |
-
'key'
|
26 |
'title' => __( 'Compressor', 'boldgrid-backup' ),
|
27 |
),
|
28 |
array(
|
29 |
-
'key'
|
30 |
-
'title'
|
31 |
'suffix' => ' ' . __( 'seconds', 'boldgrid-backup' ),
|
32 |
),
|
33 |
array(
|
34 |
-
'key'
|
35 |
-
'title'
|
36 |
'suffix' => ' ' . __( 'seconds', 'boldgrid-backup' ),
|
37 |
),
|
38 |
array(
|
39 |
-
'key'
|
40 |
-
'title'
|
41 |
'presentation' => 'bool',
|
42 |
),
|
43 |
array(
|
44 |
-
'key'
|
45 |
'title' => __( 'Files included', 'boldgrid-backup' ),
|
46 |
),
|
47 |
array(
|
48 |
-
'key'
|
49 |
'title' => __( 'Files excluded', 'boldgrid-backup' ),
|
50 |
),
|
51 |
array(
|
52 |
-
'key'
|
53 |
-
'title'
|
54 |
'presentation' => 'comma_implode',
|
55 |
),
|
56 |
);
|
@@ -91,5 +97,3 @@ foreach ( $datas as $data ) {
|
|
91 |
}
|
92 |
|
93 |
return $details;
|
94 |
-
|
95 |
-
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: details.php
|
4 |
+
*
|
5 |
* Render the details of a particular backup.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
+
* @since 1.6.0
|
9 |
*
|
10 |
* @package Boldgrid_Backup
|
11 |
+
* @subpackage Boldgrid_Backup/admin/partials/archive-details
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*
|
16 |
* @param bool $archive_found Whether or not the archive was found.
|
17 |
*/
|
18 |
|
19 |
+
defined( 'WPINC' ) || die;
|
20 |
|
21 |
$details = '';
|
22 |
|
24 |
|
25 |
$datas = array(
|
26 |
array(
|
27 |
+
'key' => 'trigger',
|
28 |
'title' => __( 'Backup triggered by', 'boldgrid-backup' ),
|
29 |
),
|
30 |
array(
|
31 |
+
'key' => 'compressor',
|
32 |
'title' => __( 'Compressor', 'boldgrid-backup' ),
|
33 |
),
|
34 |
array(
|
35 |
+
'key' => 'duration',
|
36 |
+
'title' => __( 'Total duration', 'boldgrid-backup' ),
|
37 |
'suffix' => ' ' . __( 'seconds', 'boldgrid-backup' ),
|
38 |
),
|
39 |
array(
|
40 |
+
'key' => 'db_duration',
|
41 |
+
'title' => __( 'Time to backup database', 'boldgrid-backup' ),
|
42 |
'suffix' => ' ' . __( 'seconds', 'boldgrid-backup' ),
|
43 |
),
|
44 |
array(
|
45 |
+
'key' => 'mail_success',
|
46 |
+
'title' => __( 'Email sent after backup', 'boldgrid-backup' ),
|
47 |
'presentation' => 'bool',
|
48 |
),
|
49 |
array(
|
50 |
+
'key' => 'folder_include',
|
51 |
'title' => __( 'Files included', 'boldgrid-backup' ),
|
52 |
),
|
53 |
array(
|
54 |
+
'key' => 'folder_exclude',
|
55 |
'title' => __( 'Files excluded', 'boldgrid-backup' ),
|
56 |
),
|
57 |
array(
|
58 |
+
'key' => 'table_exclude',
|
59 |
+
'title' => __( 'Database tables excluded', 'boldgrid-backup' ),
|
60 |
'presentation' => 'comma_implode',
|
61 |
),
|
62 |
);
|
97 |
}
|
98 |
|
99 |
return $details;
|
|
|
|
admin/partials/archive-details/not-found.php
CHANGED
@@ -1,16 +1,20 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Display for instances in which backup is not local and not remote.
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.6.0
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin/partials/archive-details
|
|
|
|
|
|
|
10 |
*/
|
11 |
|
12 |
-
defined( 'WPINC' )
|
13 |
-
|
14 |
-
return '<p>' . $this->core->lang['icon_warning'] . __( 'Backup file not found!', 'boldgrid-backup' ) . '</p>';
|
15 |
-
|
16 |
|
|
|
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: not-found.php
|
4 |
+
*
|
5 |
* Display for instances in which backup is not local and not remote.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.6.0
|
9 |
*
|
10 |
* @package Boldgrid_Backup
|
11 |
* @subpackage Boldgrid_Backup/admin/partials/archive-details
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
defined( 'WPINC' ) || die;
|
|
|
|
|
|
|
18 |
|
19 |
+
return '<p>' . $this->core->lang['icon_warning'] .
|
20 |
+
__( 'Backup file not found!', 'boldgrid-backup' ) . '</p>';
|
admin/partials/archive-details/only-remote.php
CHANGED
@@ -1,17 +1,23 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Display for instances in which backup is not local, but exists remotely.
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since 1.
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin/partials/archive-details
|
|
|
|
|
|
|
10 |
*/
|
11 |
|
12 |
-
defined( 'WPINC' )
|
13 |
|
14 |
-
return sprintf(
|
|
|
15 |
<p>
|
16 |
%1$s <span class="dashicons dashicons-editor-help" data-id="help-web-server"></span>
|
17 |
</p>
|
@@ -24,9 +30,11 @@ return sprintf( '
|
|
24 |
'<a class="button button-primary" id="download_first">Download to web server</a>',
|
25 |
$this->core->lang['spinner'],
|
26 |
sprintf(
|
27 |
-
|
|
|
|
|
|
|
|
|
28 |
'admin.php?page=boldgrid-backup-tools§ion=section_locations'
|
29 |
)
|
30 |
);
|
31 |
-
|
32 |
-
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: only-remote.php
|
4 |
+
*
|
5 |
* Display for instances in which backup is not local, but exists remotely.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
+
* @since 1.6.0
|
9 |
*
|
10 |
* @package Boldgrid_Backup
|
11 |
* @subpackage Boldgrid_Backup/admin/partials/archive-details
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
defined( 'WPINC' ) || die;
|
18 |
|
19 |
+
return sprintf(
|
20 |
+
'
|
21 |
<p>
|
22 |
%1$s <span class="dashicons dashicons-editor-help" data-id="help-web-server"></span>
|
23 |
</p>
|
30 |
'<a class="button button-primary" id="download_first">Download to web server</a>',
|
31 |
$this->core->lang['spinner'],
|
32 |
sprintf(
|
33 |
+
// translators: 1: Link.
|
34 |
+
esc_html__(
|
35 |
+
'After your backup has been downloaded to the web server, this page will refresh and you will see more options available. To learn more about your web server vs. remote storage providers, <a href="%1$s">click here</a>.',
|
36 |
+
'boldgrid-backup'
|
37 |
+
),
|
38 |
'admin.php?page=boldgrid-backup-tools§ion=section_locations'
|
39 |
)
|
40 |
);
|
|
|
|
admin/partials/archive-details/remote-storage.php
CHANGED
@@ -1,14 +1,25 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Render remote provider's table on archive details page.
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
*
|
5 |
-
*
|
6 |
-
*
|
|
|
|
|
|
|
7 |
*
|
8 |
* @param bool $archive_found Whether or not the archive was found.
|
9 |
*/
|
10 |
|
11 |
-
defined( 'WPINC' )
|
12 |
|
13 |
$data['postbox'] = '';
|
14 |
|
@@ -31,7 +42,8 @@ foreach ( $this->remote_storage_li as $provider ) {
|
|
31 |
// Generate a link to "download to server" from remote provider.
|
32 |
$download = '';
|
33 |
if ( ! $archive_found && $provider['uploaded'] ) {
|
34 |
-
$download = sprintf(
|
|
|
35 |
<a class="button download-to-server" data-provider-id="%3$s">%1$s</a>
|
36 |
%2$s
|
37 |
',
|
@@ -49,13 +61,23 @@ foreach ( $this->remote_storage_li as $provider ) {
|
|
49 |
__( 'Upload', 'boldgrid-backup' ),
|
50 |
$provider['id']
|
51 |
);
|
52 |
-
} elseif ( isset( $provider['is_setup'] )
|
53 |
-
$upload = sprintf(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
} else {
|
55 |
$upload = '';
|
56 |
}
|
57 |
|
58 |
-
$data['postbox'] .= sprintf(
|
|
|
59 |
%5$s
|
60 |
<div data-remote-provider="%3$s">
|
61 |
<span style="float:left;" %6$s><strong>%1$s</strong></span>
|
@@ -76,5 +98,3 @@ foreach ( $this->remote_storage_li as $provider ) {
|
|
76 |
}
|
77 |
|
78 |
return $data;
|
79 |
-
|
80 |
-
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: remote-storage.php
|
4 |
+
*
|
5 |
* Render remote provider's table on archive details page.
|
6 |
+
* This file is included by:
|
7 |
+
* admin/partials/boldgrid-backup-admin-archive-details.php
|
8 |
+
* admin/class-boldgrid-backup-admin-archive-details.php
|
9 |
+
*
|
10 |
+
* @link https://www.boldgrid.com
|
11 |
+
* @since 1.5.2
|
12 |
*
|
13 |
+
* @package Boldgrid_Backup
|
14 |
+
* @subpackage Boldgrid_Backup/admin/partials/archive-details
|
15 |
+
* @copyright BoldGrid
|
16 |
+
* @version $Id$
|
17 |
+
* @author BoldGrid <support@boldgrid.com>
|
18 |
*
|
19 |
* @param bool $archive_found Whether or not the archive was found.
|
20 |
*/
|
21 |
|
22 |
+
defined( 'WPINC' ) || die;
|
23 |
|
24 |
$data['postbox'] = '';
|
25 |
|
42 |
// Generate a link to "download to server" from remote provider.
|
43 |
$download = '';
|
44 |
if ( ! $archive_found && $provider['uploaded'] ) {
|
45 |
+
$download = sprintf(
|
46 |
+
'
|
47 |
<a class="button download-to-server" data-provider-id="%3$s">%1$s</a>
|
48 |
%2$s
|
49 |
',
|
61 |
__( 'Upload', 'boldgrid-backup' ),
|
62 |
$provider['id']
|
63 |
);
|
64 |
+
} elseif ( isset( $provider['is_setup'] ) && false === $provider['is_setup'] ) {
|
65 |
+
$upload = sprintf(
|
66 |
+
// translators: 1: HTML anchor open tag, 2: HTML anchor close tag, 3: Provider title.
|
67 |
+
esc_html__(
|
68 |
+
'Please go to your %1$ssettings page%2$s to configure %3$s.',
|
69 |
+
'boldgrid-backup'
|
70 |
+
),
|
71 |
+
'<a target="_parent" href="admin.php?page=boldgrid-backup-settings">',
|
72 |
+
'</a>',
|
73 |
+
$provider['title']
|
74 |
+
);
|
75 |
} else {
|
76 |
$upload = '';
|
77 |
}
|
78 |
|
79 |
+
$data['postbox'] .= sprintf(
|
80 |
+
'
|
81 |
%5$s
|
82 |
<div data-remote-provider="%3$s">
|
83 |
<span style="float:left;" %6$s><strong>%1$s</strong></span>
|
98 |
}
|
99 |
|
100 |
return $data;
|
|
|
|
admin/partials/archives/add-new.php
CHANGED
@@ -1,30 +1,35 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
|
|
5 |
* It follows the same structure as the "Upload Plugin" section of plugins.
|
6 |
*
|
|
|
7 |
* @since 1.5.1
|
8 |
*
|
9 |
* @package Boldgrid_Backup
|
10 |
* @subpackage Boldgrid_Backup/admin/partials/archives
|
|
|
|
|
|
|
11 |
*/
|
12 |
|
13 |
-
defined( 'WPINC' )
|
14 |
|
15 |
$max_file_size = Boldgrid_Backup_Admin_Utility::get_upload_limit();
|
16 |
|
17 |
-
$size_limit =
|
18 |
Boldgrid_Backup_Admin_Utility::bytes_to_human(
|
19 |
Boldgrid_Backup_Admin_Utility::get_upload_limit()
|
20 |
);
|
21 |
|
22 |
-
$size_info =
|
23 |
'To change the limit, you may be able to modify your server\'s php.ini or .htaccess file. Please ask your web hosting provider if you need assistance.',
|
24 |
'boldgrid-backup'
|
25 |
);
|
26 |
|
27 |
-
$upload_info =
|
28 |
'You can upload a backup file that was created with BoldGrid Backup.
|
29 |
If you choose to restore an uploaded file from a different web location (URL), then we will try to ensure that references to URL address are updated.
|
30 |
There may be times when some items may need to be updated manually.',
|
@@ -32,7 +37,8 @@ $upload_info = esc_html__(
|
|
32 |
);
|
33 |
|
34 |
$backup_id_notice = sprintf(
|
35 |
-
|
|
|
36 |
'Your BoldGrid Backup id is %3$s. This backup id is used to determine if a backup archive file is associated with this WordPress installation.
|
37 |
Manually uploaded archive files must have filenames starting with "%2$s", contain the BoldGrid Backup id "%3$s", and end with "%4$s", to be recognized.%1$s%1$s
|
38 |
For example: %5$s%1$s%1$s
|
@@ -57,12 +63,19 @@ $backup_id_notice = sprintf(
|
|
57 |
</p>
|
58 |
|
59 |
<p class="help wp-upload-form" data-id="upload-backup">
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
</p>
|
62 |
|
63 |
<div id="upload-archive-section" class="wp-upload-form">
|
64 |
<form id="upload-archive-form" method="POST" enctype="multipart/form-data">
|
65 |
-
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>" />
|
66 |
<input type="hidden" name="uploading" value="1" />
|
67 |
<?php wp_nonce_field( 'upload_archive_file' ); ?>
|
68 |
<input name="file" type="file" />
|
@@ -71,11 +84,11 @@ $backup_id_notice = sprintf(
|
|
71 |
</form>
|
72 |
|
73 |
<p id="file_too_large" class="hidden">
|
74 |
-
<span class="dashicons dashicons-warning yellow"></span> <?php
|
75 |
</p>
|
76 |
|
77 |
<p id="bad_extension" class="hidden">
|
78 |
-
<span class="dashicons dashicons-warning yellow"></span> <?php
|
79 |
</p>
|
80 |
</div>
|
81 |
|
@@ -85,7 +98,7 @@ $backup_id_notice = sprintf(
|
|
85 |
</p>
|
86 |
|
87 |
<div class="help wp-upload-form" data-id="backup-id">
|
88 |
-
<?php echo $backup_id_notice; ?>
|
89 |
</div>
|
90 |
|
91 |
</div>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: add-new.php
|
4 |
*
|
5 |
+
* This file contains the markup necessary to upload a new backup archive.
|
6 |
* It follows the same structure as the "Upload Plugin" section of plugins.
|
7 |
*
|
8 |
+
* @link https://www.boldgrid.com
|
9 |
* @since 1.5.1
|
10 |
*
|
11 |
* @package Boldgrid_Backup
|
12 |
* @subpackage Boldgrid_Backup/admin/partials/archives
|
13 |
+
* @copyright BoldGrid
|
14 |
+
* @version $Id$
|
15 |
+
* @author BoldGrid <support@boldgrid.com>
|
16 |
*/
|
17 |
|
18 |
+
defined( 'WPINC' ) || die;
|
19 |
|
20 |
$max_file_size = Boldgrid_Backup_Admin_Utility::get_upload_limit();
|
21 |
|
22 |
+
$size_limit = __( 'File size limit', 'boldgrid-backup' ) . ': ' .
|
23 |
Boldgrid_Backup_Admin_Utility::bytes_to_human(
|
24 |
Boldgrid_Backup_Admin_Utility::get_upload_limit()
|
25 |
);
|
26 |
|
27 |
+
$size_info = __(
|
28 |
'To change the limit, you may be able to modify your server\'s php.ini or .htaccess file. Please ask your web hosting provider if you need assistance.',
|
29 |
'boldgrid-backup'
|
30 |
);
|
31 |
|
32 |
+
$upload_info = __(
|
33 |
'You can upload a backup file that was created with BoldGrid Backup.
|
34 |
If you choose to restore an uploaded file from a different web location (URL), then we will try to ensure that references to URL address are updated.
|
35 |
There may be times when some items may need to be updated manually.',
|
37 |
);
|
38 |
|
39 |
$backup_id_notice = sprintf(
|
40 |
+
// translators: 1: HTML tag, 2: Filename part, 3: Backup identifier, 4: File extension, 5: Archive filename, 6: Backup directory path.
|
41 |
+
__(
|
42 |
'Your BoldGrid Backup id is %3$s. This backup id is used to determine if a backup archive file is associated with this WordPress installation.
|
43 |
Manually uploaded archive files must have filenames starting with "%2$s", contain the BoldGrid Backup id "%3$s", and end with "%4$s", to be recognized.%1$s%1$s
|
44 |
For example: %5$s%1$s%1$s
|
63 |
</p>
|
64 |
|
65 |
<p class="help wp-upload-form" data-id="upload-backup">
|
66 |
+
<?php
|
67 |
+
printf(
|
68 |
+
'%1$s<br />%2$s<br /><br />%3$s',
|
69 |
+
esc_html( $size_limit ),
|
70 |
+
esc_html( $size_info ),
|
71 |
+
esc_html( $upload_info )
|
72 |
+
);
|
73 |
+
?>
|
74 |
</p>
|
75 |
|
76 |
<div id="upload-archive-section" class="wp-upload-form">
|
77 |
<form id="upload-archive-form" method="POST" enctype="multipart/form-data">
|
78 |
+
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo esc_attr( $max_file_size ); ?>" />
|
79 |
<input type="hidden" name="uploading" value="1" />
|
80 |
<?php wp_nonce_field( 'upload_archive_file' ); ?>
|
81 |
<input name="file" type="file" />
|
84 |
</form>
|
85 |
|
86 |
<p id="file_too_large" class="hidden">
|
87 |
+
<span class="dashicons dashicons-warning yellow"></span> <?php esc_html_e( 'The file you selected is too large.', 'boldgrid-bacup' ); ?>
|
88 |
</p>
|
89 |
|
90 |
<p id="bad_extension" class="hidden">
|
91 |
+
<span class="dashicons dashicons-warning yellow"></span> <?php esc_html_e( 'Invalid file format. Please choose a .zip file.', 'boldgrid-bacup' ); ?>
|
92 |
</p>
|
93 |
</div>
|
94 |
|
98 |
</p>
|
99 |
|
100 |
<div class="help wp-upload-form" data-id="backup-id">
|
101 |
+
<?php echo $backup_id_notice; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>
|
102 |
</div>
|
103 |
|
104 |
</div>
|
admin/partials/archives/note-pre-backup.php
CHANGED
@@ -1,34 +1,47 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Display a note for the user next to the "Backup Site Now" button.
|
4 |
*
|
|
|
5 |
* @since 1.3
|
6 |
*
|
7 |
* @package Boldgrid_Backup
|
8 |
* @subpackage Boldgrid_Backup/admin/partials/archives
|
|
|
|
|
|
|
9 |
*/
|
10 |
|
11 |
-
defined( 'WPINC' )
|
12 |
?>
|
13 |
|
14 |
<p id='note-pre-backup'>
|
15 |
<?php
|
|
|
16 |
/*
|
17 |
* Print this text:
|
18 |
*
|
19 |
* Note: Backups use resources and <a>must pause your site</a> momentarily. Use sparingly.
|
20 |
*/
|
21 |
-
|
22 |
wp_kses(
|
23 |
-
|
|
|
|
|
|
|
|
|
24 |
array(
|
25 |
-
'a'
|
|
|
|
|
|
|
26 |
'strong' => array(),
|
27 |
-
|
28 |
),
|
29 |
esc_url( $this->configs['urls']['resource_usage'] )
|
30 |
);
|
31 |
-
echo $link;
|
32 |
|
33 |
/*
|
34 |
* Print this text:
|
@@ -38,18 +51,21 @@ defined( 'WPINC' ) ? : die;
|
|
38 |
* make room for your new backup. We recommend you download a backup to your local computer.
|
39 |
*/
|
40 |
if ( count( $archives ) >= $settings['retention_count'] ) {
|
41 |
-
|
42 |
wp_kses(
|
43 |
-
|
|
|
|
|
|
|
|
|
44 |
array(
|
45 |
'a' => array( 'href' => array() ),
|
46 |
)
|
47 |
),
|
48 |
count( $archives ),
|
49 |
-
$settings['retention_count'],
|
50 |
-
get_admin_url( null, 'admin.php?page=boldgrid-backup-settings' )
|
51 |
);
|
52 |
-
echo $link;
|
53 |
}
|
54 |
-
?>
|
55 |
</p>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: note-pre-backup.php
|
4 |
+
*
|
5 |
* Display a note for the user next to the "Backup Site Now" button.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.3
|
9 |
*
|
10 |
* @package Boldgrid_Backup
|
11 |
* @subpackage Boldgrid_Backup/admin/partials/archives
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
defined( 'WPINC' ) || die;
|
18 |
?>
|
19 |
|
20 |
<p id='note-pre-backup'>
|
21 |
<?php
|
22 |
+
|
23 |
/*
|
24 |
* Print this text:
|
25 |
*
|
26 |
* Note: Backups use resources and <a>must pause your site</a> momentarily. Use sparingly.
|
27 |
*/
|
28 |
+
printf(
|
29 |
wp_kses(
|
30 |
+
// translators: 1: URL address.
|
31 |
+
__(
|
32 |
+
'<strong>Note</strong>: Backups use resources and <a href="%s" target="_blank">must pause your site</a> momentarily. Use sparingly. ',
|
33 |
+
'boldgrid-backup'
|
34 |
+
),
|
35 |
array(
|
36 |
+
'a' => array(
|
37 |
+
'href' => array(),
|
38 |
+
'target' => array(),
|
39 |
+
),
|
40 |
'strong' => array(),
|
41 |
+
)
|
42 |
),
|
43 |
esc_url( $this->configs['urls']['resource_usage'] )
|
44 |
);
|
|
|
45 |
|
46 |
/*
|
47 |
* Print this text:
|
51 |
* make room for your new backup. We recommend you download a backup to your local computer.
|
52 |
*/
|
53 |
if ( count( $archives ) >= $settings['retention_count'] ) {
|
54 |
+
printf(
|
55 |
wp_kses(
|
56 |
+
// translators: 1: Archive count, 2: Retention limit, 3: URL address.
|
57 |
+
__(
|
58 |
+
'You currently have %1$s backups stored on your server, and your <a href="%3$s">backup settings</a> are only configured to store %2$s. Backing up your site now will delete your oldest backup to make room for your new backup. We recommend you download a backup to your local computer.',
|
59 |
+
'boldgrid-backup'
|
60 |
+
),
|
61 |
array(
|
62 |
'a' => array( 'href' => array() ),
|
63 |
)
|
64 |
),
|
65 |
count( $archives ),
|
66 |
+
esc_html( $settings['retention_count'] ),
|
67 |
+
esc_url( get_admin_url( null, 'admin.php?page=boldgrid-backup-settings' ) )
|
68 |
);
|
|
|
69 |
}
|
70 |
+
?>
|
71 |
</p>
|
admin/partials/boldgrid-backup-admin-archive-details.php
CHANGED
@@ -1,18 +1,24 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* This file contains renders the details page of a backup archive.
|
4 |
*
|
|
|
5 |
* @since 1.5.1
|
6 |
*
|
7 |
* @package Boldgrid_Backup
|
8 |
* @subpackage Boldgrid_Backup/admin/partials
|
|
|
|
|
|
|
9 |
*
|
10 |
* @param bool $archive_found Whether or not the archive was found.
|
11 |
* @param array $archive An array of details about the archive, similar to
|
12 |
* the $info created during archiving.
|
13 |
*/
|
14 |
|
15 |
-
defined( 'WPINC' )
|
16 |
|
17 |
wp_enqueue_style( 'editor-buttons' );
|
18 |
|
@@ -20,23 +26,23 @@ wp_nonce_field( 'boldgrid_backup_remote_storage_upload' );
|
|
20 |
|
21 |
$separator = '<hr class="separator">';
|
22 |
|
23 |
-
$details
|
24 |
$remote_storage = include BOLDGRID_BACKUP_PATH . '/admin/partials/archive-details/remote-storage.php';
|
25 |
-
$browser
|
26 |
-
$db
|
27 |
|
28 |
// Special situations where the backup file is not local and/or remote.
|
29 |
$only_remote = include BOLDGRID_BACKUP_PATH . '/admin/partials/archive-details/only-remote.php';
|
30 |
-
$not_found
|
31 |
|
32 |
-
$delete_link
|
33 |
$download_button = $this->core->archive_actions->get_download_button( $archive['filename'] );
|
34 |
-
$restore_button
|
35 |
|
36 |
if ( ! $archive_found ) {
|
37 |
-
$file_size
|
38 |
-
$backup_date
|
39 |
-
$more_info
|
40 |
$major_actions = '';
|
41 |
} else {
|
42 |
$file_size = sprintf(
|
@@ -53,7 +59,8 @@ if ( ! $archive_found ) {
|
|
53 |
$this->core->time->get_span()
|
54 |
);
|
55 |
|
56 |
-
$more_info = empty( $details ) ? '' : sprintf(
|
|
|
57 |
<div class="misc-pub-section">
|
58 |
More info <a href="" data-toggle-target="#more_info">Show</a>
|
59 |
<div id="more_info" class="hidden">
|
@@ -64,7 +71,8 @@ if ( ! $archive_found ) {
|
|
64 |
$details
|
65 |
);
|
66 |
|
67 |
-
$major_actions = sprintf(
|
|
|
68 |
<div id="major-publishing-actions">
|
69 |
<div id="delete-action">
|
70 |
%1$s
|
@@ -76,7 +84,8 @@ if ( ! $archive_found ) {
|
|
76 |
);
|
77 |
}
|
78 |
|
79 |
-
$main_meta_box = sprintf(
|
|
|
80 |
<div id="submitdiv" class="postbox">
|
81 |
<h2 class="hndle ui-sortable-handle"><span>%1$s</span></h2>
|
82 |
<div class="inside submitbox">
|
@@ -102,7 +111,8 @@ $main_meta_box = sprintf( '
|
|
102 |
/* 7 */ $major_actions
|
103 |
);
|
104 |
|
105 |
-
$remote_meta_box = sprintf(
|
|
|
106 |
<div class="postbox remote-storage">
|
107 |
<h2 class="hndle ui-sortable-handle">
|
108 |
<span>%1$s</span>
|
@@ -120,7 +130,8 @@ $remote_meta_box = sprintf( '
|
|
120 |
</div>',
|
121 |
/* 1 */ __( 'Remote Storage', 'boldgrid-backup' ),
|
122 |
/* 2 */ $remote_storage['postbox'],
|
123 |
-
/* 3 */ $this->core->config->is_premium_done ? '' : sprintf(
|
|
|
124 |
<div class="inside premium wp-clearfix">
|
125 |
%1$s
|
126 |
%2$s
|
@@ -131,7 +142,8 @@ $remote_meta_box = sprintf( '
|
|
131 |
/* 4 */ __( 'Secure your backups by keeping copies of them on <a href="admin.php?page=boldgrid-backup-tools§ion=section_locations">remote storage</a>.', 'boldgrid-backup' )
|
132 |
);
|
133 |
|
134 |
-
$editor_tools = sprintf(
|
|
|
135 |
<div style="padding-top:0px;" id="wp-content-editor-tools" class="wp-editor-tools hide-if-no-js">
|
136 |
<div id="wp-content-media-buttons" class="wp-media-buttons">
|
137 |
%1$s
|
@@ -147,7 +159,8 @@ $editor_tools = sprintf( '
|
|
147 |
/* 3 */ __( 'Database', 'boldgrid-backup' )
|
148 |
);
|
149 |
|
150 |
-
$intro = $this->core->config->is_premium_done ? '' : sprintf(
|
|
|
151 |
<div class="bg-box-bottom premium" style="margin-bottom:15px;">
|
152 |
<strong>%1$s</strong>
|
153 |
|
@@ -200,12 +213,13 @@ if ( ! $this->core->archive->is_stored_locally() ) {
|
|
200 |
if ( $this->core->archive->is_stored_remotely() ) {
|
201 |
$main_content = $only_remote;
|
202 |
} else {
|
203 |
-
$main_content
|
204 |
$remote_meta_box = '';
|
205 |
}
|
206 |
}
|
207 |
|
208 |
-
$page = sprintf(
|
|
|
209 |
<input type="hidden" id="filename" value="%1$s" />
|
210 |
<div class="wrap">
|
211 |
<h1 class="wp-heading-inline">%2$s</h1>
|
@@ -229,12 +243,10 @@ $page = sprintf( '
|
|
229 |
',
|
230 |
/* 1 */ $archive['filename'],
|
231 |
/* 2 */ __( 'Backup Archive Details', 'boldgrid-backup' ),
|
232 |
-
/* 3 */
|
233 |
/* 4 */ $main_content,
|
234 |
/* 5 */ $main_meta_box,
|
235 |
/* 6 */ $remote_meta_box
|
236 |
);
|
237 |
|
238 |
-
echo $page;
|
239 |
-
|
240 |
-
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: boldgrid-backup-admin-archive-details.php
|
4 |
+
*
|
5 |
* This file contains renders the details page of a backup archive.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.5.1
|
9 |
*
|
10 |
* @package Boldgrid_Backup
|
11 |
* @subpackage Boldgrid_Backup/admin/partials
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*
|
16 |
* @param bool $archive_found Whether or not the archive was found.
|
17 |
* @param array $archive An array of details about the archive, similar to
|
18 |
* the $info created during archiving.
|
19 |
*/
|
20 |
|
21 |
+
defined( 'WPINC' ) || die;
|
22 |
|
23 |
wp_enqueue_style( 'editor-buttons' );
|
24 |
|
26 |
|
27 |
$separator = '<hr class="separator">';
|
28 |
|
29 |
+
$details = include BOLDGRID_BACKUP_PATH . '/admin/partials/archive-details/details.php';
|
30 |
$remote_storage = include BOLDGRID_BACKUP_PATH . '/admin/partials/archive-details/remote-storage.php';
|
31 |
+
$browser = include BOLDGRID_BACKUP_PATH . '/admin/partials/archive-details/browser.php';
|
32 |
+
$db = include BOLDGRID_BACKUP_PATH . '/admin/partials/archive-details/db.php';
|
33 |
|
34 |
// Special situations where the backup file is not local and/or remote.
|
35 |
$only_remote = include BOLDGRID_BACKUP_PATH . '/admin/partials/archive-details/only-remote.php';
|
36 |
+
$not_found = include BOLDGRID_BACKUP_PATH . '/admin/partials/archive-details/not-found.php';
|
37 |
|
38 |
+
$delete_link = $this->core->archive_actions->get_delete_link( $archive['filename'] );
|
39 |
$download_button = $this->core->archive_actions->get_download_button( $archive['filename'] );
|
40 |
+
$restore_button = $this->core->archive_actions->get_restore_button( $archive['filename'] );
|
41 |
|
42 |
if ( ! $archive_found ) {
|
43 |
+
$file_size = '';
|
44 |
+
$backup_date = '';
|
45 |
+
$more_info = '';
|
46 |
$major_actions = '';
|
47 |
} else {
|
48 |
$file_size = sprintf(
|
59 |
$this->core->time->get_span()
|
60 |
);
|
61 |
|
62 |
+
$more_info = empty( $details ) ? '' : sprintf(
|
63 |
+
'
|
64 |
<div class="misc-pub-section">
|
65 |
More info <a href="" data-toggle-target="#more_info">Show</a>
|
66 |
<div id="more_info" class="hidden">
|
71 |
$details
|
72 |
);
|
73 |
|
74 |
+
$major_actions = sprintf(
|
75 |
+
'
|
76 |
<div id="major-publishing-actions">
|
77 |
<div id="delete-action">
|
78 |
%1$s
|
84 |
);
|
85 |
}
|
86 |
|
87 |
+
$main_meta_box = sprintf(
|
88 |
+
'
|
89 |
<div id="submitdiv" class="postbox">
|
90 |
<h2 class="hndle ui-sortable-handle"><span>%1$s</span></h2>
|
91 |
<div class="inside submitbox">
|
111 |
/* 7 */ $major_actions
|
112 |
);
|
113 |
|
114 |
+
$remote_meta_box = sprintf(
|
115 |
+
'
|
116 |
<div class="postbox remote-storage">
|
117 |
<h2 class="hndle ui-sortable-handle">
|
118 |
<span>%1$s</span>
|
130 |
</div>',
|
131 |
/* 1 */ __( 'Remote Storage', 'boldgrid-backup' ),
|
132 |
/* 2 */ $remote_storage['postbox'],
|
133 |
+
/* 3 */ $this->core->config->is_premium_done ? '' : sprintf(
|
134 |
+
'
|
135 |
<div class="inside premium wp-clearfix">
|
136 |
%1$s
|
137 |
%2$s
|
142 |
/* 4 */ __( 'Secure your backups by keeping copies of them on <a href="admin.php?page=boldgrid-backup-tools§ion=section_locations">remote storage</a>.', 'boldgrid-backup' )
|
143 |
);
|
144 |
|
145 |
+
$editor_tools = sprintf(
|
146 |
+
'
|
147 |
<div style="padding-top:0px;" id="wp-content-editor-tools" class="wp-editor-tools hide-if-no-js">
|
148 |
<div id="wp-content-media-buttons" class="wp-media-buttons">
|
149 |
%1$s
|
159 |
/* 3 */ __( 'Database', 'boldgrid-backup' )
|
160 |
);
|
161 |
|
162 |
+
$intro = $this->core->config->is_premium_done ? '' : sprintf(
|
163 |
+
'
|
164 |
<div class="bg-box-bottom premium" style="margin-bottom:15px;">
|
165 |
<strong>%1$s</strong>
|
166 |
|
213 |
if ( $this->core->archive->is_stored_remotely() ) {
|
214 |
$main_content = $only_remote;
|
215 |
} else {
|
216 |
+
$main_content = $not_found;
|
217 |
$remote_meta_box = '';
|
218 |
}
|
219 |
}
|
220 |
|
221 |
+
$page = sprintf(
|
222 |
+
'
|
223 |
<input type="hidden" id="filename" value="%1$s" />
|
224 |
<div class="wrap">
|
225 |
<h1 class="wp-heading-inline">%2$s</h1>
|
243 |
',
|
244 |
/* 1 */ $archive['filename'],
|
245 |
/* 2 */ __( 'Backup Archive Details', 'boldgrid-backup' ),
|
246 |
+
/* 3 */ require BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-nav.php',
|
247 |
/* 4 */ $main_content,
|
248 |
/* 5 */ $main_meta_box,
|
249 |
/* 6 */ $remote_meta_box
|
250 |
);
|
251 |
|
252 |
+
echo $page; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
|
|
|
admin/partials/boldgrid-backup-admin-backup-button.php
CHANGED
@@ -1,19 +1,29 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Display a "Backup Site Now" button.
|
4 |
*
|
|
|
5 |
* @since 1.3
|
6 |
*
|
7 |
* @package Boldgrid_Backup
|
8 |
-
* @subpackage Boldgrid_Backup/admin/partials
|
|
|
|
|
|
|
9 |
*/
|
10 |
|
11 |
-
|
|
|
|
|
12 |
|
13 |
$core = isset( $this->core ) ? $this->core : $this;
|
14 |
|
15 |
// Are we loading the "protect now" form via ajax?
|
16 |
-
$update_protection_ajax = ! empty( $_POST['action'] ) &&
|
|
|
|
|
17 |
|
18 |
return sprintf(
|
19 |
'<div id="backup-site-now-section">
|
@@ -36,5 +46,3 @@ return sprintf(
|
|
36 |
$update_protection_ajax || $core->auto_rollback->on_update_page ? 'data-updating="true"' : '',
|
37 |
/* 4 */ __( 'You may leave this page, doing so will not stop your backup.', 'boldgrid-backup' )
|
38 |
);
|
39 |
-
|
40 |
-
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: boldgrid-backup-admin-backup-button.php
|
4 |
+
*
|
5 |
* Display a "Backup Site Now" button.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.3
|
9 |
*
|
10 |
* @package Boldgrid_Backup
|
11 |
+
* @subpackage Boldgrid_Backup/admin/partials
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
// phpcs:disable WordPress.VIP, WordPress.CSRF.NonceVerification.NoNonceVerification
|
18 |
+
|
19 |
+
defined( 'WPINC' ) || die;
|
20 |
|
21 |
$core = isset( $this->core ) ? $this->core : $this;
|
22 |
|
23 |
// Are we loading the "protect now" form via ajax?
|
24 |
+
$update_protection_ajax = ! empty( $_POST['action'] ) &&
|
25 |
+
'boldgrid_backup_get_protect_notice' === $_POST['action'] &&
|
26 |
+
! empty( $_POST['update_protection'] );
|
27 |
|
28 |
return sprintf(
|
29 |
'<div id="backup-site-now-section">
|
46 |
$update_protection_ajax || $core->auto_rollback->on_update_page ? 'data-updating="true"' : '',
|
47 |
/* 4 */ __( 'You may leave this page, doing so will not stop your backup.', 'boldgrid-backup' )
|
48 |
);
|
|
|
|
admin/partials/boldgrid-backup-admin-backup-modal.php
CHANGED
@@ -1,16 +1,23 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Display a "Backup Site Now" button and modal.
|
4 |
*
|
5 |
-
* @
|
|
|
6 |
*
|
7 |
* @package Boldgrid_Backup
|
8 |
* @subpackage Boldgrid_Backup/admin/partials
|
|
|
|
|
|
|
9 |
*/
|
10 |
|
11 |
-
defined( 'WPINC' )
|
12 |
|
13 |
-
return sprintf(
|
|
|
14 |
<div id="backup_now_content" style="display:none;">
|
15 |
<h2>%1$s</h2>
|
16 |
|
@@ -28,9 +35,7 @@ return sprintf('
|
|
28 |
</div>',
|
29 |
/* 1 */ __( 'Backup Site Now', 'boldgrid-backup' ),
|
30 |
/* 2 */ __( 'The <strong>Files and Folders</strong> and <strong>Database</strong> settings below customize which parts of your site to backup.', 'boldgrid-backup' ),
|
31 |
-
/* 3 */
|
32 |
-
/* 4 */
|
33 |
-
/* 5 */
|
34 |
);
|
35 |
-
|
36 |
-
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: boldgrid-backup-admin-backup-modal.php
|
4 |
+
*
|
5 |
* Display a "Backup Site Now" button and modal.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
+
* @since 1.6.0
|
9 |
*
|
10 |
* @package Boldgrid_Backup
|
11 |
* @subpackage Boldgrid_Backup/admin/partials
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
defined( 'WPINC' ) || die;
|
18 |
|
19 |
+
return sprintf(
|
20 |
+
'
|
21 |
<div id="backup_now_content" style="display:none;">
|
22 |
<h2>%1$s</h2>
|
23 |
|
35 |
</div>',
|
36 |
/* 1 */ __( 'Backup Site Now', 'boldgrid-backup' ),
|
37 |
/* 2 */ __( 'The <strong>Files and Folders</strong> and <strong>Database</strong> settings below customize which parts of your site to backup.', 'boldgrid-backup' ),
|
38 |
+
/* 3 */ require BOLDGRID_BACKUP_PATH . '/admin/partials/settings/folders.php',
|
39 |
+
/* 4 */ require BOLDGRID_BACKUP_PATH . '/admin/partials/settings/db.php',
|
40 |
+
/* 5 */ require BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-backup-button.php'
|
41 |
);
|
|
|
|
admin/partials/boldgrid-backup-admin-backup.php
CHANGED
@@ -1,20 +1,25 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
* This file is used to markup the admin-facing aspects of the plugin.
|
6 |
*
|
7 |
-
* @link
|
8 |
* @since 1.0
|
9 |
*
|
10 |
-
* @package
|
11 |
* @subpackage Boldgrid_Backup/admin/partials
|
|
|
|
|
|
|
12 |
*/
|
13 |
|
14 |
-
|
15 |
|
16 |
-
|
17 |
-
|
|
|
|
|
18 |
$redirect_url = admin_url( 'admin.php?page=boldgrid-backup' );
|
19 |
|
20 |
/*
|
@@ -33,7 +38,6 @@ $redirect_url = admin_url( 'admin.php?page=boldgrid-backup' );
|
|
33 |
* @since 1.6.0
|
34 |
*/
|
35 |
if ( $is_restore && $is_success ) {
|
36 |
-
|
37 |
/*
|
38 |
* After restoration, redirect user to the backups page.
|
39 |
*
|
@@ -51,7 +55,9 @@ if ( $is_restore && $is_success ) {
|
|
51 |
* to see it. We'll take care of the refresh for the user.
|
52 |
*/
|
53 |
if ( ! wp_doing_ajax() ) {
|
54 |
-
|
|
|
|
|
55 |
return;
|
56 |
}
|
57 |
}
|
@@ -75,9 +81,10 @@ $core->archive->init( $archive_info['filepath'] );
|
|
75 |
*/
|
76 |
|
77 |
// Create a link to the settings page.
|
78 |
-
$url
|
79 |
$settings_page_link = sprintf(
|
80 |
wp_kses(
|
|
|
81 |
__( 'See <a href="%s">Settings for BoldGrid Backup</a> for details.', 'boldgrid-backup' ),
|
82 |
array( 'a' => array( 'href' => array() ) )
|
83 |
),
|
@@ -88,7 +95,7 @@ if ( ! empty( $archive_info ) ) {
|
|
88 |
|
89 |
if ( ! empty( $archive_info['dryrun'] ) ) {
|
90 |
$message = array(
|
91 |
-
'class'
|
92 |
'message' => sprintf( '<p>%1$s</p>', esc_html__( 'This was a dry run test', 'boldgrid-backup' ) ),
|
93 |
);
|
94 |
}
|
@@ -108,8 +115,9 @@ if ( ! empty( $archive_info ) ) {
|
|
108 |
*/
|
109 |
if ( $is_success ) {
|
110 |
$message = array(
|
111 |
-
'class'
|
112 |
-
'message' => sprintf(
|
|
|
113 |
<h2 class="header-notice">%1$s - %2$s</h2>
|
114 |
<p>%3$s <a href="%4$s">%5$s</a></p>
|
115 |
',
|
@@ -122,37 +130,42 @@ if ( ! empty( $archive_info ) ) {
|
|
122 |
);
|
123 |
} else {
|
124 |
$message = array(
|
125 |
-
'class'
|
126 |
'message' => esc_html( $archive_info['error'] ),
|
127 |
-
'header'
|
128 |
'%1$s - %2$s',
|
129 |
__( 'BoldGrid Backup', 'boldgrid-backup' ),
|
130 |
-
empty( $_POST['restore_now'] ) ?
|
|
|
|
|
131 |
),
|
132 |
);
|
133 |
}
|
134 |
} else {
|
135 |
$message = array(
|
136 |
-
'class'
|
137 |
-
'message' => sprintf(
|
|
|
138 |
<p>%1$s</p>
|
139 |
%2$s
|
140 |
%3$s
|
141 |
%4$s %5$s',
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
|
|
|
|
147 |
),
|
148 |
);
|
149 |
}
|
150 |
|
151 |
if ( ! isset( $message ) ) {
|
152 |
$message = array(
|
153 |
-
'class'
|
154 |
'message' => __( 'Unknown error.', 'boldgrid-backup' ),
|
155 |
-
'header'
|
156 |
);
|
157 |
}
|
158 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: boldgrid-backup-admin-backup.php
|
4 |
*
|
5 |
* This file is used to markup the admin-facing aspects of the plugin.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.0
|
9 |
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
* @subpackage Boldgrid_Backup/admin/partials
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
// phpcs:disable WordPress.VIP
|
18 |
|
19 |
+
defined( 'WPINC' ) || die;
|
20 |
+
|
21 |
+
$is_restore = ! empty( $_POST['restore_now'] ) && '1' === $_POST['restore_now']; // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
22 |
+
$is_success = ! empty( $archive_info ) && empty( $archive_info['error'] );
|
23 |
$redirect_url = admin_url( 'admin.php?page=boldgrid-backup' );
|
24 |
|
25 |
/*
|
38 |
* @since 1.6.0
|
39 |
*/
|
40 |
if ( $is_restore && $is_success ) {
|
|
|
41 |
/*
|
42 |
* After restoration, redirect user to the backups page.
|
43 |
*
|
55 |
* to see it. We'll take care of the refresh for the user.
|
56 |
*/
|
57 |
if ( ! wp_doing_ajax() ) {
|
58 |
+
?>
|
59 |
+
<script type="text/javascript">window.location.href = "<?php echo esc_url( $redirect_url ); ?>";</script>
|
60 |
+
<?php
|
61 |
return;
|
62 |
}
|
63 |
}
|
81 |
*/
|
82 |
|
83 |
// Create a link to the settings page.
|
84 |
+
$url = admin_url( 'admin.php?page=boldgrid-backup-settings' );
|
85 |
$settings_page_link = sprintf(
|
86 |
wp_kses(
|
87 |
+
// translators: 1: URL address.
|
88 |
__( 'See <a href="%s">Settings for BoldGrid Backup</a> for details.', 'boldgrid-backup' ),
|
89 |
array( 'a' => array( 'href' => array() ) )
|
90 |
),
|
95 |
|
96 |
if ( ! empty( $archive_info['dryrun'] ) ) {
|
97 |
$message = array(
|
98 |
+
'class' => 'notice notice-info is-dismissible',
|
99 |
'message' => sprintf( '<p>%1$s</p>', esc_html__( 'This was a dry run test', 'boldgrid-backup' ) ),
|
100 |
);
|
101 |
}
|
115 |
*/
|
116 |
if ( $is_success ) {
|
117 |
$message = array(
|
118 |
+
'class' => 'notice notice-success is-dismissible boldgrid-backup-complete',
|
119 |
+
'message' => sprintf(
|
120 |
+
'
|
121 |
<h2 class="header-notice">%1$s - %2$s</h2>
|
122 |
<p>%3$s <a href="%4$s">%5$s</a></p>
|
123 |
',
|
130 |
);
|
131 |
} else {
|
132 |
$message = array(
|
133 |
+
'class' => 'notice notice-error is-dismissible',
|
134 |
'message' => esc_html( $archive_info['error'] ),
|
135 |
+
'header' => sprintf(
|
136 |
'%1$s - %2$s',
|
137 |
__( 'BoldGrid Backup', 'boldgrid-backup' ),
|
138 |
+
empty( $_POST['restore_now'] ) ? // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
|
139 |
+
__( 'Error creating archive', 'boldgrid-backup' ) :
|
140 |
+
__( 'Error restoring archive', 'boldgrid-backup' )
|
141 |
),
|
142 |
);
|
143 |
}
|
144 |
} else {
|
145 |
$message = array(
|
146 |
+
'class' => 'notice notice-error is-dismissible',
|
147 |
+
'message' => sprintf(
|
148 |
+
'
|
149 |
<p>%1$s</p>
|
150 |
%2$s
|
151 |
%3$s
|
152 |
%4$s %5$s',
|
153 |
+
$is_restore ? esc_html__( 'There was an error restoring the selected backup archive file', 'boldgrid-backup' ) : esc_html__( 'There was an error creating a backup archive file', 'boldgrid-backup' ),
|
154 |
+
// translators: 1: File path.
|
155 |
+
empty( $archive_info['filepath'] ) ? '' : '<p>' . sprintf( esc_html__( 'File Path: %s', 'boldgrid-backup' ), $archive_info['filepath'] ) . '</p>',
|
156 |
+
empty( $archive_info['error'] ) ? '' : '<p>' . $archive_info['error'] . '</p>',
|
157 |
+
// translators: 1: Error message.
|
158 |
+
! isset( $archive_info['error_message'] ) ? '' : '<p>' . sprintf( __( 'Error Details: %s', 'boldgrid-backup' ), $archive_info['error_message'] ),
|
159 |
+
isset( $archive_info['error_message'] ) && isset( $archive_info['error_code'] ) ? ' (' . $archive_info['error_code'] . ')' : ''
|
160 |
),
|
161 |
);
|
162 |
}
|
163 |
|
164 |
if ( ! isset( $message ) ) {
|
165 |
$message = array(
|
166 |
+
'class' => 'notice notice-error is-dismissible',
|
167 |
'message' => __( 'Unknown error.', 'boldgrid-backup' ),
|
168 |
+
'header' => __( 'BoldGrid Backup', 'boldgrid-backup' ),
|
169 |
);
|
170 |
}
|
171 |
|
admin/partials/boldgrid-backup-admin-home.php
CHANGED
@@ -1,17 +1,20 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
* This file is used to markup the admin-facing aspects of the plugin.
|
6 |
*
|
7 |
-
* @link
|
8 |
* @since 1.0
|
9 |
*
|
10 |
-
* @package
|
11 |
* @subpackage Boldgrid_Backup/admin/partials
|
|
|
|
|
|
|
12 |
*/
|
13 |
|
14 |
-
defined( 'WPINC' )
|
15 |
|
16 |
/*
|
17 |
* Variables passed by scope.
|
@@ -34,7 +37,8 @@ defined( 'WPINC' ) ? : die;
|
|
34 |
$nav = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-nav.php';
|
35 |
|
36 |
// Premium advertisement on the bottom of the archives page.
|
37 |
-
$ad = $this->config->is_premium_done ? '' : sprintf(
|
|
|
38 |
<div class="bg-box-bottom premium wp-clearfix">
|
39 |
%1$s
|
40 |
%2$s
|
@@ -45,7 +49,7 @@ $ad = $this->config->is_premium_done ? '' : sprintf( '
|
|
45 |
|
46 |
// Backup now modal.
|
47 |
$in_modal = true;
|
48 |
-
$modal
|
49 |
$in_modal = false;
|
50 |
|
51 |
?>
|
@@ -53,22 +57,22 @@ $in_modal = false;
|
|
53 |
|
54 |
<h1 class="wp-heading-inline"><?php esc_html_e( 'Backup Archives', 'boldgrid-backup' ); ?></h1>
|
55 |
|
56 |
-
<a href="#TB_inline?width=800&height=600&inlineId=backup_now_content" class="thickbox page-title-action page-title-action-primary"><?php
|
57 |
|
58 |
-
<a class="page-title-action add-new"><?php
|
59 |
|
60 |
<?php
|
61 |
-
echo $nav;
|
62 |
|
63 |
-
|
64 |
|
65 |
-
echo $table;
|
66 |
|
67 |
-
echo $modal;
|
68 |
|
69 |
-
|
70 |
|
71 |
-
echo $ad;
|
72 |
?>
|
73 |
|
74 |
</div>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: boldgrid-backup-admin-home.php
|
4 |
*
|
5 |
* This file is used to markup the admin-facing aspects of the plugin.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.0
|
9 |
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
* @subpackage Boldgrid_Backup/admin/partials
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
defined( 'WPINC' ) || die;
|
18 |
|
19 |
/*
|
20 |
* Variables passed by scope.
|
37 |
$nav = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-nav.php';
|
38 |
|
39 |
// Premium advertisement on the bottom of the archives page.
|
40 |
+
$ad = $this->config->is_premium_done ? '' : sprintf(
|
41 |
+
'
|
42 |
<div class="bg-box-bottom premium wp-clearfix">
|
43 |
%1$s
|
44 |
%2$s
|
49 |
|
50 |
// Backup now modal.
|
51 |
$in_modal = true;
|
52 |
+
$modal = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-backup-modal.php';
|
53 |
$in_modal = false;
|
54 |
|
55 |
?>
|
57 |
|
58 |
<h1 class="wp-heading-inline"><?php esc_html_e( 'Backup Archives', 'boldgrid-backup' ); ?></h1>
|
59 |
|
60 |
+
<a href="#TB_inline?width=800&height=600&inlineId=backup_now_content" class="thickbox page-title-action page-title-action-primary"><?php esc_html_e( 'Backup Site Now', 'boldgrid-backup' ); ?></a>
|
61 |
|
62 |
+
<a class="page-title-action add-new"><?php esc_html_e( 'Upload Backup', 'boldgrid-backup' ); ?></a>
|
63 |
|
64 |
<?php
|
65 |
+
echo $nav; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
66 |
|
67 |
+
require BOLDGRID_BACKUP_PATH . '/admin/partials/archives/add-new.php';
|
68 |
|
69 |
+
echo $table; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
70 |
|
71 |
+
echo $modal; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
72 |
|
73 |
+
require BOLDGRID_BACKUP_PATH . '/admin/partials/archives/note-pre-backup.php';
|
74 |
|
75 |
+
echo $ad; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
76 |
?>
|
77 |
|
78 |
</div>
|
admin/partials/boldgrid-backup-admin-mail-restore.php
CHANGED
@@ -1,14 +1,20 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Mail template for restoration notifications.
|
4 |
*
|
|
|
5 |
* @since 1.2.2
|
6 |
*
|
7 |
-
* @package
|
8 |
* @subpackage Boldgrid_Backup/admin/partials
|
|
|
|
|
|
|
9 |
*/
|
10 |
|
11 |
-
defined( 'WPINC' )
|
12 |
|
13 |
/**
|
14 |
* This template uses inherited variables.
|
@@ -19,16 +25,14 @@ defined( 'WPINC' ) ? : die;
|
|
19 |
* @param bool $restore_ok Success of the restoration.
|
20 |
* @param string $info['filepath'] The file path restored.
|
21 |
*/
|
22 |
-
// Create a site identifier.
|
23 |
$site_id = Boldgrid_Backup_Admin_Utility::create_site_id();
|
24 |
|
25 |
-
// Create subject.
|
26 |
$subject = sprintf(
|
|
|
27 |
esc_html__( 'Restoration completed for %s', 'boldgrid-backup' ),
|
28 |
$site_id
|
29 |
);
|
30 |
|
31 |
-
// Create message.
|
32 |
$body = esc_html__( 'Hello', 'boldgrid-backup' ) . ",\n\n";
|
33 |
|
34 |
if ( $dryrun ) {
|
@@ -45,6 +49,7 @@ if ( $restore_ok ) {
|
|
45 |
}
|
46 |
|
47 |
$body .= sprintf(
|
|
|
48 |
__( ' for %s', 'boldgrid-backup' ),
|
49 |
$site_id
|
50 |
) . ".\n\n";
|
@@ -52,11 +57,13 @@ $body .= sprintf(
|
|
52 |
$body .= esc_html__( 'Restoration details', 'boldgrid-backup' ) . ":\n";
|
53 |
|
54 |
$body .= sprintf(
|
|
|
55 |
esc_html__( 'Archive file path: %s', 'boldgrid-backup' ),
|
56 |
$info['filepath']
|
57 |
) . "\n";
|
58 |
|
59 |
$body .= sprintf(
|
|
|
60 |
esc_html__( 'Archive file size: %s', 'boldgrid-backup' ),
|
61 |
Boldgrid_Backup_Admin_Utility::bytes_to_human( $info['filesize'] )
|
62 |
) . "\n";
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: boldgrid-backup-admin-mail-restore.php
|
4 |
+
*
|
5 |
* Mail template for restoration notifications.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.2.2
|
9 |
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
* @subpackage Boldgrid_Backup/admin/partials
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
defined( 'WPINC' ) || die;
|
18 |
|
19 |
/**
|
20 |
* This template uses inherited variables.
|
25 |
* @param bool $restore_ok Success of the restoration.
|
26 |
* @param string $info['filepath'] The file path restored.
|
27 |
*/
|
|
|
28 |
$site_id = Boldgrid_Backup_Admin_Utility::create_site_id();
|
29 |
|
|
|
30 |
$subject = sprintf(
|
31 |
+
// translators: 1: Site identifier.
|
32 |
esc_html__( 'Restoration completed for %s', 'boldgrid-backup' ),
|
33 |
$site_id
|
34 |
);
|
35 |
|
|
|
36 |
$body = esc_html__( 'Hello', 'boldgrid-backup' ) . ",\n\n";
|
37 |
|
38 |
if ( $dryrun ) {
|
49 |
}
|
50 |
|
51 |
$body .= sprintf(
|
52 |
+
// translators: 1: Site identifier.
|
53 |
__( ' for %s', 'boldgrid-backup' ),
|
54 |
$site_id
|
55 |
) . ".\n\n";
|
57 |
$body .= esc_html__( 'Restoration details', 'boldgrid-backup' ) . ":\n";
|
58 |
|
59 |
$body .= sprintf(
|
60 |
+
// translators: 1: Archive file path.
|
61 |
esc_html__( 'Archive file path: %s', 'boldgrid-backup' ),
|
62 |
$info['filepath']
|
63 |
) . "\n";
|
64 |
|
65 |
$body .= sprintf(
|
66 |
+
// translators: 1: Archive file size.
|
67 |
esc_html__( 'Archive file size: %s', 'boldgrid-backup' ),
|
68 |
Boldgrid_Backup_Admin_Utility::bytes_to_human( $info['filesize'] )
|
69 |
) . "\n";
|
admin/partials/boldgrid-backup-admin-nav.php
CHANGED
@@ -1,39 +1,49 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* This file contains the navbar for all BoldGrid Backup pages.
|
4 |
*
|
|
|
5 |
* @since 1.5.1
|
6 |
*
|
7 |
* @package Boldgrid_Backup
|
8 |
* @subpackage Boldgrid_Backup/admin/partials
|
|
|
|
|
|
|
9 |
*/
|
10 |
|
11 |
-
|
|
|
|
|
12 |
|
13 |
$active = 'nav-tab-active';
|
14 |
|
|
|
15 |
$navs = array(
|
16 |
array(
|
17 |
'title' => __( 'Backups', 'boldgrid-backup' ),
|
18 |
-
'href'
|
19 |
'class' => ! empty( $_GET['page'] ) && 'boldgrid-backup' === $_GET['page'] ? $active : '',
|
20 |
),
|
21 |
array(
|
22 |
'title' => __( 'Settings', 'boldgrid-backup' ),
|
23 |
-
'href'
|
24 |
'class' => ! empty( $_GET['page'] ) && 'boldgrid-backup-settings' === $_GET['page'] ? $active : '',
|
25 |
),
|
26 |
array(
|
27 |
'title' => __( 'Preflight Check', 'boldgrid-backup' ),
|
28 |
-
'href'
|
29 |
'class' => ! empty( $_GET['page'] ) && 'boldgrid-backup-test' === $_GET['page'] ? $active : '',
|
30 |
),
|
31 |
array(
|
32 |
'title' => __( 'Tools', 'boldgrid-backup' ),
|
33 |
-
'href'
|
34 |
'class' => ! empty( $_GET['page'] ) && 'boldgrid-backup-tools' === $_GET['page'] ? $active : '',
|
35 |
),
|
36 |
);
|
|
|
37 |
|
38 |
/**
|
39 |
* Allow the update of our nav menu items.
|
@@ -56,5 +66,3 @@ foreach ( $navs as $nav ) {
|
|
56 |
$markup .= '</h2>';
|
57 |
|
58 |
return $markup;
|
59 |
-
|
60 |
-
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: boldgrid-backup-admin-nav.php
|
4 |
+
*
|
5 |
* This file contains the navbar for all BoldGrid Backup pages.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.5.1
|
9 |
*
|
10 |
* @package Boldgrid_Backup
|
11 |
* @subpackage Boldgrid_Backup/admin/partials
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
// phpcs:disable WordPress.VIP
|
18 |
+
|
19 |
+
defined( 'WPINC' ) || die;
|
20 |
|
21 |
$active = 'nav-tab-active';
|
22 |
|
23 |
+
// phpcs:disable WordPress.CSRF.NonceVerification.NoNonceVerification
|
24 |
$navs = array(
|
25 |
array(
|
26 |
'title' => __( 'Backups', 'boldgrid-backup' ),
|
27 |
+
'href' => 'admin.php?page=boldgrid-backup',
|
28 |
'class' => ! empty( $_GET['page'] ) && 'boldgrid-backup' === $_GET['page'] ? $active : '',
|
29 |
),
|
30 |
array(
|
31 |
'title' => __( 'Settings', 'boldgrid-backup' ),
|
32 |
+
'href' => 'admin.php?page=boldgrid-backup-settings',
|
33 |
'class' => ! empty( $_GET['page'] ) && 'boldgrid-backup-settings' === $_GET['page'] ? $active : '',
|
34 |
),
|
35 |
array(
|
36 |
'title' => __( 'Preflight Check', 'boldgrid-backup' ),
|
37 |
+
'href' => 'admin.php?page=boldgrid-backup-test',
|
38 |
'class' => ! empty( $_GET['page'] ) && 'boldgrid-backup-test' === $_GET['page'] ? $active : '',
|
39 |
),
|
40 |
array(
|
41 |
'title' => __( 'Tools', 'boldgrid-backup' ),
|
42 |
+
'href' => 'admin.php?page=boldgrid-backup-tools',
|
43 |
'class' => ! empty( $_GET['page'] ) && 'boldgrid-backup-tools' === $_GET['page'] ? $active : '',
|
44 |
),
|
45 |
);
|
46 |
+
// phpcs:enable WordPress.CSRF.NonceVerification.NoNonceVerification
|
47 |
|
48 |
/**
|
49 |
* Allow the update of our nav menu items.
|
66 |
$markup .= '</h2>';
|
67 |
|
68 |
return $markup;
|
|
|
|
admin/partials/boldgrid-backup-admin-settings.php
CHANGED
@@ -1,71 +1,75 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
* This file is used to markup the admin-facing aspects of the plugin.
|
6 |
*
|
7 |
-
* @link
|
8 |
* @since 1.0
|
9 |
*
|
10 |
-
* @package
|
11 |
* @subpackage Boldgrid_Backup/admin/partials
|
|
|
|
|
|
|
12 |
*/
|
13 |
|
14 |
-
defined( 'WPINC' )
|
15 |
|
16 |
-
$nav
|
17 |
-
$scheduler
|
18 |
-
$folders_include
|
19 |
-
$db
|
20 |
-
$retention
|
21 |
-
$auto_updates
|
22 |
-
$notifications
|
23 |
$backup_directory = include BOLDGRID_BACKUP_PATH . '/admin/partials/settings/backup-directory.php';
|
24 |
-
$connect_key
|
25 |
|
26 |
$days_of_week = '';
|
27 |
-
$time_of_day
|
28 |
-
$storage
|
29 |
if ( $this->core->scheduler->is_available( 'cron' ) || $this->core->scheduler->is_available( 'wp-cron' ) ) {
|
30 |
$days_of_week = include BOLDGRID_BACKUP_PATH . '/admin/partials/settings/days-of-week.php';
|
31 |
-
$time_of_day
|
32 |
-
$storage
|
33 |
}
|
34 |
|
35 |
$sections = array(
|
36 |
-
'sections'
|
37 |
array(
|
38 |
-
'id'
|
39 |
-
'title'
|
40 |
'content' => $scheduler . $days_of_week . $time_of_day . $storage . $folders_include . $db,
|
41 |
),
|
42 |
array(
|
43 |
-
'id'
|
44 |
-
'title'
|
45 |
'content' => $connect_key,
|
46 |
),
|
47 |
array(
|
48 |
-
'id'
|
49 |
-
'title'
|
50 |
'content' => $retention,
|
51 |
),
|
52 |
array(
|
53 |
-
'id'
|
54 |
-
'title'
|
55 |
'content' => $auto_updates,
|
56 |
),
|
57 |
array(
|
58 |
-
'id'
|
59 |
-
'title'
|
60 |
'content' => $notifications,
|
61 |
),
|
62 |
array(
|
63 |
-
'id'
|
64 |
-
'title'
|
65 |
'content' => $backup_directory,
|
66 |
),
|
67 |
),
|
68 |
-
'post_col_right' => sprintf(
|
|
|
69 |
<div id="boldgrid-settings-submit-div">
|
70 |
<p>
|
71 |
<input id="boldgrid-settings-submit" class="button button-primary" type="submit" name="submit" value="%1$s" />
|
@@ -78,7 +82,7 @@ $sections = array(
|
|
78 |
/**
|
79 |
* Allow other plugins to modify the sections of the settings page.
|
80 |
*
|
81 |
-
* @since 1.
|
82 |
*
|
83 |
* @param array $sections
|
84 |
*/
|
@@ -87,9 +91,11 @@ $sections = apply_filters( 'boldgrid_backup_settings_sections', $sections );
|
|
87 |
/**
|
88 |
* Render the $sections into displayable markup.
|
89 |
*
|
90 |
-
* @since 1.
|
91 |
*
|
92 |
* @param array $sections
|
|
|
|
|
93 |
*/
|
94 |
$col_container = apply_filters( 'Boldgrid\Library\Ui\render_col_container', $sections );
|
95 |
if ( is_array( $col_container ) ) {
|
@@ -98,7 +104,8 @@ if ( is_array( $col_container ) ) {
|
|
98 |
|
99 |
// Check if settings are available, show an error notice if not.
|
100 |
if ( empty( $settings ) ) {
|
101 |
-
add_action(
|
|
|
102 |
array(
|
103 |
$this,
|
104 |
'notice_settings_retrieval',
|
@@ -113,7 +120,7 @@ wp_nonce_field( 'boldgrid_backup_settings' );
|
|
113 |
<h1><?php esc_html_e( 'BoldGrid Backup and Restore Settings', 'boldgrid-backup' ); ?></h1>
|
114 |
|
115 |
<?php
|
116 |
-
echo $nav;
|
117 |
|
118 |
/*
|
119 |
* Print this text:
|
@@ -122,25 +129,31 @@ wp_nonce_field( 'boldgrid_backup_settings' );
|
|
122 |
* being afraid it will do something you cannot easily undo. We perform a Preflight Check to see
|
123 |
* if the needed support is available on your web hosting account.
|
124 |
*/
|
125 |
-
|
126 |
-
|
|
|
|
|
127 |
wp_kses(
|
128 |
-
|
|
|
|
|
|
|
|
|
129 |
array( 'a' => array( 'href' => array() ) )
|
130 |
),
|
131 |
-
esc_url(
|
132 |
);
|
133 |
-
echo '<p>' . $link . '</p>';
|
134 |
?>
|
|
|
135 |
|
136 |
<hr />
|
137 |
|
138 |
<form id='schedule-form' method='post'>
|
139 |
<?php
|
140 |
-
echo $col_container;
|
141 |
wp_nonce_field( 'boldgrid-backup-settings', 'settings_auth' );
|
142 |
-
printf( '<input type="hidden" name="save_time" value="%1$s" />', time() );
|
143 |
?>
|
|
|
144 |
</form>
|
145 |
|
146 |
</div>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: boldgrid-backup-admin-settings.php
|
4 |
*
|
5 |
* This file is used to markup the admin-facing aspects of the plugin.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.0
|
9 |
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
* @subpackage Boldgrid_Backup/admin/partials
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
defined( 'WPINC' ) || die;
|
18 |
|
19 |
+
$nav = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-nav.php';
|
20 |
+
$scheduler = include BOLDGRID_BACKUP_PATH . '/admin/partials/settings/scheduler.php';
|
21 |
+
$folders_include = include BOLDGRID_BACKUP_PATH . '/admin/partials/settings/folders.php';
|
22 |
+
$db = include BOLDGRID_BACKUP_PATH . '/admin/partials/settings/db.php';
|
23 |
+
$retention = include BOLDGRID_BACKUP_PATH . '/admin/partials/settings/retention.php';
|
24 |
+
$auto_updates = include BOLDGRID_BACKUP_PATH . '/admin/partials/settings/auto-updates.php';
|
25 |
+
$notifications = include BOLDGRID_BACKUP_PATH . '/admin/partials/settings/notifications.php';
|
26 |
$backup_directory = include BOLDGRID_BACKUP_PATH . '/admin/partials/settings/backup-directory.php';
|
27 |
+
$connect_key = include BOLDGRID_BACKUP_PATH . '/admin/partials/settings/connect-key.php';
|
28 |
|
29 |
$days_of_week = '';
|
30 |
+
$time_of_day = '';
|
31 |
+
$storage = '';
|
32 |
if ( $this->core->scheduler->is_available( 'cron' ) || $this->core->scheduler->is_available( 'wp-cron' ) ) {
|
33 |
$days_of_week = include BOLDGRID_BACKUP_PATH . '/admin/partials/settings/days-of-week.php';
|
34 |
+
$time_of_day = include BOLDGRID_BACKUP_PATH . '/admin/partials/settings/time-of-day.php';
|
35 |
+
$storage = include BOLDGRID_BACKUP_PATH . '/admin/partials/settings/storage.php';
|
36 |
}
|
37 |
|
38 |
$sections = array(
|
39 |
+
'sections' => array(
|
40 |
array(
|
41 |
+
'id' => 'section_schedule',
|
42 |
+
'title' => __( 'Backup Schedule', 'boldgrid-backup' ),
|
43 |
'content' => $scheduler . $days_of_week . $time_of_day . $storage . $folders_include . $db,
|
44 |
),
|
45 |
array(
|
46 |
+
'id' => 'connect_key',
|
47 |
+
'title' => __( 'BoldGrid Connect Key', 'boldgrid-bacup' ),
|
48 |
'content' => $connect_key,
|
49 |
),
|
50 |
array(
|
51 |
+
'id' => 'section_retention',
|
52 |
+
'title' => __( 'Retention', 'boldgrid-backup' ),
|
53 |
'content' => $retention,
|
54 |
),
|
55 |
array(
|
56 |
+
'id' => 'section_updates',
|
57 |
+
'title' => __( 'Auto Updates & Rollback', 'boldgrid-backup' ),
|
58 |
'content' => $auto_updates,
|
59 |
),
|
60 |
array(
|
61 |
+
'id' => 'section_notifications',
|
62 |
+
'title' => __( 'Notifications', 'boldgrid-backup' ),
|
63 |
'content' => $notifications,
|
64 |
),
|
65 |
array(
|
66 |
+
'id' => 'section_directory',
|
67 |
+
'title' => __( 'Backup Directory', 'boldgrid-backup' ),
|
68 |
'content' => $backup_directory,
|
69 |
),
|
70 |
),
|
71 |
+
'post_col_right' => sprintf(
|
72 |
+
'
|
73 |
<div id="boldgrid-settings-submit-div">
|
74 |
<p>
|
75 |
<input id="boldgrid-settings-submit" class="button button-primary" type="submit" name="submit" value="%1$s" />
|
82 |
/**
|
83 |
* Allow other plugins to modify the sections of the settings page.
|
84 |
*
|
85 |
+
* @since 1.6.0
|
86 |
*
|
87 |
* @param array $sections
|
88 |
*/
|
91 |
/**
|
92 |
* Render the $sections into displayable markup.
|
93 |
*
|
94 |
+
* @since 1.6.0
|
95 |
*
|
96 |
* @param array $sections
|
97 |
+
*
|
98 |
+
* phpcs:disable WordPress.NamingConventions.ValidHookName
|
99 |
*/
|
100 |
$col_container = apply_filters( 'Boldgrid\Library\Ui\render_col_container', $sections );
|
101 |
if ( is_array( $col_container ) ) {
|
104 |
|
105 |
// Check if settings are available, show an error notice if not.
|
106 |
if ( empty( $settings ) ) {
|
107 |
+
add_action(
|
108 |
+
'admin_footer',
|
109 |
array(
|
110 |
$this,
|
111 |
'notice_settings_retrieval',
|
120 |
<h1><?php esc_html_e( 'BoldGrid Backup and Restore Settings', 'boldgrid-backup' ); ?></h1>
|
121 |
|
122 |
<?php
|
123 |
+
echo $nav; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
124 |
|
125 |
/*
|
126 |
* Print this text:
|
129 |
* being afraid it will do something you cannot easily undo. We perform a Preflight Check to see
|
130 |
* if the needed support is available on your web hosting account.
|
131 |
*/
|
132 |
+
?>
|
133 |
+
<p>
|
134 |
+
<?php
|
135 |
+
printf(
|
136 |
wp_kses(
|
137 |
+
// translators: 1: URL address.
|
138 |
+
esc_html__(
|
139 |
+
'The BoldGrid Backup and Restore system allows you to upgrade your themes and plugins without being afraid it will do something you cannot easily undo. We perform a <a href="%s">Preflight Check</a> to see if the needed support is available on your web hosting account.',
|
140 |
+
'boldgrid-backup'
|
141 |
+
),
|
142 |
array( 'a' => array( 'href' => array() ) )
|
143 |
),
|
144 |
+
esc_url( admin_url( 'admin.php?page=boldgrid-backup-test' ) )
|
145 |
);
|
|
|
146 |
?>
|
147 |
+
</p>
|
148 |
|
149 |
<hr />
|
150 |
|
151 |
<form id='schedule-form' method='post'>
|
152 |
<?php
|
153 |
+
echo $col_container; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
154 |
wp_nonce_field( 'boldgrid-backup-settings', 'settings_auth' );
|
|
|
155 |
?>
|
156 |
+
<input type="hidden" name="save_time" value="<?php echo esc_attr( time() ); ?>" />
|
157 |
</form>
|
158 |
|
159 |
</div>
|
admin/partials/boldgrid-backup-admin-test.php
CHANGED
@@ -1,26 +1,33 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
*
|
|
|
|
|
6 |
* @since 1.0
|
7 |
*
|
8 |
-
* @package
|
9 |
* @subpackage Boldgrid_Backup/admin/partials
|
|
|
|
|
|
|
10 |
*/
|
11 |
|
12 |
-
|
|
|
|
|
13 |
|
14 |
// Setup our lang.
|
15 |
$lang = array(
|
16 |
-
'yes'
|
17 |
-
'no'
|
18 |
-
'untested'
|
19 |
-
'PASS'
|
20 |
-
'FAIL'
|
21 |
-
'not_set'
|
22 |
'before_test_compress' => __( 'Before any compressors are tested, please be sure your backup directory is created and has proper permissions set.', 'boldgrid-backup' ),
|
23 |
-
'ensure_dir_perms'
|
24 |
);
|
25 |
|
26 |
$lang['dir_of_dir'] = $lang['ensure_dir_perms'];
|
@@ -28,18 +35,18 @@ if ( $this->test->is_windows() ) {
|
|
28 |
$lang['dir_of_dir'] = __( 'Please review directory permissions. If you are on a Windows server, your user may need to be able to read BOTH the backup directory and its parent directory.', 'boldgrid-backup' );
|
29 |
}
|
30 |
|
31 |
-
$error_span
|
32 |
$warning_span = '<span class="warning">%1$s</span><br />%2$s';
|
33 |
$success_span = '<span class="success">%1$s</span>';
|
34 |
|
35 |
$allowed_tags = array(
|
36 |
'span' => array(
|
37 |
'class' => array(
|
38 |
-
'error'
|
39 |
),
|
40 |
),
|
41 |
-
'br'
|
42 |
-
'pre'
|
43 |
);
|
44 |
|
45 |
$backup_dir_perms = $this->test->extensive_dir_test( $backup_directory );
|
@@ -57,8 +64,8 @@ $timezone = false === $timezone ? 'UTC' . $this->time->get_server_offset() : $ti
|
|
57 |
$tests = array(
|
58 |
array(
|
59 |
'id' => 'pass',
|
60 |
-
'k'
|
61 |
-
'v'
|
62 |
),
|
63 |
array(
|
64 |
'heading' => __( 'General tests', 'boldgrid-backup' ),
|
@@ -89,7 +96,7 @@ $tests = array(
|
|
89 |
),
|
90 |
array(
|
91 |
'k' => __( 'PHP in safe mode?', 'boldgrid-backup' ),
|
92 |
-
'v' =>
|
93 |
),
|
94 |
array(
|
95 |
'k' => __( 'WordPress version:', 'boldgrid-backup' ),
|
@@ -336,7 +343,8 @@ if ( $is_functional ) {
|
|
336 |
if ( $is_functional ) {
|
337 |
$fail_tips = '';
|
338 |
} else {
|
339 |
-
$fail_tips = sprintf(
|
|
|
340 |
<p>
|
341 |
%1$s<br />
|
342 |
<a href="%3$s" target="_blank" />%2$s</a>
|
@@ -353,17 +361,20 @@ foreach ( $tests as $test ) {
|
|
353 |
if ( ! empty( $test['heading'] ) ) {
|
354 |
$table .= sprintf( '<tr class="heading"><td colspan="2"><h2>%1$s</h2></td></tr>', esc_html( $test['heading'] ) );
|
355 |
} elseif ( isset( $test['id'] ) && 'pass' === $test['id'] ) {
|
356 |
-
$table .= sprintf(
|
|
|
357 |
esc_html( $test['k'] ),
|
358 |
wp_kses( $test['v'], $allowed_tags )
|
359 |
);
|
360 |
} elseif ( isset( $test['k'] ) ) {
|
361 |
-
$table .= sprintf(
|
|
|
362 |
esc_html( $test['k'] ),
|
363 |
wp_kses( $test['v'], $allowed_tags )
|
364 |
);
|
365 |
} else {
|
366 |
-
$table .= sprintf(
|
|
|
367 |
esc_html( $test['v'] )
|
368 |
);
|
369 |
}
|
@@ -374,14 +385,14 @@ $table .= '</table>';
|
|
374 |
<div class="functionality-test-section wrap">
|
375 |
|
376 |
<?php
|
377 |
-
printf( '<h1>%1$s</h1>',
|
378 |
|
379 |
$nav = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-nav.php';
|
380 |
-
echo $nav;
|
381 |
|
382 |
-
echo $fail_tips;
|
383 |
|
384 |
-
echo $table;
|
385 |
?>
|
386 |
|
387 |
</div>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: boldgrid-backup-admin-test.php
|
4 |
*
|
5 |
+
* Provide a admin area view for the plugin functionality test report.
|
6 |
+
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.0
|
9 |
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
* @subpackage Boldgrid_Backup/admin/partials
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
// phpcs:disable WordPress.VIP
|
18 |
+
|
19 |
+
defined( 'WPINC' ) || die;
|
20 |
|
21 |
// Setup our lang.
|
22 |
$lang = array(
|
23 |
+
'yes' => __( 'Yes', 'boldgrid-backup' ),
|
24 |
+
'no' => __( 'No', 'boldgrid-backup' ),
|
25 |
+
'untested' => __( 'untested', 'boldgrid-backup' ),
|
26 |
+
'PASS' => __( 'PASS', 'boldgrid-backup' ),
|
27 |
+
'FAIL' => __( 'FAIL', 'boldgrid-backup' ),
|
28 |
+
'not_set' => __( 'not set', 'boldgrid-backup' ),
|
29 |
'before_test_compress' => __( 'Before any compressors are tested, please be sure your backup directory is created and has proper permissions set.', 'boldgrid-backup' ),
|
30 |
+
'ensure_dir_perms' => __( 'Please be sure that your backup directory exists. If it does, also ensure it has read, write, and modify permissions.', 'boldgrid-backup' ),
|
31 |
);
|
32 |
|
33 |
$lang['dir_of_dir'] = $lang['ensure_dir_perms'];
|
35 |
$lang['dir_of_dir'] = __( 'Please review directory permissions. If you are on a Windows server, your user may need to be able to read BOTH the backup directory and its parent directory.', 'boldgrid-backup' );
|
36 |
}
|
37 |
|
38 |
+
$error_span = '<span class="error">%1$s</span><br />%2$s';
|
39 |
$warning_span = '<span class="warning">%1$s</span><br />%2$s';
|
40 |
$success_span = '<span class="success">%1$s</span>';
|
41 |
|
42 |
$allowed_tags = array(
|
43 |
'span' => array(
|
44 |
'class' => array(
|
45 |
+
'error',
|
46 |
),
|
47 |
),
|
48 |
+
'br' => array(),
|
49 |
+
'pre' => array(),
|
50 |
);
|
51 |
|
52 |
$backup_dir_perms = $this->test->extensive_dir_test( $backup_directory );
|
64 |
$tests = array(
|
65 |
array(
|
66 |
'id' => 'pass',
|
67 |
+
'k' => __( 'Functionality test status:', 'boldgrid-backup' ),
|
68 |
+
'v' => ( $this->test->run_functionality_tests() ? sprintf( $success_span, $lang['PASS'] ) : sprintf( $error_span, $lang['FAIL'], '' ) ),
|
69 |
),
|
70 |
array(
|
71 |
'heading' => __( 'General tests', 'boldgrid-backup' ),
|
96 |
),
|
97 |
array(
|
98 |
'k' => __( 'PHP in safe mode?', 'boldgrid-backup' ),
|
99 |
+
'v' => $this->test->is_php_safemode() ? sprintf( $error_span, $lang['yes'], '' ) : $lang['no'],
|
100 |
),
|
101 |
array(
|
102 |
'k' => __( 'WordPress version:', 'boldgrid-backup' ),
|
343 |
if ( $is_functional ) {
|
344 |
$fail_tips = '';
|
345 |
} else {
|
346 |
+
$fail_tips = sprintf(
|
347 |
+
'
|
348 |
<p>
|
349 |
%1$s<br />
|
350 |
<a href="%3$s" target="_blank" />%2$s</a>
|
361 |
if ( ! empty( $test['heading'] ) ) {
|
362 |
$table .= sprintf( '<tr class="heading"><td colspan="2"><h2>%1$s</h2></td></tr>', esc_html( $test['heading'] ) );
|
363 |
} elseif ( isset( $test['id'] ) && 'pass' === $test['id'] ) {
|
364 |
+
$table .= sprintf(
|
365 |
+
'<tr><td>%1$s</td><td><strong>%2$s</strong></td></tr>',
|
366 |
esc_html( $test['k'] ),
|
367 |
wp_kses( $test['v'], $allowed_tags )
|
368 |
);
|
369 |
} elseif ( isset( $test['k'] ) ) {
|
370 |
+
$table .= sprintf(
|
371 |
+
'<tr><td>%1$s</td><td><em>%2$s</em></td></tr>',
|
372 |
esc_html( $test['k'] ),
|
373 |
wp_kses( $test['v'], $allowed_tags )
|
374 |
);
|
375 |
} else {
|
376 |
+
$table .= sprintf(
|
377 |
+
'<tr><td colspan="2">%1$s</td></tr>',
|
378 |
esc_html( $test['v'] )
|
379 |
);
|
380 |
}
|
385 |
<div class="functionality-test-section wrap">
|
386 |
|
387 |
<?php
|
388 |
+
printf( '<h1>%1$s</h1>', esc_html__( 'BoldGrid Backup Preflight Check', 'boldgrid-backup' ) );
|
389 |
|
390 |
$nav = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-nav.php';
|
391 |
+
echo $nav; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
392 |
|
393 |
+
echo $fail_tips; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
394 |
|
395 |
+
echo $table; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
396 |
?>
|
397 |
|
398 |
</div>
|
admin/partials/boldgrid-backup-admin-tools.php
CHANGED
@@ -1,23 +1,26 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since 1.
|
7 |
*
|
8 |
-
* @package
|
9 |
* @subpackage Boldgrid_Backup/admin/partials
|
|
|
|
|
|
|
10 |
*/
|
11 |
|
12 |
-
defined( 'WPINC' )
|
13 |
|
14 |
$nav = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-nav.php';
|
15 |
|
16 |
$sections = array(
|
17 |
'sections' => array(
|
18 |
array(
|
19 |
-
'id'
|
20 |
-
'title'
|
21 |
'content' => include BOLDGRID_BACKUP_PATH . '/admin/partials/tools/local-remote.php',
|
22 |
),
|
23 |
),
|
@@ -26,7 +29,7 @@ $sections = array(
|
|
26 |
/**
|
27 |
* Allow other plugins to modify the sections of the tools page.
|
28 |
*
|
29 |
-
* @since 1.
|
30 |
*
|
31 |
* @param array $sections
|
32 |
*/
|
@@ -35,9 +38,11 @@ $sections = apply_filters( 'boldgrid_backup_tools_sections', $sections );
|
|
35 |
/**
|
36 |
* Render the $sections into displayable markup.
|
37 |
*
|
38 |
-
* @since 1.
|
39 |
*
|
40 |
* @param array $sections
|
|
|
|
|
41 |
*/
|
42 |
$col_container = apply_filters( 'Boldgrid\Library\Ui\render_col_container', $sections );
|
43 |
|
@@ -47,7 +52,6 @@ $col_container = apply_filters( 'Boldgrid\Library\Ui\render_col_container', $sec
|
|
47 |
<h1><?php esc_html_e( 'BoldGrid Backup and Restore Settings', 'boldgrid-backup' ); ?></h1>
|
48 |
|
49 |
<?php
|
50 |
-
echo $nav;
|
51 |
-
echo $col_container;
|
52 |
?>
|
53 |
</div>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: boldgrid-backup-admin-tools.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.6.0
|
7 |
*
|
8 |
+
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/admin/partials
|
10 |
+
* @copyright BoldGrid
|
11 |
+
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
defined( 'WPINC' ) || die;
|
16 |
|
17 |
$nav = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-nav.php';
|
18 |
|
19 |
$sections = array(
|
20 |
'sections' => array(
|
21 |
array(
|
22 |
+
'id' => 'section_locations',
|
23 |
+
'title' => __( 'Local & Remote', 'boldgrid-backup' ),
|
24 |
'content' => include BOLDGRID_BACKUP_PATH . '/admin/partials/tools/local-remote.php',
|
25 |
),
|
26 |
),
|
29 |
/**
|
30 |
* Allow other plugins to modify the sections of the tools page.
|
31 |
*
|
32 |
+
* @since 1.6.0
|
33 |
*
|
34 |
* @param array $sections
|
35 |
*/
|
38 |
/**
|
39 |
* Render the $sections into displayable markup.
|
40 |
*
|
41 |
+
* @since 1.6.0
|
42 |
*
|
43 |
* @param array $sections
|
44 |
+
*
|
45 |
+
* phpcs:disable WordPress.NamingConventions.ValidHookName
|
46 |
*/
|
47 |
$col_container = apply_filters( 'Boldgrid\Library\Ui\render_col_container', $sections );
|
48 |
|
52 |
<h1><?php esc_html_e( 'BoldGrid Backup and Restore Settings', 'boldgrid-backup' ); ?></h1>
|
53 |
|
54 |
<?php
|
55 |
+
echo $nav . $col_container; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
|
|
56 |
?>
|
57 |
</div>
|
admin/partials/remote/ftp.php
CHANGED
@@ -1,11 +1,20 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* The file handles the rendering of the settings page.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
8 |
-
$selected
|
9 |
$ftp_selected = 'ftp' === $data['type'] ? $selected : '';
|
10 |
$sftp_selected = 'sftp' === $data['type'] ? $selected : '';
|
11 |
|
@@ -13,7 +22,7 @@ $sftp_selected = 'sftp' === $data['type'] ? $selected : '';
|
|
13 |
|
14 |
<form method="post">
|
15 |
|
16 |
-
<h1><?php
|
17 |
|
18 |
<hr />
|
19 |
|
@@ -21,51 +30,52 @@ $sftp_selected = 'sftp' === $data['type'] ? $selected : '';
|
|
21 |
<tr>
|
22 |
<td>
|
23 |
<?php
|
24 |
-
printf(
|
|
|
25 |
<label for="host">%1$s</label>
|
26 |
<input type="text" name="host" value="%2$s" minlength="5" title="%3$s" required />
|
27 |
',
|
28 |
-
|
29 |
-
$data['host'],
|
30 |
-
|
31 |
);
|
32 |
-
|
33 |
</td>
|
34 |
<td></td>
|
35 |
</tr>
|
36 |
<tr>
|
37 |
<td>
|
38 |
-
<?php
|
39 |
<select name="type">
|
40 |
<option value='ftp' <?php echo esc_attr( $ftp_selected ); ?> >FTP</option>
|
41 |
<option value='sftp' <?php echo esc_attr( $sftp_selected ); ?> >SFTP</option>
|
42 |
</select>
|
43 |
</td>
|
44 |
<td>
|
45 |
-
<?php
|
46 |
-
<input type="number" name="port" value="<?php echo $data['port']; ?>" min="1" required />
|
47 |
</td>
|
48 |
</tr>
|
49 |
<tr>
|
50 |
<td>
|
51 |
-
<?php
|
52 |
-
<input type="text" name="user" value="<?php echo $data['user']; ?>" required />
|
53 |
</td>
|
54 |
<td>
|
55 |
-
<?php
|
56 |
-
<input type="password" name="pass" value="<?php echo $data['pass']; ?>" required />
|
57 |
</td>
|
58 |
</tr>
|
59 |
<tr>
|
60 |
<td>
|
61 |
-
<?php
|
62 |
-
<input type="number" name="retention_count" value="<?php echo $data['retention_count']; ?>" min="1" required/>
|
63 |
</td>
|
64 |
<td></td>
|
65 |
</tr>
|
66 |
<tr>
|
67 |
<td>
|
68 |
-
<?php
|
69 |
<input type="text" name="nickname" value="<?php echo esc_attr( $data['nickname'] ); ?>" />
|
70 |
</td>
|
71 |
<td></td>
|
@@ -74,14 +84,18 @@ $sftp_selected = 'sftp' === $data['type'] ? $selected : '';
|
|
74 |
|
75 |
<p>
|
76 |
<?php
|
77 |
-
echo $this->core->lang['icon_warning']
|
|
|
|
|
|
|
|
|
78 |
?>
|
79 |
</p>
|
80 |
|
81 |
<p>
|
82 |
<input type="hidden" name="action" value="save" />
|
83 |
-
<input class="button button-primary" type="submit" value="<?php
|
84 |
-
<button class="button button-secondary"><?php
|
85 |
<span class="spinner inline middle hidden"></span>
|
86 |
</p>
|
87 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: ftp.php
|
4 |
*
|
5 |
+
* The file handles the rendering of the remove FTP/SFTP options on the settings page.
|
6 |
+
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
+
* @since 1.6.0
|
9 |
+
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
+
* @subpackage Boldgrid_Backup/admin/partials/remote
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
$selected = 'selected="selected"';
|
18 |
$ftp_selected = 'ftp' === $data['type'] ? $selected : '';
|
19 |
$sftp_selected = 'sftp' === $data['type'] ? $selected : '';
|
20 |
|
22 |
|
23 |
<form method="post">
|
24 |
|
25 |
+
<h1><?php esc_html_e( 'BoldGrid Backup - FTP Settings', 'boldgrid-backup' ); ?></h1>
|
26 |
|
27 |
<hr />
|
28 |
|
30 |
<tr>
|
31 |
<td>
|
32 |
<?php
|
33 |
+
printf(
|
34 |
+
'
|
35 |
<label for="host">%1$s</label>
|
36 |
<input type="text" name="host" value="%2$s" minlength="5" title="%3$s" required />
|
37 |
',
|
38 |
+
esc_html__( 'FTP Host', 'boldgrid-backup' ),
|
39 |
+
esc_attr( $data['host'] ),
|
40 |
+
esc_attr__( 'FTP host should be in the format of: example.com', 'boldgrid-backup' )
|
41 |
);
|
42 |
+
?>
|
43 |
</td>
|
44 |
<td></td>
|
45 |
</tr>
|
46 |
<tr>
|
47 |
<td>
|
48 |
+
<?php esc_html_e( 'FTP / SFTP', 'boldgrid-backup' ); ?><br />
|
49 |
<select name="type">
|
50 |
<option value='ftp' <?php echo esc_attr( $ftp_selected ); ?> >FTP</option>
|
51 |
<option value='sftp' <?php echo esc_attr( $sftp_selected ); ?> >SFTP</option>
|
52 |
</select>
|
53 |
</td>
|
54 |
<td>
|
55 |
+
<?php esc_html_e( 'FTP Port', 'boldgrid-backup' ); ?><br />
|
56 |
+
<input type="number" name="port" value="<?php echo esc_attr( $data['port'] ); ?>" min="1" required />
|
57 |
</td>
|
58 |
</tr>
|
59 |
<tr>
|
60 |
<td>
|
61 |
+
<?php esc_html_e( 'FTP Username', 'boldgrid-backup' ); ?><br />
|
62 |
+
<input type="text" name="user" value="<?php echo esc_attr( $data['user'] ); ?>" required />
|
63 |
</td>
|
64 |
<td>
|
65 |
+
<?php esc_html_e( 'FTP Password', 'boldgrid-backup' ); ?><br />
|
66 |
+
<input type="password" name="pass" value="<?php echo esc_attr( $data['pass'] ); ?>" required />
|
67 |
</td>
|
68 |
</tr>
|
69 |
<tr>
|
70 |
<td>
|
71 |
+
<?php esc_html_e( 'Retention (Number of backup archives to retain)', 'boldgrid-backup' ); ?><br />
|
72 |
+
<input type="number" name="retention_count" value="<?php echo esc_attr( $data['retention_count'] ); ?>" min="1" required/>
|
73 |
</td>
|
74 |
<td></td>
|
75 |
</tr>
|
76 |
<tr>
|
77 |
<td>
|
78 |
+
<?php esc_html_e( 'Nickname (If you would like to refer to this account as something other than FTP)', 'boldgrid-backup' ); ?><br />
|
79 |
<input type="text" name="nickname" value="<?php echo esc_attr( $data['nickname'] ); ?>" />
|
80 |
</td>
|
81 |
<td></td>
|
84 |
|
85 |
<p>
|
86 |
<?php
|
87 |
+
echo $this->core->lang['icon_warning']; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
88 |
+
esc_html_e(
|
89 |
+
'With automated FTP your credentials must be stored here in your WordPress. They will be encrypted in the database and this protects them significantly, but they could be decrypted in the unlikely event of a compromise. We recommended you use a separate FTP user and password specifically for backups.',
|
90 |
+
'boldgrid-backup'
|
91 |
+
);
|
92 |
?>
|
93 |
</p>
|
94 |
|
95 |
<p>
|
96 |
<input type="hidden" name="action" value="save" />
|
97 |
+
<input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Save changes', 'boldgrid-backup' ); ?>" />
|
98 |
+
<button class="button button-secondary"><?php esc_html_e( 'Delete settings', 'boldgrid-backup' ); ?></button>
|
99 |
<span class="spinner inline middle hidden"></span>
|
100 |
</p>
|
101 |
|
admin/partials/settings/auto-updates.php
CHANGED
@@ -1,18 +1,27 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Show "Auto Updates" on settings page.
|
4 |
*
|
5 |
-
* @
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
8 |
-
defined( 'WPINC' )
|
9 |
|
10 |
ob_start();
|
11 |
?>
|
12 |
|
13 |
<div class="bg-box">
|
14 |
<div class="bg-box-top">
|
15 |
-
<?php
|
16 |
</div>
|
17 |
<div class="bg-box-bottom">
|
18 |
|
@@ -20,104 +29,131 @@ ob_start();
|
|
20 |
<tr>
|
21 |
<th>
|
22 |
<?php esc_html_e( 'Plugin Auto-Updates', 'boldgrid-backup' ); ?>
|
23 |
-
|
24 |
|
25 |
-
|
26 |
<?php
|
27 |
printf(
|
28 |
-
|
|
|
|
|
|
|
|
|
29 |
'https://codex.wordpress.org/Configuring_Automatic_Background_Updates#Plugin_.26_Theme_Updates_via_Filter'
|
30 |
);
|
31 |
?>
|
32 |
</p>
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
36 |
<?php
|
37 |
if ( isset( $settings['plugin_autoupdate'] ) &&
|
38 |
-
|
39 |
-
|
|
|
|
|
40 |
}
|
41 |
-
?>
|
|
|
42 |
id="plugin-autoupdate-disabled" type="radio" name="plugin_autoupdate" value="0"
|
43 |
<?php
|
44 |
if ( ! isset( $settings['plugin_autoupdate'] ) ||
|
45 |
! $settings['plugin_autoupdate'] ) {
|
46 |
-
|
|
|
|
|
47 |
}
|
48 |
-
?>
|
49 |
-
|
50 |
-
|
|
|
51 |
|
52 |
-
|
53 |
-
|
54 |
<?php esc_html_e( 'Theme Auto-Updates', 'boldgrid-backup' ); ?>
|
55 |
-
|
56 |
|
57 |
-
|
58 |
<?php
|
59 |
printf(
|
60 |
-
|
|
|
|
|
|
|
|
|
61 |
'https://codex.wordpress.org/Configuring_Automatic_Background_Updates#Plugin_.26_Theme_Updates_via_Filter'
|
62 |
);
|
63 |
?>
|
64 |
<p>
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
<?php
|
69 |
if ( isset( $settings['theme_autoupdate'] ) &&
|
70 |
-
|
71 |
-
|
|
|
|
|
72 |
}
|
73 |
-
?>
|
|
|
74 |
id="theme-autoupdate-disabled" type="radio" name="theme_autoupdate" value="0"
|
75 |
<?php
|
76 |
if ( ! isset( $settings['theme_autoupdate'] ) ||
|
77 |
! $settings['theme_autoupdate'] ) {
|
78 |
-
|
|
|
|
|
79 |
}
|
80 |
-
?>
|
81 |
-
|
82 |
-
|
|
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
<?php
|
87 |
-
|
88 |
|
89 |
-
|
90 |
<?php
|
91 |
printf(
|
92 |
-
|
|
|
|
|
|
|
|
|
93 |
'https://developer.wordpress.org/reference/hooks/pre_auto_update/'
|
94 |
);
|
95 |
?>
|
96 |
<p>
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
value='1'
|
101 |
<?php
|
102 |
if ( ! isset( $settings['auto_backup'] ) ||
|
103 |
-
|
104 |
echo ' checked';
|
105 |
}
|
106 |
-
?>
|
|
|
107 |
id='auto-backup-disabled' type='radio' name='auto_backup' value='0'
|
108 |
<?php
|
109 |
if ( isset( $settings['auto_backup'] ) && 0 === $settings['auto_backup'] ) {
|
110 |
echo ' checked';
|
111 |
}
|
112 |
-
?>
|
113 |
-
|
114 |
-
|
|
|
115 |
|
116 |
-
|
117 |
-
|
118 |
<?php esc_html_e( 'Auto Rollback', 'boldgrid-backup' ); ?><span class='dashicons dashicons-editor-help' data-id='auto-rollback'></span>
|
119 |
|
120 |
-
|
121 |
<?php
|
122 |
esc_html_e(
|
123 |
'If something goes wrong while performing WordPress updates, automatically restore the site using a backup made before updating WordPress. This feature does not apply to auto updates.',
|
@@ -125,25 +161,27 @@ ob_start();
|
|
125 |
);
|
126 |
?>
|
127 |
</p>
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
value='1'
|
132 |
<?php
|
133 |
if ( ! isset( $settings['auto_rollback'] ) ||
|
134 |
-
|
135 |
echo ' checked';
|
136 |
}
|
137 |
-
?>
|
|
|
138 |
id='auto-rollback-disabled' type='radio' name='auto_rollback'
|
139 |
value='0'
|
140 |
<?php
|
141 |
if ( isset( $settings['auto_rollback'] ) && 0 === $settings['auto_rollback'] ) {
|
142 |
echo ' checked';
|
143 |
}
|
144 |
-
?>
|
145 |
-
|
146 |
-
|
|
|
147 |
</table>
|
148 |
</div>
|
149 |
</div>
|
@@ -152,4 +190,3 @@ ob_start();
|
|
152 |
$output = ob_get_contents();
|
153 |
ob_end_clean();
|
154 |
return $output;
|
155 |
-
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: auto-updates.php
|
4 |
+
*
|
5 |
* Show "Auto Updates" on settings page.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
+
* @since 1.6.0
|
9 |
+
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
+
* @subpackage Boldgrid_Backup/admin/partials/settings
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
defined( 'WPINC' ) || die;
|
18 |
|
19 |
ob_start();
|
20 |
?>
|
21 |
|
22 |
<div class="bg-box">
|
23 |
<div class="bg-box-top">
|
24 |
+
<?php esc_html_e( 'Auto Updates and Rollback', 'boldgrid-inspirations' ); ?>
|
25 |
</div>
|
26 |
<div class="bg-box-bottom">
|
27 |
|
29 |
<tr>
|
30 |
<th>
|
31 |
<?php esc_html_e( 'Plugin Auto-Updates', 'boldgrid-backup' ); ?>
|
32 |
+
<span class="dashicons dashicons-editor-help" data-id="plugin-autoupdate"></span>
|
33 |
|
34 |
+
<p class="help" data-id="plugin-autoupdate">
|
35 |
<?php
|
36 |
printf(
|
37 |
+
// translators: 1: URL address.
|
38 |
+
esc_html__(
|
39 |
+
'Automatically perform all plugin updates when available. Enabling this feature adds the <a target="_blank" href="%1$s">auto_update_plugin filter</a>, which enables automatic plugin updates when an update is available.',
|
40 |
+
'boldgrid-backup'
|
41 |
+
),
|
42 |
'https://codex.wordpress.org/Configuring_Automatic_Background_Updates#Plugin_.26_Theme_Updates_via_Filter'
|
43 |
);
|
44 |
?>
|
45 |
</p>
|
46 |
+
</th>
|
47 |
+
<td>
|
48 |
+
<input id="plugin-autoupdate-enabled" type="radio" name="plugin_autoupdate"
|
49 |
+
value="1"
|
50 |
<?php
|
51 |
if ( isset( $settings['plugin_autoupdate'] ) &&
|
52 |
+
1 === $settings['plugin_autoupdate'] ) {
|
53 |
+
?>
|
54 |
+
checked
|
55 |
+
<?php
|
56 |
}
|
57 |
+
?>
|
58 |
+
/> <?php esc_html_e( 'Enabled', 'boldgrid-backup' ); ?> <input
|
59 |
id="plugin-autoupdate-disabled" type="radio" name="plugin_autoupdate" value="0"
|
60 |
<?php
|
61 |
if ( ! isset( $settings['plugin_autoupdate'] ) ||
|
62 |
! $settings['plugin_autoupdate'] ) {
|
63 |
+
?>
|
64 |
+
checked
|
65 |
+
<?php
|
66 |
}
|
67 |
+
?>
|
68 |
+
/> <?php esc_html_e( 'Disabled', 'boldgrid-backup' ); ?>
|
69 |
+
</td>
|
70 |
+
</tr>
|
71 |
|
72 |
+
<tr>
|
73 |
+
<th>
|
74 |
<?php esc_html_e( 'Theme Auto-Updates', 'boldgrid-backup' ); ?>
|
75 |
+
<span class="dashicons dashicons-editor-help" data-id="theme-autoupdate"></span>
|
76 |
|
77 |
+
<p class="help" data-id="theme-autoupdate">
|
78 |
<?php
|
79 |
printf(
|
80 |
+
// translators: 1: URL address.
|
81 |
+
esc_html__(
|
82 |
+
'Automatically perform all theme updates when available. Enabling this feature adds the <a target="_blank" href="%1$s">auto_update_theme filter</a>, which enables automatic theme updates when an update is available.',
|
83 |
+
'boldgrid-backup'
|
84 |
+
),
|
85 |
'https://codex.wordpress.org/Configuring_Automatic_Background_Updates#Plugin_.26_Theme_Updates_via_Filter'
|
86 |
);
|
87 |
?>
|
88 |
<p>
|
89 |
+
</th>
|
90 |
+
<td>
|
91 |
+
<input id="theme-autoupdate-enabled" type="radio" name="theme_autoupdate" value="1"
|
92 |
<?php
|
93 |
if ( isset( $settings['theme_autoupdate'] ) &&
|
94 |
+
1 === $settings['theme_autoupdate'] ) {
|
95 |
+
?>
|
96 |
+
checked
|
97 |
+
<?php
|
98 |
}
|
99 |
+
?>
|
100 |
+
/> <?php esc_html_e( 'Enabled', 'boldgrid-backup' ); ?> <input
|
101 |
id="theme-autoupdate-disabled" type="radio" name="theme_autoupdate" value="0"
|
102 |
<?php
|
103 |
if ( ! isset( $settings['theme_autoupdate'] ) ||
|
104 |
! $settings['theme_autoupdate'] ) {
|
105 |
+
?>
|
106 |
+
checked
|
107 |
+
<?php
|
108 |
}
|
109 |
+
?>
|
110 |
+
/> <?php esc_html_e( 'Disabled', 'boldgrid-backup' ); ?>
|
111 |
+
</td>
|
112 |
+
</tr>
|
113 |
|
114 |
+
<tr>
|
115 |
+
<th>
|
116 |
+
<?php esc_html_e( 'Auto Backup<br />Before Updates', 'boldgrid-backup' ); ?>
|
117 |
+
<span class='dashicons dashicons-editor-help' data-id='auto-backup'></span>
|
118 |
|
119 |
+
<p class='help' data-id='auto-backup'>
|
120 |
<?php
|
121 |
printf(
|
122 |
+
// translators: 1: URL address.
|
123 |
+
esc_html__(
|
124 |
+
'Automatically perform a backup before WordPress updates. When this feature is enabled, a full backup will be made during the <a target="_blank" href="%1$s">pre_auto_update action</a>. ',
|
125 |
+
'boldgrid-backup'
|
126 |
+
),
|
127 |
'https://developer.wordpress.org/reference/hooks/pre_auto_update/'
|
128 |
);
|
129 |
?>
|
130 |
<p>
|
131 |
+
</th>
|
132 |
+
<td>
|
133 |
+
<input id='auto-backup-enabled' type='radio' name='auto_backup'
|
134 |
value='1'
|
135 |
<?php
|
136 |
if ( ! isset( $settings['auto_backup'] ) ||
|
137 |
+
1 === $settings['auto_backup'] ) {
|
138 |
echo ' checked';
|
139 |
}
|
140 |
+
?>
|
141 |
+
/> <?php esc_html_e( 'Enabled', 'boldgrid-backup' ); ?> <input
|
142 |
id='auto-backup-disabled' type='radio' name='auto_backup' value='0'
|
143 |
<?php
|
144 |
if ( isset( $settings['auto_backup'] ) && 0 === $settings['auto_backup'] ) {
|
145 |
echo ' checked';
|
146 |
}
|
147 |
+
?>
|
148 |
+
/> <?php esc_html_e( 'Disabled', 'boldgrid-backup' ); ?>
|
149 |
+
</td>
|
150 |
+
</tr>
|
151 |
|
152 |
+
<tr>
|
153 |
+
<th>
|
154 |
<?php esc_html_e( 'Auto Rollback', 'boldgrid-backup' ); ?><span class='dashicons dashicons-editor-help' data-id='auto-rollback'></span>
|
155 |
|
156 |
+
<p class='help' data-id='auto-rollback'>
|
157 |
<?php
|
158 |
esc_html_e(
|
159 |
'If something goes wrong while performing WordPress updates, automatically restore the site using a backup made before updating WordPress. This feature does not apply to auto updates.',
|
161 |
);
|
162 |
?>
|
163 |
</p>
|
164 |
+
</th>
|
165 |
+
<td>
|
166 |
+
<input id='auto-rollback-enabled' type='radio' name='auto_rollback'
|
167 |
value='1'
|
168 |
<?php
|
169 |
if ( ! isset( $settings['auto_rollback'] ) ||
|
170 |
+
1 === $settings['auto_rollback'] ) {
|
171 |
echo ' checked';
|
172 |
}
|
173 |
+
?>
|
174 |
+
/> <?php esc_html_e( 'Enabled', 'boldgrid-backup' ); ?> <input
|
175 |
id='auto-rollback-disabled' type='radio' name='auto_rollback'
|
176 |
value='0'
|
177 |
<?php
|
178 |
if ( isset( $settings['auto_rollback'] ) && 0 === $settings['auto_rollback'] ) {
|
179 |
echo ' checked';
|
180 |
}
|
181 |
+
?>
|
182 |
+
/> <?php esc_html_e( 'Disabled', 'boldgrid-backup' ); ?>
|
183 |
+
</td>
|
184 |
+
</tr>
|
185 |
</table>
|
186 |
</div>
|
187 |
</div>
|
190 |
$output = ob_get_contents();
|
191 |
ob_end_clean();
|
192 |
return $output;
|
|
admin/partials/settings/backup-directory.php
CHANGED
@@ -1,11 +1,20 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Show "Backup Directory" on settings page.
|
4 |
*
|
|
|
5 |
* @since 1.3.1
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
8 |
-
defined( 'WPINC' )
|
9 |
|
10 |
ob_start();
|
11 |
?>
|
@@ -19,6 +28,7 @@ ob_start();
|
|
19 |
|
20 |
<p class="help" data-id="backup-dir">
|
21 |
<?php
|
|
|
22 |
/*
|
23 |
* Print this text:
|
24 |
*
|
@@ -26,21 +36,29 @@ ob_start();
|
|
26 |
* this, it is not recommended that you change it again. You can find more help with setting
|
27 |
* your backup directory <a>here</a>.
|
28 |
*/
|
29 |
-
|
30 |
wp_kses(
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
),
|
34 |
esc_url( $this->core->configs['urls']['setting_directory'] )
|
35 |
);
|
36 |
-
echo $link;
|
37 |
?>
|
38 |
</p>
|
39 |
|
40 |
<table class='backup-directory form-table'>
|
41 |
<tr>
|
42 |
<th><?php esc_html_e( 'Directory to store backup archives', 'boldgrid-backup' ); ?>:</th>
|
43 |
-
<td><input id='backup-directory-path' type='text' size='40' name='backup_directory' value='<?php echo $settings['backup_directory']; ?>'></td>
|
44 |
</tr>
|
45 |
<tr id="move-backups" class="hidden">
|
46 |
<th><?php esc_html_e( 'If you change this directory, current backups will not show in the list. Would you like us to move the backups to the new directory?', 'boldgrid-backup' ); ?></th>
|
@@ -54,4 +72,3 @@ ob_start();
|
|
54 |
$output = ob_get_contents();
|
55 |
ob_end_clean();
|
56 |
return $output;
|
57 |
-
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: backup-directory.php
|
4 |
+
*
|
5 |
* Show "Backup Directory" on settings page.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.3.1
|
9 |
+
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
+
* @subpackage Boldgrid_Backup/admin/partials/settings
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
defined( 'WPINC' ) || die;
|
18 |
|
19 |
ob_start();
|
20 |
?>
|
28 |
|
29 |
<p class="help" data-id="backup-dir">
|
30 |
<?php
|
31 |
+
|
32 |
/*
|
33 |
* Print this text:
|
34 |
*
|
36 |
* this, it is not recommended that you change it again. You can find more help with setting
|
37 |
* your backup directory <a>here</a>.
|
38 |
*/
|
39 |
+
printf(
|
40 |
wp_kses(
|
41 |
+
// translators: 1: URL address.
|
42 |
+
esc_html__(
|
43 |
+
'For security purposes, please do not set this to a publicly available directory. Once you set this, it is not recommended that you change it again. You can find more help with setting your backup directory <a href="%s" target="_blank">here</a>.',
|
44 |
+
'boldgrid-backup'
|
45 |
+
),
|
46 |
+
array(
|
47 |
+
'a' => array(
|
48 |
+
'href' => array(),
|
49 |
+
'target' => array(),
|
50 |
+
),
|
51 |
+
)
|
52 |
),
|
53 |
esc_url( $this->core->configs['urls']['setting_directory'] )
|
54 |
);
|
|
|
55 |
?>
|
56 |
</p>
|
57 |
|
58 |
<table class='backup-directory form-table'>
|
59 |
<tr>
|
60 |
<th><?php esc_html_e( 'Directory to store backup archives', 'boldgrid-backup' ); ?>:</th>
|
61 |
+
<td><input id='backup-directory-path' type='text' size='40' name='backup_directory' value='<?php echo esc_attr( $settings['backup_directory'] ); ?>'></td>
|
62 |
</tr>
|
63 |
<tr id="move-backups" class="hidden">
|
64 |
<th><?php esc_html_e( 'If you change this directory, current backups will not show in the list. Would you like us to move the backups to the new directory?', 'boldgrid-backup' ); ?></th>
|
72 |
$output = ob_get_contents();
|
73 |
ob_end_clean();
|
74 |
return $output;
|
|
admin/partials/settings/compressor.php
CHANGED
@@ -1,16 +1,21 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
|
|
5 |
* This page is only shown for testers who have appropriate hooks in place.
|
6 |
*
|
|
|
7 |
* @since 1.5.1
|
8 |
*
|
9 |
* @package Boldgrid_Backup
|
10 |
* @subpackage Boldgrid_Backup/admin/partials/settings
|
|
|
|
|
|
|
11 |
*/
|
12 |
|
13 |
-
defined( 'WPINC' )
|
14 |
|
15 |
ob_start();
|
16 |
|
@@ -19,14 +24,24 @@ $selected = 'selected="selected"';
|
|
19 |
$available_compressors = array( 'php_zip', 'pcl_zip' );
|
20 |
|
21 |
// Settings for compressor.
|
22 |
-
$pcl_zip_selected = empty( $settings['compressor'] ) || 'pcl_zip' === $settings['compressor'] ?
|
23 |
-
$
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
// Settings for extractor.
|
27 |
-
$extractor_pcl_zip_selected = ! empty( $settings['extractor'] ) && 'pcl_zip' === $settings['extractor'] ?
|
28 |
-
$
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
?>
|
32 |
<div class="bg-box">
|
@@ -38,26 +53,26 @@ $extractor_php_zip_option = ! in_array( 'php_zip', $available_compressors ) ? ''
|
|
38 |
|
39 |
<p class="help" data-id="compressor">
|
40 |
<?php
|
41 |
-
|
42 |
?>
|
43 |
</p>
|
44 |
|
45 |
<table class="form-table">
|
46 |
<tr>
|
47 |
-
<th><?php
|
48 |
<td>
|
49 |
<select name="compressor">
|
50 |
-
<option value='pcl_zip' <?php echo $pcl_zip_selected; ?> >PclZip</option>
|
51 |
-
<?php echo $php_zip_option; ?>
|
52 |
</select>
|
53 |
</td>
|
54 |
</tr>
|
55 |
<tr>
|
56 |
-
<th><?php
|
57 |
<td>
|
58 |
<select name="extractor">
|
59 |
-
<option value='pcl_zip' <?php echo $extractor_pcl_zip_selected; ?> >PclZip</option>
|
60 |
-
<?php echo $extractor_php_zip_option; ?>
|
61 |
</select>
|
62 |
</td>
|
63 |
</tr>
|
@@ -69,4 +84,3 @@ $extractor_php_zip_option = ! in_array( 'php_zip', $available_compressors ) ? ''
|
|
69 |
$output = ob_get_contents();
|
70 |
ob_end_clean();
|
71 |
return $output;
|
72 |
-
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: compressor.php
|
4 |
*
|
5 |
+
* Compressor on settings page.
|
6 |
* This page is only shown for testers who have appropriate hooks in place.
|
7 |
*
|
8 |
+
* @link https://www.boldgrid.com
|
9 |
* @since 1.5.1
|
10 |
*
|
11 |
* @package Boldgrid_Backup
|
12 |
* @subpackage Boldgrid_Backup/admin/partials/settings
|
13 |
+
* @copyright BoldGrid
|
14 |
+
* @version $Id$
|
15 |
+
* @author BoldGrid <support@boldgrid.com>
|
16 |
*/
|
17 |
|
18 |
+
defined( 'WPINC' ) || die;
|
19 |
|
20 |
ob_start();
|
21 |
|
24 |
$available_compressors = array( 'php_zip', 'pcl_zip' );
|
25 |
|
26 |
// Settings for compressor.
|
27 |
+
$pcl_zip_selected = empty( $settings['compressor'] ) || 'pcl_zip' === $settings['compressor'] ?
|
28 |
+
$selected : '';
|
29 |
+
|
30 |
+
$php_zip_selected = ! empty( $settings['compressor'] ) && 'php_zip' === $settings['compressor'] ?
|
31 |
+
$selected : '';
|
32 |
+
|
33 |
+
$php_zip_option = ! in_array( 'php_zip', $available_compressors, true ) ?
|
34 |
+
'' : sprintf( '<option value="php_zip" %1$s>ZipArchive</option>', $php_zip_selected );
|
35 |
|
36 |
// Settings for extractor.
|
37 |
+
$extractor_pcl_zip_selected = ! empty( $settings['extractor'] ) && 'pcl_zip' === $settings['extractor'] ?
|
38 |
+
$selected : '';
|
39 |
+
|
40 |
+
$extractor_php_zip_selected = empty( $settings['extractor'] ) || 'php_zip' === $settings['extractor'] ?
|
41 |
+
$selected : '';
|
42 |
+
|
43 |
+
$extractor_php_zip_option = ! in_array( 'php_zip', $available_compressors, true ) ?
|
44 |
+
'' : sprintf( '<option value="php_zip" %1$s>ZipArchive</option>', $extractor_php_zip_selected );
|
45 |
|
46 |
?>
|
47 |
<div class="bg-box">
|
53 |
|
54 |
<p class="help" data-id="compressor">
|
55 |
<?php
|
56 |
+
esc_html_e( 'These are advanced settings. You do not need to configure this setting.', 'boldgrid-backup' );
|
57 |
?>
|
58 |
</p>
|
59 |
|
60 |
<table class="form-table">
|
61 |
<tr>
|
62 |
+
<th><?php esc_html_e( 'Compressor', 'boldgrid-backup' ); ?>:</th>
|
63 |
<td>
|
64 |
<select name="compressor">
|
65 |
+
<option value='pcl_zip' <?php echo esc_attr( $pcl_zip_selected ); ?> >PclZip</option>
|
66 |
+
<?php echo $php_zip_option; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>
|
67 |
</select>
|
68 |
</td>
|
69 |
</tr>
|
70 |
<tr>
|
71 |
+
<th><?php esc_html_e( 'Extractor', 'boldgrid-backup' ); ?>:</th>
|
72 |
<td>
|
73 |
<select name="extractor">
|
74 |
+
<option value='pcl_zip' <?php echo esc_attr( $extractor_pcl_zip_selected ); ?> >PclZip</option>
|
75 |
+
<?php echo $extractor_php_zip_option; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>
|
76 |
</select>
|
77 |
</td>
|
78 |
</tr>
|
84 |
$output = ob_get_contents();
|
85 |
ob_end_clean();
|
86 |
return $output;
|
|
admin/partials/settings/connect-key.php
CHANGED
@@ -4,11 +4,19 @@
|
|
4 |
*
|
5 |
* Show Connect Key status.
|
6 |
*
|
7 |
-
* @
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
*/
|
9 |
|
10 |
-
defined( 'WPINC' )
|
11 |
|
|
|
12 |
$is_dismissed = apply_filters( 'Boldgrid\Library\Notice\KeyPrompt\getIsDismissed', false );
|
13 |
$is_displayed = apply_filters( 'Boldgrid\Library\Notice\KeyPrompt\getIsDisplayed', false );
|
14 |
|
@@ -30,18 +38,25 @@ $refresh_key = ! $has_key_entered || $this->core->config->get_is_premium() ? ''
|
|
30 |
ob_start();
|
31 |
if ( $has_key_entered ) {
|
32 |
printf(
|
|
|
33 |
__( 'You have entered a <strong>%1$s</strong> BoldGrid Connect Key.', 'boldgrid-backup' ),
|
34 |
-
$this->core->config->get_is_premium() ?
|
|
|
35 |
);
|
36 |
} elseif ( $is_dismissed ) {
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
40 |
);
|
41 |
|
42 |
wp_nonce_field( 'boldgrid_set_key', 'set_key_auth' );
|
43 |
} else {
|
44 |
-
|
45 |
}
|
46 |
$output = ob_get_contents();
|
47 |
ob_end_clean();
|
@@ -64,5 +79,5 @@ return '
|
|
64 |
' . $output . $refresh_key . '
|
65 |
</div>
|
66 |
' . $bottom_box_premium . '
|
67 |
-
</div>
|
68 |
-
|
4 |
*
|
5 |
* Show Connect Key status.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
+
* @since 1.6.0
|
9 |
+
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
+
* @subpackage Boldgrid_Backup/admin/partials/settings
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
defined( 'WPINC' ) || die;
|
18 |
|
19 |
+
/* phpcs:disable WordPress.NamingConventions.ValidHookName */
|
20 |
$is_dismissed = apply_filters( 'Boldgrid\Library\Notice\KeyPrompt\getIsDismissed', false );
|
21 |
$is_displayed = apply_filters( 'Boldgrid\Library\Notice\KeyPrompt\getIsDisplayed', false );
|
22 |
|
38 |
ob_start();
|
39 |
if ( $has_key_entered ) {
|
40 |
printf(
|
41 |
+
// translators: 1: Subscription type ("Premium" or "Free").
|
42 |
__( 'You have entered a <strong>%1$s</strong> BoldGrid Connect Key.', 'boldgrid-backup' ),
|
43 |
+
$this->core->config->get_is_premium() ?
|
44 |
+
esc_html__( 'Premium', 'boldgrid-backup' ) : esc_html__( 'Free', 'boldgrid-backup' )
|
45 |
);
|
46 |
} elseif ( $is_dismissed ) {
|
47 |
+
printf(
|
48 |
+
// translators: 1: HTML anchor open tag. 2: HTML anchor close taag.
|
49 |
+
esc_html__(
|
50 |
+
'You have dismissed the prompt to enter a BoldGrid Connect Key. Click %1$shere%2$s to restore the prompt.',
|
51 |
+
'boldgrid-backup'
|
52 |
+
),
|
53 |
+
'<a class="undismissBoldgridNotice" href="#">',
|
54 |
+
'</a>'
|
55 |
);
|
56 |
|
57 |
wp_nonce_field( 'boldgrid_set_key', 'set_key_auth' );
|
58 |
} else {
|
59 |
+
esc_html_e( 'Please enter your BoldGrid Connect Key in the form at the top of this page.', 'boldgrid-backup' );
|
60 |
}
|
61 |
$output = ob_get_contents();
|
62 |
ob_end_clean();
|
79 |
' . $output . $refresh_key . '
|
80 |
</div>
|
81 |
' . $bottom_box_premium . '
|
82 |
+
</div>
|
83 |
+
';
|
admin/partials/settings/days-of-week.php
CHANGED
@@ -1,11 +1,20 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Days of the week.
|
4 |
*
|
5 |
-
* @
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
8 |
-
defined( 'WPINC' )
|
9 |
|
10 |
ob_start();
|
11 |
?>
|
@@ -15,33 +24,83 @@ ob_start();
|
|
15 |
<?php esc_html_e( 'Days of the Week', 'boldgrid-backup' ); ?>
|
16 |
</div>
|
17 |
<div class="bg-box-bottom">
|
18 |
-
<input id='dow-sunday' type='checkbox' name='dow_sunday' value='1'
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
<input id='dow-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
<br /><br />
|
27 |
|
28 |
<div class='hidden' id='no-backup-days'>
|
29 |
-
<p><span class="dashicons dashicons-warning yellow"></span>
|
|
|
30 |
esc_html_e( 'Backup will not occur if no days are selected.', 'boldgrid-backup' );
|
31 |
-
|
|
|
32 |
</div>
|
33 |
|
34 |
<?php
|
35 |
$url = $this->core->configs['urls']['resource_usage'];
|
36 |
-
|
|
|
|
|
|
|
37 |
wp_kses(
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
),
|
41 |
esc_url( $url )
|
42 |
);
|
43 |
-
|
44 |
-
|
|
|
45 |
</div>
|
46 |
</div>
|
47 |
|
@@ -49,4 +108,3 @@ ob_start();
|
|
49 |
$output = ob_get_contents();
|
50 |
ob_end_clean();
|
51 |
return $output;
|
52 |
-
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: days-of-week.php
|
4 |
+
*
|
5 |
* Days of the week.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
+
* @since 1.6.0
|
9 |
+
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
+
* @subpackage Boldgrid_Backup/admin/partials/settings
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
defined( 'WPINC' ) || die;
|
18 |
|
19 |
ob_start();
|
20 |
?>
|
24 |
<?php esc_html_e( 'Days of the Week', 'boldgrid-backup' ); ?>
|
25 |
</div>
|
26 |
<div class="bg-box-bottom">
|
27 |
+
<input id='dow-sunday' type='checkbox' name='dow_sunday' value='1'
|
28 |
+
<?php
|
29 |
+
if ( ! empty( $settings['schedule']['dow_sunday'] ) ) {
|
30 |
+
echo ' checked'; }
|
31 |
+
?>
|
32 |
+
/><?php esc_html_e( 'Sunday', 'boldgrid-backup' ); ?><br />
|
33 |
+
<input id='dow-monday' type='checkbox' name='dow_monday' value='1'
|
34 |
+
<?php
|
35 |
+
if ( ! empty( $settings['schedule']['dow_monday'] ) ) {
|
36 |
+
echo ' checked'; }
|
37 |
+
?>
|
38 |
+
/><?php esc_html_e( 'Monday', 'boldgrid-backup' ); ?><br />
|
39 |
+
<input id='dow-tuesday' type='checkbox' name='dow_tuesday' value='1'
|
40 |
+
<?php
|
41 |
+
if ( ! empty( $settings['schedule']['dow_tuesday'] ) ) {
|
42 |
+
echo ' checked'; }
|
43 |
+
?>
|
44 |
+
/><?php esc_html_e( 'Tuesday', 'boldgrid-backup' ); ?><br />
|
45 |
+
<input id='dow-wednesday' type='checkbox' name='dow_wednesday' value='1'
|
46 |
+
<?php
|
47 |
+
if ( ! empty( $settings['schedule']['dow_wednesday'] ) ) {
|
48 |
+
echo ' checked'; }
|
49 |
+
?>
|
50 |
+
/><?php esc_html_e( 'Wednesday', 'boldgrid-backup' ); ?><br />
|
51 |
+
<input id='dow-thursday' type='checkbox' name='dow_thursday' value='1'
|
52 |
+
<?php
|
53 |
+
if ( ! empty( $settings['schedule']['dow_thursday'] ) ) {
|
54 |
+
echo ' checked'; }
|
55 |
+
?>
|
56 |
+
/><?php esc_html_e( 'Thursday', 'boldgrid-backup' ); ?><br />
|
57 |
+
<input id='dow-friday' type='checkbox' name='dow_friday' value='1'
|
58 |
+
<?php
|
59 |
+
if ( ! empty( $settings['schedule']['dow_friday'] ) ) {
|
60 |
+
echo ' checked'; }
|
61 |
+
?>
|
62 |
+
/><?php esc_html_e( 'Friday', 'boldgrid-backup' ); ?><br />
|
63 |
+
<input id='dow-saturday' type='checkbox' name='dow_saturday' value='1'
|
64 |
+
<?php
|
65 |
+
if ( ! empty( $settings['schedule']['dow_saturday'] ) ) {
|
66 |
+
echo ' checked'; }
|
67 |
+
?>
|
68 |
+
/><?php esc_html_e( 'Saturday', 'boldgrid-backup' ); ?>
|
69 |
|
70 |
<br /><br />
|
71 |
|
72 |
<div class='hidden' id='no-backup-days'>
|
73 |
+
<p><span class="dashicons dashicons-warning yellow"></span>
|
74 |
+
<?php
|
75 |
esc_html_e( 'Backup will not occur if no days are selected.', 'boldgrid-backup' );
|
76 |
+
?>
|
77 |
+
</p>
|
78 |
</div>
|
79 |
|
80 |
<?php
|
81 |
$url = $this->core->configs['urls']['resource_usage'];
|
82 |
+
|
83 |
+
echo '<div id="use-sparingly" class="hidden"><p><span class="dashicons dashicons-warning yellow"></span> ';
|
84 |
+
|
85 |
+
printf(
|
86 |
wp_kses(
|
87 |
+
// translators: 1: HTML markup.
|
88 |
+
__(
|
89 |
+
'Backups use resources and <a href="%s" target="_blank">must pause your site</a> momentarily. Use sparingly.',
|
90 |
+
'boldgrid-backup'
|
91 |
+
),
|
92 |
+
array(
|
93 |
+
'a' => array(
|
94 |
+
'href' => array(),
|
95 |
+
'target' => array(),
|
96 |
+
),
|
97 |
+
)
|
98 |
),
|
99 |
esc_url( $url )
|
100 |
);
|
101 |
+
|
102 |
+
echo '</p></div>';
|
103 |
+
?>
|
104 |
</div>
|
105 |
</div>
|
106 |
|
108 |
$output = ob_get_contents();
|
109 |
ob_end_clean();
|
110 |
return $output;
|
|
admin/partials/settings/db.php
CHANGED
@@ -2,10 +2,17 @@
|
|
2 |
/**
|
3 |
* Database settings.
|
4 |
*
|
|
|
5 |
* @since 1.5.3
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
8 |
-
defined( 'WPINC' )
|
9 |
|
10 |
// $core will vary based on how this file is included.
|
11 |
$core = isset( $this->core ) ? $this->core : $this;
|
@@ -17,12 +24,13 @@ $tables = $core->db_omit->format_prefixed_tables();
|
|
17 |
|
18 |
// Determine if the "Backup all tables" option should be checked.
|
19 |
$all_included = empty( $settings['exclude_tables'] );
|
20 |
-
$type
|
21 |
$full_checked = 'full' === $type || $all_included;
|
22 |
|
23 |
$checked = 'checked="checked"';
|
24 |
|
25 |
-
$types = sprintf(
|
|
|
26 |
<input type="radio" name="table_inclusion_type" value="full" %3$s>%1$s<br>
|
27 |
<input type="radio" name="table_inclusion_type" value="custom" %4$s>%2$s
|
28 |
',
|
@@ -32,7 +40,8 @@ $types = sprintf( '
|
|
32 |
/* 4 */ $in_modal || $full_checked ? '' : $checked
|
33 |
);
|
34 |
|
35 |
-
$buttons = sprintf(
|
|
|
36 |
<button id="include_all_tables" class="button button-primary">%1$s</button>
|
37 |
<button id="exclude_all_tables" class="button button">%2$s</button>
|
38 |
',
|
@@ -40,7 +49,8 @@ $buttons = sprintf( '
|
|
40 |
/* 2 */ esc_html__( 'Exclude all', 'boldgrid-backup' )
|
41 |
);
|
42 |
|
43 |
-
$status = sprintf(
|
|
|
44 |
<p class="yes-default">
|
45 |
%1$s
|
46 |
</p>
|
@@ -53,7 +63,8 @@ $status = sprintf( '
|
|
53 |
/* 3 */ sprintf( '<a href="#" class="include-all">%1$s</a>', __( 'Backup all tables', 'boldgrid-backup' ) )
|
54 |
);
|
55 |
|
56 |
-
return sprintf(
|
|
|
57 |
<div class="bg-box" id="table_inclusion">
|
58 |
<div class="bg-box-top">
|
59 |
%1$s
|
@@ -79,5 +90,3 @@ return sprintf( '
|
|
79 |
/* 4 */ $buttons,
|
80 |
/* 5 */ $tables
|
81 |
);
|
82 |
-
|
83 |
-
|
2 |
/**
|
3 |
* Database settings.
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.5.3
|
7 |
+
*
|
8 |
+
* @package Boldgrid_Backup
|
9 |
+
* @subpackage Boldgrid_Backup/admin/partials/settings
|
10 |
+
* @copyright BoldGrid
|
11 |
+
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
defined( 'WPINC' ) || die;
|
16 |
|
17 |
// $core will vary based on how this file is included.
|
18 |
$core = isset( $this->core ) ? $this->core : $this;
|
24 |
|
25 |
// Determine if the "Backup all tables" option should be checked.
|
26 |
$all_included = empty( $settings['exclude_tables'] );
|
27 |
+
$type = $core->db_omit->get_settings_type();
|
28 |
$full_checked = 'full' === $type || $all_included;
|
29 |
|
30 |
$checked = 'checked="checked"';
|
31 |
|
32 |
+
$types = sprintf(
|
33 |
+
'
|
34 |
<input type="radio" name="table_inclusion_type" value="full" %3$s>%1$s<br>
|
35 |
<input type="radio" name="table_inclusion_type" value="custom" %4$s>%2$s
|
36 |
',
|
40 |
/* 4 */ $in_modal || $full_checked ? '' : $checked
|
41 |
);
|
42 |
|
43 |
+
$buttons = sprintf(
|
44 |
+
'
|
45 |
<button id="include_all_tables" class="button button-primary">%1$s</button>
|
46 |
<button id="exclude_all_tables" class="button button">%2$s</button>
|
47 |
',
|
49 |
/* 2 */ esc_html__( 'Exclude all', 'boldgrid-backup' )
|
50 |
);
|
51 |
|
52 |
+
$status = sprintf(
|
53 |
+
'
|
54 |
<p class="yes-default">
|
55 |
%1$s
|
56 |
</p>
|
63 |
/* 3 */ sprintf( '<a href="#" class="include-all">%1$s</a>', __( 'Backup all tables', 'boldgrid-backup' ) )
|
64 |
);
|
65 |
|
66 |
+
return sprintf(
|
67 |
+
'
|
68 |
<div class="bg-box" id="table_inclusion">
|
69 |
<div class="bg-box-top">
|
70 |
%1$s
|
90 |
/* 4 */ $buttons,
|
91 |
/* 5 */ $tables
|
92 |
);
|
|
|
|
admin/partials/settings/folders.php
CHANGED
@@ -4,18 +4,25 @@
|
|
4 |
*
|
5 |
* Which files and folders should be included / excluded?
|
6 |
*
|
7 |
-
* @
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
*/
|
9 |
|
10 |
-
defined( 'WPINC' )
|
11 |
|
12 |
$nonce = wp_create_nonce( 'folder_exclusion_preview' );
|
13 |
|
14 |
$tags = array(
|
15 |
'strong' => array(),
|
16 |
-
'a'
|
17 |
'href' => array(),
|
18 |
-
'id'
|
19 |
),
|
20 |
);
|
21 |
|
@@ -30,8 +37,9 @@ $using_defaults = $core->folder_exclusion->is_using_defaults();
|
|
30 |
|
31 |
$markup = '<table class="form-table bulk-action-notice" id="folder_exclusion"><tbody>';
|
32 |
|
33 |
-
// TR for the header and intro
|
34 |
-
$tr_header = sprintf(
|
|
|
35 |
<p>
|
36 |
<input type="radio" name="folder_exclusion_type" value="full" %3$s>%1$s<br>
|
37 |
<input type="radio" name="folder_exclusion_type" value="custom" %4$s>%2$s
|
@@ -42,9 +50,9 @@ $tr_header = sprintf( '
|
|
42 |
/* 4 */ ! $in_modal && ! $using_defaults ? $checked : ''
|
43 |
);
|
44 |
|
45 |
-
// This markup for the legend.
|
46 |
-
|
47 |
-
|
48 |
<table class="folder_exclude_help wp-list-table widefat fixed striped pages">
|
49 |
<tr>
|
50 |
<th>*</th>
|
@@ -86,8 +94,9 @@ $table_legend = sprintf( '
|
|
86 |
/* 8 */ wp_kses( __( 'For example, <strong>wp-admin,wp-includes</strong> will backup both the wp-admin folder and the wp-includes folder.', 'boldgrid-backup' ), $tags )
|
87 |
);
|
88 |
|
89 |
-
// Examples
|
90 |
-
$table_examples = sprintf(
|
|
|
91 |
<table class="folder_exclude_help wp-list-table widefat fixed striped pages">
|
92 |
<tr>
|
93 |
<th><a href="#" class="folder_exclude_sample" data-include="%1$s" data-exclude="%2$s">%3$s</a></th>
|
@@ -119,7 +128,8 @@ $table_examples = sprintf( '
|
|
119 |
/* 10 */ wp_kses( __( 'Backup everything except WordPress core files.', 'boldgrid-backup' ), $tags )
|
120 |
);
|
121 |
|
122 |
-
$status = sprintf(
|
|
|
123 |
<p class="yes-default">
|
124 |
%1$s
|
125 |
</p>
|
@@ -138,7 +148,8 @@ $status = sprintf( '
|
|
138 |
);
|
139 |
|
140 |
// TR for the help text.
|
141 |
-
$tr_help = sprintf(
|
|
|
142 |
<div id="folder_misc_info">
|
143 |
<p>
|
144 |
<span class="dashicons dashicons-editor-help" data-id="folder_exclude_inputs" style="float:left;margin-right:4px;"></span>
|
@@ -170,8 +181,9 @@ $tr_help = sprintf( '
|
|
170 |
/* 7 */ $status
|
171 |
);
|
172 |
|
173 |
-
// TR for the include
|
174 |
-
$tr_include = sprintf(
|
|
|
175 |
<tr class="%3$s">
|
176 |
<th style="padding-top:0px;">
|
177 |
%1$s
|
@@ -187,7 +199,8 @@ $tr_include = sprintf( '
|
|
187 |
);
|
188 |
|
189 |
// TR for the exclude.
|
190 |
-
$tr_exclude = sprintf(
|
|
|
191 |
<tr class="%3$s">
|
192 |
<th>
|
193 |
%1$s
|
@@ -202,8 +215,9 @@ $tr_exclude = sprintf( '
|
|
202 |
/* A1 */ $using_defaults ? 'hidden' : ''
|
203 |
);
|
204 |
|
205 |
-
// TR for the preview
|
206 |
-
$tr_preview = sprintf(
|
|
|
207 |
<tr class="%1$s">
|
208 |
<th></th>
|
209 |
<td>
|
@@ -232,7 +246,8 @@ $tr_preview = sprintf( '
|
|
232 |
/* 4 */ esc_attr( __( 'Filter below results', 'boldgrid-backup' ) )
|
233 |
);
|
234 |
|
235 |
-
$markup = sprintf(
|
|
|
236 |
<div class="bg-box" id="folder_exclusion">
|
237 |
<div class="bg-box-top">
|
238 |
%1$s
|
@@ -258,5 +273,3 @@ $markup = sprintf( '
|
|
258 |
);
|
259 |
|
260 |
return $markup;
|
261 |
-
|
262 |
-
|
4 |
*
|
5 |
* Which files and folders should be included / excluded?
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
+
* @since 1.6.0
|
9 |
+
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
+
* @subpackage Boldgrid_Backup/admin/partials/settings
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
defined( 'WPINC' ) || die;
|
18 |
|
19 |
$nonce = wp_create_nonce( 'folder_exclusion_preview' );
|
20 |
|
21 |
$tags = array(
|
22 |
'strong' => array(),
|
23 |
+
'a' => array(
|
24 |
'href' => array(),
|
25 |
+
'id' => array(),
|
26 |
),
|
27 |
);
|
28 |
|
37 |
|
38 |
$markup = '<table class="form-table bulk-action-notice" id="folder_exclusion"><tbody>';
|
39 |
|
40 |
+
// TR for the header and intro.
|
41 |
+
$tr_header = sprintf(
|
42 |
+
'
|
43 |
<p>
|
44 |
<input type="radio" name="folder_exclusion_type" value="full" %3$s>%1$s<br>
|
45 |
<input type="radio" name="folder_exclusion_type" value="custom" %4$s>%2$s
|
50 |
/* 4 */ ! $in_modal && ! $using_defaults ? $checked : ''
|
51 |
);
|
52 |
|
53 |
+
// This markup for the legend. TR for the help text.
|
54 |
+
$table_legend = sprintf(
|
55 |
+
'
|
56 |
<table class="folder_exclude_help wp-list-table widefat fixed striped pages">
|
57 |
<tr>
|
58 |
<th>*</th>
|
94 |
/* 8 */ wp_kses( __( 'For example, <strong>wp-admin,wp-includes</strong> will backup both the wp-admin folder and the wp-includes folder.', 'boldgrid-backup' ), $tags )
|
95 |
);
|
96 |
|
97 |
+
// Examples.
|
98 |
+
$table_examples = sprintf(
|
99 |
+
'
|
100 |
<table class="folder_exclude_help wp-list-table widefat fixed striped pages">
|
101 |
<tr>
|
102 |
<th><a href="#" class="folder_exclude_sample" data-include="%1$s" data-exclude="%2$s">%3$s</a></th>
|
128 |
/* 10 */ wp_kses( __( 'Backup everything except WordPress core files.', 'boldgrid-backup' ), $tags )
|
129 |
);
|
130 |
|
131 |
+
$status = sprintf(
|
132 |
+
'
|
133 |
<p class="yes-default">
|
134 |
%1$s
|
135 |
</p>
|
148 |
);
|
149 |
|
150 |
// TR for the help text.
|
151 |
+
$tr_help = sprintf(
|
152 |
+
'
|
153 |
<div id="folder_misc_info">
|
154 |
<p>
|
155 |
<span class="dashicons dashicons-editor-help" data-id="folder_exclude_inputs" style="float:left;margin-right:4px;"></span>
|
181 |
/* 7 */ $status
|
182 |
);
|
183 |
|
184 |
+
// TR for the include.
|
185 |
+
$tr_include = sprintf(
|
186 |
+
'
|
187 |
<tr class="%3$s">
|
188 |
<th style="padding-top:0px;">
|
189 |
%1$s
|
199 |
);
|
200 |
|
201 |
// TR for the exclude.
|
202 |
+
$tr_exclude = sprintf(
|
203 |
+
'
|
204 |
<tr class="%3$s">
|
205 |
<th>
|
206 |
%1$s
|
215 |
/* A1 */ $using_defaults ? 'hidden' : ''
|
216 |
);
|
217 |
|
218 |
+
// TR for the preview.
|
219 |
+
$tr_preview = sprintf(
|
220 |
+
'
|
221 |
<tr class="%1$s">
|
222 |
<th></th>
|
223 |
<td>
|
246 |
/* 4 */ esc_attr( __( 'Filter below results', 'boldgrid-backup' ) )
|
247 |
);
|
248 |
|
249 |
+
$markup = sprintf(
|
250 |
+
'
|
251 |
<div class="bg-box" id="folder_exclusion">
|
252 |
<div class="bg-box-top">
|
253 |
%1$s
|
273 |
);
|
274 |
|
275 |
return $markup;
|
|
|
|
admin/partials/settings/notifications.php
CHANGED
@@ -1,11 +1,20 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Show "Notifications" on settings page.
|
4 |
*
|
|
|
5 |
* @since 1.5.1
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
8 |
-
defined( 'WPINC' )
|
9 |
|
10 |
ob_start();
|
11 |
?>
|
@@ -19,7 +28,7 @@ ob_start();
|
|
19 |
<tr>
|
20 |
<th><?php esc_html_e( 'Notification email address', 'boldgrid-backup' ); ?></th>
|
21 |
<td>
|
22 |
-
<input id='notification-email' type='text' size='40' name='notification_email' value='<?php echo $settings['notification_email']; ?>'></td>
|
23 |
</tr>
|
24 |
<tr>
|
25 |
<th><?php esc_html_e( 'Send an email when a backup completes', 'boldgrid-backup' ); ?></th>
|
@@ -30,7 +39,8 @@ ob_start();
|
|
30 |
0 !== $settings['notifications']['backup'] ) {
|
31 |
echo ' checked';
|
32 |
}
|
33 |
-
?>
|
|
|
34 |
</td>
|
35 |
</tr>
|
36 |
<tr>
|
@@ -42,7 +52,8 @@ ob_start();
|
|
42 |
0 !== $settings['notifications']['restore'] ) {
|
43 |
echo ' checked';
|
44 |
}
|
45 |
-
?>
|
|
|
46 |
</td>
|
47 |
</tr>
|
48 |
</table>
|
@@ -53,4 +64,3 @@ ob_start();
|
|
53 |
$output = ob_get_contents();
|
54 |
ob_end_clean();
|
55 |
return $output;
|
56 |
-
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: notifications.php
|
4 |
+
*
|
5 |
* Show "Notifications" on settings page.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.5.1
|
9 |
+
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
+
* @subpackage Boldgrid_Backup/admin/partials/settings
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
defined( 'WPINC' ) || die;
|
18 |
|
19 |
ob_start();
|
20 |
?>
|
28 |
<tr>
|
29 |
<th><?php esc_html_e( 'Notification email address', 'boldgrid-backup' ); ?></th>
|
30 |
<td>
|
31 |
+
<input id='notification-email' type='text' size='40' name='notification_email' value='<?php echo esc_attr( $settings['notification_email'] ); ?>'></td>
|
32 |
</tr>
|
33 |
<tr>
|
34 |
<th><?php esc_html_e( 'Send an email when a backup completes', 'boldgrid-backup' ); ?></th>
|
39 |
0 !== $settings['notifications']['backup'] ) {
|
40 |
echo ' checked';
|
41 |
}
|
42 |
+
?>
|
43 |
+
/>
|
44 |
</td>
|
45 |
</tr>
|
46 |
<tr>
|
52 |
0 !== $settings['notifications']['restore'] ) {
|
53 |
echo ' checked';
|
54 |
}
|
55 |
+
?>
|
56 |
+
/>
|
57 |
</td>
|
58 |
</tr>
|
59 |
</table>
|
64 |
$output = ob_get_contents();
|
65 |
ob_end_clean();
|
66 |
return $output;
|
|
admin/partials/settings/premium-message.php
CHANGED
@@ -1,16 +1,27 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Show free / premium message.
|
4 |
*
|
5 |
* @summary Show an intro atop the settings page regarding free / premium version of the plugin.
|
6 |
*
|
|
|
7 |
* @since 1.3.1
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
*/
|
9 |
|
10 |
-
defined( 'WPINC' )
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
if( $this->core->config->get_is_premium() ) {
|
13 |
-
?><p><?php
|
14 |
/*
|
15 |
* Print this message:
|
16 |
*
|
@@ -19,12 +30,23 @@ if( $this->core->config->get_is_premium() ) {
|
|
19 |
*/
|
20 |
printf(
|
21 |
wp_kses(
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
),
|
25 |
esc_url( $this->core->configs['urls']['user_guide'] )
|
26 |
);
|
27 |
-
|
|
|
|
|
28 |
} else {
|
29 |
/*
|
30 |
* Print this message:
|
@@ -38,7 +60,8 @@ if( $this->core->config->get_is_premium() ) {
|
|
38 |
*/
|
39 |
printf(
|
40 |
wp_kses(
|
41 |
-
|
|
|
42 |
'
|
43 |
<p>The BoldGrid Backup plugin comes in two versions, the Free and Premium. The Premium version is part of the BoldGrid Premium Suite. To learn about the capabilities of the BoldGrid Backup Plugin, check out our <a href="%1$s" target="_blank">BoldGrid Backup User Guide</a>.</p>
|
44 |
<p>Key differences are size of backups supported, scheduling capabilities, and number of archives supported. To upgrade now, go <a href="%2$s" target="_blank">here</a>.</p>
|
@@ -46,7 +69,10 @@ if( $this->core->config->get_is_premium() ) {
|
|
46 |
'boldgrid-backup'
|
47 |
),
|
48 |
array(
|
49 |
-
'a' => array(
|
|
|
|
|
|
|
50 |
'p' => array(),
|
51 |
)
|
52 |
),
|
@@ -54,4 +80,3 @@ if( $this->core->config->get_is_premium() ) {
|
|
54 |
esc_url( $this->core->configs['urls']['upgrade'] )
|
55 |
);
|
56 |
}
|
57 |
-
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: premium-message.php
|
4 |
+
*
|
5 |
* Show free / premium message.
|
6 |
*
|
7 |
* @summary Show an intro atop the settings page regarding free / premium version of the plugin.
|
8 |
*
|
9 |
+
* @link https://www.boldgrid.com
|
10 |
* @since 1.3.1
|
11 |
+
*
|
12 |
+
* @package Boldgrid_Backup
|
13 |
+
* @subpackage Boldgrid_Backup/admin/partials/settings
|
14 |
+
* @copyright BoldGrid
|
15 |
+
* @version $Id$
|
16 |
+
* @author BoldGrid <support@boldgrid.com>
|
17 |
*/
|
18 |
|
19 |
+
defined( 'WPINC' ) || die;
|
20 |
+
|
21 |
+
if ( $this->core->config->get_is_premium() ) {
|
22 |
+
?><p>
|
23 |
+
<?php
|
24 |
|
|
|
|
|
25 |
/*
|
26 |
* Print this message:
|
27 |
*
|
30 |
*/
|
31 |
printf(
|
32 |
wp_kses(
|
33 |
+
// translators: 1: URL address.
|
34 |
+
esc_html__(
|
35 |
+
'You are running the Premium version of the BoldGrid Backup Plugin. Please visit our <a href="%s" target="_blank">BoldGrid Backup User Guide</a> for more information.',
|
36 |
+
'boldgrid-backup'
|
37 |
+
),
|
38 |
+
array(
|
39 |
+
'a' => array(
|
40 |
+
'href' => array(),
|
41 |
+
'target' => array(),
|
42 |
+
),
|
43 |
+
)
|
44 |
),
|
45 |
esc_url( $this->core->configs['urls']['user_guide'] )
|
46 |
);
|
47 |
+
?>
|
48 |
+
</p>
|
49 |
+
<?php
|
50 |
} else {
|
51 |
/*
|
52 |
* Print this message:
|
60 |
*/
|
61 |
printf(
|
62 |
wp_kses(
|
63 |
+
// translators: 1: URL address for user guide, 2: URL address for upgrade.
|
64 |
+
esc_html__(
|
65 |
'
|
66 |
<p>The BoldGrid Backup plugin comes in two versions, the Free and Premium. The Premium version is part of the BoldGrid Premium Suite. To learn about the capabilities of the BoldGrid Backup Plugin, check out our <a href="%1$s" target="_blank">BoldGrid Backup User Guide</a>.</p>
|
67 |
<p>Key differences are size of backups supported, scheduling capabilities, and number of archives supported. To upgrade now, go <a href="%2$s" target="_blank">here</a>.</p>
|
69 |
'boldgrid-backup'
|
70 |
),
|
71 |
array(
|
72 |
+
'a' => array(
|
73 |
+
'href' => array(),
|
74 |
+
'target' => array(),
|
75 |
+
),
|
76 |
'p' => array(),
|
77 |
)
|
78 |
),
|
80 |
esc_url( $this->core->configs['urls']['upgrade'] )
|
81 |
);
|
82 |
}
|
|
admin/partials/settings/retention.php
CHANGED
@@ -1,13 +1,20 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
*
|
6 |
*
|
|
|
7 |
* @since 1.3.1
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
*/
|
9 |
|
10 |
-
defined( 'WPINC' )
|
11 |
|
12 |
ob_start();
|
13 |
|
@@ -41,9 +48,10 @@ $is_retention_set = ( isset( $settings['retention_count'] ) );
|
|
41 |
$requires_upgrade = '';
|
42 |
}
|
43 |
|
44 |
-
printf(
|
45 |
-
$
|
46 |
-
$
|
|
|
47 |
);
|
48 |
}
|
49 |
?>
|
@@ -55,4 +63,3 @@ $is_retention_set = ( isset( $settings['retention_count'] ) );
|
|
55 |
$output = ob_get_contents();
|
56 |
ob_end_clean();
|
57 |
return $output;
|
58 |
-
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: retention.php
|
4 |
*
|
5 |
+
* Show the retention settings section of the BoldGrid Backup settings page.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.3.1
|
9 |
+
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
+
* @subpackage Boldgrid_Backup/admin/partials/settings
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
defined( 'WPINC' ) || die;
|
18 |
|
19 |
ob_start();
|
20 |
|
48 |
$requires_upgrade = '';
|
49 |
}
|
50 |
|
51 |
+
printf(
|
52 |
+
'<option value="%1$d" %2$s>%1$d</option>',
|
53 |
+
esc_attr( $x ),
|
54 |
+
esc_attr( $selected )
|
55 |
);
|
56 |
}
|
57 |
?>
|
63 |
$output = ob_get_contents();
|
64 |
ob_end_clean();
|
65 |
return $output;
|
|
admin/partials/settings/scheduler.php
CHANGED
@@ -1,11 +1,20 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Show "Scheduler" on settings page.
|
4 |
*
|
|
|
5 |
* @since 1.5.1
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
8 |
-
defined( 'WPINC' )
|
9 |
|
10 |
$schedulers_available = $this->core->scheduler->get_available();
|
11 |
|
@@ -35,7 +44,8 @@ foreach ( $schedulers_available as $key => $scheduler_data ) {
|
|
35 |
|
36 |
$scheduler_select = sprintf( '<select name="scheduler" id="scheduler">%1$s</select>', $scheduler_options );
|
37 |
|
38 |
-
return sprintf(
|
|
|
39 |
<div class="bg-box">
|
40 |
<div class="bg-box-top">
|
41 |
%1$s
|
@@ -49,5 +59,3 @@ return sprintf( '
|
|
49 |
$scheduler_select,
|
50 |
$wp_cron_warning
|
51 |
);
|
52 |
-
|
53 |
-
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: scheduler.php
|
4 |
+
*
|
5 |
* Show "Scheduler" on settings page.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.5.1
|
9 |
+
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
+
* @subpackage Boldgrid_Backup/admin/partials/settings
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
defined( 'WPINC' ) || die;
|
18 |
|
19 |
$schedulers_available = $this->core->scheduler->get_available();
|
20 |
|
44 |
|
45 |
$scheduler_select = sprintf( '<select name="scheduler" id="scheduler">%1$s</select>', $scheduler_options );
|
46 |
|
47 |
+
return sprintf(
|
48 |
+
'
|
49 |
<div class="bg-box">
|
50 |
<div class="bg-box-top">
|
51 |
%1$s
|
59 |
$scheduler_select,
|
60 |
$wp_cron_warning
|
61 |
);
|
|
|
|
admin/partials/settings/storage-location.php
CHANGED
@@ -1,13 +1,19 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
*
|
5 |
*
|
6 |
-
*
|
7 |
-
* table.
|
8 |
*
|
|
|
9 |
* @since 1.5.2
|
10 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
* @param array $location {
|
12 |
* A remote storage location / provider.
|
13 |
*
|
@@ -22,14 +28,14 @@
|
|
22 |
* @return string
|
23 |
*/
|
24 |
|
25 |
-
defined( 'WPINC' )
|
26 |
|
27 |
$configure = '';
|
28 |
|
29 |
$configure_link = '<a href="%1$s&TB_iframe=true&width=600&height=550" class="thickbox">%2$s</a>';
|
30 |
|
31 |
if ( $location['is_setup'] && ! empty( $location['configure'] ) ) {
|
32 |
-
$configure
|
33 |
$configure .= ' (' . sprintf( $configure_link, $location['configure'], __( 'update', 'boldgrid-backup' ) ) . ')';
|
34 |
} elseif ( ! empty( $location['configure'] ) ) {
|
35 |
$configure .= sprintf( $configure_link, $location['configure'], __( 'Configure', 'boldgrid-backup' ) );
|
@@ -39,7 +45,8 @@ $disabled = $location['is_setup'] ? '' : 'disabled';
|
|
39 |
|
40 |
$checked = isset( $location['enabled'] ) && true === $location['enabled'] ? 'checked' : '';
|
41 |
|
42 |
-
return sprintf(
|
|
|
43 |
<tr data-key="%4$s">
|
44 |
<td>
|
45 |
<input type="checkbox" name="storage_location[%4$s]" value="1" %3$s %5$s> <strong>%1$s</strong>
|
@@ -55,5 +62,3 @@ return sprintf( '
|
|
55 |
$location['key'],
|
56 |
$checked
|
57 |
);
|
58 |
-
|
59 |
-
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* File: storage-location.php
|
4 |
*
|
5 |
+
* Display a single provider on the settings page.
|
6 |
+
* This page returns the html markup needed for the <tr> #storage_locations table.
|
7 |
*
|
8 |
+
* @link https://www.boldgrid.com
|
9 |
* @since 1.5.2
|
10 |
*
|
11 |
+
* @package Boldgrid_Backup
|
12 |
+
* @subpackage Boldgrid_Backup/admin/partials/settings
|
13 |
+
* @copyright BoldGrid
|
14 |
+
* @version $Id$
|
15 |
+
* @author BoldGrid <support@boldgrid.com>
|
16 |
+
*
|
17 |
* @param array $location {
|
18 |
* A remote storage location / provider.
|
19 |
*
|
28 |
* @return string
|
29 |
*/
|
30 |
|
31 |
+
defined( 'WPINC' ) || die;
|
32 |
|
33 |
$configure = '';
|
34 |
|
35 |
$configure_link = '<a href="%1$s&TB_iframe=true&width=600&height=550" class="thickbox">%2$s</a>';
|
36 |
|
37 |
if ( $location['is_setup'] && ! empty( $location['configure'] ) ) {
|
38 |
+
$configure = sprintf( '✓ %1$s', __( 'Configured', 'boldgrid-backup' ) );
|
39 |
$configure .= ' (' . sprintf( $configure_link, $location['configure'], __( 'update', 'boldgrid-backup' ) ) . ')';
|
40 |
} elseif ( ! empty( $location['configure'] ) ) {
|
41 |
$configure .= sprintf( $configure_link, $location['configure'], __( 'Configure', 'boldgrid-backup' ) );
|
45 |
|
46 |
$checked = isset( $location['enabled'] ) && true === $location['enabled'] ? 'checked' : '';
|
47 |
|
48 |
+
return sprintf(
|
49 |
+
'
|
50 |
<tr data-key="%4$s">
|
51 |
<td>
|
52 |
<input type="checkbox" name="storage_location[%4$s]" value="1" %3$s %5$s> <strong>%1$s</strong>
|
62 |
$location['key'],
|
63 |
$checked
|
64 |
);
|
|
|
|
admin/partials/settings/storage.php
CHANGED
@@ -1,23 +1,30 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* This file is included on the BoldGrid Backup Settings page and helps render
|
6 |
-
*
|
7 |
*
|
|
|
8 |
* @since 1.5.2
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
*/
|
10 |
|
11 |
-
defined( 'WPINC' )
|
12 |
|
13 |
ob_start();
|
14 |
|
15 |
$storage_locations = array(
|
16 |
array(
|
17 |
-
'title'
|
18 |
-
'key'
|
19 |
'is_setup' => true,
|
20 |
-
'enabled'
|
21 |
),
|
22 |
);
|
23 |
|
@@ -38,7 +45,8 @@ $storage_locations = array(
|
|
38 |
*/
|
39 |
$storage_locations = apply_filters( 'boldgrid_backup_register_storage_location', $storage_locations );
|
40 |
|
41 |
-
$premium_box = $this->core->config->is_premium_done ? '' : sprintf(
|
|
|
42 |
<div class="bg-box-bottom premium">
|
43 |
<input type="checkbox" disabled="true" /> <strong>%1$s</strong>
|
44 |
|
@@ -56,19 +64,33 @@ $premium_box = $this->core->config->is_premium_done ? '' : sprintf( '
|
|
56 |
|
57 |
<div class='bg-box'>
|
58 |
<div class='bg-box-top'>
|
59 |
-
<?php
|
60 |
<?php echo '<span class="dashicons dashicons-editor-help" data-id="remote_storage"></span>'; ?>
|
61 |
</div>
|
62 |
<div class='bg-box-bottom'>
|
63 |
<p class="help" data-id="remote_storage">
|
64 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
</p>
|
66 |
|
67 |
<table id="storage_locations">
|
68 |
<?php
|
69 |
foreach ( $storage_locations as $location ) {
|
70 |
$tr = include BOLDGRID_BACKUP_PATH . '/admin/partials/settings/storage-location.php';
|
71 |
-
echo $tr;
|
72 |
}
|
73 |
?>
|
74 |
</table>
|
@@ -76,14 +98,13 @@ $premium_box = $this->core->config->is_premium_done ? '' : sprintf( '
|
|
76 |
<br />
|
77 |
<p class="hidden" id="no_storage">
|
78 |
<span class="dashicons dashicons-warning yellow"></span>
|
79 |
-
<?php
|
80 |
</p>
|
81 |
</div>
|
82 |
-
<?php echo $premium_box; ?>
|
83 |
</div>
|
84 |
|
85 |
<?php
|
86 |
$output = ob_get_contents();
|
87 |
ob_end_clean();
|
88 |
return $output;
|
89 |
-
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: storage.php
|
4 |
*
|
5 |
+
* This file is included on the BoldGrid Backup Settings page and helps render the "Backup Storage"
|
6 |
+
* section.
|
7 |
*
|
8 |
+
* @link https://www.boldgrid.com
|
9 |
* @since 1.5.2
|
10 |
+
*
|
11 |
+
* @package Boldgrid_Backup
|
12 |
+
* @subpackage Boldgrid_Backup/admin/partials/settings
|
13 |
+
* @copyright BoldGrid
|
14 |
+
* @version $Id$
|
15 |
+
* @author BoldGrid <support@boldgrid.com>
|
16 |
*/
|
17 |
|
18 |
+
defined( 'WPINC' ) || die;
|
19 |
|
20 |
ob_start();
|
21 |
|
22 |
$storage_locations = array(
|
23 |
array(
|
24 |
+
'title' => __( 'Web Server', 'boldgrid-backup' ),
|
25 |
+
'key' => 'local',
|
26 |
'is_setup' => true,
|
27 |
+
'enabled' => ! empty( $settings['remote']['local']['enabled'] ) && true === $settings['remote']['local']['enabled'],
|
28 |
),
|
29 |
);
|
30 |
|
45 |
*/
|
46 |
$storage_locations = apply_filters( 'boldgrid_backup_register_storage_location', $storage_locations );
|
47 |
|
48 |
+
$premium_box = $this->core->config->is_premium_done ? '' : sprintf(
|
49 |
+
'
|
50 |
<div class="bg-box-bottom premium">
|
51 |
<input type="checkbox" disabled="true" /> <strong>%1$s</strong>
|
52 |
|
64 |
|
65 |
<div class='bg-box'>
|
66 |
<div class='bg-box-top'>
|
67 |
+
<?php esc_html_e( 'Backup Storage', 'boldgrid-backup' ); ?>
|
68 |
<?php echo '<span class="dashicons dashicons-editor-help" data-id="remote_storage"></span>'; ?>
|
69 |
</div>
|
70 |
<div class='bg-box-bottom'>
|
71 |
<p class="help" data-id="remote_storage">
|
72 |
+
<?php
|
73 |
+
printf(
|
74 |
+
wp_kses(
|
75 |
+
// translators: 1: URL address.
|
76 |
+
__(
|
77 |
+
'The following is a list of storage locations available to store your backup archives on. It is recommended to store your backups on at least 2 different storage locations. You can find more information <a href="%1$s">here</a>.',
|
78 |
+
'boldgrid-backup'
|
79 |
+
),
|
80 |
+
array( 'a' => array( 'href' => array() ) )
|
81 |
+
),
|
82 |
+
esc_url( admin_url(
|
83 |
+
'admin.php?page=boldgrid-backup-tools§ion=section_locations'
|
84 |
+
) )
|
85 |
+
);
|
86 |
+
?>
|
87 |
</p>
|
88 |
|
89 |
<table id="storage_locations">
|
90 |
<?php
|
91 |
foreach ( $storage_locations as $location ) {
|
92 |
$tr = include BOLDGRID_BACKUP_PATH . '/admin/partials/settings/storage-location.php';
|
93 |
+
echo $tr; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
94 |
}
|
95 |
?>
|
96 |
</table>
|
98 |
<br />
|
99 |
<p class="hidden" id="no_storage">
|
100 |
<span class="dashicons dashicons-warning yellow"></span>
|
101 |
+
<?php esc_html_e( 'Backup will not occur if no storage locations are selected.', 'boldgrid-backup' ); ?>
|
102 |
</p>
|
103 |
</div>
|
104 |
+
<?php echo $premium_box; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>
|
105 |
</div>
|
106 |
|
107 |
<?php
|
108 |
$output = ob_get_contents();
|
109 |
ob_end_clean();
|
110 |
return $output;
|
|
admin/partials/settings/time-of-day.php
CHANGED
@@ -1,11 +1,18 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
8 |
-
defined( 'WPINC' )
|
9 |
|
10 |
$tz_info = $this->core->time->get_timezone_info();
|
11 |
|
@@ -20,14 +27,15 @@ ob_start();
|
|
20 |
<select id='tod-h' name='tod_h'>
|
21 |
<?php
|
22 |
for ( $x = 1; $x <= 12; $x ++ ) {
|
23 |
-
|
24 |
-
<option value='<?php echo $x
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
31 |
}
|
32 |
?>
|
33 |
</select>
|
@@ -37,14 +45,15 @@ ob_start();
|
|
37 |
for ( $x = 0; $x <= 59; $x ++ ) {
|
38 |
// Convert $x to a padded string.
|
39 |
$x = str_pad( $x, 2, '0', STR_PAD_LEFT );
|
40 |
-
|
41 |
-
<option value='<?php echo $x
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
48 |
}
|
49 |
?>
|
50 |
</select>
|
@@ -55,20 +64,24 @@ ob_start();
|
|
55 |
if ( ! isset( $settings['schedule']['tod_a'] ) || 'PM' !== $settings['schedule']['tod_a'] ) {
|
56 |
echo ' selected';
|
57 |
}
|
58 |
-
|
|
|
59 |
<option value='PM'
|
60 |
<?php
|
61 |
if ( isset( $settings['schedule']['tod_a'] ) && 'PM' === $settings['schedule']['tod_a'] ) {
|
62 |
echo ' selected';
|
63 |
}
|
64 |
-
|
|
|
65 |
</select>
|
66 |
|
67 |
<div style="vertical-align:middle;display:inline-block;">
|
68 |
-
<?php
|
|
|
|
|
69 |
</div>
|
70 |
|
71 |
-
<p class="wp-cron-notice hidden"><em>WP Cron runs on GMT time, which is currently <?php echo date( 'l g:i a e' )?>.</em></p>
|
72 |
</div>
|
73 |
</div>
|
74 |
|
@@ -76,4 +89,3 @@ ob_start();
|
|
76 |
$output = ob_get_contents();
|
77 |
ob_end_clean();
|
78 |
return $output;
|
79 |
-
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: time-of-day.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.6.0
|
7 |
+
*
|
8 |
+
* @package Boldgrid_Backup
|
9 |
+
* @subpackage Boldgrid_Backup/admin/partials/settings
|
10 |
+
* @copyright BoldGrid
|
11 |
+
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
defined( 'WPINC' ) || die;
|
16 |
|
17 |
$tz_info = $this->core->time->get_timezone_info();
|
18 |
|
27 |
<select id='tod-h' name='tod_h'>
|
28 |
<?php
|
29 |
for ( $x = 1; $x <= 12; $x ++ ) {
|
30 |
+
?>
|
31 |
+
<option value='<?php echo esc_attr( $x ); ?>'
|
32 |
+
<?php
|
33 |
+
if ( ! empty( $settings['schedule']['tod_h'] ) && $x === $settings['schedule']['tod_h'] ) {
|
34 |
+
echo ' selected';
|
35 |
+
}
|
36 |
+
?>
|
37 |
+
><?php echo esc_html( $x ); ?></option>
|
38 |
+
<?php
|
39 |
}
|
40 |
?>
|
41 |
</select>
|
45 |
for ( $x = 0; $x <= 59; $x ++ ) {
|
46 |
// Convert $x to a padded string.
|
47 |
$x = str_pad( $x, 2, '0', STR_PAD_LEFT );
|
48 |
+
?>
|
49 |
+
<option value='<?php echo esc_attr( $x ); ?>'
|
50 |
+
<?php
|
51 |
+
if ( ! empty( $settings['schedule']['tod_m'] ) && $x === $settings['schedule']['tod_m'] ) {
|
52 |
+
echo ' selected';
|
53 |
+
}
|
54 |
+
?>
|
55 |
+
><?php echo esc_html( $x ); ?></option>
|
56 |
+
<?php
|
57 |
}
|
58 |
?>
|
59 |
</select>
|
64 |
if ( ! isset( $settings['schedule']['tod_a'] ) || 'PM' !== $settings['schedule']['tod_a'] ) {
|
65 |
echo ' selected';
|
66 |
}
|
67 |
+
?>
|
68 |
+
>AM</option>
|
69 |
<option value='PM'
|
70 |
<?php
|
71 |
if ( isset( $settings['schedule']['tod_a'] ) && 'PM' === $settings['schedule']['tod_a'] ) {
|
72 |
echo ' selected';
|
73 |
}
|
74 |
+
?>
|
75 |
+
>PM</option>
|
76 |
</select>
|
77 |
|
78 |
<div style="vertical-align:middle;display:inline-block;">
|
79 |
+
<?php
|
80 |
+
echo $tz_info['markup_timezone'] . ' <em>' . $tz_info['markup_change'] . '</em>'; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
81 |
+
?>
|
82 |
</div>
|
83 |
|
84 |
+
<p class="wp-cron-notice hidden"><em>WP Cron runs on GMT time, which is currently <?php echo esc_html( date( 'l g:i a e' ) ); ?>.</em></p>
|
85 |
</div>
|
86 |
</div>
|
87 |
|
89 |
$output = ob_get_contents();
|
90 |
ob_end_clean();
|
91 |
return $output;
|
|
admin/partials/tools/local-remote.php
CHANGED
@@ -1,14 +1,25 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Show "Auto Updates" on settings page.
|
4 |
*
|
5 |
-
* @
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
8 |
-
|
9 |
|
10 |
-
|
11 |
-
|
|
|
|
|
12 |
$browser = new Browser();
|
13 |
|
14 |
ob_start();
|
@@ -30,21 +41,25 @@ foreach ( $local_info as $info ) {
|
|
30 |
continue;
|
31 |
}
|
32 |
|
33 |
-
$local_info_markup .= sprintf(
|
|
|
|
|
|
|
|
|
34 |
}
|
35 |
|
36 |
$server_info = array(
|
37 |
array(
|
38 |
'title' => __( 'Server Name', 'boldgrid-backup' ),
|
39 |
-
'key'
|
40 |
),
|
41 |
array(
|
42 |
'title' => __( 'Server IP Address', 'boldgrid-backup' ),
|
43 |
-
'key'
|
44 |
),
|
45 |
array(
|
46 |
'title' => __( 'Server Type / OS', 'boldgrid-backup' ),
|
47 |
-
'key'
|
48 |
),
|
49 |
);
|
50 |
|
@@ -57,74 +72,135 @@ foreach ( $server_info as $info ) {
|
|
57 |
$server_info_markup .= sprintf( '<li><strong>%1$s</strong>: %2$s</li>', $info['title'], $_SERVER[ $info['key'] ] );
|
58 |
}
|
59 |
|
60 |
-
printf(
|
|
|
61 |
<h2>%1$s</h2>
|
62 |
<p>%2$s</p>
|
63 |
<p>%3$s</p>
|
64 |
<hr />',
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
);
|
69 |
|
|
|
70 |
|
71 |
-
|
72 |
-
printf( '<h3>%1$s</h3>', __( 'Local Machine', 'boldgrid-backup' ) );
|
73 |
-
|
74 |
printf(
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
77 |
);
|
|
|
78 |
|
79 |
if ( ! empty( $local_info_markup ) ) {
|
80 |
-
printf(
|
|
|
81 |
<p>%1$s</p>
|
82 |
%2$s',
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
);
|
86 |
}
|
87 |
|
88 |
echo '<hr />';
|
89 |
|
90 |
-
printf( '<h3>%1$s</h3>',
|
91 |
|
|
|
92 |
printf(
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
95 |
);
|
|
|
96 |
|
97 |
if ( ! empty( $server_info_markup ) ) {
|
98 |
-
printf(
|
|
|
99 |
<p>%1$s</p>
|
100 |
%2$s',
|
101 |
-
|
102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
);
|
104 |
}
|
105 |
|
106 |
echo '<hr />';
|
107 |
|
108 |
-
printf( '<h3>%1$s</h3>',
|
109 |
|
|
|
110 |
printf(
|
111 |
-
|
112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
);
|
|
|
114 |
|
115 |
if ( ! $this->core->config->is_premium_done ) {
|
116 |
-
printf(
|
|
|
117 |
<div class="bg-box-bottom premium wp-clearfix">
|
118 |
%1$s
|
119 |
%2$s
|
120 |
</div>',
|
121 |
-
$this->core->go_pro->get_premium_button(),
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
);
|
124 |
}
|
125 |
|
126 |
-
|
127 |
$output = ob_get_contents();
|
128 |
ob_end_clean();
|
129 |
-
return $output;
|
130 |
|
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: local-remote.php
|
4 |
+
*
|
5 |
* Show "Auto Updates" on settings page.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
+
* @since 1.6.0
|
9 |
+
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
+
* @subpackage Boldgrid_Backup/admin/partials/tools
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
// phpcs:disable WordPress.VIP
|
18 |
|
19 |
+
defined( 'WPINC' ) || die;
|
20 |
+
|
21 |
+
// @link https://github.com/cbschuld/Browser.php
|
22 |
+
require_once BOLDGRID_BACKUP_PATH . '/vendor/cbschuld/browser.php/lib/Browser.php';
|
23 |
$browser = new Browser();
|
24 |
|
25 |
ob_start();
|
41 |
continue;
|
42 |
}
|
43 |
|
44 |
+
$local_info_markup .= sprintf(
|
45 |
+
'<li><strong>%1$s</strong>: %2$s</li>',
|
46 |
+
esc_html( $info['title'] ),
|
47 |
+
esc_html( $info['value'] )
|
48 |
+
);
|
49 |
}
|
50 |
|
51 |
$server_info = array(
|
52 |
array(
|
53 |
'title' => __( 'Server Name', 'boldgrid-backup' ),
|
54 |
+
'key' => 'SERVER_NAME',
|
55 |
),
|
56 |
array(
|
57 |
'title' => __( 'Server IP Address', 'boldgrid-backup' ),
|
58 |
+
'key' => 'SERVER_ADDR',
|
59 |
),
|
60 |
array(
|
61 |
'title' => __( 'Server Type / OS', 'boldgrid-backup' ),
|
62 |
+
'key' => 'SERVER_SOFTWARE',
|
63 |
),
|
64 |
);
|
65 |
|
72 |
$server_info_markup .= sprintf( '<li><strong>%1$s</strong>: %2$s</li>', $info['title'], $_SERVER[ $info['key'] ] );
|
73 |
}
|
74 |
|
75 |
+
printf(
|
76 |
+
'
|
77 |
<h2>%1$s</h2>
|
78 |
<p>%2$s</p>
|
79 |
<p>%3$s</p>
|
80 |
<hr />',
|
81 |
+
esc_html__( 'Where should I store my backups?', 'boldgrid-backup' ),
|
82 |
+
sprintf(
|
83 |
+
// translators: 1: HTML strong open tag. 2: HTML strong close tag.
|
84 |
+
esc_html__(
|
85 |
+
'Throughout the BoldGrid Backup plugin, you will see references to %1$sLocal Machine%2$s, %1$sWeb Server%2$s, and %1$sRemote Storage%2$s. These are all locations you can save your backup archives to.',
|
86 |
+
'boldgrid-backup'
|
87 |
+
),
|
88 |
+
'<strong>',
|
89 |
+
'</strong>'
|
90 |
+
),
|
91 |
+
esc_html__(
|
92 |
+
'Continue reading below to find out more about each. It is recommended to store backup archives in at least 2 different storage locations.',
|
93 |
+
'boldgrid-backup'
|
94 |
+
)
|
95 |
);
|
96 |
|
97 |
+
printf( '<h3>%1$s</h3>', esc_html__( 'Local Machine', 'boldgrid-backup' ) );
|
98 |
|
99 |
+
echo '<p>';
|
|
|
|
|
100 |
printf(
|
101 |
+
// translators: 1: HTML strong open tag. 2: HTML strong close tag.
|
102 |
+
esc_html__(
|
103 |
+
'Your %1$sLocal Machine%2$s is the device you are using right now to access the internet. It could be a desktop, laptop, tablet, or even a smart phone.',
|
104 |
+
'boldgrid-backup'
|
105 |
+
),
|
106 |
+
'<strong>',
|
107 |
+
'</strong>'
|
108 |
);
|
109 |
+
echo '</p>';
|
110 |
|
111 |
if ( ! empty( $local_info_markup ) ) {
|
112 |
+
printf(
|
113 |
+
'
|
114 |
<p>%1$s</p>
|
115 |
%2$s',
|
116 |
+
sprintf(
|
117 |
+
// translators: 1: HTML strong open tag. 2: HTML strong close tag.
|
118 |
+
esc_html__(
|
119 |
+
'We are able to see the following information about your %1$sLocal Machine%2$s:',
|
120 |
+
'boldgrid-backup'
|
121 |
+
),
|
122 |
+
'<strong>',
|
123 |
+
'</strong>'
|
124 |
+
),
|
125 |
+
$local_info_markup // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
126 |
);
|
127 |
}
|
128 |
|
129 |
echo '<hr />';
|
130 |
|
131 |
+
printf( '<h3>%1$s</h3>', esc_html__( 'Web Server', 'boldgrid-backup' ) );
|
132 |
|
133 |
+
echo '<p>';
|
134 |
printf(
|
135 |
+
// translators: 1: HTML strong open tag. 2: HTML strong close tag.
|
136 |
+
esc_html__(
|
137 |
+
'The %1$sWeb Server%2$s is the server where your WordPress website lives. You usually pay your web hosting provider monthly or yearly for hosting.',
|
138 |
+
'boldgrid-backup'
|
139 |
+
),
|
140 |
+
'<strong>',
|
141 |
+
'</strong>'
|
142 |
);
|
143 |
+
echo '</p>';
|
144 |
|
145 |
if ( ! empty( $server_info_markup ) ) {
|
146 |
+
printf(
|
147 |
+
'
|
148 |
<p>%1$s</p>
|
149 |
%2$s',
|
150 |
+
sprintf(
|
151 |
+
// translators: 1: HTML strong open tag. 2: HTML strong close tag.
|
152 |
+
esc_html__(
|
153 |
+
'We are able to see the following information about your %1$sWeb Server%2$s:',
|
154 |
+
'boldgrid-backup'
|
155 |
+
),
|
156 |
+
'<strong>',
|
157 |
+
'</strong>'
|
158 |
+
),
|
159 |
+
$server_info_markup // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
160 |
);
|
161 |
}
|
162 |
|
163 |
echo '<hr />';
|
164 |
|
165 |
+
printf( '<h3>%1$s</h3>', esc_html__( 'Remote Storage', 'boldgrid-backup' ) );
|
166 |
|
167 |
+
echo '<p>';
|
168 |
printf(
|
169 |
+
// translators: 1: HTML strong open tag, 2: HTML strong close tag, 3: HTML em open tag, 4: HTML em close tag.
|
170 |
+
esc_html__(
|
171 |
+
'%1$sRemote Storage%2$s providers are servers other than your %3$sLocal Machine%4$s and %3$sWeb Server%4$s where you can store files. For example, %3$sFTP%4$s, %3$sSFTP%4$s, and %3$sAmazon S3%4$s are all considered Remote Storage Providers.',
|
172 |
+
'boldgrid-backup'
|
173 |
+
),
|
174 |
+
'<strong>',
|
175 |
+
'</strong>',
|
176 |
+
'<em>',
|
177 |
+
'</em>'
|
178 |
);
|
179 |
+
echo '</p>';
|
180 |
|
181 |
if ( ! $this->core->config->is_premium_done ) {
|
182 |
+
printf(
|
183 |
+
'
|
184 |
<div class="bg-box-bottom premium wp-clearfix">
|
185 |
%1$s
|
186 |
%2$s
|
187 |
</div>',
|
188 |
+
$this->core->go_pro->get_premium_button(), // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
189 |
+
sprintf(
|
190 |
+
// translators: 1: HTML strong open tag, 2: HTML strong close tag, 3: HTML em open tag, 4: HTML em close tag.
|
191 |
+
esc_html__(
|
192 |
+
'Upgrade to %1$sBoldGrid Backup Premium%2$s to gain access to more %3$sRemote Storage Providers%4$s.',
|
193 |
+
'boldgrid-backup'
|
194 |
+
),
|
195 |
+
'<strong>',
|
196 |
+
'</strong>',
|
197 |
+
'<em>',
|
198 |
+
'</em>'
|
199 |
+
)
|
200 |
);
|
201 |
}
|
202 |
|
|
|
203 |
$output = ob_get_contents();
|
204 |
ob_end_clean();
|
|
|
205 |
|
206 |
+
return $output;
|
admin/remote/{ftp-hooks.php → class-boldgrid-backup-admin-ftp-hooks.php}
RENAMED
@@ -1,32 +1,37 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since 1.
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
-
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* The only purpose this class is to be used for is to separate methods that are
|
19 |
* used for registering a new remove provider. All of these methods are called
|
20 |
* via hooks.
|
21 |
*
|
22 |
-
* @since 1.
|
23 |
*/
|
24 |
class Boldgrid_Backup_Admin_Ftp_Hooks {
|
25 |
-
|
26 |
/**
|
27 |
* The core class object.
|
28 |
*
|
29 |
-
* @since
|
30 |
* @access private
|
31 |
* @var Boldgrid_Backup_Admin_Core
|
32 |
*/
|
@@ -35,7 +40,7 @@ class Boldgrid_Backup_Admin_Ftp_Hooks {
|
|
35 |
/**
|
36 |
* Constructor.
|
37 |
*
|
38 |
-
* @since 1.
|
39 |
*
|
40 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
41 |
*/
|
@@ -46,7 +51,7 @@ class Boldgrid_Backup_Admin_Ftp_Hooks {
|
|
46 |
/**
|
47 |
* Add menu items.
|
48 |
*
|
49 |
-
* @since 1.
|
50 |
*/
|
51 |
public function add_menu_items() {
|
52 |
$capability = 'administrator';
|
@@ -67,7 +72,7 @@ class Boldgrid_Backup_Admin_Ftp_Hooks {
|
|
67 |
/**
|
68 |
* Hook into the filter to add all ftp backups to the full list of backups.
|
69 |
*
|
70 |
-
* @since 1.
|
71 |
*/
|
72 |
public function filter_get_all() {
|
73 |
$contents = $this->core->ftp->get_contents( true, $this->core->ftp->remote_dir );
|
@@ -77,14 +82,14 @@ class Boldgrid_Backup_Admin_Ftp_Hooks {
|
|
77 |
$filename = $item['filename'];
|
78 |
|
79 |
$backup = array(
|
80 |
-
'filename'
|
81 |
'last_modified' => $item['time'],
|
82 |
-
'size'
|
83 |
-
'locations'
|
84 |
array(
|
85 |
-
'title'
|
86 |
'on_remote_server' => true,
|
87 |
-
'title_attr'
|
88 |
),
|
89 |
),
|
90 |
);
|
@@ -96,7 +101,7 @@ class Boldgrid_Backup_Admin_Ftp_Hooks {
|
|
96 |
/**
|
97 |
* Determine if FTP is setup.
|
98 |
*
|
99 |
-
* @since 1.
|
100 |
*/
|
101 |
public function is_setup_ajax() {
|
102 |
if ( ! current_user_can( 'update_plugins' ) ) {
|
@@ -110,7 +115,7 @@ class Boldgrid_Backup_Admin_Ftp_Hooks {
|
|
110 |
$settings = $this->core->settings->get_settings();
|
111 |
|
112 |
$location = $this->core->ftp->get_details();
|
113 |
-
$tr
|
114 |
|
115 |
if ( $this->core->ftp->is_setup() ) {
|
116 |
wp_send_json_success( $tr );
|
@@ -122,12 +127,11 @@ class Boldgrid_Backup_Admin_Ftp_Hooks {
|
|
122 |
/**
|
123 |
* Actions to take after a backup file has been generated.
|
124 |
*
|
125 |
-
* @since 1.
|
126 |
*
|
127 |
-
* @param array $info
|
128 |
*/
|
129 |
public function post_archive_files( $info ) {
|
130 |
-
|
131 |
/*
|
132 |
* We only want to add this to the jobs queue if we're in the middle of
|
133 |
* an automatic backup. If the user simply clicked on "Backup site now",
|
@@ -143,9 +147,10 @@ class Boldgrid_Backup_Admin_Ftp_Hooks {
|
|
143 |
}
|
144 |
|
145 |
$args = array(
|
146 |
-
'filepath'
|
147 |
-
'action'
|
148 |
-
'action_data'
|
|
|
149 |
'action_title' => sprintf( __( 'Upload backup file to %1$s', 'boldgrid-backup' ), $this->core->ftp->title ),
|
150 |
);
|
151 |
|
@@ -155,7 +160,9 @@ class Boldgrid_Backup_Admin_Ftp_Hooks {
|
|
155 |
/**
|
156 |
* Register FTP as a storage location.
|
157 |
*
|
158 |
-
* @since 1.
|
|
|
|
|
159 |
*/
|
160 |
public function register_storage_location( $storage_locations ) {
|
161 |
$storage_locations[] = $this->core->ftp->get_details();
|
@@ -166,21 +173,21 @@ class Boldgrid_Backup_Admin_Ftp_Hooks {
|
|
166 |
/**
|
167 |
* Register FTP on the archive details page.
|
168 |
*
|
169 |
-
* @since 1.
|
170 |
*
|
171 |
-
* @param string $filepath
|
172 |
*/
|
173 |
public function single_archive_remote_option( $filepath ) {
|
174 |
$allow_upload = $this->core->ftp->is_setup();
|
175 |
-
$uploaded
|
176 |
|
177 |
$this->core->archive_details->remote_storage_li[] = array(
|
178 |
-
'id'
|
179 |
-
'title'
|
180 |
-
'title_attr'
|
181 |
-
'uploaded'
|
182 |
'allow_upload' => $allow_upload,
|
183 |
-
'is_setup'
|
184 |
);
|
185 |
}
|
186 |
|
@@ -191,7 +198,7 @@ class Boldgrid_Backup_Admin_Ftp_Hooks {
|
|
191 |
*
|
192 |
* @since 1.0.0
|
193 |
*
|
194 |
-
* @param string $filepath
|
195 |
*/
|
196 |
public function upload_post_archiving( $filepath ) {
|
197 |
$success = $this->core->ftp->upload( $filepath );
|
@@ -202,7 +209,7 @@ class Boldgrid_Backup_Admin_Ftp_Hooks {
|
|
202 |
/**
|
203 |
* Handle the ajax request to download an FTP backup locally.
|
204 |
*
|
205 |
-
* @since 1.
|
206 |
*/
|
207 |
public function wp_ajax_download() {
|
208 |
$error = __( 'Unable to download backup from FTP', 'bolgrid-bakcup' );
|
@@ -242,9 +249,12 @@ class Boldgrid_Backup_Admin_Ftp_Hooks {
|
|
242 |
if ( $result ) {
|
243 |
$this->core->notice->add_user_notice(
|
244 |
sprintf(
|
245 |
-
|
246 |
-
|
247 |
-
|
|
|
|
|
|
|
248 |
),
|
249 |
'notice notice-success'
|
250 |
);
|
@@ -255,7 +265,7 @@ class Boldgrid_Backup_Admin_Ftp_Hooks {
|
|
255 |
/**
|
256 |
* Upload a file (triggered by ajax).
|
257 |
*
|
258 |
-
* @since 1.
|
259 |
*/
|
260 |
public function wp_ajax_upload() {
|
261 |
if ( ! current_user_can( 'update_plugins' ) ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-ftp-hooks.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.6.0
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
+
* @subpackage Boldgrid_Backup/admin/remote
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
+
*/
|
14 |
+
|
15 |
+
/*
|
16 |
+
* AJAX callback functions in this class have their nonce verified by validate_nonce() in the Boldgrid_Backup_Admin_Archive_Details class.
|
17 |
+
*
|
18 |
+
* phpcs:disable WordPress.VIP, WordPress.CSRF.NonceVerification.NoNonceVerification, WordPress.Security.NonceVerification.NoNonceVerification
|
19 |
*/
|
20 |
|
21 |
/**
|
22 |
+
* Class: Boldgrid_Backup_Admin_Ftp_Hooks
|
23 |
*
|
24 |
* The only purpose this class is to be used for is to separate methods that are
|
25 |
* used for registering a new remove provider. All of these methods are called
|
26 |
* via hooks.
|
27 |
*
|
28 |
+
* @since 1.6.0
|
29 |
*/
|
30 |
class Boldgrid_Backup_Admin_Ftp_Hooks {
|
|
|
31 |
/**
|
32 |
* The core class object.
|
33 |
*
|
34 |
+
* @since 1.6.0
|
35 |
* @access private
|
36 |
* @var Boldgrid_Backup_Admin_Core
|
37 |
*/
|
40 |
/**
|
41 |
* Constructor.
|
42 |
*
|
43 |
+
* @since 1.6.0
|
44 |
*
|
45 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
46 |
*/
|
51 |
/**
|
52 |
* Add menu items.
|
53 |
*
|
54 |
+
* @since 1.6.0
|
55 |
*/
|
56 |
public function add_menu_items() {
|
57 |
$capability = 'administrator';
|
72 |
/**
|
73 |
* Hook into the filter to add all ftp backups to the full list of backups.
|
74 |
*
|
75 |
+
* @since 1.6.0
|
76 |
*/
|
77 |
public function filter_get_all() {
|
78 |
$contents = $this->core->ftp->get_contents( true, $this->core->ftp->remote_dir );
|
82 |
$filename = $item['filename'];
|
83 |
|
84 |
$backup = array(
|
85 |
+
'filename' => $filename,
|
86 |
'last_modified' => $item['time'],
|
87 |
+
'size' => $item['size'],
|
88 |
+
'locations' => array(
|
89 |
array(
|
90 |
+
'title' => $this->core->ftp->nickname,
|
91 |
'on_remote_server' => true,
|
92 |
+
'title_attr' => $this->core->ftp->title_attr,
|
93 |
),
|
94 |
),
|
95 |
);
|
101 |
/**
|
102 |
* Determine if FTP is setup.
|
103 |
*
|
104 |
+
* @since 1.6.0
|
105 |
*/
|
106 |
public function is_setup_ajax() {
|
107 |
if ( ! current_user_can( 'update_plugins' ) ) {
|
115 |
$settings = $this->core->settings->get_settings();
|
116 |
|
117 |
$location = $this->core->ftp->get_details();
|
118 |
+
$tr = include BOLDGRID_BACKUP_PATH . '/admin/partials/settings/storage-location.php';
|
119 |
|
120 |
if ( $this->core->ftp->is_setup() ) {
|
121 |
wp_send_json_success( $tr );
|
127 |
/**
|
128 |
* Actions to take after a backup file has been generated.
|
129 |
*
|
130 |
+
* @since 1.6.0
|
131 |
*
|
132 |
+
* @param array $info Archive information.
|
133 |
*/
|
134 |
public function post_archive_files( $info ) {
|
|
|
135 |
/*
|
136 |
* We only want to add this to the jobs queue if we're in the middle of
|
137 |
* an automatic backup. If the user simply clicked on "Backup site now",
|
147 |
}
|
148 |
|
149 |
$args = array(
|
150 |
+
'filepath' => $info['filepath'],
|
151 |
+
'action' => 'boldgrid_backup_' . $this->core->ftp->key . '_upload_post_archive',
|
152 |
+
'action_data' => $info['filepath'],
|
153 |
+
// translators: 1: FTP account title/name.
|
154 |
'action_title' => sprintf( __( 'Upload backup file to %1$s', 'boldgrid-backup' ), $this->core->ftp->title ),
|
155 |
);
|
156 |
|
160 |
/**
|
161 |
* Register FTP as a storage location.
|
162 |
*
|
163 |
+
* @since 1.6.0
|
164 |
+
*
|
165 |
+
* @param array $storage_locations Storage locations.
|
166 |
*/
|
167 |
public function register_storage_location( $storage_locations ) {
|
168 |
$storage_locations[] = $this->core->ftp->get_details();
|
173 |
/**
|
174 |
* Register FTP on the archive details page.
|
175 |
*
|
176 |
+
* @since 1.6.0
|
177 |
*
|
178 |
+
* @param string $filepath File path.
|
179 |
*/
|
180 |
public function single_archive_remote_option( $filepath ) {
|
181 |
$allow_upload = $this->core->ftp->is_setup();
|
182 |
+
$uploaded = $this->core->ftp->is_uploaded( $filepath );
|
183 |
|
184 |
$this->core->archive_details->remote_storage_li[] = array(
|
185 |
+
'id' => $this->core->ftp->key,
|
186 |
+
'title' => $this->core->ftp->nickname,
|
187 |
+
'title_attr' => $this->core->ftp->title_attr,
|
188 |
+
'uploaded' => $uploaded,
|
189 |
'allow_upload' => $allow_upload,
|
190 |
+
'is_setup' => $this->core->ftp->is_setup(),
|
191 |
);
|
192 |
}
|
193 |
|
198 |
*
|
199 |
* @since 1.0.0
|
200 |
*
|
201 |
+
* @param string $filepath File path.
|
202 |
*/
|
203 |
public function upload_post_archiving( $filepath ) {
|
204 |
$success = $this->core->ftp->upload( $filepath );
|
209 |
/**
|
210 |
* Handle the ajax request to download an FTP backup locally.
|
211 |
*
|
212 |
+
* @since 1.6.0
|
213 |
*/
|
214 |
public function wp_ajax_download() {
|
215 |
$error = __( 'Unable to download backup from FTP', 'bolgrid-bakcup' );
|
249 |
if ( $result ) {
|
250 |
$this->core->notice->add_user_notice(
|
251 |
sprintf(
|
252 |
+
// translators: 1: Filename.
|
253 |
+
esc_html__(
|
254 |
+
'<h2>BoldGrid Backup Premium - FTP Download</h2><p>Backup file <strong>%1$s</strong> successfully downloaded from FTP.</p>',
|
255 |
+
'boldgrid-backup'
|
256 |
+
),
|
257 |
+
$filename
|
258 |
),
|
259 |
'notice notice-success'
|
260 |
);
|
265 |
/**
|
266 |
* Upload a file (triggered by ajax).
|
267 |
*
|
268 |
+
* @since 1.6.0
|
269 |
*/
|
270 |
public function wp_ajax_upload() {
|
271 |
if ( ! current_user_can( 'update_plugins' ) ) {
|
admin/remote/{ftp-page.php → class-boldgrid-backup-admin-ftp-page.php}
RENAMED
@@ -1,28 +1,29 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since 1.
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
-
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
|
|
|
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
-
* @since 1.
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Ftp_Page {
|
21 |
-
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
25 |
-
* @since
|
26 |
* @access private
|
27 |
* @var Boldgrid_Backup_Admin_Core
|
28 |
*/
|
@@ -31,7 +32,7 @@ class Boldgrid_Backup_Admin_Ftp_Page {
|
|
31 |
/**
|
32 |
* Constructor.
|
33 |
*
|
34 |
-
* @since 1.
|
35 |
*
|
36 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
37 |
*/
|
@@ -42,11 +43,12 @@ class Boldgrid_Backup_Admin_Ftp_Page {
|
|
42 |
/**
|
43 |
* Enqueue scripts.
|
44 |
*
|
45 |
-
* @since 1.
|
46 |
*/
|
47 |
public function enqueue_scripts() {
|
48 |
$handle = 'boldgrid-backup-admin-ftp-settings';
|
49 |
-
wp_register_script(
|
|
|
50 |
plugin_dir_url( dirname( __FILE__ ) ) . 'js/' . $handle . '.js',
|
51 |
array( 'jquery' ),
|
52 |
BOLDGRID_BACKUP_VERSION,
|
@@ -69,7 +71,7 @@ class Boldgrid_Backup_Admin_Ftp_Page {
|
|
69 |
/**
|
70 |
* Generate the submenu page for our FTP Settings page.
|
71 |
*
|
72 |
-
* @since 1.
|
73 |
*/
|
74 |
public function settings() {
|
75 |
if ( ! current_user_can( 'update_plugins' ) ) {
|
@@ -80,25 +82,25 @@ class Boldgrid_Backup_Admin_Ftp_Page {
|
|
80 |
wp_enqueue_style( 'boldgrid-backup-admin-hide-all' );
|
81 |
|
82 |
// Blank data, used when deleting settings.
|
83 |
-
$type
|
84 |
$blank_data = array(
|
85 |
-
'type'
|
86 |
-
'host'
|
87 |
-
'port'
|
88 |
-
'user'
|
89 |
-
'pass'
|
90 |
'retention_count' => $this->core->ftp->retention_count,
|
91 |
-
'nickname'
|
92 |
);
|
93 |
|
94 |
// Post data, used by default or when updating settings.
|
95 |
$post_data = $this->core->ftp->get_from_post();
|
96 |
|
97 |
-
$action = ! empty( $_POST['action'] ) ? sanitize_key( $_POST['action'] ) : null;
|
98 |
|
99 |
switch ( $action ) {
|
100 |
case 'save':
|
101 |
-
|
102 |
ob_flush();
|
103 |
flush();
|
104 |
|
@@ -113,13 +115,13 @@ class Boldgrid_Backup_Admin_Ftp_Page {
|
|
113 |
$data = $post_data;
|
114 |
}
|
115 |
|
116 |
-
include BOLDGRID_BACKUP_PATH . '/admin/partials/remote/ftp.php';
|
117 |
}
|
118 |
|
119 |
/**
|
120 |
* Process the user's request to update their FTP settings.
|
121 |
*
|
122 |
-
* @since 1.
|
123 |
*/
|
124 |
public function settings_delete() {
|
125 |
$ftp = $this->core->ftp;
|
@@ -145,7 +147,7 @@ class Boldgrid_Backup_Admin_Ftp_Page {
|
|
145 |
/**
|
146 |
* Process the user's request to update their FTP settings.
|
147 |
*
|
148 |
-
* @since 1.
|
149 |
*/
|
150 |
public function settings_save() {
|
151 |
|
@@ -156,7 +158,7 @@ class Boldgrid_Backup_Admin_Ftp_Page {
|
|
156 |
return false;
|
157 |
}
|
158 |
|
159 |
-
if ( empty( $_POST ) ) {
|
160 |
return false;
|
161 |
}
|
162 |
|
@@ -178,7 +180,7 @@ class Boldgrid_Backup_Admin_Ftp_Page {
|
|
178 |
}
|
179 |
|
180 |
$settings['remote'][ $ftp->key ]['retention_count'] = $data['retention_count'];
|
181 |
-
$settings['remote'][ $ftp->key ]['nickname']
|
182 |
|
183 |
if ( ! empty( $ftp->errors ) ) {
|
184 |
do_action( 'boldgrid_backup_notice', implode( '<br /><br />', $ftp->errors ) );
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-ftp-page.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.6.0
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
+
* @subpackage Boldgrid_Backup/admin/remote
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
// phpcs:disable WordPress.VIP
|
16 |
+
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Ftp_Page
|
19 |
*
|
20 |
+
* @since 1.6.0
|
21 |
*/
|
22 |
class Boldgrid_Backup_Admin_Ftp_Page {
|
|
|
23 |
/**
|
24 |
* The core class object.
|
25 |
*
|
26 |
+
* @since 1.6.0
|
27 |
* @access private
|
28 |
* @var Boldgrid_Backup_Admin_Core
|
29 |
*/
|
32 |
/**
|
33 |
* Constructor.
|
34 |
*
|
35 |
+
* @since 1.6.0
|
36 |
*
|
37 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
38 |
*/
|
43 |
/**
|
44 |
* Enqueue scripts.
|
45 |
*
|
46 |
+
* @since 1.6.0
|
47 |
*/
|
48 |
public function enqueue_scripts() {
|
49 |
$handle = 'boldgrid-backup-admin-ftp-settings';
|
50 |
+
wp_register_script(
|
51 |
+
$handle,
|
52 |
plugin_dir_url( dirname( __FILE__ ) ) . 'js/' . $handle . '.js',
|
53 |
array( 'jquery' ),
|
54 |
BOLDGRID_BACKUP_VERSION,
|
71 |
/**
|
72 |
* Generate the submenu page for our FTP Settings page.
|
73 |
*
|
74 |
+
* @since 1.6.0
|
75 |
*/
|
76 |
public function settings() {
|
77 |
if ( ! current_user_can( 'update_plugins' ) ) {
|
82 |
wp_enqueue_style( 'boldgrid-backup-admin-hide-all' );
|
83 |
|
84 |
// Blank data, used when deleting settings.
|
85 |
+
$type = $this->core->ftp->default_type;
|
86 |
$blank_data = array(
|
87 |
+
'type' => $type,
|
88 |
+
'host' => null,
|
89 |
+
'port' => $this->core->ftp->default_port[ $type ],
|
90 |
+
'user' => null,
|
91 |
+
'pass' => null,
|
92 |
'retention_count' => $this->core->ftp->retention_count,
|
93 |
+
'nickname' => '',
|
94 |
);
|
95 |
|
96 |
// Post data, used by default or when updating settings.
|
97 |
$post_data = $this->core->ftp->get_from_post();
|
98 |
|
99 |
+
$action = ! empty( $_POST['action'] ) ? sanitize_key( $_POST['action'] ) : null; // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification, WordPress.Security.NonceVerification.NoNonceVerification
|
100 |
|
101 |
switch ( $action ) {
|
102 |
case 'save':
|
103 |
+
esc_html( $this->core->elements['long_checking_creds'] );
|
104 |
ob_flush();
|
105 |
flush();
|
106 |
|
115 |
$data = $post_data;
|
116 |
}
|
117 |
|
118 |
+
include BOLDGRID_BACKUP_PATH . '/admin/partials/remote/class-boldgrid-backup-admin-ftp.php';
|
119 |
}
|
120 |
|
121 |
/**
|
122 |
* Process the user's request to update their FTP settings.
|
123 |
*
|
124 |
+
* @since 1.6.0
|
125 |
*/
|
126 |
public function settings_delete() {
|
127 |
$ftp = $this->core->ftp;
|
147 |
/**
|
148 |
* Process the user's request to update their FTP settings.
|
149 |
*
|
150 |
+
* @since 1.6.0
|
151 |
*/
|
152 |
public function settings_save() {
|
153 |
|
158 |
return false;
|
159 |
}
|
160 |
|
161 |
+
if ( empty( $_POST ) ) { // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification, WordPress.Security.NonceVerification.NoNonceVerification
|
162 |
return false;
|
163 |
}
|
164 |
|
180 |
}
|
181 |
|
182 |
$settings['remote'][ $ftp->key ]['retention_count'] = $data['retention_count'];
|
183 |
+
$settings['remote'][ $ftp->key ]['nickname'] = $data['nickname'];
|
184 |
|
185 |
if ( ! empty( $ftp->errors ) ) {
|
186 |
do_action( 'boldgrid_backup_notice', implode( '<br /><br />', $ftp->errors ) );
|
admin/remote/{ftp.php → class-boldgrid-backup-admin-ftp.php}
RENAMED
@@ -1,28 +1,29 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since 1.
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
-
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
|
|
|
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
-
* @since 1.
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Ftp {
|
21 |
-
|
22 |
/**
|
23 |
* An FTP connection.
|
24 |
*
|
25 |
-
* @since
|
26 |
* @access private
|
27 |
* @var Resource
|
28 |
*/
|
@@ -31,7 +32,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
31 |
/**
|
32 |
* The core class object.
|
33 |
*
|
34 |
-
* @since
|
35 |
* @access private
|
36 |
* @var Boldgrid_Backup_Admin_Core
|
37 |
*/
|
@@ -40,19 +41,19 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
40 |
/**
|
41 |
* Default port numbers.
|
42 |
*
|
43 |
-
* @since
|
44 |
* @access public
|
45 |
* @var array
|
46 |
*/
|
47 |
public $default_port = array(
|
48 |
-
'ftp'
|
49 |
'sftp' => 22,
|
50 |
);
|
51 |
|
52 |
/**
|
53 |
* Default type.
|
54 |
*
|
55 |
-
* @since
|
56 |
* @access public
|
57 |
* @var string
|
58 |
*/
|
@@ -61,7 +62,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
61 |
/**
|
62 |
* Errors.
|
63 |
*
|
64 |
-
* @since
|
65 |
* @access public
|
66 |
* @var array
|
67 |
*/
|
@@ -70,7 +71,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
70 |
/**
|
71 |
* Hooks class.
|
72 |
*
|
73 |
-
* @since
|
74 |
* @access public
|
75 |
* @var Boldgrid_Backup_Admin_Ftp_Hooks
|
76 |
*/
|
@@ -79,7 +80,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
79 |
/**
|
80 |
* FTP host.
|
81 |
*
|
82 |
-
* @since
|
83 |
* @access private
|
84 |
* @var string
|
85 |
*/
|
@@ -88,7 +89,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
88 |
/**
|
89 |
* Whether or not we have logged in.
|
90 |
*
|
91 |
-
* @since
|
92 |
* @access public
|
93 |
* @var bool
|
94 |
*/
|
@@ -108,7 +109,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
108 |
/**
|
109 |
* Our key / label for ftp.
|
110 |
*
|
111 |
-
* @since
|
112 |
* @access public
|
113 |
* @var string
|
114 |
*/
|
@@ -117,7 +118,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
117 |
/**
|
118 |
* FTP password.
|
119 |
*
|
120 |
-
* @since
|
121 |
* @access private
|
122 |
* @var string
|
123 |
*/
|
@@ -126,7 +127,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
126 |
/**
|
127 |
* FTP remote directory.
|
128 |
*
|
129 |
-
* @since
|
130 |
* @access public
|
131 |
* @var string
|
132 |
*/
|
@@ -135,7 +136,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
135 |
/**
|
136 |
* Retention count.
|
137 |
*
|
138 |
-
* @since
|
139 |
* @access public
|
140 |
* @var int $retention_count
|
141 |
*/
|
@@ -144,7 +145,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
144 |
/**
|
145 |
* Default timeout.
|
146 |
*
|
147 |
-
* @since
|
148 |
* @access public
|
149 |
* @var int
|
150 |
*/
|
@@ -153,7 +154,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
153 |
/**
|
154 |
* Our title / label for ftp.
|
155 |
*
|
156 |
-
* @since
|
157 |
* @access public
|
158 |
* @var string
|
159 |
*/
|
@@ -174,7 +175,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
174 |
/**
|
175 |
* Our FTP type, ftp or sftp.
|
176 |
*
|
177 |
-
* @since
|
178 |
* @access public
|
179 |
* @var string
|
180 |
*/
|
@@ -183,7 +184,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
183 |
/**
|
184 |
* FTP username.
|
185 |
*
|
186 |
-
* @since
|
187 |
* @access private
|
188 |
* @var string
|
189 |
*/
|
@@ -192,7 +193,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
192 |
/**
|
193 |
* Valid types.
|
194 |
*
|
195 |
-
* @since
|
196 |
* @access public
|
197 |
* @var array
|
198 |
*/
|
@@ -201,22 +202,22 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
201 |
/**
|
202 |
* Constructor.
|
203 |
*
|
204 |
-
* @since 1.
|
205 |
*
|
206 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
207 |
*/
|
208 |
public function __construct( $core ) {
|
209 |
include_once BOLDGRID_BACKUP_PATH . '/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php';
|
210 |
|
211 |
-
$this->core
|
212 |
$this->hooks = new Boldgrid_Backup_Admin_Ftp_Hooks( $core );
|
213 |
-
$this->page
|
214 |
}
|
215 |
|
216 |
/**
|
217 |
* Connect to our ftp server.
|
218 |
*
|
219 |
-
* @since 1.
|
220 |
*/
|
221 |
public function connect() {
|
222 |
if ( ! empty( $this->connection ) ) {
|
@@ -242,7 +243,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
242 |
/**
|
243 |
* Create backup directory on remote host.
|
244 |
*
|
245 |
-
* @since 1.
|
246 |
*
|
247 |
* @return bool False when we were unable to create directory.
|
248 |
*/
|
@@ -271,7 +272,14 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
271 |
}
|
272 |
|
273 |
if ( ! $created ) {
|
274 |
-
$this->errors[] = sprintf(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
}
|
276 |
|
277 |
return $created;
|
@@ -280,30 +288,30 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
280 |
/**
|
281 |
* Disconnect from FTP server.
|
282 |
*
|
283 |
-
* @since 1.
|
284 |
*/
|
285 |
public function disconnect() {
|
286 |
if ( 'ftp' === $this->type && is_resource( $this->connection ) ) {
|
287 |
ftp_close( $this->connection );
|
288 |
$this->connection = null;
|
289 |
-
$this->logged_in
|
290 |
}
|
291 |
}
|
292 |
|
293 |
/**
|
294 |
* Download a backup via FTP.
|
295 |
*
|
296 |
-
* @since 1.
|
297 |
*
|
298 |
-
* @param string $filename
|
299 |
* @return bool
|
300 |
*/
|
301 |
public function download( $filename ) {
|
302 |
$this->connect();
|
303 |
|
304 |
-
$local_filepath
|
305 |
$server_filepath = $this->remote_dir . '/' . $filename;
|
306 |
-
$success
|
307 |
|
308 |
$this->log_in();
|
309 |
|
@@ -326,7 +334,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
326 |
/**
|
327 |
* Enforce retention.
|
328 |
*
|
329 |
-
* @since 1.
|
330 |
*/
|
331 |
public function enforce_retention() {
|
332 |
if ( empty( $this->retention_count ) ) {
|
@@ -334,7 +342,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
334 |
}
|
335 |
|
336 |
$contents = $this->get_contents( true, $this->remote_dir );
|
337 |
-
$backups
|
338 |
|
339 |
$count_to_delete = count( $backups ) - $this->retention_count;
|
340 |
|
@@ -342,13 +350,15 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
342 |
return false;
|
343 |
}
|
344 |
|
345 |
-
usort(
|
346 |
-
|
347 |
-
|
|
|
|
|
348 |
|
349 |
for ( $x = 0; $x < $count_to_delete; $x++ ) {
|
350 |
$filename = $backups[ $x ]['filename'];
|
351 |
-
$path
|
352 |
|
353 |
switch ( $this->type ) {
|
354 |
case 'ftp':
|
@@ -362,7 +372,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
362 |
/**
|
363 |
* Remote file deleted due to remote retention settings.
|
364 |
*
|
365 |
-
* @since 1.
|
366 |
*/
|
367 |
do_action(
|
368 |
'boldgrid_backup_remote_retention_deleted',
|
@@ -375,7 +385,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
375 |
/**
|
376 |
* Get our settings from $_POST.
|
377 |
*
|
378 |
-
* @since 1.
|
379 |
*
|
380 |
* @return array
|
381 |
*/
|
@@ -384,43 +394,45 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
384 |
|
385 |
$values = array(
|
386 |
array(
|
387 |
-
'key'
|
388 |
-
'default'
|
389 |
'callback' => 'sanitize_file_name',
|
390 |
),
|
391 |
array(
|
392 |
-
'key'
|
393 |
-
'default'
|
394 |
'callback' => 'sanitize_text_field',
|
395 |
),
|
396 |
array(
|
397 |
-
'key'
|
398 |
'default' => null,
|
399 |
),
|
400 |
array(
|
401 |
-
'key'
|
402 |
-
'default'
|
403 |
'callback' => 'sanitize_key',
|
404 |
),
|
405 |
array(
|
406 |
-
'key'
|
407 |
-
'default'
|
408 |
'callback' => 'intval',
|
409 |
),
|
410 |
array(
|
411 |
-
'key'
|
412 |
-
'default'
|
413 |
'callback' => 'intval',
|
414 |
),
|
415 |
array(
|
416 |
-
'key'
|
417 |
-
'default'
|
418 |
'callback' => 'stripslashes',
|
419 |
),
|
420 |
);
|
421 |
|
|
|
|
|
422 |
foreach ( $values as $value ) {
|
423 |
-
$key
|
424 |
$callback = ! empty( $value['callback'] ) ? $value['callback'] : null;
|
425 |
|
426 |
if ( ! empty( $_POST[ $key ] ) ) {
|
@@ -437,6 +449,8 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
437 |
}
|
438 |
}
|
439 |
|
|
|
|
|
440 |
return $data;
|
441 |
}
|
442 |
|
@@ -451,9 +465,9 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
451 |
* # Files / backups that do not belong to this site.
|
452 |
* See $this->core->archive->is_site_archive().
|
453 |
*
|
454 |
-
* @since 1.
|
455 |
*
|
456 |
-
* @param array $
|
457 |
* @return array {
|
458 |
* An array of backups.
|
459 |
*
|
@@ -462,7 +476,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
462 |
* }
|
463 |
*/
|
464 |
public function format_raw_contents( $contents ) {
|
465 |
-
$skips
|
466 |
$backups = array();
|
467 |
|
468 |
if ( ! is_array( $contents ) ) {
|
@@ -478,16 +492,16 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
478 |
}
|
479 |
|
480 |
$backups[] = array(
|
481 |
-
'time'
|
482 |
'filename' => $filename,
|
483 |
-
'size'
|
484 |
);
|
485 |
} else {
|
486 |
// Before exploding by space, replace multiple spaces with one space.
|
487 |
$item = preg_replace( '!\s+!', ' ', $item );
|
488 |
|
489 |
$exploded_item = explode( ' ', $item );
|
490 |
-
$count
|
491 |
|
492 |
$filename = $exploded_item[ $count - 1 ];
|
493 |
if ( in_array( $filename, $skips, true ) ) {
|
@@ -496,14 +510,14 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
496 |
|
497 |
// Get the timestamp.
|
498 |
$month = $exploded_item[ $count - 4 ];
|
499 |
-
$day
|
500 |
-
$time
|
501 |
-
$time
|
502 |
|
503 |
$backups[] = array(
|
504 |
-
'time'
|
505 |
'filename' => $filename,
|
506 |
-
'size'
|
507 |
);
|
508 |
}
|
509 |
}
|
@@ -521,7 +535,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
521 |
/**
|
522 |
* Get the remote contents / listing.
|
523 |
*
|
524 |
-
* @since 1.
|
525 |
*
|
526 |
* @param bool $raw Whether to get the raw contents (ftp_rawlist) or not
|
527 |
* (ftp_nlist).
|
@@ -541,7 +555,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
541 |
if ( $raw ) {
|
542 |
return ftp_rawlist( $this->connection, $dir );
|
543 |
} else {
|
544 |
-
return ftp_nlist( $this->connection
|
545 |
}
|
546 |
break;
|
547 |
case 'sftp':
|
@@ -557,7 +571,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
557 |
/**
|
558 |
* Get settings.
|
559 |
*
|
560 |
-
* @since 1.
|
561 |
*/
|
562 |
public function get_details() {
|
563 |
$is_setup = $this->is_setup();
|
@@ -565,18 +579,18 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
565 |
$settings = $this->core->settings->get_settings();
|
566 |
|
567 |
return array(
|
568 |
-
'title'
|
569 |
-
'key'
|
570 |
'configure' => 'admin.php?page=boldgrid-backup-ftp',
|
571 |
-
'is_setup'
|
572 |
-
'enabled'
|
573 |
);
|
574 |
}
|
575 |
|
576 |
/**
|
577 |
* Init properties.
|
578 |
*
|
579 |
-
* @since 1.
|
580 |
*/
|
581 |
public function init() {
|
582 |
if ( ! empty( $this->user ) || ! empty( $this->pass ) || ! empty( $this->host ) ) {
|
@@ -590,31 +604,31 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
590 |
$configs = array(
|
591 |
array(
|
592 |
'property' => 'user',
|
593 |
-
'default'
|
594 |
),
|
595 |
array(
|
596 |
'property' => 'pass',
|
597 |
-
'default'
|
598 |
),
|
599 |
array(
|
600 |
'property' => 'host',
|
601 |
-
'default'
|
602 |
),
|
603 |
array(
|
604 |
'property' => 'port',
|
605 |
-
'default'
|
606 |
),
|
607 |
array(
|
608 |
'property' => 'type',
|
609 |
-
'default'
|
610 |
),
|
611 |
array(
|
612 |
'property' => 'retention_count',
|
613 |
-
'default'
|
614 |
),
|
615 |
array(
|
616 |
'property' => 'nickname',
|
617 |
-
'default'
|
618 |
),
|
619 |
);
|
620 |
|
@@ -636,7 +650,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
636 |
/**
|
637 |
* Determine whether or not FTP is setup.
|
638 |
*
|
639 |
-
* @since 1.
|
640 |
*
|
641 |
* @return bool
|
642 |
*/
|
@@ -654,36 +668,52 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
654 |
/**
|
655 |
* Determine if a set of FTP credentials are valid.
|
656 |
*
|
657 |
-
* @since 1.
|
658 |
*
|
659 |
-
* @param string $host
|
660 |
-
* @param string $user
|
661 |
-
* @param string $pass
|
662 |
-
* @param int $port
|
663 |
-
* @param string $type
|
664 |
* @return bool
|
665 |
*/
|
666 |
public function is_valid_credentials( $host, $user, $pass, $port, $type ) {
|
667 |
$connection = false;
|
668 |
-
$logged_in
|
669 |
-
$port
|
670 |
|
671 |
// Avoid a really long timeout.
|
672 |
if ( 21 === $port && 'sftp' === $type ) {
|
673 |
-
$this->errors[] = sprintf(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
674 |
return false;
|
675 |
}
|
676 |
|
677 |
switch ( $type ) {
|
678 |
case 'ftp':
|
679 |
-
$connection = @ftp_connect( $host, $port, $this->timeout );
|
680 |
break;
|
681 |
case 'sftp':
|
682 |
-
$connection = @new phpseclib\Net\SFTP( $host, $port, $this->timeout );
|
683 |
break;
|
684 |
}
|
685 |
if ( ! $connection ) {
|
686 |
-
$this->errors[] = sprintf(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
687 |
return false;
|
688 |
}
|
689 |
|
@@ -701,7 +731,9 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
701 |
* and throw an Exception.
|
702 |
*/
|
703 |
$error_caught = false;
|
704 |
-
|
|
|
|
|
705 |
try {
|
706 |
switch ( $type ) {
|
707 |
case 'ftp':
|
@@ -714,7 +746,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
714 |
}
|
715 |
} catch ( Exception $e ) {
|
716 |
$this->errors[] = $e->getMessage();
|
717 |
-
$error_caught
|
718 |
}
|
719 |
restore_error_handler();
|
720 |
|
@@ -728,7 +760,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
728 |
/**
|
729 |
* Log into the FTP server.
|
730 |
*
|
731 |
-
* @since 1.
|
732 |
*
|
733 |
* @return bool
|
734 |
*/
|
@@ -745,7 +777,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
745 |
|
746 |
switch ( $this->type ) {
|
747 |
case 'ftp':
|
748 |
-
$this->logged_in = @ftp_login( $this->connection, $this->user, $this->pass );
|
749 |
break;
|
750 |
case 'sftp':
|
751 |
$this->logged_in = $this->connection->login( $this->user, $this->pass );
|
@@ -764,23 +796,23 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
764 |
* If the user wants to delete all FTP settings, after we clear the data from
|
765 |
* the options, run this method to clear the properties.
|
766 |
*
|
767 |
-
* @since 1.
|
768 |
*/
|
769 |
public function reset() {
|
770 |
$this->host = null;
|
771 |
$this->user = null;
|
772 |
$this->set_pass( null );
|
773 |
-
$this->port
|
774 |
$this->retention_count = null;
|
775 |
-
$this->type
|
776 |
}
|
777 |
|
778 |
/**
|
779 |
* Set our ftp password.
|
780 |
*
|
781 |
-
* @since 1.
|
782 |
*
|
783 |
-
* @param string $pass
|
784 |
*/
|
785 |
public function set_pass( $pass ) {
|
786 |
$this->pass = $pass;
|
@@ -789,9 +821,9 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
789 |
/**
|
790 |
* Determine if a backup archive is uploaded to the remote server.
|
791 |
*
|
792 |
-
* @since 1.
|
793 |
*
|
794 |
-
* @param string $filepath
|
795 |
*/
|
796 |
public function is_uploaded( $filepath ) {
|
797 |
$contents = $this->get_contents( false, $this->remote_dir );
|
@@ -802,9 +834,9 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
802 |
/**
|
803 |
* Upload a file.
|
804 |
*
|
805 |
-
* @since 1.
|
806 |
*
|
807 |
-
* @param string $filepath
|
808 |
* @return bool
|
809 |
*/
|
810 |
public function upload( $filepath ) {
|
@@ -842,7 +874,7 @@ class Boldgrid_Backup_Admin_Ftp {
|
|
842 |
* such as ftp_put(): Quota exceeded. Make sure the user sees the
|
843 |
* last error.
|
844 |
*/
|
845 |
-
if ( ! empty( $last_error['message'] ) && ! empty( $last_error['file'] ) && $last_error['file']
|
846 |
$this->errors[] = $last_error['message'];
|
847 |
}
|
848 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-ftp.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.6.0
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
+
* @subpackage Boldgrid_Backup/admin/remote
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
// phpcs:disable WordPress.VIP
|
16 |
+
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Ftp
|
19 |
*
|
20 |
+
* @since 1.6.0
|
21 |
*/
|
22 |
class Boldgrid_Backup_Admin_Ftp {
|
|
|
23 |
/**
|
24 |
* An FTP connection.
|
25 |
*
|
26 |
+
* @since 1.6.0
|
27 |
* @access private
|
28 |
* @var Resource
|
29 |
*/
|
32 |
/**
|
33 |
* The core class object.
|
34 |
*
|
35 |
+
* @since 1.6.0
|
36 |
* @access private
|
37 |
* @var Boldgrid_Backup_Admin_Core
|
38 |
*/
|
41 |
/**
|
42 |
* Default port numbers.
|
43 |
*
|
44 |
+
* @since 1.6.0
|
45 |
* @access public
|
46 |
* @var array
|
47 |
*/
|
48 |
public $default_port = array(
|
49 |
+
'ftp' => 21,
|
50 |
'sftp' => 22,
|
51 |
);
|
52 |
|
53 |
/**
|
54 |
* Default type.
|
55 |
*
|
56 |
+
* @since 1.6.0
|
57 |
* @access public
|
58 |
* @var string
|
59 |
*/
|
62 |
/**
|
63 |
* Errors.
|
64 |
*
|
65 |
+
* @since 1.6.0
|
66 |
* @access public
|
67 |
* @var array
|
68 |
*/
|
71 |
/**
|
72 |
* Hooks class.
|
73 |
*
|
74 |
+
* @since 1.6.0
|
75 |
* @access public
|
76 |
* @var Boldgrid_Backup_Admin_Ftp_Hooks
|
77 |
*/
|
80 |
/**
|
81 |
* FTP host.
|
82 |
*
|
83 |
+
* @since 1.6.0
|
84 |
* @access private
|
85 |
* @var string
|
86 |
*/
|
89 |
/**
|
90 |
* Whether or not we have logged in.
|
91 |
*
|
92 |
+
* @since 1.6.0
|
93 |
* @access public
|
94 |
* @var bool
|
95 |
*/
|
109 |
/**
|
110 |
* Our key / label for ftp.
|
111 |
*
|
112 |
+
* @since 1.6.0
|
113 |
* @access public
|
114 |
* @var string
|
115 |
*/
|
118 |
/**
|
119 |
* FTP password.
|
120 |
*
|
121 |
+
* @since 1.6.0
|
122 |
* @access private
|
123 |
* @var string
|
124 |
*/
|
127 |
/**
|
128 |
* FTP remote directory.
|
129 |
*
|
130 |
+
* @since 1.6.0
|
131 |
* @access public
|
132 |
* @var string
|
133 |
*/
|
136 |
/**
|
137 |
* Retention count.
|
138 |
*
|
139 |
+
* @since 1.6.0
|
140 |
* @access public
|
141 |
* @var int $retention_count
|
142 |
*/
|
145 |
/**
|
146 |
* Default timeout.
|
147 |
*
|
148 |
+
* @since 1.6.0
|
149 |
* @access public
|
150 |
* @var int
|
151 |
*/
|
154 |
/**
|
155 |
* Our title / label for ftp.
|
156 |
*
|
157 |
+
* @since 1.6.0
|
158 |
* @access public
|
159 |
* @var string
|
160 |
*/
|
175 |
/**
|
176 |
* Our FTP type, ftp or sftp.
|
177 |
*
|
178 |
+
* @since 1.6.0
|
179 |
* @access public
|
180 |
* @var string
|
181 |
*/
|
184 |
/**
|
185 |
* FTP username.
|
186 |
*
|
187 |
+
* @since 1.6.0
|
188 |
* @access private
|
189 |
* @var string
|
190 |
*/
|
193 |
/**
|
194 |
* Valid types.
|
195 |
*
|
196 |
+
* @since 1.6.0
|
197 |
* @access public
|
198 |
* @var array
|
199 |
*/
|
202 |
/**
|
203 |
* Constructor.
|
204 |
*
|
205 |
+
* @since 1.6.0
|
206 |
*
|
207 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
208 |
*/
|
209 |
public function __construct( $core ) {
|
210 |
include_once BOLDGRID_BACKUP_PATH . '/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php';
|
211 |
|
212 |
+
$this->core = $core;
|
213 |
$this->hooks = new Boldgrid_Backup_Admin_Ftp_Hooks( $core );
|
214 |
+
$this->page = new Boldgrid_Backup_Admin_Ftp_Page( $core );
|
215 |
}
|
216 |
|
217 |
/**
|
218 |
* Connect to our ftp server.
|
219 |
*
|
220 |
+
* @since 1.6.0
|
221 |
*/
|
222 |
public function connect() {
|
223 |
if ( ! empty( $this->connection ) ) {
|
243 |
/**
|
244 |
* Create backup directory on remote host.
|
245 |
*
|
246 |
+
* @since 1.6.0
|
247 |
*
|
248 |
* @return bool False when we were unable to create directory.
|
249 |
*/
|
272 |
}
|
273 |
|
274 |
if ( ! $created ) {
|
275 |
+
$this->errors[] = sprintf(
|
276 |
+
// translators: 1: Remote directory path.
|
277 |
+
__(
|
278 |
+
'Unable to create the following directory on FTP server: %1$s',
|
279 |
+
'boldgrid-backup'
|
280 |
+
),
|
281 |
+
$this->remote_dir
|
282 |
+
);
|
283 |
}
|
284 |
|
285 |
return $created;
|
288 |
/**
|
289 |
* Disconnect from FTP server.
|
290 |
*
|
291 |
+
* @since 1.6.0
|
292 |
*/
|
293 |
public function disconnect() {
|
294 |
if ( 'ftp' === $this->type && is_resource( $this->connection ) ) {
|
295 |
ftp_close( $this->connection );
|
296 |
$this->connection = null;
|
297 |
+
$this->logged_in = false;
|
298 |
}
|
299 |
}
|
300 |
|
301 |
/**
|
302 |
* Download a backup via FTP.
|
303 |
*
|
304 |
+
* @since 1.6.0
|
305 |
*
|
306 |
+
* @param string $filename Filename.
|
307 |
* @return bool
|
308 |
*/
|
309 |
public function download( $filename ) {
|
310 |
$this->connect();
|
311 |
|
312 |
+
$local_filepath = $this->core->backup_dir->get_path_to( $filename );
|
313 |
$server_filepath = $this->remote_dir . '/' . $filename;
|
314 |
+
$success = false;
|
315 |
|
316 |
$this->log_in();
|
317 |
|
334 |
/**
|
335 |
* Enforce retention.
|
336 |
*
|
337 |
+
* @since 1.6.0
|
338 |
*/
|
339 |
public function enforce_retention() {
|
340 |
if ( empty( $this->retention_count ) ) {
|
342 |
}
|
343 |
|
344 |
$contents = $this->get_contents( true, $this->remote_dir );
|
345 |
+
$backups = $this->format_raw_contents( $contents );
|
346 |
|
347 |
$count_to_delete = count( $backups ) - $this->retention_count;
|
348 |
|
350 |
return false;
|
351 |
}
|
352 |
|
353 |
+
usort(
|
354 |
+
$backups, function( $a, $b ) {
|
355 |
+
return $a['time'] < $b['time'] ? -1 : 1;
|
356 |
+
}
|
357 |
+
);
|
358 |
|
359 |
for ( $x = 0; $x < $count_to_delete; $x++ ) {
|
360 |
$filename = $backups[ $x ]['filename'];
|
361 |
+
$path = $this->remote_dir . '/' . $filename;
|
362 |
|
363 |
switch ( $this->type ) {
|
364 |
case 'ftp':
|
372 |
/**
|
373 |
* Remote file deleted due to remote retention settings.
|
374 |
*
|
375 |
+
* @since 1.6.0
|
376 |
*/
|
377 |
do_action(
|
378 |
'boldgrid_backup_remote_retention_deleted',
|
385 |
/**
|
386 |
* Get our settings from $_POST.
|
387 |
*
|
388 |
+
* @since 1.6.0
|
389 |
*
|
390 |
* @return array
|
391 |
*/
|
394 |
|
395 |
$values = array(
|
396 |
array(
|
397 |
+
'key' => 'host',
|
398 |
+
'default' => null,
|
399 |
'callback' => 'sanitize_file_name',
|
400 |
),
|
401 |
array(
|
402 |
+
'key' => 'user',
|
403 |
+
'default' => null,
|
404 |
'callback' => 'sanitize_text_field',
|
405 |
),
|
406 |
array(
|
407 |
+
'key' => 'pass',
|
408 |
'default' => null,
|
409 |
),
|
410 |
array(
|
411 |
+
'key' => 'type',
|
412 |
+
'default' => $this->default_type,
|
413 |
'callback' => 'sanitize_key',
|
414 |
),
|
415 |
array(
|
416 |
+
'key' => 'port',
|
417 |
+
'default' => $this->default_port[ $this->default_type ],
|
418 |
'callback' => 'intval',
|
419 |
),
|
420 |
array(
|
421 |
+
'key' => 'retention_count',
|
422 |
+
'default' => $this->retention_count,
|
423 |
'callback' => 'intval',
|
424 |
),
|
425 |
array(
|
426 |
+
'key' => 'nickname',
|
427 |
+
'default' => '',
|
428 |
'callback' => 'stripslashes',
|
429 |
),
|
430 |
);
|
431 |
|
432 |
+
// phpcs:disable WordPress.CSRF.NonceVerification.NoNonceVerification, WordPress.Security.NonceVerification.NoNonceVerification
|
433 |
+
|
434 |
foreach ( $values as $value ) {
|
435 |
+
$key = $value['key'];
|
436 |
$callback = ! empty( $value['callback'] ) ? $value['callback'] : null;
|
437 |
|
438 |
if ( ! empty( $_POST[ $key ] ) ) {
|
449 |
}
|
450 |
}
|
451 |
|
452 |
+
// phpcs:enable WordPress.CSRF.NonceVerification.NoNonceVerification, WordPress.Security.NonceVerification.NoNonceVerification
|
453 |
+
|
454 |
return $data;
|
455 |
}
|
456 |
|
465 |
* # Files / backups that do not belong to this site.
|
466 |
* See $this->core->archive->is_site_archive().
|
467 |
*
|
468 |
+
* @since 1.6.0
|
469 |
*
|
470 |
+
* @param array $contents Raw contents received from this->get_contents.
|
471 |
* @return array {
|
472 |
* An array of backups.
|
473 |
*
|
476 |
* }
|
477 |
*/
|
478 |
public function format_raw_contents( $contents ) {
|
479 |
+
$skips = array( '.', '..' );
|
480 |
$backups = array();
|
481 |
|
482 |
if ( ! is_array( $contents ) ) {
|
492 |
}
|
493 |
|
494 |
$backups[] = array(
|
495 |
+
'time' => $item['mtime'],
|
496 |
'filename' => $filename,
|
497 |
+
'size' => $item['size'],
|
498 |
);
|
499 |
} else {
|
500 |
// Before exploding by space, replace multiple spaces with one space.
|
501 |
$item = preg_replace( '!\s+!', ' ', $item );
|
502 |
|
503 |
$exploded_item = explode( ' ', $item );
|
504 |
+
$count = count( $exploded_item );
|
505 |
|
506 |
$filename = $exploded_item[ $count - 1 ];
|
507 |
if ( in_array( $filename, $skips, true ) ) {
|
510 |
|
511 |
// Get the timestamp.
|
512 |
$month = $exploded_item[ $count - 4 ];
|
513 |
+
$day = $exploded_item[ $count - 3 ];
|
514 |
+
$time = $exploded_item[ $count - 2 ];
|
515 |
+
$time = strtotime( $month . ' ' . $day . ' ' . $time );
|
516 |
|
517 |
$backups[] = array(
|
518 |
+
'time' => $time,
|
519 |
'filename' => $filename,
|
520 |
+
'size' => $exploded_item[ $count - 5 ],
|
521 |
);
|
522 |
}
|
523 |
}
|
535 |
/**
|
536 |
* Get the remote contents / listing.
|
537 |
*
|
538 |
+
* @since 1.6.0
|
539 |
*
|
540 |
* @param bool $raw Whether to get the raw contents (ftp_rawlist) or not
|
541 |
* (ftp_nlist).
|
555 |
if ( $raw ) {
|
556 |
return ftp_rawlist( $this->connection, $dir );
|
557 |
} else {
|
558 |
+
return ftp_nlist( $this->connection, $dir );
|
559 |
}
|
560 |
break;
|
561 |
case 'sftp':
|
571 |
/**
|
572 |
* Get settings.
|
573 |
*
|
574 |
+
* @since 1.6.0
|
575 |
*/
|
576 |
public function get_details() {
|
577 |
$is_setup = $this->is_setup();
|
579 |
$settings = $this->core->settings->get_settings();
|
580 |
|
581 |
return array(
|
582 |
+
'title' => $this->title,
|
583 |
+
'key' => $this->key,
|
584 |
'configure' => 'admin.php?page=boldgrid-backup-ftp',
|
585 |
+
'is_setup' => $is_setup,
|
586 |
+
'enabled' => ! empty( $settings['remote'][ $this->key ]['enabled'] ) && $settings['remote'][ $this->key ]['enabled'] && $is_setup,
|
587 |
);
|
588 |
}
|
589 |
|
590 |
/**
|
591 |
* Init properties.
|
592 |
*
|
593 |
+
* @since 1.6.0
|
594 |
*/
|
595 |
public function init() {
|
596 |
if ( ! empty( $this->user ) || ! empty( $this->pass ) || ! empty( $this->host ) ) {
|
604 |
$configs = array(
|
605 |
array(
|
606 |
'property' => 'user',
|
607 |
+
'default' => null,
|
608 |
),
|
609 |
array(
|
610 |
'property' => 'pass',
|
611 |
+
'default' => null,
|
612 |
),
|
613 |
array(
|
614 |
'property' => 'host',
|
615 |
+
'default' => null,
|
616 |
),
|
617 |
array(
|
618 |
'property' => 'port',
|
619 |
+
'default' => $this->default_port,
|
620 |
),
|
621 |
array(
|
622 |
'property' => 'type',
|
623 |
+
'default' => $this->default_type,
|
624 |
),
|
625 |
array(
|
626 |
'property' => 'retention_count',
|
627 |
+
'default' => $this->retention_count,
|
628 |
),
|
629 |
array(
|
630 |
'property' => 'nickname',
|
631 |
+
'default' => $this->title,
|
632 |
),
|
633 |
);
|
634 |
|
650 |
/**
|
651 |
* Determine whether or not FTP is setup.
|
652 |
*
|
653 |
+
* @since 1.6.0
|
654 |
*
|
655 |
* @return bool
|
656 |
*/
|
668 |
/**
|
669 |
* Determine if a set of FTP credentials are valid.
|
670 |
*
|
671 |
+
* @since 1.6.0
|
672 |
*
|
673 |
+
* @param string $host Hostname.
|
674 |
+
* @param string $user Username.
|
675 |
+
* @param string $pass Password.
|
676 |
+
* @param int $port Port number.
|
677 |
+
* @param string $type Type.
|
678 |
* @return bool
|
679 |
*/
|
680 |
public function is_valid_credentials( $host, $user, $pass, $port, $type ) {
|
681 |
$connection = false;
|
682 |
+
$logged_in = false;
|
683 |
+
$port = intval( $port );
|
684 |
|
685 |
// Avoid a really long timeout.
|
686 |
if ( 21 === $port && 'sftp' === $type ) {
|
687 |
+
$this->errors[] = sprintf(
|
688 |
+
// translators: 1: Hostname, 2: Port number.
|
689 |
+
__(
|
690 |
+
'Unable to connect to %1$s over port %2$u.',
|
691 |
+
'boldgrid-backup'
|
692 |
+
),
|
693 |
+
$host,
|
694 |
+
$port
|
695 |
+
);
|
696 |
return false;
|
697 |
}
|
698 |
|
699 |
switch ( $type ) {
|
700 |
case 'ftp':
|
701 |
+
$connection = @ftp_connect( $host, $port, $this->timeout ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
|
702 |
break;
|
703 |
case 'sftp':
|
704 |
+
$connection = @new phpseclib\Net\SFTP( $host, $port, $this->timeout ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
|
705 |
break;
|
706 |
}
|
707 |
if ( ! $connection ) {
|
708 |
+
$this->errors[] = sprintf(
|
709 |
+
// translators: 1: Hostname, 2: Port number.
|
710 |
+
__(
|
711 |
+
'Unable to connect to %1$s over port %2$u.',
|
712 |
+
'boldgrid-backup'
|
713 |
+
),
|
714 |
+
$host,
|
715 |
+
$port
|
716 |
+
);
|
717 |
return false;
|
718 |
}
|
719 |
|
731 |
* and throw an Exception.
|
732 |
*/
|
733 |
$error_caught = false;
|
734 |
+
|
735 |
+
set_error_handler( array( 'Boldgrid_Backup_Admin_Utility', 'handle_error' ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_set_error_handler
|
736 |
+
|
737 |
try {
|
738 |
switch ( $type ) {
|
739 |
case 'ftp':
|
746 |
}
|
747 |
} catch ( Exception $e ) {
|
748 |
$this->errors[] = $e->getMessage();
|
749 |
+
$error_caught = true;
|
750 |
}
|
751 |
restore_error_handler();
|
752 |
|
760 |
/**
|
761 |
* Log into the FTP server.
|
762 |
*
|
763 |
+
* @since 1.6.0
|
764 |
*
|
765 |
* @return bool
|
766 |
*/
|
777 |
|
778 |
switch ( $this->type ) {
|
779 |
case 'ftp':
|
780 |
+
$this->logged_in = @ftp_login( $this->connection, $this->user, $this->pass ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
|
781 |
break;
|
782 |
case 'sftp':
|
783 |
$this->logged_in = $this->connection->login( $this->user, $this->pass );
|
796 |
* If the user wants to delete all FTP settings, after we clear the data from
|
797 |
* the options, run this method to clear the properties.
|
798 |
*
|
799 |
+
* @since 1.6.0
|
800 |
*/
|
801 |
public function reset() {
|
802 |
$this->host = null;
|
803 |
$this->user = null;
|
804 |
$this->set_pass( null );
|
805 |
+
$this->port = $this->default_port['ftp'];
|
806 |
$this->retention_count = null;
|
807 |
+
$this->type = $this->default_type;
|
808 |
}
|
809 |
|
810 |
/**
|
811 |
* Set our ftp password.
|
812 |
*
|
813 |
+
* @since 1.6.0
|
814 |
*
|
815 |
+
* @param string $pass Password.
|
816 |
*/
|
817 |
public function set_pass( $pass ) {
|
818 |
$this->pass = $pass;
|
821 |
/**
|
822 |
* Determine if a backup archive is uploaded to the remote server.
|
823 |
*
|
824 |
+
* @since 1.6.0
|
825 |
*
|
826 |
+
* @param string $filepath File path.
|
827 |
*/
|
828 |
public function is_uploaded( $filepath ) {
|
829 |
$contents = $this->get_contents( false, $this->remote_dir );
|
834 |
/**
|
835 |
* Upload a file.
|
836 |
*
|
837 |
+
* @since 1.6.0
|
838 |
*
|
839 |
+
* @param string $filepath File path.
|
840 |
* @return bool
|
841 |
*/
|
842 |
public function upload( $filepath ) {
|
874 |
* such as ftp_put(): Quota exceeded. Make sure the user sees the
|
875 |
* last error.
|
876 |
*/
|
877 |
+
if ( ! empty( $last_error['message'] ) && ! empty( $last_error['file'] ) && __FILE__ === $last_error['file'] ) {
|
878 |
$this->errors[] = $last_error['message'];
|
879 |
}
|
880 |
|
admin/remote/{sftp.php → class-boldgrid-backup-admin-sftp.php}
RENAMED
@@ -1,28 +1,29 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
-
* @since 1.
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
-
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
|
|
|
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
-
* @since 1.
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Sftp {
|
21 |
-
|
22 |
/**
|
23 |
* An SFTP connection.
|
24 |
*
|
25 |
-
* @since 1.
|
26 |
* @access private
|
27 |
* @var Resource
|
28 |
*/
|
@@ -31,7 +32,7 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
31 |
/**
|
32 |
* The core class object.
|
33 |
*
|
34 |
-
* @since 1.
|
35 |
* @access private
|
36 |
* @var Boldgrid_Backup_Admin_Core
|
37 |
*/
|
@@ -40,7 +41,7 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
40 |
/**
|
41 |
* Hooks class.
|
42 |
*
|
43 |
-
* @since 1.
|
44 |
* @access public
|
45 |
* @var Boldgrid_Backup_Admin_Sftp_Hooks
|
46 |
*/
|
@@ -49,7 +50,7 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
49 |
/**
|
50 |
* SFTP host.
|
51 |
*
|
52 |
-
* @since 1.
|
53 |
* @access private
|
54 |
* @var string
|
55 |
*/
|
@@ -58,7 +59,7 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
58 |
/**
|
59 |
* Whether or not we have logged in.
|
60 |
*
|
61 |
-
* @since 1.
|
62 |
* @access public
|
63 |
* @var bool
|
64 |
*/
|
@@ -67,7 +68,7 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
67 |
/**
|
68 |
* Our key / label for sftp.
|
69 |
*
|
70 |
-
* @since 1.
|
71 |
* @access public
|
72 |
* @var string
|
73 |
*/
|
@@ -76,7 +77,7 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
76 |
/**
|
77 |
* SFTP password.
|
78 |
*
|
79 |
-
* @since 1.
|
80 |
* @access private
|
81 |
* @var string
|
82 |
*/
|
@@ -85,7 +86,7 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
85 |
/**
|
86 |
* SFTP port.
|
87 |
*
|
88 |
-
* @since 1.
|
89 |
* @access public
|
90 |
* @var int
|
91 |
*/
|
@@ -94,7 +95,7 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
94 |
/**
|
95 |
* SFTP remote directory.
|
96 |
*
|
97 |
-
* @since 1.
|
98 |
* @access public
|
99 |
* @var string
|
100 |
*/
|
@@ -103,7 +104,7 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
103 |
/**
|
104 |
* Retention count.
|
105 |
*
|
106 |
-
* @since 1.
|
107 |
* @access public
|
108 |
* @var int $retention_count
|
109 |
*/
|
@@ -112,7 +113,7 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
112 |
/**
|
113 |
* Our title / label for sftp.
|
114 |
*
|
115 |
-
* @since 1.
|
116 |
* @access public
|
117 |
* @var string
|
118 |
*/
|
@@ -121,7 +122,7 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
121 |
/**
|
122 |
* SFTP username.
|
123 |
*
|
124 |
-
* @since 1.
|
125 |
* @access private
|
126 |
* @var string
|
127 |
*/
|
@@ -130,7 +131,7 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
130 |
/**
|
131 |
* Constructor.
|
132 |
*
|
133 |
-
* @since 1.
|
134 |
*
|
135 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
136 |
*/
|
@@ -138,13 +139,12 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
138 |
include_once BOLDGRID_BACKUP_PATH . '/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php';
|
139 |
|
140 |
$this->core = $core;
|
141 |
-
// $this->hooks = new Boldgrid_Backup_Admin_Sftp_Hooks( $core );
|
142 |
}
|
143 |
|
144 |
/**
|
145 |
* Connect to our sftp server.
|
146 |
*
|
147 |
-
* @since 1.
|
148 |
*/
|
149 |
public function connect() {
|
150 |
if ( ! empty( $this->connection ) ) {
|
@@ -163,7 +163,7 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
163 |
/**
|
164 |
* Create backup directory on remote host.
|
165 |
*
|
166 |
-
* @since 1.
|
167 |
*
|
168 |
* @return bool False when we were unable to create directory.
|
169 |
*/
|
@@ -185,27 +185,22 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
185 |
/**
|
186 |
* Disconnect from SFTP server.
|
187 |
*
|
188 |
-
* @since 1.
|
189 |
*/
|
190 |
public function disconnect() {
|
191 |
-
if ( $this->connection ) {
|
192 |
-
// sftp_close( $this->connection );
|
193 |
-
// $this->connection = null;
|
194 |
-
// $this->logged_in = false;
|
195 |
-
}
|
196 |
}
|
197 |
|
198 |
/**
|
199 |
* Enforce retention.
|
200 |
*
|
201 |
-
* @since 1.
|
202 |
*/
|
203 |
public function enforce_retention() {
|
204 |
if ( empty( $this->retention_count ) ) {
|
205 |
return;
|
206 |
}
|
207 |
|
208 |
-
$backups
|
209 |
$contents = $this->get_contents( true, $this->remote_dir );
|
210 |
|
211 |
// The contents usually include . and .., so remove 2 from list.
|
@@ -217,9 +212,11 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
217 |
|
218 |
$backups = $this->format_raw_contents( $contents );
|
219 |
|
220 |
-
usort(
|
221 |
-
|
222 |
-
|
|
|
|
|
223 |
|
224 |
for ( $x = 0; $x < $count_to_delete; $x++ ) {
|
225 |
$filename = $backups[ $x ]['filename'];
|
@@ -228,7 +225,7 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
228 |
/**
|
229 |
* Remote file deleted due to remote retention settings.
|
230 |
*
|
231 |
-
* @since 1.
|
232 |
*/
|
233 |
do_action(
|
234 |
'boldgrid_backup_remote_retention_deleted',
|
@@ -244,9 +241,9 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
244 |
* This method takes in raw contents and returns an array of backups, with
|
245 |
* keys defining timestamp and filename.
|
246 |
*
|
247 |
-
* @since 1.
|
248 |
*
|
249 |
-
* @param array $
|
250 |
* @return array {
|
251 |
* An array of backups.
|
252 |
*
|
@@ -255,7 +252,7 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
255 |
* }
|
256 |
*/
|
257 |
public function format_raw_contents( $contents ) {
|
258 |
-
$skips
|
259 |
$backups = array();
|
260 |
|
261 |
if ( ! is_array( $contents ) ) {
|
@@ -275,12 +272,12 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
275 |
|
276 |
// Get the timestamp.
|
277 |
$month = $exploded_item[ $count - 4 ];
|
278 |
-
$day
|
279 |
-
$time
|
280 |
-
$time
|
281 |
|
282 |
$backups[] = array(
|
283 |
-
'time'
|
284 |
'filename' => $filename,
|
285 |
);
|
286 |
}
|
@@ -291,7 +288,7 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
291 |
/**
|
292 |
* Get the remote contents / listing.
|
293 |
*
|
294 |
-
* @since 1.
|
295 |
*
|
296 |
* @param bool $raw Whether to get the raw contents (sftp_rawlist) or not
|
297 |
* (sftp_nlist).
|
@@ -315,24 +312,24 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
315 |
/**
|
316 |
* Get settings.
|
317 |
*
|
318 |
-
* @since 1.
|
319 |
*/
|
320 |
public function get_details() {
|
321 |
$settings = $this->core->settings->get_settings();
|
322 |
|
323 |
return array(
|
324 |
-
'title'
|
325 |
-
'key'
|
326 |
'configure' => 'admin.php?page=boldgrid-backup-sftp',
|
327 |
-
'is_setup'
|
328 |
-
'enabled'
|
329 |
);
|
330 |
}
|
331 |
|
332 |
/**
|
333 |
* Init properties.
|
334 |
*
|
335 |
-
* @since 1.
|
336 |
*/
|
337 |
public function init() {
|
338 |
if ( ! empty( $this->user ) || ! empty( $this->pass ) || ! empty( $this->host ) ) {
|
@@ -351,7 +348,7 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
351 |
/**
|
352 |
* Determine whether or not SFTP is setup.
|
353 |
*
|
354 |
-
* @since 1.
|
355 |
*
|
356 |
* @return bool
|
357 |
*/
|
@@ -365,12 +362,12 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
365 |
/**
|
366 |
* Determine if a set of SFTP credentials are valid.
|
367 |
*
|
368 |
-
* @since 1.
|
369 |
*
|
370 |
-
* @param string $host
|
371 |
-
* @param string $user
|
372 |
-
* @param string $pass
|
373 |
-
* @param int $port
|
374 |
* @return bool
|
375 |
*/
|
376 |
public function is_valid_credentials( $host, $user, $pass, $port ) {
|
@@ -379,21 +376,19 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
379 |
return false;
|
380 |
}
|
381 |
|
382 |
-
$logged_in = @$connection->login( $user, $pass );
|
383 |
if ( ! $logged_in ) {
|
384 |
-
// sftp_close( $connection );
|
385 |
$this->errors[] = __( 'Unable to connect and log in.', 'boldgrid-backup' );
|
386 |
return false;
|
387 |
}
|
388 |
|
389 |
-
// sftp_close( $connection );
|
390 |
return true;
|
391 |
}
|
392 |
|
393 |
/**
|
394 |
* Log into the SFTP server.
|
395 |
*
|
396 |
-
* @since 1.
|
397 |
*
|
398 |
* @return bool
|
399 |
*/
|
@@ -414,7 +409,11 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
414 |
}
|
415 |
|
416 |
/**
|
|
|
|
|
|
|
417 |
*
|
|
|
418 |
*/
|
419 |
public function is_uploaded( $filepath ) {
|
420 |
$contents = $this->get_contents( false, $this->remote_dir );
|
@@ -425,7 +424,7 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
425 |
/**
|
426 |
* Generate the submenu page for our SFTP Settings page.
|
427 |
*
|
428 |
-
* @since 1.
|
429 |
*/
|
430 |
public function submenu_page() {
|
431 |
wp_enqueue_style( 'boldgrid-backup-admin-hide-all' );
|
@@ -434,10 +433,10 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
434 |
|
435 |
$settings = $this->core->settings->get_settings();
|
436 |
|
437 |
-
$host
|
438 |
-
$user
|
439 |
-
$pass
|
440 |
-
$port
|
441 |
$retention_count = ! empty( $settings['remote'][ $this->key ]['retention_count'] ) ? $settings['remote'][ $this->key ]['retention_count'] : $this->retention_count;
|
442 |
|
443 |
include BOLDGRID_BACKUP_PATH . '/admin/partials/remote/sftp.php';
|
@@ -446,13 +445,15 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
446 |
/**
|
447 |
* Process the user's request to update their SFTP settings.
|
448 |
*
|
449 |
-
* @since 1.
|
450 |
*/
|
451 |
public function submenu_page_save() {
|
452 |
if ( ! current_user_can( 'update_plugins' ) ) {
|
453 |
return false;
|
454 |
}
|
455 |
|
|
|
|
|
456 |
if ( empty( $_POST ) ) {
|
457 |
return false;
|
458 |
}
|
@@ -470,9 +471,9 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
470 |
$settings['remote'][ $this->key ] = array();
|
471 |
update_site_option( 'boldgrid_backup_settings', $settings );
|
472 |
|
473 |
-
$this->host
|
474 |
-
$this->user
|
475 |
-
$this->pass
|
476 |
$this->retention_count = null;
|
477 |
$this->disconnect();
|
478 |
|
@@ -511,14 +512,16 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
511 |
update_site_option( 'boldgrid_backup_settings', $settings );
|
512 |
do_action( 'boldgrid_backup_notice', __( 'Settings saved.', 'boldgrid-backup' ), 'notice updated is-dismissible' );
|
513 |
}
|
|
|
|
|
514 |
}
|
515 |
|
516 |
/**
|
517 |
* Upload a file.
|
518 |
*
|
519 |
-
* @since 1.
|
520 |
*
|
521 |
-
* @param string $filepath
|
522 |
* @return bool
|
523 |
*/
|
524 |
public function upload( $filepath ) {
|
@@ -533,7 +536,14 @@ class Boldgrid_Backup_Admin_Sftp {
|
|
533 |
|
534 |
$has_remote_dir = $this->create_backup_dir();
|
535 |
if ( ! $has_remote_dir ) {
|
536 |
-
$this->errors[] = sprint_f(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
537 |
return false;
|
538 |
}
|
539 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-sftp.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
+
* @since 1.6.0
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
+
* @subpackage Boldgrid_Backup/admin/remote
|
10 |
+
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
+
// phpcs:disable WordPress.VIP
|
16 |
+
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Sftp
|
19 |
*
|
20 |
+
* @since 1.6.0
|
21 |
*/
|
22 |
class Boldgrid_Backup_Admin_Sftp {
|
|
|
23 |
/**
|
24 |
* An SFTP connection.
|
25 |
*
|
26 |
+
* @since 1.6.0
|
27 |
* @access private
|
28 |
* @var Resource
|
29 |
*/
|
32 |
/**
|
33 |
* The core class object.
|
34 |
*
|
35 |
+
* @since 1.6.0
|
36 |
* @access private
|
37 |
* @var Boldgrid_Backup_Admin_Core
|
38 |
*/
|
41 |
/**
|
42 |
* Hooks class.
|
43 |
*
|
44 |
+
* @since 1.6.0
|
45 |
* @access public
|
46 |
* @var Boldgrid_Backup_Admin_Sftp_Hooks
|
47 |
*/
|
50 |
/**
|
51 |
* SFTP host.
|
52 |
*
|
53 |
+
* @since 1.6.0
|
54 |
* @access private
|
55 |
* @var string
|
56 |
*/
|
59 |
/**
|
60 |
* Whether or not we have logged in.
|
61 |
*
|
62 |
+
* @since 1.6.0
|
63 |
* @access public
|
64 |
* @var bool
|
65 |
*/
|
68 |
/**
|
69 |
* Our key / label for sftp.
|
70 |
*
|
71 |
+
* @since 1.6.0
|
72 |
* @access public
|
73 |
* @var string
|
74 |
*/
|
77 |
/**
|
78 |
* SFTP password.
|
79 |
*
|
80 |
+
* @since 1.6.0
|
81 |
* @access private
|
82 |
* @var string
|
83 |
*/
|
86 |
/**
|
87 |
* SFTP port.
|
88 |
*
|
89 |
+
* @since 1.6.0
|
90 |
* @access public
|
91 |
* @var int
|
92 |
*/
|
95 |
/**
|
96 |
* SFTP remote directory.
|
97 |
*
|
98 |
+
* @since 1.6.0
|
99 |
* @access public
|
100 |
* @var string
|
101 |
*/
|
104 |
/**
|
105 |
* Retention count.
|
106 |
*
|
107 |
+
* @since 1.6.0
|
108 |
* @access public
|
109 |
* @var int $retention_count
|
110 |
*/
|
113 |
/**
|
114 |
* Our title / label for sftp.
|
115 |
*
|
116 |
+
* @since 1.6.0
|
117 |
* @access public
|
118 |
* @var string
|
119 |
*/
|
122 |
/**
|
123 |
* SFTP username.
|
124 |
*
|
125 |
+
* @since 1.6.0
|
126 |
* @access private
|
127 |
* @var string
|
128 |
*/
|
131 |
/**
|
132 |
* Constructor.
|
133 |
*
|
134 |
+
* @since 1.6.0
|
135 |
*
|
136 |
* @param Boldgrid_Backup_Admin_Core $core Core class object.
|
137 |
*/
|
139 |
include_once BOLDGRID_BACKUP_PATH . '/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php';
|
140 |
|
141 |
$this->core = $core;
|
|
|
142 |
}
|
143 |
|
144 |
/**
|
145 |
* Connect to our sftp server.
|
146 |
*
|
147 |
+
* @since 1.6.0
|
148 |
*/
|
149 |
public function connect() {
|
150 |
if ( ! empty( $this->connection ) ) {
|
163 |
/**
|
164 |
* Create backup directory on remote host.
|
165 |
*
|
166 |
+
* @since 1.6.0
|
167 |
*
|
168 |
* @return bool False when we were unable to create directory.
|
169 |
*/
|
185 |
/**
|
186 |
* Disconnect from SFTP server.
|
187 |
*
|
188 |
+
* @since 1.6.0
|
189 |
*/
|
190 |
public function disconnect() {
|
|
|
|
|
|
|
|
|
|
|
191 |
}
|
192 |
|
193 |
/**
|
194 |
* Enforce retention.
|
195 |
*
|
196 |
+
* @since 1.6.0
|
197 |
*/
|
198 |
public function enforce_retention() {
|
199 |
if ( empty( $this->retention_count ) ) {
|
200 |
return;
|
201 |
}
|
202 |
|
203 |
+
$backups = array();
|
204 |
$contents = $this->get_contents( true, $this->remote_dir );
|
205 |
|
206 |
// The contents usually include . and .., so remove 2 from list.
|
212 |
|
213 |
$backups = $this->format_raw_contents( $contents );
|
214 |
|
215 |
+
usort(
|
216 |
+
$backups, function( $a, $b ) {
|
217 |
+
return $a['time'] < $b['time'] ? -1 : 1;
|
218 |
+
}
|
219 |
+
);
|
220 |
|
221 |
for ( $x = 0; $x < $count_to_delete; $x++ ) {
|
222 |
$filename = $backups[ $x ]['filename'];
|
225 |
/**
|
226 |
* Remote file deleted due to remote retention settings.
|
227 |
*
|
228 |
+
* @since 1.6.0
|
229 |
*/
|
230 |
do_action(
|
231 |
'boldgrid_backup_remote_retention_deleted',
|
241 |
* This method takes in raw contents and returns an array of backups, with
|
242 |
* keys defining timestamp and filename.
|
243 |
*
|
244 |
+
* @since 1.6.0
|
245 |
*
|
246 |
+
* @param array $contents Raw contents received from this->get_contents.
|
247 |
* @return array {
|
248 |
* An array of backups.
|
249 |
*
|
252 |
* }
|
253 |
*/
|
254 |
public function format_raw_contents( $contents ) {
|
255 |
+
$skips = array( '.', '..' );
|
256 |
$backups = array();
|
257 |
|
258 |
if ( ! is_array( $contents ) ) {
|
272 |
|
273 |
// Get the timestamp.
|
274 |
$month = $exploded_item[ $count - 4 ];
|
275 |
+
$day = $exploded_item[ $count - 3 ];
|
276 |
+
$time = $exploded_item[ $count - 2 ];
|
277 |
+
$time = strtotime( $month . ' ' . $day . ' ' . $time );
|
278 |
|
279 |
$backups[] = array(
|
280 |
+
'time' => $time,
|
281 |
'filename' => $filename,
|
282 |
);
|
283 |
}
|
288 |
/**
|
289 |
* Get the remote contents / listing.
|
290 |
*
|
291 |
+
* @since 1.6.0
|
292 |
*
|
293 |
* @param bool $raw Whether to get the raw contents (sftp_rawlist) or not
|
294 |
* (sftp_nlist).
|
312 |
/**
|
313 |
* Get settings.
|
314 |
*
|
315 |
+
* @since 1.6.0
|
316 |
*/
|
317 |
public function get_details() {
|
318 |
$settings = $this->core->settings->get_settings();
|
319 |
|
320 |
return array(
|
321 |
+
'title' => $this->title,
|
322 |
+
'key' => $this->key,
|
323 |
'configure' => 'admin.php?page=boldgrid-backup-sftp',
|
324 |
+
'is_setup' => $this->is_setup(),
|
325 |
+
'enabled' => ! empty( $settings['remote'][ $this->key ]['enabled'] ) && $settings['remote'][ $this->key ]['enabled'] && $this->is_setup(),
|
326 |
);
|
327 |
}
|
328 |
|
329 |
/**
|
330 |
* Init properties.
|
331 |
*
|
332 |
+
* @since 1.6.0
|
333 |
*/
|
334 |
public function init() {
|
335 |
if ( ! empty( $this->user ) || ! empty( $this->pass ) || ! empty( $this->host ) ) {
|
348 |
/**
|
349 |
* Determine whether or not SFTP is setup.
|
350 |
*
|
351 |
+
* @since 1.6.0
|
352 |
*
|
353 |
* @return bool
|
354 |
*/
|
362 |
/**
|
363 |
* Determine if a set of SFTP credentials are valid.
|
364 |
*
|
365 |
+
* @since 1.6.0
|
366 |
*
|
367 |
+
* @param string $host Hostname.
|
368 |
+
* @param string $user Username.
|
369 |
+
* @param string $pass Password.
|
370 |
+
* @param int $port Port number.
|
371 |
* @return bool
|
372 |
*/
|
373 |
public function is_valid_credentials( $host, $user, $pass, $port ) {
|
376 |
return false;
|
377 |
}
|
378 |
|
379 |
+
$logged_in = @$connection->login( $user, $pass ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
|
380 |
if ( ! $logged_in ) {
|
|
|
381 |
$this->errors[] = __( 'Unable to connect and log in.', 'boldgrid-backup' );
|
382 |
return false;
|
383 |
}
|
384 |
|
|
|
385 |
return true;
|
386 |
}
|
387 |
|
388 |
/**
|
389 |
* Log into the SFTP server.
|
390 |
*
|
391 |
+
* @since 1.6.0
|
392 |
*
|
393 |
* @return bool
|
394 |
*/
|
409 |
}
|
410 |
|
411 |
/**
|
412 |
+
* Is file uploaded?
|
413 |
+
*
|
414 |
+
* @since 1.6.0
|
415 |
*
|
416 |
+
* @param string $filepath File path.
|
417 |
*/
|
418 |
public function is_uploaded( $filepath ) {
|
419 |
$contents = $this->get_contents( false, $this->remote_dir );
|
424 |
/**
|
425 |
* Generate the submenu page for our SFTP Settings page.
|
426 |
*
|
427 |
+
* @since 1.6.0
|
428 |
*/
|
429 |
public function submenu_page() {
|
430 |
wp_enqueue_style( 'boldgrid-backup-admin-hide-all' );
|
433 |
|
434 |
$settings = $this->core->settings->get_settings();
|
435 |
|
436 |
+
$host = ! empty( $settings['remote'][ $this->key ]['host'] ) ? $settings['remote'][ $this->key ]['host'] : null;
|
437 |
+
$user = ! empty( $settings['remote'][ $this->key ]['user'] ) ? $settings['remote'][ $this->key ]['user'] : null;
|
438 |
+
$pass = ! empty( $settings['remote'][ $this->key ]['pass'] ) ? $settings['remote'][ $this->key ]['pass'] : null;
|
439 |
+
$port = ! empty( $settings['remote'][ $this->key ]['port'] ) ? $settings['remote'][ $this->key ]['port'] : $this->port;
|
440 |
$retention_count = ! empty( $settings['remote'][ $this->key ]['retention_count'] ) ? $settings['remote'][ $this->key ]['retention_count'] : $this->retention_count;
|
441 |
|
442 |
include BOLDGRID_BACKUP_PATH . '/admin/partials/remote/sftp.php';
|
445 |
/**
|
446 |
* Process the user's request to update their SFTP settings.
|
447 |
*
|
448 |
+
* @since 1.6.0
|
449 |
*/
|
450 |
public function submenu_page_save() {
|
451 |
if ( ! current_user_can( 'update_plugins' ) ) {
|
452 |
return false;
|
453 |
}
|
454 |
|
455 |
+
// phpcs:disable WordPress.CSRF.NonceVerification.NoNonceVerification, WordPress.Security.NonceVerification.NoNonceVerification
|
456 |
+
|
457 |
if ( empty( $_POST ) ) {
|
458 |
return false;
|
459 |
}
|
471 |
$settings['remote'][ $this->key ] = array();
|
472 |
update_site_option( 'boldgrid_backup_settings', $settings );
|
473 |
|
474 |
+
$this->host = null;
|
475 |
+
$this->user = null;
|
476 |
+
$this->pass = null;
|
477 |
$this->retention_count = null;
|
478 |
$this->disconnect();
|
479 |
|
512 |
update_site_option( 'boldgrid_backup_settings', $settings );
|
513 |
do_action( 'boldgrid_backup_notice', __( 'Settings saved.', 'boldgrid-backup' ), 'notice updated is-dismissible' );
|
514 |
}
|
515 |
+
|
516 |
+
// phpcs:enable WordPress.CSRF.NonceVerification.NoNonceVerification, WordPress.Security.NonceVerification.NoNonceVerification
|
517 |
}
|
518 |
|
519 |
/**
|
520 |
* Upload a file.
|
521 |
*
|
522 |
+
* @since 1.6.0
|
523 |
*
|
524 |
+
* @param string $filepath File path.
|
525 |
* @return bool
|
526 |
*/
|
527 |
public function upload( $filepath ) {
|
536 |
|
537 |
$has_remote_dir = $this->create_backup_dir();
|
538 |
if ( ! $has_remote_dir ) {
|
539 |
+
$this->errors[] = sprint_f(
|
540 |
+
// translators: 1: Remote directory path.
|
541 |
+
__(
|
542 |
+
'Unable to create the following directory on SFTP server: %1$s',
|
543 |
+
'boldgrid-backup'
|
544 |
+
),
|
545 |
+
$this->remote_dir
|
546 |
+
);
|
547 |
return false;
|
548 |
}
|
549 |
|
admin/storage/{local.php → class-boldgrid-backup-admin-storage-local.php}
RENAMED
@@ -1,24 +1,25 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Local storage.
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.5.2
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
9 |
-
* @subpackage Boldgrid_Backup/admin
|
10 |
-
* @copyright BoldGrid
|
11 |
* @version $Id$
|
12 |
-
* @author BoldGrid
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @since 1.5.2
|
19 |
*/
|
20 |
class Boldgrid_Backup_Admin_Storage_Local {
|
21 |
-
|
22 |
/**
|
23 |
* The core class object.
|
24 |
*
|
@@ -33,7 +34,7 @@ class Boldgrid_Backup_Admin_Storage_Local {
|
|
33 |
*
|
34 |
* @since 1.5.2
|
35 |
*
|
36 |
-
* @param Boldgrid_Backup_Admin_Core $core
|
37 |
*/
|
38 |
public function __construct( $core ) {
|
39 |
$this->core = $core;
|
@@ -65,10 +66,9 @@ class Boldgrid_Backup_Admin_Storage_Local {
|
|
65 |
*
|
66 |
* @see self::delete_local()
|
67 |
*
|
68 |
-
* @param array $info
|
69 |
*/
|
70 |
public function post_archive_files( $info ) {
|
71 |
-
|
72 |
/*
|
73 |
* Do not "delete local copy" in the following scenarios:
|
74 |
*
|
@@ -89,9 +89,9 @@ class Boldgrid_Backup_Admin_Storage_Local {
|
|
89 |
}
|
90 |
|
91 |
$args = array(
|
92 |
-
'filepath'
|
93 |
-
'action'
|
94 |
-
'action_data'
|
95 |
'action_title' => __( 'Delete backup from Web Server', 'boldgrid-backup' ),
|
96 |
);
|
97 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-admin-storage-local.php
|
4 |
+
*
|
5 |
* Local storage.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.5.2
|
9 |
*
|
10 |
* @package Boldgrid_Backup
|
11 |
+
* @subpackage Boldgrid_Backup/admin/storage
|
12 |
+
* @copyright BoldGrid
|
13 |
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Admin_Storage_Local
|
19 |
*
|
20 |
* @since 1.5.2
|
21 |
*/
|
22 |
class Boldgrid_Backup_Admin_Storage_Local {
|
|
|
23 |
/**
|
24 |
* The core class object.
|
25 |
*
|
34 |
*
|
35 |
* @since 1.5.2
|
36 |
*
|
37 |
+
* @param Boldgrid_Backup_Admin_Core $core Boldgrid_Backup_Admin_Core object.
|
38 |
*/
|
39 |
public function __construct( $core ) {
|
40 |
$this->core = $core;
|
66 |
*
|
67 |
* @see self::delete_local()
|
68 |
*
|
69 |
+
* @param array $info Archive information.
|
70 |
*/
|
71 |
public function post_archive_files( $info ) {
|
|
|
72 |
/*
|
73 |
* Do not "delete local copy" in the following scenarios:
|
74 |
*
|
89 |
}
|
90 |
|
91 |
$args = array(
|
92 |
+
'filepath' => $info['filepath'],
|
93 |
+
'action' => 'boldgrid_backup_delete_local',
|
94 |
+
'action_data' => $info['filepath'],
|
95 |
'action_title' => __( 'Delete backup from Web Server', 'boldgrid-backup' ),
|
96 |
);
|
97 |
|
boldgrid-backup-cron.php
CHANGED
@@ -1,19 +1,23 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
*
|
|
|
|
|
6 |
* @since 1.0
|
7 |
*
|
8 |
-
* @package
|
9 |
-
* @copyright
|
10 |
-
* @version
|
11 |
-
* @author
|
12 |
*/
|
13 |
|
|
|
|
|
14 |
// Abort if not being ran from the command line.
|
15 |
if ( ! isset( $_SERVER['argv'], $_SERVER['argc'] ) || ! $_SERVER['argc'] ) {
|
16 |
-
die( 'Error: No parameters were passed. A "siteurl", "mode", and "id" are required.' .
|
17 |
}
|
18 |
|
19 |
// Initialize $input and $error.
|
@@ -41,7 +45,7 @@ foreach ( $required_arguments as $required_argument ) {
|
|
41 |
}
|
42 |
|
43 |
if ( $error ) {
|
44 |
-
die( $error );
|
45 |
}
|
46 |
|
47 |
// Abort if not a valid mode.
|
@@ -51,7 +55,7 @@ $valid_modes = array(
|
|
51 |
);
|
52 |
|
53 |
if ( ! in_array( $input['mode'], $valid_modes, true ) ) {
|
54 |
-
die( 'Error: Invalid mode "' . $input['mode'] . '".' . PHP_EOL );
|
55 |
}
|
56 |
|
57 |
// Make an ajax call to run jobs, and report status.
|
@@ -59,9 +63,9 @@ $url = $input['siteurl'] . '/wp-admin/admin-ajax.php?action=boldgrid_backup_run_
|
|
59 |
'&id=' . $input['id'] . '&secret=' . $input['secret'] . '&doing_wp_cron=' . time();
|
60 |
|
61 |
// The helper class method will sanitize the url.
|
62 |
-
require dirname( __FILE__ ) . '/cron/url-helper.php';
|
63 |
$url_helper = new Boldgrid_Backup_Url_Helper();
|
64 |
-
$result
|
65 |
|
66 |
if ( false !== $result ) {
|
67 |
$message = $result;
|
@@ -69,4 +73,4 @@ if ( false !== $result ) {
|
|
69 |
$message = 'Error: Could not reach URL address "' . $url . '".';
|
70 |
}
|
71 |
|
72 |
-
die( $message );
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: boldgrid-backup-cron.php
|
4 |
*
|
5 |
+
* BoldGrid Backup cron control script.
|
6 |
+
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.0
|
9 |
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
+
* @copyright BoldGrid
|
12 |
+
* @version $Id$
|
13 |
+
* @author BoldGrid <support@boldgrid.com>
|
14 |
*/
|
15 |
|
16 |
+
// phpcs:disable WordPress.VIP
|
17 |
+
|
18 |
// Abort if not being ran from the command line.
|
19 |
if ( ! isset( $_SERVER['argv'], $_SERVER['argc'] ) || ! $_SERVER['argc'] ) {
|
20 |
+
die( 'Error: No parameters were passed. A "siteurl", "mode", and "id" are required.' . "\n" );
|
21 |
}
|
22 |
|
23 |
// Initialize $input and $error.
|
45 |
}
|
46 |
|
47 |
if ( $error ) {
|
48 |
+
die( $error ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
49 |
}
|
50 |
|
51 |
// Abort if not a valid mode.
|
55 |
);
|
56 |
|
57 |
if ( ! in_array( $input['mode'], $valid_modes, true ) ) {
|
58 |
+
die( 'Error: Invalid mode "' . $input['mode'] . '".' . PHP_EOL ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
59 |
}
|
60 |
|
61 |
// Make an ajax call to run jobs, and report status.
|
63 |
'&id=' . $input['id'] . '&secret=' . $input['secret'] . '&doing_wp_cron=' . time();
|
64 |
|
65 |
// The helper class method will sanitize the url.
|
66 |
+
require dirname( __FILE__ ) . '/cron/class-boldgrid-backup-url-helper.php';
|
67 |
$url_helper = new Boldgrid_Backup_Url_Helper();
|
68 |
+
$result = $url_helper->call_url( $url );
|
69 |
|
70 |
if ( false !== $result ) {
|
71 |
$message = $result;
|
73 |
$message = 'Error: Could not reach URL address "' . $url . '".';
|
74 |
}
|
75 |
|
76 |
+
die( $message ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
boldgrid-backup.php
CHANGED
@@ -1,21 +1,22 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
|
|
5 |
* This file is read by WordPress to generate the plugin information in the plugin
|
6 |
* admin area. This file also includes all of the dependencies used by the plugin,
|
7 |
* registers the activation and deactivation functions, and defines a function
|
8 |
* that starts the plugin.
|
9 |
*
|
10 |
-
* @link
|
11 |
-
* @since 1.0.
|
12 |
* @package Boldgrid_Backup
|
13 |
*
|
14 |
* @wordpress-plugin
|
15 |
* Plugin Name: BoldGrid Backup
|
16 |
* Plugin URI: https://www.boldgrid.com/boldgrid-backup/
|
17 |
* Description: BoldGrid Backup provides WordPress backup and restoration with update protection.
|
18 |
-
* Version: 1.6.
|
19 |
* Author: BoldGrid
|
20 |
* Author URI: https://www.boldgrid.com/
|
21 |
* License: GPL-2.0+
|
@@ -88,17 +89,31 @@ function load_boldgrid_backup() {
|
|
88 |
$exists_composer = file_exists( BOLDGRID_BACKUP_PATH . '/composer.json' );
|
89 |
$exists_autoload = file_exists( BOLDGRID_BACKUP_PATH . '/vendor/autoload.php' );
|
90 |
if ( $exists_composer && ! $exists_autoload ) {
|
91 |
-
add_action(
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
return false;
|
104 |
}
|
@@ -112,11 +127,11 @@ function load_boldgrid_backup() {
|
|
112 |
// Load Library.
|
113 |
$load = new Boldgrid\Library\Util\Load(
|
114 |
array(
|
115 |
-
'type'
|
116 |
-
'file'
|
117 |
-
'loader'
|
118 |
-
'keyValidate'
|
119 |
-
'licenseActivate'
|
120 |
)
|
121 |
);
|
122 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: boldgrid-backup.php
|
4 |
*
|
5 |
+
* The plugin bootstrap file.
|
6 |
* This file is read by WordPress to generate the plugin information in the plugin
|
7 |
* admin area. This file also includes all of the dependencies used by the plugin,
|
8 |
* registers the activation and deactivation functions, and defines a function
|
9 |
* that starts the plugin.
|
10 |
*
|
11 |
+
* @link https://www.boldgrid.com
|
12 |
+
* @since 1.0.0
|
13 |
* @package Boldgrid_Backup
|
14 |
*
|
15 |
* @wordpress-plugin
|
16 |
* Plugin Name: BoldGrid Backup
|
17 |
* Plugin URI: https://www.boldgrid.com/boldgrid-backup/
|
18 |
* Description: BoldGrid Backup provides WordPress backup and restoration with update protection.
|
19 |
+
* Version: 1.6.4
|
20 |
* Author: BoldGrid
|
21 |
* Author URI: https://www.boldgrid.com/
|
22 |
* License: GPL-2.0+
|
89 |
$exists_composer = file_exists( BOLDGRID_BACKUP_PATH . '/composer.json' );
|
90 |
$exists_autoload = file_exists( BOLDGRID_BACKUP_PATH . '/vendor/autoload.php' );
|
91 |
if ( $exists_composer && ! $exists_autoload ) {
|
92 |
+
add_action(
|
93 |
+
'admin_init', function() {
|
94 |
+
deactivate_plugins( 'boldgrid-backup/boldgrid-backup.php', true );
|
95 |
+
|
96 |
+
add_action(
|
97 |
+
'admin_notices', function() {
|
98 |
+
?>
|
99 |
+
<div class="notice notice-error is-dismissible"><p>
|
100 |
+
<?php
|
101 |
+
printf(
|
102 |
+
// translators: 1: HTML strong open tag, 2: HTML string close tag.
|
103 |
+
esc_html__(
|
104 |
+
'%1$sBoldGrid Backup%1$s has been deactivated because the vendor folder is missing. Please run %1$scomposer install%2$s, or contact your host for further assistance.',
|
105 |
+
'boldgrid-backup'
|
106 |
+
),
|
107 |
+
'<strong>',
|
108 |
+
'</strong>'
|
109 |
+
);
|
110 |
+
?>
|
111 |
+
</p></div>
|
112 |
+
<?php
|
113 |
+
}
|
114 |
+
);
|
115 |
+
}
|
116 |
+
);
|
117 |
|
118 |
return false;
|
119 |
}
|
127 |
// Load Library.
|
128 |
$load = new Boldgrid\Library\Util\Load(
|
129 |
array(
|
130 |
+
'type' => 'plugin',
|
131 |
+
'file' => plugin_basename( __FILE__ ),
|
132 |
+
'loader' => $loader,
|
133 |
+
'keyValidate' => true,
|
134 |
+
'licenseActivate' => false,
|
135 |
)
|
136 |
);
|
137 |
|
cron/{url-helper.php → class-boldgrid-backup-url-helper.php}
RENAMED
@@ -1,97 +1,106 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* File: url-helper.php
|
4 |
-
*
|
5 |
-
*
|
6 |
-
*
|
7 |
-
*
|
8 |
-
* @
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
* @
|
12 |
-
|
13 |
-
|
14 |
-
|
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 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
return $result;
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Detect if cURL SSL is available.
|
71 |
-
*
|
72 |
-
* @since 1.6.3
|
73 |
-
*
|
74 |
-
* @return bool
|
75 |
-
*/
|
76 |
-
public function has_curl_ssl() {
|
77 |
-
$has_curl_ssl = false;
|
78 |
-
|
79 |
-
if ( function_exists( 'curl_version' ) ) {
|
80 |
-
$curl_version = curl_version();
|
81 |
-
$has_curl_ssl = (bool) ( $curl_version['features'] & CURL_VERSION_SSL );
|
82 |
-
}
|
83 |
-
|
84 |
-
return $has_curl_ssl;
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Detect if allow_url_fopen is on.
|
89 |
-
*
|
90 |
-
* @since 1.6.3
|
91 |
-
*
|
92 |
-
* @return bool
|
93 |
-
*/
|
94 |
-
public function has_url_fopen() {
|
95 |
-
return (bool) ini_get( 'allow_url_fopen' );
|
96 |
-
}
|
97 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* File: class-boldgrid-backup-url-helper.php
|
4 |
+
*
|
5 |
+
* Standalone URL address helper for Cron tasks.
|
6 |
+
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
+
* @since 1.6.3
|
9 |
+
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
+
* @copyright BoldGrid
|
12 |
+
* @version $Id$
|
13 |
+
* @author BoldGrid <support@boldgrid.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
// phpcs:disable WordPress.VIP, WordPress.WP.AlternativeFunctions
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Class: Boldgrid_Backup_Url_Helper.
|
20 |
+
*
|
21 |
+
* @since 1.6.3
|
22 |
+
*/
|
23 |
+
class Boldgrid_Backup_Url_Helper {
|
24 |
+
/**
|
25 |
+
* Call a URL address.
|
26 |
+
*
|
27 |
+
* @since 1.6.3
|
28 |
+
*
|
29 |
+
* @param string $url A URL address.
|
30 |
+
* @return mixed Returns a string or FALSE on failure to make the call.
|
31 |
+
*/
|
32 |
+
public function call_url( $url ) {
|
33 |
+
$result = false;
|
34 |
+
|
35 |
+
if ( empty( $url ) ) {
|
36 |
+
return false;
|
37 |
+
}
|
38 |
+
|
39 |
+
// Sanitize the url.
|
40 |
+
$url = filter_var( $url, FILTER_SANITIZE_URL );
|
41 |
+
|
42 |
+
switch ( true ) {
|
43 |
+
case $this->has_curl_ssl():
|
44 |
+
$ch = curl_init( $url );
|
45 |
+
|
46 |
+
$curl_options = array(
|
47 |
+
CURLOPT_FOLLOWLOCATION => true,
|
48 |
+
CURLOPT_RETURNTRANSFER => true,
|
49 |
+
CURLOPT_SSL_VERIFYPEER => false,
|
50 |
+
CURLOPT_SSL_VERIFYHOST => 0,
|
51 |
+
CURLOPT_TIMEOUT => 0,
|
52 |
+
CURLOPT_USERAGENT => 'BoldGrid Backup cron task',
|
53 |
+
);
|
54 |
+
|
55 |
+
curl_setopt_array( $ch, $curl_options );
|
56 |
+
|
57 |
+
$result = curl_exec( $ch );
|
58 |
+
|
59 |
+
if ( curl_errno( $ch ) ) {
|
60 |
+
$result = false;
|
61 |
+
}
|
62 |
+
|
63 |
+
curl_close( $ch );
|
64 |
+
|
65 |
+
break;
|
66 |
+
|
67 |
+
case $this->has_url_fopen():
|
68 |
+
$result = file_get_contents( $url );
|
69 |
+
break;
|
70 |
+
|
71 |
+
default:
|
72 |
+
break;
|
73 |
+
}
|
74 |
+
|
75 |
return $result;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Detect if cURL SSL is available.
|
80 |
+
*
|
81 |
+
* @since 1.6.3
|
82 |
+
*
|
83 |
+
* @return bool
|
84 |
+
*/
|
85 |
+
public function has_curl_ssl() {
|
86 |
+
$has_curl_ssl = false;
|
87 |
+
|
88 |
+
if ( function_exists( 'curl_version' ) ) {
|
89 |
+
$curl_version = curl_version();
|
90 |
+
$has_curl_ssl = (bool) ( $curl_version['features'] & CURL_VERSION_SSL );
|
91 |
+
}
|
92 |
+
|
93 |
+
return $has_curl_ssl;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Detect if allow_url_fopen is on.
|
98 |
+
*
|
99 |
+
* @since 1.6.3
|
100 |
+
*
|
101 |
+
* @return bool
|
102 |
+
*/
|
103 |
+
public function has_url_fopen() {
|
104 |
+
return (bool) ini_get( 'allow_url_fopen' );
|
105 |
+
}
|
106 |
+
}
|
cron/cli-support.php
CHANGED
@@ -1,18 +1,29 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Test for support from the command line.
|
4 |
*
|
|
|
5 |
* @since 1.6.2
|
6 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
* @see Boldgrid_Backup_Admin_Test::get_cli_support().
|
8 |
*/
|
9 |
|
|
|
|
|
10 |
// Require Boldgrid_Backup_Url_Helper class.
|
11 |
-
require dirname( __FILE__ ) . '/url-helper.php';
|
12 |
|
13 |
$url_helper = new Boldgrid_Backup_Url_Helper();
|
14 |
|
15 |
die( json_encode( array(
|
16 |
-
'has_curl_ssl'
|
17 |
'has_url_fopen' => $url_helper->has_url_fopen(),
|
18 |
) ) );
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: cli-support.php
|
4 |
+
*
|
5 |
* Test for support from the command line.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.6.2
|
9 |
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
+
* @subpackage Boldgrid_Backup/cron
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
+
*
|
16 |
* @see Boldgrid_Backup_Admin_Test::get_cli_support().
|
17 |
*/
|
18 |
|
19 |
+
// phpcs:disable WordPress.WP.AlternativeFunctions
|
20 |
+
|
21 |
// Require Boldgrid_Backup_Url_Helper class.
|
22 |
+
require dirname( __FILE__ ) . '/class-boldgrid-backup-url-helper.php';
|
23 |
|
24 |
$url_helper = new Boldgrid_Backup_Url_Helper();
|
25 |
|
26 |
die( json_encode( array(
|
27 |
+
'has_curl_ssl' => $url_helper->has_curl_ssl(),
|
28 |
'has_url_fopen' => $url_helper->has_url_fopen(),
|
29 |
) ) );
|
cron/{run_jobs.php → run-jobs.php}
RENAMED
@@ -1,8 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* BoldGrid Backup Run Jobs.
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.5.2
|
7 |
*
|
8 |
* @package Boldgrid_Backup
|
@@ -48,9 +50,9 @@ $url = $input['siteurl'] . '/wp-admin/admin-ajax.php?action=boldgrid_backup_run_
|
|
48 |
$input['id'] . '&secret=' . $input['secret'] . '&doing_wp_cron=' . time();
|
49 |
|
50 |
// The helper class method will sanitize the url.
|
51 |
-
require dirname( __FILE__ ) . '/url-helper.php';
|
52 |
$url_helper = new Boldgrid_Backup_Url_Helper();
|
53 |
-
$result
|
54 |
|
55 |
if ( false !== $result ) {
|
56 |
$message = $result;
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: run-jobs.php
|
4 |
+
*
|
5 |
* BoldGrid Backup Run Jobs.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.5.2
|
9 |
*
|
10 |
* @package Boldgrid_Backup
|
50 |
$input['id'] . '&secret=' . $input['secret'] . '&doing_wp_cron=' . time();
|
51 |
|
52 |
// The helper class method will sanitize the url.
|
53 |
+
require dirname( __FILE__ ) . '/class-boldgrid-backup-url-helper.php';
|
54 |
$url_helper = new Boldgrid_Backup_Url_Helper();
|
55 |
+
$result = $url_helper->call_url( $url );
|
56 |
|
57 |
if ( false !== $result ) {
|
58 |
$message = $result;
|
includes/class-boldgrid-backup-activator.php
CHANGED
@@ -1,34 +1,39 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.0
|
7 |
*
|
8 |
-
* @package
|
9 |
* @subpackage Boldgrid_Backup/includes
|
|
|
|
|
|
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
*
|
15 |
* This class defines all code necessary to run during the plugin's activation.
|
16 |
*
|
17 |
* @since 1.0
|
18 |
-
* @package Boldgrid_Backup
|
19 |
-
* @subpackage Boldgrid_Backup/includes
|
20 |
-
* @author BoldGrid.com <wpb@boldgrid.com>
|
21 |
*/
|
22 |
class Boldgrid_Backup_Activator {
|
23 |
-
|
24 |
/**
|
25 |
* Plugin activation.
|
26 |
*
|
27 |
* @since 1.0
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
*/
|
29 |
public static function activate() {
|
30 |
-
$core
|
31 |
-
$settings
|
32 |
$scheduler = ! empty( $settings['scheduler'] ) ? $settings['scheduler'] : null;
|
33 |
|
34 |
/*
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-activator.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.0
|
7 |
*
|
8 |
+
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/includes
|
10 |
+
* @copyright BoldGrid
|
11 |
+
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Activator
|
17 |
*
|
18 |
* This class defines all code necessary to run during the plugin's activation.
|
19 |
*
|
20 |
* @since 1.0
|
|
|
|
|
|
|
21 |
*/
|
22 |
class Boldgrid_Backup_Activator {
|
|
|
23 |
/**
|
24 |
* Plugin activation.
|
25 |
*
|
26 |
* @since 1.0
|
27 |
+
*
|
28 |
+
* @static
|
29 |
+
*
|
30 |
+
* @see Boldgrid_Backup_Admin_Core()
|
31 |
+
* @see Boldgrid_Backup_Admin_Settings::get_settings()
|
32 |
+
* @see Boldgrid_Backup_Admin_Cron::add_all_crons()
|
33 |
*/
|
34 |
public static function activate() {
|
35 |
+
$core = new Boldgrid_Backup_Admin_Core();
|
36 |
+
$settings = $core->settings->get_settings();
|
37 |
$scheduler = ! empty( $settings['scheduler'] ) ? $settings['scheduler'] : null;
|
38 |
|
39 |
/*
|
includes/class-boldgrid-backup-deactivator.php
CHANGED
@@ -1,16 +1,19 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @link
|
6 |
* @since 1.0
|
7 |
*
|
8 |
-
* @package
|
9 |
* @subpackage Boldgrid_Backup/includes
|
|
|
|
|
|
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
*
|
15 |
* This class defines all code necessary to run during the plugin's deactivation.
|
16 |
*
|
@@ -20,7 +23,6 @@
|
|
20 |
* @author BoldGrid.com <wpb@boldgrid.com>
|
21 |
*/
|
22 |
class Boldgrid_Backup_Deactivator {
|
23 |
-
|
24 |
/**
|
25 |
* Plugin deactivation.
|
26 |
*
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-deactivator.php
|
4 |
*
|
5 |
+
* @link https://www.boldgrid.com
|
6 |
* @since 1.0
|
7 |
*
|
8 |
+
* @package Boldgrid_Backup
|
9 |
* @subpackage Boldgrid_Backup/includes
|
10 |
+
* @copyright BoldGrid
|
11 |
+
* @version $Id$
|
12 |
+
* @author BoldGrid <support@boldgrid.com>
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
+
* Class: Boldgrid_Backup_Deactivator
|
17 |
*
|
18 |
* This class defines all code necessary to run during the plugin's deactivation.
|
19 |
*
|
23 |
* @author BoldGrid.com <wpb@boldgrid.com>
|
24 |
*/
|
25 |
class Boldgrid_Backup_Deactivator {
|
|
|
26 |
/**
|
27 |
* Plugin deactivation.
|
28 |
*
|
includes/class-boldgrid-backup-i18n.php
CHANGED
@@ -1,37 +1,40 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
|
|
5 |
* Loads and defines the internationalization files for this plugin
|
6 |
* so that it is ready for translation.
|
7 |
*
|
8 |
-
* @link
|
9 |
* @since 1.0
|
10 |
*
|
11 |
-
* @package
|
12 |
* @subpackage Boldgrid_Backup/includes
|
|
|
|
|
|
|
13 |
*/
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
|
|
18 |
* Loads and defines the internationalization files for this plugin
|
19 |
* so that it is ready for translation.
|
20 |
*
|
21 |
* @since 1.0
|
22 |
-
* @package Boldgrid_Backup
|
23 |
-
* @subpackage Boldgrid_Backup/includes
|
24 |
-
* @author BoldGrid.com <wpb@boldgrid.com>
|
25 |
*/
|
26 |
-
class
|
27 |
-
|
28 |
/**
|
29 |
* Load the plugin text domain for translation.
|
30 |
*
|
31 |
* @since 1.0
|
32 |
*/
|
33 |
public function load_plugin_textdomain() {
|
34 |
-
load_plugin_textdomain(
|
35 |
-
|
|
|
|
|
36 |
}
|
37 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-i18n.php
|
4 |
*
|
5 |
+
* Define the internationalization functionality.
|
6 |
* Loads and defines the internationalization files for this plugin
|
7 |
* so that it is ready for translation.
|
8 |
*
|
9 |
+
* @link https://www.boldgrid.com
|
10 |
* @since 1.0
|
11 |
*
|
12 |
+
* @package Boldgrid_Backup
|
13 |
* @subpackage Boldgrid_Backup/includes
|
14 |
+
* @copyright BoldGrid
|
15 |
+
* @version $Id$
|
16 |
+
* @author BoldGrid <support@boldgrid.com>
|
17 |
*/
|
18 |
|
19 |
/**
|
20 |
+
* Class: Boldgrid_Backup_I18n
|
21 |
*
|
22 |
+
* Define the internationalization functionality.
|
23 |
* Loads and defines the internationalization files for this plugin
|
24 |
* so that it is ready for translation.
|
25 |
*
|
26 |
* @since 1.0
|
|
|
|
|
|
|
27 |
*/
|
28 |
+
class Boldgrid_Backup_I18n {
|
|
|
29 |
/**
|
30 |
* Load the plugin text domain for translation.
|
31 |
*
|
32 |
* @since 1.0
|
33 |
*/
|
34 |
public function load_plugin_textdomain() {
|
35 |
+
load_plugin_textdomain(
|
36 |
+
'boldgrid-backup', false,
|
37 |
+
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
|
38 |
+
);
|
39 |
}
|
40 |
}
|
includes/class-boldgrid-backup-loader.php
CHANGED
@@ -1,27 +1,30 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
*
|
|
|
|
|
6 |
* @since 1.0
|
7 |
*
|
8 |
-
* @package
|
9 |
* @subpackage Boldgrid_Backup/includes
|
|
|
|
|
|
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
*
|
|
|
15 |
* Maintain a list of all hooks that are registered throughout
|
16 |
* the plugin, and register them with the WordPress API. Call the
|
17 |
* run function to execute the list of actions and filters.
|
18 |
*
|
19 |
-
* @
|
20 |
-
* @subpackage Boldgrid_Backup/includes
|
21 |
-
* @author BoldGrid.com <wpb@boldgrid.com>
|
22 |
*/
|
23 |
class Boldgrid_Backup_Loader {
|
24 |
-
|
25 |
/**
|
26 |
* The array of actions registered with WordPress.
|
27 |
*
|
@@ -62,8 +65,10 @@ class Boldgrid_Backup_Loader {
|
|
62 |
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
|
63 |
*/
|
64 |
public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
65 |
-
$this->actions = $this->add(
|
66 |
-
|
|
|
|
|
67 |
}
|
68 |
|
69 |
/**
|
@@ -78,8 +83,10 @@ class Boldgrid_Backup_Loader {
|
|
78 |
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
|
79 |
*/
|
80 |
public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
81 |
-
$this->filters = $this->add(
|
82 |
-
|
|
|
|
|
83 |
}
|
84 |
|
85 |
/**
|
@@ -99,10 +106,10 @@ class Boldgrid_Backup_Loader {
|
|
99 |
*/
|
100 |
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
|
101 |
$hooks[] = array(
|
102 |
-
'hook'
|
103 |
-
'component'
|
104 |
-
'callback'
|
105 |
-
'priority'
|
106 |
'accepted_args' => $accepted_args,
|
107 |
);
|
108 |
|
@@ -116,17 +123,21 @@ class Boldgrid_Backup_Loader {
|
|
116 |
*/
|
117 |
public function run() {
|
118 |
foreach ( $this->filters as $hook ) {
|
119 |
-
add_filter(
|
120 |
-
$hook['
|
121 |
-
|
122 |
-
|
|
|
|
|
123 |
}
|
124 |
|
125 |
foreach ( $this->actions as $hook ) {
|
126 |
-
add_action(
|
127 |
-
$hook['
|
128 |
-
|
129 |
-
|
|
|
|
|
130 |
}
|
131 |
}
|
132 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup-loader.php
|
4 |
*
|
5 |
+
* Register all actions and filters for the plugin.
|
6 |
+
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.0
|
9 |
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
* @subpackage Boldgrid_Backup/includes
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
/**
|
18 |
+
* Class: Boldgrid_Backup_Loader
|
19 |
*
|
20 |
+
* Register all actions and filters for the plugin.
|
21 |
* Maintain a list of all hooks that are registered throughout
|
22 |
* the plugin, and register them with the WordPress API. Call the
|
23 |
* run function to execute the list of actions and filters.
|
24 |
*
|
25 |
+
* @since 1.0
|
|
|
|
|
26 |
*/
|
27 |
class Boldgrid_Backup_Loader {
|
|
|
28 |
/**
|
29 |
* The array of actions registered with WordPress.
|
30 |
*
|
65 |
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
|
66 |
*/
|
67 |
public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
68 |
+
$this->actions = $this->add(
|
69 |
+
$this->actions, $hook, $component, $callback, $priority,
|
70 |
+
$accepted_args
|
71 |
+
);
|
72 |
}
|
73 |
|
74 |
/**
|
83 |
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
|
84 |
*/
|
85 |
public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
86 |
+
$this->filters = $this->add(
|
87 |
+
$this->filters, $hook, $component, $callback, $priority,
|
88 |
+
$accepted_args
|
89 |
+
);
|
90 |
}
|
91 |
|
92 |
/**
|
106 |
*/
|
107 |
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
|
108 |
$hooks[] = array(
|
109 |
+
'hook' => $hook,
|
110 |
+
'component' => $component,
|
111 |
+
'callback' => $callback,
|
112 |
+
'priority' => $priority,
|
113 |
'accepted_args' => $accepted_args,
|
114 |
);
|
115 |
|
123 |
*/
|
124 |
public function run() {
|
125 |
foreach ( $this->filters as $hook ) {
|
126 |
+
add_filter(
|
127 |
+
$hook['hook'], array(
|
128 |
+
$hook['component'],
|
129 |
+
$hook['callback'],
|
130 |
+
), $hook['priority'], $hook['accepted_args']
|
131 |
+
);
|
132 |
}
|
133 |
|
134 |
foreach ( $this->actions as $hook ) {
|
135 |
+
add_action(
|
136 |
+
$hook['hook'], array(
|
137 |
+
$hook['component'],
|
138 |
+
$hook['callback'],
|
139 |
+
), $hook['priority'], $hook['accepted_args']
|
140 |
+
);
|
141 |
}
|
142 |
}
|
143 |
}
|
includes/class-boldgrid-backup.php
CHANGED
@@ -1,31 +1,33 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
* A class definition that includes attributes and functions used across the admin area.
|
6 |
*
|
7 |
-
* @link
|
8 |
* @since 1.0
|
9 |
*
|
10 |
-
* @package
|
11 |
* @subpackage Boldgrid_Backup/includes
|
|
|
|
|
|
|
12 |
*/
|
13 |
|
|
|
|
|
14 |
/**
|
15 |
-
*
|
16 |
*
|
|
|
17 |
* This is used to define internationalization and admin-specific hooks.
|
18 |
*
|
19 |
* Also maintains the unique identifier of this plugin as well as the current
|
20 |
* version of the plugin.
|
21 |
*
|
22 |
* @since 1.0
|
23 |
-
* @package Boldgrid_Backup
|
24 |
-
* @subpackage Boldgrid_Backup/includes
|
25 |
-
* @author BoldGrid.com <wpb@boldgrid.com>
|
26 |
*/
|
27 |
class Boldgrid_Backup {
|
28 |
-
|
29 |
/**
|
30 |
* The loader that's responsible for maintaining and registering all hooks that power
|
31 |
* the plugin.
|
@@ -64,7 +66,7 @@ class Boldgrid_Backup {
|
|
64 |
*/
|
65 |
public function __construct() {
|
66 |
$this->plugin_name = 'boldgrid-backup';
|
67 |
-
$this->version
|
68 |
|
69 |
$this->load_dependencies();
|
70 |
$this->set_locale();
|
@@ -77,7 +79,7 @@ class Boldgrid_Backup {
|
|
77 |
* Include the following files that make up the plugin:
|
78 |
*
|
79 |
* - Boldgrid_Backup_Loader. Orchestrates the hooks of the plugin.
|
80 |
-
* -
|
81 |
* - Boldgrid_Backup_Admin. Defines all hooks for the admin area.
|
82 |
*
|
83 |
* Create an instance of the loader which will be used to register the hooks
|
@@ -160,8 +162,8 @@ class Boldgrid_Backup {
|
|
160 |
|
161 |
require_once BOLDGRID_BACKUP_PATH . '/admin/class-boldgrid-backup-admin-compressor.php';
|
162 |
require_once BOLDGRID_BACKUP_PATH . '/admin/class-boldgrid-backup-admin-compressors.php';
|
163 |
-
require_once BOLDGRID_BACKUP_PATH . '/admin/compressor/
|
164 |
-
require_once BOLDGRID_BACKUP_PATH . '/admin/compressor/
|
165 |
|
166 |
include BOLDGRID_BACKUP_PATH . '/vendor/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php';
|
167 |
require_once BOLDGRID_BACKUP_PATH . '/admin/class-boldgrid-backup-admin-db-dump.php';
|
@@ -192,7 +194,7 @@ class Boldgrid_Backup {
|
|
192 |
|
193 |
require_once BOLDGRID_BACKUP_PATH . '/admin/class-boldgrid-backup-admin-remote.php';
|
194 |
|
195 |
-
require_once BOLDGRID_BACKUP_PATH . '/admin/storage/local.php';
|
196 |
|
197 |
require_once BOLDGRID_BACKUP_PATH . '/admin/class-boldgrid-backup-admin-email.php';
|
198 |
|
@@ -202,9 +204,9 @@ class Boldgrid_Backup {
|
|
202 |
|
203 |
require_once BOLDGRID_BACKUP_PATH . '/admin/class-boldgrid-backup-admin-in-progress.php';
|
204 |
|
205 |
-
require_once BOLDGRID_BACKUP_PATH . '/admin/remote/ftp.php';
|
206 |
-
require_once BOLDGRID_BACKUP_PATH . '/admin/remote/ftp-hooks.php';
|
207 |
-
require_once BOLDGRID_BACKUP_PATH . '/admin/remote/ftp-page.php';
|
208 |
|
209 |
require_once BOLDGRID_BACKUP_PATH . '/admin/class-boldgrid-backup-admin-go-pro.php';
|
210 |
|
@@ -220,14 +222,14 @@ class Boldgrid_Backup {
|
|
220 |
/**
|
221 |
* Define the locale for this plugin for internationalization.
|
222 |
*
|
223 |
-
* Uses the
|
224 |
* with WordPress.
|
225 |
*
|
226 |
* @since 1.0
|
227 |
* @access private
|
228 |
*/
|
229 |
private function set_locale() {
|
230 |
-
$plugin_i18n = new
|
231 |
|
232 |
$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
|
233 |
}
|
@@ -237,8 +239,6 @@ class Boldgrid_Backup {
|
|
237 |
*
|
238 |
* @since 1.0
|
239 |
* @access private
|
240 |
-
*
|
241 |
-
* @return null
|
242 |
*/
|
243 |
private function define_admin_hooks() {
|
244 |
// Instantiate a Boldgrid_Backup_Admin class object.
|
@@ -250,12 +250,14 @@ class Boldgrid_Backup {
|
|
250 |
$plugin_admin_core = new Boldgrid_Backup_Admin_Core();
|
251 |
|
252 |
// Add nav menu items.
|
253 |
-
$this->loader->add_action(
|
|
|
254 |
'add_menu_items'
|
255 |
);
|
256 |
|
257 |
// Add a custom action for admin notices.
|
258 |
-
$this->loader->add_action(
|
|
|
259 |
'boldgrid_backup_notice', 10, 2
|
260 |
);
|
261 |
|
@@ -265,39 +267,46 @@ class Boldgrid_Backup {
|
|
265 |
$this->loader->add_action( 'wp_ajax_boldgrid_backup_get_progress_notice', $plugin_admin_core->in_progress, 'wp_ajax_get_progress_notice' );
|
266 |
|
267 |
// Add a custom action to handle AJAX callback for creating a backup archive file.
|
268 |
-
$this->loader->add_action(
|
|
|
269 |
'boldgrid_backup_now_callback'
|
270 |
);
|
271 |
|
272 |
// Add a custom action to handle AJAX callback for archive file download buttons.
|
273 |
-
$this->loader->add_action(
|
|
|
274 |
'download_archive_file_callback'
|
275 |
);
|
276 |
|
277 |
// Add an action to perform an auto-backup before an auto-update occurs.
|
278 |
-
$this->loader->add_action(
|
|
|
279 |
'boldgrid_backup_now_auto'
|
280 |
);
|
281 |
|
282 |
// Add an action to display an admin notice for a pending rollback.
|
283 |
-
$this->loader->add_action(
|
|
|
284 |
'notice_countdown_show'
|
285 |
);
|
286 |
|
287 |
// Add a custom action to handle AJAX callback for canceling a pending rollback.
|
288 |
-
$this->loader->add_action(
|
|
|
289 |
'wp_ajax_cancel'
|
290 |
);
|
291 |
|
292 |
$this->loader->add_action( 'admin_notices', $plugin_admin_core->auto_rollback, 'notice_backup_show' );
|
293 |
|
294 |
// Add an action to add a cron job to restore after WordPress Updates, unless canceled.
|
295 |
-
$this->loader->add_action(
|
|
|
296 |
'notice_deadline_show', 10, 2
|
297 |
);
|
298 |
|
299 |
// Add a custom action to handle AJAX callback for getting the rollback deadline.
|
300 |
-
$this->loader->add_action(
|
|
|
301 |
'wp_ajax_get_deadline'
|
302 |
);
|
303 |
|
@@ -356,7 +365,7 @@ class Boldgrid_Backup {
|
|
356 |
// Process upload via ajax.
|
357 |
$this->loader->add_filter( 'wp_ajax_boldgrid_backup_remote_storage_upload_ftp', $plugin_admin_core->ftp->hooks, 'wp_ajax_upload' );
|
358 |
// Add to the settings page.
|
359 |
-
$this->loader->add_filter( 'boldgrid_backup_register_storage_location',
|
360 |
// Add our "configure ftp" page.
|
361 |
$this->loader->add_action( 'admin_menu', $plugin_admin_core->ftp->hooks, 'add_menu_items' );
|
362 |
// After updating settings on the settings page, check if we have valid credentials.
|
@@ -384,8 +393,6 @@ class Boldgrid_Backup {
|
|
384 |
$this->loader->add_action( 'wp_ajax_nopriv_boldgrid_backup_run_jobs', $plugin_admin_core->jobs, 'run' );
|
385 |
$this->loader->add_action( 'wp_ajax_nopriv_boldgrid_backup_run_backup', $plugin_admin_core->cron, 'backup' );
|
386 |
$this->loader->add_action( 'wp_ajax_nopriv_boldgrid_backup_run_restore', $plugin_admin_core->cron, 'restore' );
|
387 |
-
|
388 |
-
return;
|
389 |
}
|
390 |
|
391 |
/**
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-boldgrid-backup.php
|
4 |
*
|
5 |
* A class definition that includes attributes and functions used across the admin area.
|
6 |
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.0
|
9 |
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
* @subpackage Boldgrid_Backup/includes
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
+
// phpcs:disable WordPress.VIP
|
18 |
+
|
19 |
/**
|
20 |
+
* Class: Boldgrid_Backup
|
21 |
*
|
22 |
+
* The core plugin class.
|
23 |
* This is used to define internationalization and admin-specific hooks.
|
24 |
*
|
25 |
* Also maintains the unique identifier of this plugin as well as the current
|
26 |
* version of the plugin.
|
27 |
*
|
28 |
* @since 1.0
|
|
|
|
|
|
|
29 |
*/
|
30 |
class Boldgrid_Backup {
|
|
|
31 |
/**
|
32 |
* The loader that's responsible for maintaining and registering all hooks that power
|
33 |
* the plugin.
|
66 |
*/
|
67 |
public function __construct() {
|
68 |
$this->plugin_name = 'boldgrid-backup';
|
69 |
+
$this->version = ( defined( 'BOLDGRID_BACKUP_VERSION' ) ? BOLDGRID_BACKUP_VERSION : '' );
|
70 |
|
71 |
$this->load_dependencies();
|
72 |
$this->set_locale();
|
79 |
* Include the following files that make up the plugin:
|
80 |
*
|
81 |
* - Boldgrid_Backup_Loader. Orchestrates the hooks of the plugin.
|
82 |
+
* - Boldgrid_Backup_I18n. Defines internationalization functionality.
|
83 |
* - Boldgrid_Backup_Admin. Defines all hooks for the admin area.
|
84 |
*
|
85 |
* Create an instance of the loader which will be used to register the hooks
|
162 |
|
163 |
require_once BOLDGRID_BACKUP_PATH . '/admin/class-boldgrid-backup-admin-compressor.php';
|
164 |
require_once BOLDGRID_BACKUP_PATH . '/admin/class-boldgrid-backup-admin-compressors.php';
|
165 |
+
require_once BOLDGRID_BACKUP_PATH . '/admin/compressor/class-boldgrid-backup-admin-compressor-php-zip.php';
|
166 |
+
require_once BOLDGRID_BACKUP_PATH . '/admin/compressor/class-boldgrid-backup-admin-compressor-pcl-zip.php';
|
167 |
|
168 |
include BOLDGRID_BACKUP_PATH . '/vendor/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php';
|
169 |
require_once BOLDGRID_BACKUP_PATH . '/admin/class-boldgrid-backup-admin-db-dump.php';
|
194 |
|
195 |
require_once BOLDGRID_BACKUP_PATH . '/admin/class-boldgrid-backup-admin-remote.php';
|
196 |
|
197 |
+
require_once BOLDGRID_BACKUP_PATH . '/admin/storage/class-boldgrid-backup-admin-storage-local.php';
|
198 |
|
199 |
require_once BOLDGRID_BACKUP_PATH . '/admin/class-boldgrid-backup-admin-email.php';
|
200 |
|
204 |
|
205 |
require_once BOLDGRID_BACKUP_PATH . '/admin/class-boldgrid-backup-admin-in-progress.php';
|
206 |
|
207 |
+
require_once BOLDGRID_BACKUP_PATH . '/admin/remote/class-boldgrid-backup-admin-ftp.php';
|
208 |
+
require_once BOLDGRID_BACKUP_PATH . '/admin/remote/class-boldgrid-backup-admin-ftp-hooks.php';
|
209 |
+
require_once BOLDGRID_BACKUP_PATH . '/admin/remote/class-boldgrid-backup-admin-ftp-page.php';
|
210 |
|
211 |
require_once BOLDGRID_BACKUP_PATH . '/admin/class-boldgrid-backup-admin-go-pro.php';
|
212 |
|
222 |
/**
|
223 |
* Define the locale for this plugin for internationalization.
|
224 |
*
|
225 |
+
* Uses the Boldgrid_Backup_I18n class in order to set the domain and to register the hook
|
226 |
* with WordPress.
|
227 |
*
|
228 |
* @since 1.0
|
229 |
* @access private
|
230 |
*/
|
231 |
private function set_locale() {
|
232 |
+
$plugin_i18n = new Boldgrid_Backup_I18n();
|
233 |
|
234 |
$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
|
235 |
}
|
239 |
*
|
240 |
* @since 1.0
|
241 |
* @access private
|
|
|
|
|
242 |
*/
|
243 |
private function define_admin_hooks() {
|
244 |
// Instantiate a Boldgrid_Backup_Admin class object.
|
250 |
$plugin_admin_core = new Boldgrid_Backup_Admin_Core();
|
251 |
|
252 |
// Add nav menu items.
|
253 |
+
$this->loader->add_action(
|
254 |
+
'admin_menu', $plugin_admin_core,
|
255 |
'add_menu_items'
|
256 |
);
|
257 |
|
258 |
// Add a custom action for admin notices.
|
259 |
+
$this->loader->add_action(
|
260 |
+
'boldgrid_backup_notice', $plugin_admin_core->notice,
|
261 |
'boldgrid_backup_notice', 10, 2
|
262 |
);
|
263 |
|
267 |
$this->loader->add_action( 'wp_ajax_boldgrid_backup_get_progress_notice', $plugin_admin_core->in_progress, 'wp_ajax_get_progress_notice' );
|
268 |
|
269 |
// Add a custom action to handle AJAX callback for creating a backup archive file.
|
270 |
+
$this->loader->add_action(
|
271 |
+
'wp_ajax_boldgrid_backup_now', $plugin_admin_core,
|
272 |
'boldgrid_backup_now_callback'
|
273 |
);
|
274 |
|
275 |
// Add a custom action to handle AJAX callback for archive file download buttons.
|
276 |
+
$this->loader->add_action(
|
277 |
+
'wp_ajax_download_archive_file', $plugin_admin_core,
|
278 |
'download_archive_file_callback'
|
279 |
);
|
280 |
|
281 |
// Add an action to perform an auto-backup before an auto-update occurs.
|
282 |
+
$this->loader->add_action(
|
283 |
+
'pre_auto_update', $plugin_admin_core,
|
284 |
'boldgrid_backup_now_auto'
|
285 |
);
|
286 |
|
287 |
// Add an action to display an admin notice for a pending rollback.
|
288 |
+
$this->loader->add_action(
|
289 |
+
'admin_notices', $plugin_admin_core->auto_rollback,
|
290 |
'notice_countdown_show'
|
291 |
);
|
292 |
|
293 |
// Add a custom action to handle AJAX callback for canceling a pending rollback.
|
294 |
+
$this->loader->add_action(
|
295 |
+
'wp_ajax_boldgrid_cancel_rollback', $plugin_admin_core->auto_rollback,
|
296 |
'wp_ajax_cancel'
|
297 |
);
|
298 |
|
299 |
$this->loader->add_action( 'admin_notices', $plugin_admin_core->auto_rollback, 'notice_backup_show' );
|
300 |
|
301 |
// Add an action to add a cron job to restore after WordPress Updates, unless canceled.
|
302 |
+
$this->loader->add_action(
|
303 |
+
'upgrader_process_complete', $plugin_admin_core->auto_rollback,
|
304 |
'notice_deadline_show', 10, 2
|
305 |
);
|
306 |
|
307 |
// Add a custom action to handle AJAX callback for getting the rollback deadline.
|
308 |
+
$this->loader->add_action(
|
309 |
+
'wp_ajax_boldgrid_backup_deadline', $plugin_admin_core->auto_rollback,
|
310 |
'wp_ajax_get_deadline'
|
311 |
);
|
312 |
|
365 |
// Process upload via ajax.
|
366 |
$this->loader->add_filter( 'wp_ajax_boldgrid_backup_remote_storage_upload_ftp', $plugin_admin_core->ftp->hooks, 'wp_ajax_upload' );
|
367 |
// Add to the settings page.
|
368 |
+
$this->loader->add_filter( 'boldgrid_backup_register_storage_location', $plugin_admin_core->ftp->hooks, 'register_storage_location' );
|
369 |
// Add our "configure ftp" page.
|
370 |
$this->loader->add_action( 'admin_menu', $plugin_admin_core->ftp->hooks, 'add_menu_items' );
|
371 |
// After updating settings on the settings page, check if we have valid credentials.
|
393 |
$this->loader->add_action( 'wp_ajax_nopriv_boldgrid_backup_run_jobs', $plugin_admin_core->jobs, 'run' );
|
394 |
$this->loader->add_action( 'wp_ajax_nopriv_boldgrid_backup_run_backup', $plugin_admin_core->cron, 'backup' );
|
395 |
$this->loader->add_action( 'wp_ajax_nopriv_boldgrid_backup_run_restore', $plugin_admin_core->cron, 'restore' );
|
|
|
|
|
396 |
}
|
397 |
|
398 |
/**
|
includes/config/config.plugin.php
CHANGED
@@ -1,12 +1,17 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
*
|
|
|
|
|
6 |
* @since 1.0
|
7 |
*
|
8 |
-
* @package
|
9 |
* @subpackage Boldgrid_Backup/includes
|
|
|
|
|
|
|
10 |
*/
|
11 |
|
12 |
// Prevent direct calls.
|
@@ -17,27 +22,28 @@ if ( ! defined( 'WPINC' ) ) {
|
|
17 |
}
|
18 |
|
19 |
return array(
|
20 |
-
'ajax_calls'
|
21 |
'get_plugin_version' => '/api/open/get-plugin-version',
|
22 |
-
'get_asset'
|
23 |
),
|
24 |
-
'asset_server'
|
25 |
|
26 |
-
'urls'
|
27 |
-
'compatibility'
|
28 |
-
'possible_issues'
|
29 |
'reduce_size_warning' => 'https://www.boldgrid.com/support/advanced-tutorials/backup-userguide#reduce-size-warning',
|
30 |
-
'resource_usage'
|
31 |
-
'upgrade'
|
32 |
-
'user_guide'
|
33 |
-
'restore'
|
34 |
-
'setting_directory'
|
35 |
),
|
36 |
-
'lang'
|
|
|
37 |
'est_pause' => esc_html__( 'Estimated Pause: %s seconds', 'boldgrid-backup' ),
|
38 |
),
|
39 |
-
'plugin_name'
|
40 |
-
'plugin_key_code'
|
41 |
-
'main_file_path'
|
42 |
'plugin_transient_name' => 'boldgrid_backup_version_data',
|
43 |
);
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: config.plugin.php
|
4 |
*
|
5 |
+
* Plugin configuration file.
|
6 |
+
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.0
|
9 |
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
* @subpackage Boldgrid_Backup/includes
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
// Prevent direct calls.
|
22 |
}
|
23 |
|
24 |
return array(
|
25 |
+
'ajax_calls' => array(
|
26 |
'get_plugin_version' => '/api/open/get-plugin-version',
|
27 |
+
'get_asset' => '/api/open/get-asset',
|
28 |
),
|
29 |
+
'asset_server' => 'https://wp-assets.boldgrid.com',
|
30 |
|
31 |
+
'urls' => array(
|
32 |
+
'compatibility' => 'https://www.boldgrid.com/support/advanced-tutorials/backup-compatibility-guide',
|
33 |
+
'possible_issues' => 'https://www.boldgrid.com/support/advanced-tutorials/backup-userguide#possible-issues',
|
34 |
'reduce_size_warning' => 'https://www.boldgrid.com/support/advanced-tutorials/backup-userguide#reduce-size-warning',
|
35 |
+
'resource_usage' => 'https://www.boldgrid.com/support/advanced-tutorials/backup-userguide#resource-usage',
|
36 |
+
'upgrade' => 'https://www.boldgrid.com/support/advanced-tutorials/backup-userguide#upgrade',
|
37 |
+
'user_guide' => 'https://www.boldgrid.com/support/advanced-tutorials/backup-userguide',
|
38 |
+
'restore' => 'https://www.boldgrid.com/support/advanced-tutorials/restoring-boldgrid-backup/',
|
39 |
+
'setting_directory' => 'https://www.boldgrid.com/support/advanced-tutorials/backup-userguide#setting-backup-directory',
|
40 |
),
|
41 |
+
'lang' => array(
|
42 |
+
// translators: 1: Number of seconds.
|
43 |
'est_pause' => esc_html__( 'Estimated Pause: %s seconds', 'boldgrid-backup' ),
|
44 |
),
|
45 |
+
'plugin_name' => 'boldgrid-backup',
|
46 |
+
'plugin_key_code' => 'backup',
|
47 |
+
'main_file_path' => BOLDGRID_BACKUP_PATH . '/boldgrid-backup.php',
|
48 |
'plugin_transient_name' => 'boldgrid_backup_version_data',
|
49 |
);
|
includes/config/config.sample.php
CHANGED
@@ -1,12 +1,17 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
*
|
|
|
|
|
6 |
* @since 1.0
|
7 |
*
|
8 |
-
* @package
|
9 |
* @subpackage Boldgrid_Backup/includes
|
|
|
|
|
|
|
10 |
*/
|
11 |
|
12 |
// Prevent direct calls.
|
@@ -17,8 +22,9 @@ if ( ! defined( 'WPINC' ) ) {
|
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
-
* Copy this sample file to config.local.php and update it with any variables that you would like
|
|
|
21 |
*/
|
22 |
return array(
|
23 |
-
'asset_server'
|
24 |
);
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: config.sample.php
|
4 |
*
|
5 |
+
* Plugin sample configuration file.
|
6 |
+
*
|
7 |
+
* @link https://www.boldgrid.com
|
8 |
* @since 1.0
|
9 |
*
|
10 |
+
* @package Boldgrid_Backup
|
11 |
* @subpackage Boldgrid_Backup/includes
|
12 |
+
* @copyright BoldGrid
|
13 |
+
* @version $Id$
|
14 |
+
* @author BoldGrid <support@boldgrid.com>
|
15 |
*/
|
16 |
|
17 |
// Prevent direct calls.
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
+
* Copy this sample file to config.local.php and update it with any variables that you would like
|
26 |
+
* to override.
|
27 |
*/
|
28 |
return array(
|
29 |
+
'asset_server' => 'https://wp-assets-dev.boldgrid.com',
|
30 |
);
|
includes/config/index.php
CHANGED
@@ -1,2 +1,8 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
// Silence is golden.
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* File: index.php
|
4 |
+
*
|
5 |
+
* @package Boldgrid_Backup
|
6 |
+
*/
|
7 |
+
|
8 |
// Silence is golden.
|
includes/index.php
CHANGED
@@ -1,2 +1,8 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
// Silence is golden.
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* File: index.php
|
4 |
+
*
|
5 |
+
* @package Boldgrid_Backup
|
6 |
+
*/
|
7 |
+
|
8 |
// Silence is golden.
|
index.php
CHANGED
@@ -1,2 +1,8 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
// Silence is golden.
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* File: index.php
|
4 |
+
*
|
5 |
+
* @package Boldgrid_Backup
|
6 |
+
*/
|
7 |
+
|
8 |
// Silence is golden.
|
readme.txt
CHANGED
@@ -28,12 +28,20 @@ WordPress backup and restoration with update protection.
|
|
28 |
|
29 |
== Changelog ==
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
= 1.6.3 =
|
32 |
|
33 |
Release Date: June 11th, 2018
|
34 |
|
35 |
* Bug fix: System Cron detection failed in some environments.
|
36 |
-
* Update:
|
37 |
|
38 |
= 1.6.2 =
|
39 |
|
28 |
|
29 |
== Changelog ==
|
30 |
|
31 |
+
= 1.6.4 =
|
32 |
+
|
33 |
+
Release Date: July 17th, 2018
|
34 |
+
|
35 |
+
* Bug fix: Fixed and improved php-cli detection.
|
36 |
+
* Bug fix: Fixed "Undefined index 'plugins'" bug.
|
37 |
+
* Update: Cleaned up codebase to pass PHP CodeSniffer.
|
38 |
+
|
39 |
= 1.6.3 =
|
40 |
|
41 |
Release Date: June 11th, 2018
|
42 |
|
43 |
* Bug fix: System Cron detection failed in some environments.
|
44 |
+
* Update: Clarified verbiage on setting up Premium connect key.
|
45 |
|
46 |
= 1.6.2 =
|
47 |
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInit2d055860d5c15ffa34614718a8387474::getLoader();
|
vendor/boldgrid/library/README.md
CHANGED
@@ -11,6 +11,15 @@ composer require boldgrid/library
|
|
11 |
|
12 |
## Changelog ##
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
### 2.3.3 ###
|
15 |
* Bug fix: JIRA BGINSP-15 Disable Connect Key request button after submission.
|
16 |
|
11 |
|
12 |
## Changelog ##
|
13 |
|
14 |
+
### 2.3.6 In progress ###
|
15 |
+
* Update: JIRA BGINSP-23 Updated "boldgrid_available" transient lifetime and checking. Also fixed fatal error when API has an error response.
|
16 |
+
|
17 |
+
### 2.3.5 ###
|
18 |
+
* Bug fix: Updating boldgrid-backup link in config.
|
19 |
+
|
20 |
+
### 2.3.4 ###
|
21 |
+
* Update: JIRA BGBKUP-220 Sanitize inputs.
|
22 |
+
|
23 |
### 2.3.3 ###
|
24 |
* Bug fix: JIRA BGINSP-15 Disable Connect Key request button after submission.
|
25 |
|
vendor/boldgrid/library/src/Library/Api/Availability.php
CHANGED
@@ -22,7 +22,6 @@ use \WP_Http;
|
|
22 |
* @since 1.0.0
|
23 |
*/
|
24 |
class Availability {
|
25 |
-
|
26 |
/**
|
27 |
* @var array $url URL to make call to.
|
28 |
* @var array Request parameters
|
@@ -75,7 +74,6 @@ class Availability {
|
|
75 |
* @return bool
|
76 |
*/
|
77 |
private function checkAvailability() {
|
78 |
-
|
79 |
// Get the boldgrid_available transient.
|
80 |
$available = get_site_transient( 'boldgrid_available' );
|
81 |
|
@@ -89,7 +87,7 @@ class Availability {
|
|
89 |
}
|
90 |
|
91 |
// Update the boldgrid_available transient.
|
92 |
-
set_site_transient( 'boldgrid_available', ( int ) $available,
|
93 |
|
94 |
return $available;
|
95 |
}
|
22 |
* @since 1.0.0
|
23 |
*/
|
24 |
class Availability {
|
|
|
25 |
/**
|
26 |
* @var array $url URL to make call to.
|
27 |
* @var array Request parameters
|
74 |
* @return bool
|
75 |
*/
|
76 |
private function checkAvailability() {
|
|
|
77 |
// Get the boldgrid_available transient.
|
78 |
$available = get_site_transient( 'boldgrid_available' );
|
79 |
|
87 |
}
|
88 |
|
89 |
// Update the boldgrid_available transient.
|
90 |
+
set_site_transient( 'boldgrid_available', ( int ) $available, 2 * MINUTE_IN_SECONDS );
|
91 |
|
92 |
return $available;
|
93 |
}
|
vendor/boldgrid/library/src/Library/Key.php
CHANGED
@@ -137,9 +137,8 @@ class Key {
|
|
137 |
* @since 1.0.0
|
138 |
*/
|
139 |
public function setNotice() {
|
140 |
-
|
141 |
// If we already have transient data saying the API is not available.
|
142 |
-
if (
|
143 |
return new Notice( 'ConnectionIssue' );
|
144 |
}
|
145 |
|
@@ -234,7 +233,7 @@ class Key {
|
|
234 |
|
235 |
// We can update the available status transient since we know the server was reached.
|
236 |
// @todo move this into the Call class since it's the earliest point of access.
|
237 |
-
set_site_transient( 'boldgrid_available', 1,
|
238 |
|
239 |
// We update transient with the response of the API check version call.
|
240 |
set_site_transient( 'boldgrid_api_data', $data, 8 * HOUR_IN_SECONDS );
|
137 |
* @since 1.0.0
|
138 |
*/
|
139 |
public function setNotice() {
|
|
|
140 |
// If we already have transient data saying the API is not available.
|
141 |
+
if ( 0 === get_site_transient( 'boldgrid_available' ) ) {
|
142 |
return new Notice( 'ConnectionIssue' );
|
143 |
}
|
144 |
|
233 |
|
234 |
// We can update the available status transient since we know the server was reached.
|
235 |
// @todo move this into the Call class since it's the earliest point of access.
|
236 |
+
set_site_transient( 'boldgrid_available', 1, 2 * MINUTE_IN_SECONDS );
|
237 |
|
238 |
// We update transient with the response of the API check version call.
|
239 |
set_site_transient( 'boldgrid_api_data', $data, 8 * HOUR_IN_SECONDS );
|
vendor/boldgrid/library/src/Library/License.php
CHANGED
@@ -61,7 +61,7 @@ class License {
|
|
61 |
* @hook: wp_ajax_bg_clear_license
|
62 |
*/
|
63 |
public function ajaxClear() {
|
64 |
-
$plugin = ! empty( $_POST['plugin'] ) ? $_POST['plugin'] : null;
|
65 |
if( empty( $plugin ) ) {
|
66 |
wp_send_json_error( __( 'Unknown plugin.' ) );
|
67 |
}
|
61 |
* @hook: wp_ajax_bg_clear_license
|
62 |
*/
|
63 |
public function ajaxClear() {
|
64 |
+
$plugin = ! empty( $_POST['plugin'] ) ? sanitize_text_field( $_POST['plugin'] ) : null;
|
65 |
if( empty( $plugin ) ) {
|
66 |
wp_send_json_error( __( 'Unknown plugin.' ) );
|
67 |
}
|
vendor/boldgrid/library/src/Library/Notice/ClaimPremiumKey.php
CHANGED
@@ -112,11 +112,17 @@ class ClaimPremiumKey {
|
|
112 |
$hasConnectKey = (bool) Library\Configs::get( 'key' );
|
113 |
|
114 |
if ( $enabled && $hasConnectKey ) {
|
|
|
|
|
115 |
// If user has dismissed the notice, then do not display the notice.
|
116 |
$display = ! Library\Notice::isDismissed( $this->userNoticeKey );
|
117 |
|
118 |
// Do not display if user has an Envato-connected Prime theme.
|
119 |
-
$
|
|
|
|
|
|
|
|
|
120 |
|
121 |
if ( $hasEnvatoPrime ) {
|
122 |
$display = false;
|
112 |
$hasConnectKey = (bool) Library\Configs::get( 'key' );
|
113 |
|
114 |
if ( $enabled && $hasConnectKey ) {
|
115 |
+
$hasEnvatoPrime = false;
|
116 |
+
|
117 |
// If user has dismissed the notice, then do not display the notice.
|
118 |
$display = ! Library\Notice::isDismissed( $this->userNoticeKey );
|
119 |
|
120 |
// Do not display if user has an Envato-connected Prime theme.
|
121 |
+
$licenseData = $this->key->getLicense();
|
122 |
+
|
123 |
+
if ( $licenseData ) {
|
124 |
+
$hasEnvatoPrime = $licenseData->isPremium( 'envato-prime' );
|
125 |
+
}
|
126 |
|
127 |
if ( $hasEnvatoPrime ) {
|
128 |
$display = false;
|
vendor/boldgrid/library/src/Library/Notice/KeyPrompt.php
CHANGED
@@ -197,7 +197,7 @@ class KeyPrompt {
|
|
197 |
}
|
198 |
|
199 |
// Validate key.
|
200 |
-
$valid = new Library\Key\Validate( $_POST['api_key'] );
|
201 |
if ( ! $valid->getValid() ) {
|
202 |
wp_send_json_error( array( 'message' => $msg->error ) );
|
203 |
}
|
197 |
}
|
198 |
|
199 |
// Validate key.
|
200 |
+
$valid = new Library\Key\Validate( sanitize_text_field( $_POST['api_key'] ) );
|
201 |
if ( ! $valid->getValid() ) {
|
202 |
wp_send_json_error( array( 'message' => $msg->error ) );
|
203 |
}
|
vendor/boldgrid/library/src/Library/Views/KeyPrompt.php
CHANGED
@@ -80,15 +80,15 @@ if ( $enableClaimMessage ) {
|
|
80 |
<label>
|
81 |
<?php esc_html_e( 'First Name', 'boldgrid-inspirations' ); ?>:
|
82 |
</label>
|
83 |
-
<input type="text" id="firstName" maxlength="50" placeholder="<?php esc_html_e( 'First Name', 'boldgrid-inspirations' ); ?>" value="<?php echo $first_name; ?>" />
|
84 |
<label>
|
85 |
<?php esc_html_e( 'Last Name', 'boldgrid-inspirations' ); ?>:
|
86 |
</label>
|
87 |
-
<input type="text" id="lastName" maxlength="50" placeholder="<?php esc_html_e( 'Last Name', 'boldgrid-inspirations' ); ?>" value="<?php echo $last_name; ?>" />
|
88 |
<label>
|
89 |
<?php esc_html_e( 'E-mail', 'boldgrid-inspirations' ); ?>:
|
90 |
</label>
|
91 |
-
<input type="text" id="emailAddr" maxlength="50" placeholder="your@name.com" value="<?php echo $email; ?>" />
|
92 |
<br />
|
93 |
<input type="hidden" id="siteUrl" value="<?php echo get_admin_url(); ?>" />
|
94 |
<br />
|
@@ -96,7 +96,7 @@ if ( $enableClaimMessage ) {
|
|
96 |
<?php esc_html_e( 'Submit', 'boldgrid-inspirations' ); ?>
|
97 |
</button>
|
98 |
<span class="spinner"></span>
|
99 |
-
<input type="hidden" id="generate-api-key" value="<?php echo $api ?>" />
|
100 |
</form>
|
101 |
</div>
|
102 |
</div>
|
80 |
<label>
|
81 |
<?php esc_html_e( 'First Name', 'boldgrid-inspirations' ); ?>:
|
82 |
</label>
|
83 |
+
<input type="text" id="firstName" maxlength="50" placeholder="<?php esc_html_e( 'First Name', 'boldgrid-inspirations' ); ?>" value="<?php echo esc_attr( $first_name ); ?>" />
|
84 |
<label>
|
85 |
<?php esc_html_e( 'Last Name', 'boldgrid-inspirations' ); ?>:
|
86 |
</label>
|
87 |
+
<input type="text" id="lastName" maxlength="50" placeholder="<?php esc_html_e( 'Last Name', 'boldgrid-inspirations' ); ?>" value="<?php echo esc_attr( $last_name ); ?>" />
|
88 |
<label>
|
89 |
<?php esc_html_e( 'E-mail', 'boldgrid-inspirations' ); ?>:
|
90 |
</label>
|
91 |
+
<input type="text" id="emailAddr" maxlength="50" placeholder="your@name.com" value="<?php echo esc_attr( $email ); ?>" />
|
92 |
<br />
|
93 |
<input type="hidden" id="siteUrl" value="<?php echo get_admin_url(); ?>" />
|
94 |
<br />
|
96 |
<?php esc_html_e( 'Submit', 'boldgrid-inspirations' ); ?>
|
97 |
</button>
|
98 |
<span class="spinner"></span>
|
99 |
+
<input type="hidden" id="generate-api-key" value="<?php echo esc_attr( $api ); ?>" />
|
100 |
</form>
|
101 |
</div>
|
102 |
</div>
|
vendor/boldgrid/library/src/library.global.php
CHANGED
@@ -34,11 +34,6 @@ return array(
|
|
34 |
'file' => 'boldgrid-inspirations/boldgrid-inspirations.php',
|
35 |
'priority' => 20,
|
36 |
),
|
37 |
-
'boldgrid-backup' => array(
|
38 |
-
'key' => 'backup',
|
39 |
-
'file' => 'boldgrid-backup/boldgrid-backup.php',
|
40 |
-
'priority' => 40,
|
41 |
-
),
|
42 |
'boldgrid-staging' => array(
|
43 |
'key' => 'staging',
|
44 |
'file' => 'boldgrid-staging/boldgrid-staging.php',
|
@@ -68,6 +63,11 @@ return array(
|
|
68 |
'link' => '//wordpress.org/plugins/boldgrid-easy-seo/',
|
69 |
'priority' => 30,
|
70 |
),
|
|
|
|
|
|
|
|
|
|
|
71 |
'wpforms-lite' => array(
|
72 |
'slug' => 'wpforms-lite',
|
73 |
'link' => '//wpforms.com/lite-upgrade/',
|
34 |
'file' => 'boldgrid-inspirations/boldgrid-inspirations.php',
|
35 |
'priority' => 20,
|
36 |
),
|
|
|
|
|
|
|
|
|
|
|
37 |
'boldgrid-staging' => array(
|
38 |
'key' => 'staging',
|
39 |
'file' => 'boldgrid-staging/boldgrid-staging.php',
|
63 |
'link' => '//wordpress.org/plugins/boldgrid-easy-seo/',
|
64 |
'priority' => 30,
|
65 |
),
|
66 |
+
'boldgrid-backup' => array(
|
67 |
+
'slug' => 'boldgrid-backup',
|
68 |
+
'link' => '//wordpress.org/plugins/boldgrid-backup/',
|
69 |
+
'priority' => 40,
|
70 |
+
),
|
71 |
'wpforms-lite' => array(
|
72 |
'slug' => 'wpforms-lite',
|
73 |
'link' => '//wpforms.com/lite-upgrade/',
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit3e84638393c3ae1a1355713a4a501090
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
-
call_user_func(\Composer\Autoload\
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
@@ -48,19 +48,19 @@ class ComposerAutoloaderInit3e84638393c3ae1a1355713a4a501090
|
|
48 |
$loader->register(true);
|
49 |
|
50 |
if ($useStaticLoader) {
|
51 |
-
$includeFiles = Composer\Autoload\
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
-
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
-
function
|
64 |
{
|
65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
require $file;
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInit2d055860d5c15ffa34614718a8387474
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInit2d055860d5c15ffa34614718a8387474', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit2d055860d5c15ffa34614718a8387474', 'loadClassLoader'));
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
+
call_user_func(\Composer\Autoload\ComposerStaticInit2d055860d5c15ffa34614718a8387474::getInitializer($loader));
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
48 |
$loader->register(true);
|
49 |
|
50 |
if ($useStaticLoader) {
|
51 |
+
$includeFiles = Composer\Autoload\ComposerStaticInit2d055860d5c15ffa34614718a8387474::$files;
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
+
composerRequire2d055860d5c15ffa34614718a8387474($fileIdentifier, $file);
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
+
function composerRequire2d055860d5c15ffa34614718a8387474($fileIdentifier, $file)
|
64 |
{
|
65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
require $file;
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'f15d016d70663d5e96ccd2b863511eb8' => __DIR__ . '/..' . '/cbschuld/browser.php/lib/Browser.php',
|
@@ -44,8 +44,8 @@ class ComposerStaticInit3e84638393c3ae1a1355713a4a501090
|
|
44 |
public static function getInitializer(ClassLoader $loader)
|
45 |
{
|
46 |
return \Closure::bind(function () use ($loader) {
|
47 |
-
$loader->prefixLengthsPsr4 =
|
48 |
-
$loader->prefixDirsPsr4 =
|
49 |
|
50 |
}, null, ClassLoader::class);
|
51 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInit2d055860d5c15ffa34614718a8387474
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'f15d016d70663d5e96ccd2b863511eb8' => __DIR__ . '/..' . '/cbschuld/browser.php/lib/Browser.php',
|
44 |
public static function getInitializer(ClassLoader $loader)
|
45 |
{
|
46 |
return \Closure::bind(function () use ($loader) {
|
47 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInit2d055860d5c15ffa34614718a8387474::$prefixLengthsPsr4;
|
48 |
+
$loader->prefixDirsPsr4 = ComposerStaticInit2d055860d5c15ffa34614718a8387474::$prefixDirsPsr4;
|
49 |
|
50 |
}, null, ClassLoader::class);
|
51 |
}
|
vendor/composer/installed.json
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
[
|
2 |
{
|
3 |
"name": "boldgrid/library",
|
4 |
-
"version": "2.3.
|
5 |
-
"version_normalized": "2.3.
|
6 |
"source": {
|
7 |
"type": "git",
|
8 |
"url": "https://github.com/BoldGrid/library.git",
|
9 |
-
"reference": "
|
10 |
},
|
11 |
"dist": {
|
12 |
"type": "zip",
|
13 |
-
"url": "https://api.github.com/repos/BoldGrid/library/zipball/
|
14 |
-
"reference": "
|
15 |
"shasum": ""
|
16 |
},
|
17 |
-
"time": "2018-
|
18 |
"type": "library",
|
19 |
"installation-source": "dist",
|
20 |
"autoload": {
|
@@ -99,17 +99,17 @@
|
|
99 |
},
|
100 |
{
|
101 |
"name": "ifsnop/mysqldump-php",
|
102 |
-
"version": "v2.
|
103 |
-
"version_normalized": "2.
|
104 |
"source": {
|
105 |
"type": "git",
|
106 |
"url": "https://github.com/ifsnop/mysqldump-php.git",
|
107 |
-
"reference": "
|
108 |
},
|
109 |
"dist": {
|
110 |
"type": "zip",
|
111 |
-
"url": "https://api.github.com/repos/ifsnop/mysqldump-php/zipball/
|
112 |
-
"reference": "
|
113 |
"shasum": ""
|
114 |
},
|
115 |
"require": {
|
@@ -119,7 +119,7 @@
|
|
119 |
"phpunit/phpunit": "3.7.*",
|
120 |
"squizlabs/php_codesniffer": "1.*"
|
121 |
},
|
122 |
-
"time": "2018-
|
123 |
"type": "library",
|
124 |
"installation-source": "dist",
|
125 |
"autoload": {
|
1 |
[
|
2 |
{
|
3 |
"name": "boldgrid/library",
|
4 |
+
"version": "2.3.6",
|
5 |
+
"version_normalized": "2.3.6.0",
|
6 |
"source": {
|
7 |
"type": "git",
|
8 |
"url": "https://github.com/BoldGrid/library.git",
|
9 |
+
"reference": "8d8519c848722afa9a872984cceca8bf587916f0"
|
10 |
},
|
11 |
"dist": {
|
12 |
"type": "zip",
|
13 |
+
"url": "https://api.github.com/repos/BoldGrid/library/zipball/8d8519c848722afa9a872984cceca8bf587916f0",
|
14 |
+
"reference": "8d8519c848722afa9a872984cceca8bf587916f0",
|
15 |
"shasum": ""
|
16 |
},
|
17 |
+
"time": "2018-06-26T13:55:05+00:00",
|
18 |
"type": "library",
|
19 |
"installation-source": "dist",
|
20 |
"autoload": {
|
99 |
},
|
100 |
{
|
101 |
"name": "ifsnop/mysqldump-php",
|
102 |
+
"version": "v2.5",
|
103 |
+
"version_normalized": "2.5.0.0",
|
104 |
"source": {
|
105 |
"type": "git",
|
106 |
"url": "https://github.com/ifsnop/mysqldump-php.git",
|
107 |
+
"reference": "8d063449981e3f7bd28a3a083842e21a24d1f4af"
|
108 |
},
|
109 |
"dist": {
|
110 |
"type": "zip",
|
111 |
+
"url": "https://api.github.com/repos/ifsnop/mysqldump-php/zipball/8d063449981e3f7bd28a3a083842e21a24d1f4af",
|
112 |
+
"reference": "8d063449981e3f7bd28a3a083842e21a24d1f4af",
|
113 |
"shasum": ""
|
114 |
},
|
115 |
"require": {
|
119 |
"phpunit/phpunit": "3.7.*",
|
120 |
"squizlabs/php_codesniffer": "1.*"
|
121 |
},
|
122 |
+
"time": "2018-06-30T19:40:05+00:00",
|
123 |
"type": "library",
|
124 |
"installation-source": "dist",
|
125 |
"autoload": {
|
vendor/ifsnop/mysqldump-php/.scrutinizer.yml
CHANGED
@@ -1,43 +1,135 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
tools:
|
11 |
-
php_mess_detector:
|
12 |
-
enabled: true
|
13 |
-
config:
|
14 |
-
controversial_rules:
|
15 |
-
camel_case_method_name: false
|
16 |
-
|
17 |
-
sensiolabs_security_checker: true
|
18 |
-
|
19 |
-
# Analyzes the size and structure of a PHP project.
|
20 |
-
php_pdepend: true
|
21 |
php_loc:
|
22 |
enabled: true
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
build:
|
2 |
+
nodes:
|
3 |
+
tests: true
|
4 |
+
analysis:
|
5 |
+
tests:
|
6 |
+
override:
|
7 |
+
-
|
8 |
+
command: phpcs-run
|
9 |
+
use_website_config: true
|
10 |
+
- php-scrutinizer-run
|
11 |
+
dependencies:
|
12 |
+
before:
|
13 |
+
- 'composer install --dev --prefer-source'
|
14 |
+
# Run after dependencies
|
15 |
+
project_setup:
|
16 |
+
before:
|
17 |
+
- 'tests/create_users.sh'
|
18 |
+
environment:
|
19 |
+
php:
|
20 |
+
version: 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, hhvm, nightly
|
21 |
tools:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
php_loc:
|
23 |
enabled: true
|
24 |
+
command: phploc
|
25 |
+
excluded_dirs:
|
26 |
+
- vendor
|
27 |
+
- tests
|
28 |
+
sensiolabs_security_checker: true
|
29 |
+
filter:
|
30 |
+
excluded_paths:
|
31 |
+
- 'vendor/'
|
32 |
+
- 'tests/'
|
33 |
+
coding_style:
|
34 |
+
php: { }
|
35 |
+
imports:
|
36 |
+
- php
|
37 |
+
checks:
|
38 |
+
php:
|
39 |
+
verify_property_names: true
|
40 |
+
verify_argument_usable_as_reference: true
|
41 |
+
verify_access_scope_valid: true
|
42 |
+
variable_existence: true
|
43 |
+
useless_calls: true
|
44 |
+
use_statement_alias_conflict: true
|
45 |
+
unused_variables: true
|
46 |
+
unused_properties: true
|
47 |
+
unused_parameters: true
|
48 |
+
unused_methods: true
|
49 |
+
unreachable_code: true
|
50 |
+
too_many_arguments: true
|
51 |
+
symfony_request_injection: true
|
52 |
+
switch_fallthrough_commented: true
|
53 |
+
sql_injection_vulnerabilities: true
|
54 |
+
security_vulnerabilities: true
|
55 |
+
return_in_constructor: true
|
56 |
+
require_scope_for_methods: true
|
57 |
+
require_php_tag_first: true
|
58 |
+
property_assignments: true
|
59 |
+
precedence_mistakes: true
|
60 |
+
precedence_in_conditions: true
|
61 |
+
parse_doc_comments: true
|
62 |
+
parameter_non_unique: true
|
63 |
+
overriding_private_members: true
|
64 |
+
overriding_parameter: true
|
65 |
+
non_commented_empty_catch_block: true
|
66 |
+
no_trait_type_hints: true
|
67 |
+
no_trailing_whitespace: true
|
68 |
+
no_short_open_tag: true
|
69 |
+
no_property_on_interface: true
|
70 |
+
no_non_implemented_abstract_methods: true
|
71 |
+
no_exit: true
|
72 |
+
no_eval: true
|
73 |
+
no_error_suppression: true
|
74 |
+
no_debug_code: true
|
75 |
+
missing_arguments: true
|
76 |
+
method_calls_on_non_object: true
|
77 |
+
instanceof_class_exists: true
|
78 |
+
foreach_usable_as_reference: true
|
79 |
+
foreach_traversable: true
|
80 |
+
fix_doc_comments: true
|
81 |
+
encourage_shallow_comparison: true
|
82 |
+
duplication: true
|
83 |
+
deprecated_code_usage: true
|
84 |
+
deadlock_detection_in_loops: true
|
85 |
+
comparison_always_same_result: true
|
86 |
+
code_rating: true
|
87 |
+
closure_use_not_conflicting: true
|
88 |
+
closure_use_modifiable: true
|
89 |
+
catch_class_exists: true
|
90 |
+
call_to_parent_method: true
|
91 |
+
avoid_superglobals: true
|
92 |
+
avoid_length_functions_in_loops: true
|
93 |
+
avoid_entity_manager_injection: true
|
94 |
+
avoid_duplicate_types: true
|
95 |
+
avoid_closing_tag: true
|
96 |
+
assignment_of_null_return: true
|
97 |
+
argument_type_checks: true
|
98 |
+
simplify_boolean_return: true
|
99 |
+
return_doc_comments: true
|
100 |
+
return_doc_comment_if_not_inferrable: true
|
101 |
+
remove_extra_empty_lines: true
|
102 |
+
properties_in_camelcaps: true
|
103 |
+
parameters_in_camelcaps: true
|
104 |
+
parameter_doc_comments: true
|
105 |
+
param_doc_comment_if_not_inferrable: true
|
106 |
+
no_short_variable_names:
|
107 |
+
minimum: '3'
|
108 |
+
no_short_method_names:
|
109 |
+
minimum: '3'
|
110 |
+
no_long_variable_names:
|
111 |
+
maximum: '20'
|
112 |
+
no_goto: true
|
113 |
+
naming_conventions:
|
114 |
+
local_variable: '^[a-z][a-zA-Z0-9]*$'
|
115 |
+
abstract_class_name: ^Abstract|Factory$
|
116 |
+
utility_class_name: 'Utils?$'
|
117 |
+
constant_name: '^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$'
|
118 |
+
property_name: '^[a-z][a-zA-Z0-9]*$'
|
119 |
+
method_name: '^(?:[a-z]|__)[a-zA-Z0-9]*$'
|
120 |
+
parameter_name: '^[a-z][a-zA-Z0-9]*$'
|
121 |
+
interface_name: '^[A-Z][a-zA-Z0-9]*Interface$'
|
122 |
+
type_name: '^[A-Z][a-zA-Z0-9]*$'
|
123 |
+
exception_name: '^[A-Z][a-zA-Z0-9]*Exception$'
|
124 |
+
isser_method_name: '^(?:is|has|should|may|supports)'
|
125 |
+
more_specific_types_in_doc_comments: true
|
126 |
+
fix_use_statements:
|
127 |
+
remove_unused: true
|
128 |
+
preserve_multiple: false
|
129 |
+
preserve_blanklines: false
|
130 |
+
order_alphabetically: false
|
131 |
+
fix_line_ending: true
|
132 |
+
check_method_contracts:
|
133 |
+
verify_interface_like_constraints: true
|
134 |
+
verify_documented_constraints: true
|
135 |
+
verify_parent_constraints: true
|
vendor/ifsnop/mysqldump-php/README.md
CHANGED
@@ -27,6 +27,7 @@ MySQLDump-PHP is the only library that supports:
|
|
27 |
* dumps events.
|
28 |
* does extended-insert and/or complete-insert.
|
29 |
* supports virtual columns from MySQL 5.7.
|
|
|
30 |
|
31 |
## Important
|
32 |
|
@@ -128,6 +129,7 @@ $dumpSettingsDefault = array(
|
|
128 |
'extended-insert' => true,
|
129 |
'events' => false,
|
130 |
'hex-blob' => true, /* faster than escaped content */
|
|
|
131 |
'net_buffer_length' => self::MAXLINESIZE,
|
132 |
'no-autocommit' => true,
|
133 |
'no-create-info' => false,
|
@@ -192,6 +194,8 @@ $this->_dumpSettings = self::array_replace_recursive($dumpSettingsDefault, $dump
|
|
192 |
- http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_extended-insert
|
193 |
- **hex-blob**
|
194 |
- http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_hex-blob
|
|
|
|
|
195 |
- **lock-tables**
|
196 |
- http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_lock-tables
|
197 |
- **net_buffer_length**
|
27 |
* dumps events.
|
28 |
* does extended-insert and/or complete-insert.
|
29 |
* supports virtual columns from MySQL 5.7.
|
30 |
+
* does insert-ignore, like a REPLACE but ignoring errors if a duplicate key exists.
|
31 |
|
32 |
## Important
|
33 |
|
129 |
'extended-insert' => true,
|
130 |
'events' => false,
|
131 |
'hex-blob' => true, /* faster than escaped content */
|
132 |
+
'insert-ignore' => false,
|
133 |
'net_buffer_length' => self::MAXLINESIZE,
|
134 |
'no-autocommit' => true,
|
135 |
'no-create-info' => false,
|
194 |
- http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_extended-insert
|
195 |
- **hex-blob**
|
196 |
- http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_hex-blob
|
197 |
+
- **insert-ignore**
|
198 |
+
- https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#option_mysqldump_insert-ignore
|
199 |
- **lock-tables**
|
200 |
- http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_lock-tables
|
201 |
- **net_buffer_length**
|
vendor/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php
CHANGED
@@ -47,24 +47,24 @@ class Mysqldump
|
|
47 |
const UTF8MB4 = 'utf8mb4';
|
48 |
|
49 |
/**
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
public $user;
|
54 |
/**
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
public $pass;
|
59 |
/**
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
public $dsn;
|
64 |
/**
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
public $fileName = 'php://output';
|
69 |
|
70 |
// Internal stuff
|
@@ -74,7 +74,7 @@ class Mysqldump
|
|
74 |
private $procedures = array();
|
75 |
private $events = array();
|
76 |
private $dbHandler = null;
|
77 |
-
private $dbType;
|
78 |
private $compressManager;
|
79 |
private $typeAdapter;
|
80 |
private $dumpSettings = array();
|
@@ -82,19 +82,19 @@ class Mysqldump
|
|
82 |
private $version;
|
83 |
private $tableColumnTypes = array();
|
84 |
/**
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
private $dbName;
|
89 |
/**
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
private $host;
|
94 |
/**
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
private $dsnArray = array();
|
99 |
|
100 |
/**
|
@@ -132,6 +132,7 @@ class Mysqldump
|
|
132 |
'extended-insert' => true,
|
133 |
'events' => false,
|
134 |
'hex-blob' => true, /* faster than escaped content */
|
|
|
135 |
'net_buffer_length' => self::MAXLINESIZE,
|
136 |
'no-autocommit' => true,
|
137 |
'no-create-info' => false,
|
@@ -151,28 +152,32 @@ class Mysqldump
|
|
151 |
$pdoSettingsDefault = array(
|
152 |
PDO::ATTR_PERSISTENT => true,
|
153 |
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
154 |
-
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false
|
155 |
);
|
156 |
|
157 |
$this->user = $user;
|
158 |
$this->pass = $pass;
|
159 |
$this->parseDsn($dsn);
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
$this->pdoSettings = self::array_replace_recursive($pdoSettingsDefault, $pdoSettings);
|
161 |
$this->dumpSettings = self::array_replace_recursive($dumpSettingsDefault, $dumpSettings);
|
162 |
-
|
163 |
-
$this->dumpSettings['init_commands'][] = "SET NAMES " . $this->dumpSettings['default-character-set'];
|
164 |
|
165 |
if (false === $this->dumpSettings['skip-tz-utc']) {
|
166 |
$this->dumpSettings['init_commands'][] = "SET TIME_ZONE='+00:00'";
|
167 |
}
|
168 |
|
169 |
$diff = array_diff(array_keys($this->dumpSettings), array_keys($dumpSettingsDefault));
|
170 |
-
if (count($diff)>0) {
|
171 |
-
throw new Exception("Unexpected value in dumpSettings: ("
|
172 |
}
|
173 |
|
174 |
-
if (
|
175 |
-
!is_array($this->dumpSettings['exclude-tables'])
|
176 |
throw new Exception("Include-tables and exclude-tables should be arrays");
|
177 |
}
|
178 |
|
@@ -233,7 +238,7 @@ class Mysqldump
|
|
233 |
}
|
234 |
|
235 |
$this->dsn = $dsn;
|
236 |
-
$this->dbType = strtolower(substr($dsn, 0, $pos));
|
237 |
|
238 |
if (empty($this->dbType)) {
|
239 |
throw new Exception("Missing database type from DSN string");
|
@@ -241,7 +246,7 @@ class Mysqldump
|
|
241 |
|
242 |
$dsn = substr($dsn, $pos + 1);
|
243 |
|
244 |
-
foreach(explode(";", $dsn) as $kvp) {
|
245 |
$kvpArr = explode("=", $kvp);
|
246 |
$this->dsnArray[strtolower($kvpArr[0])] = $kvpArr[1];
|
247 |
}
|
@@ -251,8 +256,7 @@ class Mysqldump
|
|
251 |
throw new Exception("Missing host from DSN string");
|
252 |
}
|
253 |
$this->host = (!empty($this->dsnArray['host'])) ?
|
254 |
-
$this->dsnArray['host'] :
|
255 |
-
$this->dsnArray['unix_socket'];
|
256 |
|
257 |
if (empty($this->dsnArray['dbname'])) {
|
258 |
throw new Exception("Missing database name from DSN string");
|
@@ -274,7 +278,7 @@ class Mysqldump
|
|
274 |
try {
|
275 |
switch ($this->dbType) {
|
276 |
case 'sqlite':
|
277 |
-
$this->dbHandler = @new PDO("sqlite:"
|
278 |
break;
|
279 |
case 'mysql':
|
280 |
case 'pgsql':
|
@@ -286,24 +290,24 @@ class Mysqldump
|
|
286 |
$this->pdoSettings
|
287 |
);
|
288 |
// Execute init commands once connected
|
289 |
-
foreach($this->dumpSettings['init_commands'] as $stmt) {
|
290 |
$this->dbHandler->exec($stmt);
|
291 |
}
|
292 |
// Store server version
|
293 |
$this->version = $this->dbHandler->getAttribute(PDO::ATTR_SERVER_VERSION);
|
294 |
break;
|
295 |
default:
|
296 |
-
throw new Exception("Unsupported database type ("
|
297 |
}
|
298 |
} catch (PDOException $e) {
|
299 |
throw new Exception(
|
300 |
-
"Connection to "
|
301 |
$e->getMessage()
|
302 |
);
|
303 |
}
|
304 |
|
305 |
-
if (
|
306 |
-
throw new Exception("Connection to "
|
307 |
}
|
308 |
|
309 |
$this->dbHandler->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_NATURAL);
|
@@ -363,7 +367,7 @@ class Mysqldump
|
|
363 |
// This check will be removed once include-tables supports regexps
|
364 |
if (0 < count($this->dumpSettings['include-tables'])) {
|
365 |
$name = implode(",", $this->dumpSettings['include-tables']);
|
366 |
-
throw new Exception("Table ("
|
367 |
}
|
368 |
|
369 |
$this->exportTables();
|
@@ -390,19 +394,19 @@ class Mysqldump
|
|
390 |
private function getDumpFileHeader()
|
391 |
{
|
392 |
$header = '';
|
393 |
-
if (
|
394 |
// Some info about software, source and time
|
395 |
-
$header = "-- mysqldump-php https://github.com/ifsnop/mysqldump-php"
|
396 |
-
"--"
|
397 |
-
"-- Host: {$this->host}\tDatabase: {$this->dbName}"
|
398 |
-
"-- ------------------------------------------------------"
|
399 |
|
400 |
-
if (
|
401 |
-
$header .= "-- Server version \t"
|
402 |
}
|
403 |
|
404 |
-
if (
|
405 |
-
$header .= "-- Date: "
|
406 |
}
|
407 |
}
|
408 |
return $header;
|
@@ -419,7 +423,7 @@ class Mysqldump
|
|
419 |
if (!$this->dumpSettings['skip-comments']) {
|
420 |
$footer .= '-- Dump completed';
|
421 |
if (!$this->dumpSettings['skip-dump-date']) {
|
422 |
-
$footer .= ' on: '
|
423 |
}
|
424 |
$footer .= PHP_EOL;
|
425 |
}
|
@@ -507,10 +511,10 @@ class Mysqldump
|
|
507 |
$match = false;
|
508 |
|
509 |
foreach ($arr as $pattern) {
|
510 |
-
if (
|
511 |
continue;
|
512 |
}
|
513 |
-
if (
|
514 |
$match = true;
|
515 |
}
|
516 |
}
|
@@ -527,14 +531,14 @@ class Mysqldump
|
|
527 |
{
|
528 |
// Exporting tables one by one
|
529 |
foreach ($this->tables as $table) {
|
530 |
-
if (
|
531 |
continue;
|
532 |
}
|
533 |
$this->getTableStructure($table);
|
534 |
-
if (
|
535 |
$this->listValues($table);
|
536 |
-
} else if (
|
537 |
-
|| $this->matches($table, $this->dumpSettings['no-data'])
|
538 |
continue;
|
539 |
} else {
|
540 |
$this->listValues($table);
|
@@ -552,14 +556,14 @@ class Mysqldump
|
|
552 |
if (false === $this->dumpSettings['no-create-info']) {
|
553 |
// Exporting views one by one
|
554 |
foreach ($this->views as $view) {
|
555 |
-
if (
|
556 |
continue;
|
557 |
}
|
558 |
$this->tableColumnTypes[$view] = $this->getTableColumnTypes($view);
|
559 |
$this->getViewStructureTable($view);
|
560 |
}
|
561 |
foreach ($this->views as $view) {
|
562 |
-
if (
|
563 |
continue;
|
564 |
}
|
565 |
$this->getViewStructureView($view);
|
@@ -618,9 +622,9 @@ class Mysqldump
|
|
618 |
if (!$this->dumpSettings['no-create-info']) {
|
619 |
$ret = '';
|
620 |
if (!$this->dumpSettings['skip-comments']) {
|
621 |
-
$ret = "--"
|
622 |
-
"-- Table structure for table `$tableName`"
|
623 |
-
"--"
|
624 |
}
|
625 |
$stmt = $this->typeAdapter->show_create_table($tableName);
|
626 |
foreach ($this->dbHandler->query($stmt) as $r) {
|
@@ -654,7 +658,7 @@ class Mysqldump
|
|
654 |
);
|
655 |
$columns->setFetchMode(PDO::FETCH_ASSOC);
|
656 |
|
657 |
-
foreach($columns as $key => $col) {
|
658 |
$types = $this->typeAdapter->parseColumnType($col);
|
659 |
$columnTypes[$col['Field']] = array(
|
660 |
'is_numeric'=> $types['is_numeric'],
|
@@ -678,9 +682,9 @@ class Mysqldump
|
|
678 |
private function getViewStructureTable($viewName)
|
679 |
{
|
680 |
if (!$this->dumpSettings['skip-comments']) {
|
681 |
-
$ret = "--"
|
682 |
-
"-- Stand-In structure for view `${viewName}`"
|
683 |
-
"--"
|
684 |
$this->compressManager->write($ret);
|
685 |
}
|
686 |
$stmt = $this->typeAdapter->show_create_view($viewName);
|
@@ -709,13 +713,13 @@ class Mysqldump
|
|
709 |
*/
|
710 |
function createStandInTable($viewName) {
|
711 |
$ret = array();
|
712 |
-
foreach($this->tableColumnTypes[$viewName] as $k => $v) {
|
713 |
$ret[] = "`${k}` ${v['type_sql']}";
|
714 |
}
|
715 |
-
$ret = implode(PHP_EOL
|
716 |
|
717 |
-
$ret = "CREATE TABLE IF NOT EXISTS `$viewName` ("
|
718 |
-
PHP_EOL
|
719 |
|
720 |
return $ret;
|
721 |
}
|
@@ -730,9 +734,9 @@ class Mysqldump
|
|
730 |
private function getViewStructureView($viewName)
|
731 |
{
|
732 |
if (!$this->dumpSettings['skip-comments']) {
|
733 |
-
$ret = "--"
|
734 |
-
"-- View structure for view `${viewName}`"
|
735 |
-
"--"
|
736 |
$this->compressManager->write($ret);
|
737 |
}
|
738 |
$stmt = $this->typeAdapter->show_create_view($viewName);
|
@@ -782,9 +786,9 @@ class Mysqldump
|
|
782 |
private function getProcedureStructure($procedureName)
|
783 |
{
|
784 |
if (!$this->dumpSettings['skip-comments']) {
|
785 |
-
$ret = "--"
|
786 |
-
"-- Dumping routines for database '"
|
787 |
-
"--"
|
788 |
$this->compressManager->write($ret);
|
789 |
}
|
790 |
$stmt = $this->typeAdapter->show_create_procedure($procedureName);
|
@@ -805,9 +809,9 @@ class Mysqldump
|
|
805 |
private function getEventStructure($eventName)
|
806 |
{
|
807 |
if (!$this->dumpSettings['skip-comments']) {
|
808 |
-
$ret = "--"
|
809 |
-
"-- Dumping events for database '"
|
810 |
-
"--"
|
811 |
$this->compressManager->write($ret);
|
812 |
}
|
813 |
$stmt = $this->typeAdapter->show_create_event($eventName);
|
@@ -819,6 +823,27 @@ class Mysqldump
|
|
819 |
}
|
820 |
}
|
821 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
822 |
/**
|
823 |
* Escape values with quotes when needed
|
824 |
*
|
@@ -827,26 +852,38 @@ class Mysqldump
|
|
827 |
*
|
828 |
* @return string
|
829 |
*/
|
830 |
-
private function escape($
|
831 |
{
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
if (
|
836 |
-
|
837 |
-
} elseif ($this->dumpSettings['hex-blob'] && $columnTypes[$colName]['is_blob']) {
|
838 |
-
if ($columnTypes[$colName]['type'] == 'bit' || !empty($colValue)) {
|
839 |
-
$ret[] = "0x${colValue}";
|
840 |
-
} else {
|
841 |
-
$ret[] = "''";
|
842 |
-
}
|
843 |
-
} elseif ($columnTypes[$colName]['is_numeric']) {
|
844 |
-
$ret[] = $colValue;
|
845 |
} else {
|
846 |
-
|
847 |
}
|
|
|
|
|
848 |
}
|
849 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
850 |
}
|
851 |
|
852 |
/**
|
@@ -863,8 +900,14 @@ class Mysqldump
|
|
863 |
$onlyOnce = true;
|
864 |
$lineSize = 0;
|
865 |
|
|
|
866 |
$colStmt = $this->getColumnStmt($tableName);
|
867 |
-
|
|
|
|
|
|
|
|
|
|
|
868 |
|
869 |
if ($this->dumpSettings['where']) {
|
870 |
$stmt .= " WHERE {$this->dumpSettings['where']}";
|
@@ -872,35 +915,37 @@ class Mysqldump
|
|
872 |
$resultSet = $this->dbHandler->query($stmt);
|
873 |
$resultSet->setFetchMode(PDO::FETCH_ASSOC);
|
874 |
|
|
|
|
|
875 |
foreach ($resultSet as $row) {
|
876 |
-
$vals = $this->
|
877 |
if ($onlyOnce || !$this->dumpSettings['extended-insert']) {
|
878 |
|
879 |
if ($this->dumpSettings['complete-insert']) {
|
880 |
$lineSize += $this->compressManager->write(
|
881 |
-
"INSERT INTO `$tableName` ("
|
882 |
-
implode(", ", $
|
883 |
-
") VALUES ("
|
884 |
);
|
885 |
} else {
|
886 |
$lineSize += $this->compressManager->write(
|
887 |
-
"INSERT INTO `$tableName` VALUES ("
|
888 |
);
|
889 |
}
|
890 |
$onlyOnce = false;
|
891 |
} else {
|
892 |
-
$lineSize += $this->compressManager->write(",("
|
893 |
}
|
894 |
if (($lineSize > $this->dumpSettings['net_buffer_length']) ||
|
895 |
!$this->dumpSettings['extended-insert']) {
|
896 |
$onlyOnce = true;
|
897 |
-
$lineSize = $this->compressManager->write(";"
|
898 |
}
|
899 |
}
|
900 |
$resultSet->closeCursor();
|
901 |
|
902 |
if (!$onlyOnce) {
|
903 |
-
$this->compressManager->write(";"
|
904 |
}
|
905 |
|
906 |
$this->endListValues($tableName);
|
@@ -917,9 +962,9 @@ class Mysqldump
|
|
917 |
{
|
918 |
if (!$this->dumpSettings['skip-comments']) {
|
919 |
$this->compressManager->write(
|
920 |
-
"--"
|
921 |
-
"-- Dumping data for table `$tableName`"
|
922 |
-
"--"
|
923 |
);
|
924 |
}
|
925 |
|
@@ -996,16 +1041,16 @@ class Mysqldump
|
|
996 |
}
|
997 |
|
998 |
/**
|
999 |
-
* Build SQL List of all columns on current table
|
1000 |
*
|
1001 |
* @param string $tableName Name of table to get columns
|
1002 |
*
|
1003 |
-
* @return
|
1004 |
*/
|
1005 |
function getColumnStmt($tableName)
|
1006 |
{
|
1007 |
$colStmt = array();
|
1008 |
-
foreach($this->tableColumnTypes[$tableName] as $colName => $colType) {
|
1009 |
if ($colType['type'] == 'bit' && $this->dumpSettings['hex-blob']) {
|
1010 |
$colStmt[] = "LPAD(HEX(`${colName}`),2,'0') AS `${colName}`";
|
1011 |
} else if ($colType['is_blob'] && $this->dumpSettings['hex-blob']) {
|
@@ -1020,6 +1065,27 @@ class Mysqldump
|
|
1020 |
|
1021 |
return $colStmt;
|
1022 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1023 |
}
|
1024 |
|
1025 |
/**
|
@@ -1053,11 +1119,11 @@ abstract class CompressManagerFactory
|
|
1053 |
public static function create($c)
|
1054 |
{
|
1055 |
$c = ucfirst(strtolower($c));
|
1056 |
-
if (!
|
1057 |
throw new Exception("Compression method ($c) is not defined yet");
|
1058 |
}
|
1059 |
|
1060 |
-
$method =
|
1061 |
|
1062 |
return new $method;
|
1063 |
}
|
@@ -1069,7 +1135,7 @@ class CompressBzip2 extends CompressManagerFactory
|
|
1069 |
|
1070 |
public function __construct()
|
1071 |
{
|
1072 |
-
if (!
|
1073 |
throw new Exception("Compression is enabled, but bzip2 lib is not installed or configured properly");
|
1074 |
}
|
1075 |
}
|
@@ -1107,7 +1173,7 @@ class CompressGzip extends CompressManagerFactory
|
|
1107 |
|
1108 |
public function __construct()
|
1109 |
{
|
1110 |
-
if (!
|
1111 |
throw new Exception("Compression is enabled, but gzip lib is not installed or configured properly");
|
1112 |
}
|
1113 |
}
|
@@ -1207,10 +1273,10 @@ abstract class TypeAdapterFactory
|
|
1207 |
public static function create($c, $dbHandler = null, $dumpSettings = array())
|
1208 |
{
|
1209 |
$c = ucfirst(strtolower($c));
|
1210 |
-
if (!
|
1211 |
throw new Exception("Database type support for ($c) not yet available");
|
1212 |
}
|
1213 |
-
$method =
|
1214 |
return new $method($dbHandler, $dumpSettings);
|
1215 |
}
|
1216 |
|
@@ -1231,8 +1297,8 @@ abstract class TypeAdapterFactory
|
|
1231 |
|
1232 |
public function show_create_table($tableName)
|
1233 |
{
|
1234 |
-
return "SELECT tbl_name as 'Table', sql as 'Create Table' "
|
1235 |
-
"FROM sqlite_master "
|
1236 |
"WHERE type='table' AND tbl_name='$tableName'";
|
1237 |
}
|
1238 |
|
@@ -1247,8 +1313,8 @@ abstract class TypeAdapterFactory
|
|
1247 |
|
1248 |
public function show_create_view($viewName)
|
1249 |
{
|
1250 |
-
return "SELECT tbl_name as 'View', sql as 'Create View' "
|
1251 |
-
"FROM sqlite_master "
|
1252 |
"WHERE type='view' AND tbl_name='$viewName'";
|
1253 |
}
|
1254 |
|
@@ -1490,9 +1556,9 @@ class TypeAdapterMysql extends TypeAdapterFactory
|
|
1490 |
$ret = "";
|
1491 |
|
1492 |
$ret .= "CREATE DATABASE /*!32312 IF NOT EXISTS*/ `${databaseName}`".
|
1493 |
-
" /*!40100 DEFAULT CHARACTER SET ${characterSet} "
|
1494 |
-
" COLLATE ${collationDb} */;"
|
1495 |
-
"USE `${databaseName}`;"
|
1496 |
|
1497 |
return $ret;
|
1498 |
}
|
@@ -1522,23 +1588,23 @@ class TypeAdapterMysql extends TypeAdapterFactory
|
|
1522 |
return "SHOW CREATE EVENT `$eventName`";
|
1523 |
}
|
1524 |
|
1525 |
-
public function create_table(
|
1526 |
{
|
1527 |
-
if (
|
1528 |
throw new Exception("Error getting table code, unknown output");
|
1529 |
}
|
1530 |
|
1531 |
$createTable = $row['Create Table'];
|
1532 |
-
if (
|
1533 |
$match = "/AUTO_INCREMENT=[0-9]+/s";
|
1534 |
$replace = "";
|
1535 |
$createTable = preg_replace($match, $replace, $createTable);
|
1536 |
}
|
1537 |
|
1538 |
-
$ret = "/*!40101 SET @saved_cs_client = @@character_set_client */;"
|
1539 |
-
"/*!40101 SET character_set_client = "
|
1540 |
-
$createTable
|
1541 |
-
"/*!40101 SET character_set_client = @saved_cs_client */;"
|
1542 |
PHP_EOL;
|
1543 |
return $ret;
|
1544 |
}
|
@@ -1564,7 +1630,7 @@ class TypeAdapterMysql extends TypeAdapterFactory
|
|
1564 |
$viewStmt = $viewStmtReplaced;
|
1565 |
};
|
1566 |
|
1567 |
-
$ret .= $viewStmt
|
1568 |
return $ret;
|
1569 |
}
|
1570 |
|
@@ -1586,9 +1652,9 @@ class TypeAdapterMysql extends TypeAdapterFactory
|
|
1586 |
$triggerStmt = $triggerStmtReplaced;
|
1587 |
}
|
1588 |
|
1589 |
-
$ret .= "DELIMITER ;;"
|
1590 |
-
$triggerStmt
|
1591 |
-
"DELIMITER ;"
|
1592 |
return $ret;
|
1593 |
}
|
1594 |
|
@@ -1596,19 +1662,19 @@ class TypeAdapterMysql extends TypeAdapterFactory
|
|
1596 |
{
|
1597 |
$ret = "";
|
1598 |
if (!isset($row['Create Procedure'])) {
|
1599 |
-
throw new Exception("Error getting procedure code, unknown output. "
|
1600 |
"Please check 'https://bugs.mysql.com/bug.php?id=14564'");
|
1601 |
}
|
1602 |
$procedureStmt = $row['Create Procedure'];
|
1603 |
|
1604 |
-
$ret .= "/*!50003 DROP PROCEDURE IF EXISTS `"
|
1605 |
-
$row['Procedure']
|
1606 |
-
"/*!40101 SET @saved_cs_client = @@character_set_client */;"
|
1607 |
-
"/*!40101 SET character_set_client = "
|
1608 |
-
"DELIMITER ;;"
|
1609 |
-
$procedureStmt
|
1610 |
-
"DELIMITER ;"
|
1611 |
-
"/*!40101 SET character_set_client = @saved_cs_client */;"
|
1612 |
|
1613 |
return $ret;
|
1614 |
}
|
@@ -1616,8 +1682,8 @@ class TypeAdapterMysql extends TypeAdapterFactory
|
|
1616 |
public function create_event($row)
|
1617 |
{
|
1618 |
$ret = "";
|
1619 |
-
if (
|
1620 |
-
throw new Exception("Error getting event code, unknown output. "
|
1621 |
"Please check 'http://stackoverflow.com/questions/10853826/mysql-5-5-create-event-gives-syntax-error'");
|
1622 |
}
|
1623 |
$eventName = $row['Event'];
|
@@ -1634,27 +1700,27 @@ class TypeAdapterMysql extends TypeAdapterFactory
|
|
1634 |
$eventStmt = $eventStmtReplaced;
|
1635 |
}
|
1636 |
|
1637 |
-
$ret .= "/*!50106 SET @save_time_zone= @@TIME_ZONE */ ;"
|
1638 |
-
"/*!50106 DROP EVENT IF EXISTS `"
|
1639 |
-
"DELIMITER ;;"
|
1640 |
-
"/*!50003 SET @saved_cs_client = @@character_set_client */ ;;"
|
1641 |
-
"/*!50003 SET @saved_cs_results = @@character_set_results */ ;;"
|
1642 |
-
"/*!50003 SET @saved_col_connection = @@collation_connection */ ;;"
|
1643 |
-
"/*!50003 SET character_set_client = utf8 */ ;;"
|
1644 |
-
"/*!50003 SET character_set_results = utf8 */ ;;"
|
1645 |
-
"/*!50003 SET collation_connection = utf8_general_ci */ ;;"
|
1646 |
-
"/*!50003 SET @saved_sql_mode = @@sql_mode */ ;;"
|
1647 |
-
"/*!50003 SET sql_mode = '"
|
1648 |
-
"/*!50003 SET @saved_time_zone = @@time_zone */ ;;"
|
1649 |
-
"/*!50003 SET time_zone = 'SYSTEM' */ ;;"
|
1650 |
-
$eventStmt
|
1651 |
-
"/*!50003 SET time_zone = @saved_time_zone */ ;;"
|
1652 |
-
"/*!50003 SET sql_mode = @saved_sql_mode */ ;;"
|
1653 |
-
"/*!50003 SET character_set_client = @saved_cs_client */ ;;"
|
1654 |
-
"/*!50003 SET character_set_results = @saved_cs_results */ ;;"
|
1655 |
-
"/*!50003 SET collation_connection = @saved_col_connection */ ;;"
|
1656 |
-
"DELIMITER ;"
|
1657 |
-
"/*!50106 SET TIME_ZONE= @save_time_zone */ ;"
|
1658 |
// Commented because we are doing this in restore_parameters()
|
1659 |
// "/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;" . PHP_EOL . PHP_EOL;
|
1660 |
|
@@ -1665,8 +1731,8 @@ class TypeAdapterMysql extends TypeAdapterFactory
|
|
1665 |
{
|
1666 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1667 |
$args = func_get_args();
|
1668 |
-
return "SELECT TABLE_NAME AS tbl_name "
|
1669 |
-
"FROM INFORMATION_SCHEMA.TABLES "
|
1670 |
"WHERE TABLE_TYPE='BASE TABLE' AND TABLE_SCHEMA='${args[0]}'";
|
1671 |
}
|
1672 |
|
@@ -1674,8 +1740,8 @@ class TypeAdapterMysql extends TypeAdapterFactory
|
|
1674 |
{
|
1675 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1676 |
$args = func_get_args();
|
1677 |
-
return "SELECT TABLE_NAME AS tbl_name "
|
1678 |
-
"FROM INFORMATION_SCHEMA.TABLES "
|
1679 |
"WHERE TABLE_TYPE='VIEW' AND TABLE_SCHEMA='${args[0]}'";
|
1680 |
}
|
1681 |
|
@@ -1697,8 +1763,8 @@ class TypeAdapterMysql extends TypeAdapterFactory
|
|
1697 |
{
|
1698 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1699 |
$args = func_get_args();
|
1700 |
-
return "SELECT SPECIFIC_NAME AS procedure_name "
|
1701 |
-
"FROM INFORMATION_SCHEMA.ROUTINES "
|
1702 |
"WHERE ROUTINE_TYPE='PROCEDURE' AND ROUTINE_SCHEMA='${args[0]}'";
|
1703 |
}
|
1704 |
|
@@ -1712,8 +1778,8 @@ class TypeAdapterMysql extends TypeAdapterFactory
|
|
1712 |
{
|
1713 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1714 |
$args = func_get_args();
|
1715 |
-
return "SELECT EVENT_NAME AS event_name "
|
1716 |
-
"FROM INFORMATION_SCHEMA.EVENTS "
|
1717 |
"WHERE EVENT_SCHEMA='${args[0]}'";
|
1718 |
}
|
1719 |
|
@@ -1749,19 +1815,19 @@ class TypeAdapterMysql extends TypeAdapterFactory
|
|
1749 |
{
|
1750 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1751 |
$args = func_get_args();
|
1752 |
-
return "LOCK TABLES `${args[0]}` WRITE;"
|
1753 |
}
|
1754 |
|
1755 |
public function end_add_lock_table()
|
1756 |
{
|
1757 |
-
return "UNLOCK TABLES;"
|
1758 |
}
|
1759 |
|
1760 |
public function start_add_disable_keys()
|
1761 |
{
|
1762 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1763 |
$args = func_get_args();
|
1764 |
-
return "/*!40000 ALTER TABLE `${args[0]}` DISABLE KEYS */;"
|
1765 |
PHP_EOL;
|
1766 |
}
|
1767 |
|
@@ -1769,57 +1835,57 @@ class TypeAdapterMysql extends TypeAdapterFactory
|
|
1769 |
{
|
1770 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1771 |
$args = func_get_args();
|
1772 |
-
return "/*!40000 ALTER TABLE `${args[0]}` ENABLE KEYS */;"
|
1773 |
PHP_EOL;
|
1774 |
}
|
1775 |
|
1776 |
public function start_disable_autocommit()
|
1777 |
{
|
1778 |
-
return "SET autocommit=0;"
|
1779 |
}
|
1780 |
|
1781 |
public function end_disable_autocommit()
|
1782 |
{
|
1783 |
-
return "COMMIT;"
|
1784 |
}
|
1785 |
|
1786 |
public function add_drop_database()
|
1787 |
{
|
1788 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1789 |
$args = func_get_args();
|
1790 |
-
return "/*!40000 DROP DATABASE IF EXISTS `${args[0]}`*/;"
|
1791 |
-
PHP_EOL
|
1792 |
}
|
1793 |
|
1794 |
public function add_drop_trigger()
|
1795 |
{
|
1796 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1797 |
$args = func_get_args();
|
1798 |
-
return "DROP TRIGGER IF EXISTS `${args[0]}`;"
|
1799 |
}
|
1800 |
|
1801 |
public function drop_table()
|
1802 |
{
|
1803 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1804 |
$args = func_get_args();
|
1805 |
-
return "DROP TABLE IF EXISTS `${args[0]}`;"
|
1806 |
}
|
1807 |
|
1808 |
public function drop_view()
|
1809 |
{
|
1810 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1811 |
$args = func_get_args();
|
1812 |
-
return "DROP TABLE IF EXISTS `${args[0]}`;"
|
1813 |
-
"/*!50001 DROP VIEW IF EXISTS `${args[0]}`*/;"
|
1814 |
}
|
1815 |
|
1816 |
public function getDatabaseHeader()
|
1817 |
{
|
1818 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1819 |
$args = func_get_args();
|
1820 |
-
return "--"
|
1821 |
-
"-- Current Database: `${args[0]}`"
|
1822 |
-
"--"
|
1823 |
}
|
1824 |
|
1825 |
/**
|
@@ -1834,38 +1900,39 @@ class TypeAdapterMysql extends TypeAdapterFactory
|
|
1834 |
$colInfo = array();
|
1835 |
$colParts = explode(" ", $colType['Type']);
|
1836 |
|
1837 |
-
if($fparen = strpos($colParts[0], "("))
|
1838 |
-
{
|
1839 |
$colInfo['type'] = substr($colParts[0], 0, $fparen);
|
1840 |
-
$colInfo['length']
|
1841 |
$colInfo['attributes'] = isset($colParts[1]) ? $colParts[1] : NULL;
|
1842 |
-
}
|
1843 |
-
else
|
1844 |
-
{
|
1845 |
$colInfo['type'] = $colParts[0];
|
1846 |
}
|
1847 |
$colInfo['is_numeric'] = in_array($colInfo['type'], $this->mysqlTypes['numerical']);
|
1848 |
$colInfo['is_blob'] = in_array($colInfo['type'], $this->mysqlTypes['blob']);
|
1849 |
-
|
|
|
|
|
|
|
|
|
1850 |
return $colInfo;
|
1851 |
}
|
1852 |
|
1853 |
public function backup_parameters()
|
1854 |
{
|
1855 |
-
$ret = "/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;"
|
1856 |
-
"/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;"
|
1857 |
-
"/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;"
|
1858 |
-
"/*!40101 SET NAMES "
|
1859 |
|
1860 |
if (false === $this->dumpSettings['skip-tz-utc']) {
|
1861 |
-
$ret .= "/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;"
|
1862 |
-
"/*!40103 SET TIME_ZONE='+00:00' */;"
|
1863 |
}
|
1864 |
|
1865 |
-
$ret .= "/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;"
|
1866 |
-
"/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;"
|
1867 |
-
"/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;"
|
1868 |
-
"/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;"
|
1869 |
|
1870 |
return $ret;
|
1871 |
}
|
@@ -1875,16 +1942,16 @@ class TypeAdapterMysql extends TypeAdapterFactory
|
|
1875 |
$ret = "";
|
1876 |
|
1877 |
if (false === $this->dumpSettings['skip-tz-utc']) {
|
1878 |
-
$ret .= "/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;"
|
1879 |
}
|
1880 |
|
1881 |
-
$ret .= "/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;"
|
1882 |
-
"/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;"
|
1883 |
-
"/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;"
|
1884 |
-
"/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;"
|
1885 |
-
"/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;"
|
1886 |
-
"/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;"
|
1887 |
-
"/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;"
|
1888 |
|
1889 |
return $ret;
|
1890 |
}
|
@@ -1899,7 +1966,7 @@ class TypeAdapterMysql extends TypeAdapterFactory
|
|
1899 |
*/
|
1900 |
private function check_parameters($num_args, $expected_num_args, $method_name)
|
1901 |
{
|
1902 |
-
if (
|
1903 |
throw new Exception("Unexpected parameter passed to $method_name");
|
1904 |
}
|
1905 |
return;
|
47 |
const UTF8MB4 = 'utf8mb4';
|
48 |
|
49 |
/**
|
50 |
+
* Database username
|
51 |
+
* @var string
|
52 |
+
*/
|
53 |
public $user;
|
54 |
/**
|
55 |
+
* Database password
|
56 |
+
* @var string
|
57 |
+
*/
|
58 |
public $pass;
|
59 |
/**
|
60 |
+
* Connection string for PDO
|
61 |
+
* @var string
|
62 |
+
*/
|
63 |
public $dsn;
|
64 |
/**
|
65 |
+
* Destination filename, defaults to stdout
|
66 |
+
* @var string
|
67 |
+
*/
|
68 |
public $fileName = 'php://output';
|
69 |
|
70 |
// Internal stuff
|
74 |
private $procedures = array();
|
75 |
private $events = array();
|
76 |
private $dbHandler = null;
|
77 |
+
private $dbType = "";
|
78 |
private $compressManager;
|
79 |
private $typeAdapter;
|
80 |
private $dumpSettings = array();
|
82 |
private $version;
|
83 |
private $tableColumnTypes = array();
|
84 |
/**
|
85 |
+
* database name, parsed from dsn
|
86 |
+
* @var string
|
87 |
+
*/
|
88 |
private $dbName;
|
89 |
/**
|
90 |
+
* host name, parsed from dsn
|
91 |
+
* @var string
|
92 |
+
*/
|
93 |
private $host;
|
94 |
/**
|
95 |
+
* dsn string parsed as an array
|
96 |
+
* @var array
|
97 |
+
*/
|
98 |
private $dsnArray = array();
|
99 |
|
100 |
/**
|
132 |
'extended-insert' => true,
|
133 |
'events' => false,
|
134 |
'hex-blob' => true, /* faster than escaped content */
|
135 |
+
'insert-ignore' => false,
|
136 |
'net_buffer_length' => self::MAXLINESIZE,
|
137 |
'no-autocommit' => true,
|
138 |
'no-create-info' => false,
|
152 |
$pdoSettingsDefault = array(
|
153 |
PDO::ATTR_PERSISTENT => true,
|
154 |
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
|
|
155 |
);
|
156 |
|
157 |
$this->user = $user;
|
158 |
$this->pass = $pass;
|
159 |
$this->parseDsn($dsn);
|
160 |
+
|
161 |
+
// this drops MYSQL dependency, only use the constant if it's defined
|
162 |
+
if ("mysql" === $this->dbType) {
|
163 |
+
$pdoSettingsDefault[PDO::MYSQL_ATTR_USE_BUFFERED_QUERY] = false;
|
164 |
+
}
|
165 |
+
|
166 |
$this->pdoSettings = self::array_replace_recursive($pdoSettingsDefault, $pdoSettings);
|
167 |
$this->dumpSettings = self::array_replace_recursive($dumpSettingsDefault, $dumpSettings);
|
168 |
+
$this->dumpSettings['init_commands'][] = "SET NAMES ".$this->dumpSettings['default-character-set'];
|
|
|
169 |
|
170 |
if (false === $this->dumpSettings['skip-tz-utc']) {
|
171 |
$this->dumpSettings['init_commands'][] = "SET TIME_ZONE='+00:00'";
|
172 |
}
|
173 |
|
174 |
$diff = array_diff(array_keys($this->dumpSettings), array_keys($dumpSettingsDefault));
|
175 |
+
if (count($diff) > 0) {
|
176 |
+
throw new Exception("Unexpected value in dumpSettings: (".implode(",", $diff).")");
|
177 |
}
|
178 |
|
179 |
+
if (!is_array($this->dumpSettings['include-tables']) ||
|
180 |
+
!is_array($this->dumpSettings['exclude-tables'])) {
|
181 |
throw new Exception("Include-tables and exclude-tables should be arrays");
|
182 |
}
|
183 |
|
238 |
}
|
239 |
|
240 |
$this->dsn = $dsn;
|
241 |
+
$this->dbType = strtolower(substr($dsn, 0, $pos)); // always returns a string
|
242 |
|
243 |
if (empty($this->dbType)) {
|
244 |
throw new Exception("Missing database type from DSN string");
|
246 |
|
247 |
$dsn = substr($dsn, $pos + 1);
|
248 |
|
249 |
+
foreach (explode(";", $dsn) as $kvp) {
|
250 |
$kvpArr = explode("=", $kvp);
|
251 |
$this->dsnArray[strtolower($kvpArr[0])] = $kvpArr[1];
|
252 |
}
|
256 |
throw new Exception("Missing host from DSN string");
|
257 |
}
|
258 |
$this->host = (!empty($this->dsnArray['host'])) ?
|
259 |
+
$this->dsnArray['host'] : $this->dsnArray['unix_socket'];
|
|
|
260 |
|
261 |
if (empty($this->dsnArray['dbname'])) {
|
262 |
throw new Exception("Missing database name from DSN string");
|
278 |
try {
|
279 |
switch ($this->dbType) {
|
280 |
case 'sqlite':
|
281 |
+
$this->dbHandler = @new PDO("sqlite:".$this->dbName, null, null, $this->pdoSettings);
|
282 |
break;
|
283 |
case 'mysql':
|
284 |
case 'pgsql':
|
290 |
$this->pdoSettings
|
291 |
);
|
292 |
// Execute init commands once connected
|
293 |
+
foreach ($this->dumpSettings['init_commands'] as $stmt) {
|
294 |
$this->dbHandler->exec($stmt);
|
295 |
}
|
296 |
// Store server version
|
297 |
$this->version = $this->dbHandler->getAttribute(PDO::ATTR_SERVER_VERSION);
|
298 |
break;
|
299 |
default:
|
300 |
+
throw new Exception("Unsupported database type (".$this->dbType.")");
|
301 |
}
|
302 |
} catch (PDOException $e) {
|
303 |
throw new Exception(
|
304 |
+
"Connection to ".$this->dbType." failed with message: ".
|
305 |
$e->getMessage()
|
306 |
);
|
307 |
}
|
308 |
|
309 |
+
if (is_null($this->dbHandler)) {
|
310 |
+
throw new Exception("Connection to ".$this->dbType."failed");
|
311 |
}
|
312 |
|
313 |
$this->dbHandler->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_NATURAL);
|
367 |
// This check will be removed once include-tables supports regexps
|
368 |
if (0 < count($this->dumpSettings['include-tables'])) {
|
369 |
$name = implode(",", $this->dumpSettings['include-tables']);
|
370 |
+
throw new Exception("Table (".$name.") not found in database");
|
371 |
}
|
372 |
|
373 |
$this->exportTables();
|
394 |
private function getDumpFileHeader()
|
395 |
{
|
396 |
$header = '';
|
397 |
+
if (!$this->dumpSettings['skip-comments']) {
|
398 |
// Some info about software, source and time
|
399 |
+
$header = "-- mysqldump-php https://github.com/ifsnop/mysqldump-php".PHP_EOL.
|
400 |
+
"--".PHP_EOL.
|
401 |
+
"-- Host: {$this->host}\tDatabase: {$this->dbName}".PHP_EOL.
|
402 |
+
"-- ------------------------------------------------------".PHP_EOL;
|
403 |
|
404 |
+
if (!empty($this->version)) {
|
405 |
+
$header .= "-- Server version \t".$this->version.PHP_EOL;
|
406 |
}
|
407 |
|
408 |
+
if (!$this->dumpSettings['skip-dump-date']) {
|
409 |
+
$header .= "-- Date: ".date('r').PHP_EOL.PHP_EOL;
|
410 |
}
|
411 |
}
|
412 |
return $header;
|
423 |
if (!$this->dumpSettings['skip-comments']) {
|
424 |
$footer .= '-- Dump completed';
|
425 |
if (!$this->dumpSettings['skip-dump-date']) {
|
426 |
+
$footer .= ' on: '.date('r');
|
427 |
}
|
428 |
$footer .= PHP_EOL;
|
429 |
}
|
511 |
$match = false;
|
512 |
|
513 |
foreach ($arr as $pattern) {
|
514 |
+
if ('/' != $pattern[0]) {
|
515 |
continue;
|
516 |
}
|
517 |
+
if (1 == preg_match($pattern, $table)) {
|
518 |
$match = true;
|
519 |
}
|
520 |
}
|
531 |
{
|
532 |
// Exporting tables one by one
|
533 |
foreach ($this->tables as $table) {
|
534 |
+
if ($this->matches($table, $this->dumpSettings['exclude-tables'])) {
|
535 |
continue;
|
536 |
}
|
537 |
$this->getTableStructure($table);
|
538 |
+
if (false === $this->dumpSettings['no-data']) { // don't break compatibility with old trigger
|
539 |
$this->listValues($table);
|
540 |
+
} else if (true === $this->dumpSettings['no-data']
|
541 |
+
|| $this->matches($table, $this->dumpSettings['no-data'])) {
|
542 |
continue;
|
543 |
} else {
|
544 |
$this->listValues($table);
|
556 |
if (false === $this->dumpSettings['no-create-info']) {
|
557 |
// Exporting views one by one
|
558 |
foreach ($this->views as $view) {
|
559 |
+
if ($this->matches($view, $this->dumpSettings['exclude-tables'])) {
|
560 |
continue;
|
561 |
}
|
562 |
$this->tableColumnTypes[$view] = $this->getTableColumnTypes($view);
|
563 |
$this->getViewStructureTable($view);
|
564 |
}
|
565 |
foreach ($this->views as $view) {
|
566 |
+
if ($this->matches($view, $this->dumpSettings['exclude-tables'])) {
|
567 |
continue;
|
568 |
}
|
569 |
$this->getViewStructureView($view);
|
622 |
if (!$this->dumpSettings['no-create-info']) {
|
623 |
$ret = '';
|
624 |
if (!$this->dumpSettings['skip-comments']) {
|
625 |
+
$ret = "--".PHP_EOL.
|
626 |
+
"-- Table structure for table `$tableName`".PHP_EOL.
|
627 |
+
"--".PHP_EOL.PHP_EOL;
|
628 |
}
|
629 |
$stmt = $this->typeAdapter->show_create_table($tableName);
|
630 |
foreach ($this->dbHandler->query($stmt) as $r) {
|
658 |
);
|
659 |
$columns->setFetchMode(PDO::FETCH_ASSOC);
|
660 |
|
661 |
+
foreach ($columns as $key => $col) {
|
662 |
$types = $this->typeAdapter->parseColumnType($col);
|
663 |
$columnTypes[$col['Field']] = array(
|
664 |
'is_numeric'=> $types['is_numeric'],
|
682 |
private function getViewStructureTable($viewName)
|
683 |
{
|
684 |
if (!$this->dumpSettings['skip-comments']) {
|
685 |
+
$ret = "--".PHP_EOL.
|
686 |
+
"-- Stand-In structure for view `${viewName}`".PHP_EOL.
|
687 |
+
"--".PHP_EOL.PHP_EOL;
|
688 |
$this->compressManager->write($ret);
|
689 |
}
|
690 |
$stmt = $this->typeAdapter->show_create_view($viewName);
|
713 |
*/
|
714 |
function createStandInTable($viewName) {
|
715 |
$ret = array();
|
716 |
+
foreach ($this->tableColumnTypes[$viewName] as $k => $v) {
|
717 |
$ret[] = "`${k}` ${v['type_sql']}";
|
718 |
}
|
719 |
+
$ret = implode(PHP_EOL.",", $ret);
|
720 |
|
721 |
+
$ret = "CREATE TABLE IF NOT EXISTS `$viewName` (".
|
722 |
+
PHP_EOL.$ret.PHP_EOL.");".PHP_EOL;
|
723 |
|
724 |
return $ret;
|
725 |
}
|
734 |
private function getViewStructureView($viewName)
|
735 |
{
|
736 |
if (!$this->dumpSettings['skip-comments']) {
|
737 |
+
$ret = "--".PHP_EOL.
|
738 |
+
"-- View structure for view `${viewName}`".PHP_EOL.
|
739 |
+
"--".PHP_EOL.PHP_EOL;
|
740 |
$this->compressManager->write($ret);
|
741 |
}
|
742 |
$stmt = $this->typeAdapter->show_create_view($viewName);
|
786 |
private function getProcedureStructure($procedureName)
|
787 |
{
|
788 |
if (!$this->dumpSettings['skip-comments']) {
|
789 |
+
$ret = "--".PHP_EOL.
|
790 |
+
"-- Dumping routines for database '".$this->dbName."'".PHP_EOL.
|
791 |
+
"--".PHP_EOL.PHP_EOL;
|
792 |
$this->compressManager->write($ret);
|
793 |
}
|
794 |
$stmt = $this->typeAdapter->show_create_procedure($procedureName);
|
809 |
private function getEventStructure($eventName)
|
810 |
{
|
811 |
if (!$this->dumpSettings['skip-comments']) {
|
812 |
+
$ret = "--".PHP_EOL.
|
813 |
+
"-- Dumping events for database '".$this->dbName."'".PHP_EOL.
|
814 |
+
"--".PHP_EOL.PHP_EOL;
|
815 |
$this->compressManager->write($ret);
|
816 |
}
|
817 |
$stmt = $this->typeAdapter->show_create_event($eventName);
|
823 |
}
|
824 |
}
|
825 |
|
826 |
+
/**
|
827 |
+
* Prepare values for output
|
828 |
+
*
|
829 |
+
* @param string $tableName Name of table which contains rows
|
830 |
+
* @param array $row Associative array of column names and values to be
|
831 |
+
* quoted
|
832 |
+
*
|
833 |
+
* @return array
|
834 |
+
*/
|
835 |
+
private function prepareColumnValues($tableName, $row)
|
836 |
+
{
|
837 |
+
$ret = [];
|
838 |
+
$columnTypes = $this->tableColumnTypes[$tableName];
|
839 |
+
foreach ($row as $colName => $colValue) {
|
840 |
+
$colValue = $this->hookTransformColumnValue($tableName, $colName, $colValue);
|
841 |
+
$ret[] = $this->escape($colValue, $columnTypes[$colName]);
|
842 |
+
}
|
843 |
+
|
844 |
+
return $ret;
|
845 |
+
}
|
846 |
+
|
847 |
/**
|
848 |
* Escape values with quotes when needed
|
849 |
*
|
852 |
*
|
853 |
* @return string
|
854 |
*/
|
855 |
+
private function escape($colValue, $colType)
|
856 |
{
|
857 |
+
if (is_null($colValue)) {
|
858 |
+
return "NULL";
|
859 |
+
} elseif ($this->dumpSettings['hex-blob'] && $colType['is_blob']) {
|
860 |
+
if ($colType['type'] == 'bit' || !empty($colValue)) {
|
861 |
+
return "0x${colValue}";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
862 |
} else {
|
863 |
+
return "''";
|
864 |
}
|
865 |
+
} elseif ($colType['is_numeric']) {
|
866 |
+
return $colValue;
|
867 |
}
|
868 |
+
|
869 |
+
return $this->dbHandler->quote($colValue);
|
870 |
+
}
|
871 |
+
|
872 |
+
/**
|
873 |
+
* Give extending classes an opportunity to transform column values
|
874 |
+
*
|
875 |
+
* @param string $tableName Name of table which contains rows
|
876 |
+
* @param string $colName Name of the column in question
|
877 |
+
* @param string $colValue Value of the column in question
|
878 |
+
*
|
879 |
+
* @return string
|
880 |
+
*/
|
881 |
+
protected function hookTransformColumnValue(
|
882 |
+
/** @scrutinizer ignore-unused */ $tableName,
|
883 |
+
/** @scrutinizer ignore-unused */ $colName,
|
884 |
+
$colValue)
|
885 |
+
{
|
886 |
+
return $colValue;
|
887 |
}
|
888 |
|
889 |
/**
|
900 |
$onlyOnce = true;
|
901 |
$lineSize = 0;
|
902 |
|
903 |
+
// colStmt is used to form a query to obtain row values
|
904 |
$colStmt = $this->getColumnStmt($tableName);
|
905 |
+
// colNames is used to get the name of the columns when using complete-insert
|
906 |
+
if ($this->dumpSettings['complete-insert']) {
|
907 |
+
$colNames = $this->getColumnNames($tableName);
|
908 |
+
}
|
909 |
+
|
910 |
+
$stmt = "SELECT ".implode(",", $colStmt)." FROM `$tableName`";
|
911 |
|
912 |
if ($this->dumpSettings['where']) {
|
913 |
$stmt .= " WHERE {$this->dumpSettings['where']}";
|
915 |
$resultSet = $this->dbHandler->query($stmt);
|
916 |
$resultSet->setFetchMode(PDO::FETCH_ASSOC);
|
917 |
|
918 |
+
$ignore = $this->dumpSettings['insert-ignore'] ? ' IGNORE' : '';
|
919 |
+
|
920 |
foreach ($resultSet as $row) {
|
921 |
+
$vals = $this->prepareColumnValues($tableName, $row);
|
922 |
if ($onlyOnce || !$this->dumpSettings['extended-insert']) {
|
923 |
|
924 |
if ($this->dumpSettings['complete-insert']) {
|
925 |
$lineSize += $this->compressManager->write(
|
926 |
+
"INSERT$ignore INTO `$tableName` (".
|
927 |
+
implode(", ", $colNames).
|
928 |
+
") VALUES (".implode(",", $vals).")"
|
929 |
);
|
930 |
} else {
|
931 |
$lineSize += $this->compressManager->write(
|
932 |
+
"INSERT$ignore INTO `$tableName` VALUES (".implode(",", $vals).")"
|
933 |
);
|
934 |
}
|
935 |
$onlyOnce = false;
|
936 |
} else {
|
937 |
+
$lineSize += $this->compressManager->write(",(".implode(",", $vals).")");
|
938 |
}
|
939 |
if (($lineSize > $this->dumpSettings['net_buffer_length']) ||
|
940 |
!$this->dumpSettings['extended-insert']) {
|
941 |
$onlyOnce = true;
|
942 |
+
$lineSize = $this->compressManager->write(";".PHP_EOL);
|
943 |
}
|
944 |
}
|
945 |
$resultSet->closeCursor();
|
946 |
|
947 |
if (!$onlyOnce) {
|
948 |
+
$this->compressManager->write(";".PHP_EOL);
|
949 |
}
|
950 |
|
951 |
$this->endListValues($tableName);
|
962 |
{
|
963 |
if (!$this->dumpSettings['skip-comments']) {
|
964 |
$this->compressManager->write(
|
965 |
+
"--".PHP_EOL.
|
966 |
+
"-- Dumping data for table `$tableName`".PHP_EOL.
|
967 |
+
"--".PHP_EOL.PHP_EOL
|
968 |
);
|
969 |
}
|
970 |
|
1041 |
}
|
1042 |
|
1043 |
/**
|
1044 |
+
* Build SQL List of all columns on current table which will be used for selecting
|
1045 |
*
|
1046 |
* @param string $tableName Name of table to get columns
|
1047 |
*
|
1048 |
+
* @return array SQL sentence with columns
|
1049 |
*/
|
1050 |
function getColumnStmt($tableName)
|
1051 |
{
|
1052 |
$colStmt = array();
|
1053 |
+
foreach ($this->tableColumnTypes[$tableName] as $colName => $colType) {
|
1054 |
if ($colType['type'] == 'bit' && $this->dumpSettings['hex-blob']) {
|
1055 |
$colStmt[] = "LPAD(HEX(`${colName}`),2,'0') AS `${colName}`";
|
1056 |
} else if ($colType['is_blob'] && $this->dumpSettings['hex-blob']) {
|
1065 |
|
1066 |
return $colStmt;
|
1067 |
}
|
1068 |
+
|
1069 |
+
/**
|
1070 |
+
* Build SQL List of all columns on current table which will be used for inserting
|
1071 |
+
*
|
1072 |
+
* @param string $tableName Name of table to get columns
|
1073 |
+
*
|
1074 |
+
* @return string SQL sentence with columns
|
1075 |
+
*/
|
1076 |
+
function getColumnNames($tableName)
|
1077 |
+
{
|
1078 |
+
$colNames = array();
|
1079 |
+
foreach($this->tableColumnTypes[$tableName] as $colName => $colType) {
|
1080 |
+
if ($colType['is_virtual']) {
|
1081 |
+
$this->dumpSettings['complete-insert'] = true;
|
1082 |
+
continue;
|
1083 |
+
} else {
|
1084 |
+
$colNames[] = "`${colName}`";
|
1085 |
+
}
|
1086 |
+
}
|
1087 |
+
return $colNames;
|
1088 |
+
}
|
1089 |
}
|
1090 |
|
1091 |
/**
|
1119 |
public static function create($c)
|
1120 |
{
|
1121 |
$c = ucfirst(strtolower($c));
|
1122 |
+
if (!CompressMethod::isValid($c)) {
|
1123 |
throw new Exception("Compression method ($c) is not defined yet");
|
1124 |
}
|
1125 |
|
1126 |
+
$method = __NAMESPACE__."\\"."Compress".$c;
|
1127 |
|
1128 |
return new $method;
|
1129 |
}
|
1135 |
|
1136 |
public function __construct()
|
1137 |
{
|
1138 |
+
if (!function_exists("bzopen")) {
|
1139 |
throw new Exception("Compression is enabled, but bzip2 lib is not installed or configured properly");
|
1140 |
}
|
1141 |
}
|
1173 |
|
1174 |
public function __construct()
|
1175 |
{
|
1176 |
+
if (!function_exists("gzopen")) {
|
1177 |
throw new Exception("Compression is enabled, but gzip lib is not installed or configured properly");
|
1178 |
}
|
1179 |
}
|
1273 |
public static function create($c, $dbHandler = null, $dumpSettings = array())
|
1274 |
{
|
1275 |
$c = ucfirst(strtolower($c));
|
1276 |
+
if (!TypeAdapter::isValid($c)) {
|
1277 |
throw new Exception("Database type support for ($c) not yet available");
|
1278 |
}
|
1279 |
+
$method = __NAMESPACE__."\\"."TypeAdapter".$c;
|
1280 |
return new $method($dbHandler, $dumpSettings);
|
1281 |
}
|
1282 |
|
1297 |
|
1298 |
public function show_create_table($tableName)
|
1299 |
{
|
1300 |
+
return "SELECT tbl_name as 'Table', sql as 'Create Table' ".
|
1301 |
+
"FROM sqlite_master ".
|
1302 |
"WHERE type='table' AND tbl_name='$tableName'";
|
1303 |
}
|
1304 |
|
1313 |
|
1314 |
public function show_create_view($viewName)
|
1315 |
{
|
1316 |
+
return "SELECT tbl_name as 'View', sql as 'Create View' ".
|
1317 |
+
"FROM sqlite_master ".
|
1318 |
"WHERE type='view' AND tbl_name='$viewName'";
|
1319 |
}
|
1320 |
|
1556 |
$ret = "";
|
1557 |
|
1558 |
$ret .= "CREATE DATABASE /*!32312 IF NOT EXISTS*/ `${databaseName}`".
|
1559 |
+
" /*!40100 DEFAULT CHARACTER SET ${characterSet} ".
|
1560 |
+
" COLLATE ${collationDb} */;".PHP_EOL.PHP_EOL.
|
1561 |
+
"USE `${databaseName}`;".PHP_EOL.PHP_EOL;
|
1562 |
|
1563 |
return $ret;
|
1564 |
}
|
1588 |
return "SHOW CREATE EVENT `$eventName`";
|
1589 |
}
|
1590 |
|
1591 |
+
public function create_table($row)
|
1592 |
{
|
1593 |
+
if (!isset($row['Create Table'])) {
|
1594 |
throw new Exception("Error getting table code, unknown output");
|
1595 |
}
|
1596 |
|
1597 |
$createTable = $row['Create Table'];
|
1598 |
+
if ($this->dumpSettings['reset-auto-increment']) {
|
1599 |
$match = "/AUTO_INCREMENT=[0-9]+/s";
|
1600 |
$replace = "";
|
1601 |
$createTable = preg_replace($match, $replace, $createTable);
|
1602 |
}
|
1603 |
|
1604 |
+
$ret = "/*!40101 SET @saved_cs_client = @@character_set_client */;".PHP_EOL.
|
1605 |
+
"/*!40101 SET character_set_client = ".$this->dumpSettings['default-character-set']." */;".PHP_EOL.
|
1606 |
+
$createTable.";".PHP_EOL.
|
1607 |
+
"/*!40101 SET character_set_client = @saved_cs_client */;".PHP_EOL.
|
1608 |
PHP_EOL;
|
1609 |
return $ret;
|
1610 |
}
|
1630 |
$viewStmt = $viewStmtReplaced;
|
1631 |
};
|
1632 |
|
1633 |
+
$ret .= $viewStmt.';'.PHP_EOL.PHP_EOL;
|
1634 |
return $ret;
|
1635 |
}
|
1636 |
|
1652 |
$triggerStmt = $triggerStmtReplaced;
|
1653 |
}
|
1654 |
|
1655 |
+
$ret .= "DELIMITER ;;".PHP_EOL.
|
1656 |
+
$triggerStmt.";;".PHP_EOL.
|
1657 |
+
"DELIMITER ;".PHP_EOL.PHP_EOL;
|
1658 |
return $ret;
|
1659 |
}
|
1660 |
|
1662 |
{
|
1663 |
$ret = "";
|
1664 |
if (!isset($row['Create Procedure'])) {
|
1665 |
+
throw new Exception("Error getting procedure code, unknown output. ".
|
1666 |
"Please check 'https://bugs.mysql.com/bug.php?id=14564'");
|
1667 |
}
|
1668 |
$procedureStmt = $row['Create Procedure'];
|
1669 |
|
1670 |
+
$ret .= "/*!50003 DROP PROCEDURE IF EXISTS `".
|
1671 |
+
$row['Procedure']."` */;".PHP_EOL.
|
1672 |
+
"/*!40101 SET @saved_cs_client = @@character_set_client */;".PHP_EOL.
|
1673 |
+
"/*!40101 SET character_set_client = ".$this->dumpSettings['default-character-set']." */;".PHP_EOL.
|
1674 |
+
"DELIMITER ;;".PHP_EOL.
|
1675 |
+
$procedureStmt." ;;".PHP_EOL.
|
1676 |
+
"DELIMITER ;".PHP_EOL.
|
1677 |
+
"/*!40101 SET character_set_client = @saved_cs_client */;".PHP_EOL.PHP_EOL;
|
1678 |
|
1679 |
return $ret;
|
1680 |
}
|
1682 |
public function create_event($row)
|
1683 |
{
|
1684 |
$ret = "";
|
1685 |
+
if (!isset($row['Create Event'])) {
|
1686 |
+
throw new Exception("Error getting event code, unknown output. ".
|
1687 |
"Please check 'http://stackoverflow.com/questions/10853826/mysql-5-5-create-event-gives-syntax-error'");
|
1688 |
}
|
1689 |
$eventName = $row['Event'];
|
1700 |
$eventStmt = $eventStmtReplaced;
|
1701 |
}
|
1702 |
|
1703 |
+
$ret .= "/*!50106 SET @save_time_zone= @@TIME_ZONE */ ;".PHP_EOL.
|
1704 |
+
"/*!50106 DROP EVENT IF EXISTS `".$eventName."` */;".PHP_EOL.
|
1705 |
+
"DELIMITER ;;".PHP_EOL.
|
1706 |
+
"/*!50003 SET @saved_cs_client = @@character_set_client */ ;;".PHP_EOL.
|
1707 |
+
"/*!50003 SET @saved_cs_results = @@character_set_results */ ;;".PHP_EOL.
|
1708 |
+
"/*!50003 SET @saved_col_connection = @@collation_connection */ ;;".PHP_EOL.
|
1709 |
+
"/*!50003 SET character_set_client = utf8 */ ;;".PHP_EOL.
|
1710 |
+
"/*!50003 SET character_set_results = utf8 */ ;;".PHP_EOL.
|
1711 |
+
"/*!50003 SET collation_connection = utf8_general_ci */ ;;".PHP_EOL.
|
1712 |
+
"/*!50003 SET @saved_sql_mode = @@sql_mode */ ;;".PHP_EOL.
|
1713 |
+
"/*!50003 SET sql_mode = '".$sqlMode."' */ ;;".PHP_EOL.
|
1714 |
+
"/*!50003 SET @saved_time_zone = @@time_zone */ ;;".PHP_EOL.
|
1715 |
+
"/*!50003 SET time_zone = 'SYSTEM' */ ;;".PHP_EOL.
|
1716 |
+
$eventStmt." ;;".PHP_EOL.
|
1717 |
+
"/*!50003 SET time_zone = @saved_time_zone */ ;;".PHP_EOL.
|
1718 |
+
"/*!50003 SET sql_mode = @saved_sql_mode */ ;;".PHP_EOL.
|
1719 |
+
"/*!50003 SET character_set_client = @saved_cs_client */ ;;".PHP_EOL.
|
1720 |
+
"/*!50003 SET character_set_results = @saved_cs_results */ ;;".PHP_EOL.
|
1721 |
+
"/*!50003 SET collation_connection = @saved_col_connection */ ;;".PHP_EOL.
|
1722 |
+
"DELIMITER ;".PHP_EOL.
|
1723 |
+
"/*!50106 SET TIME_ZONE= @save_time_zone */ ;".PHP_EOL.PHP_EOL;
|
1724 |
// Commented because we are doing this in restore_parameters()
|
1725 |
// "/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;" . PHP_EOL . PHP_EOL;
|
1726 |
|
1731 |
{
|
1732 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1733 |
$args = func_get_args();
|
1734 |
+
return "SELECT TABLE_NAME AS tbl_name ".
|
1735 |
+
"FROM INFORMATION_SCHEMA.TABLES ".
|
1736 |
"WHERE TABLE_TYPE='BASE TABLE' AND TABLE_SCHEMA='${args[0]}'";
|
1737 |
}
|
1738 |
|
1740 |
{
|
1741 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1742 |
$args = func_get_args();
|
1743 |
+
return "SELECT TABLE_NAME AS tbl_name ".
|
1744 |
+
"FROM INFORMATION_SCHEMA.TABLES ".
|
1745 |
"WHERE TABLE_TYPE='VIEW' AND TABLE_SCHEMA='${args[0]}'";
|
1746 |
}
|
1747 |
|
1763 |
{
|
1764 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1765 |
$args = func_get_args();
|
1766 |
+
return "SELECT SPECIFIC_NAME AS procedure_name ".
|
1767 |
+
"FROM INFORMATION_SCHEMA.ROUTINES ".
|
1768 |
"WHERE ROUTINE_TYPE='PROCEDURE' AND ROUTINE_SCHEMA='${args[0]}'";
|
1769 |
}
|
1770 |
|
1778 |
{
|
1779 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1780 |
$args = func_get_args();
|
1781 |
+
return "SELECT EVENT_NAME AS event_name ".
|
1782 |
+
"FROM INFORMATION_SCHEMA.EVENTS ".
|
1783 |
"WHERE EVENT_SCHEMA='${args[0]}'";
|
1784 |
}
|
1785 |
|
1815 |
{
|
1816 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1817 |
$args = func_get_args();
|
1818 |
+
return "LOCK TABLES `${args[0]}` WRITE;".PHP_EOL;
|
1819 |
}
|
1820 |
|
1821 |
public function end_add_lock_table()
|
1822 |
{
|
1823 |
+
return "UNLOCK TABLES;".PHP_EOL;
|
1824 |
}
|
1825 |
|
1826 |
public function start_add_disable_keys()
|
1827 |
{
|
1828 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1829 |
$args = func_get_args();
|
1830 |
+
return "/*!40000 ALTER TABLE `${args[0]}` DISABLE KEYS */;".
|
1831 |
PHP_EOL;
|
1832 |
}
|
1833 |
|
1835 |
{
|
1836 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1837 |
$args = func_get_args();
|
1838 |
+
return "/*!40000 ALTER TABLE `${args[0]}` ENABLE KEYS */;".
|
1839 |
PHP_EOL;
|
1840 |
}
|
1841 |
|
1842 |
public function start_disable_autocommit()
|
1843 |
{
|
1844 |
+
return "SET autocommit=0;".PHP_EOL;
|
1845 |
}
|
1846 |
|
1847 |
public function end_disable_autocommit()
|
1848 |
{
|
1849 |
+
return "COMMIT;".PHP_EOL;
|
1850 |
}
|
1851 |
|
1852 |
public function add_drop_database()
|
1853 |
{
|
1854 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1855 |
$args = func_get_args();
|
1856 |
+
return "/*!40000 DROP DATABASE IF EXISTS `${args[0]}`*/;".
|
1857 |
+
PHP_EOL.PHP_EOL;
|
1858 |
}
|
1859 |
|
1860 |
public function add_drop_trigger()
|
1861 |
{
|
1862 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1863 |
$args = func_get_args();
|
1864 |
+
return "DROP TRIGGER IF EXISTS `${args[0]}`;".PHP_EOL;
|
1865 |
}
|
1866 |
|
1867 |
public function drop_table()
|
1868 |
{
|
1869 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1870 |
$args = func_get_args();
|
1871 |
+
return "DROP TABLE IF EXISTS `${args[0]}`;".PHP_EOL;
|
1872 |
}
|
1873 |
|
1874 |
public function drop_view()
|
1875 |
{
|
1876 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1877 |
$args = func_get_args();
|
1878 |
+
return "DROP TABLE IF EXISTS `${args[0]}`;".PHP_EOL.
|
1879 |
+
"/*!50001 DROP VIEW IF EXISTS `${args[0]}`*/;".PHP_EOL;
|
1880 |
}
|
1881 |
|
1882 |
public function getDatabaseHeader()
|
1883 |
{
|
1884 |
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
|
1885 |
$args = func_get_args();
|
1886 |
+
return "--".PHP_EOL.
|
1887 |
+
"-- Current Database: `${args[0]}`".PHP_EOL.
|
1888 |
+
"--".PHP_EOL.PHP_EOL;
|
1889 |
}
|
1890 |
|
1891 |
/**
|
1900 |
$colInfo = array();
|
1901 |
$colParts = explode(" ", $colType['Type']);
|
1902 |
|
1903 |
+
if ($fparen = strpos($colParts[0], "(")) {
|
|
|
1904 |
$colInfo['type'] = substr($colParts[0], 0, $fparen);
|
1905 |
+
$colInfo['length'] = str_replace(")", "", substr($colParts[0], $fparen + 1));
|
1906 |
$colInfo['attributes'] = isset($colParts[1]) ? $colParts[1] : NULL;
|
1907 |
+
} else {
|
|
|
|
|
1908 |
$colInfo['type'] = $colParts[0];
|
1909 |
}
|
1910 |
$colInfo['is_numeric'] = in_array($colInfo['type'], $this->mysqlTypes['numerical']);
|
1911 |
$colInfo['is_blob'] = in_array($colInfo['type'], $this->mysqlTypes['blob']);
|
1912 |
+
// for virtual columns that are of type 'Extra', column type
|
1913 |
+
// could by "STORED GENERATED" or "VIRTUAL GENERATED"
|
1914 |
+
// MySQL reference: https://dev.mysql.com/doc/refman/5.7/en/create-table-generated-columns.html
|
1915 |
+
$colInfo['is_virtual'] = strpos($colType['Extra'], "VIRTUAL GENERATED") !== false || strpos($colType['Extra'], "STORED GENERATED") !== false;
|
1916 |
+
|
1917 |
return $colInfo;
|
1918 |
}
|
1919 |
|
1920 |
public function backup_parameters()
|
1921 |
{
|
1922 |
+
$ret = "/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;".PHP_EOL.
|
1923 |
+
"/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;".PHP_EOL.
|
1924 |
+
"/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;".PHP_EOL.
|
1925 |
+
"/*!40101 SET NAMES ".$this->dumpSettings['default-character-set']." */;".PHP_EOL;
|
1926 |
|
1927 |
if (false === $this->dumpSettings['skip-tz-utc']) {
|
1928 |
+
$ret .= "/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;".PHP_EOL.
|
1929 |
+
"/*!40103 SET TIME_ZONE='+00:00' */;".PHP_EOL;
|
1930 |
}
|
1931 |
|
1932 |
+
$ret .= "/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;".PHP_EOL.
|
1933 |
+
"/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;".PHP_EOL.
|
1934 |
+
"/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;".PHP_EOL.
|
1935 |
+
"/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;".PHP_EOL.PHP_EOL;
|
1936 |
|
1937 |
return $ret;
|
1938 |
}
|
1942 |
$ret = "";
|
1943 |
|
1944 |
if (false === $this->dumpSettings['skip-tz-utc']) {
|
1945 |
+
$ret .= "/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;".PHP_EOL;
|
1946 |
}
|
1947 |
|
1948 |
+
$ret .= "/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;".PHP_EOL.
|
1949 |
+
"/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;".PHP_EOL.
|
1950 |
+
"/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;".PHP_EOL.
|
1951 |
+
"/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;".PHP_EOL.
|
1952 |
+
"/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;".PHP_EOL.
|
1953 |
+
"/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;".PHP_EOL.
|
1954 |
+
"/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;".PHP_EOL.PHP_EOL;
|
1955 |
|
1956 |
return $ret;
|
1957 |
}
|
1966 |
*/
|
1967 |
private function check_parameters($num_args, $expected_num_args, $method_name)
|
1968 |
{
|
1969 |
+
if ($num_args != $expected_num_args) {
|
1970 |
throw new Exception("Unexpected parameter passed to $method_name");
|
1971 |
}
|
1972 |
return;
|
vendor/ifsnop/mysqldump-php/tests/delete_users.sh
CHANGED
@@ -7,6 +7,9 @@ mysql -e "DROP DATABASE test006a;"
|
|
7 |
mysql -e "DROP DATABASE test006b;"
|
8 |
mysql -e "DROP DATABASE test008;"
|
9 |
mysql -e "DROP DATABASE test009;"
|
|
|
|
|
|
|
10 |
|
11 |
mysql -e "DROP USER 'travis'";
|
12 |
|
7 |
mysql -e "DROP DATABASE test006b;"
|
8 |
mysql -e "DROP DATABASE test008;"
|
9 |
mysql -e "DROP DATABASE test009;"
|
10 |
+
mysql -e "DROP DATABASE test010;"
|
11 |
+
mysql -e "DROP DATABASE test011;"
|
12 |
+
mysql -e "DROP DATABASE test012;"
|
13 |
|
14 |
mysql -e "DROP USER 'travis'";
|
15 |
|
vendor/ifsnop/mysqldump-php/tests/test.php
CHANGED
@@ -47,6 +47,16 @@ $dump = new IMysqldump\Mysqldump(
|
|
47 |
$dumpSettings);
|
48 |
$dump->start("mysqldump-php_test001.sql");
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
print "starting mysql-php_test002.sql" . PHP_EOL;
|
51 |
$dumpSettings['default-character-set'] = IMysqldump\Mysqldump::UTF8MB4;
|
52 |
$dumpSettings['complete-insert'] = true;
|
@@ -133,4 +143,15 @@ $dump = new IMysqldump\Mysqldump(
|
|
133 |
));
|
134 |
$dump->start("mysqldump-php_test012_no-definer.sql");
|
135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
exit(0);
|
47 |
$dumpSettings);
|
48 |
$dump->start("mysqldump-php_test001.sql");
|
49 |
|
50 |
+
// checks if complete-insert && hex-blob works ok together
|
51 |
+
print "starting mysql-php_test001_complete.sql" . PHP_EOL;
|
52 |
+
$dumpSettings['complete-insert'] = true;
|
53 |
+
$dump = new IMysqldump\Mysqldump(
|
54 |
+
"mysql:host=localhost;dbname=test001",
|
55 |
+
"travis",
|
56 |
+
"",
|
57 |
+
$dumpSettings);
|
58 |
+
$dump->start("mysqldump-php_test001_complete.sql");
|
59 |
+
|
60 |
print "starting mysql-php_test002.sql" . PHP_EOL;
|
61 |
$dumpSettings['default-character-set'] = IMysqldump\Mysqldump::UTF8MB4;
|
62 |
$dumpSettings['complete-insert'] = true;
|
143 |
));
|
144 |
$dump->start("mysqldump-php_test012_no-definer.sql");
|
145 |
|
146 |
+
print "starting mysql-php_test013.sql" . PHP_EOL;
|
147 |
+
$dump = new IMysqldump\Mysqldump(
|
148 |
+
"mysql:unix_socket=/var/run/mysqld/mysqld.sock;dbname=test001",
|
149 |
+
"travis",
|
150 |
+
"",
|
151 |
+
array(
|
152 |
+
"insert-ignore" => true,
|
153 |
+
"extended-insert" => false
|
154 |
+
));
|
155 |
+
$dump->start("mysqldump-php_test013.sql");
|
156 |
+
|
157 |
exit(0);
|
vendor/ifsnop/mysqldump-php/tests/test.sh
CHANGED
@@ -33,6 +33,7 @@ mysql -utravis < test009.src.sql; ret[((index++))]=$?
|
|
33 |
mysql -utravis < test010.src.sql; ret[((index++))]=$?
|
34 |
mysql -utravis < test011.src.sql; ret[((index++))]=$?
|
35 |
mysql -utravis < test012.src.sql; ret[((index++))]=$?
|
|
|
36 |
|
37 |
checksum_test001 > test001.src.checksum
|
38 |
checksum_test002 > test002.src.checksum
|
@@ -45,6 +46,15 @@ mysqldump -utravis test001 \
|
|
45 |
> mysqldump_test001.sql
|
46 |
ret[((index++))]=$?
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
mysqldump -utravis test002 \
|
49 |
--no-autocommit \
|
50 |
--extended-insert=false \
|
@@ -69,6 +79,14 @@ mysqldump -utravis test012 \
|
|
69 |
> mysqldump_test012.sql
|
70 |
ret[((index++))]=$?
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
php test.php || { echo "ERROR running test.php" && exit -1; }
|
73 |
ret[((index++))]=$?
|
74 |
|
@@ -92,22 +110,29 @@ cat test002.src.sql | grep ^INSERT > test002.filtered.sql
|
|
92 |
cat test005.src.sql | grep ^INSERT > test005.filtered.sql
|
93 |
cat test008.src.sql | grep FOREIGN > test008.filtered.sql
|
94 |
cat test010.src.sql | grep CREATE | grep EVENT > test010.filtered.sql
|
95 |
-
cat test011.src.sql |
|
96 |
cat mysqldump_test001.sql | grep ^INSERT > mysqldump_test001.filtered.sql
|
|
|
97 |
cat mysqldump_test002.sql | grep ^INSERT > mysqldump_test002.filtered.sql
|
98 |
cat mysqldump_test005.sql | grep ^INSERT > mysqldump_test005.filtered.sql
|
99 |
cat mysqldump_test012.sql | grep -E -e '50001 (CREATE|VIEW)' -e '50013 DEFINER' -e 'TRIGGER' | grep -v -e 'TABLE' -e 'CREATE VIEW' > mysqldump_test012.filtered.sql
|
|
|
100 |
cat mysqldump-php_test001.sql | grep ^INSERT > mysqldump-php_test001.filtered.sql
|
|
|
101 |
cat mysqldump-php_test002.sql | grep ^INSERT > mysqldump-php_test002.filtered.sql
|
102 |
cat mysqldump-php_test005.sql | grep ^INSERT > mysqldump-php_test005.filtered.sql
|
103 |
cat mysqldump-php_test008.sql | grep FOREIGN > mysqldump-php_test008.filtered.sql
|
104 |
cat mysqldump-php_test010.sql | grep CREATE | grep EVENT > mysqldump-php_test010.filtered.sql
|
105 |
-
cat mysqldump-php_test011a.sql |
|
106 |
-
cat mysqldump-php_test011b.sql |
|
107 |
cat mysqldump-php_test012.sql | grep -E -e '50001 (CREATE|VIEW)' -e '50013 DEFINER' -e 'CREATE.*TRIGGER' > mysqldump-php_test012.filtered.sql
|
|
|
108 |
|
109 |
diff test001.filtered.sql mysqldump_test001.filtered.sql
|
110 |
ret[((index++))]=$?
|
|
|
|
|
|
|
111 |
diff test002.filtered.sql mysqldump_test002.filtered.sql
|
112 |
ret[((index++))]=$?
|
113 |
|
@@ -151,6 +176,10 @@ ret[((index++))]=$?
|
|
151 |
! grep 'DEFINER' mysqldump-php_test012_no-definer.sql
|
152 |
ret[((index++))]=$?
|
153 |
|
|
|
|
|
|
|
|
|
154 |
rm *.checksum 2> /dev/null
|
155 |
rm *.filtered.sql 2> /dev/null
|
156 |
rm mysqldump* 2> /dev/null
|
@@ -158,7 +187,7 @@ rm mysqldump* 2> /dev/null
|
|
158 |
echo "Done $index tests"
|
159 |
|
160 |
retvalue=0
|
161 |
-
for i in $(seq 0
|
162 |
if [[ ${ret[$i]} -ne 0 ]]; then
|
163 |
echo "test $i returned ${ret[$i]}"
|
164 |
retvalue=${ret[$i]}
|
33 |
mysql -utravis < test010.src.sql; ret[((index++))]=$?
|
34 |
mysql -utravis < test011.src.sql; ret[((index++))]=$?
|
35 |
mysql -utravis < test012.src.sql; ret[((index++))]=$?
|
36 |
+
#mysql -utravis < test013.src.sql; ret[((index++))]=$?
|
37 |
|
38 |
checksum_test001 > test001.src.checksum
|
39 |
checksum_test002 > test002.src.checksum
|
46 |
> mysqldump_test001.sql
|
47 |
ret[((index++))]=$?
|
48 |
|
49 |
+
mysqldump -utravis test001 \
|
50 |
+
--no-autocommit \
|
51 |
+
--extended-insert=false \
|
52 |
+
--hex-blob=true \
|
53 |
+
--routines=true \
|
54 |
+
--complete-insert=true \
|
55 |
+
> mysqldump_test001_complete.sql
|
56 |
+
ret[((index++))]=$?
|
57 |
+
|
58 |
mysqldump -utravis test002 \
|
59 |
--no-autocommit \
|
60 |
--extended-insert=false \
|
79 |
> mysqldump_test012.sql
|
80 |
ret[((index++))]=$?
|
81 |
|
82 |
+
mysqldump -utravis test001 \
|
83 |
+
--no-autocommit \
|
84 |
+
--extended-insert=false \
|
85 |
+
--hex-blob=true \
|
86 |
+
--insert-ignore \
|
87 |
+
> mysqldump_test013.sql
|
88 |
+
ret[((index++))]=$?
|
89 |
+
|
90 |
php test.php || { echo "ERROR running test.php" && exit -1; }
|
91 |
ret[((index++))]=$?
|
92 |
|
110 |
cat test005.src.sql | grep ^INSERT > test005.filtered.sql
|
111 |
cat test008.src.sql | grep FOREIGN > test008.filtered.sql
|
112 |
cat test010.src.sql | grep CREATE | grep EVENT > test010.filtered.sql
|
113 |
+
cat test011.src.sql | egrep "INSERT|GENERATED" > test011.filtered.sql
|
114 |
cat mysqldump_test001.sql | grep ^INSERT > mysqldump_test001.filtered.sql
|
115 |
+
cat mysqldump_test001_complete.sql | grep ^INSERT > mysqldump_test001_complete.filtered.sql
|
116 |
cat mysqldump_test002.sql | grep ^INSERT > mysqldump_test002.filtered.sql
|
117 |
cat mysqldump_test005.sql | grep ^INSERT > mysqldump_test005.filtered.sql
|
118 |
cat mysqldump_test012.sql | grep -E -e '50001 (CREATE|VIEW)' -e '50013 DEFINER' -e 'TRIGGER' | grep -v -e 'TABLE' -e 'CREATE VIEW' > mysqldump_test012.filtered.sql
|
119 |
+
cat mysqldump_test013.sql | grep "INSERT" > mysqldump_test013.filtered.sql
|
120 |
cat mysqldump-php_test001.sql | grep ^INSERT > mysqldump-php_test001.filtered.sql
|
121 |
+
cat mysqldump-php_test001_complete.sql | grep ^INSERT > mysqldump-php_test001_complete.filtered.sql
|
122 |
cat mysqldump-php_test002.sql | grep ^INSERT > mysqldump-php_test002.filtered.sql
|
123 |
cat mysqldump-php_test005.sql | grep ^INSERT > mysqldump-php_test005.filtered.sql
|
124 |
cat mysqldump-php_test008.sql | grep FOREIGN > mysqldump-php_test008.filtered.sql
|
125 |
cat mysqldump-php_test010.sql | grep CREATE | grep EVENT > mysqldump-php_test010.filtered.sql
|
126 |
+
cat mysqldump-php_test011a.sql | egrep "INSERT|GENERATED" > mysqldump-php_test011a.filtered.sql
|
127 |
+
cat mysqldump-php_test011b.sql | egrep "INSERT|GENERATED" > mysqldump-php_test011b.filtered.sql
|
128 |
cat mysqldump-php_test012.sql | grep -E -e '50001 (CREATE|VIEW)' -e '50013 DEFINER' -e 'CREATE.*TRIGGER' > mysqldump-php_test012.filtered.sql
|
129 |
+
cat mysqldump-php_test013.sql | grep INSERT > mysqldump-php_test013.filtered.sql
|
130 |
|
131 |
diff test001.filtered.sql mysqldump_test001.filtered.sql
|
132 |
ret[((index++))]=$?
|
133 |
+
diff mysqldump_test001_complete.filtered.sql mysqldump-php_test001_complete.filtered.sql
|
134 |
+
ret[((index++))]=$?
|
135 |
+
|
136 |
diff test002.filtered.sql mysqldump_test002.filtered.sql
|
137 |
ret[((index++))]=$?
|
138 |
|
176 |
! grep 'DEFINER' mysqldump-php_test012_no-definer.sql
|
177 |
ret[((index++))]=$?
|
178 |
|
179 |
+
# test INSERT IGNORE
|
180 |
+
diff mysqldump_test013.filtered.sql mysqldump-php_test013.filtered.sql
|
181 |
+
ret[((index++))]=$?
|
182 |
+
|
183 |
rm *.checksum 2> /dev/null
|
184 |
rm *.filtered.sql 2> /dev/null
|
185 |
rm mysqldump* 2> /dev/null
|
187 |
echo "Done $index tests"
|
188 |
|
189 |
retvalue=0
|
190 |
+
for i in $(seq 0 $index) ; do
|
191 |
if [[ ${ret[$i]} -ne 0 ]]; then
|
192 |
echo "test $i returned ${ret[$i]}"
|
193 |
retvalue=${ret[$i]}
|
vendor/ifsnop/mysqldump-php/tests/test011.src.sql
CHANGED
@@ -28,7 +28,8 @@ DROP TABLE IF EXISTS `test011`;
|
|
28 |
/*!40101 SET character_set_client = utf8 */;
|
29 |
CREATE TABLE `test011` (
|
30 |
`id` int(11) NOT NULL,
|
31 |
-
`
|
|
|
32 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
|
33 |
/*!40101 SET character_set_client = @saved_cs_client */;
|
34 |
|
28 |
/*!40101 SET character_set_client = utf8 */;
|
29 |
CREATE TABLE `test011` (
|
30 |
`id` int(11) NOT NULL,
|
31 |
+
`hash_stored` char(32) CHARACTER SET ascii COLLATE ascii_bin GENERATED ALWAYS AS (md5(`id`)) STORED NOT NULL,
|
32 |
+
`hash_virtual` char(32) CHARACTER SET ascii COLLATE ascii_bin GENERATED ALWAYS AS (md5(`id`)) VIRTUAL NOT NULL
|
33 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
|
34 |
/*!40101 SET character_set_client = @saved_cs_client */;
|
35 |
|