function wp_supercache_searchengine_admin()
{
    global $cache_no_adverts_for_friends, $wp_cache_config_file, $valid_nonce;
    $cache_no_adverts_for_friends = $cache_no_adverts_for_friends == '' ? 'no' : $cache_no_adverts_for_friends;
    if (isset($_POST['cache_no_adverts_for_friends']) && $valid_nonce) {
        $cache_no_adverts_for_friends = $_POST['cache_no_adverts_for_friends'] == __('Disable', 'wp-super-cache') ? 'no' : 'yes';
        wp_cache_replace_line('^ *\\$cache_no_adverts_for_friends', "\$cache_no_adverts_for_friends = '{$cache_no_adverts_for_friends}';", $wp_cache_config_file);
    }
    $id = 'no_adverts_for_friends-section';
    ?>
		<fieldset id="<?php 
    echo $id;
    ?>
" class="options"> 
		<h4><?php 
    _e('No Adverts for Friends', 'wp-super-cache');
    ?>
</h4>
		<form name="wp_manager" action="<?php 
    echo $_SERVER["REQUEST_URI"];
    ?>
" method="post">
		<label><input type="radio" name="cache_no_adverts_for_friends" value="1" <?php 
    if ($cache_no_adverts_for_friends == 'yes') {
        echo 'checked="checked" ';
    }
    ?>
/> <?php 
    _e('Enabled', 'wp-super-cache');
    ?>
</label>
		<label><input type="radio" name="cache_no_adverts_for_friends" value="0" <?php 
    if ($cache_no_adverts_for_friends == 'no') {
        echo 'checked="checked" ';
    }
    ?>
/> <?php 
    _e('Disabled', 'wp-super-cache');
    ?>
</label>
		<p><?php 
    _e('', 'wp-super-cache');
    ?>
</p><?php 
    echo '<p>' . __('Provides support for <a href="http://ocaoimh.ie/no-adverts-for-friends/">No Adverts for Friends</a>.', 'wp-super-cache') . '</p>';
    if (isset($changed) && $changed) {
        if ('yes' == $cache_no_adverts_for_friends) {
            $status = __("enabled");
        } else {
            $status = __("disabled");
        }
        echo "<p><strong>" . sprintf(__("No Adverts for Friends support is now %s", 'wp-super-cache'), $status) . "</strong></p>";
    }
    echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="' . __('Update', 'wp-super-cache') . '" /></div>';
    wp_nonce_field('wp-cache');
    ?>
	</form>
	</fieldset>
<?php 
}
function wp_supercache_awaitingmoderation_admin()
{
    global $cache_awaitingmoderation, $wp_cache_config_file, $valid_nonce;
    $cache_awaitingmoderation = $cache_awaitingmoderation == '' ? '0' : $cache_awaitingmoderation;
    if (isset($_POST['cache_awaitingmoderation']) && $valid_nonce) {
        $cache_awaitingmoderation = (int) $_POST['cache_awaitingmoderation'];
        wp_cache_replace_line('^ *\\$cache_awaitingmoderation', "\$cache_awaitingmoderation = '{$cache_awaitingmoderation}';", $wp_cache_config_file);
        $changed = true;
    } else {
        $changed = false;
    }
    $id = 'awaitingmoderation-section';
    ?>
		<fieldset id="<?php 
    echo $id;
    ?>
" class="options"> 
		<h4><?php 
    _e('Awaiting Moderation', 'wp-super-cache');
    ?>
</h4>
		<form name="wp_manager" action="" method="post">
		<label><input type="radio" name="cache_awaitingmoderation" value="1" <?php 
    if ($cache_awaitingmoderation) {
        echo 'checked="checked" ';
    }
    ?>
/> <?php 
    _e('Enabled', 'wp-super-cache');
    ?>
</label>
		<label><input type="radio" name="cache_awaitingmoderation" value="0" <?php 
    if (!$cache_awaitingmoderation) {
        echo 'checked="checked" ';
    }
    ?>
/> <?php 
    _e('Disabled', 'wp-super-cache');
    ?>
</label>
		<p><?php 
    _e('Enables or disables plugin to Remove the text "Your comment is awaiting moderation." when someone leaves a moderated comment.', 'wp-super-cache');
    ?>
</p>
		<?php 
    if ($changed) {
        if ($cache_awaitingmoderation) {
            $status = __("enabled");
        } else {
            $status = __("disabled");
        }
        echo "<p><strong>" . sprintf(__("Awaiting Moderation is now %s", 'wp-super-cache'), $status) . "</strong></p>";
    }
    echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="' . __('Update', 'wp-super-cache') . '" /></div>';
    wp_nonce_field('wp-cache');
    ?>
	</form>
	</fieldset>
	<?php 
}
 function checkWPSuperCache()
 {
     if (!function_exists('wp_cache_replace_line')) {
         return;
     }
     global $wp_cache_config_file, $wp_cache_mobile_enabled;
     $wp_cache_mobile_enabled = 1;
     wp_cache_replace_line('^ *\\$wp_cache_mobile_enabled', "\$wp_cache_mobile_enabled = 1;", $wp_cache_config_file);
 }
 function wp_supercache_ktaistyle_admin()
 {
     global $valid_nonce, $wp_cache_config_file, $cache_ktaistyle, $wp_cache_mobile_browsers, $orig_wp_cache_mobile_browsers;
     if (!isset($cache_ktaistyle)) {
         $cache_ktaistyle = 0;
     }
     $ktaistyle_browsers = 'DoCoMo/, J-PHONE/, J-EMULATOR/, Vodafone/, MOT-, MOTEMULATOR-, SoftBank/, emulator/, DDIPOCKET;, WILLCOM;, KDDI-, UP.Browser/, emobile/, Huawei/, IAC/, Nokia, Opera Mini, Opera Mobi, Palm OS, Windows CE;, PDA; SL-, PlayStation Portable, SONY/COM, Nitro, Nintendo, mixi-mobile-converter/';
     if (function_exists('ks_option') && ks_option('ks_theme_touch')) {
         $ktaistyle_browsers .= ', iPhone;, iPod;, Android';
     }
     if (isset($_POST['cache_ktaistyle']) && $valid_nonce) {
         if (!class_exists('KtaiStyle') && !class_exists('Ktai_Style')) {
             $_POST['cache_ktaistyle'] = __('Disable', 'wp-super-cache');
             $err = __('Ktai Style not found. Please check your install.', 'wp-super-cache');
         }
         $cache_ktaistyle = $_POST['cache_ktaistyle'] == __('Disable', 'wp-super-cache') ? 0 : 1;
         wp_cache_replace_line('^ *\\$cache_ktaistyle', "\$cache_ktaistyle = '{$cache_ktaistyle}';", $wp_cache_config_file);
         if ($cache_ktaistyle) {
             if (!isset($orig_wp_cache_mobile_browsers)) {
                 wp_cache_replace_line('^ *\\$orig_wp_cache_mobile_browsers', "\$orig_wp_cache_mobile_browsers = '{$wp_cache_mobile_browsers}';", $wp_cache_config_file);
             }
             wp_cache_replace_line('^ *\\$wp_cache_mobile_browsers ', "\$wp_cache_mobile_browsers = '{$ktaistyle_browsers}';", $wp_cache_config_file);
         } elseif (isset($orig_wp_cache_mobile_browsers) && $orig_wp_cache_mobile_browsers != $ktaistyle_browsers) {
             wp_cache_replace_line('^ *\\$wp_cache_mobile_browsers ', "\$wp_cache_mobile_browsers = '{$orig_wp_cache_mobile_browsers}';", $wp_cache_config_file);
             wp_cache_replace_line('^ *\\$orig_wp_cache_mobile_browsers', '', $wp_cache_config_file);
         }
     }
     echo '<form name="wp_supercache_ktaistyle_admin" action="' . $_SERVER["REQUEST_URI"] . '" method="post">';
     wp_nonce_field('wp-cache');
     if ($cache_ktaistyle == 0) {
         $ks_status = __('disabled', 'wp-super-cache');
     } else {
         $ks_status = __('enabled', 'wp-super-cache');
         wp_super_cache_disable();
     }
     echo '<strong>' . sprintf(__('Ktai Style support is %s', 'wp-super-cache'), $ks_status);
     echo '.</strong>';
     printf(__('(Changing supporting mobile devices. Requires <a href="http://wppluginsj.sourceforge.jp/ktai_style/">Ktai Style</a>.) ', 'wp-super-cache'));
     if ($cache_ktaistyle == 0) {
         echo '<input type="submit" name="cache_ktaistyle" value="' . __('Enable', 'wp-super-cache') . '" />';
     } else {
         echo '<input type="submit" name="cache_ktaistyle" value="' . __('Disable', 'wp-super-cache') . '" />';
     }
     echo "</form>\n";
     if ($err) {
         echo "<p><strong>" . __('Warning!', 'wp-super-cache') . "</strong> {$err}</p>";
     }
 }
