Admin tools

This commit is contained in:
Pablo Aragon 2023-03-09 17:21:18 +01:00
parent cbc05f7ea0
commit d3ed5a93fc
5 changed files with 291 additions and 143 deletions

View File

@ -195,140 +195,183 @@ function extension_api_checker()
); );
} }
ui_print_page_header( // Header.
__('API checker'), ui_print_standard_header(
__('Extensions'),
'images/extensions.png', 'images/extensions.png',
false, false,
'', '',
true, true,
'' [],
[
[
'link' => '',
'label' => __('Admin tools'),
],
[
'link' => '',
'label' => __('Extension manager'),
],
[
'link' => '',
'label' => __('API checker'),
],
]
); );
$table = new stdClass(); $table = new stdClass();
$table->width = '100%';
$table->class = 'databox filters filter-table-adv';
$table->size[0] = '50%';
$table->size[1] = '50%';
$table->data = []; $table->data = [];
$row = []; $row = [];
$row[] = __('IP'); $row[] = html_print_label_input_block(
$row[] = html_print_input_text('ip', $ip, '', 50, 255, true); __('IP'),
html_print_input_text('ip', $ip, '', 50, 255, true)
);
$row[] = html_print_label_input_block(
__('%s Console URL', get_product_name()),
html_print_input_text('pandora_url', $pandora_url, '', 50, 255, true)
);
$table->data[] = $row; $table->data[] = $row;
$row = []; $row = [];
$row[] = __('%s Console URL', get_product_name()); $row[] = html_print_label_input_block(
$row[] = html_print_input_text('pandora_url', $pandora_url, '', 50, 255, true); __('API Token').ui_print_help_tip(__('Use API Token instead API Pass, User and Password.'), true),
html_print_input_text('token', $token, '', 50, 255, true)
);
$row[] = html_print_label_input_block(
__('API Pass'),
html_print_input_password('apipass', $apipass, '', 50, 255, true)
);
$table->data[] = $row; $table->data[] = $row;
$row = []; $row = [];
$row[] = __('API Token').ui_print_help_tip(__('Use API Token instead API Pass, User and Password.'), true); $row[] = html_print_label_input_block(
$row[] = html_print_input_text('token', $token, '', 50, 255, true); __('User'),
$table->data[] = $row; html_print_input_text('user', $user, '', 50, 255, true)
);
$row = []; $row[] = html_print_label_input_block(
$row[] = __('API Pass'); __('Password'),
$row[] = html_print_input_password('apipass', $apipass, '', 50, 255, true); html_print_input_password('password', $password, '', 50, 255, true)
$table->data[] = $row; );
$row = [];
$row[] = __('User');
$row[] = html_print_input_text('user', $user, '', 50, 255, true);
$table->data[] = $row;
$row = [];
$row[] = __('Password');
$row[] = html_print_input_password('password', $password, '', 50, 255, true);
$table->data[] = $row; $table->data[] = $row;
$table2 = new stdClass(); $table2 = new stdClass();
$table2->width = '100%';
$table2->class = 'databox filters filter-table-adv';
$table2->size[0] = '50%';
$table2->size[1] = '50%';
$table2->data = []; $table2->data = [];
$row = []; $row = [];
$row[] = __('Action (get or set)'); $row[] = html_print_label_input_block(
$row[] = html_print_input_text('op', $op, '', 50, 255, true); __('Action (get or set)'),
html_print_input_text('op', $op, '', 50, 255, true)
);
$row[] = html_print_label_input_block(
__('Operation'),
html_print_input_text('op2', $op2, '', 50, 255, true)
);
$table2->data[] = $row; $table2->data[] = $row;
$row = []; $row = [];
$row[] = __('Operation'); $row[] = html_print_label_input_block(
$row[] = html_print_input_text('op2', $op2, '', 50, 255, true); __('ID'),
html_print_input_text('id', $id, '', 50, 255, true)
);
$row[] = html_print_label_input_block(
__('ID 2'),
html_print_input_text('id2', $id2, '', 50, 255, true)
);
$table2->data[] = $row; $table2->data[] = $row;
$row = []; $row = [];
$row[] = __('ID'); $row[] = html_print_label_input_block(
$row[] = html_print_input_text('id', $id, '', 50, 255, true); __('Return Type'),
html_print_input_text('return_type', $return_type, '', 50, 255, true)
);
$row[] = html_print_label_input_block(
__('Other'),
html_print_input_text('other', $other, '', 50, 255, true)
);
$table2->data[] = $row; $table2->data[] = $row;
$row = []; $row = [];
$row[] = __('ID 2'); $row[] = html_print_label_input_block(
$row[] = html_print_input_text('id2', $id2, '', 50, 255, true); __('Other Mode'),
$table2->data[] = $row; html_print_input_text('other_mode', $other_mode, '', 50, 255, true)
);
$row = [];
$row[] = __('Return Type');
$row[] = html_print_input_text('return_type', $return_type, '', 50, 255, true);
$table2->data[] = $row;
$row = [];
$row[] = __('Other');
$row[] = html_print_input_text('other', $other, '', 50, 255, true);
$table2->data[] = $row;
$row = [];
$row[] = __('Other Mode');
$row[] = html_print_input_text('other_mode', $other_mode, '', 50, 255, true);
$table2->data[] = $row; $table2->data[] = $row;
$table3 = new stdClass(); $table3 = new stdClass();
$table3->width = '100%';
$table3->class = 'databox filters filter-table-adv';
$table3->size[0] = '50%';
$table3->size[1] = '50%';
$table3->data = []; $table3->data = [];
$row = []; $row = [];
$row[] = __('Raw URL'); $row[] = html_print_label_input_block(
$row[] = html_print_input_text('url', $url, '', 50, 2048, true); __('Raw URL'),
html_print_input_text('url', $url, '', 50, 2048, true)
);
$table3->data[] = $row; $table3->data[] = $row;
echo "<form method='post'>"; echo "<form method='post' class='max_floating_element_size'>";
echo '<fieldset>'; echo '<fieldset class="mrgn_btn_10px">';
echo '<legend>'.__('Credentials').'</legend>'; echo '<legend>'.__('Credentials').'</legend>';
html_print_table($table); html_print_table($table);
echo '</fieldset>'; echo '</fieldset>';
echo '<fieldset>'; echo '<fieldset class="mrgn_btn_10px">';
echo '<legend>'.__('Call parameters').' '.ui_print_help_tip(__('Action: get Operation: module_last_value id: 63'), true).'</legend>'; echo '<legend>'.__('Call parameters').' '.ui_print_help_tip(__('Action: get Operation: module_last_value id: 63'), true).'</legend>';
html_print_table($table2); html_print_table($table2);
echo '</fieldset>'; echo '</fieldset>';
echo "<div class='right'>"; echo "<div class='right'>";
echo '</div>'; echo '</div>';
echo '<fieldset>'; echo '<fieldset class="mrgn_btn_10px">';
echo '<legend>'.__('Custom URL').'</legend>'; echo '<legend>'.__('Custom URL').'</legend>';
html_print_table($table3); html_print_table($table3);
echo '</fieldset>'; echo '</fieldset>';
html_print_input_hidden('api_execute', 1); html_print_input_hidden('api_execute', 1);
html_print_div( html_print_action_buttons(
[ html_print_submit_button(
'class' => 'action-buttons', __('Call'),
'content' => html_print_submit_button( 'submit',
__('Call'), false,
'submit', [ 'icon' => 'next' ],
false, true
[ 'icon' => 'next' ], )
true
),
]
); );
echo '</form>'; echo '</form>';
if ($api_execute === true) { if ($api_execute === true) {
echo '<fieldset>'; echo '<fieldset class="mrgn_0px mrgn_btn_10px pdd_15px" style="max-width: 1122px;">';
echo '<legend>'.__('Result').'</legend>'; echo '<legend>'.__('Result').'</legend>';
echo __('URL').'<br />'; echo html_print_label_input_block(
html_print_input_password('url', $return_call_api['url'], '', 150, 255, false, true); __('URL'),
echo "&nbsp;<a id='show_icon' title='".__('Show URL')."' href='javascript: show_url();'>"; html_print_input_password('url', $return_call_api['url'], '', 150, 255, true, true, false, 'mrgn_top_10px'),
html_print_image('images/input_zoom.png'); ['label_class' => 'font-title-font']
echo '</a>'; );
echo '<br />'; echo '<br />';
echo __('Result').'<br />'; echo html_print_label_input_block(
html_print_textarea('result', 30, 20, $return_call_api['result'], 'readonly="readonly"'); __('Result'),
html_print_textarea('result', 30, 20, $return_call_api['result'], 'readonly="readonly"', true, 'w100p mrgn_top_10px'),
['label_class' => 'font-title-font']
);
echo '</fieldset>'; echo '</fieldset>';
} }
?> ?>

