} } if (is_array($validation_errors) && !empty($validation_errors)) { $data['status'] = 'error'; if (POST('ajax_validation_all') == TRUE) { $data['data'] = $validation_errors; } else { $data['data'] = '<div>' . _('We Found the following errors') . ":</div>\n <div style='padding: 10px;'>" . implode('<br/>', $validation_errors) . '</div>'; } } else { if (POST('ajax_validation_all') == TRUE) { $data['status'] = 'OK'; $data['data'] = _('Automatic deployment data checked successfully'); } else { $d_data = array('ossec_server_ip' => $ossec_server_ip, 'sensor_ip' => POST('sensor_ip'), 'agent_ip' => POST('agent_ip')); if ($os_type == 'windows') { $d_data['domain'] = POST('domain'); $d_data['user'] = POST('user'); $d_data['password'] = POST('pass'); } try { $data['status'] = 'success'; $data['data'] = Ossec_agent::execute_deployment_action($d_data, 'deploy', $os_type); } catch (Exception $e) { $data['status'] = 'warning'; $data['data'] = $e->getMessage(); } } } echo json_encode($data); exit;
$conn = $db->connect(); $res = Av_center::get_system_info_by_ip($conn, $d_data['sensor_ip']); if ($res['status'] == 'success') { $sensor_id = $res['data']['sensor_id']; if (!Ossec_utilities::is_sensor_allowed($conn, $sensor_id)) { $data['status'] = 'error'; $data['data'] = _('Error! Sensor not allowed'); } } else { $data['status'] = 'error'; $data['data'] = _('Error! Unable to validate sensor IP'); } if ($data['status'] == 'error') { $db->close(); echo json_encode($data); exit; } $db->close(); try { if ($order == 'status') { $data = Ossec_agent::check_deployment_status($d_data, $os_type); } else { $data = Ossec_agent::execute_deployment_action($d_data, $order, $os_type); } } catch (Exception $e) { $data['status'] = 'warning'; $data['data'] = $e->getMessage(); } echo json_encode($data); exit; }