From 3f2caf94044cc3b835a30f4c98041e40bdde8a0e Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Wed, 27 Sep 2023 18:28:12 +0200 Subject: [PATCH] some gotty changes --- pandora_console/cron.php | 8 +- pandora_console/godmode/menu.php | 4 +- pandora_console/godmode/setup/setup.php | 12 +- .../godmode/setup/setup_quickshell.php | 53 ++++++++ .../godmode/setup/setup_websocket_engine.php | 121 ------------------ .../include/class/ConsoleSupervisor.php | 4 +- .../include/class/DiscoveryConsoleTask.php | 9 +- pandora_console/include/functions_config.php | 14 -- .../include/functions_cron_task.php | 6 +- 9 files changed, 77 insertions(+), 154 deletions(-) create mode 100644 pandora_console/godmode/setup/setup_quickshell.php delete mode 100644 pandora_console/godmode/setup/setup_websocket_engine.php diff --git a/pandora_console/cron.php b/pandora_console/cron.php index c6a3439403..0811a9ef40 100644 --- a/pandora_console/cron.php +++ b/pandora_console/cron.php @@ -5,7 +5,9 @@ require_once 'include/auth/mysql.php'; require_once 'include/functions.php'; require_once 'include/functions_db.php'; -if (enterprise_installed() === true) { +global $config; + +if ((bool) $config['enterprise_installed'] === true) { return; } @@ -13,8 +15,6 @@ if (enterprise_installed() === true) { require_once 'include/class/DiscoveryConsoleTask.php'; require_once 'include/class/ConsoleSupervisor.php'; -global $config; - db_process_sql_update( 'tconfig', ['value' => get_system_time()], @@ -28,4 +28,4 @@ $tasks->run(); if (is_reporting_console_node() === true) { $supervisor = new ConsoleSupervisor(); $supervisor->run(); -} \ No newline at end of file +} diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index da06372b8a..b6f7b1a3b7 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -485,8 +485,8 @@ if ($access_console_node === true) { $sub2['godmode/setup/setup§ion=notifications']['text'] = __('Notifications'); $sub2['godmode/setup/setup§ion=notifications']['refr'] = 0; - $sub2['godmode/setup/setup§ion=websocket_engine']['text'] = __('QuickShell'); - $sub2['godmode/setup/setup§ion=websocket_engine']['refr'] = 0; + $sub2['godmode/setup/setup§ion=quickshell']['text'] = __('QuickShell'); + $sub2['godmode/setup/setup§ion=quickshell']['refr'] = 0; $sub2['godmode/setup/setup§ion=external_tools']['text'] = __('External Tools'); $sub2['godmode/setup/setup§ion=external_tools']['refr'] = 0; diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index c1cf635d28..18a9b1db78 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -221,9 +221,9 @@ $buttons['notifications'] = [ ).'', ]; -$buttons['websocket_engine'] = [ +$buttons['quickshell'] = [ 'active' => false, - 'text' => ''.html_print_image( + 'text' => ''.html_print_image( 'images/websocket_small.png', true, [ @@ -325,8 +325,8 @@ switch ($section) { $subpage = __('Notifications'); break; - case 'websocket_engine': - $buttons['websocket_engine']['active'] = true; + case 'quickshell': + $buttons['quickshell']['active'] = true; $subpage = __('QuickShell'); $help_header = 'quickshell_settings'; break; @@ -454,8 +454,8 @@ switch ($section) { include_once $config['homedir'].'/godmode/setup/setup_notifications.php'; break; - case 'websocket_engine': - include_once $config['homedir'].'/godmode/setup/setup_websocket_engine.php'; + case 'quickshell': + include_once $config['homedir'].'/godmode/setup/setup_quickshell.php'; break; case 'external_tools': diff --git a/pandora_console/godmode/setup/setup_quickshell.php b/pandora_console/godmode/setup/setup_quickshell.php new file mode 100644 index 0000000000..84b3fad1d0 --- /dev/null +++ b/pandora_console/godmode/setup/setup_quickshell.php @@ -0,0 +1,53 @@ +'; + +if (function_exists('quickShellSettings') === true) { + quickShellSettings(); +} + +$action_btns = html_print_submit_button( + __('Update'), + 'update_button', + false, + [ 'icon' => 'update' ], + true +); + +html_print_action_buttons( + $action_btns +); + +echo ''; diff --git a/pandora_console/godmode/setup/setup_websocket_engine.php b/pandora_console/godmode/setup/setup_websocket_engine.php deleted file mode 100644 index bed6a01ee9..0000000000 --- a/pandora_console/godmode/setup/setup_websocket_engine.php +++ /dev/null @@ -1,121 +0,0 @@ -'; - -if (function_exists('quickShellSettings') === true) { - quickShellSettings(); -} - -$action_btns = html_print_submit_button( - __('Update'), - 'update_button', - false, - [ 'icon' => 'update' ], - true -); - -html_print_action_buttons( - $action_btns -); - -echo ''; - -echo ''; - diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 26e3014edc..b4320b1a4d 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -499,9 +499,7 @@ class ConsoleSupervisor * NOTIF.CRON.CONFIGURED */ - if (enterprise_installed()) { - $this->checkCronRunning(); - } + $this->checkCronRunning(); /* * Check if instance is registered. diff --git a/pandora_console/include/class/DiscoveryConsoleTask.php b/pandora_console/include/class/DiscoveryConsoleTask.php index f9bd6ed877..129bc93435 100644 --- a/pandora_console/include/class/DiscoveryConsoleTask.php +++ b/pandora_console/include/class/DiscoveryConsoleTask.php @@ -26,7 +26,7 @@ * ============================================================================ */ -if (enterprise_installed() === true) { +if ((bool) $config['enterprise_installed'] === true) { enterprise_include_once('/include/functions_cron.php'); } else { include_once $config['homedir'].'/include/functions_cron_task.php'; @@ -163,6 +163,13 @@ class DiscoveryConsoleTask // Maintenance task: schedule task 'cron_task_start_gotty' if not defined yet. // Must do at every Cron execution. + if ((bool) $config['enterprise_installed'] === false) { + $call_func_user_task_id = db_get_value_sql('SELECT id FROM `tuser_task` WHERE `function_name` = "cron_task_call_user_function"'); + if ($call_func_user_task_id === false) { + db_process_sql("INSERT INTO `tuser_task` (`function_name`, `parameters`, `name`) VALUES ('cron_task_call_user_function','a:1:{i:0;a:2:{s:11:\"description\";s:13:\"Function name\";s:4:\"type\";s:4:\"text\";}}','Call PHP function')"); + } + } + $user_function_task_id = db_get_value_sql('SELECT id FROM `tuser_task_scheduled` WHERE `args` LIKE "%cron_task_start_gotty%"'); if ($user_function_task_id === false) { diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 393c6a2610..3be80ad923 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -2030,20 +2030,6 @@ function config_update_config() } break; - case 'websocket_engine': - if (config_update_value('ws_bind_address', get_parameter('ws_bind_address'), true) === false) { - $error_update[] = __('WebSocket bind address'); - } - - if (config_update_value('ws_port', get_parameter('ws_port'), true) === false) { - $error_update[] = __('WebSocket port'); - } - - if (config_update_value('ws_proxy_url', get_parameter('ws_proxy_url'), true) === false) { - $error_update[] = __('WebSocket proxy url'); - } - break; - default: // Ignore. break; diff --git a/pandora_console/include/functions_cron_task.php b/pandora_console/include/functions_cron_task.php index 69586a17b6..0cc9cb08cd 100644 --- a/pandora_console/include/functions_cron_task.php +++ b/pandora_console/include/functions_cron_task.php @@ -227,7 +227,7 @@ function cron_task_run( $args = unserialize($task_scheduled['args']); - if (enterprise_installed() === false + if ((bool) $config['enterprise_installed'] === false && isset($args['function_name']) === true && $args['function_name'] !== 'cron_task_start_gotty' ) { @@ -235,7 +235,7 @@ function cron_task_run( return; } - if (enterprise_installed() === true) { + if ((bool) $config['enterprise_installed'] === true) { $task = db_get_row('tuser_task', 'id', $task_scheduled['id_user_task']); } else { $task = [ @@ -282,7 +282,6 @@ function cron_task_run( set_time_limit(0); - if ($task['function_name'] == 'cron_task_generate_report_by_template' || $task['function_name'] == 'cron_task_generate_report' ) { @@ -432,6 +431,7 @@ function cron_task_run( function cron_task_call_user_function(string $function_name) { global $config; + include_once $config['homedir'].'/vendor/autoload.php'; call_user_func($function_name);