diff --git a/net/phpldapadmin/Makefile b/net/phpldapadmin/Makefile index 62831744b9d2..140a93c19f30 100644 --- a/net/phpldapadmin/Makefile +++ b/net/phpldapadmin/Makefile @@ -1,66 +1,66 @@ PORTNAME= phpldapadmin PORTVERSION= 1.2.6.3 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= net www PKGNAMESUFFIX= ${PHP_PKGNAMESUFFIX} MAINTAINER= ports@bsdserwis.com COMMENT= PHP application to administer LDAP over the web WWW= http://phpldapadmin.sourceforge.net/ LICENSE= GPLv2 LICENSE_FILE= ${WRKSRC}/LICENSE USES= cpe php:web,flavors tar:tgz CPE_VENDOR= phpldapadmin_project USE_GITHUB= yes GH_ACCOUNT= leenooks GH_PROJECT= phpLDAPadmin USE_PHP= gettext hash iconv ldap openssl pcre session xml NO_ARCH= yes NO_BUILD= yes OPTIONS_DEFINE= MCRYPT MCRYPT_DESC= Use pecl-mcrypt for password hashing MCRYPT_USE= PHP=mcrypt .include GROUPS?= ${WWWGRP} CFGDIR= config CFGFILE= config.php PLIST= ${WRKDIR}/plist PLIST_FILES= '@sample(,${GROUPS},640) ${WWWDIR_REL}/config/config.php.example ${WWWDIR_REL}/config/config.php' SUB_LIST+= PKGNAME=${PKGNAME} SUB_FILES+= pkg-message .SILENT: .include post-patch: cd ${WRKSRC} ; \ ${CP} lib/Attribute.php lib/PLAAttribute.php; \ ${FIND} . ! -type d ! -name ${CFGFILE}.example ! -name .cvsignore \ ! -name .gitignore ! -name *.orig \ ! -name Attribute.php | ${SORT} | \ ${SED} -e "s!^\.!${WWWDIR_REL}!" >${PLIST} ; do-install: cd ${WRKSRC} ; \ for src in $$( ${FIND} . ! -name .cvsignore \ ! -name .gitignore ! -name *.orig \ ! -name Attribute.php) ; do \ dst=${STAGEDIR}${WWWDIR}$${src#.} ; \ if ${TEST} -d $$src ; then \ ${MKDIR} $$dst ; \ else \ ${INSTALL_DATA} $$src $$dst ; \ fi \ done .include diff --git a/net/phpldapadmin/files/patch-lib_AttributeFactory.php b/net/phpldapadmin/files/patch-lib_AttributeFactory.php index 12488014c85c..7f53c65e6b79 100644 --- a/net/phpldapadmin/files/patch-lib_AttributeFactory.php +++ b/net/phpldapadmin/files/patch-lib_AttributeFactory.php @@ -1,50 +1,55 @@ --- lib/AttributeFactory.php.orig 2021-12-12 02:35:51 UTC +++ lib/AttributeFactory.php @@ -83,7 +83,7 @@ class AttributeFactory { if (isset($values['type'])) switch ($values['type']) { case 'password': - if (! strcasecmp($name,'sambaLMPassword') || ! strcasecmp($name,'sambaNTPassword')) + if (! strcasecmp((string) $name,'sambaLMPassword') || ! strcasecmp((string) $name,'sambaNTPassword')) return $this->newSambaPasswordAttribute($name,$values,$server_id,$source); else return $this->newPasswordAttribute($name,$values,$server_id,$source); @@ -96,7 +96,7 @@ class AttributeFactory { return $this->newMultiLineAttribute($name,$values,$server_id,$source); } - if (! strcasecmp($name,'objectClass')) { + if (! strcasecmp((string) $name,'objectClass')) { return $this->newObjectClassAttribute($name,$values,$server_id,$source); } elseif ($app['server']->isJpegPhoto($name) || in_array($name,$app['server']->getValue('server','jpeg_attributes'))) { @@ -105,16 +105,16 @@ class AttributeFactory { } elseif ($app['server']->isAttrBinary($name)) { return $this->newBinaryAttribute($name,$values,$server_id,$source); - } elseif (! strcasecmp($name,'userPassword')) { + } elseif (! strcasecmp((string) $name,'userPassword')) { return $this->newPasswordAttribute($name,$values,$server_id,$source); - } elseif (! strcasecmp($name,'sambaLMPassword') || ! strcasecmp($name,'sambaNTPassword')) { + } elseif (! strcasecmp((string) $name,'sambaLMPassword') || ! strcasecmp((string) $name,'sambaNTPassword')) { return $this->newSambaPasswordAttribute($name,$values,$server_id,$source); - } elseif (in_array(strtolower($name),array_keys(array_change_key_case($_SESSION[APPCONFIG]->getValue('appearance','date_attrs'))))) { + } elseif (in_array(strtolower((string) $name),array_keys(array_change_key_case($_SESSION[APPCONFIG]->getValue('appearance','date_attrs'))))) { return $this->newDateAttribute($name,$values,$server_id,$source); - } elseif (in_array(strtolower($name),array('shadowlastchange','shadowmin','shadowmax','shadowexpire','shadowwarning','shadowinactive'))) { + } elseif (in_array(strtolower((string) $name),array('shadowlastchange','shadowmin','shadowmax','shadowexpire','shadowwarning','shadowinactive'))) { return $this->newShadowAttribute($name,$values,$server_id,$source); } elseif ($app['server']->isAttrBoolean($name)) { -@@ -129,7 +129,7 @@ class AttributeFactory { +@@ -129,11 +129,11 @@ class AttributeFactory { } elseif ($app['server']->isMultiLineAttr($name)) { return $this->newMultiLineAttribute($name,$values,$server_id,$source); - } elseif (! strcasecmp($name,'gidNumber')) { + } elseif (! strcasecmp((string) $name,'gidNumber')) { return $this->newGidAttribute($name,$values,$server_id,$source); } else { +- return new Attribute($name,$values,$server_id,$source); ++ return new PLAAttribute($name,$values,$server_id,$source); + } + } + diff --git a/net/phpldapadmin/files/patch-lib_PageRender.php b/net/phpldapadmin/files/patch-lib_PageRender.php index f97df7e2ebaf..eaafb0cfc1f6 100644 --- a/net/phpldapadmin/files/patch-lib_PageRender.php +++ b/net/phpldapadmin/files/patch-lib_PageRender.php @@ -1,120 +1,149 @@ --- lib/PageRender.php.orig 2021-12-12 02:35:51 UTC +++ lib/PageRender.php @@ -182,7 +182,7 @@ class PageRender extends Visitor { $attribute2 = $this->template->getAttribute($joinattr); if (! $attribute2) { - if (($pv = get_request(strtolower($joinattr),'REQUEST')) && isset($pv[$attribute->getName()][$i])) { + if (($pv = get_request(strtolower((string) $joinattr),'REQUEST')) && isset($pv[$attribute->getName()][$i])) { array_push($values,$pv[$attribute->getName()][$i]); if (! $pv[$attribute->getName()][$i]) @@ -242,7 +242,7 @@ class PageRender extends Visitor { return; # Get the attribute. - if (preg_match_all('/%(\w+)(\|.+)?(\/[lU])?%/U',strtolower($args[1]),$matchall)) { + if (preg_match_all('/%(\w+)(\|.+)?(\/[lU])?%/U',strtolower((string) $args[1]),$matchall)) { if (count($matchall[1]) != 1) system_message(array( 'title'=>_('Invalid value count for PasswordEncrypt'), @@ -255,11 +255,11 @@ class PageRender extends Visitor { } else $passwordvalue = $args[1]; - if (! trim($passwordvalue) || in_array($passwordvalue,$attribute->getOldValues())) + if (! trim((string) $passwordvalue) || in_array($passwordvalue,$attribute->getOldValues())) return; # Get the encoding - if ($passwordattr && preg_match_all('/%(\w+)(\|.+)?(\/[lU])?%/U',strtolower($args[0]),$matchall)) { + if ($passwordattr && preg_match_all('/%(\w+)(\|.+)?(\/[lU])?%/U',strtolower((string) $args[0]),$matchall)) { if (count($matchall[1]) != 1) system_message(array( 'title'=>_('Invalid value count for PasswordEncrypt'), @@ -271,7 +271,7 @@ class PageRender extends Visitor { } else $enc = $args[0]; - $enc = strtolower($enc); + $enc = strtolower((string) $enc); switch ($enc) { case 'lm': @@ -403,7 +403,7 @@ class PageRender extends Visitor { $alias_note = $this->get($note,$attribute); if ($alias_note) { - if (trim($attr_note)) + if (trim((string) $attr_note)) $attr_note .= ', '; $attr_note .= $alias_note; @@ -423,7 +423,7 @@ class PageRender extends Visitor { # Is there a user-friendly translation available for this attribute? $friendly_name = $attribute->getFriendlyName(); - if (strtolower($friendly_name) != $attribute->getName()) + if (strtolower((string) $friendly_name) != $attribute->getName()) return sprintf('%s', _('Note'),$friendly_name,_('is an alias for'),$attribute->getName(false),_('alias')); else +@@ -827,7 +827,7 @@ class PageRender extends Visitor { + if (! $attribute->getOldValue($i)) + return; + +- draw_jpeg_photo($this->getServer(),$this->template->getDN(),$attribute->getName(),$i,false,false); ++ draw_jpeg_photo($this->getServer(),$this->template->getDN(),$i,$attribute->getName(),false,false); + } + + /** +@@ -844,16 +844,16 @@ class PageRender extends Visitor { + # If the attribute is modified, the new value needs to be stored in a session variable for the draw_jpeg_photo callback. + if ($attribute->hasBeenModified()) { + $_SESSION['tmp'][$attribute->getName()][$i] = $attribute->getValue($i); +- draw_jpeg_photo(null,$this->template->getDN(),$attribute->getName(),$i,false,false); ++ draw_jpeg_photo(null,$this->template->getDN(),$i,$attribute->getName(),false,false); + } else +- draw_jpeg_photo($this->getServer(),$this->template->getDN(),$attribute->getName(),$i,false,false); ++ draw_jpeg_photo($this->getServer(),$this->template->getDN(),$i,$attribute->getName(),false,false); + } + + protected function drawFormReadOnlyValueJpegAttribute($attribute,$i) { + $this->draw('HiddenValue',$attribute,$i); + $_SESSION['tmp'][$attribute->getName()][$i] = $attribute->getValue($i); + +- draw_jpeg_photo(null,$this->template->getDN(),$attribute->getName(),$i,false,false); ++ draw_jpeg_photo(null,$this->template->getDN(),$i,$attribute->getName(),false,false); + } + + protected function drawFormReadOnlyValueMultiLineAttribute($attribute,$i) { @@ -954,7 +954,7 @@ class PageRender extends Visitor { $server = $this->getServer(); $val = $attribute->getValue($i); - if (trim($val)) + if (trim((string) $val)) $enc_type = get_enc_type($val); else $enc_type = $server->getValue('appearance','pla_password_hash'); @@ -966,7 +966,7 @@ class PageRender extends Visitor { htmlspecialchars($attribute->getName()),$i,htmlspecialchars($attribute->getName()), $i,htmlspecialchars($val),($attribute->getSize() > 0) ? 'size="'.$attribute->getSize().'"' : ''); - if (trim($val)) + if (trim((string) $val)) $this->draw('CheckLink',$attribute,'new_values_'.htmlspecialchars($attribute->getName()).'_'.$i); } @@ -979,7 +979,7 @@ class PageRender extends Visitor { $enc_type = get_enc_type($val); # Set the default hashing type if the password is blank (must be newly created) - if (trim($val)) + if (trim((string) $val)) $enc_type = get_enc_type($val); else $enc_type = $server->getValue('appearance','pla_password_hash'); @@ -1125,7 +1125,7 @@ class PageRender extends Visitor { foreach ($attribute->getSelection() as $value => $description) { printf('',$value, - ((strcasecmp($value,$val) == 0) && $found = true) ? 'selected="selected"' : '',$description); + ((strcasecmp((string) $value,(string) $val) == 0) && (string) $found = true) ? 'selected="selected"' : '',(string) $description); if ($value == '') $empty_value = true; @@ -1140,7 +1140,7 @@ class PageRender extends Visitor { echo "\n"; } - if ((strlen($val) > 0) && ! $empty_value && $this->template->getDN()) { + if ((strlen((string) $val) > 0) && ! $empty_value && $this->template->getDN()) { printf('',_('none, remove value')); echo "\n"; } @@ -1212,11 +1212,11 @@ class PageRender extends Visitor { $today = date('U'); echo '
'; - if (($today < $shadow_date) && in_array(strtolower($attribute->getName()),$shadow_before_today_attrs)) + if (($today < $shadow_date) && in_array(strtolower((string) $attribute->getName()),$shadow_before_today_attrs)) printf('(%s)', strftime($_SESSION[APPCONFIG]->getValue('appearance','date'),$shadow_date)); - elseif (($today > $shadow_date) && in_array(strtolower($attribute->getName()),$shadow_after_today_attrs)) + elseif (($today > $shadow_date) && in_array(strtolower((string) $attribute->getName()),$shadow_after_today_attrs)) printf('(%s)', strftime($_SESSION[APPCONFIG]->getValue('appearance','date'),$shadow_date)); diff --git a/net/phpldapadmin/files/patch-lib_Tree.php b/net/phpldapadmin/files/patch-lib_Tree.php index 17113e51bee1..59e1ecbdcc1e 100644 --- a/net/phpldapadmin/files/patch-lib_Tree.php +++ b/net/phpldapadmin/files/patch-lib_Tree.php @@ -1,20 +1,29 @@ --- lib/Tree.php.orig 2021-12-12 02:35:51 UTC +++ lib/Tree.php +@@ -68,7 +68,7 @@ abstract class Tree { + } + } + +- set_cached_item($server_id,'tree','null',$tree); ++ set_cached_item($server_id,$tree,'tree','null'); + } + + return $tree; @@ -132,7 +132,7 @@ abstract class Tree { if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); - $index = strtolower(implode(',',pla_explode_dn($dn))); + $index = strtolower((string) implode(',',pla_explode_dn($dn))); if (DEBUG_ENABLED) debug_log('Result (%s)',1,0,__FILE__,__LINE__,__METHOD__,$index); @@ -185,7 +185,7 @@ abstract class Tree { $tree_factory = new TreeItem($server->getIndex(),$dn); $tree_factory->setObjectClasses($server->getDNAttrValue($dn,'objectClass')); - if ((($isleaf = $server->getDNAttrValue($dn,'hassubordinates')) && ! strcasecmp($isleaf[0],'false'))) + if ((($isleaf = $server->getDNAttrValue($dn,'hassubordinates')) && ! strcasecmp((string) $isleaf[0],'false'))) $tree_factory->setLeaf(); $this->entries[$dnlower] = $tree_factory; diff --git a/net/phpldapadmin/files/patch-lib_common.php b/net/phpldapadmin/files/patch-lib_common.php index 9e464a0fd2a1..33b76dae081a 100644 --- a/net/phpldapadmin/files/patch-lib_common.php +++ b/net/phpldapadmin/files/patch-lib_common.php @@ -1,14 +1,25 @@ --- lib/common.php.orig 2021-12-12 02:35:51 UTC +++ lib/common.php @@ -247,9 +247,9 @@ if ($app['language'] == 'auto') { $value = preg_split('/[-]+/',$value); if (sizeof($value) == 2) - $app['lang_http'][$key] = strtolower($value[0]).'_'.strtoupper($value[1]); + $app['lang_http'][$key] = strtolower((string) $value[0]).'_'.strtoupper($value[1]); else - $app['lang_http'][$key] = auto_lang(strtolower($value[0])); + $app['lang_http'][$key] = auto_lang(strtolower((string) $value[0])); } $app['lang_http'] = array_unique($app['lang_http']); +@@ -296,7 +296,9 @@ if ($app['language'] == 'auto') { + * Strip slashes from GET, POST, and COOKIE variables if this + * PHP install is configured to automatically addslashes() + */ +-if (@get_magic_quotes_gpc() && (! isset($slashes_stripped) || ! $slashes_stripped)) { ++if (@version_compare(phpversion(), '5.4.0', '<') && ++ @get_magic_quotes_gpc() && ++ (!isset($slashes_stripped) || !$slashes_stripped)) { + array_stripslashes($_REQUEST); + array_stripslashes($_GET); + array_stripslashes($_POST); diff --git a/net/phpldapadmin/files/patch-lib_ds__ldap.php b/net/phpldapadmin/files/patch-lib_ds__ldap.php index 8ed7f9831b50..389cf1128878 100644 --- a/net/phpldapadmin/files/patch-lib_ds__ldap.php +++ b/net/phpldapadmin/files/patch-lib_ds__ldap.php @@ -1,459 +1,490 @@ --- lib/ds_ldap.php.orig 2021-12-12 02:35:51 UTC +++ lib/ds_ldap.php @@ -206,6 +206,7 @@ class ldap extends DS { if ($this->getValue('server','port')) $resource = ldap_connect($this->getValue('server','host'),$this->getValue('server','port')); + else $resource = ldap_connect($this->getValue('server','host')); @@ -216,7 +217,8 @@ class ldap extends DS { debug_log('LDAP Resource [%s], Host [%s], Port [%s]',16,0,__FILE__,__LINE__,__METHOD__, $resource,$this->getValue('server','host'),$this->getValue('server','port')); - if (! is_resource($resource)) + // if (! is_resource($resource)) + if ( !$resource ) debug_dump_backtrace('UNHANDLED, $resource is not a resource',1); # Go with LDAP version 3 if possible (needed for renaming and Novell schema fetching) @@ -328,7 +330,7 @@ class ldap extends DS { } } - if (! $this->isAnonBindAllowed() && ! trim($userDN)) + if (! $this->isAnonBindAllowed() && ! trim((string) $userDN)) return false; # Temporarily set our user details @@ -337,7 +339,7 @@ class ldap extends DS { $connect = $this->connect($method,false,$new); # If we didnt log in... - if (! is_resource($connect) || $this->noconnect || ! $this->userIsAllowedLogin($userDN)) { + if (!$connect || $this->noconnect || ! $this->userIsAllowedLogin($userDN)) { $this->logout($method); return false; @@ -565,11 +567,11 @@ class ldap extends DS { private function fillDNTemplate($user) { foreach($this->getLoginBaseDN() as $base) - if(substr_compare($user, $base, -strlen($base)) === 0) + if(substr_compare($user, $base, -strlen((string) $base)) === 0) return $user; // $user already passed as DN // fill template - return sprintf($this->getValue('login', 'bind_dn_template'), preg_replace('/([,\\\\#+<>;"=])/', '\\\\$1', $user)); + return sprintf($this->getValue('login', 'bind_dn_template'), preg_replace('/([,\\\\#+<>;"=])/', '\\\\$1',is_null( $user)? "": $user)); } /** @@ -684,7 +686,7 @@ class ldap extends DS { if (! in_array($this->getValue('login','auth_type'), array('sasl','sasl_external'))) { // check if SASL mech uses login from other auth_types - if (! in_array(strtolower($this->getValue('sasl', 'mech')), array('plain'))) + if (! in_array(strtolower((string) $this->getValue('sasl', 'mech')), array('plain'))) return false; } @@ -722,7 +724,7 @@ class ldap extends DS { } # At the moment, we have only implemented GSSAPI and PLAIN - if (! in_array(strtolower($this->getValue('sasl','mech')),array('gssapi','plain'))) { + if (! in_array(strtolower((string) $this->getValue('sasl','mech')),array('gssapi','plain'))) { system_message(array( 'title'=>_('SASL Method not implemented'), 'body'=>sprintf('%s: %s %s',_('Error'),$this->getValue('sasl','mech'),_('has not been implemented yet')), @@ -731,7 +733,7 @@ class ldap extends DS { return false; } - if (strtolower($this->getValue('sasl','mech')) == 'plain') { + if (strtolower((string) $this->getValue('sasl','mech')) == 'plain') { return @ldap_sasl_bind($resource,NULL,$pass,'PLAIN', $this->getValue('sasl','realm'), $login, @@ -746,14 +748,15 @@ class ldap extends DS { /* # Do we need to rewrite authz_id? if (! isset($CACHE['authz_id'])) - if (! trim($this->getValue('sasl','authz_id')) && strtolower($this->getValue('sasl','mech')) != 'gssapi') { + if (! trim((string) $this->getValue('sasl','authz_id')) && strtolower((string) $this->getValue('sasl','mech')) != 'gssapi') { if (DEBUG_ENABLED) debug_log('Rewriting bind DN [%s] -> authz_id with regex [%s] and replacement [%s].',9,0,__FILE__,__LINE__,__METHOD__, $CACHE['login_dn'], $this->getValue('sasl','authz_id_regex'), $this->getValue('sasl','authz_id_replacement')); - $CACHE['authz_id'] = @preg_replace($this->getValue('sasl','authz_id_regex'), + $CACHE['authz_id'] = @preg_replace($this->getValue('sasl','authz_id_regex'),is_null( +)? "": $this->getValue('sasl','authz_id_replacement'),$CACHE['login_dn']); # Invalid regex? @@ -1212,14 +1215,14 @@ class ldap extends DS { if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); - if (! trim($dn)) + if (! trim((string) $dn)) return $dn; # Check if the RDN has a comma and escape it. while (preg_match('/([^\\\\]),(\s*[^=]*\s*),/',$dn)) - $dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*),/','$1\\\\2C$2,',$dn); + $dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*),/','$1\\\\2C$2,',is_null($dn)? "":$dn); - $dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*)([^,])$/','$1\\\\2C$2$3',$dn); + $dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*)([^,])$/','$1\\\\2C$2$3',is_null($dn)? "":$dn); if (DEBUG_ENABLED) debug_log('Returning (%s)',17,0,__FILE__,__LINE__,__METHOD__,$dn); @@ -1237,12 +1240,12 @@ class ldap extends DS { if (is_array($dn)) { $a = array(); foreach ($dn as $key => $rdn) { - $a[$key] = preg_replace_callback('/\\\([0-9A-Fa-f]{2})/', function($m) { return chr(hexdec($m[1])); }, $rdn); + $a[$key] = preg_replace_callback('/\\\([0-9A-Fa-f]{2})/', function($m) { return chr(hexdec($m[1])); },is_null( $rdn)? "": $rdn); } return $a; } else { - return preg_replace_callback('/\\\([0-9A-Fa-f]{2})/', function($m) { return chr(hexdec($m[1])); }, $dn); + return preg_replace_callback('/\\\([0-9A-Fa-f]{2})/', function($m) { return chr(hexdec($m[1])); },is_null( $dn)? "": $dn); } } @@ -1388,7 +1391,7 @@ class ldap extends DS { return false; # error checking - $schema_to_fetch = strtolower($schema_to_fetch); + $schema_to_fetch = strtolower((string) $schema_to_fetch); if (! is_null($this->_schema_entries) && isset($this->_schema_entries[$schema_to_fetch])) { $schema = $this->_schema_entries[$schema_to_fetch]; @@ -1408,7 +1411,7 @@ class ldap extends DS { $schema_dn = $this->getSchemaDN($method,$dn); # Do we need to try again with the Root DSE? - if (! $schema_dn && trim($dn)) + if (! $schema_dn && trim((string) $dn)) $schema_dn = $this->getSchemaDN($method,''); # Store the eventual schema retrieval in $schema_search @@ -1609,7 +1612,7 @@ class ldap extends DS { foreach ($entry[$olc_schema] as $schema_definition) /* Schema definitions in child nodes prefix the schema entries with "{n}" the preg_replace call strips out this prefix. */ - $schema[] = preg_replace('/^\{\d*\}\(/','(',$schema_definition); + $schema[] = preg_replace('/^\{\d*\}\(/','(',is_null($schema_definition)? "":$schema_definition); } } @@ -1672,7 +1675,7 @@ class ldap extends DS { if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) debug_log('Entered (%%)',25,0,__FILE__,__LINE__,__METHOD__,$fargs); - $oclass_name = strtolower($oclass_name); + $oclass_name = strtolower((string) $oclass_name); $socs = $this->SchemaObjectClasses($method,$dn); # Default return value @@ -1703,7 +1706,7 @@ class ldap extends DS { if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) debug_log('Entered (%%)',25,0,__FILE__,__LINE__,__METHOD__,$fargs); - $attr_name = strtolower($attr_name); + $attr_name = strtolower((string) $attr_name); $sattrs = $this->SchemaAttributes($method,$dn); # Default return value @@ -1752,7 +1755,7 @@ class ldap extends DS { $return = array(); foreach ($raw as $line) { - if (is_null($line) || ! strlen($line)) + if (is_null($line) || ! strlen((string) $line)) continue; $object_class = new ObjectClass($line,$this); -@@ -1762,8 +1765,8 @@ class ldap extends DS { +@@ -1762,13 +1765,13 @@ class ldap extends DS { # Now go through and reference the parent/child relationships foreach ($return as $oclass) foreach ($oclass->getSupClasses() as $parent_name) - if (isset($return[strtolower($parent_name)])) - $return[strtolower($parent_name)]->addChildObjectClass($oclass->getName(false)); + if (isset($return[strtolower((string) $parent_name)])) + $return[strtolower((string) $parent_name)]->addChildObjectClass($oclass->getName(false)); ksort($return); + # cache the schema to prevent multiple schema fetches from LDAP server +- set_cached_item($this->index,'schema','objectclasses',$return); ++ set_cached_item($this->index,$return,'schema','objectclasses'); + } + + if (DEBUG_ENABLED) @@ -1816,7 +1819,7 @@ class ldap extends DS { */ $attrs_oid = array(); foreach ($raw as $line) { - if (is_null($line) || ! strlen($line)) + if (is_null($line) || ! strlen((string) $line)) continue; $attr = new AttributeType($line); @@ -1847,7 +1850,7 @@ class ldap extends DS { $new_attr->setName($alias_attr_name); $new_attr->addAlias($attr->getName(false)); $new_attr->removeAlias($alias_attr_name); - $new_attr_key = strtolower($alias_attr_name); + $new_attr_key = strtolower((string) $alias_attr_name); $attrs[$new_attr_key] = $new_attr; } } @@ -1858,7 +1861,7 @@ class ldap extends DS { $sup_attr_name = $attr->getSupAttribute(); $sup_attr = null; - if (trim($sup_attr_name)) { + if (trim((string) $sup_attr_name)) { /* This loop really should traverse infinite levels of inheritance (SUP) for attributeTypes, * but just in case we get carried away, stop at 100. This shouldn't happen, but for @@ -1871,17 +1874,17 @@ class ldap extends DS { $sup_attr_name = $attr->getSupAttribute(); } - if (! isset($attrs[strtolower($sup_attr_name)])){ + if (! isset($attrs[strtolower((string) $sup_attr_name)])){ error(sprintf('Schema error: attributeType "%s" inherits from "%s", but attributeType "%s" does not exist.', $attr->getName(),$sup_attr_name,$sup_attr_name),'error','index.php'); return; } - $sup_attr = $attrs[strtolower($sup_attr_name)]; + $sup_attr = $attrs[strtolower((string) $sup_attr_name)]; $sup_attr_name = $sup_attr->getSupAttribute(); # Does this superior attributeType not have a superior attributeType? - if (is_null($sup_attr_name) || strlen(trim($sup_attr_name)) == 0) { + if (is_null($sup_attr_name) || strlen((string) trim((string) $sup_attr_name)) == 0) { /* Since this attribute's superior attribute does not have another superior * attribute, clone its properties for this attribute. Then, replace -@@ -1936,18 +1939,18 @@ class ldap extends DS { +@@ -1936,24 +1939,24 @@ class ldap extends DS { # Add Used In. foreach ($oclass_attrs as $attr_name) - if (isset($attrs[strtolower($attr_name)])) - $attrs[strtolower($attr_name)]->addUsedInObjectClass($object_class->getName(false)); + if (isset($attrs[strtolower((string) $attr_name)])) + $attrs[strtolower((string) $attr_name)]->addUsedInObjectClass($object_class->getName(false)); # Add Required By. foreach ($must_attrs as $attr_name) - if (isset($attrs[strtolower($attr_name)])) - $attrs[strtolower($attr_name)]->addRequiredByObjectClass($object_class->getName(false)); + if (isset($attrs[strtolower((string) $attr_name)])) + $attrs[strtolower((string) $attr_name)]->addRequiredByObjectClass($object_class->getName(false)); # Force May foreach ($object_class->getForceMayAttrs() as $attr_name) - if (isset($attrs[strtolower($attr_name->name)])) - $attrs[strtolower($attr_name->name)]->setForceMay(); + if (isset($attrs[strtolower((string) $attr_name->name)])) + $attrs[strtolower((string) $attr_name->name)]->setForceMay(); } $return = $attrs; + + # cache the schema to prevent multiple schema fetches from LDAP server +- set_cached_item($this->index,'schema','attributes',$return); ++ set_cached_item($this->index,$return,'schema','attributes'); + } + + if (DEBUG_ENABLED) @@ -1987,7 +1990,7 @@ class ldap extends DS { $rules = array(); foreach ($raw as $line) { - if (is_null($line) || ! strlen($line)) + if (is_null($line) || ! strlen((string) $line)) continue; $rule = new MatchingRule($line); @@ -2003,7 +2006,7 @@ class ldap extends DS { if ($raw != false) { foreach ($raw as $line) { - if (is_null($line) || ! strlen($line)) + if (is_null($line) || ! strlen((string) $line)) continue; $rule_use = new MatchingRuleUse($line); @@ -2019,7 +2022,7 @@ class ldap extends DS { $sattrs = $this->SchemaAttributes($method,$dn); if (is_array($sattrs)) foreach ($sattrs as $attr) { - $rule_key = strtolower($attr->getEquality()); + $rule_key = strtolower((string) $attr->getEquality()); if (isset($rules[$rule_key])) $rules[$rule_key]->addUsedByAttr($attr->getName(false)); +@@ -2029,7 +2032,7 @@ class ldap extends DS { + $return = $rules; + + # cache the schema to prevent multiple schema fetches from LDAP server +- set_cached_item($this->index,'schema','matchingrules',$return); ++ set_cached_item($this->index,$return,'schema','matchingrules'); + } + + if (DEBUG_ENABLED) @@ -2063,11 +2066,11 @@ class ldap extends DS { $return = array(); foreach ($raw as $line) { - if (is_null($line) || ! strlen($line)) + if (is_null($line) || ! strlen((string) $line)) continue; $syntax = new Syntax($line); - $key = strtolower(trim($syntax->getOID())); + $key = strtolower((string) trim((string) $syntax->getOID())); if (! $key) continue; +@@ -2078,7 +2081,7 @@ class ldap extends DS { + ksort($return); + + # cache the schema to prevent multiple schema fetches from LDAP server +- set_cached_item($this->index,'schema','syntaxes',$return); ++ set_cached_item($this->index,$return,'schema','syntaxes'); + } + + if (DEBUG_ENABLED) @@ -2097,7 +2100,7 @@ class ldap extends DS { if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); - return in_array($attr_name,unserialize(strtolower(serialize($this->getValue('server','force_may'))))); + return in_array($attr_name,unserialize(strtolower((string) serialize($this->getValue('server','force_may'))))); } /** @@ -2133,7 +2136,7 @@ class ldap extends DS { debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); # Ensure our attr is in lowercase - $attr = strtolower($attr); + $attr = strtolower((string) $attr); $values = $this->getDNAttrValues($dn,$method,$deref); @@ -2247,7 +2250,7 @@ class ldap extends DS { # Simple test first $dn_attrs = array('aliasedObjectName'); foreach ($dn_attrs as $dn_attr) - if (strcasecmp($attr_name,$dn_attr) == 0) + if (strcasecmp((string) $attr_name,(string) $dn_attr) == 0) return true; # Now look at the schema OID @@ -2266,7 +2269,7 @@ class ldap extends DS { return false; $syntax_desc = $syntaxes[ $syntax_oid ]->getDescription(); - if (strpos(strtolower($syntax_desc),'distinguished name')) + if (strpos(strtolower((string) $syntax_desc),'distinguished name')) return true; return false; @@ -2286,7 +2289,7 @@ class ldap extends DS { debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); # easy quick check - if (! strcasecmp($attr_name,'jpegPhoto') || ! strcasecmp($attr_name,'photo')) + if (! strcasecmp((string) $attr_name,'jpegPhoto') || ! strcasecmp((string) $attr_name,'photo')) return true; # go to the schema and get the Syntax OID @@ -2297,7 +2300,7 @@ class ldap extends DS { $oid = $sattr->getSyntaxOID(); $type = $sattr->getType(); - if (! strcasecmp($type,'JPEG') || ($oid == '1.3.6.1.4.1.1466.115.121.1.28')) + if (! strcasecmp((string) $type,'JPEG') || ((string) $oid == '1.3.6.1.4.1.1466.115.121.1.28')) return true; return false; @@ -2318,9 +2321,9 @@ class ldap extends DS { $type = ($sattr = $this->getSchemaAttribute($attr_name)) ? $sattr->getType() : null; - if (! strcasecmp('boolean',$type) || - ! strcasecmp('isCriticalSystemObject',$attr_name) || - ! strcasecmp('showInAdvancedViewOnly',$attr_name)) + if (! strcasecmp('boolean',(string) $type) || + ! strcasecmp('isCriticalSystemObject',(string) $attr_name) || + ! strcasecmp('showInAdvancedViewOnly',(string) $attr_name)) return true; else @@ -2359,7 +2362,7 @@ class ldap extends DS { static $attr_cache; - $attr_name = strtolower($attr_name); + $attr_name = strtolower((string) $attr_name); if (isset($attr_cache[$this->index][$attr_name])) return $attr_cache[$this->index][$attr_name]; @@ -2370,7 +2373,7 @@ class ldap extends DS { } # Quick check: If the attr name ends in ";binary", then it's binary. - if (strcasecmp(substr($attr_name,strlen($attr_name) - 7),';binary') == 0) { + if (strcasecmp(substr((string) $attr_name,strlen((string) (string) $attr_name) - 7),';binary') == 0) { $attr_cache[$this->index][$attr_name] = true; return true; } @@ -2389,17 +2392,17 @@ class ldap extends DS { $syntax = $sattr->getSyntaxOID(); } - if (strcasecmp($type,'Certificate') == 0 || - strcasecmp($type,'Binary') == 0 || - strcasecmp($attr_name,'usercertificate') == 0 || - strcasecmp($attr_name,'usersmimecertificate') == 0 || - strcasecmp($attr_name,'networkaddress') == 0 || - strcasecmp($attr_name,'objectGUID') == 0 || - strcasecmp($attr_name,'objectSID') == 0 || - strcasecmp($attr_name,'auditingPolicy') == 0 || - strcasecmp($attr_name,'jpegPhoto') == 0 || - strcasecmp($attr_name,'krbExtraData') == 0 || - strcasecmp($attr_name,'krbPrincipalKey') == 0 || + if (strcasecmp((string) $type,'Certificate') == 0 || + strcasecmp((string) $type,'Binary') == 0 || + strcasecmp((string) $attr_name,'usercertificate') == 0 || + strcasecmp((string) $attr_name,'usersmimecertificate') == 0 || + strcasecmp((string) $attr_name,'networkaddress') == 0 || + strcasecmp((string) $attr_name,'objectGUID') == 0 || + strcasecmp((string) $attr_name,'objectSID') == 0 || + strcasecmp((string) $attr_name,'auditingPolicy') == 0 || + strcasecmp((string) $attr_name,'jpegPhoto') == 0 || + strcasecmp((string) $attr_name,'krbExtraData') == 0 || + strcasecmp((string) $attr_name,'krbPrincipalKey') == 0 || $syntax == '1.3.6.1.4.1.1466.115.121.1.10' || $syntax == '1.3.6.1.4.1.1466.115.121.1.28' || $syntax == '1.3.6.1.4.1.1466.115.121.1.5' || @@ -2428,7 +2431,7 @@ class ldap extends DS { if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); - $user = strtolower($user); + $user = strtolower((string) $user); $group = $this->getDNAttrValues($group); # If you are using groupOfNames objectClass @@ -2459,7 +2462,7 @@ class ldap extends DS { if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); - $dn = trim(strtolower($dn)); + $dn = trim((string) strtolower((string) $dn)); if (! $this->getValue('login','allowed_dns')) return true; @@ -2498,7 +2501,7 @@ class ldap extends DS { debug_log('Comparing with [%s]',80,0,__FILE__,__LINE__,__METHOD__,$result_dn); # Check if $result_dn is a user DN - if (strcasecmp($dn,trim(strtolower($result_dn))) == 0) + if (strcasecmp((string) $dn,trim((string) strtolower((string) (string) $result_dn))) == 0) return true; # Check if $result_dn is a group DN @@ -2510,7 +2513,7 @@ class ldap extends DS { } # Check if $login_allowed_dn is a user DN - if (strcasecmp($dn,trim(strtolower($login_allowed_dn))) == 0) + if (strcasecmp((string) $dn,trim((string) strtolower((string) (string) $login_allowed_dn))) == 0) return true; # Check if $login_allowed_dn is a group DN diff --git a/net/phpldapadmin/files/patch-lib_ds__ldap__pla.php b/net/phpldapadmin/files/patch-lib_ds__ldap__pla.php index 2de761e9e9c4..fc33585335fc 100644 --- a/net/phpldapadmin/files/patch-lib_ds__ldap__pla.php +++ b/net/phpldapadmin/files/patch-lib_ds__ldap__pla.php @@ -1,40 +1,67 @@ --- lib/ds_ldap_pla.php.orig 2021-12-12 02:35:51 UTC +++ lib/ds_ldap_pla.php @@ -248,7 +248,7 @@ class ldap_pla extends ldap { # Next, compare strictly by name first else foreach ($_SESSION[APPCONFIG]->getValue('appearance','multi_line_attributes') as $multi_line_attr_name) - if (strcasecmp($multi_line_attr_name,$attr_name) == 0) { + if (strcasecmp((string) $multi_line_attr_name,(string) $attr_name) == 0) { $return = true; break; } @@ -285,8 +285,8 @@ class ldap_pla extends ldap { * @return boolean */ private function isAttrTest($attr,$attrs,$except_dn) { - $attr = trim($attr); - if (! trim($attr) || ! count($attrs)) + $attr = trim((string) $attr); + if (! trim((string) $attr) || ! count($attrs)) return false; # Is the user excluded? @@ -294,7 +294,7 @@ class ldap_pla extends ldap { return false; foreach ($attrs as $attr_name) - if (strcasecmp($attr,trim($attr_name)) == 0) + if (strcasecmp((string) $attr,trim((string) (string) $attr_name)) == 0) return true; return false; +@@ -371,7 +371,7 @@ class ldap_pla extends ldap { + + $tree->addEntry($dn); + +- set_cached_item($this->index,'tree','null',$tree); ++ set_cached_item($this->index,$tree,'tree','null'); + + run_hook('post_entry_create',array('server_id'=>$this->index,'method'=>$method,'dn'=>$dn,'attrs'=>$entry_array)); + +@@ -403,7 +403,7 @@ class ldap_pla extends ldap { + $tree = get_cached_item($this->index,'tree'); + $tree->delEntry($dn); + +- set_cached_item($this->index,'tree','null',$tree); ++ set_cached_item($this->index,$tree,'tree','null'); + + run_hook('post_entry_delete',array('server_id'=>$this->index,'method'=>$method,'dn'=>$dn)); + } +@@ -430,7 +430,7 @@ class ldap_pla extends ldap { + $newdn = sprintf('%s,%s',$new_rdn,$container); + $tree->renameEntry($dn,$newdn); + +- set_cached_item($this->index,'tree','null',$tree); ++ set_cached_item($this->index,$tree,'tree','null'); + + run_hook('post_entry_rename',array('server_id'=>$this->index,'method'=>$method,'dn'=>$dn,'rdn'=>$new_rdn,'container'=>$container)); + } @@ -674,7 +674,7 @@ class ldap_pla extends ldap { if ($this->getValue('appearance', 'show_authz') && function_exists('ldap_exop_whoami')) { $result = @ldap_exop_whoami($this->connect($method)); if ($result) // strip any dn: or u: prefix - $result = preg_replace('/^(u|dn):/i', '', $result); + $result = preg_replace('/^(u|dn):/i', '',is_null( $result)? "": $result); else // fall back to login on error $result = $this->getLogin($method); return $result; diff --git a/net/phpldapadmin/files/patch-lib_functions.php b/net/phpldapadmin/files/patch-lib_functions.php index d97a5febf06e..91951e3ca8b5 100644 --- a/net/phpldapadmin/files/patch-lib_functions.php +++ b/net/phpldapadmin/files/patch-lib_functions.php @@ -1,454 +1,483 @@ --- lib/functions.php.orig 2021-12-12 02:35:51 UTC +++ lib/functions.php @@ -161,7 +161,7 @@ function app_error_handler($errno,$errstr,$file,$linen } # Take out extra spaces in error strings. - $errstr = preg_replace('/\s+/',' ',$errstr); + $errstr = preg_replace('/\s+/',' ',is_null($errstr)? "":$errstr); if ($errno == E_NOTICE) { $body = ''; @@ -214,9 +214,9 @@ function app_version() { $CACHE = 'UNKNOWN'; else { - $version = rtrim(file_get_contents($version_file)); + $version = rtrim((string) file_get_contents($version_file)); - $CACHE = preg_replace('/^RELEASE-([0-9\.]+(-.*)*)$/','$1',$version); + $CACHE = preg_replace('/^RELEASE-([0-9\.]+(-.*)*)$/','$1',is_null($version)? "":$version); # Check if we are a CVS copy. if (preg_match('/^(DEVEL)?$/',$CACHE)) @@ -525,7 +525,8 @@ function debug_log($msg,$level,$indent) { # Pull the file/line/method if (is_string($args[0]) && preg_match('/.php$/',$args[0])) { - $file = preg_replace('/.php$/','',array_shift($args)); + $file_a_shift = array_shift($args); + $file = preg_replace('/.php$/','',is_null($file_a_shift? "":$file_a_shift)); $line = array_shift($args); $method = array_shift($args); @@ -550,7 +551,7 @@ function debug_log($msg,$level,$indent) { } if (preg_match('/%%/',$msg)) - $msg = preg_replace('/%%/',join('|',$fargs),$msg); + $msg = preg_replace('/%%/',join('|',$fargs),is_null($msg)? "":$msg); else $msg = vsprintf($msg,array_values($fargs)); @@ -761,11 +762,11 @@ function blowfish_encrypt($data,$secret=null) { debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); # If our secret is null or blank, get the default. - if ($secret === null || ! trim($secret)) + if ($secret === null || ! trim((string) $secret)) $secret = $_SESSION[APPCONFIG]->getValue('session','blowfish') ? $_SESSION[APPCONFIG]->getValue('session','blowfish') : session_id(); # If the secret isnt set, then just return the data. - if (! trim($secret)) + if (! trim((string) $secret)) return $data; if (! empty($data) && function_exists('openssl_encrypt') && in_array('bf-ecb', openssl_get_cipher_methods())) { @@ -791,10 +792,10 @@ function blowfish_encrypt($data,$secret=null) { $pma_cipher = new Horde_Cipher_blowfish; $encrypt = ''; - for ($i=0; $iencryptBlock($block, $secret); @@ -822,11 +823,11 @@ function blowfish_decrypt($encdata,$secret=null) { return $CACHE[$encdata]; # If our secret is null or blank, get the default. - if ($secret === null || ! trim($secret)) + if ($secret === null || ! trim((string) $secret)) $secret = $_SESSION[APPCONFIG]->getValue('session','blowfish') ? $_SESSION[APPCONFIG]->getValue('session','blowfish') : session_id(); # If the secret isnt set, then just return the data. - if (! trim($secret)) + if (! trim((string) $secret)) return $encdata; if (! empty($encdata) && function_exists('openssl_encrypt') && in_array('bf-ecb', openssl_get_cipher_methods())) { @@ -838,7 +839,7 @@ function blowfish_decrypt($encdata,$secret=null) { $td = mcrypt_module_open(MCRYPT_BLOWFISH,'',MCRYPT_MODE_ECB,''); $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td),MCRYPT_DEV_URANDOM); mcrypt_generic_init($td,substr($secret,0,mcrypt_enc_get_key_size($td)),$iv); - $decrypted_data = trim(mdecrypt_generic($td,base64_decode($encdata))); + $decrypted_data = trim((string) mdecrypt_generic($td,base64_decode($encdata))); mcrypt_generic_deinit($td); return $decrypted_data; @@ -853,11 +854,11 @@ function blowfish_decrypt($encdata,$secret=null) { $decrypt = ''; $data = base64_decode($encdata); - for ($i=0; $idecryptBlock(substr($data, $i, 8), $secret); // Strip off our \0's that were added. - $return = preg_replace("/\\0*$/",'',$decrypt); + $return = preg_replace("/\\0*$/",'',is_null($decrypt)? "":$decrypt); $CACHE[$encdata] = $return; return $return; } @@ -876,7 +877,7 @@ function full_str_pad($input,$pad_length,$pad_string=' debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); $str = ''; - $length = $pad_length - strlen($input); + $length = $pad_length - strlen((string) $input); if ($length > 0) { // str_repeat doesn't like negatives if ($pad_type == STR_PAD_RIGHT) { // STR_PAD_RIGHT == 1 +@@ -928,7 +929,7 @@ function get_cached_item($index,$item,$subitem='null') + * + * Returns true on success of false on failure. + */ +-function set_cached_item($index,$item,$subitem='null',$data) { ++function set_cached_item($index,$data,$item,$subitem='null') { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); + @@ -1090,7 +1091,7 @@ function masort(&$data,$sortby,$rev=0) { $code .= " \$a = array_change_key_case(\$a);\n"; $code .= " \$b = array_change_key_case(\$b);\n"; - $key = strtolower($key); + $key = strtolower((string) $key); $code .= " if ((! isset(\$a['$key'])) && isset(\$b['$key'])) return 1;\n"; $code .= " if (isset(\$a['$key']) && (! isset(\$b['$key']))) return -1;\n"; @@ -1248,7 +1249,7 @@ function is_dn_string($str) { $left = $sub_parts[0]; $right = $sub_parts[1]; - if ( ! strlen(trim($left)) || ! strlen(trim($right))) + if ( ! strlen((string) trim((string) $left)) || ! strlen((string) trim((string) $right))) return false; if (strpos($left,'#') !== false) @@ -1343,7 +1344,7 @@ function pla_compare_dns($dn1,$dn2) { $dn2 = implode('+',$dn2); # If they are obviously the same, return immediately - if (! strcasecmp($dn1,$dn2)) + if (! strcasecmp((string) $dn1,(string) $dn2)) return 0; $dn1_parts = pla_explode_dn(pla_reverse_dn($dn1)); @@ -1364,15 +1365,15 @@ function pla_compare_dns($dn1,$dn2) { $dn1_sub_parts = explode('=',$dn1_part,2); $dn2_sub_parts = explode('=',$dn2_part,2); - $dn1_sub_part_attr = trim($dn1_sub_parts[0]); - $dn2_sub_part_attr = trim($dn2_sub_parts[0]); + $dn1_sub_part_attr = trim((string) $dn1_sub_parts[0]); + $dn2_sub_part_attr = trim((string) $dn2_sub_parts[0]); - if (0 != ($cmp = strcasecmp($dn1_sub_part_attr,$dn2_sub_part_attr))) + if (0 != ((string) $cmp = strcasecmp((string) $dn1_sub_part_attr,(string) $dn2_sub_part_attr))) return $cmp; - $dn1_sub_part_val = trim($dn1_sub_parts[1]); - $dn2_sub_part_val = trim($dn2_sub_parts[1]); - if (0 != ($cmp = strcasecmp($dn1_sub_part_val,$dn2_sub_part_val))) + $dn1_sub_part_val = trim((string) $dn1_sub_parts[1]); + $dn2_sub_part_val = trim((string) $dn2_sub_parts[1]); + if (0 != ((string) $cmp = strcasecmp((string) $dn1_sub_part_val,(string) $dn2_sub_part_val))) return $cmp; } @@ -1430,7 +1431,7 @@ function get_next_number($base,$attr,$increment=false, debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); $server = $_SESSION[APPCONFIG]->getServer(get_request('server_id','REQUEST')); - $attr = strtolower($attr); + $attr = strtolower((string) $attr); $query = array(); if (! $server->getValue('auto_number','enable')) { @@ -1457,7 +1458,7 @@ function get_next_number($base,$attr,$increment=false, if (! $base) { $query['base'] = $server->getValue('auto_number','search_base'); - if (! trim($query['base'])) { + if (! trim((string) $query['base'])) { system_message(array( 'title'=>_('No AUTO_NUMBER search_base configured for this server'), 'body'=>_('A call was made to get_next_number(), however, the base to search is empty.'), @@ -1628,7 +1629,7 @@ function get_icon($server_id,$dn,$object_classes=array $object_classes = $server->getDNAttrValue($dn,'objectClass'); foreach ($object_classes as $index => $value) - $object_classes[$index] = strtolower($value); + $object_classes[$index] = strtolower((string) $value); $rdn = get_rdn($dn); $rdn_parts = explode('=',$rdn,2); @@ -1638,7 +1639,7 @@ function get_icon($server_id,$dn,$object_classes=array # Return icon filename based upon objectClass value if (in_array('sambaaccount',$object_classes) && - '$' == $rdn[ strlen($rdn) - 1 ]) + '$' == $rdn[ strlen((string) $rdn) - 1 ]) return 'nt_machine.png'; if (in_array('sambaaccount',$object_classes)) @@ -1688,9 +1689,9 @@ function get_icon($server_id,$dn,$object_classes=array $cval = explode('=',$tmp[0],2); $cval = isset($cval[1]) ? $cval[1] : false; if ($cval && false === strpos($cval,'..') && - file_exists(realpath(sprintf('%s/../countries/%s.png',IMGDIR,strtolower($cval))))) + file_exists(realpath(sprintf('%s/../countries/%s.png',IMGDIR,strtolower((string) $cval))))) - return sprintf('../countries/%s.png',strtolower($cval)); + return sprintf('../countries/%s.png',strtolower((string) $cval)); else return 'country.png'; @@ -1777,13 +1778,13 @@ function get_icon($server_id,$dn,$object_classes=array return 'hard-drive.png'; elseif (strpos($rdn_value,'ipsec') === 0 || - strcasecmp($rdn_value,'IP Security') == 0|| - strcasecmp($rdn_value,'MSRADIUSPRIVKEY Secret') == 0 || + strcasecmp((string) $rdn_value,'IP Security') == 0|| + strcasecmp((string) $rdn_value,'MSRADIUSPRIVKEY Secret') == 0 || strpos($rdn_value,'BCKUPKEY_') === 0) return 'lock.png'; - elseif (strcasecmp($rdn_value,'MicrosoftDNS') == 0) + elseif (strcasecmp((string) $rdn_value,'MicrosoftDNS') == 0) return 'ldap-dc.png'; # Oh well, I don't know what it is. Use a generic icon. @@ -1802,7 +1803,7 @@ function expand_dn_with_base($base,$sub_dn) { if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); - $empty_str = (is_null($sub_dn) || (($len=strlen(trim($sub_dn))) == 0)); + $empty_str = (is_null($sub_dn) || (($len=strlen((string) trim((string) $sub_dn))) == 0)); if ($empty_str) return $base; @@ -1927,7 +1928,7 @@ function pla_verbose_error($key) { $hex_code = isset($entry[1]) ? $entry[1] : null; $title = isset($entry[2]) ? $entry[2] : null; $desc = isset($entry[3]) ? $entry[3] : null; - $desc = preg_replace('/\s+/',' ',$desc); + $desc = preg_replace('/\s+/',' ',is_null($desc)? "":$desc); $CACHE[$hex_code] = array('title'=>$title,'desc'=>$desc); } } @@ -1984,7 +1985,7 @@ function support_oid_to_text($key) { $CACHE[$oid_id]['title'] = isset($entry[4]) ? $entry[4] : null; $CACHE[$oid_id]['ref'] = isset($entry[6]) ? $entry[6] : null; $desc = isset($entry[8]) ? $entry[8] : sprintf('%s',$unknown['desc'],$unknown['title']); - $CACHE[$oid_id]['desc'] = preg_replace('/\s+/',' ',$desc); + $CACHE[$oid_id]['desc'] = preg_replace('/\s+/',' ',is_null($desc)? "":$desc); } } } +@@ -2032,8 +2033,8 @@ function ldap_error_msg($msg,$errnum) { + * + * Usage Examples: + * +- * draw_jpeg_photo(0,'cn=Bob,ou=People,dc=example,dc=com',"jpegPhoto",0,true,array('img_opts'=>"border: 1px; width: 150px")); +- * draw_jpeg_photo(1,'cn=Fred,ou=People,dc=example,dc=com',null,1); ++ * draw_jpeg_photo(0,'cn=Bob,ou=People,dc=example,dc=com',0,"jpegPhoto",true,array('img_opts'=>"border: 1px; width: 150px")); ++ * draw_jpeg_photo(1,'cn=Fred,ou=People,dc=example,dc=com',1,null); + * + * + * @param object The Server to get the image from. +@@ -2046,7 +2047,7 @@ function ldap_error_msg($msg,$errnum) { + * @param array Specifies optional image and CSS style attributes for the table tag. Supported keys are + * fixed_width, fixed_height, img_opts. + */ +-function draw_jpeg_photo($server,$dn,$attr_name='jpegphoto',$index,$draw_delete_buttons=false,$options=array()) { ++function draw_jpeg_photo($server,$dn,$index,$attr_name='jpegphoto',$draw_delete_buttons=false,$options=array()) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); + @@ -2164,7 +2165,7 @@ function pla_password_hash($password_clear,$enc_type) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); - $enc_type = strtolower($enc_type); + $enc_type = strtolower((string) $enc_type); switch($enc_type) { case 'blowfish': @@ -2335,7 +2336,7 @@ function password_check($cryptedpassword,$plainpasswor if (preg_match('/{([^}]+)}(.*)/',$cryptedpassword,$matches)) { $cryptedpassword = $matches[2]; - $cypher = strtolower($matches[1]); + $cypher = strtolower((string) $matches[1]); } else { $cypher = null; @@ -2389,7 +2390,7 @@ function password_check($cryptedpassword,$plainpasswor # SHA crypted passwords case 'sha': - if (strcasecmp(pla_password_hash($plainpassword,'sha'),'{SHA}'.$cryptedpassword) == 0) + if (strcasecmp(pla_password_hash((string) $plainpassword,'sha'),'{SHA}'.(string) $cryptedpassword) == 0) return true; else return false; @@ -2398,7 +2399,7 @@ function password_check($cryptedpassword,$plainpasswor # MD5 crypted passwords case 'md5': - if( strcasecmp(pla_password_hash($plainpassword,'md5'),'{MD5}'.$cryptedpassword) == 0) + if( strcasecmp(pla_password_hash((string) $plainpassword,'md5'),'{MD5}'.(string) $cryptedpassword) == 0) return true; else return false; @@ -2463,7 +2464,7 @@ function password_check($cryptedpassword,$plainpasswor # SHA256 crypted passwords case 'sha256': - if (strcasecmp(pla_password_hash($plainpassword,'sha256'),'{SHA256}'.$cryptedpassword) == 0) + if (strcasecmp(pla_password_hash((string) $plainpassword,'sha256'),'{SHA256}'.(string) $cryptedpassword) == 0) return true; else return false; @@ -2485,7 +2486,7 @@ function password_check($cryptedpassword,$plainpasswor # SHA384 crypted passwords case 'sha384': - if (strcasecmp(pla_password_hash($plainpassword,'sha384'),'{SHA384}'.$cryptedpassword) == 0) + if (strcasecmp(pla_password_hash((string) $plainpassword,'sha384'),'{SHA384}'.(string) $cryptedpassword) == 0) return true; else return false; @@ -2507,7 +2508,7 @@ function password_check($cryptedpassword,$plainpasswor # SHA512 crypted passwords case 'sha512': - if (strcasecmp(pla_password_hash($plainpassword,'sha512'),'{SHA512}'.$cryptedpassword) == 0) + if (strcasecmp(pla_password_hash((string) $plainpassword,'sha512'),'{SHA512}'.(string) $cryptedpassword) == 0) return true; else return false; @@ -2554,12 +2555,12 @@ function get_enc_type($user_password) { $enc_type = null; if (preg_match('/{([^}]+)}/',$user_password,$enc_type)) - $enc_type = strtolower($enc_type[1]); + $enc_type = strtolower((string) $enc_type[1]); else return null; # Handle crypt types - if (strcasecmp($enc_type,'crypt') == 0) { + if (strcasecmp((string) $enc_type,'crypt') == 0) { # No need to check for standard crypt, because enc_type is already equal to 'crypt'. if (preg_match('/{[^}]+}\\$1\\$+/',$user_password)) @@ -2698,9 +2699,9 @@ function dn_escape($dn) { # Check if the RDN has a comma and escape it. while (preg_match('/([^\\\\]),(\s*[^=]*\s*),/',$dn)) - $dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*),/','$1\\\\2C$2,',$dn); + $dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*),/','$1\\\\2C$2,',is_null($dn)? "":$dn); - $dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*)([^,])$/','$1\\\\2C$2$3',$dn); + $dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*)([^,])$/','$1\\\\2C$2$3',is_null($dn)? "":$dn); if (DEBUG_ENABLED) debug_log('Returning (%s)',1,0,__FILE__,__LINE__,__METHOD__,$dn); @@ -2872,17 +2873,17 @@ function sortAttrs($a,$b) { $b_key = array_search($b->getName(),$attrs_display_order); if ((! $a_key) && ($a_key !== 0)) - if ((! $a_key = array_search(strtolower($a->getFriendlyName()),$attrs_display_order)) && ($a_key !== 0)) + if ((! $a_key = array_search(strtolower((string) $a->getFriendlyName()),$attrs_display_order)) && ($a_key !== 0)) $a_key = count($attrs_display_order)+1; if ((! $b_key) && ($b_key !== 0)) - if ((! $b_key = array_search(strtolower($b->getFriendlyName()),$attrs_display_order)) && ($b_key !== 0)) + if ((! $b_key = array_search(strtolower((string) $b->getFriendlyName()),$attrs_display_order)) && ($b_key !== 0)) $b_key = count($attrs_display_order)+1; # Case where neither $a, nor $b are in $attrs_display_order, $a_key = $b_key = one greater than num elements. # So we sort them alphabetically if ($a_key === $b_key) - return strcasecmp($a->getFriendlyName(),$b->getFriendlyName()); + return strcasecmp((string) $a->getFriendlyName(),(string) $b->getFriendlyName()); # Case where at least one attribute or its friendly name is in $attrs_display_order # return -1 if $a before $b in $attrs_display_order @@ -2904,7 +2905,7 @@ function arrayLower($array) { $newarray = array(); foreach ($array as $key => $value) - $newarray[$key] = strtolower($value); + $newarray[$key] = strtolower((string) $value); return $newarray; } @@ -2929,7 +2930,7 @@ function in_array_ignore_case($needle,$haystack) { $return = false; foreach ($haystack as $element) { - if (is_string($element) && (strcasecmp($needle,$element) == 0)) { + if (is_string((string) $element) && (strcasecmp((string) $needle,(string) $element) == 0)) { $return = true; break; } @@ -2961,13 +2962,13 @@ function draw_formatted_dn($server,$entry) { debug_log('The tokens are (%s)',1,0,__FILE__,__LINE__,__METHOD__,$tokens); foreach ($tokens as $token) { - if (strcasecmp($token,'%dn') == 0) + if (strcasecmp((string) $token,'%dn') == 0) $format = str_replace($token,pretty_print_dn($dn),$format); - elseif (strcasecmp($token,'%rdn') == 0) + elseif (strcasecmp((string) $token,'%rdn') == 0) $format = str_replace($token,pretty_print_dn($entry->getRDN()),$format); - elseif (strcasecmp($token,'%rdnvalue') == 0) { + elseif (strcasecmp((string) $token,'%rdnvalue') == 0) { $rdn = get_rdn($dn,0,true); $rdn_value = explode('=',$rdn,2); $rdn_value = $rdn_value[1]; @@ -3046,7 +3047,7 @@ function littleEndian($hex) { $result = ''; - for ($x=strlen($hex)-2;$x>= 0;$x=$x-2) + for ($x=strlen((string) $hex)-2;$x>= 0;$x=$x-2) $result .= substr($hex,$x,2); return $result; @@ -3088,7 +3089,7 @@ function return_ldap_hash($base,$filter,$key,$attrs,$s debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); $server = $_SESSION[APPCONFIG]->getServer(get_request('server_id','REQUEST')); - $key = strtolower($key); + $key = strtolower((string) $key); $query = array(); $query['base'] = $base; @@ -3103,21 +3104,21 @@ function return_ldap_hash($base,$filter,$key,$attrs,$s if (is_array($values[$key])) foreach ($values[$key] as $i => $k) foreach ($attrs as $attr) { - $lattr = strtolower($attr); + $lattr = strtolower((string) $attr); if (isset($values[$lattr])) { $v = ''; if (is_array($values[$lattr]) && isset($values[$lattr][$i])) $v = $values[$lattr][$i]; - if (is_string($v) && (strlen($v) > 0)) + if (is_string($v) && (strlen((string) $v) > 0)) $results[$k][$attr] = $v; } } else foreach ($attrs as $attr) { - $lattr = strtolower($attr); + $lattr = strtolower((string) $attr); if (isset($values[$lattr])) $results[$values[$key]][$attr] = $values[$lattr]; } @@ -3263,7 +3264,7 @@ function random_junk() { * @return string */ function htmlid($sid,$dn) { - return sprintf('SID%s:%s',$sid,preg_replace('/[\ =,]/','_',$dn)); + return sprintf('SID%s:%s',$sid,preg_replace('/[\ =,]/','_',is_null($dn)? "":$dn)); } /** diff --git a/net/phpldapadmin/files/patch-lib_xmlTemplates.php b/net/phpldapadmin/files/patch-lib_xmlTemplates.php index 9088d3297f1e..64602daf25fe 100644 --- a/net/phpldapadmin/files/patch-lib_xmlTemplates.php +++ b/net/phpldapadmin/files/patch-lib_xmlTemplates.php @@ -1,47 +1,56 @@ --- lib/xmlTemplates.php.orig 2021-12-12 02:35:51 UTC +++ lib/xmlTemplates.php @@ -85,7 +85,7 @@ abstract class xmlTemplates { $filename = sprintf('%s/%s',$dir,$file); if (! in_array($filename,$this->getTemplateFiles())) { - $templatename = preg_replace('/.xml$/','',$file); + $templatename = preg_replace('/.xml$/','',is_null($file)? "":$file); $this->templates[$index] = new $class['name']($this->server_id,$templatename,$filename,$type,$index); $index++; @@ -128,7 +128,7 @@ abstract class xmlTemplates { $filename = sprintf('%s/%s',$dir,$file); # Store the template - $templatename = preg_replace('/.xml$/','',$file); + $templatename = preg_replace('/.xml$/','',is_null($file)? "":$file); $this->templates[$counter] = new $class['name']($this->server_id,$templatename,$filename,$type,$counter); $counter++; } +@@ -140,7 +140,7 @@ abstract class xmlTemplates { + + if ($changed) { + masort($this->templates,'title'); +- set_cached_item($server_id,$class['item'],'null',$this->templates); ++ set_cached_item($server_id,$this->templates,$class['item'],'null'); + } + } + @@ -304,7 +304,7 @@ abstract class xmlTemplate { debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); foreach ($this->attributes as $index => $attribute) - if (strtolower($attr) == $attribute->getName() || in_array(strtolower($attr),$attribute->getAliases())) + if (strtolower((string) $attr) == $attribute->getName() || in_array(strtolower($attr),$attribute->getAliases())) return $index; return null; @@ -343,7 +343,7 @@ abstract class xmlTemplate { debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->name); if ($lower) - return strtolower($this->name); + return strtolower((string) $this->name); else return $this->name; } @@ -482,7 +482,7 @@ abstract class xmlTemplate { debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); foreach ($this->attributes as $attribute) - if (($attribute->getName() == strtolower($name)) || in_array(strtolower($name),$attribute->getAliases())) + if (($attribute->getName() == strtolower((string) $name)) || in_array(strtolower($name),$attribute->getAliases())) return $attribute; return null;