Version Description
Download this release
Release Info
Developer | GamerZ |
Plugin | WP-DBManager |
Version | 2.79.2 |
Comparing to | |
See all releases |
Code changes from version 2.79.1 to 2.79.2
- database-manage.php +15 -17
- readme.txt +4 -1
- wp-dbmanager.php +45 -40
database-manage.php
CHANGED
@@ -21,7 +21,7 @@ $backup['charset'] = ' --default-character-set="utf8"';
|
|
21 |
if( !empty( $_POST['do'] ) ) {
|
22 |
check_admin_referer('wp-dbmanager_manage');
|
23 |
// Lets Prepare The Variables
|
24 |
-
$database_file =
|
25 |
$nice_file_date = mysql2date(sprintf(__('%s @ %s', 'wp-dbmanager'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', substr($database_file, 0, 10)));
|
26 |
$text = '';
|
27 |
|
@@ -29,20 +29,21 @@ if( !empty( $_POST['do'] ) ) {
|
|
29 |
switch($_POST['do']) {
|
30 |
case __('Restore', 'wp-dbmanager'):
|
31 |
if(!empty($database_file)) {
|
32 |
-
$brace =
|
33 |
$backup['host'] = DB_HOST;
|
34 |
$backup['port'] = '';
|
35 |
$backup['sock'] = '';
|
36 |
if(strpos(DB_HOST, ':') !== false) {
|
37 |
$db_host = explode(':', DB_HOST);
|
38 |
$backup['host'] = $db_host[0];
|
39 |
-
if(
|
40 |
-
$backup['port'] = ' --port=' . escapeshellarg(
|
41 |
} else {
|
42 |
$backup['sock'] = ' --socket=' . escapeshellarg( $db_host[1] );
|
43 |
}
|
44 |
}
|
45 |
-
|
|
|
46 |
do_action( 'wp_dbmanager_before_escapeshellcmd' );
|
47 |
$backup['command'] = 'gunzip < ' . $brace . escapeshellcmd( $backup['path'] . '/' . $database_file ) . $brace . ' | ' . $brace . escapeshellcmd( $backup['mysqlpath'] ) . $brace . ' --host=' . escapeshellarg( $backup['host'] ) . ' --user=' . escapeshellarg( DB_USER ) . ' --password=' . escapeshellarg( DB_PASSWORD ) . $backup['port'] . $backup['sock'] . $backup['charset'] . ' ' . DB_NAME;
|
48 |
} else {
|
@@ -84,9 +85,9 @@ if( !empty( $_POST['do'] ) ) {
|
|
84 |
}
|
85 |
break;
|
86 |
case __('Delete', 'wp-dbmanager'):
|
87 |
-
if(!empty($database_file)) {
|
88 |
-
if(is_file($backup['path'].'/'
|
89 |
-
if(!unlink($backup['path'].'/'
|
90 |
$text .= '<p style="color: red;">'.sprintf(__('Unable To Delete Database Backup File On \'%s\'', 'wp-dbmanager'), $nice_file_date).'</p>';
|
91 |
} else {
|
92 |
$text .= '<p style="color: green;">'.sprintf(__('Database Backup File On \'%s\' Deleted Successfully', 'wp-dbmanager'), $nice_file_date).'</p>';
|
@@ -121,18 +122,18 @@ if( !empty( $_POST['do'] ) ) {
|
|
121 |
<?php
|
122 |
$no = 0;
|
123 |
$totalsize = 0;
|
124 |
-
if(!is_emtpy_folder($backup['path'])) {
|
125 |
-
if ($handle = opendir($backup['path'])) {
|
126 |
$database_files = array();
|
127 |
while (false !== ($file = readdir($handle))) {
|
128 |
-
if ($file
|
129 |
$database_files[] = $file;
|
130 |
}
|
131 |
}
|
132 |
closedir($handle);
|
133 |
sort($database_files);
|
134 |
-
|
135 |
-
|
|
|
136 |
$style = '';
|
137 |
} else {
|
138 |
$style = ' class="alternate"';
|
@@ -149,9 +150,6 @@ if( !empty( $_POST['do'] ) ) {
|
|
149 |
echo "<td><input type=\"radio\" name=\"database_file\" value=\"$database_files[$i]\" /></td>\n</tr>\n";
|
150 |
$totalsize += $size_text;
|
151 |
}
|
152 |
-
} else {
|
153 |
-
echo '<tr><td align="center" colspan="5">'.__('There Are No Database Backup Files Available.', 'wp-dbmanager').'</td></tr>';
|
154 |
-
}
|
155 |
} else {
|
156 |
echo '<tr><td align="center" colspan="5">'.__('There Are No Database Backup Files Available.', 'wp-dbmanager').'</td></tr>';
|
157 |
}
|
@@ -171,7 +169,7 @@ if( !empty( $_POST['do'] ) ) {
|
|
171 |
<input type="submit" name="do" value="<?php _e('Download', 'wp-dbmanager'); ?>" class="button" />
|
172 |
<input type="submit" name="do" value="<?php _e('Restore', 'wp-dbmanager'); ?>" onclick="return confirm('<?php _e('You Are About To Restore A Database.\nThis Action Is Not Reversible.\nAny Data Inserted After The Backup Date Will Be Gone.\n\n Choose [Cancel] to stop, [Ok] to restore.', 'wp-dbmanager'); ?>')" class="button" />
|
173 |
<input type="submit" class="button" name="do" value="<?php _e('Delete', 'wp-dbmanager'); ?>" onclick="return confirm('<?php _e('You Are About To Delete The Selected Database Backup Files.\nThis Action Is Not Reversible.\n\n Choose [Cancel] to stop, [Ok] to delete.', 'wp-dbmanager'); ?>')" />
|
174 |
-
<input type="button" name="cancel" value="<?php _e('Cancel', 'wp-dbmanager'); ?>" class="button" onclick="
|
175 |
</tr>
|
176 |
</table>
|
177 |
</div>
|
21 |
if( !empty( $_POST['do'] ) ) {
|
22 |
check_admin_referer('wp-dbmanager_manage');
|
23 |
// Lets Prepare The Variables
|
24 |
+
$database_file = ! empty ( $_POST['database_file'] ) ? sanitize_file_name( $_POST['database_file'] ) : '';
|
25 |
$nice_file_date = mysql2date(sprintf(__('%s @ %s', 'wp-dbmanager'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', substr($database_file, 0, 10)));
|
26 |
$text = '';
|
27 |
|
29 |
switch($_POST['do']) {
|
30 |
case __('Restore', 'wp-dbmanager'):
|
31 |
if(!empty($database_file)) {
|
32 |
+
$brace = substr(PHP_OS, 0, 3) === 'WIN' ? '"' : '';
|
33 |
$backup['host'] = DB_HOST;
|
34 |
$backup['port'] = '';
|
35 |
$backup['sock'] = '';
|
36 |
if(strpos(DB_HOST, ':') !== false) {
|
37 |
$db_host = explode(':', DB_HOST);
|
38 |
$backup['host'] = $db_host[0];
|
39 |
+
if ( (int) $db_host[1] !== 0 ) {
|
40 |
+
$backup['port'] = ' --port=' . escapeshellarg( (int) $db_host[1] );
|
41 |
} else {
|
42 |
$backup['sock'] = ' --socket=' . escapeshellarg( $db_host[1] );
|
43 |
}
|
44 |
}
|
45 |
+
|
46 |
+
if ( false !== stripos( $database_file, '.gz' ) ) {
|
47 |
do_action( 'wp_dbmanager_before_escapeshellcmd' );
|
48 |
$backup['command'] = 'gunzip < ' . $brace . escapeshellcmd( $backup['path'] . '/' . $database_file ) . $brace . ' | ' . $brace . escapeshellcmd( $backup['mysqlpath'] ) . $brace . ' --host=' . escapeshellarg( $backup['host'] ) . ' --user=' . escapeshellarg( DB_USER ) . ' --password=' . escapeshellarg( DB_PASSWORD ) . $backup['port'] . $backup['sock'] . $backup['charset'] . ' ' . DB_NAME;
|
49 |
} else {
|
85 |
}
|
86 |
break;
|
87 |
case __('Delete', 'wp-dbmanager'):
|
88 |
+
if ( ! empty( $database_file ) ) {
|
89 |
+
if ( is_file( $backup['path'] . '/' . $database_file ) ) {
|
90 |
+
if ( ! unlink( $backup['path'] . '/' . $database_file ) ) {
|
91 |
$text .= '<p style="color: red;">'.sprintf(__('Unable To Delete Database Backup File On \'%s\'', 'wp-dbmanager'), $nice_file_date).'</p>';
|
92 |
} else {
|
93 |
$text .= '<p style="color: green;">'.sprintf(__('Database Backup File On \'%s\' Deleted Successfully', 'wp-dbmanager'), $nice_file_date).'</p>';
|
122 |
<?php
|
123 |
$no = 0;
|
124 |
$totalsize = 0;
|
125 |
+
if ( ! is_emtpy_folder( $backup['path'] ) && $handle = opendir($backup['path'] ) ) {
|
|
|
126 |
$database_files = array();
|
127 |
while (false !== ($file = readdir($handle))) {
|
128 |
+
if ( $file !== '.' && $file !== '..' && $file !== '.htaccess' && ( file_ext( $file ) === 'sql' || file_ext( $file ) === 'gz' ) ) {
|
129 |
$database_files[] = $file;
|
130 |
}
|
131 |
}
|
132 |
closedir($handle);
|
133 |
sort($database_files);
|
134 |
+
$database_files_count = count( $database_files ) - 1;
|
135 |
+
for ( $i = $database_files_count; $i > -1; $i-- ) {
|
136 |
+
if ( $no % 2 === 0 ) {
|
137 |
$style = '';
|
138 |
} else {
|
139 |
$style = ' class="alternate"';
|
150 |
echo "<td><input type=\"radio\" name=\"database_file\" value=\"$database_files[$i]\" /></td>\n</tr>\n";
|
151 |
$totalsize += $size_text;
|
152 |
}
|
|
|
|
|
|
|
153 |
} else {
|
154 |
echo '<tr><td align="center" colspan="5">'.__('There Are No Database Backup Files Available.', 'wp-dbmanager').'</td></tr>';
|
155 |
}
|
169 |
<input type="submit" name="do" value="<?php _e('Download', 'wp-dbmanager'); ?>" class="button" />
|
170 |
<input type="submit" name="do" value="<?php _e('Restore', 'wp-dbmanager'); ?>" onclick="return confirm('<?php _e('You Are About To Restore A Database.\nThis Action Is Not Reversible.\nAny Data Inserted After The Backup Date Will Be Gone.\n\n Choose [Cancel] to stop, [Ok] to restore.', 'wp-dbmanager'); ?>')" class="button" />
|
171 |
<input type="submit" class="button" name="do" value="<?php _e('Delete', 'wp-dbmanager'); ?>" onclick="return confirm('<?php _e('You Are About To Delete The Selected Database Backup Files.\nThis Action Is Not Reversible.\n\n Choose [Cancel] to stop, [Ok] to delete.', 'wp-dbmanager'); ?>')" />
|
172 |
+
<input type="button" name="cancel" value="<?php _e('Cancel', 'wp-dbmanager'); ?>" class="button" onclick="history.go(-1)" /></td>
|
173 |
</tr>
|
174 |
</table>
|
175 |
</div>
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://lesterchan.net/site/donation/
|
|
4 |
Tags: database, manage, wp-dbmanager, manager, table, optimize, backup, queries, query, drop, empty, tables, table, run, repair, cron, schedule, scheduling, automatic
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 4.9
|
7 |
-
Stable tag: 2.79.
|
8 |
|
9 |
Manages your WordPress database.
|
10 |
|
@@ -42,6 +42,9 @@ Allows you to optimize database, repair database, backup database, restore datab
|
|
42 |
* To know about the difference between WP-DBManager and WP-DB-backup, checkout __What is the difference between WP-DBManager and WP-DB-Backup?__ in the [FAQ section](https://wordpress.org/plugins/wp-dbmanager/faq/).
|
43 |
|
44 |
## Changelog
|
|
|
|
|
|
|
45 |
### Version 2.79.1
|
46 |
* FIXED: Added default utf8 charset
|
47 |
|
4 |
Tags: database, manage, wp-dbmanager, manager, table, optimize, backup, queries, query, drop, empty, tables, table, run, repair, cron, schedule, scheduling, automatic
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 4.9
|
7 |
+
Stable tag: 2.79.2
|
8 |
|
9 |
Manages your WordPress database.
|
10 |
|
42 |
* To know about the difference between WP-DBManager and WP-DB-backup, checkout __What is the difference between WP-DBManager and WP-DB-Backup?__ in the [FAQ section](https://wordpress.org/plugins/wp-dbmanager/faq/).
|
43 |
|
44 |
## Changelog
|
45 |
+
### Version 2.79.2
|
46 |
+
* FIXED: Arbitrary file delete bug by sanitizing filename. Props [RIPS Technologies](https://www.ripstech.com).
|
47 |
+
|
48 |
### Version 2.79.1
|
49 |
* FIXED: Added default utf8 charset
|
50 |
|
wp-dbmanager.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: WP-DBManager
|
4 |
Plugin URI: https://lesterchan.net/portfolio/programming/php/
|
5 |
Description: Manages your WordPress database. Allows you to optimize database, repair database, backup database, restore database, delete backup database , drop/empty tables and run selected queries. Supports automatic scheduling of backing up, optimizing and repairing of database.
|
6 |
-
Version: 2.79.
|
7 |
Author: Lester 'GaMerZ' Chan
|
8 |
Author URI: https://lesterchan.net
|
9 |
Text Domain: wp-dbmanager
|
@@ -11,7 +11,7 @@ Text Domain: wp-dbmanager
|
|
11 |
|
12 |
|
13 |
/*
|
14 |
-
Copyright
|
15 |
|
16 |
This program is free software; you can redistribute it and/or modify
|
17 |
it under the terms of the GNU General Public License as published by
|
@@ -54,7 +54,14 @@ function dbmanager_menu() {
|
|
54 |
}
|
55 |
|
56 |
|
57 |
-
###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
add_filter('cron_schedules', 'cron_dbmanager_reccurences');
|
59 |
add_action('dbmanager_cron_backup', 'cron_dbmanager_backup');
|
60 |
add_action('dbmanager_cron_optimize', 'cron_dbmanager_optimize');
|
@@ -105,7 +112,7 @@ function cron_dbmanager_backup() {
|
|
105 |
function cron_dbmanager_optimize() {
|
106 |
global $wpdb;
|
107 |
$backup_options = get_option('dbmanager_options');
|
108 |
-
$optimize_period =
|
109 |
if($optimize_period > 0) {
|
110 |
$optimize_tables = array();
|
111 |
$tables = $wpdb->get_col("SHOW TABLES");
|
@@ -119,7 +126,7 @@ function cron_dbmanager_optimize() {
|
|
119 |
function cron_dbmanager_repair() {
|
120 |
global $wpdb;
|
121 |
$backup_options = get_option('dbmanager_options');
|
122 |
-
$repair_period =
|
123 |
if($repair_period > 0) {
|
124 |
$repair_tables = array();
|
125 |
$tables = $wpdb->get_col("SHOW TABLES");
|
@@ -134,17 +141,17 @@ function cron_dbmanager_reccurences($schedules) {
|
|
134 |
$backup_options = get_option( 'dbmanager_options' );
|
135 |
|
136 |
if( isset( $backup_options['backup'] ) && isset( $backup_options['backup_period'] ) ) {
|
137 |
-
$backup =
|
138 |
} else {
|
139 |
$backup = 0;
|
140 |
}
|
141 |
if( isset( $backup_options['optimize'] ) && isset( $backup_options['optimize_period'] ) ) {
|
142 |
-
$optimize =
|
143 |
} else {
|
144 |
$optimize = 0;
|
145 |
}
|
146 |
if( isset( $backup_options['repair'] ) && isset( $backup_options['repair_period'] ) ) {
|
147 |
-
$repair =
|
148 |
} else {
|
149 |
$repair = 0;
|
150 |
}
|
@@ -170,11 +177,11 @@ add_action( 'admin_notices', 'dbmanager_admin_notices' );
|
|
170 |
function dbmanager_admin_notices() {
|
171 |
$backup_options = get_option( 'dbmanager_options' );
|
172 |
$backup_folder_writable = ( is_dir( $backup_options['path'] ) && wp_is_writable( $backup_options['path'] ) );
|
173 |
-
$htaccess_exists =
|
174 |
-
$webconfig_exists =
|
175 |
-
$index_exists =
|
176 |
|
177 |
-
if( ! isset( $backup_options['hide_admin_notices'] ) ||
|
178 |
{
|
179 |
if( ! $backup_folder_writable || ! $index_exists || ( is_iis() && ! $webconfig_exists ) || ( ! is_iis() && ! $htaccess_exists ) ) {
|
180 |
|
@@ -209,7 +216,7 @@ function dbmanager_admin_notices() {
|
|
209 |
function detect_mysql() {
|
210 |
global $wpdb;
|
211 |
$paths = array('mysq' => '', 'mysqldump' => '');
|
212 |
-
if(substr(PHP_OS,0,3)
|
213 |
$mysql_install = $wpdb->get_row("SHOW VARIABLES LIKE 'basedir'");
|
214 |
if($mysql_install) {
|
215 |
$install_path = trailingslashit( str_replace('\\', '/', $mysql_install->Value) );
|
@@ -496,11 +503,9 @@ function dbmanager_create_backup_folder() {
|
|
496 |
|
497 |
add_action( 'init', 'dbmanager_try_fix' );
|
498 |
function dbmanager_try_fix() {
|
499 |
-
if ( ! empty( $_GET['try_fix'] ) ) {
|
500 |
-
|
501 |
-
|
502 |
-
dbmanager_create_backup_folder();
|
503 |
-
}
|
504 |
}
|
505 |
}
|
506 |
|
@@ -533,7 +538,7 @@ function download_database() {
|
|
533 |
|
534 |
### Function: Check whether a function is disabled.
|
535 |
function dbmanager_is_function_disabled( $function_name ) {
|
536 |
-
return in_array( $function_name, array_map( 'trim', explode( ',', ini_get( 'disable_functions' ) ) ) );
|
537 |
}
|
538 |
|
539 |
### Function: Database Options
|
@@ -543,22 +548,22 @@ function dbmanager_options() {
|
|
543 |
$old_backup_options = $backup_options;
|
544 |
if(!empty($_POST['Submit'])) {
|
545 |
check_admin_referer('wp-dbmanager_options');
|
546 |
-
$backup_options['mysqldumppath'] = sanitize_text_field( $_POST['db_mysqldumppath'] );
|
547 |
-
$backup_options['mysqlpath'] = sanitize_text_field( $_POST['db_mysqlpath'] );
|
548 |
-
$backup_options['path'] = sanitize_text_field( $_POST['db_path'] );
|
549 |
-
$backup_options['max_backup'] =
|
550 |
-
$backup_options['backup'] =
|
551 |
-
$backup_options['backup_gzip'] =
|
552 |
-
$backup_options['backup_period'] =
|
553 |
-
$backup_options['backup_email'] = sanitize_email( $_POST['db_backup_email'] );
|
554 |
-
$backup_options['backup_email_from'] = sanitize_email( $_POST['db_backup_email_from'] );
|
555 |
-
$backup_options['backup_email_from_name'] = sanitize_text_field( $_POST['db_backup_email_from_name'] );
|
556 |
-
$backup_options['backup_email_subject'] = sanitize_text_field( $_POST['db_backup_email_subject'] );
|
557 |
-
$backup_options['optimize'] =
|
558 |
-
$backup_options['optimize_period'] =
|
559 |
-
$backup_options['repair'] =
|
560 |
-
$backup_options['repair_period'] =
|
561 |
-
$backup_options['hide_admin_notices'] =
|
562 |
|
563 |
if( realpath( $backup_options['path'] ) === false ) {
|
564 |
$text = '<div id="message" class="error"><p>' . sprintf( __( '%s is not a valid backup path', 'wp-dbmanager' ), stripslashes( $backup_options['path'] ) ) . '</p></div>';
|
@@ -704,7 +709,7 @@ function dbmanager_options() {
|
|
704 |
}
|
705 |
?>
|
706 |
<p>
|
707 |
-
<?php _e('Every', 'wp-dbmanager'); ?> <input type="text" name="db_backup" size="3" maxlength="5" value="<?php echo
|
708 |
<select name="db_backup_period" size="1">
|
709 |
<option value="0"<?php selected('0', $backup_options['backup_period']); ?>><?php _e('Disable', 'wp-dbmanager'); ?></option>
|
710 |
<option value="60"<?php selected('60', $backup_options['backup_period']); ?>><?php _e('Minutes(s)', 'wp-dbmanager'); ?></option>
|
@@ -734,7 +739,7 @@ function dbmanager_options() {
|
|
734 |
}
|
735 |
?>
|
736 |
<p>
|
737 |
-
<?php _e('Every', 'wp-dbmanager'); ?> <input type="text" name="db_optimize" size="3" maxlength="5" value="<?php echo
|
738 |
<select name="db_optimize_period" size="1">
|
739 |
<option value="0"<?php selected('0', $backup_options['optimize_period']); ?>><?php _e('Disable', 'wp-dbmanager'); ?></option>
|
740 |
<option value="60"<?php selected('60', $backup_options['optimize_period']); ?>><?php _e('Minutes(s)', 'wp-dbmanager'); ?></option>
|
@@ -759,7 +764,7 @@ function dbmanager_options() {
|
|
759 |
}
|
760 |
?>
|
761 |
<p>
|
762 |
-
<?php _e('Every', 'wp-dbmanager'); ?> <input type="text" name="db_repair" size="3" maxlength="5" value="<?php echo
|
763 |
<select name="db_repair_period" size="1">
|
764 |
<option value="0"<?php selected('0', $backup_options['repair_period']); ?>><?php _e('Disable', 'wp-dbmanager'); ?></option>
|
765 |
<option value="60"<?php selected('60', $backup_options['repair_period']); ?>><?php _e('Minutes(s)', 'wp-dbmanager'); ?></option>
|
@@ -812,8 +817,8 @@ function dbmanager_options() {
|
|
812 |
<td valign="top"><strong><?php _e('Hide Admin Notices', 'wp-dbmanager'); ?></strong></td>
|
813 |
<td>
|
814 |
<p>
|
815 |
-
<input type="radio" name="db_hide_admin_notices" value="1"<?php echo (
|
816 |
-
<input type="radio" name="db_hide_admin_notices" value="0"<?php echo (
|
817 |
</p>
|
818 |
</td>
|
819 |
</tr>
|
3 |
Plugin Name: WP-DBManager
|
4 |
Plugin URI: https://lesterchan.net/portfolio/programming/php/
|
5 |
Description: Manages your WordPress database. Allows you to optimize database, repair database, backup database, restore database, delete backup database , drop/empty tables and run selected queries. Supports automatic scheduling of backing up, optimizing and repairing of database.
|
6 |
+
Version: 2.79.2
|
7 |
Author: Lester 'GaMerZ' Chan
|
8 |
Author URI: https://lesterchan.net
|
9 |
Text Domain: wp-dbmanager
|
11 |
|
12 |
|
13 |
/*
|
14 |
+
Copyright 2018 Lester Chan (email : lesterchan@gmail.com)
|
15 |
|
16 |
This program is free software; you can redistribute it and/or modify
|
17 |
it under the terms of the GNU General Public License as published by
|
54 |
}
|
55 |
|
56 |
|
57 |
+
### Function: Append get_allowed_mime_types()
|
58 |
+
add_filter( 'upload_mimes', 'dbmanager_upload_mimes' );
|
59 |
+
function dbmanager_upload_mimes( $mime_types ) {
|
60 |
+
$mime_types['sql'] = 'application/sql';
|
61 |
+
return $mime_types;
|
62 |
+
}
|
63 |
+
|
64 |
+
### Function: Database Manager Cron
|
65 |
add_filter('cron_schedules', 'cron_dbmanager_reccurences');
|
66 |
add_action('dbmanager_cron_backup', 'cron_dbmanager_backup');
|
67 |
add_action('dbmanager_cron_optimize', 'cron_dbmanager_optimize');
|
112 |
function cron_dbmanager_optimize() {
|
113 |
global $wpdb;
|
114 |
$backup_options = get_option('dbmanager_options');
|
115 |
+
$optimize_period = (int) $backup_options['optimize_period'];
|
116 |
if($optimize_period > 0) {
|
117 |
$optimize_tables = array();
|
118 |
$tables = $wpdb->get_col("SHOW TABLES");
|
126 |
function cron_dbmanager_repair() {
|
127 |
global $wpdb;
|
128 |
$backup_options = get_option('dbmanager_options');
|
129 |
+
$repair_period = (int) $backup_options['repair_period'];
|
130 |
if($repair_period > 0) {
|
131 |
$repair_tables = array();
|
132 |
$tables = $wpdb->get_col("SHOW TABLES");
|
141 |
$backup_options = get_option( 'dbmanager_options' );
|
142 |
|
143 |
if( isset( $backup_options['backup'] ) && isset( $backup_options['backup_period'] ) ) {
|
144 |
+
$backup = (int) $backup_options['backup'] * (int) $backup_options['backup_period'];
|
145 |
} else {
|
146 |
$backup = 0;
|
147 |
}
|
148 |
if( isset( $backup_options['optimize'] ) && isset( $backup_options['optimize_period'] ) ) {
|
149 |
+
$optimize = (int) $backup_options['optimize'] * (int) $backup_options['optimize_period'];
|
150 |
} else {
|
151 |
$optimize = 0;
|
152 |
}
|
153 |
if( isset( $backup_options['repair'] ) && isset( $backup_options['repair_period'] ) ) {
|
154 |
+
$repair = (int) $backup_options['repair'] * (int) $backup_options['repair_period'];
|
155 |
} else {
|
156 |
$repair = 0;
|
157 |
}
|
177 |
function dbmanager_admin_notices() {
|
178 |
$backup_options = get_option( 'dbmanager_options' );
|
179 |
$backup_folder_writable = ( is_dir( $backup_options['path'] ) && wp_is_writable( $backup_options['path'] ) );
|
180 |
+
$htaccess_exists = file_exists( $backup_options['path'] . '/.htaccess' );
|
181 |
+
$webconfig_exists = file_exists( $backup_options['path'] . '/Web.config' );
|
182 |
+
$index_exists = file_exists( $backup_options['path'] . '/index.php' );
|
183 |
|
184 |
+
if( ! isset( $backup_options['hide_admin_notices'] ) || (int) $backup_options['hide_admin_notices'] === 0 )
|
185 |
{
|
186 |
if( ! $backup_folder_writable || ! $index_exists || ( is_iis() && ! $webconfig_exists ) || ( ! is_iis() && ! $htaccess_exists ) ) {
|
187 |
|
216 |
function detect_mysql() {
|
217 |
global $wpdb;
|
218 |
$paths = array('mysq' => '', 'mysqldump' => '');
|
219 |
+
if ( substr( PHP_OS,0,3 ) === 'WIN' ) {
|
220 |
$mysql_install = $wpdb->get_row("SHOW VARIABLES LIKE 'basedir'");
|
221 |
if($mysql_install) {
|
222 |
$install_path = trailingslashit( str_replace('\\', '/', $mysql_install->Value) );
|
503 |
|
504 |
add_action( 'init', 'dbmanager_try_fix' );
|
505 |
function dbmanager_try_fix() {
|
506 |
+
if ( ! empty( $_GET['try_fix'] ) && (int) $_GET['try_fix'] === 1 ) {
|
507 |
+
check_admin_referer( 'wp-dbmanager_fix' );
|
508 |
+
dbmanager_create_backup_folder();
|
|
|
|
|
509 |
}
|
510 |
}
|
511 |
|
538 |
|
539 |
### Function: Check whether a function is disabled.
|
540 |
function dbmanager_is_function_disabled( $function_name ) {
|
541 |
+
return in_array( $function_name, array_map( 'trim', explode( ',', ini_get( 'disable_functions' ) ) ), true );
|
542 |
}
|
543 |
|
544 |
### Function: Database Options
|
548 |
$old_backup_options = $backup_options;
|
549 |
if(!empty($_POST['Submit'])) {
|
550 |
check_admin_referer('wp-dbmanager_options');
|
551 |
+
$backup_options['mysqldumppath'] = ! empty( $_POST['db_mysqldumppath'] ) ? sanitize_text_field( $_POST['db_mysqldumppath'] ) : '';
|
552 |
+
$backup_options['mysqlpath'] = ! empty ( $_POST['db_mysqlpath'] ) ? sanitize_text_field( $_POST['db_mysqlpath'] ) : '';
|
553 |
+
$backup_options['path'] = ! empty ( $_POST['db_path'] ) ? sanitize_text_field( $_POST['db_path'] ) : '';
|
554 |
+
$backup_options['max_backup'] = ! empty( $_POST['db_max_backup'] ) ? (int) $_POST['db_max_backup'] : 0;
|
555 |
+
$backup_options['backup'] = ! empty ( $_POST['db_backup'] ) ? (int) $_POST['db_backup'] : 0;
|
556 |
+
$backup_options['backup_gzip'] = ! empty( $_POST['db_backup_gzip'] ) ? (int) $_POST['db_backup_gzip'] : 0;
|
557 |
+
$backup_options['backup_period'] = ! empty( $_POST['db_backup_period'] ) ? (int) $_POST['db_backup_period'] : 0;
|
558 |
+
$backup_options['backup_email'] = ! empty( $_POST['db_backup_email'] ) ? sanitize_email( $_POST['db_backup_email'] ) : '';
|
559 |
+
$backup_options['backup_email_from'] = ! empty( $_POST['db_backup_email_from'] ) ? sanitize_email( $_POST['db_backup_email_from'] ) : '';
|
560 |
+
$backup_options['backup_email_from_name'] = ! empty( $_POST['db_backup_email_from_name'] ) ? sanitize_text_field( $_POST['db_backup_email_from_name'] ) : '';
|
561 |
+
$backup_options['backup_email_subject'] = ! empty( $_POST['db_backup_email_subject'] ) ? sanitize_text_field( $_POST['db_backup_email_subject'] ) : '';
|
562 |
+
$backup_options['optimize'] = ! empty( $_POST['db_optimize'] ) ? (int) $_POST['db_optimize'] : 0;
|
563 |
+
$backup_options['optimize_period'] = ! empty( $_POST['db_optimize_period'] ) ? (int) $_POST['db_optimize_period'] : 0;
|
564 |
+
$backup_options['repair'] = ! empty( $_POST['db_repair'] ) ? (int) $_POST['db_repair'] : 0;
|
565 |
+
$backup_options['repair_period'] = ! empty( $_POST['db_repair_period'] ) ? (int) $_POST['db_repair_period'] : 0;
|
566 |
+
$backup_options['hide_admin_notices'] = ! empty( $_POST['db_hide_admin_notices'] ) ? (int) $_POST['db_hide_admin_notices'] : 0;
|
567 |
|
568 |
if( realpath( $backup_options['path'] ) === false ) {
|
569 |
$text = '<div id="message" class="error"><p>' . sprintf( __( '%s is not a valid backup path', 'wp-dbmanager' ), stripslashes( $backup_options['path'] ) ) . '</p></div>';
|
709 |
}
|
710 |
?>
|
711 |
<p>
|
712 |
+
<?php _e('Every', 'wp-dbmanager'); ?> <input type="text" name="db_backup" size="3" maxlength="5" value="<?php echo esc_attr( $backup_options['backup'] ); ?>" />
|
713 |
<select name="db_backup_period" size="1">
|
714 |
<option value="0"<?php selected('0', $backup_options['backup_period']); ?>><?php _e('Disable', 'wp-dbmanager'); ?></option>
|
715 |
<option value="60"<?php selected('60', $backup_options['backup_period']); ?>><?php _e('Minutes(s)', 'wp-dbmanager'); ?></option>
|
739 |
}
|
740 |
?>
|
741 |
<p>
|
742 |
+
<?php _e('Every', 'wp-dbmanager'); ?> <input type="text" name="db_optimize" size="3" maxlength="5" value="<?php echo esc_attr( $backup_options['optimize'] ); ?>" />
|
743 |
<select name="db_optimize_period" size="1">
|
744 |
<option value="0"<?php selected('0', $backup_options['optimize_period']); ?>><?php _e('Disable', 'wp-dbmanager'); ?></option>
|
745 |
<option value="60"<?php selected('60', $backup_options['optimize_period']); ?>><?php _e('Minutes(s)', 'wp-dbmanager'); ?></option>
|
764 |
}
|
765 |
?>
|
766 |
<p>
|
767 |
+
<?php _e('Every', 'wp-dbmanager'); ?> <input type="text" name="db_repair" size="3" maxlength="5" value="<?php echo esc_attr( $backup_options['repair'] ); ?>" />
|
768 |
<select name="db_repair_period" size="1">
|
769 |
<option value="0"<?php selected('0', $backup_options['repair_period']); ?>><?php _e('Disable', 'wp-dbmanager'); ?></option>
|
770 |
<option value="60"<?php selected('60', $backup_options['repair_period']); ?>><?php _e('Minutes(s)', 'wp-dbmanager'); ?></option>
|
817 |
<td valign="top"><strong><?php _e('Hide Admin Notices', 'wp-dbmanager'); ?></strong></td>
|
818 |
<td>
|
819 |
<p>
|
820 |
+
<input type="radio" name="db_hide_admin_notices" value="1"<?php echo (int) $backup_options['hide_admin_notices'] === 1 ? ' checked="checked"' : ''; ?> /> <?php _e('Yes', 'wp-dbmanager'); ?>
|
821 |
+
<input type="radio" name="db_hide_admin_notices" value="0"<?php echo (int) $backup_options['hide_admin_notices'] === 0 ? ' checked="checked"' : ''; ?> /> <?php _e('No', 'wp-dbmanager'); ?>
|
822 |
</p>
|
823 |
</td>
|
824 |
</tr>
|