PluginProbe
WP-DBManager / 2.80.3
WP-DBManager v2.80.3
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.3, at wp-dbmanager.php

876 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.3
7 Author: Lester 'GaMerZ' Chan
8 Author URI: https://lesterchan.net
9 Text Domain: wp-dbmanager
10 */
11
12
13 /*
14 Copyright 2020 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'), 'manage_database', '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'), 'manage_database', 'wp-dbmanager/database-backup.php');
47 add_submenu_page('wp-dbmanager/database-manager.php', __('Manage Backup DB', 'wp-dbmanager'), __('Manage Backup DB', 'wp-dbmanager'), 'manage_database', 'wp-dbmanager/database-manage.php');
48 add_submenu_page('wp-dbmanager/database-manager.php', __('Optimize DB', 'wp-dbmanager'), __('Optimize DB', 'wp-dbmanager'), 'manage_database', 'wp-dbmanager/database-optimize.php');
49 add_submenu_page('wp-dbmanager/database-manager.php', __('Repair DB', 'wp-dbmanager'), __('Repair DB', 'wp-dbmanager'), 'manage_database', 'wp-dbmanager/database-repair.php');
50 add_submenu_page('wp-dbmanager/database-manager.php', __('Empty/Drop Tables', 'wp-dbmanager'), __('Empty/Drop Tables', 'wp-dbmanager'), 'manage_database', 'wp-dbmanager/database-empty.php');
51 add_submenu_page('wp-dbmanager/database-manager.php', __('Run SQL Query', 'wp-dbmanager'), __('Run SQL Query', 'wp-dbmanager'), 'manage_database', 'wp-dbmanager/database-run.php');
52 add_submenu_page('wp-dbmanager/database-manager.php', __('DB Options', 'wp-dbmanager'), __('DB Options', 'wp-dbmanager'), 'manage_database', '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="utf8"';
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 // Set 'manage_database' Capabilities To Administrator
500 $role = get_role( 'administrator' );
501 if( ! $role->has_cap( 'manage_database') )
502 {
503 $role->add_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="105" 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