Plugin Directory

Changeset 881593


Ignore:
Timestamp:
03/25/2014 10:13:56 AM (12 years ago)
Author:
belinde
Message:

Tagging version 0.5.1

Location:
autochmod
Files:
1 deleted
2 edited
12 copied

Legend:

Unmodified
Added
Removed
  • autochmod/tags/0.5.1/autochmod.php

    r847596 r881593  
    55  Description: Protect folders and files from unhautorized changes managing filesystem permissions.
    66  Author: Franco Traversaro
    7   Version: 0.5
     7  Version: 0.5.1
    88  Author URI: mailto:franco.traversaro@e2net.it
    99  Text Domain: autochmod
     
    2626
    2727    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 );
    3030
    3131        register_activation_hook( __FILE__, array( $this, 'activation_hook' ) );
     
    4444        add_filter( 'network_admin_plugin_action_links_autochmod/autochmod.php', array( $this, 'plugin_action_links' ) );
    4545
    46         if ( get_option( 'autochmod_protection_active' ) ) {
     46        if ( $this->get_option( 'autochmod_protection_active' ) ) {
    4747            add_action( 'in_admin_footer', array( $this, 'in_admin_footer' ) );
    4848        } else {
    49             if ( (get_option( 'autochmod_safe_again_at' ) - time()) > 0 ) {
     49            if ( ($this->get_option( 'autochmod_safe_again_at' ) - time()) > 0 ) {
    5050                add_action( 'admin_head', array( $this, 'admin_head_countdown_scripts' ) );
    5151            }
    5252        }
     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 );
    5365    }
    5466
     
    5769        $when = time() + HOUR_IN_SECONDS;
    5870        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 );
    6173    }
    6274
     
    6476        $this->togli_permessi( ABSPATH );
    6577        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 );
    6880    }
    6981
     
    102114
    103115    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' );
    109121    }
    110122
    111123    public function activation_hook() {
    112         $kw = get_option( 'autochmod_keep_writable' );
     124        $kw = $this->get_option( 'autochmod_keep_writable' );
    113125        if ( !is_array( $kw ) ) {
    114126            $dir = wp_upload_dir();
     
    116128            if ( $blogs_dir = realpath( WP_CONTENT_DIR . '/blogs.dir' ) and !$this->writable( $blogs_dir ) )
    117129                $kw[] = $blogs_dir;
    118             update_option( 'autochmod_keep_writable', $kw );
     130            $this->update_option( 'autochmod_keep_writable', $kw );
    119131        }
    120132        $this->keep_writable = $kw;
    121         update_option( 'autochmod_perms', $this->perms );
     133        $this->update_option( 'autochmod_perms', $this->perms );
    122134    }
    123135
     
    127139
    128140    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();
    132144                $style = "background:no-repeat center left url('" . WP_PLUGIN_URL . "/autochmod/graphic/opened.png');";
    133145                $act = 'togli';
     
    188200                    $this->togli_permessi( ABSPATH );
    189201                    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 );
    192204                    break;
    193205                case 'metti':
     
    195207                    $when = time() + AutoCHMOD::RIPRISTINO_AUTOMATICO;
    196208                    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 );
    199211                    break;
    200212                case 'eterno':
    201213                    $this->metti_permessi( ABSPATH );
    202214                    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 );
    205217                    $msg = 2;
    206218                    break;
    207219                case 'keep';
    208                     update_option( 'autochmod_config_verified', true );
     220                    $this->update_option( 'autochmod_config_verified', true );
    209221
    210222                    $save = array();
     
    214226                                $save[] = $path;
    215227                    sort( $save );
    216                     update_option( 'autochmod_keep_writable', $save );
     228                    $this->update_option( 'autochmod_keep_writable', $save );
    217229                    $this->keep_writable = $save;
    218230
     
    225237                                        $this->perms[ $mode ][ $kind ][ $target ] = $permission;
    226238
    227                     update_option( 'autochmod_perms', $this->perms );
     239                    $this->update_option( 'autochmod_perms', $this->perms );
    228240                    $msg = 1;
    229241                    break;
     
    314326
    315327    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 );
    318330        $this->togli_permessi( ABSPATH );
    319331    }
     
    415427            <h2><?php _e( "Write permissions", 'autochmod' ); ?></h2>
    416428            <?php $this->message( 2 ); ?>
    417             <?php if ( !get_option( 'autochmod_config_verified' ) ) : ?>
     429            <?php if ( !$this->get_option( 'autochmod_config_verified' ) ) : ?>
    418430                <div class="chmodyellow updated">
    419431                    <h3><?php _e( "It seems you've never changed the options!", 'autochmod' ); ?></h3>
     
    421433                </div>
    422434            <?php endif; ?>
    423             <?php if ( !get_option( 'autochmod_protection_active' ) ) : ?>
     435            <?php if ( !$this->get_option( 'autochmod_protection_active' ) ) : ?>
    424436                <div class="chmodyellow updated">
    425437                    <h3><?php _e( 'Beware!', 'autochmod' ); ?></h3>
  • autochmod/tags/0.5.1/readme.txt

    r847590 r881593  
    55Requires at least: 3.1.0
    66Tested up to: 3.8.1
    7 Stable tag: 0.5
     7Stable tag: 0.5.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4747* Let the automatic updates happen!
    4848
     49**0.5.1** Fixed the behaviour of the admin bar button on multisite installation: the option are now saved on site_meta
     50
    4951= 0.4 =
    5052* Check suggested configuration with a real case
     
    8789= 0.5 =
    8890Experimental 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  
    55  Description: Protect folders and files from unhautorized changes managing filesystem permissions.
    66  Author: Franco Traversaro
    7   Version: 0.5
     7  Version: 0.5.1
    88  Author URI: mailto:franco.traversaro@e2net.it
    99  Text Domain: autochmod
     
    2626
    2727    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 );
    3030
    3131        register_activation_hook( __FILE__, array( $this, 'activation_hook' ) );
     
    4444        add_filter( 'network_admin_plugin_action_links_autochmod/autochmod.php', array( $this, 'plugin_action_links' ) );
    4545
    46         if ( get_option( 'autochmod_protection_active' ) ) {
     46        if ( $this->get_option( 'autochmod_protection_active' ) ) {
    4747            add_action( 'in_admin_footer', array( $this, 'in_admin_footer' ) );
    4848        } else {
    49             if ( (get_option( 'autochmod_safe_again_at' ) - time()) > 0 ) {
     49            if ( ($this->get_option( 'autochmod_safe_again_at' ) - time()) > 0 ) {
    5050                add_action( 'admin_head', array( $this, 'admin_head_countdown_scripts' ) );
    5151            }
    5252        }
     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 );
    5365    }
    5466
     
    5769        $when = time() + HOUR_IN_SECONDS;
    5870        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 );
    6173    }
    6274
     
    6476        $this->togli_permessi( ABSPATH );
    6577        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 );
    6880    }
    6981
     
    102114
    103115    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' );
    109121    }
    110122
    111123    public function activation_hook() {
    112         $kw = get_option( 'autochmod_keep_writable' );
     124        $kw = $this->get_option( 'autochmod_keep_writable' );
    113125        if ( !is_array( $kw ) ) {
    114126            $dir = wp_upload_dir();
     
    116128            if ( $blogs_dir = realpath( WP_CONTENT_DIR . '/blogs.dir' ) and !$this->writable( $blogs_dir ) )
    117129                $kw[] = $blogs_dir;
    118             update_option( 'autochmod_keep_writable', $kw );
     130            $this->update_option( 'autochmod_keep_writable', $kw );
    119131        }
    120132        $this->keep_writable = $kw;
    121         update_option( 'autochmod_perms', $this->perms );
     133        $this->update_option( 'autochmod_perms', $this->perms );
    122134    }
    123135
     
    127139
    128140    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();
    132144                $style = "background:no-repeat center left url('" . WP_PLUGIN_URL . "/autochmod/graphic/opened.png');";
    133145                $act = 'togli';
     
    188200                    $this->togli_permessi( ABSPATH );
    189201                    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 );
    192204                    break;
    193205                case 'metti':
     
    195207                    $when = time() + AutoCHMOD::RIPRISTINO_AUTOMATICO;
    196208                    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 );
    199211                    break;
    200212                case 'eterno':
    201213                    $this->metti_permessi( ABSPATH );
    202214                    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 );
    205217                    $msg = 2;
    206218                    break;
    207219                case 'keep';
    208                     update_option( 'autochmod_config_verified', true );
     220                    $this->update_option( 'autochmod_config_verified', true );
    209221
    210222                    $save = array();
     
    214226                                $save[] = $path;
    215227                    sort( $save );
    216                     update_option( 'autochmod_keep_writable', $save );
     228                    $this->update_option( 'autochmod_keep_writable', $save );
    217229                    $this->keep_writable = $save;
    218230
     
    225237                                        $this->perms[ $mode ][ $kind ][ $target ] = $permission;
    226238
    227                     update_option( 'autochmod_perms', $this->perms );
     239                    $this->update_option( 'autochmod_perms', $this->perms );
    228240                    $msg = 1;
    229241                    break;
     
    314326
    315327    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 );
    318330        $this->togli_permessi( ABSPATH );
    319331    }
     
    415427            <h2><?php _e( "Write permissions", 'autochmod' ); ?></h2>
    416428            <?php $this->message( 2 ); ?>
    417             <?php if ( !get_option( 'autochmod_config_verified' ) ) : ?>
     429            <?php if ( !$this->get_option( 'autochmod_config_verified' ) ) : ?>
    418430                <div class="chmodyellow updated">
    419431                    <h3><?php _e( "It seems you've never changed the options!", 'autochmod' ); ?></h3>
     
    421433                </div>
    422434            <?php endif; ?>
    423             <?php if ( !get_option( 'autochmod_protection_active' ) ) : ?>
     435            <?php if ( !$this->get_option( 'autochmod_protection_active' ) ) : ?>
    424436                <div class="chmodyellow updated">
    425437                    <h3><?php _e( 'Beware!', 'autochmod' ); ?></h3>
  • autochmod/trunk/readme.txt

    r847590 r881593  
    55Requires at least: 3.1.0
    66Tested up to: 3.8.1
    7 Stable tag: 0.5
     7Stable tag: 0.5.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4747* Let the automatic updates happen!
    4848
     49**0.5.1** Fixed the behaviour of the admin bar button on multisite installation: the option are now saved on site_meta
     50
    4951= 0.4 =
    5052* Check suggested configuration with a real case
     
    8789= 0.5 =
    8890Experimental 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.