Options configuration panel Version: 1.3 Author: AskApache Author URI: http://www.askapache.com */ /* == Installation == 1. Upload askapache-crazy-cache.zip to the /wp-content/plugins/ directory 2. Unzip into its own folder /wp-content/plugins/askapache-crazy-cache/askapache-crazy-cache.php 3. Activate the plugin through the 'Plugins' menu in WordPress by clicking "AskApache Crazy Cache" 4. Go to your Options Panel and open the "AA Crazy Cache" submenu. /wp-admin/options-general.php?page=askapache-crazy-cache.php */ /* /--------------------------------------------------------------------\ | | | License: GPL | | | | AskApache Crazy Cache Plugin - Caches Entire Site if using WP-Cache| | Copyright (C) 2008, AskApache, www.askapache.com | | All rights reserved. | | | | This program is free software; you can redistribute it and/or | | modify it under the terms of the GNU General Public License | | as published by the Free Software Foundation; either version 2 | | of the License, or (at your option) any later version. | | | | This program is distributed in the hope that it will be useful, | | but WITHOUT ANY WARRANTY; without even the implied warranty of | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | GNU General Public License for more details. | | | | 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 Street, Fifth Floor | | Boston, MA 02110-1301, USA | | | \--------------------------------------------------------------------/ */ // aa_cache_all_options_setup //--------------------------- function aa_cache_all_options_setup() { global $aa_CA; add_options_page($aa_CA['Name'], 'AA Crazy Cache', 8, basename(__FILE__), 'aa_cache_all_page'); }//===================================================================================== //aa_cache_admin_header function aa_cache_admin_header(){ global $wpdb,$cache_path, $file_prefix, $cache_max_time, $aa_CA, $aa_crazy_wpcache_enabled, $aa_cc_valid_nonce; $aa_CA=get_option('askapache_crazy_cache'); if (get_option('active_plugins'))$current_plugins = get_option('active_plugins'); $plugins = get_plugins(); foreach($plugins as $plugin_file => $plugin_data) { if (!empty($current_plugins) && in_array($plugin_file, $current_plugins) && (false!==($t=strpos($plugin_file, 'wp-cache'))))$aa_crazy_wpcache_enabled=true; } if($aa_crazy_wpcache_enabled){ $wp_cache_config_file = ABSPATH . 'wp-content/wp-cache-config.php'; $wp_cache_config_file_sample = ABSPATH . 'wp-content/plugins/wp-cache/wp-cache-config-sample.php'; $wp_cache_link = ABSPATH . 'wp-content/advanced-cache.php'; $wp_cache_file = ABSPATH . 'wp-content/plugins/wp-cache/wp-cache-phase1.php'; if( !@include($wp_cache_config_file) ) @include($wp_cache_config_file_sample); @require(ABSPATH . 'wp-content/plugins/wp-cache/wp-cache-base.php'); } }//===================================================================================== // aa_cache_all_page //--------------------------- function aa_cache_all_page() { global $wpdb,$cache_path, $file_prefix, $cache_max_time, $aa_CA, $aa_crazy_wpcache_enabled, $aa_cc_valid_nonce; if (! user_can_access_admin_page()) wp_die( __('You do not have sufficient permissions to access this page.') ); if (function_exists('current_user_can')&&!current_user_can(8)||!current_user_can('upload_files'))wp_die(__("You are not allowed to be here")); echo '

'.$aa_CA['Title'].' '.$aa_CA['Version'] . ' by '.$aa_CA['Author'].'    |  Google 404 SEO Plugin - .htaccess examples - .htaccess help forum


'; echo '

'.$aa_CA['Name'].'


'; if(!function_exists('curl_init') || !function_exists('gzuncompress')) echo '

OOPS! Your server does not have curl and/or gzuncompress, sorry but you cannot use this plugin until I upgrade it. Sorry.

'; else { echo '
'; echo '
Cache Entire Site'; if(!$aa_crazy_wpcache_enabled)echo "

wp-cache is disabled! Please enable it to use this plugin.

"; else echo "

wp-cache is enabled

"; echo '

Please note that caching your entire site takes around 3.5 seconds / 30 posts.

'; echo '

This AskApache Crazy Cache version only caches single posts for now...

'; echo '

Many more options will be available in the future, I love it and hopefully the WordPress masses will too.

'; echo '
'; if($aa_crazy_wpcache_enabled){ echo ''; echo ''; } echo '
'; wp_nonce_field('askapache-crazy-cache-update_modify'); echo "
\n"; echo '
'; if($_SERVER['REQUEST_METHOD']==='POST'){ $aa_cc_valid_nonce = wp_verify_nonce($_REQUEST['_wpnonce'], 'askapache-crazy-cache-update_modify'); if(!$aa_cc_valid_nonce)die(__('Cheatin’ uh?')); if(isset($_POST['aacacheall'])) if(!aa_background_crazy_cache())echo '

