Skip to content

Commit

Permalink
Merge commit from fork
Browse files Browse the repository at this point in the history
  • Loading branch information
trasher authored Feb 12, 2025
1 parent cb3c3c1 commit ccf7500
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/System/Status/StatusChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ public static function getLDAPStatus($public_only = true): array
$global_status = self::STATUS_OK;
foreach ($ldap_methods as $method) {
$ldap = null;
$display_name = $public_only ? 'GLPI_LDAP_' . $method['id'] : $method['name'];
try {
if (
@AuthLDAP::tryToConnectToServer(
Expand All @@ -278,11 +279,11 @@ public static function getLDAPStatus($public_only = true): array
(new \GLPIKey())->decrypt($method['rootdn_passwd'])
)
) {
$status['servers'][$method['name']] = [
$status['servers'][$display_name] = [
'status' => self::STATUS_OK
];
} else {
$status['servers'][$method['name']] = [
$status['servers'][$display_name] = [
'status' => self::STATUS_PROBLEM,
'status_msg' => _x('glpi_status', 'Unable to connect to the LDAP server')
];
Expand Down Expand Up @@ -338,6 +339,7 @@ public static function getIMAPStatus($public_only = true): array
$global_status = self::STATUS_OK;
foreach ($imap_methods as $method) {
$param = Toolbox::parseMailServerConnectString($method['connect_string'], true);
$display_name = $public_only ? 'GLPI_IMAP_' . $method['id'] : $method['name'];
if ($param['ssl'] === true) {
$host = 'ssl://' . $param['address'];
} else if ($param['tls'] === true) {
Expand All @@ -346,11 +348,11 @@ public static function getIMAPStatus($public_only = true): array
$host = $param['address'];
}
if ($fp = @fsockopen($host, $param['port'], $errno, $errstr, 1)) {
$status['servers'][$method['name']] = [
$status['servers'][$display_name] = [
'status' => self::STATUS_OK
];
} else {
$status['servers'][$method['name']] = [
$status['servers'][$display_name] = [
'status' => self::STATUS_PROBLEM,
'status_msg' => _x('glpi_status', 'Unable to connect to the IMAP server')
];
Expand Down Expand Up @@ -444,13 +446,14 @@ public static function getMailCollectorStatus($public_only = true): array
$mailcol = new MailCollector();
foreach ($mailcollectors as $mc) {
if ($mailcol->getFromDB($mc['id'])) {
$display_name = $public_only ? 'GLPI_COLLECTOR_' . $mc['id'] : $mc['name'];
try {
$mailcol->connect();
$status['servers'][$mc['name']] = [
$status['servers'][$display_name] = [
'status' => self::STATUS_OK
];
} catch (\Throwable $e) {
$status['servers'][$mc['name']] = [
$status['servers'][$display_name] = [
'status' => self::STATUS_PROBLEM,
'error_code' => $e->getCode(),
'status_msg' => $e->getMessage()
Expand Down

0 comments on commit ccf7500

Please sign in to comment.