WordPress.org

Plugin Directory

Changeset 554719


Ignore:
Timestamp:
06/08/12 07:14:43 (23 months ago)
Author:
isaacchapman
Message:

Updating version to 0.5 which includes better detection of when WordPress is installed in a sub-directory

Location:
htaccess-secure-files
Files:
10 added
3 edited

Legend:

Unmodified
Added
Removed
  • htaccess-secure-files/trunk/dl.php

    r468838 r554719  
    109109 
    110110// Check if the file is there 
    111 $file = ABSPATH . substr($_SERVER['REQUEST_URI'], 1); 
     111$file = substr(ABSPATH, 0, strlen(ABSPATH) - strlen(hsf_get_home_root())) . $_SERVER['REQUEST_URI']; 
    112112if (!file_exists($file)) { 
    113113    header('Status: 404 Not Found', true, 404); 
     
    141141    } 
    142142} 
     143 
    143144$filestat = stat($file); 
    144145header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $filestat['mtime']) . ' GMT'); 
  • htaccess-secure-files/trunk/htaccess-secure-files.php

    r487820 r554719  
    22/* 
    33Plugin Name: Htaccess Secure Files 
    4 Version: 0.3 
     4Version: 0.5 
    55Plugin URI: http://isaacchapman.com/wordpress-plugins/htaccess-secure-files/ 
    66Description: Allows securing media library uploaded files to be vieweable to only users with specified capabilities. A different <a href="http://wordpress.org/extend/plugins/search.php?q=roles+capabilities&sort=" title="WordPress plugins repository">WordPress plugin</a> will be needed if custom <a href="http://codex.wordpress.org/Roles_and_Capabilities" title="Roles and Capabilities">roles and capabilities</a> need to created. <strong>Requires Apache with mod_rewrite enabled!</strong>  
     
    2626*/ 
    2727 
    28 define('HSF_VERSION', '0.4.0'); 
     28define('HSF_VERSION', '0.5.0'); 
    2929 
    3030// If the existing settings are to be used and shouldn't be changed through the admin interface HSF_HIDE_ADMIN should be defined as false in the wp-config.php file. For example: 
     
    602602    } 
    603603     
     604//  $hsf_home_root = hsf_get_home_root(); 
     605         
    604606    // Write the initial ruleset 
    605607    fwrite($handle, HSF_HTACCESS_NOTICE . "\n"); 
    606608    fwrite($handle, "RewriteEngine On\n"); 
     609//  fwrite($handle, "RewriteBase " . $hsf_home_root . "\n"); 
     610//  fwrite($handle, "# Skip requests for index.php\n"); 
     611//  fwrite($handle, "RewriteRule ^index\.php$ - [L]\n"); 
    607612    fwrite($handle, "# For files that do not exist use WordPress' root index.php\n"); 
    608613    fwrite($handle, "RewriteCond %{SCRIPT_FILENAME} !-f\n"); 
    609     fwrite($handle, "RewriteRule . " . hsf_get_home_root() . "index.php [L]\n"); 
     614    fwrite($handle, "RewriteRule . " . $hsf_home_root . "index.php [L]\n"); 
    610615    fwrite($handle, "# For files that do exist see if they are secured\n"); 
    611616    fwrite($handle, "RewriteCond %{SCRIPT_FILENAME} -f\n"); 
     
    619624 
    620625/**** File/path lookup functions ****/ 
     626function hsf_get_home_root() { 
     627    global $hsf_home_root; 
     628    if (isset($hsf_home_root) && $hsf_home_root) { return $hsf_home_root; } 
     629     
     630    $hsf_home_root = parse_url(get_option('siteurl')); 
     631    if ( isset( $hsf_home_root['path'] ) ) { 
     632        $hsf_home_root = trailingslashit($hsf_home_root['path']); 
     633    } else { 
     634        $hsf_home_root = '/'; 
     635    } 
     636    return $hsf_home_root; 
     637} 
     638 
     639 
    621640function hsf_get_dl_file() { 
    622641    global $hsf_dl_file; 
    623642    if (isset($hsf_dl_file) && $hsf_dl_file) { return $hsf_dl_file; } 
    624      
    625     $hsf_dl_file = substr(plugin_dir_path(__FILE__), strlen(ABSPATH) - 1) . 'dl.php'; 
     643    $hsf_dl_file = substr(plugin_dir_path(__FILE__), strlen(ABSPATH) - strlen(hsf_get_home_root())) . 'dl.php'; 
    626644    return $hsf_dl_file; 
    627 } 
    628  
    629 function hsf_get_home_root() { 
    630     global $hsf_home_root; 
    631     if (isset($hsf_home_root) && $hsf_home_root) { return $hsf_home_root; } 
    632      
    633     // Get the location of the root index file (from function mod_rewrite_rules) 
    634     $home_root = parse_url(home_url()); 
    635     if ( isset( $home_root['path'] ) ) { 
    636         $hsf_home_root = trailingslashit($home_root['path']); 
    637     } else { 
    638         $hsf_home_root = '/'; 
    639     } 
    640     return $hsf_home_root; 
    641645} 
    642646 
  • htaccess-secure-files/trunk/readme.txt

    r498937 r554719  
    33Tags: secure, htaccess, media 
    44Requires at least: 3.2.1 
    5 Tested up to: 3.3.1 
    6 Stable tag: 0.4 
     5Tested up to: 3.3.2 
     6Stable tag: 0.5 
    77 
    88Allows securing files in WP's media library to be only accessible to users with specific roles, capabilities, or IP addresses. 
     
    2929== Changelog == 
    3030 
     31= 0.5 = 
     32* Adding smarter detection when WordPress is installed in a sub-directory of a site. 
     33 
    3134= 0.4 = 
    3235* MIME/Content-type detection routine expanded (in order of priority): 1) Use WordPress's built-in (or plugin modified) MIME types. 2) Use Fileinfo PECL extension if installed. 3) Check with mime_content_type (deprecated). 4) Fallback to 'application/octet-stream'. 
Note: See TracChangeset for help on using the changeset viewer.