Changeset 1909778
- Timestamp:
- 07/16/2018 12:06:26 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
spiderblocker/trunk/index.php
r1812529 r1909778 4 4 * Plugin Name: Spider Blocker 5 5 * Description: Spider Blocker will block most common bots that consume bandwidth and slow down your server. 6 * Version: 1.0.1 66 * Version: 1.0.17 7 7 * Runtime: 5.3+ 8 8 * Author: Easy Blog Networks … … 204 204 ), 205 205 array( 206 'name' => 'MJ12', 207 're' => 'MJ12', 208 'desc' => 'http://www.majestic12.co.uk/projects/dsearch/mj12bot.php', 209 'state' => true, 210 ), 211 array( 206 212 'name' => 'Blekko Bot', 207 213 're' => 'BlekkoBot', … … 280 286 add_action('wp_ajax_NSB-reset_list', array(&$this, 'resetList')); 281 287 } 288 289 // Filter (for robots.txt) 290 add_filter( 'robots_txt', array (&$this, 'robotsFile' ), ~PHP_INT_MAX, 2 ); 282 291 add_action('generate_rewrite_rules', array(&$this, "generateRewriteRules")); 283 292 … … 457 466 { 458 467 $data = get_option(self::OptionName); 459 if($data && count($data) > 0){468 if($data){ 460 469 return maybe_unserialize($data); 461 470 } … … 475 484 delete_option(self::OptionName); 476 485 $this->generateBlockRules(); 486 add_filter( 'robots_txt', array (&$this, 'robotsFile' ), ~PHP_INT_MAX, 2 ); 477 487 wp_send_json_success($this->getBots()); 478 488 } … … 496 506 497 507 check_ajax_referer(self::nonce, 'nonce'); 498 $data = json_decode(stripcslashes($_POST['data']) );508 $data = json_decode(stripcslashes($_POST['data']), true); 499 509 500 510 if (json_last_error()) { … … 513 523 514 524 $this->generateBlockRules(); 525 add_filter( 'robots_txt', array (&$this, 'robotsFile' ), ~PHP_INT_MAX, 2 ); 515 526 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; 516 546 517 547 } … … 774 804 } 775 805 776 777 806 } 778 807 … … 780 809 if (defined('ABSPATH')) { 781 810 $NiteowebSpiderBlocker_ins = new SpiderBlocker; 811 782 812 add_action( "upgrader_process_complete", array(&$NiteowebSpiderBlocker_ins, 'onPluginUpgrade'), 10, 2); 783 813 register_activation_hook(__FILE__, array(&$NiteowebSpiderBlocker_ins, 'activatePlugin'));
Note: See TracChangeset
for help on using the changeset viewer.