diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 4f279e2193..14a75b7317 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,19 @@ +2011-03-09 Miguel de Dios + + * install.php, operation/incidents/incident.php, + operation/agentes/status_monitor.php, operation/agentes/datos_agente.php, + operation/servers/view_server.php, operation/snmpconsole/snmp_view.php, + operation/events/events_rss.php, operation/events/events_list.php, + operation/events/events_marquee.php, operation/search_users.php, + mobile/operation/agents/monitor_status.php, + mobile/operation/agents/view_agents.php, + mobile/operation/agents/view_alerts.php, mobile/operation/events/events.php, + mobile/include/functions_web.php, godmode/admin_access_logs.php, + godmode/agentes/modificar_agente.php, godmode/alerts/alert_actions.php, + godmode/reporting/reporting_builder.list_items.php: changed and addded in + the source, the SQL queries for the "LIMIT x, x" to "LIMIT x OFFSET x", that + it is standard for PostgreSQL. + 2011-03-09 Miguel de Dios * include/functions_reporting.php, include/functions.php, diff --git a/pandora_console/godmode/admin_access_logs.php b/pandora_console/godmode/admin_access_logs.php index 39c9821060..18fb686ea7 100644 --- a/pandora_console/godmode/admin_access_logs.php +++ b/pandora_console/godmode/admin_access_logs.php @@ -119,7 +119,14 @@ $url = "index.php?sec=godmode&sec2=godmode/admin_access_logs&tipo_log=".$tipo_lo pagination ($count, $url); -$sql = sprintf ("SELECT * FROM tsesion %s ORDER BY fecha DESC LIMIT %d, %d", $filter, $offset, $config["block_size"]); +switch ($config["dbtype"]) { + case "mysql": + $sql = sprintf ("SELECT * FROM tsesion %s ORDER BY fecha DESC LIMIT %d, %d", $filter, $offset, $config["block_size"]); + break; + case "postgresql": + $sql = sprintf ("SELECT * FROM tsesion %s ORDER BY fecha DESC LIMIT %d OFFSET %d", $filter, $config["block_size"], $offset); + break; +} $result = get_db_all_rows_sql ($sql); if (empty ($result)) { diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 76601d358a..985167d433 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -182,20 +182,45 @@ if ($ag_group > 0) { $ag_group, $search_sql); $total_agents = get_db_sql ($sql); - $sql = sprintf ('SELECT * - FROM tagente - WHERE id_grupo = %d - %s - ORDER BY %s %s LIMIT %d, %d', - $ag_group, $search_sql, $order['field'], $order['order'], $offset, $config["block_size"]); -} else { + switch ($config["dbtype"]) { + case "mysql": + $sql = sprintf ('SELECT * + FROM tagente + WHERE id_grupo = %d + %s + ORDER BY %s %s LIMIT %d, %d', + $ag_group, $search_sql, $order['field'], $order['order'], $offset, $config["block_size"]); + break; + case "postgresql": + $sql = sprintf ('SELECT * + FROM tagente + WHERE id_grupo = %d + %s + ORDER BY %s %s LIMIT %d OFFSET %d', + $ag_group, $search_sql, $order['field'], $order['order'], $config["block_size"], $offset); + break; + } +} +else { // Admin user get ANY group, even if they doesnt exist if (check_acl ($config['id_user'], 0, "PM")){ $sql = sprintf ('SELECT COUNT(*) FROM tagente WHERE 1=1 %s', $search_sql); $total_agents = get_db_sql ($sql); - $sql = sprintf ('SELECT * FROM tagente WHERE 1=1 %s ORDER BY %s %s LIMIT %d, %d', $search_sql, $order['field'], $order['order'], $offset, $config["block_size"]); - } else { + switch ($config["dbtype"]) { + case "mysql": + $sql = sprintf ('SELECT * + FROM tagente WHERE 1=1 %s + ORDER BY %s %s LIMIT %d, %d', $search_sql, $order['field'], $order['order'], $offset, $config["block_size"]); + break; + case "postgresql": + $sql = sprintf ('SELECT * + FROM tagente WHERE 1=1 %s + ORDER BY %s %s LIMIT %d OFFSET %d', $search_sql, $order['field'], $order['order'], $config["block_size"], $offset); + break; + } + } + else { $sql = sprintf ('SELECT COUNT(*) FROM tagente @@ -204,14 +229,27 @@ if ($ag_group > 0) { implode (',', array_keys (get_user_groups ())), $search_sql); $total_agents = get_db_sql ($sql); - - $sql = sprintf ('SELECT * - FROM tagente - WHERE id_grupo IN (%s) - %s - ORDER BY %s %s LIMIT %d, %d', - implode (',', array_keys (get_user_groups ())), - $search_sql, $order['field'], $order['order'], $offset, $config["block_size"]); + + switch ($config["dbtype"]) { + case "mysql": + $sql = sprintf ('SELECT * + FROM tagente + WHERE id_grupo IN (%s) + %s + ORDER BY %s %s LIMIT %d, %d', + implode (',', array_keys (get_user_groups ())), + $search_sql, $order['field'], $order['order'], $offset, $config["block_size"]); + break; + case "postgresql": + $sql = sprintf ('SELECT * + FROM tagente + WHERE id_grupo IN (%s) + %s + ORDER BY %s %s LIMIT %d OFFSET %d', + implode (',', array_keys (get_user_groups ())), + $search_sql, $order['field'], $order['order'], $config["block_size"], $offset); + break; + } } } diff --git a/pandora_console/godmode/alerts/alert_actions.php b/pandora_console/godmode/alerts/alert_actions.php index f9398a5670..30e788fe02 100644 --- a/pandora_console/godmode/alerts/alert_actions.php +++ b/pandora_console/godmode/alerts/alert_actions.php @@ -209,7 +209,8 @@ if ($delete_action) { // Header print_page_header (__('Alerts').' » '.__('Alert actions'), "images/god2.png", false, "", true); // If user tries to delete an action of others groups - }else{ + } + else{ $own_info = get_user_info ($config['id_user']); if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) $own_groups = array_keys(get_user_groups($config['id_user'], "LM")); @@ -227,7 +228,8 @@ if ($delete_action) { exit; } } - }else + } + else // Header print_page_header (__('Alerts').' » '.__('Alert actions'), "images/god2.png", false, "", true); diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index e13470ad0f..a1c99ff892 100644 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -133,7 +133,7 @@ switch ($config["dbtype"]) { FROM treport_content WHERE ' . $where . ' AND id_report = ' . $idReport . ' ORDER BY "order" - LIMIT ' . $offset . ', ' . $config["block_size"]); + LIMIT ' . $config["block_size"] . ' OFFSET ' . $offset); break; } $countItems = get_db_sql('SELECT COUNT(id_rc) FROM treport_content WHERE ' . $where . ' AND id_report = ' . $idReport); diff --git a/pandora_console/install.php b/pandora_console/install.php index ce1dcf3636..767378a1b1 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -312,16 +312,15 @@ function install_step1_licence() { if (!file_exists("COPYING")){ echo "
Licence file 'COPYING' is not present in your distribution. This means you have some 'partial' Pandora FMS distribution. We cannot continue without accepting the licence file."; echo "
"; - } else { - + } + else { echo "
"; echo ""; echo "

"; echo ""; - - } + } echo ""; print_logo_status (2, 5); diff --git a/pandora_console/mobile/include/functions_web.php b/pandora_console/mobile/include/functions_web.php index 696d01a637..6a67459759 100644 --- a/pandora_console/mobile/include/functions_web.php +++ b/pandora_console/mobile/include/functions_web.php @@ -71,7 +71,8 @@ function footer() { if (isset($_SERVER['REQUEST_TIME'])) { $time = $_SERVER['REQUEST_TIME']; - } else { + } + else { $time = get_system_time (); } ?> diff --git a/pandora_console/mobile/operation/agents/monitor_status.php b/pandora_console/mobile/operation/agents/monitor_status.php index 64740e6724..47691aee76 100644 --- a/pandora_console/mobile/operation/agents/monitor_status.php +++ b/pandora_console/mobile/operation/agents/monitor_status.php @@ -144,7 +144,14 @@ class MonitorStatus { $total = get_db_value_sql('SELECT COUNT(*) ' . $sql); - $rows = get_db_all_rows_sql($selectSQL . $sql . ' LIMIT ' . $this->offset . ', ' . $this->system->getPageSize()); + switch ($config["dbtype"]) { + case "mysql": + $rows = get_db_all_rows_sql($selectSQL . $sql . ' LIMIT ' . $this->offset . ', ' . $this->system->getPageSize()); + break; + case "postgresql": + $rows = get_db_all_rows_sql($selectSQL . $sql . ' LIMIT ' . $this->system->getPageSize() . ' OFFSET ' . $this->offset); + break; + } if ($rows === false) $rows = array(); diff --git a/pandora_console/mobile/operation/agents/view_agents.php b/pandora_console/mobile/operation/agents/view_agents.php index 5e8330c575..3287949c3d 100644 --- a/pandora_console/mobile/operation/agents/view_agents.php +++ b/pandora_console/mobile/operation/agents/view_agents.php @@ -351,24 +351,6 @@ class ViewAgent { $template = safe_output(get_alert_template ($alert['id_alert_template'])); $data[] = printTruncateText(safe_output($template['name']), 20, true, true); -// $actions = get_alert_agent_module_actions ($alert['id'], false, false); -// if (!empty($actions)){ -// $actionText = '

    '; -// foreach ($actions as $action) { -// $actionText .= '
  • ' . $action['name']; -// if ($action["fires_min"] != $action["fires_max"]){ -// $actionText .= " (".$action["fires_min"] . " / ". $action["fires_max"] . ")"; -// } -// $actionText .= '

  • '; -// } -// $actionText .= '
'; -// } -// else { -// if ($actionDefault != "") -// $actionText = get_db_sql ("SELECT name FROM talert_actions WHERE id = $actionDefault"). " (".__("Default") . ")"; -// } -// -// $data[] = $actionText; $data[] = print_timestamp ($alert["last_fired"], true, array('units' => 'tiny')); $status = STATUS_ALERT_NOT_FIRED; @@ -377,10 +359,12 @@ class ViewAgent { if ($alert["times_fired"] > 0) { $status = STATUS_ALERT_FIRED; $title = __('Alert fired').' '.$alert["times_fired"].' '.__('times'); - } elseif ($alert["disabled"] > 0) { + } + elseif ($alert["disabled"] > 0) { $status = STATUS_ALERT_DISABLED; $title = __('Alert disabled'); - } else { + } + else { $status = STATUS_ALERT_NOT_FIRED; $title = __('Alert not fired'); } @@ -391,17 +375,6 @@ class ViewAgent { $table->data[] = $data; } print_table($table); - -// echo "

" . __('Alerts compound') . "

"; -// -// $alertsCombined = get_agent_alerts_compound(array($this->idAgent)); -// -// $table->data = array(); -// foreach ($alertsCombined as $alert) { -// $data = array(); -// -// $table->data[] = $data; -// } } } @@ -415,7 +388,7 @@ class viewGraph { $this->system = $system; $this->idAgentModule = $idAgentModule; $this->agentModule = get_db_row_filter('tagente_modulo', array('id_agente_modulo' => $this->idAgentModule)); - //$this->system->debug($this->agentModule); + $this->period = $this->system->getRequest('period', 86400); $this->offset = $this->system->getRequest("offset", 0); @@ -493,7 +466,14 @@ class viewGraph { $count = get_db_value_sql($sql_count); - $sql = 'SELECT * ' . $sql_body . ' LIMIT ' . $this->offset . ',' . $this->system->getPageSize(); + switch ($config["dbtype"]) { + case "mysql": + $sql = 'SELECT * ' . $sql_body . ' LIMIT ' . $this->offset . ',' . $this->system->getPageSize(); + break; + case "postgresql": + $sql = 'SELECT * ' . $sql_body . ' LIMIT ' . $this->system->getPageSize() . ' OFFSET ' . $this->offset; + break; + } $result = get_db_all_rows_sql ($sql); diff --git a/pandora_console/mobile/operation/agents/view_alerts.php b/pandora_console/mobile/operation/agents/view_alerts.php index 1fe26ffc07..eae28117d6 100644 --- a/pandora_console/mobile/operation/agents/view_alerts.php +++ b/pandora_console/mobile/operation/agents/view_alerts.php @@ -69,10 +69,12 @@ class ViewAlerts { if ($alert["times_fired"] > 0) { $status = STATUS_ALERT_FIRED; $title = __('Alert fired').' '.$alert["times_fired"].' '.__('times'); - } elseif ($alert["disabled"] > 0) { + } + elseif ($alert["disabled"] > 0) { $status = STATUS_ALERT_DISABLED; $title = __('Alert disabled'); - } else { + } + else { $status = STATUS_ALERT_NOT_FIRED; $title = __('Alert not fired'); } diff --git a/pandora_console/mobile/operation/events/events.php b/pandora_console/mobile/operation/events/events.php index a3de7a4806..b789c19c04 100644 --- a/pandora_console/mobile/operation/events/events.php +++ b/pandora_console/mobile/operation/events/events.php @@ -25,6 +25,7 @@ class EventsView { function show() { global $config; + $config['text_char_long'] = 12; $offset = $this->system->getRequest("offset", 0); @@ -119,7 +120,14 @@ class EventsView { $sql_count = str_replace('*', 'COUNT(*)', $sql); - $sql = $sql . sprintf(' LIMIT %d,%d', $offset, $this->system->getPageSize()); + switch ($config["dbtype"]) { + case "mysql": + $sql = $sql . sprintf(' LIMIT %d,%d', $offset, $this->system->getPageSize()); + break; + case "postgresql": + $sql = $sql . sprintf(' LIMIT %d OFFSET %d', $this->system->getPageSize(), $offset); + break; + } $count = get_db_value_sql($sql_count); diff --git a/pandora_console/operation/agentes/datos_agente.php b/pandora_console/operation/agentes/datos_agente.php index 7e650a4f45..8e95e8bf6e 100644 --- a/pandora_console/operation/agentes/datos_agente.php +++ b/pandora_console/operation/agentes/datos_agente.php @@ -98,7 +98,14 @@ $sql_count = "SELECT count(*) " . $sql_body; $count = get_db_value_sql($sql_count); -$sql .= " LIMIT " . $offset . "," . $block_size; +switch ($config["dbtype"]) { + case "mysql": + $sql .= " LIMIT " . $offset . "," . $block_size; + break; + case "postgresql": + $sql .= " LIMIT " . $block_size . " OFFSET " . $offset; + break; +} $result = get_db_all_rows_sql ($sql); if ($result === false) { diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 7246050c2c..5a33b3515e 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -216,20 +216,40 @@ $sql .= " ORDER BY tagente.id_grupo, tagente.nombre"; // Build final SQL sentences $count = get_db_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo)".$sql); -$sql = "SELECT tagente_modulo.id_agente_modulo, - tagente.intervalo AS agent_interval, - tagente.nombre AS agent_name, - tagente_modulo.nombre AS module_name, - tagente_modulo.id_agente_modulo, - tagente_modulo.history_data, - tagente_modulo.flag AS flag, - tagente.id_grupo AS id_group, - tagente.id_agente AS id_agent, - tagente_modulo.id_tipo_modulo AS module_type, - tagente_modulo.module_interval, - tagente_estado.datos, - tagente_estado.estado, - tagente_estado.utimestamp AS utimestamp".$sql." LIMIT ".$offset.",".$config["block_size"]; +switch ($config["dbtype"]) { + case "mysql": + $sql = "SELECT tagente_modulo.id_agente_modulo, + tagente.intervalo AS agent_interval, + tagente.nombre AS agent_name, + tagente_modulo.nombre AS module_name, + tagente_modulo.id_agente_modulo, + tagente_modulo.history_data, + tagente_modulo.flag AS flag, + tagente.id_grupo AS id_group, + tagente.id_agente AS id_agent, + tagente_modulo.id_tipo_modulo AS module_type, + tagente_modulo.module_interval, + tagente_estado.datos, + tagente_estado.estado, + tagente_estado.utimestamp AS utimestamp".$sql." LIMIT ".$offset.",".$config["block_size"]; + break; + case "postgresql": + $sql = "SELECT tagente_modulo.id_agente_modulo, + tagente.intervalo AS agent_interval, + tagente.nombre AS agent_name, + tagente_modulo.nombre AS module_name, + tagente_modulo.id_agente_modulo, + tagente_modulo.history_data, + tagente_modulo.flag AS flag, + tagente.id_grupo AS id_group, + tagente.id_agente AS id_agent, + tagente_modulo.id_tipo_modulo AS module_type, + tagente_modulo.module_interval, + tagente_estado.datos, + tagente_estado.estado, + tagente_estado.utimestamp AS utimestamp".$sql." LIMIT " . $config["block_size"] . " OFFSET " . $offset; + break; +} $result = get_db_all_rows_sql ($sql); if ($count > $config["block_size"]) { diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index 6bf5a1d435..8dcb989845 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -244,16 +244,37 @@ echo '
 
'; echo ''; if ($group_rep == 0) { - $sql = "SELECT * - FROM tevento - WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC LIMIT ".$offset.",".$pagination; + switch ($config["dbtype"]) { + case "mysql": + $sql = "SELECT * + FROM tevento + WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC LIMIT ".$offset.",".$pagination; + break; + case "postgresql": + $sql = "SELECT * + FROM tevento + WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC LIMIT ".$pagination." OFFSET ".$offset; + break; + } } else { - $sql = "SELECT *, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep - FROM tevento - WHERE 1=1 ".$sql_post." - GROUP BY evento, id_agentmodule - ORDER BY timestamp_rep DESC LIMIT ".$offset.",".$pagination; + switch ($config["dbtype"]) { + case "mysql": + $sql = "SELECT *, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep + FROM tevento + WHERE 1=1 ".$sql_post." + GROUP BY evento, id_agentmodule + ORDER BY timestamp_rep DESC LIMIT ".$offset.",".$pagination; + break; + case "postgresql": + $sql = "SELECT *, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep + FROM tevento + WHERE 1=1 ".$sql_post." + GROUP BY evento, id_agentmodule + ORDER BY timestamp_rep DESC LIMIT ".$pagination." OFFSET ".$offset; + break; + } + } //Extract the events by filter (or not) from db diff --git a/pandora_console/operation/events/events_marquee.php b/pandora_console/operation/events/events_marquee.php index 2b4e2cf26f..d1ad191197 100644 --- a/pandora_console/operation/events/events_marquee.php +++ b/pandora_console/operation/events/events_marquee.php @@ -57,8 +57,14 @@ if (!check_acl ($config["id_user"], 0, "PM")) { $sql_group_filter .= " AND id_grupo != 0"; } - -$sql = "SELECT evento, timestamp, id_agente FROM tevento WHERE 1=1 $sql_group_filter ORDER BY utimestamp DESC LIMIT 0 , $MAX_MARQUEE_EVENTS"; +switch ($config["dbtype"]) { + case "mysql": + $sql = "SELECT evento, timestamp, id_agente FROM tevento WHERE 1=1 $sql_group_filter ORDER BY utimestamp DESC LIMIT 0 , $MAX_MARQUEE_EVENTS"; + break; + case "postgresql": + $sql = "SELECT evento, timestamp, id_agente FROM tevento WHERE 1=1 $sql_group_filter ORDER BY utimestamp DESC LIMIT $MAX_MARQUEE_EVENTS OFFSET 0"; + break; +} $result = get_db_all_rows_sql ($sql); foreach ($result as $row) { diff --git a/pandora_console/operation/events/events_rss.php b/pandora_console/operation/events/events_rss.php index 50c6cde035..9878761728 100644 --- a/pandora_console/operation/events/events_rss.php +++ b/pandora_console/operation/events/events_rss.php @@ -156,18 +156,35 @@ if ($id_event != -1) // Avoid to show system events to not administrators if(!check_acl($user, 0, "PM")) $sql_post .= " AND tevento.event_type <> 'system'"; - -$sql="SELECT tevento.id_evento AS event_id, - tevento.id_agente AS id_agent, - tevento.id_usuario AS validated_by, - tevento.id_grupo AS id_group, - tevento.estado AS validated, - tevento.evento AS event_descr, - tevento.utimestamp AS unix_timestamp, - tevento.event_type AS event_type - FROM tevento - WHERE 1 = 1" . $sql_post . " - ORDER BY utimestamp DESC LIMIT 0 , 30"; + +switch ($config["dbtype"]) { + case "mysql": + $sql="SELECT tevento.id_evento AS event_id, + tevento.id_agente AS id_agent, + tevento.id_usuario AS validated_by, + tevento.id_grupo AS id_group, + tevento.estado AS validated, + tevento.evento AS event_descr, + tevento.utimestamp AS unix_timestamp, + tevento.event_type AS event_type + FROM tevento + WHERE 1 = 1" . $sql_post . " + ORDER BY utimestamp DESC LIMIT 0 , 30"; + break; + case "postgresql": + $sql="SELECT tevento.id_evento AS event_id, + tevento.id_agente AS id_agent, + tevento.id_usuario AS validated_by, + tevento.id_grupo AS id_group, + tevento.estado AS validated, + tevento.evento AS event_descr, + tevento.utimestamp AS unix_timestamp, + tevento.event_type AS event_type + FROM tevento + WHERE 1 = 1" . $sql_post . " + ORDER BY utimestamp DESC LIMIT 30 OFFSET 0"; + break; +} $result= get_db_all_rows_sql ($sql); diff --git a/pandora_console/operation/incidents/incident.php b/pandora_console/operation/incidents/incident.php index c8b078c28f..fb21614ebb 100644 --- a/pandora_console/operation/incidents/incident.php +++ b/pandora_console/operation/incidents/incident.php @@ -181,9 +181,18 @@ $groups = get_user_groups ($config["id_user"], "IR"); //Select incidencts where the user has access to ($groups from //get_user_groups), array_keys for the id, implode to pass to SQL -$sql = "SELECT * FROM tincidencia - WHERE id_grupo IN (".implode (",",array_keys ($groups)).")" . $filter . " - ORDER BY actualizacion DESC LIMIT ".$offset.",".$config["block_size"]; +switch ($config["dbtype"]) { + case "mysql": + $sql = "SELECT * FROM tincidencia + WHERE id_grupo IN (".implode (",",array_keys ($groups)).")" . $filter . " + ORDER BY actualizacion DESC LIMIT ".$offset.",".$config["block_size"]; + break; + case "postgresql": + $sql = "SELECT * FROM tincidencia + WHERE id_grupo IN (".implode (",",array_keys ($groups)).")" . $filter . " + ORDER BY actualizacion DESC LIMIT ".$config["block_size"]." OFFSET ".$offset; + break; +} $result = get_db_all_rows_sql ($sql); if (empty ($result)) { diff --git a/pandora_console/operation/search_users.php b/pandora_console/operation/search_users.php index 86bfa4ee55..27964aac61 100755 --- a/pandora_console/operation/search_users.php +++ b/pandora_console/operation/search_users.php @@ -143,7 +143,8 @@ if ($searchUsers) { if(!$users_id) { $user_condition = ""; - }else { + } + else { // Condition with the visible agents $user_condition = " AND id_user IN (\"".implode('","',$users_id)."\")"; } @@ -200,7 +201,8 @@ else { $profileCell = print_image ("images/user_suit.png", true, array ("alt" => __('Admin'), "title" => __('Administrator'))).' '; - } else { + } + else { $profileCell = print_image ("images/user_green.png", true, array ("alt" => __('User'), "title" => __('Standard User'))).' '; @@ -214,7 +216,8 @@ else { $profileCell .= get_group_name ($row["id_grupo"]); $profileCell .= "
"; } - } else { + } + else { $profileCell .= __('The user doesn\'t have any assigned profile/group'); } $profileCell .= ""; diff --git a/pandora_console/operation/servers/view_server.php b/pandora_console/operation/servers/view_server.php index 368ccdc407..c093a20aa6 100644 --- a/pandora_console/operation/servers/view_server.php +++ b/pandora_console/operation/servers/view_server.php @@ -65,7 +65,8 @@ foreach ($servers as $server) { if ($server['status'] == 0) { $data[1] = print_status_image (STATUS_SERVER_DOWN, '', true); - } else { + } + else { $data[1] = print_status_image (STATUS_SERVER_OK, '', true); } diff --git a/pandora_console/operation/snmpconsole/snmp_view.php b/pandora_console/operation/snmpconsole/snmp_view.php index 95a2a6c43a..e3c6277ccc 100644 --- a/pandora_console/operation/snmpconsole/snmp_view.php +++ b/pandora_console/operation/snmpconsole/snmp_view.php @@ -116,7 +116,14 @@ if (isset ($_POST["updatebt"])) { } } -$sql = sprintf ("SELECT * FROM ttrap ORDER BY timestamp DESC LIMIT %d,%d",$offset,$pagination); +switch ($config["dbtype"]) { + case "mysql": + $sql = sprintf ("SELECT * FROM ttrap ORDER BY timestamp DESC LIMIT %d,%d",$offset,$pagination); + break; + case "postgresql": + $sql = sprintf ("SELECT * FROM ttrap ORDER BY timestamp DESC LIMIT %d OFFSET %d", $pagination, $offset); + break; +} $traps = get_db_all_rows_sql ($sql); // No traps @@ -150,7 +157,14 @@ foreach ($traps as $trap) { } //Make query to extract traps of DB. -$sql = "SELECT * FROM ttrap %s ORDER BY timestamp DESC LIMIT %d,%d"; +switch ($config["dbtype"]) { + case "mysql": + $sql = "SELECT * FROM ttrap %s ORDER BY timestamp DESC LIMIT %d,%d"; + break; + case "postgresql": + $sql = "SELECT * FROM ttrap %s ORDER BY timestamp DESC LIMIT %d OFFSET %d"; + break; +} $whereSubquery = 'WHERE 1=1'; if ($filter_agent != '') { @@ -214,8 +228,14 @@ if ($filter_severity != -1) { if ($filter_status != -1) $whereSubquery .= ' AND status = ' . $filter_status; - -$sql = sprintf($sql, $whereSubquery, $offset, $pagination); +switch ($config["dbtype"]) { + case "mysql": + $sql = sprintf($sql, $whereSubquery, $offset, $pagination); + break; + case "postgresql": + $sql = sprintf($sql, $whereSubquery, $pagination, $offset); + break; +} $traps = get_db_all_rows_sql($sql);