View File

@ -126,8 +126,30 @@ function pandora_files_repo_godmode()
'godmode' => $godmode, 'godmode' => $godmode,
'operation' => $operation, 'operation' => $operation,
]; ];
// Header. // Header.
ui_print_page_header(__('Files repository manager'), 'images/extensions.png', false, '', true, $onheader); ui_print_standard_header(
__('Extensions'),
'images/extensions.png',
false,
'',
true,
$onheader,
[
[
'link' => '',
'label' => __('Admin tools'),
],
[
'link' => '',
'label' => __('Extension manager'),
],
[
'link' => '',
'label' => __('Files repository manager'),
],
]
);
$full_extensions_dir = $config['homedir'].'/'.EXTENSIONS_DIR.'/'; $full_extensions_dir = $config['homedir'].'/'.EXTENSIONS_DIR.'/';
include_once $full_extensions_dir.'files_repo/functions_files_repo.php'; include_once $full_extensions_dir.'files_repo/functions_files_repo.php';

View File

@ -32,17 +32,15 @@ if (isset($file_id) && $file_id > 0) {
$table = new stdClass(); $table = new stdClass();
$table->width = '100%'; $table->width = '100%';
$table->class = 'databox filters'; $table->class = 'databox filters filter-table-adv';
$table->style = []; $table->size[0] = '50%';
$table->style[0] = 'font-weight: bold;'; $table->size[1] = '50%';
$table->style[2] = 'text-align: center;';
$table->colspan = [];
$table->data = []; $table->data = [];
// GROUPS // GROUPS.
$groups = groups_get_all(); $groups = groups_get_all();
// Add the All group to the beginning to be always the first // Add the All group to the beginning to be always the first.
// Use this instead array_unshift to keep the array keys // Use this instead array_unshift to keep the array keys.
$groups = ([0 => __('All')] + $groups); $groups = ([0 => __('All')] + $groups);
$groups_selected = []; $groups_selected = [];
foreach ($groups as $id => $name) { foreach ($groups as $id => $name) {
@ -52,66 +50,110 @@ foreach ($groups as $id => $name) {
} }
$row = []; $row = [];
$row[0] = __('Groups'); $row[0] = html_print_label_input_block(
$row[1] = '<div class="w290px">'.html_print_select_groups( __('Groups'),
// Id_user. html_print_select_groups(
false, // Id_user.
// Privilege. false,
'AR', // Privilege.
// ReturnAllGroup. 'AR',
true, // ReturnAllGroup.
// Name. true,
'groups[]', // Name.
// Selected. 'groups[]',
$groups_selected, // Selected.
// Script. $groups_selected,
'', // Script.
// Nothing. '',
'', // Nothing.
// Nothing_value. '',
0, // Nothing_value.
// Return. 0,
true, // Return.
// Multiple. true,
true // Multiple.
).'</div>'; true
$table->data[] = $row; )
$table->colspan[][1] = 3; );
// DESCRIPTION // DESCRIPTION.
$row = []; $row[1] = html_print_label_input_block(
$row[0] = __('Description'); __('Description').ui_print_help_tip(__('Only 200 characters are permitted'), true),
$row[0] .= ui_print_help_tip(__('Only 200 characters are permitted'), true); html_print_textarea(
$row[1] = html_print_textarea('description', 3, 20, $file['description'], 'class="file_repo_description"', true); 'description',
4,
20,
$file['description'],
'class="file_repo_description" style="min-height: 60px; max-height: 60px;"',
true
)
);
$table->data[] = $row; $table->data[] = $row;
$table->colspan[][1] = 3;
// FILE and SUBMIT BUTTON // FILE and SUBMIT BUTTON.
$row = []; $row = [];
// Public checkbox // Public checkbox.
$checkbox = html_print_checkbox('public', 1, (bool) !empty($file['hash']), true); $checkbox = html_print_checkbox('public', 1, (bool) !empty($file['hash']), true);
$style = 'class="inline padding-2-10"'; $style = 'class="inline padding-2-10"';
$row[0] = __('File'); $row[0] = __('File');
if ($file_id > 0) { if ($file_id > 0) {
$row[1] = $file['name']; $submit_button = html_print_submit_button(
$row[2] = "<div $style>".__('Public link')."&nbsp;$checkbox</div>"; __('Update'),
$row[3] = html_print_submit_button(__('Update'), 'submit', false, 'class="sub upd"', true); 'submit',
$row[3] .= html_print_input_hidden('update_file', 1, true); false,
$row[3] .= html_print_input_hidden('file_id', $file_id, true); ['icon' => 'wand'],
true
);
$row[0] = html_print_label_input_block(
__('File'),
$file['name']
);
$row[1] = html_print_label_input_block(
__('Public link'),
$checkbox.html_print_input_hidden(
'file_id',
$file_id,
true
)
);
} else { } else {
$row[1] = html_print_input_file('upfile', true); $submit_button = html_print_submit_button(
$row[2] = "<div $style>".__('Public link')."&nbsp;$checkbox</div>"; __('Add'),
$row[3] = html_print_submit_button(__('Add'), 'submit', false, 'class="sub add"', true); 'submit',
$row[3] .= html_print_input_hidden('add_file', 1, true); false,
['icon' => 'wand'],
true
);
$row[0] = html_print_label_input_block(
__('File'),
html_print_input_file(
'upfile',
true
)
);
$row[1] = html_print_label_input_block(
__('Public link'),
$checkbox.html_print_input_hidden(
'add_file',
1,
true
)
);
} }
$table->data[] = $row; $table->data[] = $row;
$table->colspan[][1] = 1;
$url = ui_get_full_url('index.php?sec=godmode/extensions&sec2=extensions/files_repo'); $url = ui_get_full_url('index.php?sec=godmode/extensions&sec2=extensions/files_repo');
echo "<form method='post' action='$url' enctype='multipart/form-data'>"; echo "<form method='post' action='$url' enctype='multipart/form-data'>";
html_print_table($table); html_print_table($table);
html_print_action_buttons($submit_button);
echo '</form>'; echo '</form>';
?> ?>

View File

@ -11,11 +11,12 @@
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
function view_logfile($file_name) function view_logfile($file_name, $toggle=false)
{ {
global $config; global $config;
$memory_limit = ini_get('memory_limit'); $memory_limit = ini_get('memory_limit');
$code = '';
if (strstr($memory_limit, 'M') !== false) { if (strstr($memory_limit, 'M') !== false) {
$memory_limit = str_replace('M', '', $memory_limit); $memory_limit = str_replace('M', '', $memory_limit);
@ -31,21 +32,37 @@ function view_logfile($file_name)
$file_size = filesize($file_name); $file_size = filesize($file_name);
if ($memory_limit < $file_size) { if ($memory_limit < $file_size) {
echo "<h2>$file_name (".__('File is too large than PHP memory allocated in the system.').')</h2>'; $code .= '<pre><h2>'.$file_name.' ('.__('File is too large than PHP memory allocated in the system.').')</h2>';
echo '<h2>'.__('The preview file is imposible.').'</h2>'; $code .= '<h2>'.__('The preview file is imposible.').'</h2>';
} else if ($file_size > ($config['max_log_size'] * 1000)) { } else if ($file_size > ($config['max_log_size'] * 1000)) {
$data = file_get_contents($file_name, false, null, ($file_size - ($config['max_log_size'] * 1000))); $data = file_get_contents($file_name, false, null, ($file_size - ($config['max_log_size'] * 1000)));
echo "<h2>$file_name (".format_numeric(filesize($file_name) / 1024).' KB) '.ui_print_help_tip(__('The folder /var/log/pandora must have pandora:apache and its content too.'), true).' </h2>'; $code .= "<h2>$file_name (".format_numeric(filesize($file_name) / 1024).' KB) '.ui_print_help_tip(__('The folder /var/log/pandora must have pandora:apache and its content too.'), true).' </h2>';
echo "<textarea class='pandora_logs' name='$file_name'>"; $code .= "<textarea class='pandora_logs' name='$file_name'>";
echo '... '; $code .= '... ';
echo $data; $code .= $data;
echo '</textarea><br><br>'; $code .= '</textarea><br><br>';
} else { } else {
$data = file_get_contents($file_name); $data = file_get_contents($file_name);
echo "<h2>$file_name (".format_numeric(filesize($file_name) / 1024).' KB) '.ui_print_help_tip(__('The folder /var/log/pandora must have pandora:apache and its content too.'), true).' </h2>'; $code .= "<h2>$file_name (".format_numeric(filesize($file_name) / 1024).' KB) '.ui_print_help_tip(__('The folder /var/log/pandora must have pandora:apache and its content too.'), true).' </h2>';
echo "<textarea class='pandora_logs' name='$file_name'>"; $code .= "<textarea class='pandora_logs' name='$file_name'>";
echo $data; $code .= $data;
echo '</textarea><br><br>'; $code .= '</textarea><br><br></pre>';
}
if ($toggle === true) {
ui_toggle(
$code,
'<span class="subsection_header_title">'.$file_name.'</span>',
$file_name,
'a',
false,
false,
'',
'white-box-content no_border',
'filter-datatable-main box-flat white_table_graph'
);
} else {
echo $code;
} }
} }
} }
@ -64,21 +81,45 @@ function pandoralogs_extension_main()
return; return;
} }
ui_print_page_header(__('System logfile viewer'), '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' => __('System logfile viewer'),
],
]
);
echo '<p>'.__('Use this tool to view your %s logfiles directly on the console', get_product_name()).'</p>'; ui_print_info_message(
__('Use this tool to view your %s logfiles directly on the console', get_product_name()).'<br>
echo '<p>'.__('You can choose the amount of information shown in general setup (Log size limit in system logs viewer extension), '.($config['max_log_size'] * 1000).'B at the moment').'</p>'; '.__('You can choose the amount of information shown in general setup (Log size limit in system logs viewer extension), '.($config['max_log_size'] * 1000).'B at the moment')
);
$logs_directory = (!empty($config['server_log_dir'])) ? io_safe_output($config['server_log_dir']) : '/var/log/pandora'; $logs_directory = (!empty($config['server_log_dir'])) ? io_safe_output($config['server_log_dir']) : '/var/log/pandora';
// Do not attempt to show console log if disabled. // Do not attempt to show console log if disabled.
if ($config['console_log_enabled']) { if ($config['console_log_enabled']) {
view_logfile($config['homedir'].'/log/console.log'); view_logfile($config['homedir'].'/log/console.log', true);
} }
view_logfile($logs_directory.'/pandora_server.log'); view_logfile($logs_directory.'/pandora_server.log', true);
view_logfile($logs_directory.'/pandora_server.error'); view_logfile($logs_directory.'/pandora_server.error', true);
} }

View File

@ -8466,7 +8466,7 @@ div.graph div.legend table {
} }
.pandora_logs { .pandora_logs {
width: 98%; width: 100%;
float: right; float: right;
height: 200px; height: 200px;
margin-bottom: 20px; margin-bottom: 20px;