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/install/php/Update-20.04.12.php
centreon/www/install/php/Update-20.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-2.8.25.php
centreon/www/install/php/Update-2.8.25.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.21.php
centreon/www/install/php/Update-2.8.21.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.2.php
centreon/www/install/php/Update-21.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 * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 21.04.2: '; /** * 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-20.04.9.php
centreon/www/install/php/Update-20.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 * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; // error specific content $versionOfTheUpgrade = 'UPGRADE - 20.04.9 : '; $errorMessage = ''; try { $statement = $pearDB->query( 'SELECT COLUMN_DEFAULT FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = \'centreon\' AND TABLE_NAME = \'on_demand_macro_host\' AND COLUMN_NAME = \'is_password\'' ); if (($result = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { $defaultValue = $result['COLUMN_DEFAULT']; if ($defaultValue !== 0) { // An update is required $errorMessage = 'Impossible to alter the table on_demand_macro_host'; $pearDB->query('ALTER TABLE on_demand_macro_host ALTER is_password SET DEFAULT 0'); $errorMessage = 'Impossible to update the column on_demand_macro_host.is_password'; $pearDB->query('UPDATE on_demand_macro_host SET is_password = 0 WHERE is_password IS NULL'); } } $statement = $pearDB->query( 'SELECT COLUMN_DEFAULT FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = \'centreon\' AND TABLE_NAME = \'on_demand_macro_service\' AND COLUMN_NAME = \'is_password\'' ); if (($defaultValue = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { $defaultValue = $result['COLUMN_DEFAULT']; if ($defaultValue !== 0) { // An update is required $errorMessage = 'Impossible to alter the table on_demand_macro_service'; $pearDB->query('ALTER TABLE on_demand_macro_service ALTER is_password SET DEFAULT 0'); $errorMessage = 'Impossible to update the column on_demand_macro_service.is_password'; $pearDB->query('UPDATE on_demand_macro_service SET is_password = 0 WHERE is_password IS NULL'); } } } catch (Throwable $ex) { (new CentreonLog())->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . $ex->getCode() . ' - Error : ' . $ex->getMessage() . ' - Trace : ' . $ex->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, $ex->getCode(), $ex); } // Contact language with transaction try { $pearDB->beginTransaction(); $errorMessage = 'Unable to Update user language'; $pearDB->query( "UPDATE contact SET contact_lang = CONCAT(contact_lang, '.UTF-8') WHERE contact_lang NOT LIKE '%UTF-8' AND contact_lang <> 'browser' AND contact_lang <> ''" ); $pearDB->commit(); } catch (Throwable $ex) { $pearDB->rollBack(); (new CentreonLog())->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . $ex->getCode() . ' - Error : ' . $ex->getMessage() . ' - Trace : ' . $ex->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, $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-22.10.14.php
centreon/www/install/php/Update-22.10.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-20.04.5.php
centreon/www/install/php/Update-20.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 * */
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.4.php
centreon/www/install/php/Update-22.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-23.10.1.php
centreon/www/install/php/Update-23.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-2.8.27.php
centreon/www/install/php/Update-2.8.27.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.9.php
centreon/www/install/php/Update-20.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-2.8.5.php
centreon/www/install/php/Update-2.8.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.0-beta.1.post.php
centreon/www/install/php/Update-20.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(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 20.10.0-beta.1.post : '; /** * Queries needing exception management and rollback if failing */ try { $pearDB->beginTransaction(); /** * register server to 'platform_status' table */ // Correct 'isCentral' flag value $errorMessage = "Unable to get server data from the 'informations' table."; $result = $pearDB->query(" SELECT count(*) as `count` FROM `informations` WHERE (`key` = 'isRemote' AND `value` = 'no') OR (`key` = 'isCentral' AND `value` = 'no') "); $row = $result->fetch(); if ((int) $row['count'] === 2) { $errorMessage = "Unable to modify isCentral flag value in 'informations' table."; $stmt = $pearDB->query("UPDATE `informations` SET `value` = 'yes' WHERE `key` = 'isCentral'"); } /** * activate remote access page in topology menu */ $showPage = '0'; $serverType = $pearDB->query(" SELECT `value` FROM `informations` WHERE `key` = 'isRemote' "); if ($serverType->fetch()['value'] === 'yes') { $showPage = '1'; } // Create a new menu page related to remote. Hidden by default on a Central // This page is displayed only on remote platforms. $errorMessage = "Unable to insert 'Remote access' page in 'topology' table."; $stmt = $pearDB->query(" INSERT INTO `topology` ( `topology_name`, `topology_parent`, `topology_page`, `topology_order`, `topology_group`, `topology_url`, `topology_url_opt`, `topology_popup`, `topology_modules`, `topology_show`, `topology_style_class`, `topology_style_id`, `topology_OnClick`, `readonly` ) VALUES ( 'Remote access', 501, 50120, 25, 1, './include/Administration/parameters/parameters.php', '&o=remote', '0', '0', '" . $showPage . "', NULL, NULL, NULL, '1' ) "); // migrate resource status menu acl $errorMessage = 'Unable to update acl of resource status page.'; $resourceStatusQuery = $pearDB->query( 'SELECT topology_id, topology_page FROM topology WHERE topology_page IN (2, 200)' ); $topologyAclStatement = $pearDB->prepare( 'SELECT DISTINCT(tr1.acl_topo_id) FROM acl_topology_relations tr1 WHERE tr1.acl_topo_id NOT IN ( SELECT tr2.acl_topo_id FROM acl_topology_relations tr2, topology t2 WHERE tr2.topology_topology_id = t2.topology_id AND t2.topology_page = :topology_page ) AND tr1.acl_topo_id IN ( SELECT tr3.acl_topo_id FROM acl_topology_relations tr3, topology t3 WHERE tr3.topology_topology_id = t3.topology_id AND t3.topology_page IN (20201, 20202) )' ); $topologyInsertStatement = $pearDB->prepare(' INSERT INTO `acl_topology_relations` ( `topology_topology_id`, `acl_topo_id`, `access_right` ) VALUES ( :topology_id, :acl_topology_id, 1 ) '); while ($resourceStatusPage = $resourceStatusQuery->fetch()) { $topologyAclStatement->bindValue(':topology_page', (int) $resourceStatusPage['topology_page'], PDO::PARAM_INT); $topologyAclStatement->execute(); while ($row = $topologyAclStatement->fetch()) { $topologyInsertStatement->bindValue(':topology_id', (int) $resourceStatusPage['topology_id'], PDO::PARAM_INT); $topologyInsertStatement->bindValue(':acl_topology_id', (int) $row['acl_topo_id'], PDO::PARAM_INT); $topologyInsertStatement->execute(); } } $monitoringTopologyStatement = $pearDB->query( 'SELECT DISTINCT(tr1.acl_topo_id) FROM acl_topology_relations tr1 WHERE tr1.acl_topo_id NOT IN ( SELECT tr2.acl_topo_id FROM acl_topology_relations tr2, topology t2 WHERE tr2.topology_topology_id = t2.topology_id AND t2.topology_page = 2 ) AND tr1.acl_topo_id IN ( SELECT tr3.acl_topo_id FROM acl_topology_relations tr3, topology t3 WHERE tr3.topology_topology_id = t3.topology_id AND t3.topology_page = 200 )' ); $monitoringPageQuery = $pearDB->query( 'SELECT topology_id FROM topology WHERE topology_page = 2' ); $monitoringPage = $monitoringPageQuery->fetch(); while ($topology = $monitoringTopologyStatement->fetch()) { if ($monitoringPage !== false) { $topologyInsertStatement->bindValue(':topology_id', (int) $monitoringPage['topology_id'], PDO::PARAM_INT); $topologyInsertStatement->bindValue(':acl_topology_id', (int) $topology['acl_topo_id'], PDO::PARAM_INT); $topologyInsertStatement->execute(); } } $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-23.10.4.php
centreon/www/install/php/Update-23.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 * */
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.php
centreon/www/install/php/Update-22.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-22.04.15.php
centreon/www/install/php/Update-22.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 * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 22.04.15: '; $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.10.16.php
centreon/www/install/php/Update-21.10.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-22.10.4.php
centreon/www/install/php/Update-22.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 * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 22.10.4: '; $errorMessage = ''; /** * 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('cfg_centreonbroker', 'event_queues_total_size') === 0) { $errorMessage = 'Impossible to update cfg_centreonbroker table'; $pearDB->query( 'ALTER TABLE `cfg_centreonbroker` ADD COLUMN `event_queues_total_size` INT(11) DEFAULT NULL AFTER `event_queue_max_size`' ); } // 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-20.04.1.php
centreon/www/install/php/Update-20.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 * */ // get current configuration data require_once __DIR__ . '/../../../config/centreon.config.php'; require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 20.04.1 : '; $errorMessage = ''; /** * Queries needing exception management BUT no rollback if failing */ try { // Get user data to generate a new config file for the gorgone daemon module // get engine command $res = $pearDB->query( "SELECT command_file FROM cfg_nagios cn JOIN nagios_server ns ON ns.id = cn.nagios_id WHERE localhost = '1'" ); $engineCommand = $res->fetch()['command_file']; // escape double quotes and backslashes $needle = ['\\', '"']; $escape = ['\\\\', '\"']; $password = str_replace($needle, $escape, password); // set macro keys $pattern = [ '/--ADDRESS--/', '/--DBPORT--/', '/--DBUSER--/', '/--DBPASS--/', '/--CONFDB--/', '/--STORAGEDB--/', '/--CENTREON_VARLIB--/', '/--CENTREON_CACHEDIR--/', '/--CENTREON_SPOOL--/', '/--CENTREON_TRAPDIR--/', '/--HTTPSERVERADDRESS--/', '/--HTTPSERVERPORT--/', '/--SSLMODE--/', '/--GORGONE_VARLIB--/', '/--ENGINE_COMMAND--/', ]; // set default values for these parameters $userValues = [ hostCentreon, port, user, $password, db, dbcstg, _CENTREON_VARLIB_, _CENTREON_CACHEDIR_, '/var/spool/centreon', '/etc/snmp/centreon_traps', '0.0.0.0', '8085', 'false', '/var/lib/centreon-gorgone', $engineCommand, ]; /** * check if the file has already been generated on a 20.04.0-beta or not * if already exists, generate a new file * * @param string - path to the file * * @return string - corrected filename */ function returnFinalFileName(string $destinationFile) { if (file_exists($destinationFile)) { $destinationFile .= '.new'; } return $destinationFile; } // database configuration file $fileTpl = __DIR__ . '/../var/databaseTemplate.yaml'; if (! file_exists($fileTpl) || filesize($fileTpl) === 0) { $errorMessage = 'Database configuration template is empty or missing'; throw new InvalidArgumentException($errorMessage); } $content = file_get_contents($fileTpl); $content = preg_replace($pattern, $userValues, $content); $destinationFile = returnFinalFileName(_CENTREON_ETC_ . '/config.d/10-database.yaml'); file_put_contents($destinationFile, $content); if (! file_exists($destinationFile) || filesize($destinationFile) === 0) { $errorMessage = 'Database configuration file is not created properly'; throw new InvalidArgumentException($errorMessage); } // gorgone configuration file for centreon. Created in the centreon-gorgone folder $fileTpl = __DIR__ . '/../var/gorgone/gorgoneCentralTemplate.yaml'; if (! file_exists($fileTpl) || filesize($fileTpl) === 0) { $errorMessage = 'Gorgone configuration template is empty or missing'; throw new InvalidArgumentException($errorMessage); } $content = file_get_contents($fileTpl); $content = preg_replace($pattern, $userValues, $content); $destinationFolder = _CENTREON_ETC_ . '/../centreon-gorgone'; $destinationFile = returnFinalFileName($destinationFolder . '/config.d/40-gorgoned.yaml'); // checking if mandatory centreon-gorgone configuration sub-folder already exists if (! file_exists($destinationFolder . '/config.d')) { $errorMessage = 'Gorgone configuration folder does not exist. ' . 'Please reinstall the centreon-gorgone package and retry'; throw new InvalidArgumentException($errorMessage); } file_put_contents($destinationFile, $content); if (! file_exists($destinationFile) || filesize($destinationFile) === 0) { $errorMessage = 'Gorgone configuration file is not created properly'; throw new InvalidArgumentException($errorMessage); } } 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.6.php
centreon/www/install/php/Update-20.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 * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; // error specific content $versionOfTheUpgrade = 'UPGRADE - 20.10.6 : '; $errorMessage = ''; try { // engine postpone if ($pearDB->isColumnExist('cfg_nagios', 'postpone_notification_to_timeperiod')) { // An update is required $errorMessage = 'Impossible to drop postpone_notification_to_timeperiod from fg_nagios'; $pearDB->query('ALTER TABLE `cfg_nagios` DROP COLUMN `postpone_notification_to_timeperiod`'); } // Platform_topology refacto if ($pearDB->isColumnExist('platform_topology', 'pending') === 0) { // Create the new column $errorMessage = 'Unable to add pending column to platform_topology table'; $pearDB->query( "ALTER TABLE `platform_topology` ADD COLUMN `pending` enum('0','1') DEFAULT '1' AFTER `parent_id`" ); } $errorMessage = ''; } catch (Exception $e) { (new 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 needing exception management and rollback if failing */ try { $pearDB->beginTransaction(); $errorMessage = 'Unable to update pending state on platform_topology table'; // find registered platforms $statement = $pearDB->query( "SELECT id FROM `platform_topology` WHERE `type` NOT IN ('central', 'remote', 'poller') OR `server_id` IS NOT NULL" ); while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { $result[] = $row['id']; } if (empty($result)) { throw new Exception('Cannot find the monitoring platform in platform_topology table'); } $registeredPlatforms = implode(', ', $result); $pearDB->query( "UPDATE `platform_topology` SET `pending` = '0' WHERE id IN ({$registeredPlatforms})" ); $pearDB->commit(); } catch (Exception $e) { $pearDB->rollBack(); (new 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.5.php
centreon/www/install/php/Update-21.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 * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 21.04.5:'; /** * Query with transaction */ try { $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')" ); } } 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-2.8.0.php
centreon/www/install/php/Update-2.8.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 _CENTREON_PATH_ . '/www/class/centreonMeta.class.php'; if (isset($pearDB)) { $metaObj = new CentreonMeta($pearDB); $hostId = null; $virtualServices = []; // Check virtual host $queryHost = 'SELECT host_id ' . 'FROM host ' . 'WHERE host_register = "2" ' . 'AND host_name = "_Module_Meta" '; $res = $pearDB->query($queryHost); if ($res->rowCount()) { $row = $res->fetchRow(); $hostId = $row['host_id']; } else { $query = 'INSERT INTO host (host_name, host_register) ' . 'VALUES ("_Module_Meta", "2") '; $pearDB->query($query); $res = $pearDB->query($queryHost); if ($res->rowCount()) { $row = $res->fetchRow(); $hostId = $row['host_id']; } } // Check existing virtual services $query = 'SELECT service_id, service_description ' . 'FROM service ' . 'WHERE service_description LIKE "meta_%" ' . 'AND service_register = "2" '; $res = $pearDB->query($query); while ($row = $res->fetchRow()) { if (preg_match('/meta_(\d+)/', $row['service_description'], $matches)) { $metaId = $matches[1]; $virtualServices[$matches[1]]['service_id'] = $row['service_id']; } } // Check existing relations between virtual services and virtual host $query = 'SELECT s.service_id, s.service_description ' . 'FROM service s, host_service_relation hsr ' . 'WHERE hsr.host_host_id = :host_id ' . 'AND s.service_register = "2" ' . 'AND s.service_description LIKE "meta_%" '; $statement = $pearDB->prepare($query); $statement->bindValue(':host_id', (int) $hostId, PDO::PARAM_INT); $statement->execute(); while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { if (preg_match('/meta_(\d+)/', $row['service_description'], $matches)) { $metaId = $matches[1]; $virtualServices[$matches[1]]['relation'] = true; } } $query = 'SELECT meta_id, meta_name ' . 'FROM meta_service '; $res = $pearDB->query($query); while ($row = $res->fetchRow()) { if (! isset($virtualServices[$row['meta_id']]) || ! isset($virtualServices[$row['meta_id']]['service_id'])) { $serviceId = $metaObj->insertVirtualService($row['meta_id'], $row['meta_name']); } else { $serviceId = $virtualServices[$row['meta_id']]['service_id']; } if (! isset($virtualServices[$row['meta_id']]) || ! isset($virtualServices[$row['meta_id']]['relation'])) { $query = 'INSERT INTO host_service_relation (host_host_id, service_service_id) ' . 'VALUES (:host_id, :service_id) '; $statement = $pearDB->prepare($query); $statement->bindValue(':host_id', (int) $hostId, PDO::PARAM_INT); $statement->bindValue(':service_id', (int) $serviceId, PDO::PARAM_INT); $statement->execute(); } } }
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.04.2.php
centreon/www/install/php/Update-19.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 * */
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.8.php
centreon/www/install/php/Update-22.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 - 22.10.8: '; $errorMessage = ''; $updateOpenIdCustomConfiguration = function (CentreonDB $pearDB): void { $customConfigurationJson = $pearDB->query( <<<'SQL' SELECT custom_configuration FROM provider_configuration WHERE name = 'openid' SQL )->fetchColumn(); $customConfiguration = json_decode($customConfigurationJson, true); if (! array_key_exists('redirect_url', $customConfiguration)) { $customConfiguration['redirect_url'] = null; $updatedCustomConfigurationEncoded = json_encode($customConfiguration); $statement = $pearDB->prepare( <<<'SQL' UPDATE provider_configuration SET custom_configuration = :encodedConfiguration WHERE name = 'openid' SQL ); $statement->bindValue(':encodedConfiguration', $updatedCustomConfigurationEncoded, PDO::PARAM_STR); $statement->execute(); } }; try { if (! $pearDB->inTransaction()) { $pearDB->beginTransaction(); } $errorMessage = 'Unable to update provider_configuration table to add redirect_url'; $updateOpenIdCustomConfiguration($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-22.04.7.php
centreon/www/install/php/Update-22.04.7.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.3.php
centreon/www/install/php/Update-18.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 * */
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.5.php
centreon/www/install/php/Update-23.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 * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 23.10.5: '; $errorMessage = ''; // ------------ INSERT / UPDATE / DELETE $updateTopologyForCloudNotifications = function (CentreonDB $pearDB): void { $statement = $pearDB->query( <<<'SQL' SELECT 1 FROM `topology` WHERE `topology_url` = '/configuration/notifications' SQL ); if ((bool) $statement->fetch(PDO::FETCH_COLUMN) === false) { $pearDB->query( <<<'SQL' INSERT INTO `topology` (`topology_name`, `topology_url`, `readonly`, `is_react`, `topology_parent`, `topology_page`, `topology_order`, `topology_group`,`topology_feature_flag`) VALUES ('Notifications', '/configuration/notifications', '1', '1', 604, 60413, 1, 1,'notification') SQL ); } }; try { $errorMessage = ''; // Transactional queries if (! $pearDB->inTransaction()) { $pearDB->beginTransaction(); } $errorMessage = 'Unable to update topology for Cloud Notifications'; $updateTopologyForCloudNotifications($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-21.04.10.php
centreon/www/install/php/Update-21.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 * */
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.7.php
centreon/www/install/php/Update-2.8.7.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.10.14.php
centreon/www/install/php/Update-21.10.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 * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 21.10.14: '; try { $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'" ); // Transactional queries $pearDB->beginTransaction(); // check if entry ldap_connection_timeout exist $query = $pearDB->query("SELECT * FROM auth_ressource_info WHERE ari_name = 'ldap_connection_timeout'"); $ldapResult = $query->fetchAll(PDO::FETCH_ASSOC); // insert entry ldap_connection_timeout with default value if (! $ldapResult) { $errorMessage = 'Unable to add default ldap connection timeout'; $pearDB->query( "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) (SELECT ar_id, 'ldap_connection_timeout', '' FROM auth_ressource)" ); } $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); } /** * 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 */ function decodeIllegalCharactersNagios(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(); } }
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.8.php
centreon/www/install/php/Update-2.8.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 * */ // Update Wiki url if (isset($pearDB)) { $res = $pearDB->query('SELECT * FROM `options` WHERE `key` = "kb_wiki_url"'); if ($res->rowCount() == 0) { $query = 'UPDATE `options` SET `key` = "kb_wiki_url" WHERE `key` = "kb_WikiURL"'; $pearDB->query($query); } else { $query = 'DELETE FROM `options` WHERE `key` = "kb_WikiURL"'; $pearDB->query($query); } }
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.3.php
centreon/www/install/php/Update-20.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 * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; // error specific content $versionOfTheUpgrade = 'UPGRADE - 20.10.3 : '; $errorMessage = ''; try { $statement = $pearDB->query( 'SELECT COLUMN_DEFAULT FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = \'centreon\' AND TABLE_NAME = \'on_demand_macro_host\' AND COLUMN_NAME = \'is_password\'' ); if (($result = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { $defaultValue = $result['COLUMN_DEFAULT']; if ($defaultValue !== 0) { // An update is required $errorMessage = 'Impossible to alter the table on_demand_macro_host'; $pearDB->query('ALTER TABLE on_demand_macro_host ALTER is_password SET DEFAULT 0'); $errorMessage = 'Impossible to update the column on_demand_macro_host.is_password'; $pearDB->query('UPDATE on_demand_macro_host SET is_password = 0 WHERE is_password IS NULL'); } } $statement = $pearDB->query( 'SELECT COLUMN_DEFAULT FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = \'centreon\' AND TABLE_NAME = \'on_demand_macro_service\' AND COLUMN_NAME = \'is_password\'' ); if (($defaultValue = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { $defaultValue = $result['COLUMN_DEFAULT']; if ($defaultValue !== 0) { // An update is required $errorMessage = 'Impossible to alter the table on_demand_macro_service'; $pearDB->query('ALTER TABLE on_demand_macro_service ALTER is_password SET DEFAULT 0'); $errorMessage = 'Impossible to update the column on_demand_macro_service.is_password'; $pearDB->query('UPDATE on_demand_macro_service SET is_password = 0 WHERE is_password IS NULL'); } } } catch (Throwable $ex) { (new CentreonLog())->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . $ex->getCode() . ' - Error : ' . $ex->getMessage() . ' - Trace : ' . $ex->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, $ex->getCode(), $ex); } // Contact language with transaction try { $pearDB->beginTransaction(); $errorMessage = 'Unable to Update user language'; $pearDB->query( "UPDATE contact SET contact_lang = CONCAT(contact_lang, '.UTF-8') WHERE contact_lang NOT LIKE '%UTF-8' AND contact_lang <> 'browser' AND contact_lang <> ''" ); $pearDB->commit(); } catch (Throwable $ex) { $pearDB->rollBack(); (new CentreonLog())->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . $ex->getCode() . ' - Error : ' . $ex->getMessage() . ' - Trace : ' . $ex->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, $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-24.09.0.php
centreon/www/install/php/Update-24.09.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.09.0: '; $errorMessage = ''; // ADDITIONAL CONNECTOR CONFIGURATION $createAcc = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to create table additional_connector_configuration'; $pearDB->executeQuery( <<<'SQL' CREATE TABLE IF NOT EXISTS `additional_connector_configuration` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `type` enum('vmware_v6') NOT NULL DEFAULT 'vmware_v6', `name` varchar(255) NOT NULL, `description` text, `parameters` JSON NOT NULL, `created_by` int(11) DEFAULT NULL, `updated_by` int(11) DEFAULT NULL, `created_at` int(11) NOT NULL, `updated_at` int(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name_unique` (`name`), CONSTRAINT `acc_contact_created_by` FOREIGN KEY (`created_by`) REFERENCES `contact` (`contact_id`) ON DELETE SET NULL, CONSTRAINT `acc_contact_updated_by` FOREIGN KEY (`updated_by`) REFERENCES `contact` (`contact_id`) ON DELETE SET NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 SQL ); $errorMessage = 'Unable to create table acc_poller_relation'; $pearDB->executeQuery( <<<'SQL' CREATE TABLE IF NOT EXISTS `acc_poller_relation` ( `acc_id` INT UNSIGNED NOT NULL, `poller_id` INT(11) NOT NULL, UNIQUE KEY `name_unique` (`acc_id`, `poller_id`), CONSTRAINT `acc_id_contraint` FOREIGN KEY (`acc_id`) REFERENCES `additional_connector_configuration` (`id`) ON DELETE CASCADE, CONSTRAINT `poller_id_contraint` FOREIGN KEY (`poller_id`) REFERENCES `nagios_server` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 SQL ); }; $insertIntoTopology = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to insert data into table topology'; $statement = $pearDB->executeQuery( <<<'SQL' SELECT 1 FROM `topology` WHERE `topology_name` = 'Additional connector configurations' SQL ); if ((bool) $statement->fetch(PDO::FETCH_COLUMN) === false) { $pearDB->executeQuery( <<<'SQL' INSERT INTO `topology` (`topology_name`, `topology_url`, `readonly`, `is_react`, `topology_parent`, `topology_page`, `topology_order`, `topology_group`, `topology_show`) VALUES ( 'Additional connector configurations', '/configuration/additional-connector-configurations', '1', '1', 6, 618, 1, 1, '0') SQL ); } }; // CLOCK WIDGET $insertClockWidget = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to select data into table dashboard_widgets'; $statement = $pearDB->executeQuery( <<<'SQL' SELECT 1 FROM `dashboard_widgets` WHERE `name` = 'centreon-widget-clock' SQL ); $errorMessage = 'Unable to insert data into table dashboard_widgets'; if ((bool) $statement->fetch(PDO::FETCH_COLUMN) === false) { $pearDB->executeQuery( <<<'SQL' INSERT INTO `dashboard_widgets` (`name`) VALUES ('centreon-widget-clock') SQL ); } }; // BROKER LOGS $addCentreonBrokerForeignKeyOnBrokerLogTable = function (CentreonDB $pearDB) use (&$errorMessage): void { $constraintStatement = $pearDB->prepareQuery( <<<'SQL' SELECT 1 FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_NAME='cfg_centreonbroker_log_ibfk_01' AND TABLE_SCHEMA = :db_name AND TABLE_NAME = 'cfg_centreonbroker_log' SQL ); $pearDB->executePreparedQuery($constraintStatement, ['db_name' => db]); if ($constraintStatement->rowCount() === 0) { // Clean no more existings broker configuration in log table $errorMessage = 'Unable to delete no more existing Broker Configuration'; $pearDB->executeQuery( <<<'SQL' DELETE FROM `cfg_centreonbroker_log` WHERE `id_centreonbroker` NOT IN ( SELECT `config_id` FROM `cfg_centreonbroker` ) SQL ); // Add Foreign Key. $errorMessage = 'Unable to add foreign key on cfg_centreonbroker_log table'; $pearDB->executeQuery( <<<'SQL' ALTER TABLE `cfg_centreonbroker_log` ADD CONSTRAINT `cfg_centreonbroker_log_ibfk_01` FOREIGN KEY (`id_centreonbroker`) REFERENCES `cfg_centreonbroker` (`config_id`) ON DELETE CASCADE SQL ); } }; $insertNewBrokerLogs = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to insert new logs in cfg_centreonbroker_log table'; $pearDB->executeQuery( <<<'SQL' INSERT INTO `cb_log` VALUES (11, 'neb'), (12, 'rrd'), (13, 'grpc'), (14, 'influxdb'), (15, 'graphite'), (16, 'victoria_metrics'), (17, 'stats') ON DUPLICATE KEY UPDATE `name` = `name` SQL ); }; $insertNewBrokersLogsRelations = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to find config_id in cfg_centreonbroker table'; $statement = $pearDB->executeQuery( <<<'SQL' SELECT `config_id` FROM `cfg_centreonbroker` SQL ); $configIds = []; while (($configId = $statement->fetchColumn()) !== false) { $configIds[] = $configId; } $insertSubQuery = ''; // Logs 11 to 17 are new logs, 3 is the default "error" level foreach ($configIds as $configId) { for ($logId = 11; $logId <= 17; $logId++) { $insertSubQuery .= "({$configId},{$logId},3),"; } } $insertSubQuery = rtrim($insertSubQuery, ','); $errorMessage = 'Unable to insert new logs in cfg_centreonbroker_log table'; $pearDB->executeQuery( <<<SQL INSERT INTO `cfg_centreonbroker_log` (`id_centreonbroker`, `id_log`, `id_level`) VALUES {$insertSubQuery} SQL ); }; $removeDashboardFeatureFlagFromTopology = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to update topology feature dashboard entries on topology table'; $pearDB->executeQuery( <<<'SQL' UPDATE topology SET topology_feature_flag=NULL WHERE topology_feature_flag='dashboard' SQL ); }; try { $createAcc($pearDB); $addCentreonBrokerForeignKeyOnBrokerLogTable($pearDB); // Transactional queries if (! $pearDB->inTransaction()) { $pearDB->beginTransaction(); } $insertIntoTopology($pearDB); $insertClockWidget($pearDB); $insertNewBrokerLogs($pearDB); $insertNewBrokersLogsRelations($pearDB); $removeDashboardFeatureFlagFromTopology($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-20.04.20.php
centreon/www/install/php/Update-20.04.20.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.10.6.php
centreon/www/install/php/Update-21.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-21.10.0-beta.2.php
centreon/www/install/php/Update-21.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-2.8.6.php
centreon/www/install/php/Update-2.8.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-21.10.0-beta.1.php
centreon/www/install/php/Update-21.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(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 21.10.0-beta.1: '; /** * Query with transaction */ try { $pearDB->beginTransaction(); // Purge all session. $errorMessage = 'Impossible to purge the table session'; $pearDB->query('DELETE FROM `session`'); // Add TLS hostname in config brocker for input/outputs IPV4 $statement = $pearDB->query("SELECT cb_field_id from cb_field WHERE fieldname = 'tls_hostname'"); if ($statement->fetchColumn() === false) { $errorMessage = 'Unable to update cb_field'; $pearDB->query(" INSERT INTO `cb_field` ( `cb_field_id`, `fieldname`,`displayname`, `description`, `fieldtype`, `external` ) VALUES ( null, 'tls_hostname', 'TLS Host name', 'Expected TLS certificate common name (CN) - leave blank if unsure.', 'text', NULL ) "); $errorMessage = 'Unable to update cb_type_field_relation'; $fieldId = $pearDB->lastInsertId(); $pearDB->query(' INSERT INTO `cb_type_field_relation` (`cb_type_id`, `cb_field_id`, `is_required`, `order_display`) VALUES (3, ' . $fieldId . ', 0, 5) '); } $pearDB->commit(); $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' ); } } 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-23.10.0.php
centreon/www/install/php/Update-23.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 * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 23.10.0: '; $errorMessage = ''; // ------------ CREATE TABLE $createTablesForDashboard = function (CentreonDB $pearDB): void { $pearDB->query( <<<'SQL' CREATE TABLE IF NOT EXISTS `dashboard` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `name` VARCHAR(200) NOT NULL, `description` text, `created_by` int(11) NULL, `updated_by` int(11) NULL, `created_at` int(11) NOT NULL, `updated_at` int(11) NOT NULL, `refresh_type` enum('global', 'manual') NOT NULL DEFAULT 'global', `refresh_interval` int(11) NULL, PRIMARY KEY (`id`), KEY `name_index` (`name`), CONSTRAINT `contact_created_by` FOREIGN KEY (`created_by`) REFERENCES `contact` (`contact_id`) ON DELETE SET NULL, CONSTRAINT `contact_updated_by` FOREIGN KEY (`updated_by`) REFERENCES `contact` (`contact_id`) ON DELETE SET NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 SQL ); $pearDB->query( <<<'SQL' CREATE TABLE IF NOT EXISTS `dashboard_panel` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `dashboard_id` INT UNSIGNED NOT NULL, `name` VARCHAR(200) NOT NULL, `widget_type` VARCHAR(200) NOT NULL, `widget_settings` text NOT NULL, `layout_x` smallint(6) NOT NULL, `layout_y` smallint(6) NOT NULL, `layout_width` smallint(6) NOT NULL, `layout_height` smallint(6) NOT NULL, `layout_min_width` smallint(6) NOT NULL, `layout_min_height` smallint(6) NOT NULL, PRIMARY KEY (`id`), KEY `name_index` (`name`), CONSTRAINT `parent_dashboard_id` FOREIGN KEY (`dashboard_id`) REFERENCES `dashboard` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 SQL ); $pearDB->query( <<<'SQL' CREATE TABLE IF NOT EXISTS `dashboard_contact_relation` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `dashboard_id` INT UNSIGNED NOT NULL, `contact_id` int(11) NOT NULL, `role` enum('viewer','editor') NOT NULL DEFAULT 'viewer', PRIMARY KEY (`id`), KEY `role_index` (`role`), UNIQUE KEY `dashboard_contact_relation_unique` (`dashboard_id`,`contact_id`), CONSTRAINT `dashboard_contact_relation_dashboard_id` FOREIGN KEY (`dashboard_id`) REFERENCES `dashboard` (`id`) ON DELETE CASCADE, CONSTRAINT `dashboard_contact_relation_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `contact` (`contact_id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 SQL ); $pearDB->query( <<<'SQL' CREATE TABLE IF NOT EXISTS `dashboard_contactgroup_relation` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `dashboard_id` INT UNSIGNED NOT NULL, `contactgroup_id` int(11) NOT NULL, `role` enum('viewer','editor') NOT NULL DEFAULT 'viewer', PRIMARY KEY (`id`), KEY `role_index` (`role`), UNIQUE KEY `dashboard_contactgroup_relation_unique` (`dashboard_id`,`contactgroup_id`), CONSTRAINT `dashboard_contactgroup_relation_dashboard_id` FOREIGN KEY (`dashboard_id`) REFERENCES `dashboard` (`id`) ON DELETE CASCADE, CONSTRAINT `dashboard_contactgroup_relation_contactgroup_id` FOREIGN KEY (`contactgroup_id`) REFERENCES `contactgroup` (`cg_id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 SQL ); $pearDB->query( <<<'SQL' CREATE TABLE IF NOT EXISTS `dashboard_widgets` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `version` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 SQL ); }; $createTablesForNotificationConfiguration = function (CentreonDB $pearDB): void { $pearDB->query( <<<'SQL' CREATE TABLE IF NOT EXISTS `notification` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `name` VARCHAR(250) NOT NULL, `is_activated` BOOLEAN NOT NULL DEFAULT 1, `timeperiod_id` INT NOT NULL, `hostgroup_events` TINYINT UNSIGNED NOT NULL DEFAULT 0, `servicegroup_events` TINYINT UNSIGNED NOT NULL DEFAULT 0, `included_service_events` TINYINT UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (`id`), FOREIGN KEY (`timeperiod_id`) REFERENCES `timeperiod` (`tp_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 SQL ); $pearDB->query( <<<'SQL' CREATE TABLE IF NOT EXISTS `notification_message` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `notification_id` INT UNSIGNED NOT NULL, `channel` enum('Email','Slack','Sms') DEFAULT 'Email', `subject` VARCHAR(255) NOT NULL, `message` TEXT NOT NULL, `formatted_message` TEXT NOT NULL, PRIMARY KEY (`id`), CONSTRAINT `notification_message_notification_id` FOREIGN KEY (`notification_id`) REFERENCES `notification` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 SQL ); $pearDB->query( <<<'SQL' CREATE TABLE IF NOT EXISTS `notification_user_relation` ( `notification_id` INT UNSIGNED NOT NULL, `user_id` INT NOT NULL, UNIQUE KEY `notification_user_relation_unique_index` (`notification_id`,`user_id`), CONSTRAINT `notification_user_relation_notification_id` FOREIGN KEY (`notification_id`) REFERENCES `notification` (`id`) ON DELETE CASCADE, CONSTRAINT `notification_user_relation_user_id` FOREIGN KEY (`user_id`) REFERENCES `contact` (`contact_id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 SQL ); $pearDB->query( <<<'SQL' CREATE TABLE IF NOT EXISTS `notification_hg_relation` ( `notification_id` INT UNSIGNED NOT NULL, `hg_id` INT NOT NULL, UNIQUE KEY `notification_hg_relation_unique_index` (`notification_id`,`hg_id`), CONSTRAINT `notification_hg_relation_notification_id` FOREIGN KEY (`notification_id`) REFERENCES `notification` (`id`) ON DELETE CASCADE, CONSTRAINT `notification_hg_relation_hg_id` FOREIGN KEY (`hg_id`) REFERENCES `hostgroup` (`hg_id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 SQL ); $pearDB->query( <<<'SQL' CREATE TABLE IF NOT EXISTS `notification_sg_relation` ( `notification_id` INT UNSIGNED NOT NULL, `sg_id` INT NOT NULL, UNIQUE KEY `notification_sg_relation_unique_index` (`notification_id`,`sg_id`), CONSTRAINT `notification_sg_relation_notification_id` FOREIGN KEY (`notification_id`) REFERENCES `notification` (`id`) ON DELETE CASCADE, CONSTRAINT `notification_sg_relation_hg_id` FOREIGN KEY (`sg_id`) REFERENCES `servicegroup` (`sg_id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 SQL ); }; // ------------ ALTER TABLE $alterResourceTableStmnt = function (CentreonDB $pearDBO): void { $pearDBO->query( <<<'SQL' ALTER TABLE `resources` MODIFY `check_attempts` SMALLINT UNSIGNED, MODIFY `max_check_attempts` SMALLINT UNSIGNED SQL ); }; $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 ); }; $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 ); } }; $alterSecurityTokenTable = function (CentreonDB $pearDB): void { if (! $pearDB->isColumnExist('security_authentication_tokens', 'token_name')) { $pearDB->query( <<<'SQL' ALTER TABLE `security_authentication_tokens` ADD COLUMN `token_name` varchar(255) DEFAULT NULL, ADD COLUMN `token_type` enum('auto', 'manual') NOT NULL DEFAULT 'auto', ADD COLUMN `creator_id` int(11) DEFAULT NULL, ADD COLUMN `creator_name` varchar(255) DEFAULT NULL, ADD COLUMN `is_revoked` BOOLEAN NOT NULL DEFAULT 0, ADD KEY `security_authentication_tokens_creator_id_fk` (`creator_id`), ADD CONSTRAINT `security_authentication_tokens_creator_id_fk` FOREIGN KEY (`creator_id`) REFERENCES `contact` (`contact_id`) ON DELETE SET NULL SQL ); } }; // ------------ INSERT / UPDATE / DELETE $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'"); } }; $enableDisabledServiceTemplates = function (CentreonDB $pearDB): void { $pearDB->query( <<<'SQL' UPDATE `service` SET service_activate = '1' WHERE service_register = '0' AND service_activate = '0' SQL ); }; $enableDisabledHostTemplates = function (CentreonDB $pearDB): void { $pearDB->query( <<<'SQL' UPDATE `host` SET host_activate = '1' WHERE host_register = '0' AND host_activate = '0' SQL ); }; $updateTopologyForDashboards = function (CentreonDB $pearDB): void { $statement = $pearDB->query( <<<'SQL' SELECT 1 FROM `topology` WHERE `topology_name` = 'Dashboards' SQL ); if ((bool) $statement->fetch(PDO::FETCH_COLUMN) === false) { $pearDB->query( <<<'SQL' INSERT INTO `topology` (`topology_name`, `topology_url`, `readonly`, `is_react`, `topology_parent`, `topology_page`, `topology_group`, `topology_order`, `topology_feature_flag`, `topology_url_opt`) VALUES ('Dashboards', '/home/dashboards', '1', '1', 1, 104, 1, 2, 'dashboard', 'Beta') SQL ); $pearDB->query( <<<'SQL' INSERT INTO `topology` (`topology_name`, `topology_url`, `readonly`, `is_react`, `topology_parent`, `topology_page`, `topology_show`, `topology_feature_flag`) VALUES ('Viewer', '/home/dashboards', '1', '0', 104, 10401, '0', 'dashboard'), ('Creator', '/home/dashboards', '1', '0', 104, 10402, '0', 'dashboard'), ('Administrator', '/home/dashboards', '1', '0', 104, 10403, '0', 'dashboard') SQL ); } }; $updateTopologyForApiTokens = function (CentreonDb $pearDB): void { $statement = $pearDB->query( <<<'SQL' SELECT 1 FROM `topology` WHERE `topology_name` = 'API Tokens' SQL ); if ((bool) $statement->fetch(PDO::FETCH_COLUMN) === false) { $pearDB->query( <<<'SQL' INSERT INTO `topology` (`topology_name`, `topology_order`, `topology_group`, `topology_url`, `readonly`, `is_react`, `topology_parent`, `topology_page`, `topology_show`) VALUES ('API Tokens', 16, 1, null, '1', '0', 5, 515, '0') SQL ); } }; $populateDahsboardTables = function (CentreonDb $pearDB): void { if ($pearDB->isColumnExist('dashboard_widgets', 'name')) { $statement = $pearDB->query( <<<'SQL' SELECT 1 FROM `dashboard_widgets` WHERE `name` = 'centreon-widget-generictext' SQL ); if ((bool) $statement->fetch(PDO::FETCH_COLUMN) === false) { $pearDB->query( <<<'SQL' INSERT INTO `dashboard_widgets` (`name`, `version`) VALUES ('centreon-widget-generictext', '23.10.0'), ('centreon-widget-singlemetric', '23.10.0'), ('centreon-widget-graph', '23.10.0'), ('centreon-widget-topbottom', '23.10.0') SQL ); } } }; $renameLegacyDashboardInTopology = function (CentreonDB $pearDB): void { $pearDB->query( <<<'SQL' UPDATE `topology` SET `topology_name` = 'Availability' WHERE `topology_name` = 'Dashboard' AND `topology_parent` IN (3, 307) SQL ); }; $createHostCategoriesIndex = function (CentreonDb $pearDB): void { if (! $pearDB->isIndexExists('hostcategories', 'level_index')) { $pearDB->query('CREATE INDEX `level_index` ON `hostcategories` (`level`)'); } }; $createAclResourcesHcRelationsConstraint = function (CentreonDB $pearDB): void { if (! $pearDB->isConstraintExists('acl_resources_hc_relations', 'acl_resources_hc_relations_pk')) { $pearDB->query( <<<'SQL' ALTER TABLE `acl_resources_hc_relations` ADD CONSTRAINT `acl_resources_hc_relations_pk` UNIQUE (`hc_id`, `acl_res_id`) SQL ); } }; try { $errorMessage = "Couldn't create tables for Dashboards configuration"; $createTablesForDashboard($pearDB); $errorMessage = "Couldn't create tables for Notifications configuration"; $createTablesForNotificationConfiguration($pearDB); $errorMessage = "Couldn't modify resources table"; $alterResourceTableStmnt($pearDBO); $errorMessage = 'Impossible to alter metrics table'; $alterMetricsTable($pearDBO); $errorMessage = 'Impossible to add column topology_feature_flag to topology table'; $alterTopologyForFeatureFlag($pearDB); $errorMessage = 'Unable to alter security_authentication_tokens table'; $alterSecurityTokenTable($pearDB); $errorMessage = 'Unable to create index on hostcategories table'; $createHostCategoriesIndex($pearDB); $errorMessage = 'Unable to create constraints on acl_resources_hc_relations table'; $createAclResourcesHcRelationsConstraint($pearDB); $errorMessage = ''; // Transactional queries if (! $pearDB->inTransaction()) { $pearDB->beginTransaction(); } $errorMessage = 'Unable to Delete nagios_path_img from options table'; $removeNagiosPathImg($pearDB); $errorMessage = 'Unable to activate deactivated service templates'; $enableDisabledServiceTemplates($pearDB); $errorMessage = 'Unable to activate deactivated host templates'; $enableDisabledHostTemplates($pearDB); $errorMessage = 'Unable to update topology for Dashboard'; $updateTopologyForDashboards($pearDB); $errorMessage = 'Unable to update topology for API Tokens'; $updateTopologyForApiTokens($pearDB); $errorMessage = 'Unable to populate dashboard_widgets table'; $populateDahsboardTables($pearDB); $errorMessage = 'Unable to rename legacy Dashboard topology'; $renameLegacyDashboardInTopology($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-24.05.1.php
centreon/www/install/php/Update-24.05.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';
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.2.php
centreon/www/install/php/Update-19.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 * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // fix contact auto login default value when not set try { $pearDB->query( "UPDATE `contact` SET `contact_autologin_key` = NULL WHERE `contact_autologin_key` =''" ); } catch (PDOException $e) { $centreonLog->insertLog( 2, 'UPGRADE : 19.10.2 Unable to set default contact_autologin_key' ); }
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.10.9.php
centreon/www/install/php/Update-21.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-21.10.8.php
centreon/www/install/php/Update-21.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 * */
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.10.7.php
centreon/www/install/php/Update-21.10.7.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.5.php
centreon/www/install/php/Update-22.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 - 22.04.5: '; $errorMessage = ''; /** * Manage relations between remote servers and nagios servers * * @param CentreonDB $pearDB */ $migrateRemoteServerRelations = function (CentreonDB $pearDB): void { $processedIps = []; $selectServerStatement = $pearDB->prepare( 'SELECT id FROM nagios_server WHERE ns_ip_address = :ip_address' ); $deleteRemoteStatement = $pearDB->prepare( 'DELETE FROM remote_servers WHERE id = :id' ); $updateRemoteStatement = $pearDB->prepare( 'UPDATE remote_servers SET server_id = :server_id WHERE id = :id' ); $result = $pearDB->query( 'SELECT id, ip FROM remote_servers' ); while ($remote = $result->fetch()) { $remoteIp = $remote['ip']; $remoteId = $remote['id']; if (in_array($remoteIp, $processedIps)) { $deleteRemoteStatement->bindValue(':id', $remoteId, PDO::PARAM_INT); $deleteRemoteStatement->execute(); } $processedIps[] = $remoteIp; $selectServerStatement->bindValue(':ip_address', $remoteIp, PDO::PARAM_STR); $selectServerStatement->execute(); if ($server = $selectServerStatement->fetch()) { $updateRemoteStatement->bindValue(':server_id', $server['id'], PDO::PARAM_INT); $updateRemoteStatement->bindValue(':id', $remoteId, PDO::PARAM_INT); $updateRemoteStatement->execute(); } else { $deleteRemoteStatement->bindValue(':id', $remoteId, PDO::PARAM_INT); $deleteRemoteStatement->execute(); } } }; try { if ($pearDB->isColumnExist('remote_servers', 'server_id') === 0) { $errorMessage = "Unable to add 'server_id' column to remote_servers table"; $pearDB->query( 'ALTER TABLE remote_servers ADD COLUMN `server_id` int(11) NOT NULL' ); $migrateRemoteServerRelations($pearDB); $errorMessage = 'Unable to add foreign key constraint of remote_servers.server_id'; $pearDB->query( 'ALTER TABLE remote_servers ADD CONSTRAINT `remote_server_nagios_server_ibfk_1` FOREIGN KEY(`server_id`) REFERENCES `nagios_server` (`id`) ON DELETE CASCADE' ); } } 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.10.4.php
centreon/www/install/php/Update-21.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 - 21.10.4: '; /** * Query with transaction */ try { $pearDB->beginTransaction(); $errorMessage = 'Unable to delete logger entry in cb_tag'; $statement = $pearDB->query("DELETE FROM cb_tag WHERE tagname = 'logger'"); $errorMessage = 'Unable to update the description in cb_field'; $statement = $pearDB->query( "UPDATE cb_field SET `description` = 'Time in seconds to wait between each connection attempt (Default value: 30s).' WHERE `cb_field_id` = 31" ); $errorMessage = 'Cannot purge host macros'; $cache = loadHosts($pearDB); foreach ($cache as $hostId => $value) { cleanDuplicateHostMacros($pearDB, $centreonLog, $cache, (int) $hostId); } $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); } /** * @param CentreonDb $db * @return array<int, array<string, mixed>> */ function loadHosts(CentreonDb $db): array { $stmt = $db->prepare('SELECT host_id, host_name FROM host'); $stmt->execute(); $cache = $stmt->fetchAll(PDO::FETCH_GROUP | PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC); $stmt = $db->prepare( 'SELECT host_host_id, host_tpl_id FROM host_template_relation ORDER BY `host_host_id`, `order` ASC' ); $stmt->execute(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $cache[$row['host_host_id']]['htpl'][] = $row['host_tpl_id']; } $stmt = $db->prepare( 'SELECT host_macro_id, host_host_id, host_macro_name, host_macro_value FROM on_demand_macro_host' ); $stmt->execute(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $cache[$row['host_host_id']]['macros'][$row['host_macro_name']] = $row; } return $cache; } /** * @param CentreonDb $db * @param CentreonLog $centreonLog * @param array<int, array<string, mixed>> $cache * @param int $srcHostId */ function cleanDuplicateHostMacros( CentreonDb $db, CentreonLog $centreonLog, array $cache, int $srcHostId, ): void { global $versionOfTheUpgrade; if (! isset($cache[$srcHostId]['htpl']) || ! isset($cache[$srcHostId]['macros'])) { return; } $loop = []; $stack = []; $macros = $cache[$srcHostId]['macros']; $stack = $cache[$srcHostId]['htpl']; while (($hostId = array_shift($stack)) !== null) { if (isset($loop[$hostId])) { continue; } $loop[$hostId] = 1; foreach ($macros as $macroName => $macro) { if (isset($macro['checked']) && $macro['checked'] === 1) { continue; } if (isset($cache[$hostId]['macros'][$macroName])) { $macro['checked'] = 1; if ($cache[$hostId]['macros'][$macroName]['host_macro_value'] === $macro['host_macro_value']) { $centreonLog->insertLog( 4, $versionOfTheUpgrade . 'host ' . $cache[$hostId]['host_name'] . ' delete macro ' . $macroName ); $db->query( 'DELETE FROM on_demand_macro_host WHERE host_macro_id = ' . (int) $macro['host_macro_id'] ); } } } if (isset($cache[$hostId]['htpl'])) { $stack = array_merge($cache[$hostId]['htpl'], $stack); } } // clean empty macros with no macros inherited foreach ($macros as $macroName => $macro) { if (! isset($macro['checked']) && empty($macro['host_macro_value'])) { $centreonLog->insertLog( 4, $versionOfTheUpgrade . 'host ' . $cache[$srcHostId]['host_name'] . ' delete macro ' . $macroName ); $db->query( 'DELETE FROM on_demand_macro_host WHERE host_macro_id = ' . (int) $macro['host_macro_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-20.04.19.php
centreon/www/install/php/Update-20.04.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 * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 20.04.19:'; $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' ); } $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.14.php
centreon/www/install/php/Update-21.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-22.04.10.php
centreon/www/install/php/Update-22.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 * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 22.04.10: '; try { // Transactional queries $pearDB->beginTransaction(); // Update illegal_object_name_chars + illegal_macro_output_chars fields from cf_nagios table. // The aim is to decode entities from them. // We fix here in 22.04.10 the flag problem which changed between php 8.0 and php 8.1 $errorMessage = 'Unable to update illegal characters fields from engine configuration of pollers'; (static 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); // We want to enforce the flags as if we are in PHP 8.1 and not let the current // version 8.0 default flags which not enough for entities like &#039; (ENT_COMPAT) $defaultPhp81Flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401; $preparedUpdate = null; foreach ($configs as $config) { $modified = $config; $modified['illegal_object_name_chars'] = html_entity_decode($config['illegal_object_name_chars'], $defaultPhp81Flags); $modified['illegal_macro_output_chars'] = html_entity_decode($config['illegal_macro_output_chars'], $defaultPhp81Flags); if ($config === $modified) { // no need to update, we skip a useless query continue; } $preparedUpdate ??= $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 ); $preparedUpdate->bindValue(':illegal_object_name_chars', $modified['illegal_object_name_chars'], PDO::PARAM_STR); $preparedUpdate->bindValue(':illegal_macro_output_chars', $modified['illegal_macro_output_chars'], PDO::PARAM_STR); $preparedUpdate->bindValue(':nagios_id', $modified['nagios_id'], PDO::PARAM_INT); $preparedUpdate->execute(); } })( $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-2.8.18.php
centreon/www/install/php/Update-2.8.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 * */ // Update comments unique key 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='index1'"; $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-19.10.19.php
centreon/www/install/php/Update-19.10.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 * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; // error specific content $versionOfTheUpgrade = 'UPGRADE - 19.10.19 : '; $errorMessage = ''; try { $statement = $pearDB->query( 'SELECT COLUMN_DEFAULT FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = \'centreon\' AND TABLE_NAME = \'on_demand_macro_host\' AND COLUMN_NAME = \'is_password\'' ); if (($result = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { $defaultValue = $result['COLUMN_DEFAULT']; if ($defaultValue !== 0) { // An update is required $errorMessage = 'Impossible to alter the table on_demand_macro_host'; $pearDB->query('ALTER TABLE on_demand_macro_host ALTER is_password SET DEFAULT 0'); $errorMessage = 'Impossible to update the column on_demand_macro_host.is_password'; $pearDB->query('UPDATE on_demand_macro_host SET is_password = 0 WHERE is_password IS NULL'); } } $statement = $pearDB->query( 'SELECT COLUMN_DEFAULT FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = \'centreon\' AND TABLE_NAME = \'on_demand_macro_service\' AND COLUMN_NAME = \'is_password\'' ); if (($defaultValue = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { $defaultValue = $result['COLUMN_DEFAULT']; if ($defaultValue !== 0) { // An update is required $errorMessage = 'Impossible to alter the table on_demand_macro_service'; $pearDB->query('ALTER TABLE on_demand_macro_service ALTER is_password SET DEFAULT 0'); $errorMessage = 'Impossible to update the column on_demand_macro_service.is_password'; $pearDB->query('UPDATE on_demand_macro_service SET is_password = 0 WHERE is_password IS NULL'); } } } catch (Throwable $ex) { (new CentreonLog())->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . $ex->getCode() . ' - Error : ' . $ex->getMessage() . ' - Trace : ' . $ex->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, $ex->getCode(), $ex); } // Contact language with transaction try { $pearDB->beginTransaction(); $errorMessage = 'Unable to Update user language'; $pearDB->query( "UPDATE contact SET contact_lang = CONCAT(contact_lang, '.UTF-8') WHERE contact_lang NOT LIKE '%UTF-8' AND contact_lang <> 'browser' AND contact_lang <> ''" ); $pearDB->commit(); } catch (Throwable $ex) { $pearDB->rollBack(); (new CentreonLog())->insertLog( 4, $versionOfTheUpgrade . $errorMessage . ' - Code : ' . $ex->getCode() . ' - Error : ' . $ex->getMessage() . ' - Trace : ' . $ex->getTraceAsString() ); throw new Exception($versionOfTheUpgrade . $errorMessage, $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-25.01.1.php
centreon/www/install/php/Update-25.01.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-22.04.13.php
centreon/www/install/php/Update-22.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 * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 22.04.13: '; $errorMessage = ''; $updateOpenIdCustomConfiguration = function (CentreonDB $pearDB): void { $customConfigurationJson = $pearDB->query( <<<'SQL' SELECT custom_configuration FROM provider_configuration WHERE name = 'openid' SQL )->fetchColumn(); $customConfiguration = json_decode($customConfigurationJson, true); if (! array_key_exists('redirect_url', $customConfiguration)) { $customConfiguration['redirect_url'] = null; $updatedCustomConfigurationEncoded = json_encode($customConfiguration); $statement = $pearDB->prepare( <<<'SQL' UPDATE provider_configuration SET custom_configuration = :encodedConfiguration WHERE name = 'openid' SQL ); $statement->bindValue(':encodedConfiguration', $updatedCustomConfigurationEncoded, PDO::PARAM_STR); $statement->execute(); } }; try { if (! $pearDB->inTransaction()) { $pearDB->beginTransaction(); } $errorMessage = 'Unable to update provider_configuration table to add redirect_url'; $updateOpenIdCustomConfiguration($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-22.04.12.php
centreon/www/install/php/Update-22.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-24.10.0.php
centreon/www/install/php/Update-24.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 * */ require_once __DIR__ . '/../../../bootstrap.php'; require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 24.10.0: '; $errorMessage = ''; // CLOCK WIDGET $insertWebPageWidget = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to select data into table dashboard_widgets'; $statement = $pearDB->executeQuery( <<<'SQL' SELECT 1 FROM `dashboard_widgets` WHERE `name` = 'centreon-widget-webpage' SQL ); $errorMessage = 'Unable to insert data into table dashboard_widgets'; if ((bool) $statement->fetch(PDO::FETCH_COLUMN) === false) { $pearDB->executeQuery( <<<'SQL' INSERT INTO `dashboard_widgets` (`name`) VALUES ('centreon-widget-webpage') SQL ); } }; // Vault configuration $insertVaultConfiguration = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to retrieve from topology table'; $statement = $pearDB->executeQuery( <<<'SQL' SELECT 1 FROM `topology` WHERE `topology_name` = 'Vault' SQL ); $errorMessage = 'Unable to insert data into table topology'; if ((bool) $statement->fetch(PDO::FETCH_COLUMN) === false) { $pearDB->executeQuery( <<<'SQL' INSERT INTO `topology` (`topology_name`, `topology_url`, `readonly`, `is_react`, `topology_parent`, `topology_page`, `topology_order`, `topology_group`, `topology_feature_flag`) VALUES ('Vault', '/administration/parameters/vault', '1', '1', 501, 50112, 100, 1, 'vault') SQL ); } }; $addDisableServiceCheckColumn = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to add column host_down_disable_service_checks to table cfg_nagios'; if (! $pearDB->isColumnExist('cfg_nagios', 'host_down_disable_service_checks')) { $pearDB->executeQuery( <<<'SQL' ALTER TABLE `cfg_nagios` ADD COLUMN `host_down_disable_service_checks` ENUM('0', '1') DEFAULT '0' AFTER `enable_predictive_service_dependency_checks` SQL ); } }; // ACC $fixNamingAndActivateAccTopology = function (CentreonDB $pearDB) use (&$errorMessage): void { $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 update table topology'; $constraintStatement = $pearDB->prepareQuery( <<<'SQL' UPDATE `topology` SET `topology_show` = :show, `topology_name` = 'Additional connector configurations', `topology_order` = 91 WHERE `topology_url` = '/configuration/additional-connector-configurations' SQL ); $pearDB->executePreparedQuery($constraintStatement, [':show' => $isCentral === 'yes' ? '1' : '0']); }; // Nagios Macros $updateNagiosMacros = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to check for existing macros in nagios_macro table'; $statement = $pearDB->executeQuery( <<<'SQL' SELECT COUNT(*) FROM `nagios_macro` WHERE `macro_name` IN ( '$NOTIFICATIONAUTHOR$', '$NOTIFICATIONAUTHORNAME$', '$NOTIFICATIONAUTHORALIAS$', '$NOTIFICATIONCOMMENT$' ) SQL ); $errorMessage = 'Unable to insert new macros into nagios_macro table'; if ((int) $statement->fetch(PDO::FETCH_COLUMN) === 0) { $pearDB->executeQuery( <<<'SQL' INSERT INTO `nagios_macro` (`macro_name`) VALUES ('$NOTIFICATIONAUTHOR$'), ('$NOTIFICATIONAUTHORNAME$'), ('$NOTIFICATIONAUTHORALIAS$'), ('$NOTIFICATIONCOMMENT$') SQL ); } $errorMessage = 'Unable to delete deprecated macros from nagios_macro table'; $pearDB->executeQuery( <<<'SQL' DELETE FROM `nagios_macro` WHERE `macro_name` IN ( '$HOSTACKAUTHOR$', '$HOSTACKCOMMENT$', '$SERVICEACKAUTHOR$', '$SERVICEACKCOMMENT$' ) SQL ); }; try { $addDisableServiceCheckColumn($pearDB); // Transactional queries if (! $pearDB->inTransaction()) { $pearDB->beginTransaction(); } $insertVaultConfiguration($pearDB); $insertWebPageWidget($pearDB); $fixNamingAndActivateAccTopology($pearDB); $updateNagiosMacros($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.3.php
centreon/www/install/php/Update-19.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 * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // remove ldap users missing contact name // these users have been added using the auto-import ldap feature // and will be re-imported at their next login. try { $pearDB->query( 'DELETE FROM contact WHERE contact_name = ""' ); } catch (PDOException $e) { $centreonLog->insertLog( 2, 'UPGRADE : 19.10.3 Unable to delete ldap auto-imported users with empty contact_name' ); } // correct the DN of manually imported users from an LDAP try { // finding the data of contacts linked to an LDAP $stmt = $pearDB->query( 'SELECT contact_id, contact_name, contact_ldap_dn FROM contact WHERE ar_id is NOT NULL' ); $updateDB = $pearDB->prepare( 'UPDATE contact SET contact_ldap_dn = :newDn WHERE contact_id = :contactId' ); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { // removing the double slashes if needed and saving the corrected data if (strpos($row['contact_ldap_dn'], '\\\\')) { $newDn = str_replace('\\\\', '\\', $row['contact_ldap_dn']); $updateDB->bindValue(':newDn', $newDn, PDO::PARAM_STR); $updateDB->bindValue(':contactId', $row['contact_id'], PDO::PARAM_INT); $updateDB->execute(); } } } catch (PDOException $e) { $centreonLog->insertLog( 2, 'UPGRADE : 19.10.3 Unable to correct the LDAP DN data' ); }
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.04.1.php
centreon/www/install/php/Update-19.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 * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); try { $pearDB->query('SET SESSION innodb_strict_mode=OFF'); // Add HTTPS connexion to Remote Server if (! $pearDB->isColumnExist('remote_servers', 'http_method')) { $pearDB->query( "ALTER TABLE remote_servers ADD COLUMN `http_method` enum('http','https') NOT NULL DEFAULT 'http'" ); } if (! $pearDB->isColumnExist('remote_servers', 'http_port')) { $pearDB->query( 'ALTER TABLE remote_servers ADD COLUMN `http_port` int(11) NULL DEFAULT NULL' ); } if (! $pearDB->isColumnExist('remote_servers', 'no_check_certificate')) { $pearDB->query( "ALTER TABLE remote_servers ADD COLUMN `no_check_certificate` enum('0','1') NOT NULL DEFAULT '0'" ); } if (! $pearDB->isColumnExist('remote_servers', 'no_proxy')) { $pearDB->query( "ALTER TABLE remote_servers ADD COLUMN `no_proxy` enum('0','1') NOT NULL DEFAULT '0'" ); } } catch (PDOException $e) { $centreonLog->insertLog( 2, 'UPGRADE : Unable to process 19.04.1 upgrade' ); } 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-19.04.3.php
centreon/www/install/php/Update-19.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 * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); try { // Change traps_execution_command from varchar(255) to text $pearDB->query( 'ALTER TABLE `traps` MODIFY COLUMN `traps_execution_command` text DEFAULT NULL' ); // 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`" ); } // Add trap filter $pearDB->query( "ALTER TABLE `traps` MODIFY COLUMN `traps_exec_interval_type` ENUM('0','1','2','3') NULL DEFAULT '0'" ); } catch (PDOException $e) { $centreonLog->insertLog( 2, 'UPGRADE : Unable to process 19.04.3 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-22.10.0-beta.1.php
centreon/www/install/php/Update-22.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 * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 22.10.0-beta.1: '; $errorMessage = ''; /** * Manage relations between remote servers and nagios servers * * @param CentreonDB $pearDB */ $migrateRemoteServerRelations = function (CentreonDB $pearDB): void { $processedIps = []; $selectServerStatement = $pearDB->prepare( 'SELECT id FROM nagios_server WHERE ns_ip_address = :ip_address' ); $deleteRemoteStatement = $pearDB->prepare( 'DELETE FROM remote_servers WHERE id = :id' ); $updateRemoteStatement = $pearDB->prepare( 'UPDATE remote_servers SET server_id = :server_id WHERE id = :id' ); $result = $pearDB->query( 'SELECT id, ip FROM remote_servers' ); while ($remote = $result->fetch()) { $remoteIp = $remote['ip']; $remoteId = $remote['id']; if (in_array($remoteIp, $processedIps)) { $deleteRemoteStatement->bindValue(':id', $remoteId, PDO::PARAM_INT); $deleteRemoteStatement->execute(); } $processedIps[] = $remoteIp; $selectServerStatement->bindValue(':ip_address', $remoteIp, PDO::PARAM_STR); $selectServerStatement->execute(); if ($server = $selectServerStatement->fetch()) { $updateRemoteStatement->bindValue(':server_id', $server['id'], PDO::PARAM_INT); $updateRemoteStatement->bindValue(':id', $remoteId, PDO::PARAM_INT); $updateRemoteStatement->execute(); } else { $deleteRemoteStatement->bindValue(':id', $remoteId, PDO::PARAM_INT); $deleteRemoteStatement->execute(); } } }; try { $errorMessage = "Impossible to update 'cb_field' table"; $pearDB->query('ALTER TABLE cb_field MODIFY description VARCHAR(510) DEFAULT NULL'); $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'); } $errorMessage = "Impossible to create 'security_provider_contact_group_relation'"; $pearDB->query('CREATE TABLE IF NOT EXISTS `security_provider_contact_group_relation` ( `claim_value` VARCHAR(255) NOT NULL, `contact_group_id` int(11) NOT NULL, `provider_configuration_id` int(11) NOT NULL, PRIMARY KEY (`claim_value`, `contact_group_id`, `provider_configuration_id`), CONSTRAINT `security_provider_contact_group_id` FOREIGN KEY (`contact_group_id`) REFERENCES `contactgroup` (`cg_id`) ON DELETE CASCADE, CONSTRAINT `security_provider_configuration_provider_id` FOREIGN KEY (`provider_configuration_id`) REFERENCES `provider_configuration` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8'); $pearDB->beginTransaction(); $errorMessage = "Unable to delete 'oreon_web_path' and color options from database"; $pearDB->query("DELETE FROM `options` WHERE `key` = 'oreon_web_path' OR `key` LIKE 'color_%'"); $errorMessage = "Unable to delete 'appKey' information from database"; $pearDB->query("DELETE FROM `informations` WHERE `key` = 'appKey'"); $errorMessage = 'Impossible to add new BBDO streams'; createBbdoStreamConfigurationForms($pearDB); $errorMessage = 'Impossible to update pollers ACLs'; updatePollerAcls($pearDB); $errorMessage = 'Impossible to update OpenID Provider configuration'; updateOpenIdCustomConfiguration($pearDB); $pearDB->commit(); if ($pearDB->isColumnExist('remote_servers', 'app_key') === 1) { $errorMessage = "Unable to drop 'app_key' from remote_servers table"; $pearDB->query('ALTER TABLE remote_servers DROP COLUMN `app_key`'); } if ($pearDB->isColumnExist('remote_servers', 'server_id') === 0) { $errorMessage = "Unable to add 'server_id' column to remote_servers table"; $pearDB->query( 'ALTER TABLE remote_servers ADD COLUMN `server_id` int(11) NOT NULL' ); $migrateRemoteServerRelations($pearDB); $errorMessage = 'Unable to add foreign key constraint of remote_servers.server_id'; $pearDB->query( 'ALTER TABLE remote_servers ADD CONSTRAINT `remote_server_nagios_server_ibfk_1` FOREIGN KEY(`server_id`) REFERENCES `nagios_server` (`id`) ON DELETE CASCADE' ); } } catch (Exception $e) { if ($pearDB->inTransaction()) { $pearDB->rollBack(); } 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); } /** * @param CentreonDB $pearDB * @throws Exception */ function updatePollerAcls(CentreonDB $pearDB): void { $stmt = $pearDB->query( 'SELECT topology_id FROM topology WHERE topology_page = 60901' ); $pollersTopologyId = $stmt->fetch(); if ($pollersTopologyId === false) { return; } $pollersTopologyId = (int) $pollersTopologyId['topology_id']; updatePollerActionsAcls($pearDB, $pollersTopologyId); updatePollerMenusAcls($pearDB, $pollersTopologyId); } /** * @param CentreonDB $pearDB * @param int $topologyId * @throws Exception */ function updatePollerMenusAcls(CentreonDB $pearDB, int $topologyId): void { $stmt = $pearDB->prepare( "UPDATE acl_topology_relations SET access_right = '1' WHERE access_right = '2' AND topology_topology_id = :topologyId" ); $stmt->bindValue(':topologyId', $topologyId, PDO::PARAM_INT); $stmt->execute(); $stmt = $pearDB->prepare("UPDATE topology SET readonly = '1' WHERE topology_id = :topologyId"); $stmt->bindValue(':topologyId', $topologyId, PDO::PARAM_INT); $stmt->execute(); } /** * @param CentreonDB $pearDB * @param int $topologyId * @throws Exception */ function updatePollerActionsAcls(CentreonDB $pearDB, int $topologyId): void { // Get ACL action ids linked to pollers page with read/write access $stmt = $pearDB->prepare( "SELECT DISTINCT(gar.acl_action_id) FROM acl_group_actions_relations gar JOIN acl_group_topology_relations gtr ON gar.acl_group_id = gtr.acl_group_id JOIN acl_topology_relations tr ON tr.acl_topo_id = gtr.acl_topology_id WHERE tr.topology_topology_id = :topologyId AND tr.access_right = '1'" ); $stmt->bindValue(':topologyId', $topologyId, PDO::PARAM_INT); $stmt->execute(); $actionIdsToUpdate = $stmt->fetchAll(PDO::FETCH_COLUMN, 0); if (empty($actionIdsToUpdate)) { return; } // Get ACL action ids linked to pollers page without read/write access $stmt = $pearDB->prepare( "SELECT DISTINCT(gar.acl_action_id) FROM acl_group_actions_relations gar JOIN acl_group_topology_relations gtr ON gar.acl_group_id = gtr.acl_group_id WHERE gtr.acl_topology_id NOT IN ( SELECT acl_topo_id FROM acl_topology_relations WHERE topology_topology_id = :topologyId AND access_right = '1' )" ); $stmt->bindValue(':topologyId', $topologyId, PDO::PARAM_INT); $stmt->execute(); $actionIdsToExclude = $stmt->fetchAll(PDO::FETCH_COLUMN, 0); foreach ($actionIdsToUpdate as $actionId) { /** * Do not update ACL action linked to write AND read only / none pollers page access * so the most restrictive access wins */ if (in_array($actionId, $actionIdsToExclude)) { continue; } $stmt = $pearDB->prepare( "INSERT INTO acl_actions_rules (acl_action_rule_id, acl_action_name) VALUES (:actionId, 'create_edit_poller_cfg'), (:actionId, 'delete_poller_cfg')" ); $stmt->bindValue(':actionId', $actionId); $stmt->execute(); } } /** * @param CentreonDb $pearDB */ function createBbdoStreamConfigurationForms(CentreonDb $pearDB): void { $streams = insertStreams($pearDB); $fields = getFieldsDetails(); $tagTypeRelationStmt = $pearDB->prepare('INSERT INTO cb_tag_type_relation VALUES (1, :typeId, 0), (2, :typeId, 0)'); foreach ($streams as $id => $name) { $tagTypeRelationStmt->bindValue(':typeId', $id, PDO::PARAM_INT); $tagTypeRelationStmt->execute(); $fields[$name] = insertFields($pearDB, $fields[$name]); linkFieldsToStreamType($pearDB, $id, $fields[$name]); } } /** * @param CentreonDB $pearDB * @param int $streamTypeId * @param array<string,string|int|null> $fields */ function linkFieldsToStreamType(CentreonDB $pearDB, int $streamTypeId, array $fields): void { $typeFieldRelationStmt = $pearDB->prepare( 'INSERT INTO cb_type_field_relation (cb_type_id, cb_field_id, is_required, order_display, jshook_name, jshook_arguments) VALUES (:typeId, :fieldId, :isRequired, :orderDisplay, :jshook_name, :jshook_arguments)' ); foreach ($fields as $key => $field) { $typeFieldRelationStmt->bindValue(':typeId', $streamTypeId, PDO::PARAM_INT); $typeFieldRelationStmt->bindValue(':fieldId', $field['id'], PDO::PARAM_INT); $typeFieldRelationStmt->bindValue(':isRequired', $field['isRequired'], PDO::PARAM_STR); $typeFieldRelationStmt->bindValue(':orderDisplay', $key, PDO::PARAM_STR); $typeFieldRelationStmt->bindValue(':jshook_name', $field['jsHook'] ?? null, PDO::PARAM_STR); $typeFieldRelationStmt->bindValue(':jshook_arguments', $field['jsArguments'] ?? null, PDO::PARAM_STR); $typeFieldRelationStmt->execute(); } } /** * @param CentreonDB $pearDB * @return array<int,string> */ function insertStreams(CentreonDB $pearDB): array { $pearDB->query("INSERT INTO cb_module VALUES (NULL, 'BBDO', NULL, NULL, 0, 1)"); $moduleId = $pearDB->lastInsertId(); $stmt = $pearDB->prepare( "INSERT INTO cb_type (type_name, type_shortname, cb_module_id) VALUES ('BBDO Server', 'bbdo_server', :moduleId), ('BBDO Client', 'bbdo_client', :moduleId)" ); $stmt->bindValue(':moduleId', $moduleId, PDO::PARAM_INT); $stmt->execute(); $stmt = $pearDB->query( "SELECT cb_type_id, type_shortname FROM cb_type WHERE type_shortname in ('bbdo_server', 'bbdo_client')" ); return $stmt->fetchAll(PDO::FETCH_KEY_PAIR); } /** * @param CentreonDB $pearDB * @param array<string,string|int|null> $fields * @return array<string,string|int|null> */ function insertFields(CentreonDB $pearDB, array $fields): array { $fieldStmt = $pearDB->prepare( 'INSERT INTO cb_field (fieldname, displayname, fieldtype, description) VALUES (:fieldname, :displayname, :fieldtype, :description)' ); foreach ($fields as &$field) { $fieldStmt->bindValue(':fieldname', $field['fieldname'], PDO::PARAM_STR); $fieldStmt->bindValue(':displayname', $field['displayname'], PDO::PARAM_STR); $fieldStmt->bindValue(':fieldtype', $field['fieldtype'], PDO::PARAM_STR); $fieldStmt->bindValue(':description', $field['description'], PDO::PARAM_STR); $fieldStmt->execute(); $field['id'] = $pearDB->lastInsertId(); if (in_array($field['fieldtype'], ['radio', 'multiselect'])) { insertFieldOptions($pearDB, $field); } } return $fields; } /** * @param CentreonDB $pearDB * @param array<string,string|int|null> $field * @throws Exception */ function insertFieldOptions(CentreonDB $pearDB, array $field): void { if (in_array($field['fieldname'], ['encryption', 'compression', 'retention'])) { $field['optionListId'] = findListIdByFieldname($pearDB, 'config'); } else { $field['optionListId'] = findListIdByFieldname($pearDB, $field['fieldname']); } $fieldOptionsStmt = $pearDB->prepare( 'INSERT INTO cb_list (cb_list_id, cb_field_id, default_value) VALUES (:listId, :fieldId, :defaultValue)' ); $fieldOptionsStmt->bindValue(':listId', $field['optionListId'], PDO::PARAM_INT); $fieldOptionsStmt->bindValue(':fieldId', $field['id'], PDO::PARAM_INT); $fieldOptionsStmt->bindValue(':defaultValue', $field['defaultValue'], PDO::PARAM_STR); $fieldOptionsStmt->execute(); if ($field['fieldname'] === 'transport_protocol') { insertGrpcListOptions($pearDB, $field['optionListId']); } } /** * Retrieve a list id based on an existing field name already attached to it * * @param CentreonDB $pearDB * @param string $fieldname * @throws Exception * @return int */ function findListIdByFieldname(CentreonDB $pearDB, string $fieldname): int { $stmt = $pearDB->prepare( 'SELECT l.cb_list_id FROM cb_list l, cb_field f WHERE l.cb_field_id = f.cb_field_id AND f.fieldname = :fieldname' ); $stmt->bindValue(':fieldname', $fieldname, PDO::PARAM_STR); $stmt->execute(); $listId = $stmt->fetchColumn(); if ($listId === false) { if ($fieldname === 'transport_protocol') { $stmt = $pearDB->query('SELECT MAX(cb_list_id) FROM cb_list_values'); $maxId = $stmt->fetchColumn(); if ($maxId === false) { throw new Exception('Cannot find biggest cb_list_id in cb_list_values table'); } $listId = $maxId + 1; } else { throw new Exception('Cannot find cb_list_id in cb_list_values table'); } } return $listId; } /** * @param CentreonDB $pearDB * @param int $listId * @throws Exception * @return int id of the newly created list */ function insertGrpcListOptions(CentreonDB $pearDB, int $listId): void { $stmt = $pearDB->prepare('SELECT 1 FROM cb_list_values where cb_list_id = :listId'); $stmt->bindValue(':listId', $listId, PDO::PARAM_INT); $stmt->execute(); $doesListExist = $stmt->fetchColumn(); if ($doesListExist) { return; } $insertStmt = $pearDB->prepare( "INSERT INTO cb_list_values VALUES (:listId, 'gRPC', 'gRPC'), (:listId, 'TCP', 'TCP')" ); $insertStmt->bindValue(':listId', $listId, PDO::PARAM_INT); $insertStmt->execute(); } /** * @return array{bbdo_server:<string,string|int|null>,bbdo_client:<string,string|int|null>} */ function getFieldsDetails(): array { $bbdoServer = [ [ 'fieldname' => 'host', 'displayname' => 'Listening address (optional)', 'fieldtype' => 'text', 'description' => 'Fill in this field only if you want to specify the address on which Broker ' . 'should listen', 'isRequired' => 0, ], [ 'fieldname' => 'port', 'displayname' => 'Listening port', 'fieldtype' => 'text', 'description' => 'TCP port on which Broker should listen', 'isRequired' => 1, ], [ 'fieldname' => 'transport_protocol', 'displayname' => 'Transport protocol', 'fieldtype' => 'radio', 'description' => 'The transport protocol can be either TCP (binary flow over TCP) or gRPC (HTTP2)', 'isRequired' => 1, 'defaultValue' => 'gRPC', 'optionListId' => null, 'jsHook' => 'bbdoStreams', 'jsArguments' => '{"target": "authorization", "value": "gRPC"}', ], [ 'fieldname' => 'authorization', 'displayname' => 'Authorization token (optional)', 'fieldtype' => 'password', 'description' => 'Authorization token to be requested from the client (must be the same for both client ' . 'and server)', 'isRequired' => 0, ], [ 'fieldname' => 'encryption', 'displayname' => 'Enable TLS encryption', 'fieldtype' => 'radio', 'description' => 'Enable TLS 1.3 encryption', 'isRequired' => 1, 'defaultValue' => 'no', 'optionListId' => null, 'jsHook' => 'bbdoStreams', 'jsArguments' => '{"target": ["private_key", "certificate"], "value": "yes"}', ], [ 'fieldname' => 'private_key', 'displayname' => 'Private key path', 'fieldtype' => 'text', 'description' => 'Full path to the file containing the private key in PEM format (required for encryption)', 'isRequired' => 0, ], [ 'fieldname' => 'certificate', 'displayname' => 'Certificate path', 'fieldtype' => 'text', 'description' => 'Full path to the file containing the certificate in PEM format (required for encryption)', 'isRequired' => 0, ], [ 'fieldname' => 'compression', 'displayname' => 'Compression', 'fieldtype' => 'radio', 'description' => 'Enable data compression', 'isRequired' => 1, 'defaultValue' => 'no', 'optionListId' => null, 'jsHook' => 'bbdoStreams', 'jsArguments' => '{"tag": "output"}', ], [ 'fieldname' => 'retention', 'displayname' => 'Enable retention', 'fieldtype' => 'radio', 'description' => 'Enable data retention until the client is connected', 'isRequired' => 1, 'defaultValue' => 'no', 'optionListId' => null, 'jsHook' => 'bbdoStreams', 'jsArguments' => '{"tag": "output"}', ], [ 'fieldname' => 'category', 'displayname' => 'Filter on event categories', 'fieldtype' => 'multiselect', 'description' => 'Broker event categories to filter. If none is selected, all categories of events will ' . 'be processed', 'isRequired' => 0, 'defaultValue' => null, 'optionListId' => null, ], ]; $bbdoClient = [ [ 'fieldname' => 'host', 'displayname' => 'Server address', 'fieldtype' => 'text', 'description' => 'Address of the server to which the client should connect', 'isRequired' => 1, ], [ 'fieldname' => 'port', 'displayname' => 'Server port', 'fieldtype' => 'int', 'description' => 'TCP port of the server to which the client should connect', 'isRequired' => 1, ], [ 'fieldname' => 'retry_interval', 'displayname' => 'Retry interval (seconds)', 'fieldtype' => 'int', 'description' => 'Number of seconds between a lost or failed connection and the next try', 'isRequired' => 0, ], [ 'fieldname' => 'transport_protocol', 'displayname' => 'Transport protocol', 'fieldtype' => 'radio', 'description' => 'The transport protocol can be either TCP (binary flow over TCP) or gRPC (HTTP2)', 'isRequired' => 1, 'defaultValue' => 'gRPC', 'optionListId' => null, 'jsHook' => 'bbdoStreams', 'jsArguments' => '{"target": "authorization", "value": "gRPC"}', ], [ 'fieldname' => 'authorization', 'displayname' => 'Authorization token (optional)', 'fieldtype' => 'password', 'description' => 'Authorization token expected by the server (must be the same for both client and server)', 'isRequired' => 0, ], [ 'fieldname' => 'encryption', 'displayname' => 'Enable TLS encryption', 'fieldtype' => 'radio', 'description' => 'Enable TLS 1.3 encryption', 'isRequired' => 1, 'defaultValue' => 'no', 'optionListId' => null, 'jsHook' => 'bbdoStreams', 'jsArguments' => '{"target": ["ca_certificate", "ca_name"], "value": "yes"}', ], [ 'fieldname' => 'ca_certificate', 'displayname' => 'Trusted CA\'s certificate path (optional)', 'fieldtype' => 'text', 'description' => "If the server's certificate is signed by an untrusted Certification Authority (CA), " . "then specify the certificate's path.\nIf the server's certificate is self-signed, then specify " . "its path.\n You can also add the certificate to the store of certificates trusted by the operating " . "system.\nThe file must be in PEM format.", 'isRequired' => 0, ], [ 'fieldname' => 'ca_name', 'displayname' => 'Certificate Common Name (optional)', 'fieldtype' => 'text', 'description' => 'If the Common Name (CN) of the certificate is different from the value in the ' . '"Server address" field, the CN must be provided here', 'isRequired' => 0, ], [ 'fieldname' => 'compression', 'displayname' => 'Compression', 'fieldtype' => 'radio', 'description' => 'Enable data compression', 'isRequired' => 1, 'defaultValue' => 'no', 'optionListId' => null, 'jsHook' => 'bbdoStreams', 'jsArguments' => '{"tag": "output"}', ], [ 'fieldname' => 'category', 'displayname' => 'Filter on event categories', 'fieldtype' => 'multiselect', 'description' => 'Broker event categories to filter. If none is selected, all categories of events will ' . 'be processed', 'isRequired' => 0, 'defaultValue' => null, 'optionListId' => 6, ], ]; return ['bbdo_server' => $bbdoServer, 'bbdo_client' => $bbdoClient]; } /** * Update Open ID Provider with new parameters. * * @param CentreonDB $pearDB */ function updateOpenIdCustomConfiguration(CentreonDB $pearDB): void { $statement = $pearDB->query("SELECT custom_configuration FROM provider_configuration WHERE `name`='openid'"); if ($result = $statement->fetch()) { $customConfiguration = json_decode($result['custom_configuration'], true); /** * Remove trusted & blacklist client addresses from root of custom configuration * and add them to authentication conditions */ $trustedClientAddresses = $customConfiguration['trusted_client_addresses']; $blacklistClientAddresses = $customConfiguration['blacklist_client_addresses']; unset($customConfiguration['trusted_client_addresses'], $customConfiguration['blacklist_client_addresses'], $customConfiguration['claim_name'], $customConfiguration['contact_group_id']); /** * Remove claim name and contact group id as they are know handled in roles mapping and groups mapping. */ $customConfiguration['authentication_conditions'] = [ 'is_enabled' => false, 'attribute_path' => '', 'endpoint' => ['type' => 'introspection_endpoint', 'custom_endpoint' => ''], 'authorized_values' => [], 'trusted_client_addresses' => $trustedClientAddresses, 'blacklist_client_addresses' => $blacklistClientAddresses, ]; $customConfiguration['roles_mapping'] = [ 'is_enabled' => false, 'apply_only_first_role' => false, 'attribute_path' => '', 'endpoint' => ['type' => 'introspection_endpoint', 'custom_endpoint' => ''], ]; $customConfiguration['groups_mapping'] = [ 'is_enabled' => false, 'attribute_path' => '', 'endpoint' => ['type' => 'introspection_endpoint', 'custom_endpoint' => ''], ]; $encodedConfiguration = json_encode($customConfiguration); $statement = $pearDB->prepare( "UPDATE provider_configuration SET custom_configuration = :customConfiguration WHERE `name`='openid'" ); $statement->bindValue(':customConfiguration', $encodedConfiguration, PDO::PARAM_STR); $statement->execute(); } }
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.4.php
centreon/www/install/php/Update-24.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 * */ require_once __DIR__ . '/../../../bootstrap.php'; require_once __DIR__ . '/../../class/centreonLog.class.php'; $versionOfTheUpgrade = 'UPGRADE - 24.10.4: '; $errorMessage = ''; /** * @param CentreonDB $pearDB * * @throws PDOException * @return void */ $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'); } }; /** * @param CentreonDB $pearDB * * @throws PDOException * @return void */ $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'); } }; /** * @param CentreonDB $pearDB * * @throws CentreonDBException * @return void */ $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 ); }; /** * @param CentreonDB $pearDB * * @throws PDOException * @return void */ $createUserProfileTable = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to add table user_profile'; $pearDB->exec( <<<'SQL' CREATE TABLE IF NOT EXISTS `user_profile` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `contact_id` INT(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `unique_user_profile` (`id`, `contact_id`), CONSTRAINT `fk_user_profile_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `contact` (`contact_id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; SQL ); }; /** * @param CentreonDB $pearDB * * @throws PDOException * @return void */ $createUserProfileFavoriteDashboards = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to add table user_profile_favorite_dashboards'; $pearDB->exec( <<<'SQL' CREATE TABLE IF NOT EXISTS `user_profile_favorite_dashboards` ( `profile_id` INT UNSIGNED NOT NULL, `dashboard_id` INT UNSIGNED NOT NULL, CONSTRAINT `fk_user_profile_favorite_dashboards_profile_id` FOREIGN KEY (`profile_id`) REFERENCES `user_profile` (`id`) ON DELETE CASCADE, CONSTRAINT `fk_user_profile_favorite_dashboards_dashboard_id` FOREIGN KEY (`dashboard_id`) REFERENCES `dashboard` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; SQL ); }; // -------------------------------------------- Resource Status -------------------------------------------- // /** * @param CentreonDB $pearDBO * * @throws PDOException * @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 ); } }; try { // DDL statements for real time database $addColumnToResourcesTable($pearDBO); // DDL statements for configuration database $addAllContactsColumnToAclGroups($pearDB); $addAllContactGroupsColumnToAclGroups($pearDB); $createUserProfileTable($pearDB); $createUserProfileFavoriteDashboards($pearDB); // Transactional queries for configuration database if (! $pearDB->inTransaction()) { $pearDB->beginTransaction(); } $fixNamingOfAccTopology($pearDB); $pearDB->commit(); } catch (Exception $e) { try { if ($pearDB->inTransaction()) { $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-next.php
centreon/www/install/php/Update-next.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\ConnectionInterface; use Adaptation\Database\Connection\Exception\ConnectionException; use Adaptation\Database\Connection\ValueObject\QueryParameter; use Core\AgentConfiguration\Domain\Model\AgentConfiguration; require_once __DIR__ . '/../../../bootstrap.php'; $version = 'xx.xx.x'; $errorMessage = ''; /** * @var ConnectionInterface $pearDB * @var ConnectionInterface $pearDBO */ // TODO add your functions here /** -------------------------------------- Backup updates -------------------------------------- */ $setBackupMysqlConfDefaultAsEmpty = function () use ($pearDB, &$errorMessage, $version): void { $errorMessage = 'Unable to reset default of database configuration path in backup configuration'; CentreonLog::create()->info( logTypeId: CentreonLog::TYPE_UPGRADE, message: "UPGRADE - {$version}: [backup] Updating default value of backup_mysql_conf in 'options' table", ); $pearDB->update( <<<'SQL' UPDATE options SET value = '' WHERE options.key = 'backup_mysql_conf' AND options.value = '/etc/my.cnf.d/centreon.cnf' SQL ); }; $updateFreshnessforCMAServicesAndHosts = function () use ($pearDB, &$errorMessage, $version): void { $errorMessage = 'Unable to select CMA connector'; CentreonLog::create()->info( logTypeId: CentreonLog::TYPE_UPGRADE, message: "UPGRADE - {$version}: [CMA] Selecting Centreon Monitoring Agent Connector ID", ); $cmaConnectorId = $pearDB->fetchOne( <<<'SQL' SELECT id FROM connector WHERE name = 'Centreon Monitoring Agent' SQL ); if ($cmaConnectorId === false) { CentreonLog::create()->info( logTypeId: CentreonLog::TYPE_UPGRADE, message: "UPGRADE - {$version}: [CMA] CMA connector not found, skipping check_freshness update", ); return; } $errorMessage = 'Unable to select commands for CMA connector'; CentreonLog::create()->info( logTypeId: CentreonLog::TYPE_UPGRADE, message: "UPGRADE - {$version}: [CMA] Selecting commands IDs for CMA connector", ); $commandsIds = $pearDB->fetchFirstColumn( <<<'SQL' SELECT DISTINCT command_id FROM command WHERE connector_id = :cmaConnectorId SQL, QueryParameters::create([QueryParameter::int('cmaConnectorId', $cmaConnectorId)]) ); if (empty($commandsIds)) { CentreonLog::create()->info( logTypeId: CentreonLog::TYPE_UPGRADE, message: "UPGRADE - {$version}: [CMA] No commands found for CMA connector, skipping check_freshness update", ); return; } $commandsIds = array_map('intval', $commandsIds); $commandsIdsAsString = implode(',', $commandsIds); $errorMessage = 'Unable to update service_check_freshness and service_freshness_threshold'; CentreonLog::create()->info( logTypeId: CentreonLog::TYPE_UPGRADE, message: "UPGRADE - {$version}: [CMA] Setting service_check_freshness to true and service_freshness_threshold " . 'to 120 for services using CMA commands', ); $pearDB->update( <<<SQL UPDATE service SET service_check_freshness = '1', service_freshness_threshold = 120 WHERE command_command_id IN ({$commandsIdsAsString}) SQL ); $errorMessage = 'Unable to update host_check_freshness and host_freshness_threshold'; CentreonLog::create()->info( logTypeId: CentreonLog::TYPE_UPGRADE, message: "UPGRADE - {$version}: [CMA] Setting host_check_freshness to true and host_freshness_threshold " . 'to 120 for hosts using CMA commands', ); $pearDB->update( <<<SQL UPDATE host SET host_check_freshness = '1', host_freshness_threshold = 120 WHERE command_command_id IN ({$commandsIdsAsString}) SQL ); }; $addDefaultPortToAgentInitiatedAgentConfiguration = function () use ($pearDB, &$errorMessage, $version): void { $errorMessage = 'Unable to add default port to agent initiated agent configurations'; CentreonLog::create()->info( logTypeId: CentreonLog::TYPE_UPGRADE, message: "UPGRADE - {$version}: [agent_configuration] Adding default port to agent initiated agent configurations", ); $agentConfigurations = $pearDB->fetchAllAssociative( <<<'SQL' SELECT id, configuration FROM agent_configuration SQL ); foreach ($agentConfigurations as $configurationJson) { $configuration = json_decode($configurationJson['configuration'], true, JSON_THROW_ON_ERROR); if (! isset($configuration['port'])) { $configuration['port'] = (bool) $configuration['agent_initiated'] === true ? AgentConfiguration::DEFAULT_PORT : null; } $updatedConfigurationJson = json_encode($configuration, JSON_THROW_ON_ERROR); $pearDB->update( <<<'SQL' UPDATE agent_configuration SET configuration = :configuration WHERE id = :id SQL, QueryParameters::create([ QueryParameter::string('configuration', $updatedConfigurationJson), QueryParameter::int('id', (int) $configurationJson['id']), ]) ); } }; $linkCMAConnectorToExistingRelatedCMACommands = function () use ($pearDB, &$errorMessage, $version): void { $errorMessage = 'Unable to select CMA connector'; CentreonLog::create()->info( logTypeId: CentreonLog::TYPE_UPGRADE, message: "UPGRADE - {$version}: [CMA] select existing Centreon Monitoring Agent Connector ID", ); $cmaConnectorId = $pearDB->fetchOne( <<<'SQL' SELECT id FROM connector WHERE name = 'Centreon Monitoring Agent' LIMIT 1 SQL ); if ($cmaConnectorId === false) { CentreonLog::create()->info( logTypeId: CentreonLog::TYPE_UPGRADE, message: "UPGRADE - {$version}: [CMA] No CMA connector found, skipping linking CMA commands", ); return; } $errorMessage = 'Unable to update commands to link them to CMA connector'; CentreonLog::create()->info( logTypeId: CentreonLog::TYPE_UPGRADE, message: "UPGRADE - {$version}: [CMA] Updating commands to link them to CMA connector", ); $pearDB->update( <<<'SQL' UPDATE command SET connector_id = :cmaConnectorId WHERE command_name LIKE "%Centreon-Monitoring-Agent%" OR command_name LIKE "%-CMA-%" SQL, QueryParameters::create([ QueryParameter::int('cmaConnectorId', $cmaConnectorId), ]) ); }; try { // DDL statements for real time database // TODO add your function calls to update the real time database structure here // DDL statements for configuration database // TODO add your function calls to update the configuration database structure here // Transactional queries for configuration database if (! $pearDB->isTransactionActive()) { $pearDB->startTransaction(); } // TODO add your function calls to update the configuration database data here $setBackupMysqlConfDefaultAsEmpty(); $updateFreshnessforCMAServicesAndHosts(); $addDefaultPortToAgentInitiatedAgentConfiguration(); $linkCMAConnectorToExistingRelatedCMACommands(); $pearDB->commitTransaction(); } catch (Throwable $throwable) { CentreonLog::create()->error( logTypeId: CentreonLog::TYPE_UPGRADE, message: "UPGRADE - {$version}: " . $errorMessage, exception: $throwable ); try { if ($pearDB->isTransactionActive()) { $pearDB->rollBackTransaction(); } } catch (ConnectionException $rollbackException) { CentreonLog::create()->error( logTypeId: CentreonLog::TYPE_UPGRADE, message: "UPGRADE - {$version}: error while rolling back the upgrade operation for : {$errorMessage}", exception: $rollbackException ); throw new RuntimeException( message: "UPGRADE - {$version}: error while rolling back the upgrade operation for : {$errorMessage}", previous: $rollbackException ); } throw new RuntimeException( message: "UPGRADE - {$version}: " . $errorMessage, previous: $throwable ); }
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.10.php
centreon/www/install/php/Update-23.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 * */
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.13.php
centreon/www/install/php/Update-22.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-22.04.17.php
centreon/www/install/php/Update-22.04.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.13.php
centreon/www/install/php/Update-21.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-2.8.11.php
centreon/www/install/php/Update-2.8.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/index.php
centreon/www/install/php/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/php/Update-2.8.13.php
centreon/www/install/php/Update-2.8.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.14.php
centreon/www/install/php/Update-20.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 * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 20.04.14 : '; /** * 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-25.09.2.php
centreon/www/install/php/Update-25.09.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.7.php
centreon/www/install/php/Update-21.04.7.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.7: '; /** * Query with transaction */ try { $pearDB->beginTransaction(); // Add TLS hostname in config brocker for input/outputs IPV4 $statement = $pearDB->query("SELECT cb_field_id from cb_field WHERE fieldname = 'tls_hostname'"); if ($statement->fetchColumn() === false) { $errorMessage = 'Unable to update cb_field'; $pearDB->query(" INSERT INTO `cb_field` ( `cb_field_id`, `fieldname`,`displayname`, `description`, `fieldtype`, `external` ) VALUES ( null, 'tls_hostname', 'TLS Host name', 'Expected TLS certificate common name (CN) - leave blank if unsure.', 'text', NULL ) "); $errorMessage = 'Unable to update cb_type_field_relation'; $fieldId = $pearDB->lastInsertId(); $pearDB->query(' INSERT INTO `cb_type_field_relation` (`cb_type_id`, `cb_field_id`, `is_required`, `order_display`) VALUES (3, ' . $fieldId . ', 0, 5) '); } if ($pearDB->inTransaction()) { $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.1.php
centreon/www/install/php/Update-19.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-18.10.0.post.php
centreon/www/install/php/Update-18.10.0.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 * */ // Generate random key for application key $uniqueKey = md5(uniqid(rand(), true)); $query = "INSERT INTO `informations` (`key`,`value`) VALUES ('appKey', '{$uniqueKey}')"; $pearDB->query($query); $query = "INSERT INTO `informations` (`key`,`value`) VALUES ('isRemote', 'no')"; $pearDB->query($query); $query = "INSERT INTO `informations` (`key`,`value`) VALUES ('isCentral', 'no')"; $pearDB->query($query); // Retrieve current Nagios plugins path. $query = "SELECT value FROM options WHERE `key`='nagios_path_plugins'"; $result = $pearDB->query($query); $row = $result->fetchRow(); // Update to new path if necessary. if ($row && preg_match('#/usr/lib/nagios/plugins/?#', $row['value']) && is_dir('/usr/lib64/nagios/plugins') ) { // options table. $query = "UPDATE options SET value='/usr/lib64/nagios/plugins/' WHERE `key`='nagios_path_plugins'"; $pearDB->query($query); // USER1 resource. $pearDB->query( "UPDATE cfg_resource SET resource_line='/usr/lib64/nagios/plugins' WHERE resource_line='/usr/lib/nagios/plugins'" ); } // fix menu acl when child is checked but its parent is not checked // get all acl menu configurations $aclTopologies = $pearDB->query('SELECT acl_topo_id FROM acl_topology'); while ($aclTopology = $aclTopologies->fetch()) { $aclTopologyId = $aclTopology['acl_topo_id']; // get parents of topologies which are at least read only $statement = $pearDB->prepare( 'SELECT t.topology_page, t.topology_id, t.topology_parent ' . 'FROM acl_topology_relations atr, topology t ' . 'WHERE acl_topo_id = :topologyId ' . 'AND atr.topology_topology_id = t.topology_id ' . 'AND atr.access_right IN (1,2) ' // read/write and read only ); $statement->bindParam(':topologyId', $aclTopologyId, PDO::PARAM_INT); $statement->execute(); $topologies = $statement->fetchAll(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC); // get missing parent topology relations $aclToInsert = []; foreach ($topologies as $topologyPage => $topologyParameters) { if (isset($topologyParameters['topology_parent']) && ! isset($topologies[$topologyParameters['topology_parent']]) && ! in_array($topologyParameters['topology_parent'], $aclToInsert) ) { if (strlen($topologyPage) === 5) { // level 3 $levelOne = substr($topologyPage, 0, 1); // get level 1 from beginning of topology_page if (! isset($aclToInsert[$levelOne])) { $aclToInsert[] = $levelOne; } $levelTwo = substr($topologyPage, 0, 3); // get level 2 from beginning of topology_page if (! isset($aclToInsert[$levelTwo])) { $aclToInsert[] = $levelTwo; } } elseif (strlen($topologyPage) === 3) { // level 2 $levelOne = substr($topologyPage, 0, 1); // get level 1 from beginning of topology_page if (! isset($aclToInsert[$levelOne])) { $aclToInsert[] = $levelOne; } } } } // insert missing parent topology relations if ($aclToInsert !== []) { $bindedValues = []; foreach ($aclToInsert as $aclIndex => $aclValue) { $bindedValues[':acl_' . $aclIndex] = (int) $aclValue; } $bindedQueries = implode(', ', array_keys($bindedValues)); $statement = $pearDB->prepare( 'INSERT INTO acl_topology_relations(acl_topo_id, topology_topology_id) ' . 'SELECT :acl_topology_id, t.topology_id ' . 'FROM topology t ' . "WHERE t.topology_page IN ({$bindedQueries})" ); $statement->bindValue(':acl_topology_id', (int) $aclTopologyId, PDO::PARAM_INT); foreach ($bindedValues as $bindedIndex => $bindedValue) { $statement->bindValue($bindedIndex, $bindedValue, PDO::PARAM_INT); } $statement->execute(); } }
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.8.php
centreon/www/install/php/Update-21.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-23.04.3.php
centreon/www/install/php/Update-23.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-23.10.7.php
centreon/www/install/php/Update-23.10.7.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.7.php
centreon/www/install/php/Update-23.04.7.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.18.php
centreon/www/install/php/Update-20.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-20.10.1.php
centreon/www/install/php/Update-20.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-24.11.0.php
centreon/www/install/php/Update-24.11.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-23.04.0.php
centreon/www/install/php/Update-23.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 * */ require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 23.04.0: '; $errorMessage = ''; /** * 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(); } }; $updateOpenIdCustomConfiguration = function (CentreonDB $pearDB): void { $customConfigurationJson = $pearDB->query( <<<'SQL' SELECT custom_configuration FROM provider_configuration WHERE name = 'openid' SQL )->fetchColumn(); $customConfiguration = json_decode($customConfigurationJson, true); if (! array_key_exists('redirect_url', $customConfiguration)) { $customConfiguration['redirect_url'] = null; $updatedCustomConfigurationEncoded = json_encode($customConfiguration); $statement = $pearDB->prepare( <<<'SQL' UPDATE provider_configuration SET custom_configuration = :encodedConfiguration WHERE name = 'openid' SQL ); $statement->bindValue(':encodedConfiguration', $updatedCustomConfigurationEncoded, PDO::PARAM_STR); $statement->execute(); } }; $insertSAMLProviderConfiguration = function (CentreonDB $pearDB): void { $customConfiguration = [ 'remote_login_url' => '', 'entity_id_url' => '', 'certificate' => '', 'user_id_attribute' => '', 'logout_from' => true, 'logout_from_url' => null, 'auto_import' => false, 'contact_template_id' => null, 'email_bind_attribute' => '', 'fullname_bind_attribute' => '', 'authentication_conditions' => [ 'is_enabled' => false, 'attribute_path' => '', 'authorized_values' => [], ], 'roles_mapping' => [ 'is_enabled' => false, 'apply_only_first_role' => false, 'attribute_path' => '', ], 'groups_mapping' => [ 'is_enabled' => false, 'attribute_path' => '', ], ]; $isActive = false; $isForced = false; $insertStatement = $pearDB->prepare( "INSERT INTO provider_configuration (`type`,`name`,`custom_configuration`,`is_active`,`is_forced`) VALUES ('saml','SAML', :customConfiguration, :isActive, :isForced)" ); $insertStatement->bindValue(':isActive', $isActive, PDO::PARAM_INT); $insertStatement->bindValue(':isForced', $isForced, PDO::PARAM_INT); $insertStatement->bindValue(':customConfiguration', json_encode($customConfiguration)); $insertStatement->execute(); }; try { if ($pearDB->isColumnExist('cfg_centreonbroker', 'event_queues_total_size') === 0) { $errorMessage = 'Impossible to update cfg_centreonbroker table'; $pearDB->query( 'ALTER TABLE `cfg_centreonbroker` ADD COLUMN `event_queues_total_size` INT(11) DEFAULT NULL AFTER `event_queue_max_size`' ); } $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'" ); // Transactional queries $pearDB->beginTransaction(); // check if entry ldap_connection_timeout exist $query = $pearDB->query("SELECT * FROM auth_ressource_info WHERE ari_name = 'ldap_connection_timeout'"); $ldapResult = $query->fetchAll(PDO::FETCH_ASSOC); // insert entry ldap_connection_timeout with default value if (! $ldapResult) { $errorMessage = 'Unable to add default ldap connection timeout'; $pearDB->query( "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) (SELECT ar_id, 'ldap_connection_timeout', '' FROM auth_ressource)" ); } $errorMessage = 'Unable to update illegal characters fields from engine configuration of pollers'; $decodeIllegalCharactersNagios($pearDB); $errorMessage = 'Unable to update provider_configuration table to add redirect_url'; $updateOpenIdCustomConfiguration($pearDB); $errorMessage = 'Unable to add SAML provider_configuration'; $insertSAMLProviderConfiguration($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-20.10.14.php
centreon/www/install/php/Update-20.10.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-21.10.3.php
centreon/www/install/php/Update-21.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 * */
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.0.php
centreon/www/install/php/Update-25.01.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'; $version = '25.01.0'; $errorMessage = ''; // -------------------------------------------- Dashboard -------------------------------------------- // /** * @param CentreonDB $pearDB * * @throws CentreonDbException * @return void */ $createUserProfileTable = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to add table user_profile'; $pearDB->executeQuery( <<<'SQL' CREATE TABLE IF NOT EXISTS `user_profile` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `contact_id` INT(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `unique_user_profile` (`id`, `contact_id`), CONSTRAINT `fk_user_profile_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `contact` (`contact_id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; SQL ); }; /** * @param CentreonDB $pearDB * * @throws CentreonDbException * @return void */ $createUserProfileFavoriteDashboards = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to add table user_profile_favorite_dashboards'; $pearDB->executeQuery( <<<'SQL' CREATE TABLE IF NOT EXISTS `user_profile_favorite_dashboards` ( `profile_id` INT UNSIGNED NOT NULL, `dashboard_id` INT UNSIGNED NOT NULL, CONSTRAINT `fk_user_profile_favorite_dashboards_profile_id` FOREIGN KEY (`profile_id`) REFERENCES `user_profile` (`id`) ON DELETE CASCADE, CONSTRAINT `fk_user_profile_favorite_dashboards_dashboard_id` FOREIGN KEY (`dashboard_id`) REFERENCES `dashboard` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; SQL ); }; // -------------------------------------------- Dahsboard thumbnail -------------------------------------------- // $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']); } }; try { $createUserProfileTable($pearDB); $createUserProfileFavoriteDashboards($pearDB); $createAgentConfiguration($pearDB); $createDashboardThumbnailTable($pearDB); // Transactional queries if (! $pearDB->inTransaction()) { $pearDB->beginTransaction(); } $insertAgentConfigurationTopology($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-21.04.1.php
centreon/www/install/php/Update-21.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 * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 21.04.1: '; /** * Query with transaction */ try { $pearDB->beginTransaction(); /** * Retrieve user filters */ $statement = $pearDB->query( 'SELECT `id`, `criterias` FROM `user_filter`' ); $fixedCriteriaFilters = []; /** * Sort filter criteria was not correctly added during the 21.04.0 * upgrade. It should be an array and not an object */ while ($filter = $statement->fetch()) { $id = $filter['id']; $decodedCriterias = json_decode($filter['criterias'], true); foreach ($decodedCriterias as $criteriaKey => $criteria) { if ($criteria['name'] === 'sort') { $decodedCriterias[$criteriaKey]['value'] = [ 'status_severity_code', $criteria['value']['status_severity_code'], ]; } } $fixedCriteriaFilters[$id] = json_encode($decodedCriterias); } /** * UPDATE SQL request on filters */ foreach ($fixedCriteriaFilters 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(); } $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-22.10.3.php
centreon/www/install/php/Update-22.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 * */
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.3.php
centreon/www/install/php/Update-23.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 - 23.10.3: '; $errorMessage = ''; $dropColumnVersionFromDashboardWidgetsTable = function (CentreonDB $pearDB): void { if ($pearDB->isColumnExist('dashboard_widgets', 'version')) { $pearDB->query( <<<'SQL' ALTER TABLE dashboard_widgets DROP COLUMN `version` SQL ); } }; $populateDashboardTables = 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 ); } }; try { $dropColumnVersionFromDashboardWidgetsTable($pearDB); $populateDashboardTables($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-19.04.0.php
centreon/www/install/php/Update-19.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 * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); /** * New configuration options for Centreon Engine */ try { $pearDB->query('SET SESSION innodb_strict_mode=OFF'); if (! $pearDB->isColumnExist('cfg_nagios', 'enable_macros_filter')) { // $pearDB = "centreon" // $pearDBO = "realtime" $pearDB->query( "ALTER TABLE `cfg_nagios` ADD COLUMN `enable_macros_filter` ENUM('0', '1') DEFAULT '0'" ); } if (! $pearDB->isColumnExist('cfg_nagios', 'macros_filter')) { $pearDB->query( "ALTER TABLE `cfg_nagios` ADD COLUMN `macros_filter` TEXT DEFAULT ('')" ); } } catch (PDOException $e) { $centreonLog->insertLog( 2, 'UPGRADE : 19.04.0 Unable to modify centreon engine 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-18.10.2.php
centreon/www/install/php/Update-18.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.0.php
centreon/www/install/php/Update-21.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-24.11.1.php
centreon/www/install/php/Update-24.11.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-23.04.2.php
centreon/www/install/php/Update-23.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 * */
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.20.php
centreon/www/install/php/Update-21.04.20.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.04.0.php
centreon/www/install/php/Update-24.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 * */ require_once __DIR__ . '/../../../bootstrap.php'; require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 24.04.0: '; $errorMessage = ''; // ------------ Widgets database updates ---------------- // $updateWidgetModelsTable = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to add column is_internal to table widget_models'; if (! $pearDB->isColumnExist('widget_models', 'is_internal')) { $pearDB->query( <<<'SQL' ALTER TABLE `widget_models` ADD COLUMN `is_internal` BOOLEAN NOT NULL DEFAULT FALSE AFTER `version` SQL ); } $errorMessage = 'Unable to modify column version on table widget_models'; $pearDB->query( <<<'SQL' ALTER TABLE `widget_models` MODIFY COLUMN `version` varchar(255) DEFAULT NULL SQL ); }; $installCoreWidgets = function (): void { $moduleService = Centreon\LegacyContainer::getInstance()[CentreonModule\ServiceProvider::CENTREON_MODULE]; $widgets = $moduleService->getList(null, false, null, ['widget']); foreach ($widgets['widget'] as $widget) { if ($widget->isInternal()) { $moduleService->install($widget->getId(), 'widget'); } } }; $setCoreWidgetsToInternal = function (CentreonDB $pearDB): void { $pearDB->query( <<<'SQL' UPDATE `widget_models` SET version = NULL, is_internal = TRUE WHERE `directory` IN ( 'engine-status', 'global-health', 'graph-monitoring', 'grid-map', 'httploader', 'host-monitoring', 'hostgroup-monitoring', 'live-top10-cpu-usage', 'live-top10-memory-usage', 'ntopng-listing', 'service-monitoring', 'servicegroup-monitoring', 'single-metric', 'tactical-overview' ) SQL ); }; $dropColumnVersionFromDashboardWidgetsTable = function (CentreonDB $pearDB): void { if ($pearDB->isColumnExist('dashboard_widgets', 'version')) { $pearDB->query( <<<'SQL' ALTER TABLE dashboard_widgets DROP COLUMN `version` 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 ); } }; $updateTopologyForApiTokens = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Could not update topology for API tokens'; $pearDB->query( <<<'SQL' UPDATE `topology` SET topology_url = '/administration/api-token', is_react = '1', topology_show='1' WHERE `topology_name` = 'API Tokens' SQL ); }; // ------------ Resource Access Management database updates ---------------- // $insertTopologyForResourceAccessManagement = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to insert topology for Resource Access Management'; $statement = $pearDB->query( <<<'SQL' SELECT 1 FROM `topology` WHERE `topology_name` = 'Resource Access Management' SQL ); if ((bool) $statement->fetch(PDO::FETCH_COLUMN) === false) { $pearDB->query( <<<'SQL' INSERT INTO `topology` (`topology_name`, `topology_url`, `readonly`, `is_react`, `topology_parent`, `topology_page`, `topology_order`, `topology_group`, `topology_feature_flag`) VALUES ( 'Resource Access Management', '/administration/resource-access/rules', '1', '1', 502, 50206, 1, 1, 'resource_access_management'); SQL ); } }; $addCloudDescriptionToAclGroups = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to add cloud_description column to acl_groups table'; if (! $pearDB->isColumnExist('acl_groups', 'cloud_description')) { $pearDB->query( 'ALTER TABLE `acl_groups` ADD COLUMN `cloud_description` TEXT DEFAULT NULL' ); } }; $addCloudSpecificToAclGroups = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to add cloud_specific column to acl_groups table'; if (! $pearDB->isColumnExist('acl_groups', 'cloud_specific')) { $pearDB->query( 'ALTER TABLE `acl_groups` ADD COLUMN `cloud_specific` BOOLEAN NOT NULL DEFAULT 0' ); } }; $addCloudSpecificToAclResources = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to add cloud_specific column to acl_resources table'; if (! $pearDB->isColumnExist('acl_resources', 'cloud_specific')) { $pearDB->query( 'ALTER TABLE `acl_resources` ADD COLUMN `cloud_specific` BOOLEAN NOT NULL DEFAULT 0' ); } }; $createDatasetFiltersTable = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to create dataset_filters configuration table'; $pearDB->query( <<<'SQL' CREATE TABLE IF NOT EXISTS `dataset_filters` ( `id` int(11) NOT NULL AUTO_INCREMENT, `parent_id` int(11) DEFAULT NULL, `type` enum('host', 'hostgroup', 'host_category', 'servicegroup', 'service_category', 'meta_service', 'service') DEFAULT NULL, `acl_resource_id` int(11) DEFAULT NULL, `acl_group_id` int(11) DEFAULT NULL, `resource_ids` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), CONSTRAINT `acl_resources_dataset_relations` FOREIGN KEY (`acl_resource_id`) REFERENCES `acl_resources` (`acl_res_id`) ON DELETE CASCADE, CONSTRAINT `acl_groups_dataset_relations` FOREIGN KEY (`acl_group_id`) REFERENCES `acl_groups` (`acl_group_id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; SQL ); }; $alterTypeDefinitionDatasetFilterTable = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to change `type` from enum to varchar in dataset_filters table'; $pearDB->query( <<<'SQL' ALTER TABLE `dataset_filters` MODIFY COLUMN `type` VARCHAR(255) DEFAULT NULL SQL ); }; $insertGroupMonitoringWidget = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to insert centreon-widget-groupmonitoring in dashboard_widgets'; $statement = $pearDB->query("SELECT 1 from dashboard_widgets WHERE name = 'centreon-widget-groupmonitoring'"); if ((bool) $statement->fetchColumn() === false) { $pearDB->query( <<<'SQL' INSERT INTO dashboard_widgets (`name`) VALUES ('centreon-widget-groupmonitoring') SQL ); } }; $addDefaultValueforTaskTable = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to alter created_at for task table'; $pearDB->query('ALTER TABLE task MODIFY COLUMN `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP'); }; $insertStatusChartWidget = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to insert centreon-widget-statuschart in dashboard_widgets'; $statement = $pearDB->query("SELECT 1 from dashboard_widgets WHERE name = 'centreon-widget-statuschart'"); if ((bool) $statement->fetchColumn() === false) { $pearDB->query( <<<'SQL' INSERT INTO dashboard_widgets (`name`) VALUES ('centreon-widget-statuschart') SQL ); } }; $removeBetaTagFromDashboards = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to remove the dashboard beta tag'; $pearDB->query( <<<'SQL' UPDATE topology SET topology_url_opt=NULL WHERE topology_name='Dashboards' AND topology_url_opt = 'Beta' SQL ); }; $updateHostGroupsTopology = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to update topology_url_substitute to NULL for host group configuration page (60102)'; $pearDB->query( <<<'SQL' UPDATE `topology` SET `topology_url_substitute` = NULL WHERE `topology_page` = 60102 SQL ); }; $updateDatasetFilterResourceIdsColumn = function (CentreonDB $pearDB) use (&$errorMessage): void { $errorMessage = 'Unable to change resourceIds column type from VARCHAR to TEXT'; $pearDB->query( <<<'SQL' ALTER TABLE `dataset_filters` MODIFY COLUMN `resource_ids` TEXT DEFAULT NULL 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->query( <<<'SQL' ALTER TABLE `acl_groups` ADD COLUMN `all_contacts` TINYINT(1) DEFAULT 0 NOT NULL SQL ); } }; $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->query( <<<'SQL' ALTER TABLE `acl_groups` ADD COLUMN `all_contact_groups` TINYINT(1) DEFAULT 0 NOT NULL SQL ); } }; try { $updateWidgetModelsTable($pearDB); $errorMessage = 'Unable to install core widgets'; $installCoreWidgets(); $dropColumnVersionFromDashboardWidgetsTable($pearDB); $addCloudSpecificToAclGroups($pearDB); $addCloudDescriptionToAclGroups($pearDB); $addCloudSpecificToAclResources($pearDB); $createDatasetFiltersTable($pearDB); $alterTypeDefinitionDatasetFilterTable($pearDB); $addDefaultValueforTaskTable($pearDB); $updateDatasetFilterResourceIdsColumn($pearDB); $addAllContactsColumnToAclGroups($pearDB); $addAllContactGroupsColumnToAclGroups($pearDB); // Tansactional queries if (! $pearDB->inTransaction()) { $pearDB->beginTransaction(); } $errorMessage = 'Could not set core widgets to internal'; $setCoreWidgetsToInternal($pearDB); $insertResourcesTableWidget($pearDB); $insertGroupMonitoringWidget($pearDB); $insertStatusChartWidget($pearDB); $insertTopologyForResourceAccessManagement($pearDB); $updateTopologyForApiTokens($pearDB); $removeBetaTagFromDashboards($pearDB); $updateHostGroupsTopology($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-18.10.4.php
centreon/www/install/php/Update-18.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 * */
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.8.php
centreon/www/install/php/Update-23.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 - 23.04.8: '; $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 ); } }; try { $errorMessage = 'Impossible to add column topology_feature_flag to topology table'; $alterTopologyForFeatureFlag($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-2.8.9.php
centreon/www/install/php/Update-2.8.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-25.07.1.php
centreon/www/install/php/Update-25.07.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-22.04.1.php
centreon/www/install/php/Update-22.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 * */ use Core\Security\ProviderConfiguration\Domain\OpenId\Model\Configuration; require_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 22.04.1: '; $errorMessage = ''; try { $pearDB->beginTransaction(); $errorMessage = "Unable to update 'custom_configuration' column on 'provider_configuration' table"; updateOpenIdConfiguration($pearDB); $pearDB->commit(); $errorMessage = "Unable to create 'security_provider_access_group_relation' table"; $pearDB->query('CREATE TABLE IF NOT EXISTS `security_provider_access_group_relation` ( `claim_value` VARCHAR(255) NOT NULL, `access_group_id` int(11) NOT NULL, `provider_configuration_id` int(11) NOT NULL, PRIMARY KEY (`claim_value`, `access_group_id`, `provider_configuration_id`), CONSTRAINT `security_provider_access_group_id` FOREIGN KEY (`access_group_id`) REFERENCES `acl_groups` (`acl_group_id`) ON DELETE CASCADE, CONSTRAINT `security_provider_provider_configuration_id` FOREIGN KEY (`provider_configuration_id`) REFERENCES `provider_configuration` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; '); } 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); } /** * Update OpenID Configuration with Auto Import options * * @param CentreonDB $pearDB * @throws Exception */ function updateOpenIdConfiguration(CentreonDB $pearDB): void { $statement = $pearDB->query("SELECT custom_configuration FROM provider_configuration WHERE name='openid'"); if ($statement !== false && $result = $statement->fetch(PDO::FETCH_ASSOC)) { $defaultContactGroupId = createOpenIdDefaultContactGroup($pearDB); $openIdCustomConfiguration = json_decode($result['custom_configuration'], true); $openIdCustomConfiguration['auto_import'] = false; $openIdCustomConfiguration['contact_template_id'] = null; $openIdCustomConfiguration['email_bind_attribute'] = null; $openIdCustomConfiguration['fullname_bind_attribute'] = null; $openIdCustomConfiguration['contact_group_id'] = $defaultContactGroupId; $openIdCustomConfiguration['claim_name'] = 'groups'; $statement = $pearDB->prepare( "UPDATE provider_configuration SET custom_configuration = :customConfiguration WHERE name='openid'" ); $statement->bindValue(':customConfiguration', json_encode($openIdCustomConfiguration), PDO::PARAM_STR); $statement->execute(); } else { throw new Exception('No custom_configuration for open_id has been found'); } } /** * create Default Contact Group for OpenId Configuration * Return its id to be inserted as contact_group_id in the openid custom configuration * * @param CentreonDB $pearDB * @return int id of the created contact group */ function createOpenIdDefaultContactGroup(CentreonDB $pearDB): int { $pearDB->query("INSERT INTO contactgroup (cg_name, cg_alias, cg_activate) VALUES ('OpenId Default', 'OpenId Default ContactGroup', '1') "); return $pearDB->lastInsertId(); }
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.10.0-rc.1.php
centreon/www/install/php/Update-21.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 * */ include_once __DIR__ . '/../../class/centreonLog.class.php'; $centreonLog = new CentreonLog(); // error specific content $versionOfTheUpgrade = 'UPGRADE - 21.10.0-rc.1: '; /** * Query with transaction */ try { $pearDB->beginTransaction(); $errorMessage = 'Impossible to clean openid options'; $defaultValues = [ 'openid_connect_enable' => '0', 'openid_connect_mode' => '1', 'openid_connect_trusted_clients' => '', 'openid_connect_blacklist_clients' => '', 'openid_connect_base_url' => '', 'openid_connect_authorization_endpoint' => '', 'openid_connect_token_endpoint' => '', 'openid_connect_introspection_endpoint' => '', 'openid_connect_userinfo_endpoint' => '', 'openid_connect_end_session_endpoint' => '', 'openid_connect_scope' => '', 'openid_connect_login_claim' => '', 'openid_connect_redirect_url' => '', 'openid_connect_client_id' => '', 'openid_connect_client_secret' => '', 'openid_connect_client_basic_auth' => '0', 'openid_connect_verify_peer' => '0', ]; $result = $pearDB->query("SELECT * FROM `options` WHERE options.key LIKE 'openid%'"); $generalOptions = []; while ($row = $result->fetch()) { $generalOptions[$row['key']] = $row['value']; } foreach ($defaultValues as $defaultValueName => $defautValue) { if (! isset($generalOptions[$defaultValueName])) { $statement = $pearDB->prepare('INSERT INTO `options` (`key`, `value`) VALUES (:option_key, :option_value)'); $statement->bindValue(':option_key', $defaultValueName, PDO::PARAM_STR); $statement->bindValue(':option_value', $defautValue, PDO::PARAM_STR); $statement->execute(); } } /** * Retrieve user filters */ $statement = $pearDB->query( "SELECT `id`, `criterias` FROM `user_filter` WHERE `page_name` = 'events-view'" ); $fixedCriteriaFilters = []; /** * Sort filter criteria was not correctly added during the 21.04.0 * upgrade. It should be an array and not an object */ $errorMessage = 'Cannot parse filter values in user_filter table.'; while ($filter = $statement->fetch()) { $id = $filter['id']; $decodedCriterias = json_decode($filter['criterias'], true); foreach ($decodedCriterias as $criteriaKey => $criteria) { if ( $criteria['name'] === 'sort' && is_array($criteria['value']) && count($criteria['value']) === 2 && $criteria['value'][0] === 'status_severity_code' && ! in_array($criteria['value'][1], ['asc', 'desc']) ) { $decodedCriterias[$criteriaKey]['value'][1] = 'desc'; } } $fixedCriteriaFilters[$id] = json_encode($decodedCriterias); } /** * UPDATE SQL request on filters */ $errorMessage = 'Unable to update filter sort values in user_filter table.'; foreach ($fixedCriteriaFilters as $id => $criterias) { $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(); } $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