home *** CD-ROM | disk | FTP | other *** search
- <?php
- function wp_supercache_searchengine( $string ) {
- global $passingthrough, $nevershowads, $cache_no_adverts_for_friends;
-
- if( $cache_no_adverts_for_friends != 'yes' )
- return $string;
-
- if( $_COOKIE[ '7a1254cba80da02d5478d91cfd0a873a' ] == 1 ) {
- $string = 'searchengine';
- } elseif( $_SERVER[ 'HTTP_REFERER' ] != '' ) {
- if( is_array( $passingthrough ) == false )
- return $string;
-
- foreach( $passingthrough as $url ) {
- if( strpos( $_SERVER[ 'HTTP_REFERER' ], $url ) ) {
- reset( $nevershowads );
- $se = false;
- foreach( $nevershowads as $whitesite ) {
- if( false == strpos( $_SERVER[ 'HTTP_REFERER' ], $whitesite ) ) {
- $se = true;
- }
- }
- if( $se ) {
- $string = 'searchengine';
- @setcookie( '7a1254cba80da02d5478d91cfd0a873a', 1, time()+3600, '/' );
- }
- }
- }
- }
-
- return $string;
- }
- add_cacheaction( 'wp_cache_get_cookies_values', 'wp_supercache_searchengine' );
-
- function searchenginesupercache( $user_info ) {
- if( $user_info == 'searchengine' && is_single() && is_old_post() ) {
- return true;
- } else {
- return false;
- }
- return $user_info;
- }
-
- function searchengine_phase2_actions() {
- global $cache_no_adverts_for_friends;
- if( $cache_no_adverts_for_friends == 'yes' ) {
- add_filter( 'do_createsupercache', 'searchenginesupercache' );
- }
- }
- add_cacheaction( 'add_cacheaction', 'searchengine_phase2_actions' );
-
- 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)<div class="submit">';
- 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 "</div></form>\n";
-
- }
- add_cacheaction( 'cache_admin_page', 'wp_supercache_searchengine_admin' );
-
- ?>
-