Commit 9a3e67bd authored by Erick Hitter's avatar Erick Hitter

Pinking shears

parent fa4a8597
......@@ -19,12 +19,12 @@ function requestHasSecret($secret) {
function isRemotePageLoad($currentUrl, $websiteIp) {
return (isset($_SERVER['HTTP_REFERER'])
&& $_SERVER['HTTP_REFERER']== $currentUrl
&& $_SERVER['REQUEST_URI'] != '/'
&& $_SERVER['REQUEST_URI'] != '/'
&& $_SERVER['REMOTE_ADDR'] != $websiteIp);
}
function handleCDNRemoteAddressing() {
// so we don't confuse the cloudflare server
// so we don't confuse the cloudflare server
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
}
......@@ -61,7 +61,7 @@ try {
// Sockets can be used as well. Documentation @ https://github.com/nicolasff/phpredis/#connection
$redis->connect($reddis_server);
} else { // Fallback to predis5.2.php
if ($debug) {
......@@ -70,7 +70,7 @@ try {
include_once("wp-content/plugins/wp-redis-cache/predis5.2.php"); //we need this to use Redis inside of PHP
$redis = new Predis_Client();
}
//Either manual refresh cache by adding ?refresh=secret_string after the URL or somebody posting a comment
if (refreshHasSecret($secret_string) || requestHasSecret($secret_string) || isRemotePageLoad($current_url, $websiteIp)) {
if ($debug) {
......@@ -78,7 +78,7 @@ try {
}
$redis->del($redis_key);
require('./wp-blog-header.php');
$unlimited = get_option('wp-redis-cache-debug',false);
$seconds_cache_redis = get_option('wp-redis-cache-seconds',43200);
// This page is cached, lets display it
......@@ -95,9 +95,9 @@ try {
if ($debug) {
echo "<!-- displaying page without cache -->\n";
}
$isPOST = ($_SERVER['REQUEST_METHOD'] === 'POST') ? 1 : 0;
$loggedIn = preg_match("/wordpress_logged_in/", var_export($_COOKIE, true));
if (!$isPOST && !$loggedIn) {
ob_start();
......@@ -123,7 +123,7 @@ try {
} else { //either the user is logged in, or is posting a comment, show them uncached
require('./wp-blog-header.php');
}
} else if ($_SERVER['REMOTE_ADDR'] != $websiteIp && strstr($current_url, 'preview=true') == true) {
require('./wp-blog-header.php');
}
......
......@@ -40,13 +40,13 @@ function clear_wp_redis_cache()
$redis_key = md5($permalink);
if (($redis->exists($redis_key)) == true ) {
$redis->del($redis_key);
$i++;
$i++;
}
endwhile;
echo $i++." of " . $wp_query -> found_posts . " posts was cleared in cache";
echo $i++." of " . $wp_query -> found_posts . " posts was cleared in cache";
die();
}
......@@ -67,7 +67,7 @@ jQuery(document).ready(function($) {
});
});
</script>
<?php
<?php
}
?>
......@@ -6,7 +6,7 @@ Version: 1.0
Author: Benjamin Adams
Author URI: http://dudelol.com
Cache Wordpress using Redis, the fastest way to date to cache Wordpress.
Cache Wordpress using Redis, the fastest way to date to cache Wordpress.
== Description ==
## Wp Redis Cache
......@@ -100,7 +100,7 @@ We do this because Wordpress is no longer in charge of displaying our posts. Re
/* Copyright 2013 Benjamin Adams (email : ben@dudelol.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
......@@ -111,7 +111,7 @@ We do this because Wordpress is no longer in charge of displaying our posts. Re
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
......@@ -128,20 +128,20 @@ function edit_redis_options() {
<h2>Wp-Redis Options</h2>
<form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?>
<p>This plugin does not work out of the box and requires additional steps.<br />
Please follow these install instructions: <a target='_blank' href='https://github.com/BenjaminAdams/wp-redis-cache'>https://github.com/BenjaminAdams/wp-redis-cache</a></p>
<p>If you do not have Redis installed on your machine this will NOT work! </p>
<p><strong>Seconds of Caching:</strong><br />
How many seconds would you like to cache? *Recommended 12 hours or 43200 seconds <br />
<input type="text" name="wp-redis-cache-seconds" size="45" value="<?php echo get_option('wp-redis-cache-seconds'); ?>" /></p>
<p><strong>Cache unlimeted:</strong><br />
If this options set the cache never expire. This option overiedes the setting "Seconds of Caching"<br />
<input type="checkbox" name="wp-redis-cache-unlimited" size="45" value="true" <?php checked('true', get_option('wp-redis-cache-unlimited')); ?>/></p>
<p><input type="submit" name="Submit" value="Update Options" /></p>
<p><input type="button" id="WPRedisClearCache" name="WPRedisClearCache" value="Clear Cache"></p>
<input type="hidden" name="action" value="update" />
......
......@@ -192,7 +192,7 @@ class Predis_Client {
return $this->_connection;
}
else {
return Predis_Shared_Utils::isCluster($this->_connection)
return Predis_Shared_Utils::isCluster($this->_connection)
? $this->_connection->getConnectionById($id)
: $this->_connection;
}
......@@ -460,7 +460,7 @@ abstract class Predis_Command {
}
if (isset($this->_arguments[0])) {
// TODO: should we throw an exception if the command does
// TODO: should we throw an exception if the command does
// not support sharding?
$key = $this->_arguments[0];
......@@ -533,7 +533,7 @@ abstract class Predis_BulkCommand extends Predis_Command {
if (is_array($data)) {
$data = implode($data, ' ');
}
return $command . ' ' . implode($arguments, ' ') . ' ' . strlen($data) .
return $command . ' ' . implode($arguments, ' ') . ' ' . strlen($data) .
"\r\n" . $data . "\r\n";
}
}
......@@ -773,11 +773,11 @@ class Predis_ResponseReader implements Predis_IResponseReader {
private function initializePrefixHandlers() {
$this->_prefixHandlers = array(
Predis_Protocol::PREFIX_STATUS => new Predis_ResponseStatusHandler(),
Predis_Protocol::PREFIX_ERROR => new Predis_ResponseErrorHandler(),
Predis_Protocol::PREFIX_INTEGER => new Predis_ResponseIntegerHandler(),
Predis_Protocol::PREFIX_BULK => new Predis_ResponseBulkHandler(),
Predis_Protocol::PREFIX_MULTI_BULK => new Predis_ResponseMultiBulkHandler(),
Predis_Protocol::PREFIX_STATUS => new Predis_ResponseStatusHandler(),
Predis_Protocol::PREFIX_ERROR => new Predis_ResponseErrorHandler(),
Predis_Protocol::PREFIX_INTEGER => new Predis_ResponseIntegerHandler(),
Predis_Protocol::PREFIX_BULK => new Predis_ResponseBulkHandler(),
Predis_Protocol::PREFIX_MULTI_BULK => new Predis_ResponseMultiBulkHandler(),
);
}
......@@ -909,7 +909,7 @@ class Predis_CommandPipeline {
if (count($this->_pipelineBuffer) > 0) {
$connection = $this->_redisClient->getConnection();
$this->_returnValues = array_merge(
$this->_returnValues,
$this->_returnValues,
$this->_executor->execute($connection, $this->_pipelineBuffer)
);
$this->_pipelineBuffer = array();
......@@ -1174,8 +1174,8 @@ class Predis_MultiExecBlock {
}
private function malformedServerResponse($message) {
// Since a MULTI/EXEC block cannot be initialized over a clustered
// connection, we can safely assume that Predis_Client::getConnection()
// Since a MULTI/EXEC block cannot be initialized over a clustered
// connection, we can safely assume that Predis_Client::getConnection()
// will always return an instance of Predis_Connection.
Predis_Shared_Utils::onCommunicationException(
new Predis_MalformedServerResponse(
......@@ -2391,19 +2391,19 @@ class Predis_Distribution_HashRing implements Predis_Distribution_IDistributionS
public function add($node, $weight = null) {
// NOTE: in case of collisions in the hashes of the nodes, the node added
// last wins, thus the order in which nodes are added is significant.
// TODO: self::DEFAULT_WEIGHT does not work for inherited classes that
// TODO: self::DEFAULT_WEIGHT does not work for inherited classes that
// override the DEFAULT_WEIGHT constant.
$this->_nodes[] = array(
'object' => $node,
'weight' => (int) ($weight !== null ? $weight : self::DEFAULT_WEIGHT),
'object' => $node,
'weight' => (int) ($weight !== null ? $weight : self::DEFAULT_WEIGHT),
);
$this->reset();
}
public function remove($node) {
// NOTE: a node is removed by resetting the ring so that it's recreated from
// scratch, in order to reassign possible hashes with collisions to the
// right node according to the order in which they were added in the
// NOTE: a node is removed by resetting the ring so that it's recreated from
// scratch, in order to reassign possible hashes with collisions to the
// right node according to the order in which they were added in the
// first place.
for ($i = 0; $i < count($this->_nodes); ++$i) {
if ($this->_nodes[$i]['object'] === $node) {
......@@ -2493,8 +2493,8 @@ class Predis_Distribution_HashRing implements Predis_Distribution_IDistributionS
}
protected function wrapAroundStrategy($upper, $lower, $ringKeysCount) {
// NOTE: binary search for the last item in _ringkeys with a value
// less or equal to the key. If no such item exists, return the
// NOTE: binary search for the last item in _ringkeys with a value
// less or equal to the key. If no such item exists, return the
// last item.
return $upper >= 0 ? $upper : $ringKeysCount - 1;
}
......@@ -2525,8 +2525,8 @@ class Predis_Distribution_KetamaPureRing extends Predis_Distribution_HashRing {
}
protected function wrapAroundStrategy($upper, $lower, $ringKeysCount) {
// NOTE: binary search for the first item in _ringkeys with a value
// greater or equal to the key. If no such item exists, return the
// NOTE: binary search for the first item in _ringkeys with a value
// greater or equal to the key. If no such item exists, return the
// first item.
return $lower < $ringKeysCount ? $lower : 0;
}
......@@ -2584,8 +2584,8 @@ abstract class Predis_Shared_MultiBulkResponseIteratorBase implements Iterator,
}
public function count() {
// NOTE: use count if you want to get the size of the current multi-bulk
// response without using iterator_count (which actually consumes
// NOTE: use count if you want to get the size of the current multi-bulk
// response without using iterator_count (which actually consumes
// our iterator to calculate the size, and we cannot perform a rewind)
return $this->_replySize;
}
......@@ -3264,7 +3264,7 @@ class Predis_Commands_Sort extends Predis_MultiBulkCommand {
$query[] = $getargs;
}
}
if (isset($sortParams['LIMIT']) && is_array($sortParams['LIMIT'])
if (isset($sortParams['LIMIT']) && is_array($sortParams['LIMIT'])
&& count($sortParams['LIMIT']) == 2) {
$query[] = 'LIMIT';
......@@ -3434,7 +3434,7 @@ class Predis_Commands_Info extends Predis_MultiBulkCommand {
}
return $stats;
}
}
}
class Predis_Commands_Info_v24 extends Predis_Commands_Info {
public function parseResponse($data) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment