key scheme change added
This commit is contained in:
parent
0c368e2bb9
commit
23ee5f0109
7 changed files with 63 additions and 29 deletions
|
@ -93,6 +93,7 @@ What's new:
|
|||
* 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:
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit c862af55f464e366dd6f44d20dcf709d0b5bbe51
|
||||
Subproject commit fe3a3c9c52091f21924de59d379442201e8a059a
|
|
@ -69,8 +69,8 @@ if ( isset($wp_ffpc_config['nocache_cookies']) && !empty($wp_ffpc_config['nocach
|
|||
|
||||
/* 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 @@ if (!class_exists('WP_FFPC_Backend')) {
|
|||
private $options = array();
|
||||
private $status = array();
|
||||
public $cookies = array();
|
||||
private $urimap = array();
|
||||
private $utilities;
|
||||
|
||||
/**
|
||||
|
@ -59,7 +60,14 @@ if (!class_exists('WP_FFPC_Backend')) {
|
|||
|
||||
$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 @@ if (!class_exists('WP_FFPC_Backend')) {
|
|||
*
|
||||
*/
|
||||
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 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
* @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 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
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 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
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 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
/* 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 ) )
|
||||
if ( @file_exists ( $this->precache_logfile ) ) {
|
||||
unlink ( $this->precache_logfile );
|
||||
}
|
||||
|
||||
if ( @file_exists ( $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 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
<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 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
</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 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
}
|
||||
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 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
<?php } ?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
</table></div>
|
||||
<?php } ?>
|
||||
</fieldset>
|
||||
|
||||
|
@ -798,7 +824,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
/* 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 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
|
||||
/* 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,10 +935,10 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
$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";
|
||||
unset ( $page, $size, $starttime, $endtime );
|
||||
|
|
|
@ -79,7 +79,7 @@ MEMCACHED_SERVERS
|
|||
# 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 @@ $wp_ffpc_defaults = array (
|
|||
'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' );
|
||||
|
|
Loading…
Reference in a new issue