| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPDataAccess\Settings { |
| 4 |
|
| 5 |
use WPDataAccess\Connection\WPDADB; |
| 6 |
use WPDataAccess\Utilities\WPDA_Message_Box; |
| 7 |
use WPDataAccess\WPDA; |
| 8 |
|
| 9 |
class WPDA_Settings_Plugin extends WPDA_Settings { |
| 10 |
|
| 11 |
protected function add_content() { |
| 12 |
if ( isset( $_REQUEST['action'] ) ) { |
| 13 |
$action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ); // input var okay. |
| 14 |
|
| 15 |
// Security check. |
| 16 |
if ( 'delete_remote_database' === $action ) { |
| 17 |
$wp_nonce = isset( $_REQUEST['_wpnoncedelrdb'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnoncedelrdb'] ) ) : ''; // input var okay. |
| 18 |
if ( ! wp_verify_nonce( $wp_nonce, 'wpda-delete-remote-database-' . WPDA::get_current_user_login() ) ) { |
| 19 |
wp_die( esc_attr__( 'ERROR: Not authorized', 'wp-data-access' ) ); |
| 20 |
} |
| 21 |
|
| 22 |
if ( isset( $_REQUEST['remote_database_name'] ) ) { |
| 23 |
$remote_database_name = sanitize_text_field( wp_unslash( $_REQUEST['remote_database_name'] ) ); // input var okay. |
| 24 |
WPDADB::del_remote_database( $remote_database_name ); |
| 25 |
} |
| 26 |
} elseif ( 'update_remote_database' === $action ) { |
| 27 |
$wp_nonce = isset( $_REQUEST['_wpnonceupdrdb'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonceupdrdb'] ) ) : ''; // input var okay. |
| 28 |
if ( ! wp_verify_nonce( $wp_nonce, 'wpda-update-remote-database-' . WPDA::get_current_user_login() ) ) { |
| 29 |
wp_die( esc_attr__( 'ERROR: Not authorized', 'wp-data-access' ) ); |
| 30 |
} |
| 31 |
|
| 32 |
$database_old = isset( $_REQUEST['remote_database_old'] ) ? |
| 33 |
sanitize_text_field( wp_unslash( $_REQUEST['remote_database_old'] ) ) : ''; // input var okay. |
| 34 |
$database = isset( $_REQUEST['remote_database'] ) ? |
| 35 |
sanitize_text_field( wp_unslash( $_REQUEST['remote_database'] ) ) : ''; // input var okay. |
| 36 |
$host = isset( $_REQUEST['remote_host'] ) ? |
| 37 |
sanitize_text_field( wp_unslash( $_REQUEST['remote_host'] ) ) : ''; // input var okay. |
| 38 |
$username = isset( $_REQUEST['remote_user'] ) ? |
| 39 |
sanitize_text_field( wp_unslash( $_REQUEST['remote_user'] ) ) : ''; // input var okay. |
| 40 |
$password = isset( $_REQUEST['remote_passwd'] ) ? // Cannot use sanitize_text_field on password field! |
| 41 |
wp_unslash( $_REQUEST['remote_passwd'] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 42 |
$port = isset( $_REQUEST['remote_port'] ) ? |
| 43 |
sanitize_text_field( wp_unslash( $_REQUEST['remote_port'] ) ) : ''; // input var okay. |
| 44 |
$schema = isset( $_REQUEST['remote_schema'] ) ? |
| 45 |
sanitize_text_field( wp_unslash( $_REQUEST['remote_schema'] ) ) : ''; // input var okay. |
| 46 |
$enabled = isset( $_REQUEST['remote_enabled'] ) ? true : false; |
| 47 |
|
| 48 |
// Add ssl |
| 49 |
$remote_ssl = isset( $_REQUEST['remote_ssl'] ) ? |
| 50 |
sanitize_text_field( wp_unslash( $_REQUEST['remote_ssl'] ) ) : 'off'; // input var okay. |
| 51 |
$remote_client_key = isset( $_REQUEST['remote_client_key'] ) ? |
| 52 |
sanitize_text_field( wp_unslash( $_REQUEST['remote_client_key'] ) ) : ''; // input var okay. |
| 53 |
$remote_client_certificate = isset( $_REQUEST['remote_client_certificate'] ) ? |
| 54 |
sanitize_text_field( wp_unslash( $_REQUEST['remote_client_certificate'] ) ) : ''; // input var okay. |
| 55 |
$remote_ca_certificate = isset( $_REQUEST['remote_ca_certificate'] ) ? |
| 56 |
sanitize_text_field( wp_unslash( $_REQUEST['remote_ca_certificate'] ) ) : ''; // input var okay. |
| 57 |
$remote_certificate_path = isset( $_REQUEST['remote_certificate_path'] ) ? |
| 58 |
sanitize_text_field( wp_unslash( $_REQUEST['remote_certificate_path'] ) ) : ''; // input var okay. |
| 59 |
$remote_specified_cipher = isset( $_REQUEST['remote_specified_cipher'] ) ? |
| 60 |
sanitize_text_field( wp_unslash( $_REQUEST['remote_specified_cipher'] ) ) : ''; // input var okay. |
| 61 |
|
| 62 |
if ( '' === $database_old || '' === $database || '' === $host || '' === $username || '' === $password || '' === $port || '' === $schema || '' === $enabled ) { |
| 63 |
$msg = new WPDA_Message_Box( |
| 64 |
array( |
| 65 |
'message_text' => __( 'Cannot save remote database connection [missing arguments]', 'wp-data-access' ), |
| 66 |
'message_type' => 'error', |
| 67 |
'message_is_dismissible' => false, |
| 68 |
) |
| 69 |
); |
| 70 |
$msg->box(); |
| 71 |
} else { |
| 72 |
WPDADB::upd_remote_database( |
| 73 |
$database, |
| 74 |
$host, |
| 75 |
$username, |
| 76 |
$password, |
| 77 |
$port, |
| 78 |
$schema, |
| 79 |
! $enabled, |
| 80 |
$database_old, |
| 81 |
$remote_ssl, |
| 82 |
$remote_client_key, |
| 83 |
$remote_client_certificate, |
| 84 |
$remote_ca_certificate, |
| 85 |
$remote_certificate_path, |
| 86 |
$remote_specified_cipher |
| 87 |
); |
| 88 |
} |
| 89 |
} else { |
| 90 |
$wp_nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : ''; // input var okay. |
| 91 |
if ( ! wp_verify_nonce( $wp_nonce, 'wpda-plugin-settings-' . WPDA::get_current_user_login() ) ) { |
| 92 |
wp_die( esc_attr__( 'ERROR: Not authorized', 'wp-data-access' ) ); |
| 93 |
} |
| 94 |
|
| 95 |
if ( 'save' === $action ) { |
| 96 |
WPDA::set_option( |
| 97 |
WPDA::OPTION_PLUGIN_HIDE_NOTICES, |
| 98 |
isset( $_REQUEST['hide_foreign_notices'] ) ? 'on' : 'off' // input var okay. |
| 99 |
); |
| 100 |
|
| 101 |
WPDA::set_option( |
| 102 |
WPDA::OPTION_PLUGIN_HIDE_ADMIN_MENU, |
| 103 |
isset( $_REQUEST['hide_admin_menu'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['hide_admin_menu'] ) ) : 'off' // input var okay. |
| 104 |
); |
| 105 |
|
| 106 |
if ( isset( $_REQUEST['panel_cookies'] ) ) { |
| 107 |
WPDA::set_option( |
| 108 |
WPDA::OPTION_PLUGIN_PANEL_COOKIES, |
| 109 |
sanitize_text_field( wp_unslash( $_REQUEST['panel_cookies'] ) ) // input var okay. |
| 110 |
); |
| 111 |
} |
| 112 |
|
| 113 |
if ( ! isset( $_REQUEST['secret_key'] ) || ! isset( $_REQUEST['secret_iv'] ) ) { |
| 114 |
// Leave both values untouched |
| 115 |
} else { |
| 116 |
$secret_key_old = WPDA::get_option( WPDA::OPTION_PLUGIN_SECRET_KEY ); |
| 117 |
$secret_iv_old = WPDA::get_option( WPDA::OPTION_PLUGIN_SECRET_IV ); |
| 118 |
|
| 119 |
$secret_key_new = sanitize_text_field( wp_unslash( $_REQUEST['secret_key'] ) ); // input var okay. |
| 120 |
$secret_iv_new = sanitize_text_field( wp_unslash( $_REQUEST['secret_iv'] ) ); // input var okay. |
| 121 |
|
| 122 |
if ( $secret_key_old !== $secret_key_new || $secret_iv_old !== $secret_iv_new ) { |
| 123 |
// Update existing remote databases |
| 124 |
WPDADB::load_remote_databases(); // load remote databases with old secret key and iv |
| 125 |
WPDA::set_option( WPDA::OPTION_PLUGIN_SECRET_KEY, $secret_key_new ); // update secret key |
| 126 |
WPDA::set_option( WPDA::OPTION_PLUGIN_SECRET_IV, $secret_iv_new ); // update secret iv |
| 127 |
WPDADB::save_remote_databases(); // save remote databases with new secret key and iv |
| 128 |
} |
| 129 |
} |
| 130 |
|
| 131 |
if ( isset( $_REQUEST['remote_database_name'] ) && isset( $_REQUEST['remote_database_enabled'] ) ) { |
| 132 |
if ( is_array( $_REQUEST['remote_database_name'] ) && |
| 133 |
is_array( $_REQUEST['remote_database_enabled'] ) && |
| 134 |
count( $_REQUEST['remote_database_name'] ) === count( $_REQUEST['remote_database_enabled'] ) // phpcs:ignore -- 8.1 proof |
| 135 |
) { |
| 136 |
$i = 0; |
| 137 |
while ( $i < count( $_REQUEST['remote_database_name'] ) ) { // phpcs:ignore -- 8.1 proof |
| 138 |
$rdb_name = sanitize_text_field( wp_unslash( $_REQUEST['remote_database_name'][ $i ] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated |
| 139 |
$dbs = WPDADB::get_remote_database( $rdb_name, true ); |
| 140 |
if ( ! $dbs ) { |
| 141 |
$msg = new WPDA_Message_Box( |
| 142 |
array( |
| 143 |
'message_text' => __( 'Remote database connection not found', 'wp-data-access' ), |
| 144 |
'message_type' => 'error', |
| 145 |
'message_is_dismissible' => false, |
| 146 |
) |
| 147 |
); |
| 148 |
$msg->box(); |
| 149 |
} else { |
| 150 |
WPDADB::upd_remote_database( |
| 151 |
$rdb_name, |
| 152 |
$dbs['host'], |
| 153 |
$dbs['username'], |
| 154 |
$dbs['password'], |
| 155 |
$dbs['port'], |
| 156 |
$dbs['database'], |
| 157 |
$_REQUEST['remote_database_enabled'][ $i ] === 'FALSE', // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated |
| 158 |
false, |
| 159 |
$dbs['ssl'], |
| 160 |
$dbs['ssl_key'], |
| 161 |
$dbs['ssl_cert'], |
| 162 |
$dbs['ssl_ca'], |
| 163 |
$dbs['ssl_path'], |
| 164 |
$dbs['ssl_cipher'] |
| 165 |
); |
| 166 |
} |
| 167 |
$i++; |
| 168 |
} |
| 169 |
WPDADB::save_remote_databases(); // save changes |
| 170 |
} |
| 171 |
} |
| 172 |
|
| 173 |
WPDA::set_option( |
| 174 |
WPDA::OPTION_PLUGIN_DEBUG, |
| 175 |
isset( $_REQUEST['debug'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['debug'] ) ) : 'off' // input var okay. |
| 176 |
); |
| 177 |
} elseif ( 'setdefaults' === $action ) { |
| 178 |
// Set all back-end settings back to default. |
| 179 |
WPDA::get_option( WPDA::OPTION_PLUGIN_HIDE_NOTICES ); |
| 180 |
|
| 181 |
WPDA::set_option( WPDA::OPTION_PLUGIN_HIDE_ADMIN_MENU ); |
| 182 |
|
| 183 |
WPDA::set_option( WPDA::OPTION_PLUGIN_PANEL_COOKIES ); |
| 184 |
|
| 185 |
// DO NOT RESET SECRET KEY AND IV |
| 186 |
|
| 187 |
// DO NOT RESET RDBs |
| 188 |
|
| 189 |
WPDA::set_option( WPDA::OPTION_PLUGIN_DEBUG ); |
| 190 |
} |
| 191 |
} |
| 192 |
|
| 193 |
$msg = new WPDA_Message_Box( |
| 194 |
array( |
| 195 |
'message_text' => __( 'Settings saved', 'wp-data-access' ), |
| 196 |
) |
| 197 |
); |
| 198 |
$msg->box(); |
| 199 |
} elseif ( isset( $_REQUEST['msg'] ) && 'ok' === $_REQUEST['msg'] ) { |
| 200 |
$msg = new WPDA_Message_Box( |
| 201 |
array( |
| 202 |
'message_text' => __( 'Settings saved', 'wp-data-access' ), |
| 203 |
) |
| 204 |
); |
| 205 |
$msg->box(); |
| 206 |
} |
| 207 |
|
| 208 |
// Get options. |
| 209 |
$hide_foreign_notices = WPDA::get_option( WPDA::OPTION_PLUGIN_HIDE_NOTICES ); |
| 210 |
|
| 211 |
$hide_admin_menu = WPDA::get_option( WPDA::OPTION_PLUGIN_HIDE_ADMIN_MENU ); |
| 212 |
|
| 213 |
$panel_cookies = WPDA::get_option( WPDA::OPTION_PLUGIN_PANEL_COOKIES ); |
| 214 |
|
| 215 |
$secret_key = WPDA::get_option( WPDA::OPTION_PLUGIN_SECRET_KEY ); |
| 216 |
$secret_iv = WPDA::get_option( WPDA::OPTION_PLUGIN_SECRET_IV ); |
| 217 |
|
| 218 |
$debug = WPDA::get_option( WPDA::OPTION_PLUGIN_DEBUG ); |
| 219 |
|
| 220 |
$remote_databases = WPDADB::get_remote_databases( true ); |
| 221 |
?> |
| 222 |
|
| 223 |
<style> |
| 224 |
.item_label { |
| 225 |
width: 14.9em; |
| 226 |
display: inline-block; |
| 227 |
padding-left: 0.3em; |
| 228 |
} |
| 229 |
|
| 230 |
.item_label_text { |
| 231 |
width: 7em; |
| 232 |
display: inline-block; |
| 233 |
} |
| 234 |
|
| 235 |
.item_label_format { |
| 236 |
width: 5em; |
| 237 |
padding: 0.6em; |
| 238 |
border-radius: 4px; |
| 239 |
} |
| 240 |
|
| 241 |
.item_label_align { |
| 242 |
float: right; |
| 243 |
} |
| 244 |
|
| 245 |
#wpda_update_database_popup { |
| 246 |
display: none; |
| 247 |
padding: 10px; |
| 248 |
position: absolute; |
| 249 |
top: 30px; |
| 250 |
left: 10px; |
| 251 |
color: black; |
| 252 |
overflow-y: auto; |
| 253 |
background-color: white; |
| 254 |
border: 1px solid #ccc; |
| 255 |
width: max-content; |
| 256 |
} |
| 257 |
|
| 258 |
#wpda_update_database_popup_header { |
| 259 |
background-color: #ccc; |
| 260 |
height: 30px; |
| 261 |
padding: 10px; |
| 262 |
margin-bottom: 10px; |
| 263 |
} |
| 264 |
</style> |
| 265 |
|
| 266 |
<script> |
| 267 |
function delete_remote_database(id) { |
| 268 |
remote_database_name = jQuery('#remote_database_name' + id).val(); |
| 269 |
if (confirm("<?php esc_html_e( 'Delete remote database connection from plugin repository?', 'wp-data-access' ); ?>")) { |
| 270 |
jQuery('#delete_remote_database_name').val(remote_database_name); |
| 271 |
jQuery('#wpda_delete_database').submit(); |
| 272 |
} |
| 273 |
} |
| 274 |
|
| 275 |
function update_rdb_setting(id) { |
| 276 |
if (jQuery('#remote_database' + id).is(':checked')) { |
| 277 |
jQuery('#remote_database_enabled' + id).val('TRUE'); |
| 278 |
} else { |
| 279 |
jQuery('#remote_database_enabled' + id).val('FALSE'); |
| 280 |
} |
| 281 |
} |
| 282 |
|
| 283 |
function edit_rdb_setting(id) { |
| 284 |
jQuery('#wpda_update_database_popup').show(); |
| 285 |
jQuery('#remote_database_old').val(id); |
| 286 |
jQuery('#remote_database').val(id); |
| 287 |
jQuery('#remote_host').val(remote_databases[id].host); |
| 288 |
jQuery('#remote_user').val(remote_databases[id].username); |
| 289 |
jQuery('#remote_passwd').val(remote_databases[id].password); |
| 290 |
jQuery('#remote_port').val(remote_databases[id].port); |
| 291 |
jQuery('#remote_schema').val(remote_databases[id].database); |
| 292 |
jQuery('#remote_enabled').prop('checked', !remote_databases[id].disabled); |
| 293 |
jQuery('#remote_ssl').prop('checked', remote_databases[id].ssl==="on");//.val(remote_databases[id].ssl); |
| 294 |
jQuery('#remote_client_key').val(remote_databases[id].ssl_key); |
| 295 |
jQuery('#remote_client_certificate').val(remote_databases[id].ssl_cert); |
| 296 |
jQuery('#remote_ca_certificate').val(remote_databases[id].ssl_ca); |
| 297 |
jQuery('#remote_certificate_path').val(remote_databases[id].ssl_path); |
| 298 |
jQuery('#remote_specified_cipher').val(remote_databases[id].ssl_cipher); |
| 299 |
if (remote_databases[id].ssl==="on") { |
| 300 |
jQuery('#remote_database_block_ssl').show(); |
| 301 |
} else { |
| 302 |
jQuery('#remote_database_block_ssl').hide(); |
| 303 |
} |
| 304 |
} |
| 305 |
|
| 306 |
function test_remote_clear(mode = '') { |
| 307 |
jQuery('#' + mode + 'remote_database_block_test_content').html(''); |
| 308 |
jQuery('#' + mode + 'remote_database_block_test').hide(); |
| 309 |
jQuery('#' + mode + 'remote_clear_button').hide(); |
| 310 |
} |
| 311 |
|
| 312 |
function test_remote_connection(mode = '') { |
| 313 |
host = jQuery('#remote_host').val(); |
| 314 |
user = jQuery('#remote_user').val(); |
| 315 |
pass = jQuery('#remote_passwd').val(); |
| 316 |
port = jQuery('#remote_port').val(); |
| 317 |
dbs = jQuery('#remote_schema').val(); |
| 318 |
|
| 319 |
url = '//' + window.location.host + window.location.pathname.replace('options-general','admin') + |
| 320 |
'?action=wpda_check_remote_database_connection'; |
| 321 |
|
| 322 |
jQuery('#remote_test_button').val('Testing...'); |
| 323 |
|
| 324 |
jQuery.ajax({ |
| 325 |
method: 'POST', |
| 326 |
url: url, |
| 327 |
data: { |
| 328 |
host: host, |
| 329 |
user: user, |
| 330 |
passwd: pass, |
| 331 |
port: port, |
| 332 |
schema: dbs |
| 333 |
} |
| 334 |
}).done( |
| 335 |
function (msg) { |
| 336 |
jQuery('#remote_database_block_test_content').html(msg); |
| 337 |
jQuery('#remote_database_block_test').show(); |
| 338 |
} |
| 339 |
).fail( |
| 340 |
function () { |
| 341 |
jQuery('#remote_database_block_test_content').html('Preparing connection...<br/>Establishing connection...<br/><br/><strong>Remote database connection invalid</strong>'); |
| 342 |
jQuery('#remote_database_block_test').show(); |
| 343 |
} |
| 344 |
).always( |
| 345 |
function () { |
| 346 |
jQuery('#remote_test_button').val('Test'); |
| 347 |
jQuery('#remote_clear_button').show(); |
| 348 |
} |
| 349 |
); |
| 350 |
} |
| 351 |
|
| 352 |
jQuery(function () { |
| 353 |
jQuery('#remote_database').keydown(function(e) { |
| 354 |
var field = this; |
| 355 |
setTimeout(function () { |
| 356 |
if (field.value.indexOf('rdb:') !== 0) { |
| 357 |
jQuery(field).val('rdb:'); |
| 358 |
} |
| 359 |
}, 1); |
| 360 |
}); |
| 361 |
}); |
| 362 |
|
| 363 |
var remote_databases = new Object(); |
| 364 |
<?php |
| 365 |
foreach ( $remote_databases as $key => $value ) { |
| 366 |
echo "remote_databases['$key'] = " . json_encode( $value ) . ';'; // phpcs:ignore WordPress.Security.EscapeOutput |
| 367 |
} |
| 368 |
?> |
| 369 |
</script> |
| 370 |
|
| 371 |
<div id="wpda_update_database_popup"> |
| 372 |
<div id="wpda_update_database_popup_header"> |
| 373 |
<span style="display:inline-block;margin-top:5px;"> |
| 374 |
<strong> |
| 375 |
<?php esc_html_e( 'Edit Remote Database Connection', 'wp-data-access' ); ?> |
| 376 |
</strong> |
| 377 |
</span> |
| 378 |
<span class="button" style="float:right;height:10px;" |
| 379 |
onclick="jQuery('#wpda_update_database_popup').hide()">x</span><br/> |
| 380 |
</div> |
| 381 |
|
| 382 |
<form id="wpda_update_database" method="post" |
| 383 |
action="?page=<?php echo esc_attr( $this->page ); ?>&tab=plugin"> |
| 384 |
|
| 385 |
<div> |
| 386 |
<label for="remote_database" style="vertical-align:baseline;" |
| 387 |
class="database_item_label">Database name:</label> |
| 388 |
<input type="text" name="remote_database" id="remote_database" value="rdb:"> |
| 389 |
<span>(local WordPress dashboard)</span> |
| 390 |
<div style="height:10px;"></div> |
| 391 |
<label for="remote_host" style="vertical-align:baseline;" class="database_item_label">MySQL host:</label> |
| 392 |
<input type="text" name="remote_host" id="remote_host"> |
| 393 |
<span>(ip address or hostname)</span> |
| 394 |
<br/> |
| 395 |
<label for="remote_user" style="vertical-align:baseline;" class="database_item_label">MySQL username:</label> |
| 396 |
<input type="text" name="remote_user" id="remote_user"> |
| 397 |
<br/> |
| 398 |
<label for="remote_passwd" style="vertical-align:baseline;" class="database_item_label">MySQL password:</label> |
| 399 |
<input type="password" name="remote_passwd" id="remote_passwd" autocomplete="new-password"> |
| 400 |
<i class="fas fa-eye" onclick="wpda_toggle_password('remote_passwd', event)" style="cursor:pointer"></i> |
| 401 |
<br/> |
| 402 |
<label for="remote_port" style="vertical-align:baseline;" class="database_item_label">MySQL port:</label> |
| 403 |
<input type="text" name="remote_port" id="remote_port" value="3306"> |
| 404 |
<br/> |
| 405 |
<label for="remote_schema" style="vertical-align:baseline;" class="database_item_label">MySQL schema:</label> |
| 406 |
<input type="text" name="remote_schema" id="remote_schema"> |
| 407 |
<br/> |
| 408 |
<label for="remote_schema" style="vertical-align:baseline;line-height:30px;" class="database_item_label"> |
| 409 |
Enabled: |
| 410 |
</label> |
| 411 |
<input type="checkbox" name="remote_enabled" id="remote_enabled"> |
| 412 |
|
| 413 |
<br/> |
| 414 |
<label style="line-height:30px;" for="remote_ssl" style="vertical-align:baseline;" class="database_item_label">SSL:</label> |
| 415 |
<input type="checkbox" name="remote_ssl" id="remote_ssl" unchecked onclick="jQuery('#remote_database_block_ssl').toggle()"> |
| 416 |
<div id="remote_database_block_ssl"> |
| 417 |
<label for="remote_client_key" style="vertical-align:baseline;" class="database_item_label">Client key:</label> |
| 418 |
<input type="text" name="remote_client_key" id="remote_client_key"> |
| 419 |
<br/> |
| 420 |
<label for="remote_client_certificate" style="vertical-align:baseline;" class="database_item_label">Client certificate:</label> |
| 421 |
<input type="text" name="remote_client_certificate" id="remote_client_certificate"> |
| 422 |
<br/> |
| 423 |
<label for="remote_ca_certificate" style="vertical-align:baseline;" class="database_item_label">CA certificate:</label> |
| 424 |
<input type="text" name="remote_ca_certificate" id="remote_ca_certificate"> |
| 425 |
<br/> |
| 426 |
<label for="remote_certificate_path" style="vertical-align:baseline;" class="database_item_label">Certificate path:</label> |
| 427 |
<input type="text" name="remote_certificate_path" id="remote_certificate_path"> |
| 428 |
<br/> |
| 429 |
<label for="remote_specified_cipher" style="vertical-align:baseline;" class="database_item_label">Specified Cipher:</label> |
| 430 |
<input type="text" name="remote_specified_cipher" id="remote_specified_cipher"> |
| 431 |
</div> |
| 432 |
|
| 433 |
<div style="height:10px;"></div> |
| 434 |
<label class="database_item_label"></label> |
| 435 |
<input type="button" value="Test" onclick="test_remote_connection(); return false;" |
| 436 |
id="remote_test_button" class="button"> |
| 437 |
<input type="button" value="Clear" onclick="test_remote_clear(); return false;" |
| 438 |
id="remote_clear_button" class="button" style="display:none;"> |
| 439 |
<div style="height:10px;"></div> |
| 440 |
</div> |
| 441 |
<div id="remote_database_block_test" style="display:none;"> |
| 442 |
<div id="remote_database_block_test_content" |
| 443 |
class="remote_database_block_test_content"></div> |
| 444 |
<div style="height:10px;"></div> |
| 445 |
</div> |
| 446 |
<input type="hidden" name="remote_database_old" id="remote_database_old" value="""> |
| 447 |
<input type="hidden" name="action" value="update_remote_database"/> |
| 448 |
<input type="submit" class="button button-secondary" value="<?php esc_html_e( 'Save', 'wp-data-access' ); ?>"> |
| 449 |
<a href="javascript:void(0)" |
| 450 |
onclick="jQuery('#wpda_update_database_popup').hide()" |
| 451 |
class="button button-secondary"> |
| 452 |
<?php esc_html_e( 'Cancel', 'wp-data-access' ); ?> |
| 453 |
</a> |
| 454 |
<?php |
| 455 |
$rdb_wp_nonce_action = 'wpda-update-remote-database-' . WPDA::get_current_user_login(); |
| 456 |
$rdb_wp_nonce = wp_create_nonce( $rdb_wp_nonce_action ); |
| 457 |
?> |
| 458 |
<input type="hidden" name="_wpnonceupdrdb" value="<?php echo esc_attr( $rdb_wp_nonce ); ?>"/> |
| 459 |
</form> |
| 460 |
</div> |
| 461 |
<form id="wpda_delete_database" method="post" style="display:none;" |
| 462 |
action="?page=<?php echo esc_attr( $this->page ); ?>&tab=plugin"> |
| 463 |
<input type="hidden" name="remote_database_name" id="delete_remote_database_name" value=""/> |
| 464 |
<input type="hidden" name="action" value="delete_remote_database"/> |
| 465 |
<?php |
| 466 |
$rdb_wp_nonce_action = 'wpda-delete-remote-database-' . WPDA::get_current_user_login(); |
| 467 |
$rdb_wp_nonce = wp_create_nonce( $rdb_wp_nonce_action ); |
| 468 |
?> |
| 469 |
<input type="hidden" name="_wpnoncedelrdb" value="<?php echo esc_attr( $rdb_wp_nonce ); ?>"/> |
| 470 |
</form> |
| 471 |
<form id="wpda_settings_plugin" method="post" |
| 472 |
action="?page=<?php echo esc_attr( $this->page ); ?>&tab=plugin"> |
| 473 |
<table class="wpda-table-settings" id="wpda_table_plugin"> |
| 474 |
<tr> |
| 475 |
<th><?php esc_html_e( 'Plugin menu', 'wp-data-access' ); ?></th> |
| 476 |
<td> |
| 477 |
<label> |
| 478 |
<input type="checkbox" name="hide_admin_menu" <?php echo 'on' === $hide_admin_menu ? 'checked="checked"' : ''; ?>/> |
| 479 |
<?php esc_html_e( 'Hide plugin menu in admin panel', 'wp-data-access' ); ?> |
| 480 |
</label> |
| 481 |
</td> |
| 482 |
</tr> |
| 483 |
<tr> |
| 484 |
<th><?php esc_html_e( 'Notices', 'wp-data-access' ); ?></th> |
| 485 |
<td> |
| 486 |
<label> |
| 487 |
<input type="checkbox" name="hide_foreign_notices" <?php echo $hide_foreign_notices === 'on' ? 'checked' : ''; ?> /> |
| 488 |
<?php esc_html_e( 'Hide notices of other themes and plugins on WP Data Access admin pages', 'wp-data-access' ); ?> |
| 489 |
</label> |
| 490 |
</td> |
| 491 |
</tr> |
| 492 |
<tr> |
| 493 |
<th><?php esc_html_e( 'Panel cookies', 'wp-data-access' ); ?></th> |
| 494 |
<td> |
| 495 |
<label> |
| 496 |
<input |
| 497 |
type="radio" |
| 498 |
name="panel_cookies" |
| 499 |
value="clear" |
| 500 |
<?php echo 'clear' === $panel_cookies ? 'checked' : ''; ?> |
| 501 |
><?php esc_html_e( 'Clear when switching panels', 'wp-data-access' ); ?> |
| 502 |
</label> |
| 503 |
<br/> |
| 504 |
<label> |
| 505 |
<input |
| 506 |
type="radio" |
| 507 |
name="panel_cookies" |
| 508 |
value="keep" |
| 509 |
<?php echo 'keep' === $panel_cookies ? 'checked' : ''; ?> |
| 510 |
><?php esc_html_e( 'Keep when switching panels', 'wp-data-access' ); ?> |
| 511 |
</label> |
| 512 |
</td> |
| 513 |
</tr> |
| 514 |
<tr> |
| 515 |
<th><?php esc_html_e( 'Secret key and IV', 'wp-data-access' ); ?></th> |
| 516 |
<td> |
| 517 |
<input type="text" name="secret_key" value="<?php echo esc_attr( $secret_key ); ?>"/> |
| 518 |
<br/> |
| 519 |
<input type="text" name="secret_iv" value="<?php echo esc_attr( $secret_iv ); ?>"/> |
| 520 |
<br/><br/> |
| 521 |
<span class="dashicons dashicons-info"></span><?php esc_html_e( 'Existing remote database connection settings will be converted', 'wp-data-access' ); ?> |
| 522 |
</td> |
| 523 |
</tr> |
| 524 |
<tr> |
| 525 |
<th><?php esc_html_e( 'Remote database connections', 'wp-data-access' ); ?></th> |
| 526 |
<td> |
| 527 |
<?php |
| 528 |
$i = 0; |
| 529 |
foreach ( $remote_databases as $remote_database => $remote_database_settings ) { |
| 530 |
$checked = isset( $remote_database_settings['disabled'] ) && $remote_database_settings['disabled'] ? '' : 'checked'; |
| 531 |
$enabled = isset( $remote_database_settings['disabled'] ) && $remote_database_settings['disabled'] ? 'FALSE' : 'TRUE'; |
| 532 |
?> |
| 533 |
<a href="javascript:void(0)" |
| 534 |
onclick="delete_remote_database('<?php echo esc_attr( $i ); ?>')" |
| 535 |
style="text-decoration:none;" |
| 536 |
class="wpda_tooltip" |
| 537 |
title="<?php esc_html_e( 'Delete remote database connection from plugin repository', 'wp-data-access' ); ?>"> |
| 538 |
<span class="dashicons dashicons-trash" style="font-size:18px;"></span> |
| 539 |
</a> |
| 540 |
<label class="wpda_tooltip" title="<?php esc_html_e( 'Disable remote database connection', 'wp-data-access' ); ?>"> |
| 541 |
<input type="checkbox" name="remote_database[]" id="remote_database<?php echo esc_attr( $i ); ?>" onclick="update_rdb_setting('<?php echo esc_attr( $i ); ?>')" <?php echo esc_attr( $checked ); ?>> |
| 542 |
<input type="hidden" name="remote_database_name[]" id="remote_database_name<?php echo esc_attr( $i ); ?>" value="<?php echo esc_attr( $remote_database ); ?>"> |
| 543 |
<input type="hidden" name="remote_database_enabled[]" id="remote_database_enabled<?php echo esc_attr( $i ); ?>" value="<?php echo esc_attr( $enabled ); ?>"> |
| 544 |
<?php echo esc_attr( $remote_database ); ?> |
| 545 |
</label> |
| 546 |
<a href="javascript:void(0)" |
| 547 |
onclick="edit_rdb_setting('<?php echo esc_attr( $remote_database ); ?>')" |
| 548 |
style="text-decoration:none;" |
| 549 |
class="wpda_tooltip" |
| 550 |
title="<?php esc_html_e( 'Edit remote database connection', 'wp-data-access' ); ?>"> |
| 551 |
<span class="dashicons dashicons-edit" style="font-size:18px;"></span> |
| 552 |
</a><br/> |
| 553 |
<?php |
| 554 |
$i++; |
| 555 |
} |
| 556 |
?> |
| 557 |
</td> |
| 558 |
</tr> |
| 559 |
<tr> |
| 560 |
<th><?php esc_html_e( 'Debug mode', 'wp-data-access' ); ?></th> |
| 561 |
<td> |
| 562 |
<label> |
| 563 |
<input |
| 564 |
type="checkbox" |
| 565 |
name="debug" <?php echo 'on' === $debug ? 'checked' : ''; ?> |
| 566 |
><?php esc_html_e( 'Enable debug mode', 'wp-data-access' ); ?> |
| 567 |
</label> |
| 568 |
</td> |
| 569 |
</tr> |
| 570 |
</table> |
| 571 |
<div class="wpda-table-settings-button"> |
| 572 |
<input type="hidden" name="action" value="save"/> |
| 573 |
<button type="submit" class="button button-primary"> |
| 574 |
<i class="fas fa-check wpda_icon_on_button"></i> |
| 575 |
<?php esc_html_e( 'Save Plugin Settings', 'wp-data-access' ); ?> |
| 576 |
</button> |
| 577 |
<a href="javascript:void(0)" |
| 578 |
onclick="if (confirm('<?php esc_html_e( 'Reset to defaults?', 'wp-data-access' ); ?>')) { |
| 579 |
jQuery('input[name="action"]').val('setdefaults'); |
| 580 |
jQuery('#wpda_settings_plugin').trigger('submit') |
| 581 |
}" |
| 582 |
class="button"> |
| 583 |
<i class="fas fa-times-circle wpda_icon_on_button"></i> |
| 584 |
<?php esc_html_e( 'Reset Plugin Settings To Defaults', 'wp-data-access' ); ?> |
| 585 |
</a> |
| 586 |
</div> |
| 587 |
<?php wp_nonce_field( 'wpda-plugin-settings-' . WPDA::get_current_user_login(), '_wpnonce', false ); ?> |
| 588 |
</form> |
| 589 |
<?php |
| 590 |
} |
| 591 |
|
| 592 |
} |
| 593 |
|
| 594 |
} |
| 595 |
|