示例#1
0
    //Database connection
    $db = new ossim_db();
    $conn = $db->connect();
    //Validating Sensors
    if (is_array($sensors) && !empty($sensors)) {
        foreach ($sensors as $sensor) {
            if (!Av_sensor::is_allowed($conn, $sensor)) {
                $validation_errors['sboxs[]'] = _('Error! Net could not be saved because there are unallowed sensors');
            }
        }
    } else {
        $validation_errors['sboxs[]'] = _("Error in the 'Sensors' field (missing required field)");
    }
    if (!empty($group_name)) {
        //Checking group name
        $_hostgroups = Asset_group::get_id_by_name($conn, $group_name);
        if (is_array($_hostgroups) && !empty($_hostgroups)) {
            $validation_errors['group_name'] = _('Error! The group name already exists');
        }
    }
    $db->close();
}
$data['status'] = 'OK';
$data['data'] = $validation_errors;
if (POST('ajax_validation_all') == TRUE) {
    if (is_array($validation_errors) && !empty($validation_errors)) {
        $data['status'] = 'error';
        echo json_encode($data);
    } else {
        echo json_encode($data);
    }