Changeset 881593
- Timestamp:
- 03/25/2014 10:13:56 AM (12 years ago)
- Location:
- autochmod
- Files:
-
- 1 deleted
- 2 edited
- 12 copied
-
tags/0.5.1 (copied) (copied from autochmod/trunk)
-
tags/0.5.1/autochmod.php (copied) (copied from autochmod/trunk/autochmod.php) (15 diffs)
-
tags/0.5.1/graphic (copied) (copied from autochmod/trunk/graphic)
-
tags/0.5.1/graphic/admin.css (deleted)
-
tags/0.5.1/graphic/configpage.css (copied) (copied from autochmod/trunk/graphic/configpage.css)
-
tags/0.5.1/jstree (copied) (copied from autochmod/trunk/jstree)
-
tags/0.5.1/languages (copied) (copied from autochmod/trunk/languages)
-
tags/0.5.1/languages/autochmod-it_IT.mo (copied) (copied from autochmod/trunk/languages/autochmod-it_IT.mo)
-
tags/0.5.1/languages/autochmod-it_IT.po (copied) (copied from autochmod/trunk/languages/autochmod-it_IT.po)
-
tags/0.5.1/languages/autochmod.pot (copied) (copied from autochmod/trunk/languages/autochmod.pot)
-
tags/0.5.1/readme.txt (copied) (copied from autochmod/trunk/readme.txt) (3 diffs)
-
tags/0.5.1/scripts.js (copied) (copied from autochmod/trunk/scripts.js)
-
tags/0.5.1/test (copied) (copied from autochmod/trunk/test)
-
trunk/autochmod.php (modified) (15 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
autochmod/tags/0.5.1/autochmod.php
r847596 r881593 5 5 Description: Protect folders and files from unhautorized changes managing filesystem permissions. 6 6 Author: Franco Traversaro 7 Version: 0.5 7 Version: 0.5.1 8 8 Author URI: mailto:franco.traversaro@e2net.it 9 9 Text Domain: autochmod … … 26 26 27 27 private function __construct() { 28 $this->keep_writable = get_option( 'autochmod_keep_writable', array() );29 $this->perms = get_option( 'autochmod_perms', $this->perms );28 $this->keep_writable = $this->get_option( 'autochmod_keep_writable', array() ); 29 $this->perms = $this->get_option( 'autochmod_perms', $this->perms ); 30 30 31 31 register_activation_hook( __FILE__, array( $this, 'activation_hook' ) ); … … 44 44 add_filter( 'network_admin_plugin_action_links_autochmod/autochmod.php', array( $this, 'plugin_action_links' ) ); 45 45 46 if ( get_option( 'autochmod_protection_active' ) ) {46 if ( $this->get_option( 'autochmod_protection_active' ) ) { 47 47 add_action( 'in_admin_footer', array( $this, 'in_admin_footer' ) ); 48 48 } else { 49 if ( ( get_option( 'autochmod_safe_again_at' ) - time()) > 0 ) {49 if ( ($this->get_option( 'autochmod_safe_again_at' ) - time()) > 0 ) { 50 50 add_action( 'admin_head', array( $this, 'admin_head_countdown_scripts' ) ); 51 51 } 52 52 } 53 } 54 55 private function get_option( $option ) { 56 return is_multisite() ? get_site_option( $option ) : get_option( $option ); 57 } 58 59 private function update_option( $option, $value ) { 60 return is_multisite() ? update_site_option( $option, $value ) : update_option( $option, $value ); 61 } 62 63 private function delete_option( $option ) { 64 return is_multisite() ? delete_site_option( $option ) : delete_option( $option ); 53 65 } 54 66 … … 57 69 $when = time() + HOUR_IN_SECONDS; 58 70 wp_schedule_single_event( $when, 'rimuovi_permessi_scrittura' ); 59 update_option( 'autochmod_safe_again_at', $when );60 update_option( 'autochmod_protection_active', false );71 $this->update_option( 'autochmod_safe_again_at', $when ); 72 $this->update_option( 'autochmod_protection_active', false ); 61 73 } 62 74 … … 64 76 $this->togli_permessi( ABSPATH ); 65 77 wp_unschedule_event( get_option( 'autochmod_safe_again_at' ), 'rimuovi_permessi_scrittura' ); 66 delete_option( 'autochmod_safe_again_at' );67 update_option( 'autochmod_protection_active', true );78 $this->delete_option( 'autochmod_safe_again_at' ); 79 $this->update_option( 'autochmod_protection_active', true ); 68 80 } 69 81 … … 102 114 103 115 public function deactivation_hook() { 104 delete_option( 'autochmod_keep_writable' );105 delete_option( 'autochmod_perms' );106 delete_option( 'autochmod_safe_again_at' );107 delete_option( 'autochmod_protection_active' );108 delete_option( 'autochmod_config_verified' );116 $this->delete_option( 'autochmod_keep_writable' ); 117 $this->delete_option( 'autochmod_perms' ); 118 $this->delete_option( 'autochmod_safe_again_at' ); 119 $this->delete_option( 'autochmod_protection_active' ); 120 $this->delete_option( 'autochmod_config_verified' ); 109 121 } 110 122 111 123 public function activation_hook() { 112 $kw = get_option( 'autochmod_keep_writable' );124 $kw = $this->get_option( 'autochmod_keep_writable' ); 113 125 if ( !is_array( $kw ) ) { 114 126 $dir = wp_upload_dir(); … … 116 128 if ( $blogs_dir = realpath( WP_CONTENT_DIR . '/blogs.dir' ) and !$this->writable( $blogs_dir ) ) 117 129 $kw[] = $blogs_dir; 118 update_option( 'autochmod_keep_writable', $kw );130 $this->update_option( 'autochmod_keep_writable', $kw ); 119 131 } 120 132 $this->keep_writable = $kw; 121 update_option( 'autochmod_perms', $this->perms );133 $this->update_option( 'autochmod_perms', $this->perms ); 122 134 } 123 135 … … 127 139 128 140 public function admin_bar_menu( WP_Admin_Bar $wp_admin_bar ) { 129 if ( get_option( 'autochmod_config_verified' ) ) {130 if ( ! get_option( 'autochmod_protection_active' ) ) {131 $sec = get_option( 'autochmod_safe_again_at' ) - time();141 if ( $this->get_option( 'autochmod_config_verified' ) ) { 142 if ( !$this->get_option( 'autochmod_protection_active' ) ) { 143 $sec = $this->get_option( 'autochmod_safe_again_at' ) - time(); 132 144 $style = "background:no-repeat center left url('" . WP_PLUGIN_URL . "/autochmod/graphic/opened.png');"; 133 145 $act = 'togli'; … … 188 200 $this->togli_permessi( ABSPATH ); 189 201 wp_unschedule_event( get_option( 'autochmod_safe_again_at' ), 'rimuovi_permessi_scrittura' ); 190 delete_option( 'autochmod_safe_again_at' );191 update_option( 'autochmod_protection_active', true );202 $this->delete_option( 'autochmod_safe_again_at' ); 203 $this->update_option( 'autochmod_protection_active', true ); 192 204 break; 193 205 case 'metti': … … 195 207 $when = time() + AutoCHMOD::RIPRISTINO_AUTOMATICO; 196 208 wp_schedule_single_event( $when, 'rimuovi_permessi_scrittura' ); 197 update_option( 'autochmod_safe_again_at', $when );198 update_option( 'autochmod_protection_active', false );209 $this->update_option( 'autochmod_safe_again_at', $when ); 210 $this->update_option( 'autochmod_protection_active', false ); 199 211 break; 200 212 case 'eterno': 201 213 $this->metti_permessi( ABSPATH ); 202 214 wp_unschedule_event( get_option( 'autochmod_safe_again_at' ), 'rimuovi_permessi_scrittura' ); 203 update_option( 'autochmod_safe_again_at', 0 );204 update_option( 'autochmod_protection_active', false );215 $this->update_option( 'autochmod_safe_again_at', 0 ); 216 $this->update_option( 'autochmod_protection_active', false ); 205 217 $msg = 2; 206 218 break; 207 219 case 'keep'; 208 update_option( 'autochmod_config_verified', true );220 $this->update_option( 'autochmod_config_verified', true ); 209 221 210 222 $save = array(); … … 214 226 $save[] = $path; 215 227 sort( $save ); 216 update_option( 'autochmod_keep_writable', $save );228 $this->update_option( 'autochmod_keep_writable', $save ); 217 229 $this->keep_writable = $save; 218 230 … … 225 237 $this->perms[ $mode ][ $kind ][ $target ] = $permission; 226 238 227 update_option( 'autochmod_perms', $this->perms );239 $this->update_option( 'autochmod_perms', $this->perms ); 228 240 $msg = 1; 229 241 break; … … 314 326 315 327 public function rimuovi_permessi_scrittura() { 316 delete_option( 'autochmod_safe_again_at' );317 update_option( 'autochmod_protection_active', true );328 $this->delete_option( 'autochmod_safe_again_at' ); 329 $this->update_option( 'autochmod_protection_active', true ); 318 330 $this->togli_permessi( ABSPATH ); 319 331 } … … 415 427 <h2><?php _e( "Write permissions", 'autochmod' ); ?></h2> 416 428 <?php $this->message( 2 ); ?> 417 <?php if ( ! get_option( 'autochmod_config_verified' ) ) : ?>429 <?php if ( !$this->get_option( 'autochmod_config_verified' ) ) : ?> 418 430 <div class="chmodyellow updated"> 419 431 <h3><?php _e( "It seems you've never changed the options!", 'autochmod' ); ?></h3> … … 421 433 </div> 422 434 <?php endif; ?> 423 <?php if ( ! get_option( 'autochmod_protection_active' ) ) : ?>435 <?php if ( !$this->get_option( 'autochmod_protection_active' ) ) : ?> 424 436 <div class="chmodyellow updated"> 425 437 <h3><?php _e( 'Beware!', 'autochmod' ); ?></h3> -
autochmod/tags/0.5.1/readme.txt
r847590 r881593 5 5 Requires at least: 3.1.0 6 6 Tested up to: 3.8.1 7 Stable tag: 0.5 7 Stable tag: 0.5.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 47 47 * Let the automatic updates happen! 48 48 49 **0.5.1** Fixed the behaviour of the admin bar button on multisite installation: the option are now saved on site_meta 50 49 51 = 0.4 = 50 52 * Check suggested configuration with a real case … … 87 89 = 0.5 = 88 90 Experimental feature: disable protection at the start of an automatic WP upgrade and re-enable at upgrade finished (or after 60 minutes if anything goes wrong). I haven't been able to really test it, so cross your fingers and hope for the best! But the worst it could happen is that the protection remains disactivated, or that WP dosn't get upgraded at all. Please inform me if anything goes wrong! 91 **0.5.1:** On multisite installation options are now saved in sitemeta: you'll need to reconfigure the plugin. I'm truly sorry. -
autochmod/trunk/autochmod.php
r847596 r881593 5 5 Description: Protect folders and files from unhautorized changes managing filesystem permissions. 6 6 Author: Franco Traversaro 7 Version: 0.5 7 Version: 0.5.1 8 8 Author URI: mailto:franco.traversaro@e2net.it 9 9 Text Domain: autochmod … … 26 26 27 27 private function __construct() { 28 $this->keep_writable = get_option( 'autochmod_keep_writable', array() );29 $this->perms = get_option( 'autochmod_perms', $this->perms );28 $this->keep_writable = $this->get_option( 'autochmod_keep_writable', array() ); 29 $this->perms = $this->get_option( 'autochmod_perms', $this->perms ); 30 30 31 31 register_activation_hook( __FILE__, array( $this, 'activation_hook' ) ); … … 44 44 add_filter( 'network_admin_plugin_action_links_autochmod/autochmod.php', array( $this, 'plugin_action_links' ) ); 45 45 46 if ( get_option( 'autochmod_protection_active' ) ) {46 if ( $this->get_option( 'autochmod_protection_active' ) ) { 47 47 add_action( 'in_admin_footer', array( $this, 'in_admin_footer' ) ); 48 48 } else { 49 if ( ( get_option( 'autochmod_safe_again_at' ) - time()) > 0 ) {49 if ( ($this->get_option( 'autochmod_safe_again_at' ) - time()) > 0 ) { 50 50 add_action( 'admin_head', array( $this, 'admin_head_countdown_scripts' ) ); 51 51 } 52 52 } 53 } 54 55 private function get_option( $option ) { 56 return is_multisite() ? get_site_option( $option ) : get_option( $option ); 57 } 58 59 private function update_option( $option, $value ) { 60 return is_multisite() ? update_site_option( $option, $value ) : update_option( $option, $value ); 61 } 62 63 private function delete_option( $option ) { 64 return is_multisite() ? delete_site_option( $option ) : delete_option( $option ); 53 65 } 54 66 … … 57 69 $when = time() + HOUR_IN_SECONDS; 58 70 wp_schedule_single_event( $when, 'rimuovi_permessi_scrittura' ); 59 update_option( 'autochmod_safe_again_at', $when );60 update_option( 'autochmod_protection_active', false );71 $this->update_option( 'autochmod_safe_again_at', $when ); 72 $this->update_option( 'autochmod_protection_active', false ); 61 73 } 62 74 … … 64 76 $this->togli_permessi( ABSPATH ); 65 77 wp_unschedule_event( get_option( 'autochmod_safe_again_at' ), 'rimuovi_permessi_scrittura' ); 66 delete_option( 'autochmod_safe_again_at' );67 update_option( 'autochmod_protection_active', true );78 $this->delete_option( 'autochmod_safe_again_at' ); 79 $this->update_option( 'autochmod_protection_active', true ); 68 80 } 69 81 … … 102 114 103 115 public function deactivation_hook() { 104 delete_option( 'autochmod_keep_writable' );105 delete_option( 'autochmod_perms' );106 delete_option( 'autochmod_safe_again_at' );107 delete_option( 'autochmod_protection_active' );108 delete_option( 'autochmod_config_verified' );116 $this->delete_option( 'autochmod_keep_writable' ); 117 $this->delete_option( 'autochmod_perms' ); 118 $this->delete_option( 'autochmod_safe_again_at' ); 119 $this->delete_option( 'autochmod_protection_active' ); 120 $this->delete_option( 'autochmod_config_verified' ); 109 121 } 110 122 111 123 public function activation_hook() { 112 $kw = get_option( 'autochmod_keep_writable' );124 $kw = $this->get_option( 'autochmod_keep_writable' ); 113 125 if ( !is_array( $kw ) ) { 114 126 $dir = wp_upload_dir(); … … 116 128 if ( $blogs_dir = realpath( WP_CONTENT_DIR . '/blogs.dir' ) and !$this->writable( $blogs_dir ) ) 117 129 $kw[] = $blogs_dir; 118 update_option( 'autochmod_keep_writable', $kw );130 $this->update_option( 'autochmod_keep_writable', $kw ); 119 131 } 120 132 $this->keep_writable = $kw; 121 update_option( 'autochmod_perms', $this->perms );133 $this->update_option( 'autochmod_perms', $this->perms ); 122 134 } 123 135 … … 127 139 128 140 public function admin_bar_menu( WP_Admin_Bar $wp_admin_bar ) { 129 if ( get_option( 'autochmod_config_verified' ) ) {130 if ( ! get_option( 'autochmod_protection_active' ) ) {131 $sec = get_option( 'autochmod_safe_again_at' ) - time();141 if ( $this->get_option( 'autochmod_config_verified' ) ) { 142 if ( !$this->get_option( 'autochmod_protection_active' ) ) { 143 $sec = $this->get_option( 'autochmod_safe_again_at' ) - time(); 132 144 $style = "background:no-repeat center left url('" . WP_PLUGIN_URL . "/autochmod/graphic/opened.png');"; 133 145 $act = 'togli'; … … 188 200 $this->togli_permessi( ABSPATH ); 189 201 wp_unschedule_event( get_option( 'autochmod_safe_again_at' ), 'rimuovi_permessi_scrittura' ); 190 delete_option( 'autochmod_safe_again_at' );191 update_option( 'autochmod_protection_active', true );202 $this->delete_option( 'autochmod_safe_again_at' ); 203 $this->update_option( 'autochmod_protection_active', true ); 192 204 break; 193 205 case 'metti': … … 195 207 $when = time() + AutoCHMOD::RIPRISTINO_AUTOMATICO; 196 208 wp_schedule_single_event( $when, 'rimuovi_permessi_scrittura' ); 197 update_option( 'autochmod_safe_again_at', $when );198 update_option( 'autochmod_protection_active', false );209 $this->update_option( 'autochmod_safe_again_at', $when ); 210 $this->update_option( 'autochmod_protection_active', false ); 199 211 break; 200 212 case 'eterno': 201 213 $this->metti_permessi( ABSPATH ); 202 214 wp_unschedule_event( get_option( 'autochmod_safe_again_at' ), 'rimuovi_permessi_scrittura' ); 203 update_option( 'autochmod_safe_again_at', 0 );204 update_option( 'autochmod_protection_active', false );215 $this->update_option( 'autochmod_safe_again_at', 0 ); 216 $this->update_option( 'autochmod_protection_active', false ); 205 217 $msg = 2; 206 218 break; 207 219 case 'keep'; 208 update_option( 'autochmod_config_verified', true );220 $this->update_option( 'autochmod_config_verified', true ); 209 221 210 222 $save = array(); … … 214 226 $save[] = $path; 215 227 sort( $save ); 216 update_option( 'autochmod_keep_writable', $save );228 $this->update_option( 'autochmod_keep_writable', $save ); 217 229 $this->keep_writable = $save; 218 230 … … 225 237 $this->perms[ $mode ][ $kind ][ $target ] = $permission; 226 238 227 update_option( 'autochmod_perms', $this->perms );239 $this->update_option( 'autochmod_perms', $this->perms ); 228 240 $msg = 1; 229 241 break; … … 314 326 315 327 public function rimuovi_permessi_scrittura() { 316 delete_option( 'autochmod_safe_again_at' );317 update_option( 'autochmod_protection_active', true );328 $this->delete_option( 'autochmod_safe_again_at' ); 329 $this->update_option( 'autochmod_protection_active', true ); 318 330 $this->togli_permessi( ABSPATH ); 319 331 } … … 415 427 <h2><?php _e( "Write permissions", 'autochmod' ); ?></h2> 416 428 <?php $this->message( 2 ); ?> 417 <?php if ( ! get_option( 'autochmod_config_verified' ) ) : ?>429 <?php if ( !$this->get_option( 'autochmod_config_verified' ) ) : ?> 418 430 <div class="chmodyellow updated"> 419 431 <h3><?php _e( "It seems you've never changed the options!", 'autochmod' ); ?></h3> … … 421 433 </div> 422 434 <?php endif; ?> 423 <?php if ( ! get_option( 'autochmod_protection_active' ) ) : ?>435 <?php if ( !$this->get_option( 'autochmod_protection_active' ) ) : ?> 424 436 <div class="chmodyellow updated"> 425 437 <h3><?php _e( 'Beware!', 'autochmod' ); ?></h3> -
autochmod/trunk/readme.txt
r847590 r881593 5 5 Requires at least: 3.1.0 6 6 Tested up to: 3.8.1 7 Stable tag: 0.5 7 Stable tag: 0.5.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 47 47 * Let the automatic updates happen! 48 48 49 **0.5.1** Fixed the behaviour of the admin bar button on multisite installation: the option are now saved on site_meta 50 49 51 = 0.4 = 50 52 * Check suggested configuration with a real case … … 87 89 = 0.5 = 88 90 Experimental feature: disable protection at the start of an automatic WP upgrade and re-enable at upgrade finished (or after 60 minutes if anything goes wrong). I haven't been able to really test it, so cross your fingers and hope for the best! But the worst it could happen is that the protection remains disactivated, or that WP dosn't get upgraded at all. Please inform me if anything goes wrong! 91 **0.5.1:** On multisite installation options are now saved in sitemeta: you'll need to reconfigure the plugin. I'm truly sorry.
Note: See TracChangeset
for help on using the changeset viewer.