2009-05-01 17:01:52 +02:00
< ? php
2009-06-08 20:26:14 +02:00
//Pandora FMS- http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
2009-05-01 17:01:52 +02:00
// 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 for 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.
2009-05-04 15:11:16 +02:00
function dbmanager_query ( $sql , & $error ) {
2009-05-02 01:41:09 +02:00
global $config ;
$retval = array ();
if ( $sql == '' )
return false ;
2009-11-19 21:04:11 +01:00
$sql = html_entity_decode ( $sql , ENT_QUOTES );
2009-05-02 01:41:09 +02:00
$result = mysql_query ( $sql );
if ( $result === false ) {
$backtrace = debug_backtrace ();
2009-05-04 15:11:16 +02:00
$error = mysql_error ();
2009-05-02 01:41:09 +02:00
return false ;
2009-05-04 15:11:16 +02:00
}
if ( $result === true ) {
return mysql_affected_rows ();
}
while ( $row = mysql_fetch_array ( $result , MYSQL_ASSOC )) {
array_push ( $retval , $row );
2009-05-02 01:41:09 +02:00
}
2009-05-04 15:11:16 +02:00
mysql_free_result ( $result );
2009-05-02 01:41:09 +02:00
if ( ! empty ( $retval ))
return $retval ;
2010-02-19 Sancho Lerena <slerena@artica.es>
* functions_events.php: Fixed typo (switched meaning) in two labels.
* include/styles/pandora.css: Changed background color of th default style.
* include/functions_reporting.php: Improved function get_group_stats(). Now
supports stats from batch-mode and get realtime stats in a more efficient
way. Fixed get_fired_alerts_reporting_table() to avoid problems in external
reporting (PDF & XML).
* include/functions_servers.php: get_server_performance() now uses batch mode
stats reporting, and improved also the realtime stats generation. Same with
function get_server_info().
* include/functions_config.php: Added new config tokens (not fully
implemented yet) for event, trap, strings and audit automatic purge.
* include/functions_ui.php: Added new print_page_header() function to set
the new standard header in all pages, using the "tabbed" format to show
the title, subtitle and other options like help, or custom-tabs for the page
* pandoradb.sql: Added tserver.stat_utimestamp field. Added indexes to
tsession table. Fixed typo in field name in tgroup_stat: agents_uknown to
agents_unknown.
* extensions/ext_backup: New directory to place "deleted" extensions.
* extensions/dbmanager/dbmanager.css: Table names now are in it's original
lowercase/uppercase format.
* extensions/dbmanager.php: Updated headers, and now return "empty" when
a search is empty, instead "error" as before.
* extensions/users_connected.php
extensions/module_groups.php
extensions/plugin_registration.php
extensions/pandora_logs.php
operation/incidents/incident.php
operation/snmpconsole/snmp_view.php
operation/users/user.php
operation/users/user_edit.php
godmode/agentes/planned_downtime.php
operation/events/events.php
operation/visual_console/index.php
operation/agentes/estado_generalagente.php
operation/agentes/estado_agente.php
operation/agentes/exportdata.php
operation/agentes/ver_agente.php
operation/agentes/status_monitor.php
operation/agentes/alerts_status.php
operation/users/user_statistics.php: Added new header format.
* operation/agentes/estado_grupo.php: Removed old group view.
* operation/agentes/tactical.php: Adapted to use new realtime/batch
statistical system. Placed events above server info. Showing only pending
events and other minor changes.
* operation/agentes/group_view.php: NEW screen, replacing old one. Probably
most ugly, but much more useful than before.
* operation/agentes/networkmap.php: Added title.
* operation/messages/message.php: Added title and adding some exists in
code was missing before.
* operation/reporting/reporting_viewer.php: Added title.
* operation/reporting/graph_viewer.php: Added title.
* operation/reporting/custom_reporting.php: Added title.
* operation/servers/view_server.php:
* operation/menu.php: Replaced old group view with new (this has english
name). Removed autorefresh "by default" in server view.
* extras/pandoradb_migrate_v3.0_to_v3.1.sql: Fixed typo.
* extras/pandora_diag.php: Minor changes, removed some info and added other.
* general/logon_ok.php: Minor aesthetic changes.
* general/header.php: Fixed missing ";"
* operation/extensions.php,
godmode/extensions.php: Added support for delete extensions.
* godmode/menu.php: New setup items.
* godmode/setup/setup.php,
godmode/setup/performance.php,
godmode/setup/setup_visuals.php: Reordered setup options, new setup section
"Performance", added new performance options to set "realtime" statistics
or "batchmode" with it's own interval. Some setup info is now shared with
the servers (but it it's any change in setup, servers should be restarted
anyway).
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2390 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-02-19 16:16:03 +01:00
2009-05-02 01:41:09 +02:00
//Return false, check with === or !==
2010-02-19 Sancho Lerena <slerena@artica.es>
* functions_events.php: Fixed typo (switched meaning) in two labels.
* include/styles/pandora.css: Changed background color of th default style.
* include/functions_reporting.php: Improved function get_group_stats(). Now
supports stats from batch-mode and get realtime stats in a more efficient
way. Fixed get_fired_alerts_reporting_table() to avoid problems in external
reporting (PDF & XML).
* include/functions_servers.php: get_server_performance() now uses batch mode
stats reporting, and improved also the realtime stats generation. Same with
function get_server_info().
* include/functions_config.php: Added new config tokens (not fully
implemented yet) for event, trap, strings and audit automatic purge.
* include/functions_ui.php: Added new print_page_header() function to set
the new standard header in all pages, using the "tabbed" format to show
the title, subtitle and other options like help, or custom-tabs for the page
* pandoradb.sql: Added tserver.stat_utimestamp field. Added indexes to
tsession table. Fixed typo in field name in tgroup_stat: agents_uknown to
agents_unknown.
* extensions/ext_backup: New directory to place "deleted" extensions.
* extensions/dbmanager/dbmanager.css: Table names now are in it's original
lowercase/uppercase format.
* extensions/dbmanager.php: Updated headers, and now return "empty" when
a search is empty, instead "error" as before.
* extensions/users_connected.php
extensions/module_groups.php
extensions/plugin_registration.php
extensions/pandora_logs.php
operation/incidents/incident.php
operation/snmpconsole/snmp_view.php
operation/users/user.php
operation/users/user_edit.php
godmode/agentes/planned_downtime.php
operation/events/events.php
operation/visual_console/index.php
operation/agentes/estado_generalagente.php
operation/agentes/estado_agente.php
operation/agentes/exportdata.php
operation/agentes/ver_agente.php
operation/agentes/status_monitor.php
operation/agentes/alerts_status.php
operation/users/user_statistics.php: Added new header format.
* operation/agentes/estado_grupo.php: Removed old group view.
* operation/agentes/tactical.php: Adapted to use new realtime/batch
statistical system. Placed events above server info. Showing only pending
events and other minor changes.
* operation/agentes/group_view.php: NEW screen, replacing old one. Probably
most ugly, but much more useful than before.
* operation/agentes/networkmap.php: Added title.
* operation/messages/message.php: Added title and adding some exists in
code was missing before.
* operation/reporting/reporting_viewer.php: Added title.
* operation/reporting/graph_viewer.php: Added title.
* operation/reporting/custom_reporting.php: Added title.
* operation/servers/view_server.php:
* operation/menu.php: Replaced old group view with new (this has english
name). Removed autorefresh "by default" in server view.
* extras/pandoradb_migrate_v3.0_to_v3.1.sql: Fixed typo.
* extras/pandora_diag.php: Minor changes, removed some info and added other.
* general/logon_ok.php: Minor aesthetic changes.
* general/header.php: Fixed missing ";"
* operation/extensions.php,
godmode/extensions.php: Added support for delete extensions.
* godmode/menu.php: New setup items.
* godmode/setup/setup.php,
godmode/setup/performance.php,
godmode/setup/setup_visuals.php: Reordered setup options, new setup section
"Performance", added new performance options to set "realtime" statistics
or "batchmode" with it's own interval. Some setup info is now shared with
the servers (but it it's any change in setup, servers should be restarted
anyway).
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2390 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-02-19 16:16:03 +01:00
return " Empty " ;
2009-05-02 01:41:09 +02:00
}
2009-05-01 17:01:52 +02:00
function dbmgr_extension_main () {
2009-05-04 15:11:16 +02:00
require_css_file ( 'dbmanager' , 'extensions/dbmanager/' );
2009-05-01 17:01:52 +02:00
2010-03-06 14:45:48 +01:00
global $config ;
if ( ! give_acl ( $config [ 'id_user' ], 0 , " PM " ) && ! is_user_admin ( $config [ 'id_user' ])) {
2010-10-27 Miguel de Dios <miguel.dedios@artica.es>
* godmode/admin_access_logs.php: added hooks to enterprise code, and added
new filter with more options.
* include/functions_db.php: erase the deprecated function "audit_db", and
added in function "pandora_audit" two new parameters $user_id, $ip for
pass this values when it are differents to the default values. Finally
replaced the depecrated "audit_db" for "pandora_audit".
* include/functions_events.php, include/functions_filemanager.php,
include/ajax/reporting.ajax.php,
include/ajax/visual_console_builder.ajax.php,
include/ajax/alert_list.ajax.php, include/help/es/modu_group_list.php,
include/functions_incidents.php, index.php, extensions/agents_modules.php,
extensions/insert_data.php, extensions/system_info.php,
extensions/dbmanager.php, extensions/update_manager/settings.php,
extensions/pandora_logs.php, extensions/plugin_registration.php,
operation/incidents/incident.php, operation/incidents/incident_detail.php,
operation/incidents/incident_statistics.php, operation/extensions.php,
operation/visual_console/render_view.php,
operation/agentes/status_monitor.php, operation/agentes/export_csv.php,
operation/agentes/datos_agente.php, operation/agentes/alerts_status.php,
operation/agentes/estado_generalagente.php,
operation/agentes/custom_fields.php, operation/agentes/estado_agente.php,
operation/agentes/networkmap.topology.php,
operation/agentes/networkmap.groups.php, operation/agentes/sla_view.php,
operation/agentes/gis_view.php, operation/agentes/estado_monitores.php,
operation/agentes/ver_agente.php, operation/agentes/graphs.php,
operation/agentes/agent_fields.php, operation/agentes/tactical.php,
operation/agentes/group_view.php, operation/agentes/networkmap.php,
operation/servers/view_server.php,operation/servers/view_server_detail.php,
operation/snmpconsole/snmp_view.php, operation/users/user_edit.php,
operation/gis_maps/render_view.php, operation/events/event_statistics.php,
operation/events/sound_events.php, operation/events/events_validate.php,
operation/events/events_list.php, operation/events/events_marquee.php,
operation/events/events.php, operation/reporting/reporting_xml.php,
operation/reporting/reporting_viewer.php,
operation/reporting/graph_viewer.php,
mobile/operation/agents/view_agents.php, mobile/index.php,
godmode/groups/modu_group_list.php, godmode/groups/configure_group.php,
godmode/groups/configure_modu_group.php, godmode/groups/group_list.php,
godmode/extensions.php, godmode/db/db_main.php, godmode/db/db_audit.php,
godmode/db/db_sanity.php, godmode/db/db_refine.php, godmode/db/db_info.php,
godmode/db/db_event.php, godmode/db/db_purge.php,
godmode/agentes/fields_manager.php, godmode/agentes/module_manager.php,
godmode/agentes/modificar_agente.php, godmode/agentes/configurar_agente.php,
godmode/agentes/configure_field.php, godmode/agentes/planned_downtime.php,
godmode/agentes/manage_config_remote.php, godmode/agentes/agent_manager.php,
godmode/servers/manage_export.php, godmode/servers/recon_script.php,
godmode/servers/manage_export_form.php, godmode/servers/plugin.php,
godmode/servers/manage_recontask.php, godmode/servers/modificar_server.php,
godmode/servers/manage_recontask_form.php,
godmode/alerts/alert_list.list.php,
godmode/alerts/configure_alert_compound.php,
godmode/alerts/alert_compounds.php, godmode/alerts/alert_list.php,
godmode/alerts/configure_alert_template.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_action.php,
godmode/alerts/configure_alert_command.php,
godmode/alerts/alert_actions.php, godmode/alerts/alert_list.builder.php,
godmode/alerts/alert_commands.php, godmode/snmpconsole/snmp_alert.php,
godmode/snmpconsole/snmp_filters.php, godmode/setup/file_manager.php,
godmode/setup/os.list.php, godmode/setup/news.php,
godmode/setup/gis_step_2.php, godmode/setup/links.php,
godmode/setup/setup.php, godmode/setup/os.php,
godmode/setup/performance.php, godmode/setup/setup_auth.php,
godmode/setup/gis.php, godmode/setup/os.builder.php,
godmode/setup/setup_visuals.php, godmode/users/user_list.php,
godmode/users/configure_user.php, godmode/users/configure_profile.php,
godmode/gis_maps/configure_gis_map.php, godmode/gis_maps/index.php,
godmode/massive/massive_add_alerts.php,
godmode/massive/massive_copy_modules.php,
godmode/massive/massive_delete_agents.php,
godmode/massive/massive_enable_disable_alerts.php,
godmode/massive/massive_operations.php,
godmode/massive/massive_delete_profiles.php,
godmode/massive/massive_edit_agents.php,
godmode/massive/massive_delete_action_alerts.php,
godmode/massive/massive_delete_modules.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_delete_alerts.php,
godmode/massive/massive_edit_modules.php,
godmode/massive/massive_standby_alerts.php,
godmode/massive/massive_add_action_alerts.php,
godmode/modules/manage_network_components_form.php,
godmode/modules/manage_nc_groups_form.php,
godmode/modules/manage_network_templates.php,
godmode/modules/module_list.php,
godmode/modules/manage_network_components_form_common.php,
godmode/modules/manage_network_components_form_network.php,
godmode/modules/manage_network_templates_form.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/modules/manage_nc_groups.php,
godmode/reporting/reporting_builder.list_items.php,
godmode/reporting/graph_builder.main.php,
godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/visual_console_builder.php,
godmode/reporting/reporting_builder.preview.php,
godmode/reporting/reporting_builder.main.php,
godmode/reporting/visual_console_builder.data.php,
godmode/reporting/map_builder_wizard.php,
godmode/reporting/visual_console_builder.elements.php,
godmode/reporting/graph_builder.php,
godmode/reporting/visual_console_builder.preview.php,
godmode/reporting/graph_builder.graph_editor.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/visual_console_builder.editor.php,
godmode/reporting/reporting_builder.item_editor.php,
godmode/reporting/graphs.php, godmode/reporting/graph_builder.preview.php:
Replaced the depecrated "audit_db" for "pandora_audit".
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3467 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-10-27 12:47:07 +02:00
pandora_audit ( " ACL Violation " , " Trying to access Setup Management " );
2010-03-06 14:45:48 +01:00
require ( " general/noaccess.php " );
return ;
}
2009-05-04 15:11:16 +02:00
$sql = ( string ) get_parameter ( 'sql' );
2009-05-01 17:01:52 +02:00
2010-02-19 Sancho Lerena <slerena@artica.es>
* functions_events.php: Fixed typo (switched meaning) in two labels.
* include/styles/pandora.css: Changed background color of th default style.
* include/functions_reporting.php: Improved function get_group_stats(). Now
supports stats from batch-mode and get realtime stats in a more efficient
way. Fixed get_fired_alerts_reporting_table() to avoid problems in external
reporting (PDF & XML).
* include/functions_servers.php: get_server_performance() now uses batch mode
stats reporting, and improved also the realtime stats generation. Same with
function get_server_info().
* include/functions_config.php: Added new config tokens (not fully
implemented yet) for event, trap, strings and audit automatic purge.
* include/functions_ui.php: Added new print_page_header() function to set
the new standard header in all pages, using the "tabbed" format to show
the title, subtitle and other options like help, or custom-tabs for the page
* pandoradb.sql: Added tserver.stat_utimestamp field. Added indexes to
tsession table. Fixed typo in field name in tgroup_stat: agents_uknown to
agents_unknown.
* extensions/ext_backup: New directory to place "deleted" extensions.
* extensions/dbmanager/dbmanager.css: Table names now are in it's original
lowercase/uppercase format.
* extensions/dbmanager.php: Updated headers, and now return "empty" when
a search is empty, instead "error" as before.
* extensions/users_connected.php
extensions/module_groups.php
extensions/plugin_registration.php
extensions/pandora_logs.php
operation/incidents/incident.php
operation/snmpconsole/snmp_view.php
operation/users/user.php
operation/users/user_edit.php
godmode/agentes/planned_downtime.php
operation/events/events.php
operation/visual_console/index.php
operation/agentes/estado_generalagente.php
operation/agentes/estado_agente.php
operation/agentes/exportdata.php
operation/agentes/ver_agente.php
operation/agentes/status_monitor.php
operation/agentes/alerts_status.php
operation/users/user_statistics.php: Added new header format.
* operation/agentes/estado_grupo.php: Removed old group view.
* operation/agentes/tactical.php: Adapted to use new realtime/batch
statistical system. Placed events above server info. Showing only pending
events and other minor changes.
* operation/agentes/group_view.php: NEW screen, replacing old one. Probably
most ugly, but much more useful than before.
* operation/agentes/networkmap.php: Added title.
* operation/messages/message.php: Added title and adding some exists in
code was missing before.
* operation/reporting/reporting_viewer.php: Added title.
* operation/reporting/graph_viewer.php: Added title.
* operation/reporting/custom_reporting.php: Added title.
* operation/servers/view_server.php:
* operation/menu.php: Replaced old group view with new (this has english
name). Removed autorefresh "by default" in server view.
* extras/pandoradb_migrate_v3.0_to_v3.1.sql: Fixed typo.
* extras/pandora_diag.php: Minor changes, removed some info and added other.
* general/logon_ok.php: Minor aesthetic changes.
* general/header.php: Fixed missing ";"
* operation/extensions.php,
godmode/extensions.php: Added support for delete extensions.
* godmode/menu.php: New setup items.
* godmode/setup/setup.php,
godmode/setup/performance.php,
godmode/setup/setup_visuals.php: Reordered setup options, new setup section
"Performance", added new performance options to set "realtime" statistics
or "batchmode" with it's own interval. Some setup info is now shared with
the servers (but it it's any change in setup, servers should be restarted
anyway).
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2390 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-02-19 16:16:03 +01:00
print_page_header ( __ ( 'Database interface' ), " " , false , false , true );
2009-05-04 15:11:16 +02:00
echo '<div class="notify">' ;
echo " This is an advanced extension to interface with Pandora FMS database directly from WEB console using native SQL sentences. Please note that <b>you can damage</b> your Pandora FMS installation if you don't know </b>exactly</b> what are you doing, this means that you can severily damage your setup using this extension. This extension is intended to be used <b>only by experienced users</b> with a depth knowledgue of Pandora FMS internals. " ;
echo '</div>' ;
2009-05-01 17:01:52 +02:00
2009-05-04 15:11:16 +02:00
echo " <br /> " ;
echo " Some samples of usage: <blockquote><em>SHOW STATUS;<br />DESCRIBE tagente<br />SELECT * FROM tserver<br />UPDATE tagente SET id_grupo = 15 WHERE nombre LIKE '%194.179%'</em></blockquote> " ;
2009-05-01 17:01:52 +02:00
2009-05-04 15:11:16 +02:00
echo " <br /><br /> " ;
2009-05-01 17:01:52 +02:00
echo " <form method='post' action=''> " ;
2010-02-01 20:22:34 +01:00
print_textarea ( 'sql' , 5 , 40 , html_entity_decode ( $sql , ENT_QUOTES ));
2009-05-04 15:11:16 +02:00
echo '<br />' ;
2010-02-01 20:22:34 +01:00
echo '<div class="action-buttons" style="width: 96%">' ;
2009-05-04 15:11:16 +02:00
print_submit_button ( __ ( 'Execute SQL' ), '' , false , 'class="sub next"' );
echo '</div>' ;
2009-05-01 17:01:52 +02:00
echo " </form> " ;
// Processing SQL Code
2009-05-04 15:11:16 +02:00
if ( $sql == '' )
return ;
echo " <br /> " ;
echo " <hr /> " ;
echo " <br /> " ;
$error = '' ;
$result = dbmanager_query ( $sql , $error );
if ( $result === false ) {
echo '<strong>An error has occured when querying the database.</strong><br />' ;
echo $error ;
return ;
}
if ( ! is_array ( $result )) {
echo " <strong>Output: <strong> " . $result ;
return ;
}
$table -> width = '90%' ;
$table -> class = 'dbmanager' ;
$table -> head = array_keys ( $result [ 0 ]);
$table -> data = $result ;
print_table ( $table );
2009-05-01 17:01:52 +02:00
}
/* This adds a option in the operation menu */
2009-12-27 22:50:32 +01:00
add_godmode_menu_option ( __ ( 'DB interface' ), 'PM' , 'gdbman' , " dbmanager/icon.png " );
2009-05-01 17:01:52 +02:00
/* This sets the function to be called when the extension is selected in the operation menu */
add_extension_godmode_function ( 'dbmgr_extension_main' );
?>