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