Skip to content
This repository was archived by the owner on Dec 13, 2022. It is now read-only.

Commit 640435a

Browse files
tuntojakduretemabassi-extvhsantoshyahiaoui-ext
authored
chore(release): merge release-21.10.next into 21.10.x (#11820)
* fix(git): resync 21.10.x to dev-21.10.x (#11499) * fix(test): wait 8s before checking downtime is active in rest api v1 test (#11498) (#11505) Refs: MON-14585 * fix(UI): Include host_id when selecting ServiceGroups on dashreports (#11428) (#11520) Co-authored-by: VHS <[email protected]> Co-authored-by: VHS <[email protected]> * [SNYK] Sanitize and bind centreonGraph class queries (#11409) (#11518) 1122 1153 1134 * [Snyk] Sanitize and bind ACL action access queries (#11385) (#11515) * Sanitize and bind ACL action access queries _ sanitize if possible each variables inserted in a query _ use PDO prepared statement and bind() method _ Do not use $pearDB->escape on which is for examples useless on integers and on non closed HTML tags (svg, img, etc) * fix line length * fix failed checks * fix(cron): Escape database name in CentACL 21.10.x (#11509) * fix(pendo): correctly set locale when language is detection by browser (#11484) (#11529) * fix(test): fix random fails on virtual metric test (#11524) Refs: MON-14359 * enh(platform): Use API to select metrics in virtual metrics configuration form 21.10.x (#11508) Refs: MON-14359 * doc(ack): acknowledge Hakaï security (#11539) * fix(web): fix the comment deletion for host monitored by poller (#11138) (#11557) Refs: MON-12828 Co-authored-by: Stéphane Duret <[email protected]> * SNYK: Sanitize and bind Broker listing queries (#11551) * Sanitizing and binding broker listing queries * applying suggested changes * fix(conf) fix encoding in template service listing (#11558) (#11565) * fix encoding * remove useless function * SNYK: Sanitize and bind generateImage queries (#11562) * sanitize and bind generate image queries * adding throw exception * applying suggested changes * Update www/include/views/graphs/generateGraphs/generateImage.php Co-authored-by: Kevin Duret <[email protected]> Co-authored-by: Kevin Duret <[email protected]> * SNYK: Sanitize and bind ACL actions queries (#11548) * sanitizing and binding acl actions queries * fix missing bind * MON-14501 - sanitize query in centreonXmlbgRequest class (#11571) * sanitize query in centreonXmlbgRequest class * add closeCursor func to resolve conv * SNYK: Sanitize and bind Meta-Services dependency queries (#11568) * sanityze 2 insert queries * spaces removed in a query * chore(release): merge release 21.10.9 into 21.10.x (#11628) (#11629) * fix(git): resync 21.10.x to dev-21.10.x (#11499) * fix(test): wait 8s before checking downtime is active in rest api v1 test (#11498) (#11505) Refs: MON-14585 * fix(UI): Include host_id when selecting ServiceGroups on dashreports (#11428) (#11520) Co-authored-by: VHS <[email protected]> Co-authored-by: VHS <[email protected]> * [SNYK] Sanitize and bind centreonGraph class queries (#11409) (#11518) 1122 1153 1134 * [Snyk] Sanitize and bind ACL action access queries (#11385) (#11515) * Sanitize and bind ACL action access queries _ sanitize if possible each variables inserted in a query _ use PDO prepared statement and bind() method _ Do not use $pearDB->escape on which is for examples useless on integers and on non closed HTML tags (svg, img, etc) * fix line length * fix failed checks * fix(cron): Escape database name in CentACL 21.10.x (#11509) * fix(pendo): correctly set locale when language is detection by browser (#11484) (#11529) * fix(test): fix random fails on virtual metric test (#11524) Refs: MON-14359 * enh(platform): Use API to select metrics in virtual metrics configuration form 21.10.x (#11508) Refs: MON-14359 * doc(ack): acknowledge Hakaï security (#11539) * fix(web): fix the comment deletion for host monitored by poller (#11138) (#11557) Refs: MON-12828 Co-authored-by: Stéphane Duret <[email protected]> * SNYK: Sanitize and bind Broker listing queries (#11551) * Sanitizing and binding broker listing queries * applying suggested changes * fix(conf) fix encoding in template service listing (#11558) (#11565) * fix encoding * remove useless function * SNYK: Sanitize and bind generateImage queries (#11562) * sanitize and bind generate image queries * adding throw exception * applying suggested changes * Update www/include/views/graphs/generateGraphs/generateImage.php Co-authored-by: Kevin Duret <[email protected]> Co-authored-by: Kevin Duret <[email protected]> * SNYK: Sanitize and bind ACL actions queries (#11548) * sanitizing and binding acl actions queries * fix missing bind * MON-14501 - sanitize query in centreonXmlbgRequest class (#11571) * sanitize query in centreonXmlbgRequest class * add closeCursor func to resolve conv * SNYK: Sanitize and bind Meta-Services dependency queries (#11568) * sanityze 2 insert queries * spaces removed in a query * chore(install): Update version to 21.10.9 * fix(sql): fix query to select contact during ldap import (#11579) Refs: MON-14263 * (fix)MON-14742 Escape database name in CentACL (#11602) * fixed issue of using special chars in db names * fix escape database name * fixed security issue on sql requests * fix(platform) : Issue with cross databases query when the name contains some characters (#11279) (#11619) Co-authored-by: Kevin Duret <[email protected]> Co-authored-by: Elmahdi ABBASSI <[email protected]> Co-authored-by: VHS <[email protected]> Co-authored-by: hyahiaoui-ext <[email protected]> Co-authored-by: jeremyjaouen <[email protected]> Co-authored-by: Stéphane Chapron <[email protected]> Co-authored-by: Stéphane Duret <[email protected]> Co-authored-by: alaunois <[email protected]> Co-authored-by: Dmytro Iosypenko <[email protected]> Co-authored-by: Kevin Duret <[email protected]> Co-authored-by: Elmahdi ABBASSI <[email protected]> Co-authored-by: VHS <[email protected]> Co-authored-by: hyahiaoui-ext <[email protected]> Co-authored-by: jeremyjaouen <[email protected]> Co-authored-by: Stéphane Chapron <[email protected]> Co-authored-by: Stéphane Duret <[email protected]> Co-authored-by: alaunois <[email protected]> Co-authored-by: Dmytro Iosypenko <[email protected]> * query sanitized in listServiceCategoriesà (#11597) (#11633) * Sanitize and bind listVirtualMetrics queries (#11648) * sanitize insrert queries in db-func (#11651) MON-14667 * Sanitized and bound queries in service argumentsXml file (#11654) MON-14669 * sanitize and bind host categories query (#11644) * Fix encoding issue on status serviceXML (#11582) * sanitize and bind in centreon connector query (#11636) * chore(git): update codeowners (#11593) * fix(conf) fix parent template display in service template listing (#11671) (#11677) * fix(poller): fix remote server duplication (#11552) (#11675) Refs: MON-14579 * fix(clapi): Check that user is admin to use clapi (#11631) (#11639) * Fix: Sanitize and bind service group dependecies queries 21.10.x (#11666) * fix(widgets): retrieve possibility to not select poller in pref (#11696) (#11699) Refs: MON-14919 * Fix: In Acces group the second select not working [ACL] 21.10.x (#11710) * fix second select not working * applying suggested changes * fix(details): remove dead code (#11672) (#11685) * fix(details): second part of code cleanup for "tools" (#11718) (#11722) * FIX: Sanitize and bind graph configuration queries 21.10.x (#11730) * Fix: Sanitize and bind CLAPI poller configuration 21.10.x (#11732) * sanitize and bind CLAPI poller config * remove unecessary comment * revert deleted imports * FIX: Sanitize and bind Meta Service configuration 21.10.x (#11734) * sanitize and bind meta service config * applying suggested changes * [Fix]:Sanitize and bind queries in template of service listing (#11745) * fix(resource): Fix bad SQL request (#11702) (#11750) * FIX: Sanitize and bind command configuration queries 21.10.x (#11755) Co-authored-by: Kevin Duret <[email protected]> Co-authored-by: Elmahdi ABBASSI <[email protected]> Co-authored-by: VHS <[email protected]> Co-authored-by: hyahiaoui-ext <[email protected]> Co-authored-by: jeremyjaouen <[email protected]> Co-authored-by: Stéphane Chapron <[email protected]> Co-authored-by: Stéphane Duret <[email protected]> Co-authored-by: alaunois <[email protected]> Co-authored-by: Charles Gautier <[email protected]> Co-authored-by: Dmytro Iosypenko <[email protected]> Co-authored-by: TamazC <[email protected]> Co-authored-by: Adrien Morais-Mestre <[email protected]> Co-authored-by: Laurent Calvet <[email protected]>
1 parent a63aa87 commit 640435a

File tree

48 files changed

+551
-351
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+551
-351
lines changed

.github/CODEOWNERS

-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
/project/ @centreon/centreon-devops
77
*.sh @centreon/centreon-devops
88

9-
/.snyk @centreon/centreon-security
10-
/sonar-project.properties @centreon/centreon-security
11-
129
*.po @centreon/centreon-documentation
1310

1411
/src/ @centreon/centreon-php

bin/registerServerTopology.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ function request_to_remote() {
431431
fi
432432

433433
# Prepare Remote Payload
434-
REMOTE_PAYLOAD='{"isRemote":true,"platformName":"'"${CURRENT_NODE_NAME}"'","centralServerAddress":"'"${PARSED_URL[HOST]}"'","apiUsername":"'"${API_USERNAME}"'","apiCredentials":"'"${API_TARGET_PASSWORD}"'","apiScheme":"'"${PARSED_URL[SCHEME]}"'","apiPort":'"${PARSED_URL[PORT]}"',"apiPath":"'"${CENTREON_BASE_URI}"'",'"${PEER_VALIDATION}"
434+
REMOTE_PAYLOAD='{"isRemote":true,"address":"'${PARSED_CURRENT_NODE_URL[HOST]}'","platformName":"'"${CURRENT_NODE_NAME}"'","centralServerAddress":"'"${PARSED_URL[HOST]}"'","apiUsername":"'"${API_USERNAME}"'","apiCredentials":"'"${API_TARGET_PASSWORD}"'","apiScheme":"'"${PARSED_URL[SCHEME]}"'","apiPort":'"${PARSED_URL[PORT]}"',"apiPath":"'"${CENTREON_BASE_URI}"'",'"${PEER_VALIDATION}"
435435
if [[ -n PROXY_PAYLOAD ]]; then
436436
REMOTE_PAYLOAD="${REMOTE_PAYLOAD}""${PROXY_PAYLOAD}"
437437
fi

config/json_validator/latest/Centreon/PlatformInformation/Update.json

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"isRemote": {
1111
"type": "boolean"
1212
},
13+
"address": {
14+
"type": "string"
15+
},
1316
"centralServerAddress": {
1417
"type": "string"
1518
},

doc/API/centreon-api-v21.10.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -5993,6 +5993,10 @@ components:
59935993
type: boolean
59945994
example: true
59955995
description: "Platform is a remote server"
5996+
address:
5997+
type: string
5998+
example: "10.0.0.1"
5999+
description: "The address of the platform"
59966000
centralServerAddress:
59976001
type: string
59986002
example: "192.168.0.1"

src/Centreon/Application/ApiPlatform.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,27 @@
2828
class ApiPlatform
2929
{
3030
/**
31-
* @var float
31+
* @var string
3232
*/
3333
private $version;
3434

3535
/**
3636
* Get the API version
3737
*
38-
* @return float
38+
* @return string
3939
*/
40-
public function getVersion(): float
40+
public function getVersion(): string
4141
{
4242
return $this->version;
4343
}
4444

4545
/**
4646
* Set the API version
4747
*
48-
* @param float $version
48+
* @param string $version
4949
* @return $this
5050
*/
51-
public function setVersion(float $version): self
51+
public function setVersion(string $version): self
5252
{
5353
$this->version = $version;
5454
return $this;

src/Centreon/Domain/PlatformInformation/Model/PlatformInformation.php

+24
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ class PlatformInformation
4040
*/
4141
private $platformName;
4242

43+
/**
44+
* @var string server address
45+
*/
46+
private string $address = '127.0.0.1';
47+
4348
/**
4449
* @var string|null central's address
4550
*/
@@ -126,6 +131,25 @@ public function setPlatformName(?string $name): self
126131
return $this;
127132
}
128133

134+
/**
135+
* @return string
136+
*/
137+
public function getAddress(): string
138+
{
139+
return $this->address;
140+
}
141+
142+
/**
143+
* @param string $address
144+
* @return $this
145+
*/
146+
public function setAddress(string $address): self
147+
{
148+
$this->address = $address;
149+
150+
return $this;
151+
}
152+
129153
/**
130154
* @return string|null
131155
*/

src/Centreon/Domain/PlatformInformation/Model/PlatformInformationFactory.php

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public function createRemoteInformation(array $information): PlatformInformation
5454
$platformInformation = new PlatformInformation($isRemote);
5555
foreach ($information as $key => $value) {
5656
switch ($key) {
57+
case 'address':
58+
$platformInformation->setAddress($value);
59+
break;
5760
case 'centralServerAddress':
5861
$platformInformation->setCentralServerAddress($value);
5962
break;

src/Centreon/Domain/PlatformInformation/UseCase/V20/UpdatePartiallyPlatformInformation.php

+1
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ private function convertCentralToRemote(
241241
$platformInformationToUpdate,
242242
$currentPlatformInformation
243243
);
244+
244245
$this->remoteServerService->convertCentralToRemote(
245246
$platformInformationToUpdate
246247
);

src/Centreon/Domain/PlatformTopology/Model/PlatformPending.php

+6-8
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,11 @@ private function checkIpAddress(?string $address): ?string
196196
{
197197
// Check for valid IPv4 or IPv6 IP
198198
// or not sent address (in the case of Central's "parent_address")
199-
if (null === $address || false !== filter_var($address, FILTER_VALIDATE_IP)) {
200-
return $address;
201-
}
202-
203-
// check for DNS to be resolved
204-
$addressResolved = filter_var(gethostbyname($address), FILTER_VALIDATE_IP);
205-
if (false === $addressResolved) {
199+
if (
200+
$address !== null
201+
&& ! filter_var($address, FILTER_VALIDATE_IP)
202+
&& ! filter_var($address, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)
203+
) {
206204
throw new \InvalidArgumentException(
207205
sprintf(
208206
_("The address '%s' of '%s' is not valid or not resolvable"),
@@ -212,7 +210,7 @@ private function checkIpAddress(?string $address): ?string
212210
);
213211
}
214212

215-
return $addressResolved;
213+
return $address;
216214
}
217215

218216
/**

src/Centreon/Domain/PlatformTopology/Model/PlatformRegistered.php

+5-8
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,11 @@ public function setHostname(?string $hostname): PlatformInterface
194194
*/
195195
private function checkIpAddress(?string $address): ?string
196196
{
197-
// Check for valid IPv4 or IPv6 IP
198-
// or not sent address (in the case of Central's "parent_address")
199-
if (null === $address || false !== filter_var($address, FILTER_VALIDATE_IP)) {
200-
return $address;
201-
}
202-
203-
// check for DNS to be resolved
204-
if (false === filter_var(gethostbyname($address), FILTER_VALIDATE_IP)) {
197+
if (
198+
$address !== null
199+
&& ! filter_var($address, FILTER_VALIDATE_IP)
200+
&& ! filter_var($address, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)
201+
) {
205202
throw new \InvalidArgumentException(
206203
sprintf(
207204
_("The address '%s' of '%s' is not valid or not resolvable"),

src/Centreon/Domain/PlatformTopology/PlatformTopologyService.php

+10-4
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,14 @@ private function findParentPlatform(PlatformInterface $platform): ?PlatformInter
482482
return null;
483483
}
484484

485-
$registeredParentInTopology = $this->platformTopologyRepository->findPlatformByAddress(
486-
$platform->getParentAddress()
487-
);
485+
if ($platform->getType() === PlatformPending::TYPE_REMOTE) {
486+
$registeredParentInTopology = $this->platformTopologyRepository->findTopLevelPlatform();
487+
} else {
488+
$registeredParentInTopology = $this->platformTopologyRepository->findPlatformByAddress(
489+
$platform->getParentAddress()
490+
);
491+
}
492+
488493
if (null === $registeredParentInTopology) {
489494
throw new EntityNotFoundException(
490495
sprintf(
@@ -553,6 +558,7 @@ public function getPlatformTopology(): array
553558
);
554559
if (null !== $platformParent) {
555560
$platform->setParentAddress($platformParent->getAddress());
561+
$platform->setParentId($platformParent->getId());
556562
}
557563
}
558564

@@ -614,7 +620,7 @@ public function deletePlatformAndReallocateChildren(int $serverId): void
614620
*/
615621
if ($deletedPlatform->getServerId() !== null) {
616622
if ($deletedPlatform->getType() === PlatformPending::TYPE_REMOTE) {
617-
$this->remoteServerRepository->deleteRemoteServerByAddress($deletedPlatform->getAddress());
623+
$this->remoteServerRepository->deleteRemoteServerByServerId($deletedPlatform->getServerId());
618624
$this->remoteServerRepository->deleteAdditionalRemoteServer($deletedPlatform->getServerId());
619625
}
620626

src/Centreon/Domain/RemoteServer/Interfaces/RemoteServerRepositoryInterface.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ interface RemoteServerRepositoryInterface
2828
/**
2929
* Delete a Remote Server.
3030
*
31-
* @param string $address
31+
* @param int $serverId
3232
*/
33-
public function deleteRemoteServerByAddress(string $address): void;
33+
public function deleteRemoteServerByServerId(int $serverId): void;
3434

3535
/**
3636
* Delete an Additional Remote Server, for pollers linked to multiple Remote Servers.

src/Centreon/Domain/RemoteServer/RemoteServerService.php

+4
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,20 @@ public function convertCentralToRemote(PlatformInformation $platformInformation)
138138
if ($platformInformation->getPlatformName() !== null) {
139139
$topLevelPlatform->setName($platformInformation->getPlatformName());
140140
}
141+
$topLevelPlatform->setAddress($platformInformation->getAddress());
142+
141143
/**
142144
* Find any children platform and forward them to Central Parent.
143145
*/
144146
$platforms = $this->platformTopologyRepository->findChildrenPlatformsByParentId(
145147
$topLevelPlatform->getId()
146148
);
149+
147150
/**
148151
* Insert the Top Level Platform at the beginning of array, as it need to be registered first.
149152
*/
150153
array_unshift($platforms, $topLevelPlatform);
154+
151155
/**
152156
* Register the platforms on the Parent Central
153157
*/

src/Centreon/Infrastructure/RemoteServer/RemoteServerRepositoryRDB.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ public function __construct(DatabaseConnection $db)
4141
/**
4242
* @inheritDoc
4343
*/
44-
public function deleteRemoteServerByAddress(string $address): void
44+
public function deleteRemoteServerByServerId(int $serverId): void
4545
{
46-
$statement = $this->db->prepare($this->translateDbName("DELETE FROM remote_servers WHERE ip = :address"));
47-
$statement->bindValue(':address', $address, \PDO::PARAM_STR);
46+
$statement = $this->db->prepare(
47+
$this->translateDbName("DELETE FROM remote_servers WHERE server_id = :server_id")
48+
);
49+
$statement->bindValue(':server_id', $serverId, \PDO::PARAM_INT);
4850
$statement->execute();
4951
}
5052

src/CentreonRemote/Application/Webservice/CentreonConfigurationRemote.php

+42-28
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public function getList(): array
211211
public function postGetRemotesList(): array
212212
{
213213
$query = 'SELECT ns.id, ns.ns_ip_address as ip, ns.name FROM nagios_server as ns ' .
214-
'JOIN remote_servers as rs ON rs.ip = ns.ns_ip_address ' .
214+
'JOIN remote_servers as rs ON rs.server_id = ns.id ' .
215215
'WHERE rs.is_connected = 1';
216216
$statement = $this->pearDB->query($query);
217217

@@ -469,6 +469,7 @@ public function postLinkCentreonRemoteServer(): array
469469

470470
// add server to the list of remote servers in database (table remote_servers)
471471
$this->addServerToListOfRemotes(
472+
(int) $serverId,
472473
$serverIP,
473474
$centreonPath,
474475
$httpMethod,
@@ -532,6 +533,7 @@ public function authorize($action, $user, $isInternal = false)
532533
/**
533534
* Add server ip in table of remote servers
534535
*
536+
* @param int $serverId the poller id
535537
* @param string $serverIP the IP of the server
536538
* @param string $centreonPath the path to access to Centreon
537539
* @param string $httpMethod the method to access to server (HTTP/HTTPS)
@@ -540,42 +542,54 @@ public function authorize($action, $user, $isInternal = false)
540542
* @param bool $noProxy to do not use configured proxy
541543
*/
542544
private function addServerToListOfRemotes(
545+
int $serverId,
543546
string $serverIP,
544547
string $centreonPath,
545548
string $httpMethod,
546549
string $httpPort,
547550
bool $noCheckCertificate,
548551
bool $noProxy
549552
): void {
550-
$dbAdapter = $this->getDi()[\Centreon\ServiceProvider::CENTREON_DB_MANAGER]->getAdapter('configuration_db');
551-
$date = date('Y-m-d H:i:s');
552-
553-
$sql = 'SELECT * FROM `remote_servers` WHERE `ip` = ?';
554-
$dbAdapter->query($sql, [$serverIP]);
555-
$hasIpInTable = (bool)$dbAdapter->count();
553+
$currentDate = date('Y-m-d H:i:s');
556554

557-
if ($hasIpInTable) {
558-
$sql = 'UPDATE `remote_servers` SET
559-
`is_connected` = ?, `connected_at` = ?, `centreon_path` = ?,
560-
`no_check_certificate` = ?, `no_proxy` = ?
561-
WHERE `ip` = ?';
562-
$data = ['1', $date, $centreonPath, ($noCheckCertificate ?: 0), ($noProxy ?: 0), $serverIP];
563-
$dbAdapter->query($sql, $data);
555+
$statement = $this->pearDB->prepare('SELECT 1 FROM `remote_servers` WHERE `server_id` = :server_id');
556+
$statement->bindValue(':server_id', $serverId, \PDO::PARAM_INT);
557+
$statement->execute();
558+
$remoteAlreadyExists = (bool) $statement->rowCount();
559+
560+
if ($remoteAlreadyExists) {
561+
$updateStatement = $this->pearDB->prepare(
562+
'UPDATE `remote_servers` SET
563+
`is_connected` = 1, `connected_at` = :connected_at, `centreon_path` = :centreon_path,
564+
`no_check_certificate` = :no_check_certificate, `no_proxy` = :no_proxy, `ip_address` = :ip_address
565+
WHERE `server_id` = :server_id'
566+
);
567+
$updateStatement->bindValue(':connected_at', $currentDate, \PDO::PARAM_STR);
568+
$updateStatement->bindValue(':centreon_path', $centreonPath, \PDO::PARAM_STR);
569+
$updateStatement->bindValue(':no_check_certificate', $noCheckCertificate ? '1' : '0', \PDO::PARAM_STR);
570+
$updateStatement->bindValue(':no_proxy', $noProxy ? '1' : '0', \PDO::PARAM_STR);
571+
$updateStatement->bindValue(':ip_address', $serverIP, \PDO::PARAM_STR);
572+
$updateStatement->bindValue(':server_id', $serverId, \PDO::PARAM_INT);
573+
$updateStatement->execute();
564574
} else {
565-
$data = [
566-
'ip' => $serverIP,
567-
'app_key' => '',
568-
'version' => '',
569-
'is_connected' => '1',
570-
'created_at' => $date,
571-
'connected_at' => $date,
572-
'centreon_path' => $centreonPath,
573-
'http_method' => $httpMethod,
574-
'http_port' => $httpPort ?: null,
575-
'no_check_certificate' => $noCheckCertificate ?: 0,
576-
'no_proxy' => $noProxy ?: 0
577-
];
578-
$dbAdapter->insert('remote_servers', $data);
575+
$insertStatement = $this->pearDB->prepare(
576+
'INSERT INTO `remote_servers`
577+
(`ip`, `app_key`, `version`, `is_connected`, `created_at`, `connected_at`, `centreon_path`,
578+
`http_method`, `http_port`, `no_check_certificate`, `no_proxy`, `server_id`)
579+
VALUES
580+
(:ip_address, "", "", 1, :created_at, :connected_at, :centreon_path, :http_method, :http_port,
581+
:no_check_certificate, :no_proxy, :server_id)'
582+
);
583+
$insertStatement->bindValue(':ip_address', $serverIP, \PDO::PARAM_STR);
584+
$insertStatement->bindValue(':created_at', $currentDate, \PDO::PARAM_STR);
585+
$insertStatement->bindValue(':connected_at', $currentDate, \PDO::PARAM_STR);
586+
$insertStatement->bindValue(':centreon_path', $centreonPath, \PDO::PARAM_STR);
587+
$insertStatement->bindValue(':http_method', $httpMethod, \PDO::PARAM_STR);
588+
$insertStatement->bindValue(':http_port', $httpPort ?: null, \PDO::PARAM_INT);
589+
$insertStatement->bindValue(':no_check_certificate', $noCheckCertificate ? '1' : '0', \PDO::PARAM_STR);
590+
$insertStatement->bindValue(':no_proxy', $noProxy ? '1' : '0', \PDO::PARAM_STR);
591+
$insertStatement->bindValue(':server_id', $serverId, \PDO::PARAM_INT);
592+
$insertStatement->execute();
579593
}
580594
}
581595

0 commit comments

Comments
 (0)