function wp_supercache_badbehaviour_admin()
{
    global $cache_badbehaviour, $wp_cache_config_file, $valid_nonce;
    $cache_badbehaviour = $cache_badbehaviour == '' ? 'no' : $cache_badbehaviour;
    $err = false;
    if (isset($_POST['cache_badbehaviour']) && $valid_nonce) {
        $bbfile = get_bb_file_loc();
        if (!$bbfile) {
            $_POST['cache_badbehaviour'] = 'Disable';
            $err = __('Bad Behaviour not found. Please check your install.', 'wp-super-cache');
        }
        $cache_badbehaviour = $_POST['cache_badbehaviour'] == __('Disable', 'wp-super-cache') ? 0 : 1;
        wp_cache_replace_line('^ *\\$cache_compression', "\$cache_compression = 0;", $wp_cache_config_file);
        wp_cache_replace_line('^ *\\$cache_badbehaviour', "\$cache_badbehaviour = {$cache_badbehaviour};", $wp_cache_config_file);
        wp_cache_replace_line('^ *\\$cache_badbehaviour_file', "\$cache_badbehaviour_file = '{$bbfile}';", $wp_cache_config_file);
    }
    echo '<form name="wp_supercache_badbehaviour_admin" action="' . $_SERVER["REQUEST_URI"] . '" method="post">';
    wp_nonce_field('wp-cache');
    if ($cache_badbehaviour == 0) {
        $bb_status = __('disabled', 'wp-super-cache');
    } else {
        $bb_status = __('enabled', 'wp-super-cache');
        wp_super_cache_disable();
    }
    echo '<strong>' . sprintf(__('Bad Behaviour support is %s', 'wp-super-cache'), $bb_status);
    echo '.</strong>';
    printf(__('(Only half-on caching supported, disabled compression and requires <a href="http://www.bad-behavior.ioerror.us/">Bad Behavior</a> in "%s/plugins/bad-behavior/") ', 'wp-super-cache'), WP_CONTENT_DIR);
    if ($cache_badbehaviour == 0) {
        echo '<input type="submit" name="cache_badbehaviour" value="' . __('Enable', 'wp-super-cache') . '" />';
    } else {
        echo '<input type="submit" name="cache_badbehaviour" value="' . __('Disable', 'wp-super-cache') . '" />';
    }
    echo "</form>\n";
    if ($err) {
        echo "<p><strong>" . __('Warning!', 'wp-super-cache') . "</strong> {$err}</p>";
    }
}
function wp_supercache_domain_mapping_admin()
{
    global $cache_domain_mapping, $wp_cache_config_file, $valid_nonce;
    $cache_domain_mapping = $cache_domain_mapping == '' ? '0' : $cache_domain_mapping;
    if (isset($_POST['cache_domain_mapping']) && $valid_nonce) {
        $cache_domain_mapping = $_POST['cache_domain_mapping'] == __('Disable', 'wp-super-cache') ? '0' : '1';
        wp_cache_replace_line('^ *\\$cache_domain_mapping', "\$cache_domain_mapping = '{$cache_domain_mapping}';", $wp_cache_config_file);
    }
    echo '<li><form name="wp_supercache_searchengine_admin" action="' . $_SERVER["REQUEST_URI"] . '" method="post">';
    wp_nonce_field('wp-cache');
    if ($cache_domain_mapping == '0') {
        $status = __('disabled', 'wp-super-cache');
    } else {
        $status = __('enabled', 'wp-super-cache');
    }
    echo '<strong>' . sprintf(__('<a href="http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/">Domain Mapping</a> support plugin is %s', 'wp-super-cache'), $status);
    echo '.</strong> ' . __('(support for multiple domains on multisite websites) ', 'wp-super-cache');
    if ($cache_domain_mapping == '0') {
        echo '<input type="submit" name="cache_domain_mapping" value="' . __('Enable', 'wp-super-cache') . '" />';
    } else {
        echo '<input type="submit" name="cache_domain_mapping" value="' . __('Disable', 'wp-super-cache') . '" />';
    }
    echo "</form></li>\n";
}
function wp_supercache_awaitingmoderation_admin()
{
    global $cache_awaitingmoderation, $wp_cache_config_file, $valid_nonce;
    $cache_awaitingmoderation = $cache_awaitingmoderation == '' ? '0' : $cache_awaitingmoderation;
    if (isset($_POST['cache_awaitingmoderation']) && $valid_nonce) {
        $cache_awaitingmoderation = $_POST['cache_awaitingmoderation'] == __('Disable', 'wp-super-cache') ? '0' : '1';
        wp_cache_replace_line('^ *\\$cache_awaitingmoderation', "\$cache_awaitingmoderation = '{$cache_awaitingmoderation}';", $wp_cache_config_file);
    }
    echo '<li><form name="wp_supercache_searchengine_admin" action="' . $_SERVER["REQUEST_URI"] . '" method="post">';
    wp_nonce_field('wp-cache');
    if ($cache_awaitingmoderation == '0') {
        $status = __('disabled', 'wp-super-cache');
    } else {
        $status = __('enabled', 'wp-super-cache');
    }
    echo '<strong>' . sprintf(__('Awaiting Moderation plugin is %s', 'wp-super-cache'), $status);
    echo '.</strong> ' . __('(Remove the text "Your comment is awaiting moderation." when someone leaves a moderated comment.) ', 'wp-super-cache');
    if ($cache_awaitingmoderation == '0') {
        echo '<input type="submit" name="cache_awaitingmoderation" value="' . __('Enable', 'wp-super-cache') . '" />';
    } else {
        echo '<input type="submit" name="cache_awaitingmoderation" value="' . __('Disable', 'wp-super-cache') . '" />';
    }
    echo "</form></li>\n";
}
Exemple #8
0
function wp_supercache_searchengine_admin()
{
    global $cache_no_adverts_for_friends, $wp_cache_config_file, $valid_nonce;
    $cache_no_adverts_for_friends = $cache_no_adverts_for_friends == '' ? 'no' : $cache_no_adverts_for_friends;
    if (isset($_POST['cache_no_adverts_for_friends']) && $valid_nonce) {
        $cache_no_adverts_for_friends = $_POST['cache_no_adverts_for_friends'] == 'Disable' ? 'no' : 'yes';
        wp_cache_replace_line('^ *\\$cache_no_adverts_for_friends', "\$cache_no_adverts_for_friends = '{$cache_no_adverts_for_friends}';", $wp_cache_config_file);
    }
    echo '<form name="wp_supercache_searchengine_admin" action="' . $_SERVER["REQUEST_URI"] . '" method="post">';
    wp_nonce_field('wp-cache');
    echo '<strong><a href="http://ocaoimh.ie/no-adverts-for-friends/">No Adverts for Friends</a> plugin is ';
    if ($cache_no_adverts_for_friends == 'no') {
        echo 'disabled';
    } else {
        echo 'enabled';
    }
    echo '.</strong> (requires <a href="http://ocaoimh.ie/no-adverts-for-friends/">friendsadverts.php</a> too) ';
    if ($cache_no_adverts_for_friends == 'no') {
        echo '<input type="submit" name="cache_no_adverts_for_friends" value="Enable" />';
    } else {
        echo '<input type="submit" name="cache_no_adverts_for_friends" value="Disable" />';
    }
    echo "</form>\n";
}
Exemple #9
0
function scossdl_off_options()
{
    global $ossdlcdn, $wp_cache_config_file;
    $valid_nonce = isset($_REQUEST['_wpnonce']) ? wp_verify_nonce($_REQUEST['_wpnonce'], 'wp-cache') : false;
    if ($valid_nonce && isset($_POST['action']) && $_POST['action'] == 'update_ossdl_off') {
        update_option('ossdl_off_cdn_url', $_POST['ossdl_off_cdn_url']);
        update_option('ossdl_off_include_dirs', $_POST['ossdl_off_include_dirs'] == '' ? 'wp-content,wp-includes' : $_POST['ossdl_off_include_dirs']);
        update_option('ossdl_off_exclude', $_POST['ossdl_off_exclude']);
        update_option('ossdl_cname', $_POST['ossdl_cname']);
        update_option('ossdl_https', (int) $_POST['ossdl_https']);
        if (isset($_POST['ossdlcdn'])) {
            $ossdlcdn = 1;
        } else {
            $ossdlcdn = 0;
        }
        wp_cache_replace_line('^ *\\$ossdlcdn', "\$ossdlcdn = {$ossdlcdn};", $wp_cache_config_file);
    }
    $example_cdn_uri = str_replace('http://', 'http://cdn.', str_replace('www.', '', get_option('siteurl')));
    $example_cnames = str_replace('http://cdn.', 'http://cdn1.', $example_cdn_uri);
    $example_cnames .= ',' . str_replace('http://cdn.', 'http://cdn2.', $example_cdn_uri);
    $example_cnames .= ',' . str_replace('http://cdn.', 'http://cdn3.', $example_cdn_uri);
    $example_cdn_uri = get_option('ossdl_off_cdn_url') == get_option('siteurl') ? $example_cdn_uri : get_option('ossdl_off_cdn_url');
    $example_cdn_uri .= '/wp-includes/js/prototype.js';
    ?>
		<p><?php 
    _e('Your website probably uses lots of static files. Image, Javascript and CSS files are usually static files that could just as easily be served from another site or CDN. Therefore this plugin replaces any links in the <code>wp-content</code> and <code>wp-includes</code> directories (except for PHP files) on your site with the URL you provide below. That way you can either copy all the static content to a dedicated host or mirror the files to a CDN by <a href="http://knowledgelayer.softlayer.com/questions/365/How+does+Origin+Pull+work%3F" target="_blank">origin pull</a>.', 'wp-super-cache');
    ?>
</p>
		<p><?php 
    printf(__('The <a href="%1$s">CDN Sync Tool</a> plugin will help upload files to Amazon S3/Cloudfront if you would rather not depend on origin pull. See the <a href="%2$s">plugin support forum</a> if you have any queries about this plugin.', 'wp-super-cache'), 'http://wordpress.org/extend/plugins/cdn-sync-tool/', 'http://wordpress.org/tags/cdn-sync-tool?forum_id=10');
    ?>
</p>
		<p><?php 
    printf(__('<strong style="color: red">WARNING:</strong> Test some static urls e.g., %s  to ensure your CDN service is fully working before saving changes.', 'wp-super-cache'), '<code>' . $example_cdn_uri . '</code>');
    ?>
</p>
		<p><?php 
    _e('You can define different CDN URLs for each site on a multsite network.', 'wp-super-cache');
    ?>
</p>
		<p><form method="post" action="">
		<?php 
    wp_nonce_field('wp-cache');
    ?>
		<table class="form-table"><tbod>
			<tr valign="top">
				<td style='text-align: right'>
					<input id='ossdlcdn' type="checkbox" name="ossdlcdn" value="1" <?php 
    if ($ossdlcdn) {
        echo "checked=1";
    }
    ?>
 />
				</td>
				<th scope="row"><label for="ossdlcdn"><?php 
    _e('Enable CDN Support', 'wp-super-cache');
    ?>
</label></th>
			</tr>
			<tr valign="top">
				<th scope="row"><label for="ossdl_off_cdn_url"><?php 
    _e('Off-site URL', 'wp-super-cache');
    ?>
</label></th>
				<td>
					<input type="text" name="ossdl_off_cdn_url" value="<?php 
    echo get_option('ossdl_off_cdn_url');
    ?>
" size="64" class="regular-text code" /><br />
					<span class="description"><?php 
    printf(__('The new URL to be used in place of %1$s for rewriting. No trailing <code>/</code> please.<br />Example: <code>%2$s</code>.', 'wp-super-cache'), get_option('siteurl'), $example_cdn_uri);
    ?>
</span>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row"><label for="ossdl_off_include_dirs"><?php 
    _e('Include directories', 'wp-super-cache');
    ?>
</label></th>
				<td>
					<input type="text" name="ossdl_off_include_dirs" value="<?php 
    echo esc_attr(get_option('ossdl_off_include_dirs'));
    ?>
" size="64" class="regular-text code" /><br />
					<span class="description"><?php 
    _e('Directories to include in static file matching. Use a comma as the delimiter. Default is <code>wp-content, wp-includes</code>, which will be enforced if this field is left empty.', 'wp-super-cache');
    ?>
</span>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row"><label for="ossdl_off_exclude"><?php 
    _e('Exclude if substring', 'wp-super-cache');
    ?>
</label></th>
				<td>
					<input type="text" name="ossdl_off_exclude" value="<?php 
    echo esc_attr(get_option('ossdl_off_exclude'));
    ?>
" size="64" class="regular-text code" /><br />
					<span class="description"><?php 
    _e('Excludes something from being rewritten if one of the above strings is found in the match. Use a comma as the delimiter like this, <code>.php, .flv, .do</code>, and always include <code>.php</code> (default).', 'wp-super-cache');
    ?>
</span>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row"><label for="ossdl_cname"><?php 
    _e('Additional CNAMES', 'wp-super-cache');
    ?>
</label></th>
				<td>
					<input type="text" name="ossdl_cname" value="<?php 
    echo esc_attr(get_option('ossdl_cname'));
    ?>
" size="64" class="regular-text code" /><br />
					<span class="description"><?php 
    printf(__('These <a href="http://en.wikipedia.org/wiki/CNAME_record">CNAMES</a> will be used in place of %1$s for rewriting (in addition to the off-site URL above). Use a comma as the delimiter. For pages with a large number of static files, this can improve browser performance. CNAMEs may also need to be configured on your CDN.<br />Example: %2$s', 'wp-super-cache'), get_option('siteurl'), $example_cnames);
    ?>
</span>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row" colspan='2'><label><input type='checkbox' name='ossdl_https' value='1' <?php 
    if (get_option('ossdl_https')) {
        echo 'checked';
    }
    ?>
 /> <?php 
    _e('Skip https URLs to avoid "mixed content" errors', 'wp-super-cache');
    ?>
</label></th>
			</tr>
		</tbody></table>
		<input type="hidden" name="action" value="update_ossdl_off" />
		<p class="submit"><input type="submit" class="button-primary" value="<?php 
    _e('Save Changes');
    ?>
" /></p>
		</form></p>
		<p><?php 
    _e('CDN functionality provided by <a href="http://wordpress.org/extend/plugins/ossdl-cdn-off-linker/">OSSDL CDN Off Linker</a> by <a href="http://mark.ossdl.de/">Mark Kubacki</a>', 'wp-super-cache');
    ?>
</p>
	<?php 
}
Exemple #10
0
function wp_cache_disable_plugin()
{
    global $wp_cache_config_file, $wp_rewrite;
    if (file_exists(ABSPATH . 'wp-config.php')) {
        $global_config_file = ABSPATH . 'wp-config.php';
    } else {
        $global_config_file = dirname(ABSPATH) . '/wp-config.php';
    }
    $line = 'define(\'WP_CACHE\', true);';
    if (strpos(file_get_contents($global_config_file), $line) && (!is_writeable_ACLSafe($global_config_file) || !wp_cache_replace_line('define *\\( *\'WP_CACHE\'', '//' . $line, $global_config_file))) {
        wp_die("Could not remove WP_CACHE define from {$global_config_file}. Please edit that file and remove the line containing the text 'WP_CACHE'. Then refresh this page.");
    }
    uninstall_supercache(WP_CONTENT_DIR . '/cache');
    $file_not_deleted = false;
    if (@file_exists(WP_CONTENT_DIR . "/advanced-cache.php")) {
        if (false == @unlink(WP_CONTENT_DIR . "/advanced-cache.php")) {
            $file_not_deleted[] = 'advanced-cache.php';
        }
    }
    if (@file_exists(WP_CONTENT_DIR . "/wp-cache-config.php")) {
        if (false == unlink(WP_CONTENT_DIR . "/wp-cache-config.php")) {
            $file_not_deleted[] = 'wp-cache-config.php';
        }
    }
    if ($file_not_deleted) {
        $msg = "<p>One or more files could not be deleted. These files and directories must be made writeable:</p>\n <ol><li>" . WP_CONTENT_DIR . "</li>\n";
        $code = "<ul>\n";
        foreach ((array) $file_not_deleted as $filename) {
            $msg .= "<li>" . WP_CONTENT_DIR . "/{$filename}</li>";
            $code .= "<li><code>chmod 666 " . WP_CONTENT_DIR . "/{$filename}</code></li>\n";
        }
        $code .= "</ul>\n";
        $msg .= "</ol>\n<p>First try fixing the directory permissions with this command and refresh this page:<br /><br /><code>chmod 777 " . WP_CONTENT_DIR . "</code><br /><br />If you still see this error, you have to fix the permissions on the files themselves and refresh this page again:</p> {$code}\n<p>Don't forgot to fix things later:<br /><code>chmod 755 " . WP_CONTENT_DIR . "</code></p><p>If you don't know what <strong>chmod</strong> is use <a href='http://www.google.ie/search?hl=en&q=ftp+chmod+777'>this Google search</a> to find out all about it.</p><p>Please refresh this page when the permissions have been modified.</p>";
        wp_die($msg);
    }
    extract(wpsc_get_htaccess_info());
    if ($scrules != '' && insert_with_markers($home_path . '.htaccess', 'WPSuperCache', array())) {
        $wp_rewrite->flush_rules();
    } elseif ($scrules != '') {
        wp_mail(get_option('admin_email'), __('Supercache Uninstall Problems', 'wp-super-cache'), sprintf(__("Dear User,\n\nWP Super Cache was removed from your blog but the mod_rewrite rules\nin your .htaccess were not.\n\nPlease edit the following file and remove the code\nbetween 'BEGIN WPSuperCache' and 'END WPSuperCache'. Please backup the file first!\n\n%s\n\nRegards,\nWP Super Cache Plugin\nhttp://wordpress.org/extend/plugins/wp-super-cache/", 'wp-super-cache'), ABSPATH . '/.htaccess'));
    }
}
function wp_cache_check_global_config()
{
    if (defined('WP_CACHE')) {
        return true;
    }
    if (file_exists(ABSPATH . 'wp-config.php')) {
        $global = ABSPATH . 'wp-config.php';
    } else {
        $global = dirname(ABSPATH) . '/wp-config.php';
    }
    $howtoenable = "Edit <code>{$global}</code> and add the following line: <code>define('WP_CACHE', true);</code>Otherwise, <strong>WP-Cache will not be executed</strong> by Wordpress core. ";
    $lines = file($global);
    foreach ($lines as $line) {
        if (preg_match('/^\\s*define\\s*\\(\\s*\'WP_CACHE\'\\s*,\\s*(?i:TRUE|1)\\s*\\)\\s*;/', $line)) {
            echo $howtoenable;
            return false;
        }
    }
    $line = 'define(\'WP_CACHE\', true);';
    if (!is_writeable_ACLSafe($global) || !wp_cache_replace_line('define *\\( *\'WP_CACHE\'', $line, $global)) {
        echo "<strong>Error: WP_CACHE is not enabled</strong> in your <code>wp-config.php</code> file and I couldn't modify it.";
        echo $howtoenable;
        return false;
    }
    return true;
}
Exemple #12
0
function wp_supercache_badbehaviour_admin()
{
    global $cache_badbehaviour, $wp_cache_config_file, $valid_nonce;
    $cache_badbehaviour = $cache_badbehaviour == '' ? 0 : $cache_badbehaviour;
    if ($cache_badbehaviour == 'no') {
        $cache_badbehaviour = 0;
    }
    $err = false;
    if (isset($_POST['cache_badbehaviour']) && $valid_nonce) {
        $bbfile = get_bb_file_loc();
        if (!$bbfile) {
            $_POST['cache_badbehaviour'] = 0;
            $err = __('Bad Behaviour not found. Please check your install.', 'wp-super-cache');
        }
        if ($cache_badbehaviour == (int) $_POST['cache_badbehaviour']) {
            $changed = false;
        } else {
            $changed = true;
        }
        $cache_badbehaviour = (int) $_POST['cache_badbehaviour'];
        wp_cache_replace_line('^ *\\$cache_compression', "\$cache_compression = 0;", $wp_cache_config_file);
        wp_cache_replace_line('^ *\\$cache_badbehaviour', "\$cache_badbehaviour = {$cache_badbehaviour};", $wp_cache_config_file);
        wp_cache_replace_line('^ *\\$cache_badbehaviour_file', "\$cache_badbehaviour_file = '{$bbfile}';", $wp_cache_config_file);
        $changed = true;
    }
    $id = 'badbehavior-section';
    ?>
		<fieldset id="<?php 
    echo $id;
    ?>
" class="options">
		<h4><?php 
    _e('Bad Behavior', 'wp-super-cache');
    ?>
</h4>
		<form name="wp_manager" action="" method="post">
		<label><input type="radio" name="cache_badbehaviour" value="1" <?php 
    if ($cache_badbehaviour) {
        echo 'checked="checked" ';
    }
    ?>
/> <?php 
    _e('Enabled', 'wp-super-cache');
    ?>
</label>
		<label><input type="radio" name="cache_badbehaviour" value="0" <?php 
    if (!$cache_badbehaviour) {
        echo 'checked="checked" ';
    }
    ?>
/> <?php 
    _e('Disabled', 'wp-super-cache');
    ?>
</label>
		<p><?php 
    _e('', 'wp-super-cache');
    ?>
</p><?php 
    echo '<p>' . sprintf(__('(Only legacy caching supported, disabled compression and requires <a href="http://www.bad-behavior.ioerror.us/">Bad Behavior</a> in "%s/plugins/bad-behavior/") ', 'wp-super-cache'), WP_CONTENT_DIR) . '</p>';
    if (isset($changed) && $changed) {
        if ($cache_badbehaviour) {
            $status = __("enabled");
        } else {
            $status = __("disabled");
        }
        echo "<p><strong>" . sprintf(__("Bad Behavior support is now %s", 'wp-super-cache'), $status) . "</strong></p>";
    }
    echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __('Update', 'wp-super-cache') . '" /></div>';
    wp_nonce_field('wp-cache');
    ?>
	</form>
	</fieldset>
	<?php 
    if ($err) {
        echo "<p><strong>" . __('Warning!', 'wp-super-cache') . "</strong> {$err}</p>";
    }
}
Exemple #13
0
function wp_super_cache_jetpack_admin()
{
    global $cache_jetpack, $wp_cache_config_file, $valid_nonce;
    $cache_jetpack = $cache_jetpack == '' ? '0' : $cache_jetpack;
    if (isset($_POST['cache_jetpack']) && $valid_nonce) {
        if ($cache_jetpack == (int) $_POST['cache_jetpack']) {
            $changed = false;
        } else {
            $changed = true;
        }
        $cache_jetpack = (int) $_POST['cache_jetpack'];
        wp_cache_replace_line('^ *\\$cache_jetpack', "\$cache_jetpack = '{$cache_jetpack}';", $wp_cache_config_file);
        if ($changed && $cache_jetpack) {
            wp_cache_replace_line('^ *\\$wp_cache_mobile_enabled', '$wp_cache_mobile_enabled = 1;', $wp_cache_config_file);
            wp_cache_replace_line('^ *\\$wp_cache_mod_rewrite', '$wp_cache_mod_rewrite = 0;', $wp_cache_config_file);
            wp_cache_replace_line('^ *\\$super_cache_enabled', '$super_cache_enabled = 1;', $wp_cache_config_file);
        }
    }
    $id = 'jetpack-section';
    ?>
	<fieldset id="<?php 
    echo $id;
    ?>
" class="options">
	<h4><?php 
    _e('Jetpack Mobile Theme', 'wp-super-cache');
    ?>
</h4>
	<?php 
    if (false == file_exists(dirname(WPCACHEHOME) . '/jetpack/class.jetpack-user-agent.php')) {
        echo "<strong>" . sprintf(__("Jetpack not found in %s. Install it and enable the mobile theme and this helper plugin to cache visits by mobile visitors."), dirname(WPCACHEHOME)) . "</strong>>";
    } else {
        ?>
		<form name="wp_manager" action="" method="post">
		<label><input type="radio" name="cache_jetpack" value="1" <?php 
        if ($cache_jetpack) {
            echo 'checked="checked" ';
        }
        ?>
/> <?php 
        _e('Enabled', 'wp-super-cache');
        ?>
</label>
		<label><input type="radio" name="cache_jetpack" value="0" <?php 
        if (!$cache_jetpack) {
            echo 'checked="checked" ';
        }
        ?>
/> <?php 
        _e('Disabled', 'wp-super-cache');
        ?>
</label>
		<?php 
        echo '<p>' . __('Provides support for the <a href="http://wordpress.org/extend/plugins/jetpack/">Jetpack</a> mobile theme and plugin. PHP caching mode and mobile support will be enabled too.', 'wp-super-cache') . '</p>';
        if (isset($changed) && $changed) {
            if ($cache_jetpack) {
                $status = __("enabled");
            } else {
                $status = __("disabled");
            }
            echo "<p><strong>" . sprintf(__("Jetpack Mobile Theme support is now %s", 'wp-super-cache'), $status) . "</strong></p>";
        }
        echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __('Update', 'wp-super-cache') . '" /></div>';
        wp_nonce_field('wp-cache');
        ?>
		</form>
	<?php 
    }
    ?>
	</fieldset>
	<?php 
}
Exemple #14
0
 static function WPCacheSaveRejectedUri()
 {
     global $cache_rejected_uri, $wp_cache_config_file;
     if (!isset($cache_rejected_uri) || empty($wp_cache_config_file) || !function_exists('wp_cache_replace_line')) {
         return false;
     }
     $text = var_export($cache_rejected_uri, true);
     $text = preg_replace('/[\\s]+/', ' ', $text);
     wp_cache_replace_line('^ *\\$cache_rejected_uri', "\$cache_rejected_uri = {$text};", $wp_cache_config_file);
     return true;
 }
