key scheme change added
@@ -93,6 +93,7 @@
* additional cookie patterns to exclude visitors from cache * syslog dropped; using standard PHP log instead, combined with WP_DEBUG to change to info/notice level * possibility to start pre-cache from wp-cron +* changeable key scheme ( was fixed previously ) What's fixed:
@@ -69,8 +69,8 @@ }
/* canonical redirect storage */ $wp_ffpc_redirect = null; - /* fires up the backend storage array with current config */ +include_once ('wp-ffpc-backend.php'); $wp_ffpc_backend = new WP_FFPC_Backend( $wp_ffpc_config ); /* no cache for for logged in users unless it's set
@@ -44,6 +44,7 @@ private $network = false;
private $options = array(); private $status = array(); public $cookies = array(); + private $urimap = array(); private $utilities; /**@@ -59,7 +60,14 @@ $this->network = $network;
$this->cookies = array ( 'comment_author_' , 'wordpressuser_' , 'wp-postpass_', 'wordpress_logged_in_' ); - $this->utilities = WP_Plugins_Utilities::Utility(); + $this->utilities = WP_Plugins_Utilities_v1::Utility(); + + $this->urimap = array( + '$scheme' => str_replace ( '://', '', $this->utilities->replace_if_ssl ( 'http://' ) ), + '$host' => $_SERVER['HTTP_HOST'], + '$request_uri' => $_SERVER['REQUEST_URI'], + '$remote_user' => $_SERVER['REMOTE_USER'], + ); /* no config, nothing is going to work */ if ( empty ( $this->options ) ) {@@ -85,14 +93,12 @@ * @param string $prefix prefix to add to prefix
* */ public function key ( &$prefix ) { - /* use the full accessed URL string as key, same will be generated by nginx as well - we need a data and a meta key: data is string only with content, meta is not used in nginx */ - if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) - $_SERVER['HTTPS'] = 'on'; + /* data is string only with content, meta is not used in nginx */ + $key = str_replace ( array_keys( $this->urimap ), $this->urimap, $this->options['key'] ); + $this->log ( __translate__('original key configuration: ', $this->plugin_constant ) . $this->options['key'] ); + $this->log ( __translate__('setting key to: ', $this->plugin_constant ) . $key ); - $protocol = ( isset($_SERVER['HTTPS']) && ( ( strtolower($_SERVER['HTTPS']) == 'on' ) || ( $_SERVER['HTTPS'] == '1' ) ) ) ? 'https://' : 'http://'; - - return $prefix . $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + return $key; }
@@ -10,7 +10,6 @@ *
*/ if ( ! class_exists( 'WP_FFPC' ) ) { - /* get the plugin abstract class*/ include_once ( 'wp-common/wp-plugin-abstract.php' ); /* get the common functions class*/@@ -29,7 +28,7 @@ * @var array $select_cache_type Cache types string array
* @var array $select_invalidation_method Invalidation methods string array * */ - class WP_FFPC extends WP_Plugins_Abstract { + class WP_FFPC extends WP_Plugins_Abstract_v2 { const host_separator = ','; const port_separator = ':'; const donation_id_key = 'hosted_button_id=';@@ -63,7 +62,7 @@ protected $select_cache_type = array ();
protected $select_invalidation_method = array (); protected $select_schedules = array(); protected $valid_cache_type = array (); - + protected $list_uri_vars = array(); private $shell_function = false; private $shell_possibilities = array (); private $backend = NULL;@@ -130,6 +129,17 @@ 1 => __( 'only modified post' , $this->plugin_constant ),
2 => __( 'modified post and all taxonomies' , $this->plugin_constant ), ); + $this->list_uri_vars = array ( + '$scheme' => __('The HTTP scheme (i.e. http, https).', $this->plugin_constant ), + '$host' => __('Host in the header of request or name of the server processing the request if the Host header is not available.', $this->plugin_constant ), + '$request_uri' => __('The *original* request URI as received from the client including the args', $this->plugin_constant ), + '$remote_user' => __('Name of user, authenticated by the Auth Basic Module', $this->plugin_constant ), + //'$cookie_COOKnginy IE' => __('Value of COOKIE', $this->plugin_constant ), + //'$http_HEADER' => __('Value of HTTP request header HEADER ( lowercase, dashes converted to underscore )', $this->plugin_constant ), + //'$query_string' => __('Full request URI after rewrites', $this->plugin_constant ), + //'' => __('', $this->plugin_constant ), + ); + $wp_schedules = wp_get_schedules(); $schedules['null'] = __( 'do not use timed precache' ); foreach ( $wp_schedules as $interval=>$details ) {@@ -217,14 +227,16 @@ public function plugin_hook_admin_init () {
/* save parameter updates, if there are any */ if ( isset( $_POST[ $this->button_flush ] ) ) { - update_option( self::precache_log , '' ); - update_option( self::precache_timestamp , '' ); + $this->_delete_option( self::precache_log ); + $this->_delete_option( self::precache_timestamp ); - if ( @file_exists ( $this->precache_logfile ) ) - unlink ( $this->precache_logfile ); + if ( @file_exists ( $this->precache_logfile ) ) { + unlink ( $this->precache_logfile ); + } - if ( @file_exists ( $this->precache_phpfile ) ) - unlink ( $this->precache_phpfile ); + if ( @file_exists ( $this->precache_phpfile ) ) { + unlink ( $this->precache_phpfile ); + } $this->backend->clear( false, true ); $this->status = 3;@@ -439,6 +451,20 @@ <dd>
<input type="text" name="prefix_meta" id="prefix_meta" value="<?php echo $this->options['prefix_meta']; ?>" /> <span class="description"><?php _e('Prefix for meta content keys, used only with PHP processing.', $this->plugin_constant); ?></span> </dd> + + <dt> + <label for="key"><?php _e('Key scheme', $this->plugin_constant); ?></label> + </dt> + <dd> + <input type="text" name="key" id="key" value="<?php echo $this->options['key']; ?>" /> + <span class="description"><?php _e('Key layout; <strong>use the guide below to change it</strong>. Changing this requires changes in the nginx configuration and restarting nginx, if nginx memcached is in use.', $this->plugin_constant); ?><?php ?></span> + <dl class="description"><?php + foreach ( $this->list_uri_vars as $uri => $desc ) { + echo '<dt>'. $uri .'</dt><dd>'. $desc .'</dd>'; + } + ?></dl> + </dd> + </dl> </fieldset>@@ -450,7 +476,7 @@ <label for="log"><?php _e("Enable logging", $this->plugin_constant); ?></label>
</dt> <dd> <input type="checkbox" name="log" id="log" value="1" <?php checked($this->options['log'],true); ?> /> - <span class="description"><?php _e('Enables ERROR and WARNING level syslog messages. Requires PHP syslog function.', $this->plugin_constant); ?></span> + <span class="description"><?php _e('Enables log messages; if <a href="http://codex.wordpress.org/WP_DEBUG">WP_DEBUG</a> is enabled, notices and info level is displayed as well, otherwie only ERRORS are logged.', $this->plugin_constant); ?></span> </dd> <dt>@@ -602,7 +628,7 @@ _e('No precache log was found!', $this->plugin_constant);
} else { ?> <p><strong><?php _e( 'Time of run: ') ?><?php echo date('r', $gentime ); ?></strong></p> - <table style="width:100%; border: 1px solid #ccc;"> + <div style="overflow: auto; max-height: 20em;"><table style="width:100%; border: 1px solid #ccc;"> <thead><tr> <?php $head = explode( " ", array_shift( $log )); foreach ( $head as $column ) { ?>@@ -618,7 +644,7 @@ <td><?php echo $column; ?></td>
<?php } ?> </tr> <?php } ?> - </table> + </table></div> <?php } ?> </fieldset>@@ -798,7 +824,7 @@
/* add the required includes and generate the needed code */ $string[] = "<?php"; $string[] = self::global_config_var . ' = ' . var_export ( $this->global_config, true ) . ';' ; - $string[] = "include_once ('" . $this->acache_backend . "');"; + //$string[] = "include_once ('" . $this->acache_backend . "');"; $string[] = "include_once ('" . $this->acache_worker . "');"; $string[] = "?>";@@ -818,7 +844,7 @@ $nginx = file_get_contents ( $this->nginx_sample );
/* replace the data prefix with the configured one */ $to_replace = array ( 'DATAPREFIX' , 'SERVERROOT', 'SERVERLOG' ); - $replace_with = array ( $this->options['prefix_data'], ABSPATH, $_SERVER['SERVER_NAME'] ); + $replace_with = array ( $this->options['prefix_data'] . $this->options['key'] , ABSPATH, $_SERVER['SERVER_NAME'] ); $nginx = str_replace ( $to_replace , $replace_with , $nginx ); /* set upstream servers from configured servers, best to get from the actual backend */@@ -909,12 +935,12 @@ $starttime = explode ( " ", microtime() );
$starttime = $starttime[1] + $starttime[0]; $page = file_get_contents( $permalink ); - $size = round ( ( strlen ( $page ) / 1024 ), 3 ); + $size = round ( ( strlen ( $page ) / 1024 ), 2 ); $endtime = explode ( " ", microtime() ); - $endtime = ( $endtime[1] + $endtime[0] ) - $starttime; + $endtime = round( ( $endtime[1] + $endtime[0] ) - $starttime, 2 ); - echo $permalink . "\t" . $endtime . "\t" . $size . "\n"; + echo $permalink . "\t" . $endtime . "\t" . $size . "\n"; unset ( $page, $size, $starttime, $endtime ); sleep( 1 ); }
@@ -79,7 +79,7 @@
# try to get result from memcached location @memcached { default_type text/html; - set $memcached_key DATAPREFIX$scheme://$host$request_uri; + set $memcached_key DATAPREFIX; set $memcached_request 1; # exceptions
@@ -47,7 +47,8 @@ 'sync_protocols' => false,
'persistent' => false, 'response_header' => false, 'generate_time' => false, - 'precache_schedule' => 'null' + 'precache_schedule' => 'null', + 'key' => '$scheme://$host$request_uri', ); $wp_ffpc = new WP_FFPC ( 'wp-ffpc', '1.2', 'WP-FFPC', $wp_ffpc_defaults, 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XU3DG7LLA76WC' );