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/api/index.php
centreon/api/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 * */ declare(strict_types=1); require_once dirname(__DIR__) . '/vendor/autoload_runtime.php'; require_once dirname(__DIR__) . '/config.new/bootstrap.php'; $uri = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH); $matches = []; preg_match('#^(/[^/]+)/#', $uri, $matches); $baseUri = $matches[1] ?? '/centreon'; // Fake SCRIPT_NAME and PHP_SELF so Symfony thinks the script is under $baseUri $_SERVER['SCRIPT_NAME'] = $baseUri . '/index.php'; $_SERVER['PHP_SELF'] = $baseUri . '/index.php'; return function (array $context) { return new App\Shared\Infrastructure\Symfony\Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); };
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/features/bootstrap/DowntimeStartAndStopContext.php
centreon/features/bootstrap/DowntimeStartAndStopContext.php
<?php use Centreon\Test\Behat\CentreonContext; use Centreon\Test\Behat\Configuration\DowntimeConfigurationPage; use Centreon\Test\Behat\Configuration\ServiceConfigurationPage; use Centreon\Test\Behat\Configuration\CurrentUserConfigurationPage; use Centreon\Test\Behat\Configuration\DowntimeConfigurationListingPage; use Centreon\Test\Behat\Configuration\HostConfigurationListingPage; use Centreon\Test\Behat\Configuration\RecurrentDowntimeConfigurationPage; /** * Defines application features from the specific context. */ class DowntimeStartAndStopContext extends CentreonContext { protected $host = 'Centreon-Server'; protected $service = 'downtimeService'; protected $downtimeStartTime; protected $downtimeEndTime; protected $downtimeDuration = 20; public function __construct() { parent::__construct(); $this->downtimeStartTime = (new \DateTime('now', new \DateTimezone('Europe/Paris')))->format('H:i'); $this->page = ''; $this->dateStartTimestamp = ''; $this->dateEndTimestamp = ''; $this->timezone = ''; $this->timezoneUser = ''; } /** * @Given a passive service is monitored */ public function aPassiveServiceIsMonitored() { $page = new ServiceConfigurationPage($this); $page->setProperties(array( 'hosts' => $this->host, 'description' => $this->service, 'templates' => 'generic-service', 'check_command' => 'check_centreon_dummy', 'check_period' => '24x7', 'max_check_attempts' => 1, 'normal_check_interval' => 1, 'retry_check_interval' => 1, 'active_checks_enabled' => 0, 'passive_checks_enabled' => 1, 'notifications_enabled' => 1, 'notify_on_recovery' => 1, 'notify_on_critical' => 1, 'recovery_notification_delay' => 1, 'cs' => 'admin admin' )); $page->save(); $this->reloadAllPollers(); $this->submitServiceResult($this->host, $this->service, 0, __FUNCTION__); } /** * @Given a fixed downtime on a monitored element */ public function aFixedDowntimeOnAMonitoredElement() { $page = new DowntimeConfigurationPage($this); $this->downtimeEndTime = (new \DateTime('+2 minutes', new \DateTimezone('Europe/Paris')))->format('H:i'); $page->setProperties(array( 'type' => DowntimeConfigurationPage::TYPE_SERVICE, 'service' => $this->host . ' - ' . $this->service, 'comment' => 'Acceptance test', 'start_time' => $this->downtimeStartTime, 'end_time' => $this->downtimeEndTime )); $page->save(); } /** * @Given a flexible downtime on a monitored element */ public function aFlexibleDowntimeOnAMonitoredElement() { $this->submitServiceResult($this->host, $this->service, 0, __FUNCTION__); $page = new DowntimeConfigurationPage($this); $this->downtimeEndTime = (new \DateTime('+2 minutes', new \DateTimezone('Europe/Paris')))->format('H:i'); $page->setProperties(array( 'type' => DowntimeConfigurationPage::TYPE_SERVICE, 'service' => $this->host . ' - ' . $this->service, 'comment' => 'Acceptance test', 'fixed' => false, 'duration' => $this->downtimeDuration, 'start_time' => $this->downtimeStartTime, 'end_time' => $this->downtimeEndTime )); $page->save(); } /** * @Given the downtime is started */ public function theDowntimeIsStarted() { $this->spin( function ($context) { $found = false; $page = new DowntimeConfigurationListingPage($context); foreach ($page->getEntries() as $entry) { if ($entry['host'] == $context->host && $entry['service'] == $context->service && $entry['started'] == true ) { $found = true; } } return $found; } ); } /** * @Given the flexible downtime is started */ public function theFlexibleDowntimeIsStarted() { $this->theMonitoredElementIsNotOk(); $this->theDowntimePeriodIsStarted(); $this->theDowntimeIsStarted(); } /** * @Given the downtime period is started */ public function theDowntimePeriodIsStarted() { $this->spin( function ($context) { $currentTime = (new \DateTime('now', new \DateTimezone('Europe/Paris')))->format('H:i'); if ($currentTime >= $context->downtimeStartTime) { return true; } }, 'The downtime period did not start (' . $this->downtimeStartTime . ').', 80 ); } /** * @When the downtime duration is finished */ public function theDowntimeDurationIsFinished() { sleep($this->downtimeDuration); } /** * @When the monitored element is not OK */ public function theMonitoredElementIsNotOk() { $this->submitServiceResult($this->host, $this->service, 2, __FUNCTION__); } /** * @When the end date of the downtime happens */ public function theEndDateOfTheDowntimeHappens() { $this->spin( function ($context) { $currentTime = (new \DateTime('now', new \DateTimezone('Europe/Paris')))->format('H:i'); return $currentTime >= $context->downtimeEndTime; }, 'The end of the downtime is too late (' . $this->downtimeEndTime . ').', 180 // 3 minutes for 2 minutes-long downtimes ); } /** * @Then the downtime is stopped */ public function theDowntimeIsStopped() { $this->spin( function ($context) { $found = false; $page = new DowntimeConfigurationListingPage($context); foreach ($page->getEntries() as $entry) { if ($entry['host'] == $context->host && $entry['service'] == $context->service) { $found = true; } } return !$found; }, 'Downtime is still running.' ); } /** * @Then the flexible downtime is stopped */ public function theFlexibleDowntimeIsStopped() { $this->spin( function ($context) { $finished = false; $storageDb = $context->getStorageDatabase(); $res = $storageDb->query( 'SELECT d.downtime_id, d.actual_end_time ' . 'FROM downtimes d, hosts h, services s ' . 'WHERE h.host_id = d.host_id ' . 'AND s.service_id = d.service_id ' . 'AND h.name = "' . $context->host . '" ' . 'AND s.description = "' . $context->service . '" ' . 'AND d.actual_end_time IS NOT NULL ' . 'AND d.actual_end_time < ' . time() ); if ($row = $res->fetch()) { $finished = true; } return $finished; }, 'FLexible downtime is still running.', 30 ); } /** * @Given a downtime in configuration of a user in other timezone */ public function aDowntimeInConfigurationOfAUserInOtherTimezone() { $this->timezoneUser = 'Asia/Tokyo'; //user $user = new CurrentUserConfigurationPage($this); $user->setProperties(array( 'location' => $this->timezoneUser )); $user->save(); $this->iAmLoggedOut(); $this->iAmLoggedIn(); $this->reloadAllPollers(); //downtime $this->page = new DowntimeConfigurationPage($this); $this->page->setProperties(array( 'type' => DowntimeConfigurationPage::TYPE_SERVICE, 'service' => $this->host . ' - ' . $this->service, 'comment' => 'service comment' )); $props = $this->page->getProperties(); //convert local start hour in timestamp utc $dataTimeStart = new DateTime( $props['start_day'] . ' ' . $props['start_time'], timezone_open($this->timezoneUser) ); $dataTimeStart->format('Y/m/d H:i'); $this->dateStartTimestamp = $dataTimeStart->getTimestamp(); //convert local end hour in timestamp utc $dataTimeEnd = new DateTime($props['end_day'] . ' ' . $props['end_time'], timezone_open($this->timezoneUser)); $dataTimeEnd->format('Y/m/d H:i'); $this->dateEndTimestamp = $dataTimeEnd->getTimestamp(); $this->downtimeDuration = $this->dateEndTimestamp - $this->dateStartTimestamp; } /** * @Given a recurrent downtime on an other timezone service */ public function aRecurrentDowntimeOnService() { $this->timezone = 'Asia/Tokyo'; $this->timezoneUser = 'Europe/Paris'; $this->downtimeDuration = 240; $hostListingPage = new HostConfigurationListingPage($this); $hostPage = $hostListingPage->inspect($this->host); $hostPage->setProperties(array( 'location' => $this->timezone )); $hostPage->save(); $this->reloadAllPollers(); //get the time of the timezone + x seconds for the start $datetimeStartLocal = new DateTime('now +120seconds', new DateTimeZone($this->timezone)); $datetimeStartLocal->setTime($datetimeStartLocal->format('H'), $datetimeStartLocal->format('i'), '00'); $datetimeEndLocal = new DateTime( 'now +' . ($this->downtimeDuration + 120) . 'seconds', new DateTimeZone($this->timezone) ); $datetimeEndLocal->setTime($datetimeEndLocal->format('H'), $datetimeEndLocal->format('i'), '00'); //check if the downtime is on two days and add time if ($datetimeStartLocal->format('d') != $datetimeEndLocal->format('d')) { $datetimeStartLocal->add(new DateInterval('PT5M')); $datetimeEndLocal->add(new DateInterval('PT5M')); } $startHour = $datetimeStartLocal->format('H:i'); $endHour = $datetimeEndLocal->format('H:i'); //convert the local time to utc time $this->dateStartTimestamp = $datetimeStartLocal->getTimestamp(); $this->dateEndTimestamp = $datetimeEndLocal->getTimestamp(); //add recurent downtime $this->page = new RecurrentDowntimeConfigurationPage($this); //set downtime properties $this->page->setProperties(array( 'name' => 'test', 'alias' => $this->service, 'days' => array(7, 1, 2, 3, 4, 5, 6), 'start' => $startHour, 'end' => $endHour, 'svc_relation' => $this->host . ' - ' . $this->service )); $this->page->save(); } /** * @When I save a downtime */ public function iSaveADowntime() { $this->page->save(); } /** * @When this one gives a downtime */ public function thisOneGivesADowntime() { /* cron */ $this->container->execute("php /usr/share/centreon/cron/downtimeManager.php", $this->webService); } /** * @Then the downtime start and end uses host timezone */ public function theDowntimeUseTheTimezone() { $dataDowntime = array(); $this->spin( function ($context) use (&$dataDowntime) { $listPage = new DowntimeConfigurationListingPage($context); $listPage->displayDowntimeCycle(); $dataDowntime = $listPage->getEntries(); if (count($dataDowntime)) { return true; } } ); //get the start and stop time ('Y-m-d H:i') of the downtime in user timezone $dateStart = $dataDowntime[0]['start']; $dateEnd = $dataDowntime[0]['end']; //convert the user timestamp to utc time $dataTimeStart = new DateTime($dateStart, new DateTimeZone($this->timezoneUser)); $dateStartTimestamp = $dataTimeStart->getTimestamp(); $dataTimeEnd = new DateTime($dateEnd, new DateTimeZone($this->timezoneUser)); $dateEndTimestamp = $dataTimeEnd->getTimestamp(); if ($this->dateStartTimestamp != $dateStartTimestamp) { throw new \Exception('Error bad timezone in start downtime configuration: ' . $this->dateStartTimestamp . ' != ' . $dateStartTimestamp); } if ($this->dateEndTimestamp != $dateEndTimestamp) { throw new \Exception('Error bad timezone in end downtime configuration: ' . $this->dateEndTimestamp . ' != ' . $dateEndTimestamp); } } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/features/bootstrap/DowntimeRecurrentContext.php
centreon/features/bootstrap/DowntimeRecurrentContext.php
<?php use Centreon\Test\Behat\CentreonContext; use Centreon\Test\Behat\Configuration\DowntimeConfigurationListingPage; use Centreon\Test\Behat\Configuration\HostConfigurationPage; use Centreon\Test\Behat\Configuration\HostGroupConfigurationPage; use Centreon\Test\Behat\Configuration\RecurrentDowntimeConfigurationPage; use Centreon\Test\Behat\Configuration\ServiceConfigurationPage; /** * Defines application features from the specific context. */ class DowntimeRecurrentContext extends CentreonContext { protected $currentPage; protected $startDate; protected $endDate; protected $host = array( 'name' => 'host', 'alias' => 'host', 'address' => '1.2.3.4', 'check_command' => 'check_centreon_dummy', 'location' => 'Europe/Paris' ); protected $hostGroup = array( 'name' => 'hostGroupName', 'alias' => 'hostGroupAlias', 'hosts' => 'host', 'enabled' => 1 ); protected $service = array( 'hosts' => 'host', 'description' => 'service', 'templates' => 'generic-service', 'check_command' => 'check_centreon_dummy', 'check_period' => '24x7', 'max_check_attempts' => 1, 'normal_check_interval' => 1, 'retry_check_interval' => 1, 'active_checks_enabled' => 1, 'passive_checks_enabled' => 0, 'notifications_enabled' => 1, 'notify_on_recovery' => 1, 'notify_on_critical' => 1, 'recovery_notification_delay' => 1, 'cs' => 'admin admin' ); /** * @Given a hostGroup is configured */ public function aHostGroupIsConfigured() { $this->currentPage = new HostConfigurationPage($this); $this->currentPage->setproperties($this->host); $this->currentPage->save(); $this->currentPage = new ServiceConfigurationPage($this); $this->currentPage->setProperties($this->service); $this->currentPage->save(); $this->reloadAllPollers(); } /** * @Given a recurrent downtime on a hostGroup */ public function aRecurrentDowntime() { $this->startDate = new \DateTime('now', new \DateTimezone('Europe/Paris')); $this->endDate = new \DateTime('+360 minutes', new \DateTimezone('Europe/Paris')); //check if the downtime is on two days and add time if ($this->startDate->format('d') != $this->endDate->format('d')) { $endDateTest = '23:59'; } else { $endDateTest = $this->endDate->format('H:i'); } $this->currentPage = new RecurrentDowntimeConfigurationPage($this); $this->currentPage->setProperties(array( 'name' => 'test_DT', 'alias' => 'recurrent_DT', 'days' => array(7, 1, 2, 3, 4, 5, 6), 'start' => $this->startDate->format('H:i'), 'end' => $endDateTest, 'host_relation' => $this->host['name'] )); $this->currentPage->save(); } /** * @When this one gives a downtime */ public function thisOneGivesADowntime() { /* faking cron's launchtime. 2 min sooner */ $this->container->execute( "faketime -f '-120s' php /usr/share/centreon/cron/downtimeManager.php", $this->webService ); } /** * @Then the recurrent downtime started */ public function aRecurrentDowntimeIsStarted() { /* checking for results */ $this->spin( function ($context) { $found = false; $this->currentPage = new DowntimeConfigurationListingPage($context); $this->currentPage->displayDowntimeCycle(); foreach ($this->currentPage->getEntries() as $entry) { if ($entry['host'] == $context->host['name'] && $entry['service'] == $context->service['description'] && $entry['started'] == true ) { $found = true; } } return $found; } ); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/features/bootstrap/CentreonModuleAPIContext.php
centreon/features/bootstrap/CentreonModuleAPIContext.php
<?php /* ** Copyright 2016 Centreon ** ** All rights reserved. */ use Centreon\Test\Behat\CentreonAPIContext; class CentreonModuleAPIContext extends CentreonAPIContext { /** * @Given I have a non-installed module ready for installation */ public function iHaveNonInstalledModuleReady() { $this->container->execute( 'mkdir /usr/share/centreon/www/modules/centreon-test', $this->webService, true ); $this->container->copyToContainer( __DIR__ . '/../assets/centreon-test.conf.php', '/usr/share/centreon/www/modules/centreon-test/conf.php', $this->webService ); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/features/bootstrap/AcknowledgementTimeoutContext.php
centreon/features/bootstrap/AcknowledgementTimeoutContext.php
<?php use Centreon\Test\Behat\CentreonContext; use Centreon\Test\Behat\Monitoring\MonitoringServicesPage; use Centreon\Test\Behat\Monitoring\MonitoringHostsPage; use Centreon\Test\Behat\Configuration\HostConfigurationPage; use Centreon\Test\Behat\Configuration\ServiceConfigurationPage; /** * Defines application features from the specific context. */ class AcknowledgementTimeoutContext extends CentreonContext { private $hostName; private $serviceName; public function __construct() { parent::__construct(); $this->hostName = 'ExpireAckTestHost'; $this->serviceHostName = 'Centreon-Server'; $this->serviceName = 'ExpireAckTestService'; } /** * @Given a host configured with acknowledgement expiration */ public function aHostConfiguredWithAckExpiration() { $hostPage = new HostConfigurationPage($this); $hostPage->setProperties(array( 'name' => $this->hostName, 'alias' => $this->hostName, 'address' => 'localhost', 'max_check_attempts' => 1, 'normal_check_interval' => 1, 'retry_check_interval' => 1, 'active_checks_enabled' => 0, 'passive_checks_enabled' => 1, 'acknowledgement_timeout' => 1 )); $hostPage->save(); $this->reloadAllPollers(); } /** * @Given a service configured with acknowledgement expiration */ public function aServiceConfiguredWithAckExpiration() { $servicePage = new ServiceConfigurationPage($this); $servicePage->setProperties(array( 'hosts' => $this->serviceHostName, 'description' => $this->serviceName, 'templates' => 'generic-service', 'check_command' => 'check_centreon_dummy', 'check_period' => '24x7', 'max_check_attempts' => 1, 'normal_check_interval' => 1, 'retry_check_interval' => 1, 'active_checks_enabled' => 0, 'passive_checks_enabled' => 1, 'acknowledgement_timeout' => 1 )); $servicePage->save(); $this->reloadAllPollers(); } /** * @Given the host is down */ public function theHostIsDown() { $this->submitHostResult($this->hostName, 'DOWN'); $hostName = $this->hostName; $this->spin( function ($ctx) use ($hostName) { return ((new MonitoringHostsPage($ctx))->getStatus($hostName) == "DOWN"); } ); } /** * @Given the service is in a critical state */ public function serviceInACriticalState() { $hostName = $this->serviceHostName; $serviceName = $this->serviceName; (new MonitoringServicesPage($this))->listServices(); $this->spin( function ($ctx) use ($hostName, $serviceName) { try { (new MonitoringServicesPage($ctx))->getStatus($hostName, $serviceName); $found = true; } catch (\Exception $e) { $found = false; } return $found; } ); $this->submitServiceResult($hostName, $serviceName, 'CRITICAL'); $this->spin( function ($ctx) use ($hostName, $serviceName) { $status = (new MonitoringServicesPage($ctx))->getStatus($hostName, $serviceName); return ($status == 'CRITICAL'); } ); } /** * @Given the host is acknowledged */ public function hostAcknowledged() { $page = new MonitoringHostsPage($this); $url = 'http://' . $this->container->getHost() . ':' . $this->container->getPort(80, $this->webService) . '/centreon/include/monitoring/external_cmd/cmdPopup.php'; $page->addAcknowledgementOnHost( $this->hostName, 'Unit test', true, true, true, false, false, $url ); $hostName = $this->hostName; $this->spin( function ($ctx) use ($hostName) { return ((new MonitoringHostsPage($ctx))->isHostAcknowledged($hostName)); } ); } /** * @Given the service is acknowledged */ public function serviceAcknowledged() { $hostName = $this->serviceHostName; $serviceName = $this->serviceName; $page = new MonitoringServicesPage($this); $url = 'http://' . $this->container->getHost() . ':' . $this->container->getPort(80, $this->webService) . '/centreon/include/monitoring/external_cmd/cmdPopup.php'; $page->addAcknowledgementOnService( $hostName, $serviceName, 'Unit test', true, true, true, false, $url ); $this->spin( function ($ctx) use ($hostName, $serviceName) { return ((new MonitoringServicesPage($ctx))->isServiceAcknowledged($hostName, $serviceName)); } ); } /** * @When I wait the time limit set for expiration */ public function iWaitTheTimeLimitSetForExpiration() { $this->getSession()->wait(60000); } /** * @Then The host acknowledgement disappears */ public function theHostAcknowledgementDisappears() { $hostName = $this->hostName; $this->spin( function ($ctx) use ($hostName) { return !(new MonitoringHostsPage($ctx))->isHostAcknowledged( $hostName ); } ); } /** * @Then The service acknowledgement disappears */ public function theServiceAcknowledgementDisappears() { $hostName = $this->serviceHostName; $serviceName = $this->serviceName; $this->spin( function ($ctx) use ($hostName, $serviceName) { return !(new MonitoringServicesPage($ctx))->isServiceAcknowledged( $hostName, $serviceName ); } ); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/features/bootstrap/DowntimeServiceContext.php
centreon/features/bootstrap/DowntimeServiceContext.php
<?php use Centreon\Test\Behat\CentreonContext; use Centreon\Test\Behat\Configuration\CommentConfigurationPage; use Centreon\Test\Behat\Configuration\DowntimeConfigurationPage; use Centreon\Test\Behat\Configuration\DowntimeConfigurationListingPage; use Centreon\Test\Behat\Configuration\MetaServiceConfigurationPage; use Centreon\Test\Behat\Monitoring\ServiceMonitoringDetailsPage; /** * Defines application features from the specific context. */ class DowntimeServiceContext extends CentreonContext { public function __construct() { parent::__construct(); $this->metaName = 'testmeta'; } /** * @Given I have a meta service */ public function iHaveAMetaServices() { $metaservicePage = new MetaServiceConfigurationPage($this); $metaservicePage->setProperties(array( 'name' => $this->metaName, 'check_period' => '24x7', 'max_check_attempts' => 1, 'normal_check_interval' => 1, 'retry_check_interval' => 1 )); $metaservicePage->save(); $this->reloadAllPollers(); } /** * @When I place a downtime */ public function iPlaceADowntime() { $page = new DowntimeConfigurationPage($this); $page->setProperties(array( 'type' => DowntimeConfigurationPage::TYPE_SERVICE, 'service' => 'Meta - ' . $this->metaName, 'comment' => __METHOD__ )); $page->save(); } /** * @When I place a comment */ public function iPlaceAComment() { $page = new CommentConfigurationPage($this, '_Module_Meta', 'meta_1'); $page->setProperties(array( 'comment' => 'Acceptance test downtime comment.' )); $page->save(); } /** * @When I cancel a downtime */ public function iCancelADowntime() { $this->spin( function ($context) { $page = new DowntimeConfigurationListingPage($this); return count($page->getEntries()) > 0; } ); $page = new DowntimeConfigurationListingPage($this); $page->selectEntry(0); $page->cancel(); } /** * @Then this one appears in the interface */ public function thisOneAppearsInTheInterface() { $this->visit('main.php?p=21002'); $this->getSession()->getPage()->has('css', 'table.ListTable tbody tr.list_two td.ListColLeft a'); } /** * @Then this one does not appear in the interface */ public function thisOneDoesNotAppearInTheInterface() { $this->spin( function ($context) { $page = new ServiceMonitoringDetailsPage( $context, '_Module_Meta', 'meta_1' ); $props = $page->getProperties(); return !$props['in_downtime']; } ); } /** * @Then this one appears in the interface in downtime */ public function thisOneAppearsInTheInterfaceInDowntime() { $this->spin( function ($context) { $page = new ServiceMonitoringDetailsPage( $context, '_Module_Meta', 'meta_1' ); $props = $page->getProperties(); return $props['in_downtime']; } ); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/features/bootstrap/RestApiContext.php
centreon/features/bootstrap/RestApiContext.php
<?php use Centreon\Test\Behat\CentreonContext; use Centreon\Test\Behat\Administration\ImageListingPage; class RestApiContext extends CentreonContext { private $logfile; private $retval; private $npmCommand; private $logFilePrefix; /** * @Given a Centreon server with REST API testing data */ public function aCentreonServerWithRestApiTestingData() { // Launch container. $this->launchCentreonWebContainer('docker_compose_web', [], ['CENTREON_DATASET' => '0']); // Copy images. $basedir = 'tests/rest_api/images'; $imgdirs = scandir($basedir); foreach ($imgdirs as $dir) { if (($dir != '.') && ($dir != '..')) { $this->container->copyToContainer( $basedir . '/' . $dir, '/usr/share/centreon/www/img/media/' . $dir, $this->webService ); } } // Copy MIB. $this->container->copyToContainer( 'tests/rest_api/behat-collections/IF-MIB.txt', '/usr/share/centreon/IF-MIB.txt', $this->webService ); // Synchronize images. $this->iAmLoggedIn(); $page = new ImageListingPage($this); $page->synchronize(); } /** * @When REST API are called */ public function restApiAreCalled() { $this->npmCommand = 'test:behat:configuration'; $this->logFilePrefix = 'rest_api_log'; $this->callRestApi(); } /** * @When realtime REST API are called */ public function realtimeRestApiAreCalled() { $this->npmCommand = 'test:behat:realtime'; $this->logFilePrefix = 'realtime_rest_api_log'; $this->callRestApi(); } /** * launch newman for api tests */ public function callRestApi() { $envFile = 'tests/rest_api/behat-collections/rest_api.postman_environment.json'; $env = file_get_contents($envFile); $env = str_replace( '@IP_CENTREON@', $this->container->getHost() . ':' . $this->container->getPort('80', $this->webService), $env ); file_put_contents($envFile, $env); $this->logfile = tempnam(sys_get_temp_dir(), $this->logFilePrefix); exec( 'cd tests/rest_api && pnpm run ' . $this->npmCommand . ' > ' . $this->logfile, $output, $retval ); $this->retval = $retval; } /** * @Then they reply as per specifications */ public function theyReplyAsPerSpecifications() { if (!($this->retval == 0)) { copy( $this->logfile, $this->composeFiles['log_directory'] . '/' . basename($this->logfile) . '.txt' ); unlink($this->logfile); throw new \Exception( 'REST API are not working properly. Check newman log file for more details.' ); } unlink($this->logfile); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/features/bootstrap/MetaServicesApiContext.php
centreon/features/bootstrap/MetaServicesApiContext.php
<?php use Centreon\Test\Behat\CentreonContext; use Centreon\Test\Behat\Configuration\MetaServiceConfigurationPage; /** * Defines application features from the specific context. */ class MetaServicesApiContext extends CentreonContext { public function __construct() { parent::__construct(); $this->jsonreturn = ''; $this->metaName = 'testmeta'; } /** * @Given I have a meta service */ public function iHaveAMetaServices() { $metaservicePage = new MetaServiceConfigurationPage($this); $metaservicePage->setProperties(array( 'name' => $this->metaName, 'check_period' => '24x7', 'max_check_attempts' => 1, 'normal_check_interval' => 1, 'retry_check_interval' => 1 )); $metaservicePage->save(); $this->restartAllPollers(); } /** * @When a call to API configuration services with s equal all is defined */ public function aCallToApiConfigurationServicesWithParameterAll() { $param = 'all'; $this->jsonreturn = $this->callToApiConfigurationServices($param); } /** * @When a call to API configuration services with s equal s is defined */ public function aCallToApiConfigurationServicesWithParameterS() { $param = 's'; $this->jsonreturn = $this->callToApiConfigurationServices($param); } /** * @When a call to API configuration services with s equal m is defined */ public function aCallToApiConfigurationServicesWithParameterM() { $param = 'm'; $this->jsonreturn = $this->callToApiConfigurationServices($param); } /** * @Then the table understands the services and the meta services */ public function theTableUnderstandsTheServicesAndTheMetaServices() { $service = 0; $meta = 0; $json = json_decode($this->jsonreturn); $i = count($json->items) - 1; while ((($service == 0) && ($meta == 0)) || (0 <= $i)) { if ($json->items[$i]->text == 'Meta - ' . $this->metaName) { $meta = 1; } elseif (strstr($json->items[$i]->text, 'Centreon-Server -')) { $service = 1; } $i--; } if (($service == 0) || ($meta == 0)) { throw new Exception('Bad service'); } } /** * @Then the table understands only the services */ public function theTableUnderstandsOnlyTheServices() { $service = 0; $meta = 0; $json = json_decode($this->jsonreturn); $i = count($json->items) - 1; while ((($service == 0) && ($meta == 0)) || (0 <= $i)) { if ($json->items[$i]->text == 'Meta - ' . $this->metaName) { $meta = 1; } elseif (strstr($json->items[$i]->text, 'Centreon-Server -')) { $service = 1; } $i--; } if (($service == 0) || ($meta == 1)) { throw new Exception('Bad service'); } } /** * @Then the table understands only the meta services */ public function theTableUnderstandsOnlyTheMeta() { $service = 0; $meta = 0; $json = json_decode($this->jsonreturn); $i = count($json->items) - 1; while ((($service == 0) && ($meta == 0)) || (0 <= $i)) { if ($json->items[$i]->text == 'Meta - ' . $this->metaName) { $meta = 1; } elseif (strstr($json->items[$i]->text, 'Centreon-Server -')) { $service = 1; } $i--; } if (($service == 1) || ($meta == 0)) { throw new Exception('Bad service'); } } public function callToApiConfigurationServices($param) { $apiPage = '/include/common/webServices/rest/internal.php?' . 'object=centreon_configuration_service&action=list&page_limit=60&page=1&s=' . $param; $this->visit($apiPage); $this->getSession()->wait(1000); $json = strip_tags($this->getSession()->getPage()->getHtml()); return $json; } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/features/bootstrap/AcknowledgementContext.php
centreon/features/bootstrap/AcknowledgementContext.php
<?php use Centreon\Test\Behat\CentreonContext; use Centreon\Test\Behat\Configuration\MetaServiceConfigurationPage; use Centreon\Test\Behat\Monitoring\MonitoringServicesPage; use Centreon\Test\Behat\Configuration\ServiceConfigurationPage; use Centreon\Test\Behat\Monitoring\ServiceMonitoringDetailsPage; class AcknowledgementContext extends CentreonContext { /** * @Given a non-OK service */ public function aNonOKService() { $page = new ServiceConfigurationPage($this); $page->setProperties( array( 'hosts' => 'Centreon-Server', 'description' => 'AcceptanceTestService', 'templates' => 'generic-service', 'check_command' => 'check_centreon_dummy', 'check_period' => '24x7', 'max_check_attempts' => 1, 'normal_check_interval' => 1, 'retry_check_interval' => 1, 'active_checks_enabled' => 0, 'passive_checks_enabled' => 1 ) ); $page->save(); $this->reloadAllPollers(); $this->submitServiceResult( 'Centreon-Server', 'AcceptanceTestService', 2, 'Acceptance test output.' ); } /** * @Given a non-OK meta-service */ public function aNonOKMetaService() { $page = new MetaServiceConfigurationPage($this); $page->setProperties( array( 'name' => 'AcceptanceTestMetaService', 'warning_level' => 0, 'critical_level' => 0, 'check_period' => '24x7', 'max_check_attempts' => 1, 'normal_check_interval' => 1, 'retry_check_interval' => 1 ) ); $page->save(); $this->restartAllPollers(); $page = new MonitoringServicesPage($this); $this->spin( function ($context) use ($page) { $page->scheduleImmediateCheckForcedOnService('_Module_Meta', 'meta_1'); return true; }, 'Could not schedule check.' ); $this->spin( function ($context) { $page = new ServiceMonitoringDetailsPage( $context, '_Module_Meta', 'meta_1' ); $props = $page->getProperties(); return $props['last_check'] && $props['state'] != 'PENDING'; }, 'Could not open meta-service monitoring details page.', 120 ); } /** * @When I acknowledge the service */ public function iAcknowledgeTheService() { $page = new MonitoringServicesPage($this); $url = 'http://' . $this->container->getHost() . ':' . $this->container->getPort(80, $this->webService) . '/centreon/include/monitoring/external_cmd/cmdPopup.php'; $page->addAcknowledgementOnService( 'Centreon-Server', 'AcceptanceTestService', 'Acceptance test.', true, true, true, false, $url ); } /** * @When I acknowledge the meta-service */ public function iAcknowledgeTheMetaService() { $page = new MonitoringServicesPage($this); $url = 'http://' . $this->container->getHost() . ':' . $this->container->getPort(80, $this->webService) . '/centreon/include/monitoring/external_cmd/cmdPopup.php'; $page->addAcknowledgementOnService( '_Module_Meta', 'meta_1', 'Acceptance test.', true, true, true, false, $url ); } /** * @Then the service is marked as acknowledged */ public function theServiceIsMarkedAsAcknowledged() { $this->spin( function ($context) { $page = new MonitoringServicesPage($context); return $page->isServiceAcknowledged( 'Centreon-Server', 'AcceptanceTestService' ); } ); } /** * @Then the meta-service is marked as acknowledged */ public function theMetaServiceIsMarkedAsAcknowledged() { $this->spin( function ($context) { $page = new MonitoringServicesPage($context); return $page->isServiceAcknowledged( '_Module_Meta', 'meta_1' ); } ); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/features/bootstrap/DowntimeDSTContext.php
centreon/features/bootstrap/DowntimeDSTContext.php
<?php use Centreon\Test\Behat\CentreonContext; use Centreon\Test\Behat\Configuration\DowntimeConfigurationPage; use Centreon\Test\Behat\Configuration\ServiceConfigurationPage; use Centreon\Test\Behat\Configuration\RecurrentDowntimeConfigurationPage; /** * Defines application features from the specific context. */ class DowntimeDSTContext extends CentreonContext { protected $page; protected $host = 'Centreon-Server'; protected $service = 'downtimeService'; protected $downtimeProperties; private function setRecurrentDowntime() { $this->page = new RecurrentDowntimeConfigurationPage($this); $this->page->setProperties(array( 'name' => 'test', 'alias' => $this->service, 'days' => array(7, 1, 2, 3, 4, 5, 6), 'start' => $this->downtimeProperties['start_time'], 'end' => $this->downtimeProperties['end_time'], 'svc_relation' => $this->host . ' - ' . $this->service )); $this->page->save(); } private function setRealtimeDowntime() { $this->page = new DowntimeConfigurationPage($this); $this->page->setProperties(array( 'type' => DowntimeConfigurationPage::TYPE_SERVICE, 'service' => $this->host . ' - ' . $this->service, 'comment' => 'Acceptance test', 'start_day' => $this->downtimeProperties['start_day'], 'start_time' => $this->downtimeProperties['start_time'], 'end_day' => $this->downtimeProperties['end_day'], 'end_time' => $this->downtimeProperties['end_time'], )); $this->page->save(); } /** * @Given a passive service is monitored */ public function aPassiveServiceIsMonitored() { $page = new ServiceConfigurationPage($this); $page->setProperties(array( 'hosts' => $this->host, 'description' => $this->service, 'templates' => 'generic-service', 'check_command' => 'check_centreon_dummy', 'check_period' => '24x7', 'max_check_attempts' => 1, 'normal_check_interval' => 1, 'retry_check_interval' => 1, 'active_checks_enabled' => 0, 'passive_checks_enabled' => 1, 'notifications_enabled' => 1, 'notify_on_recovery' => 1, 'notify_on_critical' => 1, 'recovery_notification_delay' => 1, 'cs' => 'admin admin' )); $page->save(); $this->reloadAllPollers(); $this->submitServiceResult($this->host, $this->service, 0, __FUNCTION__); $this->waitServiceInMonitoring(); } private function waitServiceInMonitoring() { $this->spin( function ($context) { $monitored = false; $storageDb = $context->getStorageDatabase(); $res = $storageDb->query( 'SELECT s.service_id ' . 'FROM hosts h, services s ' . 'WHERE s.host_id = h.host_id ' . 'AND h.name = "' . $context->host . '" ' . 'AND s.description = "' . $context->service . '" ' ); if ($res->fetch()) { $monitored = true; } return $monitored; }, 'Service ' . $this->host . ' / ' . $this->service . ' is not monitored.', 30 ); } /** * @Given a downtime starting on summer changing time */ public function aDowntimeStartingOnSummerChangingTime() { // on Europe/Paris at 2AM, we jump to 3AM $this->downtimeProperties = array( 'start_day' => '03/25/2029', 'start_time' => '02:30', 'end_day' => '03/25/2029', 'end_time' => '03:30', 'expected_start' => '2029-03-25 03:00', 'expected_end' => '2029-03-25 03:30', 'expected_duration' => '1800', // 30m 'faketime' => '2029-03-25 01:56:00' ); } /** * @Given a downtime ending on summer changing time */ public function aDowntimeEndingOnSummerChangingTime() { // on Europe/Paris at 2AM, we jump to 3AM $this->downtimeProperties = array( 'start_day' => '03/25/2029', 'start_time' => '01:30', 'end_day' => '03/25/2029', 'end_time' => '02:30', 'expected_start' => '2029-03-25 01:30', 'expected_end' => '2029-03-25 03:00', 'expected_duration' => '1800', // 30m 'faketime' => '2029-03-25 01:26:00' ); } /** * @Given a downtime starting and ending on summer changing time */ public function aDowntimeStartingAndEndingOnSummerChangingTime() { // on Europe/Paris at 2AM, we jump to 3AM $this->downtimeProperties = array( 'start_day' => '03/25/2029', 'start_time' => '02:03', 'end_day' => '03/25/2029', 'end_time' => '02:33', 'expected_start' => '', 'expected_end' => '', 'expected_duration' => '0', 'faketime' => '2029-03-25 01:58:00' ); } /** * @Given a downtime during all day on summer changing date */ public function aDowntimeDuringAllDayOnSummerChangingDate() { // on Europe/Paris at 2AM, we jump to 3AM $this->downtimeProperties = array( 'start_day' => '03/25/2029', 'start_time' => '00:00', 'end_day' => '03/25/2029', 'end_time' => '24:00', 'expected_start' => '2029-03-25 00:00', 'expected_end' => '2029-03-26 00:00', 'expected_duration' => '82800', //23h 'faketime' => '2029-03-24 23:56:00' ); } /** * @Given a downtime during all day on summer changing date is scheduled */ public function aDowntimeDuringAllDayOnSummerChangingDateIsScheduled() { $this->aDowntimeDuringAllDayOnSummerChangingDate(); $this->downtimeIsApplied('recurrent'); $this->theDowntimeIsProperlyScheduled(); } /** * @Given a downtime of next day of summer changing date */ public function aDowntimeOfNextDayOfSummerChangingDate() { $this->downtimeProperties = array( 'start_day' => '03/26/2029', 'start_time' => '00:00', 'end_day' => '03/26/2029', 'end_time' => '24:00', 'expected_start' => '2029-03-26 00:00', 'expected_end' => '2029-03-27 00:00', 'expected_duration' => '86400', // 24h 'faketime' => '2029-03-25 23:58:00' ); } /** * @Given a downtime starting on winter changing time */ public function aDowntimeStartingOnWinterChangingDate() { // on Europe/Paris at 3AM, backward to 2AM $this->downtimeProperties = array( 'start_day' => '10/28/2029', 'start_time' => '02:03', 'end_day' => '10/28/2029', 'end_time' => '03:33', 'expected_start' => '2029-10-28 02:03', 'expected_end' => '2029-10-28 03:33', 'expected_duration' => '9000', // 2h30 'faketime' => '2029-10-28 01:58:00' ); } /** * @Given a downtime ending on winter changing time */ public function aDowntimeEndingOnWinterChangingDate() { // on Europe/Paris at 3AM, backward to 2AM $this->downtimeProperties = array( 'start_day' => '10/28/2029', 'start_time' => '01:00', 'end_day' => '10/28/2029', 'end_time' => '02:30', 'expected_start' => '2029-10-28 01:00', 'expected_end' => '2029-10-28 02:30', 'expected_duration' => '9000', // 2h30 'faketime' => '2029-10-28 00:58:00' ); } /** * @Given a downtime starting and ending on winter changing time */ public function aDowntimeStartingAndEndingOnWinterChangingDate() { // on Europe/Paris at 3AM, backward to 2AM $this->downtimeProperties = array( 'start_day' => '10/28/2029', 'start_time' => '02:03', 'end_day' => '10/28/2029', 'end_time' => '02:33', 'expected_start' => '2029-10-28 02:03', 'expected_end' => '2029-10-28 02:33', 'expected_duration' => '5400', // 1h30 'faketime' => '2029-10-28 01:58:00' ); } /** * @Given a downtime during all day on winter changing date */ public function aDowntimeDuringAllDayOnWinterChangingDate() { // on Europe/Paris at 3AM, backward to 2AM $this->downtimeProperties = array( 'start_day' => '10/28/2029', 'start_time' => '00:00', 'end_day' => '10/28/2029', 'end_time' => '24:00', 'expected_start' => '2029-10-28 00:00', 'expected_end' => '2029-10-29 00:00', 'expected_duration' => '90000', // 25h 'faketime' => '2029-10-27 23:58:00' ); } /** * @Given a downtime during all day on winter changing date is scheduled */ public function aDowntimeDuringAllDayOnWinterChangingDateIsScheduled() { $this->aDowntimeDuringAllDayOnWinterChangingDate(); $this->downtimeIsApplied('recurrent'); $this->theDowntimeIsProperlyScheduled(); } /** * @Given a downtime of next day of winter changing date */ public function aDowntimeOfNextDayOfWinterChangingDate() { $this->downtimeProperties = array( 'start_day' => '10/29/2029', 'start_time' => '00:00', 'end_day' => '10/29/2029', 'end_time' => '24:00', 'expected_start' => '2029-10-29 00:00', 'expected_end' => '2029-10-30 00:00', 'expected_duration' => '86400', // 24h 'faketime' => '2029-10-28 23:58:00' ); } /** * @When :downtimeType downtime is applied */ public function downtimeIsApplied($downtimeType) { if ($downtimeType == 'realtime') { $this->setRealtimeDowntime(); } else { $this->setRecurrentDowntime(); $this->container->execute( "faketime '" . $this->downtimeProperties['faketime'] . "'" . " php /usr/share/centreon/cron/downtimeManager.php", $this->webService ); } } /** * @Then the downtime is properly scheduled */ public function theDowntimeIsProperlyScheduled() { $this->spin( function ($context) { $return = $context->container->execute( "cat /var/log/centreon-engine/centengine.log", $this->webService ); $output = $return['output']; if (preg_match_all( '/SCHEDULE_SVC_DOWNTIME;' . $context->host . ';' . $context->service . ';(\d+);(\d+);.+/', $output, $matches )) { $startTimestamp = (int)end($matches[1]); $endTimestamp = (int)end($matches[2]); $dateStart = new DateTime('now', new \DateTimeZone('Europe/Paris')); $dateStart->setTimestamp($startTimestamp); $dateEnd = new DateTime('now', new \DateTimeZone('Europe/Paris')); $dateEnd->setTimestamp($endTimestamp); if ($dateStart->format('Y-m-d H:i') != $context->downtimeProperties['expected_start'] || $dateEnd->format('Y-m-d H:i') != $context->downtimeProperties['expected_end'] || ($endTimestamp - $startTimestamp) != (int)$context->downtimeProperties['expected_duration']) { throw new \Exception( 'Downtime external command parameters are wrong (start, end or duration)' ); } $storageDb = $context->getStorageDatabase(); $res = $storageDb->query( "SELECT downtime_id FROM downtimes " . "WHERE start_time = " . $startTimestamp . " " . "AND end_time = " . $endTimestamp ); if (!$res->fetch()) { throw new \Exception('Downtime does not exist in storage database'); } } else { throw new \Exception('Downtime external command does not exist in centengine logs'); } return true; }, 'Downtime is not scheduled', 30 ); } /** * @Then the downtime is not scheduled */ public function theDowntimeIsNotScheduled() { $this->spin( function ($context) { $scheduled = true; $return = $context->container->execute( "cat /var/log/centreon-engine/centengine.log", $this->webService ); $output = $return['output']; if (preg_match( '/SCHEDULE_SVC_DOWNTIME;' . $this->host . ';' . $this->service . ';(\d+);(\d+);.+/', $output )) { $scheduled = false; } return $scheduled; }, 'Downtime is scheduled', 10 ); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/features/bootstrap/ClapiContext.php
centreon/features/bootstrap/ClapiContext.php
<?php use Centreon\Test\Behat\CentreonContext; class ClapiContext extends CentreonContext { private const CLAPI_ACTIONS_ORDER = [ "ACLACTION", "INSTANCE", "TP", "VENDOR", "CMD", "RESOURCECFG", "CENTBROKERCFG", "ENGINECFG", "CONTACTTPL", "CONTACT", "TRAP", "HTPL", "CG", "LDAP", "HOST", "STPL", "HG", "SERVICE", "SC", "ACLRESOURCE", "ACLGROUP" ]; private const CLAPI_ADD_OBJECTS = [ "ACLMENU", "ACLACTION", "INSTANCE", "TP", "VENDOR", "CMD", "RESOURCECFG", "CENTBROKERCFG", "ENGINECFG", "CONTACTTPL", "CONTACT", "TRAP", "HTPL", "CG", "LDAP", "HOST", "STPL", "HC", "HG", "SERVICE", "SC", "ACLRESOURCE", "ACLGROUP", ]; private const CONFIGURATION_EXPORT_FILENAME = 'clapi-export.txt'; protected $test; protected $object; protected $parameter; protected $file; public function exportClapi($file = null, $selectList = array(), $filter = null) { $cmd = 'centreon -u admin -p Centreon!2021 -e'; if (!empty($selectList)) { foreach ($selectList as $select) { $cmd .= " --select='" . $select . "'"; } } if ($filter) { $cmd .= " --filter='" . $filter . "'"; } if ($file) { $cmd .= " > " . $file; } $output = $this->container->execute( $cmd, $this->webService ); return $output; } /** * @Given a Clapi configuration file */ public function aClapiConfigurationFile() { $this->file['localpath'] = 'tests/clapi_export/clapi-configuration.txt'; $this->file['init'] = '/tmp/clapi-export.txt'; $this->file['compare'] = '/tmp/compare-clapi-export.txt'; $this->container->copyToContainer( $this->file['localpath'], $this->file['init'], $this->webService ); } /** * @Given it was imported */ public function itWasImported() { $cmd = "centreon -u admin -p Centreon!2021 -i " . $this->file['init']; $this->container->execute( $cmd, $this->webService ); } /** * @When I export the configuration through Clapi */ public function IExportTheConfigurationThroughClapi() { $this->exportClapi($this->file['compare']); } /** * @Then the exported file is similar to the imported filed */ public function theExportedFileIsSimilarToTheImportedFiled() { $fileLocal = trim(file_get_contents($this->file['localpath'], FILE_USE_INCLUDE_PATH)); $fileCompare = trim(file_get_contents($this->file['compare'], FILE_USE_INCLUDE_PATH)); if ($fileLocal != $fileCompare) { exec( 'diff ' . $this->file['localpath'] . ' ' . $this->file['compare'], $output ); file_put_contents( $this->composeFiles['log_directory'] . '/' . date('Y-m-d-H-i') . '-diffClapi.txt', implode("\n", $output) ); throw new \Exception('Configuration not imported'); } } /** * @When the user uses the clapi export command */ public function theUserUsesTheClapiExportCommand() { $this->exportClapi(sys_get_temp_dir() . DIRECTORY_SEPARATOR . self::CONFIGURATION_EXPORT_FILENAME); } /** * @Then a valid clapi configuration file should be generated */ public function aValidClapiConfigurationFileShouldBeGenerated() { $exportFileLines = file(sys_get_temp_dir() . DIRECTORY_SEPARATOR . self::CONFIGURATION_EXPORT_FILENAME); array_pop($exportFileLines); foreach ($exportFileLines as $key => $line) { $clapiCommand = explode(';', $line); if (count($clapiCommand) < 3) { throw new \Exception('Wrong export line format, too few arguments : line ' . $key . ' : ' . $line); } } } /** * @Then it should contain the supported configuration objects */ public function itShouldContainTheSupportedConfigurationObjects() { $exportFileLines = file(sys_get_temp_dir() . DIRECTORY_SEPARATOR . self::CONFIGURATION_EXPORT_FILENAME); array_shift($exportFileLines); array_pop($exportFileLines); $clapiActions = []; foreach ($exportFileLines as $line) { $clapiCommand = explode(';', $line); $clapiActions[] = $clapiCommand[0]; } $clapiActions = array_merge(array_unique($clapiActions)); if (self::CLAPI_ACTIONS_ORDER !== $clapiActions) { throw new \Exception( 'Clapi actions order is not the same as the one in the file : ' . implode(', ', $clapiActions) ); } } /** * @When the user uses the clapi import command */ public function theUserUsesTheClapiImportCommand() { $this->container->execute( 'centreon -u admin -p Centreon!2021 -i /tmp/' . self::CONFIGURATION_EXPORT_FILENAME, $this->webService ); } /** * @Then the configuration objects should be added to the central configuration */ public function theConfigurationObjectsShouldBeAddedToTheCentralConfiguration() { $this->exportClapi(sys_get_temp_dir() . DIRECTORY_SEPARATOR . self::CONFIGURATION_EXPORT_FILENAME); $exportFileLines = file(sys_get_temp_dir() . DIRECTORY_SEPARATOR . self::CONFIGURATION_EXPORT_FILENAME); array_shift($exportFileLines); array_pop($exportFileLines); $clapiAddedActions = []; foreach ($exportFileLines as $line) { if (strpos($line, 'ADD;') !== false) { $clapiCommand = explode(';', $line); $clapiAddedActions[] = $clapiCommand[0]; } } $clapiAddedActions = array_merge(array_unique($clapiAddedActions)); if ($clapiAddedActions !== self::CLAPI_ADD_OBJECTS) { throw new \Exception( 'Clapi actions order is not the same as the one in the file : ' . implode(', ', array_diff($clapiAddedActions)) ); } } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/features/assets/centreon-test.conf.php
centreon/features/assets/centreon-test.conf.php
<?php $module_conf['centreon-test']["rname"] = "Centreon Test"; $module_conf['centreon-test']["name"] = "centreon-test"; $module_conf['centreon-test']["mod_release"] = "21.10.0"; $module_conf['centreon-test']["infos"] = "Test module"; $module_conf['centreon-test']["is_removeable"] = "1"; $module_conf['centreon-test']["author"] = "Centreon"; $module_conf['centreon-test']["stability"] = "stable"; $module_conf['centreon-test']["last_update"] = "2021-10-29"; $module_conf['centreon-test']["release_note"] = "https://docs.centreon.com"; $module_conf['centreon-test']["images"] = [];
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/bin/migrateCredentials.php
centreon/bin/migrateCredentials.php
<?php require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../config/centreon.config.php'; require_once __DIR__ . '/../www/include/common/vault-functions.php'; use App\Kernel; use Core\Common\Application\Repository\WriteVaultRepositoryInterface; use Core\Common\Infrastructure\FeatureFlags; use Core\Common\Infrastructure\Repository\AbstractVaultRepository; use Core\Security\Vault\Application\Repository\ReadVaultConfigurationRepositoryInterface; use Symfony\Component\Dotenv\Dotenv; use Symfony\Component\Process\Exception\ProcessFailedException; use Symfony\Component\Process\Process; try { if (posix_getuid() !== 0) { throw new Exception('This script must be run as root'); } $kernel = Kernel::createForWeb(); $readVaultConfigurationRepository = $kernel->getContainer()->get( ReadVaultConfigurationRepositoryInterface::class ); $vaultConfiguration = $readVaultConfigurationRepository->find(); if ($vaultConfiguration === null) { throw new Exception('No vault configured'); } /** @var WriteVaultRepositoryInterface $writeVaultRepository */ $writeVaultRepository = $kernel->getContainer()->get(WriteVaultRepositoryInterface::class); migrateAndUpdateDatabaseCredentials($writeVaultRepository); migrateGorgoneApiCredentials($writeVaultRepository); migrateApplicationCredentials(); } catch (Throwable $ex) { echo($ex->getMessage() . PHP_EOL); } /** * Migrate database credentials into the vault and update configuration files. * * This is handle outside of Symfony Command as this should be executed as root. * * @throws Throwable */ function migrateAndUpdateDatabaseCredentials(WriteVaultRepositoryInterface $writeVaultRepository): void { echo('Migration of database credentials' . PHP_EOL); $writeVaultRepository->setCustomPath(AbstractVaultRepository::DATABASE_VAULT_PATH); $vaultPaths = migrateDatabaseCredentialsToVault($writeVaultRepository); if (! empty($vaultPaths)) { updateConfigFilesWithVaultPath($vaultPaths); } echo('Migration of database credentials completed' . PHP_EOL); } /** * Execute Symfony command to migrate web and modules credentials. * * @throws ProcessFailedException */ function migrateApplicationCredentials(): void { echo('Migration of application credentials' . PHP_EOL); $process = Process::fromShellCommandline( 'sudo -u apache php ' . _CENTREON_PATH_ . '/bin/console list vault:migrate-credentials' ); $process->setWorkingDirectory(_CENTREON_PATH_); $process->mustRun(); preg_match_all('/\S*vault:migrate-credentials:\S*/', $process->getOutput(), $matches); foreach ($matches[0] as $migrationCommand) { $process = Process::fromShellCommandline( 'sudo -u apache php ' . _CENTREON_PATH_ . '/bin/console ' . $migrationCommand ); $process->setWorkingDirectory(_CENTREON_PATH_); $process->mustRun(function ($type, $buffer): void { if (Process::ERR === $type) { echo 'ERROR: ' . $buffer . PHP_EOL; } else { echo $buffer; } }); } echo('Migration of application credentials completed' . PHP_EOL); } /** * Migrate Gorgone API credentials to Vault and update Gorgone API configuration file. * * @param WriteVaultRepositoryInterface $writeVaultRepository */ function migrateGorgoneApiCredentials(WriteVaultRepositoryInterface $writeVaultRepository): void { echo('Migration of Gorgone API credentials' . PHP_EOL); (new Dotenv())->bootEnv('/usr/share/centreon/.env'); $isCloudPlatform = false; if (array_key_exists("IS_CLOUD_PLATFORM", $_ENV) && $_ENV["IS_CLOUD_PLATFORM"]) { $isCloudPlatform = true; } $featuresFileContent = file_get_contents(__DIR__ . '/../config/features.json'); $featureFlagManager = new FeatureFlags($isCloudPlatform, $featuresFileContent); if ($featureFlagManager->isEnabled('vault_gorgone')) { $gorgoneVaultPaths = migrateGorgoneCredentialsToVault($writeVaultRepository); if (! empty($gorgoneVaultPaths)) { updateGorgoneApiFile($gorgoneVaultPaths); } } echo('Migration of Gorgone API credentials completed' . PHP_EOL); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/bin/centreon-remove-duplicate-host-service-relations.php
centreon/bin/centreon-remove-duplicate-host-service-relations.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 * */ declare(strict_types=1); require_once __DIR__ . '/../config/centreon.config.php'; require_once _CENTREON_PATH_ . '/www/class/centreonDB.class.php'; $centreonDb = new CentreonDB(hostCentreon); $number = $centreonDb->exec( <<<'SQL' DELETE FROM host_service_relation WHERE hsr_id IN ( SELECT hsr_id FROM host_service_relation INNER JOIN ( SELECT min(hsr_id) as hsr_id_to_keep, host_host_id, service_service_id FROM host_service_relation WHERE hostgroup_hg_id IS NULL AND servicegroup_sg_id IS NULL GROUP BY host_host_id, service_service_id HAVING count(*) > 1 ) duplicates USING (host_host_id, service_service_id) WHERE hsr_id != hsr_id_to_keep ) SQL ); if (is_int($number)) { $message = match ($number) { 1 => $number . ' relation was deleted', default => $number . ' relations were deleted', }; echo $message . PHP_EOL; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/bin/migrateWikiPages.php
centreon/bin/migrateWikiPages.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(realpath(dirname(__FILE__) . '/../config/centreon.config.php')); require_once _CENTREON_PATH_ . '/www/class/centreonDB.class.php'; require_once _CENTREON_PATH_ . '/www/class/centreon-knowledge/wikiApi.class.php'; $wikiApi = new WikiApi(); $pages = $wikiApi->getAllPages(); foreach ($pages as $page) { $newName = ''; if (preg_match('/Host\:(.+)/', $page, $matches)) { $newName = 'Host : ' . $matches[1]; } elseif (preg_match('/Host-Template\:(.+)/', $page, $matches)) { $newName = 'Host-Template : ' . $matches[1]; } elseif (preg_match('/Service\:(.+)/', $page, $matches) && !preg_match('/Service\:\s+\/\s+/', $page)) { $name = explode(' ', $matches[1]); if (count($name) > 1) { $hostName = array_shift($name); $serviceName = implode(' ', $name); $newName = 'Service : ' . $hostName . ' / ' . $serviceName; } } elseif (preg_match('/Service-Template\:(.+)/', $page, $matches)) { $newName = 'Service-Template : ' . $matches[1]; } if (!empty($newName)) { $newName = str_replace(' ', '_', $newName); $wikiApi->movePage($page, $newName); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/bin/centreon-partitioning.php
centreon/bin/centreon-partitioning.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(realpath(dirname(__FILE__) . '/../config/centreon.config.php')); require_once _CENTREON_PATH_ . '/www/class/centreonPurgeEngine.class.php'; require_once _CENTREON_PATH_ . '/www/class/centreonDB.class.php'; require_once _CENTREON_PATH_ . '/www/class/centreon-partition/partEngine.class.php'; require_once _CENTREON_PATH_ . '/www/class/centreon-partition/config.class.php'; require_once _CENTREON_PATH_ . '/www/class/centreon-partition/mysqlTable.class.php'; require_once _CENTREON_PATH_ . '/www/class/centreon-partition/options.class.php'; $options = new Options(); $table = $options->getOptionValue('m'); if (is_null($table)) { echo "Missing -m option. Please select a table to be partitioned\n"; exit(1); } /* Create partitioned tables */ $centreonDb = new CentreonDB('centreon'); $centstorageDb = new CentreonDB('centstorage', 3); $partEngine = new PartEngine(); if (!$partEngine->isCompatible($centstorageDb)) { echo "[" . date(DATE_RFC822) . "] " . "CRITICAL: MySQL server is not compatible with partitionning. MySQL version must be greater or equal to 5.1\n"; exit(1); } echo "[" . date(DATE_RFC822) . "] PARTITIONING STARTED\n"; try { $configFile = _CENTREON_PATH_ . '/config/partition.d/partitioning-' . $table . '.xml'; $config = new Config($centstorageDb, $configFile, $centreonDb); $mysqlTable = $config->getTable($table); if ($partEngine->isPartitioned($mysqlTable, $centstorageDb)) { throw new \Exception("Table " . $table . " is already partitioned\n"); } $partEngine->migrate($mysqlTable, $centstorageDb); } catch (\Exception $e) { echo "[" . date(DATE_RFC822) . "] " . $e->getMessage(); echo "[" . date(DATE_RFC822) . "] PARTITIONING EXITED\n"; exit(1); } echo "[" . date(DATE_RFC822) . "] PARTITIONING COMPLETED\n"; exit(0);
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/bin/centreon-sanitize-images.php
centreon/bin/centreon-sanitize-images.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(__DIR__ . '/../vendor/autoload.php'); use enshrined\svgSanitize\Sanitizer; use Symfony\Component\Finder\Finder; ############################### # COMMON FUNCTION # ############################### /** * Get the result of asked question. * * @param string $question * @param boolean $hidden * @return string */ $askQuestion = function (string $question, bool $hidden = false): string { if ($hidden) { system("stty -echo"); } printf("%s", $question); $handle = fopen("php://stdin", "r"); $response = ''; if ($handle) { $fGets = fgets($handle); if ($fGets) { $response = trim($fGets); } fclose($handle); } if ($hidden) { system("stty echo"); } printf("\n"); return $response; }; /** * Get the images where MIME Type is incorrect or image extension don't match the MIME Type. * * @param array<string> $files * @return array<string> * @throws \Exception */ $getInvalidImages = function (array $files): array { $mimeTypeFileExtensionConcordance = [ "svg" => "image/svg+xml", "jpg" => "image/jpeg", "jpeg" => "image/jpeg", "gif" => "image/gif", "png" => "image/png" ]; $invalidImages = []; foreach ($files as $file) { $fileExploded = explode(".", $file); $fileExtension = end($fileExploded); if (!array_key_exists($fileExtension, $mimeTypeFileExtensionConcordance)) { throw new \Exception(sprintf('Invalid image extension: %s', $fileExtension)); } $mimeType = mime_content_type($file); if ($mimeType) { /** * If MIME type is invalid or extension doesn't match MIME type */ if ( !preg_match('/(^image\/(jpg|jpeg|svg\+xml|gif|png)$)/', $mimeType) || ( preg_match('/^image\//', $mimeType) && $mimeType !== $mimeTypeFileExtensionConcordance[$fileExtension] ) ) { $invalidImages[] = $file; } } } return $invalidImages; }; /** * Get all the svg images. * * @param array<string> $files * @return array<string> */ $getSvgImages = function (array $files): array { $svgFiles = []; foreach ($files as $file) { $fileExploded = explode(".", $file); $fileExtension = end($fileExploded); $mimeType = mime_content_type($file); if (($mimeType && preg_match('/(^image\/svg\+xml$)/', $mimeType)) && $fileExtension === "svg") { $svgFiles[] = $file; } } return $svgFiles; }; /** * Sanitize a SVG file. * * @param string $file * @throws \Exception */ $sanitizeSvg = function (string $file): void { $sanitizer = new Sanitizer(); $svg = file_get_contents($file); if ($svg === false) { throw new \Exception('Unable to get content of file: ' . $file); } $cleanSvg = $sanitizer->sanitize($svg); if (file_put_contents($file, $cleanSvg) === false) { throw new \Exception('Unable to replace content of file: ' . $file); }; }; /** * List all the invalid and/or svg images * * @return array<string,array> */ $listImages = function () use ($getInvalidImages, $getSvgImages): array { $finder = new Finder(); $images = $finder->in(__DIR__ . '/../www/img/media')->name(['*.jpg', '*.jpeg', '*.svg', '*.gif', '*.png']); $imagesPath = []; foreach ($images as $image) { $imagesPath[] = $image->getPathName(); } $invalidImages = $getInvalidImages($imagesPath); $svgImages = $getSvgImages($imagesPath); $images = [ "invalidImages" => [], "svgImages" => [] ]; foreach ($invalidImages as $invalidImage) { $images['invalidImages'][] = $invalidImage; } foreach ($svgImages as $svgImage) { $images['svgImages'][] = $svgImage; } return $images; }; /** * Convert a corrupted image into a red cross on white background. * * @param string $invalidImg * @throws \Exception */ $convertCorruptedImageOrFail = function (string $invalidImg): void { // Get image extension $invalidImgPathExploded = explode('.', $invalidImg); $invalidImgExtension = end($invalidImgPathExploded); //Check that extension is handled. if (in_array($invalidImgExtension, ['jpg', 'jpeg', 'svg', 'gif', 'png']) === false) { throw new \Exception('Invalid format: ' . $invalidImgExtension); } // Get size $invalidImgSize = getimagesize($invalidImg); if ($invalidImgSize === false) { $width = 100; $height = 100; } else { $width = $invalidImgSize[0]; $height = $invalidImgSize[1]; } // Create the image $newImg = imagecreate($width, $height); if ($newImg === false) { throw new Exception('Unable to create a generic image for file: ' . $invalidImg); } imagecolorallocate($newImg, 255, 255, 255); $lineColor = imagecolorallocate($newImg, 255, 0, 0); if ($lineColor !== false) { imageline($newImg, $width, 0, 0, $height, $lineColor); imageline($newImg, 0, 0, $width, $height, $lineColor); } // Save image as correct MIME Type switch ($invalidImgExtension) { case "jpeg": case "jpg": if (@unlink($invalidImg) === false) { throw new \Exception( sprintf("Unable to delete %s before replacing it by a generic image.", $invalidImg) ); } imagejpeg($newImg, $invalidImg); break; case "gif": if (@unlink($invalidImg) === false) { throw new \Exception( sprintf("Unable to delete %s before replacing it by a generic image.", $invalidImg) ); } imagegif($newImg, $invalidImg); break; //svg will be recreated as PNG as we don't have possibility to recreate a svg. case "png": case "svg": if (@unlink($invalidImg) === false) { throw new \Exception( sprintf("Unable to delete %s before replacing it by a generic image.", $invalidImg) ); } imagepng($newImg, $invalidImg); break; default: break; } }; // Get Script options $options = getopt('h::', ['help::']); if (($options && array_key_exists('help', $options)) || ($options && array_key_exists('h', $options))) { echo "This script will sanitize all your svg files and replace your corrupted images by a generic image. \n"; exit(0); } $files = $listImages(); if (empty($files['svgImages']) && empty($files['invalidImages'])) { echo PHP_EOL . "Nothing to do, everything is fine." . PHP_EOL; exit(0); } if (!empty($files['svgImages'])) { echo "The following SVGs can be sanitized to prevent any injections:" . PHP_EOL; foreach ($files['svgImages'] as $svgImage) { $pattern = str_replace('/', '\/', __DIR__ . '/../www/img/media/'); echo preg_replace('/' . $pattern . '/', '', $svgImage) . PHP_EOL; } echo PHP_EOL; } if (!empty($files['invalidImages'])) { echo "The following images have an invalid MIME type or a mismatch between MIME type and " . "file extension and can be replaced by a generic image:" . PHP_EOL; foreach ($files['invalidImages'] as $invalidImg) { $pattern = str_replace('/', '\/', __DIR__ . '/../www/img/media/'); echo preg_replace('/' . $pattern . '/', '', $invalidImg) . PHP_EOL; } echo PHP_EOL; } $proceed = $askQuestion('Would you like to proceed to sanitize ? [y/N]: '); if (strtolower($proceed) === 'y') { foreach ($files['svgImages'] as $svgImage) { try { $sanitizeSvg($svgImage); } catch (\Exception $ex) { echo "ERROR - " . $ex->getMessage(); exit(1); } } foreach ($files['invalidImages'] as $invalidImg) { try { $convertCorruptedImageOrFail($invalidImg); } catch (\Exception $ex) { echo "ERROR - " . $ex->getMessage(); exit(1); } } echo "Sanitize done." . PHP_EOL; } else { exit(0); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/bin/centreon-translations.php
centreon/bin/centreon-translations.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ if (strlen($argv[1]) !== 2) { exit( sprintf("The length of the language code must be 2\n") ); } $languageCode = strtolower($argv[1]); if ($argc === 3 || $argc === 4) { if (!file_exists($argv[2])) { exit( sprintf("Translation file '%s' does not exist\n", $argv[2]) ); } } else { $currentFileInfos = pathinfo(__FILE__); $execFile = $currentFileInfos['filename'] . '.' . $currentFileInfos['extension']; printf("usage: {$execFile} code_language translation_file.po translated_file.ser\n" . " code_language code of the language (ex: fr, es, de, ...)\n" . " translation_file.po file where the translation exists\n" . " translated_file.ser Serialized file where the translation will be converted\n"); } define('TOKEN_LENGTH', 6); if ($argc === 3) { $translationFileInfos = pathinfo($argv[1]); $destinationFile = $translationFileInfos['dirname'] . '/' . $translationFileInfos['filename'] . '.json'; createTranslationFile($languageCode, $argv[2], $destinationFile); } if ($argc === 4) { if (file_exists($argv[3])) { if (false === unlink($argv[3])) { exit("Destination file already exists, impossible to delete it\n"); } } $destinationFileInfos = pathinfo($argv[3]); $destinationDirectory = $destinationFileInfos['dirname']; if (!is_dir($destinationDirectory)) { if (false === mkdir($destinationDirectory, 0775, true)) { exit( sprintf("Impossible to create directory '%s'\n", $destinationDirectory) ); } } createTranslationFile($languageCode, $argv[2], $argv[3]); } /** * Create translation file for React * * @param string $languageCode Code of the language (ex: fr, es, de, ...) * @param string $translationFile File where the translation exists * @param string $destinationFile Serialized file where the translation will be converted */ function createTranslationFile( string $languageCode, string $translationFile, string $destinationFile ): void { $translations = []; $englishTranslation = []; $isDefaultTranslation = $languageCode === 'en'; $id = null; $translation = null; if ($fleHandler = fopen($translationFile, 'r')) { while (false !== ($line = fgets($fleHandler))) { $line = trim($line); // Removes double-quotes character that surround the text if (preg_match('/^(?:(msgid|msgstr)\s+)?"(.*)"\s*$/', $line, $matches)) { if ($matches[1] === 'msgid') { $id = $matches[2]; $translation = null; } elseif ($matches[1] === 'msgstr') { $translation = $matches[2]; } elseif ($id !== null && $translation === null) { $id .= $matches[2]; } elseif ($id !== null && $translation !== null) { $translation .= $matches[2]; } } elseif (!empty($id) && !empty($translation)) { $englishTranslation[$id] = $id; if (!$isDefaultTranslation) { // Only if the code of language is not 'en' $translations[$id] = $translation; } $id = null; $translation = null; } } fclose($fleHandler); } if (!empty($id) && !empty($translation)) { $englishTranslation[$id] = $id; if (!$isDefaultTranslation) { $translations[$id] = $translation; } } $final['en'] = $englishTranslation; if (!$isDefaultTranslation) { // Only if the code of language is not 'en' $final[$languageCode] = $translations; } if (0 === file_put_contents($destinationFile, serialize($final))) { exit( sprintf("Impossible to create destination file '%s'\n", $destinationFile) ); } chmod($destinationFile, 0664); }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Slug.class.php
centreon/lib/Slug.class.php
<?php /* * Copyright 2005 - 2025 Centreon (https://www.centreon.com/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information : contact@centreon.com * */ /** * Create a slug for URLs * * Note that this Class is made for UTF-8-Strings * * @author Fabian Graßl <fg@jusmeum.de> */ class Slug implements ArrayAccess { protected $original = null; protected $slug = null; protected $options = ['to_lower' => true, 'max_length' => null, 'prefix' => null, 'postfix' => null, 'seperator_char' => '-']; protected $char_map = ['Š' => 'S', 'š' => 's', 'Ð' => 'Dj', 'Ž' => 'Z', 'ž' => 'z', 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'Ae', 'Å' => 'A', 'Æ' => 'A', 'Ç' => 'C', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'Oe', 'Ø' => 'O', 'Ü' => 'Ue', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ý' => 'Y', 'Þ' => 'B', 'ß' => 'ss', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'ae', 'å' => 'a', 'æ' => 'a', 'ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ð' => 'o', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'oe', 'ø' => 'o', 'ü' => 'ue', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ý' => 'y', 'ý' => 'y', 'þ' => 'b', 'ÿ' => 'y', 'ƒ' => 'f', 'Ŕ' => 'R', 'ŕ' => 'r']; /** * Constructor. * * Available options: * * * to_lower: Whether the slug should be lowercase (true by default) * * max_length: NULL for no maximum lenght or maximum lenght of the returned slug (NULL by default) * * prefix: prefix for the slug * * postfix: postfix for the slug * * seperator_char: word seperator char for the slug (default -) * * @param string $original An array of field default values * @param array $options An array of options * @param array $char_map a char-map-array that is used for the strtr() PHP-function in the slug generation process */ public function __construct($original, $options = [], $char_map = null) { $this->original = $original; $this->options = array_merge($this->options, $options); if ($char_map !== null) { $this->char_map = $char_map; } } /** * Returns the slug-string * * @return string the slug * @see getSlug() */ public function __toString() { return $this->getSlug(); } /** * Generate the slug. */ public function generateSlug(): void { $str = $this->original; if ($this['to_lower']) { $str = mb_strtolower($str, 'UTF-8'); } // replace the chars in $this->char_map $str = strtr($str, $this->char_map); // ensure that there are only valid characters in the url (A-Z a-z 0-9, seperator_char) $str = preg_replace('/[^A-Za-z0-9]/', $this['seperator_char'], $str); // trim the seperator char at the end and teh beginning $str = trim($str, $this['seperator_char']); // remove duplicate seperator chars $str = preg_replace('/[' . preg_quote($this['seperator_char']) . ']+/', $this['seperator_char'], $str); if ($this['max_length']) { $str = $this->shortenSlug($str, $this['max_length'] - mb_strlen($this['prefix'], 'UTF-8') - mb_strlen($this['postfix'], 'UTF-8')); } // Add prefix & postfix $this->slug = $this['prefix'] . $str . $this['postfix']; } /** * Returns the slug-string * * @return string the slug * @see generateSlug() */ public function getSlug() { if ($this->slug === null) { $this->generateSlug(); } return $this->slug; } /** * Sets a char-map-array that is used for the strtr() PHP-function in the slug generation process * * @param string $char_map The option name */ public function setCharMap($char_map): void { $this->char_map = $char_map; } /** * Sets the option associated with the offset (implements the ArrayAccess interface). * * @param string $offset The option name * @param string $value The option value */ public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->options[] = $value; } else { $this->options[$offset] = $value; } } /** * Returns true if the option exists (implements the ArrayAccess interface). * * @param string $name The name of option * @param mixed $offset * @return bool true if the option exists, false otherwise */ public function offsetExists($offset) { return isset($this->options[$offset]); } /** * Unsets the option associated with the offset (implements the ArrayAccess interface). * * @param string $offset The option name */ public function offsetUnset($offset): void { $this->options[$offset] = null; } /** * Returns an option (implements the ArrayAccess interface). * * @param string $name The offset of the option to get * @param mixed $offset * @return mixed The option if exists, null otherwise */ public function offsetGet($offset) { return $this->options[$offset] ?? null; } /** * Shorten the slug. * @param mixed $slug * @param mixed $maxLen */ protected function shortenSlug($slug, $maxLen) { // $maxLen must be greater than 1 if ($maxLen < 1) { return $slug; } // check whether there is work to do if (strlen($slug) < $maxLen) { return $slug; } // cut to $maxLen $cutted_slug = trim(substr($slug, 0, $maxLen), $this['seperator_char']); // cut to the last position of '-' in cutted string $beautified_slug = trim(preg_replace('/[^' . preg_quote($this['seperator_char']) . ']*$/', '', $cutted_slug), $this['seperator_char']); // only return the beautified string when it is long enough if (strlen($beautified_slug) < ($maxLen / 2)) { return $cutted_slug; } return $beautified_slug; } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Object.php
centreon/lib/Centreon/Object/Object.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 Pimple\Container; /** * Abstract Centreon Object class * * @author sylvestre */ abstract class Centreon_Object { /** * Database Connector * @var CentreonDB */ protected $db; /** * Table name of the object * @var string|null */ protected $table = null; /** * Primary key name * @var string|null */ protected $primaryKey = null; /** * Unique label field * @var string|null */ protected $uniqueLabelField = null; /** * Centreon_Object constructor * * @param Container $dependencyInjector */ public function __construct(Container $dependencyInjector) { $this->db = $dependencyInjector['configuration_db']; } /** * Generic method that allows to retrieve object ids * from another object parameter * * @param string $name * @param array $args * @throws Exception * @return array */ public function __call($name, $args) { if (preg_match('/^getIdBy([a-zA-Z0-9_]+)/', $name, $matches)) { return $this->getIdByParameter($matches[1], $args); } throw new Exception('Unknown method'); } /** * Used for inserting object into database * * @param array $params * * @throws PDOException * @return false|string|null */ public function insert($params = []) { $sql = "INSERT INTO {$this->table} "; $sqlFields = ''; $sqlValues = ''; $sqlParams = []; foreach ($params as $key => $value) { if ($key == $this->primaryKey) { continue; } if ($sqlFields != '') { $sqlFields .= ','; } if ($sqlValues != '') { $sqlValues .= ','; } $sqlFields .= $key; $sqlValues .= '?'; $sqlParams[] = trim($value); } if ($sqlFields && $sqlValues) { $sql .= '(' . $sqlFields . ') VALUES (' . $sqlValues . ')'; $this->db->query($sql, $sqlParams); return $this->db->lastInsertId(); } return null; } /** * Used for deleteing object from database * * @param int $objectId * * @throws PDOException */ public function delete($objectId): void { $sql = "DELETE FROM {$this->table} WHERE {$this->primaryKey} = ?"; $this->db->query($sql, [$objectId]); } /** * Used for updating object in database * * @param int $objectId * @param array $params * * @throws PDOException * @return void */ public function update($objectId, $params = []): void { $sql = "UPDATE {$this->table} SET "; $sqlUpdate = ''; $sqlParams = []; $not_null_attributes = []; if (array_search('', $params)) { $sql_attr = "SHOW FIELDS FROM {$this->table}"; $res = $this->getResult($sql_attr, [], 'fetchAll'); foreach ($res as $tab) { if ($tab['Null'] == 'NO') { $not_null_attributes[$tab['Field']] = true; } } } foreach ($params as $key => $value) { if ($key == $this->primaryKey) { continue; } if ($sqlUpdate != '') { $sqlUpdate .= ','; } $sqlUpdate .= $key . ' = ? '; if ($value === '' && ! isset($not_null_attributes[$key])) { $value = null; } if (! is_null($value)) { $value = str_replace('<br/>', "\n", $value); } $sqlParams[] = $value; } if ($sqlUpdate) { $sqlParams[] = $objectId; $sql .= $sqlUpdate . " WHERE {$this->primaryKey} = ?"; $this->db->query($sql, $sqlParams); } } /** * Used for duplicating object * * @param int $sourceObjectId * @param int $duplicateEntries * * @throws PDOException * @todo relations */ public function duplicate($sourceObjectId, $duplicateEntries = 1): void { $sourceParams = $this->getParameters($sourceObjectId, '*'); if (isset($sourceParams[$this->primaryKey])) { unset($sourceParams[$this->primaryKey]); } if (isset($sourceParams[$this->uniqueLabelField])) { $originalName = $sourceParams[$this->uniqueLabelField]; } $originalName = $sourceParams[$this->uniqueLabelField]; for ($i = 1; $i <= $duplicateEntries; $i++) { if (isset($sourceParams[$this->uniqueLabelField], $originalName)) { $sourceParams[$this->uniqueLabelField] = $originalName . '_' . $i; } $ids = $this->getIdByParameter($this->uniqueLabelField, [$sourceParams[$this->uniqueLabelField]]); if (! count($ids)) { $this->insert($sourceParams); } } } /** * Get object parameters * * @param int $objectId * @param mixed $parameterNames * * @throws PDOException * @return array */ public function getParameters($objectId, $parameterNames) { $params = is_array($parameterNames) ? implode(',', $parameterNames) : $parameterNames; $sql = "SELECT {$params} FROM {$this->table} WHERE {$this->primaryKey} = ?"; return $this->getResult($sql, [$objectId], 'fetch'); } /** * List all objects with all their parameters * Data heavy, use with as many parameters as possible * in order to limit it * * @param mixed $parameterNames * @param int $count * @param int $offset * @param string $order * @param string $sort * @param array $filters * @param string $filterType * @throws Exception * @return array */ public function getList( $parameterNames = '*', $count = -1, $offset = 0, $order = null, $sort = 'ASC', $filters = [], $filterType = 'OR', ) { if ($filterType != 'OR' && $filterType != 'AND') { throw new Exception('Unknown filter type'); } $params = is_array($parameterNames) ? implode(',', $parameterNames) : $parameterNames; $sql = "SELECT {$params} FROM {$this->table} "; $filterTab = []; if (count($filters)) { foreach ($filters as $key => $rawvalue) { if ($filterTab === []) { $sql .= " WHERE {$key} "; } else { $sql .= " {$filterType} {$key} "; } if (is_array($rawvalue)) { $sql .= ' IN (' . str_repeat('?,', count($rawvalue) - 1) . '?) '; $filterTab = array_merge($filterTab, $rawvalue); } else { $sql .= ' LIKE ? '; $value = trim($rawvalue); $value = str_replace('\\', '\\\\', $value); $value = str_replace('_', "\_", $value); $value = str_replace(' ', "\ ", $value); $filterTab[] = $value; } } } if (isset($order, $sort) && (strtoupper($sort) == 'ASC' || strtoupper($sort) == 'DESC')) { $sql .= " ORDER BY {$order} {$sort} "; } if (isset($count) && $count != -1) { $sql = $this->db->limit($sql, $count, $offset); } return $this->getResult($sql, $filterTab, 'fetchAll'); } /** * Generic method that allows to retrieve object ids * from another object parameter * * @param string $paramName * @param array $paramValues * * @throws PDOException * @return array */ public function getIdByParameter($paramName, $paramValues = []) { $sql = "SELECT {$this->primaryKey} FROM {$this->table} WHERE "; $condition = ''; if (! is_array($paramValues)) { $paramValues = [$paramValues]; } foreach ($paramValues as $val) { if ($condition != '') { $condition .= ' OR '; } $condition .= $paramName . ' = ? '; } if ($condition) { $sql .= $condition; $rows = $this->getResult($sql, $paramValues, 'fetchAll'); $tab = []; foreach ($rows as $val) { $tab[] = $val[$this->primaryKey]; } return $tab; } return []; } /** * Primary Key Getter * * @return string */ public function getPrimaryKey() { return $this->primaryKey; } /** * Unique label field getter * * @return string */ public function getUniqueLabelField() { return $this->uniqueLabelField; } /** * Get Table Name * * @return string */ public function getTableName() { return $this->table; } /** * Get result from sql query * * @param string $sqlQuery * @param array $sqlParams * @param string $fetchMethod * * @throws PDOException * @return array */ protected function getResult($sqlQuery, $sqlParams = [], $fetchMethod = 'fetchAll') { $res = $this->db->query($sqlQuery, $sqlParams); return $res->{$fetchMethod}(); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/ObjectRt.php
centreon/lib/Centreon/Object/ObjectRt.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 Pimple\Container; /** * Abstract Centreon Object class */ abstract class Centreon_ObjectRt { /** Database Connector */ protected $dbMon; /** Table name of the object */ protected $table = null; /** Primary key name */ protected $primaryKey = null; /** Unique label field */ protected $uniqueLabelField = null; /** * Centreon_ObjectRt constructor * * @param Container $dependencyInjector */ public function __construct(Container $dependencyInjector) { $this->dbMon = $dependencyInjector['realtime_db']; } /** * Generic method that allows to retrieve object ids * from another object parameter * * @param string $name * @param array $args * @throws Exception * @return array */ public function __call($name, $args) { if (preg_match('/^getIdBy([a-zA-Z0-9_]+)/', $name, $matches)) { return $this->getIdByParameter($matches[1], $args); } throw new Exception('Unknown method'); } /** * Get object parameters * * @param int $objectId * @param mixed $parameterNames * @return array */ public function getParameters($objectId, $parameterNames) { $params = is_array($parameterNames) ? implode(',', $parameterNames) : $parameterNames; $sql = "SELECT {$params} FROM {$this->table} WHERE {$this->primaryKey} = ?"; return $this->getResult($sql, [$objectId], 'fetch'); } /** * List all objects with all their parameters * Data heavy, use with as many parameters as possible * in order to limit it * * @param mixed $parameterNames * @param int $count * @param int $offset * @param string $order * @param string $sort * @param array $filters * @param string $filterType * @throws Exception * @return array */ public function getList( $parameterNames = '*', $count = -1, $offset = 0, $order = null, $sort = 'ASC', $filters = [], $filterType = 'OR', ) { if ($filterType != 'OR' && $filterType != 'AND') { throw new Exception('Unknown filter type'); } $params = is_array($parameterNames) ? implode(',', $parameterNames) : $parameterNames; $sql = "SELECT {$params} FROM {$this->table} "; $filterTab = []; if (count($filters)) { foreach ($filters as $key => $rawvalue) { if ($filterTab === []) { $sql .= " WHERE {$key} LIKE ? "; } else { $sql .= " {$filterType} {$key} LIKE ? "; } $value = trim($rawvalue); $value = str_replace('\\', '\\\\', $value); $value = str_replace('_', "\_", $value); $value = str_replace(' ', "\ ", $value); $filterTab[] = $value; } } if (isset($order, $sort) && (strtoupper($sort) == 'ASC' || strtoupper($sort) == 'DESC')) { $sql .= " ORDER BY {$order} {$sort} "; } if (isset($count) && $count != -1) { $sql = $this->dbMon->limit($sql, $count, $offset); } return $this->getResult($sql, $filterTab, 'fetchAll'); } /** * Generic method that allows to retrieve object ids * from another object parameter * * @param string $paramName * @param array $paramValues * @return array */ public function getIdByParameter($paramName, $paramValues = []) { $sql = "SELECT {$this->primaryKey} FROM {$this->table} WHERE "; $condition = ''; if (! is_array($paramValues)) { $paramValues = [$paramValues]; } foreach ($paramValues as $val) { if ($condition != '') { $condition .= ' OR '; } $condition .= $paramName . ' = ? '; } if ($condition) { $sql .= $condition; $rows = $this->getResult($sql, $paramValues, 'fetchAll'); $tab = []; foreach ($rows as $val) { $tab[] = $val[$this->primaryKey]; } return $tab; } return []; } /** * Primary Key Getter * * @return string */ public function getPrimaryKey() { return $this->primaryKey; } /** * Unique label field getter * * @return string */ public function getUniqueLabelField() { return $this->uniqueLabelField; } /** * Get Table Name * * @return string */ public function getTableName() { return $this->table; } /** * Get result from sql query * * @param string $sqlQuery * @param array $sqlParams * @param string $fetchMethod * @return array */ protected function getResult($sqlQuery, $sqlParams = [], $fetchMethod = 'fetchAll') { $res = $this->dbMon->query($sqlQuery, $sqlParams); return $res->{$fetchMethod}(); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Meta/Service.php
centreon/lib/Centreon/Object/Meta/Service.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/Object/Object.php'; /** * Used for interacting with service categories * * @author sylvestre */ class Centreon_Object_Meta_Service extends Centreon_Object { protected $table = 'meta_service'; protected $primaryKey = 'meta_id'; protected $uniqueLabelField = 'meta_name'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Timeperiod/Timeperiod.php
centreon/lib/Centreon/Object/Timeperiod/Timeperiod.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__ . '/../Object.php'; /** * Used for interacting with time periods * * @author sylvestre */ class Centreon_Object_Timeperiod extends Centreon_Object { protected $table = 'timeperiod'; protected $primaryKey = 'tp_id'; protected $uniqueLabelField = 'tp_name'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Timeperiod/Exception.php
centreon/lib/Centreon/Object/Timeperiod/Exception.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__ . '/../Object.php'; /** * Used for interacting with host custom macros * * @author sylvestre */ class Centreon_Object_Timeperiod_Exception extends Centreon_Object { protected $table = 'timeperiod_exceptions'; protected $primaryKey = 'exception_id'; protected $uniqueLabelField = 'days'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Resource/Resource.php
centreon/lib/Centreon/Object/Resource/Resource.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/Object/Object.php'; /** * Used for interacting with Resource objects ($USER1$, $USER2$ etc...) * * @author sylvestre */ class Centreon_Object_Resource extends Centreon_Object { protected $table = 'cfg_resource'; protected $primaryKey = 'resource_id'; protected $uniqueLabelField = 'resource_name'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Graph/Template/Template.php
centreon/lib/Centreon/Object/Graph/Template/Template.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/Object/Object.php'; /** * Used for interacting with Graph templates * * @author sylvestre */ class Centreon_Object_Graph_Template extends Centreon_Object { protected $table = 'giv_graphs_template'; protected $primaryKey = 'graph_id'; protected $uniqueLabelField = 'name'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Acknowledgement/RtAcknowledgement.php
centreon/lib/Centreon/Object/Acknowledgement/RtAcknowledgement.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/Object/ObjectRt.php'; /** * Class * * @class Centreon_Object_RtAcknowledgement */ class Centreon_Object_RtAcknowledgement extends Centreon_ObjectRt { /** @var string */ protected $table = 'acknowledgements'; /** @var string */ protected $primaryKey = 'acknowledgement_id'; /** @var string */ protected $uniqueLabelField = 'comment_data'; /** * @param int[] $hostIds * @return array */ public function getLastHostAcknowledgement($hostIds = []) { $hostFilter = ''; if (! empty($hostIds)) { $hostFilter = 'AND hosts.host_id IN (' . implode(',', $hostIds) . ')'; } return $this->getResult( sprintf( 'SELECT ack.acknowledgement_id, hosts.name, ack.entry_time as entry_time, ack.author, ack.comment_data, ack.sticky, ack.notify_contacts, ack.persistent_comment FROM acknowledgements ack INNER JOIN hosts ON hosts.host_id = ack.host_id INNER JOIN (SELECT MAX(ack.entry_time) AS entry_time, ack.host_id FROM acknowledgements ack INNER JOIN hosts ON hosts.host_id = ack.host_id WHERE hosts.acknowledged = 1 AND ack.service_id = 0 %s GROUP BY ack.host_id ) AS tmp ON tmp.entry_time = ack.entry_time AND tmp.host_id = ack.host_id AND ack.service_id = 0 ORDER BY ack.entry_time, hosts.name', $hostFilter ) ); } /** * @param string[] $svcList * @return array */ public function getLastSvcAcknowledgement($svcList = []) { $serviceFilter = ''; if (! empty($svcList)) { $serviceFilter = 'AND ('; $filterTab = []; $counter = count($svcList); for ($i = 0; $i < $counter; $i += 2) { $hostname = $svcList[$i]; $serviceDescription = $svcList[$i + 1]; $filterTab[] = '(host.name = "' . $hostname . '" AND service.description = "' . $serviceDescription . '")'; } $serviceFilter .= implode(' AND ', $filterTab) . ') '; } return $this->getResult( sprintf( 'SELECT ack.acknowledgement_id, host.name, service.description, ack.entry_time, ack.author, ack.comment_data , ack.sticky, ack.notify_contacts, ack.persistent_comment FROM acknowledgements ack INNER JOIN services service ON service.service_id = ack.service_id INNER JOIN hosts host ON host.host_id = service.host_id AND host.host_id = ack.host_id INNER JOIN (SELECT max(ack.entry_time) AS entry_time, host.host_id, service.service_id FROM acknowledgements ack INNER JOIN services service ON service.service_id = ack.service_id INNER JOIN hosts host ON host.host_id = service.host_id AND host.host_id = ack.host_id WHERE service.acknowledged = 1 %s GROUP BY host.host_id, service.service_id) AS tmp ON tmp.entry_time = ack.entry_time AND tmp.host_id = ack.host_id AND tmp.service_id = ack.service_id ORDER BY ack.entry_time, host.name, service.description', $serviceFilter ) ); } /** * @param $serviceId * @return bool */ public function svcIsAcknowledged($serviceId) { $query = 'SELECT acknowledged FROM services WHERE service_id = ? '; return (bool) ($this->getResult($query, [$serviceId], 'fetch')['acknowledged'] == 1); } /** * @param $hostId * @return bool */ public function hostIsAcknowledged($hostId) { $query = 'SELECT acknowledged FROM hosts WHERE host_id = ? '; return (bool) ($this->getResult($query, [$hostId], 'fetch')['acknowledged'] == 1); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Host/Extended.php
centreon/lib/Centreon/Object/Host/Extended.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/Object/Object.php'; /** * Used for interacting with host extended information * * @author sylvestre */ class Centreon_Object_Host_Extended extends Centreon_Object { protected $table = 'extended_host_information'; protected $primaryKey = 'host_host_id'; protected $uniqueLabelField = 'host_host_id'; /** * Used for inserting object into database * * @param array $params * @return int */ public function insert($params = []) { $sql = "INSERT INTO {$this->table} "; $sqlFields = ''; $sqlValues = ''; $sqlParams = []; foreach ($params as $key => $value) { if ($sqlFields != '') { $sqlFields .= ','; } if ($sqlValues != '') { $sqlValues .= ','; } $sqlFields .= $key; $sqlValues .= '?'; $sqlParams[] = $value; } if ($sqlFields && $sqlValues) { $sql .= '(' . $sqlFields . ') VALUES (' . $sqlValues . ')'; $this->db->query($sql, $sqlParams); return $this->db->lastInsertId(); } return null; } /** * Get object parameters * * @param int $objectId * @param mixed $parameterNames * @return array */ public function getParameters($objectId, $parameterNames) { $params = parent::getParameters($objectId, $parameterNames); $params_image = ['ehi_icon_image', 'ehi_statusmap_image']; foreach ($params_image as $image) { if (array_key_exists($image, $params)) { $sql = 'SELECT dir_name,img_path FROM view_img vi LEFT JOIN view_img_dir_relation vidr ON vi.img_id = vidr.img_img_id LEFT JOIN view_img_dir vid ON vid.dir_id = vidr.dir_dir_parent_id WHERE img_id = ?'; $res = $this->getResult($sql, [$params[$image]], 'fetch'); if (is_array($res)) { $params[$image] = $res['dir_name'] . '/' . $res['img_path']; } } } return $params; } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Host/Category.php
centreon/lib/Centreon/Object/Host/Category.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/Object/Object.php'; /** * Used for interacting with host categories * * @author sylvestre */ class Centreon_Object_Host_Category extends Centreon_Object { protected $table = 'hostcategories'; protected $primaryKey = 'hc_id'; protected $uniqueLabelField = 'hc_name'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Host/Template.php
centreon/lib/Centreon/Object/Host/Template.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/Object/Object.php'; /** * Used for interacting with hosts * * @author Toufik MECHOUET */ class Centreon_Object_Host_Template extends Centreon_Object { protected $table = 'host'; protected $primaryKey = 'host_id'; protected $uniqueLabelField = 'host_name'; /** * Generic method that allows to retrieve object ids * from another object parameter * * @param string $paramName * @param array $paramValues * @return array */ public function getIdByParameter($paramName, $paramValues = []) { $sql = "SELECT {$this->primaryKey} FROM {$this->table} WHERE "; $condition = ''; if (! is_array($paramValues)) { $paramValues = [$paramValues]; } foreach ($paramValues as $val) { if ($condition != '') { $condition .= ' OR '; } $condition .= $paramName . ' = ? '; } if ($condition) { $sql .= $condition; $sql .= ' AND ' . $this->table . ".host_register = '0' "; $rows = $this->getResult($sql, $paramValues, 'fetchAll'); $tab = []; foreach ($rows as $val) { $tab[] = $val[$this->primaryKey]; } return $tab; } return []; } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Host/Group.php
centreon/lib/Centreon/Object/Host/Group.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/Object/Object.php'; /** * Used for interacting with hostgroups * * @author sylvestre */ class Centreon_Object_Host_Group extends Centreon_Object { protected $table = 'hostgroup'; protected $primaryKey = 'hg_id'; protected $uniqueLabelField = 'hg_name'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Host/Host.php
centreon/lib/Centreon/Object/Host/Host.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/Object/Object.php'; /** * Used for interacting with hosts * * @author sylvestre */ class Centreon_Object_Host extends Centreon_Object { protected $table = 'host'; protected $primaryKey = 'host_id'; protected $uniqueLabelField = 'host_name'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Host/Macro/Custom.php
centreon/lib/Centreon/Object/Host/Macro/Custom.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/Object/Object.php'; /** * Used for interacting with host custom macros * * @author sylvestre */ class Centreon_Object_Host_Macro_Custom extends Centreon_Object { protected $table = 'on_demand_macro_host'; protected $primaryKey = 'host_macro_id'; protected $uniqueLabelField = 'host_macro_name'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Timezone/Timezone.php
centreon/lib/Centreon/Object/Timezone/Timezone.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/Object/Object.php'; /** * Used for interacting with timezone */ class Centreon_Object_Timezone extends Centreon_Object { protected $table = 'timezone'; protected $primaryKey = 'timezone_id'; protected $uniqueLabelField = 'timezone_name'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Manufacturer/Manufacturer.php
centreon/lib/Centreon/Object/Manufacturer/Manufacturer.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/Object/Object.php'; /** * Used for interacting with Manufacturer (vendor) * * @author sylvestre */ class Centreon_Object_Manufacturer extends Centreon_Object { protected $table = 'traps_vendor'; protected $primaryKey = 'id'; protected $uniqueLabelField = 'name'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Ldap/ObjectLdap.php
centreon/lib/Centreon/Object/Ldap/ObjectLdap.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/Object/Object.php'; /** * Used for interacting with Instances (pollers) * * @author sylvestre */ class Centreon_Object_Ldap extends Centreon_Object { protected $table = 'auth_ressource'; protected $primaryKey = 'ar_id'; protected $uniqueLabelField = 'ar_name'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Ldap/ConfigurationLdap.php
centreon/lib/Centreon/Object/Ldap/ConfigurationLdap.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/Object/Object.php'; /** * Used for interacting with Instances (pollers) * * @author sylvestre */ class Centreon_Object_Configuration_Ldap extends Centreon_Object { protected $table = 'auth_ressource_info'; protected $primaryKey = 'ar_id'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Ldap/ServerLdap.php
centreon/lib/Centreon/Object/Ldap/ServerLdap.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/Object/Object.php'; /** * Used for interacting with Instances (pollers) * * @author sylvestre */ class Centreon_Object_Server_Ldap extends Centreon_Object { protected $table = 'auth_ressource_host'; protected $primaryKey = 'ldap_host_id'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Broker/Broker.php
centreon/lib/Centreon/Object/Broker/Broker.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/Object/Object.php'; /** * Class * * @class Centreon_Object_Broker * @descriptionUsed for interacting with Centreon Broker configuration */ class Centreon_Object_Broker extends Centreon_Object { /** @var string */ protected $table = 'cfg_centreonbroker'; /** @var string */ protected $primaryKey = 'config_id'; /** @var string */ protected $uniqueLabelField = 'config_name'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Dependency/Dependency.php
centreon/lib/Centreon/Object/Dependency/Dependency.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/Object/Object.php'; /** * Class * * @class Centreon_Object_Dependency */ class Centreon_Object_Dependency extends Centreon_Object { /** @var string */ protected $table = 'dependency'; /** @var string */ protected $primaryKey = 'dep_id'; /** @var string */ protected $uniqueLabelField = 'dep_name'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Dependency/DependencyServicegroupParent.php
centreon/lib/Centreon/Object/Dependency/DependencyServicegroupParent.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/Object/Object.php'; /** * Class * * @class Centreon_Object_DependencyServicegroupParent * @description Used for interacting with dependencies */ class Centreon_Object_DependencyServicegroupParent extends Centreon_Object { /** @var string */ protected $table = 'dependency_servicegroupParent_relation'; /** @var string */ protected $primaryKey = 'dependency_dep_id'; /** * @param int $servicegroupId * * @throws PDOException * @return void */ public function removeRelationLastServicegroupDependency(int $servicegroupId): void { $query = 'SELECT count(dependency_dep_id) AS nb_dependency , dependency_dep_id AS id FROM dependency_servicegroupParent_relation WHERE dependency_dep_id = (SELECT dependency_dep_id FROM dependency_servicegroupParent_relation WHERE servicegroup_sg_id = ?) GROUP BY dependency_dep_id'; $result = $this->getResult($query, [$servicegroupId], 'fetch'); // is last parent if (isset($result['nb_dependency']) && $result['nb_dependency'] == 1) { $this->db->query('DELETE FROM dependency WHERE dep_id = ' . $result['id']); } } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Dependency/DependencyServiceParent.php
centreon/lib/Centreon/Object/Dependency/DependencyServiceParent.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/Object/Object.php'; /** * Class * * @class Centreon_Object_DependencyServiceParent * @description Used for interacting with dependencies */ class Centreon_Object_DependencyServiceParent extends Centreon_Object { /** @var string */ protected $table = 'dependency_serviceParent_relation'; /** @var string */ protected $primaryKey = 'dependency_dep_id'; /** * @param int $serviceId * * @throws PDOException * @return void */ public function removeRelationLastServiceDependency(int $serviceId): void { $query = 'SELECT count(dependency_dep_id) AS nb_dependency , dependency_dep_id AS id FROM dependency_serviceParent_relation WHERE dependency_dep_id = (SELECT dependency_dep_id FROM dependency_serviceParent_relation WHERE service_service_id = ?) GROUP BY dependency_dep_id'; $result = $this->getResult($query, [$serviceId], 'fetch'); // is last parent if (isset($result['nb_dependency']) && $result['nb_dependency'] == 1) { $this->db->query('DELETE FROM dependency WHERE dep_id = ' . $result['id']); } } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Dependency/DependencyHostParent.php
centreon/lib/Centreon/Object/Dependency/DependencyHostParent.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/Object/Object.php'; /** * Class * * @class Centreon_Object_DependencyHostParent * @description Used for interacting with dependencies */ class Centreon_Object_DependencyHostParent extends Centreon_Object { /** @var string */ protected $table = 'dependency_hostParent_relation'; /** @var string */ protected $primaryKey = 'dependency_dep_id'; /** * @param int $hostId * * @throws PDOException * @return void */ public function removeRelationLastHostDependency(int $hostId): void { $query = 'SELECT count(dependency_dep_id) AS nb_dependency , dependency_dep_id AS id FROM dependency_hostParent_relation WHERE dependency_dep_id = (SELECT dependency_dep_id FROM dependency_hostParent_relation WHERE host_host_id = ?) GROUP BY dependency_dep_id'; $result = $this->getResult($query, [$hostId], 'fetch'); // is last parent if (isset($result['nb_dependency']) && $result['nb_dependency'] == 1) { $this->db->query('DELETE FROM dependency WHERE dep_id = ' . $result['id']); } } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Dependency/DependencyHostgroupParent.php
centreon/lib/Centreon/Object/Dependency/DependencyHostgroupParent.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/Object/Object.php'; /** * Class * * @class Centreon_Object_DependencyHostgroupParent * @descritpion Used for interacting with dependencies */ class Centreon_Object_DependencyHostgroupParent extends Centreon_Object { /** @var string */ protected $table = 'dependency_hostgroupParent_relation'; /** @var string */ protected $primaryKey = 'dependency_dep_id'; /** * @param int $hgId * * @throws PDOException * @return void */ public function removeRelationLastHostgroupDependency(int $hgId): void { $query = 'SELECT count(dependency_dep_id) AS nb_dependency , dependency_dep_id AS id FROM dependency_hostgroupParent_relation WHERE dependency_dep_id = (SELECT dependency_dep_id FROM dependency_hostgroupParent_relation WHERE hostgroup_hg_id = ?) GROUP BY dependency_dep_id'; $result = $this->getResult($query, [$hgId], 'fetch'); // is last parent if (isset($result['nb_dependency']) && $result['nb_dependency'] == 1) { $this->db->query('DELETE FROM dependency WHERE dep_id = ' . $result['id']); } } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Contact/Group.php
centreon/lib/Centreon/Object/Contact/Group.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__ . '/../Object.php'; /** * Class * * @class Centreon_Object_Contact_Group */ class Centreon_Object_Contact_Group extends Centreon_Object { /** @var string */ protected $table = 'contactgroup'; /** @var string */ protected $primaryKey = 'cg_id'; /** @var string */ protected $uniqueLabelField = 'cg_name'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Contact/Contact.php
centreon/lib/Centreon/Object/Contact/Contact.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__ . '/../Object.php'; require_once __DIR__ . '/../../../../www/class/centreonContact.class.php'; /** * Class * * @class Centreon_Object_Contact */ class Centreon_Object_Contact extends Centreon_Object { /** @var string */ protected $table = 'contact'; /** @var string */ protected $primaryKey = 'contact_id'; /** @var string */ protected $uniqueLabelField = 'contact_alias'; /** * @param $params * * @throws PDOException * @return false|string|null */ public function insert($params = []) { $sql = "INSERT INTO {$this->table} "; $sqlFields = ''; $sqlValues = ''; $sqlParams = []; // Store password value and remove it from the array to not inserting it in contact table. if (isset($params['contact_passwd'])) { $password = $params['contact_passwd']; unset($params['contact_passwd']); } foreach ($params as $key => $value) { if ($key == $this->primaryKey) { continue; } if ($sqlFields != '') { $sqlFields .= ','; } if ($sqlValues != '') { $sqlValues .= ','; } $sqlFields .= $key; $sqlValues .= '?'; $sqlParams[] = trim($value); } if ($sqlFields && $sqlValues) { $sql .= '(' . $sqlFields . ') VALUES (' . $sqlValues . ')'; $this->db->query($sql, $sqlParams); $contactId = $this->db->lastInsertId(); if (isset($password, $contactId)) { $contact = new CentreonContact($this->db); $contact->addPasswordByContactId($contactId, $password); } return $contactId; } return null; } /** * @inheritDoc */ public function getList( $parameterNames = '*', $count = -1, $offset = 0, $order = null, $sort = 'ASC', $filters = [], $filterType = 'OR', ) { if ($filterType != 'OR' && $filterType != 'AND') { throw new Exception('Unknown filter type'); } if (is_array($parameterNames)) { if (($key = array_search('contact_id', $parameterNames)) !== false) { $parameterNames[$key] = $this->table . '.contact_id'; } $params = implode(',', $parameterNames); } elseif ($parameterNames === 'contact_id') { $params = $this->table . '.contact_id'; } else { $params = $parameterNames; } $sql = "SELECT {$params} FROM {$this->table}"; $filterTab = []; if (count($filters)) { foreach ($filters as $key => $rawvalue) { if ($filterTab === []) { $sql .= " WHERE {$key} "; } else { $sql .= " {$filterType} {$key} "; } if (is_array($rawvalue)) { $sql .= ' IN (' . str_repeat('?,', count($rawvalue) - 1) . '?) '; $filterTab = array_merge($filterTab, $rawvalue); } else { $sql .= ' LIKE ? '; $value = trim($rawvalue); $value = str_replace('\\', '\\\\', $value); $value = str_replace('_', "\_", $value); $value = str_replace(' ', "\ ", $value); $filterTab[] = $value; } } } if (isset($order, $sort) && (strtoupper($sort) == 'ASC' || strtoupper($sort) == 'DESC')) { $sql .= " ORDER BY {$order} {$sort} "; } if (isset($count) && $count != -1) { $sql = $this->db->limit($sql, $count, $offset); } $contacts = $this->getResult($sql, $filterTab, 'fetchAll'); foreach ($contacts as &$contact) { $statement = $this->db->prepare( 'SELECT password FROM contact_password WHERE contact_id = :contactId ' . 'ORDER BY creation_date DESC LIMIT 1' ); $statement->bindValue(':contactId', $contact['contact_id'], PDO::PARAM_INT); $statement->execute(); $contact['contact_passwd'] = ($result = $statement->fetch(PDO::FETCH_ASSOC)) ? $result['password'] : null; } return $contacts; } /** * @inheritDoc */ public function update($contactId, $params = []): void { $sql = "UPDATE {$this->table} SET "; $sqlUpdate = ''; $sqlParams = []; $not_null_attributes = []; // Store password value and remove it from the array to not inserting it in contact table. if (isset($params['contact_passwd'])) { $password = $params['contact_passwd']; unset($params['contact_passwd']); } if (isset($params['contact_autologin_key'])) { $statement = $this->db->prepare( 'SELECT password FROM contact_password WHERE contact_id = :contactId ' . 'ORDER BY creation_date DESC LIMIT 1' ); $statement->bindValue(':contactId', $contactId, PDO::PARAM_INT); $statement->execute(); if ( ($result = $statement->fetch(PDO::FETCH_ASSOC)) && password_verify($params['contact_autologin_key'], $result['password']) ) { throw new Exception(_('Your autologin key must be different than your current password')); } } if (array_search('', $params)) { $sql_attr = "SHOW FIELDS FROM {$this->table}"; $res = $this->getResult($sql_attr, [], 'fetchAll'); foreach ($res as $tab) { if ($tab['Null'] == 'NO') { $not_null_attributes[$tab['Field']] = true; } } } foreach ($params as $key => $value) { if ($key == $this->primaryKey) { continue; } if ($sqlUpdate != '') { $sqlUpdate .= ','; } $sqlUpdate .= $key . ' = ? '; if ($value === '' && ! isset($not_null_attributes[$key])) { $value = null; } if (! is_null($value)) { $value = str_replace('<br/>', "\n", $value); } $sqlParams[] = $value; } if ($sqlUpdate) { $sqlParams[] = $contactId; $sql .= $sqlUpdate . " WHERE {$this->primaryKey} = ?"; $this->db->query($sql, $sqlParams); } if (isset($password, $contactId)) { $contact = new CentreonContact($this->db); $contact->renewPasswordByContactId($contactId, $password); } } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Downtime/RtDowntime.php
centreon/lib/Centreon/Object/Downtime/RtDowntime.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/Object/ObjectRt.php'; /** * Class * * @class Centreon_Object_RtDowntime */ class Centreon_Object_RtDowntime extends Centreon_ObjectRt { /** @var string */ protected $table = 'downtimes'; /** @var string */ protected $name = 'downtime_name'; /** @var string */ protected $primaryKey = 'downtime_id'; /** @var string */ protected $uniqueLabelField = 'comment_data'; /** * @param array $hostList * @return array */ public function getHostDowntimes($hostList = []) { $hostFilter = ''; if (! empty($hostList)) { $hostFilter = "AND h.name IN ('" . implode("','", $hostList) . "') "; } $query = 'SELECT downtime_id, name, author, actual_start_time , actual_end_time, ' . 'start_time, end_time, comment_data, duration, fixed ' . 'FROM downtimes d, hosts h ' . 'WHERE d.host_id = h.host_id ' . 'AND d.cancelled = 0 ' . 'AND type = 2 ' . 'AND end_time > UNIX_TIMESTAMP(NOW()) ' . $hostFilter . 'ORDER BY actual_start_time, name'; return $this->getResult($query); } /** * @param array $svcList * @return array */ public function getSvcDowntimes($svcList = []) { $serviceFilter = ''; if (! empty($svcList)) { $serviceFilter = 'AND ('; $filterTab = []; $counter = count($svcList); for ($i = 0; $i < $counter; $i += 2) { $hostname = $svcList[$i]; $serviceDescription = $svcList[$i + 1]; $filterTab[] = '(h.name = "' . $hostname . '" AND s.description = "' . $serviceDescription . '")'; } $serviceFilter .= implode(' AND ', $filterTab) . ') '; } $query = 'SELECT d.downtime_id, h.name, s.description, author, actual_start_time, actual_end_time, ' . 'start_time, end_time, comment_data, duration, fixed ' . 'FROM downtimes d, hosts h, services s ' . 'WHERE d.service_id = s.service_id ' . 'AND d.host_id = s.host_id ' . 'AND s.host_id = h.host_id ' . 'AND d.cancelled = 0 ' . 'AND d.type = 1 ' . 'AND end_time > UNIX_TIMESTAMP(NOW()) ' . $serviceFilter . 'ORDER BY actual_start_time, h.name, s.description'; return $this->getResult($query); } /** * @param $id * @return array */ public function getCurrentDowntime($id) { $query = 'SELECT * FROM downtimes WHERE ISNULL(actual_end_time) ' . ' AND end_time > ' . time() . ' AND downtime_id = ' . $id; return $this->getResult($query, [], 'fetch'); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Downtime/Downtime.php
centreon/lib/Centreon/Object/Downtime/Downtime.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/Object/Object.php'; /** * Class * * @class Centreon_Object_Downtime */ class Centreon_Object_Downtime extends Centreon_Object { /** @var string */ protected $table = 'downtime'; /** @var string */ protected $primaryKey = 'dt_id'; /** @var string */ protected $uniqueLabelField = 'dt_name'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Acl/Action.php
centreon/lib/Centreon/Object/Acl/Action.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__ . '/../Object.php'; /** * Class * * @class Centreon_Object_Acl_Action */ class Centreon_Object_Acl_Action extends Centreon_Object { /** @var string */ protected $table = 'acl_actions'; /** @var string */ protected $primaryKey = 'acl_action_id'; /** @var string */ protected $uniqueLabelField = 'acl_action_name'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Acl/Menu.php
centreon/lib/Centreon/Object/Acl/Menu.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__ . '/../Object.php'; /** * Class * * @class Centreon_Object_Acl_Menu */ class Centreon_Object_Acl_Menu extends Centreon_Object { /** @var string */ protected $table = 'acl_topology'; /** @var string */ protected $primaryKey = 'acl_topo_id'; /** @var string */ protected $uniqueLabelField = 'acl_topo_name'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Acl/Resource.php
centreon/lib/Centreon/Object/Acl/Resource.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__ . '/../Object.php'; /** * Class * * @class Centreon_Object_Acl_Resource */ class Centreon_Object_Acl_Resource extends Centreon_Object { /** @var string */ protected $table = 'acl_resources'; /** @var string */ protected $primaryKey = 'acl_res_id'; /** @var string */ protected $uniqueLabelField = 'acl_res_name'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Acl/Group.php
centreon/lib/Centreon/Object/Acl/Group.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__ . '/../Object.php'; /** * Class * * @class Centreon_Object_Acl_Group */ class Centreon_Object_Acl_Group extends Centreon_Object { /** @var string */ protected $table = 'acl_groups'; /** @var string */ protected $primaryKey = 'acl_group_id'; /** @var string */ protected $uniqueLabelField = 'acl_group_name'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Instance/Instance.php
centreon/lib/Centreon/Object/Instance/Instance.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 Centreon\Domain\PlatformTopology\Interfaces\PlatformInterface; use Centreon\Domain\PlatformTopology\Model\PlatformRegistered; use Centreon\Infrastructure\PlatformTopology\Repository\Model\PlatformTopologyFactoryRDB; require_once 'Centreon/Object/Object.php'; /** * Used for interacting with Instances (pollers) * * @author sylvestre */ class Centreon_Object_Instance extends Centreon_Object { protected $table = 'nagios_server'; protected $primaryKey = 'id'; protected $uniqueLabelField = 'name'; public function getDefaultInstance() { $res = $this->db->query('SELECT `name` FROM `nagios_server` WHERE `is_default` = 1'); if ($res->rowCount() == 0) { $res = $this->db->query("SELECT `name` FROM `nagios_server` WHERE `localhost` = '1'"); } $row = $res->fetch(); return $row['name']; } /** * Insert platform in nagios_server and platform_topology tables. * * @param array<string,mixed> $params * @return int */ public function insert($params = []) { if (! array_key_exists('ns_ip_address', $params) || ! array_key_exists('name', $params)) { throw new InvalidArgumentException('Missing parameters'); } $platformTopology = $this->findPlatformTopologyByAddress($params['ns_ip_address']); $serverId = null; $isAlreadyInTransaction = $this->db->inTransaction(); if (! $isAlreadyInTransaction) { $this->db->beginTransaction(); } if ($platformTopology !== null) { if ($platformTopology->isPending() === false) { throw new Exception('Platform already created'); } /** * Check if the parent is a registered remote. */ $parentPlatform = $this->findPlatformTopology($platformTopology->getParentId()); if ($parentPlatform !== null && $parentPlatform->getType() === PlatformRegistered::TYPE_REMOTE) { if ($parentPlatform->getServerId() === null) { throw new Exception("Parent remote server isn't registered"); } $params['remote_id'] = $parentPlatform->getServerId(); } try { $serverId = parent::insert($params); $platformTopology->setPending(false); $platformTopology->setServerId($serverId); $this->updatePlatformTopology($platformTopology); } catch (Exception $ex) { if (! $isAlreadyInTransaction) { $this->db->rollBack(); } throw new Exception('Unable to update platform', 0, $ex); } } else { try { $serverId = parent::insert($params); $params['server_id'] = $serverId; $this->insertIntoPlatformTopology($params); } catch (Exception $ex) { if (! $isAlreadyInTransaction) { $this->db->rollBack(); } throw new Exception('Unable to create platform', 0, $ex); } } if (! $isAlreadyInTransaction) { $this->db->commit(); } return $serverId; } /** * Find existing platform by id. * * @param int $id * @return PlatformInterface|null */ private function findPlatformTopology(int $id): ?PlatformInterface { $statement = $this->db->prepare('SELECT * FROM platform_topology WHERE id=:id'); $statement->bindValue(':id', $id, PDO::PARAM_INT); $statement->execute(); if ($result = $statement->fetch(PDO::FETCH_ASSOC)) { return PlatformTopologyFactoryRDB::create($result); } return null; } /** * Find existing platform by address. * * @param string $address * @return PlatformInterface|null */ private function findPlatformTopologyByAddress(string $address): ?PlatformInterface { $statement = $this->db->prepare('SELECT * FROM platform_topology WHERE address=:address'); $statement->bindValue(':address', $address, PDO::PARAM_STR); $statement->execute(); if ($result = $statement->fetch(PDO::FETCH_ASSOC)) { return PlatformTopologyFactoryRDB::create($result); } return null; } /** * Update a platform topology. * * @param PlatformInterface $platformTopology */ private function updatePlatformTopology(PlatformInterface $platformTopology): void { $statement = $this->db->prepare( 'UPDATE platform_topology SET pending=:isPending, server_id=:serverId WHERE address=:address' ); $statement->bindValue(':isPending', $platformTopology->isPending() ? '1' : '0', PDO::PARAM_STR); $statement->bindValue(':serverId', $platformTopology->getServerId(), PDO::PARAM_INT); $statement->bindValue(':address', $platformTopology->getAddress(), PDO::PARAM_STR); $statement->execute(); } /** * Insert the poller in platform_topology. * * @param array<string,mixed> $params */ private function insertIntoPlatformTopology(array $params): void { $centralPlatformTopologyId = $this->findCentralPlatformTopologyId(); if ($centralPlatformTopologyId === null) { throw new Exception('No Central found in topology'); } $statement = $this->db->prepare( 'INSERT INTO platform_topology (address, name, type, pending, parent_id, server_id) ' . "VALUES (:address, :name, '" . PlatformRegistered::TYPE_POLLER . "', '0', :parentId, :serverId)" ); $statement->bindValue(':address', $params['ns_ip_address'], PDO::PARAM_STR); $statement->bindValue(':name', $params['name'], PDO::PARAM_STR); $statement->bindValue(':parentId', $centralPlatformTopologyId, PDO::PARAM_INT); $statement->bindValue(':serverId', $params['server_id'], PDO::PARAM_INT); $statement->execute(); } /** * Find the Central Id in platform_topology. * * @return int|null */ private function findCentralPlatformTopologyId(): ?int { $result = $this->db->query( "SELECT id from platform_topology WHERE type ='" . PlatformRegistered::TYPE_CENTRAL . "'" ); if ($row = $result->fetch(PDO::FETCH_ASSOC)) { return (int) $row['id']; } return null; } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Trap/Trap.php
centreon/lib/Centreon/Object/Trap/Trap.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/Object/Object.php'; /** * Used for interacting with traps * * @author sylvestre */ class Centreon_Object_Trap extends Centreon_Object { protected $table = 'traps'; protected $primaryKey = 'traps_id'; protected $uniqueLabelField = 'traps_name'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Trap/Matching.php
centreon/lib/Centreon/Object/Trap/Matching.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/Object/Object.php'; /** * Used for interacting with Trap matching rules (vendor) * * @author sylvestre */ class Centreon_Object_Trap_Matching extends Centreon_Object { protected $table = 'traps_matching_properties'; protected $primaryKey = 'tmo_id'; protected $uniqueLabelField = ''; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Relation.php
centreon/lib/Centreon/Object/Relation/Relation.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 Pimple\Container; /** * Class * * @class Centreon_Object_Relation */ abstract class Centreon_Object_Relation { /** @var string */ public $firstObject; /** @var string */ public $secondObject; /** @var mixed */ protected $db; /** @var null */ protected $relationTable = null; /** @var null */ protected $firstKey = null; /** @var null */ protected $secondKey = null; /** * Centreon_Object_Relation constructor * * @param Container $dependencyInjector */ public function __construct(Container $dependencyInjector) { $this->db = $dependencyInjector['configuration_db']; } /** * Generic method that allows to retrieve target ids * from another another source id * * @param string $name * @param array $args * @throws Exception * @return array */ public function __call($name, $args = []) { if (! count($args)) { throw new Exception('Missing arguments'); } if (! isset($this->secondKey)) { throw new Exception('Not a relation table'); } if (preg_match('/^get([a-zA-Z0-9_]+)From([a-zA-Z0-9_]+)/', $name, $matches)) { if ( ($matches[1] != $this->firstKey && $matches[1] != $this->secondKey) || ($matches[2] != $this->firstKey && $matches[2] != $this->secondKey) ) { throw new Exception('Unknown field'); } return $this->getTargetIdFromSourceId($matches[1], $matches[2], $args); } if (preg_match('/^delete_([a-zA-Z0-9_]+)/', $name, $matches)) { if ($matches[1] == $this->firstKey) { $this->delete($args[0]); } elseif ($matches[1] == $this->secondKey) { $this->delete(null, $args[0]); } else { throw new Exception('Unknown field'); } } else { throw new Exception('Unknown method'); } } /** * Used for inserting relation into database * * @param int $fkey * @param int $skey * @return void */ public function insert($fkey, $skey = null): void { $sql = "INSERT INTO {$this->relationTable} ({$this->firstKey}, {$this->secondKey}) VALUES (?, ?)"; $this->db->query($sql, [$fkey, $skey]); } /** * Used for deleting relation from database * * @param int $fkey * @param int $skey * @return void */ public function delete($fkey, $skey = null): void { if (isset($fkey, $skey)) { $sql = "DELETE FROM {$this->relationTable} WHERE {$this->firstKey} = ? AND {$this->secondKey} = ?"; $args = [$fkey, $skey]; } elseif (isset($skey)) { $sql = "DELETE FROM {$this->relationTable} WHERE {$this->secondKey} = ?"; $args = [$skey]; } else { $sql = "DELETE FROM {$this->relationTable} WHERE {$this->firstKey} = ?"; $args = [$fkey]; } $this->db->query($sql, $args); } /** * Get relation Ids * * @throws Exception * @return array */ public function getRelations() { $sql = 'SELECT ' . $this->firstKey . ',' . $this->secondKey . ' ' . 'FROM ' . $this->relationTable; return $this->getResult($sql); } /** * Get Merged Parameters from seperate tables * * @param array $firstTableParams * @param array $secondTableParams * @param int $count * @param int $offset * @param null $order * @param string $sort * @param array $filters * @param string $filterType * @throws Exception * @return false|mixed */ public function getMergedParameters( $firstTableParams = [], $secondTableParams = [], $count = -1, $offset = 0, $order = null, $sort = 'ASC', $filters = [], $filterType = 'OR', ) { if (! isset($this->firstObject) || ! isset($this->secondObject)) { throw new Exception('Unsupported method on this object'); } $fString = ''; $sString = ''; foreach ($firstTableParams as $fparams) { if ($fString != '') { $fString .= ','; } $fString .= $this->firstObject->getTableName() . '.' . $fparams; } foreach ($secondTableParams as $sparams) { if ($fString != '' || $sString != '') { $sString .= ','; } $sString .= $this->secondObject->getTableName() . '.' . $sparams; } $sql = 'SELECT ' . $fString . $sString . ' FROM ' . $this->firstObject->getTableName() . ',' . $this->secondObject->getTableName() . ',' . $this->relationTable . ' WHERE ' . $this->firstObject->getTableName() . '.' . $this->firstObject->getPrimaryKey() . ' = ' . $this->relationTable . '.' . $this->firstKey . ' AND ' . $this->relationTable . '.' . $this->secondKey . ' = ' . $this->secondObject->getTableName() . '.' . $this->secondObject->getPrimaryKey(); $filterTab = []; if (count($filters)) { foreach ($filters as $key => $rawvalue) { if (is_array($rawvalue)) { $sql .= " {$filterType} {$key} IN (" . str_repeat('?,', count($rawvalue) - 1) . '?) '; $filterTab = array_merge($filterTab, $rawvalue); } else { $sql .= " {$filterType} {$key} LIKE ? "; $value = trim($rawvalue); $value = str_replace('\\', '\\\\', $value); $value = str_replace('_', "\_", $value); $value = str_replace(' ', "\ ", $value); $filterTab[] = $value; } } } if (isset($order, $sort) && (strtoupper($sort) == 'ASC' || strtoupper($sort) == 'DESC')) { $sql .= " ORDER BY {$order} {$sort} "; } if (isset($count) && $count != -1) { $sql = $this->db->limit($sql, $count, $offset); } return $this->getResult($sql, $filterTab); } /** * Get target id from source id * * @param int $sourceKey * @param int $targetKey * @param array $sourceId * @return array */ public function getTargetIdFromSourceId($targetKey, $sourceKey, $sourceId) { if (! is_array($sourceId)) { $sourceId = [$sourceId]; } $sql = "SELECT {$targetKey} FROM {$this->relationTable} WHERE {$sourceKey} = ?"; $result = $this->getResult($sql, $sourceId); $tab = []; foreach ($result as $rez) { $tab[] = $rez[$targetKey]; } return $tab; } /** * Get First Key * * @return string */ public function getFirstKey() { return $this->firstKey; } /** * Get Second Key * * @return string */ public function getSecondKey() { return $this->secondKey; } /** * @param $sql * @param $params * * @return mixed */ protected function getResult($sql, $params = []) { $res = $this->db->query($sql, $params); return $res->fetchAll(); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Timeperiod/Exclude.php
centreon/lib/Centreon/Object/Relation/Timeperiod/Exclude.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__ . '/../Relation.php'; class Centreon_Object_Relation_Timeperiod_Exclude extends Centreon_Object_Relation { protected $relationTable = 'timeperiod_exclude_relations'; protected $firstKey = 'timeperiod_id'; protected $secondKey = 'timeperiod_exclude_id'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Timeperiod/Include.php
centreon/lib/Centreon/Object/Relation/Timeperiod/Include.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__ . '/../Relation.php'; class Centreon_Object_Relation_Timeperiod_Include extends Centreon_Object_Relation { protected $relationTable = 'timeperiod_include_relations'; protected $firstKey = 'timeperiod_id'; protected $secondKey = 'timeperiod_include_id'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Host/Service.php
centreon/lib/Centreon/Object/Relation/Host/Service.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/Object/Relation/Relation.php'; require_once 'Centreon/Object/Host/Host.php'; require_once 'Centreon/Object/Service/Service.php'; /** * Class * * @class Centreon_Object_Relation_Host_Service */ class Centreon_Object_Relation_Host_Service extends Centreon_Object_Relation { /** @var Centreon_Object_Host */ public $firstObject; /** @var Centreon_Object_Service */ public $secondObject; /** @var string */ protected $relationTable = 'host_service_relation'; /** @var string */ protected $firstKey = 'host_host_id'; /** @var string */ protected $secondKey = 'service_service_id'; /** * Centreon_Object_Relation_Host_Service constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Host($dependencyInjector); $this->secondObject = new Centreon_Object_Service($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Host/Template/Host.php
centreon/lib/Centreon/Object/Relation/Host/Template/Host.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/Object/Relation/Relation.php'; /** * Class * * @class Centreon_Object_Relation_Host_Template_Host */ class Centreon_Object_Relation_Host_Template_Host extends Centreon_Object_Relation { /** @var Centreon_Object_Host */ public $firstObject; /** @var Centreon_Object_Host */ public $secondObject; /** @var string */ protected $relationTable = 'host_template_relation'; /** @var string */ protected $firstKey = 'host_tpl_id'; /** @var string */ protected $secondKey = 'host_host_id'; /** * Centreon_Object_Relation_Host_Template_Host constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Host($dependencyInjector); $this->secondObject = new Centreon_Object_Host($dependencyInjector); } /** * Insert host template / host relation * Order has importance * * @param int $fkey * @param int $skey * @return void */ public function insert($fkey, $skey = null): void { $sql = 'SELECT MAX(`order`) as maxorder FROM ' . $this->relationTable . ' WHERE ' . $this->secondKey . ' = ?'; $res = $this->db->query($sql, [$skey]); $row = $res->fetch(); $order = 1; if (isset($row['maxorder'])) { $order = $row['maxorder'] + 1; } unset($res); $sql = "INSERT INTO {$this->relationTable} ({$this->firstKey}, {$this->secondKey}, `order`) VALUES (?, ?, ?)"; $this->db->query($sql, [$fkey, $skey, $order]); } /** * Delete host template / host relation and linked services * * @param int $fkey - host template * @param int $skey - host * @return void */ public function delete($fkey, $skey = null): void { global $pearDB; $this->db->beginTransaction(); try { parent::delete($fkey, $skey); $pearDB = $this->db; $centreon = true; // Needed so we can include file below require_once _CENTREON_PATH_ . '/www/include/configuration/configObject/host/DB-Func.php'; deleteHostServiceMultiTemplate($skey, $fkey, [], null); $this->db->commit(); } catch (PDOException $e) { $this->db->rollBack(); exitProcess(PROCESS_ID, 1, $e->getMessage()); } } /** * Get target id from source id * * @param int $sourceKey * @param int $targetKey * @param array $sourceId * @return array */ public function getTargetIdFromSourceId($targetKey, $sourceKey, $sourceId) { if (! is_array($sourceId)) { $sourceId = [$sourceId]; } $sql = "SELECT {$targetKey} FROM {$this->relationTable} WHERE {$sourceKey} = ? ORDER BY `order`"; $result = $this->getResult($sql, $sourceId); $tab = []; foreach ($result as $rez) { $tab[] = $rez[$targetKey]; } return $tab; } /** * Get Merged Parameters from seperate tables * * @param array $firstTableParams * @param array $secondTableParams * @param int $count * @param string $order * @param string $sort * @param array $filters * @param string $filterType * @param mixed $offset * * @throws Exception * @return array */ public function getMergedParameters( $firstTableParams = [], $secondTableParams = [], $count = -1, $offset = 0, $order = null, $sort = 'ASC', $filters = [], $filterType = 'OR', ) { if (! isset($this->firstObject) || ! isset($this->secondObject)) { throw new Exception('Unsupported method on this object'); } $fString = ''; $sString = ''; foreach ($firstTableParams as $fparams) { if ($fString != '') { $fString .= ','; } $fString .= 'h.' . $fparams; } foreach ($secondTableParams as $sparams) { if ($fString != '' || $sString != '') { $sString .= ','; } $sString .= 'h2.' . $sparams; } $sql = 'SELECT ' . $fString . $sString . ' FROM ' . $this->firstObject->getTableName() . ' h,' . $this->relationTable . ' JOIN ' . $this->secondObject->getTableName() . ' h2 ON ' . $this->relationTable . '.' . $this->firstKey . ' = h2.' . $this->secondObject->getPrimaryKey() . ' WHERE h.' . $this->firstObject->getPrimaryKey() . ' = ' . $this->relationTable . '.' . $this->secondKey; $filterTab = []; if (count($filters)) { foreach ($filters as $key => $rawvalue) { $sql .= " {$filterType} {$key} LIKE ? "; $value = trim($rawvalue); $value = str_replace('_', "\_", $value); $value = str_replace(' ', "\ ", $value); $filterTab[] = $value; } } if (isset($order, $sort) && (strtoupper($sort) == 'ASC' || strtoupper($sort) == 'DESC')) { $sql .= " ORDER BY {$order} {$sort} "; } if (isset($count) && $count != -1) { $sql = $this->db->limit($sql, $count, $offset); } return $this->getResult($sql, $filterTab); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Host/Child/Host.php
centreon/lib/Centreon/Object/Relation/Host/Child/Host.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/Object/Relation/Relation.php'; /** * Class * * @class Centreon_Object_Relation_Host_Child_Host */ class Centreon_Object_Relation_Host_Child_Host extends Centreon_Object_Relation { /** @var Centreon_Object_Host */ public $firstObject; /** @var Centreon_Object_Host */ public $secondObject; /** @var string */ protected $relationTable = 'host_hostparent_relation'; /** @var string */ protected $firstKey = 'host_host_id'; /** @var string */ protected $secondKey = 'host_parent_hp_id'; /** * Centreon_Object_Relation_Host_Child_Host constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Host($dependencyInjector); $this->secondObject = new Centreon_Object_Host($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Host/Category/Host.php
centreon/lib/Centreon/Object/Relation/Host/Category/Host.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/Object/Relation/Relation.php'; require_once 'Centreon/Object/Host/Host.php'; require_once 'Centreon/Object/Host/Category.php'; /** * Class * * @class Centreon_Object_Relation_Host_Category_Host */ class Centreon_Object_Relation_Host_Category_Host extends Centreon_Object_Relation { /** @var Centreon_Object_Host_Category */ public $firstObject; /** @var Centreon_Object_Host */ public $secondObject; /** @var string */ protected $relationTable = 'hostcategories_relation'; /** @var string */ protected $firstKey = 'hostcategories_hc_id'; /** @var string */ protected $secondKey = 'host_host_id'; /** * Centreon_Object_Relation_Host_Category_Host constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Host_Category($dependencyInjector); $this->secondObject = new Centreon_Object_Host($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Host/Group/Host.php
centreon/lib/Centreon/Object/Relation/Host/Group/Host.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/Object/Relation/Relation.php'; /** * Class * * @class Centreon_Object_Relation_Host_Group_Host */ class Centreon_Object_Relation_Host_Group_Host extends Centreon_Object_Relation { /** @var Centreon_Object_Host_Group */ public $firstObject; /** @var Centreon_Object_Host */ public $secondObject; /** @var string */ protected $relationTable = 'hostgroup_relation'; /** @var string */ protected $firstKey = 'hostgroup_hg_id'; /** @var string */ protected $secondKey = 'host_host_id'; /** * Centreon_Object_Relation_Host_Group_Host constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Host_Group($dependencyInjector); $this->secondObject = new Centreon_Object_Host($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Host/Group/Service/Service.php
centreon/lib/Centreon/Object/Relation/Host/Group/Service/Service.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/Object/Relation/Relation.php'; require_once 'Centreon/Object/Host/Group.php'; /** * Class * * @class Centreon_Object_Relation_Host_Group_Service */ class Centreon_Object_Relation_Host_Group_Service extends Centreon_Object_Relation { /** @var Centreon_Object_Host_Group */ public $firstObject; /** @var Centreon_Object_Service */ public $secondObject; /** @var string */ protected $relationTable = 'host_service_relation'; /** @var string */ protected $firstKey = 'hostgroup_hg_id'; /** @var string */ protected $secondKey = 'service_service_id'; /** * Centreon_Object_Relation_Host_Group_Service constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Host_Group($dependencyInjector); $this->secondObject = new Centreon_Object_Service($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Host/Group/Service/Group.php
centreon/lib/Centreon/Object/Relation/Host/Group/Service/Group.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/Object/Relation/Relation.php'; class Centreon_Object_Relation_Host_Group_Service_Group extends Centreon_Object_Relation { protected $relationTable = 'host_service_relation'; protected $firstKey = 'hostgroup_hg_id'; protected $secondKey = 'servicegroup_sg_id'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Host/Parent/Host.php
centreon/lib/Centreon/Object/Relation/Host/Parent/Host.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/Object/Relation/Relation.php'; /** * Class * * @class Centreon_Object_Relation_Host_Parent_Host */ class Centreon_Object_Relation_Host_Parent_Host extends Centreon_Object_Relation { /** @var Centreon_Object_Host */ public $firstObject; /** @var Centreon_Object_Host */ public $secondObject; /** @var string */ protected $relationTable = 'host_hostparent_relation'; /** @var string */ protected $firstKey = 'host_parent_hp_id'; /** @var string */ protected $secondKey = 'host_host_id'; /** * Centreon_Object_Relation_Host_Parent_Host constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Host($dependencyInjector); $this->secondObject = new Centreon_Object_Host($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Dependency/Parent/Servicegroup.php
centreon/lib/Centreon/Object/Relation/Dependency/Parent/Servicegroup.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/Object/Relation/Relation.php'; require_once 'Centreon/Object/Dependency/Dependency.php'; require_once 'Centreon/Object/Service/Group.php'; /** * Class * * @class Centreon_Object_Relation_Dependency_Parent_Servicegroup */ class Centreon_Object_Relation_Dependency_Parent_Servicegroup extends Centreon_Object_Relation { /** @var Centreon_Object_Dependency */ public $firstObject; /** @var Centreon_Object_Service_Group */ public $secondObject; /** @var string */ protected $relationTable = 'dependency_servicegroupParent_relation'; /** @var string */ protected $firstKey = 'dependency_dep_id'; /** @var string */ protected $secondKey = 'servicegroup_sg_id'; /** * Centreon_Object_Relation_Dependency_Parent_Servicegroup constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Dependency($dependencyInjector); $this->secondObject = new Centreon_Object_Service_Group($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Dependency/Parent/Metaservice.php
centreon/lib/Centreon/Object/Relation/Dependency/Parent/Metaservice.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/Object/Relation/Relation.php'; require_once 'Centreon/Object/Dependency/Dependency.php'; require_once 'Centreon/Object/Meta/Service.php'; /** * Class * * @class Centreon_Object_Relation_Dependency_Parent_Metaservice */ class Centreon_Object_Relation_Dependency_Parent_Metaservice extends Centreon_Object_Relation { /** @var Centreon_Object_Dependency */ public $firstObject; /** @var Centreon_Object_Meta_Service */ public $secondObject; /** @var string */ protected $relationTable = 'dependency_metaserviceParent_relation'; /** @var string */ protected $firstKey = 'dependency_dep_id'; /** @var string */ protected $secondKey = 'meta_service_meta_id'; /** * Centreon_Object_Relation_Dependency_Parent_Metaservice constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Dependency($dependencyInjector); $this->secondObject = new Centreon_Object_Meta_Service($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Dependency/Parent/Hostgroup.php
centreon/lib/Centreon/Object/Relation/Dependency/Parent/Hostgroup.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/Object/Relation/Relation.php'; require_once 'Centreon/Object/Dependency/Dependency.php'; require_once 'Centreon/Object/Host/Group.php'; /** * Class * * @class Centreon_Object_Relation_Dependency_Parent_Hostgroup */ class Centreon_Object_Relation_Dependency_Parent_Hostgroup extends Centreon_Object_Relation { /** @var Centreon_Object_Dependency */ public $firstObject; /** @var Centreon_Object_Host_Group */ public $secondObject; /** @var string */ protected $relationTable = 'dependency_hostgroupParent_relation'; /** @var string */ protected $firstKey = 'dependency_dep_id'; /** @var string */ protected $secondKey = 'hostgroup_hg_id'; /** * Centreon_Object_Relation_Dependency_Parent_Hostgroup constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Dependency($dependencyInjector); $this->secondObject = new Centreon_Object_Host_Group($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Dependency/Parent/Host.php
centreon/lib/Centreon/Object/Relation/Dependency/Parent/Host.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/Object/Relation/Relation.php'; require_once 'Centreon/Object/Dependency/Dependency.php'; require_once 'Centreon/Object/Host/Host.php'; /** * Class * * @class Centreon_Object_Relation_Dependency_Parent_Host */ class Centreon_Object_Relation_Dependency_Parent_Host extends Centreon_Object_Relation { /** @var Centreon_Object_Dependency */ public $firstObject; /** @var Centreon_Object_Host */ public $secondObject; /** @var string */ protected $relationTable = 'dependency_hostParent_relation'; /** @var string */ protected $firstKey = 'dependency_dep_id'; /** @var string */ protected $secondKey = 'host_host_id'; /** * Centreon_Object_Relation_Dependency_Parent_Host constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Dependency($dependencyInjector); $this->secondObject = new Centreon_Object_Host($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Contact/Service.php
centreon/lib/Centreon/Object/Relation/Contact/Service.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/Object/Relation/Relation.php'; /** * Class * * @class Centreon_Object_Relation_Contact_Service */ class Centreon_Object_Relation_Contact_Service extends Centreon_Object_Relation { /** @var Centreon_Object_Contact */ public $firstObject; /** @var Centreon_Object_Service */ public $secondObject; /** @var string */ protected $relationTable = 'contact_service_relation'; /** @var string */ protected $firstKey = 'contact_id'; /** @var string */ protected $secondKey = 'service_service_id'; /** * Centreon_Object_Relation_Contact_Service constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Contact($dependencyInjector); $this->secondObject = new Centreon_Object_Service($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Contact/Host.php
centreon/lib/Centreon/Object/Relation/Contact/Host.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/Object/Relation/Relation.php'; /** * Class * * @class Centreon_Object_Relation_Contact_Host */ class Centreon_Object_Relation_Contact_Host extends Centreon_Object_Relation { /** @var Centreon_Object_Contact */ public $firstObject; /** @var Centreon_Object_Host */ public $secondObject; /** @var string */ protected $relationTable = 'contact_host_relation'; /** @var string */ protected $firstKey = 'contact_id'; /** @var string */ protected $secondKey = 'host_host_id'; /** * Centreon_Object_Relation_Contact_Host constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Contact($dependencyInjector); $this->secondObject = new Centreon_Object_Host($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Contact/Group/Service.php
centreon/lib/Centreon/Object/Relation/Contact/Group/Service.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/Object/Relation/Relation.php'; /** * Class * * @class Centreon_Object_Relation_Contact_Group_Service */ class Centreon_Object_Relation_Contact_Group_Service extends Centreon_Object_Relation { /** @var Centreon_Object_Contact_Group */ public $firstObject; /** @var Centreon_Object_Service */ public $secondObject; /** @var string */ protected $relationTable = 'contactgroup_service_relation'; /** @var string */ protected $firstKey = 'contactgroup_cg_id'; /** @var string */ protected $secondKey = 'service_service_id'; /** * Centreon_Object_Relation_Contact_Group_Service constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Contact_Group($dependencyInjector); $this->secondObject = new Centreon_Object_Service($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Contact/Group/Host.php
centreon/lib/Centreon/Object/Relation/Contact/Group/Host.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/Object/Relation/Relation.php'; /** * Class * * @class Centreon_Object_Relation_Contact_Group_Host */ class Centreon_Object_Relation_Contact_Group_Host extends Centreon_Object_Relation { /** @var Centreon_Object_Contact_Group */ public $firstObject; /** @var Centreon_Object_Host */ public $secondObject; /** @var string */ protected $relationTable = 'contactgroup_host_relation'; /** @var string */ protected $firstKey = 'contactgroup_cg_id'; /** @var string */ protected $secondKey = 'host_host_id'; /** * Centreon_Object_Relation_Contact_Group_Host constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Contact_Group($dependencyInjector); $this->secondObject = new Centreon_Object_Host($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Contact/Group/Contact.php
centreon/lib/Centreon/Object/Relation/Contact/Group/Contact.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__ . '/../../Relation.php'; /** * Class * * @class Centreon_Object_Relation_Contact_Group_Contact */ class Centreon_Object_Relation_Contact_Group_Contact extends Centreon_Object_Relation { /** @var Centreon_Object_Contact_Group */ public $firstObject; /** @var Centreon_Object_Contact */ public $secondObject; /** @var string */ protected $relationTable = 'contactgroup_contact_relation'; /** @var string */ protected $firstKey = 'contactgroup_cg_id'; /** @var string */ protected $secondKey = 'contact_contact_id'; /** * Centreon_Object_Relation_Contact_Group_Contact constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Contact_Group($dependencyInjector); $this->secondObject = new Centreon_Object_Contact($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Contact/Command/Service.php
centreon/lib/Centreon/Object/Relation/Contact/Command/Service.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/Object/Relation/Relation.php'; /** * Class * * @class Centreon_Object_Relation_Contact_Command_Service */ class Centreon_Object_Relation_Contact_Command_Service extends Centreon_Object_Relation { /** @var Centreon_Object_Contact */ public $firstObject; /** @var Centreon_Object_Command */ public $secondObject; /** @var string */ protected $relationTable = 'contact_servicecommands_relation'; /** @var string */ protected $firstKey = 'contact_contact_id'; /** @var string */ protected $secondKey = 'command_command_id'; /** * Centreon_Object_Relation_Contact_Command_Service constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Contact($dependencyInjector); $this->secondObject = new Centreon_Object_Command($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Contact/Command/Host.php
centreon/lib/Centreon/Object/Relation/Contact/Command/Host.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/Object/Relation/Relation.php'; /** * Class * * @class Centreon_Object_Relation_Contact_Command_Host */ class Centreon_Object_Relation_Contact_Command_Host extends Centreon_Object_Relation { /** @var Centreon_Object_Contact */ public $firstObject; /** @var Centreon_Object_Command */ public $secondObject; /** @var string */ protected $relationTable = 'contact_hostcommands_relation'; /** @var string */ protected $firstKey = 'contact_contact_id'; /** @var string */ protected $secondKey = 'command_command_id'; /** * Centreon_Object_Relation_Contact_Command_Host constructor. * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Contact($dependencyInjector); $this->secondObject = new Centreon_Object_Command($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Downtime/Servicegroup.php
centreon/lib/Centreon/Object/Relation/Downtime/Servicegroup.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/Object/Relation/Relation.php'; require_once 'Centreon/Object/Downtime/Downtime.php'; require_once 'Centreon/Object/Service/Group.php'; /** * Class * * @class Centreon_Object_Relation_Downtime_Servicegroup */ class Centreon_Object_Relation_Downtime_Servicegroup extends Centreon_Object_Relation { /** @var Centreon_Object_Downtime */ public $firstObject; /** @var Centreon_Object_Service_Group */ public $secondObject; /** @var string */ protected $relationTable = 'downtime_servicegroup_relation'; /** @var string */ protected $firstKey = 'dt_id'; /** @var string */ protected $secondKey = 'sg_sg_id'; /** * Centreon_Object_Relation_Downtime_Servicegroup constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Downtime($dependencyInjector); $this->secondObject = new Centreon_Object_Service_Group($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Downtime/Hostgroup.php
centreon/lib/Centreon/Object/Relation/Downtime/Hostgroup.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/Object/Relation/Relation.php'; require_once 'Centreon/Object/Downtime/Downtime.php'; require_once 'Centreon/Object/Host/Group.php'; /** * Class * * @class Centreon_Object_Relation_Downtime_Hostgroup */ class Centreon_Object_Relation_Downtime_Hostgroup extends Centreon_Object_Relation { /** @var Centreon_Object_Downtime */ public $firstObject; /** @var Centreon_Object_Host_Group */ public $secondObject; /** @var string */ protected $relationTable = 'downtime_hostgroup_relation'; /** @var string */ protected $firstKey = 'dt_id'; /** @var string */ protected $secondKey = 'hg_hg_id'; /** * Centreon_Object_Relation_Downtime_Hostgroup constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Downtime($dependencyInjector); $this->secondObject = new Centreon_Object_Host_Group($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Downtime/Host.php
centreon/lib/Centreon/Object/Relation/Downtime/Host.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/Object/Relation/Relation.php'; require_once 'Centreon/Object/Downtime/Downtime.php'; require_once 'Centreon/Object/Host/Host.php'; /** * Class * * @class Centreon_Object_Relation_Downtime_Host */ class Centreon_Object_Relation_Downtime_Host extends Centreon_Object_Relation { /** @var Centreon_Object_Downtime */ public $firstObject; /** @var Centreon_Object_Host */ public $secondObject; /** @var string */ protected $relationTable = 'downtime_host_relation'; /** @var string */ protected $firstKey = 'dt_id'; /** @var string */ protected $secondKey = 'host_host_id'; /** * Centreon_Object_Relation_Downtime_Host constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Downtime($dependencyInjector); $this->secondObject = new Centreon_Object_Host($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Acl/Resource/Instance.php
centreon/lib/Centreon/Object/Relation/Acl/Resource/Instance.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/Object/Relation/Relation.php'; class Centreon_Object_Relation_Acl_Resource_Instance extends Centreon_Object_Relation { protected $relationTable = 'acl_resources_poller_relations'; protected $firstKey = 'acl_res_id'; protected $secondKey = 'poller_id'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Acl/Resource/Meta/Service.php
centreon/lib/Centreon/Object/Relation/Acl/Resource/Meta/Service.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/Object/Relation/Relation.php'; class Centreon_Object_Relation_Acl_Resource_Meta_Service extends Centreon_Object_Relation { protected $relationTable = 'acl_resources_meta_relations'; protected $firstKey = 'acl_res_id'; protected $secondKey = 'meta_id'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Acl/Resource/Host/Category.php
centreon/lib/Centreon/Object/Relation/Acl/Resource/Host/Category.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/Object/Relation/Relation.php'; class Centreon_Object_Relation_Acl_Resource_Host_Category extends Centreon_Object_Relation { protected $relationTable = 'acl_resources_hc_relations'; protected $firstKey = 'acl_res_id'; protected $secondKey = 'hc_id'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Acl/Resource/Host/Exclude.php
centreon/lib/Centreon/Object/Relation/Acl/Resource/Host/Exclude.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/Object/Relation/Relation.php'; class Centreon_Object_Relation_Acl_Resource_Host_Exclude extends Centreon_Object_Relation { protected $relationTable = 'acl_resources_hostex_relations'; protected $firstKey = 'acl_res_id'; protected $secondKey = 'host_host_id'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Acl/Resource/Host/Group.php
centreon/lib/Centreon/Object/Relation/Acl/Resource/Host/Group.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/Object/Relation/Relation.php'; class Centreon_Object_Relation_Acl_Resource_Host_Group extends Centreon_Object_Relation { protected $relationTable = 'acl_resources_hg_relations'; protected $firstKey = 'acl_res_id'; protected $secondKey = 'hg_hg_id'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Acl/Resource/Host/Host.php
centreon/lib/Centreon/Object/Relation/Acl/Resource/Host/Host.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/Object/Relation/Relation.php'; class Centreon_Object_Relation_Acl_Resource_Host extends Centreon_Object_Relation { protected $relationTable = 'acl_resources_host_relations'; protected $firstKey = 'acl_res_id'; protected $secondKey = 'host_host_id'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Acl/Resource/Service/Category.php
centreon/lib/Centreon/Object/Relation/Acl/Resource/Service/Category.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/Object/Relation/Relation.php'; class Centreon_Object_Relation_Acl_Resource_Service_Category extends Centreon_Object_Relation { protected $relationTable = 'acl_resources_sc_relations'; protected $firstKey = 'acl_res_id'; protected $secondKey = 'sc_id'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Acl/Resource/Service/Service.php
centreon/lib/Centreon/Object/Relation/Acl/Resource/Service/Service.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/Object/Relation/Relation.php'; class Centreon_Object_Relation_Acl_Resource_Service extends Centreon_Object_Relation { protected $relationTable = 'acl_resources_service_relations'; protected $firstKey = 'acl_group_id'; protected $secondKey = 'service_service_id'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Acl/Resource/Service/Group.php
centreon/lib/Centreon/Object/Relation/Acl/Resource/Service/Group.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/Object/Relation/Relation.php'; class Centreon_Object_Relation_Acl_Resource_Service_Group extends Centreon_Object_Relation { protected $relationTable = 'acl_resources_sg_relations'; protected $firstKey = 'acl_res_id'; protected $secondKey = 'sg_id'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Acl/Group/Action.php
centreon/lib/Centreon/Object/Relation/Acl/Group/Action.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__ . '/../../Relation.php'; /** * Class * * @class Centreon_Object_Relation_Acl_Group_Action */ class Centreon_Object_Relation_Acl_Group_Action extends Centreon_Object_Relation { /** @var Centreon_Object_Acl_Group */ public $firstObject; /** @var Centreon_Object_Acl_Action */ public $secondObject; /** @var string */ protected $relationTable = 'acl_group_actions_relations'; /** @var string */ protected $firstKey = 'acl_group_id'; /** @var string */ protected $secondKey = 'acl_action_id'; /** * Centreon_Object_Relation_Acl_Group_Action constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Acl_Group($dependencyInjector); $this->secondObject = new Centreon_Object_Acl_Action($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Acl/Group/Menu.php
centreon/lib/Centreon/Object/Relation/Acl/Group/Menu.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__ . '/../../Relation.php'; /** * Class * * @class Centreon_Object_Relation_Acl_Group_Menu */ class Centreon_Object_Relation_Acl_Group_Menu extends Centreon_Object_Relation { /** @var Centreon_Object_Acl_Group */ public $firstObject; /** @var Centreon_Object_Acl_Menu */ public $secondObject; /** @var string */ protected $relationTable = 'acl_group_topology_relations'; /** @var string */ protected $firstKey = 'acl_group_id'; /** @var string */ protected $secondKey = 'acl_topology_id'; /** * Centreon_Object_Relation_Acl_Group_Menu constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Acl_Group($dependencyInjector); $this->secondObject = new Centreon_Object_Acl_Menu($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Acl/Group/Resource.php
centreon/lib/Centreon/Object/Relation/Acl/Group/Resource.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__ . '/../../Relation.php'; /** * Class * * @class Centreon_Object_Relation_Acl_Group_Resource */ class Centreon_Object_Relation_Acl_Group_Resource extends Centreon_Object_Relation { /** @var Centreon_Object_Acl_Group */ public $firstObject; /** @var Centreon_Object_Acl_Resource */ public $secondObject; /** @var string */ protected $relationTable = 'acl_res_group_relations'; /** @var string */ protected $firstKey = 'acl_group_id'; /** @var string */ protected $secondKey = 'acl_res_id'; /** * Centreon_Object_Relation_Acl_Group_Resource constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Acl_Group($dependencyInjector); $this->secondObject = new Centreon_Object_Acl_Resource($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Acl/Group/Contact/Group.php
centreon/lib/Centreon/Object/Relation/Acl/Group/Contact/Group.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__ . '/../../../Relation.php'; /** * Class * * @class Centreon_Object_Relation_Acl_Group_Contact_Group */ class Centreon_Object_Relation_Acl_Group_Contact_Group extends Centreon_Object_Relation { /** @var Centreon_Object_Acl_Group */ public $firstObject; /** @var Centreon_Object_Contact_Group */ public $secondObject; /** @var string */ protected $relationTable = 'acl_group_contactgroups_relations'; /** @var string */ protected $firstKey = 'acl_group_id'; /** @var string */ protected $secondKey = 'cg_cg_id'; /** * Centreon_Object_Relation_Acl_Group_Contact_Group constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Acl_Group($dependencyInjector); $this->secondObject = new Centreon_Object_Contact_Group($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Acl/Group/Contact/Contact.php
centreon/lib/Centreon/Object/Relation/Acl/Group/Contact/Contact.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__ . '/../../../Relation.php'; /** * Class * * @class Centreon_Object_Relation_Acl_Group_Contact */ class Centreon_Object_Relation_Acl_Group_Contact extends Centreon_Object_Relation { /** @var Centreon_Object_Acl_Group */ public $firstObject; /** @var Centreon_Object_Contact */ public $secondObject; /** @var string */ protected $relationTable = 'acl_group_contacts_relations'; /** @var string */ protected $firstKey = 'acl_group_id'; /** @var string */ protected $secondKey = 'contact_contact_id'; /** * Centreon_Object_Relation_Acl_Group_Contact constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Acl_Group($dependencyInjector); $this->secondObject = new Centreon_Object_Contact($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Instance/Resource.php
centreon/lib/Centreon/Object/Relation/Instance/Resource.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/Object/Relation/Relation.php'; class Centreon_Object_Relation_Instance_Resource extends Centreon_Object_Relation { protected $relationTable = 'cfg_resource_instance_relations'; protected $firstKey = 'instance_id'; protected $secondKey = 'resource_id'; }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Instance/Host.php
centreon/lib/Centreon/Object/Relation/Instance/Host.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/Object/Relation/Relation.php'; /** * Class * * @class Centreon_Object_Relation_Instance_Host */ class Centreon_Object_Relation_Instance_Host extends Centreon_Object_Relation { /** @var Centreon_Object_Instance */ public $firstObject; /** @var Centreon_Object_Host */ public $secondObject; /** @var string */ protected $relationTable = 'ns_host_relation'; /** @var string */ protected $firstKey = 'nagios_server_id'; /** @var string */ protected $secondKey = 'host_host_id'; /** * Centreon_Object_Relation_Instance_Host constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Instance($dependencyInjector); $this->secondObject = new Centreon_Object_Host($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Trap/Service.php
centreon/lib/Centreon/Object/Relation/Trap/Service.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/Object/Relation/Relation.php'; /** * Class * * @class Centreon_Object_Relation_Trap_Service */ class Centreon_Object_Relation_Trap_Service extends Centreon_Object_Relation { /** @var Centreon_Object_Trap */ public $firstObject; /** @var Centreon_Object_Service */ public $secondObject; /** @var string */ protected $relationTable = 'traps_service_relation'; /** @var string */ protected $firstKey = 'traps_id'; /** @var string */ protected $secondKey = 'service_id'; /** * Centreon_Object_Relation_Trap_Service constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Trap($dependencyInjector); $this->secondObject = new Centreon_Object_Service($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Service/Template/Host.php
centreon/lib/Centreon/Object/Relation/Service/Template/Host.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/Object/Relation/Relation.php'; /** * Class * * @class Centreon_Object_Relation_Service_Template_Host */ class Centreon_Object_Relation_Service_Template_Host extends Centreon_Object_Relation { /** @var Centreon_Object_Service_Template */ public $firstObject; /** @var Centreon_Object_Host_Template */ public $secondObject; /** @var string */ protected $relationTable = 'host_service_relation'; /** @var string */ protected $firstKey = 'service_service_id'; /** @var string */ protected $secondKey = 'host_host_id'; /** * Centreon_Object_Relation_Service_Template_Host constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Service_Template($dependencyInjector); $this->secondObject = new Centreon_Object_Host_Template($dependencyInjector); } /** * Insert host template / host relation * Order has importance * * @param int $fkey * @param int $skey * @return void */ public function insert($fkey, $skey = null): void { $sql = "INSERT INTO {$this->relationTable} ({$this->secondKey}, {$this->firstKey}) VALUES (?, ?)"; $this->db->query($sql, [$fkey, $skey]); } /** * Get Merged Parameters from seperate tables * * @param array $firstTableParams * @param array $secondTableParams * @param int $count * @param string $order * @param string $sort * @param array $filters * @param string $filterType * @param mixed $offset * * @throws Exception * @return array */ public function getMergedParameters($firstTableParams = [], $secondTableParams = [], $count = -1, $offset = 0, $order = null, $sort = 'ASC', $filters = [], $filterType = 'OR') { if (! isset($this->firstObject) || ! isset($this->secondObject)) { throw new Exception('Unsupported method on this object'); } $fString = ''; $sString = ''; foreach ($firstTableParams as $fparams) { if ($fString != '') { $fString .= ','; } $fString .= 'h.' . $fparams; } foreach ($secondTableParams as $sparams) { if ($fString != '' || $sString != '') { $sString .= ','; } $sString .= 'h2.' . $sparams; } $sql = 'SELECT ' . $fString . $sString . ' FROM ' . $this->firstObject->getTableName() . ' h,' . $this->relationTable . ' JOIN ' . $this->secondObject->getTableName() . ' h2 ON ' . $this->relationTable . '.' . $this->firstKey . ' = h2.' . $this->secondObject->getPrimaryKey() . ' WHERE h.' . $this->firstObject->getPrimaryKey() . ' = ' . $this->relationTable . '.' . $this->secondKey; $filterTab = []; if (count($filters)) { foreach ($filters as $key => $rawvalue) { $sql .= " {$filterType} {$key} LIKE ? "; $value = trim($rawvalue); $value = str_replace('_', "\_", $value); $value = str_replace(' ', "\ ", $value); $filterTab[] = $value; } } if (isset($order, $sort) && (strtoupper($sort) == 'ASC' || strtoupper($sort) == 'DESC')) { $sql .= " ORDER BY {$order} {$sort} "; } if (isset($count) && $count != -1) { $sql = $this->db->limit($sql, $count, $offset); } return $this->getResult($sql, $filterTab); } /** * Delete host template / host relation * Order has importance * * @param int|null $fkey * @param int|null $skey * @return void */ public function delete($fkey, $skey = null): void { if (isset($fkey, $skey)) { $sql = "DELETE FROM {$this->relationTable} WHERE {$this->firstKey} = ? AND {$this->secondKey} = ?"; $args = [$skey, $fkey]; } elseif (isset($skey)) { $sql = "DELETE FROM {$this->relationTable} WHERE {$this->firstKey} = ?"; $args = [$skey]; } else { $sql = "DELETE FROM {$this->relationTable} WHERE {$this->secondKey} = ?"; $args = [$fkey]; } $this->db->query($sql, $args); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Service/Category/Service.php
centreon/lib/Centreon/Object/Relation/Service/Category/Service.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/Object/Relation/Relation.php'; require_once 'Centreon/Object/Service/Category.php'; require_once 'Centreon/Object/Service/Service.php'; /** * Class * * @class Centreon_Object_Relation_Service_Category_Service */ class Centreon_Object_Relation_Service_Category_Service extends Centreon_Object_Relation { /** @var Centreon_Object_Service_Category */ public $firstObject; /** @var Centreon_Object_Service */ public $secondObject; /** @var string */ protected $relationTable = 'service_categories_relation'; /** @var string */ protected $firstKey = 'sc_id'; /** @var string */ protected $secondKey = 'service_service_id'; /** * Centreon_Object_Relation_Service_Category_Service constructor * * @param Pimple\Container $dependencyInjector */ public function __construct(Pimple\Container $dependencyInjector) { parent::__construct($dependencyInjector); $this->firstObject = new Centreon_Object_Service_Category($dependencyInjector); $this->secondObject = new Centreon_Object_Service($dependencyInjector); } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false
centreon/centreon
https://github.com/centreon/centreon/blob/6ae83001e94de0a4cec11e084780fcfa63f1c985/centreon/lib/Centreon/Object/Relation/Service/Group/Service.php
centreon/lib/Centreon/Object/Relation/Service/Group/Service.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/Object/Relation/Relation.php'; class Centreon_Object_Relation_Service_Group_Service extends Centreon_Object_Relation { protected $relationTable = 'servicegroup_relation'; protected $firstKey = 'servicegroup_sg_id'; protected $secondKey = 'service_service_id'; /** * This call will directly throw an exception * * @param string $name * @param array $arg * @throws Exception */ public function __call($name, $arg = []) { throw new Exception('Unknown method'); } /** * Used for inserting relation into database * @param int $fkey * @param null $key */ public function insert($fkey, $key = null): void { $hostId = $key['hostId']; $serviceId = $key['serviceId']; $sql = "INSERT INTO {$this->relationTable} ({$this->firstKey}, host_host_id, {$this->secondKey}) VALUES (?, ?, ?)"; $this->db->query($sql, [$fkey, $hostId, $serviceId]); } /** * Used for deleting relation from database * * @param int $fkey * @param int $hostId * @param int $serviceId * @return void */ public function delete($fkey, $hostId = null, $serviceId = null): void { if (isset($fkey, $hostId, $serviceId)) { $sql = "DELETE FROM {$this->relationTable} WHERE {$this->firstKey} = ? AND host_host_id = ? AND {$this->secondKey} = ?"; $args = [$fkey, $hostId, $serviceId]; } elseif (isset($hostId, $serviceId)) { $sql = "DELETE FROM {$this->relationTable} WHERE host_host_id = ? AND {$this->secondKey} = ?"; $args = [$hostId, $serviceId]; } else { $sql = "DELETE FROM {$this->relationTable} WHERE {$this->firstKey} = ?"; $args = [$fkey]; } $this->db->query($sql, $args); } /** * Get service group id from host id, service id * * @param int $hostId * @param int $serviceId * @return array */ public function getServicegroupIdFromHostIdServiceId($hostId, $serviceId) { $sql = "SELECT {$this->firstKey} FROM {$this->relationTable} WHERE host_host_id = ? AND {$this->secondKey} = ?"; $result = $this->getResult($sql, [$hostId, $serviceId]); $tab = []; foreach ($result as $rez) { $tab[] = $rez[$this->firstKey]; } return $tab; } /** * Get Host id service id from service group id * * @param int $servicegroupId * @return array multidimentional array with host_id and service_id indexes */ public function getHostIdServiceIdFromServicegroupId($servicegroupId) { $sql = "SELECT host_host_id, {$this->secondKey} FROM {$this->relationTable} WHERE {$this->firstKey} = ?"; $result = $this->getResult($sql, [$servicegroupId]); $tab = []; $i = 0; foreach ($result as $rez) { $tab[$i]['host_id'] = $rez['host_host_id']; $tab[$i]['service_id'] = $rez[$this->secondKey]; $i++; } return $tab; } }
php
Apache-2.0
6ae83001e94de0a4cec11e084780fcfa63f1c985
2026-01-05T04:45:18.914281Z
false