' . $message . '
' );
+ exit;
+ default:
+ if ( !defined( 'WP_DEBUG' ) && WP_DEBUG != true )
+ return;
+ break;
+ }
+
+ error_log( __CLASS__ . ": " . $message );
+ }
+
+ /**
+ * display formatted alert message
+ *
+ * @param string $msg Error message
+ * @param string $error "level" of error
+ * @param boolean $network WordPress network or not, DEPRECATED
+ *
+ */
+ static public function alert ( $msg, $level=LOG_WARNING, $network=false ) {
+ if ( empty($msg)) return false;
+
+ switch ($level) {
+ case LOG_ERR:
+ case LOG_WARNING:
+ $css = "error";
+ break;
+ default:
+ $css = "updated";
+ break;
+ }
+
+ $r = ''. sprintf ( __('%s', 'PluginUtils' ), $msg ) .'
';
+ if ( version_compare(phpversion(), '5.3.0', '>=')) {
+ add_action('admin_notices', function() use ($r) { echo $r; }, 10 );
+ }
+ else {
+ global $tmp;
+ $tmp = $r;
+ $f = create_function ( '', 'global $tmp; echo $tmp;' );
+ add_action('admin_notices', $f );
+ }
+ static::debug( $msg, $level );
+ }
+
+}
+
+endif;
diff --git a/wp-ffpc-acache.php b/wp-ffpc-acache.php
index 96774ab..3c2941d 100644
--- a/wp-ffpc-acache.php
+++ b/wp-ffpc-acache.php
@@ -180,7 +180,7 @@ if ( $wp_ffpc_config['response_header'] )
header( 'X-Cache-Engine: WP-FFPC with ' . $wp_ffpc_config['cache_type'] .' via PHP');
/* HTML data */
-echo $wp_ffpc_values['data'];
+echo trim($wp_ffpc_values['data']);
flush();
die();
@@ -332,8 +332,6 @@ function wp_ffpc_callback( $buffer ) {
}
/* echoes HTML out */
- return $buffer;
+ return trim($buffer);
}
/*** END GENERATING CACHE ENTRY ***/
-
-?>
diff --git a/wp-ffpc-backend.php b/wp-ffpc-backend.php
index de6fa40..d601ec3 100644
--- a/wp-ffpc-backend.php
+++ b/wp-ffpc-backend.php
@@ -126,9 +126,11 @@ class WP_FFPC_Backend {
public function key ( $prefix, $customUrimap = null ) {
$urimap = $customUrimap ?: $this->urimap;
+ $key_base = self::map_urimap($urimap, $this->options['key']);
/* data is string only with content, meta is not used in nginx */
- $key = $prefix . self::map_urimap($urimap, $this->options['key']);
+ $key = sha1 ($prefix . $key_base );
$this->log ( sprintf( __translate__( 'original key configuration: %s', $this->plugin_constant ), $this->options['key'] ) );
+ $this->log ( sprintf( __translate__( 'setting key for: %s', $this->plugin_constant ), $key_base ) );
$this->log ( sprintf( __translate__( 'setting key to: %s', $this->plugin_constant ), $key ) );
return $key;
}
@@ -142,7 +144,6 @@ class WP_FFPC_Backend {
* @return mixed False when entry not found or entry value on success
*/
public function get ( &$key ) {
-
/* look for backend aliveness, exit on inactive backend */
if ( ! $this->is_alive() )
return false;
@@ -169,7 +170,6 @@ class WP_FFPC_Backend {
* @return mixed $result status of set function
*/
public function set ( &$key, &$data, $expire = false ) {
-
/* look for backend aliveness, exit on inactive backend */
if ( ! $this->is_alive() )
return false;
@@ -480,11 +480,22 @@ class WP_FFPC_Backend {
* @var mixed $message Message to log
* @var int $log_level Log level
*/
- private function log ( $message, $log_level = LOG_NOTICE ) {
- if ( !isset ( $this->options['log'] ) || $this->options['log'] != 1 )
- return false;
- else
- $this->utilities->log ( $this->plugin_constant , $message, $log_level );
+ private function log ( $message, $level = LOG_NOTICE ) {
+ if ( @is_array( $message ) || @is_object ( $message ) )
+ $message = json_encode($message);
+
+
+ switch ( $level ) {
+ case LOG_ERR :
+ wp_die( '' . $message . '
' );
+ exit;
+ default:
+ if ( !defined( 'WP_DEBUG' ) && WP_DEBUG != true )
+ return;
+ break;
+ }
+
+ error_log( __CLASS__ . ": " . $message );
}
/*********************** END PUBLIC FUNCTIONS ***********************/
@@ -1084,4 +1095,4 @@ class WP_FFPC_Backend {
}
-endif; ?>
+endif;
diff --git a/wp-ffpc-class.php b/wp-ffpc-class.php
index eee1ca4..b1eacd2 100644
--- a/wp-ffpc-class.php
+++ b/wp-ffpc-class.php
@@ -3,7 +3,7 @@
if ( ! class_exists( 'WP_FFPC' ) ) :
/* get the plugin abstract class*/
-include_once ( dirname(__FILE__) . '/wp-common/plugin_abstract.php' );
+include_once ( dirname(__FILE__) . '/wp-ffpc-abstract.php' );
/* get the common functions class*/
include_once ( dirname(__FILE__) .'/wp-ffpc-backend.php' );
@@ -22,7 +22,7 @@ include_once ( dirname(__FILE__) .'/wp-ffpc-backend.php' );
* @var array $shell_possibilities List of possible precache worker callers
[TODO] finish list of vars
*/
-class WP_FFPC extends PluginAbstract {
+class WP_FFPC extends WP_FFPC_ABSTRACT {
const host_separator = ',';
const port_separator = ':';
const donation_id_key = 'hosted_button_id=';
@@ -112,6 +112,9 @@ class WP_FFPC extends PluginAbstract {
}
}
+ if (!isset($_SERVER['HTTP_HOST']))
+ $_SERVER['HTTP_HOST'] = '127.0.0.1';
+
/* set global config key; here, because it's needed for migration */
if ( $this->network ) {
$this->global_config_key = 'network';
@@ -221,7 +224,7 @@ class WP_FFPC extends PluginAbstract {
/* look for global settings array */
if ( ! $this->global_saved )
- $this->errors['no_global_saved'] = sprintf( __('This site was reached as %s ( according to PHP HTTP_HOST ) and there are no settings present for this domain in the WP-FFPC configuration yet. Please save the