sprintf( __( '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( __( 'ERROR: Not authorized', 'wp-data-access' ) ); } if ( 'save' === $action ) { WPDA::set_option( WPDA::OPTION_PLUGIN_HIDE_NOTICES, ( isset( $_REQUEST['hide_foreign_notices'] ) ? 'on' : 'off' ) ); WPDA::set_option( WPDA::OPTION_PLUGIN_HIDE_ADMIN_MENU, ( isset( $_REQUEST['hide_admin_menu'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['hide_admin_menu'] ) ) : 'off' ) ); if ( isset( $_REQUEST['panel_cookies'] ) ) { WPDA::set_option( WPDA::OPTION_PLUGIN_PANEL_COOKIES, sanitize_text_field( wp_unslash( $_REQUEST['panel_cookies'] ) ) ); } 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'] ) ) { $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] ) ); $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', 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_WPDATAACCESS_POST, ( isset( $_REQUEST['wpdataaccess_post'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpdataaccess_post'] ) ) : 'off' ) ); WPDA::set_option( WPDA::OPTION_PLUGIN_WPDATAACCESS_PAGE, ( isset( $_REQUEST['wpdataaccess_page'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpdataaccess_page'] ) ) : 'off' ) ); WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADIEHARD_POST, ( isset( $_REQUEST['wpdadiehard_post'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpdadiehard_post'] ) ) : 'off' ) ); WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADIEHARD_PAGE, ( isset( $_REQUEST['wpdadiehard_page'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpdadiehard_page'] ) ) : 'off' ) ); WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADATAFORMS_POST, ( isset( $_REQUEST['wpdadataforms_post'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpdadataforms_post'] ) ) : 'off' ) ); WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADATAFORMS_PAGE, ( isset( $_REQUEST['wpdadataforms_page'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpdadataforms_page'] ) ) : 'off' ) ); WPDA::set_option( WPDA::OPTION_PLUGIN_DEBUG, ( isset( $_REQUEST['debug'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['debug'] ) ) : 'off' ) ); if ( isset( $_REQUEST['date_format'] ) ) { WPDA::set_option( WPDA::OPTION_PLUGIN_DATE_FORMAT, sanitize_text_field( wp_unslash( $_REQUEST['date_format'] ) ) ); } if ( isset( $_REQUEST['date_placeholder'] ) ) { WPDA::set_option( WPDA::OPTION_PLUGIN_DATE_PLACEHOLDER, sanitize_text_field( wp_unslash( $_REQUEST['date_placeholder'] ) ) ); } if ( isset( $_REQUEST['time_format'] ) ) { WPDA::set_option( WPDA::OPTION_PLUGIN_TIME_FORMAT, sanitize_text_field( wp_unslash( $_REQUEST['time_format'] ) ) ); } if ( isset( $_REQUEST['time_placeholder'] ) ) { WPDA::set_option( WPDA::OPTION_PLUGIN_TIME_PLACEHOLDER, sanitize_text_field( wp_unslash( $_REQUEST['time_placeholder'] ) ) ); } if ( isset( $_REQUEST['set_format'] ) ) { WPDA::set_option( WPDA::OPTION_PLUGIN_SET_FORMAT, sanitize_text_field( wp_unslash( $_REQUEST['set_format'] ) ) ); } } 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_WPDATAACCESS_POST ); WPDA::set_option( WPDA::OPTION_PLUGIN_WPDATAACCESS_PAGE ); WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADIEHARD_POST ); WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADIEHARD_PAGE ); WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADATAFORMS_POST ); WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADATAFORMS_PAGE ); WPDA::set_option( WPDA::OPTION_PLUGIN_DEBUG ); WPDA::set_option( WPDA::OPTION_PLUGIN_DATE_FORMAT ); WPDA::set_option( WPDA::OPTION_PLUGIN_DATE_PLACEHOLDER ); WPDA::set_option( WPDA::OPTION_PLUGIN_TIME_FORMAT ); WPDA::set_option( WPDA::OPTION_PLUGIN_TIME_PLACEHOLDER ); WPDA::set_option( WPDA::OPTION_PLUGIN_SET_FORMAT ); } } $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 ); $wpdataaccess_post = WPDA::get_option( WPDA::OPTION_PLUGIN_WPDATAACCESS_POST ); $wpdataaccess_page = WPDA::get_option( WPDA::OPTION_PLUGIN_WPDATAACCESS_PAGE ); $wpdadiehard_post = WPDA::get_option( WPDA::OPTION_PLUGIN_WPDADIEHARD_POST ); $wpdadiehard_page = WPDA::get_option( WPDA::OPTION_PLUGIN_WPDADIEHARD_PAGE ); $wpdadataforms_post = WPDA::get_option( WPDA::OPTION_PLUGIN_WPDADATAFORMS_POST ); $wpdadataforms_page = WPDA::get_option( WPDA::OPTION_PLUGIN_WPDADATAFORMS_PAGE ); $debug = WPDA::get_option( WPDA::OPTION_PLUGIN_DEBUG ); $date_format = WPDA::get_option( WPDA::OPTION_PLUGIN_DATE_FORMAT ); $date_placeholder = WPDA::get_option( WPDA::OPTION_PLUGIN_DATE_PLACEHOLDER ); $time_format = WPDA::get_option( WPDA::OPTION_PLUGIN_TIME_FORMAT ); $time_placeholder = WPDA::get_option( WPDA::OPTION_PLUGIN_TIME_PLACEHOLDER ); $set_format = WPDA::get_option( WPDA::OPTION_PLUGIN_SET_FORMAT ); $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' ); ?>