Changeset 3265881
- Timestamp:
- 04/02/2025 07:28:54 PM (12 months ago)
- Location:
- aam-protected-media-files
- Files:
-
- 8 added
- 3 edited
-
tags/1.3.0 (added)
-
tags/1.3.0/LICENSE (added)
-
tags/1.3.0/application (added)
-
tags/1.3.0/application/Handler.php (added)
-
tags/1.3.0/application/HandlerV7.php (added)
-
tags/1.3.0/bootstrap.php (added)
-
tags/1.3.0/readme.txt (added)
-
trunk/application/Handler.php (modified) (3 diffs)
-
trunk/application/HandlerV7.php (added)
-
trunk/bootstrap.php (modified) (11 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
aam-protected-media-files/trunk/application/Handler.php
r3096891 r3265881 9 9 10 10 namespace AAM\AddOn\ProtectedMediaFiles; 11 12 use AAM_Service_Uri; 11 13 12 14 /** … … 127 129 { 128 130 // First, let's check if URI is restricted 129 \AAM_Service_Uri::getInstance()->authorizeUri('/' . $this->request);131 AAM_Service_Uri::getInstance()->authorizeUri('/' . $this->request); 130 132 131 133 $media = $this->findMedia(); … … 274 276 $filename = realpath(urldecode($filename)); 275 277 276 if (is_string($filename) && $this->_isAllowed( realpath($filename))) {278 if (is_string($filename) && $this->_isAllowed($filename)) { 277 279 if (empty($mime)) { 278 280 if (function_exists('mime_content_type')) { -
aam-protected-media-files/trunk/bootstrap.php
r3096891 r3265881 4 4 * Plugin Name: AAM Protected Media Files 5 5 * Description: Manage access to a physical file and prevent from a direct access 6 * Version: 1. 2.56 * Version: 1.3.0 7 7 * Author: Vasyl Martyniuk <vasyl@vasyltech.com> 8 8 * Author URI: https://vasyltech.com … … 15 15 namespace AAM\AddOn\ProtectedMediaFiles; 16 16 17 use AAM; 18 17 19 require_once __DIR__ . '/application/Handler.php'; 20 require_once __DIR__ . '/application/HandlerV7.php'; 18 21 19 22 /** … … 35 38 * 36 39 * @var Bootstrap 40 * @access private 37 41 * 38 * @access private39 42 * @version 1.0.0 40 43 */ … … 45 48 * 46 49 * @return void 50 * @access protected 47 51 * 48 52 * @since 1.1.0 Adding new setting to the AAM Settings area 49 53 * @since 1.0.0 Initial implementation of the method 50 54 * 51 * @access protected52 55 * @version 1.1.0 53 56 */ … … 57 60 add_filter( 58 61 'aam_settings_list_filter', 59 array($this, 'registerContentOptions'),60 10,61 262 function($options, $type) { 63 return $this->_register_additional_settings($options, $type); 64 }, 10, 2 62 65 ); 63 66 } … … 71 74 * 72 75 * @return array 76 * @access private 73 77 * 74 * @access public 75 * @version 1.1.0 78 * @version 1.3.0 76 79 */ 77 p ublic function registerContentOptions($options, $type)80 private function _register_additional_settings($options, $type) 78 81 { 79 82 if ($type === 'content') { 80 $options['addon.protected-media-files.settings.deniedRedirect'] = array( 81 'title' => __('Use Access Denied Redirect For Restricted Media Items'), 82 'description' => __('When direct access to a physical file is restricted, the default behavior is to return HTTP 401 (Unauthorized) response. If you enable this option, the Access Denied Redirect rule applies instead.'), 83 'value' => \AAM::api()->getConfig( 84 'addon.protected-media-files.settings.deniedRedirect', false 85 ) 83 if (self::is_v7()) { 84 $key = 'addon.protected_media_files.settings.denied_redirect'; 85 $value = AAM::api()->config->get($key, false); 86 } else { 87 $key = 'addon.protected-media-files.settings.deniedRedirect'; 88 $value = AAM::api()->getConfig($key, false); 89 } 90 91 $options[$key] = array( 92 'title' => __( 93 'Use Access Denied Redirect For Restricted Media Items', 94 'aam-protected-media-files' 95 ), 96 'description' => __( 97 'When direct access to a physical file is restricted, the default behavior is to return HTTP 401 (Unauthorized) response. If you enable this option, the Access Denied Redirect rule applies instead.', 98 'aam-protected-media-files' 99 ), 100 'value' => $value 86 101 ); 87 102 } … … 94 109 * 95 110 * @return void 111 * @access public 96 112 * 97 * @access public 98 * @version 1.0.0 113 * @since 1.3.0 Ability to handle AAM v6 & v7 114 * @since 1.0.0 Initial implementation of the method 115 * 116 * @version 1.3.0 99 117 */ 100 public static function on Init()118 public static function on_init() 101 119 { 102 Bootstrap::get Instance();120 Bootstrap::get_instance(); 103 121 104 122 // Check Media Access if needed 105 123 if (filter_input(INPUT_GET, 'aam-media')) { 106 Handler::bootstrap()->authorize(); 124 if (self::is_v7()) { 125 HandlerV7::bootstrap()->authorize(); 126 } else { 127 Handler::bootstrap()->authorize(); 128 } 107 129 } 130 } 131 132 /** 133 * Check if AAM is V7 134 * 135 * @return boolean 136 * @access public 137 * 138 * @version 1.3.0 139 */ 140 public static function is_v7() 141 { 142 return version_compare(AAM_VERSION, '7.0.0-alpha.1') >= 0; 108 143 } 109 144 … … 112 147 * 113 148 * @return Bootstrap 149 * @access public 114 150 * 115 * @access public116 151 * @version 1.0.0 117 152 */ 118 public static function get Instance()153 public static function get_instance() 119 154 { 120 155 if (is_null(self::$_instance)) { … … 129 164 * 130 165 * @return void 166 * @access public 131 167 * 132 * @access public133 168 * @version 1.0.0 134 169 */ … … 138 173 139 174 if (version_compare(PHP_VERSION, '5.6.40') === -1) { 140 exit(__('PHP 5.6.40 or higher is required.' ));175 exit(__('PHP 5.6.40 or higher is required.', 'aam-protected-media-files')); 141 176 } elseif (version_compare($wp_version, '5.0.0') === -1) { 142 exit(__('WP 5.0.0 or higher is required.')); 177 exit(__('WP 5.0.0 or higher is required.', 'aam-protected-media-files')); 178 } elseif (!defined('AAM_KEY')) { 179 exit(__( 180 'Free Advanced Access Manager plugin is required to be active.', 181 'aam-protected-media-files' 182 )); 143 183 } 144 184 } … … 148 188 if (defined('ABSPATH')) { 149 189 // Init hook 150 add_action('init', __NAMESPACE__ . '\Bootstrap::on Init');190 add_action('init', __NAMESPACE__ . '\Bootstrap::on_init', PHP_INT_MAX); 151 191 152 192 // Activation hooks -
aam-protected-media-files/trunk/readme.txt
r3096891 r3265881 5 5 Requires PHP: 5.6.0 6 6 License: GPLv2 or later 7 Tested up to: 6. 5.38 Stable tag: 1. 2.57 Tested up to: 6.7.2 8 Stable tag: 1.3.0 9 9 10 10 Add-on to the free Advanced Access Manager plugin that protects media files from direct access for visitors, roles or users … … 37 37 38 38 == Changelog == 39 40 = 1.3.0 = 41 * Added: Introduced updated to support upcoming AAM 7 version 39 42 40 43 = 1.2.5 =
Note: See TracChangeset
for help on using the changeset viewer.