pandorafms/pandora_console/extensions/update_manager.php

168 lines
4.9 KiB
PHP
Raw Normal View History

<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// 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.
function load_update_manager_lib () {
set_time_limit (0);
require_once ('update_manager/load_updatemanager.php');
}
function update_settings_database_connection () {
global $config;
um_db_connect ('mysql', $config['dbhost'], $config['dbuser'],
$config['dbpass'], $config['dbname']);
um_db_update_setting ('dbname', $config['dbname']);
um_db_update_setting ('dbuser', $config['dbuser']);
um_db_update_setting ('dbpass', $config['dbpass']);
um_db_update_setting ('dbhost', $config['dbhost']);
}
function pandora_update_manager_install () {
global $config;
if (isset ($config['update_manager_installed']))
/* Already installed */
return;
load_update_manager_lib ();
/* SQL installation */
switch ($config['dbtype']) {
case 'mysql':
$sentences = file (EXTENSIONS_DIR.'/update_manager/sql/update_manager.sql');
break;
case 'postgresql':
$sentences = file (EXTENSIONS_DIR.'/update_manager/sql/update_manager.postgreSQL.sql');
break;
2011-04-11 Juan Manuel Ramon <juanmanuel.ramon@artica.es> * include/functions_events.php include/functions_messages.php include/db/oracle.php include/functions_modules.php include/functions_reporting.php include/functions_groups.php include/functions_gis.php include/auth/mysql.php include/functions_networkmap.php include/functions_servers.php include/functions_network_components.php include/ajax/reporting.ajax.php include/ajax/agent.php include/functions_config.php include/functions_api.php include/help/en/help_timesource.php include/help/es/help_timesource.php include/help/ja/help_timesource.php include/fgraph.php include/functions.php include/functions_agents.php include/functions_db.php include/functions_fsgraph.php include/functions_alerts.php include/functions_reports.php pandoradb.oracle.sql install.php extensions/system_info.php extensions/update_manager.php extensions/dbmanager.php extensions/users_connected.php extensions/module_groups.php extensions/update_manager/sql/update_manager.oracle.sql extensions/update_manager/load_updatemanager.php extensions/update_manager/lib/libupdate_manager_client.php extensions/update_manager/lib/libupdate_manager.php extensions/update_manager/lib/libupdate_manager_components.php extensions/update_manager/lib/libupdate_manager_updates.php operation/search_modules.php operation/agentes/status_monitor.php operation/agentes/alerts_status.php operation/agentes/datos_agente.php operation/agentes/estado_ultimopaquete.php operation/agentes/exportdata.php operation/agentes/gis_view.php operation/agentes/estado_monitores.php operation/agentes/ver_agente.php operation/snmpconsole/snmp_view.php operation/users/user_edit.php operation/gis_maps/render_view.php operation/gis_maps/ajax.php operation/events/events_rss.php operation/events/events_list.php operation/events/events_marquee.php operation/search_alerts.php operation/reporting/reporting_xml.php operation/reporting/reporting_viewer.php pandoradb.data.oracle.sql extras/pandora_diag.php mobile/operation/agents/monitor_status.php mobile/operation/agents/view_agents.php mobile/operation/events/events.php general/logon_ok.php godmode/groups/group_list.php godmode/admin_access_logs.php godmode/db/db_main.php godmode/agentes/agent_template.php godmode/agentes/module_manager.php godmode/agentes/modificar_agente.php godmode/agentes/configurar_agente.php godmode/agentes/module_manager_editor.php godmode/agentes/planned_downtime.php godmode/alerts/alert_list.list.php godmode/alerts/alert_compounds.php godmode/alerts/alert_list.php godmode/setup/setup.php godmode/modules/manage_network_templates.php godmode/modules/manage_network_templates_form.php godmode/reporting/reporting_builder.list_items.php godmode/reporting/reporting_builder.preview.php godmode/reporting/reporting_builder.php godmode/reporting/reporting_builder.item_editor.php: Support for Oracle DBMS over Console code. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4187 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-04-11 19:05:20 +02:00
case 'oracle':
$sentences = file (EXTENSIONS_DIR.'/update_manager/sql/update_manager.oracle.sql');
break;
}
foreach ($sentences as $sentence) {
$success = process_sql ($sentence);
if ($success === false)
return;
}
$values = array("token" => "update_manager_installed", "value" => 1);
process_sql_insert('tconfig', $values);
um_db_connect ('mysql', $config['dbhost'], $config['dbuser'],
$config['dbpass'], $config['dbname']);
um_db_update_setting ('updating_code_path',
dirname ($_SERVER['SCRIPT_FILENAME']));
update_settings_database_connection ();
}
function pandora_update_manager_uninstall () {
global $config;
switch ($config["dbtype"]) {
case "mysql":
process_sql ('DELETE FROM `tconfig` WHERE `token` = "update_manager_installed"');
process_sql ('DROP TABLE `tupdate_settings`');
process_sql ('DROP TABLE `tupdate_journal`');
process_sql ('DROP TABLE `tupdate`');
process_sql ('DROP TABLE `tupdate_package`');
break;
case "postgresql":
process_sql ('DELETE FROM "tconfig" WHERE "token" = \'update_manager_installed\'');
process_sql ('DROP TABLE "tupdate_settings"');
process_sql ('DROP TABLE "tupdate_journal"');
process_sql ('DROP TABLE "tupdate"');
process_sql ('DROP TABLE "tupdate_package"');
break;
2011-04-11 Juan Manuel Ramon <juanmanuel.ramon@artica.es> * include/functions_events.php include/functions_messages.php include/db/oracle.php include/functions_modules.php include/functions_reporting.php include/functions_groups.php include/functions_gis.php include/auth/mysql.php include/functions_networkmap.php include/functions_servers.php include/functions_network_components.php include/ajax/reporting.ajax.php include/ajax/agent.php include/functions_config.php include/functions_api.php include/help/en/help_timesource.php include/help/es/help_timesource.php include/help/ja/help_timesource.php include/fgraph.php include/functions.php include/functions_agents.php include/functions_db.php include/functions_fsgraph.php include/functions_alerts.php include/functions_reports.php pandoradb.oracle.sql install.php extensions/system_info.php extensions/update_manager.php extensions/dbmanager.php extensions/users_connected.php extensions/module_groups.php extensions/update_manager/sql/update_manager.oracle.sql extensions/update_manager/load_updatemanager.php extensions/update_manager/lib/libupdate_manager_client.php extensions/update_manager/lib/libupdate_manager.php extensions/update_manager/lib/libupdate_manager_components.php extensions/update_manager/lib/libupdate_manager_updates.php operation/search_modules.php operation/agentes/status_monitor.php operation/agentes/alerts_status.php operation/agentes/datos_agente.php operation/agentes/estado_ultimopaquete.php operation/agentes/exportdata.php operation/agentes/gis_view.php operation/agentes/estado_monitores.php operation/agentes/ver_agente.php operation/snmpconsole/snmp_view.php operation/users/user_edit.php operation/gis_maps/render_view.php operation/gis_maps/ajax.php operation/events/events_rss.php operation/events/events_list.php operation/events/events_marquee.php operation/search_alerts.php operation/reporting/reporting_xml.php operation/reporting/reporting_viewer.php pandoradb.data.oracle.sql extras/pandora_diag.php mobile/operation/agents/monitor_status.php mobile/operation/agents/view_agents.php mobile/operation/events/events.php general/logon_ok.php godmode/groups/group_list.php godmode/admin_access_logs.php godmode/db/db_main.php godmode/agentes/agent_template.php godmode/agentes/module_manager.php godmode/agentes/modificar_agente.php godmode/agentes/configurar_agente.php godmode/agentes/module_manager_editor.php godmode/agentes/planned_downtime.php godmode/alerts/alert_list.list.php godmode/alerts/alert_compounds.php godmode/alerts/alert_list.php godmode/setup/setup.php godmode/modules/manage_network_templates.php godmode/modules/manage_network_templates_form.php godmode/reporting/reporting_builder.list_items.php godmode/reporting/reporting_builder.preview.php godmode/reporting/reporting_builder.php godmode/reporting/reporting_builder.item_editor.php: Support for Oracle DBMS over Console code. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4187 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-04-11 19:05:20 +02:00
case "oracle":
process_sql ('DELETE FROM tconfig WHERE token = \'update_manager_installed\'');
process_sql ('DROP TABLE tupdate_settings');
process_sql ('DROP TABLE tupdate_journal');
process_sql ('DROP TABLE tupdate');
process_sql ('DROP TABLE tupdate_package');
break;
}
}
function pandora_update_manager_main () {
global $config;
if (! check_acl($config['id_user'], 0, "PM")) {
require ("general/noaccess.php");
return;
}
load_update_manager_lib ();
update_settings_database_connection ();
require_once ('update_manager/main.php');
}
function pandora_update_manager_login () {
global $config;
// If first time, make the first autoupdate and disable it in DB
if (!isset($config["autoupdate"])){
$config["autoupdate"] = 1;
process_sql_insert('tconfig', array('token' => 'autoupdate', 'value' => 0));
}
if ($config["autoupdate"] == 0)
return;
load_update_manager_lib ();
um_db_connect ('mysql', $config['dbhost'], $config['dbuser'],
$config['dbpass'], $config['dbname']);
$settings = um_db_load_settings ();
$user_key = get_user_key ($settings);
$package = um_client_check_latest_update ($settings, $user_key);
if (is_object ($package)) {
echo '<div class="notify">';
echo '<img src="images/information.png" alt="info" /> ';
echo __('There\'s a new update for Pandora');
2009-02-09 19:41:54 +01:00
echo '. <a href="index.php?sec=extensions&amp;sec2=extensions/update_manager">';
echo __('More info');
echo '</a>';
echo '</div>';
}
}
function pandora_update_manager_godmode () {
global $config;
load_update_manager_lib ();
require_once ('update_manager/settings.php');
}
if(isset($config['id_user'])) {
if (check_acl($config['id_user'], 0, "PM")) {
add_operation_menu_option (__('Update manager'));
add_godmode_menu_option (__('Update manager settings'), 'PM','gsetup');
add_extension_main_function ('pandora_update_manager_main');
add_extension_godmode_function ('pandora_update_manager_godmode');
add_extension_login_function ('pandora_update_manager_login');
}
}
pandora_update_manager_install ();
$db = NULL;
?>