function wp_supercache_domain_mapping_admin()
{
    global $cache_domain_mapping, $wp_cache_config_file, $valid_nonce;
    $cache_domain_mapping = $cache_domain_mapping == '' ? '0' : $cache_domain_mapping;
    if (isset($_POST['cache_domain_mapping']) && $valid_nonce) {
        if ($cache_domain_mapping == (int) $_POST['cache_domain_mapping']) {
            $changed = false;
        } else {
            $changed = true;
        }
        $cache_domain_mapping = (int) $_POST['cache_domain_mapping'];
        wp_cache_replace_line('^ *\\$cache_domain_mapping', "\$cache_domain_mapping = '{$cache_domain_mapping}';", $wp_cache_config_file);
    }
    $id = 'domain_mapping-section';
    ?>
		<fieldset id="<?php 
    echo $id;
    ?>
" class="options">
		<h4><?php 
    _e('Domain Mapping', 'wp-super-cache');
    ?>
</h4>
		<form name="wp_manager" action="" method="post">
		<label><input type="radio" name="cache_domain_mapping" value="1" <?php 
    if ($cache_domain_mapping) {
        echo 'checked="checked" ';
    }
    ?>
/> <?php 
    _e('Enabled', 'wp-super-cache');
    ?>
</label>
		<label><input type="radio" name="cache_domain_mapping" value="0" <?php 
    if (!$cache_domain_mapping) {
        echo 'checked="checked" ';
    }
    ?>
/> <?php 
    _e('Disabled', 'wp-super-cache');
    ?>
</label>
		<p><?php 
    _e('', 'wp-super-cache');
    ?>
</p><?php 
    echo '<p>' . __('Provides support for <a href="http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/">Domain Mapping</a> plugin to map multiple domains to a blog.', 'wp-super-cache') . '</p>';
    if (isset($changed) && $changed) {
        if ($cache_domain_mapping) {
            $status = __("enabled");
        } else {
            $status = __("disabled");
        }
        echo "<p><strong>" . sprintf(__("Domain Mapping support is now %s", 'wp-super-cache'), $status) . "</strong></p>";
    }
    echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __('Update', 'wp-super-cache') . '" /></div>';
    wp_nonce_field('wp-cache');
    ?>
	</form>
	</fieldset>
	<?php 
}
Exemple #16
0
function wp_cache_check_global_config()
{
    global $wp_cache_check_wp_config;
    if (!isset($wp_cache_check_wp_config)) {
        return true;
    }
    if (file_exists(ABSPATH . 'wp-config.php')) {
        $global = ABSPATH . 'wp-config.php';
    } else {
        $global = dirname(ABSPATH) . '/wp-config.php';
    }
    $line = 'define(\'WP_CACHE\', true);';
    if (!is_writeable_ACLSafe($global) || !wp_cache_replace_line('define *\\( *\'WP_CACHE\'', $line, $global)) {
        echo "<p>" . __("<strong>Error: WP_CACHE is not enabled</strong> in your <code>wp-config.php</code> file and I couldn&#8217;t modify it.", 'wp-super-cache') . "</p>";
        echo "<p>" . sprintf(__("Edit <code>%s</code> and add the following line:<br /> <code>define('WP_CACHE', true);</code><br />Otherwise, <strong>WP-Cache will not be executed</strong> by Wordpress core. ", 'wp-super-cache'), $global) . "</p>";
        return false;
    } else {
        echo "<div style='border: 1px solid #333; background: #ffffaa; padding: 2px;'>" . __('<h3>WP_CACHE constant added to wp-config.php</h3><p>If you continue to see this warning message please see point 5 of the <a href="http://wordpress.org/extend/plugins/wp-super-cache/faq/">FAQ</a>. The WP_CACHE line must be moved up.', 'wp-super-cache') . "</div>";
    }
    return true;
}
Exemple #17
0
function update_cached_mobile_ua_list($mobile_browsers, $mobile_prefixes = 0, $mobile_groups = 0)
{
    global $wp_cache_config_file, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes, $wp_cache_mobile_groups;
    if (is_array($mobile_browsers)) {
        $wp_cache_mobile_browsers = $mobile_browsers;
        wp_cache_replace_line('^ *\\$wp_cache_mobile_browsers', "\$wp_cache_mobile_browsers = '" . implode(', ', $mobile_browsers) . "';", $wp_cache_config_file);
    }
    if (is_array($mobile_prefixes)) {
        $wp_cache_mobile_prefixes = $mobile_prefixes;
        wp_cache_replace_line('^ *\\$wp_cache_mobile_prefixes', "\$wp_cache_mobile_prefixes = '" . implode(', ', $mobile_prefixes) . "';", $wp_cache_config_file);
    }
    if (is_array($mobile_groups)) {
        $wp_cache_mobile_groups = $mobile_groups;
        wp_cache_replace_line('^ *\\$wp_cache_mobile_groups', "\$wp_cache_mobile_groups = '" . implode(', ', $mobile_groups) . "';", $wp_cache_config_file);
    }
    return true;
}
Exemple #18
0
function wp_cache_check_global_config()
{
    if (file_exists(ABSPATH . 'wp-config.php')) {
        $global = ABSPATH . 'wp-config.php';
    } else {
        $global = dirname(ABSPATH) . '/wp-config.php';
    }
    $lines = file($global);
    foreach ($lines as $line) {
        if (preg_match('/^ *define *\\( *\'WP_CACHE\' *, *true *\\) *;/', $line)) {
            return true;
        }
    }
    $line = 'define(\'WP_CACHE\', true);';
    if (!is_writeable_ACLSafe($global) || !wp_cache_replace_line('define *\\( *\'WP_CACHE\'', $line, $global)) {
        echo "<b>Error: WP_CACHE is not enabled</b> in your <code>wp-config.php</code> file and I couldn't modified it.<br />";
        echo "Edit <code>{$global}</code> and add the following line: <br /><code>define('WP_CACHE', true);</code><br />Otherwise, <b>WP-Cache will not be executed</b> by Wordpress core. <br />";
        return false;
    }
    return true;
}
Exemple #19
0
function wp_super_cache_wptouch_browsers($browsers)
{
    global $cache_wptouch, $wptouch_exclude_ua, $wp_cache_config_file;
    if (false == function_exists('bnc_wptouch_get_exclude_user_agents') || false == function_exists('bnc_wptouch_get_user_agents')) {
        return $browsers;
    }
    $browsers = implode(',', bnc_wptouch_get_exclude_user_agents());
    // hack, support exclude agents too
    if ($browsers != $wptouch_exclude_ua) {
        wp_cache_replace_line('^ *\\$wptouch_exclude_ua', "\$wptouch_exclude_ua = '{$browsers}';", $wp_cache_config_file);
        $wptouch_exclude_ua = $browsers;
    }
    return bnc_wptouch_get_user_agents();
}