PluginProbe
WP-DBManager / 2.80.9
WP-DBManager v2.80.9
4.0.0 trunk 1.00 2.00 2.01 2.02 2.03 2.04 2.05 2.10 2.11 2.20 2.30 2.31 2.40 2.50 2.65 2.70 2.71 2.72 2.73 2.74 2.75 2.76 2.78 All 40 releases
wp-dbmanager / wp-dbmanager.php

wp-dbmanager.php in WP-DBManager 2.80.9, at wp-dbmanager.php

876 lines 40.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
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.80.9
7 Author: Lester 'GaMerZ' Chan
8 Author URI: https://lesterchan.net
9 Text Domain: wp-dbmanager
10 */
11
12
13 /*
14 Copyright 2022 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
18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version.
20
21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
25
26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 */
30
31
32 ### Create Text Domain For Translations
33 add_action( 'plugins_loaded', 'dbmanager_textdomain' );
34 function dbmanager_textdomain() {
35 load_plugin_textdomain( 'wp-dbmanager', false, dirname( plugin_basename( __FILE__ ) ) );
36 }
37
38
39 ### Function: Database Manager Menu
40 add_action('admin_menu', 'dbmanager_menu');
41 function dbmanager_menu() {
42 if (function_exists('add_menu_page')) {
43 add_menu_page(__('Database', 'wp-dbmanager'), __('Database', 'wp-dbmanager'), 'install_plugins', 'wp-dbmanager/database-manager.php', '', 'dashicons-archive');
44 }
45 if (function_exists('add_submenu_page')) {
46 add_submenu_page('wp-dbmanager/database-manager.php', __('Backup DB', 'wp-dbmanager'), __('Backup DB', 'wp-dbmanager'), 'install_plugins', 'wp-dbmanager/database-backup.php');
47 add_submenu_page('wp-dbmanager/database-manager.php', __('Manage Backup DB', 'wp-dbmanager'), __('Manage Backup DB', 'wp-dbmanager'), 'install_plugins', 'wp-dbmanager/database-manage.php');
48 add_submenu_page('wp-dbmanager/database-manager.php', __('Optimize DB', 'wp-dbmanager'), __('Optimize DB', 'wp-dbmanager'), 'install_plugins', 'wp-dbmanager/database-optimize.php');
49 add_submenu_page('wp-dbmanager/database-manager.php', __('Repair DB', 'wp-dbmanager'), __('Repair DB', 'wp-dbmanager'), 'install_plugins', 'wp-dbmanager/database-repair.php');
50 add_submenu_page('wp-dbmanager/database-manager.php', __('Empty/Drop Tables', 'wp-dbmanager'), __('Empty/Drop Tables', 'wp-dbmanager'), 'install_plugins', 'wp-dbmanager/database-empty.php');
51 add_submenu_page('wp-dbmanager/database-manager.php', __('Run SQL Query', 'wp-dbmanager'), __('Run SQL Query', 'wp-dbmanager'), 'install_plugins', 'wp-dbmanager/database-run.php');
52 add_submenu_page('wp-dbmanager/database-manager.php', __('DB Options', 'wp-dbmanager'), __('DB Options', 'wp-dbmanager'), 'install_plugins', 'wp-dbmanager/wp-dbmanager.php', 'dbmanager_options');
53 }
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');
68 add_action('dbmanager_cron_repair', 'cron_dbmanager_repair');
69 function cron_dbmanager_backup() {
70 $backup_options = get_option('dbmanager_options');
71
72 // Enesure that backup path is valid before proceeding
73 if ( empty( $backup_options['path'] ) || ! dbmanager_is_folder_valid( $backup_options['path'] ) ) {
74 return;
75 }
76
77 if ( (int) $backup_options['backup_period'] > 0 ) {
78 $backup = array();
79 $backup['date'] = current_time('timestamp');
80 $backup['mysqldumppath'] = $backup_options['mysqldumppath'];
81 $backup['mysqlpath'] = $backup_options['mysqlpath'];
82 $backup['path'] = $backup_options['path'];
83 $backup['charset'] = ' --default-character-set="utf8mb4"';
84 $backup['host'] = DB_HOST;
85 $backup['port'] = '';
86 $backup['sock'] = '';
87 if ( strpos( DB_HOST, ':' ) !== false ) {
88 $db_host = explode(':', DB_HOST);
89 $backup['host'] = $db_host[0];
90 if ( (int) $db_host[1] !== 0 ) {
91 $backup['port'] = ' --port=' . escapeshellarg( (int) $db_host[1] );
92 } else {
93 $backup['sock'] = ' --socket=' . escapeshellarg( $db_host[1] );
94 }
95 }
96 $backup['command'] = '';
97 $backup['filename'] = $backup['date'] . '_-_' . DB_NAME . '.sql';
98 $brace = 0 === strpos( PHP_OS, 'WIN' ) ? '"' : '';
99 if ( (int) $backup_options['backup_gzip'] === 1 ) {
100 $backup['filename'] .= '.gz';
101 $backup['filepath'] = $backup['path'] . '/'. $backup['filename'];
102 do_action( 'wp_dbmanager_before_escapeshellcmd' );
103 $backup['command'] = $brace . escapeshellcmd( $backup['mysqldumppath'] ) . $brace . ' --force --host=' . escapeshellarg( $backup['host'] ).' --user=' . escapeshellarg( DB_USER ) . ' --password=' . escapeshellarg( DB_PASSWORD ) . $backup['port'] . $backup['sock'] . $backup['charset'] . ' --add-drop-table --skip-lock-tables ' . DB_NAME . ' | gzip > '. $brace . escapeshellcmd( $backup['filepath'] ) . $brace;
104 } else {
105 $backup['filepath'] = $backup['path'] . '/'. $backup['filename'];
106 do_action( 'wp_dbmanager_before_escapeshellcmd' );
107 $backup['command'] = $brace . escapeshellcmd( $backup['mysqldumppath'] ) . $brace . ' --force --host=' . escapeshellarg( $backup['host'] ).' --user=' . escapeshellarg( DB_USER ). ' --password=' . escapeshellarg( DB_PASSWORD ) . $backup['port'] . $backup['sock'] . $backup['charset'] . ' --add-drop-table --skip-lock-tables ' . DB_NAME . ' > ' . $brace . escapeshellcmd( $backup['filepath'] ) . $brace;
108 }
109 execute_backup( $backup['command'] );
110 $new_filepath = $backup['path'] . '/' . md5_file( $backup['filepath'] ) . '_-_' . $backup['filename'];
111 rename( $backup['filepath'], $new_filepath );
112 $backup_email = stripslashes( $backup_options['backup_email'] );
113 if ( ! empty( $backup_email ) ) {
114 dbmanager_email_backup( $backup_email, $new_filepath );
115 }
116 }
117 }
118
119 function cron_dbmanager_optimize() {
120 global $wpdb;
121 $backup_options = get_option('dbmanager_options');
122 $optimize_period = (int) $backup_options['optimize_period'];
123 if($optimize_period > 0) {
124 $optimize_tables = array();
125 $tables = $wpdb->get_col("SHOW TABLES");
126 foreach($tables as $table_name) {
127 $optimize_tables[] = '`'.$table_name.'`';
128 }
129 $wpdb->query('OPTIMIZE TABLE '.implode(',', $optimize_tables));
130 }
131 }
132
133 function cron_dbmanager_repair() {
134 global $wpdb;
135 $backup_options = get_option('dbmanager_options');
136 $repair_period = (int) $backup_options['repair_period'];
137 if($repair_period > 0) {
138 $repair_tables = array();
139 $tables = $wpdb->get_col("SHOW TABLES");
140 foreach($tables as $table_name) {
141 $repair_tables[] = '`'.$table_name.'`';
142 }
143 $wpdb->query('REPAIR TABLE '.implode(',', $repair_tables));
144 }
145 }
146
147 function cron_dbmanager_reccurences($schedules) {
148 $backup_options = get_option( 'dbmanager_options' );
149
150 if( isset( $backup_options['backup'] ) && isset( $backup_options['backup_period'] ) ) {
151 $backup = (int) $backup_options['backup'] * (int) $backup_options['backup_period'];
152 } else {
153 $backup = 0;
154 }
155 if( isset( $backup_options['optimize'] ) && isset( $backup_options['optimize_period'] ) ) {
156 $optimize = (int) $backup_options['optimize'] * (int) $backup_options['optimize_period'];
157 } else {
158 $optimize = 0;
159 }
160 if( isset( $backup_options['repair'] ) && isset( $backup_options['repair_period'] ) ) {
161 $repair = (int) $backup_options['repair'] * (int) $backup_options['repair_period'];
162 } else {
163 $repair = 0;
164 }
165
166 if( $backup === 0 ) {
167 $backup = 31536000;
168 }
169 if( $optimize === 0 ) {
170 $optimize = 31536000;
171 }
172 if( $repair === 0 ) {
173 $repair = 31536000;
174 }
175 $schedules['dbmanager_backup'] = array( 'interval' => $backup, 'display' => __( 'WP-DBManager Backup Schedule', 'wp-dbmanager' ) );
176 $schedules['dbmanager_optimize'] = array( 'interval' => $optimize, 'display' => __( 'WP-DBManager Optimize Schedule', 'wp-dbmanager' ) );
177 $schedules['dbmanager_repair'] = array( 'interval' => $repair, 'display' => __( 'WP-DBManager Repair Schedule', 'wp-dbmanager' ) );
178 return $schedules;
179 }
180
181
182 ### Function: Ensure .htaccess Is In The Backup Folder
183 add_action( 'admin_notices', 'dbmanager_admin_notices' );
184 function dbmanager_admin_notices() {
185 $backup_options = get_option( 'dbmanager_options' );
186 $backup_folder_writable = ( is_dir( $backup_options['path'] ) && wp_is_writable( $backup_options['path'] ) );
187 $htaccess_exists = file_exists( $backup_options['path'] . '/.htaccess' );
188 $webconfig_exists = file_exists( $backup_options['path'] . '/Web.config' );
189 $index_exists = file_exists( $backup_options['path'] . '/index.php' );
190
191 if( ! isset( $backup_options['hide_admin_notices'] ) || (int) $backup_options['hide_admin_notices'] === 0 )
192 {
193 if( ! $backup_folder_writable || ! $index_exists || ( is_iis() && ! $webconfig_exists ) || ( ! is_iis() && ! $htaccess_exists ) ) {
194
195 echo '<div class="error">';
196 if( !$backup_folder_writable ) {
197 echo '<p style="font-weight: bold;">' . __( 'Your backup folder is NOT writable', 'wp-postratings') . '</p>';
198 echo '<p>'.sprintf( __( 'To correct this issue, make the folder <strong>%s</strong> writable.', 'wp-dbmanager' ), $backup_options['path'] ).'</p>';
199 }
200 if( ! $index_exists || ( is_iis() && ! $webconfig_exists ) || ( ! is_iis() && ! $htaccess_exists ) ) {
201 echo '<p style="font-weight: bold;">'.__( 'Your backup folder MIGHT be visible to the public', 'wp-dbmanager' ).'</p>';
202 }
203 if( is_iis() ) {
204 if( ! $webconfig_exists ) {
205 echo '<p>'.sprintf( __( 'To correct this issue, move the file from <strong>%s</strong> to <strong>%s</strong>', 'wp-dbmanager'), plugin_dir_path( __FILE__ ) . 'Web.config.txt', $backup_options['path'] .'/Web.config' ).'</p>';
206 }
207 } else {
208 if( ! $htaccess_exists ) {
209 echo '<p>'.sprintf( __( 'To correct this issue, move the file from <strong>%s</strong> to <strong>%s</strong>', 'wp-dbmanager'), plugin_dir_path( __FILE__ ) . 'htaccess.txt', $backup_options['path'] .'/.htaccess' ).'</p>';
210 }
211 }
212 if( ! $index_exists ) {
213 echo '<p>'.sprintf( __( 'To correct this issue, move the file from <strong>%s</strong> to <strong>%s</strong>', 'wp-dbmanager'), plugin_dir_path( __FILE__ ) . 'index.php', $backup_options['path'] .'/index.php' ).'</p>';
214 }
215 echo '<p>' . sprintf( __( '<a href="%s">Click here</a> to let WP-DBManager try to fix it', 'wp-dbmanager' ), wp_nonce_url( admin_url( 'admin.php?page=wp-dbmanager/database-backup.php&try_fix=1' ), 'wp-dbmanager_fix' ) ) . '</a></p>';
216 echo '</div>';
217 }
218 }
219 }
220
221
222 ### Function: Auto Detect MYSQL and MYSQL Dump Paths
223 function detect_mysql() {
224 global $wpdb;
225 $paths = array('mysq' => '', 'mysqldump' => '');
226 if ( substr( PHP_OS,0,3 ) === 'WIN' ) {
227 $mysql_install = $wpdb->get_row("SHOW VARIABLES LIKE 'basedir'");
228 if($mysql_install) {
229 $install_path = trailingslashit( str_replace('\\', '/', $mysql_install->Value) );
230 $paths['mysql'] = $install_path.'bin/mysql.exe';
231 $paths['mysqldump'] = $install_path.'bin/mysqldump.exe';
232 } else {
233 $paths['mysql'] = 'mysql.exe';
234 $paths['mysqldump'] = 'mysqldump.exe';
235 }
236 } else {
237 if(function_exists('exec')) {
238 $paths['mysql'] = @exec('which mysql');
239 $paths['mysqldump'] = @exec('which mysqldump');
240 } else {
241 $paths['mysql'] = 'mysql';
242 $paths['mysqldump'] = 'mysqldump';
243 }
244 }
245 return $paths;
246 }
247
248 ### Function: Check if WordPress is installed on IIS
249 function is_iis() {
250 $server_software = strtolower( $_SERVER['SERVER_SOFTWARE'] );
251 if ( strpos( $server_software, 'microsoft-iis') !== false ) {
252 return true;
253 }
254
255 return false;
256 }
257
258 ### Executes OS-Dependent mysqldump Command (By: Vlad Sharanhovich)
259 function execute_backup($command) {
260 $backup_options = get_option('dbmanager_options');
261 check_backup_files();
262
263 if( realpath( $backup_options['path'] ) === false ) {
264 return sprintf( __( '%s is not a valid backup path', 'wp-dbmanager' ), stripslashes( $backup_options['path'] ) );
265 } else if( dbmanager_is_valid_path( $backup_options['mysqldumppath'] ) === 0 ) {
266 return sprintf( __( '%s is not a valid mysqldump path', 'wp-dbmanager' ), stripslashes( $backup_options['mysqldumppath'] ) );
267 } else if( dbmanager_is_valid_path( $backup_options['mysqlpath'] ) === 0 ) {
268 return sprintf( __( '%s is not a valid mysql path', 'wp-dbmanager' ), stripslashes( $backup_options['mysqlpath'] ) );
269 }
270
271 if( substr( PHP_OS, 0, 3 ) === 'WIN' ) {
272 $writable_dir = $backup_options['path'];
273 $tmpnam = $writable_dir.'/wp-dbmanager.bat';
274 $fp = fopen( $tmpnam, 'w' );
275 fwrite ($fp, $command );
276 fclose( $fp );
277 system( $tmpnam.' > NUL', $error );
278 unlink( $tmpnam );
279 } else {
280 passthru( $command, $error );
281 }
282 return $error;
283 }
284
285 ### Function: Check for valid file path
286 function dbmanager_is_valid_path( $path ) {
287 return preg_match( '/^[^*?"<>|;]*$/', $path );
288 }
289
290 ### Functionn : Breakdown the file name into array
291 function dbmanager_parse_filename( $filename ) {
292 $file_parts = explode( '_-_', $filename );
293 if ( count( $file_parts ) > 2 ) {
294 $file = array(
295 'checksum' => $file_parts[0],
296 'timestamp' => $file_parts[1],
297 'database' => $file_parts[2],
298 );
299 } else {
300 $file = array(
301 'checksum' => '-',
302 'timestamp' => $file_parts[0],
303 'database' => $file_parts[1],
304 );
305 }
306
307 $file['name'] = $filename;
308 $file['formatted_date'] = mysql2date( sprintf( __( '%s @ %s', 'wp-dbmanager' ), get_option( 'date_format' ), get_option( 'time_format' ) ), gmdate( 'Y-m-d H:i:s', $file['timestamp'] ) );
309
310 return $file;
311 }
312
313 ### Functionn : Return extra information like file size and nice date of the file
314 function dbmanager_parse_file( $filepath ) {
315 $filename = basename( $filepath );
316 $file_parts = dbmanager_parse_filename( $filename );
317 $file_parts['path'] = dirname( $filepath );
318 $file_parts['size'] = filesize( $filepath );
319 $file_parts['formatted_size'] = format_size( $file_parts['size'] );
320
321 return $file_parts;
322 }
323
324 ### Function: Email database backup
325 function dbmanager_email_backup( $to, $backup_file_path ) {
326 $to = ( !empty( $to ) ? $to : get_option( 'admin_email' ) );
327
328 if( is_email( $to ) && file_exists( $backup_file_path ) ) {
329 $backup_options = get_option( 'dbmanager_options' );
330
331 $file = dbmanager_parse_file( $backup_file_path );
332 $file_gmt_date = gmdate( 'Y-m-d H:i:s', $file['timestamp'] );
333
334 $subject = ( ! empty( $backup_options['backup_email_subject'] ) ? $backup_options['backup_email_subject'] : dbmanager_default_options( 'backup_email_subject' ) );
335 $subject = str_replace(
336 array(
337 '%SITE_NAME%',
338 '%POST_DATE%',
339 '%POST_TIME%'
340 ),
341 array(
342 wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ),
343 mysql2date( get_option( 'date_format' ), $file_gmt_date ),
344 mysql2date( get_option( 'time_format' ), $file_gmt_date )
345 )
346 , $subject
347 );
348 $message = __( 'Website Name:', 'wp-dbmanager' ) . ' ' . wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) . "\n" .
349 __( 'Website URL:', 'wp-dbmanager' ) . ' '. get_bloginfo( 'url' ) . "\n\n" .
350 __( 'Backup File Name:', 'wp-dbmanager' ) . ' ' . $file['name'] . "\n" .
351 __( 'Backup File MD5 Checksum:', 'wp-dbmanager' ) . ' ' . $file['checksum'] . "\n" .
352 __( 'Backup File Date:', 'wp-dbmanager' ) . ' ' . $file['formatted_date'] . "\n" .
353 __( 'Backup File Size:', 'wp-dbmanager' ) . ' ' . $file['formatted_size'] . "\n\n" .
354 __( 'With Regards,', 'wp-dbmanager' )."\n".
355 wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) . ' ' . __('Administrator', 'wp-dbmanager' ) . "\n" .
356 get_bloginfo( 'url' );
357
358 $from = ( ! empty( $backup_options['backup_email_from'] ) ? $backup_options['backup_email_from'] : dbmanager_default_options( 'backup_email_from' ) );
359 $from_name = ( ! empty( $backup_options['backup_email_from_name'] ) ? $backup_options['backup_email_from_name'] : dbmanager_default_options( 'backup_email_from_name' ) );
360 $headers[] = 'From: "' . wp_specialchars_decode( stripslashes_deep( $from_name ), ENT_QUOTES ) . '" <' . $from . '>';
361
362 return wp_mail( $to, $subject, $message, $headers, $backup_file_path );
363 }
364
365 return false;
366 }
367
368
369 ### Function: Format Bytes Into KB/MB
370 if(!function_exists('format_size')) {
371 function format_size($rawSize) {
372 if($rawSize / 1073741824 > 1)
373 return number_format_i18n($rawSize/1048576, 1) . ' '.__('GiB', 'wp-dbmanager');
374 else if ($rawSize / 1048576 > 1)
375 return number_format_i18n($rawSize/1048576, 1) . ' '.__('MiB', 'wp-dbmanager');
376 else if ($rawSize / 1024 > 1)
377 return number_format_i18n($rawSize/1024, 1) . ' '.__('KiB', 'wp-dbmanager');
378 else
379 return number_format_i18n($rawSize, 0) . ' '.__('bytes', 'wp-dbmanager');
380 }
381 }
382
383
384 ### Function: Get File Extension
385 if(!function_exists('file_ext')) {
386 function file_ext($file_name) {
387 return substr(strrchr($file_name, '.'), 1);
388 }
389 }
390
391
392 ### Function: Check Folder Whether There Are Any Files Inside
393 function dbmanager_is_folder_valid( $folder ){
394 // Check folder whether it is readable
395 if ( ! is_readable( $folder ) ) {
396 return false;
397 }
398
399 // Ensure folder is a directory
400 if ( ! is_dir( $folder ) ) {
401 return false;
402 }
403
404 // Ensure folder is not empty. 2 because it includes '.' and '..'
405 if ( scandir( $folder ) <= 2 ) {
406 return false;
407 }
408
409 return true;
410 }
411
412
413 ### Function: Make Sure Maximum Number Of Database Backup Files Does Not Exceed
414 function check_backup_files() {
415 $backup_options = get_option( 'dbmanager_options' );
416 $database_files = array();
417 if ( dbmanager_is_folder_valid( $backup_options['path'] ) ) {
418 if ( $handle = opendir($backup_options['path'] ) ) {
419 while ( false !== ( $file = readdir( $handle ) ) ) {
420 if ( $file !== '.' && $file !== '..' && ( file_ext( $file ) === 'sql' || file_ext( $file ) === 'gz' ) ) {
421 $database_files[ filemtime( $backup_options['path'] . '/' . $file ) ] = $file;
422 }
423 }
424 closedir( $handle );
425 ksort( $database_files );
426 }
427 }
428 if ( sizeof( $database_files ) >= $backup_options['max_backup'] ) {
429 @unlink( $backup_options['path'] . '/' . $database_files[ array_key_first( $database_files ) ] );
430 }
431 }
432
433
434 ### Function: DBManager Default Options
435 function dbmanager_default_options( $option_name )
436 {
437 switch( $option_name ) {
438 case 'backup_email_from':
439 return get_option( 'admin_email' );
440 break;
441 case 'backup_email_from_name':
442 return wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) .' '.__( 'Administrator', 'wp-dbmanager' );
443 break;
444 case 'backup_email_subject':
445 return __( '%SITE_NAME% Database Backup File For %POST_DATE% @ %POST_TIME%', 'wp-dbmanager' );
446 break;
447 case 'hide_admin_notices':
448 return 0;
449 break;
450 }
451 }
452
453 ### Function: Acticate Plugin
454 register_activation_hook( __FILE__, 'dbmanager_activation' );
455 function dbmanager_activation( $network_wide ) {
456 $auto = detect_mysql();
457 // Add Options
458 $option_name = 'dbmanager_options';
459 $option = array(
460 'mysqldumppath' => $auto['mysqldump']
461 , 'mysqlpath' => $auto['mysql']
462 , 'path' => str_replace( '\\', '/', WP_CONTENT_DIR ).'/backup-db'
463 , 'max_backup' => 10
464 , 'backup' => 1
465 , 'backup_gzip' => 0
466 , 'backup_period' => 604800
467 , 'backup_email' => get_option( 'admin_email' )
468 , 'backup_email_from' => dbmanager_default_options( 'backup_email_from' )
469 , 'backup_email_from_name' => dbmanager_default_options( 'backup_email_from_name' )
470 , 'backup_email_subject' => dbmanager_default_options( 'backup_email_subject' )
471 , 'optimize' => 3
472 , 'optimize_period' => 86400
473 , 'repair' => 2
474 , 'repair_period' => 604800
475 , 'hide_admin_notices' => 0
476 );
477
478 if ( is_multisite() && $network_wide ) {
479 $ms_sites = function_exists( 'get_sites' ) ? get_sites() : wp_get_sites();
480
481 if( 0 < sizeof( $ms_sites ) ) {
482 foreach ( $ms_sites as $ms_site ) {
483 $blog_id = class_exists( 'WP_Site' ) ? $ms_site->blog_id : $ms_site['blog_id'];
484 switch_to_blog( $blog_id );
485 add_option( $option_name, $option );
486 dbmanager_activate();
487 }
488 }
489
490 restore_current_blog();
491 } else {
492 add_option( $option_name, $option );
493 dbmanager_activate();
494 }
495 }
496
497 function dbmanager_activate() {
498 dbmanager_create_backup_folder();
499
500 // Remove 'manage_database', we use 'install_plugins' from 2.80.6
501 $role = get_role( 'administrator' );
502 if( $role->has_cap( 'manage_database') ) {
503 $role->remove_cap( 'manage_database' );
504 }
505 }
506
507 function dbmanager_create_backup_folder() {
508 $plugin_path = plugin_dir_path( __FILE__ );
509 $backup_path = WP_CONTENT_DIR . '/backup-db';
510 $backup_options = get_option( 'dbmanager_options' );
511
512 if( ! empty( $backup_options['path'] ) ) {
513 $backup_path = $backup_options['path'];
514 }
515
516 // Create Backup Folder
517 wp_mkdir_p( $backup_path );
518 if( is_dir( $backup_path ) && wp_is_writable( $backup_path ) ) {
519 if( is_iis() ) {
520 if ( ! is_file( $backup_path . '/Web.config' ) ) {
521 @copy( $plugin_path . 'Web.config.txt', $backup_path . '/Web.config' );
522 }
523 } else {
524 if( ! is_file( $backup_path . '/.htaccess' ) ) {
525 @copy( $plugin_path . 'htaccess.txt', $backup_path . '/.htaccess' );
526 }
527 }
528 if( ! is_file( $backup_path . '/index.php' ) ) {
529 @copy( $plugin_path . 'index.php', $backup_path . '/index.php' );
530 }
531 @chmod( $backup_path, 0750 );
532 }
533 }
534
535 add_action( 'init', 'dbmanager_try_fix' );
536 function dbmanager_try_fix() {
537 if ( ! empty( $_GET['try_fix'] ) && (int) $_GET['try_fix'] === 1 ) {
538 check_admin_referer( 'wp-dbmanager_fix' );
539 dbmanager_create_backup_folder();
540 }
541 }
542
543
544 ### Function: Download Database
545 add_action( 'init', 'download_database' );
546 function download_database() {
547 if( isset( $_POST['do'] ) && $_POST['do'] === __( 'Download', 'wp-dbmanager' ) && ! empty( $_POST['database_file'] ) ) {
548 check_admin_referer( 'wp-dbmanager_manage' );
549 $database_file = trim( $_POST['database_file'] );
550 if( substr( $database_file, strlen( $database_file ) -4, 4 ) === '.sql' || substr( $database_file, strlen( $database_file ) -7, 7 ) === '.sql.gz' ) {
551 $backup_options = get_option( 'dbmanager_options' );
552 $clean_file_name = sanitize_file_name( $database_file );
553 $clean_file_name = str_replace( 'sql_.gz', 'sql.gz', $clean_file_name );
554 $file_path = $backup_options['path'] . '/' . $clean_file_name;
555 header( 'Pragma: public' );
556 header( 'Expires: 0' );
557 header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
558 header( 'Content-Type: application/force-download' );
559 header( 'Content-Type: application/octet-stream' );
560 header( 'Content-Type: application/download' );
561 header( 'Content-Disposition: attachment; filename=' . basename( $file_path ) . ';' );
562 header( 'Content-Transfer-Encoding: binary' );
563 header( 'Content-Length: ' . filesize( $file_path ) );
564 @readfile( $file_path );
565 }
566 exit();
567 }
568 }
569
570 ### Function: Check whether a function is disabled.
571 function dbmanager_is_function_disabled( $function_name ) {
572 return in_array( $function_name, array_map( 'trim', explode( ',', ini_get( 'disable_functions' ) ) ), true );
573 }
574
575 ### Function: Polyfill array_key_first() for PHP < 7.3
576 if ( ! function_exists( 'array_key_first' ) ) {
577 function array_key_first( $arr ) {
578 foreach( $arr as $key => $unused ) {
579 return $key;
580 }
581 return null;
582 }
583 }
584
585 ### Function: Database Options
586 function dbmanager_options() {
587 $text = '';
588 $backup_options = get_option('dbmanager_options');
589 $old_backup_options = $backup_options;
590 if(!empty($_POST['Submit'])) {
591 check_admin_referer('wp-dbmanager_options');
592 $backup_options['mysqldumppath'] = ! empty( $_POST['db_mysqldumppath'] ) ? sanitize_text_field( $_POST['db_mysqldumppath'] ) : '';
593 $backup_options['mysqlpath'] = ! empty ( $_POST['db_mysqlpath'] ) ? sanitize_text_field( $_POST['db_mysqlpath'] ) : '';
594 $backup_options['path'] = ! empty ( $_POST['db_path'] ) ? sanitize_text_field( $_POST['db_path'] ) : '';
595 $backup_options['max_backup'] = ! empty( $_POST['db_max_backup'] ) ? (int) $_POST['db_max_backup'] : 0;
596 $backup_options['backup'] = ! empty ( $_POST['db_backup'] ) ? (int) $_POST['db_backup'] : 0;
597 $backup_options['backup_gzip'] = ! empty( $_POST['db_backup_gzip'] ) ? (int) $_POST['db_backup_gzip'] : 0;
598 $backup_options['backup_period'] = ! empty( $_POST['db_backup_period'] ) ? (int) $_POST['db_backup_period'] : 0;
599 $backup_options['backup_email'] = ! empty( $_POST['db_backup_email'] ) ? sanitize_email( $_POST['db_backup_email'] ) : '';
600 $backup_options['backup_email_from'] = ! empty( $_POST['db_backup_email_from'] ) ? sanitize_email( $_POST['db_backup_email_from'] ) : '';
601 $backup_options['backup_email_from_name'] = ! empty( $_POST['db_backup_email_from_name'] ) ? sanitize_text_field( $_POST['db_backup_email_from_name'] ) : '';
602 $backup_options['backup_email_subject'] = ! empty( $_POST['db_backup_email_subject'] ) ? sanitize_text_field( $_POST['db_backup_email_subject'] ) : '';
603 $backup_options['optimize'] = ! empty( $_POST['db_optimize'] ) ? (int) $_POST['db_optimize'] : 0;
604 $backup_options['optimize_period'] = ! empty( $_POST['db_optimize_period'] ) ? (int) $_POST['db_optimize_period'] : 0;
605 $backup_options['repair'] = ! empty( $_POST['db_repair'] ) ? (int) $_POST['db_repair'] : 0;
606 $backup_options['repair_period'] = ! empty( $_POST['db_repair_period'] ) ? (int) $_POST['db_repair_period'] : 0;
607 $backup_options['hide_admin_notices'] = ! empty( $_POST['db_hide_admin_notices'] ) ? (int) $_POST['db_hide_admin_notices'] : 0;
608
609 if( realpath( $backup_options['path'] ) === false ) {
610 $text = '<div id="message" class="error"><p>' . sprintf( __( '%s is not a valid backup path', 'wp-dbmanager' ), stripslashes( $backup_options['path'] ) ) . '</p></div>';
611 $backup_options['path'] = $old_backup_options['path'];
612 } else if( dbmanager_is_valid_path( $backup_options['mysqldumppath'] ) === 0 ) {
613 $text = '<div id="message" class="error"><p>' . sprintf( __( '%s is not a valid mysqldump path', 'wp-dbmanager' ), stripslashes( $backup_options['mysqldumppath'] ) ) . '</p></div>';
614 $backup_options['mysqldumppath'] = $old_backup_options['mysqldumppath'];
615 } else if( dbmanager_is_valid_path( $backup_options['mysqlpath'] ) === 0 ) {
616 $text = '<div id="message" class="error"><p>' . sprintf( __( '%s is not a valid mysql path', 'wp-dbmanager' ), stripslashes( $backup_options['mysqlpath'] ) ) . '</p></div>';
617 $backup_options['mysqlpath'] = $old_backup_options['mysqlpath'];
618 }
619
620 $update_db_options = update_option( 'dbmanager_options', $backup_options );
621 if( $update_db_options ) {
622 $text = '<div id="message" class="updated"><p>' . __( 'Database Options Updated', 'wp-dbmanager' ) . '</p></div>';
623 }
624 if( empty( $text ) ) {
625 $text = '<div id="message" class="error"><p>' . __( 'No Database Option Updated', 'wp-dbmanager' ) . '</p></div>';
626 }
627 wp_clear_scheduled_hook( 'dbmanager_cron_backup' );
628 if( $backup_options['backup_period'] > 0 ) {
629 if ( ! wp_next_scheduled( 'dbmanager_cron_backup' ) ) {
630 wp_schedule_event( time(), 'dbmanager_backup', 'dbmanager_cron_backup' );
631 }
632 }
633 wp_clear_scheduled_hook( 'dbmanager_cron_optimize' );
634 if( $backup_options['optimize_period'] > 0 ) {
635 if ( ! wp_next_scheduled('dbmanager_cron_optimize' ) ) {
636 wp_schedule_event( time(), 'dbmanager_optimize', 'dbmanager_cron_optimize' );
637 }
638 }
639 wp_clear_scheduled_hook( 'dbmanager_cron_repair' );
640 if( $backup_options['repair_period'] > 0 ) {
641 if ( ! wp_next_scheduled( 'dbmanager_cron_repair' ) ) {
642 wp_schedule_event( time(), 'dbmanager_repair', 'dbmanager_cron_repair' );
643 }
644 }
645 }
646 $path = detect_mysql();
647
648 // Default Options
649 if( !isset( $backup_options['backup_email_from'] ) )
650 {
651 $backup_options['backup_email_from'] = dbmanager_default_options( 'backup_email_from' );
652 }
653 if( !isset( $backup_options['backup_email_from_name'] ) )
654 {
655 $backup_options['backup_email_from_name'] = dbmanager_default_options( 'backup_email_from_name' );
656 }
657 if( !isset( $backup_options['backup_email_subject'] ) )
658 {
659 $backup_options['backup_email_subject'] = dbmanager_default_options( 'backup_email_subject' );
660 }
661 if( !isset( $backup_options['hide_admin_notices'] ) )
662 {
663 $backup_options['hide_admin_notices'] = dbmanager_default_options( 'hide_admin_notices' );
664 }
665
666 ?>
667 <script type="text/javascript">
668 /* <![CDATA[*/
669 function mysqlpath() {
670 jQuery("#db_mysqlpath").val("<?php echo $path['mysql']; ?>");
671 }
672 function mysqldumppath() {
673 jQuery("#db_mysqldumppath").val("<?php echo $path['mysqldump']; ?>");
674 }
675 /* ]]> */
676 </script>
677 <?php if( ! empty( $text ) ) { echo $text; } ?>
678 <!-- Database Options -->
679 <form method="post" action="<?php echo admin_url('admin.php?page='.plugin_basename(__FILE__)); ?>">
680 <?php wp_nonce_field('wp-dbmanager_options'); ?>
681 <div class="wrap">
682 <h2><?php _e('Database Options', 'wp-dbmanager'); ?></h2>
683 <h3><?php _e('Paths', 'wp-dbmanager'); ?></h3>
684 <table class="form-table">
685 <tr>
686 <td width="20%" valign="top"><strong><?php _e('Path To mysqldump:', 'wp-dbmanager'); ?></strong></td>
687 <td width="80%">
688 <input type="text" id="db_mysqldumppath" name="db_mysqldumppath" size="60" maxlength="100" value="<?php echo stripslashes($backup_options['mysqldumppath']); ?>" dir="ltr" />&nbsp;&nbsp;<input type="button" value="<?php _e('Auto Detect', 'wp-dbmanager'); ?>" onclick="mysqldumppath();" />
689 <p><?php _e('The absolute path to mysqldump without trailing slash. If unsure, please email your server administrator about this.', 'wp-dbmanager'); ?></p>
690 </td>
691 </tr>
692 <tr>
693 <td valign="top"><strong><?php _e('Path To mysql:', 'wp-dbmanager'); ?></strong></td>
694 <td>
695 <input type="text" id="db_mysqlpath" name="db_mysqlpath" size="60" maxlength="100" value="<?php echo stripslashes($backup_options['mysqlpath']); ?>" dir="ltr" />&nbsp;&nbsp;<input type="button" value="<?php _e('Auto Detect', 'wp-dbmanager'); ?>" onclick="mysqlpath();" />
696 <p><?php _e('The absolute path to mysql without trailing slash. If unsure, please email your server administrator about this.', 'wp-dbmanager'); ?></p>
697 </td>
698 </tr>
699 <tr>
700 <td valign="top"><strong><?php _e('Path To Backup:', 'wp-dbmanager'); ?></strong></td>
701 <td>
702 <input type="text" name="db_path" size="60" maxlength="200" value="<?php echo stripslashes($backup_options['path']); ?>" dir="ltr" />
703 <p><?php _e('The absolute path to your database backup folder without trailing slash. Make sure the folder is writable.', 'wp-dbmanager'); ?></p>
704 </td>
705 </tr>
706 <tr>
707 <td valign="top"><strong><?php _e('Maximum Backup Files:', 'wp-dbmanager'); ?></strong></td>
708 <td>
709 <input type="text" name="db_max_backup" size="5" maxlength="5" value="<?php echo stripslashes($backup_options['max_backup']); ?>" />
710 <p><?php _e('The maximum number of database backup files that is allowed in the backup folder as stated above. The oldest database backup file is always deleted in order to maintain this value. This is to prevent the backup folder from getting too large.', 'wp-dbmanager'); ?></p>
711 </td>
712 </tr>
713 </table>
714
715 <h3><?php _e('Note', 'wp-dbmanager'); ?></h3>
716 <table class="form-table">
717 <tr>
718 <td>
719 <strong><?php _e('Windows Server', 'wp-dbmanager'); ?></strong><br />
720 <?php _e('For mysqldump path, you can try \'<strong>mysqldump.exe</strong>\'.', 'wp-dbmanager'); ?><br />
721 <?php _e('For mysql path, you can try \'<strong>mysql.exe</strong>\'.', 'wp-dbmanager'); ?>
722 </td>
723 </tr>
724 <tr>
725 <td>
726 <strong><?php _e('Linux Server', 'wp-dbmanager'); ?></strong><br />
727 <?php _e('For mysqldump path, normally is just \'<strong>mysqldump</strong>\'.', 'wp-dbmanager'); ?><br />
728 <?php _e('For mysql path, normally is just \'<strong>mysql</strong>\'.', 'wp-dbmanager'); ?>
729 </td>
730 </tr>
731 <tr>
732 <td>
733 <strong><?php _e('Note', 'wp-dbmanager'); ?></strong><br />
734 <?php _e('The \'Auto Detect\' function does not work for some servers. If it does not work for you, please contact your server administrator for the MYSQL and MYSQL DUMP paths.', 'wp-dbmanager'); ?>
735 </td>
736 </tr>
737 </table>
738
739 <h3><?php _e('Automatic Scheduling', 'wp-dbmanager'); ?></h3>
740 <table class="form-table">
741 <tr>
742 <td valign="top"><strong><?php _e('Automatic Backing Up Of DB:', 'wp-dbmanager'); ?></strong></td>
743 <td>
744 <?php
745 _e('Next backup date: ', 'wp-dbmanager');
746 if(wp_next_scheduled('dbmanager_cron_backup')) {
747 echo '<strong>'.mysql2date(sprintf(__('%s @ %s', 'wp-dbmanager'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', (wp_next_scheduled('dbmanager_cron_backup') + (get_option('gmt_offset') * 3600)))).'</strong>';
748 } else {
749 _e('N/A', 'wp-dbmanager');
750 }
751 ?>
752 <p>
753 <?php _e('Every', 'wp-dbmanager'); ?>&nbsp;<input type="text" name="db_backup" size="3" maxlength="5" value="<?php echo esc_attr( $backup_options['backup'] ); ?>" />&nbsp;
754 <select name="db_backup_period" size="1">
755 <option value="0"<?php selected('0', $backup_options['backup_period']); ?>><?php _e('Disable', 'wp-dbmanager'); ?></option>
756 <option value="60"<?php selected('60', $backup_options['backup_period']); ?>><?php _e('Minutes(s)', 'wp-dbmanager'); ?></option>
757 <option value="3600"<?php selected('3600', $backup_options['backup_period']); ?>><?php _e('Hour(s)', 'wp-dbmanager'); ?></option>
758 <option value="86400"<?php selected('86400', $backup_options['backup_period']); ?>><?php _e('Day(s)', 'wp-dbmanager'); ?></option>
759 <option value="604800"<?php selected('604800', $backup_options['backup_period']); ?>><?php _e('Week(s)', 'wp-dbmanager'); ?></option>
760 <option value="2592000"<?php selected('2592000', $backup_options['backup_period']); ?>><?php _e('Month(s)', 'wp-dbmanager'); ?></option>
761 </select>&nbsp;&nbsp;&nbsp;
762 <?php _e('Gzip', 'wp-dbmanager'); ?>
763 <select name="db_backup_gzip" size="1">
764 <option value="0"<?php selected('0', $backup_options['backup_gzip']); ?>><?php _e('No', 'wp-dbmanager'); ?></option>
765 <option value="1"<?php selected('1', $backup_options['backup_gzip']); ?>><?php _e('Yes', 'wp-dbmanager'); ?></option>
766 </select>
767 </p>
768 <p><?php _e('WP-DBManager can automatically backup your database after a certain period.', 'wp-dbmanager'); ?></p>
769 </td>
770 </tr>
771 <tr>
772 <td valign="top"><strong><?php _e('Automatic Optimizing Of DB:', 'wp-dbmanager'); ?></strong></td>
773 <td>
774 <?php
775 _e('Next optimize date: ', 'wp-dbmanager');
776 if(wp_next_scheduled('dbmanager_cron_optimize')) {
777 echo '<strong>'.mysql2date(sprintf(__('%s @ %s', 'wp-dbmanager'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', (wp_next_scheduled('dbmanager_cron_optimize') + (get_option('gmt_offset') * 3600)))).'</strong>';
778 } else {
779 _e('N/A', 'wp-dbmanager');
780 }
781 ?>
782 <p>
783 <?php _e('Every', 'wp-dbmanager'); ?>&nbsp;<input type="text" name="db_optimize" size="3" maxlength="5" value="<?php echo esc_attr( $backup_options['optimize'] ); ?>" />&nbsp;
784 <select name="db_optimize_period" size="1">
785 <option value="0"<?php selected('0', $backup_options['optimize_period']); ?>><?php _e('Disable', 'wp-dbmanager'); ?></option>
786 <option value="60"<?php selected('60', $backup_options['optimize_period']); ?>><?php _e('Minutes(s)', 'wp-dbmanager'); ?></option>
787 <option value="3600"<?php selected('3600', $backup_options['optimize_period']); ?>><?php _e('Hour(s)', 'wp-dbmanager'); ?></option>
788 <option value="86400"<?php selected('86400', $backup_options['optimize_period']); ?>><?php _e('Day(s)', 'wp-dbmanager'); ?></option>
789 <option value="604800"<?php selected('604800', $backup_options['optimize_period']); ?>><?php _e('Week(s)', 'wp-dbmanager'); ?></option>
790 <option value="2592000"<?php selected('2592000', $backup_options['optimize_period']); ?>><?php _e('Month(s)', 'wp-dbmanager'); ?></option>
791 </select>
792 </p>
793 <p><?php _e('WP-DBManager can automatically optimize your database after a certain period.', 'wp-dbmanager'); ?></p>
794 </td>
795 </tr>
796 <tr>
797 <td valign="top"><strong><?php _e('Automatic Repairing Of DB:', 'wp-dbmanager'); ?></strong></td>
798 <td>
799 <?php
800 _e('Next repair date: ', 'wp-dbmanager');
801 if(wp_next_scheduled('dbmanager_cron_repair')) {
802 echo '<strong>'.mysql2date(sprintf(__('%s @ %s', 'wp-dbmanager'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', (wp_next_scheduled('dbmanager_cron_repair') + (get_option('gmt_offset') * 3600)))).'</strong>';
803 } else {
804 _e('N/A', 'wp-dbmanager');
805 }
806 ?>
807 <p>
808 <?php _e('Every', 'wp-dbmanager'); ?>&nbsp;<input type="text" name="db_repair" size="3" maxlength="5" value="<?php echo esc_attr( $backup_options['repair'] ); ?>" />&nbsp;
809 <select name="db_repair_period" size="1">
810 <option value="0"<?php selected('0', $backup_options['repair_period']); ?>><?php _e('Disable', 'wp-dbmanager'); ?></option>
811 <option value="60"<?php selected('60', $backup_options['repair_period']); ?>><?php _e('Minutes(s)', 'wp-dbmanager'); ?></option>
812 <option value="3600"<?php selected('3600', $backup_options['repair_period']); ?>><?php _e('Hour(s)', 'wp-dbmanager'); ?></option>
813 <option value="86400"<?php selected('86400', $backup_options['repair_period']); ?>><?php _e('Day(s)', 'wp-dbmanager'); ?></option>
814 <option value="604800"<?php selected('604800', $backup_options['repair_period']); ?>><?php _e('Week(s)', 'wp-dbmanager'); ?></option>
815 <option value="2592000"<?php selected('2592000', $backup_options['repair_period']); ?>><?php _e('Month(s)', 'wp-dbmanager'); ?></option>
816 </select>
817 </p>
818 <p><?php _e('WP-DBManager can automatically repair your database after a certain period.', 'wp-dbmanager'); ?></p>
819 </td>
820 </tr>
821 </table>
822
823 <h3><?php _e('Backup Email Options', 'wp-dbmanager'); ?></h3>
824 <table class="form-table">
825 <tr>
826 <td valign="top"><strong><?php _e('To', 'wp-dbmanager'); ?></strong></td>
827 <td>
828 <p>
829 <input type="text" name="db_backup_email" size="30" maxlength="250" placeholder="<?php _e ( 'To E-mail', 'wp-dbmanager' ); ?>" value="<?php echo esc_attr( stripslashes( $backup_options['backup_email'] ) ) ?>" dir="ltr" />
830 </p>
831 <p><?php _e('(Leave blank to disable this feature)', 'wp-dbmanager'); ?></p>
832 </td>
833 </tr>
834 <tr>
835 <td valign="top"><strong><?php _e('From', 'wp-dbmanager'); ?></strong></td>
836 <td>
837 <p>
838 <input type="text" name="db_backup_email_from_name" size="60" maxlength="250" placeholder="<?php _e ( 'From Name', 'wp-dbmanager' ); ?>" value="<?php echo esc_attr( stripslashes( $backup_options['backup_email_from_name'] ) ) ?>" dir="ltr" />&nbsp;
839 &lt;<input type="text" name="db_backup_email_from" size="30" maxlength="250" placeholder="<?php _e ( 'From E-mail', 'wp-dbmanager' ); ?>" value="<?php echo esc_attr( stripslashes( $backup_options['backup_email_from'] ) ) ?>" dir="ltr" />&gt;
840 </p>
841 <p><?php _e('(Leave blank to use the default)', 'wp-dbmanager'); ?></p>
842 </td>
843 </tr>
844 <tr>
845 <td valign="top"><strong><?php _e('Subject:', 'wp-dbmanager'); ?></strong></td>
846 <td>
847 <p>
848 <input type="text" name="db_backup_email_subject" size="90" maxlength="255" placeholder="<?php _e ( 'Subject', 'wp-dbmanager' ); ?>" value="<?php echo esc_attr( stripslashes( $backup_options['backup_email_subject'] ) ) ?>" dir="ltr" />
849 </p>
850 <p><?php _e('(Leave blank to use the default)', 'wp-dbmanager'); ?></p>
851 </td>
852 </tr>
853 </table>
854
855 <h3><?php _e('Miscellaneous Options', 'wp-dbmanager'); ?></h3>
856 <table class="form-table">
857 <tr>
858 <td valign="top"><strong><?php _e('Hide Admin Notices', 'wp-dbmanager'); ?></strong></td>
859 <td>
860 <p>
861 <input type="radio" name="db_hide_admin_notices" value="1"<?php echo (int) $backup_options['hide_admin_notices'] === 1 ? ' checked="checked"' : ''; ?> />&nbsp;<?php _e('Yes', 'wp-dbmanager'); ?>
862 <input type="radio" name="db_hide_admin_notices" value="0"<?php echo (int) $backup_options['hide_admin_notices'] === 0 ? ' checked="checked"' : ''; ?> />&nbsp;<?php _e('No', 'wp-dbmanager'); ?>
863 </p>
864 </td>
865 </tr>
866 </table>
867
868 <p class="submit">
869 <input type="submit" name="Submit" class="button" value="<?php _e('Save Changes', 'wp-dbmanager'); ?>" />
870 </p>
871 </div>
872 </form>
873 <?php
874 }
875 ?>
876