diff --git a/database-admin-css.css b/database-admin-css.css new file mode 100644 index 0000000..e8de93f --- /dev/null +++ b/database-admin-css.css @@ -0,0 +1,55 @@ +.text-ok { + color: green; +} + +/* ------------------------------------------------------------- + DBManager Check Groups + ------------------------------------------------------------- */ +.dbmanager-check-group { + margin: 1em 0; +} + +.dbmanager-check-group h3 { + margin: 0 0 .3em; + font-size: 1.2em; +} + +/* Toggle button - Override WordPress defaults */ +.dbmanager-check-group .dbmanager-toggle { + background: none; + border: none; + text-decoration: none; + outline: none; + padding: 0; + margin: 0; + cursor: pointer; + color: inherit; + font-size: inherit; + font-weight: normal; + line-height: 1.4; + width: auto; + display: inline; +} + +/* Status colors */ +.dbmanager-check-group .dbmanager-toggle.dbmanager-ok { color: green; } +.dbmanager-check-group .dbmanager-toggle.dbmanager-err { color: red; } + +/* Content area */ +.dbmanager-check-group .dbmanager-content { + margin-left: 0; + padding: 0; + display: none; /* Initially hidden */ +} + +.dbmanager-check-group .dbmanager-content p { + margin: .2em 0; + line-height: 1.4; +} + +/* Details styling */ +.dbmanager-details { + color: #666; + font-size: 0.9em; + margin-left: .4em; +} diff --git a/database-backup.php b/database-backup.php index c9621fa..cdfa701 100644 --- a/database-backup.php +++ b/database-backup.php @@ -8,6 +8,8 @@ ### Variables Variables Variables $base_name = plugin_basename('wp-dbmanager/database-manager.php'); $base_page = 'admin.php?page='.$base_name; +$return_page = 'admin.php?page=wp-dbmanager/database-manage.php'; + $current_date = mysql2date(sprintf(__('%s @ %s', 'wp-dbmanager'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', current_time('timestamp'))); $backup = array(); $backup_options = get_option('dbmanager_options'); @@ -50,6 +52,7 @@ $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; } $error = execute_backup( $backup['command'] ); + if ( ! is_writable( $backup['path'] ) ) { $text = '
'.sprintf(__('Database Failed To Backup On \'%s\'. Backup Folder Not Writable.', 'wp-dbmanager'), $current_date).'
'; } elseif ( is_file( $backup['filepath'] ) && filesize( $backup['filepath'] ) === 0 ) { @@ -59,9 +62,14 @@ } elseif ( $error ) { $text = ''.sprintf(__('Database Failed To Backup On \'%s\'.', 'wp-dbmanager'), $current_date).'
'; } else { - rename( $backup['filepath'], $backup['path'] . '/' . md5_file( $backup['filepath'] ) . '_-_' . $backup['filename'] ); + $new_filepath = $backup['path'] . '/' . md5_file( $backup['filepath'] ) . '_-_' . $backup['filename']; + rename( $backup['filepath'], $new_filepath ); + if (!empty($_POST['comment'])) { + file_put_contents("{$new_filepath}.txt",$_POST['comment']); + } $text = ''.sprintf(__('Database Backed Up Successfully On \'%s\'.', 'wp-dbmanager'), $current_date).'
'; } + header("Location: $return_page&info=" . base64_encode($text)); break; } } @@ -73,18 +81,51 @@ ### MYSQL Base Dir $has_error = false; $disabled_function = false; + +### Detailed check status flags +$security_has_error = false; +$backup_has_error = false; +$phpfn_has_error = false; + +/** + * Generate a collapsible check group header button + * + * @param string $title Group title (already translated) + * @param bool $hasError Whether group has errors + * @return string HTML for button + * + */ +function dbmanager_check_button($title, $hasError = false) { + $status = $hasError ? _e('Some tests failed', 'wp-dbmanager') : __('All OK', 'wp-dbmanager'); + $class = $hasError ? 'dbmanager-err' : 'dbmanager-ok'; + $expanded = $hasError ? 'true' : 'false'; + + // Exactly match your original inline structure + return ''; +} ?> '.$text.''; } ?>+
' . sprintf( __( 'Web.config is present in %s', 'wp-dbmanager' ), $backup_path ) . '
'; } @@ -92,6 +133,7 @@ if( ! is_file( $backup_path . '/.htaccess' ) ) { echo '' . sprintf( __( '.htaccess is missing from %s', 'wp-dbmanager' ), $backup_path ) . '
'; $has_error = true; + $security_has_error = true; } else { echo '' . sprintf( __( '.htaccess is present in %s', 'wp-dbmanager' ), $backup_path ) . '
'; } @@ -99,39 +141,48 @@ if( ! is_file( $backup_path . '/index.php' ) ) { echo '' . sprintf( __( 'index.php is missing from %s', 'wp-dbmanager' ), $backup_path ) . '
'; $has_error = true; + $security_has_error = true; } else { echo '' . sprintf( __( 'index.php is present in %s', 'wp-dbmanager' ), $backup_path ) . '
'; } ?> - - -+ +
' . __('Backup folder exists', 'wp-dbmanager') . '
'; } else { echo '' . sprintf(__('Backup folder does NOT exist. Please create \'backup-db\' folder in \'%s\' folder and CHMOD it to \'777\' or change the location of the backup folder under DB Option.', 'wp-dbmanager'), WP_CONTENT_DIR) . '
'; $has_error = true; + $backup_has_error = true; } if ( @is_writable( $backup_path ) ) { echo '' . __('Backup folder is writable', 'wp-dbmanager') . '
'; } else { echo '' . __('Backup folder is NOT writable. Please CHMOD it to \'777\'.', 'wp-dbmanager') . '
'; $has_error = true; + $backup_has_error = true; } } - ?> - -- ' . sprintf( __( '%s is not a valid backup mysqldump path', 'wp-dbmanager' ), stripslashes( $backup['mysqldumppath'] ) ) . '
'; $has_error = true; + $backup_has_error = true; } else { if ( @file_exists( stripslashes( $backup['mysqldumppath'] ) ) ) { echo __('Checking MYSQL Dump Path', 'wp-dbmanager') . ' (' . stripslashes( $backup['mysqldumppath'] ) . ') ...' . __('MYSQL dump path does NOT exist. Please check your mysqldump path under DB Options. If uncertain, contact your server administrator.', 'wp-dbmanager') . '
'; $has_error = true; + $backup_has_error = true; } } - ?> - -- ' . sprintf( __( '%s is not a valid backup mysql path', 'wp-dbmanager' ), stripslashes( $backup['mysqlpath'] ) ) . '
'; $has_error = true; + $backup_has_error = true; } else { if ( @file_exists( stripslashes($backup['mysqlpath'] ) ) ) { echo __('Checking MYSQL Path', 'wp-dbmanager') . ' (' . stripslashes($backup['mysqlpath']) . ') ...' . __('MYSQL path does NOT exist. Please check your mysql path under DB Options. If uncertain, contact your server administrator.', 'wp-dbmanager') . '
'; $has_error = true; + $backup_has_error = true; } } ?> - -
- (passthru(), system() exec()) ...
+
+
passthru() '.__('missing', 'wp-dbmanager').'.
'; $disabled_function = true; + $phpfn_has_error = true; } else { echo 'passthru() '.__('enabled', 'wp-dbmanager').'.
'; } if( dbmanager_is_function_disabled( 'system' ) ) { echo 'system() '.__('disabled', 'wp-dbmanager').'.
'; $disabled_function = true; + $phpfn_has_error = true; } else if( ! function_exists( 'system' ) ) { echo 'system() '.__('missing', 'wp-dbmanager').'.
'; $disabled_function = true; + $phpfn_has_error = true; } else { echo 'system() '.__('enabled', 'wp-dbmanager').'.
'; } if( dbmanager_is_function_disabled( 'exec' ) ) { echo 'exec() '.__('disabled', 'wp-dbmanager').'.
'; $disabled_function = true; + $phpfn_has_error = true; } else if( ! function_exists( 'exec' ) ) { echo 'exec() '.__('missing', 'wp-dbmanager').'.
'; $disabled_function = true; + $phpfn_has_error = true; } else { echo 'exec() '.__('enabled', 'wp-dbmanager').'.
'; } ?> - + +