mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
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>
|
2011-03-03 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
* include/functions_reporting.php: refixed the status when the agent have
|
* 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
|
// 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
|
// 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");
|
$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");
|
$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");
|
$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");
|
$prediction_available = get_db_sql ("SELECT count(*) from tserver where server_type = 5"); //POSTGRESQL COMPATIBLE
|
||||||
|
|
||||||
// Development mode to use all servers
|
// Development mode to use all servers
|
||||||
if ($develop_bypass) {
|
if ($develop_bypass) {
|
||||||
|
@ -30,13 +30,14 @@ print_page_header (__('Link management'), "images/extensions.png", false, "", fa
|
|||||||
if (isset($_POST["create"])){ // If create
|
if (isset($_POST["create"])){ // If create
|
||||||
$name = get_parameter_post ("name");
|
$name = get_parameter_post ("name");
|
||||||
$link = get_parameter_post ("link");
|
$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)
|
if (! $result)
|
||||||
echo "<h3 class='error'>".__('There was a problem creating link')."</h3>";
|
echo "<h3 class='error'>".__('There was a problem creating link')."</h3>";
|
||||||
else {
|
else {
|
||||||
echo "<h3 class='suc'>".__('Successfully created')."</h3>";
|
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"]);
|
$id_link = safe_input($_POST["id_link"]);
|
||||||
$name = safe_input($_POST["name"]);
|
$name = safe_input($_POST["name"]);
|
||||||
$link = safe_input($_POST["link"]);
|
$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)
|
if (! $result)
|
||||||
echo "<h3 class='error'>".__('There was a problem modifying link')."</h3>";
|
echo "<h3 class='error'>".__('There was a problem modifying link')."</h3>";
|
||||||
else
|
else
|
||||||
@ -54,8 +56,9 @@ $sql_update ="UPDATE tlink SET name = '".$name."', link ='".$link."' WHERE id_li
|
|||||||
|
|
||||||
if (isset($_GET["borrar"])){ // if delete
|
if (isset($_GET["borrar"])){ // if delete
|
||||||
$id_link = safe_input($_GET["borrar"]);
|
$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)
|
if (! $result)
|
||||||
echo "<h3 class='error'>".__('There was a problem deleting link')."</h3>";
|
echo "<h3 class='error'>".__('There was a problem deleting link')."</h3>";
|
||||||
else
|
else
|
||||||
@ -68,14 +71,16 @@ if ((isset($_GET["form_add"])) or (isset($_GET["form_edit"]))){
|
|||||||
if (isset($_GET["form_edit"])){
|
if (isset($_GET["form_edit"])){
|
||||||
$creation_mode = 0;
|
$creation_mode = 0;
|
||||||
$id_link = safe_input($_GET["id_link"]);
|
$id_link = safe_input($_GET["id_link"]);
|
||||||
$sql1='SELECT * FROM tlink WHERE id_link = '.$id_link;
|
|
||||||
$result=mysql_query($sql1);
|
$row = get_db_row("tlink", "id_link", $id_link);
|
||||||
if ($row=mysql_fetch_array($result)){
|
|
||||||
|
if ($row !== false) {
|
||||||
$nombre = $row["name"];
|
$nombre = $row["name"];
|
||||||
$link = $row["link"];
|
$link = $row["link"];
|
||||||
}
|
}
|
||||||
else echo "<h3 class='error'>".__('Name error')."</h3>";
|
else echo "<h3 class='error'>".__('Name error')."</h3>";
|
||||||
} else { // form_add
|
}
|
||||||
|
else { // form_add
|
||||||
$creation_mode =1;
|
$creation_mode =1;
|
||||||
$nombre = "";
|
$nombre = "";
|
||||||
$link = "";
|
$link = "";
|
||||||
@ -87,7 +92,9 @@ if ((isset($_GET["form_add"])) or (isset($_GET["form_edit"]))){
|
|||||||
else
|
else
|
||||||
echo "<input type='hidden' name='update' value='1'>";
|
echo "<input type='hidden' name='update' value='1'>";
|
||||||
echo "<input type='hidden' name='id_link' value='";
|
echo "<input type='hidden' name='id_link' value='";
|
||||||
if (isset($id_link)) {echo $id_link;}
|
if (isset($id_link)) {
|
||||||
|
echo $id_link;
|
||||||
|
}
|
||||||
echo "'>";
|
echo "'>";
|
||||||
echo '<tr>
|
echo '<tr>
|
||||||
<td class="datos">'.__('Link name').'</td>
|
<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 "<table cellpadding='4' cellspacing='4' class='databox'>";
|
||||||
echo "<th width='180px'>".__('Link name')."</th>";
|
echo "<th width='180px'>".__('Link name')."</th>";
|
||||||
echo "<th width='80px'>".__('Delete')."</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;
|
$color=1;
|
||||||
while ($row=mysql_fetch_array($result)){
|
foreach ($rows as $row) {
|
||||||
if ($color == 1){
|
if ($color == 1){
|
||||||
$tdcolor = "datos";
|
$tdcolor = "datos";
|
||||||
$color = 0;
|
$color = 0;
|
||||||
|
@ -130,10 +130,14 @@ else {
|
|||||||
echo "<th>".__('Author')."</th>";
|
echo "<th>".__('Author')."</th>";
|
||||||
echo "<th>".__('Timestamp')."</th>";
|
echo "<th>".__('Timestamp')."</th>";
|
||||||
echo "<th>".__('Delete')."</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;
|
$color = 1;
|
||||||
while ($row=mysql_fetch_array($result)){
|
foreach ($rows as $row) {
|
||||||
if ($color == 1) {
|
if ($color == 1) {
|
||||||
$tdcolor = "datos";
|
$tdcolor = "datos";
|
||||||
$color = 0;
|
$color = 0;
|
||||||
|
@ -334,7 +334,6 @@ function postgresql_process_sql_insert($table, $values) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Escape string to set it properly to use in sql queries
|
* Escape string to set it properly to use in sql queries
|
||||||
*
|
*
|
||||||
* @param string String to be cleaned.
|
* @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");
|
grafico_modulo_log4x_trace("$sql1");
|
||||||
|
|
||||||
$rows = 0;
|
$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++;
|
$rows++;
|
||||||
$utimestamp = $row[0];
|
$utimestamp = $row[0];
|
||||||
$severity = $row[1];
|
$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
|
* @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;
|
global $config;
|
||||||
|
|
||||||
switch ($config["dbtype"]) {
|
switch ($config["dbtype"]) {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
return mysql_process_sql_insert ($table, $values);
|
return mysql_process_sql_insert($table, $values);
|
||||||
break;
|
break;
|
||||||
case "postgresql":
|
case "postgresql":
|
||||||
return postgresql_process_sql_insert ($table, $values);
|
return postgresql_process_sql_insert($table, $values);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1270,12 +1270,14 @@ function html2rgb($htmlcolor)
|
|||||||
$g = hexdec($htmlcolor[2].$htmlcolor[3]);
|
$g = hexdec($htmlcolor[2].$htmlcolor[3]);
|
||||||
$b = hexdec($htmlcolor[4].$htmlcolor[5]);
|
$b = hexdec($htmlcolor[4].$htmlcolor[5]);
|
||||||
return array($r, $g, $b);
|
return array($r, $g, $b);
|
||||||
} elseif (strlen($htmlcolor) == 3) {
|
}
|
||||||
|
elseif (strlen($htmlcolor) == 3) {
|
||||||
$r = hexdec($htmlcolor[0].$htmlcolor[0]);
|
$r = hexdec($htmlcolor[0].$htmlcolor[0]);
|
||||||
$g = hexdec($htmlcolor[1].$htmlcolor[1]);
|
$g = hexdec($htmlcolor[1].$htmlcolor[1]);
|
||||||
$b = hexdec($htmlcolor[2].$htmlcolor[2]);
|
$b = hexdec($htmlcolor[2].$htmlcolor[2]);
|
||||||
return array($r, $g, $b);
|
return array($r, $g, $b);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -401,14 +401,16 @@ class PchartGraph extends PandoraGraphAbstract {
|
|||||||
$this->graph->drawFilledCubicCurve ($this->dataset->GetData(),
|
$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->graph->drawScale ($this->dataset->GetData (),
|
||||||
$this->dataset->GetDataDescription (),
|
$this->dataset->GetDataDescription (),
|
||||||
SCALE_START0, 80, 80, 80, $this->show_axis, 0, 0, false,
|
SCALE_START0, 80, 80, 80, $this->show_axis, 0, 0, false,
|
||||||
$this->xaxis_interval);
|
$this->xaxis_interval);
|
||||||
$this->graph->drawLineGraph ($this->dataset->GetData (),
|
$this->graph->drawLineGraph ($this->dataset->GetData (),
|
||||||
$this->dataset->GetDataDescription ());
|
$this->dataset->GetDataDescription ());
|
||||||
} else { // Non-stacked, area overlapped
|
}
|
||||||
|
else { // Non-stacked, area overlapped
|
||||||
$this->graph->drawScale ($this->dataset->GetData (),
|
$this->graph->drawScale ($this->dataset->GetData (),
|
||||||
$this->dataset->GetDataDescription (),
|
$this->dataset->GetDataDescription (),
|
||||||
SCALE_START0, 80, 80, 80, $this->show_axis, 0, 0, false,
|
SCALE_START0, 80, 80, 80, $this->show_axis, 0, 0, false,
|
||||||
@ -610,7 +612,8 @@ class PchartGraph extends PandoraGraphAbstract {
|
|||||||
$this->graph->drawTextBox ($this->width - 8, 40,
|
$this->graph->drawTextBox ($this->width - 8, 40,
|
||||||
$this->width - 240, 90, 'PANDORA FMS', 90,
|
$this->width - 240, 90, 'PANDORA FMS', 90,
|
||||||
174, 214, 174, ALIGN_BOTTOM_LEFT, false);
|
174, 214, 174, ALIGN_BOTTOM_LEFT, false);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$this->graph->setFontProperties ($this->fontpath, 7);
|
$this->graph->setFontProperties ($this->fontpath, 7);
|
||||||
$this->graph->drawTextBox ($this->width - 8, 50,
|
$this->graph->drawTextBox ($this->width - 8, 50,
|
||||||
$this->width - 240, 60, 'PANDORA FMS', 90,
|
$this->width - 240, 60, 'PANDORA FMS', 90,
|
||||||
|
@ -76,11 +76,13 @@ $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)');
|
//$modules = get_db_all_rows_filter ('tagente_modulo', array('id_agente' => $user_agents, 'nombre' => '<>delete_pending'), 'DISTINCT(nombre)');
|
||||||
|
|
||||||
$sql = '
|
switch ($config["dbtype"]) {
|
||||||
select distinct(nombre)
|
case "mysql":
|
||||||
from tagente_modulo
|
$sql = '
|
||||||
where nombre <> "delete_pending" and id_agente in
|
select distinct(nombre)
|
||||||
(
|
from tagente_modulo
|
||||||
|
where nombre <> "delete_pending" and id_agente in
|
||||||
|
(
|
||||||
select id_agente
|
select id_agente
|
||||||
from tagente where id_grupo IN (
|
from tagente where id_grupo IN (
|
||||||
select id_grupo
|
select id_grupo
|
||||||
@ -105,7 +107,41 @@ where nombre <> "delete_pending" and id_agente in
|
|||||||
from tperfil where agent_view = 1
|
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);
|
$modules = get_db_all_rows_sql($sql);
|
||||||
|
|
||||||
|
@ -28,13 +28,17 @@ $id_graph = (int) get_parameter ('id');
|
|||||||
// Delete module SQL code
|
// Delete module SQL code
|
||||||
if ($delete_graph) {
|
if ($delete_graph) {
|
||||||
if (check_acl ($config['id_user'], 0, "AW")) {
|
if (check_acl ($config['id_user'], 0, "AW")) {
|
||||||
$sql = "DELETE FROM tgraph_source WHERE id_graph = $id_graph";
|
$res = process_sql_delete('tgraph_source', array('id_graph' => $id_graph));
|
||||||
if ($res=mysql_query($sql))
|
|
||||||
|
if ($res)
|
||||||
$result = "<h3 class=suc>".__('Successfully deleted')."</h3>";
|
$result = "<h3 class=suc>".__('Successfully deleted')."</h3>";
|
||||||
else
|
else
|
||||||
$result = "<h3 class=error>".__('Not deleted. Error deleting data')."</h3>";
|
$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";
|
$sql = "DELETE FROM tgraph WHERE id_graph = $id_graph";
|
||||||
if ($res=mysql_query($sql))
|
if ($res)
|
||||||
$result = "<h3 class=suc>".__('Successfully deleted')."</h3>";
|
$result = "<h3 class=suc>".__('Successfully deleted')."</h3>";
|
||||||
else
|
else
|
||||||
$result = "<h3 class=error>".__('Not deleted. Error deleting data')."</h3>";
|
$result = "<h3 class=error>".__('Not deleted. Error deleting data')."</h3>";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user