mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-25 14:54:52 +02:00
2011-02-28 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_db.php: cleaned source code, and erased the deprecated functions "dame_nombre_real" and "show_alert_row_mini". * operation/incidents/incident_detail.php, operation/snmpconsole/snmp_view.php: replaced obsolete "dame_nombre_real" to "get_user_fullname". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4030 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
2636584aa8
commit
27f912c861
@ -1,3 +1,11 @@
|
||||
2011-02-28 Miguel de Dios <miguel.dedios@artica.es>
|
||||
* include/functions_db.php: cleaned source code, and erased the deprecated
|
||||
functions "dame_nombre_real" and "show_alert_row_mini".
|
||||
|
||||
* operation/incidents/incident_detail.php,
|
||||
operation/snmpconsole/snmp_view.php: replaced obsolete "dame_nombre_real"
|
||||
to "get_user_fullname".
|
||||
|
||||
2011-02-28 Miguel de Dios <miguel.dedios@artica.es>
|
||||
* include/functions_db.php: cleaned source code, and erased the deprecated
|
||||
function "dame_admin".
|
||||
|
@ -1008,13 +1008,6 @@ function get_agentmodule_type ($id_agentmodule) {
|
||||
return (int) get_db_value ('id_tipo_modulo', 'tagente_modulo', 'id_agente_modulo', (int) $id_agentmodule);
|
||||
}
|
||||
|
||||
/**
|
||||
* DEPRECATED: User get_user_fullname
|
||||
*/
|
||||
function dame_nombre_real ($id_user) {
|
||||
return get_user_fullname ($id_user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the times a monitor went down during a period.
|
||||
*
|
||||
@ -1840,6 +1833,7 @@ function show_icon_type ($id_type) {
|
||||
*/
|
||||
function show_server_type ($id) {
|
||||
global $config;
|
||||
|
||||
switch ($id) {
|
||||
case 1:
|
||||
return print_image("images/database.png", true, array("title" => "Pandora FMS Data server"));
|
||||
@ -1861,6 +1855,7 @@ function show_server_type ($id) {
|
||||
break;
|
||||
default:
|
||||
return "--";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1886,6 +1881,7 @@ function give_modulecategory_name ($id_category) {
|
||||
return __('Network agent monitor');
|
||||
break;
|
||||
}
|
||||
|
||||
return __('Unknown');
|
||||
}
|
||||
|
||||
@ -1985,6 +1981,7 @@ function get_agent_with_ip ($ip_address) {
|
||||
WHERE tagente.id_agente = taddress_agent.id_agent
|
||||
AND taddress_agent.id_a = taddress.id_a
|
||||
AND ip = "%s"', $ip_address);
|
||||
|
||||
return get_db_row_sql ($sql);
|
||||
}
|
||||
|
||||
@ -2185,7 +2182,8 @@ get_db_row_filter ('table', array ('disabled' => 0, 'history_data' => 0), array
|
||||
function get_db_row_filter ($table, $filter, $fields = false, $where_join = 'AND') {
|
||||
if (empty ($fields)) {
|
||||
$fields = '*';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (is_array ($fields))
|
||||
$fields = implode (',', $fields);
|
||||
else if (! is_string ($fields))
|
||||
@ -2215,8 +2213,10 @@ function get_db_row_filter ($table, $filter, $fields = false, $where_join = 'AND
|
||||
|
||||
function get_db_sql ($sql, $field = 0, $search_history_db = false) {
|
||||
$result = get_db_all_rows_sql ($sql, $search_history_db);
|
||||
|
||||
if($result === false)
|
||||
return false;
|
||||
|
||||
$ax = 0;
|
||||
foreach ($result[0] as $f){
|
||||
if ($field == $ax)
|
||||
@ -2348,7 +2348,9 @@ function sql_error_handler ($errno, $errstr) {
|
||||
|
||||
if (error_reporting () <= $errno)
|
||||
return false;
|
||||
|
||||
echo "<strong>SQL error</strong>: ".$errstr."<br />\n";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2462,14 +2464,17 @@ function get_db_all_rows_in_table ($table, $order_field = "", $order = 'ASC') {
|
||||
function get_db_all_rows_field_filter ($table, $field, $condition, $order_field = "") {
|
||||
if (is_int ($condition) || is_bool ($condition)) {
|
||||
$sql = sprintf ("SELECT * FROM `%s` WHERE `%s` = %d", $table, $field, $condition);
|
||||
} else if (is_float ($condition) || is_double ($condition)) {
|
||||
}
|
||||
else if (is_float ($condition) || is_double ($condition)) {
|
||||
$sql = sprintf ("SELECT * FROM `%s` WHERE `%s` = %f", $table, $field, $condition);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$sql = sprintf ("SELECT * FROM `%s` WHERE `%s` = '%s'", $table, $field, $condition);
|
||||
}
|
||||
|
||||
if ($order_field != "")
|
||||
$sql .= sprintf (" ORDER BY %s", $order_field);
|
||||
|
||||
return get_db_all_rows_sql ($sql);
|
||||
}
|
||||
|
||||
@ -2530,11 +2535,14 @@ function format_array_to_update_sql ($values) {
|
||||
|
||||
if ($value === NULL) {
|
||||
$sql = sprintf ("`%s` = NULL", $field);
|
||||
} elseif (is_int ($value) || is_bool ($value)) {
|
||||
}
|
||||
elseif (is_int ($value) || is_bool ($value)) {
|
||||
$sql = sprintf ("`%s` = %d", $field, $value);
|
||||
} elseif (is_float ($value) || is_double ($value)) {
|
||||
}
|
||||
elseif (is_float ($value) || is_double ($value)) {
|
||||
$sql = sprintf ("`%s` = %f", $field, $value);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* String */
|
||||
if (isset ($value[0]) && $value[0] == '`')
|
||||
/* Don't round with quotes if it references a field */
|
||||
@ -2937,7 +2945,8 @@ function get_previous_data ($id_agent_module, $utimestamp = 0, $string = 0) {
|
||||
|
||||
if ($string == 1) {
|
||||
$table = 'tagente_datos_string';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$table = 'tagente_datos';
|
||||
}
|
||||
|
||||
@ -2966,7 +2975,8 @@ function get_next_data ($id_agent_module, $utimestamp = 0, $string = 0) {
|
||||
|
||||
if ($string == 1) {
|
||||
$table = 'tagente_datos_string';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$table = 'tagente_datos';
|
||||
}
|
||||
|
||||
@ -3088,122 +3098,6 @@ function check_server_status () {
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Will show a small HTML table with some compound alert information
|
||||
*/
|
||||
function show_alert_row_mini ($id_combined_alert) {
|
||||
$color=1;
|
||||
$sql = sprintf ("SELECT talert_template_modules.*,tcompound_alert.operation
|
||||
FROM talert_template_modules, tcompound_alert
|
||||
WHERE tcompound_alert.id_aam = talert_template_modules.id
|
||||
AND tcompound_alert.id = %d", $id_combined_alert);
|
||||
$result = get_db_all_rows_sql ($sql);
|
||||
|
||||
if ($result === false)
|
||||
return;
|
||||
|
||||
echo "<table width=400 cellpadding=2 cellspacing=2 class='databox'>";
|
||||
echo "<th>".__('Name')."</th>";
|
||||
echo "<th>".__('Oper')."</th>";
|
||||
/* Translators: Abbrevation for Time threshold */
|
||||
echo "<th>".__('Tt')."</th>";
|
||||
echo "<th>".__('Firing')."</th>";
|
||||
echo "<th>".__('Time')."</th>";
|
||||
/* Translators: Abbrevation for Description */
|
||||
echo "<th>".__('Desc')."</th>";
|
||||
echo "<th>".__('Recovery')."</th>";
|
||||
echo "<th>".__('MinMax.Al')."</th>";
|
||||
echo "<th>".__('Days')."</th>";
|
||||
echo "<th>".__('Fired')."</th>";
|
||||
|
||||
foreach ($result as $row2) {
|
||||
if ($color == 1) {
|
||||
$tdcolor = "datos";
|
||||
$color = 0;
|
||||
} else {
|
||||
$tdcolor = "datos2";
|
||||
$color = 1;
|
||||
}
|
||||
echo "<tr>";
|
||||
if ($row2["disable"] == 1) {
|
||||
$tdcolor = "datos3";
|
||||
}
|
||||
echo "<td class=$tdcolor>".get_db_sql ("SELECT nombre FROM tagente_modulo WHERE id_agente_modulo =".$row2["id_agente_modulo"])."</td>";
|
||||
echo "<td class=$tdcolor>".$row2["operation"]."</td>";
|
||||
|
||||
echo "<td class='$tdcolor'>".human_time_description ($row2["time_threshold"])."</td>";
|
||||
|
||||
if ($row2["dis_min"]!=0) {
|
||||
$mytempdata = fmod ($row2["dis_min"], 1);
|
||||
if ($mytempdata == 0) {
|
||||
$mymin = intval ($row2["dis_min"]);
|
||||
} else {
|
||||
$mymin = format_for_graph ($row2["dis_min"]);
|
||||
}
|
||||
} else {
|
||||
$mymin = 0;
|
||||
}
|
||||
|
||||
if ($row2["dis_max"]!=0) {
|
||||
$mytempdata = fmod ($row2["dis_max"], 1);
|
||||
if ($mytempdata == 0) {
|
||||
$mymax = intval ($row2["dis_max"]);
|
||||
} else {
|
||||
$mymax = format_for_graph ($row2["dis_max"]);
|
||||
}
|
||||
} else {
|
||||
$mymax = 0;
|
||||
}
|
||||
|
||||
if (($mymin == 0) && ($mymax == 0)) {
|
||||
$mymin = __('N/A');
|
||||
$mymax = $mymin;
|
||||
}
|
||||
|
||||
// We have alert text ?
|
||||
if ($row2["alert_text"]!= "") {
|
||||
echo "<td class='$tdcolor'>".__('Text')."</td>";
|
||||
} else {
|
||||
echo "<td class='$tdcolor'>".$mymin."/".$mymax."</td>";
|
||||
}
|
||||
|
||||
// Alert times
|
||||
echo "<td class='$tdcolor'>";
|
||||
echo get_alert_times ($row2);
|
||||
|
||||
// Description
|
||||
echo "</td><td class='$tdcolor'>".substr ($row2["descripcion"],0,20);
|
||||
|
||||
// Has recovery notify activated ?
|
||||
if ($row2["recovery_notify"] > 0) {
|
||||
$recovery_notify = __('Yes');
|
||||
} else {
|
||||
$recovery_notify = __('No');
|
||||
}
|
||||
echo "</td><td class='$tdcolor'>".$recovery_notify;
|
||||
|
||||
// calculare firing conditions
|
||||
if ($row2["alert_text"] != ""){
|
||||
$firing_cond = __('Text')."(".substr ($row2["alert_text"],0,8).")";
|
||||
} else {
|
||||
$firing_cond = $row2["min_alerts"]." / ".$row2["max_alerts"];
|
||||
}
|
||||
echo "</td><td class='$tdcolor'>".$firing_cond;
|
||||
|
||||
// calculate days
|
||||
$firing_days = get_alert_days ( $row2 );
|
||||
echo "</td><td class='$tdcolor'>".$firing_days;
|
||||
|
||||
// Fired ?
|
||||
if ($row2["times_fired"]>0) {
|
||||
echo "<td class='".$tdcolor."' align='center'>" . print_image('images/pixel_red.png', true, array("title" => __('Alert fired'), "width" => '20', "height" => '9')) . "</td>";
|
||||
} else {
|
||||
echo "<td class='".$tdcolor."' align='center'>" . print_image('images/pixel_green.png', true, array("title" => __('Alert not fired'), "width" => '20', "height" => '9')) . "</td>";
|
||||
}
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use get_server_info instead
|
||||
* Get statistical information for a given server
|
||||
@ -3356,7 +3250,8 @@ function delete_agent ($id_agents, $disableACL = false) {
|
||||
if ($error) {
|
||||
process_sql_rollback ();
|
||||
return false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
process_sql_commit ();
|
||||
return true;
|
||||
}
|
||||
@ -3506,7 +3401,8 @@ function process_sql_update ($table, $values, $where = false, $where_join = 'AND
|
||||
if (is_string ($where)) {
|
||||
// No clean, the caller should make sure all input is clean, this is a raw function
|
||||
$query .= " WHERE ".$where;
|
||||
} else if (is_array ($where)) {
|
||||
}
|
||||
else if (is_array ($where)) {
|
||||
$query .= format_array_to_where_clause_sql ($where, $where_join, ' WHERE ');
|
||||
}
|
||||
}
|
||||
@ -3554,7 +3450,8 @@ function process_sql_delete ($table, $where, $where_join = 'AND') {
|
||||
/* FIXME: Should we clean the string for sanity?
|
||||
Who cares if this is deleting data... */
|
||||
$query .= $where;
|
||||
} else if (is_array ($where)) {
|
||||
}
|
||||
else if (is_array ($where)) {
|
||||
$query .= format_array_to_where_clause_sql ($where, $where_join);
|
||||
}
|
||||
}
|
||||
@ -3596,7 +3493,9 @@ function process_sql_rollback () {
|
||||
function get_group_users ($id_group, $filter = false) {
|
||||
if (! is_array ($filter))
|
||||
$filter = array ();
|
||||
|
||||
$filter['id_grupo'] = $id_group;
|
||||
|
||||
$resulta = array();
|
||||
$resulta = get_db_all_rows_filter ("tusuario_perfil", $filter);
|
||||
|
||||
@ -3616,13 +3515,15 @@ function get_group_users ($id_group, $filter = false) {
|
||||
|
||||
if ($result === false)
|
||||
return array ();
|
||||
|
||||
//This removes stale users from the list. This can happen if switched to another auth scheme
|
||||
//(internal users still exist) or external auth has users removed/inactivated from the list (eg. LDAP)
|
||||
$retval = array ();
|
||||
foreach ($result as $key => $user) {
|
||||
if (!is_user ($user)) {
|
||||
unset ($result[$key]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
array_push ($retval, get_user_info ($user));
|
||||
}
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ echo '</td><td class="datos"><b>'.__('Creator').'</b></td><td class="datos">';
|
||||
if (empty ($id_creator)) {
|
||||
echo 'SYSTEM';
|
||||
} else {
|
||||
echo $id_creator.' (<i>'.dame_nombre_real ($id_creator).'</i>)';
|
||||
echo $id_creator.' (<i>'.get_user_fullname($id_creator).'</i>)';
|
||||
}
|
||||
|
||||
echo '</td></tr><tr><td class="datos2" colspan="4">';
|
||||
|
@ -352,7 +352,7 @@ if ($traps !== false) {
|
||||
//User
|
||||
if (!empty ($trap["status"])) {
|
||||
$data[5] = '<a href="index.php?sec=usuarios&sec2=operation/users/user_edit&ver='.$trap["id_usuario"].'">'.substr ($trap["id_usuario"], 0, 8).'</a>';
|
||||
$data[5] .= '<a href="#" class="tip"> <span>'.dame_nombre_real($trap["id_usuario"]).'</span></a>';
|
||||
$data[5] .= '<a href="#" class="tip"> <span>'.get_user_fullname($trap["id_usuario"]).'</span></a>';
|
||||
} else {
|
||||
$data[5] = '--';
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user