Changeset 487204
- Timestamp:
- 01/09/2012 09:24:41 PM (13 years ago)
- Location:
- wordpress-sentinel/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
wordpress-sentinel/trunk/readme.txt
r481563 r487204 5 5 Requires at least: 3.0 6 6 Tested up to: 3.3 7 Stable tag: 1. 17 Stable tag: 1.2 8 8 9 9 This plugin acts as a sentinel that watches over your core Wordpress programs (plus installed themes and plugins) and tells you when changes happen. … … 52 52 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.) 53 53 54 = What are Checksums and Why do I need Them? = 55 56 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. 57 54 58 = It is complaining because my sitemap updated - How do I fix this? = 55 59 … … 93 97 == Changelog == 94 98 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 95 104 = 1.1 = 96 105 * Plugin now allows an entire plugin or theme to be ignored (not watched) -
wordpress-sentinel/trunk/wordpress_sentinel.php
r481556 r487204 41 41 var $wp_plugin_dir; 42 42 var $wp_wordpress_dir; 43 var $use_checksums; 43 44 44 45 var $base; … … 62 63 $this->wp_plugin_dir = WP_PLUGIN_DIR; 63 64 $this->wp_wordpress_dir = dirname(WP_CONTENT_DIR); 65 66 $this->use_checksums = get_site_option('wordpress_sentinel_use_checksums'); 64 67 } 65 68 … … 78 81 79 82 // Periodic (mock cron) checking for changes 80 $action_interval = 5; // minutes81 $check_interval = 2; // hours83 $action_interval = 10; // minutes 84 $check_interval = 4; // hours 82 85 83 86 $site_check = intval(get_site_option('wordpress_sentinel_site_check')); … … 97 100 } 98 101 99 delete_option('wordpress_sentinel_site_check'); 100 add_option('wordpress_sentinel_site_check', time()); 102 update_option('wordpress_sentinel_site_check', time()); 101 103 } 102 104 } … … 104 106 function admin_panel() { 105 107 $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 " ";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 " ";123 print "<a href='".$this->url('help')."' class='button'>How Does This Work?</a>";124 print "</div>";125 108 126 109 $admin_home = true; … … 128 111 $section_id = $this->arg('section', '0'); 129 112 $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; 130 129 131 130 if($action == 'snapshot') { … … 158 157 $this->check_section($section_id_intval); 159 158 } 160 159 161 160 } else if($action == 'help') { 162 161 $this->show_help(); … … 168 167 $this->display_sections(); 169 168 } 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 " "; 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 " "; 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 " "; 194 195 print "<a href='".$this->url('help')."' class='button'>How Does This Work?</a>"; 196 print "</div>"; 170 197 } 171 198 … … 238 265 <h3>What if I'm the one making changes?</h3> 239 266 <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> 240 269 <h3>It is complaining because my sitemap updated - How do I fix this?</h3> 241 270 To stop watching your sitemap files, do the following: … … 486 515 $actual_file = $section_actual_files[sha1($snapshot_file->location)]; 487 516 $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 490 520 if($difference) { 491 521 if($snapshot_file->watch == 0) { … … 557 587 if($section_row->mode == WPS_MODE_FILE) { 558 588 $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); 560 590 } else { 561 591 $this->process_directory($files, $section_row->mode, $section_row->location); … … 567 597 function process_directory(&$files, $mode, $path) { 568 598 $handle = opendir($path); 569 $skip = array('.', '..' );599 $skip = array('.', '..', 'cache', 'error_log'); 570 600 571 601 while($entry = readdir($handle)) { … … 577 607 if($mode == WPS_MODE_RECURSIVE) $this->process_directory($files, $mode, $resource); 578 608 } else { 579 $files[sha1($resource)] = new wordpresssentinel_file($resource );609 $files[sha1($resource)] = new wordpresssentinel_file($resource, $this->use_checksums); 580 610 } 581 611 } … … 670 700 var $date; 671 701 672 function wordpresssentinel_file($location ) {702 function wordpresssentinel_file($location, $use_checksums) { 673 703 $this->file = $location; 674 704 $this->size = filesize($location); 675 $this->checksum = sha1_file($location);676 705 $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 } 677 712 } 678 713 }
Note: See TracChangeset
for help on using the changeset viewer.