/** * This function calculates status of systems with profile sensor enabled * * @param object $conn DataBase access object * * @return array */ function calc_sensors_status($conn) { // Getting system list $avc_list = Av_center::get_avc_list($conn); $total = 0; $up_sensors = array(); $down_sensors = array(); // Getting DOWN systems $filters = array('level' => 'error', 'message_id' => Util::uuid_format('00000000000000000000000000010011')); $pagination = array('page' => 1, 'page_rows' => count($avc_list['data'])); $status = new System_notifications(); list($notification_list, $total_notifications) = $status->get_status_messages($filters, $pagination); if ($total_notifications > 0) { $down_systems = array(); foreach ($notification_list as $notification) { $down_systems[$notification['component_id']] = 1; } } //Calculating UP and DOWN sensors if (is_array($avc_list['data']) && !empty($avc_list['data'])) { foreach ($avc_list['data'] as $avc_data) { if (preg_match('/sensor/i', $avc_data['profile'])) { if (isset($down_systems[Util::uuid_format($avc_data['system_id'])])) { $down_sensors[$avc_data['sensor_id']] = 1; } else { $up_sensors[$avc_data['sensor_id']] = 1; } } } } $up = count($up_sensors); $down = count($down_sensors); $total = $up + $down; return array($total, $up, $down); }
* * You should have received a copy of the GNU General Public License * along with this package; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301 USA * * * On Debian GNU/Linux systems, the complete text of the GNU General * Public License can be found in `/usr/share/common-licenses/GPL-2'. * * Otherwise you can read it here: http://www.gnu.org/licenses/gpl-2.0.txt * */ require_once 'av_init.php'; $m_perms = array('environment-menu', 'environment-menu'); $sm_perms = array('PolicyHosts', 'PolicyNetworks'); Session::logcheck_ajax($m_perms, $sm_perms); $data['status'] = 'success'; $data['data'] = _('Your changes have been saved'); $message_id = POST('message_id'); if (!valid_hex32($message_id, TRUE)) { Util::response_bad_request(_('Error! Message ID not allowed. Action could not be completed')); } try { $status = new System_notifications(); $flags = array('viewed' => 'true'); $status->set_status_message($message_id, $flags); } catch (Exception $e) { Util::response_bad_request($e->getMessage()); } echo json_encode($data);
// Response array $response = array(); // Array to store data $data = array(); try { if (ossim_error()) { Av_exception::throw_error(Av_exception::USER_ERROR, ossim_get_error_clean()); } /********************** ****** FILTERS ******* **********************/ $filters = array(); if (!empty($search)) { $filters['search'] = $search; } if (!empty($only_unread)) { $filters['only_unread'] = 'true'; } /********************** ****** GET DATA ****** **********************/ $status = new System_notifications(); list($messages_stats, $stats_count) = $status->get_status_messages_stats($filters); $data = $messages_stats; } catch (Exception $e) { Util::response_bad_request($e->getMessage()); } $response['status'] = 'OK'; $response['data'] = $data; echo json_encode($response); exit;
} if (!empty($type)) { $filters['message_type'] = $type; } if (!empty($level)) { $filters['level'] = $level; } /************************ ****** Pagination ****** ************************/ $pagination = array('page' => Util::calculate_pagination_page($from, $max_rows), 'page_rows' => $max_rows); /********************** ****** API Call ****** **********************/ // Call API to get status messages $status = new System_notifications(); list($message_list, $total_messages) = $status->get_status_messages($filters, $pagination); // Wiki Parser $wiki = new Wikiparser(); // Fill data array foreach ($message_list as $message) { $res = array(); $res['DT_RowId'] = $message['id']; $res['viewed'] = $message['viewed']; $res['description'] = $wiki->parse($message['message_description']); $res['actions'] = $wiki->parse($message['message_actions']); $res['alternative_actions'] = $wiki->parse($message['message_alternative_actions']); $res[] = $message['creation_time']; $res[] = $message['message_title'] . ($message['component_ip'] ? ' (' . $message['component_ip'] . ')' : ''); $res[] = $message['message_level']; $res[] = $message['message_type'];
if (Token::verify('tk_notification_form', POST('token')) == FALSE) { $validations_errors['set_viewed'] = Token::create_error_message(); } } if (is_array($validation_errors) && !empty($validation_errors)) { //Formatted message $error_msg = '<div>' . _('The following errors occurred') . ":</div>\n <div style='padding: 5px;'>" . implode('<br/>', $validation_errors) . '</div>'; Util::response_bad_request($error_msg); } else { // Get form params $status_message_id = POST('status_message_id'); try { /********************** ****** API Call ****** **********************/ $status = new System_notifications(); switch ($action) { /************************ ****** Set viewed ****** ************************/ case 'set_viewed': $status->set_status_message($status_message_id, array('viewed' => 'true')); $data['data'] = _('Notification marked as viewed'); break; /*************************** ****** Set suppressed ***** ***************************/ /*************************** ****** Set suppressed ***** ***************************/ case 'set_suppressed':