Plugin Directory

Changeset 2727847


Ignore:
Timestamp:
05/21/2022 05:31:51 PM (4 years ago)
Author:
kubi23
Message:

added version 5.0.0

Location:
change-uploaded-file-permissions
Files:
6 added
2 edited

Legend:

Unmodified
Added
Removed
  • change-uploaded-file-permissions/trunk/change-uploaded-file-permissions.php

    r675281 r2727847  
    22/*
    33Plugin Name: Change Uploaded File Permissions
    4 Plugin URI: http://www.svenkubiak.de/wordpress-plugin
    5 Description: Changes the permissions of uploaded files, pictures and thumbnails after the upload. Patched to work with WP v3 > by Jon Thompson (jthompson (at) names.co.uk)
    6 Version: 4.0.0
     4Plugin URI: https://wordpress.org/plugins/change-uploaded-file-permissions/
     5Description: Changes the permissions of uploaded files, pictures and thumbnails after the upload.
     6Version: 5.0.0
    77Author: Sven Kubiak
    8 Author URI: http://www.svenkubiak.de
    9 
    10 Copyright 2007-2013 Sven Kubiak
     8Author URI: https://svenkubiak.de
     9
     10Copyright 2007-20022 Sven Kubiak
    1111
    1212This program is free software; you can redistribute it and/or modify
     
    2323along with this program; if not, write to the Free Software
    2424Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    25 */
    26 
    27 /*
    28 This plugin has been modified to enable it to work on all versions of Wordpress
    29 and file permissions have been hard-coded to work specifically on web servers
    30 operated by http://www.names.co.uk and http://www.register365.com
    31 
    32 These changes have been marked with comments in the format
    33 //******************************************************************************
    34 //***** NAMESCO - DESCRIPTION OF CHANGES                                   *****
    35 //******************************************************************************
    36 ...
    37 code
    38 ...
    39 //******************************************************************************
    40 //***** NAMESCO - END CHANGE                                               *****
    41 //******************************************************************************
    42  
    43 Default file and folder permissions can be modified in wp-options/options.php
    44 after the plugin has been installed
    4525*/
    4626
     
    6444        add_action('admin_menu', array(&$this, 'setAdminPage'));
    6545        add_action('wp_handle_upload', array(&$this, 'uploadHook'));
    66 
     46       
    6747        //add wp filter
    6848        add_filter('wp_generate_attachment_metadata', array(&$this, 'thumbHook'));
     
    7959                if (function_exists('mkdir')){                 
    8060                    @mkdir($folder.date("Y"));
    81                     //**********************************************************
    82                     //***** NAMESCO - SET SECURE FOLDER PERMISSIONS        *****
    83                     //**********************************************************
    84                     chmod($folder.date("Y"), octdec(get_option('sk_folder_perms')));
    85                     //**********************************************************
    86                     //***** NAMESCO - END CHANGE                           *****
    87                     //**********************************************************
    88                    
    8961                    @mkdir($folder.date("Y/m"));
    90                     //**********************************************************
    91                     //***** NAMESCO - SET SECURE FOLDER PERMISSIONS        *****
    92                     //**********************************************************
    93                     chmod($folder.date("Y/m"), octdec(get_option('sk_folder_perms')));
    94                     //**********************************************************
    95                     //***** NAMESCO - END CHANGE                           *****
    96                     //**********************************************************
    9762                }
    9863            }   
     
    10570   
    10671    function activate()
    107     {
    108         //**********************************************************************
    109         //***** NAMESCO - SET THE WORDPRESS INSTALLATION PATH CORRECTLY    *****
    110         //*****           BASED ON THE LOCATION OF THE PLUGINS FOLDER      *****
    111         //**********************************************************************
    112         $wp_root_folder = getcwd();
    113         $arr_root_folder_parts = explode("/", $wp_root_folder);
    114         $discard_ = array_pop($arr_root_folder_parts);
    115         $wp_root_folder = join("/", $arr_root_folder_parts);
    116         //**********************************************************************
    117         //***** NAMESCO - END CHANGE                                       *****
    118         //**********************************************************************
    119        
    120         add_option('sk_wproot_folder', $wp_root_folder, '', 'yes');
     72    {       
     73        add_option('sk_wproot_folder', $_SERVER['DOCUMENT_ROOT'], '', 'yes');
    12174        add_option('sk_file_log', '', '', 'yes');
    122         add_option('sk_enable_log', 'false', '', 'yes');
    123        
    124         //**********************************************************************
    125         //***** NAMESCO - SET DEFAULT FOLDER AND FILE PERMISSIONS          *****
    126         //**********************************************************************
    127         add_option('sk_folder_perms', '0771', '', 'yes');
    128         add_option('sk_file_perms', '0644', '', 'yes');
    129         //**********************************************************************
    130         //***** NAMESCO - END CHANGE                                       *****
    131         //**********************************************************************
    132        
    133         //**********************************************************************
    134         //***** NAMESCO - MAKE SURE THE UPLOAD PATH IS SET. THIS NEEDS TO  *****
    135         //*****           BE DONE SO PERMISSIONS ON THUMBNAILS ARE SET     *****
    136         //**********************************************************************
    137         if(get_option('upload_path') == "") {
    138             update_option("upload_path", 'wp-content/uploads', '', 'yes');
    139         }
    140         //**********************************************************************
    141         //***** NAMESCO - END CHANGE                                       *****
    142         //**********************************************************************
    143        
     75        add_option('sk_enable_log', 'false', '', 'yes');   
    14476    }
    14577   
     
    14981        delete_option('sk_file_log');   
    15082        delete_option('sk_enable_log');
    151        
    152         //**********************************************************************
    153         //***** NAMESCO - DELETE DEFAULT FOLDER AND FILE PERMISSIONS       *****
    154         //**********************************************************************
    155         delete_option('sk_enable_log');
    156         delete_option('sk_enable_log');
    157         //**********************************************************************
    158         //***** NAMESCO - END CHANGE                                       *****
    159         //**********************************************************************
    16083    }
    16184   
     
    16992        if (!current_user_can('manage_options'))
    17093            wp_die(__('Sorry, but you have no permissions to change settings.','change-uploaded-file-permissions'));
    171 
    172         if ($_POST['sk_updateroot'] == 'true'){
    173             update_option('sk_wproot_folder', trim($_POST['sk_wproot_folder']));
    174             echo "<div id='message' class='updated fade'><p>".__('Settings have been successfully saved.','change-uploaded-file-permissions')."</p></div>";
    175         }
    176 
    177         if ($_POST['sk_updatelog'] == 'true'){         
    178             if ($_POST['sk_enable_log'] == 'true'){
    179                 update_option('sk_enable_log', 'true');
    180             }
    181             else if ($_POST['sk_enable_log'] == 'false'){
    182                 update_option('sk_file_log', '');
    183                 update_option('sk_enable_log', 'false');               
    184             }
    185             update_option('sk_enable_log', 'true');
    186             echo "<div id='message' class='updated fade'><p>".__('Settings have been successfully saved.','change-uploaded-file-permissions')."</p></div>";
    187         }   
    18894       
    18995        ?>
    190        
    19196        <div class="wrap">
    19297        <h2><?php echo __('Change Uploaded File Permissions Settings','change-uploaded-file-permissions'); ?></h2>
    19398        <h3><?php echo __('Path','change-uploaded-file-permissions'); ?></h3>
    194         <form name="form1" method="post" action="options-general.php?page=uploadedfilepermissions">   
    19599        <table class="form-table">
    196          <tr>
    197             <th scope="row" valign="top"><?php echo __('Absolute path to WordPress-Root folder WITHOUT ending Slash','change-uploaded-file-permissions'); ?></th>
    198             <td><input type="text" size="60" name="sk_wproot_folder" value="<?php echo get_option('sk_wproot_folder'); ?>" /><br /><?php echo __('i.e.','change-uploaded-file-permissions'); ?> /12345_12345/rp-hosting/1/2/web</td>
    199          </tr>
    200          <tr>
    201          
     100        <tr>
    202101         <?php
    203 
    204102            if (file_exists(get_option('sk_wproot_folder')) && is_dir(get_option('sk_wproot_folder'))){
    205103                echo "<td colspan='2'><strong>".__('Path test','change-uploaded-file-permissions').": </strong> <font color='green'>".__('The upload folder has been successfully found!','change-uploaded-file-permissions')."</font></td>";
     
    208106                echo "<td colspan='2'><strong>".__('Path test','change-uploaded-file-permissions').": <font color='red'>".__('Error','change-uploaded-file-permissions')."</strong> - ".__('The folder wp-content/uploads was not found!')."</font></td>";
    209107            }   
    210            
    211108         ?>
    212        
    213109        </tr>     
    214110        </table>   
    215         <input name="sk_updateroot" value="true" type="hidden" />
    216         <p class="submit">
    217         <input name="submit" value="<?php echo __('Save','change-uploaded-file-permissions'); ?>" type="submit" />
    218         </p>
    219         </form>     
    220        
    221         <?php
    222 
    223         ($this->logging == 'true') ? $logging = 'checked="checked"' : $nologging = 'checked="checked"';
    224        
    225         ?> 
    226    
    227         <h3><?php echo __('Logging','change-uploaded-file-permissions'); ?></h3>
    228         <form name="form" method="post" action="options-general.php?page=uploadedfilepermissions">
    229         <table class="form-table">
    230          <tr>
    231             <th scope="row" valign="top"><?php echo __('Log, which files have been changed.','change-uploaded-file-permissions'); ?></th>
    232             <td>
    233                  <label for="inputid"><?php echo __('Yes','change-uploaded-file-permissions'); ?></label> <input type="radio" name="sk_enable_log" value="true" <?php echo $logging; ?>> <label for="inputid"><?php echo __('No','change-uploaded-file-permissions'); ?></label> <input type="radio" name="sk_enable_log" value="false" <?php echo $nologging; ?>><br /><?php echo __('NOTE: Upon deactivation all log entries will be deleted.','change-uploaded-file-permissions'); ?>
    234             </td>
    235          </tr>
    236         </table>
    237    
    238         <p class="submit">
    239         <input name="sk_updatelog" value="true" type="hidden" />
    240         <input name="submit" value="<?php echo __('Save','change-uploaded-file-permissions'); ?>" type="submit" />
    241         </p>
    242         </form>
    243            
    244         <?php ($this->logging == 'true') ? $this->displayLog() : false; ?>
    245    
    246111        </div> 
    247112       
     
    262127        $folder = explode("/",$metadata['file']);
    263128   
    264         //**********************************************************************
    265         //***** NAMESCO - ITERATE THROUGH THE METADATA ARRAY TO GET ALL    *****
    266         //*****           GENERATED THUMBNAIL DATA.                        *****
    267         //*****                                                            *****
    268         //*****           PREVIOUSLY HARD CODED, AND MISSING ALL DATA      *****
    269         //**********************************************************************
    270         if(count($metadata ['sizes'])) {
    271             foreach($metadata ['sizes'] as $image_name => $arr_image_data) {
    272                 $this->changePermission($metadata ['sizes'] [$image_name] ['file'],true,$folder);
    273             }
    274         }
    275         //**********************************************************************
    276         //***** NAMESCO - END CHANGE                                       *****
    277         //**********************************************************************
    278        
     129        $thumbnail = $metadata ['sizes'] ['thumbnail'] ['file'];
     130        $medium = $metadata ['sizes'] ['medium'] ['file'];
     131        $large = $metadata ['sizes'] ['large'] ['file'];           
     132
     133        if (!empty($thumbnail)){
     134            $this->changePermission($thumbnail,true,$folder);   
     135        }
     136        if (!empty($medium)){
     137            $this->changePermission($medium,true,$folder); 
     138        }   
     139        if (!empty($large)){
     140            $this->changePermission($large,true,$folder);   
     141        }       
     142
    279143        return $metadata;
    280 
    281144    }
    282145   
     
    296159        }
    297160   
    298         if (file_exists($currentfile) && !is_dir($currentfile)){
    299             //******************************************************************
    300             //***** NAMESCO - PERMISSION CHANGED FROM 0640 TO 0644         *****
    301             //******************************************************************
    302             if (chmod($currentfile, octdec(get_option('sk_file_perms')))){
    303             //******************************************************************
    304             //***** NAMESCO - END CHANGE                                   *****
    305             //******************************************************************
     161        if (file_exists($currentfile) && !is_dir($currentfile)){       
     162            if (chmod($currentfile, 0640)){
    306163                $this->logAction($filename, __('Filepermissions have been changed succsesfully','change-uploaded-file-permissions'));
    307164            }
  • change-uploaded-file-permissions/trunk/readme.txt

    r675281 r2727847  
    11=== Plugin Name ===
    22Contributors: kubi23
    3 Donate link: http://www.svenkubiak.de/wordpress-plugin/#donate
    4 Tested up to: 3.5.1
    5 Stable tag: 4.0.0
     3Tested up to: 5.9.3
     4Stable tag: 5.0.0
    65Requires at least: 2.6
    76Tags: file, picture, upload, permission, thumbnail, files, pictures, thumbnails, upload
     
    3029== Version History ==
    3130
     31* Version 5.0.0
     32    * Major update
     33* Version 4.0.0
     34    * Major update
    3235* Version 3.5
    3336    * Fixed Bug when uploading pictures to old postings/pages
Note: See TracChangeset for help on using the changeset viewer.