Plugin Directory

Changeset 487204


Ignore:
Timestamp:
01/09/2012 09:24:41 PM (13 years ago)
Author:
blogrescue
Message:
  • Any folder or file named 'cache' is now always ignored
  • Any folder or file named 'error_log' is now always ignored
  • A new option that enables/disabled checksum evaluation has been added (Default and recommended setting is Disabled)
Location:
wordpress-sentinel/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wordpress-sentinel/trunk/readme.txt

    r481563 r487204  
    55Requires at least: 3.0
    66Tested up to: 3.3
    7 Stable tag: 1.1
     7Stable tag: 1.2
    88
    99This plugin acts as a sentinel that watches over your core Wordpress programs (plus installed themes and plugins) and tells you when changes happen.
     
    5252Obviously, the plugin cannot differentiate between a good change and a bad change, so if you make changes to a Theme or install a new Plugin, or even Upgrade Wordpress to a newer version, it is simply going to notice the change and let you know. When this happens (and it will happen), just go to the Wordpress Sentinel option, find the item that you changed or added, and Refresh the Snapshot. (The <strong>Snapshot Everything New</strong> button is a handy way to create initial snapshots after installing new themes and plugins.  It does not touch items which have previously been catalogued.)
    5353
     54= What are Checksums and Why do I need Them? =
     55
     56Checksums are a way of looking at the contents of a file and building a hash.  If the file changes in any way, even if the size remains the same, the checksum will be different.  Enabling checksums adds extra security however, however this comes at a cost.  The added overhead can slow down a site if there are an inordinate number of files or if there are extremely large files that have to be processed.  The basic file checks compare the modification date and the file size.  This should provide adequate protection in most situations.
     57 
    5458= It is complaining because my sitemap updated - How do I fix this? =
    5559
     
    9397== Changelog ==
    9498
     99= 1.2 =
     100* Any folder or file named 'cache' is now always ignored
     101* Any folder or file named 'error_log' is now always ignored
     102* A new option that enables/disabled checksum evaluation has been added (Default and recommended setting is Disabled)
     103
    95104= 1.1 =
    96105* Plugin now allows an entire plugin or theme to be ignored (not watched)
  • wordpress-sentinel/trunk/wordpress_sentinel.php

    r481556 r487204  
    4141  var $wp_plugin_dir;
    4242  var $wp_wordpress_dir;
     43  var $use_checksums;
    4344 
    4445  var $base;
     
    6263    $this->wp_plugin_dir = WP_PLUGIN_DIR;
    6364    $this->wp_wordpress_dir = dirname(WP_CONTENT_DIR); 
     65   
     66    $this->use_checksums = get_site_option('wordpress_sentinel_use_checksums');
    6467  }
    6568 
     
    7881   
    7982    // Periodic (mock cron) checking for changes
    80     $action_interval = 5; // minutes
    81     $check_interval = 2; // hours
     83    $action_interval = 10; // minutes
     84    $check_interval = 4; // hours
    8285   
    8386    $site_check = intval(get_site_option('wordpress_sentinel_site_check'));
     
    97100      }
    98101
    99       delete_option('wordpress_sentinel_site_check');
    100       add_option('wordpress_sentinel_site_check', time());
     102      update_option('wordpress_sentinel_site_check', time());
    101103    }
    102104  }
     
    104106  function admin_panel() {
    105107    $this->build_section_list();
    106 
    107     print '<div id="icon-options-general" class="icon32"><br /></div>';
    108     print '<h2>Wordpress Sentinel</h2>';
    109     print "<div style='text-align:center;'>";
    110    
    111     $snapshot_url = $this->url('snapshot', array('section'=>'all'));
    112     $snapshot_link = ( function_exists('wp_nonce_url') ) ? wp_nonce_url($snapshot_url, 'sentinel-snapshot-all') : $snapshot_url;
    113     print "<a href='$snapshot_link' class='button'>".
    114       "Snapshot Everything New</a>";
    115      
    116     print "&nbsp;&nbsp;&nbsp;&nbsp;";
    117    
    118     $check_url = $this->url('check', array('section'=>'all'));
    119     $check_link = ( function_exists('wp_nonce_url') ) ? wp_nonce_url($check_url, 'sentinel-check-all') : $check_url;
    120     print "<a href='$check_link' class='button'>Check Everything</a>";
    121    
    122     print "&nbsp;&nbsp;&nbsp;&nbsp;";
    123     print "<a href='".$this->url('help')."' class='button'>How Does This Work?</a>";
    124     print "</div>";
    125108
    126109    $admin_home = true;
     
    128111    $section_id = $this->arg('section', '0');
    129112    $section_id_intval = intval($section_id);
     113    $checksum_message = '';
     114
     115    if($action == 'checksum') {
     116      check_admin_referer('sentinel-checksum');
     117      $this->use_checksums = !$this->use_checksums;
     118      update_option('wordpress_sentinel_use_checksums', $this->use_checksums);
     119     
     120      $checksum_message = "<div id='message' class='updated' style='margin-top:8px;'>".
     121        "<p>Checksum Mode Changed - Checksums are now <strong>".
     122        ($this->use_checksums ? 'Enabled' : 'Disabled')."</strong>.".
     123        ($this->use_checksums ? ' (All Snapshots will need to be Refreshed!)' : '').
     124        "</p></div>";
     125    } 
     126
     127    $this->interface_buttons();
     128    if($checksum_message != '') print $checksum_message;
    130129
    131130    if($action == 'snapshot') {
     
    158157        $this->check_section($section_id_intval);
    159158      }
    160      
     159
    161160    } else if($action == 'help') {
    162161      $this->show_help();
     
    168167      $this->display_sections();
    169168    }
     169  }
     170 
     171  function interface_buttons() {
     172    print '<div id="icon-options-general" class="icon32"><br /></div>';
     173    print '<h2>Wordpress Sentinel</h2>';
     174    print "<div style='text-align:center;'>";
     175   
     176    $snapshot_url = $this->url('snapshot', array('section'=>'all'));
     177    $snapshot_link = ( function_exists('wp_nonce_url') ) ? wp_nonce_url($snapshot_url, 'sentinel-snapshot-all') : $snapshot_url;
     178    print "<a href='$snapshot_link' class='button'>".
     179      "Snapshot Everything New</a>";
     180     
     181    print "&nbsp;&nbsp;&nbsp;&nbsp;";
     182   
     183    $check_url = $this->url('check', array('section'=>'all'));
     184    $check_link = ( function_exists('wp_nonce_url') ) ? wp_nonce_url($check_url, 'sentinel-check-all') : $check_url;
     185    print "<a href='$check_link' class='button'>Check Everything</a>";
     186
     187    print "&nbsp;&nbsp;&nbsp;&nbsp;";
     188   
     189    $sum_url = $this->url('checksum');
     190    $sum_link = ( function_exists('wp_nonce_url') ) ? wp_nonce_url($sum_url, 'sentinel-checksum') : $sum_url;
     191    print "<a href='$sum_link' class='button'>".($this->use_checksums ? 'Disable' : 'Enable')." Checksums</a>";
     192   
     193    print "&nbsp;&nbsp;&nbsp;&nbsp;";
     194   
     195    print "<a href='".$this->url('help')."' class='button'>How Does This Work?</a>";
     196    print "</div>";
    170197  }
    171198 
     
    238265  <h3>What if I'm the one making changes?</h3>
    239266  <p>Obviously, the plugin cannot differentiate between a good change and a bad change, so if you make changes to a Theme or install a new Plugin, or even Upgrade Wordpress to a newer version, it is simply going to notice the change and let you know. When this happens (and it will happen), just go to the Wordpress Sentinel option, find the item that you changed or added, and Refresh the Snapshot. (The <strong>Snapshot Everything New</strong> button is a handy way to create initial snapshots after installing new themes and plugins.  It does not touch items which have previously been catalogued.)</p>
     267  <h3>What are Checksums and Why do I need Them?</h3>
     268  <p>Checksums are a way of looking at the contents of a file and building a hash.  If the file changes in any way, even if the size remains the same, the checksum will be different.  Enabling checksums adds extra security however, however this comes at a cost.  The added overhead can slow down a site if there are an inordinate number of files or if there are extremely large files that have to be processed.  The basic file checks compare the modification date and the file size.  This should provide adequate protection in most situations.</p>
    240269  <h3>It is complaining because my sitemap updated - How do I fix this?</h3>
    241270  To stop watching your sitemap files, do the following:
     
    486515        $actual_file = $section_actual_files[sha1($snapshot_file->location)];
    487516        $difference = ($snapshot_file->size != $actual_file->size) ||
    488           ($snapshot_file->update_date != date("Y-m-d H:i:s", $actual_file->date)) ||
    489           ($snapshot_file->checksum != $actual_file->checksum);
     517          ($snapshot_file->update_date != date("Y-m-d H:i:s", $actual_file->date));
     518        if($this->use_checksums == true) $difference = $difference || ($snapshot_file->checksum != $actual_file->checksum);
     519       
    490520        if($difference) {
    491521          if($snapshot_file->watch == 0) {
     
    557587    if($section_row->mode == WPS_MODE_FILE) {
    558588      $file_location  = $section_row->location . DIRECTORY_SEPARATOR . $section_row->slug;
    559       $files[sha1($file_location)] = new wordpresssentinel_file($file_location);
     589      $files[sha1($file_location)] = new wordpresssentinel_file($file_location, $this->use_checksums);
    560590    } else {
    561591      $this->process_directory($files, $section_row->mode, $section_row->location);
     
    567597  function process_directory(&$files, $mode, $path) {
    568598    $handle = opendir($path);
    569     $skip = array('.', '..');
     599    $skip = array('.', '..', 'cache', 'error_log');
    570600   
    571601    while($entry = readdir($handle)) {
     
    577607        if($mode == WPS_MODE_RECURSIVE) $this->process_directory($files, $mode, $resource);
    578608      } else {
    579         $files[sha1($resource)] = new wordpresssentinel_file($resource);
     609        $files[sha1($resource)] = new wordpresssentinel_file($resource, $this->use_checksums);
    580610      }
    581611    }
     
    670700  var $date;
    671701 
    672   function wordpresssentinel_file($location) {
     702  function wordpresssentinel_file($location, $use_checksums) {
    673703    $this->file = $location;
    674704    $this->size = filesize($location);
    675     $this->checksum = sha1_file($location);
    676705    $this->date = filemtime($location);
     706
     707    if($use_checksums == true && $this->size < 50000) {
     708      $this->checksum = sha1_file($location);
     709    } else {
     710      $this->checksum = 'not used';
     711    }
    677712  }
    678713}
Note: See TracChangeset for help on using the changeset viewer.