Plugin Directory

Changeset 1909778


Ignore:
Timestamp:
07/16/2018 12:06:26 PM (7 years ago)
Author:
niteoweb
Message:

Updating to 1.0.17

File:
1 edited

Legend:

Unmodified
Added
Removed
  • spiderblocker/trunk/index.php

    r1812529 r1909778  
    44 * Plugin Name: Spider Blocker
    55 * Description: Spider Blocker will block most common bots that consume bandwidth and slow down your server.
    6  * Version:     1.0.16
     6 * Version:     1.0.17
    77 * Runtime:     5.3+
    88 * Author:      Easy Blog Networks
     
    204204        ),
    205205        array(
     206            'name' => 'MJ12',
     207            're' => 'MJ12',
     208            'desc' => 'http://www.majestic12.co.uk/projects/dsearch/mj12bot.php',
     209            'state' => true,
     210        ),
     211        array(
    206212            'name' => 'Blekko Bot',
    207213            're' => 'BlekkoBot',
     
    280286            add_action('wp_ajax_NSB-reset_list', array(&$this, 'resetList'));
    281287        }
     288
     289        // Filter (for robots.txt)
     290        add_filter( 'robots_txt', array (&$this, 'robotsFile' ), ~PHP_INT_MAX, 2 );
    282291        add_action('generate_rewrite_rules', array(&$this, "generateRewriteRules"));
    283292
     
    457466    {
    458467        $data = get_option(self::OptionName);
    459         if($data && count($data) > 0){
     468        if($data){
    460469            return maybe_unserialize($data);
    461470        }
     
    475484        delete_option(self::OptionName);
    476485        $this->generateBlockRules();
     486        add_filter( 'robots_txt', array (&$this, 'robotsFile' ), ~PHP_INT_MAX, 2 );
    477487        wp_send_json_success($this->getBots());
    478488    }
     
    496506
    497507        check_ajax_referer(self::nonce, 'nonce');
    498         $data = json_decode(stripcslashes($_POST['data']));
     508        $data = json_decode(stripcslashes($_POST['data']), true);
    499509
    500510        if (json_last_error()) {
     
    513523
    514524        $this->generateBlockRules();
     525        add_filter( 'robots_txt', array (&$this, 'robotsFile' ), ~PHP_INT_MAX, 2 );
    515526        wp_send_json_success($this->getBots());
     527
     528    }
     529
     530    function robotsFile( $output, $public ) {
     531
     532        // Get bots list
     533        $data = $this->getBots();
     534
     535        if ( $data ) {
     536            foreach ( $data as $entry ) {
     537              if ( ! empty( $entry['state'] ) ) {
     538                $output .= sprintf( "User-agent: %s\n", $entry['re'] );
     539                $output .= "Disallow: /\n";
     540                $output .= "\n";
     541              }
     542            }
     543        }
     544
     545        return $output;
    516546
    517547    }
     
    774804    }
    775805
    776 
    777806}
    778807
     
    780809if (defined('ABSPATH')) {
    781810    $NiteowebSpiderBlocker_ins = new SpiderBlocker;
     811
    782812    add_action( "upgrader_process_complete", array(&$NiteowebSpiderBlocker_ins, 'onPluginUpgrade'), 10, 2);
    783813    register_activation_hook(__FILE__, array(&$NiteowebSpiderBlocker_ins, 'activatePlugin'));
Note: See TracChangeset for help on using the changeset viewer.