__( 'Cannot save remote database connection [missing arguments]', 'wp-data-access' ), 'message_type' => 'error', 'message_is_dismissible' => false, ) ); $msg->box(); } else { WPDADB::upd_remote_database( $database, $host, $username, $password, $port, $schema, ! $enabled, $database_old, $remote_ssl, $remote_client_key, $remote_client_certificate, $remote_ca_certificate, $remote_certificate_path, $remote_specified_cipher ); } } else { $wp_nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : ''; // input var okay. if ( ! wp_verify_nonce( $wp_nonce, 'wpda-plugin-settings-' . WPDA::get_current_user_login() ) ) { wp_die( esc_attr__( 'ERROR: Not authorized', 'wp-data-access' ) ); } if ( 'save' === $action ) { WPDA::set_option( WPDA::OPTION_PLUGIN_HIDE_NOTICES, isset( $_REQUEST['hide_foreign_notices'] ) ? 'on' : 'off' // input var okay. ); WPDA::set_option( WPDA::OPTION_PLUGIN_HIDE_ADMIN_MENU, isset( $_REQUEST['hide_admin_menu'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['hide_admin_menu'] ) ) : 'off' // input var okay. ); if ( isset( $_REQUEST['panel_cookies'] ) ) { WPDA::set_option( WPDA::OPTION_PLUGIN_PANEL_COOKIES, sanitize_text_field( wp_unslash( $_REQUEST['panel_cookies'] ) ) // input var okay. ); } if ( ! isset( $_REQUEST['secret_key'] ) || ! isset( $_REQUEST['secret_iv'] ) ) { // Leave both values untouched } else { $secret_key_old = WPDA::get_option( WPDA::OPTION_PLUGIN_SECRET_KEY ); $secret_iv_old = WPDA::get_option( WPDA::OPTION_PLUGIN_SECRET_IV ); $secret_key_new = sanitize_text_field( wp_unslash( $_REQUEST['secret_key'] ) ); // input var okay. $secret_iv_new = sanitize_text_field( wp_unslash( $_REQUEST['secret_iv'] ) ); // input var okay. if ( $secret_key_old !== $secret_key_new || $secret_iv_old !== $secret_iv_new ) { // Update existing remote databases WPDADB::load_remote_databases(); // load remote databases with old secret key and iv WPDA::set_option( WPDA::OPTION_PLUGIN_SECRET_KEY, $secret_key_new ); // update secret key WPDA::set_option( WPDA::OPTION_PLUGIN_SECRET_IV, $secret_iv_new ); // update secret iv WPDADB::save_remote_databases(); // save remote databases with new secret key and iv } } if ( isset( $_REQUEST['remote_database_name'] ) && isset( $_REQUEST['remote_database_enabled'] ) ) { if ( is_array( $_REQUEST['remote_database_name'] ) && is_array( $_REQUEST['remote_database_enabled'] ) && count( $_REQUEST['remote_database_name'] ) === count( $_REQUEST['remote_database_enabled'] ) // phpcs:ignore -- 8.1 proof ) { $i = 0; while ( $i < count( $_REQUEST['remote_database_name'] ) ) { // phpcs:ignore -- 8.1 proof $rdb_name = sanitize_text_field( wp_unslash( $_REQUEST['remote_database_name'][ $i ] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated $dbs = WPDADB::get_remote_database( $rdb_name, true ); if ( ! $dbs ) { $msg = new WPDA_Message_Box( array( 'message_text' => __( 'Remote database connection not found', 'wp-data-access' ), 'message_type' => 'error', 'message_is_dismissible' => false, ) ); $msg->box(); } else { WPDADB::upd_remote_database( $rdb_name, $dbs['host'], $dbs['username'], $dbs['password'], $dbs['port'], $dbs['database'], $_REQUEST['remote_database_enabled'][ $i ] === 'FALSE', // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated false, $dbs['ssl'], $dbs['ssl_key'], $dbs['ssl_cert'], $dbs['ssl_ca'], $dbs['ssl_path'], $dbs['ssl_cipher'] ); } $i++; } WPDADB::save_remote_databases(); // save changes } } WPDA::set_option( WPDA::OPTION_PLUGIN_DEBUG, isset( $_REQUEST['debug'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['debug'] ) ) : 'off' // input var okay. ); } elseif ( 'setdefaults' === $action ) { // Set all back-end settings back to default. WPDA::get_option( WPDA::OPTION_PLUGIN_HIDE_NOTICES ); WPDA::set_option( WPDA::OPTION_PLUGIN_HIDE_ADMIN_MENU ); WPDA::set_option( WPDA::OPTION_PLUGIN_PANEL_COOKIES ); // DO NOT RESET SECRET KEY AND IV // DO NOT RESET RDBs WPDA::set_option( WPDA::OPTION_PLUGIN_DEBUG ); } } $msg = new WPDA_Message_Box( array( 'message_text' => __( 'Settings saved', 'wp-data-access' ), ) ); $msg->box(); } elseif ( isset( $_REQUEST['msg'] ) && 'ok' === $_REQUEST['msg'] ) { $msg = new WPDA_Message_Box( array( 'message_text' => __( 'Settings saved', 'wp-data-access' ), ) ); $msg->box(); } // Get options. $hide_foreign_notices = WPDA::get_option( WPDA::OPTION_PLUGIN_HIDE_NOTICES ); $hide_admin_menu = WPDA::get_option( WPDA::OPTION_PLUGIN_HIDE_ADMIN_MENU ); $panel_cookies = WPDA::get_option( WPDA::OPTION_PLUGIN_PANEL_COOKIES ); $secret_key = WPDA::get_option( WPDA::OPTION_PLUGIN_SECRET_KEY ); $secret_iv = WPDA::get_option( WPDA::OPTION_PLUGIN_SECRET_IV ); $debug = WPDA::get_option( WPDA::OPTION_PLUGIN_DEBUG ); $remote_databases = WPDADB::get_remote_databases( true ); ?>
x
(local WordPress dashboard)
(ip address or hostname)













$remote_database_settings ) { $checked = isset( $remote_database_settings['disabled'] ) && $remote_database_settings['disabled'] ? '' : 'checked'; $enabled = isset( $remote_database_settings['disabled'] ) && $remote_database_settings['disabled'] ? 'FALSE' : 'TRUE'; ?>