mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
[API ACL] Added ACL to set functions
This commit is contained in:
parent
eda5898031
commit
e3fbef309b
@ -1431,10 +1431,17 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
* @param boolean $display_front Flag to display custom field in agent's operation view
|
* @param boolean $display_front Flag to display custom field in agent's operation view
|
||||||
*/
|
*/
|
||||||
function api_set_create_custom_field($t1, $t2, $other, $returnType) {
|
function api_set_create_custom_field($t1, $t2, $other, $returnType) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!check_acl($config['id_user'], 0, "PM")) {
|
||||||
|
returnError('forbidden', $returnType);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($other['type'] == 'string') {
|
if ($other['type'] == 'string') {
|
||||||
returnError('error_parameter', 'Error in the parameters.');
|
returnError('error_parameter', 'Error in the parameters.');
|
||||||
return;
|
return;
|
||||||
@ -3097,6 +3104,8 @@ function api_set_create_synthetic_module($id, $thrash1, $other, $thrash3) {
|
|||||||
|
|
||||||
$idAgent = agents_get_agent_id(io_safe_output($agentName),true);
|
$idAgent = agents_get_agent_id(io_safe_output($agentName),true);
|
||||||
|
|
||||||
|
if (!util_api_check_agent_and_print_error($idAgent, 'string', "AW")) return;
|
||||||
|
|
||||||
if (!$idAgent) {
|
if (!$idAgent) {
|
||||||
returnError('error_create_data_module', __('Error in creation synthetic module. Agent name doesn\'t exist.'));
|
returnError('error_create_data_module', __('Error in creation synthetic module. Agent name doesn\'t exist.'));
|
||||||
return;
|
return;
|
||||||
@ -5022,14 +5031,18 @@ function api_set_add_tag_module($id, $id2, $thrash1, $thrash2) {
|
|||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id_module = $id;
|
$id_module = $id;
|
||||||
$id_tag = $id2;
|
$id_tag = $id2;
|
||||||
|
|
||||||
|
if (!util_api_check_agent_and_print_error(modules_get_agentmodule($id_module), 'string', "AW")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$exists = db_get_row_filter('ttag_module',
|
$exists = db_get_row_filter('ttag_module',
|
||||||
array('id_agente_modulo' => $id_module,
|
array('id_agente_modulo' => $id_module,
|
||||||
'id_tag' => $id_tag));
|
'id_tag' => $id_tag));
|
||||||
|
|
||||||
if (empty($exists)) {
|
if (empty($exists)) {
|
||||||
db_process_sql_insert('ttag_module',
|
db_process_sql_insert('ttag_module',
|
||||||
array('id_agente_modulo' => $id_module,
|
array('id_agente_modulo' => $id_module,
|
||||||
@ -5054,7 +5067,11 @@ function api_set_remove_tag_module($id, $id2, $thrash1, $thrash2) {
|
|||||||
|
|
||||||
$id_module = $id;
|
$id_module = $id;
|
||||||
$id_tag = $id2;
|
$id_tag = $id2;
|
||||||
|
|
||||||
|
if (!util_api_check_agent_and_print_error(modules_get_agentmodule($id_module), 'string', "AW")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$row = db_get_row_filter('ttag_module',
|
$row = db_get_row_filter('ttag_module',
|
||||||
array('id_agente_modulo' => $id_module,
|
array('id_agente_modulo' => $id_module,
|
||||||
'id_tag' => $id_tag));
|
'id_tag' => $id_tag));
|
||||||
@ -5077,10 +5094,17 @@ function api_set_remove_tag_module($id, $id2, $thrash1, $thrash2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function api_set_tag($id, $thrash1, $other, $thrash3) {
|
function api_set_tag($id, $thrash1, $other, $thrash3) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!check_acl($config['id_user'], 0, "PM")) {
|
||||||
|
returnError('forbidden', 'string');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$values = array();
|
$values = array();
|
||||||
$values['name'] = $id;
|
$values['name'] = $id;
|
||||||
$values['description'] = $other['data'][0];
|
$values['description'] = $other['data'][0];
|
||||||
@ -5091,7 +5115,7 @@ function api_set_tag($id, $thrash1, $other, $thrash3) {
|
|||||||
$id_tag = tags_create_tag($values);
|
$id_tag = tags_create_tag($values);
|
||||||
|
|
||||||
if (empty($id_tag))
|
if (empty($id_tag))
|
||||||
returnError('error_set_tag', 'Error set tag.');
|
returnError('error_set_tag', __('Error set tag.'));
|
||||||
else
|
else
|
||||||
returnData('string',
|
returnData('string',
|
||||||
array('type' => 'string', 'data' => $id_tag));
|
array('type' => 'string', 'data' => $id_tag));
|
||||||
@ -5233,9 +5257,16 @@ function api_get_planned_downtimes_items ($thrash1, $thrash2, $other, $returnTyp
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function api_set_planned_downtimes_deleted ($id, $thrash1, $thrash2, $returnType) {
|
function api_set_planned_downtimes_deleted ($id, $thrash1, $thrash2, $returnType) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!check_acl($config['id_user'], 0, "AD")) {
|
||||||
|
returnError('forbidden', $returnType);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$values = array();
|
$values = array();
|
||||||
$values = array(
|
$values = array(
|
||||||
@ -5265,12 +5296,19 @@ function api_set_planned_downtimes_deleted ($id, $thrash1, $thrash2, $returnType
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function api_set_planned_downtimes_created ($id, $thrash1, $other, $thrash3) {
|
function api_set_planned_downtimes_created ($id, $thrash1, $other, $thrash3) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$date_from = strtotime(html_entity_decode($other['data'][1]));
|
if (!check_acl($config['id_user'], 0, "AD")){
|
||||||
$date_to = strtotime(html_entity_decode($other['data'][2]));
|
returnError('forbidden', 'string');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$date_from = strtotime(html_entity_decode($other['data'][1]));
|
||||||
|
$date_to = strtotime(html_entity_decode($other['data'][2]));
|
||||||
|
|
||||||
$values = array();
|
$values = array();
|
||||||
$values['name'] = $id;
|
$values['name'] = $id;
|
||||||
@ -5330,7 +5368,7 @@ function api_set_planned_downtimes_additem ($id, $thrash1, $other, $thrash3) {
|
|||||||
$bad_agents = array();
|
$bad_agents = array();
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($total_agents as $agent_id) {
|
foreach ($total_agents as $agent_id) {
|
||||||
$result_agent = (bool) db_get_value ('id_agente', 'tagente', 'id_agente', $agent_id);
|
$result_agent = agents_check_access_agent($agent_id, "AD");
|
||||||
if ( !$result_agent ) {
|
if ( !$result_agent ) {
|
||||||
$bad_agents[] = $agent_id;
|
$bad_agents[] = $agent_id;
|
||||||
unset($agents[$i]);
|
unset($agents[$i]);
|
||||||
@ -6776,10 +6814,17 @@ function api_set_delete_group($id_group, $thrash2, $other, $thrash3) {
|
|||||||
* @param $thrash3 Don't use
|
* @param $thrash3 Don't use
|
||||||
*/
|
*/
|
||||||
function api_set_create_netflow_filter($thrash1, $thrash2, $other, $thrash3) {
|
function api_set_create_netflow_filter($thrash1, $thrash2, $other, $thrash3) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!check_acl($config['id_user'], 0, "AW")) {
|
||||||
|
returnError('forbidden', 'string');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($other['data'][0] == "") {
|
if ($other['data'][0] == "") {
|
||||||
returnError('error_create_netflow_filter', __('Error in netflow filter creation. Filter name cannot be left blank.'));
|
returnError('error_create_netflow_filter', __('Error in netflow filter creation. Filter name cannot be left blank.'));
|
||||||
return;
|
return;
|
||||||
@ -6793,7 +6838,12 @@ function api_set_create_netflow_filter($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
$group = groups_get_group_by_id($other['data'][1]);
|
$group = groups_get_group_by_id($other['data'][1]);
|
||||||
|
|
||||||
if ($group == false) {
|
if ($group == false) {
|
||||||
returnError('error_create_group', __('Error in group creation. Id_parent_group doesn\'t exist.'));
|
returnError('error_create_group', __('Error in netflow filter creation. Id_group doesn\'t exist.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!check_acl($config['id_user'], 0, "AW")) {
|
||||||
|
returnError('forbidden', 'string');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8026,7 +8076,9 @@ function api_set_gis_agent_only_position($id_agent, $trash1, $other, $return_typ
|
|||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!util_api_check_agent_and_print_error($id_agent, 'string', 'AW')) return;
|
||||||
|
|
||||||
$new_gis_data = $other['data'];
|
$new_gis_data = $other['data'];
|
||||||
|
|
||||||
$correct = true;
|
$correct = true;
|
||||||
@ -8048,6 +8100,8 @@ function api_set_gis_agent_only_position($id_agent, $trash1, $other, $return_typ
|
|||||||
|
|
||||||
if (!$config['activate_gis']) {
|
if (!$config['activate_gis']) {
|
||||||
$correct = false;
|
$correct = false;
|
||||||
|
returnError('error_gis_agent_only_position', __('Gis not activated'));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($correct) {
|
if ($correct) {
|
||||||
@ -8056,6 +8110,9 @@ function api_set_gis_agent_only_position($id_agent, $trash1, $other, $return_typ
|
|||||||
1, __('Save by %s Console', get_product_name()),
|
1, __('Save by %s Console', get_product_name()),
|
||||||
__('Update by %s Console', get_product_name()),
|
__('Update by %s Console', get_product_name()),
|
||||||
__('Insert by %s Console', get_product_name()));
|
__('Insert by %s Console', get_product_name()));
|
||||||
|
} else {
|
||||||
|
returnError('error_gis_agent_only_position', __('Missing parameters'));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8071,7 +8128,9 @@ function api_set_gis_agent($id_agent, $trash1, $other, $return_type, $user_in_db
|
|||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!util_api_check_agent_and_print_error($id_agent, 'string', 'AW')) return;
|
||||||
|
|
||||||
$new_gis_data = $other['data'];
|
$new_gis_data = $other['data'];
|
||||||
|
|
||||||
$correct = true;
|
$correct = true;
|
||||||
@ -8133,6 +8192,8 @@ function api_set_gis_agent($id_agent, $trash1, $other, $return_type, $user_in_db
|
|||||||
|
|
||||||
if (!$config['activate_gis']) {
|
if (!$config['activate_gis']) {
|
||||||
$correct = false;
|
$correct = false;
|
||||||
|
returnError('error_gis_agent_only_position', __('Gis not activated'));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($correct) {
|
if ($correct) {
|
||||||
@ -8141,6 +8202,9 @@ function api_set_gis_agent($id_agent, $trash1, $other, $return_type, $user_in_db
|
|||||||
$manual_placement, $start_timestamp, $end_timestamp,
|
$manual_placement, $start_timestamp, $end_timestamp,
|
||||||
$number_of_packages, $description_save_history,
|
$number_of_packages, $description_save_history,
|
||||||
$description_update_gis, $description_first_insert);
|
$description_update_gis, $description_first_insert);
|
||||||
|
} else {
|
||||||
|
returnError('error_set_ig_agent', __('Missing parameters'));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9473,11 +9537,17 @@ function api_get_event_info($id_event, $trash1, $trash, $returnType) {
|
|||||||
|
|
||||||
//http://127.0.0.1/pandora_console/include/api.php?op=set&op2=create_tag&other=tag_name|tag_description|tag_url|tag_email&other_mode=url_encode_separator_|&apipass=1234&user=admin&pass=pandora
|
//http://127.0.0.1/pandora_console/include/api.php?op=set&op2=create_tag&other=tag_name|tag_description|tag_url|tag_email&other_mode=url_encode_separator_|&apipass=1234&user=admin&pass=pandora
|
||||||
function api_set_create_tag ($id, $trash1, $other, $returnType) {
|
function api_set_create_tag ($id, $trash1, $other, $returnType) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!check_acl($config['id_user'], 0, "PM")){
|
||||||
|
returnError('forbidden', 'string');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
if ($other['type'] == 'string') {
|
if ($other['type'] == 'string') {
|
||||||
@ -10012,7 +10082,10 @@ function api_set_enable_disable_agent ($id, $thrash2, $other, $thrash3) {
|
|||||||
__('Error enable/disable agent. Id_agent cannot be left blank.'));
|
__('Error enable/disable agent. Id_agent cannot be left blank.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!util_api_check_agent_and_print_error($id, 'string', "AD")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($other['data'][0] != "0" and $other['data'][0] != "1") {
|
if ($other['data'][0] != "0" and $other['data'][0] != "1") {
|
||||||
returnError('error_enable_disable_agent',
|
returnError('error_enable_disable_agent',
|
||||||
@ -10064,11 +10137,16 @@ function api_set_enable_disable_agent ($id, $thrash2, $other, $thrash3) {
|
|||||||
|
|
||||||
function api_set_pagerduty_webhook($type, $matchup_path, $tresh2, $return_type) {
|
function api_set_pagerduty_webhook($type, $matchup_path, $tresh2, $return_type) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!check_acl($config['id_user'], 0, "PM")) {
|
||||||
|
returnError('forbidden', 'string');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$pagerduty_data = json_decode(file_get_contents('php://input'), true);
|
$pagerduty_data = json_decode(file_get_contents('php://input'), true);
|
||||||
|
|
||||||
foreach($pagerduty_data['messages'] as $pm) {
|
foreach($pagerduty_data['messages'] as $pm) {
|
||||||
@ -10169,11 +10247,16 @@ function api_get_special_days($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
*/
|
*/
|
||||||
function api_set_create_special_day($thrash1, $thrash2, $other, $thrash3) {
|
function api_set_create_special_day($thrash1, $thrash2, $other, $thrash3) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!check_acl($config['id_user'], 0, "LM")) {
|
||||||
|
returnError('forbidden', 'string');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$special_day = $other['data'][0];
|
$special_day = $other['data'][0];
|
||||||
$same_day = $other['data'][1];
|
$same_day = $other['data'][1];
|
||||||
$description = $other['data'][2];
|
$description = $other['data'][2];
|
||||||
@ -10223,7 +10306,8 @@ function api_set_create_special_day($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
* &other=test1%7CDescripcion de prueba%7C12%7C1%7C0.5%7C1&other_mode=url_encode_separator_%7C&apipass=1234&user=admin&pass=pandora
|
* &other=test1%7CDescripcion de prueba%7C12%7C1%7C0.5%7C1&other_mode=url_encode_separator_%7C&apipass=1234&user=admin&pass=pandora
|
||||||
*/
|
*/
|
||||||
function api_set_create_service($thrash1, $thrash2, $other, $thrash3) {
|
function api_set_create_service($thrash1, $thrash2, $other, $thrash3) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
$name = $other['data'][0];
|
$name = $other['data'][0];
|
||||||
$description = $other['data'][1];
|
$description = $other['data'][1];
|
||||||
$id_group = $other['data'][2];
|
$id_group = $other['data'][2];
|
||||||
@ -10246,6 +10330,10 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
// By default applications
|
// By default applications
|
||||||
$id_group = 12;
|
$id_group = 12;
|
||||||
}
|
}
|
||||||
|
if (!check_acl($config['id_user'], $id_group, "AR")) {
|
||||||
|
returnError('forbidden', 'string');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(empty($critical)){
|
if(empty($critical)){
|
||||||
$critical = 1;
|
$critical = 1;
|
||||||
}
|
}
|
||||||
@ -10255,6 +10343,10 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
if(empty($id_agent)){
|
if(empty($id_agent)){
|
||||||
returnError('error_create_service', __('Error in creation service. No agent id'));
|
returnError('error_create_service', __('Error in creation service. No agent id'));
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
if (!util_api_check_agent_and_print_error($id_agent, 'string', "AR")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(empty($sla_interval)){
|
if(empty($sla_interval)){
|
||||||
// By default one month
|
// By default one month
|
||||||
@ -10303,16 +10395,22 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function api_set_update_service($thrash1, $thrash2, $other, $thrash3) {
|
function api_set_update_service($thrash1, $thrash2, $other, $thrash3) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
$id_service = $thrash1;
|
$id_service = $thrash1;
|
||||||
if(empty($id_service)){
|
if(empty($id_service)){
|
||||||
returnError('error_update_service', __('Error in update service. No service id'));
|
returnError('error_update_service', __('Error in update service. No service id'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$service = db_get_row('tservice',
|
$service = db_get_row('tservice',
|
||||||
'id', $id_service);
|
'id', $id_service);
|
||||||
|
|
||||||
|
if (!check_acl($config['id_user'],$service['id_group'], "AD")) {
|
||||||
|
returnError('forbidden', 'string');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$name = $other['data'][0];
|
$name = $other['data'][0];
|
||||||
if(empty($name)){
|
if(empty($name)){
|
||||||
$name = $service['name'];
|
$name = $service['name'];
|
||||||
@ -10324,6 +10422,11 @@ function api_set_update_service($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
$id_group = $other['data'][2];
|
$id_group = $other['data'][2];
|
||||||
if(empty($id_group)){
|
if(empty($id_group)){
|
||||||
$id_group = $service['id_group'];
|
$id_group = $service['id_group'];
|
||||||
|
} else {
|
||||||
|
if (!check_acl($config['id_user'], $id_group, "AD")) {
|
||||||
|
returnError('forbidden', 'string');
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$critical = $other['data'][3];
|
$critical = $other['data'][3];
|
||||||
if(empty($critical)){
|
if(empty($critical)){
|
||||||
@ -10339,6 +10442,10 @@ function api_set_update_service($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
$id_agent = $other['data'][5];
|
$id_agent = $other['data'][5];
|
||||||
if(empty($id_agent)){
|
if(empty($id_agent)){
|
||||||
$id_agent = $service['id_agent_module'];
|
$id_agent = $service['id_agent_module'];
|
||||||
|
} else {
|
||||||
|
if (!util_api_check_agent_and_print_error($id_agent, 'string', "AR")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$sla_interval = $other['data'][6];
|
$sla_interval = $other['data'][6];
|
||||||
if(empty($sla_interval)){
|
if(empty($sla_interval)){
|
||||||
@ -10396,14 +10503,22 @@ function api_set_update_service($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) {
|
function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
$id = $thrash1;
|
$id = $thrash1;
|
||||||
|
|
||||||
if(empty($id)){
|
if(empty($id)){
|
||||||
returnError('error_add_service_element', __('Error adding elements to service. No service id'));
|
returnError('error_add_service_element', __('Error adding elements to service. No service id'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$service_group = db_get_value('id_group', 'tservice', 'id', $id);
|
||||||
|
|
||||||
|
if (!check_acl($config['id_user'], $service_group, "AD")) {
|
||||||
|
returnError('forbidden', 'string');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$array_json = json_decode(base64_decode(io_safe_output($other['data'][0])), true);
|
$array_json = json_decode(base64_decode(io_safe_output($other['data'][0])), true);
|
||||||
if(!empty($array_json)){
|
if(!empty($array_json)){
|
||||||
$results = false;
|
$results = false;
|
||||||
@ -10416,18 +10531,30 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
$id_agente_modulo = 0;
|
$id_agente_modulo = 0;
|
||||||
$id_service_child = 0;
|
$id_service_child = 0;
|
||||||
$agent_id = $element['id'];
|
$agent_id = $element['id'];
|
||||||
|
if (!agents_check_access_agent($agent_id, "AR")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'module':
|
case 'module':
|
||||||
$agent_id = 0;
|
$agent_id = 0;
|
||||||
$id_service_child = 0;
|
$id_service_child = 0;
|
||||||
$id_agente_modulo = $element['id'];
|
$id_agente_modulo = $element['id'];
|
||||||
|
if (!agents_check_access_agent(modules_get_agentmodule($id_agente_modulo), "AR")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'service':
|
case 'service':
|
||||||
$agent_id = 0;
|
$agent_id = 0;
|
||||||
$id_agente_modulo = 0;
|
$id_agente_modulo = 0;
|
||||||
$id_service_child = $element['id'];
|
$id_service_child = $element['id'];
|
||||||
|
$service_group = db_get_value(
|
||||||
|
'id_group', 'tservice', 'id', $id_service_child
|
||||||
|
);
|
||||||
|
if ($service_group === false || !check_acl($config['id_user'], $service_group, "AD")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10472,11 +10599,16 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
*/
|
*/
|
||||||
function api_set_update_special_day($id_special_day, $thrash2, $other, $thrash3) {
|
function api_set_update_special_day($id_special_day, $thrash2, $other, $thrash3) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!check_acl($config['id_user'], 0, "LM")) {
|
||||||
|
returnError('forbidden', 'string');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$special_day = $other['data'][0];
|
$special_day = $other['data'][0];
|
||||||
$same_day = $other['data'][1];
|
$same_day = $other['data'][1];
|
||||||
$description = $other['data'][2];
|
$description = $other['data'][2];
|
||||||
@ -10524,10 +10656,17 @@ function api_set_update_special_day($id_special_day, $thrash2, $other, $thrash3)
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function api_set_delete_special_day($id_special_day, $thrash2, $thrash3, $thrash4) {
|
function api_set_delete_special_day($id_special_day, $thrash2, $thrash3, $thrash4) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!check_acl($config['id_user'], 0, "LM")) {
|
||||||
|
returnError('forbidden', 'string');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($id_special_day == "") {
|
if ($id_special_day == "") {
|
||||||
returnError('error_update_special_day', __('Error deleting special day. Id cannot be left blank.'));
|
returnError('error_update_special_day', __('Error deleting special day. Id cannot be left blank.'));
|
||||||
return;
|
return;
|
||||||
@ -10714,39 +10853,39 @@ function api_set_new_cluster($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
$cluster_type = $other['data'][1];
|
$cluster_type = $other['data'][1];
|
||||||
$description = $other['data'][2];
|
$description = $other['data'][2];
|
||||||
$idGroup = $other['data'][3];
|
$idGroup = $other['data'][3];
|
||||||
|
|
||||||
|
if(!check_acl($config['id_user'], $idGroup, "AW")) {
|
||||||
|
returnError('forbidden', 'string');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$server_name = db_process_sql('select name from tserver where server_type=5 limit 1');
|
$server_name = db_process_sql('select name from tserver where server_type=5 limit 1');
|
||||||
|
|
||||||
$server_name_agent = $server_name[0]['name'];
|
$server_name_agent = $server_name[0]['name'];
|
||||||
|
|
||||||
$values_agent = array(
|
$values_agent = array(
|
||||||
'nombre' => $name,
|
'nombre' => $name,
|
||||||
'alias' => $name,
|
'alias' => $name,
|
||||||
'comentarios' => $description,
|
'comentarios' => $description,
|
||||||
'id_grupo' => $idGroup,
|
'id_grupo' => $idGroup,
|
||||||
'id_os' => 100,
|
'id_os' => 100,
|
||||||
'server_name' => $server_name_agent
|
'server_name' => $server_name_agent
|
||||||
);
|
);
|
||||||
|
|
||||||
if (trim($name) != "") {
|
if (trim($name) != "") {
|
||||||
|
|
||||||
// $id_agent = db_process_sql_insert('tagente',$values_agent);
|
|
||||||
|
|
||||||
$id_agent = agents_create_agent($values_agent['nombre'],$values_agent['id_grupo'],300,'127.0.0.1',$values_agent);
|
$id_agent = agents_create_agent($values_agent['nombre'],$values_agent['id_grupo'],300,'127.0.0.1',$values_agent);
|
||||||
|
|
||||||
// Create cluster
|
// Create cluster
|
||||||
$values_cluster = array(
|
$values_cluster = array(
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'cluster_type' => $cluster_type,
|
'cluster_type' => $cluster_type,
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
'group' => $idGroup,
|
'group' => $idGroup,
|
||||||
'id_agent' => $id_agent
|
'id_agent' => $id_agent
|
||||||
);
|
);
|
||||||
|
|
||||||
$id_cluster = db_process_sql_insert('tcluster', $values_cluster);
|
$id_cluster = db_process_sql_insert('tcluster', $values_cluster);
|
||||||
|
|
||||||
|
|
||||||
$values_module = array(
|
$values_module = array(
|
||||||
'nombre' => 'Cluster status',
|
'nombre' => 'Cluster status',
|
||||||
'id_modulo' => 5,
|
'id_modulo' => 5,
|
||||||
@ -10761,33 +10900,37 @@ function api_set_new_cluster($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
|
|
||||||
$id_module = modules_create_agent_module($values_module['id_agente'],$values_module['nombre'],$values_module);
|
$id_module = modules_create_agent_module($values_module['id_agente'],$values_module['nombre'],$values_module);
|
||||||
|
|
||||||
|
|
||||||
if ($id_cluster !== false)
|
if ($id_cluster !== false)
|
||||||
db_pandora_audit("Report management", "Create cluster #$id_cluster");
|
db_pandora_audit("Report management", "Create cluster #$id_cluster");
|
||||||
else
|
else
|
||||||
db_pandora_audit("Report management", "Fail try to create cluster");
|
db_pandora_audit("Report management", "Fail try to create cluster");
|
||||||
|
|
||||||
if ($id_agent !== false)
|
if ($id_agent !== false)
|
||||||
db_pandora_audit("Report management", "Create cluster #$id_agent");
|
db_pandora_audit("Report management", "Create cluster #$id_agent");
|
||||||
else
|
else
|
||||||
db_pandora_audit("Report management", "Fail try to create agent");
|
db_pandora_audit("Report management", "Fail try to create agent");
|
||||||
|
|
||||||
returnData('string',
|
returnData('string',
|
||||||
array('type' => 'string', 'data' => (int)$id_cluster));
|
array('type' => 'string', 'data' => (int)$id_cluster));
|
||||||
}
|
} else {
|
||||||
|
returnError('error_set_new_cluster', __('Agent name cannot be empty.'));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function api_set_add_cluster_agent($thrash1, $thrash2, $other, $thrash3) {
|
function api_set_add_cluster_agent($thrash1, $thrash2, $other, $thrash3) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
$array_json = json_decode(base64_decode(io_safe_output($other['data'][0])), true);
|
$array_json = json_decode(base64_decode(io_safe_output($other['data'][0])), true);
|
||||||
|
|
||||||
if(!empty($array_json)){
|
if(!empty($array_json)){
|
||||||
$results = false;
|
$results = false;
|
||||||
|
|
||||||
foreach ($array_json as $key => $element) {
|
foreach ($array_json as $key => $element) {
|
||||||
|
$check_cluster_group = clusters_get_group ($element['id']);
|
||||||
if($element['id'] == 0){
|
if(!$check_cluster_group ||
|
||||||
|
!check_acl($config['id_user'], $check_cluster_group, "AW") ||
|
||||||
|
!agents_check_access_agent($element['id_agent'], "AW")
|
||||||
|
){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10819,9 +10962,11 @@ function api_set_new_cluster($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
|
|
||||||
//
|
//
|
||||||
foreach ($array_json as $key => $element) {
|
foreach ($array_json as $key => $element) {
|
||||||
//
|
$cluster_group = clusters_get_group ($element['id']);
|
||||||
|
if(!$cluster_group || !check_acl($config['id_user'], $cluster_group, "AW")){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if($element["type"] == "AA"){
|
if($element["type"] == "AA"){
|
||||||
//
|
|
||||||
$tcluster_module = db_process_sql_insert('tcluster_item',array('name'=>io_safe_input($element["name"]),'id_cluster'=>$element["id_cluster"],'critical_limit'=>$element["critical_limit"],'warning_limit'=>$element["warning_limit"]));
|
$tcluster_module = db_process_sql_insert('tcluster_item',array('name'=>io_safe_input($element["name"]),'id_cluster'=>$element["id_cluster"],'critical_limit'=>$element["critical_limit"],'warning_limit'=>$element["warning_limit"]));
|
||||||
|
|
||||||
$id_agent = db_process_sql('select id_agent from tcluster where id = '.$element["id_cluster"]);
|
$id_agent = db_process_sql('select id_agent from tcluster where id = '.$element["id_cluster"]);
|
||||||
@ -10956,13 +11101,18 @@ function api_set_new_cluster($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
|
|
||||||
|
|
||||||
function api_set_delete_cluster($id, $thrash1, $thrast2, $thrash3) {
|
function api_set_delete_cluster($id, $thrash1, $thrast2, $thrash3) {
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$cluster_group = clusters_get_group($id);
|
||||||
|
if(!$cluster_group || !check_acl($config['id_user'], $cluster_group, "AD")){
|
||||||
|
returnError('error_set_delete_cluster', __('The user cannot access to the cluster'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$temp_id_cluster = db_process_sql('select id_agent from tcluster where id ='.$id);
|
$temp_id_cluster = db_process_sql('select id_agent from tcluster where id ='.$id);
|
||||||
|
|
||||||
$tcluster_modules_delete_get = db_process_sql('select id_agente_modulo from tagente_modulo where custom_integer_1 = '.$id);
|
$tcluster_modules_delete_get = db_process_sql('select id_agente_modulo from tagente_modulo where custom_integer_1 = '.$id);
|
||||||
@ -10990,7 +11140,6 @@ function api_set_new_cluster($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
|
|
||||||
|
|
||||||
function api_set_delete_cluster_agent($thrash1, $thrast2, $other, $thrash3) {
|
function api_set_delete_cluster_agent($thrash1, $thrast2, $other, $thrash3) {
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
@ -10999,6 +11148,14 @@ function api_set_new_cluster($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
|
|
||||||
$id_agent = $other['data'][0];
|
$id_agent = $other['data'][0];
|
||||||
$id_cluster = $other['data'][1];
|
$id_cluster = $other['data'][1];
|
||||||
|
|
||||||
|
$cluster_group = clusters_get_group($id_agent);
|
||||||
|
if(!$cluster_group
|
||||||
|
|| !check_acl($config['id_user'], $cluster_group, "AW")
|
||||||
|
|| !agents_check_access_agent($id_agent, "AW")){
|
||||||
|
returnError('error_set_delete_cluster_agent', __('The user cannot access to the cluster'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$tcluster_agent_delete = db_process_sql('delete from tcluster_agent where id_agent = '.$id_agent.' and id_cluster = '.$id_cluster);
|
$tcluster_agent_delete = db_process_sql('delete from tcluster_agent where id_agent = '.$id_agent.' and id_cluster = '.$id_cluster);
|
||||||
|
|
||||||
@ -11012,13 +11169,18 @@ function api_set_new_cluster($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
|
|
||||||
|
|
||||||
function api_set_delete_cluster_item($id, $thrash1, $thrast2, $thrast3) {
|
function api_set_delete_cluster_item($id, $thrash1, $thrast2, $thrast3) {
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$cluster_group = clusters_get_group($id);
|
||||||
|
if(!$cluster_group || !check_acl($config['id_user'], $cluster_group, "AD")){
|
||||||
|
returnError('error_set_delete_cluster_item', __('The user cannot access to the cluster'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$delete_module_aa_get = db_process_sql('select id_agente_modulo from tagente_modulo where custom_integer_2 = '.$id);
|
$delete_module_aa_get = db_process_sql('select id_agente_modulo from tagente_modulo where custom_integer_2 = '.$id);
|
||||||
|
|
||||||
$delete_module_aa_get_result = modules_delete_agent_module($delete_module_aa_get[0]['id_agente_modulo']);
|
$delete_module_aa_get_result = modules_delete_agent_module($delete_module_aa_get[0]['id_agente_modulo']);
|
||||||
@ -11174,10 +11336,18 @@ function api_set_apply_module_template($id_template, $id_agent, $thrash3, $thras
|
|||||||
}
|
}
|
||||||
|
|
||||||
function api_get_cluster_status($id_cluster, $trash1, $trash2, $returnType) {
|
function api_get_cluster_status($id_cluster, $trash1, $trash2, $returnType) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$cluster_group = clusters_get_group($id_cluster);
|
||||||
|
if(!$cluster_group || !check_acl($config['id_user'], $cluster_group, "AR")){
|
||||||
|
returnError('error_get_cluster_status', __('The user cannot access to the cluster'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "select estado from tagente_estado INNER JOIN tagente_modulo ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo and tagente_modulo.nombre = 'Cluster status' and tagente_modulo.id_agente = (select id_agent from tcluster where id = ".$id_cluster.")";
|
$sql = "select estado from tagente_estado INNER JOIN tagente_modulo ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo and tagente_modulo.nombre = 'Cluster status' and tagente_modulo.id_agente = (select id_agent from tcluster where id = ".$id_cluster.")";
|
||||||
|
|
||||||
$value = db_get_value_sql($sql);
|
$value = db_get_value_sql($sql);
|
||||||
@ -11192,6 +11362,8 @@ function api_get_cluster_status($id_cluster, $trash1, $trash2, $returnType) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function api_get_cluster_id_by_name($cluster_name, $trash1, $trash2, $returnType) {
|
function api_get_cluster_id_by_name($cluster_name, $trash1, $trash2, $returnType) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -11203,7 +11375,13 @@ function api_get_cluster_id_by_name($cluster_name, $trash1, $trash2, $returnType
|
|||||||
if ($value === false) {
|
if ($value === false) {
|
||||||
returnError('id_not_found', $returnType);
|
returnError('id_not_found', $returnType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$cluster_group = clusters_get_group($id_cluster);
|
||||||
|
if(!$cluster_group || !check_acl($config['id_user'], $cluster_group, "AR")){
|
||||||
|
returnError('error_get_cluster_status', __('The user cannot access to the cluster'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$data = array('type' => 'string', 'data' => $value);
|
$data = array('type' => 'string', 'data' => $value);
|
||||||
|
|
||||||
returnData($returnType, $data);
|
returnData($returnType, $data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user