repo
stringlengths
7
63
file_url
stringlengths
81
284
file_path
stringlengths
5
200
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:02:33
2026-01-05 05:24:06
truncated
bool
2 classes
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/class/centreon-knowledge/procedures.class.php
centreon/www/class/centreon-knowledge/procedures.class.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ define('PROCEDURE_SIMPLE_MODE', 0); define('PROCEDURE_INHERITANCE_MODE', 1); require_once _CENTREON_PATH_ . '/www/class/centreon-knowledge/wikiApi.class.php'; /** * Class * * @class procedures */ class procedures { /** @var CentreonDB */ public $DB; /** @var CentreonDB */ public $centreon_DB; /** @var WikiApi */ public $api; /** @var array */ private $procList = []; /** * procedures constructor * * @param CentreonDB $pearDB */ public function __construct($pearDB) { $this->api = new WikiApi(); $this->centreon_DB = $pearDB; } /** * Set procedures * * @return void */ public function fetchProcedures() { if ($this->procList !== []) { return null; } $pages = $this->api->getAllPages(); // replace space foreach ($pages as $page) { $page = str_replace(' ', '_', $page); $this->procList[$page] = ''; } } /** * Get service template * * @param null $service_id * * @throws PDOException * @return array */ public function getMyServiceTemplateModels($service_id = null) { $tplArr = []; $dbResult = $this->centreon_DB->query( 'SELECT service_description, service_template_model_stm_id ' . 'FROM service ' . "WHERE service_id = '" . $service_id . "' LIMIT 1" ); $row = $dbResult->fetch(); if (isset($row['service_template_model_stm_id']) && $row['service_template_model_stm_id'] != '') { $dbResult->closeCursor(); $service_id = $row['service_template_model_stm_id']; if ($row['service_description']) { $tplArr[$service_id] = html_entity_decode($row['service_description'], ENT_QUOTES); } while (1) { $dbResult = $this->centreon_DB->query( 'SELECT service_description, service_template_model_stm_id ' . 'FROM service ' . "WHERE service_id = '" . $service_id . "' LIMIT 1" ); $row = $dbResult->fetch(); $dbResult->closeCursor(); if ($row['service_description']) { $tplArr[$service_id] = html_entity_decode($row['service_description'], ENT_QUOTES); } else { break; } if ($row['service_template_model_stm_id']) { $service_id = $row['service_template_model_stm_id']; } else { break; } } } return $tplArr; } /** * Get host template models * * @param null $host_id * * @throws PDOException * @return array */ public function getMyHostMultipleTemplateModels($host_id = null) { if (! $host_id) { return []; } $tplArr = []; $dbResult = $this->centreon_DB->query( 'SELECT host_tpl_id ' . 'FROM `host_template_relation` ' . "WHERE host_host_id = '" . $host_id . "' " . 'ORDER BY `order`' ); $statement = $this->centreon_DB->prepare( 'SELECT host_name ' . 'FROM host ' . 'WHERE host_id = :host_id LIMIT 1' ); while ($row = $dbResult->fetch()) { $statement->bindValue(':host_id', $row['host_tpl_id'], PDO::PARAM_INT); $statement->execute(); $hTpl = $statement->fetch(PDO::FETCH_ASSOC); $tplArr[$row['host_tpl_id']] = html_entity_decode($hTpl['host_name'], ENT_QUOTES); } unset($row, $hTpl); return $tplArr; } /** * Check if Service has procedure * * @param string $key * @param array $templates * @param int $mode * @return bool */ public function serviceHasProcedure($key, $templates = [], $mode = PROCEDURE_SIMPLE_MODE) { if (isset($this->procList['Service_:_' . $key])) { return true; } if ($mode == PROCEDURE_SIMPLE_MODE) { return false; } if ($mode == PROCEDURE_INHERITANCE_MODE) { foreach ($templates as $templateId => $templateName) { $res = $this->serviceTemplateHasProcedure($templateName, null, PROCEDURE_SIMPLE_MODE); if ($res == true) { return true; } } } return false; } /** * Check if Host has procedure * * @param string $key * @param array $templates * @param int $mode * @return bool */ public function hostHasProcedure($key, $templates = [], $mode = PROCEDURE_SIMPLE_MODE) { if (isset($this->procList['Host_:_' . $key])) { return true; } if ($mode == PROCEDURE_SIMPLE_MODE) { return false; } if ($mode == PROCEDURE_INHERITANCE_MODE) { foreach ($templates as $templateId => $templateName) { $res = $this->hostTemplateHasProcedure($templateName, null, PROCEDURE_SIMPLE_MODE); if ($res == true) { return true; } } } return false; } /** * Check if Service template has procedure * * @param string $key * @param array $templates * @param int $mode * @return bool */ public function serviceTemplateHasProcedure($key = '', $templates = [], $mode = PROCEDURE_SIMPLE_MODE) { if (isset($this->procList['Service-Template_:_' . $key])) { return true; } if ($mode == PROCEDURE_SIMPLE_MODE) { return false; } if ($mode == PROCEDURE_INHERITANCE_MODE) { foreach ($templates as $templateId => $templateName) { if (isset($this->procList['Service-Template_:_' . $templateName])) { return true; } } } return false; } /** * Check if Host template has procedures * * @param string $key * @param array $templates * @param mixed $mode * @return bool */ public function hostTemplateHasProcedure($key = '', $templates = [], $mode = PROCEDURE_SIMPLE_MODE) { if (isset($this->procList['Host-Template_:_' . $key])) { return true; } if ($mode == PROCEDURE_SIMPLE_MODE) { return false; } if ($mode == PROCEDURE_INHERITANCE_MODE) { foreach ($templates as $templateId => $templateName) { if (isset($this->procList['Host-Template_:_' . $templateName])) { return true; } } } return false; } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/class/centreon-config/centreonMainCfg.class.php
centreon/www/class/centreon-config/centreonMainCfg.class.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ /** * Class * * @class CentreonMainCfg */ class CentreonMainCfg { // List of broker options Centreon Engine // (https://documentation.centreon.com/docs/centreon-engine/en/latest/user/configuration/basics/main_configuration_file_options.html#event-broker-options) public const EVENT_BROKER_OPTIONS = [ -1 => 'All', 0 => 'None', 1 => 'Program state', 2 => 'Timed events', 4 => 'Service checks', 8 => 'Host checks', 16 => 'Event handlers', 32 => 'Logged data', 64 => 'Notifications', 128 => 'Flapping data', 256 => 'Comment data', 512 => 'Downtime data', 1024 => 'System commands', 2048 => 'OCP data unused', 4096 => 'Status data', 8192 => 'Adaptive data', 16384 => 'External command data', 32768 => 'Retention data', 65536 => 'Acknowledgement data', 131072 => 'Statechange data', 262144 => 'Reserved18', 524288 => 'Reserved19', 1048576 => 'Customvariable data', 2097152 => 'Group data', 4194304 => 'Group member data', 8388608 => 'Module data', 16777216 => 'Relation data', 33554432 => 'Command data', ]; /** @var array */ private $aDefaultBrokerDirective; /** @var array */ private $aInstanceDefaultValues; /** @var CentreonDB */ private $DB; /** @var array<string,string> */ private $loggerDefaultCfg = [ 'log_v2_logger' => 'file', 'log_level_functions' => 'err', 'log_level_config' => 'info', 'log_level_events' => 'info', 'log_level_checks' => 'info', 'log_level_notifications' => 'err', 'log_level_eventbroker' => 'err', 'log_level_external_command' => 'info', 'log_level_commands' => 'err', 'log_level_downtimes' => 'err', 'log_level_comments' => 'err', 'log_level_macros' => 'err', 'log_level_process' => 'info', 'log_level_runtime' => 'err', ]; /** * CentreonMainCfg constructor */ public function __construct() { $this->DB = new CentreonDB(); $this->setBrokerOptions(); $this->setEngineOptions(); } /** * Get Default values * * @return array */ public function getDefaultMainCfg() { return $this->aInstanceDefaultValues; } /** * Get default engine logger values * * @return array */ public function getDefaultLoggerCfg(): array { return $this->loggerDefaultCfg; } /** * Get Default values * * @return array */ public function getDefaultBrokerOptions() { return $this->aDefaultBrokerDirective; } /** * Insert the broker modules in cfg_nagios * * @param int $iId * @param ? $source * * @throws PDOException * @return false|void */ public function insertBrokerDefaultDirectives($iId, $source) { if (empty($iId) || ! in_array($source, ['ui'])) { return false; } $query = "SELECT bk_mod_id FROM `cfg_nagios_broker_module` WHERE cfg_nagios_id = '" . $iId . "'"; $dbResult = $this->DB->query($query); if ($dbResult->rowCount() == 0) { $sQuery = "INSERT INTO cfg_nagios_broker_module (`broker_module`, `cfg_nagios_id`) VALUES ('" . $this->aDefaultBrokerDirective[$source] . "', " . $iId . ')'; try { $res = $this->DB->query($sQuery); } catch (PDOException $e) { return false; } } } /** * @param int $nagiosId * * @throws PDOException */ public function insertDefaultCfgNagiosLogger(int $nagiosId): void { $stmt = $this->DB->prepare('INSERT INTO cfg_nagios_logger (`cfg_nagios_id`) VALUES (:nagiosId)'); $stmt->bindValue('nagiosId', $nagiosId); $stmt->execute(); } /** * @param int $nagiosId * @param int $serverId * * @throws PDOException */ public function insertCfgNagiosLogger(int $nagiosId, int $serverId): void { $stmt = $this->DB->prepare( 'SELECT logger.* FROM cfg_nagios_logger logger, cfg_nagios cfg WHERE cfg.nagios_id = logger.cfg_nagios_id AND cfg.nagios_server_id = :serverId' ); $stmt->bindValue('serverId', $serverId, PDO::PARAM_INT); $stmt->execute(); $baseValues = $stmt->fetch(); if (empty($baseValues)) { $baseValues = $this->getDefaultLoggerCfg(); } else { unset($baseValues['id']); } $baseValues['cfg_nagios_id'] = $nagiosId; $columnNames = array_keys($baseValues); $stmt = $this->DB->prepare( 'INSERT INTO cfg_nagios_logger (`' . implode('`, `', $columnNames) . '`) VALUES(:' . implode(', :', $columnNames) . ')' ); foreach ($baseValues as $columName => $value) { if ($columName === 'cfg_nagios_id') { $stmt->bindValue(":{$columName}", $value, PDO::PARAM_INT); } else { $stmt->bindValue(":{$columName}", $value, PDO::PARAM_STR); } } $stmt->execute(); } /** * Insert the instance in cfg_nagios * * @param int $source The poller id * @param int $iId * @param string $sName * * @throws PDOException * @return false|mixed */ public function insertServerInCfgNagios($source, $iId, $sName) { if (empty($sName)) { $sName = 'poller'; } if (! isset($this->aInstanceDefaultValues) || ! isset($iId)) { return false; } $res = $this->DB->query('SELECT * FROM cfg_nagios WHERE nagios_server_id = ' . $source); $baseValues = $res->rowCount() == 0 ? $this->aInstanceDefaultValues : $res->fetch(); $rq = 'INSERT INTO `cfg_nagios` ( `nagios_name`, `nagios_server_id`, `log_file`, `cfg_dir`, `status_file`, `status_update_interval`, `enable_notifications`, `execute_service_checks`, `accept_passive_service_checks`, `execute_host_checks`, `accept_passive_host_checks`, `enable_event_handlers`, `check_external_commands`, `external_command_buffer_slots`, `command_check_interval`, `command_file`, `retain_state_information`, `state_retention_file`,`retention_update_interval`, `use_retained_program_state`, `use_retained_scheduling_info`, `use_syslog`, `log_notifications`, `log_service_retries`, `log_host_retries`, `log_event_handlers`, `log_external_commands`, `log_passive_checks`, `sleep_time`, `service_inter_check_delay_method`, `host_inter_check_delay_method`, `service_interleave_factor`, `max_concurrent_checks`, `max_service_check_spread`, `max_host_check_spread`, `check_result_reaper_frequency`, `auto_reschedule_checks`, `enable_flap_detection`, `low_service_flap_threshold`, `high_service_flap_threshold`, `low_host_flap_threshold`, `high_host_flap_threshold`, `soft_state_dependencies`, `service_check_timeout`, `host_check_timeout`, `event_handler_timeout`, `notification_timeout`, `check_for_orphaned_services`, `check_for_orphaned_hosts`, `check_service_freshness`, `check_host_freshness`, `date_format`, `illegal_object_name_chars`, `illegal_macro_output_chars`, `use_regexp_matching`, `use_true_regexp_matching`, `admin_email`, `admin_pager`, `nagios_comment`, `nagios_activate`, `event_broker_options`, `enable_predictive_host_dependency_checks`, `enable_predictive_service_dependency_checks`, `host_down_disable_service_checks`, `passive_host_checks_are_soft`, `enable_environment_macros`, `debug_file`, `debug_level`, `debug_level_opt`, `debug_verbosity`, `max_debug_file_size`, `cfg_file` ) VALUES ( :nagios_name, :nagios_server_id, :log_file, :cfg_dir, :status_file, :status_update_interval, :enable_notifications, :execute_service_checks, :accept_passive_service_checks, :execute_host_checks, :accept_passive_host_checks, :enable_event_handlers, :check_external_commands, :external_command_buffer_slots, :command_check_interval, :command_file, :retain_state_information, :state_retention_file,:retention_update_interval, :use_retained_program_state, :use_retained_scheduling_info, :use_syslog, :log_notifications, :log_service_retries, :log_host_retries, :log_event_handlers, :log_external_commands, :log_passive_checks, :sleep_time, :service_inter_check_delay_method, :host_inter_check_delay_method, :service_interleave_factor, :max_concurrent_checks, :max_service_check_spread, :max_host_check_spread, :check_result_reaper_frequency, :auto_reschedule_checks, :enable_flap_detection, :low_service_flap_threshold, :high_service_flap_threshold, :low_host_flap_threshold, :high_host_flap_threshold, :soft_state_dependencies, :service_check_timeout, :host_check_timeout, :event_handler_timeout, :notification_timeout, :check_for_orphaned_services, :check_for_orphaned_hosts, :check_service_freshness, :check_host_freshness, :date_format, :illegal_object_name_chars, :illegal_macro_output_chars, :use_regexp_matching, :use_true_regexp_matching, :admin_email, :admin_pager, :nagios_comment, :nagios_activate, :event_broker_options, :enable_predictive_host_dependency_checks, :enable_predictive_service_dependency_checks, :host_down_disable_service_checks, :passive_host_checks_are_soft, :enable_environment_macros, :debug_file, :debug_level, :debug_level_opt, :debug_verbosity, :max_debug_file_size, :cfg_file )'; $params = [ ':nagios_name' => 'Centreon Engine ' . $sName, ':nagios_server_id' => $iId, ':log_file' => $baseValues['log_file'], ':cfg_dir' => $baseValues['cfg_dir'], ':status_file' => $baseValues['status_file'], ':status_update_interval' => $baseValues['status_update_interval'], ':enable_notifications' => $baseValues['enable_notifications'], ':execute_service_checks' => $baseValues['execute_service_checks'], ':accept_passive_service_checks' => $baseValues['accept_passive_service_checks'], ':execute_host_checks' => $baseValues['execute_host_checks'], ':accept_passive_host_checks' => $baseValues['accept_passive_host_checks'], ':enable_event_handlers' => $baseValues['enable_event_handlers'], ':check_external_commands' => $baseValues['check_external_commands'], ':external_command_buffer_slots' => $baseValues['external_command_buffer_slots'], ':command_check_interval' => $baseValues['command_check_interval'], ':command_file' => $baseValues['command_file'], ':retain_state_information' => $baseValues['retain_state_information'], ':state_retention_file' => $baseValues['state_retention_file'], ':retention_update_interval' => $baseValues['retention_update_interval'], ':use_retained_program_state' => $baseValues['use_retained_program_state'], ':use_retained_scheduling_info' => $baseValues['use_retained_scheduling_info'], ':use_syslog' => $baseValues['use_syslog'], ':log_notifications' => $baseValues['log_notifications'], ':log_service_retries' => $baseValues['log_service_retries'], ':log_host_retries' => $baseValues['log_host_retries'], ':log_event_handlers' => $baseValues['log_event_handlers'], ':log_external_commands' => $baseValues['log_external_commands'], ':log_passive_checks' => $baseValues['log_passive_checks'], ':sleep_time' => $baseValues['sleep_time'], ':service_inter_check_delay_method' => $baseValues['service_inter_check_delay_method'], ':host_inter_check_delay_method' => $baseValues['host_inter_check_delay_method'], ':service_interleave_factor' => $baseValues['service_interleave_factor'], ':max_concurrent_checks' => $baseValues['max_concurrent_checks'], ':max_service_check_spread' => $baseValues['max_service_check_spread'], ':max_host_check_spread' => $baseValues['max_host_check_spread'], ':check_result_reaper_frequency' => $baseValues['check_result_reaper_frequency'], ':auto_reschedule_checks' => $baseValues['auto_reschedule_checks'], ':enable_flap_detection' => $baseValues['enable_flap_detection'], ':low_service_flap_threshold' => $baseValues['low_service_flap_threshold'], ':high_service_flap_threshold' => $baseValues['high_service_flap_threshold'], ':low_host_flap_threshold' => $baseValues['low_host_flap_threshold'], ':high_host_flap_threshold' => $baseValues['high_host_flap_threshold'], ':soft_state_dependencies' => $baseValues['soft_state_dependencies'], ':service_check_timeout' => $baseValues['service_check_timeout'], ':host_check_timeout' => $baseValues['host_check_timeout'], ':event_handler_timeout' => $baseValues['event_handler_timeout'], ':notification_timeout' => $baseValues['notification_timeout'], ':check_for_orphaned_services' => $baseValues['check_for_orphaned_services'], ':check_for_orphaned_hosts' => $baseValues['check_for_orphaned_hosts'], ':check_service_freshness' => $baseValues['check_service_freshness'], ':check_host_freshness' => $baseValues['check_host_freshness'], ':date_format' => $baseValues['date_format'], ':illegal_object_name_chars' => $baseValues['illegal_object_name_chars'], ':illegal_macro_output_chars' => $baseValues['illegal_macro_output_chars'], ':use_regexp_matching' => $baseValues['use_regexp_matching'], ':use_true_regexp_matching' => $baseValues['use_true_regexp_matching'], ':admin_email' => $baseValues['admin_email'], ':admin_pager' => $baseValues['admin_pager'], ':nagios_comment' => $baseValues['nagios_comment'], ':nagios_activate' => $baseValues['nagios_activate'], ':event_broker_options' => $baseValues['event_broker_options'], ':enable_predictive_host_dependency_checks' => $baseValues['enable_predictive_host_dependency_checks'], ':enable_predictive_service_dependency_checks' => $baseValues['enable_predictive_service_dependency_checks'], ':host_down_disable_service_checks' => $baseValues['host_down_disable_service_checks'], ':passive_host_checks_are_soft' => $baseValues['passive_host_checks_are_soft'], ':enable_environment_macros' => $baseValues['enable_environment_macros'], ':debug_file' => $baseValues['debug_file'], ':debug_level' => $baseValues['debug_level'], ':debug_level_opt' => $baseValues['debug_level_opt'], ':debug_verbosity' => $baseValues['debug_verbosity'], ':max_debug_file_size' => $baseValues['max_debug_file_size'], ':cfg_file' => $baseValues['cfg_file'], ]; try { $stmt = $this->DB->prepare($rq); foreach ($params as $paramName => $paramValue) { if ($paramName === ':nagios_server_id') { $stmt->bindValue($paramName, $paramValue, PDO::PARAM_INT); } else { $stmt->bindValue($paramName, empty($paramValue) ? null : $paramValue, PDO::PARAM_STR); } } $stmt->execute(); } catch (PDOException $e) { return false; } $res1 = $this->DB->query('SELECT MAX(nagios_id) as last_id FROM `cfg_nagios`'); $nagios = $res1->fetch(); return $nagios['last_id']; } /** * Get Broker Module Entries * * @param int $id * * @throws PDOException * @return array $entries */ public function getBrokerModules($id) { $dbResult = $this->DB->query('SELECT * FROM cfg_nagios_broker_module WHERE cfg_nagios_id = ' . $id); while ($row = $dbResult->fetch()) { $entries[] = $row; } $dbResult->closeCursor(); return $entries; } /** * Explode the bitwise event broker options to an array for QuickForm * * @param int $value The value to explode * * @return array An array of integer */ public function explodeEventBrokerOptions($value) { return $this->explodeBitwise($value, self::EVENT_BROKER_OPTIONS); } /** * @return void */ private function setBrokerOptions(): void { $this->aDefaultBrokerDirective = ['ui' => '/usr/lib64/centreon-engine/externalcmd.so']; } /** * @return void */ private function setEngineOptions(): void { $this->aInstanceDefaultValues = [ 'log_file' => '/var/log/centreon-engine/centengine.log', 'cfg_dir' => '/etc/centreon-engine/', 'status_file' => '/var/log/centreon-engine/status.dat', 'status_update_interval' => '30', 'enable_notifications' => '1', 'execute_service_checks' => '1', 'accept_passive_service_checks' => '1', 'execute_host_checks' => '1', 'accept_passive_host_checks' => '1', 'enable_event_handlers' => '1', 'check_external_commands' => '1', 'external_command_buffer_slots' => '4096', 'command_check_interval' => '1s', 'command_file' => '/var/lib/centreon-engine/rw/centengine.cmd', 'retain_state_information' => '1', 'state_retention_file' => '/var/log/centreon-engine/retention.dat', 'retention_update_interval' => '60', 'use_retained_program_state' => '1', 'use_retained_scheduling_info' => '1', 'use_syslog' => '0', 'log_notifications' => '1', 'log_service_retries' => '1', 'log_host_retries' => '1', 'log_event_handlers' => '1', 'log_external_commands' => '1', 'log_passive_checks' => '1', 'sleep_time' => '1', 'service_inter_check_delay_method' => 's', 'host_inter_check_delay_method' => 's', 'service_interleave_factor' => 's', 'max_concurrent_checks' => '0', 'max_service_check_spread' => '15', 'max_host_check_spread' => '15', 'check_result_reaper_frequency' => '5', 'auto_reschedule_checks' => '0', 'enable_flap_detection' => '1', 'low_service_flap_threshold' => '25.0', 'high_service_flap_threshold' => '50.0', 'low_host_flap_threshold' => '25.0', 'high_host_flap_threshold' => '50.0', 'soft_state_dependencies' => '0', 'service_check_timeout' => '60', 'host_check_timeout' => '12', 'event_handler_timeout' => '30', 'notification_timeout' => '30', 'check_for_orphaned_services' => '0', 'check_for_orphaned_hosts' => '0', 'check_service_freshness' => '1', 'check_host_freshness' => '0', 'date_format' => 'euro', 'illegal_object_name_chars' => "~!$%^&*\"|'<>?,()=", 'illegal_macro_output_chars' => "`~$^&\"|'<>", 'use_regexp_matching' => '0', 'use_true_regexp_matching' => '0', 'admin_email' => 'admin@localhost', 'admin_pager' => 'admin', 'nagios_comment' => 'Centreon Engine configuration file', 'nagios_activate' => '1', 'event_broker_options' => '-1', 'nagios_server_id' => '1', 'enable_predictive_host_dependency_checks' => '1', 'enable_predictive_service_dependency_checks' => '1', 'host_down_disable_service_checks' => '1', 'passive_host_checks_are_soft' => '0', 'enable_environment_macros' => '0', 'debug_file' => '/var/log/centreon-engine/centengine.debug', 'debug_level' => '0', 'debug_level_opt' => '0', 'debug_verbosity' => '0', 'max_debug_file_size' => '1000000000', 'cfg_file' => 'centengine.cfg', 'cached_host_check_horizon' => '60', 'log_pid' => 1, 'enable_macros_filter' => 0, 'logger_version' => 'log_v2_enabled', ]; } /** * Explode the bitwise to an array for QuickForm * * @param int $value The value to explode * @param array $sources The list of bit * * @return array An array of integer */ private function explodeBitwise($value, $sources) { if ($value === -1) { return [-1 => 1]; } if ($value === 0) { return [0 => 1]; } $listOptions = []; // Explode all bitwise foreach ($sources as $bit => $text) { if ($bit !== -1 && $bit !== 0 && ($value & $bit)) { $listOptions[$bit] = 1; } } return $listOptions; } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/functions.php
centreon/www/install/functions.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ require_once __DIR__ . '/../../vendor/autoload.php'; use Core\Security\ProviderConfiguration\Domain\Local\Model\SecurityPolicy; /** * Generate random password * 12 characters length with at least 1 uppercase, 1 lowercase, 1 number and 1 special character * * @return string */ function generatePassword(): string { $ruleSets = [ implode('', range('a', 'z')), implode('', range('A', 'Z')), implode('', range(0, 9)), SecurityPolicy::SPECIAL_CHARACTERS_LIST, ]; $allRuleSets = implode('', $ruleSets); $passwordLength = 12; $password = ''; foreach ($ruleSets as $ruleSet) { $password .= $ruleSet[random_int(0, strlen($ruleSet) - 1)]; } for ($i = 0; $i < ($passwordLength - count($ruleSets)); $i++) { $password .= $allRuleSets[random_int(0, strlen($allRuleSets) - 1)]; } return str_shuffle($password); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/install.conf.dist.php
centreon/www/install/install.conf.dist.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ $conf_centreon['centreon_dir'] = '/usr/share/centreon/'; $conf_centreon['centreon_etc'] = '/etc/centreon/'; $conf_centreon['centreon_dir_www'] = '/usr/share/centreon/www/'; $conf_centreon['centreon_dir_rrd'] = '/var/lib/centreon'; $conf_centreon['centreon_log'] = '/var/log/centreon'; $conf_centreon['centreon_cachedir'] = '/var/cache/centreon/'; $conf_centreon['centreon_varlib'] = '/var/lib/centreon'; $conf_centreon['centreon_group'] = 'centreon'; $conf_centreon['centreon_user'] = 'centreon'; $conf_centreon['rrdtool_dir'] = '/usr/bin/rrdtool'; $conf_centreon['apache_user'] = 'apache'; $conf_centreon['apache_group'] = 'apache'; $conf_centreon['mail'] = '/bin/mail'; $conf_centreon['broker_user'] = 'centreon-broker'; $conf_centreon['broker_group'] = 'centreon-broker'; $conf_centreon['broker_etc'] = '/etc/centreon-broker'; $conf_centreon['monitoring_user'] = 'centreon-engine'; $conf_centreon['monitoring_group'] = 'centreon-engine'; $conf_centreon['monitoring_etc'] = '/etc/centreon-engine'; $conf_centreon['monitoring_binary'] = '/usr/sbin/centengine'; $conf_centreon['monitoring_varlog'] = '/var/log/centreon-engine'; $conf_centreon['plugin_dir'] = '/usr/lib/nagios/plugins'; $conf_centreon['centreon_engine_connectors'] = '/usr/lib64/centreon-connector'; $conf_centreon['centreon_engine_lib'] = '/usr/lib64/centreon-engine'; $conf_centreon['centreon_plugins'] = '/usr/lib/centreon/plugins';
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/upgrade.php
centreon/www/install/upgrade.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ // configuration require_once realpath(__DIR__ . '/../../config/centreon.config.php'); include_once './step_upgrade/functions.php'; include_once '../class/centreonSession.class.php'; CentreonSession::start(); require_once './step_upgrade/index.php'; exit;
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/react_translation.php
centreon/www/install/react_translation.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ echo _('All pollers'); echo _('Configure pollers'); echo _('services'); echo _('Critical services'); echo _('Warning services'); echo _('Unknown services'); echo _('Ok services'); echo _('Pending services'); echo _('Edit profile'); echo _('Copy autologin link'); echo _('Server Configuration Wizard'); echo _('Choose a server type'); echo _('Add a Centreon Remote Server'); echo _('Add a Centreon Poller'); echo _('Remote Server Configuration'); echo _('Create new Remote Server'); echo _('Server Name'); echo _('Server address'); echo _('Database username'); echo _('Database password'); echo _('Centreon Central address, as seen by this server'); echo _('Centreon Web Folder on Remote'); echo _('Select Pending Remote Links'); echo _('Select IP'); echo _('Select pollers to be attached to this new Remote Server'); echo _('Finalizing Setup'); echo _('Creating Export Task'); echo _('Generating Export Files'); echo _('The field is required'); echo _('Not a valid IP address'); echo _('Add server with wizard'); echo _('Select linked Remote Server'); echo _('as'); echo _('Server Configuration'); echo _('Attach poller to a master remote server'); echo _('Attach poller to additional remote servers'); echo _('Advanced: reverse Centreon Broker communication flow'); echo _('%s is not valid.'); echo _("You need to send '%s' in the request."); echo _('Some database poller updates are not active; check your configuration'); echo _('Latency detected, check configuration for better optimization'); echo _('Do not check SSL certificate validation'); echo _('Do not use configured proxy to connect to this server');
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/index.php
centreon/www/install/index.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/install.php
centreon/www/install/install.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ require_once __DIR__ . '/../../bootstrap.php'; require_once __DIR__ . '/../class/centreonSession.class.php'; CentreonSession::start(); ini_set('track_errors', true); $installFactory = new CentreonLegacy\Core\Install\Factory($dependencyInjector); $information = $installFactory->newInformation(); $step = $information->getStep(); require_once __DIR__ . '/steps/functions.php'; $template = getTemplate(__DIR__ . '/steps/templates'); $template->display('install.tpl');
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/step_upgrade/step3.php
centreon/www/install/step_upgrade/step3.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ session_start(); DEFINE('STEP_NUMBER', 3); $_SESSION['step'] = STEP_NUMBER; require_once '../steps/functions.php'; $template = getTemplate('templates'); require_once __DIR__ . '/../../../config/centreon.config.php'; require_once __DIR__ . '/../../class/centreonDB.class.php'; $title = _('Release notes'); $db = new CentreonDB(); $res = $db->query("SELECT `value` FROM `informations` WHERE `key` = 'version'"); $row = $res->fetchRow(); $current = $row['value']; $_SESSION['CURRENT_VERSION'] = $current; /* ** To find the final version that we should update to, we will look in ** the www/install/php directory where all PHP update scripts are ** stored. We will extract the target version from the filename and find ** the farthest version to the current version. */ $next = ''; if ($handle = opendir('../php')) { while (false !== ($file = readdir($handle))) { if (preg_match('/Update-([a-zA-Z0-9\-\.]+)\.php/', $file, $matches)) { if ((version_compare($current, $matches[1]) < 0) && (empty($next) || (version_compare($next, $matches[1]) < 0))) { $next = $matches[1]; } } } closedir($handle); } $majors = preg_match('/^(\d+\.\d+)/', $next, $matches); if (! isset($matches[1])) { $matches[1] = 'current'; } $releaseNoteLink = 'https://documentation.centreon.com/' . $matches[1] . '/en/releases/centreon-core.html'; $title = _('Release notes'); $contents = '<p><b>' . _('Everything is ready !') . '</b></p>'; $contents .= '<p>' . _('Your Centreon Platform is about to be upgraded from version ') . $current . _(' to ') . $next . '</p>'; $contents .= '<p>' . _('For further details on changes, please find the complete changelog on '); $contents .= '<a href="' . $releaseNoteLink . '"target="_blank" style="text-decoration:underline;font-size:11px">documentation.centreon.com</a></p>'; $template->assign('step', STEP_NUMBER); $template->assign('title', $title); $template->assign('content', $contents); $template->assign('blockPreview', 1); $template->display('content.tpl'); ?> <script type='text/javascript'> var step3_s = 3; var step3_t; jQuery(function () { jQuery('#next').attr('disabled', 'disabled'); timeout_button(); }); function timeout_button() { if (step3_t) { clearTimeout(step3_t); } jQuery("#next").val("Next (" + step3_s + ")"); step3_s--; if (step3_s == 0) { jQuery("#next").val("Next"); jQuery("#next").removeAttr('disabled'); } else { step3_t = setTimeout('timeout_button()', 1000); } } function validation() { return true; } </script>
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/step_upgrade/step5.php
centreon/www/install/step_upgrade/step5.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ session_start(); define('STEP_NUMBER', 5); $_SESSION['step'] = STEP_NUMBER; require_once '../steps/functions.php'; require_once __DIR__ . '/../../../bootstrap.php'; $db = $dependencyInjector['configuration_db']; /** * @var CentreonDB $db */ $res = $db->query("SELECT `value` FROM `options` WHERE `key` = 'send_statistics'"); $stat = $res->fetch(); $template = getTemplate('templates'); // If CEIP is disabled and if it's a major version of Centreon ask again $aVersion = explode('.', $_SESSION['CURRENT_VERSION']); if ((int) $stat['value'] != 1 && (int) $aVersion[2] === 0) { $stat = false; } $title = _('Upgrade finished'); if (is_dir(_CENTREON_VARLIB_ . '/installs') === false) { $contents .= '<br>Warning : The installation directory cannot be moved. Please create the directory ' . _CENTREON_VARLIB_ . '/installs and give apache user write permissions.'; $moveable = false; } else { $moveable = true; $contents = sprintf( _('Congratulations, you have successfully upgraded to Centreon version <b>%s</b>.'), $_SESSION['CURRENT_VERSION'] ); } if ($stat === false) { $contents .= '<br/> <hr> <br/> <form id=\'form_step5\'> <table cellpadding=\'0\' cellspacing=\'0\' border=\'0\' class=\'StyleDottedHr\' align=\'center\'> <tbody> <tr> <td class=\'formValue\'> <div class=\'md-checkbox md-checkbox-inline\' style=\'display:none;\'> <input id=\'send_statistics\' value=\'1\' name=\'send_statistics\' type=\'checkbox\' checked=\'checked\'/> <label class=\'empty-label\' for=\'send_statistics\'></label> </div> </td> <td class=\'formlabel\'> <p style="text-align:justify">Centreon uses a telemetry system and a Centreon Customer Experience Improvement Program whereby anonymous information about the usage of this server may be sent to Centreon. This information will solely be used to improve the software user experience. You will be able to opt-out at any time about CEIP program through administration menu. Refer to <a target="_blank" style="text-decoration: underline" href="http://ceip.centreon.com/">ceip.centreon.com</a> for further details. </p> </td> </tr> </tbody> </table> </form>'; } $template->assign('step', STEP_NUMBER); $template->assign('title', $title); $template->assign('content', $contents); $template->assign('finish', 1); $template->assign('blockPreview', 1); $template->display('content.tpl'); if ($moveable) { ?> <script> /** * Validates info * * @return bool */ function validation() { jQuery.ajax({ type: 'POST', url: './step_upgrade/process/process_step5.php', data: jQuery('input[name="send_statistics"]').serialize(), success: () => { javascript:self.location = "../index.html" } }) } </script> <?php }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/step_upgrade/functions.php
centreon/www/install/step_upgrade/functions.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ function aff_header($str, $str2, $nb) { ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Style-Type" content="text/css"> <title><?php echo $str; ?></title> <link rel="shortcut icon" href="../img/favicon.ico"> <link rel="stylesheet" href="./install.css" type="text/css"> <SCRIPT language='javascript'> function LicenceAccepted() { var theForm = document.forms[0]; var nextButton = document.getElementById("button_next"); if (theForm.setup_license_accept.checked) { nextButton.disabled = ''; nextButton.focus(); } else { nextButton.disabled = "disabled"; } } function LicenceAcceptedByLink() { var theForm = document.forms[0]; var nextButton = document.getElementById("button_next"); theForm.setup_license_accept.checked = true; nextButton.disabled = ''; nextButton.focus(); } </SCRIPT> </head> <body rightmargin="0" topmargin="0" leftmargin="0"> <table cellspacing="0" cellpadding="0" border="0" align="center" class="shell"> <tr height="83" style=" background-image: url('../img/bg_banner.gif');"> <th width="400" height="83"><?php echo $nb . '. ' . $str2; ?></th> <th width="200" height="83" style="text-align: right; padding: 0px;"> <a href="http://www.centreon.com" target="_blank"><img src="../img/centreon.png" alt="Oreon" border="0" style="padding-top:10px;padding-right:10px;"></a> </th> </tr> <tr> <td colspan="2" width="600" style="background-position : right; background-color: #DDDDDD; background-repeat : no-repeat;"> <form action="upgrade.php" method="post" name="theForm" id="theForm"> <input type="hidden" name="step" value="<?php echo $nb; ?>"> <?php } function aff_middle() { ?> </td> </tr> <tr> <td align="right" colspan="2" height="20"> <hr> <table cellspacing="0" cellpadding="0" border="0" class="stdTable"> <tr> <td> <?php } function aff_footer() { ?> </td> </tr> </table> </form> </td> </tr> </table> </body> </html> <?php } ?>
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/step_upgrade/index.php
centreon/www/install/step_upgrade/index.php
<?php if (strlen(session_id()) < 1) { session_start(); } $step = 1; if (isset($_SESSION['step'])) { $step = $_SESSION['step']; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Style-Type" content="text/css"> <title><?php echo _('Centreon Installation'); ?></title> <link rel="shortcut icon" href="../img/favicon.ico"> <link rel="stylesheet" href="../Themes/Generic-theme/style.css" type="text/css"> <link rel="stylesheet" href="./install.css" type="text/css"> <link rel="stylesheet" href="./pub_install.css" type="text/css"> <script type="text/javascript" src="../include/common/javascript/jquery/jquery.min.js"></script> <script type="text/javascript" src="../include/common/javascript/jquery/jquery-ui.js"></script> <script type="text/javascript">jQuery.noConflict();</script> <script type='text/javascript'> jQuery().ready(function () { var curstep = <?php echo $step; ?>; jQuery('#installationContent').load('./step_upgrade/step' + curstep + '.php'); }); /** * Go back to previous page * * @param int stepNumber * @return void */ function jumpTo(stepNumber) { jQuery('#installationContent').load('./step_upgrade/step' + stepNumber + '.php'); } /** * Do background process * * @param boolean async * @param string url * @param array data * @param function callbackOnSuccess * @return void */ function doProcess(async, url, data, callbackOnSuccess) { jQuery.ajax({ type: 'POST', url: url, data: data, success: callbackOnSuccess, async: async }); } </script> </head> <body rightmargin="0" topmargin="0" leftmargin="0"> <div id='installationFrame'> <div id='installationContent'></div> </div> </body> </html>
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/step_upgrade/step1.php
centreon/www/install/step_upgrade/step1.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ require_once __DIR__ . '/../../class/centreonDB.class.php'; session_start(); define('STEP_NUMBER', 1); $_SESSION['step'] = STEP_NUMBER; require_once '../steps/functions.php'; $template = getTemplate('templates'); $title = _('Centreon Upgrade'); $status = 0; $content = ''; $errorMessages = []; try { checkPhpPrerequisite(); } catch (Exception $e) { $errorMessages[] = $e->getMessage(); } try { $db = new CentreonDB(); checkMariaDBPrerequisite($db); } catch (Exception $e) { $errorMessages[] = $e->getMessage(); } foreach ($errorMessages as $errorMessage) { $status = 1; $content .= "<p class='required'>" . $errorMessage . '</p>'; } if (! is_file('../install.conf.php')) { $status = 1; $content .= sprintf("<p class='required'>%s (install.conf.php)</p>", _('Configuration file not found.')); } if ($status !== 1) { $content .= sprintf( '<p>%s%s</p>', _('You are about to upgrade Centreon.'), _('The entire process should take around ten minutes.') ); $content .= sprintf( '<p>%s</p>', _('It is strongly recommended to make a backup of your databases before going any further.') ); require_once '../install.conf.php'; setSessionVariables($conf_centreon); } $template->assign('step', STEP_NUMBER); $template->assign('title', $title); $template->assign('content', $content); $template->display('content.tpl'); ?> <script type='text/javascript'> var status = <?php echo $status; ?>; /** * Validates info * * @return bool */ function validation() { if (status == 0) { return true; } return false; } </script>
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/step_upgrade/step2.php
centreon/www/install/step_upgrade/step2.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ session_start(); define('STEP_NUMBER', 2); $_SESSION['step'] = STEP_NUMBER; require_once '../steps/functions.php'; $template = getTemplate('templates'); $title = _('Dependency check up'); $requiredLib = explode("\n", file_get_contents('../var/phplib')); // PHP Libraries $contents = "<table cellpadding='0' cellspacing='0' border='0' width='80%' class='StyleDottedHr' align='center'>"; $contents .= '<tr> <th>' . _('Module name') . '</th> <th>' . _('File') . '</th> <th>' . _('Status') . '</th> </tr>'; $allClear = 1; foreach ($requiredLib as $line) { if (! $line) { continue; } $contents .= '<tr>'; [$name, $lib] = explode(':', $line); $contents .= '<td>' . $name . '</td>'; $contents .= '<td>' . $lib . '</td>'; $contents .= '<td>'; if (extension_loaded($lib)) { $libMessage = '<span style="color:#88b917; font-weight:bold;">' . _('Loaded') . '</span>'; } else { $libMessage = '<span style="color:#e00b3d; font-weight:bold;">' . _('Not loaded') . '</span>'; $allClear = 0; } $contents .= $libMessage; $contents .= '</td>'; $contents .= '</tr>'; } // Test if timezone is set if (! ini_get('date.timezone')) { $contents .= '<tr>'; $contents .= '<td>Timezone</td>'; $contents .= '<td>' . _('Set the default timezone in php.ini file') . '</td>'; $contents .= '<td>'; $libMessage = '<span style="color:#e00b3d; font-weight:bold;">' . _('Not initialized') . '</span>'; $allClear = 0; $contents .= $libMessage; $contents .= '</td>'; $contents .= '</tr>'; } $contents .= '</table>'; // PEAR Libraries // @todo $template->assign('step', STEP_NUMBER); $template->assign('title', $title); $template->assign('content', $contents); $template->assign('valid', $allClear); $template->display('content.tpl'); ?> <script type='text/javascript'> var allClear = <?php echo $allClear; ?> /** * Validates info * * @return bool */ function validation() { if (!allClear) { return false; } return true; } </script>
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/step_upgrade/step4.php
centreon/www/install/step_upgrade/step4.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ session_start(); define('STEP_NUMBER', 4); $_SESSION['step'] = STEP_NUMBER; require_once '../steps/functions.php'; require_once __DIR__ . '/../../../config/centreon.config.php'; $template = getTemplate('templates'); /* ** Get and check initial Centreon version. ** Should be >= 2.8.0-beta1. */ $current = $_SESSION['CURRENT_VERSION']; if (version_compare($current, '2.8.0-beta1') < 0) { $troubleshootTxt1 = _('Upgrade to this release requires Centreon >= 2.8.0-beta1.'); $troubleshootTxt2 = sprintf(_('Your current version is %s.'), $current); $troubleshootTxt3 = _('Please upgrade to an intermediate release (ie. 2.8.x) first.'); $contents .= sprintf( '<p class="required">%s<br/>%s<br/>%s</p>', $troubleshootTxt1, $troubleshootTxt2, $troubleshootTxt3 ); // Print upcoming database upgrade steps. } else { $contents = _('<p>Currently upgrading... please do not interrupt this process.</p>'); $contents .= "<table cellpadding='0' cellspacing='0' border='0' width='80%' class='StyleDottedHr' align='center'> <thead> <tr> <th>" . _('Step') . '</th> <th>' . _('Status') . "</th> </tr> </thead> <tbody id='step_contents'> </tbody> </table>"; $troubleshootTxt1 = _('You seem to be having trouble with your upgrade.'); $troubleshootTxt1bis = sprintf( _('Please check the "upgrade.log" and the "sql-error.log" located in "%s" for more details'), _CENTREON_LOG_ ); $troubleshootTxt2 = _('You may refer to the line in the specified file in order to correct the issue.'); $troubleshootTxt3 = sprintf(_('The SQL files are located in "%s"'), _CENTREON_PATH_ . 'www/install/sql/'); $troubleshootTxt4 = _('But do not edit the SQL files unless you know what you are doing.' . 'Refresh this page when the problem is fixed.'); $contents .= sprintf( '<br/><p id="troubleshoot" style="display:none;">%s<br/><br/>%s<br/>%s<br/><br/>%s<br/>%s</p>', $troubleshootTxt1, $troubleshootTxt1bis, $troubleshootTxt2, $troubleshootTxt3, $troubleshootTxt4 ); /* ** To find the next version that we should update to, we will look in ** the www/install/php directory where all PHP update scripts are ** stored. We will extract the target version from the filename and find ** the closest version to the current version. */ $next = ''; if ($handle = opendir('../php')) { while (false !== ($file = readdir($handle))) { if (preg_match('/Update-([a-zA-Z0-9\-\.]+)\.php/', $file, $matches)) { if ((version_compare($current, $matches[1]) < 0) && (empty($next) || (version_compare($matches[1], $next) < 0))) { $next = $matches[1]; } } } closedir($handle); } } // Generate template. $title = _('Installation'); $template->assign('step', STEP_NUMBER); $template->assign('title', $title); $template->assign('content', $contents); $template->assign('blockPreview', 1); $template->display('content.tpl'); ?> <script type='text/javascript'> let step = <?php echo STEP_NUMBER; ?>; let myCurrent; let myNext; let result = false; let stepContent = jQuery('#step_contents'); jQuery(function () { myCurrent = '<?php echo $current; ?>'; myNext = '<?php echo $next; ?>'; jQuery("input[type=button]").hide(); if (myCurrent !== '' && myNext !== '') { nextStep(myCurrent, myNext); } else { generationCache(); } }); /** * Go to next upgrade script * * @param string current * @param string next * @return void */ function nextStep(current, next) { stepContent.append('<tr>'); stepContent.append('<td>' + current + ' to ' + next + '</td>'); stepContent.append('<td style="font-weight: bold;" name="' + replaceDot(current) + '"><img src="../img/misc/ajax-loader.gif"></td>'); stepContent.append('</tr>'); doProcess( true, './step_upgrade/process/process_step' + step + '.php' , {'current': current, 'next': next}, function (response) { let data = jQuery.parseJSON(response); jQuery('td[name=' + replaceDot(current) + ']').html(data['msg']); if (data['result'] === "0") { jQuery('#troubleshoot').hide(); if (data['next']) { nextStep(data['current'], data['next']); } else { generateEngineContextConfiguration(); generationCache(); } } else { jQuery('#troubleshoot').show(); jQuery('#refresh').show(); } }); } function generateEngineContextConfiguration() { stepContent.append('<tr>'); stepContent.append('<td>Engine Context Configuration Creation</td>'); stepContent.append( '<td style="font-weight: bold;" name="engine.context"><img src="../img/misc/ajax-loader.gif"></td>' ); stepContent.append('</tr>'); doProcess( true, './steps/process/createEngineContextConfiguration.php', null, function (response) { let data = jQuery.parseJSON(response); if (data['result'] === 0) { jQuery('td[name="engine.context"]').html("<span style='color:#88b917;'>" + data['msg'] + '</span>'); jQuery('#troubleshoot').hide(); jQuery('#next').show(); result = true; } else { jQuery('td[name="engine.context"]').html("<span style='color:red;'>" + data['msg'] + '</span>'); jQuery('#refresh').show(); } } ) } function generationCache() { stepContent.append('<tr>'); stepContent.append('<td>Application cache generation</td>'); stepContent.append( '<td style="font-weight: bold;" name="api.cache"><img src="../img/misc/ajax-loader.gif"></td>' ); stepContent.append('</tr>'); doProcess( true, './steps/process/generationCache.php', null, function (response) { let data = jQuery.parseJSON(response); if (data['result'] === 0) { jQuery('td[name="api.cache"]').html("<span style='color:#88b917;'>" + data['msg'] + '</span>'); jQuery('#troubleshoot').hide(); jQuery('#next').show(); result = true; } else { jQuery('td[name="api.cache"]').html("<span style='color:red;'>" + data['msg'] + '</span>'); jQuery('#refresh').show(); } }); } /** * Replace dot with dash characters * * @param string str * @return void */ function replaceDot(str) { return str.replace(/\./g, '-'); } /** * Validates info * * @return bool */ function validation() { return result; } </script>
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/step_upgrade/process/process_step4.php
centreon/www/install/step_upgrade/process/process_step4.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ session_start(); require_once __DIR__ . '/../../../../bootstrap.php'; require_once __DIR__ . '/../../../class/centreonDB.class.php'; require_once __DIR__ . '/../../steps/functions.php'; use Core\Platform\Application\Repository\ReadUpdateRepositoryInterface; use Core\Platform\Application\Repository\UpdateLockerRepositoryInterface; use Core\Platform\Application\Repository\WriteUpdateRepositoryInterface; use Core\Platform\Application\UseCase\UpdateVersions\UpdateVersionsException; $current = $_POST['current']; $next = $_POST['next']; $status = 0; $kernel = App\Kernel::createForWeb(); $updateLockerRepository = $kernel->getContainer()->get(UpdateLockerRepositoryInterface::class); $updateWriteRepository = $kernel->getContainer()->get(WriteUpdateRepositoryInterface::class); try { if (! $updateLockerRepository->lock()) { throw UpdateVersionsException::updateAlreadyInProgress(); } $updateWriteRepository->runUpdate($next); $updateLockerRepository->unlock(); } catch (Throwable $e) { exitUpgradeProcess(1, $current, $next, $e->getMessage()); } $current = $next; $updateReadRepository = $kernel->getContainer()->get(ReadUpdateRepositoryInterface::class); $availableUpdates = $updateReadRepository->findOrderedAvailableUpdates($current); $next = empty($availableUpdates) ? '' : array_shift($availableUpdates); $_SESSION['CURRENT_VERSION'] = $current; $okMsg = "<span style='color:#88b917;'>OK</span>"; exitUpgradeProcess($status, $current, $next, $okMsg);
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/step_upgrade/process/process_step5.php
centreon/www/install/step_upgrade/process/process_step5.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ session_start(); require_once __DIR__ . '/../../../../bootstrap.php'; require_once '../../steps/functions.php'; use Core\Platform\Application\Repository\WriteUpdateRepositoryInterface; use Core\Platform\Application\UseCase\UpdateVersions\UpdateVersionsException; $kernel = App\Kernel::createForWeb(); $updateWriteRepository = $kernel->getContainer()->get(WriteUpdateRepositoryInterface::class); $parameters = filter_input_array(INPUT_POST); $current = filter_var($_POST['current'] ?? 'step 5', FILTER_SANITIZE_FULL_SPECIAL_CHARS); if ($parameters) { if ((int) $parameters['send_statistics'] === 1) { $query = "INSERT INTO options (`key`, `value`) VALUES ('send_statistics', '1')"; } else { $query = "INSERT INTO options (`key`, `value`) VALUES ('send_statistics', '0')"; } $db = $dependencyInjector['configuration_db']; $db->query("DELETE FROM options WHERE `key` = 'send_statistics'"); $db->query($query); } try { if (! isset($_SESSION['CURRENT_VERSION']) || ! preg_match('/^\d+\.\d+\.\d+/', $_SESSION['CURRENT_VERSION'])) { throw new Exception('Cannot get current version'); } $moduleService = $dependencyInjector[CentreonModule\ServiceProvider::CENTREON_MODULE]; $widgets = $moduleService->getList(null, true, null, ['widget']); foreach ($widgets['widget'] as $widget) { if ($widget->isInternal()) { $moduleService->update($widget->getId(), 'widget'); } } $updateWriteRepository->runPostUpdate($_SESSION['CURRENT_VERSION']); } catch (Throwable $e) { exitUpgradeProcess( 1, $current, '', UpdateVersionsException::errorWhenApplyingPostUpdate($e)->getMessage() ); } session_destroy();
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-19.10.0-beta.1.post.php
centreon/www/install/php/Update-19.10.0-beta.1.post.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); try { // Alter existing tables to conform with strict mode. $pearDBO->query( 'ALTER TABLE `log_action_modification` MODIFY COLUMN `field_value` text NOT NULL' ); // Add the audit log retention column for the retention options menu if (! $pearDBO->isColumnExist('config', 'audit_log_retention')) { $pearDBO->query( 'ALTER TABLE `config` ADD COLUMN audit_log_retention int(11) DEFAULT 0' ); } } catch (PDOException $e) { $centreonLog->insertLog( 2, 'UPGRADE : Unable to process 19.10.0-post-beta 1 upgrade' ); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.10.2.php
centreon/www/install/php/Update-20.10.2.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-21.04.9.php
centreon/www/install/php/Update-21.04.9.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-24.05.0.php
centreon/www/install/php/Update-24.05.0.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ require_once __DIR__ . '/../../../bootstrap.php'; require_once __DIR__ . '/../../class/centreonLog.class.php';
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-22.10.0-beta.2.php
centreon/www/install/php/Update-22.10.0-beta.2.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-19.10.0-beta.1.php
centreon/www/install/php/Update-19.10.0-beta.1.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // update topology of poller wizard to display breadcrumb $pearDB->query( 'UPDATE topology SET topology_parent = 60901, topology_page = 60959, topology_group = 1, topology_show = "0" WHERE topology_url LIKE "/poller-wizard/%"' ); try { $pearDB->query('SET SESSION innodb_strict_mode=OFF'); // Add trap regexp matching if (! $pearDB->isColumnExist('traps', 'traps_mode')) { $pearDB->query( "ALTER TABLE `traps` ADD COLUMN `traps_mode` enum('0','1') DEFAULT '0' AFTER `traps_oid`" ); } } catch (PDOException $e) { $centreonLog->insertLog( 2, 'UPGRADE : 19.10.0-beta.1 Unable to modify regexp matching in the database' ); } finally { $pearDB->query('SET SESSION innodb_strict_mode=ON'); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-22.10.9.php
centreon/www/install/php/Update-22.10.9.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.10.5.php
centreon/www/install/php/Update-20.10.5.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-19.10.0-rc.1.php
centreon/www/install/php/Update-19.10.0-rc.1.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.10.4.php
centreon/www/install/php/Update-20.10.4.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 20.10.4 : '; /** * Queries needing exception management and rollback if failing */ try { $statement = $pearDB->query( "SELECT count(CONSTRAINT_NAME) as nb from information_schema.TABLE_CONSTRAINTS WHERE table_name = 'dependency_hostChild_relation' and constraint_type = 'UNIQUE'" ); if ($statement->fetchColumn() === 0) { $errorMessage = 'Unable to update dependency_hostChild_relation'; $pearDB->query( 'ALTER IGNORE TABLE `dependency_hostChild_relation` ADD UNIQUE (`dependency_dep_id`, `host_host_id`)' ); } $statement = $pearDB->query( "SELECT count(CONSTRAINT_NAME) as nb from information_schema.TABLE_CONSTRAINTS WHERE table_name = 'dependency_hostParent_relation' and constraint_type = 'UNIQUE'" ); if ($statement->fetchColumn() === 0) { $errorMessage = 'Unable to update dependency_hostParent_relation'; $pearDB->query( 'ALTER IGNORE TABLE `dependency_hostParent_relation` ADD UNIQUE (`dependency_dep_id`, `host_host_id`)' ); } $statement = $pearDB->query( "SELECT count(CONSTRAINT_NAME) as nb from information_schema.TABLE_CONSTRAINTS WHERE table_name = 'dependency_hostgroupChild_relation' and constraint_type = 'UNIQUE'" ); if ($statement->fetchColumn() === 0) { $errorMessage = 'Unable to update dependency_hostgroupChild_relation'; $pearDB->query( 'ALTER IGNORE TABLE `dependency_hostgroupChild_relation` ADD UNIQUE (`dependency_dep_id`, `hostgroup_hg_id`)' ); } $statement = $pearDB->query( "SELECT count(CONSTRAINT_NAME) as nb from information_schema.TABLE_CONSTRAINTS WHERE table_name = 'dependency_hostgroupParent_relation' and constraint_type = 'UNIQUE'" ); if ($statement->fetchColumn() === 0) { $errorMessage = 'Unable to update dependency_hostgroupParent_relation'; $pearDB->query( 'ALTER IGNORE TABLE `dependency_hostgroupParent_relation` ADD UNIQUE (`dependency_dep_id`, `hostgroup_hg_id`)' ); } $statement = $pearDB->query( "SELECT count(CONSTRAINT_NAME) as nb from information_schema.TABLE_CONSTRAINTS WHERE table_name = 'dependency_metaserviceChild_relation' and constraint_type = 'UNIQUE'" ); if ($statement->fetchColumn() === 0) { $errorMessage = 'Unable to update dependency_metaserviceChild_relation'; $pearDB->query( 'ALTER IGNORE TABLE `dependency_metaserviceChild_relation` ADD UNIQUE (`dependency_dep_id`, `meta_service_meta_id`)' ); } $statement = $pearDB->query( "SELECT count(CONSTRAINT_NAME) as nb from information_schema.TABLE_CONSTRAINTS WHERE table_name = 'dependency_metaserviceParent_relation' and constraint_type = 'UNIQUE'" ); if ($statement->fetchColumn() === 0) { $errorMessage = 'Unable to update dependency_metaserviceParent_relation'; $pearDB->query( 'ALTER IGNORE TABLE `dependency_metaserviceParent_relation` ADD UNIQUE (`dependency_dep_id`, `meta_service_meta_id`)' ); } $statement = $pearDB->query( "SELECT count(CONSTRAINT_NAME) as nb from information_schema.TABLE_CONSTRAINTS WHERE table_name = 'dependency_serviceChild_relation' and constraint_type = 'UNIQUE'" ); if ($statement->fetchColumn() === 0) { $errorMessage = 'Unable to update dependency_serviceChild_relation'; $pearDB->query( 'ALTER IGNORE TABLE `dependency_serviceChild_relation` ADD UNIQUE (`dependency_dep_id`, `service_service_id`, `host_host_id`)' ); } $statement = $pearDB->query( "SELECT count(CONSTRAINT_NAME) as nb from information_schema.TABLE_CONSTRAINTS WHERE table_name = 'dependency_serviceParent_relation' and constraint_type = 'UNIQUE'" ); if ($statement->fetchColumn() === 0) { $errorMessage = 'Unable to update dependency_serviceParent_relation'; $pearDB->query( 'ALTER IGNORE TABLE `dependency_serviceParent_relation` ADD UNIQUE (`dependency_dep_id`, `service_service_id`, `host_host_id`)' ); } $statement = $pearDB->query( "SELECT count(CONSTRAINT_NAME) as nb from information_schema.TABLE_CONSTRAINTS WHERE table_name = 'dependency_servicegroupChild_relation' and constraint_type = 'UNIQUE'" ); if ($statement->fetchColumn() === 0) { $errorMessage = 'Unable to update dependency_servicegroupChild_relation'; $pearDB->query( 'ALTER IGNORE TABLE `dependency_servicegroupChild_relation` ADD UNIQUE (`dependency_dep_id`, `servicegroup_sg_id`)' ); } $statement = $pearDB->query( "SELECT count(CONSTRAINT_NAME) as nb from information_schema.TABLE_CONSTRAINTS WHERE table_name = 'dependency_servicegroupParent_relation' and constraint_type = 'UNIQUE'" ); if ($statement->fetchColumn() === 0) { $errorMessage = 'Unable to update dependency_servicegroupParent_relation'; $pearDB->query( 'ALTER IGNORE TABLE `dependency_servicegroupParent_relation` ADD UNIQUE (`dependency_dep_id`, `servicegroup_sg_id`)' ); } // engine postpone if (! $pearDB->isColumnExist('cfg_nagios', 'postpone_notification_to_timeperiod')) { // An update is required $errorMessage = 'Impossible to alter the table cfg_nagios with postpone_notification_to_timeperiod'; $pearDB->query( 'ALTER TABLE `cfg_nagios` ADD COLUMN `postpone_notification_to_timeperiod` boolean DEFAULT false AFTER `nagios_group`' ); } // engine heartbeat interval if (! $pearDB->isColumnExist('cfg_nagios', 'instance_heartbeat_interval')) { // An update is required $errorMessage = 'Impossible to alter the table cfg_nagios with instance_heartbeat_interval'; $pearDB->query( 'ALTER TABLE `cfg_nagios` ADD COLUMN `instance_heartbeat_interval` smallint DEFAULT 30 AFTER `date_format`' ); } $errorMessage = ''; } catch (Exception $e) { $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.04.6.php
centreon/www/install/php/Update-20.04.6.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-2.8.19.php
centreon/www/install/php/Update-2.8.19.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ // Update index of centreon_acl if (isset($pearDBO)) { $query = 'SELECT count(*) AS number ' . 'FROM INFORMATION_SCHEMA.STATISTICS ' . "WHERE table_schema = '" . $conf_centreon['dbcstg'] . "' " . "AND table_name = 'centreon_acl' " . "AND index_name='index2'"; $res = $pearDBO->query($query); $data = $res->fetchRow(); if ($data['number'] == 0) { $pearDBO->query('ALTER TABLE centreon_acl ADD INDEX `index2` (`host_id`,`service_id`,`group_id`)'); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-22.10.12.php
centreon/www/install/php/Update-22.10.12.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-21.04.0-beta.2.php
centreon/www/install/php/Update-21.04.0-beta.2.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.04.8.php
centreon/www/install/php/Update-20.04.8.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-18.10.5.php
centreon/www/install/php/Update-18.10.5.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.10.18.php
centreon/www/install/php/Update-20.10.18.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.10.12.php
centreon/www/install/php/Update-20.10.12.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 20.10.12: '; $pearDB = new CentreonDB('centreon', 3, false); /** * Query with transaction */ try { $pearDB->beginTransaction(); // Purge all session. $errorMessage = 'Impossible to purge the table session'; $pearDB->query('DELETE FROM `session`'); $errorMessage = 'Impossible to purge the table ws_token'; $pearDB->query('DELETE FROM `ws_token`'); $constraintStatement = $pearDB->query( "SELECT COUNT(*) as count FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_NAME='session_ibfk_1'" ); if (($constraint = $constraintStatement->fetch()) && (int) $constraint['count'] === 0) { $errorMessage = 'Impossible to add Delete Cascade constraint on the table session'; $pearDB->query( 'ALTER TABLE `session` ADD CONSTRAINT `session_ibfk_1` FOREIGN KEY (`user_id`) ' . 'REFERENCES `contact` (`contact_id`) ON DELETE CASCADE' ); } $errorMessage = "Impossible to drop column 'contact_platform_data_sending' from 'contact' table"; $pearDB->query('ALTER TABLE `contact` DROP IF EXISTS COLUMN `contact_platform_data_sending`'); $pearDB->commit(); } catch (Exception $e) { $pearDB->rollBack(); $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-21.04.0-beta.1.php
centreon/www/install/php/Update-21.04.0-beta.1.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 21.04.0-beta.1: '; $criteriasConcordanceArray = [ 'states' => [ 'acknowledged' => 'Acknowledged', 'in_downtime' => 'In downtime', 'unhandled_problems' => 'Unhandled', ], 'resource_types' => [ 'host' => 'Host', 'service' => 'Service', ], 'statuses' => [ 'OK' => 'Ok', 'UP' => 'Up', 'WARNING' => 'Warning', 'DOWN' => 'Down', 'CRITICAL' => 'Critical', 'UNREACHABLE' => 'Unreachable', 'UNKNOWN' => 'Unknown', 'PENDING' => 'Pending', ], ]; /** * Query without transaction */ try { if (! $pearDB->isColumnExist('cfg_centreonbroker', 'log_directory')) { // An update is required $errorMessage = 'Impossible to alter the table cfg_centreonbroker with log_directory'; $pearDB->query( 'ALTER TABLE `cfg_centreonbroker` ADD COLUMN `log_directory` VARCHAR(255) AFTER `config_write_thread_id`' ); } if (! $pearDB->isColumnExist('cfg_centreonbroker', 'log_filename')) { // An update is required $errorMessage = 'Impossible to alter the table cfg_centreonbroker with log_filename'; $pearDB->query( 'ALTER TABLE `cfg_centreonbroker` ADD COLUMN `log_filename` VARCHAR(255) AFTER `log_directory`' ); } if (! $pearDB->isColumnExist('cfg_centreonbroker', 'log_max_size')) { // An update is required $errorMessage = 'Impossible to alter the table cfg_centreonbroker with log_max_size'; $pearDB->query( 'ALTER TABLE `cfg_centreonbroker` ADD COLUMN `log_max_size` INT(11) NOT NULL DEFAULT 0 AFTER `log_filename`' ); } $errorMessage = 'Impossible to create the table cb_log'; $pearDB->query( 'CREATE TABLE IF NOT EXISTS `cb_log` (`id` INT PRIMARY KEY NOT NULL AUTO_INCREMENT,`name` varchar(255) NOT NULL)' ); $errorMessage = 'Impossible to create the table cb_log_level'; $pearDB->query( 'CREATE TABLE IF NOT EXISTS `cb_log_level` (`id` INT PRIMARY KEY NOT NULL AUTO_INCREMENT,`name` varchar(255) NOT NULL)' ); $errorMessage = 'Impossible to create the table cfg_centreonbroker_log'; $pearDB->query( 'CREATE TABLE IF NOT EXISTS `cfg_centreonbroker_log` (`id` INT PRIMARY KEY NOT NULL AUTO_INCREMENT, `id_centreonbroker` INT(11) NOT NULL, `id_log` INT(11) NOT NULL, `id_level` INT(11) NOT NULL)' ); if ($pearDB->isColumnExist('cfg_nagios', 'use_aggressive_host_checking')) { // An update is required $errorMessage = 'Impossible to drop column use_aggressive_host_checking from cfg_nagios'; $pearDB->query('ALTER TABLE `cfg_nagios` DROP COLUMN `use_aggressive_host_checking`'); } $errorMessage = ''; } catch (Exception $e) { $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); } /** * Query with transaction */ try { $pearDB->beginTransaction(); /** * Retrieve user filters */ $statement = $pearDB->query( 'SELECT `id`, `criterias` FROM `user_filter`' ); $translatedFilters = []; while ($filter = $statement->fetch()) { $id = $filter['id']; $decodedCriterias = json_decode($filter['criterias'], true); // Adding the default sorting in the criterias foreach ($decodedCriterias as $criteriaKey => $criteria) { $name = $criteria['name']; // Checking if the filter contains criterias we want to migrate if (array_key_exists($name, $criteriasConcordanceArray) === true) { foreach ($criteria['value'] as $index => $value) { $decodedCriterias[$criteriaKey]['value'][$index]['name'] = $criteriasConcordanceArray[$name][$value['id']]; } } } $decodedCriterias[] = [ 'name' => 'sort', 'type' => 'array', 'value' => [ 'status_severity_code' => 'asc', ], ]; $translatedFilters[$id] = json_encode($decodedCriterias); } /** * UPDATE SQL request on the filters */ foreach ($translatedFilters as $id => $criterias) { $errorMessage = 'Unable to update filter values in user_filter table.'; $statement = $pearDB->prepare( 'UPDATE `user_filter` SET `criterias` = :criterias WHERE `id` = :id' ); $statement->bindValue(':id', (int) $id, PDO::PARAM_INT); $statement->bindValue(':criterias', $criterias, PDO::PARAM_STR); $statement->execute(); } // queries for broker logs $errorMessage = 'Unable to Update cfg_centreonbroker'; $pearDB->query( "UPDATE `cfg_centreonbroker` SET `log_directory` = '/var/log/centreon-broker/'" ); $errorMessage = 'Unable to set cb_log'; $pearDB->query( "INSERT INTO `cb_log` (`name`) VALUES ('core'), ('config'), ('sql'), ('processing'), ('perfdata'), ('bbdo'), ('tcp'), ('tls'), ('lua'), ('bam')" ); $errorMessage = 'Unable to set cb_log_level'; $pearDB->query( "INSERT INTO `cb_log_level` (`name`) VALUES ('disabled'), ('critical'), ('error'), ('warning'), ('info'), ('debug'), ('trace')" ); $stmt = $pearDB->query( 'SELECT config_id FROM cfg_centreonbroker' ); $statement = $pearDB->prepare( 'INSERT INTO `cfg_centreonbroker_log` (`id_centreonbroker`, `id_log`, `id_level`) VALUES (:id_centreonbroker,1,5), (:id_centreonbroker,2,3), (:id_centreonbroker,3,3), (:id_centreonbroker,4,3), (:id_centreonbroker,5,3), (:id_centreonbroker,6,3), (:id_centreonbroker,7,3), (:id_centreonbroker,8,3), (:id_centreonbroker,9,3), (:id_centreonbroker,10,3)' ); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $statement->bindValue(':id_centreonbroker', (int) $row['config_id'], PDO::PARAM_INT); $statement->execute(); } $pearDB->commit(); } catch (Exception $e) { $pearDB->rollBack(); $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-25.07.2.php
centreon/www/install/php/Update-25.07.2.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-24.10.3.php
centreon/www/install/php/Update-24.10.3.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ require_once __DIR__ . '/../../../bootstrap.php'; require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 24.10.3: '; $errorMessage = ''; $createDashboardThumbnailTable = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to add table dashboard_thumbnail_relation'; $pearDB->executeQuery( <<<'SQL' CREATE TABLE IF NOT EXISTS `dashboard_thumbnail_relation` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `dashboard_id` INT UNSIGNED NOT NULL, `img_id` int(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `dashboard_thumbnail_relation_unique` (`dashboard_id`,`img_id`), CONSTRAINT `dashboard_thumbnail_relation_dashboard_id` FOREIGN KEY (`dashboard_id`) REFERENCES `dashboard` (`id`) ON DELETE CASCADE, CONSTRAINT `dashboard_thumbnail_relation_img_id` FOREIGN KEY (`img_id`) REFERENCES `view_img` (`img_id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 SQL ); }; // Agent Configuration $createAgentConfiguration = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to create agent_configuration table'; $pearDB->executeQuery( <<<'SQL' CREATE TABLE IF NOT EXISTS `agent_configuration` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `type` enum('telegraf', 'centreon-agent') NOT NULL, `name` varchar(255) NOT NULL, `configuration` JSON NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name_unique` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 SQL ); $errorMessage = 'Unable to create ac_poller_relation table'; $pearDB->executeQuery( <<<'SQL' CREATE TABLE IF NOT EXISTS `ac_poller_relation` ( `ac_id` INT UNSIGNED NOT NULL, `poller_id` INT(11) NOT NULL, UNIQUE KEY `rel_unique` (`ac_id`, `poller_id`), CONSTRAINT `ac_id_contraint` FOREIGN KEY (`ac_id`) REFERENCES `agent_configuration` (`id`) ON DELETE CASCADE, CONSTRAINT `ac_poller_id_contraint` FOREIGN KEY (`poller_id`) REFERENCES `nagios_server` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 SQL ); }; $insertAgentConfigurationTopology = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to retrieve data from topology table'; $statement = $pearDB->executeQuery( <<<'SQL' SELECT 1 FROM `topology` WHERE `topology_name` = 'Agent configurations' SQL ); $topologyAlreadyExists = (bool) $statement->fetch(PDO::FETCH_COLUMN); $errorMessage = 'Unable to retrieve data from informations table'; $statement = $pearDB->executeQuery( <<<'SQL' SELECT `value` FROM `informations` WHERE `key` = 'isCentral' SQL ); $isCentral = $statement->fetch(PDO::FETCH_COLUMN); $errorMessage = 'Unable to insert data into table topology'; if ($topologyAlreadyExists === false) { $constraintStatement = $pearDB->prepareQuery( <<<'SQL' INSERT INTO `topology` (`topology_name`, `topology_parent`, `topology_page`, `topology_order`, `topology_group`, `topology_url`, `topology_show`, `is_react`) VALUES ('Agent configurations',609,60905,50,1,'/configuration/pollers/agent-configurations', :show, '1'); SQL ); $pearDB->executePreparedQuery($constraintStatement, [':show' => $isCentral === 'yes' ? '1' : '0']); } }; /** * Updates the display name and description for the connections_count field in the cb_field table. * * @param CentreonDB $pearDB * * @throws Exception */ $updateConnectionsCountDescription = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to update description in cb_field table'; $pearDB->executeQuery( <<<'SQL' UPDATE `cb_field` SET `displayname` = "Number of connections to the database", `description` = "1: all queries are sent through one connection\n 2: one connection for data_bin and logs, one for the rest\n 3: one connection for data_bin, one for logs, one for the rest" WHERE `fieldname` = "connections_count" SQL ); }; // ACC $fixNamingOfAccTopology = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to update table topology'; $constraintStatement = $pearDB->executeQuery( <<<'SQL' UPDATE `topology` SET `topology_name` = 'Additional connector configurations' WHERE `topology_url` = '/configuration/additional-connector-configurations' SQL ); }; try { $createAgentConfiguration($pearDB); $createDashboardThumbnailTable($pearDB); // Transactional queries if (! $pearDB->inTransaction()) { $pearDB->beginTransaction(); } $insertAgentConfigurationTopology($pearDB); $updateConnectionsCountDescription($pearDB); $fixNamingOfAccTopology($pearDB); $pearDB->commit(); } catch (Exception $e) { if ($pearDB->inTransaction()) { try { $pearDB->rollBack(); } catch (PDOException $e) { CentreonLog::create()->error( logTypeId: CentreonLog::TYPE_UPGRADE, message: "{$versionOfTheUpgrade} error while rolling back the upgrade operation", customContext: ['error_message' => $e->getMessage(), 'trace' => $e->getTraceAsString()], exception: $e ); } } CentreonLog::create()->error( logTypeId: CentreonLog::TYPE_UPGRADE, message: $versionOfTheUpgrade . $errorMessage, customContext: ['error_message' => $e->getMessage(), 'trace' => $e->getTraceAsString()], exception: $e ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-22.04.3.php
centreon/www/install/php/Update-22.04.3.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.10.17.php
centreon/www/install/php/Update-20.10.17.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-21.04.15.php
centreon/www/install/php/Update-21.04.15.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-22.04.2.php
centreon/www/install/php/Update-22.04.2.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 22.04.2: '; $errorMessage = ''; try { $pearDB->beginTransaction(); $errorMessage = "Unable to delete 'appKey' information from database"; $pearDB->query("DELETE FROM `informations` WHERE `key` = 'appKey'"); $pearDB->commit(); } catch (Exception $e) { if ($pearDB->inTransaction()) { $pearDB->rollBack(); } $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-22.10.1.php
centreon/www/install/php/Update-22.10.1.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-21.04.12.php
centreon/www/install/php/Update-21.04.12.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-19.10.0-beta.3.php
centreon/www/install/php/Update-19.10.0-beta.3.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); /** * LDAP auto or manual synchronization feature */ try { $pearDB->query('SET SESSION innodb_strict_mode=OFF'); // Adding two columns to check last user's LDAP sync timestamp if (! $pearDB->isColumnExist('contact', 'contact_ldap_last_sync')) { // $pearDB = "centreon" // $pearDBO = "realtime" $pearDB->query( 'ALTER TABLE `contact` ADD COLUMN `contact_ldap_last_sync` INT(11) NOT NULL DEFAULT 0' ); } if (! $pearDB->isColumnExist('contact', 'contact_ldap_required_sync')) { $pearDB->query( "ALTER TABLE `contact` ADD COLUMN `contact_ldap_required_sync` enum('0','1') NOT NULL DEFAULT '0'" ); } // Adding a column to check last specific LDAP sync timestamp $needToUpdateValues = false; if (! $pearDB->isColumnExist('auth_ressource', 'ar_sync_base_date')) { $pearDB->query( 'ALTER TABLE `auth_ressource` ADD COLUMN `ar_sync_base_date` INT(11) DEFAULT 0' ); $needToUpdateValues = true; } } catch (PDOException $e) { $centreonLog->insertLog( 2, "UPGRADE : 19.10.0-beta.3 Unable to add LDAP new feature's tables in the database" ); } finally { $pearDB->query('SET SESSION innodb_strict_mode=ON'); } // Initializing reference synchronization time for all LDAP configurations */ if ($needToUpdateValues) { try { $stmt = $pearDB->prepare( 'UPDATE `auth_ressource` SET `ar_sync_base_date` = :minusTime' ); $stmt->bindValue(':minusTime', time(), PDO::PARAM_INT); $stmt->execute(); } catch (PDOException $e) { $centreonLog->insertLog( 2, 'UPGRADE : 19.10.0-beta.3 Unable to initialize LDAP reference date' ); } // Adding to each LDAP configuration two new fields try { // field to enable the automatic sync at login $addSyncStateField = $pearDB->prepare( "INSERT IGNORE INTO auth_ressource_info (`ar_id`, `ari_name`, `ari_value`) VALUES (:arId, 'ldap_auto_sync', '1')" ); // interval between two sync at login $addSyncIntervalField = $pearDB->prepare( "INSERT IGNORE INTO auth_ressource_info (`ar_id`, `ari_name`, `ari_value`) VALUES (:arId, 'ldap_sync_interval', '1')" ); $pearDB->beginTransaction(); $stmt = $pearDB->query('SELECT DISTINCT(ar_id) FROM auth_ressource'); while ($row = $stmt->fetch()) { $addSyncIntervalField->bindValue(':arId', $row['ar_id'], PDO::PARAM_INT); $addSyncIntervalField->execute(); $addSyncStateField->bindValue(':arId', $row['ar_id'], PDO::PARAM_INT); $addSyncStateField->execute(); } $pearDB->commit(); } catch (PDOException $e) { $centreonLog->insertLog( 1, // ldap.log 'UPGRADE PROCESS : Error - Please open your LDAP configuration and save manually each LDAP form' ); $centreonLog->insertLog( 2, // sql-error.log 'UPGRADE : 19.10.0-beta.3 Unable to add LDAP new fields' ); $pearDB->rollBack(); } } // update topology of poller wizard to display breadcrumb $pearDB->query( 'UPDATE topology SET topology_parent = 60901, topology_page = 60959, topology_group = 1, topology_show = "0" WHERE topology_url LIKE "/poller-wizard/%"' ); try { // Add trap regexp matching if (! $pearDB->isColumnExist('traps', 'traps_mode')) { $pearDB->query('SET SESSION innodb_strict_mode=OFF'); $pearDB->query( "ALTER TABLE `traps` ADD COLUMN `traps_mode` enum('0','1') DEFAULT '0' AFTER `traps_oid`" ); } } catch (PDOException $e) { $centreonLog->insertLog( 2, 'UPGRADE : 19.10.0-beta.3 Unable to modify regexp matching in the database' ); } finally { $pearDB->query('SET SESSION innodb_strict_mode=ON'); } /** * Add columns to manage engine & broker restart/reload process */ try { $pearDB->query('SET SESSION innodb_strict_mode=OFF'); $pearDB->query(' ALTER TABLE `nagios_server` ADD COLUMN `engine_start_command` varchar(255) DEFAULT \'service centengine start\' AFTER `monitoring_engine` '); $pearDB->query(' ALTER TABLE `nagios_server` ADD COLUMN `engine_stop_command` varchar(255) DEFAULT \'service centengine stop\' AFTER `engine_start_command` '); $pearDB->query(' ALTER TABLE `nagios_server` ADD COLUMN `engine_restart_command` varchar(255) DEFAULT \'service centengine restart\' AFTER `engine_stop_command` '); $pearDB->query(' ALTER TABLE `nagios_server` ADD COLUMN `engine_reload_command` varchar(255) DEFAULT \'service centengine reload\' AFTER `engine_restart_command` '); $pearDB->query(' ALTER TABLE `nagios_server` ADD COLUMN `broker_reload_command` varchar(255) DEFAULT \'service cbd reload\' AFTER `nagios_perfdata` '); } catch (PDOException $e) { $centreonLog->insertLog( 2, 'UPGRADE : 19.10.0-beta.3 Unable to manage engine & broker restart and reload processes' ); } finally { $pearDB->query('SET SESSION innodb_strict_mode=ON'); } $stmt = $pearDB->prepare(' UPDATE `nagios_server` SET engine_start_command = :engine_start_command, engine_stop_command = :engine_stop_command, engine_restart_command = :engine_restart_command, engine_reload_command = :engine_reload_command, broker_reload_command = :broker_reload_command WHERE id = :id '); $result = $pearDB->query('SELECT value FROM `options` WHERE `key` = \'broker_correlator_script\''); $brokerServiceName = 'cbd'; if ($row = $result->fetch()) { if (! empty($row['value'])) { $brokerServiceName = $row['value']; } } $stmt->bindValue(':broker_reload_command', 'service ' . $brokerServiceName . ' reload', PDO::PARAM_STR); $result = $pearDB->query('SELECT id, init_script FROM `nagios_server`'); while ($row = $result->fetch()) { $engineServiceName = 'centengine'; if (! empty($row['init_script'])) { $engineServiceName = $row['init_script']; } $stmt->bindValue(':id', $row['id'], PDO::PARAM_INT); $stmt->bindValue(':engine_start_command', 'service ' . $engineServiceName . ' start', PDO::PARAM_STR); $stmt->bindValue(':engine_stop_command', 'service ' . $engineServiceName . ' stop', PDO::PARAM_STR); $stmt->bindValue(':engine_restart_command', 'service ' . $engineServiceName . ' restart', PDO::PARAM_STR); $stmt->bindValue(':engine_reload_command', 'service ' . $engineServiceName . ' reload', PDO::PARAM_STR); $stmt->execute(); } // Remove deprecated engine & broker init script paths $pearDB->query('ALTER TABLE `nagios_server` DROP COLUMN `init_script`'); $pearDB->query('ALTER TABLE `nagios_server` DROP COLUMN `init_system`'); $pearDB->query('ALTER TABLE `nagios_server` DROP COLUMN `monitoring_engine`'); $pearDB->query('DELETE FROM `options` WHERE `key` = \'broker_correlator_script\''); $pearDB->query('DELETE FROM `options` WHERE `key` = \'monitoring_engine\''); /** * Manage upgrade of widget preferences */ // set cache for pollers $pollers = []; $result = $pearDB->query('SELECT id, name FROM nagios_server'); while ($row = $result->fetch()) { $pollerName = strtolower($row['name']); $pollers[$pollerName] = $row['id']; } // get poller preferences of engine-status widget $result = $pearDB->query( 'SELECT wpr.widget_view_id, wpr.parameter_id, wpr.preference_value, wpr.user_id FROM widget_preferences wpr INNER JOIN widget_parameters wpa ON wpa.parameter_id = wpr.parameter_id AND wpa.parameter_code_name = \'poller\' INNER JOIN widget_models wm ON wm.widget_model_id = wpa.widget_model_id AND wm.title = \'Engine-Status\'' ); $statement = $pearDB->prepare( 'UPDATE widget_preferences SET preference_value= :value WHERE widget_view_id = :view_id AND parameter_id = :parameter_id AND user_id = :user_id' ); // update poller preferences from name to id while ($row = $result->fetch()) { $pollerName = strtolower($row['preference_value']); $pollerId = $pollers[$pollerName] ?? ''; $statement->bindValue(':value', $pollerId, PDO::PARAM_STR); $statement->bindValue(':view_id', $row['widget_view_id'], PDO::PARAM_INT); $statement->bindValue(':parameter_id', $row['parameter_id'], PDO::PARAM_INT); $statement->bindValue(':user_id', $row['user_id'], PDO::PARAM_INT); $statement->execute(); } // set cache for severities $severities = []; $result = $pearDB->query('SELECT sc_id, sc_name FROM service_categories WHERE level IS NOT NULL'); while ($row = $result->fetch()) { $severityName = strtolower($row['sc_name']); $severities[$severityName] = $row['sc_id']; } // get poller preferences (criticality_filter) of service-monitoring widget $result = $pearDB->query( 'SELECT wpr.widget_view_id, wpr.parameter_id, wpr.preference_value, wpr.user_id FROM widget_preferences wpr INNER JOIN widget_parameters wpa ON wpa.parameter_id = wpr.parameter_id AND wpa.parameter_code_name = \'criticality_filter\' INNER JOIN widget_models wm ON wm.widget_model_id = wpa.widget_model_id AND wm.title = \'Service Monitoring\'' ); $statement = $pearDB->prepare( 'UPDATE widget_preferences SET preference_value= :value WHERE widget_view_id = :view_id AND parameter_id = :parameter_id AND user_id = :user_id' ); // update poller preferences from name to id while ($row = $result->fetch()) { $severityIds = []; $severityNames = explode(',', $row['preference_value']); foreach ($severityNames as $severityName) { $severityName = strtolower($severityName); if (isset($severities[$severityName])) { $severityIds[] = $severities[$severityName]; } } $severityIds = $severityIds !== [] ? implode(',', $severityIds) : ''; $statement->bindValue(':value', $severityIds, PDO::PARAM_STR); $statement->bindValue(':view_id', $row['widget_view_id'], PDO::PARAM_INT); $statement->bindValue(':parameter_id', $row['parameter_id'], PDO::PARAM_INT); $statement->bindValue(':user_id', $row['user_id'], PDO::PARAM_INT); $statement->execute(); } // manage rrdcached upgrade $result = $pearDB->query("SELECT `value` FROM options WHERE `key` = 'rrdcached_enable' "); $cache = $result->fetch(); if ($cache['value']) { try { $pearDB->beginTransaction(); $res = $pearDB->query( "SELECT * FROM cfg_centreonbroker_info WHERE `config_key` = 'type' AND `config_value` = 'rrd'" ); $result = $pearDB->query("SELECT `value` FROM options WHERE `key` = 'rrdcached_port' "); $port = $result->fetch(); while ($row = $res->fetch()) { if ($port['value']) { $brokerInfoData = [ [ 'config_id' => $row['config_id'], 'config_key' => 'rrd_cached_option', 'config_value' => 'tcp', 'config_group' => $row['config_group'], 'config_group_id' => $row['config_group_id'], ], [ 'config_id' => $row['config_id'], 'config_key' => 'rrd_cached', 'config_value' => $port['value'], 'config_group' => $row['config_group'], 'config_group_id' => $row['config_group_id'], ], ]; $query = 'INSERT INTO cfg_centreonbroker_info (config_id, config_key, config_value, ' . 'config_group, config_group_id ) VALUES ' . '( :config_id, :config_key, :config_value, ' . ':config_group, :config_group_id)'; $statement = $pearDB->prepare($query); foreach ($brokerInfoData as $dataRow) { $statement->bindValue(':config_id', (int) $dataRow['config_id'], PDO::PARAM_INT); $statement->bindValue(':config_key', $dataRow['config_key']); $statement->bindValue(':config_value', $dataRow['config_value']); $statement->bindValue(':config_group', $dataRow['config_group']); $statement->bindValue(':config_group_id', (int) $dataRow['config_group_id'], PDO::PARAM_INT); $statement->execute(); } } else { $result = $pearDB->query("SELECT `value` FROM options WHERE `key` = 'rrdcached_unix_path' "); $path = $result->fetch(); $brokerInfoData = [ [ 'config_id' => $row['config_id'], 'config_key' => 'rrd_cached_option', 'config_value' => 'unix', 'config_group' => $row['config_group'], 'config_group_id' => $row['config_group_id'], ], [ 'config_id' => $row['config_id'], 'config_key' => 'rrd_cached', 'config_value' => $path['value'], 'config_group' => $row['config_group'], 'config_group_id' => $row['config_group_id'], ], ]; $query = 'INSERT INTO cfg_centreonbroker_info (config_id, config_key, config_value, ' . 'config_group, config_group_id ) VALUES ' . '( :config_id, :config_key, :config_value, ' . ':config_group, :config_group_id)'; $statement = $pearDB->prepare($query); foreach ($brokerInfoData as $rowData) { $statement->bindValue(':config_id', (int) $rowData['config_id'], PDO::PARAM_INT); $statement->bindValue(':config_key', $rowData['config_key']); $statement->bindValue(':config_value', $rowData['config_value']); $statement->bindValue(':config_group', $rowData['config_group']); $statement->bindValue(':config_group_id', (int) $rowData['config_group_id'], PDO::PARAM_INT); $statement->execute(); } } $statement = $pearDB->prepare( 'DELETE FROM cfg_centreonbroker_info WHERE `config_id` = :config_id' . ' AND config_group_id = :config_group_id' . " AND config_group = 'output' AND ( config_key = 'port' OR config_key = 'path') " ); $statement->bindValue(':config_id', (int) $row['config_id'], PDO::PARAM_INT); $statement->bindValue(':config_group_id', (int) $row['config_group_id'], PDO::PARAM_INT); $statement->execute(); } $pearDB->query( "DELETE FROM options WHERE `key` = 'rrdcached_enable' OR `key` = 'rrdcached_port' OR `key` = 'rrdcached_unix_path'" ); $pearDB->commit(); } catch (PDOException $e) { $centreonLog->insertLog( 2, // sql-error.log 'UPGRADE : 19.10.0-beta.3 Unable to move rrd global cache option on broker form' ); $pearDB->rollBack(); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-24.10.2.php
centreon/www/install/php/Update-24.10.2.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-23.10.6.php
centreon/www/install/php/Update-23.10.6.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-22.04.8.php
centreon/www/install/php/Update-22.04.8.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 22.04.8: '; /** * Update illegal_object_name_chars + illegal_macro_output_chars fields from cf_nagios table. * The aim is to decode entities from them. * * @param CentreonDB $pearDB */ $decodeIllegalCharactersNagios = function (CentreonDB $pearDB): void { $configs = $pearDB->query( <<<'SQL' SELECT nagios_id, illegal_object_name_chars, illegal_macro_output_chars FROM `cfg_nagios` SQL )->fetchAll(PDO::FETCH_ASSOC); $statement = $pearDB->prepare( <<<'SQL' UPDATE `cfg_nagios` SET illegal_object_name_chars = :illegal_object_name_chars, illegal_macro_output_chars = :illegal_macro_output_chars WHERE nagios_id = :nagios_id SQL ); foreach ($configs as $config) { $modified = $config; $modified['illegal_object_name_chars'] = html_entity_decode($config['illegal_object_name_chars']); $modified['illegal_macro_output_chars'] = html_entity_decode($config['illegal_macro_output_chars']); if ($config === $modified) { // no need to update, we skip a useless query continue; } $statement->bindValue(':illegal_object_name_chars', $modified['illegal_object_name_chars'], PDO::PARAM_STR); $statement->bindValue(':illegal_macro_output_chars', $modified['illegal_macro_output_chars'], PDO::PARAM_STR); $statement->bindValue(':nagios_id', $modified['nagios_id'], PDO::PARAM_INT); $statement->execute(); } }; try { if ($pearDB->isColumnExist('remote_servers', 'app_key') === 1) { $errorMessage = 'Unable to remove app_key column'; $pearDB->query('ALTER TABLE `remote_servers` DROP COLUMN `app_key`'); } // Transactional queries $pearDB->beginTransaction(); $errorMessage = 'Impossible to delete color picker topology_js entries'; $pearDB->query( "DELETE FROM `topology_JS` WHERE `PathName_js` = './include/common/javascript/color_picker_mb.js'" ); $errorMessage = 'Unable to update illegal characters fields from engine configuration of pollers'; $decodeIllegalCharactersNagios($pearDB); $pearDB->commit(); } catch (Exception $e) { if ($pearDB->inTransaction()) { $pearDB->rollBack(); } $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-21.04.11.php
centreon/www/install/php/Update-21.04.11.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 21.04.11: '; /** * Query with transaction */ try { $errorMessage = 'Unable to delete logger entry in cb_tag'; $statement = $pearDB->query("DELETE FROM cb_tag WHERE tagname = 'logger'"); } catch (Exception $e) { $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-25.05.0.php
centreon/www/install/php/Update-25.05.0.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ use Adaptation\Database\Connection\Collection\QueryParameters; use Adaptation\Database\Connection\ValueObject\QueryParameter; require_once __DIR__ . '/../../../bootstrap.php'; /** * This file contains changes to be included in the next version. * The actual version number should be added in the variable $version. */ $version = '25.05.0'; $errorMessage = ''; // -------------------------------------------- Host Group Configuration -------------------------------------------- // /** * Update topology for host group configuration pages. * * @param CentreonDB $pearDB * * @throws CentreonDbException */ $updateTopologyForHostGroup = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to retrieve data from topology table'; $statement = $pearDB->executeQuery( <<<'SQL' SELECT 1 FROM `topology` WHERE `topology_name` = 'Host Groups' AND `topology_page` = 60105 SQL ); $topologyAlreadyExists = (bool) $statement->fetch(PDO::FETCH_COLUMN); if (! $topologyAlreadyExists) { $errorMessage = 'Unable to insert new host group configuration topology'; $pearDB->executeQuery( <<<'SQL' INSERT INTO `topology` (`topology_name`,`topology_url`,`readonly`,`is_react`,`topology_parent`,`topology_page`,`topology_order`,`topology_group`,`topology_show`) VALUES ('Host Groups', '/configuration/hosts/groups', '1', '1', 601, 60105,21,1,'1') SQL ); } $errorMessage = 'Unable to update old host group configuration topology'; $pearDB->executeQuery( <<<'SQL' UPDATE `topology` SET `is_react` = '1', `topology_url` = '/configuration/hosts/groups' WHERE `topology_name` = 'Host Groups' AND `topology_page` = 60102 SQL ); }; $updateSamlProviderConfiguration = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to retrieve SAML provider configuration'; $samlConfiguration = $pearDB->fetchAssociative( <<<'SQL' SELECT * FROM `provider_configuration` WHERE `type` = 'saml' SQL ); if (! $samlConfiguration || ! isset($samlConfiguration['custom_configuration'])) { throw new Exception('SAML configuration is missing'); } $customConfiguration = json_decode($samlConfiguration['custom_configuration'], true, JSON_THROW_ON_ERROR); if (! isset($customConfiguration['requested_authn_context'])) { $customConfiguration['requested_authn_context'] = 'minimum'; $query = <<<'SQL' UPDATE `provider_configuration` SET `custom_configuration` = :custom_configuration WHERE `type` = 'saml' SQL; $queryParameters = QueryParameters::create( [ QueryParameter::string( 'custom_configuration', json_encode($customConfiguration, JSON_THROW_ON_ERROR) ), ] ); $pearDB->update($query, $queryParameters); } }; $sunsetHostGroupFields = function () use ($pearDB, &$errorMessage): void { $errorMessage = 'Unable to update hostgroup table'; $pearDB->executeQuery( <<<'SQL' ALTER TABLE `hostgroup` DROP COLUMN `hg_notes`, DROP COLUMN `hg_notes_url`, DROP COLUMN `hg_action_url`, DROP COLUMN `hg_map_icon_image`, DROP COLUMN `hg_rrd_retention` SQL ); }; // -------------------------------------------- Agent Configuration -------------------------------------------- // /** * Add prefix "/etc/pki/" and extensions (.crt, .key) to certificate and key paths in agent_configuration table. * * @param CentreonDB $pearDB * * @throws CentreonDbException * * @return void */ $updateAgentConfiguration = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to retrieve data from agent_configuration table'; $statement = $pearDB->executeQuery( <<<'SQL' SELECT `id`, `configuration` FROM `agent_configuration` SQL ); $errorMessage = 'Unable to update agent_configuration table'; $updates = []; while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { $config = json_decode($row['configuration'], true); if (! is_array($config)) { continue; } foreach ($config as $key => $value) { if (str_ends_with($key, '_certificate') && is_string($value)) { $filename = str_starts_with($value, '/etc/pki/') ? substr($value, 9) : ltrim($value, '/'); $filename = preg_replace('/(\.crt|\.cer)$/', '', $filename); $config[$key] = '/etc/pki/' . ltrim($filename, '/') . '.crt'; } elseif (str_ends_with($key, '_key') && is_string($value)) { $filename = str_starts_with($value, '/etc/pki/') ? substr($value, 9) : ltrim($value, '/'); $filename = preg_replace('/\.key$/', '', $filename); $config[$key] = '/etc/pki/' . ltrim($filename, '/') . '.key'; } if ($key === 'hosts') { foreach ($value as $index => $host) { if (! is_array($host)) { continue; } if (isset($host['poller_ca_certificate']) && is_string($host['poller_ca_certificate'])) { $config[$key][$index]['poller_ca_certificate'] = '/etc/pki/' . ltrim($host['poller_ca_certificate'], '/') . '.crt'; } } } } $updatedConfig = json_encode($config); $updates[] = [ 'id' => $row['id'], 'configuration' => $updatedConfig, ]; } if ($updates !== []) { $query = 'UPDATE `agent_configuration` SET `configuration` = CASE `id` '; $params = []; $whereParams = []; foreach ($updates as $index => $update) { $idParam = ":case_id{$index}"; $configParam = ":case_config{$index}"; $query .= "WHEN {$idParam} THEN {$configParam} "; $params[$idParam] = $update['id']; $params[$configParam] = $update['configuration']; $whereParams[] = ":where_id{$index}"; $params[":where_id{$index}"] = $update['id']; } $query .= 'END WHERE `id` IN (' . implode(', ', $whereParams) . ')'; $statement = $pearDB->prepareQuery($query); $pearDB->executePreparedQuery($statement, $params); } }; /** * Add Column connection_mode to agent_configuration table. * This Column is used to define the connection mode of the agent between ("no-tls","tls","secure","insecure"). * * @param CentreonDB $pearDB * * @throws CentreonDbException */ $addConnectionModeColumnToAgentConfiguration = function () use ($pearDB, &$errorMessage): void { $errorMessage = 'Unable to add connection_mode column to agent_configuration table'; if ($pearDB->isColumnExist('agent_configuration', 'connection_mode')) { return; } $pearDB->executeStatement( <<<'SQL' ALTER TABLE `agent_configuration` ADD COLUMN `connection_mode` ENUM('no-tls', 'secure', 'insecure') DEFAULT 'secure' NOT NULL SQL ); }; // -------------------------------------------- Token -------------------------------------------- // $createJwtTable = function () use ($pearDB, &$errorMessage): void { $errorMessage = 'Failed to create table jwt_tokens'; $pearDB->executeQuery( <<<'SQL' CREATE TABLE IF NOT EXISTS `jwt_tokens` ( `token_string` varchar(4096) DEFAULT NULL COMMENT 'Encoded JWT token', `token_name` VARCHAR(255) NOT NULL COMMENT 'Token name', `creator_id` INT(11) DEFAULT NULL COMMENT 'User ID of the token creator', `creator_name` VARCHAR(255) DEFAULT NULL COMMENT 'User name of the token creator', `encoding_key` VARCHAR(255) DEFAULT NULL COMMENT 'encoding key', `is_revoked` BOOLEAN NOT NULL DEFAULT 0 COMMENT 'Define if token is revoked', `creation_date` bigint UNSIGNED NOT NULL COMMENT 'Creation date of the token', `expiration_date` bigint UNSIGNED DEFAULT NULL COMMENT 'Expiration date of the token', PRIMARY KEY (`token_name`), CONSTRAINT `jwt_tokens_user_id_fk` FOREIGN KEY (`creator_id`) REFERENCES `contact` (`contact_id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Table for JWT tokens' SQL ); }; $updateTopologyForAuthenticationTokens = function () use ($pearDB, &$errorMessage): void { $errorMessage = 'Unable to update new authentication tokens topology'; $pearDB->executeQuery( <<<'SQL' UPDATE `topology` SET `topology_name` = 'Authentication Tokens', `topology_url` = '/administration/authentication-token' WHERE `topology_name` = 'API Tokens' AND `topology_url` = '/administration/api-token'; SQL ); }; // -------------------------------------------- Broker modules directive -------------------------------------------- // $addColumnInEngineConf = function () use ($pearDB, &$errorMessage): void { $errorMessage = 'Unabled to add column in cfg_nagios table'; if ($pearDB->isColumnExist('cfg_nagios', 'broker_module_cfg_file')) { return; } $pearDB->executeStatement( <<<'SQL' ALTER TABLE `cfg_nagios` ADD COLUMN `broker_module_cfg_file` VARCHAR(255) DEFAULT NULL SQL ); }; $removeBrokerModuleDirectiveAndAddBrokerModuleConfigFile = function () use ($pearDB, &$errorMessage): void { $errorMessage = 'Unable to get data from cfg_nagios_broker_module table'; $statement = $pearDB->executeQuery( <<<'SQL' SELECT `cfg_nagios_id`, `broker_module` FROM `cfg_nagios_broker_module` WHERE `broker_module` LIKE '%cbmod.so %.json' SQL ); $brokerNagiosPair = $statement->fetchAll(PDO::FETCH_KEY_PAIR); $errorMessage = 'Unable to update cfg_nagios table'; $preparedStatement = $pearDB->prepareQuery( <<<'SQL' UPDATE `cfg_nagios` SET `broker_module_cfg_file` = :broker_module_config_file WHERE `nagios_id` = :nagios_id SQL ); foreach ($brokerNagiosPair as $nagiosId => $brokerModuleDirective) { $brokerConfigFile = preg_match('/cbmod\.so (.+\.json)/', $brokerModuleDirective, $matches) ? $matches[1] : ''; $pearDB->executePreparedQuery( $preparedStatement, [ ':broker_module_config_file' => $brokerConfigFile, ':nagios_id' => $nagiosId, ] ); } $errorMessage = 'Unable to delete rows from cfg_nagios_broker_module table'; $pearDB->executeStatement( <<<'SQL' DELETE FROM `cfg_nagios_broker_module` WHERE `broker_module` LIKE '%cbmod.so %.json' SQL ); }; try { $createJwtTable(); $addConnectionModeColumnToAgentConfiguration(); $addColumnInEngineConf(); $sunsetHostGroupFields(); // Transactional queries for configuration database if (! $pearDB->inTransaction()) { $pearDB->beginTransaction(); } $updateTopologyForHostGroup($pearDB); $updateSamlProviderConfiguration($pearDB); $updateAgentConfiguration($pearDB); $updateTopologyForAuthenticationTokens(); $removeBrokerModuleDirectiveAndAddBrokerModuleConfigFile(); $pearDB->commit(); } catch (Throwable $exception) { CentreonLog::create()->error( logTypeId: CentreonLog::TYPE_UPGRADE, message: "UPGRADE - {$version}: " . $errorMessage, exception: $exception ); try { if ($pearDB->inTransaction()) { $pearDB->rollBack(); } } catch (PDOException $rollbackException) { CentreonLog::create()->error( logTypeId: CentreonLog::TYPE_UPGRADE, message: "UPGRADE - {$version}: error while rolling back the upgrade operation for : {$errorMessage}", exception: $rollbackException ); throw new Exception( "UPGRADE - {$version}: error while rolling back the upgrade operation for : {$errorMessage}", (int) $rollbackException->getCode(), $rollbackException ); } throw new Exception("UPGRADE - {$version}: " . $errorMessage, (int) $exception->getCode(), $exception); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.04.13.php
centreon/www/install/php/Update-20.04.13.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-23.04.5.php
centreon/www/install/php/Update-23.04.5.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 23.04.5: '; $errorMessage = ''; // Change the type of check_attempt and max_check_attempts columns from table resources $errorMessage = "Couldn't modify resources table"; $alterResourceTableStmnt = 'ALTER TABLE resources MODIFY check_attempts SMALLINT UNSIGNED, MODIFY max_check_attempts SMALLINT UNSIGNED'; try { $pearDBO->query($alterResourceTableStmnt); $errorMessage = ''; } catch (Exception $e) { $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-21.04.4.php
centreon/www/install/php/Update-21.04.4.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.10.11.php
centreon/www/install/php/Update-20.10.11.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 20.10.11: '; $pearDB = new CentreonDB('centreon', 3, false); /** * Query with transaction */ try { $pearDB->beginTransaction(); $errorMessage = 'Impossible to alter the table contact'; if (! $pearDB->isColumnExist('contact', 'contact_platform_data_sending')) { $pearDB->query( "ALTER TABLE `contact` ADD COLUMN `contact_platform_data_sending` ENUM('0', '1', '2')" ); } $pearDB->commit(); } catch (Exception $e) { $pearDB->rollBack(); $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-23.10.8.php
centreon/www/install/php/Update-23.10.8.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 23.10.8: '; $errorMessage = ''; $dropColumnVersionFromDashboardWidgetsTable = function (CentreonDB $pearDB): void { if ($pearDB->isColumnExist('dashboard_widgets', 'version')) { $pearDB->query( <<<'SQL' ALTER TABLE dashboard_widgets DROP COLUMN `version` SQL ); } }; $insertStatusGridWidget = function (CentreonDb $pearDB): void { $statement = $pearDB->query( <<<'SQL' SELECT 1 FROM `dashboard_widgets` WHERE `name` = 'centreon-widget-statusgrid' SQL ); if ((bool) $statement->fetch(PDO::FETCH_COLUMN) === false) { $pearDB->query( <<<'SQL' INSERT INTO `dashboard_widgets` (`name`) VALUES ('centreon-widget-statusgrid') SQL ); } }; $insertResourcesTableWidget = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to insert centreon-widget-resourcestable in dashboard_widgets'; $statement = $pearDB->query("SELECT 1 from dashboard_widgets WHERE name = 'centreon-widget-resourcestable'"); if ((bool) $statement->fetchColumn() === false) { $pearDB->query( <<<'SQL' INSERT INTO dashboard_widgets (`name`) VALUES ('centreon-widget-resourcestable') SQL ); } }; try { $errorMessage = ''; $dropColumnVersionFromDashboardWidgetsTable($pearDB); // Transactional queries if (! $pearDB->inTransaction()) { $pearDB->beginTransaction(); } $insertStatusGridWidget($pearDB); $insertResourcesTableWidget($pearDB); $pearDB->commit(); } catch (Exception $ex) { if ($pearDB->inTransaction()) { $pearDB->rollBack(); } $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $ex->getCode() . ' - Error : ' . $ex->getMessage() . ' - Trace : ' . $ex->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $ex->getCode(), $ex); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.04.16.php
centreon/www/install/php/Update-20.04.16.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-25.03.0.php
centreon/www/install/php/Update-25.03.0.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ require_once __DIR__ . '/../../../bootstrap.php'; /** * This file contains changes to be included in the next version. * The actual version number should be added in the variable $version. */ $version = '25.03.0'; $errorMessage = ''; // -------------------------------------------- CEIP Agent Information -------------------------------------------- // /** * @param CentreonDB $pearDBO * * @throws CentreonDbException */ $createAgentInformationTable = function (CentreonDB $pearDBO) use (&$errorMessage): void { $errorMessage = 'Unable to create table agent_information'; $pearDBO->executeQuery( <<<'SQL' CREATE TABLE IF NOT EXISTS `agent_information` ( `poller_id` bigint(20) unsigned NOT NULL, `enabled` tinyint(1) NOT NULL DEFAULT 1, `infos` JSON NOT NULL, PRIMARY KEY (`poller_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; SQL ); }; // -------------------------------------------- Additional Configurations -------------------------------------------- // /** * @param centreonDB $pearDB * * @throws CentreonDbException */ $addConnectorToTopology = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to retrieve data from topology table'; $statement = $pearDB->executeQuery( <<<'SQL' SELECT 1 FROM `topology` WHERE `topology_name` = 'Connectors' AND `topology_parent` = 6 AND `topology_page` = 620 SQL ); $topologyAlreadyExists = (bool) $statement->fetch(PDO::FETCH_COLUMN); $errorMessage = 'Unable to insert into topology'; if (! $topologyAlreadyExists) { $pearDB->executeQuery( <<<'SQL' INSERT INTO `topology` ( `topology_name`, `topology_parent`, `topology_page`, `topology_order`, `topology_group`, `topology_show` ) VALUES ('Connectors', 6, 620, 92, 1, '1') SQL ); } }; /** * @param CentreonDB $pearDB * * @throws CentreonDbException * * @return void */ $changeAccNameInTopology = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to update table topology'; $pearDB->executeQuery( <<<'SQL' UPDATE `topology` SET `topology_name` = 'Additional Configurations', `topology_parent` = 620, `topology_page` = 62002 WHERE `topology_url` = '/configuration/additional-connector-configurations' SQL ); }; // -------------------------------------------- Connectors configurations -------------------------------------------- // /** * @param CentreonDB $pearDB * * @throws CentreonDbException * * @return void */ $insertAccConnectors = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to select data from connector table'; $statement = $pearDB->executeQuery( <<<'SQL' SELECT 1 FROM `connector` WHERE `name` = 'Centreon Monitoring Agent' SQL ); if ((bool) $statement->fetch(PDO::FETCH_COLUMN) === false) { $errorMessage = 'Unable to add data to connector table'; $pearDB->executeQuery( <<<'SQL' REPLACE INTO `connector` (`id`, `name`, `description`, `command_line`, `enabled`, `created`, `modified`) VALUES (null,'Centreon Monitoring Agent', 'Centreon Monitoring Agent', 'opentelemetry --processor=centreon_agent --extractor=attributes --host_path=resource_metrics.resource.attributes.host.name --service_path=resource_metrics.resource.attributes.service.name', 1, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()), (null, 'Telegraf', 'Telegraf', 'opentelemetry --processor=nagios_telegraf --extractor=attributes --host_path=resource_metrics.scope_metrics.data.data_points.attributes.host --service_path=resource_metrics.scope_metrics.data.data_points.attributes.service', 1, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()); SQL ); } }; // -------------------------------------------- Dashboard Panel -------------------------------------------- // /** * @param CentreonDB $pearDB * * @throws CentreonDbException * @return void */ $updatePanelsLayout = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to update table dashboard_panel'; $pearDB->executeQuery( <<<'SQL' UPDATE `dashboard_panel` SET `layout_x` = `layout_x` * 2, `layout_width` = `layout_width` * 2 SQL ); }; // -------------------------------------------- Resource Status -------------------------------------------- // /** * @param CentreonDB $pearDBO * * @throws CentreonDbException * @return void */ $addColumnToResourcesTable = function (CentreonDB $pearDBO) use (&$errorMessage): void { $errorMessage = 'Unable to add column flapping to table resources'; if (! $pearDBO->isColumnExist('resources', 'flapping')) { $pearDBO->exec( <<<'SQL' ALTER TABLE `resources` ADD COLUMN `flapping` TINYINT(1) NOT NULL DEFAULT 0 SQL ); } $errorMessage = 'Unable to add column percent_state_change to table resources'; if (! $pearDBO->isColumnExist('resources', 'percent_state_change')) { $pearDBO->exec( <<<'SQL' ALTER TABLE `resources` ADD COLUMN `percent_state_change` FLOAT DEFAULT NULL SQL ); } }; $createIndexesForResourceStatus = function (CentreonDB $realtimeDb) use (&$errorMessage): void { if (! $realtimeDb->isIndexExists('resources', 'resources_poller_id_index')) { $errorMessage = 'Unable to create index resources_poller_id_index'; $realtimeDb->exec('CREATE INDEX `resources_poller_id_index` ON resources (`poller_id`)'); } if (! $realtimeDb->isIndexExists('resources', 'resources_id_index')) { $errorMessage = 'Unable to create index resources_id_index'; $realtimeDb->exec('CREATE INDEX `resources_id_index` ON resources (`id`)'); } if (! $realtimeDb->isIndexExists('resources', 'resources_parent_id_index')) { $errorMessage = 'Unable to create index resources_parent_id_index'; $realtimeDb->exec('CREATE INDEX `resources_parent_id_index` ON resources (`parent_id`)'); } if (! $realtimeDb->isIndexExists('resources', 'resources_enabled_type_index')) { $errorMessage = 'Unable to create index resources_enabled_type_index'; $realtimeDb->exec('CREATE INDEX `resources_enabled_type_index` ON resources (`enabled`, `type`)'); } if (! $realtimeDb->isIndexExists('tags', 'tags_type_name_index')) { $errorMessage = 'Unable to create index tags_type_name_index'; $realtimeDb->exec('CREATE INDEX `tags_type_name_index` ON tags (`type`, `name`(10))'); } }; // -------------------------------------------- Broker I/O Configuration -------------------------------------------- // /** * @param CentreonDB $pearDB * * @throws CentreonDbException * * @return void */ $removeConstraintFromBrokerConfiguration = function (CentreonDB $pearDB) use (&$errorMessage): void { // prevent side effect on the $removeFieldFromBrokerConfiguration function $errorMessage = 'Unable to update table cb_list_values'; if ($pearDB->isConstraintExists('cb_list_values', 'fk_cb_list_values_1')) { $pearDB->executeQuery( <<<'SQL' ALTER TABLE cb_list_values DROP CONSTRAINT `fk_cb_list_values_1` SQL ); } }; /** * @param CentreonDB $pearDB * * @throws CentreonDbException * * @return void */ $removeFieldFromBrokerConfiguration = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to remove data from cb_field'; $pearDB->executeQuery( <<<'SQL' DELETE FROM cb_field WHERE fieldname = 'check_replication' SQL ); $errorMessage = 'Unable to remove data from cfg_centreonbroker_info'; $pearDB->executeQuery( <<<'SQL' DELETE FROM cfg_centreonbroker_info WHERE config_key = 'check_replication' SQL ); }; // -------------------------------------------- Downtimes -------------------------------------------- // /** * Create index for resources table. * * @param CentreonDB $realtimeDb * * @throws CentreonDbException */ $createIndexForDowntimes = function (CentreonDB $realtimeDb) use (&$errorMessage): void { if (! $realtimeDb->isIndexExists('downtimes', 'downtimes_end_time_index')) { $errorMessage = 'Unable to create index for downtimes table'; $realtimeDb->executeQuery('CREATE INDEX `downtimes_end_time_index` ON downtimes (`end_time`)'); } }; try { // DDL statements for real time database $createAgentInformationTable($pearDBO); $addColumnToResourcesTable($pearDBO); $createIndexForDowntimes($pearDBO); $createIndexesForResourceStatus($pearDBO); // DDL statements for configuration database $addConnectorToTopology($pearDB); $changeAccNameInTopology($pearDB); $removeConstraintFromBrokerConfiguration($pearDB); // Transactional queries if (! $pearDB->inTransaction()) { $pearDB->beginTransaction(); } $insertAccConnectors($pearDB); $updatePanelsLayout($pearDB); $removeFieldFromBrokerConfiguration($pearDB); $pearDB->commit(); } catch (Throwable $exception) { CentreonLog::create()->error( logTypeId: CentreonLog::TYPE_UPGRADE, message: "UPGRADE - {$version}: " . $errorMessage, exception: $exception ); try { if ($pearDB->inTransaction()) { $pearDB->rollBack(); } } catch (PDOException $rollbackException) { CentreonLog::create()->error( logTypeId: CentreonLog::TYPE_UPGRADE, message: "UPGRADE - {$version}: error while rolling back the upgrade operation for : {$errorMessage}", exception: $rollbackException ); throw new Exception( "UPGRADE - {$version}: error while rolling back the upgrade operation for : {$errorMessage}", (int) $rollbackException->getCode(), $rollbackException ); } throw new Exception("UPGRADE - {$version}: " . $errorMessage, (int) $exception->getCode(), $exception); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-24.10.1.php
centreon/www/install/php/Update-24.10.1.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ require_once __DIR__ . '/../../../bootstrap.php'; require_once __DIR__ . '/../../class/centreonLog.class.php'; // error specific content $versionOfTheUpgrade = 'UPGRADE - 24.10.1: '; $errorMessage = ''; /** * Updates the display name and description for the connections_count field in the cb_field table. * * @param CentreonDB $pearDB * * @throws Exception */ $updateConnectionsCountDescription = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to update description in cb_field table'; $pearDB->executeQuery( <<<'SQL' UPDATE `cb_field` SET `displayname` = "Number of connections to the database", `description` = "1: all queries are sent through one connection\n 2: one connection for data_bin and logs, one for the rest\n 3: one connection for data_bin, one for logs, one for the rest" WHERE `fieldname` = "connections_count" SQL ); }; $addAllContactsColumnToAclGroups = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to add the colum all_contacts to the table acl_groups'; if (! $pearDB->isColumnExist(table: 'acl_groups', column: 'all_contacts')) { $pearDB->exec('ALTER TABLE `acl_groups` ADD COLUMN `all_contacts` TINYINT(1) DEFAULT 0 NOT NULL'); } }; $addAllContactGroupsColumnToAclGroups = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to add the colum all_contact_groups to the table acl_groups'; if (! $pearDB->isColumnExist(table: 'acl_groups', column: 'all_contact_groups')) { $pearDB->exec('ALTER TABLE `acl_groups` ADD COLUMN `all_contact_groups` TINYINT(1) DEFAULT 0 NOT NULL'); } }; try { // DDL statements $addAllContactsColumnToAclGroups($pearDB); $addAllContactGroupsColumnToAclGroups($pearDB); // Transactional queries if (! $pearDB->inTransaction()) { $pearDB->beginTransaction(); } $updateConnectionsCountDescription($pearDB); $pearDB->commit(); } catch (Exception $e) { if ($pearDB->inTransaction()) { try { $pearDB->rollBack(); } catch (PDOException $e) { CentreonLog::create()->error( logTypeId: CentreonLog::TYPE_UPGRADE, message: "{$versionOfTheUpgrade} error while rolling back the upgrade operation", customContext: ['error_message' => $e->getMessage(), 'trace' => $e->getTraceAsString()], exception: $e ); } } CentreonLog::create()->error( logTypeId: CentreonLog::TYPE_UPGRADE, message: $versionOfTheUpgrade . $errorMessage, customContext: ['error_message' => $e->getMessage(), 'trace' => $e->getTraceAsString()], exception: $e ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-22.04.0-beta.1.php
centreon/www/install/php/Update-22.04.0-beta.1.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ require_once __DIR__ . '/../../../bootstrap.php'; require_once __DIR__ . '/../../class/centreonAuth.class.php'; require_once __DIR__ . '/../../class/centreonLog.class.php'; require_once __DIR__ . '/../functions.php'; use Symfony\Component\Yaml\Yaml; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 22.04.0-beta.1: '; try { /** * Create Tables */ $errorMessage = "Unable to create 'password_expiration_excluded_users' table"; $pearDB->query( 'CREATE TABLE IF NOT EXISTS `password_expiration_excluded_users` ( `provider_configuration_id` int(11) NOT NULL, `user_id` int(11) NOT NULL, PRIMARY KEY (`provider_configuration_id`, `user_id`), CONSTRAINT `password_expiration_excluded_users_provider_configuration_id_fk` FOREIGN KEY (`provider_configuration_id`) REFERENCES `provider_configuration` (`id`) ON DELETE CASCADE, CONSTRAINT `password_expiration_excluded_users_provider_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `contact` (`contact_id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8' ); $errorMessage = "Unable to create table 'contact_password'"; $pearDB->query( 'CREATE TABLE IF NOT EXISTS `contact_password` ( `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, `password` varchar(255) NOT NULL, `contact_id` int(11) NOT NULL, `creation_date` BIGINT UNSIGNED NOT NULL, PRIMARY KEY (`id`), KEY `contact_password_contact_id_fk` (`contact_id`), INDEX `creation_date_index` (`creation_date`), CONSTRAINT `contact_password_contact_id_fk` FOREIGN KEY (`contact_id`) REFERENCES `contact` (`contact_id`) ON DELETE CASCADE)' ); /** * Alter Tables */ if ( $pearDB->isColumnExist('contact', 'login_attempts') !== 1 && $pearDB->isColumnExist('contact', 'blocking_time') !== 1 ) { // Add login blocking mechanism to contact $errorMessage = 'Impossible to add "login_attempts" and "blocking_time" columns to "contact" table'; $pearDB->query( 'ALTER TABLE `contact` ADD `login_attempts` INT(11) UNSIGNED DEFAULT NULL, ADD `blocking_time` BIGINT(20) UNSIGNED DEFAULT NULL' ); } $errorMessage = 'Unable to find constraint unique_index from security_token'; $constraintExistStatement = $pearDB->query( 'SELECT CONSTRAINT_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME="security_token" AND CONSTRAINT_NAME="unique_token"' ); if ($constraintExistStatement->fetch() !== false) { $errorMessage = 'Unable to remove unique_index from security_token'; $pearDB->query('ALTER TABLE `security_token` DROP INDEX `unique_token`'); } $errorMessage = 'Unable to find key token_index from security_token'; $tokenIndexKeyExistsStatement = $pearDB->query( <<<'SQL' SHOW indexes FROM security_token WHERE Key_name='token_index' SQL ); if ($tokenIndexKeyExistsStatement->fetch() !== false) { $errorMessage = 'Unable to remove key token_index from security_token'; $pearDB->query( <<<'SQL' DROP INDEX token_index ON security_token SQL ); } $errorMessage = 'Unable to alter table security_token'; $pearDB->query('ALTER TABLE `security_token` MODIFY `token` varchar(4096)'); if ($pearDB->isColumnExist('provider_configuration', 'custom_configuration') !== 1) { // Add custom_configuration to provider configurations $errorMessage = "Unable to add column 'custom_configuration' to table 'provider_configuration'"; $pearDB->query( 'ALTER TABLE `provider_configuration` ADD COLUMN `custom_configuration` JSON NOT NULL AFTER `name`' ); } /** * Transactional queries */ $pearDB->beginTransaction(); $errorMessage = "Unable to select existing passwords from 'contact' table"; if ($pearDB->isColumnExist('contact', 'contact_passwd') === 1) { $getPasswordResult = $pearDB->query( 'SELECT `contact_id`, `contact_passwd` FROM `contact` WHERE `contact_passwd` IS NOT NULL' ); // Move old password from contact to contact_password $errorMessage = "Unable to insert password in 'contact_password' table"; $statement = $pearDB->prepare( 'INSERT INTO `contact_password` (`password`, `contact_id`, `creation_date`) VALUES (:password, :contactId, :creationDate)' ); while ($row = $getPasswordResult->fetch()) { $statement->bindValue(':password', $row['contact_passwd'], PDO::PARAM_STR); $statement->bindValue(':contactId', $row['contact_id'], PDO::PARAM_INT); $statement->bindValue(':creationDate', time(), PDO::PARAM_INT); $statement->execute(); } } // Insert default providers configurations $errorMessage = 'Impossible to add default OpenID provider configuration'; insertOpenIdConfiguration($pearDB); $errorMessage = 'Impossible to add default WebSSO provider configuration'; insertWebSSOConfiguration($pearDB); $errorMessage = 'Unable to insert default local security policy configuration'; updateSecurityPolicyConfiguration($pearDB); /** * Add new UnifiedSQl broker output */ $errorMessage = 'Unable to update cb_type table '; $pearDB->query( "UPDATE `cb_type` set type_name = 'Perfdata Generator (Centreon Storage) - DEPRECATED' WHERE type_shortname = 'storage'" ); $pearDB->query( "UPDATE `cb_type` set type_name = 'Broker SQL database - DEPRECATED' WHERE type_shortname = 'sql'" ); $errorMessage = "Unable to add 'unified_sql' broker configuration output"; addNewUnifiedSqlOutput($pearDB); $errorMessage = 'Unable to migrate broker config to unified_sql'; migrateBrokerConfigOutputsToUnifiedSql($pearDB); $errorMessage = 'Unable to configure centreon-gorgone api user'; configureGorgoneApiUser($pearDB); $errorMessage = 'Unable to exclude Gorgone / MBI / MAP users from password policy'; excludeUsersFromPasswordPolicy($pearDB); $pearDB->commit(); if ($pearDB->isColumnExist('contact', 'contact_passwd') === 1) { $errorMessage = "Unable to drop column 'contact_passwd' from 'contact' table"; $pearDB->query('ALTER TABLE `contact` DROP COLUMN `contact_passwd`'); } } catch (Exception $e) { if ($pearDB->inTransaction()) { $pearDB->rollBack(); } $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); } /** * Insert SSO configuration * * @param CentreonDB $pearDB * @return void */ function insertWebSSOConfiguration(CentreonDB $pearDB): void { $customConfiguration = [ 'trusted_client_addresses' => [], 'blacklist_client_addresses' => [], 'login_header_attribute' => 'HTTP_AUTH_USER', 'pattern_matching_login' => null, 'pattern_replace_login' => null, ]; $isActive = false; $isForced = false; $statement = $pearDB->query("SELECT * FROM options WHERE `key` LIKE 'sso_%'"); $result = $statement->fetchAll(PDO::FETCH_ASSOC); if (! empty($result)) { foreach ($result as $configLine) { switch ($configLine['key']) { case 'sso_enable': $isActive = $configLine['value'] === '1'; break; case 'sso_mode': $isForced = $configLine['value'] === '0'; // '0' SSO Only, '1' Mixed break; case 'sso_trusted_clients': $customConfiguration['trusted_client_addresses'] = ! empty($configLine['value']) ? explode(',', $configLine['value']) : []; break; case 'sso_blacklist_clients': $customConfiguration['blacklist_client_addresses'] = ! empty($configLine['value']) ? explode(',', $configLine['value']) : []; break; case 'sso_header_username': $customConfiguration['login_header_attribute'] = ! empty($configLine['value']) ? $configLine['value'] : null; break; case 'sso_username_pattern': $customConfiguration['pattern_matching_login'] = ! empty($configLine['value']) ? $configLine['value'] : null; break; case 'sso_username_replace': $customConfiguration['pattern_replace_login'] = ! empty($configLine['value']) ? $configLine['value'] : null; break; } } $pearDB->query("DELETE FROM options WHERE `key` LIKE 'sso_%'"); } $insertStatement = $pearDB->prepare( "INSERT INTO provider_configuration (`type`,`name`,`custom_configuration`,`is_active`,`is_forced`) VALUES ('web-sso','web-sso', :customConfiguration, :isActive, :isForced)" ); $insertStatement->bindValue(':customConfiguration', json_encode($customConfiguration), PDO::PARAM_STR); $insertStatement->bindValue(':isActive', $isActive ? '1' : '0', PDO::PARAM_STR); $insertStatement->bindValue(':isForced', $isForced ? '1' : '0', PDO::PARAM_STR); $insertStatement->execute(); } /** * insert OpenId Configuration Default configuration. * * @param CentreonDB $pearDB */ function insertOpenIdConfiguration(CentreonDB $pearDB): void { $customConfiguration = [ 'trusted_client_addresses' => [], 'blacklist_client_addresses' => [], 'base_url' => null, 'authorization_endpoint' => null, 'token_endpoint' => null, 'introspection_token_endpoint' => null, 'userinfo_endpoint' => null, 'endsession_endpoint' => null, 'connection_scopes' => [], 'login_claim' => null, 'client_id' => null, 'client_secret' => null, 'authentication_type' => 'client_secret_post', 'verify_peer' => true, ]; $isActive = false; $isForced = false; $statement = $pearDB->query("SELECT * FROM options WHERE `key` LIKE 'openid_%'"); $result = $statement->fetchAll(PDO::FETCH_ASSOC); if (! empty($result)) { foreach ($result as $configLine) { switch ($configLine['key']) { case 'openid_connect_enable': $isActive = $configLine['value'] === '1'; break; case 'openid_connect_mode': $isForced = $configLine['value'] === '0'; // '0' OpenId Connect Only, '1' Mixed break; case 'openid_connect_trusted_clients': $customConfiguration['trusted_client_addresses'] = ! empty($configLine['value']) ? explode(',', $configLine['value']) : []; break; case 'openid_connect_blacklist_clients': $customConfiguration['blacklist_client_addresses'] = ! empty($configLine['value']) ? explode(',', $configLine['value']) : []; break; case 'openid_connect_base_url': $customConfiguration['base_url'] = ! empty($configLine['value']) ? $configLine['value'] : null; break; case 'openid_connect_authorization_endpoint': $customConfiguration['authorization_endpoint'] = ! empty($configLine['value']) ? $configLine['value'] : null; break; case 'openid_connect_token_endpoint': $customConfiguration['token_endpoint'] = ! empty($configLine['value']) ? $configLine['value'] : null; break; case 'openid_connect_introspection_endpoint': $customConfiguration['introspection_token_endpoint'] = ! empty($configLine['value']) ? $configLine['value'] : null; break; case 'openid_connect_userinfo_endpoint': $customConfiguration['userinfo_endpoint'] = ! empty($configLine['value']) ? $configLine['value'] : null; break; case 'openid_connect_end_session_endpoint': $customConfiguration['endsession_endpoint'] = ! empty($configLine['value']) ? $configLine['value'] : null; break; case 'openid_connect_scope': $customConfiguration['connection_scopes'] = ! empty($configLine['value']) ? explode(' ', $configLine['value']) : []; break; case 'openid_connect_login_claim': $customConfiguration['login_claim'] = ! empty($configLine['value']) ? $configLine['value'] : null; break; case 'openid_connect_client_id': $customConfiguration['client_id'] = ! empty($configLine['value']) ? $configLine['value'] : null; break; case 'openid_connect_client_secret': $customConfiguration['client_secret'] = ! empty($configLine['value']) ? $configLine['value'] : null; break; case 'openid_connect_client_basic_auth': $customConfiguration['authentication_type'] = $configLine['value'] === '1' ? 'client_secret_basic' : 'client_secret_post'; break; case 'openid_connect_verify_peer': // '1' is Verify Peer disable $customConfiguration['verify_peer'] = $configLine['value'] === '1' ? false : true; break; } } $pearDB->query("DELETE FROM options WHERE `key` LIKE 'open_id%'"); } $insertStatement = $pearDB->prepare( "INSERT INTO provider_configuration (`type`,`name`,`custom_configuration`,`is_active`,`is_forced`) VALUES ('openid','openid', :customConfiguration, :isActive, :isForced)" ); $insertStatement->bindValue(':customConfiguration', json_encode($customConfiguration), PDO::PARAM_STR); $insertStatement->bindValue(':isActive', $isActive ? '1' : '0', PDO::PARAM_STR); $insertStatement->bindValue(':isForced', $isForced ? '1' : '0', PDO::PARAM_STR); $insertStatement->execute(); } /** * Handle new broker output creation 'unified_sql' * * @param CentreonDB $pearDB */ function addNewUnifiedSqlOutput(CentreonDB $pearDB): void { // Add new output type 'unified_sql' $statement = $pearDB->query("SELECT cb_module_id FROM cb_module WHERE name = 'Storage'"); $module = $statement->fetch(); if ($module === false) { throw new Exception("Cannot find 'Storage' module in cb_module table"); } $moduleId = $module['cb_module_id']; $stmt = $pearDB->prepare( "INSERT INTO `cb_type` (`type_name`, `type_shortname`, `cb_module_id`) VALUES ('Unified SQL', 'unified_sql', :cb_module_id)" ); $stmt->bindValue(':cb_module_id', $moduleId, PDO::PARAM_INT); $stmt->execute(); $typeId = $pearDB->lastInsertId(); // Link new type to tag 'output' $statement = $pearDB->query("SELECT cb_tag_id FROM cb_tag WHERE tagname = 'Output'"); $tag = $statement->fetch(); if ($tag === false) { throw new Exception("Cannot find 'Output' tag in cb_tag table"); } $tagId = $tag['cb_tag_id']; $stmt = $pearDB->prepare( 'INSERT INTO `cb_tag_type_relation` (`cb_tag_id`, `cb_type_id`, `cb_type_uniq`) VALUES (:cb_tag_id, :cb_type_id, 0)' ); $stmt->bindValue(':cb_tag_id', $tagId, PDO::PARAM_INT); $stmt->bindValue(':cb_type_id', $typeId, PDO::PARAM_INT); $stmt->execute(); // Create new field 'unified_sql_db_type' with fixed value $pearDB->query("INSERT INTO options VALUES ('unified_sql_db_type', 'mysql')"); $pearDB->query( "INSERT INTO `cb_field` (fieldname, displayname, description, fieldtype, external) VALUES ('db_type', 'DB type', 'Target DBMS.', 'text', 'T=options:C=value:CK=key:K=unified_sql_db_type')" ); $fieldId = $pearDB->lastInsertId(); // Add form fields for 'unified_sql' output $inputs = []; $statement = $pearDB->query( "SELECT DISTINCT(tfr.cb_field_id), tfr.is_required FROM cb_type_field_relation tfr, cb_type t, cb_field f WHERE tfr.cb_type_id = t.cb_type_id AND t.type_shortname in ('sql', 'storage') AND tfr.cb_field_id = f.cb_field_id AND f.fieldname NOT LIKE 'db_type'" ); $inputs = $statement->fetchAll(); if (empty($inputs)) { throw new Exception('Cannot find fields in cb_type_field_relation table'); } $inputs[] = ['cb_field_id' => $fieldId, 'is_required' => 1]; $query = 'INSERT INTO `cb_type_field_relation` (`cb_type_id`, `cb_field_id`, `is_required`, `order_display`)'; $bindedValues = []; foreach ($inputs as $key => $input) { $query .= $key === 0 ? ' VALUES ' : ', '; $query .= "(:cb_type_id_{$key}, :cb_field_id_{$key}, :is_required_{$key}, :order_display_{$key})"; $bindedValues[':cb_type_id_' . $key] = $typeId; $bindedValues[':cb_field_id_' . $key] = $input['cb_field_id']; $bindedValues[':is_required_' . $key] = $input['is_required']; $bindedValues[':order_display_' . $key] = (int) $key + 1; } $stmt = $pearDB->prepare($query); foreach ($bindedValues as $key => $value) { $stmt->bindValue($key, $value, PDO::PARAM_INT); } $stmt->execute(); } /** * Insert security policy configuration into local provider custom configuration * * @param CentreonDB $pearDB */ function updateSecurityPolicyConfiguration(CentreonDB $pearDB): void { $localProviderConfiguration = json_encode([ 'password_security_policy' => [ 'password_length' => 12, 'has_uppercase_characters' => true, 'has_lowercase_characters' => true, 'has_numbers' => true, 'has_special_characters' => true, 'attempts' => 5, 'blocking_duration' => 900, 'password_expiration_delay' => 15552000, 'delay_before_new_password' => null, 'can_reuse_passwords' => false, ], ]); $statement = $pearDB->prepare( "UPDATE `provider_configuration` SET `custom_configuration` = :localProviderConfiguration WHERE `name` = 'local'" ); $statement->bindValue(':localProviderConfiguration', $localProviderConfiguration, PDO::PARAM_STR); $statement->execute(); } /** * Migrate broker outputs 'sql' and 'storage' to a unique output 'unified_sql' * * @param CentreonDB $pearDB * @throws Exception * @return void */ function migrateBrokerConfigOutputsToUnifiedSql(CentreonDB $pearDB): void { $outputTag = 1; // Determine blockIds for output of type sql and storage $dbResult = $pearDB->query("SELECT cb_type_id FROM cb_type WHERE type_shortname IN ('sql', 'storage')"); $typeIds = $dbResult->fetchAll(PDO::FETCH_COLUMN, 0); if (empty($typeIds) || count($typeIds) !== 2) { throw new Exception("Error while retrieving 'sql' and 'storage' in cb_type table"); } $blockIds = array_map(fn ($typeId) => "{$outputTag}_{$typeId}", $typeIds); // Retrieve broker config ids to migrate $bindedValues = []; foreach ($blockIds as $key => $blockId) { $bindedValues[":blockId_{$key}"] = $blockId; } $stmt = $pearDB->prepare( "SELECT config_value, config_id FROM cfg_centreonbroker_info WHERE config_group = 'output' AND config_key = 'blockId' AND config_value IN (" . implode(', ', array_keys($bindedValues)) . ')' ); foreach ($bindedValues as $param => $value) { $stmt->bindValue($param, $value, PDO::PARAM_STR); } $stmt->execute(); $configResults = $stmt->fetchAll(PDO::FETCH_COLUMN | PDO::FETCH_GROUP); $configIds = array_intersect($configResults[$blockIds[0]], $configResults[$blockIds[1]]); if ($configIds === []) { throw new Exception('Cannot find broker config ids to migrate'); } // Retrieve unified_sql type id $dbResult = $pearDB->query("SELECT cb_type_id FROM cb_type WHERE type_shortname = 'unified_sql'"); $unifiedSqlType = $dbResult->fetch(PDO::FETCH_COLUMN, 0); if (empty($unifiedSqlType)) { throw new Exception("Cannot find 'unified_sql' in cb_type table"); } $unifiedSqlTypeId = (int) $unifiedSqlType; foreach ($configIds as $configId) { // Find next config group id $dbResult = $pearDB->query( "SELECT MAX(config_group_id) as max_config_group_id FROM cfg_centreonbroker_info WHERE config_id = {$configId} AND config_group = 'output'" ); $maxConfigGroupId = $dbResult->fetch(PDO::FETCH_COLUMN, 0); if (empty($maxConfigGroupId)) { throw new Exception('Cannot find max config group id in cfg_centreonbroker_info table'); } $nextConfigGroupId = (int) $maxConfigGroupId + 1; $blockIdsQueryBinds = []; foreach ($blockIds as $key => $value) { $blockIdsQueryBinds[':block_id_' . $key] = $value; } $blockIdBinds = implode(',', array_keys($blockIdsQueryBinds)); // Find config group ids of outputs to replace $grpIdStatement = $pearDB->prepare("SELECT config_group_id FROM cfg_centreonbroker_info WHERE config_id = :configId AND config_key = 'blockId' AND config_value IN ({$blockIdBinds})"); $grpIdStatement->bindValue(':configId', (int) $configId, PDO::PARAM_INT); foreach ($blockIdsQueryBinds as $key => $value) { $grpIdStatement->bindValue($key, $value, PDO::PARAM_STR); } $grpIdStatement->execute(); $configGroupIds = $grpIdStatement->fetchAll(PDO::FETCH_COLUMN, 0); if (empty($configGroupIds)) { throw new Exception('Cannot find config group ids in cfg_centreonbroker_info table'); } // Build unified sql output config from outputs to replace $unifiedSqlOutput = []; $statement = $pearDB->prepare("SELECT * FROM cfg_centreonbroker_info WHERE config_id = :configId AND config_group = 'output' AND config_group_id = :configGroupId"); foreach ($configGroupIds as $configGroupId) { $statement->bindValue(':configId', (int) $configId, PDO::PARAM_INT); $statement->bindValue(':configGroupId', (int) $configGroupId, PDO::PARAM_INT); $statement->execute(); while ($row = $statement->fetch()) { $unifiedSqlOutput[$row['config_key']] = array_merge($unifiedSqlOutput[$row['config_key']] ?? [], $row); $unifiedSqlOutput[$row['config_key']]['config_group_id'] = $nextConfigGroupId; } } if ($unifiedSqlOutput === []) { throw new Exception('Cannot find conf for unified sql from cfg_centreonbroker_info table'); } $unifiedSqlOutput['name']['config_value'] = str_replace( ['sql', 'perfdata'], 'unified-sql', $unifiedSqlOutput['name']['config_value'] ); $unifiedSqlOutput['type']['config_value'] = 'unified_sql'; $unifiedSqlOutput['blockId']['config_value'] = "{$outputTag}_{$unifiedSqlTypeId}"; // Insert new output $queryRows = []; $bindedValues = []; $columnNames = null; foreach ($unifiedSqlOutput as $configKey => $configInput) { $columnNames ??= implode(', ', array_keys($configInput)); $queryKeys = []; foreach ($configInput as $key => $value) { $queryKeys[] = ':' . $configKey . '_' . $key; if (in_array($key, ['config_key', 'config_value', 'config_group'])) { $bindedValues[':' . $configKey . '_' . $key] = ['value' => $value, 'type' => PDO::PARAM_STR]; } else { $bindedValues[':' . $configKey . '_' . $key] = ['value' => $value, 'type' => PDO::PARAM_INT]; } } if ($queryKeys !== []) { $queryRows[] = '(' . implode(', ', $queryKeys) . ')'; } } if ($queryRows !== [] && $columnNames !== null) { $query = "INSERT INTO cfg_centreonbroker_info ({$columnNames}) VALUES "; $query .= implode(', ', $queryRows); $stmt = $pearDB->prepare($query); foreach ($bindedValues as $key => $value) { $stmt->bindValue($key, $value['value'], $value['type']); } $stmt->execute(); } // Delete deprecated outputs $bindedValues = []; foreach ($configGroupIds as $index => $configGroupId) { $bindedValues[':id_' . $index] = $configGroupId; } $stmt = $pearDB->prepare( "DELETE FROM cfg_centreonbroker_info WHERE config_id = {$configId} AND config_group = 'output' AND config_group_id IN (" . implode(', ', array_keys($bindedValues)) . ')' ); foreach ($bindedValues as $key => $value) { $stmt->bindValue($key, $value, PDO::PARAM_INT); } $stmt->execute(); } } /** * Configure api user in centreon gorgone configuration file * and create user in database if needed * * @param CentreonDB $pearDB */ function configureGorgoneApiUser(CentreonDB $pearDB): void { $gorgoneUser = null; $apiConfigurationFile = getGorgoneApiConfigurationFilePath(); if ($apiConfigurationFile !== null && is_writable($apiConfigurationFile)) { $apiConfigurationContent = file_get_contents($apiConfigurationFile); if ( preg_match('/@GORGONE_USER@/', $apiConfigurationContent) && preg_match('/@GORGONE_PASSWORD@/', $apiConfigurationContent) ) { $gorgoneUser = 'centreon-gorgone'; $gorgonePassword = generatePassword(); file_put_contents( $apiConfigurationFile, str_replace( ['@GORGONE_USER@', '@GORGONE_PASSWORD@'], [$gorgoneUser, $gorgonePassword], $apiConfigurationContent, ), ); createGorgoneUser( $pearDB, $gorgoneUser, password_hash($gorgonePassword, CentreonAuth::PASSWORD_HASH_ALGORITHM) ); } } } /** * Create centreon-gorgone user in database * * @param CentreonDB $pearDB * @param string $userAlias * @param string $hashedPassword */ function createGorgoneUser(CentreonDB $pearDB, string $userAlias, string $hashedPassword): void { $statementCreateUser = $pearDB->prepare( "INSERT INTO `contact` (`timeperiod_tp_id`, `timeperiod_tp_id2`, `contact_name`, `contact_alias`, `contact_lang`, `contact_host_notification_options`, `contact_service_notification_options`, `contact_email`, `contact_pager`, `contact_comment`, `contact_oreon`, `contact_admin`, `contact_type_msg`, `contact_activate`, `contact_auth_type`, `contact_ldap_dn`, `contact_enable_notifications`) VALUES(1, 1, :gorgoneUser, :gorgoneUser, 'en_US.UTF-8', 'n', 'n', 'gorgone@localhost', NULL, NULL, '0', '1', 'txt', '1', 'local', NULL, '0')" ); $statementCreateUser->bindValue(':gorgoneUser', $userAlias, PDO::PARAM_STR); $statementCreateUser->execute(); $statementCreatePassword = $pearDB->prepare( 'INSERT INTO `contact_password` (`password`, `contact_id`, `creation_date`) SELECT :gorgonePassword, c.contact_id, (SELECT UNIX_TIMESTAMP(NOW())) FROM contact c WHERE c.contact_alias = :gorgoneUser' ); $statementCreatePassword->bindValue(':gorgoneUser', $userAlias, PDO::PARAM_STR); $statementCreatePassword->bindValue(':gorgonePassword', $hashedPassword, PDO::PARAM_STR); $statementCreatePassword->execute(); } /** * Exclude Gorgone / MBI / MAP users from password policy * * @param CentreonDB $pearDB */ function excludeUsersFromPasswordPolicy(CentreonDB $pearDB): void { $usersToExclude = [ ':bi' => 'CBIS', ':map' => 'centreon-map', ]; $gorgoneUser = getGorgoneApiUser(); if ($gorgoneUser !== null) { $usersToExclude[':gorgone'] = $gorgoneUser; } $statement = $pearDB->prepare( "INSERT INTO `password_expiration_excluded_users` (provider_configuration_id, user_id) SELECT pc.id, c.contact_id FROM `provider_configuration` pc, `contact` c WHERE pc.name = 'local' AND c.contact_alias IN (" . implode(',', array_keys($usersToExclude)) . ') GROUP BY pc.id, c.contact_id ON DUPLICATE KEY UPDATE provider_configuration_id = provider_configuration_id' ); foreach ($usersToExclude as $userToExcludeParam => $usersToExcludeValue) { $statement->bindValue($userToExcludeParam, $usersToExcludeValue, PDO::PARAM_STR); } $statement->execute(); } /** * Get centreon-gorgone api user from configuration file * * @return string|null */ function getGorgoneApiUser(): ?string { $gorgoneUser = null; $apiConfigurationFile = getGorgoneApiConfigurationFilePath(); if ($apiConfigurationFile !== null) { $configuration = Yaml::parseFile($apiConfigurationFile); if (isset($configuration['gorgone']['tpapi'][0]['username'])) { $gorgoneUser = $configuration['gorgone']['tpapi'][0]['username']; } elseif (isset($configuration['gorgone']['tpapi'][1]['username'])) { $gorgoneUser = $configuration['gorgone']['tpapi'][1]['username']; } } return $gorgoneUser; } /** * Get centreon-gorgone api configuration file path if found and readable * * @return string|null */ function getGorgoneApiConfigurationFilePath(): ?string { $gorgoneEtcPath = _CENTREON_ETC_ . '/../centreon-gorgone'; $apiConfigurationFile = $gorgoneEtcPath . '/config.d/31-centreon-api.yaml'; if (file_exists($apiConfigurationFile) && is_readable($apiConfigurationFile)) { return $apiConfigurationFile; } return null; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-2.8.3.php
centreon/www/install/php/Update-2.8.3.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.10.0.php
centreon/www/install/php/Update-20.10.0.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-22.10.5.php
centreon/www/install/php/Update-22.10.5.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-18.10.0.php
centreon/www/install/php/Update-18.10.0.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-21.04.18.php
centreon/www/install/php/Update-21.04.18.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-25.01.2.php
centreon/www/install/php/Update-25.01.2.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-23.04.1.php
centreon/www/install/php/Update-23.04.1.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 23.04.1: '; $errorMessage = ''; $alterTopologyForFeatureFlag = function (CentreonDB $pearDB): void { if (! $pearDB->isColumnExist('topology', 'topology_feature_flag')) { $pearDB->query( <<<'SQL' ALTER TABLE `topology` ADD COLUMN `topology_feature_flag` varchar(255) DEFAULT NULL AFTER `topology_OnClick` SQL ); } }; $removeNagiosPathImg = function (CentreonDB $pearDB): void { $selectStatement = $pearDB->query("SELECT 1 FROM options WHERE `key`='nagios_path_img'"); if ($selectStatement->rowCount() > 0) { $pearDB->query("DELETE FROM options WHERE `key`='nagios_path_img'"); } }; $alterTopologyForTopologyUrlSubstitue = function (CentreonDB $pearDB): void { if (! $pearDB->isColumnExist('topology', 'topology_url_substitute')) { $pearDB->query( <<<'SQL' ALTER TABLE `topology` ADD COLUMN `topology_url_substitute` VARCHAR(255) DEFAULT NULL AFTER `topology_url_opt` SQL ); } }; try { // Transactional queries if (! $pearDB->inTransaction()) { $pearDB->beginTransaction(); } $errorMessage = 'Impossible to remove nagios_path_img column from options table.'; $removeNagiosPathImg($pearDB); $pearDB->commit(); $errorMessage = 'Impossible to add column topology_feature_flag to topology table'; $alterTopologyForFeatureFlag($pearDB); $errorMessage = 'Impossible to add column topology_url_substitute to topology table'; $alterTopologyForTopologyUrlSubstitue($pearDB); } catch (Exception $e) { if ($pearDB->inTransaction()) { $pearDB->rollBack(); } $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-22.04.11.php
centreon/www/install/php/Update-22.04.11.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-24.07.0.php
centreon/www/install/php/Update-24.07.0.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ require_once __DIR__ . '/../../../bootstrap.php'; require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 24.07.0: '; $errorMessage = ''; $deleteVaultTables = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to drop table vault configuration'; $pearDB->query( <<<'SQL' DROP TABLE IF EXISTS `vault_configuration` SQL ); $errorMessage = 'Unable to drop table vault'; $pearDB->query( <<<'SQL' DROP TABLE IF EXISTS `vault` SQL ); }; $updateCfgResourceTable = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to update table cfg_resource'; if (! $pearDB->isColumnExist('cfg_resource', 'is_password')) { $pearDB->query( <<<'SQL' ALTER TABLE `cfg_resource` ADD COLUMN `is_password` tinyint(1) NOT NULL DEFAULT 0 SQL ); } }; $updateBrokerCfgFieldTable = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to update table cb_field'; $pearDB->query( <<<'SQL' UPDATE `cb_field` SET cb_fieldgroup_id = 1 WHERE fieldname = 'category' AND fieldtype = 'multiselect' SQL ); }; try { $deleteVaultTables($pearDB); $updateCfgResourceTable($pearDB); // Tansactional queries if (! $pearDB->inTransaction()) { $pearDB->beginTransaction(); } $updateBrokerCfgFieldTable($pearDB); $pearDB->commit(); } catch (Exception $e) { if ($pearDB->inTransaction()) { $pearDB->rollBack(); } $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-19.10.0.php
centreon/www/install/php/Update-19.10.0.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); /** * Update session duration value to the max allowed duration set in the php * configuration file 50-centreon.ini */ try { $stmt = $pearDB->query( 'SELECT `value` FROM `options` WHERE `key` = "session_expire"' ); $sessionValue = $stmt->fetch(); if ($sessionValue > 120) { $pearDB->query( 'UPDATE `options` SET `value` = "120" WHERE `key` = "session_expire"' ); } } catch (PDOException $e) { $centreonLog->insertLog( 2, 'UPGRADE : 19.10.0 Unable to modify session expiration value' ); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-22.10.10.php
centreon/www/install/php/Update-22.10.10.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 22.10.10: '; $errorMessage = ''; // Change the type of check_attempt and max_check_attempts columns from table resources $errorMessage = "Couldn't modify resources table"; $alterResourceTableStmnt = 'ALTER TABLE resources MODIFY check_attempts SMALLINT UNSIGNED, MODIFY max_check_attempts SMALLINT UNSIGNED'; try { $pearDBO->query($alterResourceTableStmnt); $errorMessage = ''; } catch (Exception $e) { $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.10.0-beta.1.php
centreon/www/install/php/Update-20.10.0-beta.1.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-2.8.12.php
centreon/www/install/php/Update-2.8.12.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-25.05.2.php
centreon/www/install/php/Update-25.05.2.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.10.10.php
centreon/www/install/php/Update-20.10.10.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.10.0-beta.2.post.php
centreon/www/install/php/Update-20.10.0-beta.2.post.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ // error specific content $versionOfTheUpgrade = 'UPGRADE - 20.10.0-beta.2.post : '; /** * Queries needing exception management and rollback if failing */ try { $pearDB->beginTransaction(); // Remove data inserted in 20.10.0-beta1 $pearDB->query('DELETE FROM `platform_topology`'); /** * register server to 'platform_status' table */ // Check if the server is a Remote or a Central $type = 'central'; $serverType = $pearDB->query(" SELECT `value` FROM `informations` WHERE `key` = 'isRemote' "); if ($serverType->fetch()['value'] === 'yes') { $type = 'remote'; } // Check if the server is enabled $errorMessage = "Unable to find the server in 'nagios_server' table."; $serverQuery = $pearDB->query(" SELECT `id`, `name` FROM nagios_server WHERE localhost = '1' AND ns_activate = '1' "); $hostName = gethostname() ?: null; // Insert the server in 'platform_topology' table if ($row = $serverQuery->fetch()) { $errorMessage = "Unable to insert server in 'platform_topology' table."; $stmt = $pearDB->prepare(' INSERT INTO `platform_topology` (`address`, `name`, `hostname`, `type`, `parent_id`, `server_id`) VALUES (:centralAddress, :name, :hostname, :type, NULL, :id) '); $stmt->bindValue(':centralAddress', $_SERVER['SERVER_ADDR'], PDO::PARAM_STR); $stmt->bindValue(':name', $row['name'], PDO::PARAM_STR); $stmt->bindValue(':hostname', $hostName, PDO::PARAM_STR); $stmt->bindValue(':type', $type, PDO::PARAM_STR); $stmt->bindValue(':id', (int) $row['id'], PDO::PARAM_INT); $stmt->execute(); } // get topology local server id $localStmt = $pearDB->query(" SELECT `platform_topology`.`id` FROM `platform_topology` INNER JOIN nagios_server ON `platform_topology`.`server_id` = `nagios_server`.`id` WHERE `nagios_server`.`localhost` = '1' "); $parentId = $localStmt->fetchColumn(); // get nagios_server children $childStmt = $pearDB->query( "SELECT `id`, `name`, `ns_ip_address`, `remote_id` FROM nagios_server WHERE localhost != '1' ORDER BY `remote_id`" ); while ($row = $childStmt->fetch()) { // check for remote or poller child types $remoteServerQuery = $pearDB->prepare( 'SELECT ns.id FROM nagios_server ns INNER JOIN remote_servers rs ON rs.ip = ns.ns_ip_address WHERE ip = :ipAddress' ); $remoteServerQuery->bindValue(':ipAddress', $row['ns_ip_address'], PDO::PARAM_STR); $remoteServerQuery->execute(); $remoteId = $remoteServerQuery->fetchColumn(); if (! empty($remoteId)) { // is remote $serverType = 'remote'; $parent = $parentId; } else { $serverType = 'poller'; $findParent = $pearDB->prepare(' SELECT id from platform_topology WHERE `server_id` = :remoteId '); $findParent->bindValue(':remoteId', (int) $row['remote_id'], PDO::PARAM_INT); $findParent->execute(); $parent = $findParent->fetchColumn(); if ($parent === false) { continue; } } $errorMessage = 'Unable to insert ' . $serverType . ':' . $row['name'] . " in 'topology' table."; $stmt = $pearDB->prepare( 'INSERT INTO `platform_topology` (`address`, `name`, `type`, `parent_id`, `server_id`) VALUES (:centralAddress, :name, :serverType, :parent, :id)' ); $stmt->bindValue(':centralAddress', $row['ns_ip_address'], PDO::PARAM_STR); $stmt->bindValue(':name', $row['name'], PDO::PARAM_STR); $stmt->bindValue(':serverType', $serverType, PDO::PARAM_STR); $stmt->bindValue(':parent', (int) $parent, PDO::PARAM_INT); $stmt->bindValue(':id', (int) $row['id'], PDO::PARAM_INT); $stmt->execute(); } $pearDB->commit(); $errorMessage = ''; } catch (Exception $e) { include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); $pearDB->rollBack(); $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-25.07.0.php
centreon/www/install/php/Update-25.07.0.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ require_once __DIR__ . '/../../../bootstrap.php'; /** * This file contains changes to be included in the next version. * The actual version number should be added in the variable $version. */ $version = '25.07.0'; $errorMessage = ''; /** * Add column `show_deprecated_custom_views` to contact table. */ $addDeprecateCustomViewsToContact = function () use (&$errorMessage, &$pearDB): void { $errorMessage = 'Unable to add column show_deprecated_custom_views to contact table'; if (! $pearDB->isColumnExist('contact', 'show_deprecated_custom_views')) { $pearDB->executeQuery( <<<'SQL' ALTER TABLE contact ADD COLUMN show_deprecated_custom_views ENUM('0','1') DEFAULT '0' SQL ); } }; /** * Switch Topology Order between Dashboards and Custom Views. */ $updateDashboardAndCustomViewsTopology = function () use (&$errorMessage, &$pearDB): void { $errorMessage = 'Unable to update topology of Custom Views'; $pearDB->executeQuery( <<<'SQL' UPDATE topology SET topology_order = 2, is_deprecated ="1" WHERE topology_name = "Custom Views" SQL ); $errorMessage = 'Unable to update topology of Dashboards'; $pearDB->executeQuery( <<<'SQL' UPDATE topology SET topology_order = 1 WHERE topology_name = "Dashboards" SQL ); }; /** * Set Show Deprecated Custom Views to true by default is there is existing custom views. */ $updateContactsShowDeprecatedCustomViews = function () use (&$errorMessage, &$pearDB): void { $errorMessage = 'Unable to retrieve custom views'; $statement = $pearDB->executeQuery( <<<'SQL' SELECT 1 FROM custom_views SQL ); if (! empty($statement->fetchAll())) { $pearDB->executeQuery( <<<'SQL' UPDATE contact SET show_deprecated_custom_views = '1' SQL ); } }; $updateCfgParameters = function () use ($pearDB, &$errorMessage): void { $errorMessage = 'Unable to update cfg_nagios table'; $pearDB->executeQuery( <<<'SQL' UPDATE cfg_nagios SET enable_flap_detection = '1', host_down_disable_service_checks = '1' WHERE enable_flap_detection != '1' OR host_down_disable_service_checks != '1' SQL ); }; /** -------------------------------------------- BBDO cfg update -------------------------------------------- */ $bbdoDefaultUpdate = function () use ($pearDB, &$errorMessage): void { if ($pearDB->isColumnExist('cfg_centreonbroker', 'bbdo_version') !== 1) { $errorMessage = "Unable to update 'bbdo_version' column to 'cfg_centreonbroker' table"; $pearDB->query('ALTER TABLE `cfg_centreonbroker` MODIFY `bbdo_version` VARCHAR(50) DEFAULT "3.1.0"'); } }; $bbdoCfgUpdate = function () use ($pearDB, &$errorMessage): void { $errorMessage = "Unable to update 'bbdo_version' version in 'cfg_centreonbroker' table"; $pearDB->query('UPDATE `cfg_centreonbroker` SET `bbdo_version` = "3.1.0"'); }; /** ------------------------------------------ Services as contacts ------------------------------------------ */ $addServiceFlagToContacts = function () use ($pearDB, &$errorMessage): void { $errorMessage = 'Unable to update contact table'; if (! $pearDB->isColumnExist('contact', 'is_service_account')) { $pearDB->executeQuery( <<<'SQL' ALTER TABLE `contact` ADD COLUMN `is_service_account` boolean DEFAULT 0 COMMENT 'Indicates if the contact is a service account (ex: centreon-gorgone)' SQL ); } }; $flagContactsAsServiceAccount = function () use ($pearDB, &$errorMessage): void { $errorMessage = 'Unable to update contact table'; $pearDB->executeQuery( <<<'SQL' UPDATE `contact` SET `is_service_account` = 1 WHERE `contact_name` IN ('centreon-gorgone', 'CBIS', 'centreon-map') SQL ); }; try { $bbdoDefaultUpdate(); $addDeprecateCustomViewsToContact(); $addServiceFlagToContacts(); // Transactional queries for configuration database if (! $pearDB->inTransaction()) { $pearDB->beginTransaction(); } $updateDashboardAndCustomViewsTopology(); $updateContactsShowDeprecatedCustomViews(); $updateCfgParameters(); $bbdoCfgUpdate(); $flagContactsAsServiceAccount(); $pearDB->commit(); } catch (Throwable $exception) { CentreonLog::create()->error( logTypeId: CentreonLog::TYPE_UPGRADE, message: "UPGRADE - {$version}: " . $errorMessage, exception: $exception ); try { if ($pearDB->inTransaction()) { $pearDB->rollBack(); } } catch (PDOException $rollbackException) { CentreonLog::create()->error( logTypeId: CentreonLog::TYPE_UPGRADE, message: "UPGRADE - {$version}: error while rolling back the upgrade operation for : {$errorMessage}", exception: $rollbackException ); throw new Exception( "UPGRADE - {$version}: error while rolling back the upgrade operation for : {$errorMessage}", (int) $rollbackException->getCode(), $rollbackException ); } throw new Exception("UPGRADE - {$version}: " . $errorMessage, (int) $exception->getCode(), $exception); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-23.04.4.php
centreon/www/install/php/Update-23.04.4.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 23.04.4: '; $errorMessage = 'Unable to add column topology_url_substitute to topology'; $addTopologyUrlSubstituteColumn = function (CentreonDB $pearDB): void { if (! $pearDB->isColumnExist('topology', 'topology_url_substitute')) { $pearDB->query('ALTER TABLE topology ADD topology_url_substitute VARCHAR(255) NULL AFTER topology_url_opt'); } }; try { $addTopologyUrlSubstituteColumn($pearDB); } catch (Exception $e) { $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.04.10.php
centreon/www/install/php/Update-20.04.10.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 20.04.10 : '; /** * Queries needing exception management and rollback if failing */ try { $statement = $pearDB->query( "SELECT count(CONSTRAINT_NAME) as nb from information_schema.TABLE_CONSTRAINTS WHERE table_name = 'dependency_hostChild_relation' and constraint_type = 'UNIQUE'" ); if ($statement->fetchColumn() === 0) { $errorMessage = 'Unable to update dependency_hostChild_relation'; $pearDB->query( 'ALTER IGNORE TABLE `dependency_hostChild_relation` ADD UNIQUE (`dependency_dep_id`, `host_host_id`)' ); } $statement = $pearDB->query( "SELECT count(CONSTRAINT_NAME) as nb from information_schema.TABLE_CONSTRAINTS WHERE table_name = 'dependency_hostParent_relation' and constraint_type = 'UNIQUE'" ); if ($statement->fetchColumn() === 0) { $errorMessage = 'Unable to update dependency_hostParent_relation'; $pearDB->query( 'ALTER IGNORE TABLE `dependency_hostParent_relation` ADD UNIQUE (`dependency_dep_id`, `host_host_id`)' ); } $statement = $pearDB->query( "SELECT count(CONSTRAINT_NAME) as nb from information_schema.TABLE_CONSTRAINTS WHERE table_name = 'dependency_hostgroupChild_relation' and constraint_type = 'UNIQUE'" ); if ($statement->fetchColumn() === 0) { $errorMessage = 'Unable to update dependency_hostgroupChild_relation'; $pearDB->query( 'ALTER IGNORE TABLE `dependency_hostgroupChild_relation` ADD UNIQUE (`dependency_dep_id`, `hostgroup_hg_id`)' ); } $statement = $pearDB->query( "SELECT count(CONSTRAINT_NAME) as nb from information_schema.TABLE_CONSTRAINTS WHERE table_name = 'dependency_hostgroupParent_relation' and constraint_type = 'UNIQUE'" ); if ($statement->fetchColumn() === 0) { $errorMessage = 'Unable to update dependency_hostgroupParent_relation'; $pearDB->query( 'ALTER IGNORE TABLE `dependency_hostgroupParent_relation` ADD UNIQUE (`dependency_dep_id`, `hostgroup_hg_id`)' ); } $statement = $pearDB->query( "SELECT count(CONSTRAINT_NAME) as nb from information_schema.TABLE_CONSTRAINTS WHERE table_name = 'dependency_metaserviceChild_relation' and constraint_type = 'UNIQUE'" ); if ($statement->fetchColumn() === 0) { $errorMessage = 'Unable to update dependency_metaserviceChild_relation'; $pearDB->query( 'ALTER IGNORE TABLE `dependency_metaserviceChild_relation` ADD UNIQUE (`dependency_dep_id`, `meta_service_meta_id`)' ); } $statement = $pearDB->query( "SELECT count(CONSTRAINT_NAME) as nb from information_schema.TABLE_CONSTRAINTS WHERE table_name = 'dependency_metaserviceParent_relation' and constraint_type = 'UNIQUE'" ); if ($statement->fetchColumn() === 0) { $errorMessage = 'Unable to update dependency_metaserviceParent_relation'; $pearDB->query( 'ALTER IGNORE TABLE `dependency_metaserviceParent_relation` ADD UNIQUE (`dependency_dep_id`, `meta_service_meta_id`)' ); } $statement = $pearDB->query( "SELECT count(CONSTRAINT_NAME) as nb from information_schema.TABLE_CONSTRAINTS WHERE table_name = 'dependency_serviceChild_relation' and constraint_type = 'UNIQUE'" ); if ($statement->fetchColumn() === 0) { $errorMessage = 'Unable to update dependency_serviceChild_relation'; $pearDB->query( 'ALTER IGNORE TABLE `dependency_serviceChild_relation` ADD UNIQUE (`dependency_dep_id`, `service_service_id`, `host_host_id`)' ); } $statement = $pearDB->query( "SELECT count(CONSTRAINT_NAME) as nb from information_schema.TABLE_CONSTRAINTS WHERE table_name = 'dependency_serviceParent_relation' and constraint_type = 'UNIQUE'" ); if ($statement->fetchColumn() === 0) { $errorMessage = 'Unable to update dependency_serviceParent_relation'; $pearDB->query( 'ALTER IGNORE TABLE `dependency_serviceParent_relation` ADD UNIQUE (`dependency_dep_id`, `service_service_id`, `host_host_id`)' ); } $statement = $pearDB->query( "SELECT count(CONSTRAINT_NAME) as nb from information_schema.TABLE_CONSTRAINTS WHERE table_name = 'dependency_servicegroupChild_relation' and constraint_type = 'UNIQUE'" ); if ($statement->fetchColumn() === 0) { $errorMessage = 'Unable to update dependency_servicegroupChild_relation'; $pearDB->query( 'ALTER IGNORE TABLE `dependency_servicegroupChild_relation` ADD UNIQUE (`dependency_dep_id`, `servicegroup_sg_id`)' ); } $statement = $pearDB->query( "SELECT count(CONSTRAINT_NAME) as nb from information_schema.TABLE_CONSTRAINTS WHERE table_name = 'dependency_servicegroupParent_relation' and constraint_type = 'UNIQUE'" ); if ($statement->fetchColumn() === 0) { $errorMessage = 'Unable to update dependency_servicegroupParent_relation'; $pearDB->query( 'ALTER IGNORE TABLE `dependency_servicegroupParent_relation` ADD UNIQUE (`dependency_dep_id`, `servicegroup_sg_id`)' ); } // engine postpone if (! $pearDB->isColumnExist('cfg_nagios', 'postpone_notification_to_timeperiod')) { // An update is required $errorMessage = 'Impossible to alter the table cfg_nagios with postpone_notification_to_timeperiod'; $pearDB->query( 'ALTER TABLE `cfg_nagios` ADD COLUMN `postpone_notification_to_timeperiod` boolean DEFAULT false AFTER `nagios_group`' ); } // engine heartbeat interval if (! $pearDB->isColumnExist('cfg_nagios', 'instance_heartbeat_interval')) { // An update is required $errorMessage = 'Impossible to alter the table cfg_nagios with instance_heartbeat_interval'; $pearDB->query( 'ALTER TABLE `cfg_nagios` ADD COLUMN `instance_heartbeat_interval` smallint DEFAULT 30 AFTER `date_format`' ); } $errorMessage = ''; } catch (Exception $e) { $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.04.0-rc.3.php
centreon/www/install/php/Update-20.04.0-rc.3.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.10.13.php
centreon/www/install/php/Update-20.10.13.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.04.3.php
centreon/www/install/php/Update-20.04.3.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-25.09.1.php
centreon/www/install/php/Update-25.09.1.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.04.2.php
centreon/www/install/php/Update-20.04.2.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 20.04.2 : '; $errorMessage = ''; /** * Queries needing exception management BUT no rollback if failing */ try { // Get timezones and add "Asia/Yangon" if doesn't exist $errorMessage = 'Cannot retrieve timezone list'; $res = $pearDB->query( "SELECT timezone_name FROM timezone WHERE timezone_name = 'Asia/Yangon'" ); $timezone = $res->fetch(); if ($timezone === false) { $errorMessage = 'Cannot add Asia/Yangon to timezone list'; $stmt = $pearDB->query( 'INSERT INTO timezone (timezone_name, timezone_offset, timezone_dst_offset, timezone_description) VALUE ("Asia/Yangon", "+06:30", "+06:30", NULL)' ); } } catch (Exception $e) { $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.10.0-beta.2.php
centreon/www/install/php/Update-20.10.0-beta.2.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 20.10.0-beta.2 : '; /** * Queries needing exception management and rollback if failing */ try { $pearDB->beginTransaction(); // Move keycloak configuration to OpenId Connect one $errorMessage = 'Unable to move Keycloak configuration to OpenId Connect'; $result = $pearDB->query( "SELECT * FROM options WHERE options.key IN ('keycloak_enable', 'keycloak_mode', 'keycloak_url', 'keycloak_redirect_url', 'keycloak_realm', 'keycloak_client_id', 'keycloak_client_secret', 'keycloak_trusted_clients', 'keycloak_blacklist_clients')" ); $keycloak = []; while ($row = $result->fetch()) { $keycloak[$row['key']] = $row['value']; } $keycloakBaseUrl = null; if (! empty($keycloak['keycloak_url']) && ! empty($keycloak['keycloak_realm'])) { $keycloakUrl = $keycloak['keycloak_url'] . '/realms/' . $keycloak['keycloak_realm'] . '/protocol/openid-connect'; } $openIdConnect = [ 'openid_connect_enable' => $keycloak['keycloak_enable'] ?? null, 'openid_connect_mode' => $keycloak['keycloak_mode'] ?? null, 'openid_connect_base_url' => $keycloakBaseUrl, 'openid_connect_authorization_endpoint' => isset($keycloak['keycloak_url']) ? '/auth' : null, 'openid_connect_token_endpoint' => isset($keycloak['keycloak_url']) ? '/token' : null, 'openid_connect_introspection_endpoint' => isset($keycloak['keycloak_url']) ? '/introspect' : null, 'openid_connect_redirect_url' => $keycloak['keycloak_redirect_url'] ?? null, 'openid_connect_client_id' => $keycloak['keycloak_client_id'] ?? null, 'openid_connect_client_secret' => $keycloak['keycloak_client_secret'] ?? null, 'openid_connect_trusted_clients' => $keycloak['keycloak_trusted_clients'] ?? null, 'openid_connect_blacklist_clients' => $keycloak['keycloak_blacklist_clients'] ?? null, ]; $statement = $pearDB->prepare( 'INSERT INTO options (`key`, `value`) VALUES (:key, :value)' ); foreach ($openIdConnect as $key => $value) { if (! is_null($value)) { $statement->bindValue(':key', $key, PDO::PARAM_STR); $statement->bindValue(':value', $value, PDO::PARAM_STR); $statement->execute(); } } $pearDB->query( "DELETE FROM options WHERE options.key IN ('keycloak_enable', 'keycloak_mode', 'keycloak_url', 'keycloak_redirect_url', 'keycloak_realm', 'keycloak_client_id', 'keycloak_client_secret', 'keycloak_trusted_clients', 'keycloak_blacklist_clients')" ); $pearDB->commit(); $errorMessage = ''; } catch (Exception $e) { $pearDB->rollBack(); $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-22.04.9.php
centreon/www/install/php/Update-22.04.9.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-2.8.10.php
centreon/www/install/php/Update-2.8.10.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ if (isset($pearDB)) { $res = $pearDB->query( 'SELECT * ' . 'FROM INFORMATION_SCHEMA.COLUMNS ' . "WHERE TABLE_NAME = 'nagios_server' " . "AND COLUMN_NAME = 'description' " ); if ($res->rowCount() > 0) { $pearDB->query('ALTER TABLE `nagios_server` DROP COLUMN `description`'); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-22.10.11.php
centreon/www/install/php/Update-22.10.11.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 22.10.11: '; $errorMessage = ''; $alterMetricsTable = function (CentreonDB $pearDBO): void { $pearDBO->query( <<<'SQL' ALTER TABLE `metrics` MODIFY COLUMN `metric_name` VARCHAR(1021) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL SQL ); }; try { $errorMessage = 'Impossible to alter metrics table'; $alterMetricsTable($pearDBO); } catch (Exception $e) { $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.04.0-beta.1.php
centreon/www/install/php/Update-20.04.0-beta.1.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 20.04.0-beta.1 : '; $errorMessage = ''; /** * Queries needing exception management and rollback if failing */ try { $pearDB->beginTransaction(); // Move broker xml files to json format $errorMessage = 'Unable to replace broker configuration from xml format to json format'; $result = $pearDB->query( 'SELECT config_id, config_filename FROM cfg_centreonbroker' ); $statement = $pearDB->prepare( 'UPDATE cfg_centreonbroker SET config_filename = :value WHERE config_id = :id' ); $configFilenames = []; while ($row = $result->fetch()) { $fileName = str_replace('.xml', '.json', $row['config_filename']); // saving data for next engine module modifications $configFilenames[$row['config_filename']] = $fileName; $statement->bindValue(':value', $fileName, PDO::PARAM_STR); $statement->bindValue(':id', $row['config_id'], PDO::PARAM_INT); $statement->execute(); } // Move engine module xml files to json format $errorMessage = "Unable to replace engine's broker modules configuration from xml to json format"; $result = $pearDB->query( 'SELECT bk_mod_id, broker_module FROM cfg_nagios_broker_module' ); $statement = $pearDB->prepare( 'UPDATE cfg_nagios_broker_module SET broker_module = :value WHERE bk_mod_id = :id' ); while ($row = $result->fetch()) { $fileName = $row['broker_module']; foreach ($configFilenames as $oldName => $newName) { $fileName = str_replace($oldName, $newName, $fileName); } $statement->bindValue(':value', $fileName, PDO::PARAM_STR); $statement->bindValue(':id', $row['bk_mod_id'], PDO::PARAM_INT); $statement->execute(); } // Change broker sql output form // set common error message on failure $partialErrorMessage = $errorMessage; // reorganise existing input form $errorMessage = $partialErrorMessage . " - While trying to update 'cb_type_field_relation' table data"; $pearDB->query( "UPDATE cb_type_field_relation AS A INNER JOIN cb_type_field_relation AS B ON A.cb_type_id = B.cb_type_id SET A.`order_display` = 8 WHERE B.`cb_field_id` = (SELECT f.cb_field_id FROM cb_field f WHERE f.fieldname = 'buffering_timeout')" ); // add new connections_count input $errorMessage = $partialErrorMessage . " - While trying to insert in 'cb_field' table new values"; $pearDB->query( "INSERT INTO `cb_field` (`fieldname`, `displayname`, `description`, `fieldtype`, `external`) VALUES ('connections_count', 'Number of connection to the database', 'Usually cpus/2', 'int', NULL)" ); // add relation $errorMessage = $partialErrorMessage . " - While trying to insert in 'cb_type_field_relation' table new values"; $pearDB->query( "INSERT INTO `cb_type_field_relation` ( `cb_type_id`, `cb_field_id`, `is_required`, `order_display`, `jshook_name`, `jshook_arguments` ) VALUES ( (SELECT `cb_type_id` FROM `cb_type` WHERE `type_shortname` = 'sql'), (SELECT `cb_field_id` FROM `cb_field` WHERE `fieldname` = 'connections_count'), 0, 7, 'countConnections', '{\"target\": \"connections_count\"}' ), ( (SELECT `cb_type_id` FROM `cb_type` WHERE `type_shortname` = 'storage'), (SELECT `cb_field_id` FROM `cb_field` WHERE `fieldname` = 'connections_count'), 0, 7, 'countConnections', '{\"target\": \"connections_count\"}' )" ); $pearDB->commit(); $errorMessage = ''; } catch (Exception $e) { $pearDB->rollBack(); $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); } /** * Queries which don't need rollback and won't throw an exception */ try { // replace autologin keys using NULL instead of empty string $pearDB->query("UPDATE `contact` SET `contact_autologin_key` = NULL WHERE `contact_autologin_key` = ''"); } catch (Exception $e) { $errorMessage = 'Unable to set default contact_autologin_key.'; $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-2.8.22.php
centreon/www/install/php/Update-2.8.22.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-2.8.16.php
centreon/www/install/php/Update-2.8.16.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.10.8.php
centreon/www/install/php/Update-20.10.8.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 20.10.8 : '; /** * Query with transaction */ try { $pearDB->beginTransaction(); /** * Retreive Meta Host Id */ $statement = $pearDB->query( "SELECT `host_id` FROM `host` WHERE `host_name` = '_Module_Meta'" ); // Add missing relation if ($moduleMeta = $statement->fetch()) { $moduleMetaId = $moduleMeta['host_id']; $errorMessage = 'Unable to add relation between Module Meta and default poller.'; $statement = $pearDB->prepare( "INSERT INTO ns_host_relation(`nagios_server_id`, `host_host_id`) VALUES( (SELECT id FROM nagios_server WHERE localhost = '1'), (:moduleMetaId) ) ON DUPLICATE KEY UPDATE nagios_server_id = nagios_server_id" ); $statement->bindValue(':moduleMetaId', (int) $moduleMetaId, PDO::PARAM_INT); $statement->execute(); } $pearDB->commit(); } catch (Exception $e) { $pearDB->rollBack(); $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-2.8.2.php
centreon/www/install/php/Update-2.8.2.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-22.04.6.php
centreon/www/install/php/Update-22.04.6.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 22.04.6: '; $errorMessage = ''; try { $errorMessage = "Impossible to update 'hosts' table"; if (! str_contains(strtolower($pearDBO->getColumnType('hosts', 'notification_number')), 'bigint')) { $pearDBO->beginTransaction(); $pearDBO->query('UPDATE `hosts` SET `notification_number`= 0 WHERE `notification_number`< 0'); $pearDBO->query('ALTER TABLE `hosts` MODIFY `notification_number` BIGINT(20) UNSIGNED DEFAULT NULL'); } $errorMessage = "Impossible to update 'services' table"; if (! str_contains(strtolower($pearDBO->getColumnType('services', 'notification_number')), 'bigint')) { $pearDBO->beginTransaction(); $pearDBO->query('UPDATE `services` SET `notification_number`= 0 WHERE `notification_number`< 0'); $pearDBO->query('ALTER TABLE `services` MODIFY `notification_number` BIGINT(20) UNSIGNED DEFAULT NULL'); } } catch (Exception $e) { if ($pearDBO->inTransaction()) { $pearDBO->rollBack(); } $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . (int) $e->getCode() . ' - Error : ' . $e->getMessage() . ' - Trace : ' . $e->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-22.10.0-beta.3.php
centreon/www/install/php/Update-22.10.0-beta.3.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.04.15.php
centreon/www/install/php/Update-20.04.15.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-22.04.14.php
centreon/www/install/php/Update-22.04.14.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-2.8.4.php
centreon/www/install/php/Update-2.8.4.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ // Update comments unique key if (isset($pearDBO)) { $query = "SELECT count(*) AS number FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'hosts' AND table_schema = '" . $conf_centreon['dbcstg'] . "' AND column_name = 'timezone'"; $res = $pearDBO->query($query); $data = $res->fetchRow(); if ($data['number'] == 0) { $pearDBO->query('ALTER TABLE services ADD INDEX last_hard_state_change (last_hard_state_change)'); $pearDBO->query('ALTER TABLE `hosts` ADD COLUMN `timezone` varchar(64) DEFAULT NULL AFTER `statusmap_image`'); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-20.04.0.php
centreon/www/install/php/Update-20.04.0.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-2.8.0-beta2.php
centreon/www/install/php/Update-2.8.0-beta2.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/www/install/php/Update-2.8.5.post.php
centreon/www/install/php/Update-2.8.5.post.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ if (isset($pearDB)) { $query = 'SELECT cb.config_id, COUNT(cbi.config_group) AS nb ' . 'FROM cfg_centreonbroker cb ' . 'LEFT JOIN cfg_centreonbroker_info cbi ' . 'ON cbi.config_id = cb.config_id ' . 'AND cbi.config_group = "input" ' . 'GROUP BY cb.config_id '; $res = $pearDB->query($query); while ($row = $res->fetchRow()) { $daemon = 0; if ($row['nb'] > 0) { $daemon = 1; } $query = 'UPDATE cfg_centreonbroker ' . 'SET daemon = :daemon ' . 'WHERE config_id = :config_id '; $statement = $pearDB->prepare($query); $statement->bindValue(':daemon', $daemon, PDO::PARAM_INT); $statement->bindValue(':config_id', (int) $row['config_id'], PDO::PARAM_INT); $statement->execute(); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false