2008-10-02 Esteban Sanchez <estebans@artica.es>

* include/functions_db.php: Removed quotes when using $order_field so
        it can be used order (ASC or DESC).

        * include/functions_html.php: Added thead and tbody to be more XHTML
        compliant.

        * operation/reporting/graph_viewer.php: Fixed a typo error that was
        not allowing to remove a graph. Style correction, variables renamed to  
        have a meaning ($row has no scope or meaning, please do not use it!) 
        and better use of the parameters.

        * godmode/extensions.php: Style correction.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1127 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
esanchezm 2008-10-02 09:19:02 +00:00
parent 9a1ad64eb8
commit c5683c4ef8
5 changed files with 58 additions and 40 deletions

View File

@ -1,3 +1,18 @@
2008-10-02 Esteban Sanchez <estebans@artica.es>
* include/functions_db.php: Removed quotes when using $order_field so
it can be used order (ASC or DESC).
* include/functions_html.php: Added thead and tbody to be more XHTML
compliant.
* operation/reporting/graph_viewer.php: Fixed a typo error that was
not allowing to remove a graph. Style correction, variables renamed to
have a meaning ($row has no scope or meaning, please do not use it!)
and better use of the parameters.
* godmode/extensions.php: Style correction.
2008-10-01 Ramon Novoa <rnovoa@artica.es> 2008-10-01 Ramon Novoa <rnovoa@artica.es>
* godmode/agentes/module_manager_editor_network.php: Added support for * godmode/agentes/module_manager_editor_network.php: Added support for

View File

@ -30,7 +30,7 @@ if (sizeof ($config['extensions']) == 0) {
return; return;
} }
echo '<h2>'.__('Defined extensions')."</h2>"; echo '<h2>'.__('Defined extensions').'</h2>';
$table->width = '95%'; $table->width = '95%';
$table->head = array (); $table->head = array ();
$table->head[0] = __('Name'); $table->head[0] = __('Name');

View File

@ -1466,7 +1466,7 @@ function process_sql ($sql, $rettype = "affected_rows") {
*/ */
function get_db_all_rows_in_table ($table, $order_field = "") { function get_db_all_rows_in_table ($table, $order_field = "") {
if ($order_field != "") { if ($order_field != "") {
return get_db_all_rows_sql ("SELECT * FROM `".$table."` ORDER BY `".$order_field."` "); return get_db_all_rows_sql ("SELECT * FROM `".$table."` ORDER BY ".$order_field);
} else { } else {
return get_db_all_rows_sql ("SELECT * FROM `".$table."`"); return get_db_all_rows_sql ("SELECT * FROM `".$table."`");
} }
@ -1491,7 +1491,7 @@ function get_db_all_rows_field_filter ($table, $field, $condition, $order_field
} }
if ($order_field != "") if ($order_field != "")
$sql .= sprintf(" ORDER BY `%s`",$order_field); $sql .= sprintf(" ORDER BY %s",$order_field);
return get_db_all_rows_sql ($sql); return get_db_all_rows_sql ($sql);
} }

View File

