PluginProbe ʕ •ᴥ•ʔ
File Manager Pro – Filester / 1.6.1
File Manager Pro – Filester v1.6.1
2.1.2 2.1.1 trunk 1.6.1 1.7.6 1.8 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 2.0 2.0.1 2.0.2 2.1.0
filester / includes / File_manager / FileManager.php
filester / includes / File_manager Last commit date
lib 5 years ago FileManager.php 5 years ago FileManagerHelper.php 5 years ago index.php 5 years ago
FileManager.php
514 lines
1 <?php
2 namespace NinjaFileManager\File_manager;
3
4 defined('ABSPATH') || exit;
5
6 /**
7 * Settings Page
8 */
9
10 class FileManager
11 {
12 protected static $instance = null;
13
14 /**
15 *
16 * @var object $options The object of the options class
17 *
18 * */
19 public $options;
20 public $fmCapability = '';
21 public $userRole = '';
22 private $hook_suffix = array();
23
24 public static function getInstance()
25 {
26 if (null == self::$instance) {
27 self::$instance = new self;
28 }
29
30 return self::$instance;
31 }
32
33 private function __construct()
34 {
35 //get user role
36 $user = wp_get_current_user();
37 $this->userRole = $user && $user->roles && $user->roles[0] ? $user->roles[0] : '';
38
39 // Loading Options
40 // Options
41 $this->options = get_option('njt_fs_settings');
42 if(empty($this->options)) {
43 $this->options = array( // Setting up default values
44 'njt_fs_file_manager_settings' => array(
45 'root_folder_path' => ABSPATH,
46 'root_folder_url' => site_url()
47 ),
48 );
49 }
50 register_shutdown_function(array($this, 'saveOptions'));
51
52 add_action('init', array($this, 'isAlowUserAccess'));
53 if ($this->isAlowUserAccess()) {
54 add_action('admin_enqueue_scripts', array($this, 'enqueueAdminScripts'));
55 add_action('admin_menu', array($this, 'FileManager'));
56 add_action('wp_ajax_fs_connector', array($this, 'fsConnector'));
57 add_action('wp_ajax_selector_themes', array($this, 'selectorThemes'));
58 add_action('wp_ajax_get_role_restrictions', array($this, 'getArrRoleRestrictions'));
59 add_action('wp_ajax_njt_fs_save_setting', array($this, 'njt_fs_saveSetting'));
60 add_action('wp_ajax_njt_fs_save_setting_restrictions', array($this, 'njt_fs_saveSettingRestrictions'));
61
62 $optionReview = get_option('njt_fs_review');
63 if (time() >= (int)$optionReview && $optionReview !== '0'){
64 add_action('admin_notices', array($this, 'njt_fs_give_review'));
65 }
66
67 add_action('wp_ajax_njt_fs_save_review', array($this, 'njt_fs_save_review'));
68 }
69 }
70
71 public function njt_fs_give_review()
72 {
73 if (function_exists('get_current_screen')) {
74 if (get_current_screen()->id == 'file-manager_page_filester-settings' || get_current_screen()->id == 'toplevel_page_njt-fs-filemanager' || get_current_screen()->id == 'plugins') {
75 $this->enqueue_scripts();
76 ?>
77 <div class="notice notice-success is-dismissible" id="njt-fs-review">
78 <h3><?php _e('Give Filester a review', 'filester')?></h3>
79 <p>
80 <?php _e('Thank you for choosing Filester. We hope you love it. Could you take a couple of seconds posting a nice review to share your happy experience?', 'filester')?>
81 </p>
82 <p>
83 <?php _e('We will be forever grateful. Thank you in advance ;)', 'filester')?>
84 </p>
85 <p>
86 <a href="javascript:;" data="rateNow" class="button button-primary" style="margin-right: 5px"><?php _e('Rate now', 'filester')?></a>
87 <a href="javascript:;" data="later" class="button" style="margin-right: 5px"><?php _e('Later', 'filester')?></a>
88 <a href="javascript:;" data="alreadyDid" class="button"><?php _e('Already did', 'filester')?></a>
89 </p>
90 </div>
91 <?php
92 }
93 }
94 }
95
96 public function njt_fs_save_review()
97 {
98 if ( isset( $_POST ) ) {
99 $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( $_POST['nonce'] ) : null;
100 $field = isset( $_POST['field'] ) ? sanitize_text_field( $_POST['field'] ) : null;
101
102 if ( ! wp_verify_nonce( $nonce, 'njt-fs-review' ) ) {
103 wp_send_json_error( array( 'status' => 'Wrong nonce validate!' ) );
104 exit();
105 }
106
107 if ($field == 'later'){
108 update_option('njt_fs_review', time() + 3*60*60*24); //After 3 days show
109 } else if ($field == 'alreadyDid'){
110 update_option('njt_fs_review', 0);
111 }
112 wp_send_json_success();
113 }
114 wp_send_json_error( array( 'message' => 'Update fail!' ) );
115 }
116
117 public function enqueue_scripts(){
118 wp_enqueue_script('njt-fs-review', NJT_FS_BN_PLUGIN_URL . 'assets/js/review.js', array('jquery'), NJT_FS_BN_VERSION, false);
119 wp_localize_script('njt-fs-review', 'wpDataFs', array(
120 'admin_ajax' => admin_url('admin-ajax.php'),
121 'nonce' => wp_create_nonce("njt-fs-review"),
122 ));
123 }
124
125 public function isAlowUserAccess()
126 {
127 if($this->userRole) {
128 $allowed_roles = !empty($this->options['njt_fs_file_manager_settings']['list_user_alow_access']) ? $this->options['njt_fs_file_manager_settings']['list_user_alow_access'] : array();
129 if( in_array($this->userRole,$allowed_roles) || $this->userRole == 'administrator') {
130 $this->fmCapability = $this->userRole;
131 return true;
132 }
133 }
134 if (is_super_admin()) {
135 $this->fmCapability = 'administrator';
136 return true;
137 }
138 $this->fmCapability = 'read';
139 return false;
140 }
141
142 public function FileManager()
143 {
144
145 $display_suffix = add_menu_page(
146 __('Filester', 'textdomain'),
147 'File Manager',
148 $this->fmCapability,
149 'njt-fs-filemanager',
150 array($this, 'fsViewFileCallback'),
151 '',
152 9
153 );
154
155 $settings_suffix = add_submenu_page (
156 'njt-fs-filemanager',
157 'Settings',
158 'Settings',
159 'manage_options',
160 'filester-settings',
161 array($this, 'fsSettingsPage') );
162
163 $this->hook_suffix = array($display_suffix, $settings_suffix);
164 }
165
166 public function fsViewFileCallback()
167 {
168 $viewPath = NJT_FS_BN_PLUGIN_PATH . 'views/pages/html-filemanager.php';
169 include_once $viewPath;
170 }
171
172 public function fsSettingsPage()
173 {
174 $viewPath = NJT_FS_BN_PLUGIN_PATH . 'views/pages/html-filemanager-settings.php';
175 include_once $viewPath;
176 }
177
178 public function enqueueAdminScripts($suffix)
179 {
180 wp_register_style('file_manager_icon_css',NJT_FS_BN_PLUGIN_URL . 'assets/css/style-icon.css');
181 wp_enqueue_style('file_manager_icon_css');
182
183 if (in_array($suffix, $this->hook_suffix)) {
184 $selectorThemes = get_option('njt_fs_selector_themes');
185 if (empty($selectorThemes[$this->userRole])) {
186 $selectorThemes[$this->userRole]['themesValue'] = 'Default';
187 update_option('njt_fs_selector_themes', $selectorThemes);
188 }
189
190 $selectedTheme = $selectorThemes[$this->userRole]['themesValue'];
191
192 //elfinder css
193 wp_enqueue_style('elfinder.jq.css', plugins_url('/lib/jquery/jquery-ui.min.css', __FILE__));
194 wp_enqueue_style('elfinder.full.css', plugins_url('/lib/css/elfinder.min.css', __FILE__));
195 wp_enqueue_style('themes', plugins_url('/lib/css/theme.css', __FILE__));
196 wp_enqueue_style('themes-selector', plugins_url('/lib/themes/' . $selectedTheme . '/css/theme.css', __FILE__));
197
198 //elfinder core
199 if(version_compare(get_bloginfo('version'),'5.6', '>=') ){
200 wp_enqueue_script('jquery_min', plugins_url('/lib/jquery/jquery-ui.min.js', __FILE__));
201 } else {
202 wp_enqueue_script('jquery_min', plugins_url('/lib/jquery/jquery-ui-old.min.js', __FILE__));
203 }
204
205 //elfinder js, toastr JS, css custom
206 wp_register_style('njt_fs_toastr_css',NJT_FS_BN_PLUGIN_URL . 'assets/js/toastr/toastr.min.css');
207 wp_enqueue_style('njt_fs_toastr_css');
208 wp_enqueue_script('njt_fs_toastr_js', NJT_FS_BN_PLUGIN_URL . 'assets/js/toastr/toastr.min.js', array('jquery'), NJT_FS_BN_VERSION);
209
210 wp_register_style('file_manager_admin_css',NJT_FS_BN_PLUGIN_URL . 'assets/css/file_manager_admin.css');
211 wp_enqueue_style('file_manager_admin_css');
212 wp_enqueue_script('file_manager_admin', NJT_FS_BN_PLUGIN_URL . 'assets/js/file_manager_admin.js', array('jquery'), NJT_FS_BN_VERSION, true);
213
214 //js load elFinder
215 wp_enqueue_script('njt_fs_elFinder', plugins_url('/lib/js/elfinder.min.js', __FILE__));
216
217 wp_enqueue_script('njt_fs_elfinder_editor', plugins_url('/lib/js/extras/editors.default.js', __FILE__));
218 //js load fm_locale
219 if(isset($this->options['njt_fs_file_manager_settings']['fm_locale'])) {
220 $locale = $this->options['njt_fs_file_manager_settings']['fm_locale'];
221 if($locale != 'en') {
222 wp_enqueue_script( 'njt_fs_fma_lang', plugins_url('lib/js/i18n/elfinder.'.$locale.'.js', __FILE__));
223 }
224 }
225
226 wp_localize_script('njt_fs_elFinder', 'wpData', array(
227 'admin_ajax' => admin_url('admin-ajax.php'),
228 'nonce' => wp_create_nonce("njt-fs-file-manager-admin"),
229 'PLUGIN_URL' => NJT_FS_BN_PLUGIN_URL .'includes/File_manager/lib/',
230 'PLUGIN_PATH' => NJT_FS_BN_PLUGIN_PATH.'includes/File_manager/lib/',
231 'PLUGIN_DIR'=> NJT_FS_BN_PLUGIN_DIR,
232 'ABSPATH'=> str_replace("\\", "/", ABSPATH)
233
234 ));
235 }
236 }
237
238 //File manager connector function
239
240 public function fsConnector()
241 {
242 if( isset( $_POST ) && !empty( $_POST ) && ! wp_verify_nonce( $_POST['nonce'] ,'file-manager-security-token') ) wp_die();
243 $uploadMaxSize = isset($this->options['njt_fs_file_manager_settings']['upload_max_size']) && !empty($this->options['njt_fs_file_manager_settings']['upload_max_size']) ? $this->options['njt_fs_file_manager_settings']['upload_max_size'] : 0;
244
245 $opts = array(
246 'bind' => array(
247 'put.pre' => array(new \FileManagerHelper, 'madeStripcslashesFile'), // Check endcode when save file.
248 ),
249 'roots' => array(
250 array(
251 'driver' => 'LocalFileSystem',
252 'path' => isset($this->options['njt_fs_file_manager_settings']['root_folder_path']) && !empty($this->options['njt_fs_file_manager_settings']['root_folder_path']) ? $this->options['njt_fs_file_manager_settings']['root_folder_path'] : ABSPATH,
253 'URL' => isset($this->options['njt_fs_file_manager_settings']['root_folder_url']) && !empty($this->options['njt_fs_file_manager_settings']['root_folder_url']) ? $this->options['njt_fs_file_manager_settings']['root_folder_url'] : site_url(),
254 'trashHash' => '', // default is empty, when not enable trash
255 'uploadMaxSize' => $uploadMaxSize .'M',
256 'winHashFix' => DIRECTORY_SEPARATOR !== '/',
257 'uploadDeny' => array(),
258 'uploadAllow' => array('all'),
259 'uploadOrder' => array('deny', 'allow'),
260 'disabled' => array(''),
261 'acceptedName' => 'validName',
262 'attributes' => array() // default is empty
263 ),
264 ),
265 );
266 // .htaccess
267 if(isset($this->options['njt_fs_file_manager_settings']['enable_htaccess']) && ($this->options['njt_fs_file_manager_settings']['enable_htaccess'] == '1')) {
268 $attributes = array(
269 'pattern' => '/.htaccess/',
270 'read' => false,
271 'write' => false,
272 'hidden' => true,
273 'locked' => false
274 );
275 array_push($opts['roots'][0]['attributes'], $attributes);
276 }
277
278 //Enable Trash
279 if(isset($this->options['njt_fs_file_manager_settings']['enable_trash']) && ($this->options['njt_fs_file_manager_settings']['enable_trash'] == '1')) {
280 $trash = array(
281 'id' => '1',
282 'driver' => 'Trash',
283 'path' => NJT_FS_BN_PLUGIN_PATH.'includes/File_manager/lib/files/.trash/',
284 'tmbURL' => site_url() . '/includes/File_manager/lib/files/.trash/.tmb',
285 'winHashFix' => DIRECTORY_SEPARATOR !== '/',
286 'uploadDeny' => array(),
287 'uploadAllow' => array('all'),
288 'uploadOrder' => array('deny', 'allow'),
289 'acceptedName' => 'validName',
290 'attributes' => array(
291 array(
292 'pattern' => '/.tmb/',
293 'read' => false,
294 'write' => false,
295 'hidden' => true,
296 'locked' => false
297 ),
298 array(
299 'pattern' => '/.gitkeep/',
300 'read' => false,
301 'write' => false,
302 'hidden' => true,
303 'locked' => false
304 )
305 )
306 );
307 $opts['roots'][0]['trashHash'] = 't1_Lw';
308 $opts['roots'][1] = $trash;
309 }
310
311 //Start --setting User Role Restrictions
312 $user = wp_get_current_user();
313 $userRoles = $user && $user->roles && $user->roles[0] ? $user->roles[0] : '';
314
315 //Disable Operations
316 if(!empty($this->options['njt_fs_file_manager_settings']['list_user_role_restrictions'][$this->userRole]['list_user_restrictions_alow_access'])){
317 $opts['roots'][0]['disabled'] = $this->options['njt_fs_file_manager_settings']['list_user_role_restrictions'][$this->userRole]['list_user_restrictions_alow_access'];
318 }
319 //Creat root path for user
320 if(!empty($this->options['njt_fs_file_manager_settings']['list_user_role_restrictions'][$this->userRole]['private_folder_access'])){
321 $opts['roots'][0]['path'] = $this->options['njt_fs_file_manager_settings']['list_user_role_restrictions'][$this->userRole]['private_folder_access'] .'/';
322 }
323
324 //Creat url root path for user
325 if(!empty($this->options['njt_fs_file_manager_settings']['list_user_role_restrictions'][$this->userRole]['private_url_folder_access'])){
326 $opts['roots'][0]['URL'] = $this->options['njt_fs_file_manager_settings']['list_user_role_restrictions'][$this->userRole]['private_url_folder_access'] .'/';
327 }
328
329 //Folder or File Paths That You want to Hide
330 if(!empty($this->options['njt_fs_file_manager_settings']['list_user_role_restrictions'][$this->userRole]['hide_paths'])){
331 foreach ($this->options['njt_fs_file_manager_settings']['list_user_role_restrictions'][$this->userRole]['hide_paths'] as $key => $value){
332 $arrItemHidePath = array(
333 'pattern' => '~/'.$value.'~',
334 'read' => false,
335 'write' => false,
336 'hidden' => true,
337 'locked' => false
338 );
339 array_push($opts['roots'][0]['attributes'], $arrItemHidePath);
340 };
341 }
342
343 //File extensions which you want to Lock
344 if(!empty($this->options['njt_fs_file_manager_settings']['list_user_role_restrictions'][$this->userRole]['lock_files'])){
345 foreach ($this->options['njt_fs_file_manager_settings']['list_user_role_restrictions'][$this->userRole]['lock_files'] as $key => $value){
346 $arrItemLockFile = array(
347 'pattern' => '/'.$value.'/',
348 'read' => false,
349 'write' => false,
350 'hidden' => false,
351 'locked' => true
352 );
353 array_push($opts['roots'][0]['attributes'], $arrItemLockFile);
354 };
355 }
356
357 //Enter file extensions which can be uploaded
358 if($this->userRole !== 'administrator' && empty($this->options['njt_fs_file_manager_settings']['list_user_role_restrictions'][$this->userRole]['can_upload_mime'])) {
359 $opts['roots'][0]['uploadDeny'] = array('all');
360 $opts['roots'][0]['uploadAllow'] = array('');
361 } else if ( $this->userRole !== 'administrator' && !empty($this->options['njt_fs_file_manager_settings']['list_user_role_restrictions'][$this->userRole]['can_upload_mime'])) {
362 $opts['roots'][0]['uploadDeny'] = array('all');
363 $opts['roots'][0]['uploadAllow'] = array();
364 $arrCanUploadMime = $this->options['njt_fs_file_manager_settings']['list_user_role_restrictions'][$this->userRole]['can_upload_mime'];
365 $mimeTypes = new \FileManagerHelper();
366 $arrMimeTypes = $mimeTypes->getArrMimeTypes();
367 foreach ($arrMimeTypes as $key => $value){
368 if(in_array($key,$arrCanUploadMime)) {
369 $explodeValue = explode(',',$value);
370 foreach($explodeValue as $item) {
371 array_push($opts['roots'][0]['uploadAllow'], $item );
372 }
373 }
374
375 };
376 foreach ($arrCanUploadMime as $value){
377 if(strpos($value,"x-conference") !== false
378 || strpos($value,"video") !== false
379 || strpos($value,"text") !== false
380 || strpos($value,"model") !== false
381 || strpos($value,"message") !== false
382 || strpos($value,"image") !== false
383 || strpos($value,"font") !== false
384 || strpos($value,"chemical") !== false
385 || strpos($value,"audio") !== false
386 || strpos($value,"application") !== false
387 ) {
388 array_push($opts['roots'][0]['uploadAllow'], $value );
389 }
390 }
391
392 } else {
393 $opts['roots'][0]['uploadDeny'] = array();
394 $opts['roots'][0]['uploadAllow'] = array('all');
395 }
396 //End --setting User Role Restrictions
397
398 $connector = new \elFinderConnector(new \elFinder($opts));
399 $connector->run();
400 wp_die();
401 }
402
403 public function selectorThemes()
404 {
405 if( ! wp_verify_nonce( $_POST['nonce'] ,'njt-fs-file-manager-admin')) wp_die();
406 check_ajax_referer('njt-fs-file-manager-admin', 'nonce', true);
407
408 $themesValue = sanitize_text_field ($_POST['themesValue']);
409 $selectorThemes = get_option('njt_fs_selector_themes');
410 if (empty($selectorThemes[$this->userRole])) {
411 $selectorThemes[$this->userRole]['themesValue'] = 'Default';
412 update_option('njt_fs_selector_themes', $selectorThemes);
413 }
414
415 if ($selectorThemes[$this->userRole]['themesValue'] != $themesValue) {
416 $selectorThemes[$this->userRole]['themesValue'] = $themesValue;
417 update_option('njt_fs_selector_themes', $selectorThemes);
418 }
419 $selected_themes = get_option('njt_fs_selector_themes');
420 $linkThemes = plugins_url('/lib/themes/' . $selected_themes[$this->userRole]['themesValue'] . '/css/theme.css', __FILE__);
421 wp_send_json_success($linkThemes);
422 wp_die();
423 }
424
425 public function saveOptions()
426 {
427 //if(isset($_POST['njt-settings-form-submit'])) {
428 update_option('njt_fs_settings', $this->options);
429 // if($u) {
430 // $this->f('?page=njt-fs-filemanager-settings&status=1');
431 // } else {
432 // $this->f('?page=njt-fs-filemanager-settings&status=2');
433 // }
434 // }
435 }
436
437 public function f($u) {
438 echo '<script>';
439 echo 'window.location.href="'.$u.'"';
440 echo '</script>';
441 }
442
443 public function getArrRoleRestrictions()
444 {
445 if(!wp_verify_nonce( $_POST['nonce'] ,'njt-fs-file-manager-admin')) wp_die();
446 check_ajax_referer('njt-fs-file-manager-admin', 'nonce', true);
447 $valueUserRole = filter_var($_POST['valueUserRole']) ? sanitize_text_field ($_POST['valueUserRole']) : '';
448 $arrRestrictions = !empty($this->options['njt_fs_file_manager_settings']['list_user_role_restrictions']) ? $this->options['njt_fs_file_manager_settings']['list_user_role_restrictions'] : array();
449 $dataArrRoleRestrictions = array (
450 'disable_operations' => implode(",", !empty($arrRestrictions[$valueUserRole]['list_user_restrictions_alow_access']) ? $arrRestrictions[$valueUserRole]['list_user_restrictions_alow_access'] : array()),
451 'private_folder_access' => !empty($arrRestrictions[$valueUserRole]['private_folder_access']) ? str_replace("\\\\", "/", trim($arrRestrictions[$valueUserRole]['private_folder_access'])) : '',
452 'private_url_folder_access' => !empty($arrRestrictions[$valueUserRole]['private_url_folder_access']) ? str_replace("\\\\", "/", trim($arrRestrictions[$valueUserRole]['private_url_folder_access'])) : '',
453 'hide_paths' => implode(',', !empty($arrRestrictions[$valueUserRole]['hide_paths']) ? $arrRestrictions[$valueUserRole]['hide_paths'] : array()),
454 'lock_files' => implode(',', !empty($arrRestrictions[$valueUserRole]['lock_files']) ? $arrRestrictions[$valueUserRole]['lock_files'] : array()),
455 'can_upload_mime' => implode(',', !empty($arrRestrictions[$valueUserRole]['can_upload_mime']) ? $arrRestrictions[$valueUserRole]['can_upload_mime'] : array())
456 );
457 wp_send_json_success($dataArrRoleRestrictions);
458 wp_die();
459 }
460
461 public function njt_fs_saveSetting()
462 {
463 if( ! wp_verify_nonce( $_POST['nonce'] ,'njt-fs-file-manager-admin')) wp_die();
464 check_ajax_referer('njt-fs-file-manager-admin', 'nonce', true);
465
466 $root_folder_path = filter_var($_POST['root_folder_path'], FILTER_SANITIZE_STRING) ? str_replace("\\\\", "/", trim($_POST['root_folder_path'])) : '';
467 $root_folder_url = filter_var($_POST['root_folder_url'], FILTER_SANITIZE_STRING) ? str_replace("\\\\", "/", trim($_POST['root_folder_url'])) : site_url();
468 $list_user_alow_access = filter_var($_POST['list_user_alow_access'], FILTER_SANITIZE_STRING) ? explode(',',$_POST['list_user_alow_access']) : array();
469 $upload_max_size = filter_var($_POST['upload_max_size'], FILTER_SANITIZE_STRING) ? sanitize_text_field(trim($_POST['upload_max_size'])) : 0;
470 $fm_locale = filter_var($_POST['fm_locale'], FILTER_SANITIZE_STRING) ? sanitize_text_field($_POST['fm_locale']) : 'en';
471 $enable_htaccess = isset($_POST['enable_htaccess']) && $_POST['enable_htaccess'] == 'true' ? 1 : 0;
472 $enable_trash = isset($_POST['enable_trash']) && $_POST['enable_trash'] == 'true' ? 1 : 0;
473 //save options
474 $this->options['njt_fs_file_manager_settings']['root_folder_path'] = $root_folder_path;
475 $this->options['njt_fs_file_manager_settings']['root_folder_url'] = $root_folder_url;
476 $this->options['njt_fs_file_manager_settings']['list_user_alow_access'] = $list_user_alow_access;
477 $this->options['njt_fs_file_manager_settings']['upload_max_size'] = $upload_max_size;
478 $this->options['njt_fs_file_manager_settings']['fm_locale'] = $fm_locale;
479 $this->options['njt_fs_file_manager_settings']['enable_htaccess'] = $enable_htaccess;
480 $this->options['njt_fs_file_manager_settings']['enable_trash'] = $enable_trash;
481 //update options
482 update_option('njt_fs_settings', $this->options);
483 wp_send_json_success(get_option('njt_fs_settings'));
484 wp_die();
485 }
486
487 public function njt_fs_saveSettingRestrictions() {
488 if( ! wp_verify_nonce( $_POST['nonce'] ,'njt-fs-file-manager-admin')) wp_die();
489 check_ajax_referer('njt-fs-file-manager-admin', 'nonce', true);
490
491 if(! $_POST['njt_fs_list_user_restrictions']) wp_die();
492
493 $njt_fs_list_user_restrictions = $_POST['njt_fs_list_user_restrictions'];
494 $list_user_restrictions_alow_access = filter_var($_POST['list_user_restrictions_alow_access'], FILTER_SANITIZE_STRING) ? explode(',', $_POST['list_user_restrictions_alow_access']) : array();
495 $private_folder_access = filter_var($_POST['private_folder_access'], FILTER_SANITIZE_STRING) ? str_replace("\\\\", "/", trim($_POST['private_folder_access'])) : '';
496 $private_url_folder_access = filter_var($_POST['private_url_folder_access'], FILTER_SANITIZE_STRING) ? str_replace("\\\\", "/", trim($_POST['private_url_folder_access'])) : '';
497 $hide_paths = filter_var($_POST['hide_paths'], FILTER_SANITIZE_STRING) ? explode('|', preg_replace('/\s+/', '', $_POST['hide_paths'])) : array();
498 $lock_files = filter_var($_POST['lock_files'], FILTER_SANITIZE_STRING) ? explode('|', preg_replace('/\s+/', '', $_POST['lock_files'])) : array();
499 $can_upload_mime = filter_var($_POST['can_upload_mime'], FILTER_SANITIZE_STRING) ? explode(',', preg_replace('/\s+/', '', $_POST['can_upload_mime'])) : array();
500
501 //save options
502 $this->options['njt_fs_file_manager_settings']['list_user_role_restrictions'][$njt_fs_list_user_restrictions]['list_user_restrictions_alow_access'] = $list_user_restrictions_alow_access;
503 $this->options['njt_fs_file_manager_settings']['list_user_role_restrictions'][$njt_fs_list_user_restrictions]['private_folder_access'] = $private_folder_access;
504 $this->options['njt_fs_file_manager_settings']['list_user_role_restrictions'][$njt_fs_list_user_restrictions]['private_url_folder_access'] = $private_url_folder_access;
505 $this->options['njt_fs_file_manager_settings']['list_user_role_restrictions'][$njt_fs_list_user_restrictions]['hide_paths'] = $hide_paths;
506 $this->options['njt_fs_file_manager_settings']['list_user_role_restrictions'][$njt_fs_list_user_restrictions]['lock_files'] = $lock_files;
507 $this->options['njt_fs_file_manager_settings']['list_user_role_restrictions'][$njt_fs_list_user_restrictions]['can_upload_mime'] = $can_upload_mime;
508 //update options
509 update_option('njt_fs_settings', $this->options);
510 wp_send_json_success(get_option('njt_fs_settings'));
511 wp_die();
512 }
513
514 }