2008-08-04 10:15:16 +02:00
|
|
|
<?php
|
|
|
|
|
2009-06-08 20:26:14 +02:00
|
|
|
// Pandora FMS - http://pandorafms.com
|
|
|
|
// ==================================================
|
2011-03-02 22:56:48 +01:00
|
|
|
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
2009-06-08 20:26:14 +02:00
|
|
|
// Please see http://pandorafms.org for full contribution list
|
2008-08-22 20:07:32 +02:00
|
|
|
|
|
|
|
// This program is free software; you can redistribute it and/or
|
2009-06-08 20:26:14 +02:00
|
|
|
// modify it under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation; version 2
|
|
|
|
|
2008-08-22 20:07:32 +02:00
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
2009-08-24 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_menu.php, include/functions_html.php,
include/functions_events.php, include/functions_messages.php,
include/functions_modules.php, include/functions_exportserver.php,
include/functions_reporting.php, include/functions_filemanager.php,
include/pchart_graph.php, include/pandora_graph.php, include/auth/dev.php,
include/auth/ldap.php, include/auth/mysql.php, include/config.inc.php,
include/functions_networkmap.php, include/functions_servers.php,
include/FusionCharts/FusionCharts_Gen.php,
include/FusionCharts/FusionCharts.php,
include/functions_network_profiles.php, include/gettext.php,
include/functions_network_components.php, include/functions_visual_map.php,
include/fgraph2.php, include/Image/image_functions.php,
include/functions_config.php, include/help/en/help_plugin_parameters.php,
include/help/en/help_snmpcommunity.php, include/help/en/help_wmiquery.php,
include/help/en/help_postprocess.php,
include/help/en/help_prediction_source_module.php,
include/help/en/help_date_format.php, include/help/en/help_recontask.php,
include/help/en/help_alert-matches.php, include/help/en/help_tcp_send.php,
include/help/en/help_wmifield.php, include/help/en/help_duplicateconfig.php,
include/help/en/help_agent_status.php,
include/help/en/help_manage_alerts.php, include/help/en/help_wmikey.php,
include/help/en/help_alert_type.php,
include/help/en/help_network_component.php,
include/help/en/help_time_stamp-comparation.php,
include/help/en/help_eventview.php, include/help/en/help_timesource.php,
include/help/en/help_alert_validation.php,
include/help/en/help_map_builder.php,
include/help/en/help_alert_recovery.php,
include/help/en/help_module_type.php,
include/help/en/help_planned_downtime.php,
include/help/en/help_serverlag.php, include/help/en/help_alerts.php,
include/help/en/help_snmpwalk.php,
include/help/en/help_module_definition.php,
include/help/en/help_plugin_definition.php,
include/help/en/help_wminamespace.php, include/help/en/help_snmpoid.php
include/help/en/help_manageconfig.php,
include/help/es/help_alert_validation.php,
include/help/es/help_plugin_parameters.php,
include/help/es/help_snmpcommunity.php, include/help/es/help_wmiquery.php,
include/help/es/help_map_builder.php, include/help/es/help_postprocess.php,
include/help/es/help_date_format.php,
include/help/es/help_alert_recovery.php,
include/help/es/help_prediction_source_module.php,
include/help/es/help_module_type.php,
include/help/es/help_planned_downtime.php,
include/help/es/help_alert-matches.php, include/help/es/help_recontask.php,
include/help/es/help_alerts.php, include/help/es/help_serverlag.php,
include/help/es/help_snmpwalk.php,
include/help/es/help_module_definition.php,
include/help/es/help_tcp_send.php, include/help/es/help_duplicateconfig.php,
include/help/es/help_wmifield.php, include/help/es/help_manage_alerts.php,
include/help/es/help_wmikey.php, include/help/es/help_plugin_definition.php,
include/help/es/help_alert_type.php, include/help/es/help_snmpoid.php,
include/help/es/help_wminamespace.php,
include/help/es/help_network_component.php,
include/help/es/help_time_stamp-comparation.php,
include/help/es/help_manageconfig.php, include/help/es/help_timesource.php,
include/config_process.php, include/functions_ui.php, include/htmlawed.php,
include/functions_custom_graphs.php, include/fgraph.php,
include/functions_incidents.php, include/functions.php,
include/functions_agents.php, include/functions_db.php,
include/functions_themes.php, include/streams.php,
include/functions_fsgraph.php, include/functions_alerts.php,
include/functions_reports.php, include/functions_extensions.php,
include/functions_ui_renders.php: change comments blocks for delete the
warnings to construct phpDoc Files, give a struct and order in the
phpDoc files.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1881 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-08-25 19:39:28 +02:00
|
|
|
/**
|
|
|
|
* @package Include
|
2009-08-24 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_menu.php, include/functions_html.php,
include/functions_events.php, include/functions_messages.php,
include/functions_modules.php, include/functions_exportserver.php,
include/functions_reporting.php, include/functions_filemanager.php,
include/pchart_graph.php, include/pandora_graph.php, include/auth/ldap.php,
include/auth/mysql.php, include/config.inc.php,
include/functions_networkmap.php, include/functions_servers.php,
include/functions_network_profiles.php, include/gettext.php,
include/functions_network_components.php, include/functions_visual_map.php,
include/fgraph2.php, include/Image/image_functions.php,
include/functions_config.php, include/config_process.php,
include/functions_ui.php, include/htmlawed.php,
include/functions_custom_graphs.php, include/fgraph.php,
include/functions_incidents.php, include/functions.php,
include/functions_agents.php, include/functions_db.php,
include/functions_themes.php, include/streams.php,
include/functions_fsgraph.php, include/functions_alerts.php,
include/functions_reports.php, include/functions_extensions.php,
include/functions_ui_renders.php: change or add the subpackage in phpdoc
comment blocks for to organize more the result phpdoc files. Start to
document undocument functions.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1882 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-08-26 17:37:47 +02:00
|
|
|
* @subpackage Extensions
|
2009-08-24 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_menu.php, include/functions_html.php,
include/functions_events.php, include/functions_messages.php,
include/functions_modules.php, include/functions_exportserver.php,
include/functions_reporting.php, include/functions_filemanager.php,
include/pchart_graph.php, include/pandora_graph.php, include/auth/dev.php,
include/auth/ldap.php, include/auth/mysql.php, include/config.inc.php,
include/functions_networkmap.php, include/functions_servers.php,
include/FusionCharts/FusionCharts_Gen.php,
include/FusionCharts/FusionCharts.php,
include/functions_network_profiles.php, include/gettext.php,
include/functions_network_components.php, include/functions_visual_map.php,
include/fgraph2.php, include/Image/image_functions.php,
include/functions_config.php, include/help/en/help_plugin_parameters.php,
include/help/en/help_snmpcommunity.php, include/help/en/help_wmiquery.php,
include/help/en/help_postprocess.php,
include/help/en/help_prediction_source_module.php,
include/help/en/help_date_format.php, include/help/en/help_recontask.php,
include/help/en/help_alert-matches.php, include/help/en/help_tcp_send.php,
include/help/en/help_wmifield.php, include/help/en/help_duplicateconfig.php,
include/help/en/help_agent_status.php,
include/help/en/help_manage_alerts.php, include/help/en/help_wmikey.php,
include/help/en/help_alert_type.php,
include/help/en/help_network_component.php,
include/help/en/help_time_stamp-comparation.php,
include/help/en/help_eventview.php, include/help/en/help_timesource.php,
include/help/en/help_alert_validation.php,
include/help/en/help_map_builder.php,
include/help/en/help_alert_recovery.php,
include/help/en/help_module_type.php,
include/help/en/help_planned_downtime.php,
include/help/en/help_serverlag.php, include/help/en/help_alerts.php,
include/help/en/help_snmpwalk.php,
include/help/en/help_module_definition.php,
include/help/en/help_plugin_definition.php,
include/help/en/help_wminamespace.php, include/help/en/help_snmpoid.php
include/help/en/help_manageconfig.php,
include/help/es/help_alert_validation.php,
include/help/es/help_plugin_parameters.php,
include/help/es/help_snmpcommunity.php, include/help/es/help_wmiquery.php,
include/help/es/help_map_builder.php, include/help/es/help_postprocess.php,
include/help/es/help_date_format.php,
include/help/es/help_alert_recovery.php,
include/help/es/help_prediction_source_module.php,
include/help/es/help_module_type.php,
include/help/es/help_planned_downtime.php,
include/help/es/help_alert-matches.php, include/help/es/help_recontask.php,
include/help/es/help_alerts.php, include/help/es/help_serverlag.php,
include/help/es/help_snmpwalk.php,
include/help/es/help_module_definition.php,
include/help/es/help_tcp_send.php, include/help/es/help_duplicateconfig.php,
include/help/es/help_wmifield.php, include/help/es/help_manage_alerts.php,
include/help/es/help_wmikey.php, include/help/es/help_plugin_definition.php,
include/help/es/help_alert_type.php, include/help/es/help_snmpoid.php,
include/help/es/help_wminamespace.php,
include/help/es/help_network_component.php,
include/help/es/help_time_stamp-comparation.php,
include/help/es/help_manageconfig.php, include/help/es/help_timesource.php,
include/config_process.php, include/functions_ui.php, include/htmlawed.php,
include/functions_custom_graphs.php, include/fgraph.php,
include/functions_incidents.php, include/functions.php,
include/functions_agents.php, include/functions_db.php,
include/functions_themes.php, include/streams.php,
include/functions_fsgraph.php, include/functions_alerts.php,
include/functions_reports.php, include/functions_extensions.php,
include/functions_ui_renders.php: change comments blocks for delete the
warnings to construct phpDoc Files, give a struct and order in the
phpDoc files.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1881 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-08-25 19:39:28 +02:00
|
|
|
*/
|
|
|
|
|
2008-08-04 10:15:16 +02:00
|
|
|
$extension_file = '';
|
|
|
|
|
2009-01-08 16:52:13 +01:00
|
|
|
|
|
|
|
/**
|
2011-04-27 15:43:31 +02:00
|
|
|
* Callback function for extensions in the console
|
2009-01-08 16:52:13 +01:00
|
|
|
*
|
2011-04-27 15:43:31 +02:00
|
|
|
* @param string $filename with contents of the extension
|
2009-01-08 16:52:13 +01:00
|
|
|
*/
|
2011-05-11 14:15:14 +02:00
|
|
|
function extensions_call_main_function ($filename) {
|
2008-08-04 10:15:16 +02:00
|
|
|
global $config;
|
|
|
|
|
|
|
|
$extension = &$config['extensions'][$filename];
|
|
|
|
if ($extension['main_function'] != '') {
|
|
|
|
$params = array ();
|
|
|
|
call_user_func_array ($extension['main_function'], $params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-08 16:52:13 +01:00
|
|
|
/**
|
2011-04-27 15:43:31 +02:00
|
|
|
* Callback function for godmode extensions
|
2009-01-08 16:52:13 +01:00
|
|
|
*
|
2011-04-27 15:43:31 +02:00
|
|
|
* @param string $filename File with extension contents
|
2009-01-08 16:52:13 +01:00
|
|
|
*/
|
2011-05-11 14:15:14 +02:00
|
|
|
function extensions_call_godmode_function ($filename) {
|
2008-08-04 10:15:16 +02:00
|
|
|
global $config;
|
|
|
|
|
|
|
|
$extension = &$config['extensions'][$filename];
|
|
|
|
if ($extension['godmode_function'] != '') {
|
|
|
|
$params = array ();
|
|
|
|
call_user_func_array ($extension['godmode_function'], $params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-08 16:52:13 +01:00
|
|
|
/**
|
2011-04-27 15:43:31 +02:00
|
|
|
* Callback login function for extensions
|
2009-01-08 16:52:13 +01:00
|
|
|
*/
|
2008-08-05 12:47:40 +02:00
|
|
|
function extensions_call_login_function () {
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
$params = array ();
|
|
|
|
foreach ($config['extensions'] as $extension) {
|
|
|
|
if ($extension['login_function'] == '')
|
|
|
|
continue;
|
|
|
|
call_user_func_array ($extension['login_function'], $params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-08 16:52:13 +01:00
|
|
|
/**
|
2011-04-27 15:43:31 +02:00
|
|
|
* Checks if the current page is an extension
|
2009-01-08 16:52:13 +01:00
|
|
|
*
|
2011-04-27 15:43:31 +02:00
|
|
|
* @param string $page To check
|
2009-01-08 16:52:13 +01:00
|
|
|
*/
|
2011-05-11 14:15:14 +02:00
|
|
|
function extensions_is_extension ($page) {
|
2008-08-04 10:15:16 +02:00
|
|
|
global $config;
|
|
|
|
|
2014-06-24 13:14:49 +02:00
|
|
|
$return = false;
|
|
|
|
|
|
|
|
//Avoid the old update manager
|
|
|
|
if ($page != "godmode/update_manager/update_manager.php") {
|
|
|
|
$filename = basename ($page);
|
|
|
|
|
|
|
|
$return = isset ($config['extensions'][$filename]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $return;
|
2008-08-04 10:15:16 +02:00
|
|
|
}
|
|
|
|
|
2009-01-08 16:52:13 +01:00
|
|
|
/**
|
2009-08-27 18:57:19 +02:00
|
|
|
* Scan the EXTENSIONS_DIR or ENTERPRISE_DIR.'/'.EXTENSIONS_DIR for search
|
|
|
|
* the files extensions.
|
2009-01-08 16:52:13 +01:00
|
|
|
*
|
|
|
|
* @param bool $enterprise
|
|
|
|
*/
|
2011-05-11 14:15:14 +02:00
|
|
|
function extensions_get_extensions ($enterprise = false) {
|
2016-05-23 15:20:46 +02:00
|
|
|
|
2008-10-14 11:19:19 +02:00
|
|
|
$dir = EXTENSIONS_DIR;
|
2016-05-23 15:20:46 +02:00
|
|
|
$master_dir = ENTERPRISE_DIR . '/' . EXTENSIONS_DIR;
|
2009-03-05 18:40:40 +01:00
|
|
|
$handle = false;
|
2016-05-23 15:20:46 +02:00
|
|
|
if ($enterprise) {
|
|
|
|
$dir = ENTERPRISE_DIR . '/' . EXTENSIONS_DIR;
|
|
|
|
if (defined("METACONSOLE")) {
|
|
|
|
$dir = '../' . EXTENSIONS_DIR;
|
|
|
|
$master_dir = '../' . EXTENSIONS_DIR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (defined("METACONSOLE")) {
|
|
|
|
$dir = '../../' . $dir;
|
|
|
|
$master_dir = '../' . EXTENSIONS_DIR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-05 18:40:40 +01:00
|
|
|
if (file_exists ($dir))
|
2014-07-04 13:49:54 +02:00
|
|
|
$handle = @opendir ($dir);
|
2009-03-05 18:40:40 +01:00
|
|
|
|
|
|
|
if (empty ($handle))
|
2008-08-04 10:15:16 +02:00
|
|
|
return;
|
2014-07-04 13:49:54 +02:00
|
|
|
|
2008-08-04 10:15:16 +02:00
|
|
|
$file = readdir ($handle);
|
|
|
|
$extensions = array ();
|
|
|
|
$ignores = array ('.', '..');
|
|
|
|
while ($file !== false) {
|
|
|
|
if (in_array ($file, $ignores)) {
|
|
|
|
$file = readdir ($handle);
|
|
|
|
continue;
|
|
|
|
}
|
2008-10-14 11:19:19 +02:00
|
|
|
$filepath = realpath ($dir."/".$file);
|
2008-08-04 10:15:16 +02:00
|
|
|
if (! is_readable ($filepath) || is_dir ($filepath) || ! preg_match ("/.*\.php$/", $filepath)) {
|
|
|
|
$file = readdir ($handle);
|
|
|
|
continue;
|
|
|
|
}
|
2014-07-04 13:49:54 +02:00
|
|
|
|
|
|
|
if ($file == "update_manager.php")
|
|
|
|
continue;
|
|
|
|
|
2008-08-04 10:15:16 +02:00
|
|
|
$extension['file'] = $file;
|
|
|
|
$extension['operation_menu'] = '';
|
|
|
|
$extension['godmode_menu'] = '';
|
|
|
|
$extension['main_function'] = '';
|
|
|
|
$extension['godmode_function'] = '';
|
|
|
|
$extension['login_function'] = '';
|
2008-10-14 11:19:19 +02:00
|
|
|
$extension['enterprise'] = $enterprise;
|
|
|
|
$extension['dir'] = $dir;
|
2008-08-04 10:15:16 +02:00
|
|
|
$extensions[$file] = $extension;
|
|
|
|
$file = readdir ($handle);
|
|
|
|
}
|
2008-10-14 11:19:19 +02:00
|
|
|
|
|
|
|
/* Load extensions in enterprise directory */
|
2016-05-23 15:20:46 +02:00
|
|
|
if (! $enterprise && file_exists ($master_dir))
|
2011-05-11 14:15:14 +02:00
|
|
|
return array_merge ($extensions, extensions_get_extensions (true));
|
2008-10-14 11:19:19 +02:00
|
|
|
|
2008-08-04 10:15:16 +02:00
|
|
|
return $extensions;
|
|
|
|
}
|
|
|
|
|
2011-04-27 15:43:31 +02:00
|
|
|
/**
|
|
|
|
* Get disabled open and enterprise extensions
|
|
|
|
*/
|
2011-05-11 14:15:14 +02:00
|
|
|
function extensions_get_disabled_extensions() {
|
2010-11-19 13:08:18 +01:00
|
|
|
global $config;
|
|
|
|
|
|
|
|
$extensions = array ();
|
|
|
|
|
|
|
|
$dirs = array('open' => EXTENSIONS_DIR . '/disabled', 'enterprise' => ENTERPRISE_DIR . '/' . EXTENSIONS_DIR . '/disabled');
|
|
|
|
|
|
|
|
foreach ($dirs as $type => $dir) {
|
|
|
|
$handle = false;
|
|
|
|
|
|
|
|
if (file_exists ($dir))
|
|
|
|
$handle = @opendir ($dir);
|
|
|
|
|
|
|
|
if (empty ($handle))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
$ignores = array ('.', '..');
|
|
|
|
|
|
|
|
$file = readdir ($handle);
|
|
|
|
while ($file !== false) {
|
|
|
|
if (in_array ($file, $ignores)) {
|
|
|
|
$file = readdir ($handle);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$filepath = realpath ($dir."/".$file);
|
|
|
|
if (! is_readable ($filepath) || is_dir ($filepath) || ! preg_match ("/.*\.php$/", $filepath)) {
|
|
|
|
$file = readdir ($handle);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
//$content = file_get_contents($filepath);
|
|
|
|
$content = '';
|
|
|
|
|
|
|
|
$data = array();
|
|
|
|
|
|
|
|
$data['operation_menu'] = false;
|
2011-05-11 14:15:14 +02:00
|
|
|
if (preg_match("/<?php(\n|.)*extensions_add_operation_menu_option(\n|.)*?>/", $content)) {
|
2010-11-19 13:08:18 +01:00
|
|
|
$data['operation_menu'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['godmode_menu'] = false;
|
2011-05-11 14:15:14 +02:00
|
|
|
if (preg_match('/<\?php(\n|.)*extensions_add_godmode_menu_option(\n|.)*\?>/', $content)) {
|
2010-11-19 13:08:18 +01:00
|
|
|
$data['godmode_menu'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['operation_function'] = false;
|
2011-05-11 14:15:14 +02:00
|
|
|
if (preg_match('/<\?php(\n|.)*extensions_add_main_function(\n|.)*\?>/', $content)) {
|
2010-11-19 13:08:18 +01:00
|
|
|
$data['operation_function'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['login_function'] = false;
|
2011-05-11 14:15:14 +02:00
|
|
|
if (preg_match('/<\?php(\n|.)*extensions_add_login_function(\n|.)*\?>/', $content)) {
|
2010-11-19 13:08:18 +01:00
|
|
|
$data['login_function'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['extension_ope_tab'] = false;
|
2011-05-11 14:15:14 +02:00
|
|
|
if (preg_match('/<\?php(\n|.)*extensions_add_opemode_tab_agent(\n|.)*\?>/', $content)) {
|
2010-11-19 13:08:18 +01:00
|
|
|
$data['extension_ope_tab'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['extension_god_tab'] = false;
|
2011-05-11 14:15:14 +02:00
|
|
|
if (preg_match('/<\?php(\n|.)*extensions_add_godmode_tab_agent(\n|.)*\?>/', $content)) {
|
2010-11-19 13:08:18 +01:00
|
|
|
$data['extension_god_tab'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['godmode_function'] = false;
|
2011-05-11 14:15:14 +02:00
|
|
|
if (preg_match('/<\?php(\n|.)*extensions_add_godmode_function(\n|.)*\?>/', $content)) {
|
2010-11-19 13:08:18 +01:00
|
|
|
$data['godmode_function'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['enterprise'] = false;
|
|
|
|
if ($type == 'enterprise') {
|
|
|
|
$data['enterprise'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['enabled'] = false;
|
|
|
|
|
|
|
|
$extensions[$file] = $data;
|
|
|
|
|
|
|
|
$file = readdir ($handle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $extensions;
|
|
|
|
}
|
|
|
|
|
2011-04-27 15:43:31 +02:00
|
|
|
/**
|
|
|
|
* Get info of all extensions (enabled/disabled)
|
|
|
|
*/
|
2011-05-11 14:15:14 +02:00
|
|
|
function extensions_get_extension_info() {
|
2010-11-19 13:08:18 +01:00
|
|
|
global $config;
|
|
|
|
|
|
|
|
$return = array ();
|
|
|
|
|
|
|
|
foreach($config['extensions'] as $extension) {
|
|
|
|
$data = array();
|
|
|
|
$data['godmode_function'] = false;
|
|
|
|
if (!empty($extension['godmode_function'])) {
|
|
|
|
$data['godmode_function'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['godmode_menu'] = false;
|
|
|
|
if (!empty($extension['godmode_menu'])) {
|
|
|
|
$data['godmode_menu'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['operation_function'] = false;
|
|
|
|
if (!empty($extension['main_function'])) {
|
|
|
|
$data['operation_function'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['operation_menu'] = false;
|
|
|
|
if (!empty($extension['operation_menu'])) {
|
|
|
|
$data['operation_menu'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['login_function'] = false;
|
|
|
|
if (!empty($extension['login_function'])) {
|
|
|
|
$data['login_function'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['extension_ope_tab'] = false;
|
|
|
|
if (!empty($extension['extension_ope_tab'])) {
|
|
|
|
$data['extension_ope_tab'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['extension_god_tab'] = false;
|
|
|
|
if (!empty($extension['extension_god_tab'])) {
|
|
|
|
$data['extension_god_tab'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['enterprise'] = (bool)$extension['enterprise'];
|
|
|
|
|
|
|
|
$data['enabled'] = true;
|
|
|
|
|
|
|
|
$return[$extension['file']] = $data;
|
|
|
|
}
|
|
|
|
|
2011-05-11 14:15:14 +02:00
|
|
|
$return = $return + extensions_get_disabled_extensions();
|
2010-11-19 13:08:18 +01:00
|
|
|
|
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
|
2009-01-08 16:52:13 +01:00
|
|
|
/**
|
2011-04-27 15:43:31 +02:00
|
|
|
* Load all extensions
|
2009-01-08 16:52:13 +01:00
|
|
|
*
|
|
|
|
* @param array $extensions
|
|
|
|
*/
|
2015-03-17 16:48:29 +01:00
|
|
|
function extensions_load_extensions ($process_login) {
|
2008-08-04 10:15:16 +02:00
|
|
|
global $config;
|
|
|
|
global $extension_file;
|
|
|
|
|
2015-03-17 16:48:29 +01:00
|
|
|
foreach ($config['extensions'] as $extension) {
|
2008-08-04 10:15:16 +02:00
|
|
|
$extension_file = $extension['file'];
|
2015-03-17 16:48:29 +01:00
|
|
|
$path_extension = realpath ($extension['dir'] . "/" . $extension_file);
|
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// PHP BUG
|
|
|
|
//
|
|
|
|
// #66518 need some exceptions for php's include or require
|
|
|
|
//
|
|
|
|
// https://bugs.php.net/bug.php?id=66518
|
|
|
|
//--------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
//~ if ($process_login) {
|
|
|
|
//~ //Check the syntax for avoid PHP errors
|
|
|
|
//~ $output = null;
|
|
|
|
//~ $return_var = null;
|
|
|
|
//~ exec('php -l ' . $path_extension, $output, $return_code);
|
|
|
|
//~ if ($return_code !== 0) {
|
|
|
|
//~ // There is a error.
|
|
|
|
//~
|
|
|
|
//~ set_pandora_error_for_header(
|
|
|
|
//~ __('There are some errors in the PHP file of extension %s .', $extension_file));
|
|
|
|
//~ }
|
|
|
|
//~ else {
|
|
|
|
//~ require_once($path_extension);
|
|
|
|
//~ }
|
|
|
|
//~ }
|
|
|
|
//~ else {
|
|
|
|
require_once($path_extension);
|
|
|
|
//~ }
|
2008-08-04 10:15:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-08 16:52:13 +01:00
|
|
|
/**
|
2011-04-27 15:43:31 +02:00
|
|
|
* This function adds a link to the extension with the given name in Operation menu.
|
2009-01-08 16:52:13 +01:00
|
|
|
*
|
2011-04-27 15:43:31 +02:00
|
|
|
* @param string name Name of the extension in the Operation menu
|
|
|
|
* @param string fatherId Id of the parent menu item for the current extension
|
2015-04-09 15:04:23 +02:00
|
|
|
* @param string subfatherId Id of the parent submenu item for the current extension
|
2011-04-27 15:43:31 +02:00
|
|
|
* @param string icon Path to the icon image (18x18 px). If this parameter is blank then predefined icon will be used
|
2009-01-08 16:52:13 +01:00
|
|
|
*/
|
2015-04-09 15:04:23 +02:00
|
|
|
function extensions_add_operation_menu_option ($name, $fatherId = null, $icon = null, $version="N/A", $subfatherId = null) {
|
2008-08-04 10:15:16 +02:00
|
|
|
global $config;
|
|
|
|
global $extension_file;
|
|
|
|
|
2012-10-25 18:46:52 +02:00
|
|
|
/*
|
|
|
|
$config['extension_file'] is set in extensions_load_extensions(),
|
|
|
|
since that function must be called before any function the extension
|
|
|
|
call, we are sure it will be set.
|
|
|
|
*/
|
2011-02-22 12:31:39 +01:00
|
|
|
$option_menu['name'] = $name;
|
2012-10-25 18:46:52 +02:00
|
|
|
|
2008-08-04 10:15:16 +02:00
|
|
|
$extension = &$config['extensions'][$extension_file];
|
2012-10-25 18:46:52 +02:00
|
|
|
|
|
|
|
$option_menu['sec2'] = $extension['dir'] . '/' . mb_substr ($extension_file, 0, -4);
|
2009-08-27 18:57:19 +02:00
|
|
|
$option_menu['fatherId'] = $fatherId;
|
2015-04-09 15:04:23 +02:00
|
|
|
$option_menu['subfatherId'] = $subfatherId;
|
2009-08-27 18:57:19 +02:00
|
|
|
$option_menu['icon'] = $icon;
|
2012-10-15 Dario Rodriguez <dario.rodriguez@artica.es>
* operation/extensions.php,
godmode/extensions.php,
include/functions_extensions.php,
extensions/insert_data.php,
extensions/snmp_explorer.php,
extensions/system_info.php,
extensions/net_tools.php,
extensions/extension_uploader.php,
extensions/pandora_logs.php,
extensions/agents_modules.php,
extensions/update_manager.php,
extensions/ssh_gateway.php,
extensions/dbmanager.php,
extensions/vnc_view.php,
extensions/resource_registration.php,
extensions/users_connected.php,
extensions/resource_exportation.php,
extensions/module_groups.php,
extensions/plugin_registration.php: Modified extension to
show versions.
MERGED FROM 4.0.2
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7074 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-15 12:23:31 +02:00
|
|
|
$option_menu['version'] = $version;
|
2012-10-25 18:46:52 +02:00
|
|
|
|
2008-08-04 10:15:16 +02:00
|
|
|
$extension['operation_menu'] = $option_menu;
|
|
|
|
}
|
|
|
|
|
2009-01-08 16:52:13 +01:00
|
|
|
/**
|
2011-04-27 15:43:31 +02:00
|
|
|
* This function adds a link to the extension with the given name in Godmode menu.
|
2009-01-08 16:52:13 +01:00
|
|
|
*
|
2011-04-27 15:43:31 +02:00
|
|
|
* @param string name Name of the extension in the Godmode menu
|
|
|
|
* @param string acl User ACL level required to see this extension in the godmode menu
|
|
|
|
* @param string fatherId Id of the parent menu item for the current extension
|
2015-04-09 15:04:23 +02:00
|
|
|
* @param string subfatherId Id of the parent submenu item for the current extension
|
2011-04-27 15:43:31 +02:00
|
|
|
* @param string icon Path to the icon image (18x18 px). If this parameter is blank then predefined icon will be used
|
2009-01-08 16:52:13 +01:00
|
|
|
*/
|
2015-04-09 15:04:23 +02:00
|
|
|
function extensions_add_godmode_menu_option ($name, $acl, $fatherId = null, $icon = null, $version="N/A", $subfatherId = null) {
|
2008-08-04 10:15:16 +02:00
|
|
|
global $config;
|
|
|
|
global $extension_file;
|
|
|
|
|
2013-03-04 15:41:26 +01:00
|
|
|
/*
|
|
|
|
$config['extension_file'] is set in extensions_load_extensions(),
|
|
|
|
since that function must be called before any function the extension
|
|
|
|
call, we are sure it will be set. */
|
2008-08-04 10:15:16 +02:00
|
|
|
$option_menu['acl'] = $acl;
|
2011-02-22 12:31:39 +01:00
|
|
|
$option_menu['name'] = $name;
|
2008-08-04 10:15:16 +02:00
|
|
|
$extension = &$config['extensions'][$extension_file];
|
2013-06-25 15:30:13 +02:00
|
|
|
$option_menu['sec2'] = $extension['dir'] . '/' . mb_substr ($extension_file, 0, -4);
|
2009-08-27 18:57:19 +02:00
|
|
|
$option_menu['fatherId'] = $fatherId;
|
2015-04-09 15:04:23 +02:00
|
|
|
$option_menu['subfatherId'] = $subfatherId;
|
2009-08-27 18:57:19 +02:00
|
|
|
$option_menu['icon'] = $icon;
|
2012-10-15 Dario Rodriguez <dario.rodriguez@artica.es>
* operation/extensions.php,
godmode/extensions.php,
include/functions_extensions.php,
extensions/insert_data.php,
extensions/snmp_explorer.php,
extensions/system_info.php,
extensions/net_tools.php,
extensions/extension_uploader.php,
extensions/pandora_logs.php,
extensions/agents_modules.php,
extensions/update_manager.php,
extensions/ssh_gateway.php,
extensions/dbmanager.php,
extensions/vnc_view.php,
extensions/resource_registration.php,
extensions/users_connected.php,
extensions/resource_exportation.php,
extensions/module_groups.php,
extensions/plugin_registration.php: Modified extension to
show versions.
MERGED FROM 4.0.2
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7074 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-15 12:23:31 +02:00
|
|
|
$option_menu['version'] = $version;
|
2008-08-04 10:15:16 +02:00
|
|
|
$extension['godmode_menu'] = $option_menu;
|
|
|
|
}
|
|
|
|
|
2010-11-15 14:36:01 +01:00
|
|
|
/**
|
2011-04-27 15:43:31 +02:00
|
|
|
* Add in the header tabs in Godmode agent menu the extension tab.
|
2010-11-15 14:36:01 +01:00
|
|
|
*
|
2011-04-27 15:43:31 +02:00
|
|
|
* @param tabId Id of the extension tab
|
|
|
|
* @param tabName Name of the extension tab
|
|
|
|
* @param tabIcon Path to the image icon
|
|
|
|
* @param tabFunction Name of the function to execute when this extension is called
|
2010-11-15 14:36:01 +01:00
|
|
|
*/
|
2012-10-15 Dario Rodriguez <dario.rodriguez@artica.es>
* operation/extensions.php,
godmode/extensions.php,
include/functions_extensions.php,
extensions/insert_data.php,
extensions/snmp_explorer.php,
extensions/system_info.php,
extensions/net_tools.php,
extensions/extension_uploader.php,
extensions/pandora_logs.php,
extensions/agents_modules.php,
extensions/update_manager.php,
extensions/ssh_gateway.php,
extensions/dbmanager.php,
extensions/vnc_view.php,
extensions/resource_registration.php,
extensions/users_connected.php,
extensions/resource_exportation.php,
extensions/module_groups.php,
extensions/plugin_registration.php: Modified extension to
show versions.
MERGED FROM 4.0.2
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7074 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-15 12:23:31 +02:00
|
|
|
function extensions_add_godmode_tab_agent($tabId, $tabName, $tabIcon, $tabFunction, $version="N/A") {
|
2010-11-15 14:36:01 +01:00
|
|
|
global $config;
|
|
|
|
global $extension_file;
|
|
|
|
|
|
|
|
$extension = &$config['extensions'][$extension_file];
|
|
|
|
$extension['extension_god_tab'] = array();
|
|
|
|
$extension['extension_god_tab']['id'] = $tabId;
|
|
|
|
$extension['extension_god_tab']['name'] = $tabName;
|
|
|
|
$extension['extension_god_tab']['icon'] = $tabIcon;
|
|
|
|
$extension['extension_god_tab']['function'] = $tabFunction;
|
2012-10-15 Dario Rodriguez <dario.rodriguez@artica.es>
* operation/extensions.php,
godmode/extensions.php,
include/functions_extensions.php,
extensions/insert_data.php,
extensions/snmp_explorer.php,
extensions/system_info.php,
extensions/net_tools.php,
extensions/extension_uploader.php,
extensions/pandora_logs.php,
extensions/agents_modules.php,
extensions/update_manager.php,
extensions/ssh_gateway.php,
extensions/dbmanager.php,
extensions/vnc_view.php,
extensions/resource_registration.php,
extensions/users_connected.php,
extensions/resource_exportation.php,
extensions/module_groups.php,
extensions/plugin_registration.php: Modified extension to
show versions.
MERGED FROM 4.0.2
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7074 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-15 12:23:31 +02:00
|
|
|
$extension['extension_god_tab']['version'] = $version;
|
2010-11-15 14:36:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-04-27 15:43:31 +02:00
|
|
|
* Add in the header tabs in Operation agent menu the extension tab.
|
2010-11-15 14:36:01 +01:00
|
|
|
*
|
2011-04-27 15:43:31 +02:00
|
|
|
* @param tabId Id of the extension tab
|
|
|
|
* @param tabName Name of the extension tab
|
|
|
|
* @param tabIcon Path to the image icon
|
|
|
|
* @param tabFunction Name of the function to execute when this extension is called
|
2010-11-15 14:36:01 +01:00
|
|
|
*/
|
2012-10-15 Dario Rodriguez <dario.rodriguez@artica.es>
* operation/extensions.php,
godmode/extensions.php,
include/functions_extensions.php,
extensions/insert_data.php,
extensions/snmp_explorer.php,
extensions/system_info.php,
extensions/net_tools.php,
extensions/extension_uploader.php,
extensions/pandora_logs.php,
extensions/agents_modules.php,
extensions/update_manager.php,
extensions/ssh_gateway.php,
extensions/dbmanager.php,
extensions/vnc_view.php,
extensions/resource_registration.php,
extensions/users_connected.php,
extensions/resource_exportation.php,
extensions/module_groups.php,
extensions/plugin_registration.php: Modified extension to
show versions.
MERGED FROM 4.0.2
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7074 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-10-15 12:23:31 +02:00
|
|
|
function extensions_add_opemode_tab_agent($tabId, $tabName, $tabIcon, $tabFunction, $version="N/A") {
|
2010-11-15 14:36:01 +01:00
|
|
|
global $config;
|
|
|
|
global $extension_file;
|
|
|
|
|
|
|
|
$extension = &$config['extensions'][$extension_file];
|
|
|
|
$extension['extension_ope_tab'] = array();
|
|
|
|
$extension['extension_ope_tab']['id'] = $tabId;
|
|
|
|
$extension['extension_ope_tab']['name'] = $tabName;
|
|
|
|
$extension['extension_ope_tab']['icon'] = $tabIcon;
|
|
|
|
$extension['extension_ope_tab']['function'] = $tabFunction;
|
2013-03-04 15:41:26 +01:00
|
|
|
$extension['extension_ope_tab']['version'] = $version;
|
2010-11-15 14:36:01 +01:00
|
|
|
}
|
|
|
|
|
2009-01-08 16:52:13 +01:00
|
|
|
/**
|
2011-04-27 15:43:31 +02:00
|
|
|
* Add the function to call when user clicks on the Operation menu link
|
2009-01-08 16:52:13 +01:00
|
|
|
*
|
2011-04-27 15:43:31 +02:00
|
|
|
* @param string $function_name Callback function name
|
2009-01-08 16:52:13 +01:00
|
|
|
*/
|
2011-05-11 14:15:14 +02:00
|
|
|
function extensions_add_main_function ($function_name) {
|
2008-08-04 10:15:16 +02:00
|
|
|
global $config;
|
|
|
|
global $extension_file;
|
|
|
|
|
|
|
|
$extension = &$config['extensions'][$extension_file];
|
|
|
|
$extension['main_function'] = $function_name;
|
|
|
|
}
|
|
|
|
|
2009-01-08 16:52:13 +01:00
|
|
|
/**
|
2011-04-27 15:43:31 +02:00
|
|
|
* Add the function to call when user clicks on the Godmode menu link
|
2009-01-08 16:52:13 +01:00
|
|
|
*
|
2011-04-27 15:43:31 +02:00
|
|
|
* @param string $function_name Callback function name
|
2009-01-08 16:52:13 +01:00
|
|
|
*/
|
2011-05-11 14:15:14 +02:00
|
|
|
function extensions_add_godmode_function ($function_name) {
|
2008-08-04 10:15:16 +02:00
|
|
|
global $config;
|
|
|
|
global $extension_file;
|
|
|
|
|
|
|
|
$extension = &$config['extensions'][$extension_file];
|
|
|
|
$extension['godmode_function'] = $function_name;
|
|
|
|
}
|
|
|
|
|
2009-01-08 16:52:13 +01:00
|
|
|
/**
|
2011-04-27 15:43:31 +02:00
|
|
|
* Adds extension function when user login on Pandora console
|
2009-01-08 16:52:13 +01:00
|
|
|
*
|
2011-04-27 15:43:31 +02:00
|
|
|
* @param string $function_name Callback function name
|
2009-01-08 16:52:13 +01:00
|
|
|
*/
|
2011-05-11 14:15:14 +02:00
|
|
|
function extensions_add_login_function ($function_name) {
|
2008-08-04 10:15:16 +02:00
|
|
|
global $config;
|
|
|
|
global $extension_file;
|
|
|
|
|
|
|
|
$extension = &$config['extensions'][$extension_file];
|
|
|
|
$extension['login_function'] = $function_name;
|
|
|
|
}
|
|
|
|
?>
|