@ -368,10 +368,9 @@ function print_table (&$table, $return = false) {
$output .= " cellpadding=\"$table->cellpadding\" cellspacing=\"$table->cellspacing\" "; $output .= " cellpadding=\"$table->cellpadding\" cellspacing=\"$table->cellspacing\" ";
$output .= " border=\"$table->border\" class=\"$table->class\" id=\"$tableid\" >\n"; $output .= " border=\"$table->border\" class=\"$table->class\" id=\"$tableid\" >\n";
$countcols = 0; $countcols = 0;
if (!empty ($table->head)) { if (!empty ($table->head)) {
$countcols = count ($table->head); $countcols = count ($table->head);
$output .= '<tr>'; $output .= '<thead><tr>';
foreach ($table->head as $key => $heading) { foreach ($table->head as $key => $heading) {
if (!isset ($size[$key])) { if (!isset ($size[$key])) {
$size[$key] = ''; $size[$key] = '';
@ -382,8 +381,10 @@ function print_table (&$table, $return = false) {
$output .= '<th class="header c'.$key.'" scope="col">'. $heading .'</th>'; $output .= '<th class="header c'.$key.'" scope="col">'. $heading .'</th>';
} }
$output .= '</tr>'."\n"; $output .= '</tr></thead>'."\n";
} }
$output .= '<tbody>'."\n";
if (!empty ($table->data)) { if (!empty ($table->data)) {
$oddeven = 1; $oddeven = 1;
foreach ($table->data as $keyrow => $row) { foreach ($table->data as $keyrow => $row) {
@ -428,7 +429,7 @@ function print_table (&$table, $return = false) {
$output .= '</tr>'."\n"; $output .= '</tr>'."\n";
} }
} }
$output .= '</table>'."\n"; $output .= '</tbody></table>'."\n";
if ($return) if ($return)
return $output; return $output;

View File

@ -21,10 +21,13 @@
check_login (); check_login ();
$delete_graph = (bool) get_parameter ('delete_graph');
$view_graph = (bool) get_parameter ('view_graph');
$id = (int) get_parameter ('id');
// Delete module SQL code // Delete module SQL code
if (isset($_GET["delete"])) { if ($delete_graph) {
if (! give_acl($config['id_user'], 0, "AW")) { if (give_acl ($config['id_user'], 0, "AW")) {
$id = $_GET["delete"];
$sql = "DELETE FROM tgraph_source WHERE id_graph = $id"; $sql = "DELETE FROM tgraph_source WHERE id_graph = $id";
if ($res=mysql_query($sql)) if ($res=mysql_query($sql))
$result = "<h3 class=suc>".__('Deleted successfully')."</h3>"; $result = "<h3 class=suc>".__('Deleted successfully')."</h3>";
@ -38,23 +41,22 @@ if (isset($_GET["delete"])) {
echo $result; echo $result;
} else { } else {
audit_db ($config['id_user'],$REMOTE_ADDR, "ACL Violation","Trying to delete a graph from access graph builder"); audit_db ($config['id_user'],$REMOTE_ADDR, "ACL Violation","Trying to delete a graph from access graph builder");
include ("general/noaccess.php"); include ("general/noaccess.php");
exit; exit;
} }
} }
if (isset($_GET["view_graph"])){ if ($view_graph) {
$id_graph = $_GET["view_graph"]; $sql="SELECT * FROM tgraph WHERE id_graph = $id";
$sql="SELECT * FROM tgraph WHERE id_graph = $id_graph";
$res=mysql_query($sql); $res=mysql_query($sql);
if ($row = mysql_fetch_array($res)){ if ($graph = mysql_fetch_array($res)){
$id_user = $row["id_user"]; $id_user = $graph["id_user"];
$private = $row["private"]; $private = $graph["private"];
$width = $row["width"]; $width = $graph["width"];
$height = $row["height"]; $height = $graph["height"];
$zoom = (int) get_parameter ('zoom', 0); $zoom = (int) get_parameter ('zoom', 0);
if ($zoom > 0){ if ($zoom > 0) {
switch ($zoom){ switch ($zoom) {
case 1: case 1:
$width = 500; $width = 500;
$height = 210; $height = 210;
@ -71,28 +73,28 @@ if (isset($_GET["view_graph"])){
} }
$period = (int) get_parameter ('period'); $period = (int) get_parameter ('period');
if (! $period) if (! $period)
$period = $row["period"]; $period = $graph["period"];
else else
$period = 3600 * $period; $period = 3600 * $period;
$events = $row["events"]; $events = $graph["events"];
$description = $row["description"]; $description = $graph["description"];
$stacked = (int) get_parameter ('stacked', -1); $stacked = (int) get_parameter ('stacked', -1);
if ($stacked == -1) if ($stacked == -1)
$stacked = $row["stacked"]; $stacked = $graph["stacked"];
$name = $row["name"]; $name = $graph["name"];
if (($row["private"]==1) && ($row["id_user"] != $id_user)){ if (($graph["private"]==1) && ($graph["id_user"] != $id_user)){
audit_db($config['id_user'],$REMOTE_ADDR, "ACL Violation","Trying to access to a custom graph not allowed"); audit_db($config['id_user'],$REMOTE_ADDR, "ACL Violation","Trying to access to a custom graph not allowed");
include ("general/noaccess.php"); include ("general/noaccess.php");
exit; exit;
} }
$sql2="SELECT * FROM tgraph_source WHERE id_graph = $id_graph"; $sql2="SELECT * FROM tgraph_source WHERE id_graph = $id";
$res2=mysql_query($sql2); $res2=mysql_query($sql2);
while ( $row2 = mysql_fetch_array($res2)){ while ($graph_source = mysql_fetch_array($res2)) {
$weight = $row2["weight"]; $weight = $graph_source["weight"];
$id_agent_module = $row2["id_agent_module"]; $id_agent_module = $graph_source["id_agent_module"];
$id_grupo = get_db_sql ("SELECT id_grupo FROM tagente, tagente_modulo WHERE tagente_modulo.id_agente_modulo = $id_agent_module AND tagente.id_agente = tagente_modulo.id_agente"); $id_grupo = get_db_sql ("SELECT id_grupo FROM tagente, tagente_modulo WHERE tagente_modulo.id_agente_modulo = $id_agent_module AND tagente.id_agente = tagente_modulo.id_agente");
if (give_acl($config["id_user"], $id_grupo, "AR")==1){ if (give_acl($config["id_user"], $id_grupo, "AR")==1){
if (!isset($modules)){ if (!isset($modules)){
@ -113,7 +115,7 @@ src='reporting/fgraph.php?tipo=combined&height=$height&width=$width&id=$modules&
border=1 alt=''>"; border=1 alt=''>";
echo "</td></tr></table>"; echo "</td></tr></table>";
$period_label = human_time_description ($period); $period_label = human_time_description ($period);
echo "<form method='POST' action='index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=$id_graph'>"; echo "<form method='POST' action='index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=1&id=$id'>";
echo "<table class='databox_frame' cellpadding=4 cellspacing=4>"; echo "<table class='databox_frame' cellpadding=4 cellspacing=4>";
echo "<tr><td class='datos'>"; echo "<tr><td class='datos'>";
echo "<b>".__('Period')."</b>"; echo "<b>".__('Period')."</b>";
@ -169,8 +171,8 @@ if (mysql_num_rows($res)) {
echo "<th>".__('Delete')."</th>"; echo "<th>".__('Delete')."</th>";
echo "</tr>"; echo "</tr>";
while ($row = mysql_fetch_array($res)){ while ($graph = mysql_fetch_array($res)){
if (($row["private"]==0) || ($row["id_user"] == $id_user)){ if (($graph["private"] == 0) || ($graph["id_user"] == $id_user)) {
// Calculate table line color // Calculate table line color
if ($color == 1){ if ($color == 1){
$tdcolor = "datos"; $tdcolor = "datos";
@ -181,13 +183,13 @@ if (mysql_num_rows($res)) {
$color = 1; $color = 1;
} }
echo "<tr>"; echo "<tr>";
echo "<td valign='top' class='$tdcolor'>".$row["name"]."</td>"; echo "<td valign='top' class='$tdcolor'>".$graph["name"]."</td>";
echo "<td class='$tdcolor'>".$row["description"]."</td>"; echo "<td class='$tdcolor'>".$graph["description"]."</td>";
$id_graph = $row["id_graph"]; $id = $graph["id_graph"];
echo "<td valign='middle' class='$tdcolor' align='center'><a href='index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=$id_graph'><img src='images/images.png'></a>"; echo "<td valign='middle' class='$tdcolor' align='center'><a href='index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=1&id=$id'><img src='images/images.png'></a>";
if (give_acl ($config['id_user'], 0, "AW")) { if (give_acl ($config['id_user'], 0, "AW")) {
echo "<td class='$tdcolor' align='center'><a href='index.php?sec=reporting&sec2=operation/reporting/graph_viewer&delete=$id_graph' ".'onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'; echo "<td class='$tdcolor' align='center'><a href='index.php?sec=reporting&sec2=operation/reporting/graph_viewer&delete_graph=1&id=$id' ".'onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
echo "<img src='images/cross.png'></a></td>"; echo "<img src='images/cross.png'></a></td>";
} }
} }