Quantcast
Channel: BulletProof Security Forum » All Posts
Viewing all articles
Browse latest Browse all 12503

Reply To: BLOB/TEXT column cant have a default value for query CREATE TABLE

$
0
0

Cheers! Yeah, this was an odd one… re LudicrousDB: I’m using a simple setup drawn from the examples provided in the plugin code… specifically, my db-config.php has

$wpdb->save_queries = false;
$wpdb->persistent = false;
$wpdb->max_connections = 20;
$wpdb->check_tcp_responsiveness = true;
$wpdb->add_database(array(
	'host'     => 'IP:PORT',
	'user'     => 'db_usr',
	'password' => 'pass',
	'name'     => 'db_name',
	'timeout'  => '0.4',
));
$wpdb->add_database(array(
	'host'     => 'IP:PORT',
	'user'     => 'db_usr',
	'password' => 'pass',
	'name'     => 'db_name',
	'timeout'  => '0.4',
	'dataset'  => 'users',
));
$wpdb->add_database(array(
	'host'     => 'IP:PORT',
	'user'     => 'db_usr',
	'password' => 'pass',
	'name'     => 'db_name',
	'timeout'  => '0.4',
	'dataset'  => 'sites1',
));
$wpdb->add_callback('user_db_callback');
function user_db_callback($query, $wpdb) {
	if ( preg_match("/^{$wpdb->base_prefix}users$/i", $wpdb->table) )
		return 'users';
}
$wpdb->add_callback('usermeta_db_callback');
function usermeta_db_callback($query, $wpdb) {
	if ( preg_match("/^{$wpdb->base_prefix}usermeta$/i", $wpdb->table) )
		return 'users';
}
$wpdb->add_callback('sites1_db_callback');
function sites1_db_callback($query, $wpdb) {
	// Multisite blog tables are "{$base_prefix}{$blog_id}_*"
	if ( preg_match("/^{$wpdb->base_prefix}\d+_/i", $wpdb->table) )
		return 'sites1';
} 

I highly recommend that you try this out… its pretty awesome generally =)

Also, since such setups can offer advantages even for single site instances and esp. as most multisite networks that grow (or want to) will eventually need to do something similar re DB structure its really great to hear that you’re aiming to allow for multiple database monitoring soon(ish)… thanks also for the config guidance re current Monitor system.

addendum: would love to know any feedback you have re. some htaccess for http to https redirect that I have been working with (and will add to the appropriate custom code area in BPS) – esp the bit about using THE_REQUEST to avoid rewriting internal requests…

### BEGIN HTTPS Catch-All
# first line optional, from https://codex.wordpress.org/Administration_Over_SSL
# An important idea in this block is using THE_REQUEST, which ensures only actual http 
# requests are rewritten and not local direct file requests, like an include or fopen
#RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)\ HTTP/ [NC]
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,QSA,L]
# note use of NC and QSA - QSA can be esp important, generally better than using QUERY_STRING
# note in RewriteRule that we are only matching against the void preceding new line which avoids
# expensive pattern matching and value capture (specifically, '^' instead of '^/?(.*)' or similar)
### END HTTPS Catch-All

I am pretty confident in this, have run it in production for awhile (and I did recently share similar in some threads in this forum)… would appreciate any critique =)

…and yeah, re the Query String Removal… perhaps the OP in that thread should have been asked if they actually even use any cache/cdn that will not cache resources with query string as – imho – catering to the testing tool generally isn’t the best way to go… any case, thanks for the fair warning, mostly I just liked your code =)

Kind Regards, Max

  • This reply was modified 14 hours, 38 minutes ago by Profile photo of Max Max. Reason: fun

Viewing all articles
Browse latest Browse all 12503

Trending Articles