Commit version 24.12.13800
This commit is contained in:
@ -5,33 +5,37 @@
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @subpackage actions
|
||||
* @copyright (C) Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
if ($_SESSION['userlevel'] >= 8) {
|
||||
if (!$limitwrite) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_intnum($vars['form_alert_table_id']) && request_token_valid($vars)) {
|
||||
if (is_intnum($vars['form_alert_table_id'])) {
|
||||
|
||||
$alert_entry = get_alert_entry_by_id($vars['form_alert_table_id']);
|
||||
|
||||
$update_array = array();
|
||||
if ($alert_entry['ignore_until_ok'] != 1) { $update_array['ignore_until_ok'] = '1'; }
|
||||
if ($alert_entry['alert_status'] == 0) { $update_array['alert_status'] = '3'; }
|
||||
$update_array = [];
|
||||
if ($alert_entry['ignore_until_ok'] != 1) {
|
||||
$update_array['ignore_until_ok'] = '1';
|
||||
}
|
||||
if ($alert_entry['alert_status'] == 0) {
|
||||
$update_array['alert_status'] = '3';
|
||||
}
|
||||
|
||||
if (count($update_array)) {
|
||||
//r($alert_entry);
|
||||
dbUpdate($update_array, 'alert_table', 'alert_table_id = ?', array($alert_entry['alert_table_id']));
|
||||
$alert_device = device_by_id_cache($alert_entry['device_id']);
|
||||
print_message("Alert entry [{$vars['form_alert_table_id']}] for device '{$alert_device['hostname']}' suppressed.");
|
||||
//r($alert_entry);
|
||||
dbUpdate($update_array, 'alert_table', 'alert_table_id = ?', [$alert_entry['alert_table_id']]);
|
||||
$alert_device = device_by_id_cache($alert_entry['device_id']);
|
||||
print_message("Alert entry [{$vars['form_alert_table_id']}] for device '{$alert_device['hostname']}' suppressed.");
|
||||
}
|
||||
|
||||
unset($update_array);
|
||||
|
||||
// FIXME - eventlog? audit log?
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
251
html/includes/actions/contact.inc.php
Normal file
251
html/includes/actions/contact.inc.php
Normal file
@ -0,0 +1,251 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
// Secure Write Actions
|
||||
if (!$securewrite) {
|
||||
return;
|
||||
}
|
||||
switch ($vars['action']) {
|
||||
case 'contact_alert_checker_add': // new ([target]_[type]_[action])
|
||||
|
||||
if (safe_empty($vars['contact_id'])) {
|
||||
return;
|
||||
}
|
||||
if (is_numeric($vars['alert_checker_id'])) {
|
||||
$vars['alert_test_id'] = $vars['alert_checker_id'];
|
||||
} elseif (!is_numeric($vars['alert_test_id'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$rows_updated = 0;
|
||||
foreach ((array)$vars['contact_id'] as $contact_id) {
|
||||
if (!is_numeric($contact_id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$id = dbInsert('alert_contacts_assoc', [ 'aca_type' => 'alert', // $vars['type']
|
||||
'contact_id' => $contact_id,
|
||||
'alert_checker_id' => $vars['alert_test_id'] ]);
|
||||
if ($id) {
|
||||
$rows_updated++;
|
||||
}
|
||||
}
|
||||
|
||||
return $rows_updated;
|
||||
|
||||
case 'contact_alert_checker_addall':
|
||||
|
||||
if (!is_numeric($vars['alert_test_id']) || !$vars['confirm_add_all']) {
|
||||
return;
|
||||
}
|
||||
$exist_contacts = dbFetchColumn('SELECT `contact_id` FROM `alert_contacts_assoc` WHERE `aca_type` = ? AND `alert_checker_id` = ?', [ 'alert', $vars['alert_test_id'] ]);
|
||||
//print_vars($exist_contacts);
|
||||
$sql = "SELECT `contact_id` FROM `alert_contacts` WHERE `contact_disabled` = 0 AND `contact_method` != 'syscontact'" .
|
||||
generate_query_values_and($exist_contacts, 'contact_id', '!='); // exclude exist contacts
|
||||
//print_vars($sql);
|
||||
$rows_updated = 0;
|
||||
foreach (dbFetchColumn($sql) as $contact_id) {
|
||||
$id = dbInsert('alert_contacts_assoc', [ 'aca_type' => 'alert',
|
||||
'contact_id' => $contact_id,
|
||||
'alert_checker_id' => $vars['alert_test_id'] ]);
|
||||
if ($id) {
|
||||
$rows_updated++;
|
||||
}
|
||||
}
|
||||
|
||||
return $rows_updated;
|
||||
|
||||
case 'contact_alert_checker_delete':
|
||||
|
||||
if (safe_empty($vars['contact_id'])) {
|
||||
return;
|
||||
}
|
||||
if (!is_numeric($vars['alert_test_id'])) {
|
||||
return;
|
||||
}
|
||||
$rows_updated = 0;
|
||||
foreach ((array)$vars['contact_id'] as $contact_id) {
|
||||
if (!is_numeric($contact_id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rows_updated += dbDelete('alert_contacts_assoc', '`aca_type` = ? AND `contact_id` = ? AND `alert_checker_id` = ?', [ 'alert', $contact_id, $vars['alert_test_id'] ]);
|
||||
}
|
||||
|
||||
return $rows_updated;
|
||||
|
||||
case 'contact_alert_checker_deleteall':
|
||||
if (!is_numeric($vars['alert_test_id']) || !$vars['confirm_delete_all']) {
|
||||
return;
|
||||
}
|
||||
|
||||
return dbDelete('alert_contacts_assoc', '`aca_type` = ? AND `alert_checker_id` = ?', [ 'alert', $vars['alert_test_id'] ]);
|
||||
|
||||
case 'contact_syslog_rule_add':
|
||||
if (!is_numeric($vars['la_id']) || safe_empty($vars['contact_id'])) {
|
||||
return;
|
||||
}
|
||||
$rows_updated = 0;
|
||||
foreach ((array)$vars['contact_id'] as $contact_id) {
|
||||
$id = dbInsert('alert_contacts_assoc', [ 'aca_type' => 'syslog', // $vars['type']
|
||||
'contact_id' => $vars['contact_id'],
|
||||
'alert_checker_id' => $vars['la_id'] ]);
|
||||
if ($id) {
|
||||
$rows_updated++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($rows_updated) {
|
||||
set_obs_attrib('syslog_rules_changed', time()); // Trigger reload syslog script
|
||||
}
|
||||
|
||||
return $rows_updated;
|
||||
|
||||
case 'contact_syslog_rule_delete':
|
||||
if (!is_numeric($vars['la_id']) || safe_empty($vars['contact_id'])) {
|
||||
return;
|
||||
}
|
||||
$rows_updated = 0;
|
||||
foreach ((array)$vars['contact_id'] as $contact_id) {
|
||||
if (!is_numeric($contact_id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rows_updated += dbDelete('alert_contacts_assoc', '`aca_type` = ? AND `contact_id` = ? AND `alert_checker_id` = ?', [ 'syslog', $contact_id, $vars['la_id'] ]);
|
||||
}
|
||||
|
||||
if ($rows_updated) {
|
||||
set_obs_attrib('syslog_rules_changed', time()); // Trigger reload syslog script
|
||||
}
|
||||
|
||||
return $rows_updated;
|
||||
}
|
||||
|
||||
// Admin only actions
|
||||
if (!$readwrite) { // Only valid forms from level 10 users
|
||||
return;
|
||||
}
|
||||
switch ($vars['action']) {
|
||||
|
||||
case 'contact_add':
|
||||
|
||||
// Only proceed if the contact_method is valid in our transports array
|
||||
if (is_array($config['transports'][$vars['contact_method']])) {
|
||||
foreach ($config['transports'][$vars['contact_method']]['parameters'] as $section => $parameters) {
|
||||
foreach ($parameters as $parameter => $param_data) {
|
||||
if (isset($vars['contact_' . $vars['contact_method'] . '_' . $parameter])) {
|
||||
|
||||
$value = smart_quotes($vars['contact_' . $vars['contact_method'] . '_' . $parameter]);
|
||||
// Validate if passed correct JSON
|
||||
if ($param_data['format'] === 'json' && !valid_json_notification($value)) {
|
||||
// Incorrect JSON
|
||||
print_error('Contact not added. Incorrect JSON.');
|
||||
break 2;
|
||||
}
|
||||
$endpoint_data[$parameter] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($endpoint_data) {
|
||||
dbInsert('alert_contacts', ['contact_descr' => $vars['contact_descr'], 'contact_endpoint' => safe_json_encode($endpoint_data), 'contact_method' => $vars['contact_method']]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'contact_edit':
|
||||
|
||||
$update_state = [];
|
||||
$contact = get_contact_by_id($vars['contact_id']);
|
||||
|
||||
foreach (safe_json_decode($contact['contact_endpoint']) as $field => $value) {
|
||||
$contact['endpoint_parameters'][$field] = $value;
|
||||
}
|
||||
|
||||
$update_state['contact_disabled'] = get_var_true($vars['contact_enabled']) ? 0 : 1;
|
||||
|
||||
if (!safe_empty($vars['contact_descr']) && $vars['contact_descr'] != $contact['contact_descr']) {
|
||||
$update_state['contact_descr'] = $vars['contact_descr'];
|
||||
}
|
||||
|
||||
$data = $config['transports'][$contact['contact_method']];
|
||||
if (!safe_count($data['parameters']['global'])) {
|
||||
// Temporary until we separate "global" out.
|
||||
$data['parameters']['global'] = [];
|
||||
}
|
||||
if (!safe_count($data['parameters']['optional'])) {
|
||||
$data['parameters']['optional'] = [];
|
||||
}
|
||||
// Plan: add defaults for transport types to global settings, which we use by default, then be able to override the settings via this GUI
|
||||
// This needs supporting code in the transport to check for set variable and if not, use the global default
|
||||
|
||||
$update_endpoint = $contact['endpoint_parameters'];
|
||||
foreach (array_merge((array)$data['parameters']['required'],
|
||||
(array)$data['parameters']['global'],
|
||||
(array)$data['parameters']['optional']) as $parameter => $param_data) {
|
||||
if ((isset($data['parameters']['optional'][$parameter]) || // Allow optional param as empty
|
||||
is_array($vars['contact_endpoint_' . $parameter]) || strlen($vars['contact_endpoint_' . $parameter])) &&
|
||||
smart_quotes($vars['contact_endpoint_' . $parameter]) != $contact['endpoint_parameters'][$parameter]) {
|
||||
|
||||
$value = smart_quotes($vars['contact_endpoint_' . $parameter]);
|
||||
// Validate if passed correct JSON
|
||||
if ($param_data['format'] === 'json' && !valid_json_notification($value)) {
|
||||
//r($value);
|
||||
//r($param_data);
|
||||
// Incorrect JSON
|
||||
print_error('Contact not updated. Incorrect JSON.');
|
||||
break 2;
|
||||
}
|
||||
$update_endpoint[$parameter] = $value;
|
||||
}
|
||||
}
|
||||
//r($update_endpoint);
|
||||
$update_endpoint = safe_json_encode($update_endpoint);
|
||||
if ($update_endpoint != $contact['contact_endpoint']) {
|
||||
//r($update_endpoint);
|
||||
//r($contact['contact_endpoint']);
|
||||
$update_state['contact_endpoint'] = $update_endpoint;
|
||||
}
|
||||
|
||||
// custom template
|
||||
$vars['contact_message_custom'] = get_var_true($vars['contact_message_custom']);
|
||||
if ($vars['contact_message_custom'] != (bool)$contact['contact_message_custom']) {
|
||||
$update_state['contact_message_custom'] = $vars['contact_message_custom'] ? '1' : '0';
|
||||
}
|
||||
if ($vars['contact_message_custom'] && $vars['contact_message_template'] != $contact['contact_message_template']) {
|
||||
$update_state['contact_message_template'] = $vars['contact_message_template'];
|
||||
}
|
||||
//r($contact);
|
||||
//r($vars);
|
||||
|
||||
if ($rows_updated = dbUpdate($update_state, 'alert_contacts', 'contact_id = ?', [$vars['contact_id']])) {
|
||||
print_success('Contact updated.');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'contact_delete':
|
||||
if (get_var_true($vars['confirm_' . $vars['contact_id']], 'confirm')) {
|
||||
$rows_deleted = dbDelete('alert_contacts', '`contact_id` = ?', [$vars['contact_id']]);
|
||||
$rows_deleted += dbDelete('alert_contacts_assoc', '`contact_id` = ?', [$vars['contact_id']]);
|
||||
|
||||
if ($rows_deleted) {
|
||||
print_success('Deleted contact and all associations (' . $vars['contact_id'] . ')');
|
||||
}
|
||||
}
|
||||
unset($vars['contact_id']);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
unset($vars['action'], $vars['confirm'], $vars['confirm_' . $vars['contact_id']], $vars['requesttoken']);
|
||||
|
||||
// EOF
|
160
html/includes/actions/role.inc.php
Normal file
160
html/includes/actions/role.inc.php
Normal file
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage actions
|
||||
* @copyright (C) Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
if (!$readwrite) { // Only valid forms from level 10 users
|
||||
return;
|
||||
}
|
||||
|
||||
switch ($vars['action']) {
|
||||
case 'role_add':
|
||||
|
||||
if (!safe_empty($vars['role_name']) && !safe_empty($vars['role_descr'])) {
|
||||
|
||||
$oid_id = dbInsert('roles', [ 'role_descr' => $vars['role_descr'],
|
||||
'role_name' => $vars['role_name'] ]);
|
||||
|
||||
if ($oid_id) {
|
||||
print_success("<strong>SUCCESS:</strong> Added role");
|
||||
return 1;
|
||||
}
|
||||
print_warning("<strong>WARNING:</strong> Role not added");
|
||||
} else {
|
||||
print_error("<strong>ERROR:</strong> All fields must be completed to add a new role.");
|
||||
}
|
||||
return;
|
||||
|
||||
case 'role_entity_add':
|
||||
|
||||
if (isset($vars['entity_id'])) {
|
||||
// use entity_id
|
||||
} elseif (isset($vars[$vars['entity_type'] . '_entity_id'])) {
|
||||
// use type_entity_id
|
||||
$vars['entity_id'] = $vars[$vars['entity_type'] . '_entity_id'];
|
||||
}
|
||||
|
||||
if (!is_array($vars['entity_id'])) {
|
||||
$vars['entity_id'] = [$vars['entity_id']];
|
||||
}
|
||||
|
||||
$added = [];
|
||||
foreach ($vars['entity_id'] as $entity_id) {
|
||||
if (get_entity_by_id_cache($vars['entity_type'], $entity_id)) { // Skip not exist entities
|
||||
if (!dbExist('roles_entity_permissions', '`role_id` = ? AND `entity_type` = ? AND `entity_id` = ?',
|
||||
[$vars['role_id'], $vars['entity_type'], $entity_id])) {
|
||||
|
||||
if (!in_array($vars['access'], ['ro', 'rw'])) {
|
||||
$vars['access'] = 'ro';
|
||||
}
|
||||
|
||||
$added[] = dbInsert(['entity_id' => $entity_id, 'entity_type' => $vars['entity_type'], 'role_id' => $vars['role_id'], 'access' => $vars['access']],
|
||||
'roles_entity_permissions');
|
||||
}
|
||||
} else {
|
||||
print_error('Error: Invalid Entity.');
|
||||
}
|
||||
}
|
||||
|
||||
// Reset permissions cache
|
||||
if ($added) {
|
||||
set_cache_clear('wui');
|
||||
}
|
||||
|
||||
return count($added);
|
||||
|
||||
case 'role_entity_del':
|
||||
case 'role_entity_delete':
|
||||
|
||||
if (isset($vars['entity_id'])) {
|
||||
// use entity_id
|
||||
} elseif (isset($vars[$vars['entity_type'] . '_entity_id'])) {
|
||||
// use type_entity_id
|
||||
$vars['entity_id'] = $vars[$vars['entity_type'] . '_entity_id'];
|
||||
}
|
||||
|
||||
$where = '`role_id` = ? AND `entity_type` = ?' . generate_query_values_and($vars['entity_id'], 'entity_id');
|
||||
if (dbExist('roles_entity_permissions', $where, [$vars['role_id'], $vars['entity_type']])) {
|
||||
// Reset permissions cache
|
||||
set_cache_clear('wui');
|
||||
|
||||
return dbDelete('roles_entity_permissions', $where, [$vars['role_id'], $vars['entity_type']]);
|
||||
}
|
||||
|
||||
//echo ("nope"); // Hrm?
|
||||
break;
|
||||
|
||||
case 'role_permission_add':
|
||||
|
||||
$added = [];
|
||||
foreach ($vars['permission'] as $permission) {
|
||||
if (isset($config['permissions'][$permission]) &&
|
||||
!dbExist('roles_permissions', '`role_id` = ? AND `permission` = ?', [ $vars['role_id'], $permission ])) {
|
||||
$added[] = dbInsert(['permission' => $permission, 'role_id' => $vars['role_id']], 'roles_permissions');
|
||||
}
|
||||
}
|
||||
|
||||
return count($added);
|
||||
|
||||
case 'role_permission_del':
|
||||
case 'role_permission_delete':
|
||||
|
||||
$where = '`role_id` = ? AND `permission` = ?';
|
||||
if (dbExist('roles_permissions', $where, [$vars['role_id'], $vars['permission']])) {
|
||||
return dbDelete('roles_permissions', $where, [$vars['role_id'], $vars['permission']]);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'role_user_add':
|
||||
|
||||
if (!is_array($vars['role_id'])) {
|
||||
$vars['role_id'] = [$vars['role_id']];
|
||||
}
|
||||
|
||||
// We need to turn this into an array for use with the roles page, but not overwrite user_id so as not to break the users page.
|
||||
if (!is_array($vars['user_id'])) {
|
||||
$vars['user_ids'] = [$vars['user_id']];
|
||||
} else {
|
||||
$vars['user_ids'] = $vars['user_id'];
|
||||
|
||||
}
|
||||
|
||||
$user_list = auth_user_list();
|
||||
|
||||
$added = [];
|
||||
foreach ($vars['user_ids'] as $user_id) {
|
||||
if (is_array($user_list[$user_id])) {
|
||||
foreach ($vars['role_id'] as $role_id) {
|
||||
if (!dbExist('roles_users', '`role_id` = ? AND `user_id` = ? AND `auth_mechanism` = ?', [$role_id, $user_id, $config['auth_mechanism']])) {
|
||||
$added[] = dbInsert(['user_id' => $user_id, 'role_id' => $role_id, 'auth_mechanism' => $config['auth_mechanism']], 'roles_users');
|
||||
} else {
|
||||
print_warning("<strong>WARNING:</strong> User " . $user_id . " is already a role " . $role_id . " member.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print_error("<strong>ERROR:</strong> Invalid user id.");
|
||||
}
|
||||
}
|
||||
|
||||
return count($added);
|
||||
|
||||
case 'role_user_del':
|
||||
|
||||
$where = '`role_id` = ? AND `user_id` = ? AND `auth_mechanism` = ?';
|
||||
$params = [$vars['role_id'], $vars['user_id'], $config['auth_mechanism']];
|
||||
if (dbExist('roles_users', $where, $params)) {
|
||||
return dbDelete('roles_users', $where, $params);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// EOF
|
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
if ($_SESSION['userlevel'] == 10 && request_token_valid($vars)) { // Only valid forms from level 10 users
|
||||
if (!safe_empty($vars['role_name']) &&
|
||||
!safe_empty($vars['role_descr'])) {
|
||||
$oid_id = dbInsert('roles', [ 'role_descr' => $vars['role_descr'],
|
||||
'role_name' => $vars['role_name'] ]
|
||||
);
|
||||
|
||||
if ($oid_id) {
|
||||
print_success("<strong>SUCCESS:</strong> Added role");
|
||||
} else {
|
||||
print_warning("<strong>WARNING:</strong> Role not added");
|
||||
}
|
||||
} else {
|
||||
print_error("<strong>ERROR:</strong> All fields must be completed to add a new role.");
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
if ($_SESSION['userlevel'] == 10 && request_token_valid($vars)) { // Only valid forms from level 10 users
|
||||
|
||||
if (isset($vars['entity_id'])) {
|
||||
// use entity_id
|
||||
} elseif (isset($vars[$vars['entity_type'] . '_entity_id'])) {
|
||||
// use type_entity_id
|
||||
$vars['entity_id'] = $vars[$vars['entity_type'] . '_entity_id'];
|
||||
}
|
||||
|
||||
if (!is_array($vars['entity_id'])) {
|
||||
$vars['entity_id'] = [ $vars['entity_id'] ];
|
||||
}
|
||||
|
||||
$changed = 0;
|
||||
foreach ($vars['entity_id'] as $entity_id) {
|
||||
if (get_entity_by_id_cache($vars['entity_type'], $entity_id)) { // Skip not exist entities
|
||||
if (!dbExist('roles_entity_permissions', '`role_id` = ? AND `entity_type` = ? AND `entity_id` = ?',
|
||||
[ $vars['role_id'], $vars['entity_type'], $entity_id ])) {
|
||||
|
||||
if (!in_array($vars['access'], [ 'ro', 'rw' ])) {
|
||||
$vars['access'] = 'ro';
|
||||
}
|
||||
|
||||
dbInsert([ 'entity_id' => $entity_id, 'entity_type' => $vars['entity_type'], 'role_id' => $vars['role_id'], 'access' => $vars['access'] ],
|
||||
'roles_entity_permissions');
|
||||
$changed++;
|
||||
}
|
||||
} else {
|
||||
print_error('Error: Invalid Entity.');
|
||||
}
|
||||
}
|
||||
|
||||
// Reset permissions cache
|
||||
if ($changed) { set_cache_clear('wui'); }
|
||||
unset($changed);
|
||||
}
|
||||
|
||||
// EOF
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
if ($_SESSION['userlevel'] == 10 && request_token_valid($vars)) { // Only valid forms from level 10 users
|
||||
|
||||
if (isset($vars['entity_id'])) {
|
||||
// use entity_id
|
||||
} elseif (isset($vars[$vars['entity_type'] . '_entity_id'])) {
|
||||
// use type_entity_id
|
||||
$vars['entity_id'] = $vars[$vars['entity_type'] . '_entity_id'];
|
||||
}
|
||||
|
||||
$where = '`role_id` = ? AND `entity_type` = ?' . generate_query_values_and($vars['entity_id'], 'entity_id');
|
||||
//if (@dbFetchCell("SELECT COUNT(*) FROM `entity_permissions` WHERE " . $where, array($vars['user_id'], $vars['entity_type'])))
|
||||
if (dbExist('roles_entity_permissions', $where, [ $vars['role_id'], $vars['entity_type'] ])) {
|
||||
dbDelete('roles_entity_permissions', $where, array($vars['role_id'], $vars['entity_type']));
|
||||
|
||||
//print_vars(dbError());
|
||||
|
||||
// Reset permissions cache
|
||||
set_cache_clear('wui');
|
||||
}
|
||||
}
|
||||
|
||||
//echo ("nope"); // Hrm?
|
||||
|
||||
// EOF
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
if ($_SESSION['userlevel'] == 10 && request_token_valid($vars)) // Only valid forms from level 10 users
|
||||
{
|
||||
|
||||
foreach ($vars['permission'] as $permission)
|
||||
{
|
||||
if(isset($config['permissions'][$permission]))
|
||||
{
|
||||
if (!dbExist('roles_permissions', '`role_id` = ? AND `permission` = ?',
|
||||
array($vars['role_id'], $permission)
|
||||
))
|
||||
{
|
||||
dbInsert(array('permission' => $permission, 'role_id' => $vars['role_id']), 'roles_permissions');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
if ($_SESSION['userlevel'] == 10 && request_token_valid($vars)) // Only valid forms from level 10 users
|
||||
{
|
||||
|
||||
$where = '`role_id` = ? AND `permission` = ?';
|
||||
if (dbExist('roles_permissions', $where, array($vars['role_id'], $vars['permission'])))
|
||||
{
|
||||
dbDelete('roles_permissions', $where, array($vars['role_id'], $vars['permission']));
|
||||
} else { }
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
if ($_SESSION['userlevel'] == 10 && request_token_valid($vars)) // Only valid forms from level 10 users
|
||||
{
|
||||
|
||||
if (!is_array($vars['user_id'])) {
|
||||
$vars['user_ids'] = array($vars['user_id']);
|
||||
} else {
|
||||
$vars['user_ids'] = $vars['user_id'];
|
||||
}
|
||||
|
||||
if (!is_array($vars['role_id'])) {
|
||||
$vars['role_id'] = array($vars['role_id']);
|
||||
}
|
||||
|
||||
$user_list = auth_user_list();
|
||||
|
||||
|
||||
foreach ($vars['user_ids'] as $user_id) {
|
||||
if (is_array($user_list[$user_id])) {
|
||||
foreach ($vars['role_id'] as $role_id) {
|
||||
if (!dbExist('roles_users', '`role_id` = ? AND `user_id` = ? AND `auth_mechanism` = ?', [ $role_id, $user_id, $config['auth_mechanism'] ]))
|
||||
{
|
||||
dbInsert([ 'user_id' => $user_id, 'role_id' => $role_id, 'auth_mechanism' => $config['auth_mechanism'] ], 'roles_users');
|
||||
} else {
|
||||
print_warning("<strong>WARNING:</strong> User " . $user_id . " is already a role " . $role_id . " member.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print_error("<strong>ERROR:</strong> Invalid user id.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// EOF
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
if ($_SESSION['userlevel'] == 10 && request_token_valid($vars)) // Only valid forms from level 10 users
|
||||
{
|
||||
|
||||
$where = '`role_id` = ? AND `user_id` = ? AND `auth_mechanism` = ?';
|
||||
$params = [ $vars['role_id'], $vars['user_id'], $config['auth_mechanism'] ];
|
||||
if (dbExist('roles_users', $where, $params))
|
||||
{
|
||||
dbDelete('roles_users', $where, $params);
|
||||
} else { }
|
||||
}
|
||||
|
||||
// EOF
|
50
html/includes/actions/syslog.inc.php
Normal file
50
html/includes/actions/syslog.inc.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
if (!$readwrite) { // Only valid forms from level 10 users
|
||||
return;
|
||||
}
|
||||
|
||||
switch ($vars['action']) {
|
||||
|
||||
case 'syslog_rule_edit':
|
||||
$update_array = [ 'la_name' => $vars['la_name'],
|
||||
'la_descr' => $vars['la_descr'],
|
||||
'la_rule' => $vars['la_rule'],
|
||||
'la_disable' => (isset($vars['la_disable']) ? 1 : 0) ];
|
||||
$rows_updated = dbUpdate($update_array, 'syslog_rules', '`la_id` = ?', [$vars['la_id']]);
|
||||
|
||||
if ($rows_updated) {
|
||||
set_obs_attrib('syslog_rules_changed', time()); // Trigger reload syslog script
|
||||
print_message('Syslog Rule updated (' . $vars['la_id'] . ')');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'syslog_rule_delete':
|
||||
if (get_var_true($vars['confirm'], 'confirm')) {
|
||||
$rows_deleted = dbDelete('syslog_rules_assoc', '`la_id` = ?', [$vars['la_id']]);
|
||||
$rows_deleted += dbDelete('syslog_rules', '`la_id` = ?', [$vars['la_id']]);
|
||||
$rows_deleted += dbDelete('syslog_alerts', '`la_id` = ?', [$vars['la_id']]);
|
||||
$rows_deleted += dbDelete('alert_contacts_assoc', '`aca_type` = ? AND `alert_checker_id` = ?', ['syslog', $vars['la_id']]);
|
||||
|
||||
if ($rows_deleted) {
|
||||
set_obs_attrib('syslog_rules_changed', time()); // Trigger reload syslog script
|
||||
print_message('Deleted all traces of Syslog Rule (' . $vars['la_id'] . ')');
|
||||
}
|
||||
unset($vars['la_id']);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
unset($vars['action'], $vars['confirm'], $vars['requesttoken']);
|
||||
|
||||
// EOF
|
Reference in New Issue
Block a user