From 2a97b26cfeb7c83d6d7ea7b65f268652b6037c0f Mon Sep 17 00:00:00 2001 From: Pablo Aragon Date: Thu, 9 Mar 2023 15:14:47 +0100 Subject: [PATCH] Admin tools --- pandora_console/extensions/db_status.php | 102 +++++++++--- pandora_console/extensions/dbmanager.php | 124 +++++++------- .../extensions/dbmanager/dbmanager.css | 5 +- .../extensions/extension_uploader.php | 67 ++++++-- pandora_console/godmode/extensions.php | 63 ++++++- .../godmode/setup/file_manager.php | 2 +- pandora_console/godmode/setup/news.php | 154 ++++++++++++++---- pandora_console/include/ajax/events.php | 4 + .../include/class/EventSound.class.php | 65 +++++--- pandora_console/include/functions_html.php | 4 + pandora_console/include/styles/pandora.css | 1 + 11 files changed, 436 insertions(+), 155 deletions(-) diff --git a/pandora_console/extensions/db_status.php b/pandora_console/extensions/db_status.php index 98b95783be..25965efb0c 100755 --- a/pandora_console/extensions/db_status.php +++ b/pandora_console/extensions/db_status.php @@ -21,13 +21,23 @@ function extension_db_status() $db_name = get_parameter('db_name', ''); $db_status_execute = (bool) get_parameter('db_status_execute', false); - ui_print_page_header( + ui_print_standard_header( __('DB Schema check'), 'images/extensions.png', false, 'db_status_tab', true, - '' + [], + [ + [ + 'link' => '', + 'label' => __('Admin tools'), + ], + [ + 'link' => '', + 'label' => __('Run test'), + ], + ] ); if (!is_user_admin($config['id_user'])) { @@ -46,38 +56,86 @@ function extension_db_status() __('At the moment the checks is for MySQL/MariaDB.') ); - echo "
"; + echo ""; echo '
'; echo ''.__('DB settings').''; $table = new stdClass(); $table->data = []; $row = []; - $row[] = __('DB User with privileges'); - $row[] = html_print_input_text('db_user', $db_user, '', 50, 255, true); - $row[] = __('DB Password for this user'); - $row[] = html_print_input_password('db_password', $db_password, '', 50, 255, true); + $row[] = html_print_label_input_block( + __('DB User with privileges'), + html_print_input_text( + 'db_user', + $db_user, + '', + 50, + 255, + true, + false, + false, + '', + 'w100p mrgn_top_10px' + ) + ); + $row[] = html_print_label_input_block( + __('DB Password for this user'), + html_print_input_password( + 'db_password', + $db_password, + '', + 50, + 255, + true, + false, + false, + 'w100p mrgn_top_10px' + ) + ); $table->data[] = $row; $row = []; - $row[] = __('DB Hostname'); - $row[] = html_print_input_text('db_host', $db_host, '', 50, 255, true); - $row[] = __('DB Name (temporal for testing)'); - $row[] = html_print_input_text('db_name', $db_name, '', 50, 255, true); + $row[] = html_print_label_input_block( + __('DB Hostname'), + html_print_input_text( + 'db_host', + $db_host, + '', + 50, + 255, + true, + false, + false, + '', + 'w100p mrgn_top_10px' + ) + ); + $row[] = html_print_label_input_block( + __('DB Name (temporal for testing)'), + html_print_input_text( + 'db_name', + $db_name, + '', + 50, + 255, + true, + false, + false, + '', + 'w100p mrgn_top_10px' + ) + ); $table->data[] = $row; html_print_table($table); echo '
'; - html_print_div( - [ - 'class' => 'action-buttons', - 'content' => html_print_submit_button( - __('Execute Test'), - 'submit', - false, - [ 'icon' => 'cog' ], - true - ), - ] + html_print_action_buttons( + html_print_submit_button( + __('Execute Test'), + 'submit', + false, + [ 'icon' => 'cog' ], + true + ) ); html_print_input_hidden('db_status_execute', 1); diff --git a/pandora_console/extensions/dbmanager.php b/pandora_console/extensions/dbmanager.php index 3aacc776a0..1ec40b79f1 100644 --- a/pandora_console/extensions/dbmanager.php +++ b/pandora_console/extensions/dbmanager.php @@ -132,47 +132,37 @@ function dbmgr_extension_main() echo $warning_message; } + ui_print_warning_message( + __( + "This is an advanced extension to interface with %s database directly from WEB console + using native SQL sentences. Please note that you can damage your %s installation + if you don't know exactly what are you are doing, + this means that you can severily damage your setup using this extension. + This extension is intended to be used only by experienced users + with a depth knowledge of %s internals.", + get_product_name(), + get_product_name(), + get_product_name() + ) + ); + echo ""; $table = new stdClass(); $table->id = 'db_interface'; - $table->class = 'databox'; + $table->class = 'databox no_border filter-table-adv'; $table->width = '100%'; $table->data = []; - $table->head = []; $table->colspan = []; - $table->rowstyle = []; + $table->style[0] = 'width: 30%;'; + $table->style[1] = 'width: 70%;'; - $table->colspan[0][0] = 2; $table->colspan[1][0] = 2; - $table->rowspan[2][0] = 3; - $table->rowclass[0] = 'notify'; - $table->rowclass[3] = 'pdd_5px'; - $table->rowclass[3] = 'flex-content-right'; - $table->rowclass[4] = 'flex-content-right'; - - $data[0][0] = __( - "This is an advanced extension to interface with %s database directly from WEB console - using native SQL sentences. Please note that you can damage your %s installation - if you don't know exactly what are you are doing, - this means that you can severily damage your setup using this extension. - This extension is intended to be used only by experienced users - with a depth knowledge of %s internals.", - get_product_name(), - get_product_name(), - get_product_name() - ); - - $data[1][0] = "Some samples of usage:
SHOW STATUS;
DESCRIBE tagente
SELECT * FROM tserver
UPDATE tagente SET id_grupo = 15 WHERE nombre LIKE '%194.179%'
"; - - $data[2][0] = html_print_textarea( - 'sql', - 5, - 50, - html_entity_decode($sql, ENT_QUOTES), - '', - true + $data[0][0] = "Some samples of usage:
SHOW STATUS;
DESCRIBE tagente
SELECT * FROM tserver
UPDATE tagente SET id_grupo = 15 WHERE nombre LIKE '%194.179%'
"; + $data[0][0] = html_print_label_input_block( + __('Some samples of usage:'), + "
SHOW STATUS;
DESCRIBE tagente
SELECT * FROM tserver
UPDATE tagente SET id_grupo = 15 WHERE nombre LIKE '%194.179%'
" ); if (is_metaconsole() === true) { @@ -191,35 +181,57 @@ function dbmgr_extension_main() $servers = []; } - $data[3][2] = html_print_input( - [ - 'name' => 'node_id', - 'type' => 'select', - 'fields' => $servers, - 'selected' => $node_id, - 'nothing' => __('This metaconsole'), - 'nothing_value' => -1, - 'return' => true, - 'label' => _('Select query target'), - ] + $data[0][1] = html_print_label_input_block( + __('Select query target'), + html_print_select( + $servers, + 'node_id', + $node_id, + '', + __('This metaconsole'), + -1, + true, + false, + false, + 'w40p', + false, + 'width: 40%;' + ) ); } - $data[4][2] = html_print_div( - [ - 'class' => 'action-buttons', - 'content' => html_print_submit_button( - __('Execute SQL'), - '', - false, - [ 'icon' => 'cog' ], - true - ), - ] + $data[1][0] = html_print_textarea( + 'sql', + 3, + 50, + html_entity_decode($sql, ENT_QUOTES), + 'placeholder="'.__('Type your query here...').'"', + true, + 'w100p' + ); + + $execute_button = html_print_submit_button( + __('Execute SQL'), + '', + false, + [ 'icon' => 'cog' ], + true ); $table->data = $data; - html_print_table($table); + // html_print_table($table); + html_print_action_buttons($execute_button); + ui_toggle( + html_print_table($table, true), + ''.__('SQL query').'', + __('SQL query'), + 'query', + false, + false, + '', + 'white-box-content no_border', + 'box-flat white_table_graph fixed_filter_bar' + ); echo '
'; // Processing SQL Code. @@ -227,10 +239,6 @@ function dbmgr_extension_main() return; } - echo '
'; - echo '
'; - echo '
'; - try { if (\is_metaconsole() === true && $node_id !== -1) { $node = new Node($node_id); diff --git a/pandora_console/extensions/dbmanager/dbmanager.css b/pandora_console/extensions/dbmanager/dbmanager.css index 1e44dce3a8..1882b71e92 100644 --- a/pandora_console/extensions/dbmanager/dbmanager.css +++ b/pandora_console/extensions/dbmanager/dbmanager.css @@ -24,7 +24,6 @@ table.dbmanager th { } textarea { - min-height: 50px; - height: 50px; - width: 95%; + width: 100% !important; + max-width: 100% !important; } diff --git a/pandora_console/extensions/extension_uploader.php b/pandora_console/extensions/extension_uploader.php index f5447703e8..d989a3661b 100644 --- a/pandora_console/extensions/extension_uploader.php +++ b/pandora_console/extensions/extension_uploader.php @@ -25,13 +25,28 @@ function extension_uploader_extensions() return; } - ui_print_page_header( - __('Uploader extension'), + // Header. + ui_print_standard_header( + __('Extensions'), 'images/extensions.png', false, '', true, - '' + [], + [ + [ + 'link' => '', + 'label' => __('Admin tools'), + ], + [ + 'link' => '', + 'label' => __('Extension manager'), + ], + [ + 'link' => '', + 'label' => __('Uploader extension'), + ], + ] ); $upload = (bool) get_parameter('upload', 0); @@ -77,20 +92,52 @@ function extension_uploader_extensions() $table = new stdClass(); $table->width = '100%'; - $table->class = 'databox filters'; + $table->class = 'databox filters filter-table-adv'; + $table->size[0] = '20%'; + $table->size[1] = '20%'; + $table->size[2] = '60%'; $table->data = []; - $table->data[0][0] = __('Upload extension'); - $table->data[0][1] = html_print_input_file('extension', true).ui_print_help_tip(__('Upload the extension as a zip file.'), true); + + $table->data[0][0] = html_print_label_input_block( + __('Upload extension').ui_print_help_tip(__('Upload the extension as a zip file.'), true), + html_print_input_file( + 'extension', + true, + [ + 'required' => true, + 'accept' => '.zip', + ] + ) + ); + if (enterprise_installed()) { - $table->data[0][2] = __('Upload enterprise extension').' '.html_print_checkbox('upload_enterprise', 1, false, true); + $table->data[0][1] = html_print_label_input_block( + __('Upload enterprise extension'), + html_print_checkbox( + 'upload_enterprise', + 1, + false, + true + ) + ); + } else { + $table->data[0][1] = ''; } + $table->data[0][2] = ''; + echo "
"; html_print_table($table); - echo "
"; html_print_input_hidden('upload', 1); - html_print_submit_button(__('Upload'), 'submit', false, 'class="sub add"'); - echo '
'; + html_print_action_buttons( + html_print_submit_button( + __('Upload'), + 'submit', + false, + ['icon' => 'wand'], + true + ) + ); echo '
'; } diff --git a/pandora_console/godmode/extensions.php b/pandora_console/godmode/extensions.php index 966ecd0ce7..8faef70d3e 100644 --- a/pandora_console/godmode/extensions.php +++ b/pandora_console/godmode/extensions.php @@ -24,8 +24,29 @@ if (! check_acl($config['id_user'], 0, 'PM')) { exit; } -// Header -ui_print_page_header(__('Extensions').' » '.__('Defined extensions'), 'images/extensions.png', false, '', true, ''); +// Header. +ui_print_standard_header( + __('Extensions'), + 'images/extensions.png', + false, + '', + true, + [], + [ + [ + 'link' => '', + 'label' => __('Admin tools'), + ], + [ + 'link' => '', + 'label' => __('Extension manager'), + ], + [ + 'link' => '', + 'label' => __('Defined extensions'), + ], + ] +); if (count($config['extensions']) == 0) { $extensions = extensions_get_extension_info(); @@ -132,7 +153,7 @@ if ($disabled != '') { $extensions = extensions_get_extension_info(); $table = new StdClass; -$table->width = '98%'; +$table->width = '100%'; $table->head = []; $table->head[] = __('File'); @@ -146,7 +167,7 @@ $table->head[] = __('Login Function'); $table->head[] = __('Agent operation tab'); $table->head[] = __('Agent godmode tab'); $table->head[] = __('Operation'); -$table->width = '100%'; + $table->class = 'info_table'; $table->align = []; @@ -254,9 +275,39 @@ foreach ($extensions as $file => $extension) { if ($file != 'update_manager.php') { $table->cellclass[][10] = 'table_action_buttons'; if (!$extension['enabled']) { - $data[] = ''.html_print_image('images/cross.disabled.png', true, ['class' => 'filter_none']).''.' '.html_print_image('images/lightbulb_off.png', true, ['class' => 'filter_none']).''; + $data[] = html_print_menu_button( + [ + 'href' => 'index.php?sec=godmode/extensions&sec2=godmode/extensions&enterprise='.(int) $extension['enterprise'].'&delete='.$file, + 'image' => 'images/cross.disabled.png', + 'title' => __('Delete'), + 'onClick' => 'if (!confirm(\''.__('Are you sure?').'\')) return false;', + ], + true + ).html_print_menu_button( + [ + 'href' => 'index.php?sec=godmode/extensions&sec2=godmode/extensions&enterprise='.(int) $extension['enterprise'].'&enabled='.$file, + 'image' => 'images/lightbulb_off.png', + 'title' => __('Delete'), + ], + true + ); } else { - $data[] = ''.html_print_image('images/cross.png', true, ['class' => 'invert_filter']).''.' '.html_print_image('images/lightbulb.png', true).''; + $data[] = html_print_menu_button( + [ + 'href' => 'index.php?sec=godmode/extensions&sec2=godmode/extensions&enterprise='.(int) $extension['enterprise'].'&delete='.$file, + 'image' => 'images/cross.png', + 'title' => __('Delete'), + 'onClick' => 'if (!confirm(\''.__('Are you sure?').'\')) return false;', + ], + true + ).html_print_menu_button( + [ + 'href' => 'index.php?sec=godmode/extensions&sec2=godmode/extensions&enterprise='.(int) $extension['enterprise'].'&disabled='.$file, + 'image' => 'images/lightbulb.png', + 'title' => __('Delete'), + ], + true + ); } } else { $data[] = ''; diff --git a/pandora_console/godmode/setup/file_manager.php b/pandora_console/godmode/setup/file_manager.php index f54cf7f7f6..dbbd2674be 100644 --- a/pandora_console/godmode/setup/file_manager.php +++ b/pandora_console/godmode/setup/file_manager.php @@ -80,7 +80,7 @@ if (empty($directory) === true) { $real_directory = realpath($config['homedir'].'/'.$directory); -echo '

'.__('Index of %s', io_safe_input($directory)).'

'; +echo '

'.__('Index of %s', io_safe_input($directory)).'

'; $upload_file = (bool) get_parameter('upload_file'); $create_text_file = (bool) get_parameter('create_text_file'); diff --git a/pandora_console/godmode/setup/news.php b/pandora_console/godmode/setup/news.php index 633e8f224f..efbf574779 100644 --- a/pandora_console/godmode/setup/news.php +++ b/pandora_console/godmode/setup/news.php @@ -170,46 +170,118 @@ if ((isset($_GET['form_add'])) || (isset($_GET['form_edit']))) { $table->id = 'news'; $table->cellpadding = 4; $table->cellspacing = 4; - $table->class = 'databox filters'; + $table->class = 'databox filters filter-table-adv'; $table->head = []; $table->data = []; - $table->style[0] = 'font-weight: bold;'; - $table->style[1] = 'font-weight: bold;'; - $table->style[2] = 'font-weight: bold;'; - $table->style[3] = 'font-weight: bold;'; - $table->style[4] = 'font-weight: bold;'; + $table->size[0] = '33%'; + $table->size[1] = '33%'; + $table->colspan[2][0] = 2; + $table->rowclass[2] = 'w100p'; $data = []; - $data[0] = __('Subject').'
'; - $data[0] .= ''; + $data[0] = html_print_label_input_block( + __('Subject'), + html_print_input_text( + 'subject', + $subject, + '', + 35, + 255, + true + ) + ); - $data[1] = __('Group').'
'; - $data[1] .= '
'; - $data[1] .= html_print_select_groups($config['id_user'], 'ER', users_can_manage_group_all(), 'id_group', $id_group, '', '', 0, true, false, false, ''); - $data[1] .= '
'; + $data[1] = html_print_label_input_block( + __('Group'), + html_print_select_groups( + $config['id_user'], + 'ER', + users_can_manage_group_all(), + 'id_group', + $id_group, + '', + '', + 0, + true, + false, + false, + 'w100p', + false, + 'width: 100%;' + ) + ); + $table->data[] = $data; - $data[2] = __('Modal screen').'
'; - $data[2] .= html_print_checkbox_extended('modal', 1, $modal, false, '', 'class="mrgn_top_5 mrg_btt_7"', true); + $data = []; + $data[0] = html_print_label_input_block( + __('Modal screen'), + html_print_checkbox_extended( + 'modal', + 1, + $modal, + false, + '', + 'class="w100p"', + true + ) + ); - $data[3] = __('Expire').'
'; - $data[3] .= html_print_checkbox_extended('expire', 1, $expire, false, '', 'class="mrgn_top_5 mrg_btt_7"', true); - - $data[4] = __('Expiration').'
'; - $data[4] .= html_print_input_text('expire_date', $expire_date, '', 12, 10, true).' '; - $data[4] .= html_print_input_text('expire_time', $expire_time, '', 10, 7, true).' '; + $data[1] = '
'.html_print_label_input_block( + __('Expire'), + html_print_checkbox_extended( + 'expire', + 1, + $expire, + false, + '', + 'class="w100p"', + true + ), + ['div_class' => 'display-grid'] + ); + $data[1] .= html_print_label_input_block( + __('Expiration'), + '
'.html_print_input_text( + 'expire_date', + $expire_date, + '', + 12, + 10, + true + ).' '.html_print_input_text( + 'expire_time', + $expire_time, + '', + 10, + 7, + true + ).'
', + [ + 'div_class' => 'display-grid mrgn_lft_20px', + 'div_id' => 'news-0-4', + ] + ).'
'; $table->rowclass[] = ''; $table->data[] = $data; $data = []; - $data[0] = __('Text').'
'; - $data[0] .= html_print_textarea('text', 25, 15, $text, '', true); - $table->rowclass[] = ''; - $table->colspan[1][0] = 5; + $data[0] = html_print_label_input_block( + __('Text'), + html_print_textarea( + 'text', + 25, + 100, + $text, + '', + true, + 'w100p' + ) + ); $table->data[] = $data; - echo '
'; + echo ''; if ($creation_mode == 1) { echo ""; } else { @@ -228,11 +300,25 @@ if ((isset($_GET['form_add'])) || (isset($_GET['form_edit']))) { echo ""; echo "
"; if (isset($_GET['form_add'])) { - echo ""; + $submit_button = html_print_submit_button( + __('Create'), + 'crtbutton', + false, + ['icon' => 'wand'], + true + ); } else { - echo ""; + $submit_button = html_print_submit_button( + __('Update'), + 'crtbutton', + false, + ['icon' => 'wand'], + true + ); } + html_print_action_buttons($submit_button); + echo '
'; } else { $rows = db_get_all_rows_in_table('tnews', 'timestamp'); @@ -293,11 +379,17 @@ if ((isset($_GET['form_add'])) || (isset($_GET['form_edit']))) { echo ''; } - echo ""; - echo "
"; echo "
"; - echo ""; - echo '
'; + html_print_action_buttons( + html_print_submit_button( + __('Add'), + 'form_add', + false, + ['icon' => 'wand'], + true + ) + ); + echo ''; } /* diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index ccdb086f9a..70d6cba47e 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -791,6 +791,10 @@ if ($save_filter_modal) { $table->rowid[1] = 'save_filter_row1'; $table->size[0] = '50%'; $table->size[1] = '50%'; + $table->rowclass[1] = 'flex'; + $table->rowclass[2] = 'flex'; + $table->rowclass[3] = 'flex'; + $table->rowclass[4] = 'flex'; $data[0] = ''.__('Filter name').''.$jump; $data[0] .= html_print_input_text('id_name', '', '', 15, 255, true); if (is_metaconsole()) { diff --git a/pandora_console/include/class/EventSound.class.php b/pandora_console/include/class/EventSound.class.php index b943e9cce1..283d99d296 100644 --- a/pandora_console/include/class/EventSound.class.php +++ b/pandora_console/include/class/EventSound.class.php @@ -239,38 +239,53 @@ class EventSound extends HTML ui_require_css_file('discovery'); if ($tab === 'add') { - echo '
'; + echo ''; $table = new stdClass(); $table->width = '100%'; - $table->class = 'databox filters'; + $table->class = 'databox filters filter-table-adv'; $table->data = []; - $table->data[0][0] = __('Name:'); + $table->size[0] = '50%'; + $table->size[1] = '50%'; - $table->data[0][1] = html_print_input_text( - 'name', - '', - '', - 80, - 100, - true, - false, - true + $table->data[0][0] = html_print_label_input_block( + __('Name:'), + html_print_input_text( + 'name', + '', + '', + 80, + 100, + true, + false, + true + ) ); - $table->data[1][0] = __('WAV Sound'); - $table->data[1][1] = html_print_input_file('file', true, ['required' => true]); + $table->data[0][1] = html_print_label_input_block( + __('WAV Sound'), + html_print_input_file( + 'file', + true, + [ + 'required' => true, + 'accept' => 'audio/*', + ] + ) + ); html_print_table($table); - echo '
'; - html_print_submit_button( - __('Create'), - 'save_sound', - false, - 'class="sub wand"' + html_print_action_buttons( + html_print_submit_button( + __('Create'), + 'save_sound', + false, + ['icon' => 'wand'], + true + ) ); - echo '
'; echo '
'; // Load own javascript file. @@ -305,7 +320,7 @@ class EventSound extends HTML [ 'id' => $this->tableId, 'class' => 'info_table', - 'style' => 'width: 100%', + 'style' => 'width: 99%', 'columns' => $columns, 'column_names' => $column_names, 'ajax_url' => $this->ajaxController, @@ -321,7 +336,7 @@ class EventSound extends HTML [ 'label' => __('Free search').ui_print_help_tip(__('Search filter by Name or Sound fields content'), true), 'type' => 'text', - 'class' => 'w200px', + 'class' => 'w70p', 'id' => 'filter_text', 'name' => 'filter_text', ], @@ -333,12 +348,13 @@ class EventSound extends HTML '0' => __('No'), '1' => __('Yes'), ], - 'class' => 'w100px', + 'class' => 'w100p', 'id' => 'active', 'name' => 'active', ], ], ], + 'filter_main_class' => 'box-flat white_table_graph fixed_filter_bar ', ] ); } catch (Exception $e) { @@ -350,6 +366,7 @@ class EventSound extends HTML close_meta_frame(); } + html_print_action_buttons(''); // Load own javascript file. echo $this->loadJS(); } diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 5d6f413573..56a19e4d1d 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -4773,6 +4773,10 @@ function html_print_input_file($name, $return=false, $options=false) if (isset($options['style']) === true) { $output .= ' style="'.$options['style'].'"'; } + + if (isset($options['accept']) === true) { + $output .= ' accept="'.$options['accept'].'"'; + } } // Close input. diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 43e66868bd..fc4acd7488 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -11452,6 +11452,7 @@ form#satellite_conf_edit > fieldset.full-column { background-repeat: no-repeat; background-size: 24px; background-image: url("../../images/enable.svg"); + padding-right: 45px; } .orientation-report {