2011-03-03 Miguel de Dios <miguel.dedios@artica.es>
* godmode/setup/news.php, godmode/setup/links.php, include/fgraph.php, operation/agentes/status_monitor.php, operation/reporting/graph_viewer.php: changed the calls to mysql functions to own functions. * godmode/agentes/module_manager.php: marked with a comment the source code the SQL postgreSQL and mySQL standar querys. * include/functions_html.php, include/db/postgresql.php, include/functions_reporting.php, include/pchart_graph.php, include/functions_db.php: cleaned source code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4056 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
8f9ed10f16
commit
fbc02682cc
|
@ -1,3 +1,15 @@
|
|||
2011-03-03 Miguel de Dios <miguel.dedios@artica.es>
|
||||
* godmode/setup/news.php, godmode/setup/links.php, include/fgraph.php,
|
||||
operation/agentes/status_monitor.php, operation/reporting/graph_viewer.php:
|
||||
changed the calls to mysql functions to own functions.
|
||||
|
||||
* godmode/agentes/module_manager.php: marked with a comment the source code
|
||||
the SQL postgreSQL and mySQL standar querys.
|
||||
|
||||
* include/functions_html.php, include/db/postgresql.php,
|
||||
include/functions_reporting.php, include/pchart_graph.php,
|
||||
include/functions_db.php: cleaned source code style.
|
||||
|
||||
2011-03-03 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_reporting.php: refixed the status when the agent have
|
||||
|
|
|
@ -30,10 +30,10 @@ echo "<tr><td class='datos'>";
|
|||
// Check if there is at least one server of each type available to assign that
|
||||
// kind of modules. If not, do not show server type in combo
|
||||
|
||||
$network_available = get_db_sql ("SELECT count(*) from tserver where server_type = 1");
|
||||
$wmi_available = get_db_sql ("SELECT count(*) from tserver where server_type = 6");
|
||||
$plugin_available = get_db_sql ("SELECT count(*) from tserver where server_type = 4");
|
||||
$prediction_available = get_db_sql ("SELECT count(*) from tserver where server_type = 5");
|
||||
$network_available = get_db_sql ("SELECT count(*) from tserver where server_type = 1"); //POSTGRESQL COMPATIBLE
|
||||
$wmi_available = get_db_sql ("SELECT count(*) from tserver where server_type = 6"); //POSTGRESQL COMPATIBLE
|
||||
$plugin_available = get_db_sql ("SELECT count(*) from tserver where server_type = 4"); //POSTGRESQL COMPATIBLE
|
||||
$prediction_available = get_db_sql ("SELECT count(*) from tserver where server_type = 5"); //POSTGRESQL COMPATIBLE
|
||||
|
||||
// Development mode to use all servers
|
||||
if ($develop_bypass) {
|
||||
|
|
|
@ -30,13 +30,14 @@ print_page_header (__('Link management'), "images/extensions.png", false, "", fa
|
|||
if (isset($_POST["create"])){ // If create
|
||||
$name = get_parameter_post ("name");
|
||||
$link = get_parameter_post ("link");
|
||||
$sql_insert = "INSERT INTO tlink (name,link) VALUES ('$name','$link')";
|
||||
$result=mysql_query($sql_insert);
|
||||
|
||||
$result = process_sql_insert("tlink", array('name' => $name, 'link' => $link));
|
||||
|
||||
if (! $result)
|
||||
echo "<h3 class='error'>".__('There was a problem creating link')."</h3>";
|
||||
else {
|
||||
echo "<h3 class='suc'>".__('Successfully created')."</h3>";
|
||||
$id_link = mysql_insert_id();
|
||||
$id_link = $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,8 +45,9 @@ if (isset($_POST["update"])){ // if update
|
|||
$id_link = safe_input($_POST["id_link"]);
|
||||
$name = safe_input($_POST["name"]);
|
||||
$link = safe_input($_POST["link"]);
|
||||
$sql_update ="UPDATE tlink SET name = '".$name."', link ='".$link."' WHERE id_link = '".$id_link."'";
|
||||
$result=mysql_query($sql_update);
|
||||
|
||||
$result = process_sql_update("tlink", array('name' => $name, 'link' => $link), array('id_link' => $id_link));
|
||||
|
||||
if (! $result)
|
||||
echo "<h3 class='error'>".__('There was a problem modifying link')."</h3>";
|
||||
else
|
||||
|
@ -54,8 +56,9 @@ $sql_update ="UPDATE tlink SET name = '".$name."', link ='".$link."' WHERE id_li
|
|||
|
||||
if (isset($_GET["borrar"])){ // if delete
|
||||
$id_link = safe_input($_GET["borrar"]);
|
||||
$sql_delete= "DELETE FROM tlink WHERE id_link = ".$id_link;
|
||||
$result=mysql_query($sql_delete);
|
||||
|
||||
$result = process_sql_delete("tlink", array("id_link" => $id_link));
|
||||
|
||||
if (! $result)
|
||||
echo "<h3 class='error'>".__('There was a problem deleting link')."</h3>";
|
||||
else
|
||||
|
@ -68,14 +71,16 @@ if ((isset($_GET["form_add"])) or (isset($_GET["form_edit"]))){
|
|||
if (isset($_GET["form_edit"])){
|
||||
$creation_mode = 0;
|
||||
$id_link = safe_input($_GET["id_link"]);
|
||||
$sql1='SELECT * FROM tlink WHERE id_link = '.$id_link;
|
||||
$result=mysql_query($sql1);
|
||||
if ($row=mysql_fetch_array($result)){
|
||||
$nombre = $row["name"];
|
||||
$link = $row["link"];
|
||||
|
||||
$row = get_db_row("tlink", "id_link", $id_link);
|
||||
|
||||
if ($row !== false) {
|
||||
$nombre = $row["name"];
|
||||
$link = $row["link"];
|
||||
}
|
||||
else echo "<h3 class='error'>".__('Name error')."</h3>";
|
||||
} else { // form_add
|
||||
}
|
||||
else { // form_add
|
||||
$creation_mode =1;
|
||||
$nombre = "";
|
||||
$link = "";
|
||||
|
@ -87,7 +92,9 @@ if ((isset($_GET["form_add"])) or (isset($_GET["form_edit"]))){
|
|||
else
|
||||
echo "<input type='hidden' name='update' value='1'>";
|
||||
echo "<input type='hidden' name='id_link' value='";
|
||||
if (isset($id_link)) {echo $id_link;}
|
||||
if (isset($id_link)) {
|
||||
echo $id_link;
|
||||
}
|
||||
echo "'>";
|
||||
echo '<tr>
|
||||
<td class="datos">'.__('Link name').'</td>
|
||||
|
@ -112,10 +119,14 @@ else { // Main list view for Links editor
|
|||
echo "<table cellpadding='4' cellspacing='4' class='databox'>";
|
||||
echo "<th width='180px'>".__('Link name')."</th>";
|
||||
echo "<th width='80px'>".__('Delete')."</th>";
|
||||
$sql1='SELECT * FROM tlink ORDER BY name';
|
||||
$result=mysql_query($sql1);
|
||||
|
||||
$rows = get_db_all_rows_in_table('tlink', 'name');
|
||||
if ($rows === false) {
|
||||
$rows = array();
|
||||
}
|
||||
|
||||
$color=1;
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
foreach ($rows as $row) {
|
||||
if ($color == 1){
|
||||
$tdcolor = "datos";
|
||||
$color = 0;
|
||||
|
|
|
@ -130,10 +130,14 @@ else {
|
|||
echo "<th>".__('Author')."</th>";
|
||||
echo "<th>".__('Timestamp')."</th>";
|
||||
echo "<th>".__('Delete')."</th>";
|
||||
$sql = 'SELECT * FROM tnews ORDER BY timestamp';
|
||||
$result = mysql_query ($sql);
|
||||
|
||||
$rows = get_db_all_rows_in_table("tnews", "timestamp");
|
||||
if ($rows === false) {
|
||||
$rows = array();
|
||||
}
|
||||
|
||||
$color = 1;
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
foreach ($rows as $row) {
|
||||
if ($color == 1) {
|
||||
$tdcolor = "datos";
|
||||
$color = 0;
|
||||
|
|
|
@ -334,7 +334,6 @@ function postgresql_process_sql_insert($table, $values) {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Escape string to set it properly to use in sql queries
|
||||
*
|
||||
* @param string String to be cleaned.
|
||||
|
|
|
@ -1938,8 +1938,11 @@ function grafico_modulo_log4x ($id_agente_modulo, $periodo, $show_event,
|
|||
grafico_modulo_log4x_trace("$sql1");
|
||||
|
||||
$rows = 0;
|
||||
$result=mysql_query($sql1);
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
|
||||
$first = true;
|
||||
while ($row = get_db_all_row_by_steps_sql($first, $result, $sql1)){
|
||||
$first = false;
|
||||
|
||||
$rows++;
|
||||
$utimestamp = $row[0];
|
||||
$severity = $row[1];
|
||||
|
|
|
@ -3220,15 +3220,15 @@ function get_modulegroup_name ($modulegroup_id) {
|
|||
*
|
||||
* @return mixed False in case of error or invalid values passed. Affected rows otherwise
|
||||
*/
|
||||
function process_sql_insert ($table, $values) {
|
||||
function process_sql_insert($table, $values) {
|
||||
global $config;
|
||||
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
return mysql_process_sql_insert ($table, $values);
|
||||
return mysql_process_sql_insert($table, $values);
|
||||
break;
|
||||
case "postgresql":
|
||||
return postgresql_process_sql_insert ($table, $values);
|
||||
return postgresql_process_sql_insert($table, $values);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1270,12 +1270,14 @@ function html2rgb($htmlcolor)
|
|||
$g = hexdec($htmlcolor[2].$htmlcolor[3]);
|
||||
$b = hexdec($htmlcolor[4].$htmlcolor[5]);
|
||||
return array($r, $g, $b);
|
||||
} elseif (strlen($htmlcolor) == 3) {
|
||||
}
|
||||
elseif (strlen($htmlcolor) == 3) {
|
||||
$r = hexdec($htmlcolor[0].$htmlcolor[0]);
|
||||
$g = hexdec($htmlcolor[1].$htmlcolor[1]);
|
||||
$b = hexdec($htmlcolor[2].$htmlcolor[2]);
|
||||
return array($r, $g, $b);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2078,7 +2078,7 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
|
|||
if ($content['header_definition'] != '') {
|
||||
$table2->head = explode('|', $content['header_definition']);
|
||||
}
|
||||
|
||||
|
||||
$data = array ();
|
||||
|
||||
$data[0] = '<img src="include/fgraph.php?tipo='.$content["type"].'&report_id='.$content["id_rc"].'&width='.$sizgraph_w.'&pure=1" border="0" alt="">';
|
||||
|
|
|
@ -379,42 +379,44 @@ class PchartGraph extends PandoraGraphAbstract {
|
|||
$this->xaxis_interval = ($this->xaxis_interval / 7 >= 1) ? ($this->xaxis_interval / 7) : 10;
|
||||
$this->graph->drawScale ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription (), SCALE_START0,
|
||||
80, 80, 80, $this->show_axis, 0, 50, false,
|
||||
$this->xaxis_interval);
|
||||
80, 80, 80, $this->show_axis, 0, 50, false,
|
||||
$this->xaxis_interval);
|
||||
|
||||
$this->graph->drawGrid (1, true, 225, 225, 225, 100, false);
|
||||
|
||||
// Draw the graph
|
||||
if ($stacked == 1) { // Stacked solid
|
||||
$this->graph->drawScale ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription (),
|
||||
SCALE_START0, 80, 80, 80, $this->show_axis, 0, 0, false,
|
||||
$this->xaxis_interval);
|
||||
$this->dataset->GetDataDescription (),
|
||||
SCALE_START0, 80, 80, 80, $this->show_axis, 0, 0, false,
|
||||
$this->xaxis_interval);
|
||||
$this->graph->drawFilledCubicCurve ($this->dataset->GetData(),
|
||||
$this->dataset->GetDataDescription(), 1, 30, true);
|
||||
$this->dataset->GetDataDescription(), 1, 30, true);
|
||||
}
|
||||
elseif ($stacked == 3) { // Stacked wired
|
||||
$this->graph->drawScale ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription (),
|
||||
SCALE_START0, 80, 80, 80, $this->show_axis, 0, 0, false,
|
||||
$this->xaxis_interval);
|
||||
$this->dataset->GetDataDescription (),
|
||||
SCALE_START0, 80, 80, 80, $this->show_axis, 0, 0, false,
|
||||
$this->xaxis_interval);
|
||||
$this->graph->drawFilledCubicCurve ($this->dataset->GetData(),
|
||||
$this->dataset->GetDataDescription(), 1, 0, true);
|
||||
$this->dataset->GetDataDescription(), 1, 0, true);
|
||||
|
||||
} else if ($stacked == 2) { // Wired mode
|
||||
}
|
||||
else if ($stacked == 2) { // Wired mode
|
||||
$this->graph->drawScale ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription (),
|
||||
SCALE_START0, 80, 80, 80, $this->show_axis, 0, 0, false,
|
||||
$this->xaxis_interval);
|
||||
$this->dataset->GetDataDescription (),
|
||||
SCALE_START0, 80, 80, 80, $this->show_axis, 0, 0, false,
|
||||
$this->xaxis_interval);
|
||||
$this->graph->drawLineGraph ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription ());
|
||||
} else { // Non-stacked, area overlapped
|
||||
$this->dataset->GetDataDescription ());
|
||||
}
|
||||
else { // Non-stacked, area overlapped
|
||||
$this->graph->drawScale ($this->dataset->GetData (),
|
||||
$this->dataset->GetDataDescription (),
|
||||
SCALE_START0, 80, 80, 80, $this->show_axis, 0, 0, false,
|
||||
$this->xaxis_interval);
|
||||
$this->dataset->GetDataDescription (),
|
||||
SCALE_START0, 80, 80, 80, $this->show_axis, 0, 0, false,
|
||||
$this->xaxis_interval);
|
||||
$this->graph->drawFilledCubicCurve ($this->dataset->GetData(),
|
||||
$this->dataset->GetDataDescription(), 1, 30, true);
|
||||
$this->dataset->GetDataDescription(), 1, 30, true);
|
||||
}
|
||||
|
||||
$this->graph->setFontProperties($this->fontpath,7);
|
||||
|
@ -608,13 +610,14 @@ class PchartGraph extends PandoraGraphAbstract {
|
|||
if ($this->show_title){
|
||||
$this->graph->setFontProperties ($this->fontpath, 7);
|
||||
$this->graph->drawTextBox ($this->width - 8, 40,
|
||||
$this->width - 240, 90, 'PANDORA FMS', 90,
|
||||
174, 214, 174, ALIGN_BOTTOM_LEFT, false);
|
||||
} else {
|
||||
$this->width - 240, 90, 'PANDORA FMS', 90,
|
||||
174, 214, 174, ALIGN_BOTTOM_LEFT, false);
|
||||
}
|
||||
else {
|
||||
$this->graph->setFontProperties ($this->fontpath, 7);
|
||||
$this->graph->drawTextBox ($this->width - 8, 50,
|
||||
$this->width - 240, 60, 'PANDORA FMS', 90,
|
||||
174, 214, 174, ALIGN_BOTTOM_LEFT, false);
|
||||
$this->width - 240, 60, 'PANDORA FMS', 90,
|
||||
174, 214, 174, ALIGN_BOTTOM_LEFT, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,36 +76,72 @@ $user_groups = implode (",", array_keys (get_user_groups ()));
|
|||
|
||||
//$modules = get_db_all_rows_filter ('tagente_modulo', array('id_agente' => $user_agents, 'nombre' => '<>delete_pending'), 'DISTINCT(nombre)');
|
||||
|
||||
$sql = '
|
||||
select distinct(nombre)
|
||||
from tagente_modulo
|
||||
where nombre <> "delete_pending" and id_agente in
|
||||
(
|
||||
select id_agente
|
||||
from tagente where id_grupo IN (
|
||||
select id_grupo
|
||||
from tusuario_perfil
|
||||
where id_usuario = "' . $config['id_user'] . '"
|
||||
and id_perfil IN (
|
||||
select id_perfil
|
||||
from tperfil where agent_view = 1
|
||||
)
|
||||
)
|
||||
OR
|
||||
(1 = (
|
||||
SELECT is_admin FROM tusuario WHERE id_user = "' . $config['id_user'] . '"
|
||||
)
|
||||
)
|
||||
OR 0 IN (
|
||||
select id_grupo
|
||||
from tusuario_perfil
|
||||
where id_usuario = "' . $config['id_user'] . '"
|
||||
and id_perfil IN (
|
||||
select id_perfil
|
||||
from tperfil where agent_view = 1
|
||||
)
|
||||
)
|
||||
)';
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$sql = '
|
||||
select distinct(nombre)
|
||||
from tagente_modulo
|
||||
where nombre <> "delete_pending" and id_agente in
|
||||
(
|
||||
select id_agente
|
||||
from tagente where id_grupo IN (
|
||||
select id_grupo
|
||||
from tusuario_perfil
|
||||
where id_usuario = "' . $config['id_user'] . '"
|
||||
and id_perfil IN (
|
||||
select id_perfil
|
||||
from tperfil where agent_view = 1
|
||||
)
|
||||
)
|
||||
OR
|
||||
(1 = (
|
||||
SELECT is_admin FROM tusuario WHERE id_user = "' . $config['id_user'] . '"
|
||||
)
|
||||
)
|
||||
OR 0 IN (
|
||||
select id_grupo
|
||||
from tusuario_perfil
|
||||
where id_usuario = "' . $config['id_user'] . '"
|
||||
and id_perfil IN (
|
||||
select id_perfil
|
||||
from tperfil where agent_view = 1
|
||||
)
|
||||
)
|
||||
)';
|
||||
break;
|
||||
case "postgresql":
|
||||
$sql = '
|
||||
select distinct(nombre)
|
||||
from tagente_modulo
|
||||
where nombre <> \'delete_pending\' and id_agente in
|
||||
(
|
||||
select id_agente
|
||||
from tagente where id_grupo IN (
|
||||
select id_grupo
|
||||
from tusuario_perfil
|
||||
where id_usuario = \'' . $config['id_user'] . '\'
|
||||
and id_perfil IN (
|
||||
select id_perfil
|
||||
from tperfil where agent_view = 1
|
||||
)
|
||||
)
|
||||
OR
|
||||
(1 = (
|
||||
SELECT is_admin FROM tusuario WHERE id_user = \'' . $config['id_user'] . '\'
|
||||
)
|
||||
)
|
||||
OR 0 IN (
|
||||
select id_grupo
|
||||
from tusuario_perfil
|
||||
where id_usuario = \'' . $config['id_user'] . '\'
|
||||
and id_perfil IN (
|
||||
select id_perfil
|
||||
from tperfil where agent_view = 1
|
||||
)
|
||||
)
|
||||
)';
|
||||
break;
|
||||
}
|
||||
|
||||
$modules = get_db_all_rows_sql($sql);
|
||||
|
||||
|
|
|
@ -28,13 +28,17 @@ $id_graph = (int) get_parameter ('id');
|
|||
// Delete module SQL code
|
||||
if ($delete_graph) {
|
||||
if (check_acl ($config['id_user'], 0, "AW")) {
|
||||
$sql = "DELETE FROM tgraph_source WHERE id_graph = $id_graph";
|
||||
if ($res=mysql_query($sql))
|
||||
$res = process_sql_delete('tgraph_source', array('id_graph' => $id_graph));
|
||||
|
||||
if ($res)
|
||||
$result = "<h3 class=suc>".__('Successfully deleted')."</h3>";
|
||||
else
|
||||
$result = "<h3 class=error>".__('Not deleted. Error deleting data')."</h3>";
|
||||
|
||||
$res = process_sql_delete('tgraph', array('id_graph' => $id_graph));
|
||||
|
||||
$sql = "DELETE FROM tgraph WHERE id_graph = $id_graph";
|
||||
if ($res=mysql_query($sql))
|
||||
if ($res)
|
||||
$result = "<h3 class=suc>".__('Successfully deleted')."</h3>";
|
||||
else
|
||||
$result = "<h3 class=error>".__('Not deleted. Error deleting data')."</h3>";
|
||||
|
|
Loading…
Reference in New Issue