From a7c05dac1b5f4993cadb19cdb36691fb7259a2bc Mon Sep 17 00:00:00 2001 From: Patrick Monnerat Date: Wed, 9 Apr 2025 16:48:23 +0200 Subject: [PATCH] Some php 8 deprecation fixes --- lib/HTMLTree.php | 3 ++- lib/ds_ldap.php | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/HTMLTree.php b/lib/HTMLTree.php index e5fbf3b7..318f68ab 100644 --- a/lib/HTMLTree.php +++ b/lib/HTMLTree.php @@ -98,7 +98,8 @@ public function draw($onlytree=false) { $this->javascript .= '
'; $this->javascript .= ''; $this->javascript .= sprintf('',$server->getIndex()); - $this->javascript .= sprintf('',htmlspecialchars($server->getContainer($base->getDN()))); + $t = $server->getContainer($base->getDN()); + $this->javascript .= sprintf('',htmlspecialchars(is_null($t)? '': $t)); $this->javascript .= sprintf('',get_rdn($base->getDN())); $this->javascript .= sprintf('',$rdn[0]); $this->javascript .= sprintf('',$rdn[0],$rdn[1]); diff --git a/lib/ds_ldap.php b/lib/ds_ldap.php index 11c527d2..e1a80c21 100644 --- a/lib/ds_ldap.php +++ b/lib/ds_ldap.php @@ -204,10 +204,13 @@ protected function connect($method,$debug=false,$new=false) { if (function_exists('run_hook')) run_hook('pre_connect',array('server_id'=>$this->index,'method'=>$method)); - if ($this->getValue('server','port')) - $resource = ldap_connect($this->getValue('server','host'),$this->getValue('server','port')); - else - $resource = ldap_connect($this->getValue('server','host')); + $uri = $this->getValue('server','host'); + if (strpos($uri, '://') === false) { + $uri = 'ldap://' . urlencode($uri); + if ($this->getValue('server','port')) + $uri .= ':' . $this->getValue('server','port'); + } + $resource = ldap_connect($uri); $this->noconnect = false; $CACHE[$this->index][$method] = $resource;