2015-02-09 19:34:36 +01:00
|
|
|
<?php
|
|
|
|
|
2021-11-04 16:28:15 +01:00
|
|
|
// Pandora FMS - http://pandorafms.com
|
2015-02-09 19:34:36 +01:00
|
|
|
// ==================================================
|
2023-06-08 11:53:13 +02:00
|
|
|
// Copyright (c) 2005-2023 Pandora FMS
|
2023-06-08 13:10:16 +02:00
|
|
|
// Please see http://pandorafms.com/community/ for full contribution list
|
2015-02-09 19:34:36 +01:00
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation; version 2
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
/**
|
2019-01-30 16:18:44 +01:00
|
|
|
* @package Include
|
2015-02-09 19:34:36 +01:00
|
|
|
* @subpackage Post Process
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Load global vars
|
|
|
|
global $config;
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
function post_process_get_custom_values()
|
|
|
|
{
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
if (!isset($config['post_process_custom_values'])) {
|
|
|
|
$return = [];
|
|
|
|
} else {
|
|
|
|
$return = json_decode(
|
|
|
|
io_safe_output($config['post_process_custom_values']),
|
|
|
|
true
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($return)) {
|
|
|
|
$return = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $return;
|
2015-02-09 19:34:36 +01:00
|
|
|
}
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
function post_process_add_custom_value($text, $value)
|
|
|
|
{
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
$value = (string) $value;
|
|
|
|
|
|
|
|
$post_process_custom_values = post_process_get_custom_values();
|
|
|
|
|
|
|
|
$post_process_custom_values[$value] = $text;
|
|
|
|
|
|
|
|
$new_conf = json_encode($post_process_custom_values);
|
|
|
|
$return = config_update_value(
|
|
|
|
'post_process_custom_values',
|
|
|
|
$new_conf
|
|
|
|
);
|
|
|
|
|
|
|
|
if ($return) {
|
|
|
|
$config['post_process_custom_values'] = $new_conf;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2015-02-09 19:34:36 +01:00
|
|
|
}
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
function post_process_delete_custom_value($value)
|
|
|
|
{
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
$post_process_custom_values = post_process_get_custom_values();
|
|
|
|
|
|
|
|
unset($post_process_custom_values[$value]);
|
|
|
|
|
|
|
|
$new_conf = json_encode($post_process_custom_values);
|
|
|
|
$return = config_update_value(
|
|
|
|
'post_process_custom_values',
|
|
|
|
$new_conf
|
|
|
|
);
|
|
|
|
|
|
|
|
if ($return) {
|
|
|
|
$config['post_process_custom_values'] = $new_conf;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2015-02-09 19:34:36 +01:00
|
|
|
}
|