'; //' Fixes certain highlighters freaking out on the PHP closing tag $rss_feed .= ''; $rss_feed .= 'Pandora RSS FeedLatest events on Pandora'; $rss_feed .= ''.date (DATE_RFC822, 0).''; $rss_feed .= ''.$url.''; //Link back to the main Pandora page $rss_feed .= ''; //Alternative for Atom feeds. It's the same. $rss_feed .= ''.$url.'/index.php?sec=eventos&sec2=operation/events/eventsError creating feed'; $rss_feed .= 'There was an error creating the feed: '.$errno.' - '.$errstr.' in '.$errfile.' on line '.$errline.''; $rss_feed .= ''.$url.'/index.php?sec=eventos&sec2=operation/events/events'; exit ($rss_feed); //Exit by displaying the feed } set_error_handler ('rss_error_handler', E_ALL); //Errors output as RSS $ev_group = get_parameter ("ev_group", 0); // group $search = get_parameter ("search", ""); // free search $event_type = get_parameter ("event_type", ''); // 0 all $severity = (int) get_parameter ("severity", -1); // -1 all $status = (int) get_parameter ("status", 0); // -1 all, 0 only red, 1 only green $id_agent = (int) get_parameter ("id_agent", -1); $id_event = (int) get_parameter ("id_event", -1); //This will allow to select only 1 event (eg. RSS) $event_view_hr = (int) get_parameter ("event_view_hr", 0); $sql_post = ""; if ($event_view_hr > 0) { $unixtime = (int) (get_system_time () - ($event_view_hr * 3600)); //Put hours in seconds $sql_post .= " AND `tevento`.`utimestamp` > ".$unixtime; } if ($ev_group > 1) $sql_post .= " AND `tevento`.`id_grupo` = $ev_group"; switch($status) { case 0: case 1: case 2: $sql_post .= " AND `tevento`.`estado` = ".$status; break; case 3: $sql_post .= " AND (`tevento`.`estado` = 0 OR `tevento`.`estado` = 2)"; break; } if ($search != "") $sql_post .= " AND `tevento`.`evento` LIKE '%$search%'"; if ($event_type != ""){ // If normal, warning, could be several (going_up_warning, going_down_warning... too complex // for the user so for him is presented only "warning, critical and normal" if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal"){ $sql_post .= " AND `tevento`.`event_type` LIKE '%$event_type%' "; } elseif ($event_type == "not_normal"){ $sql_post .= " AND `tevento`.`event_type` LIKE '%warning%' OR `tevento`.`event_type` LIKE '%critical%' OR `tevento`.`event_type` LIKE '%unknown%' "; } else $sql_post .= " AND `tevento`.`event_type` = '".$event_type."'"; } if ($severity != -1) $sql_post .= " AND `tevento`.`criticity` >= ".$severity; if ($id_agent == -2) { $text_agent = (string) get_parameter("text_agent", __("All")); switch ($text_agent) { case __('All'): $id_agent = -1; break; case __('Server'): $id_agent = 0; break; default: $id_agent = get_agent_id($text_agent); break; } } else { switch ($id_agent) { case -1: $text_agent = __('All'); break; case 0: $text_agent = __('Server'); break; default: $text_agent = get_agent_name($id_agent); break; } } if ($id_agent != -1) $sql_post .= " AND `tevento`.`id_agente` = ".$id_agent; if ($id_event != -1) $sql_post .= " AND id_evento = ".$id_event; // 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"; $result= get_db_all_rows_sql ($sql); $base = 'http'.(isset ($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == TRUE ? 's': '').'://'.$_SERVER['HTTP_HOST']; $url = $base.$config["homeurl"]; $selfurl = $base.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']; if (empty ($result)) { $lastbuild = 0; //Last build in 1970 } else { $lastbuild = (int) $result[0]['unix_timestamp']; } $rss_feed = ''; // ' '; $rss_feed .= 'Pandora RSS FeedLatest events on Pandora'; $rss_feed .= ''.date (DATE_RFC822, $lastbuild).''; //Last build date is the last event - that way readers won't mark it as having new posts $rss_feed .= ''.$url.''; //Link back to the main Pandora page $rss_feed .= ''; //Alternative for Atom feeds. It's the same. if (empty ($result)) { $result = array(); $rss_feed .= ''.safe_input ($url.'/index.php?sec=eventos&sec2=operation/events/events').'No results'; $rss_feed .= 'There are no results. Click on the link to see all Pending events'; $rss_feed .= ''.safe_input ($url.'/index.php?sec=eventos&sec2=operation/events/events').''; } foreach ($result as $row) { if (!check_acl($user, $row["id_group"], "AR")) { continue; } if ($row["event_type"] == "system") { $agent_name = __('System'); } elseif ($row["id_agent"] > 0) { // Agent name $agent_name = get_agent_name ($row["id_agent"]); } else { $agent_name = __('Alert').__('SNMP'); } //This is mandatory $rss_feed .= ''; $rss_feed .= safe_input ($url . "/index.php?sec=eventos&sec2=operation/events/events&id_event=" . $row['event_id']); $rss_feed .= ''; $rss_feed .= $agent_name; $rss_feed .= ''; $rss_feed .= safe_input ($row['event_descr']); if($row['validated'] == 1) { $rss_feed .= safe_input ('

').'Validated by ' . safe_input ($row['validated_by']); } $rss_feed .= '
'; $rss_feed .= safe_input ($url . "/index.php?sec=eventos&sec2=operation/events/events&id_event=" . $row["event_id"]); $rss_feed .= ''; //The rest is optional $rss_feed .= '' . date(DATE_RFC822, $row['unix_timestamp']) . ''; //This is mandatory again $rss_feed .= '
'; } $rss_feed .= "
"; echo $rss_feed; ?>