home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Plugins / wp-super-cache / plugins / searchengine.php
Encoding:
PHP Script  |  2008-02-19  |  2.7 KB  |  81 lines

  1. <?php
  2. function wp_supercache_searchengine( $string ) {
  3.     global $passingthrough, $nevershowads, $cache_no_adverts_for_friends;
  4.  
  5.     if( $cache_no_adverts_for_friends != 'yes' )
  6.         return $string;
  7.  
  8.     if( $_COOKIE[ '7a1254cba80da02d5478d91cfd0a873a' ] == 1 ) {
  9.         $string = 'searchengine';
  10.     } elseif( $_SERVER[ 'HTTP_REFERER' ] != '' ) {
  11.         if( is_array( $passingthrough ) == false )
  12.             return $string;
  13.  
  14.         foreach( $passingthrough as $url ) {
  15.             if( strpos( $_SERVER[ 'HTTP_REFERER' ], $url ) ) {
  16.                 reset( $nevershowads );
  17.                 $se = false;
  18.                 foreach( $nevershowads as $whitesite ) {
  19.                     if( false == strpos( $_SERVER[ 'HTTP_REFERER' ], $whitesite ) ) {
  20.                         $se = true;
  21.                     }
  22.                 }
  23.                 if( $se ) {
  24.                     $string = 'searchengine';
  25.                     @setcookie( '7a1254cba80da02d5478d91cfd0a873a', 1, time()+3600, '/' );
  26.                 }
  27.             }
  28.         }
  29.     }
  30.  
  31.     return $string;
  32. }
  33. add_cacheaction( 'wp_cache_get_cookies_values', 'wp_supercache_searchengine' );
  34.  
  35. function searchenginesupercache( $user_info ) {
  36.     if( $user_info == 'searchengine' && is_single() && is_old_post() ) {
  37.         return true;
  38.     } else {
  39.         return false;
  40.     }
  41.     return $user_info;
  42. }
  43.  
  44. function searchengine_phase2_actions() {
  45.     global $cache_no_adverts_for_friends;
  46.     if( $cache_no_adverts_for_friends == 'yes' ) {
  47.         add_filter( 'do_createsupercache', 'searchenginesupercache' );
  48.     }
  49. }
  50. add_cacheaction( 'add_cacheaction', 'searchengine_phase2_actions' );
  51.  
  52. function wp_supercache_searchengine_admin() {
  53.     global $cache_no_adverts_for_friends, $wp_cache_config_file, $valid_nonce;
  54.     
  55.     $cache_no_adverts_for_friends = $cache_no_adverts_for_friends == '' ? 'no' : $cache_no_adverts_for_friends;
  56.  
  57.     if(isset($_POST['cache_no_adverts_for_friends']) && $valid_nonce) {
  58.         $cache_no_adverts_for_friends = $_POST['cache_no_adverts_for_friends'] == 'Disable' ? 'no' : 'yes';
  59.         wp_cache_replace_line('^ *\$cache_no_adverts_for_friends', "\$cache_no_adverts_for_friends = '$cache_no_adverts_for_friends';", $wp_cache_config_file);
  60.     }
  61.     echo '<form name="wp_supercache_searchengine_admin" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
  62.     wp_nonce_field('wp-cache');
  63.     echo '<strong><a href="http://ocaoimh.ie/no-adverts-for-friends/">No Adverts for Friends</a> plugin is ';
  64.     if( $cache_no_adverts_for_friends == 'no' ) {
  65.         echo 'disabled';
  66.     } else {
  67.         echo 'enabled';
  68.     }
  69.     echo '.</strong> (requires <a href="http://ocaoimh.ie/no-adverts-for-friends/">friendsadverts.php</a> too)<div class="submit">';
  70.     if( $cache_no_adverts_for_friends == 'no' ) {
  71.         echo '<input type="submit" name="cache_no_adverts_for_friends" value="Enable »" />';
  72.     } else {
  73.         echo '<input type="submit" name="cache_no_adverts_for_friends" value="Disable »" />';
  74.     }
  75.     echo "</div></form>\n";
  76.  
  77. }
  78. add_cacheaction( 'cache_admin_page', 'wp_supercache_searchengine_admin' );
  79.  
  80. ?>
  81.