adding SASL auth fields & support for memcached
Peter Molnar hello@petermolnar.eu
Mon, 02 Jun 2014 16:02:13 +0100
3 files changed,
32 insertions(+),
1 deletions(-)
M
wp-ffpc-backend.php
→
wp-ffpc-backend.php
@@ -735,6 +735,10 @@
/* use binary and not compressed format, good for nginx and still fast */ $this->connection->setOption( Memcached::OPT_COMPRESSION , false ); $this->connection->setOption( Memcached::OPT_BINARY_PROTOCOL , true ); + + if ( version_compare( phpversion( 'memcached' ) , '2.0.0', '>=' ) && ini_get( 'memcached.use_sasl' ) == 1 ) { + $this->connection->setSaslAuthData ( $this->options['authuser'], $this->options['authpass']); + } } /* check if initialization was success or not */
M
wp-ffpc-class.php
→
wp-ffpc-class.php
@@ -631,6 +631,31 @@ <dd>
<input type="checkbox" name="persistent" id="persistent" value="1" <?php checked($this->options['persistent'],true); ?> /> <span class="description"><?php _e('Make all memcache(d) connections persistent. Be careful with this setting, always test the outcome.', $this->plugin_constant); ?></span> </dd> + + <?php + if ( strstr ( $this->options['cache_type'], 'memcached') && extension_loaded ( 'memcached' ) && version_compare( phpversion( 'memcached' ) , '2.0.0', '>=' ) ) { ?> + <?php + if ( ! ini_get('memcached.use_sasl') && ( !empty( $this->options['authuser'] ) || !empty( $this->options['authpass'] ) ) ) { ?> + <div class="error"><p><strong><?php _e( 'WARNING: you\'ve entered username and/or password for memcached authentication ( or your browser\'s autocomplete did ) which will not work unless you enable memcached sasl in the PHP settings: add `memcached.use_sasl=1` to php.ini' , $this->plugin_constant ) ?></strong></p></div> + <?php } ?> + <dt> + <label for="authuser"><?php _e('Authentication: username', $this->plugin_constant); ?></label> + </dt> + <dd> + <input type="text" name="authuser" id="authuser" value="<?php echo $this->options['authuser']; ?>" /> + <span class="description"> + <?php _e('Username for authentication with memcached backends', $this->plugin_constant); ?></span> + </dd> + + <dt> + <label for="authpass"><?php _e('Authentication: password', $this->plugin_constant); ?></label> + </dt> + <dd> + <input type="password" name="authpass" id="authpass" value="<?php echo $this->options['authpass']; ?>" /> + <span class="description"> + <?php _e('Password for authentication with memcached backends - WARNING, the password will be stored plain-text since it needs to be used!', $this->plugin_constant); ?></span> + </dd> + <?php } ?> </dl> </fieldset>
M
wp-ffpc.php
→
wp-ffpc.php
@@ -29,6 +29,8 @@ include_once ( 'wp-ffpc-class.php' );
$wp_ffpc_defaults = array ( 'hosts'=>'127.0.0.1:11211', + 'authpass'=>'', + 'authuser'=>'', 'expire'=>300, 'invalidation_method'=>0, 'prefix_meta' =>'meta-',@@ -51,6 +53,6 @@ 'key' => '$scheme://$host$request_uri',
'comments_invalidate' => true, ); -$wp_ffpc = new WP_FFPC ( 'wp-ffpc', '1.4.0', 'WP-FFPC', $wp_ffpc_defaults, 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XU3DG7LLA76WC' ); +$wp_ffpc = new WP_FFPC ( 'wp-ffpc', '1.6.0', 'WP-FFPC', $wp_ffpc_defaults, 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XU3DG7LLA76WC' ); ?>