diff --git a/pandora_console/include/functions_filemanager.php b/pandora_console/include/functions_filemanager.php index 1db21b308a..4fc6dd0b14 100644 --- a/pandora_console/include/functions_filemanager.php +++ b/pandora_console/include/functions_filemanager.php @@ -1,4 +1,5 @@ - function show_create_text_file() { - actions_dialog('create_text_file'); - $("#create_text_file").css("display", "block"); - check_opened_dialog('create_text_file'); - } + function show_create_text_file() { + actions_dialog('create_text_file'); + $("#create_text_file").css("display", "block"); + check_opened_dialog('create_text_file'); + } + function show_upload_file() { actions_dialog('upload_file'); $("#upload_file").css("display", "block"); check_opened_dialog('upload_file'); } - function check_opened_dialog(check_opened){ - if(check_opened !== 'create_folder'){ + function check_opened_dialog(check_opened) { + if (check_opened !== 'create_folder') { if (($("#create_folder").hasClass("ui-dialog-content") && $('#create_folder').dialog('isOpen') === true)) { $('#create_folder').dialog('close'); } } - if(check_opened !== 'create_text_file'){ - if (($("#create_text_file").hasClass("ui-dialog-content") && $('#create_text_file').dialog('isOpen') === true)) { - $('#create_text_file').dialog('close'); + if (check_opened !== 'create_text_file') { + if (($("#create_text_file").hasClass("ui-dialog-content") && $('#create_text_file').dialog('isOpen') === true)) { + $('#create_text_file').dialog('close'); + } } - } - if(check_opened !== 'upload_file'){ + if (check_opened !== 'upload_file') { if (($("#upload_file").hasClass("ui-dialog-content") && $('#upload_file').dialog('isOpen')) === true) { $('#upload_file').dialog('close'); } } } - function actions_dialog(action){ - $('.'+action).addClass('file_table_modal_active'); - var title_action =''; + function actions_dialog(action) { + $('.' + action).addClass('file_table_modal_active'); + var title_action = ''; switch (action) { case 'create_folder': - title_action = ""; + title_action = ""; break; - - case 'create_text_file': - title_action = ""; - break; - + + case 'create_text_file': + title_action = ""; + break; + case 'upload_file': - title_action = ""; + title_action = ""; break; default: break; } - $('#'+action) - .dialog({ - title: title_action, - resizable: true, - draggable: true, - modal: true, - overlay: { - opacity: 0.5, - background: "black" - }, - width: 500, - minWidth: 500, - minHeight: 210, - maxWidth: 800, - maxHeight: 300, - close: function () { - $('.'+action).removeClass('file_table_modal_active'); - } - }).show(); + $('#' + action) + .dialog({ + title: title_action, + resizable: true, + draggable: true, + modal: true, + overlay: { + opacity: 0.5, + background: "black" + }, + width: 500, + minWidth: 500, + minHeight: 210, + maxWidth: 800, + maxHeight: 300, + close: function() { + $('.' + action).removeClass('file_table_modal_active'); + } + }).show(); } - function show_modal_real_path (path) { + function show_modal_real_path(path) { + if (navigator.clipboard && window.isSecureContext) ; + else ; $('#modal_real_path').addClass('file_table_modal_active'); $('#real_path').empty(); $('#real_path').html(path); title_action = ""; $('#modal_real_path') - .dialog({ - title: title_action, - resizable: true, - draggable: true, - modal: true, - overlay: { - opacity: 0.5, - background: "black" - }, - width: 448, - minWidth: 448, - minHeight: 213, - maxWidth: 800, - maxHeight: 300, - close: function () { - $('#modal_real_path').removeClass('file_table_modal_active'); - } - }).show(); + .dialog({ + title: title_action, + resizable: true, + draggable: true, + modal: true, + overlay: { + opacity: 0.5, + background: "black" + }, + width: 448, + minWidth: 448, + minHeight: 213, + maxWidth: 800, + maxHeight: 300, + close: function() { + $('#modal_real_path').removeClass('file_table_modal_active'); + } + }).show(); - $("#submit-submit").on("click",copyToClipboard); + $("#submit-submit").on("click", copyToClipboard); } function copyToClipboard() { - navigator.clipboard.writeText($("#real_path").text()).then(function (){ - $('#modal_real_path').dialog('close'); - }); + if (navigator.clipboard && window.isSecureContext) { + window.navigator.clipboard.writeText($("#real_path").text()).then(function() { + $('#modal_real_path').dialog('close'); + }); + } } '.$data[1].''; + $error_message = __('This file could be executed by any user'); + $error_message .= '. '.__('Make sure it can\'t perform dangerous tasks'); + $data[1] = ''.$data[1].''; } $data[2] = ui_print_timestamp( @@ -753,11 +742,11 @@ function filemanager_file_explorer( $data[3] = ui_format_filesize($fileinfo['size']); } - // Actions buttons - // Delete button. - $data[4] = ''; - $data[4] .= ''; - $typefile = array_pop(explode('.', $fileinfo['name'])); + // Actions buttons + // Delete button. + $data[4] = ''; + $data[4] .= ''; + $typefile = array_pop(explode('.', $fileinfo['name'])); if (is_writable($fileinfo['realpath']) === true && (is_dir($fileinfo['realpath']) === false || count(scandir($fileinfo['realpath'])) < 3) && ($readOnly === false) @@ -805,9 +794,9 @@ function filemanager_file_explorer( $data[4] .= ''.html_print_image('images/book_edit.png', true, ['style' => 'margin-top: 2px;', 'title' => __('Real path'), 'class' => 'invert_filter']).''; } - $data[4] .= ''; + $data[4] .= ''; - array_push($table->data, $data); + array_push($table->data, $data); } } else { ui_print_info_message( @@ -900,7 +889,7 @@ function filemanager_file_explorer( 'content' => html_print_input_file( 'file', true, - [ 'style' => 'border:0; padding:0; width:100%' ] + ['style' => 'border:0; padding:0; width:100%'] ), ], true @@ -985,8 +974,12 @@ function filemanager_file_explorer( // Show Modal Real Path $modal_real_path = "
Real path to plugin execution is:
-
-
".html_print_submit_button(__('Copy'), 'submit', false, 'class="sub next"', true).'
'; +
"; + + if (isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'on' || $_SERVER['SERVER_NAME'] == 'localhost' || $_SERVER['SERVER_NAME'] == '127.0.0.1') { + $modal_real_path .= "
".html_print_submit_button(__('Copy'), 'submit', false, 'class="sub next"', true).'
'; + } + html_print_div( [ 'id' => 'modal_real_path', @@ -1141,4 +1134,4 @@ function filemanager_safe_directory( } return $directory; -} \ No newline at end of file +}