2008-10-22 Esteban Sanchez <estebans@artica.es>
* pandoradb.sql: Style correction. * godmode/agentes/agent_manager.php, godmode/agentes/configurar_agente.php: Removed inventory server configuration, which was moved to an enterprise hook. Style correction. * include/functions.php: Added slash to enterprise_include() path to work in some rare cases. * include/functions_db.php: Errors in process_sql() are shown using trigger_error(), so they can be disabled setting error_reporting(). * include/functions_html.php: Added print_input_image() to show input image HTML elements. * index.php: Added enterprise includes and hooks to show the future dashboard. Style corrections. * godmode/reporting/map_builder.php: Fixed error when creating a map. Javascript fixes. Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1185 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
ff10ed7ea4
commit
4b95234ace
|
@ -1,4 +1,28 @@
|
|||
2008-10-21 Esteban Sanchez <estebans@artica.es>
|
||||
2008-10-22 Esteban Sanchez <estebans@artica.es>
|
||||
|
||||
* pandoradb.sql: Style correction.
|
||||
|
||||
* godmode/agentes/agent_manager.php,
|
||||
godmode/agentes/configurar_agente.php: Removed inventory server
|
||||
configuration, which was moved to an enterprise hook. Style
|
||||
correction.
|
||||
|
||||
* include/functions.php: Added slash to enterprise_include() path to
|
||||
work in some rare cases.
|
||||
|
||||
* include/functions_db.php: Errors in process_sql() are shown using
|
||||
trigger_error(), so they can be disabled setting error_reporting().
|
||||
|
||||
* include/functions_html.php: Added print_input_image() to show input
|
||||
image HTML elements.
|
||||
|
||||
* index.php: Added enterprise includes and hooks to show the future
|
||||
dashboard. Style corrections.
|
||||
|
||||
* godmode/reporting/map_builder.php: Fixed error when creating a map.
|
||||
Javascript fixes. Style correction.
|
||||
|
||||
2008-10-22 Esteban Sanchez <estebans@artica.es>
|
||||
|
||||
* pandoradb.sql: Removed inventory tables and fields from previous
|
||||
commit.
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
|
||||
|
||||
// ========================
|
||||
// AGENT GENERAL DATA FORM
|
||||
// ========================
|
||||
// Load global vars
|
||||
require("include/config.php");
|
||||
require ('include/config.php');
|
||||
|
||||
enterprise_include ('godmode/agentes/agent_manager.php');
|
||||
|
||||
check_login ();
|
||||
|
||||
|
@ -175,19 +175,8 @@ if ($id_prediction_server == 0) {
|
|||
print_select_from_sql ('SELECT id_server, name FROM tserver WHERE prediction_server = 1 ORDER BY name',
|
||||
'prediction_server', $id_prediction_server, '', $none, $none_value);
|
||||
|
||||
// Inventory Server
|
||||
echo '<tr><td class="datos2"><b>'.__('Inventory Server').'</b>';
|
||||
echo '<a href="#" class="tip"> <span>'.__('You must select an Inventory Server for the Agent, so it can work properly with this kind of modules').'</span></a>';
|
||||
echo '</td><td class="datos2">';
|
||||
$none = '';
|
||||
$none_value = '';
|
||||
if ($id_inventory_server == 0) {
|
||||
$none = $none_str;
|
||||
$none_value = 0;
|
||||
}
|
||||
print_select_from_sql ('SELECT id_server, name FROM tserver WHERE inventory_server = 1 ORDER BY name',
|
||||
'inventory_server', $id_inventory_server, '', $none, $none_value);
|
||||
|
||||
enterprise_hook ('inventory_server');
|
||||
|
||||
// Description
|
||||
echo '<tr><td class="datos2"><b>';
|
||||
echo __('Description');
|
||||
|
|
|
@ -104,7 +104,6 @@ $id_network_server = 0;
|
|||
$id_plugin_server = 0;
|
||||
$id_prediction_server = 0;
|
||||
$id_wmi_server = 0;
|
||||
$id_inventory_server = 0;
|
||||
$grupo = 0;
|
||||
$id_os = 0;
|
||||
|
||||
|
@ -125,7 +124,6 @@ if (isset ($_POST["create_agent"])) { // Create a new and shiny agent
|
|||
$id_plugin_server = get_parameter_post ("plugin_server", 0);
|
||||
$id_prediction_server = get_parameter_post ("prediction_server", 0);
|
||||
$id_wmi_server = get_parameter_post ("wmi_server", 0);
|
||||
$id_inventory_server = get_parameter_post ("inventory_server", 0);
|
||||
$id_os = get_parameter_post ("id_os", 0);
|
||||
$disabled = get_parameter_post ("disabled", 0);
|
||||
|
||||
|
@ -138,11 +136,12 @@ if (isset ($_POST["create_agent"])) { // Create a new and shiny agent
|
|||
$agent_created_ok = 0;
|
||||
} else {
|
||||
$sql = sprintf ("INSERT INTO tagente
|
||||
(nombre, direccion, id_grupo, intervalo, comentarios, modo, id_os, disabled, id_network_server, id_plugin_server, id_wmi_server, id_prediction_server, id_inventory_server, id_parent)
|
||||
(nombre, direccion, id_grupo, intervalo, comentarios, modo, id_os, disabled, id_network_server, id_plugin_server, id_wmi_server, id_prediction_server, id_parent)
|
||||
VALUES
|
||||
('%s', '%s', %d, %d, '%s', %d, %d, %d, %d, %d, %d, %d, %d, %d)",
|
||||
$nombre_agente, $direccion_agente, $grupo, $intervalo, $comentarios, $modo, $id_os, $disabled, $id_network_server, $id_plugin_server, $id_wmi_server, $id_prediction_server, $id_inventory_server, $id_parent);
|
||||
('%s', '%s', %d, %d, '%s', %d, %d, %d, %d, %d, %d, %d, %d)",
|
||||
$nombre_agente, $direccion_agente, $grupo, $intervalo, $comentarios, $modo, $id_os, $disabled, $id_network_server, $id_plugin_server, $id_wmi_server, $id_prediction_server, $id_parent);
|
||||
$id_agente = process_sql ($sql, "insert_id");
|
||||
enterprise_hook ('update_agent', array ($id_agente));
|
||||
if ($id_agente !== false) {
|
||||
$agent_created_ok = 1;
|
||||
$agent_creation_error = "";
|
||||
|
@ -501,7 +500,6 @@ if (isset($_POST["update_agent"])) { // if modified some agent paramenter
|
|||
$id_plugin_server = (int) get_parameter_post ("plugin_server", 0);
|
||||
$id_wmi_server = (int) get_parameter_post ("wmi_server", 0);
|
||||
$id_prediction_server = (int) get_parameter_post ("prediction_server", 0);
|
||||
$id_inventory_server = (int) get_parameter_post ("inventory_server", 0);
|
||||
$id_parent = (int) get_parameter_post ("id_parent", 0);
|
||||
|
||||
//Verify if there is another agent with the same name but different ID
|
||||
|
@ -522,26 +520,21 @@ if (isset($_POST["update_agent"])) { // if modified some agent paramenter
|
|||
}
|
||||
|
||||
//Now update the thing
|
||||
$sql = sprintf ("UPDATE tagente SET
|
||||
disabled = %d,
|
||||
id_parent = %d,
|
||||
id_os = %d,
|
||||
modo = %d,
|
||||
nombre = '%s',
|
||||
direccion = '%s',
|
||||
id_grupo = %d,
|
||||
intervalo = %d,
|
||||
comentarios = '%s',
|
||||
id_network_server = %d,
|
||||
id_plugin_server = %d,
|
||||
id_wmi_server = %d,
|
||||
id_prediction_server = %d,
|
||||
id_inventory_server = %d
|
||||
WHERE id_agente = %d",$disabled,$id_parent,$id_os,$modo,$nombre_agente,$direccion_agente,$grupo,$intervalo,$comentarios,$id_network_server,$id_plugin_server,$id_wmi_server,$id_prediction_server,$id_inventory_server,$id_agente);
|
||||
$sql = sprintf ("UPDATE tagente
|
||||
SET disabled = %d, id_parent = %d, id_os = %d, modo = %d,
|
||||
nombre = '%s', direccion = '%s', id_grupo = %d,
|
||||
intervalo = %d, comentarios = '%s', id_network_server = %d,
|
||||
id_plugin_server = %d, id_wmi_server = %d, id_prediction_server = %d
|
||||
WHERE id_agente = %d",
|
||||
$disabled, $id_parent, $id_os, $modo, $nombre_agente,
|
||||
$direccion_agente, $grupo, $intervalo, $comentarios,
|
||||
$id_network_server, $id_plugin_server, $id_wmi_server,
|
||||
$id_prediction_server, $id_agente);
|
||||
$result = process_sql ($sql);
|
||||
if ($result === false) {
|
||||
echo '<h3 class="error">'.__('There was a problem updating agent').'</h3>';
|
||||
} else {
|
||||
enterprise_hook ('update_agent', array ($id_agente));
|
||||
echo '<h3 class="suc">'.__('Agent successfully updated').'</h3>';
|
||||
}
|
||||
}
|
||||
|
@ -554,12 +547,13 @@ if ((isset($agent_created_ok)) && ($agent_created_ok == 1)){
|
|||
// Read agent data
|
||||
// This should be at the end of all operation checks, to read the changess
|
||||
if (isset($_GET["id_agente"])) {
|
||||
$id_agente = get_parameter_get ("id_agente"); //This has been done in the beginning of the page, but if an agent was created, this id might change
|
||||
//This has been done in the beginning of the page, but if an agent was created, this id might change
|
||||
$id_agente = get_parameter_get ("id_agente");
|
||||
$id_grupo = dame_id_grupo ($id_agente);
|
||||
if (give_acl ($config["id_user"], $id_grupo, "AW") != 1) {
|
||||
audit_db($config["id_user"],$REMOTE_ADDR, "ACL Violation","Trying to admin an agent without access");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
exit;
|
||||
}
|
||||
|
||||
$row = get_db_row ('tagente', 'id_agente', $id_agente);
|
||||
|
@ -582,7 +576,6 @@ if (isset($_GET["id_agente"])) {
|
|||
$id_network_server = $row["id_network_server"];
|
||||
$id_prediction_server = $row["id_prediction_server"];
|
||||
$id_wmi_server = $row["id_wmi_server"];
|
||||
$id_inventory_server = $row["id_inventory_server"];
|
||||
$modo = $row["modo"];
|
||||
$id_os = $row["id_os"];
|
||||
$disabled = $row["disabled"];
|
||||
|
@ -903,12 +896,10 @@ switch ($tab) {
|
|||
case "template":
|
||||
require "agent_template.php";
|
||||
break;
|
||||
case "inventory":
|
||||
enterprise_include ('godmode/agentes/inventory_manager.php');
|
||||
break;
|
||||
default:
|
||||
//This will make sure that blank pages will have at least some
|
||||
//debug info in them
|
||||
echo '<h3 class="error">DEBUG: Invalid tab specified in '.__FILE__.':'.__LINE__.'</h3>';
|
||||
if (enterprise_hook ('switch_agent_tab', array ($tab)))
|
||||
//This will make sure that blank pages will have at least some
|
||||
//debug info in them
|
||||
echo '<h3 class="error">DEBUG: Invalid tab specified in '.__FILE__.':'.__LINE__.'</h3>';
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -196,7 +196,7 @@ if ($id_profile || $new_profile) {
|
|||
|
||||
print_table ($table);
|
||||
|
||||
echo '<div class="action-buttons" style="width: 400px">';
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
if ($new_profile) {
|
||||
print_submit_button (__('Create'), "crt", false, 'class="sub next"');
|
||||
print_input_hidden ('create_profile', 1);
|
||||
|
|
|
@ -62,8 +62,8 @@ if ($create_layout) {
|
|||
$sql = sprintf ('INSERT INTO tlayout (name, id_group, background, height, width)
|
||||
VALUES ("%s", %d, "%s", %d, %d)',
|
||||
$name, $id_group, $background, $height, $width);
|
||||
$id_layout = process_sql ($sql, 'insert-id');
|
||||
if ($result !== false) {
|
||||
$id_layout = process_sql ($sql, 'insert_id');
|
||||
if ($id_layout !== false) {
|
||||
echo '<h3 class="suc">'.__('Created successfully').'</h3>';
|
||||
} else {
|
||||
echo '<h3 class="err">'.__('Not created. Error inserting data').'</h3>';
|
||||
|
@ -160,7 +160,7 @@ if ($create_layout_data) {
|
|||
$layout_data_id_agent_module,
|
||||
$layout_data_parent_item, $layout_data_period * 3600,
|
||||
$layout_data_width, $layout_data_height);
|
||||
$result = process_sql ($sql, 'insert-id');
|
||||
$result = process_sql ($sql, 'insert_id');
|
||||
|
||||
if ($result !== false) {
|
||||
echo '<h3 class="suc">'.__('Created successfully').'</h3>';
|
||||
|
@ -252,9 +252,11 @@ if ($id_layout) {
|
|||
$height = $layout['height'];
|
||||
}
|
||||
|
||||
echo "<h2>".__('Reporting')." > ".__('Map builder');
|
||||
pandora_help ("map_builder");
|
||||
echo "</h2>";
|
||||
|
||||
if (! $edit_layout && ! $id_layout) {
|
||||
echo "<h2>".__('Reporting')." > ".__('Map builder')."</h2>";
|
||||
|
||||
$table->width = '500px';
|
||||
$table->data = array ();
|
||||
$table->head = array ();
|
||||
|
@ -265,9 +267,9 @@ if (! $edit_layout && ! $id_layout) {
|
|||
$table->align[2] = 'center';
|
||||
|
||||
$maps = get_db_all_rows_in_table ('tlayout','name');
|
||||
if (!$maps)
|
||||
if (!$maps) {
|
||||
echo '<div class="nf">'.('No maps defined').'</div>';
|
||||
else {
|
||||
} else {
|
||||
foreach ($maps as $map) {
|
||||
$data = array ();
|
||||
|
||||
|
@ -288,11 +290,6 @@ if (! $edit_layout && ! $id_layout) {
|
|||
echo '</form>';
|
||||
echo '</div>';
|
||||
} else {
|
||||
echo "<h2>".__('Reporting')." > ";
|
||||
echo __('Map builder');
|
||||
pandora_help ("map_builder");
|
||||
echo "</h2>";
|
||||
|
||||
$backgrounds_list = list_files ('images/console/background/', "jpg", 1, 0);
|
||||
$backgrounds_list = array_merge ($backgrounds_list, list_files ('images/console/background/', "png", 1, 0));
|
||||
$groups = get_user_groups ($config['id_user']);
|
||||
|
@ -450,7 +447,7 @@ function agent_changed (event, id_agent, selected) {
|
|||
id_agent = this.value;
|
||||
$('#form_layout_data_editor #module').attr ('disabled', 1);
|
||||
$('#form_layout_data_editor #module').empty ();
|
||||
$('#form_layout_data_editor #module').append (new Option ("<?php echo __('Loading'); ?>...", 0));
|
||||
$('#form_layout_data_editor #module').append ($('<option></option>').html ("<?php echo __('Loading'); ?>...").attr ("value", 0));
|
||||
jQuery.post ('ajax.php',
|
||||
{page: "operation/agentes/ver_agente",
|
||||
get_agent_modules_json: 1,
|
||||
|
@ -458,10 +455,10 @@ function agent_changed (event, id_agent, selected) {
|
|||
},
|
||||
function (data) {
|
||||
$('#form_layout_data_editor #module').empty ();
|
||||
$('#form_layout_data_editor #module').append (new Option ("--", 0));
|
||||
$('#form_layout_data_editor #module').append ($('<option></option>').html ("--").attr ("value", 0));
|
||||
jQuery.each (data, function (i, val) {
|
||||
s = html_entity_decode (val['nombre']);
|
||||
$('#form_layout_data_editor #module').append (new Option (s, val['id_agente_modulo']));
|
||||
$('#form_layout_data_editor #module').append ($('<option></option>').html (s).attr ("value", val['id_agente_modulo']));
|
||||
$('#form_layout_data_editor #module').fadeIn ('normal');
|
||||
});
|
||||
if (selected != undefined)
|
||||
|
|
|
@ -1220,7 +1220,9 @@ function enterprise_hook ($function_name, $parameters = false) {
|
|||
function enterprise_include ($filename) {
|
||||
global $config;
|
||||
// Load enterprise extensions
|
||||
$filepath = $config["homedir"].ENTERPRISE_DIR.'/'.$filename;
|
||||
$filepath = realpath ($config["homedir"].'/'.ENTERPRISE_DIR.'/'.$filename);
|
||||
if ($filepath === false)
|
||||
return ENTERPRISE_NOT_HOOK;
|
||||
if (file_exists ($filepath)) {
|
||||
include ($filepath);
|
||||
return true;
|
||||
|
|
|
@ -1434,7 +1434,7 @@ function process_sql ($sql, $rettype = "affected_rows") {
|
|||
} else {
|
||||
$result = mysql_query ($sql);
|
||||
if ($result === false) {
|
||||
echo '<strong>Error:</strong> process_sql ("'.$sql.'") :'. mysql_error ().'<br />';
|
||||
trigger_error (mysql_error ());
|
||||
return false;
|
||||
} elseif ($result === true) {
|
||||
if ($rettype == "insert_id") {
|
||||
|
|
|
@ -209,6 +209,22 @@ function print_input_text ($name, $value, $alt = '', $size = 50, $maxlength = 0,
|
|||
echo $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an input image element.
|
||||
*
|
||||
* @param string $name Input name.
|
||||
* @param string $src Image source.
|
||||
* @param string $value Input value.
|
||||
* @param string $style HTML style property.
|
||||
* @param bool $return Whether to return an output string or echo now (optional, echo by default).
|
||||
*/
|
||||
function print_input_image ($name, $src, $value, $style = '', $return = false) {
|
||||
$output = '<input id="image-'.$name.'" src="'.$src.'" style="'.$style.'" name="'.$name.'" type="image" value="'.$value.'" />';
|
||||
|
||||
if ($return)
|
||||
return $output;
|
||||
echo $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an input hidden element.
|
||||
|
|
|
@ -66,6 +66,11 @@ require_once ("include/functions_db.php");
|
|||
//We should require this or you might end up with some empty strings
|
||||
load_extensions ($config['extensions']);
|
||||
|
||||
/* Enterprise support */
|
||||
if (file_exists ("enterprise/load_enterprise.php")) {
|
||||
include ("enterprise/load_enterprise.php");
|
||||
}
|
||||
|
||||
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>';
|
||||
|
||||
// Pure mode (without menu, header and footer).
|
||||
|
@ -101,20 +106,25 @@ if ($intervalo > 0){
|
|||
}
|
||||
}
|
||||
|
||||
enterprise_include ('index.php');
|
||||
|
||||
echo '<title>Pandora FMS - '.__('the Flexible Monitoring System').'</title>
|
||||
<meta http-equiv="expires" content="0">
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<meta name="resource-type" content="document">
|
||||
<meta name="distribution" content="global">
|
||||
<meta name="author" content="Sancho Lerena">
|
||||
<meta name="copyright" content="This is GPL software. Created by Sancho Lerena and others">
|
||||
<meta name="keywords" content="pandora, monitoring, system, GPL, software">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link rel="icon" href="images/pandora.ico" type="image/ico">
|
||||
<link rel="stylesheet" href="include/styles/'.$config["style"].'.css" type="text/css">
|
||||
<meta http-equiv="expires" content="0" />
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="resource-type" content="document" />
|
||||
<meta name="distribution" content="global" />
|
||||
<meta name="author" content="Sancho Lerena" />
|
||||
<meta name="copyright" content="This is GPL software. Created by Sancho Lerena and others" />
|
||||
<meta name="keywords" content="pandora, monitoring, system, GPL, software" />
|
||||
<meta name="robots" content="index, follow" />
|
||||
<link rel="icon" href="images/pandora.ico" type="image/ico" />
|
||||
<link rel="stylesheet" href="include/styles/'.$config["style"].'.css" type="text/css" />
|
||||
<script type="text/javascript" src="include/javascript/wz_jsgraphics.js"></script>
|
||||
<script type="text/javascript" src="include/javascript/pandora.js"></script>
|
||||
</head>';
|
||||
<script type="text/javascript" src="include/javascript/pandora.js"></script>';
|
||||
|
||||
enterprise_hook ('load_html_header');
|
||||
|
||||
echo '</head>';
|
||||
|
||||
// Show custom background
|
||||
if ($config["pure"] == 0) {
|
||||
|
@ -130,7 +140,7 @@ if (! isset ($_SESSION['id_usuario']) && isset ($_GET["login"])) {
|
|||
$nick = get_parameter_post ("nick");
|
||||
$pass = get_parameter_post ("pass");
|
||||
// Connect to Database
|
||||
$sql = sprintf("SELECT `id_usuario`, `password` FROM `tusuario` WHERE `id_usuario` = '%s'",$nick);
|
||||
$sql = sprintf ("SELECT `id_usuario`, `password` FROM `tusuario` WHERE `id_usuario` = '%s'", $nick);
|
||||
$row = get_db_row_sql ($sql);
|
||||
|
||||
// For every registry
|
||||
|
@ -194,20 +204,18 @@ if (isset ($_GET["bye"])) {
|
|||
exit;
|
||||
}
|
||||
$page = "";
|
||||
if (isset ($_GET["sec2"])){
|
||||
$sec2 = "";
|
||||
$sec = "";
|
||||
if (isset ($_GET["sec2"])) {
|
||||
$sec2 = get_parameter_get ('sec2');
|
||||
$sec2 = parameter_extra_clean ($sec2);
|
||||
$page = $sec2;
|
||||
} else {
|
||||
$sec2 = "";
|
||||
}
|
||||
|
||||
if (isset ($_GET["sec"])){
|
||||
if (isset ($_GET["sec"])) {
|
||||
$sec = get_parameter_get ('sec');
|
||||
$sec = parameter_extra_clean ($sec);
|
||||
$page = $sec2;
|
||||
} else {
|
||||
$sec = "";
|
||||
}
|
||||
|
||||
// http://es2.php.net/manual/en/ref.session.php#64525
|
||||
|
@ -226,7 +234,7 @@ if ($config["pure"] == 0) {
|
|||
}
|
||||
|
||||
// Main block of content
|
||||
if ($config["pure"] == 0){
|
||||
if ($config["pure"] == 0) {
|
||||
echo '<div id="main">';
|
||||
}
|
||||
|
||||
|
@ -247,7 +255,9 @@ if ($page != "") {
|
|||
echo '<br><b class="error">'.__('Sorry! I can\'t find the page!').'</b>';
|
||||
}
|
||||
} else {
|
||||
require ("general/logon_ok.php"); //default
|
||||
if (enterprise_hook ('load_logon_ok') === ENTERPRISE_NOT_HOOK) {
|
||||
require ("general/logon_ok.php");
|
||||
}
|
||||
}
|
||||
|
||||
if ($config["pure"] == 0) {
|
||||
|
|
|
@ -716,7 +716,7 @@ CREATE TABLE IF NOT EXISTS `tplanned_downtime` (
|
|||
`description` TEXT NOT NULL,
|
||||
`date_from` bigint(20) NOT NULL default '0',
|
||||
`date_to` bigint(20) NOT NULL default '0',
|
||||
`executed` tinyint(1) UNSIGNED NOT NULL default 0,
|
||||
`executed` tinyint(1) UNSIGNED NOT NULL default 0,
|
||||
PRIMARY KEY ( `id` )
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
|
Loading…
Reference in New Issue