Error! Please make your / web directory writable! (755).

'; else aa_cache_list(); if(isset($_POST['aacachedelete'])) aa_cache_delete(); if(isset($_POST['aacachelist'])) aa_cache_list(); } echo '
'; } }//===================================================================================== function aa_cache_delete(){ global $wpdb,$cache_path, $file_prefix, $cache_max_time, $aa_CA, $aa_crazy_wpcache_enabled, $aa_cc_valid_nonce; if(!$aa_cc_valid_nonce)die(__('Cheatin’ uh?')); if(!function_exists('glob'))echo '

Couldnt delete, use wp-cache panel

'; else $files=glob("$cache_path$file_prefix*"); $f=sizeof($files); if(wp_cache_phase2_clean_cache($file_prefix))echo "

Deleted: $f files from: $cache_path

"; else if(wp_cache_phase2_clean_cache($file_prefix))echo "

Deleted: $f files from: $cache_path

"; } function aa_cache_list($list_files=true){ global $wpdb,$cache_path, $file_prefix, $cache_max_time, $aa_CA, $aa_crazy_wpcache_enabled, $aa_cc_valid_nonce; if(!$aa_cc_valid_nonce)die(__('Cheatin’ uh?')); $list_mess = "Update list"; $list_files=true; $count = 0; $expired = 0; $now = time(); ob_start(); if ( ($handle = opendir( $cache_path )) ) { if ($list_files) echo ""; while ( false !== ($file = readdir($handle))) { if ( preg_match("/^$file_prefix.*\.meta/", $file) ) { $this_expired = false; $content_file = preg_replace("/meta$/", "html", $file); $mtime = filemtime($cache_path.$file); if ( ! ($fsize = @filesize($cache_path.$content_file)) ) continue; // .meta does not exists $fsize = intval($fsize/1024); $age = $now - $mtime; if ( $age > $cache_max_time) { $expired++; $this_expired = true; } $count++; if ($list_files) { $meta = new CacheMeta; $meta = unserialize(file_get_contents($cache_path . $file)); echo $flip ? '' : ''; $flip = !$flip; echo '"; if ($this_expired) echo ""; else echo ""; echo ""; wp_nonce_field('wp-cache'); echo "\n"; } } } closedir($handle); if ($list_files) echo "
'; echo $meta->uri . "$age secs$age secs$fsize KB
"; } $cacheft=ob_get_clean(); echo "

$count cached pages

"; echo "

$expired expired pages

