Created
July 1, 2013 23:25
-
-
Save tistaharahap/5905530 to your computer and use it in GitHub Desktop.
Hacked Wordpress index.php with refresh hook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$_start = microtime(TRUE); | |
$mem = new Memcache; | |
$mem->connect('127.0.0.1', 11211) or die('Memcache is dead'); | |
$url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; | |
$key = md5($url); | |
$cache = !empty($_GET['refresh']) && $_GET['refresh'] == 'waku' ? FALSE : $mem->get($key); | |
if(!empty($cache['data'])) { | |
$elapsed = microtime(TRUE) - $_start; | |
$cache['data'] .= PHP_EOL . "<!-- Served from cache ".$elapsed." second -->"; | |
header('Content-Type: text/html'); | |
echo $cache['data']; exit; | |
} | |
else { | |
ob_start("cb"); | |
} | |
function cb($buffer) { | |
$current_url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; | |
$key = md5($current_url); | |
$ttl = 60 * 60 * 24 * 30; | |
$set = array( | |
'data' => $buffer | |
); | |
global $mem; | |
$mem->set($key, $set, false, $ttl); | |
return $buffer; | |
} | |
/** | |
* Front to the WordPress application. This file doesn't do anything, but loads | |
* wp-blog-header.php which does and tells WordPress to load the theme. | |
* | |
* @package WordPress | |
*/ | |
/** | |
* Tells WordPress to load the WordPress theme and output it. | |
* | |
* @var bool | |
*/ | |
define('WP_USE_THEMES', true); | |
/** Loads the WordPress Environment and Template */ | |
require('./wp-blog-header.php'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment