PluginProbe
WP-DBManager / 2.80.8
WP-DBManager v2.80.8
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.8, at wp-dbmanager.php

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