"; echo $cacheft; } function aa_background_crazy_cache(){ global $wpdb,$cache_path, $file_prefix, $cache_max_time, $aa_CA, $aa_crazy_wpcache_enabled, $aa_cc_valid_nonce; if(!$aa_cc_valid_nonce)die(__('Cheatin’ uh?')); // encoded this backend file to make it easy for people, // didn't want people to have to install a 2nd file! // gosh no that is asking too much! :) $e= 'eNrNVm1T20gS/hyq+A+DVxVJQZZM7lJh8YrgOM6GWt7KNltXxbGqsTS2ppBG2tEIm2T579s9IzkGkiz37SgKNNPdT793zy/vyrTc'. '3uJzZydhcy5Y4tiD95OLwfST7bpftrdeHEn2Z80liwoRMyfhUtCcOVH08fhkFEWubwfLshsXYs4XPmDZbh+EEO9oDfjhfXQ5GY0B'. 'kIs4q5MGq9Hj2wDQECoES2ZroPvtre0ta1lGMY1TFhk10ZxnjISkkSc+sY0JigmlrUHmTZv63wGJKpqXP8Aqs3rBRbXGfAzeNfJP'. 'dWRc3HwXlSa3FPxPDNRT4R+6932TypRWbK+FgwyQnaMmrM43vXeJS37M0cQHM9GWgfO/mjUDq9b5BDcpjeI4uqUZTyKBdRCC5lsm'. '+fzOnB0r+nU0vbKjZanP9rVHbFrd0NJEXtLPd2vs+IaJREPzOQGPn8ITN+HMsSeFlHdkVtSKxCn1yKC6GWhAUtG7itwVNaGSEVEo'. 'QrOsWLKEqILMGEmZZL7WAMzxTUSTnItIsjncS+cZhm1vBQFEb8ErxWRUpbVKiqWI5rWIFS8EQIDJKNvEP2EZUwxEj/hCFNB4dQVy'. 'dFZI5ShZQzaOKqYixXOss5wrp2fUbG8BEmpeyKIWCcBlWeUYWquNoDKtZgEYtUQG7PJFVsxoRqAKkplnGY6SqtQjli6EEhzmKzgZ'. 'Uk5X2gC4AMDhwPx/GPh2Djyl6IxEkWMPU0YVFy9/2n+997ZP6vQdzIi+VYbWIjSaEjQxpFLSO/DEisExFVpsVUIpJmGvb4liCb2C'. 'tjjN5IEycKyUikR3UVFCHrh0yIZTxMXS/0KA/cUyxW5zyJxmFSM7YQjCTQNKRhMUbcBckMJQvTA6ICILiIOKU6cT/LEZJf/Vf/2c'. 'KRp0muhpbVryhaVSXkW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Z5OPaPkzxWAwvj+fjDQ/eY7A'. 'ZAoOYSrm5fM0nA7+0/g08cjek0CYooIXTtS8lWA5pF6D0mqoq4yx0tnr9Vq3zMJNCng+PSCSYoYbS2KJWjLcUMFWLDbYFBrvFhYh'. 'vIJCYNfLN2NUgMi9iYF+jTmWJPAOQz9OYbqdnESnlyfT4+hiNP54Pj4lf/1F1lBk/SADoZ1W6Pw3l+BM7gzBDKLN0K85wqQsJLFk'. '52s0/qGVCPn6TNFOAYQo2mjjk5DFaUFaEq7KhuR3uh3/GyK41kjz8yAXkuXFLWvS8TAbBl8/KZyNFBmI+/ZjA6thzdN2YDQX6+Ix'. 'uXttTvfmaQK/7w7/BgSsA7w='; $home_path = get_home_path(); $backend = $home_path.'askapache-crazy-cache-backend.php'; aa_rw_unlink($backend); if(!file_exists($backend))if(!aa_rw_file_put_c($backend, $e))return false; $cookie=AUTH_COOKIE.'='.urlencode($_COOKIE[AUTH_COOKIE]); $path=wp_nonce_url("askapache-crazy-cache-backend.php?V=".$aa_CA['Version'], 'askapache-crazy-cache-backend'); $path=str_replace('&','&',$path); $ref='http://www.askapache.com'; $useragent='Mozilla/5.0 (compatible; AskApache/'.$aa_CA['Version'].'; +http://www.askapache.com/wordpress/crazy-cache-wordpress-plugin.html)'; $host=$_SERVER['HTTP_HOST']; $port=$_SERVER['SERVER_PORT']; $ip=(isset($_SERVER["SERVER_ADDR"])) ? $_SERVER["SERVER_ADDR"] : gethostbyname($_SERVER['HTTP_HOST']); $scheme=((isset($_SERVER['HTTPS'] ) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT']=='443' ) ? 'ssl://' : ''; if($fp = fsockopen($scheme.$ip, $port, $errno, $errstr, 5)) { if(!fputs($fp, "GET /$path HTTP/1.1\r\nHost: $host\r\nUser-Agent: $useragent\r\nReferer: $ref\r\nAccept: */*\r\nCookie: $cookie\r\nConnection: Close\r\n\r\n")) return false; else list(,$response) = explode(" ", fgets($fp, 128)); if(fclose($fp))$g='great'; } return true; } // aa_rw_unlink function aa_rw_unlink($f) { if (is_dir($f) && !is_link($f)) aa_pp_rm_dir($f); @ unlink($f); if(!file_exists($f))return true; @ chmod($f,0777); @ chmod(dirname($f),0777); @ unlink($f); if(!file_exists($f))return true; else { trigger_error("Couldnt delete $f", E_USER_ERROR); return false; } } // aa_rw_file_put_c function aa_rw_file_put_c($filename,$e){ $content=gzuncompress(base64_decode($e)); $old=umask(0); if (function_exists("file_put_contents")) @file_put_contents($filename, $content); else { $fh = @ fopen($filename, 'w+'); if (!$fh) { @ touch($filename); @ chmod($filename, 0666); @ fwrite($fh, $content); @ fclose($fh); } } umask($old); if (!file_exists($filename)) return false; return true; } // aa_cache_all_deactivate //--------------------------- function aa_cache_all_deactivate(){ $home_path = get_home_path(); $backend = $home_path.'askapache-crazy-cache-backend.php'; aa_rw_unlink($backend); delete_option('askapache_crazy_cache'); }//===================================================================================== // aa_cache_all_activate //--------------------------- function aa_cache_all_activate(){ global $aa_CA; $home_path = get_home_path(); $backend = $home_path.'askapache-crazy-cache-backend.php'; aa_rw_unlink($backend); $aa_CA=get_plugin_data(__FILE__); update_option('askapache_crazy_cache',$aa_CA); }//===================================================================================== if(false!==($a=strpos($_SERVER['REQUEST_URI'], basename(__FILE__))))add_action('admin_head', 'aa_cache_admin_header'); add_action('admin_menu', 'aa_cache_all_options_setup'); register_deactivation_hook(__FILE__, 'aa_cache_all_deactivate'); register_activation_hook(__FILE__, 'aa_cache_all_activate'); ?>