Plugin Directory

Changeset 2114528


Ignore:
Timestamp:
06/29/2019 03:09:38 AM (7 years ago)
Author:
kaisercrazy
Message:

version 1.1

Location:
search-limiter-blocker/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • search-limiter-blocker/trunk/readme.md

    r2114526 r2114528  
    3333## Changelog
    3434
     35### 1.1
     36Search bots excluded from IP ban by default
     37
    3538### 1.0
    3639Inıtial Release
     
    3841## Upgrade Notice
    3942
    40 ### 0.1
     43### 1.0
    4144Initial Release. No Upgrade Notice
  • search-limiter-blocker/trunk/readme.txt

    r2114526 r2114528  
    2727
    2828== Changelog ==
     29= 1.1 =
     30Search bots excluded from IP ban by default
     31
    2932= 1.0 =
    3033Inıtial Release
    3134
    3235== Upgrade Notice ==
    33 = 0.1 =
     36= 1.0 =
    3437Initial Release. No Upgrade Notice
  • search-limiter-blocker/trunk/search-limiter-blocker.php

    r2114526 r2114528  
    55Plugin URI: http://www.wpadami.com/
    66Description: Set and limit search count of visitors. Also, you can block visitor IP.
    7 Version: 1.0
     7Version: 1.1
    88Author: Serkan Algur
    99Author URI: http://www.wpadami.com
     
    3838            <h2>Search Limiter & Blocker</h2>
    3939            <p></p>
    40             <?php settings_errors(); ?>
     40                <?php settings_errors(); ?>
    4141
    4242            <form method="post" action="options.php">
    43                 <?php
     43                    <?php
    4444                    settings_fields( 'search_limiter_blocker_option_group' );
    4545                    do_settings_sections( 'search-limiter-blocker-admin' );
    4646                    submit_button();
    47                 ?>
     47                    ?>
    4848            </form>
    4949        </div>
    50         <?php
     50            <?php
    5151    }
    5252
     
    161161        $will_deleted = get_option( 'visitor_ip_block' . $this->get_the_user_ip() . '-deleteafter30min' );
    162162
    163         // Check for block
    164         if ( 'blocked' === $is_block ) :
    165             // Kill The Proccess
    166             wp_die( esc_html( $message_for_blocked_visitor_2 ), 'You are Blocked By Search Limiter & Blocker for ' . esc_html( $time_for_block ) . ' seconds', 403 );
    167         else :
    168             // Not Blocked. Continue as normal
    169             if ( $query->is_search ) :
    170                 if ( ( $visitor_i_p_count >= $visitor_i_p_limit ) && 'yes' === $will_deleted ) :
    171                     delete_option( 'visitor_ip_count-' . $this->get_the_user_ip() );
    172                     delete_option( 'visitor_ip_block' . $this->get_the_user_ip() . '-deleteafter30min' );
     163        if ( preg_match( '/google|yandex|yndx|spider|bot|slurp|msn|bing|adsbot|AdIdxBot|search|face|baidu|duck|sogou|youdao|ccbot|alexa|microsoft/i', gethostbyaddr( $this->get_the_user_ip() ) ) ) {
     164            // Search Bots Excluded by default
     165            return $query;
     166        } else {
    173167
    174                     // Check for limit again and add one more.
    175                 elseif ( $visitor_i_p_count < $visitor_i_p_limit ) :
    176                     $visitor_i_p_count++;
    177                     update_option( 'visitor_ip_count-' . $this->get_the_user_ip(), $visitor_i_p_count );
    178                     return $query;
     168            // Check for block
     169            if ( 'blocked' === $is_block ) :
     170                // Kill The Proccess
     171                wp_die( esc_html( $message_for_blocked_visitor_2 ), 'You are Blocked By Search Limiter & Blocker for ' . esc_html( $time_for_block ) . ' seconds', 403 );
    179172                else :
    180                     // Add option for block
    181                     set_transient( 'visitor_ip_block' . $this->get_the_user_ip(), 'blocked', $time_for_block );
    182                     update_option( 'visitor_ip_block' . $this->get_the_user_ip() . '-deleteafter30min', 'yes' );
     173                    // Not Blocked. Continue as normal
     174                    if ( $query->is_search ) :
     175                        if ( ( $visitor_i_p_count >= $visitor_i_p_limit ) && 'yes' === $will_deleted ) :
     176                            delete_option( 'visitor_ip_count-' . $this->get_the_user_ip() );
     177                            delete_option( 'visitor_ip_block' . $this->get_the_user_ip() . '-deleteafter30min' );
    183178
    184                     // Kill The Proccess
    185                     wp_die( esc_html( $message_for_blocked_visitor_2 ), 'You are Blocked By Search Limiter & Blocker for ' . esc_html( $time_for_block ) . ' seconds', 403 );
     179                            // Check for limit again and add one more.
     180                        elseif ( $visitor_i_p_count < $visitor_i_p_limit ) :
     181                            $visitor_i_p_count++;
     182                            update_option( 'visitor_ip_count-' . $this->get_the_user_ip(), $visitor_i_p_count );
     183                            return $query;
     184                        else :
     185                            // Add option for block
     186                            set_transient( 'visitor_ip_block' . $this->get_the_user_ip(), 'blocked', $time_for_block );
     187                            update_option( 'visitor_ip_block' . $this->get_the_user_ip() . '-deleteafter30min', 'yes' );
     188
     189                            // Kill The Proccess
     190                            wp_die( esc_html( $message_for_blocked_visitor_2 ), 'You are Blocked By Search Limiter & Blocker for ' . esc_html( $time_for_block ) . ' seconds', 403 );
     191                        endif;
     192                    endif;
    186193                endif;
    187             endif;
    188         endif;
     194        }
    189195    }
    190 
    191 
    192196
    193197}
Note: See TracChangeset for help on using the changeset viewer.