View | Details | Raw Unified | Return to bug 266678 | Differences between
and this patch

Collapse All | Expand All

(-)b/net/phpldapadmin/Makefile (-1 / +5 lines)
Lines 1-6 Link Here
1
PORTNAME=	phpldapadmin
1
PORTNAME=	phpldapadmin
2
PORTVERSION=	1.2.6.3
2
PORTVERSION=	1.2.6.3
3
PORTREVISION=	1
3
PORTREVISION=	2
4
CATEGORIES=	net www
4
CATEGORIES=	net www
5
PKGNAMESUFFIX=	${PHP_PKGNAMESUFFIX}
5
PKGNAMESUFFIX=	${PHP_PKGNAMESUFFIX}
6
6
Lines 17-25 USE_GITHUB= yes Link Here
17
GH_ACCOUNT=	leenooks
17
GH_ACCOUNT=	leenooks
18
GH_PROJECT=	phpLDAPadmin
18
GH_PROJECT=	phpLDAPadmin
19
USE_PHP=	gettext hash iconv ldap openssl pcre session xml
19
USE_PHP=	gettext hash iconv ldap openssl pcre session xml
20
USE_GITHUB=	yes
21
GH_ACCOUNT=	leenooks
22
GH_PROJECT=	phpLDAPadmin
20
23
21
NO_ARCH=	yes
24
NO_ARCH=	yes
22
NO_BUILD=	yes
25
NO_BUILD=	yes
26
CPE_VENDOR=	phpldapadmin_project
23
27
24
OPTIONS_DEFINE=	MCRYPT
28
OPTIONS_DEFINE=	MCRYPT
25
29
(-)b/net/phpldapadmin/files/patch-htdocs_add__oclass__form.php (+11 lines)
Added Link Here
1
--- htdocs/add_oclass_form.php.orig	2021-12-12 02:35:51 UTC
2
+++ htdocs/add_oclass_form.php
3
@@ -36,7 +36,7 @@ $ldap['attrs']['must'] = array();
4
 
5
 foreach ($request['template']->getAttribute('objectclass')->getValues() as $oclass_name) {
6
 	# Exclude "top" if its there.
7
-	if (! strcasecmp('top',$oclass_name))
8
+	if (! strcasecmp('top',(string) $oclass_name))
9
 		continue;
10
 
11
 	if ($soc = $app['server']->getSchemaObjectClass($oclass_name))
(-)b/net/phpldapadmin/files/patch-htdocs_add__value__form.php (+32 lines)
Added Link Here
1
--- htdocs/add_value_form.php.orig	2021-12-12 02:35:51 UTC
2
+++ htdocs/add_value_form.php
3
@@ -32,12 +32,12 @@ if ($request['attribute']->isReadOnly())
4
 */
5
 
6
 # Render the form
7
-if (! strcasecmp($request['attr'],'objectclass') || get_request('meth','REQUEST') != 'ajax') {
8
+if (! strcasecmp((string) $request['attr'],'objectclass') || get_request('meth','REQUEST') != 'ajax') {
9
 	# Render the form.
10
 	$request['page']->drawTitle(sprintf('%s <b>%s</b> %s <b>%s</b>',_('Add new'),htmlspecialchars($request['attr']),_('value to'),htmlspecialchars(get_rdn($request['dn']))));
11
 	$request['page']->drawSubTitle();
12
 
13
-	if (! strcasecmp($request['attr'],'objectclass')) {
14
+	if (! strcasecmp((string) $request['attr'],'objectclass')) {
15
 		echo '<form action="cmd.php" method="post" class="new_value" id="entry_form">';
16
 		echo '<div>';
17
 		echo '<input type="hidden" name="cmd" value="add_oclass_form" />';
18
@@ -91,12 +91,12 @@ if (! strcasecmp($request['attr'],'objectclass') || ge
19
 	printf('<td class="top">%s</td>',_('Enter the value(s) you would like to add:'));
20
 	echo '<td>';
21
 
22
-	if (! strcasecmp($request['attr'],'objectclass')) {
23
+	if (! strcasecmp((string) $request['attr'],'objectclass')) {
24
 		# If our attr is an objectClass, fetch all available objectClasses and remove those from the list that are already defined in the entry
25
 		$socs = $app['server']->SchemaObjectClasses();
26
 
27
 		foreach ($request['attribute']->getValues() as $oclass)
28
-			unset($socs[strtolower($oclass)]);
29
+			unset($socs[strtolower((string) $oclass)]);
30
 
31
 		# Draw objectClass selection
32
 		echo '<table border="0">';
(-)b/net/phpldapadmin/files/patch-htdocs_cmd.php (+11 lines)
Added Link Here
1
--- htdocs/cmd.php.orig	2021-12-12 02:35:51 UTC
2
+++ htdocs/cmd.php
3
@@ -41,7 +41,7 @@ if (DEBUG_ENABLED)
4
 $www['page'] = new page($app['server']->getIndex());
5
 
6
 # See if we can render the command
7
-if (trim($www['cmd'])) {
8
+if (trim((string) $www['cmd'])) {
9
 	# If this is a READ-WRITE operation, the LDAP server must not be in READ-ONLY mode.
10
 	if ($app['server']->isReadOnly() && ! in_array(get_request('cmd','REQUEST'),$app['readwrite_cmds']))
11
 		error(_('You cannot perform updates while server is in read-only mode'),'error','index.php');
(-)b/net/phpldapadmin/files/patch-htdocs_copy.php (+11 lines)
Added Link Here
1
--- htdocs/copy.php.orig	2021-12-12 02:35:51 UTC
2
+++ htdocs/copy.php
3
@@ -21,7 +21,7 @@ $ldap['SRC'] = $_SESSION[APPCONFIG]->getServer(get_req
4
 $ldap['DST'] = $_SESSION[APPCONFIG]->getServer(get_request('server_id_dst'));
5
 
6
 # Error checking
7
-if (! trim($request['dnDST']))
8
+if (! trim((string) $request['dnDST']))
9
 	error(_('You left the destination DN blank.'),'error','index.php');
10
 
11
 if ($ldap['DST']->isReadOnly())
(-)b/net/phpldapadmin/files/patch-htdocs_download__binary__attr.php (+11 lines)
Added Link Here
1
--- htdocs/download_binary_attr.php.orig	2021-12-12 02:35:51 UTC
2
+++ htdocs/download_binary_attr.php
3
@@ -15,7 +15,7 @@ require './common.php';
4
 
5
 $request = array();
6
 $request['dn'] = get_request('dn','GET');
7
-$request['attr'] = strtolower(get_request('attr','GET',true));
8
+$request['attr'] = strtolower((string) get_request('attr','GET',true));
9
 $request['index'] = get_request('index','GET',false,0);
10
 $request['type'] = get_request('type','GET',false,'octet-stream');
11
 $request['filename'] = get_request('filename','GET',false,sprintf('%s:%s.bin',get_rdn($request['dn'],true),$request['attr']));
(-)b/net/phpldapadmin/files/patch-htdocs_export__form.php (+11 lines)
Added Link Here
1
--- htdocs/export_form.php.orig	2021-12-12 02:35:51 UTC
2
+++ htdocs/export_form.php
3
@@ -166,7 +166,7 @@ function get_line_end_format() {
4
  */
5
 function get_user_agent_string() {
6
 	if (isset($_SERVER['HTTP_USER_AGENT']))
7
-		return strtolower($_SERVER['HTTP_USER_AGENT']);
8
+		return strtolower((string) $_SERVER['HTTP_USER_AGENT']);
9
 	else
10
 		return '';
11
 }
(-)b/net/phpldapadmin/files/patch-htdocs_login.php (+11 lines)
Added Link Here
1
--- htdocs/login.php.orig	2021-12-12 02:35:51 UTC
2
+++ htdocs/login.php
3
@@ -22,7 +22,7 @@ if ($pass) {
4
     $user['password'] = get_request('login_pass');
5
     $user['password'] = html_entity_decode($user['password'], ENT_QUOTES);
6
 
7
-    if ($user['login'] && !strlen($user['password'])) {
8
+    if ($user['login'] && empty($user['password'])) {
9
         system_message(array(
10
             'title' => _('Authenticate to server'),
11
             'body'  => _('You left the password blank.'),
(-)b/net/phpldapadmin/files/patch-htdocs_login__form.php (+16 lines)
Added Link Here
1
--- htdocs/login_form.php.orig	2021-12-12 02:35:51 UTC
2
+++ htdocs/login_form.php
3
@@ -19,11 +19,11 @@ echo '<br />';
4
 $isHTTPS = false;
5
 
6
 # Check if the current connection is encrypted
7
-if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
8
+if (isset($_SERVER['HTTPS']) && strtolower((string) $_SERVER['HTTPS']) == 'on') {
9
         $isHTTPS = true;
10
 }
11
 # Check if a proxy server downstream does encryption for us
12
-elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && strtolower($_SERVER['HTTP_X_FORWARDED_SSL'])
13
+elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower((string) $_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && strtolower($_SERVER['HTTP_X_FORWARDED_SSL'])
14
 == 'on') {
15
         $isHTTPS = true;
16
 }
(-)b/net/phpldapadmin/files/patch-htdocs_monitor.php (+29 lines)
Added Link Here
1
--- htdocs/monitor.php.orig	2021-12-12 02:35:51 UTC
2
+++ htdocs/monitor.php
3
@@ -48,7 +48,7 @@ foreach (array(
4
 	if (isset($results[$dn]['description'])) {
5
 		$description = implode(' ',$results[$dn]['description']);
6
 
7
-		$description = preg_replace('/"/','\'',$description);
8
+		$description = preg_replace('/"/','\'',is_null($description)? "":$description);
9
 	} else {
10
 		$description = '';
11
 	}
12
@@ -103,7 +103,7 @@ foreach (array(
13
 				else
14
 					$sc = $results[$key][$attr];
15
 
16
-				if (strcasecmp('supportedcontrol',$attr) == 0)
17
+				if (strcasecmp('supportedcontrol',(string) $attr) == 0)
18
 					foreach ($sc as $control) {
19
 						$oidtotext = support_oid_to_text($control);
20
 
21
@@ -199,7 +199,7 @@ foreach (array(
22
 	) as $dn ) {
23
 
24
 	$description = implode(' ',$results[$dn]['description']);
25
-	$description = preg_replace('/"/','\'',$description);
26
+	$description = preg_replace('/"/','\'',is_null($description)? "":$description);
27
 
28
 	printf('<tr class="list_item"><td class="heading" rowspan="2"><acronym title="%s">%s</acronym></td></tr>',$description,$dn);
29
 	echo '<tr class="list_item"><td class="value">';
(-)b/net/phpldapadmin/files/patch-htdocs_purge__cache.php (+11 lines)
Added Link Here
1
--- htdocs/purge_cache.php.orig	2021-12-12 02:35:51 UTC
2
+++ htdocs/purge_cache.php
3
@@ -16,7 +16,7 @@ $purge_session_keys = array('app_initialized','backtra
4
 $size = 0;
5
 foreach ($purge_session_keys as $key)
6
 	if (isset($_SESSION[$key])) {
7
-		$size += strlen(serialize($_SESSION[$key]));
8
+		$size += strlen((string) serialize($_SESSION[$key]));
9
 		unset($_SESSION[$key]);
10
 	}
11
 
(-)b/net/phpldapadmin/files/patch-htdocs_schema.php (+165 lines)
Added Link Here
1
--- htdocs/schema.php.orig	2021-12-12 02:35:51 UTC
2
+++ htdocs/schema.php
3
@@ -25,7 +25,7 @@ $entry['value'] = get_request('viewvalue','GET');
4
 
5
 if (! is_null($entry['value'])) {
6
 	$entry['viewed'] = false;
7
-	$entry['value'] = strtolower($entry['value']);
8
+	$entry['value'] = strtolower((string) $entry['value']);
9
 }
10
 
11
 $schema_error_str = sprintf('%s <b>%s</b>.<br /><br /></div>%s<ul><li>%s</li><li>%s</li><li>%s</li><li>%s</li></ul>',
12
@@ -149,12 +149,12 @@ switch($entry['view']) {
13
 		echo '<br />';
14
 
15
 		foreach ($sattrs as $attr) {
16
-			if (isAjaxEnabled() || (is_null($entry['value']) || ! trim($entry['value']) || $entry['value']==$attr->getName())) {
17
-				if ((! is_null($entry['value']) && $entry['value']==$attr->getName()) || ! trim($entry['value']))
18
+			if (isAjaxEnabled() || (is_null($entry['value']) || ! trim((string) $entry['value']) || $entry['value']==$attr->getName())) {
19
+				if ((! is_null($entry['value']) && $entry['value']==$attr->getName()) || ! trim((string) $entry['value']))
20
 					$entry['viewed'] = true;
21
 
22
 				if (isAjaxEnabled() && $entry['value'])
23
-					printf('<div id="at%s" style="display: %s">',$attr->getName(),strcasecmp($entry['value'],$attr->getName()) ? 'none' : 'block');
24
+					printf('<div id="at%s" style="display: %s">',(string) $attr->getName(),strcasecmp((string) $entry['value'],(string) $attr->getName()) ? 'none' : 'block');
25
 				else
26
 					printf('<div id="at%s">',$attr->getName());
27
 
28
@@ -193,10 +193,10 @@ switch($entry['view']) {
29
 								printf('(%s)',_('none'));
30
 
31
 							else {
32
-								$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['attributes'],strtolower($attr->getSupAttribute())));
33
+								$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['attributes'],strtolower((string) $attr->getSupAttribute())));
34
 								if (isAjaxEnabled())
35
 									printf('<a href="cmd.php?%s" onclick="return ajSHOWSCHEMA(\'attributes\',\'at\',\'%s\');">%s</a>',
36
-										$href,strtolower($attr->getSupAttribute()),$attr->getSupAttribute());
37
+										$href,strtolower((string) $attr->getSupAttribute()),$attr->getSupAttribute());
38
 								else
39
 									printf('<a href="cmd.php?%s">%s</a>',$href,$attr->getSupAttribute());
40
 							}
41
@@ -287,10 +287,10 @@ switch($entry['view']) {
42
 
43
 							else
44
 								foreach ($attr->getAliases() as $alias) {
45
-									$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['attributes'],strtolower($alias)));
46
+									$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['attributes'],strtolower((string) $alias)));
47
 									if (isAjaxEnabled())
48
 										printf('<a href="cmd.php?%s" onclick="return ajSHOWSCHEMA(\'attributes\',\'at\',\'%s\');">%s</a>',
49
-											$href,strtolower($alias),$alias);
50
+											$href,strtolower((string) $alias),$alias);
51
 									else
52
 										printf('<a href="cmd.php?%s">%s</a>',$href,$alias);
53
 								}
54
@@ -306,10 +306,10 @@ switch($entry['view']) {
55
 
56
 							else
57
 								foreach ($attr->getUsedInObjectClasses() as $objectclass) {
58
-									$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower($objectclass)));
59
+									$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower((string) $objectclass)));
60
 									if (isAjaxEnabled())
61
 										printf('<a href="cmd.php?%s" onclick="return ajJUMP(\'%s\',\'%s\',\'%s\');">%s</a> ',
62
-											$href,$href,_('ObjectClasses'),strtolower($objectclass),$objectclass);
63
+											$href,$href,_('ObjectClasses'),strtolower((string) $objectclass),$objectclass);
64
 									else
65
 										printf('<a href="cmd.php?%s">%s</a> ',$href,$objectclass);
66
 								}
67
@@ -379,8 +379,8 @@ switch($entry['view']) {
68
 			$oid = $rule->getOID();
69
 			$desc = $rule->getName(false);
70
 
71
-			if (isAjaxEnabled() || (is_null($entry['value']) || ! trim($entry['value']) || $entry['value']==$rule->getName())) {
72
-				if ((! is_null($entry['value']) && $entry['value']==$rule->getName()) || ! trim($entry['value']))
73
+			if (isAjaxEnabled() || (is_null($entry['value']) || ! trim((string) $entry['value']) || $entry['value']==$rule->getName())) {
74
+				if ((! is_null($entry['value']) && $entry['value']==$rule->getName()) || ! trim((string) $entry['value']))
75
 					$entry['viewed'] = true;
76
 
77
 				if (null != $rule->getDescription())
78
@@ -391,7 +391,7 @@ switch($entry['view']) {
79
 
80
 				if (isAjaxEnabled() && $entry['value'])
81
 					printf('<tr class="%s" id="mr%s" style="display: %s">',$counter%2 ? 'odd' : 'even',$rule->getName(),
82
-						strcasecmp($entry['value'],$rule->getName()) ? 'none' : '');
83
+						strcasecmp((string) $entry['value'],(string) $rule->getName()) ? 'none' : '');
84
 				else
85
 					printf('<tr class="%s" id="mr%s">',$counter%2 ? 'odd' : 'even',$rule->getName());
86
 				printf('<td>%s</td>',$oid);
87
@@ -467,12 +467,12 @@ switch($entry['view']) {
88
 		echo '<br />';
89
 
90
 		foreach ($socs as $name => $oclass) {
91
-			if (isAjaxEnabled() || (is_null($entry['value']) || ! trim($entry['value']) || $entry['value']==$oclass->getName())) {
92
-				if ((! is_null($entry['value']) && $entry['value']==$oclass->getName()) || ! trim($entry['value']))
93
+			if (isAjaxEnabled() || (is_null($entry['value']) || ! trim((string) $entry['value']) || $entry['value']==$oclass->getName())) {
94
+				if ((! is_null($entry['value']) && $entry['value']==$oclass->getName()) || ! trim((string) $entry['value']))
95
 					$entry['viewed'] = true;
96
 
97
 				if (isAjaxEnabled() && $entry['value'])
98
-					printf('<div id="oc%s" style="display: %s">',$oclass->getName(),strcasecmp($entry['value'],$oclass->getName()) ? 'none' : '');
99
+					printf('<div id="oc%s" style="display: %s">',(string) $oclass->getName(),strcasecmp((string) $entry['value'],(string) $oclass->getName()) ? 'none' : '');
100
 				else
101
 					printf('<div id="oc%s">',$oclass->getName());
102
 
103
@@ -494,10 +494,10 @@ switch($entry['view']) {
104
 
105
 				else
106
 					foreach ($oclass->getSupClasses() as $i => $object_class) {
107
-						$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower($object_class)));
108
+						$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower((string) $object_class)));
109
 						if (isAjaxEnabled())
110
 							printf('<a href="cmd.php?%s" onclick="return ajSHOWSCHEMA(\'objectclasses\',\'oc\',\'%s\');">%s</a>',
111
-								$href,strtolower($object_class),$object_class);
112
+								$href,strtolower((string) $object_class),$object_class);
113
 						else
114
 							printf('<a href="cmd.php?%s&viewvalue=%s" title="%s">%s</a>',
115
 								$href,$object_class,_('Jump to this objectClass definition'),$object_class);
116
@@ -508,7 +508,7 @@ switch($entry['view']) {
117
 				echo '</b></td></tr>';
118
 
119
 				printf('<tr class="odd"><td colspan="4">%s: <b>',_('Parent to'));
120
-				if (strcasecmp($oclass->getName(),'top') == 0) {
121
+				if (strcasecmp((string) $oclass->getName(),'top') == 0) {
122
 					$href = htmlspecialchars($entry['href']['objectclasses']);
123
 					if (isAjaxEnabled())
124
 						printf('<a href="cmd.php?%s" onclick="return ajSHOWSCHEMA(\'objectclasses\',\'oc\',\'\');">all</a>',
125
@@ -521,10 +521,10 @@ switch($entry['view']) {
126
 
127
 				else
128
 					foreach ($oclass->getChildObjectClasses() as $i => $object_class) {
129
-						$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower($object_class)));
130
+						$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower((string) $object_class)));
131
 						if (isAjaxEnabled())
132
 							printf('<a href="cmd.php?%s" title="%s" onclick="return ajSHOWSCHEMA(\'objectclasses\',\'oc\',\'%s\');">%s</a>',
133
-								$href,_('Jump to this objectClass definition'),strtolower($object_class),$object_class);
134
+								$href,_('Jump to this objectClass definition'),strtolower((string) $object_class),$object_class);
135
 						else
136
 							printf('<a href="cmd.php?%s" title="%s">%s</a>',$href,_('Jump to this objectClass definition'),$object_class);
137
 
138
@@ -553,11 +553,11 @@ switch($entry['view']) {
139
 
140
 						if ($attr->getSource() != $oclass->getName(false)) {
141
 							echo '<br />';
142
-							$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower($attr->getSource())));
143
+							$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower((string) $attr->getSource())));
144
 							printf('<small>(%s ',_('Inherited from'));
145
 							if (isAjaxEnabled())
146
 								printf('<a href="cmd.php?%s" title="%s" onclick="return ajSHOWSCHEMA(\'objectclasses\',\'oc\',\'%s\');">%s</a>',
147
-									$href,_('Jump to this objectClass definition'),strtolower($attr->getSource()),$attr->getSource());
148
+									$href,_('Jump to this objectClass definition'),strtolower((string) $attr->getSource()),$attr->getSource());
149
 							else
150
 								printf('<a href="cmd.php?%s">%s</a>',$href,$attr->getSource());
151
 							echo ')</small>';
152
@@ -586,11 +586,11 @@ switch($entry['view']) {
153
 
154
 						if ($attr->getSource() != $oclass->getName(false)) {
155
 							echo '<br />';
156
-							$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower($attr->getSource())));
157
+							$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower((string) $attr->getSource())));
158
 							printf('<small>(%s ',_('Inherited from'));
159
 							if (isAjaxEnabled())
160
 								printf('<a href="cmd.php?%s" title="%s" onclick="return ajSHOWSCHEMA(\'objectclasses\',\'oc\',\'%s\');">%s</a>',
161
-									$href,_('Jump to this objectClass definition'),strtolower($attr->getSource()),$attr->getSource());
162
+									$href,_('Jump to this objectClass definition'),strtolower((string) $attr->getSource()),$attr->getSource());
163
 							else
164
 								printf('<a href="cmd.php?%s">%s</a>',$href,$attr->getSource());
165
 							echo ')</small>';
(-)b/net/phpldapadmin/files/patch-htdocs_server__info.php (+20 lines)
Added Link Here
1
--- htdocs/server_info.php.orig	2021-12-12 02:35:51 UTC
2
+++ htdocs/server_info.php
3
@@ -60,7 +60,7 @@ foreach ($attrs as $key => $values) {
4
 						printf('<td>%s</td>',$oidtext['title']);
5
 
6
 				else
7
-					if (strlen($value) > 0)
8
+					if (strlen((string) $value) > 0)
9
 						printf('<td><small>%s</small></td>',$value);
10
 
11
 			} else {
12
@@ -69,7 +69,7 @@ foreach ($attrs as $key => $values) {
13
 
14
 			print '</tr>';
15
 
16
-			if (isset($oidtext['desc']) && trim($oidtext['desc']))
17
+			if (isset($oidtext['desc']) && trim((string) $oidtext['desc']))
18
 				printf('<tr><td><small>%s</small></td></tr>',$oidtext['desc']);
19
 			else
20
 				echo '<tr><td>&nbsp;</td></tr>';
(-)b/net/phpldapadmin/files/patch-htdocs_view__jpeg__photo.php (+11 lines)
Added Link Here
1
--- htdocs/view_jpeg_photo.php.orig	2021-12-12 02:35:51 UTC
2
+++ htdocs/view_jpeg_photo.php
3
@@ -15,7 +15,7 @@ require './common.php';
4
 
5
 $request = array();
6
 $request['dn'] = get_request('dn','GET');
7
-$request['attr'] = strtolower(get_request('attr','GET',false,'jpegphoto'));
8
+$request['attr'] = strtolower((string) get_request('attr','GET',false,'jpegphoto'));
9
 $request['index'] = get_request('index','GET',false,0);
10
 $request['type'] = get_request('type','GET',false,'image/jpeg');
11
 $request['filename'] = get_request('filename','GET',false,sprintf('%s.jpg',get_rdn($request['dn'],true)));
(-)b/net/phpldapadmin/files/patch-lib_AJAXTree.php (+47 lines)
Added Link Here
1
--- lib/AJAXTree.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/AJAXTree.php
3
@@ -31,7 +31,7 @@ class AJAXTree extends HTMLTree {
4
 		# Level pre-treatment
5
 		$code = '';
6
 		if (is_string($level)) {
7
-			for ($i=0; $i<strlen($level); $i++) {
8
+			for ($i=0; $i<strlen((string) $level); $i++) {
9
 				if ($level[$i] == '0')
10
 					$code .= '0';
11
 				elseif ($level[$i] == '1')
12
@@ -41,7 +41,7 @@ class AJAXTree extends HTMLTree {
13
 		} elseif ($level > 0)
14
 			$code = '0' * $level;
15
 
16
-		$level = strlen($code);
17
+		$level = strlen((string) $code);
18
 
19
 		# Get entry to display as node
20
 		$entry = $this->getEntry($item);
21
@@ -189,7 +189,7 @@ class AJAXTree extends HTMLTree {
22
 
23
 		$indent = '';
24
 
25
-		for ($i=0; $i<strlen($code); $i++) {
26
+		for ($i=0; $i<strlen((string) $code); $i++) {
27
 			switch ($code[$i]) {
28
 				case '0':
29
 					$indent .= sprintf('<img src="%s/tree_space.png" alt="  " class="imgs" style="border: 0px; vertical-align:text-top;" />',IMGDIR);
30
@@ -223,7 +223,7 @@ class AJAXTree extends HTMLTree {
31
 		if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
32
 			debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs);
33
 
34
-		if (strlen($level) == 0)
35
+		if (strlen((string) $level) == 0)
36
 			return '';
37
 
38
 		$server = $this->getServer();
39
@@ -243,7 +243,7 @@ class AJAXTree extends HTMLTree {
40
 		if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
41
 			debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs);
42
 
43
-		if (strlen($level) == 0)
44
+		if (strlen((string) $level) == 0)
45
 			return '';
46
 
47
 		$server = $this->getServer();
(-)b/net/phpldapadmin/files/patch-lib_Attribute.php (-9 / +57 lines)
Lines 1-11 Link Here
1
--- lib/Attribute.php.orig	2021-12-12 02:35:51 UTC
1
--- lib/Attribute.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/Attribute.php
2
+++ lib/Attribute.php
3
@@ -12,7 +12,7 @@
3
@@ -133,9 +133,9 @@ class PLAAttribute {
4
  * @package phpLDAPadmin
4
 			debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs,$this->name);
5
  * @subpackage Templates
5
 
6
  */
6
 		if ($real)
7
-class Attribute {
7
-			return $lower ? strtolower($this->name) : $this->name;
8
+class PLAAttribute {
8
+			return $lower ? strtolower((string) $this->name) : $this->name;
9
 	# Attribute Name
9
 		else
10
 	public $name;
10
-			return $lower ? strtolower($this->real_attr_name()) : $this->real_attr_name();
11
 	# Source of this attribute definition
11
+			return $lower ? strtolower((string) $this->real_attr_name()) : $this->real_attr_name();
12
 	}
13
 
14
 	public function getValues() {
15
@@ -389,7 +389,7 @@ class PLAAttribute {
16
 		if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
17
 			debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs);
18
 
19
-		$this->type = strtolower($type);
20
+		$this->type = strtolower((string) $type);
21
 	}
22
 
23
 	public function getType() {
24
@@ -403,7 +403,7 @@ class PLAAttribute {
25
 		if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
26
 			debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs);
27
 
28
-		$this->ldaptype = strtolower($type);
29
+		$this->ldaptype = strtolower((string) $type);
30
 	}
31
 
32
 	public function getLDAPtype() {
33
@@ -671,7 +671,7 @@ class PLAAttribute {
34
 
35
 		# Store our Aliases
36
 		foreach ($sattr->getAliases() as $alias)
37
-			array_push($this->aliases,strtolower($alias));
38
+			array_push($this->aliases,strtolower((string) $alias));
39
 
40
 		if ($sattr->getIsSingleValue())
41
 			$this->setMaxValueCount(1);
42
@@ -840,7 +840,7 @@ class PLAAttribute {
43
 								'type'=>'warn'));
44
 				}
45
 
46
-		elseif (is_string($values) && (strlen($values) > 0))
47
+		elseif (is_string($values) && (strlen((string) $values) > 0))
48
 			$this->values = array($values);
49
 	}
50
 
51
@@ -877,7 +877,7 @@ class PLAAttribute {
52
 		if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
53
 			debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->name);
54
 
55
-		return preg_replace('/;.*$/U','',$this->name);
56
+		return preg_replace('/;.*$/U','',is_null($this->name)? "":$this->name);
57
 	}
58
 
59
 	/**
(-)b/net/phpldapadmin/files/patch-lib_AttributeFactory.php (-6 / +45 lines)
Lines 1-11 Link Here
1
--- lib/AttributeFactory.php.orig	2021-12-12 02:35:51 UTC
1
--- lib/AttributeFactory.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/AttributeFactory.php
2
+++ lib/AttributeFactory.php
3
@@ -133,7 +133,7 @@ class AttributeFactory {
3
@@ -83,7 +83,7 @@ class AttributeFactory {
4
 		if (isset($values['type']))
5
 			switch ($values['type']) {
6
 				case 'password':
7
-					if (! strcasecmp($name,'sambaLMPassword') || ! strcasecmp($name,'sambaNTPassword'))
8
+					if (! strcasecmp((string) $name,'sambaLMPassword') || ! strcasecmp((string) $name,'sambaNTPassword'))
9
 						return $this->newSambaPasswordAttribute($name,$values,$server_id,$source);
10
 					else
11
 						return $this->newPasswordAttribute($name,$values,$server_id,$source);
12
@@ -96,7 +96,7 @@ class AttributeFactory {
13
 					return $this->newMultiLineAttribute($name,$values,$server_id,$source);
14
 			}
15
 
16
-		if (! strcasecmp($name,'objectClass')) {
17
+		if (! strcasecmp((string) $name,'objectClass')) {
18
 			return $this->newObjectClassAttribute($name,$values,$server_id,$source);
19
 
20
 		} elseif ($app['server']->isJpegPhoto($name) || in_array($name,$app['server']->getValue('server','jpeg_attributes'))) {
21
@@ -105,16 +105,16 @@ class AttributeFactory {
22
 		} elseif ($app['server']->isAttrBinary($name)) {
23
 			return $this->newBinaryAttribute($name,$values,$server_id,$source);
24
 
25
-		} elseif (! strcasecmp($name,'userPassword')) {
26
+		} elseif (! strcasecmp((string) $name,'userPassword')) {
27
 			return $this->newPasswordAttribute($name,$values,$server_id,$source);
28
 
29
-		} elseif (! strcasecmp($name,'sambaLMPassword') || ! strcasecmp($name,'sambaNTPassword')) {
30
+		} elseif (! strcasecmp((string) $name,'sambaLMPassword') || ! strcasecmp((string) $name,'sambaNTPassword')) {
31
 			return $this->newSambaPasswordAttribute($name,$values,$server_id,$source);
32
 
33
-		} elseif (in_array(strtolower($name),array_keys(array_change_key_case($_SESSION[APPCONFIG]->getValue('appearance','date_attrs'))))) {
34
+		} elseif (in_array(strtolower((string) $name),array_keys(array_change_key_case($_SESSION[APPCONFIG]->getValue('appearance','date_attrs'))))) {
35
 			return $this->newDateAttribute($name,$values,$server_id,$source);
36
 
37
-		} elseif (in_array(strtolower($name),array('shadowlastchange','shadowmin','shadowmax','shadowexpire','shadowwarning','shadowinactive'))) {
38
+		} elseif (in_array(strtolower((string) $name),array('shadowlastchange','shadowmin','shadowmax','shadowexpire','shadowwarning','shadowinactive'))) {
39
 			return $this->newShadowAttribute($name,$values,$server_id,$source);
40
 
41
 		} elseif ($app['server']->isAttrBoolean($name)) {
42
@@ -129,7 +129,7 @@ class AttributeFactory {
43
 		} elseif ($app['server']->isMultiLineAttr($name)) {
44
 			return $this->newMultiLineAttribute($name,$values,$server_id,$source);
45
 
46
-		} elseif (! strcasecmp($name,'gidNumber')) {
47
+		} elseif (! strcasecmp((string) $name,'gidNumber')) {
4
 			return $this->newGidAttribute($name,$values,$server_id,$source);
48
 			return $this->newGidAttribute($name,$values,$server_id,$source);
5
 
49
 
6
 		} else {
50
 		} else {
7
-			return new Attribute($name,$values,$server_id,$source);
8
+			return new PLAAttribute($name,$values,$server_id,$source);
9
 		}
10
 	}
11
 
(-)b/net/phpldapadmin/files/patch-lib_HTMLTree.php (+32 lines)
Added Link Here
1
--- lib/HTMLTree.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/HTMLTree.php
3
@@ -168,9 +168,10 @@ class HTMLTree extends Tree {
4
 		printf('<td class="name" colspan="%s">',$this->getDepth()+3-1);
5
 		printf('%s',$server->getName());
6
 
7
+		//		strftime('%H:%M',$server->inactivityTime()));
8
 		if (! is_null($server->inactivityTime())) {
9
 			$m = sprintf(_('Inactivity will log you off at %s'),
10
-				strftime('%H:%M',$server->inactivityTime()));
11
+				date('H:i',$server->inactivityTime()));
12
 			printf(' <img width="14" height="14" src="%s/timeout.png" title="%s" alt="%s"/>',IMGDIR,$m,'Timeout');
13
 		}
14
 		echo '</td></tr>';
15
@@ -361,7 +362,7 @@ class HTMLTree extends Tree {
16
 			$logged_in_dn_array = array();
17
 
18
 		} else {
19
-			$logged_in_branch = preg_replace('/,'.$server->getContainerTop($logged_in_dn).'$/','',$logged_in_dn);
20
+			$logged_in_branch = preg_replace('/,'.$server->getContainerTop($logged_in_dn).'$/','',is_null($logged_in_dn)? "":$logged_in_dn);
21
 			$logged_in_dn_array = pla_explode_dn($logged_in_branch);
22
 		}
23
 
24
@@ -375,7 +376,7 @@ class HTMLTree extends Tree {
25
 		if (! is_array($logged_in_dn_array))
26
 			$logged_in_dn_array = array($logged_in_dn);
27
 
28
-		if (trim($logged_in_dn)) {
29
+		if (trim((string) $logged_in_dn)) {
30
 			if ($server->dnExists($logged_in_dn))
31
 				foreach ($logged_in_dn_array as $rdn_piece) {
32
 					$href = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s',$server->getIndex(),rawurlencode($rdn));
(-)b/net/phpldapadmin/files/patch-lib_PageRender.php (-23 / +112 lines)
Lines 1-31 Link Here
1
--- lib/PageRender.php.orig	2021-12-12 02:35:51 UTC
1
--- lib/PageRender.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/PageRender.php
2
+++ lib/PageRender.php
3
@@ -827,7 +827,7 @@ class PageRender extends Visitor {
3
@@ -182,7 +182,7 @@ class PageRender extends Visitor {
4
 		if (! $attribute->getOldValue($i))
4
 						$attribute2 = $this->template->getAttribute($joinattr);
5
 			return;
6
 
5
 
7
-		draw_jpeg_photo($this->getServer(),$this->template->getDN(),$attribute->getName(),$i,false,false);
6
 						if (! $attribute2) {
8
+		draw_jpeg_photo($this->getServer(),$this->template->getDN(),$i,$attribute->getName(),false,false);
7
-							if (($pv = get_request(strtolower($joinattr),'REQUEST')) && isset($pv[$attribute->getName()][$i])) {
9
 	}
8
+							if (($pv = get_request(strtolower((string) $joinattr),'REQUEST')) && isset($pv[$attribute->getName()][$i])) {
9
 								array_push($values,$pv[$attribute->getName()][$i]);
10
 
10
 
11
 	/**
11
 								if (! $pv[$attribute->getName()][$i])
12
@@ -844,16 +844,16 @@ class PageRender extends Visitor {
12
@@ -242,7 +242,7 @@ class PageRender extends Visitor {
13
 		# If the attribute is modified, the new value needs to be stored in a session variable for the draw_jpeg_photo callback.
13
 					return;
14
 		if ($attribute->hasBeenModified()) {
14
 
15
 			$_SESSION['tmp'][$attribute->getName()][$i] = $attribute->getValue($i);
15
 				# Get the attribute.
16
-			draw_jpeg_photo(null,$this->template->getDN(),$attribute->getName(),$i,false,false);
16
-				if (preg_match_all('/%(\w+)(\|.+)?(\/[lU])?%/U',strtolower($args[1]),$matchall)) {
17
+			draw_jpeg_photo(null,$this->template->getDN(),$i,$attribute->getName(),false,false);
17
+				if (preg_match_all('/%(\w+)(\|.+)?(\/[lU])?%/U',strtolower((string) $args[1]),$matchall)) {
18
 		} else
18
 					if (count($matchall[1]) != 1)
19
-			draw_jpeg_photo($this->getServer(),$this->template->getDN(),$attribute->getName(),$i,false,false);
19
 						system_message(array(
20
+			draw_jpeg_photo($this->getServer(),$this->template->getDN(),$i,$attribute->getName(),false,false);
20
 							'title'=>_('Invalid value count for PasswordEncrypt'),
21
 	}
21
@@ -255,11 +255,11 @@ class PageRender extends Visitor {
22
 				} else
23
 					$passwordvalue = $args[1];
24
 
25
-				if (! trim($passwordvalue) || in_array($passwordvalue,$attribute->getOldValues()))
26
+				if (! trim((string) $passwordvalue) || in_array($passwordvalue,$attribute->getOldValues()))
27
 					return;
28
 
29
 				# Get the encoding
30
-				if ($passwordattr && preg_match_all('/%(\w+)(\|.+)?(\/[lU])?%/U',strtolower($args[0]),$matchall)) {
31
+				if ($passwordattr && preg_match_all('/%(\w+)(\|.+)?(\/[lU])?%/U',strtolower((string) $args[0]),$matchall)) {
32
 					if (count($matchall[1]) != 1)
33
 						system_message(array(
34
 							'title'=>_('Invalid value count for PasswordEncrypt'),
35
@@ -271,7 +271,7 @@ class PageRender extends Visitor {
36
 				} else
37
 					$enc = $args[0];
38
 
39
-				$enc = strtolower($enc);
40
+				$enc = strtolower((string) $enc);
41
 
42
 				switch ($enc) {
43
 					case 'lm':
44
@@ -403,7 +403,7 @@ class PageRender extends Visitor {
45
 			$alias_note = $this->get($note,$attribute);
46
 
47
 			if ($alias_note) {
48
-				if (trim($attr_note))
49
+				if (trim((string) $attr_note))
50
 					$attr_note .= ', ';
51
 
52
 				$attr_note .= $alias_note;
53
@@ -423,7 +423,7 @@ class PageRender extends Visitor {
54
 		# Is there a user-friendly translation available for this attribute?
55
 		$friendly_name = $attribute->getFriendlyName();
22
 
56
 
23
 	protected function drawFormReadOnlyValueJpegAttribute($attribute,$i) {
57
-		if (strtolower($friendly_name) != $attribute->getName())
24
 		$this->draw('HiddenValue',$attribute,$i);
58
+		if (strtolower((string) $friendly_name) != $attribute->getName())
25
 		$_SESSION['tmp'][$attribute->getName()][$i] = $attribute->getValue($i);
59
 			return sprintf('<acronym title="%s: \'%s\' %s \'%s\'">%s</acronym>',
60
 				_('Note'),$friendly_name,_('is an alias for'),$attribute->getName(false),_('alias'));
61
 		else
62
@@ -954,7 +954,7 @@ class PageRender extends Visitor {
63
 		$server = $this->getServer();
64
 		$val = $attribute->getValue($i);
26
 
65
 
27
-		draw_jpeg_photo(null,$this->template->getDN(),$attribute->getName(),$i,false,false);
66
-		if (trim($val))
28
+		draw_jpeg_photo(null,$this->template->getDN(),$i,$attribute->getName(),false,false);
67
+		if (trim((string) $val))
68
 			$enc_type = get_enc_type($val);
69
 		else
70
 			$enc_type = $server->getValue('appearance','pla_password_hash');
71
@@ -966,7 +966,7 @@ class PageRender extends Visitor {
72
 			htmlspecialchars($attribute->getName()),$i,htmlspecialchars($attribute->getName()),
73
 			$i,htmlspecialchars($val),($attribute->getSize() > 0) ? 'size="'.$attribute->getSize().'"' : '');
74
 
75
-		if (trim($val))
76
+		if (trim((string) $val))
77
 			$this->draw('CheckLink',$attribute,'new_values_'.htmlspecialchars($attribute->getName()).'_'.$i);
29
 	}
78
 	}
30
 
79
 
31
 	protected function drawFormReadOnlyValueMultiLineAttribute($attribute,$i) {
80
@@ -979,7 +979,7 @@ class PageRender extends Visitor {
81
 		$enc_type = get_enc_type($val);
82
 
83
 		# Set the default hashing type if the password is blank (must be newly created)
84
-		if (trim($val))
85
+		if (trim((string) $val))
86
 			$enc_type = get_enc_type($val);
87
 		else
88
 			$enc_type = $server->getValue('appearance','pla_password_hash');
89
@@ -1125,7 +1125,7 @@ class PageRender extends Visitor {
90
 
91
 			foreach ($attribute->getSelection() as $value => $description) {
92
 				printf('<option value="%s" %s>%s</option>',$value,
93
-					((strcasecmp($value,$val) == 0) && $found = true) ? 'selected="selected"' : '',$description);
94
+					((strcasecmp((string) $value,(string) $val) == 0) && (string) $found = true) ? 'selected="selected"' : '',(string) $description);
95
 
96
 				if ($value == '')
97
 					$empty_value = true;
98
@@ -1140,7 +1140,7 @@ class PageRender extends Visitor {
99
 				echo "\n";
100
 			}
101
 
102
-			if ((strlen($val) > 0) && ! $empty_value && $this->template->getDN()) {
103
+			if ((strlen((string) $val) > 0) && ! $empty_value && $this->template->getDN()) {
104
 				printf('<option value="">(%s)</option>',_('none, remove value'));
105
 				echo "\n";
106
 			}
107
@@ -1212,11 +1212,11 @@ class PageRender extends Visitor {
108
 		$today = date('U');
109
 
110
 		echo '<br/><small>';
111
-		if (($today < $shadow_date) && in_array(strtolower($attribute->getName()),$shadow_before_today_attrs))
112
+		if (($today < $shadow_date) && in_array(strtolower((string) $attribute->getName()),$shadow_before_today_attrs))
113
 			printf('<span style="color:red">(%s)</span>',
114
 				strftime($_SESSION[APPCONFIG]->getValue('appearance','date'),$shadow_date));
115
 
116
-		elseif (($today > $shadow_date) && in_array(strtolower($attribute->getName()),$shadow_after_today_attrs))
117
+		elseif (($today > $shadow_date) && in_array(strtolower((string) $attribute->getName()),$shadow_after_today_attrs))
118
 			printf('<span style="color:red">(%s)</span>',
119
 				strftime($_SESSION[APPCONFIG]->getValue('appearance','date'),$shadow_date));
120
 
(-)b/net/phpldapadmin/files/patch-lib_Query.php (+68 lines)
Added Link Here
1
--- lib/Query.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/Query.php
3
@@ -87,9 +87,9 @@ class Query extends xmlTemplate {
4
 					if (in_array($xml_key,$storelower))
5
 						if (is_array($xml_value))
6
 							foreach ($xml_value as $index => $value)
7
-								$xml_value[$index] = strtolower($value);
8
+								$xml_value[$index] = strtolower((string) $value);
9
 						else
10
-							$xml_value = strtolower($xml_value);
11
+							$xml_value = strtolower((string) $xml_value);
12
 
13
 					# Items that must be stored as arrays
14
 					if (in_array($xml_key,$storearray) && ! is_array($xml_value))
15
@@ -109,7 +109,7 @@ class Query extends xmlTemplate {
16
 		# Check we have some manditory items.
17
 		foreach (array() as $key) {
18
 			if (! isset($this->$key)
19
-				|| (! is_array($this->$key) && ! trim($this->$key))) {
20
+				|| (! is_array($this->$key) && ! trim((string) $this->$key))) {
21
 
22
 				$this->setInvalid(sprintf(_('Missing %s in the XML file.'),$key));
23
 				break;
24
@@ -138,7 +138,7 @@ class Query extends xmlTemplate {
25
 			$query['scope'] = get_request('scope','REQUEST',false,'sub');
26
 			$attrs = get_request('display_attrs','REQUEST');
27
 
28
-			$attrs = preg_replace('/\s+/','',$attrs);
29
+			$attrs = preg_replace('/\s+/','',is_null($attrs)? "":$attrs);
30
 			if ($attrs)
31
 				$query['attrs'] = explode(',',$attrs);
32
 			else
33
@@ -198,9 +198,9 @@ class Query extends xmlTemplate {
34
 	public function getDNEncode($url=true) {
35
 		// @todo Be nice to do all this in 1 location
36
 		if ($url)
37
-			return urlencode(preg_replace('/%([0-9a-fA-F]+)/',"%25\\1",$this->dn));
38
+			return urlencode(preg_replace('/%([0-9a-fA-F]+)/',"%25\\1",is_null($this->dn)? "":$this->dn));
39
 		else
40
-			return preg_replace('/%([0-9a-fA-F]+)/',"%25\\1",$this->dn);
41
+			return preg_replace('/%([0-9a-fA-F]+)/',"%25\\1",is_null($this->dn)? "":$this->dn);
42
 	}
43
 
44
 	public function getAttrSortOrder() {
45
@@ -216,9 +216,9 @@ class Query extends xmlTemplate {
46
 				array_push($result,$attribute->getName());
47
 
48
 		} else {
49
-			$display = preg_replace('/,\s+/',',',get_request('orderby','REQUEST',false,'dn'));
50
+			$display = preg_replace('/,\s+/',',',get_request('orderby','REQUEST',false,is_null('dn')? "":'dn'));
51
 
52
-			if (trim($display))
53
+			if (trim((string) $display))
54
 				$result = explode(',',$display);
55
 		}
56
 
57
@@ -238,9 +238,9 @@ class Query extends xmlTemplate {
58
 				array_push($result,$attribute->getName());
59
 
60
 		} else {
61
-			$display = preg_replace('/,\s+/',',',get_request('display_attrs','REQUEST',false,''));
62
+			$display = preg_replace('/,\s+/',',',get_request('display_attrs','REQUEST',false,is_null('')? "":''));
63
 
64
-			if (trim($display))
65
+			if (trim((string) $display))
66
 				$result = explode(',',$display);
67
 		}
68
 
(-)b/net/phpldapadmin/files/patch-lib_QueryRender.php (+38 lines)
Added Link Here
1
--- lib/QueryRender.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/QueryRender.php
3
@@ -280,7 +280,7 @@ class QueryRender extends PageRender {
4
 
5
 						# Iterate over each attribute for this entry
6
 						foreach (explode(',',$ado) as $attr) {
7
-							$attr = strtolower($attr);
8
+							$attr = strtolower((string) $attr);
9
 
10
 							# Ignore DN, we've already displayed it.
11
 							if ($attr == 'dn')
12
@@ -379,7 +379,7 @@ class QueryRender extends PageRender {
13
 
14
 							# Special case for DNs
15
 							if ($attr == 'dn') {
16
-								$dn_display = strlen($dndetails['dn']) > 40
17
+								$dn_display = strlen((string) $dndetails['dn']) > 40
18
 									? sprintf('<acronym title="%s">%s...</acronym>',htmlspecialchars($dndetails['dn']),htmlspecialchars(substr($dndetails['dn'],0,40)))
19
 									: htmlspecialchars($dndetails['dn']);
20
 
21
@@ -461,7 +461,7 @@ class QueryRender extends PageRender {
22
 		$results = array();
23
 
24
 		foreach (explode(',',$this->template->getAttrDisplayOrder()) as $attr)
25
-			$results[strtolower($attr)] = $attribute_factory->newAttribute($attr,array('values'=>array()),$this->getServerID());
26
+			$results[strtolower((string) $attr)] = $attribute_factory->newAttribute($attr,array('values'=>array()),$this->getServerID());
27
 
28
 		return $results;
29
 	}
30
@@ -470,7 +470,7 @@ class QueryRender extends PageRender {
31
 		if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
32
 			debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs);
33
 
34
-		return preg_replace('/=/','.',base64_encode($dn));
35
+		return preg_replace('/=/','.',is_null(base64_encode($dn)? "":base64_encode($dn));
36
 	}
37
 
38
 	private function drawBaseTabs() {
(-)b/net/phpldapadmin/files/patch-lib_Template.php (+248 lines)
Added Link Here
1
--- lib/Template.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/Template.php
3
@@ -100,7 +100,7 @@ class Template extends xmlTemplate {
4
 							foreach ($xmldata['template'][$xml_key]['objectclass'] as $index => $details) {
5
 
6
 								# XML files with only 1 objectClass dont have a numeric index.
7
-								$soc = $server->getSchemaObjectClass(strtolower($details));
8
+								$soc = $server->getSchemaObjectClass(strtolower((string) $details));
9
 
10
 								# If we havent recorded this objectclass already, do so now.
11
 								if (is_object($soc) && ! in_array($soc->getName(),$objectclasses))
12
@@ -115,7 +115,7 @@ class Template extends xmlTemplate {
13
 
14
 						} else {
15
 							# XML files with only 1 objectClass dont have a numeric index.
16
-							$soc = $server->getSchemaObjectClass(strtolower($xmldata['template'][$xml_key]['objectclass']));
17
+							$soc = $server->getSchemaObjectClass(strtolower((string) $xmldata['template'][$xml_key]['objectclass']));
18
 
19
 							# If we havent recorded this objectclass already, do so now.
20
 							if (is_object($soc) && ! in_array($soc->getName(),$objectclasses))
21
@@ -160,9 +160,9 @@ class Template extends xmlTemplate {
22
 					if (in_array($xml_key,$storelower))
23
 						if (is_array($xml_value))
24
 							foreach ($xml_value as $index => $value)
25
-								$xml_value[$index] = strtolower($value);
26
+								$xml_value[$index] = strtolower((string) $value);
27
 						else
28
-							$xml_value = strtolower($xml_value);
29
+							$xml_value = strtolower((string) $xml_value);
30
 
31
 					# Items that must be stored as arrays
32
 					if (in_array($xml_key,$storearray) && ! is_array($xml_value))
33
@@ -198,7 +198,7 @@ class Template extends xmlTemplate {
34
 		# Check we have some manditory items.
35
 		foreach (array('rdn','structural_oclass','visible') as $key) {
36
 			if (! isset($this->$key)
37
-				|| (! is_array($this->$key) && ! trim($this->$key))) {
38
+				|| (! is_array($this->$key) && ! trim((string) $this->$key))) {
39
 
40
 				$this->setInvalid(sprintf(_('Missing %s in the XML file.'),$key));
41
 				break;
42
@@ -272,7 +272,7 @@ class Template extends xmlTemplate {
43
 					'body'=>sprintf('DN (%s) didnt exist in LDAP?',$this->dn),
44
 					'type'=>'info'));
45
 
46
-			$rdnarray = rdn_explode(strtolower(get_rdn(dn_escape($this->dn))));
47
+			$rdnarray = rdn_explode(strtolower((string) get_rdn(dn_escape($this->dn))));
48
 
49
 			$counter = 1;
50
 			foreach ($server->getDNAttrValues($this->dn,null,LDAP_DEREF_NEVER,array_merge(array('*'),$server->getValue('server','custom_attrs')),$nocache) as $attr => $values) {
51
@@ -298,7 +298,7 @@ class Template extends xmlTemplate {
52
 				# Work out the RDN attributes
53
 				foreach ($attribute->getValues() as $index => $value)
54
 					if (in_array(sprintf('%s=%s',
55
-						$attribute->getName(),strtolower($attribute->getValue($index))),$rdnarray))
56
+						$attribute->getName(),strtolower((string) $attribute->getValue($index))),$rdnarray))
57
 						$attribute->setRDN($counter++);
58
 
59
 				if ($makeVisible)
60
@@ -355,7 +355,7 @@ class Template extends xmlTemplate {
61
 
62
 					# Prune out entries with a blank value.
63
 					foreach ($values as $index => $value)
64
-						if (! strlen(trim($value)))
65
+						if (! strlen((string) trim((string) $value)))
66
 							unset($values[$index]);
67
 
68
 					$attribute = $this->getAttribute($attr);
69
@@ -603,7 +603,7 @@ class Template extends xmlTemplate {
70
 			foreach ($rdnarray as $index => $rdnattr) {
71
 				list($attr,$value) = explode('=',$rdnattr);
72
 
73
-				if (strtolower($attr) == $attribute->getName()) {
74
+				if (strtolower((string) $attr) == $attribute->getName()) {
75
 					$attribute->setRDN($counter++);
76
 					unset($rdnarray[$index]);
77
 				}
78
@@ -637,9 +637,9 @@ class Template extends xmlTemplate {
79
 	public function getDNEncode($url=true) {
80
 		// @todo Be nice to do all this in 1 location
81
 		if ($url)
82
-			return urlencode(preg_replace('/%([0-9a-fA-F]+)/',"%25\\1",$this->getDN()));
83
+			return urlencode(preg_replace('/%([0-9a-fA-F]+)/',"%25\\1",is_null($this->getDN())? "":$this->getDN()));
84
 		else
85
-			return preg_replace('/%([0-9a-fA-F]+)/',"%25\\1",$this->getDN());
86
+			return preg_replace('/%([0-9a-fA-F]+)/',"%25\\1",is_null($this->getDN())? "":$this->getDN());
87
 	}
88
 
89
 	/**
90
@@ -676,9 +676,9 @@ class Template extends xmlTemplate {
91
 	public function getContainerEncode($url=true) {
92
 		// @todo Be nice to do all this in 1 location
93
 		if ($url)
94
-			return urlencode(preg_replace('/%([0-9a-fA-F]+)/',"%25\\1",$this->container));
95
+			return urlencode(preg_replace('/%([0-9a-fA-F]+)/',"%25\\1",is_null($this->container)? "":$this->container));
96
 		else
97
-			return preg_replace('/%([0-9a-fA-F]+)/',"%25\\1",$this->container);
98
+			return preg_replace('/%([0-9a-fA-F]+)/',"%25\\1",is_null($this->container)? "":$this->container);
99
 	}
100
 
101
 	/**
102
@@ -707,7 +707,7 @@ class Template extends xmlTemplate {
103
 				$modified = false;
104
 				foreach ($rdnarray as $index => $rdnattr) {
105
 					list($attr,$value) = explode('=',$rdnattr);
106
-					if (strtolower($attr) == $attribute->getName()) {
107
+					if (strtolower((string) $attr) == $attribute->getName()) {
108
 
109
 						# If this is already marked as an RDN, then this multivalue RDN was updated on a previous loop
110
 						if (! $modified) {
111
@@ -726,7 +726,7 @@ class Template extends xmlTemplate {
112
 			}
113
 
114
 			// @todo If this is a Jpeg Attribute, we need to mark it read only, since it cant be deleted like text attributes can
115
-			if (strcasecmp(get_class($attribute),'jpegAttribute') == 0)
116
+			if (strcasecmp(get_class((string) $attribute),'jpegAttribute') == 0)
117
 				$attribute->setReadOnly();
118
 		}
119
 
120
@@ -761,7 +761,7 @@ class Template extends xmlTemplate {
121
 		$result = array();
122
 
123
 		foreach ($this->attributes as $index => $attribute) {
124
-			if ($attribute->getLDAPtype() == strtolower($type))
125
+			if ($attribute->getLDAPtype() == strtolower((string) $type))
126
 				array_push($result,$attribute->getName());
127
 		}
128
 
129
@@ -775,7 +775,7 @@ class Template extends xmlTemplate {
130
 		if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
131
 			debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
132
 
133
-		if (in_array(strtolower($attr),$this->getAttrbyLdapType($type)))
134
+		if (in_array(strtolower((string) $attr),$this->getAttrbyLdapType($type)))
135
 			return true;
136
 		else
137
 			return false;
138
@@ -856,7 +856,7 @@ class Template extends xmlTemplate {
139
 		}
140
 
141
 		# Chop the last plus sign off when returning
142
-		return preg_replace('/\+$/','',$rdn);
143
+		return preg_replace('/\+$/','',is_null($rdn)? "":$rdn);
144
 	}
145
 
146
 	/**
147
@@ -1166,25 +1166,25 @@ class Template extends xmlTemplate {
148
 					$attribute->js['autoFill'] = '';
149
 
150
 				$formula = $string;
151
-				$formula = preg_replace('/^([^%])/','\'$1',$formula);
152
-				$formula = preg_replace('/([^%])$/','$1\'',$formula);
153
+				$formula = preg_replace('/^([^%])/','\'$1',is_null($formula)? "":$formula);
154
+				$formula = preg_replace('/([^%])$/','$1\'',is_null($formula)? "":$formula);
155
 
156
 				# Check that our attributes match our schema attributes.
157
 				foreach ($matchall[1] as $index => $checkattr) {
158
 					$sattr = $this->getServer()->getSchemaAttribute($checkattr);
159
 
160
 					# If the attribute is the same as in the XML file, then dont need to do anything.
161
-					if (! $sattr || ! strcasecmp($sattr->getName(),$checkattr))
162
+					if (! (string) $sattr || ! strcasecmp((string) $sattr->getName(),(string) $checkattr))
163
 						continue;
164
 
165
-					$formula = preg_replace("/$checkattr/",$sattr->getName(),$formula);
166
+					$formula = preg_replace("/$checkattr/",$sattr->getName(),is_null($formula)? "":$formula);
167
 					$matchall[1][$index] = $sattr->getName();
168
 				}
169
 
170
 				$elem_id = 0;
171
 
172
 				foreach ($matchall[0] as $index => $null) {
173
-					$match_attr = strtolower($matchall[1][$index]);
174
+					$match_attr = strtolower((string) $matchall[1][$index]);
175
 					$match_subst = $matchall[2][$index];
176
 					$match_mod = $matchall[3][$index];
177
 					$match_delim = $matchall[4][$index];
178
@@ -1199,7 +1199,7 @@ class Template extends xmlTemplate {
179
 					$js_match_attr = $match_attr;
180
 					$match_attr = $js_match_attr.'xx'.$varcount[$match_attr];
181
 
182
-					$formula = preg_replace('/%'.$js_match_attr.'([|\/%])/i','%'.$match_attr.'$1',$formula,1);
183
+					$formula = preg_replace('/%'.$js_match_attr.'([|\/%])/i','%'.$match_attr.'$1',$formula,is_null(1)? "":1);
184
 
185
 					$attribute->js['autoFill'] .= sprintf("  var %s;\n",$match_attr);
186
 					$attribute->js['autoFill'] .= sprintf(
187
@@ -1216,7 +1216,7 @@ class Template extends xmlTemplate {
188
 					$elem_id++;
189
 
190
 					if (strstr($match_mod,'k')) {
191
-						preg_match_all('/([0-9]+)/',trim($match_subst),$substrarray);
192
+						preg_match_all('/([0-9]+)/',trim((string) $match_subst),$substrarray);
193
 						if (isset($substrarray[1][0])) {
194
 							$tok_idx = $substrarray[1][0];
195
 						} else {
196
@@ -1225,7 +1225,7 @@ class Template extends xmlTemplate {
197
 						$attribute->js['autoFill'] .= sprintf("   %s = %s.split(':')[%s];\n",$match_attr,$match_attr,$tok_idx);
198
 
199
 					} elseif (strstr($match_mod,'K')) {
200
-						preg_match_all('/([0-9]+)/',trim($match_subst),$substrarray);
201
+						preg_match_all('/([0-9]+)/',trim((string) $match_subst),$substrarray);
202
 						if (isset($substrarray[1][0])) {
203
 							$tok_idx = $substrarray[1][0];
204
 						} else {
205
@@ -1240,7 +1240,7 @@ class Template extends xmlTemplate {
206
 						$attribute->js['autoFill'] .= sprintf("   %s = %s.split('%s')[%s];\n",$match_attr,$match_attr,$delimiter,$tok_idx);
207
 
208
 					} else {
209
-						preg_match_all('/([0-9]*)-([0-9]*)/',trim($match_subst),$substrarray);
210
+						preg_match_all('/([0-9]*)-([0-9]*)/',trim((string) $match_subst),$substrarray);
211
 						if ((isset($substrarray[1][0]) && $substrarray[1][0]) || (isset($substrarray[2][0]) && $substrarray[2][0])) {
212
 							$attribute->js['autoFill'] .= sprintf("   %s = %s.substr(%s,%s);\n",
213
 								$match_attr,$match_attr,
214
@@ -1260,19 +1260,19 @@ class Template extends xmlTemplate {
215
 					}
216
 
217
 					# Matchfor only entry without modifiers.
218
-					$formula = preg_replace('/^%('.$match_attr.')%$/U','$1 + \'\'',$formula);
219
+					$formula = preg_replace('/^%('.$match_attr.')%$/U','$1 + \'\'',is_null($formula)? "":$formula);
220
 					# Matchfor only entry with modifiers.
221
-					$formula = preg_replace('/^%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[KklTUA]+)?(?:\|(.))?%$/U','$1 + \'\'',$formula);
222
+					$formula = preg_replace('/^%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[KklTUA]+)?(?:\|(.))?%$/U','$1 + \'\'',is_null($formula)? "":$formula);
223
 					# Matchfor begining entry.
224
-					$formula = preg_replace('/^%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[KklTUA]+)?(?:\|(.))?%/U','$1 + \'',$formula);
225
+					$formula = preg_replace('/^%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[KklTUA]+)?(?:\|(.))?%/U','$1 + \'',is_null($formula)? "":$formula);
226
 					# Matchfor ending entry.
227
-					$formula = preg_replace('/%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[KklTUA]+)?(?:\|(.))?%$/U','\' + $1 ',$formula);
228
+					$formula = preg_replace('/%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[KklTUA]+)?(?:\|(.))?%$/U','\' + $1 ',is_null($formula)? "":$formula);
229
 					# Match for entries not at begin/end.
230
-					$formula = preg_replace('/%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[KklTUA]+)?(?:\|(.))?%/U','\' + $1 + \'',$formula);
231
+					$formula = preg_replace('/%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[KklTUA]+)?(?:\|(.))?%/U','\' + $1 + \'',is_null($formula)? "":$formula);
232
 					$attribute->js['autoFill'] .= "\n";
233
 				}
234
 
235
-				$attribute->js['autoFill'] .= sprintf(" fillRec(pre+'%s'+suf, %s); // %s\n",strtolower($attr),$formula,$string);
236
+				$attribute->js['autoFill'] .= sprintf(" fillRec(pre+'%s'+suf, %s); // %s\n",strtolower((string) $attr),$formula,$string);
237
 				$attribute->js['autoFill'] .= "\n";
238
 				break;
239
 
240
@@ -1333,7 +1333,7 @@ class Template extends xmlTemplate {
241
 							$this->setMinValueCount($sattr->getName(),1);
242
 
243
 							# We need to mark the attributes as show, except for the objectclass attribute.
244
-							if (strcasecmp('objectClass',$objectclassattr) != 0) {
245
+							if (strcasecmp('objectClass',(string) $objectclassattr) != 0) {
246
 								$attribute = $this->getAttribute($sattr->getName());
247
 								$attribute->show();
248
 							}
(-)b/net/phpldapadmin/files/patch-lib_TemplateRender.php (+99 lines)
Added Link Here
1
--- lib/TemplateRender.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/TemplateRender.php
3
@@ -291,8 +291,8 @@ class TemplateRender extends PageRender {
4
 					$formvalues = array_change_key_case($_REQUEST['form']);
5
 
6
 					foreach ($filtermatchall[1] as $arg) {
7
-						$value = $formvalues[strtolower($arg)];
8
-						$args[1] = preg_replace("/%($arg)(\|.+)?(\/[lU])?%/U",$value,$args[1]);
9
+						$value = $formvalues[strtolower((string) $arg)];
10
+						$args[1] = preg_replace("/%($arg)(\|.+)?(\/[lU])?%/U",$value,is_null($args[1])? "":$args[1]);
11
 					}
12
 				}
13
 
14
@@ -323,7 +323,7 @@ class TemplateRender extends PageRender {
15
 						$fixedvalue = preg_split('/=\>/',$fixedvalue);
16
 						$displayvalue = explode('=',$fixedvalue[1]);
17
 
18
-						$newvalue[trim($fixedvalue[0])] = array($args[2]=>trim($fixedvalue[0]),trim($displayvalue[0])=>trim($displayvalue[1]));
19
+						$newvalue[trim((string) $fixedvalue[0])] = array($args[2]=>trim((string) $fixedvalue[0]),trim((string) $displayvalue[0])=>trim((string) $displayvalue[1]));
20
 
21
 						$picklistvalues = array_merge($picklistvalues,$newvalue);
22
 					}
23
@@ -353,7 +353,7 @@ class TemplateRender extends PageRender {
24
 									if (function_exists('mb_convert_case'))
25
 										$disp_val = mb_convert_case($disp_val,MB_CASE_LOWER,'utf-8');
26
 									else
27
-										$disp_val = strtolower($disp_val);
28
+										$disp_val = strtolower((string) $disp_val);
29
 
30
 									break;
31
 
32
@@ -380,11 +380,11 @@ class TemplateRender extends PageRender {
33
 							}
34
 
35
 						# make value a substring of
36
-						preg_match_all('/^\|([0-9]*)-([0-9]*)$/',trim($matchall[2][$key]),$substrarray);
37
+						preg_match_all('/^\|([0-9]*)-([0-9]*)$/',trim((string) $matchall[2][$key]),$substrarray);
38
 
39
 						if ((isset($substrarray[1][0]) && $substrarray[1][0]) || (isset($substrarray[2][0]) && $substrarray[2][0])) {
40
 							$begin = $substrarray[1][0] ? $substrarray[1][0] : '0';
41
-							$end = $substrarray[2][0] ? $substrarray[2][0] : strlen($disp_val);
42
+							$end = $substrarray[2][0] ? $substrarray[2][0] : strlen((string) $disp_val);
43
 
44
 							if (function_exists('mb_substr'))
45
 								$disp_val = mb_substr($disp_val,$begin,$end,'utf-8');
46
@@ -392,7 +392,7 @@ class TemplateRender extends PageRender {
47
 								$disp_val = substr($disp_val,$begin,$end);
48
 						}
49
 
50
-						$display = preg_replace("/%($arg)(\|.+)?(\/[lUC])?%/U",$disp_val,$display);
51
+						$display = preg_replace("/%($arg)(\|.+)?(\/[lUC])?%/U",$disp_val,is_null($display)? "":$display);
52
 					}
53
 
54
 					if (! isset($picklist[$values[$args[2]]])) {
55
@@ -1347,7 +1347,7 @@ class TemplateRender extends PageRender {
56
 		echo '<td><select name="new_values[objectclass][]" multiple="multiple" size="15">';
57
 
58
 		foreach ($socs as $name => $oclass) {
59
-			if (! strcasecmp('top',$name))
60
+			if (! strcasecmp('top',(string) $name))
61
 				continue;
62
 
63
 			printf('<option %s value="%s">%s</option>',
64
@@ -1879,7 +1879,7 @@ function fillRec(id,value) {
65
 	protected function drawDnValueIconAttribute($attribute,$val) {
66
 		if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__);
67
 
68
-		if (strlen($val) <= 0)
69
+		if (strlen((string) $val) <= 0)
70
 			printf('<img src="%s/ldap-alias.png" alt="Go" style="float: right;" />&nbsp;',IMGDIR);
71
 		elseif ($this->getServer()->dnExists($val))
72
 			printf('<a href="cmd.php?cmd=template_engine&amp;server_id=%s&amp;dn=%s" title="%s %s"><img src="%s/ldap-alias.png" alt="Go" /></a>&nbsp;',
73
@@ -1892,7 +1892,7 @@ function fillRec(id,value) {
74
 		if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__);
75
 
76
 		$img = sprintf('<img src="%s/mail.png" alt="%s" style="float: right;" />',IMGDIR,_('Mail'));
77
-		if (strlen($val) <= 0)
78
+		if (strlen((string) $val) <= 0)
79
 			echo $img;
80
 		else
81
 			printf('<a href="mailto:%s">%s</a>',htmlspecialchars($val),$img);
82
@@ -1905,7 +1905,7 @@ function fillRec(id,value) {
83
 		$img = sprintf('<img src="%s/ldap-dc.png" alt="%s" style="float: right;" />',IMGDIR,_('URL'));
84
 		$url = explode(' +',$val,2);
85
 
86
-		if (strlen($val) <= 0)
87
+		if (strlen((string) $val) <= 0)
88
 			echo $img;
89
 		else
90
 			printf('<a href="%s" onclick="target=\'new\';">%s</a>',htmlspecialchars($url[0]),$img);
91
@@ -2387,7 +2387,7 @@ function deleteAttribute(attrName,friendlyName,i)
92
 		if (! $_SESSION[APPCONFIG]->getValue('appearance','show_schema_link') || !$_SESSION[APPCONFIG]->isCommandAvailable('script','schema'))
93
 			return;
94
 
95
-		if (strlen($val) > 0) {
96
+		if (strlen((string) $val) > 0) {
97
 			$href = sprintf('cmd.php?cmd=schema&server_id=%s&view=objectclasses&viewvalue=%s',
98
 				$this->getServerID(),$val);
99
 			printf('<a href="%s" title="%s"><img src="%s/info.png" alt="Info" /></a>&nbsp;',
(-)b/net/phpldapadmin/files/patch-lib_Tree.php (-7 / +16 lines)
Lines 1-11 Link Here
1
--- lib/Tree.php.orig	2021-12-12 02:35:51 UTC
1
--- lib/Tree.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/Tree.php
2
+++ lib/Tree.php
3
@@ -68,7 +68,7 @@ abstract class Tree {
3
@@ -132,7 +132,7 @@ abstract class Tree {
4
 				}
4
 		if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
5
 			}
5
 			debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs);
6
 
6
 
7
-			set_cached_item($server_id,'tree','null',$tree);
7
-		$index = strtolower(implode(',',pla_explode_dn($dn)));
8
+			set_cached_item($server_id,$tree,'tree','null');
8
+		$index = strtolower((string) implode(',',pla_explode_dn($dn)));
9
 		}
10
 
9
 
11
 		return $tree;
10
 		if (DEBUG_ENABLED)
11
 			debug_log('Result (%s)',1,0,__FILE__,__LINE__,__METHOD__,$index);
12
@@ -185,7 +185,7 @@ abstract class Tree {
13
 		$tree_factory = new TreeItem($server->getIndex(),$dn);
14
 		$tree_factory->setObjectClasses($server->getDNAttrValue($dn,'objectClass'));
15
 
16
-		if ((($isleaf = $server->getDNAttrValue($dn,'hassubordinates')) && ! strcasecmp($isleaf[0],'false')))
17
+		if ((($isleaf = $server->getDNAttrValue($dn,'hassubordinates')) && ! strcasecmp((string) $isleaf[0],'false')))
18
 			$tree_factory->setLeaf();
19
 
20
 		$this->entries[$dnlower] = $tree_factory;
(-)b/net/phpldapadmin/files/patch-lib_TreeItem.php (+11 lines)
Added Link Here
1
--- lib/TreeItem.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/TreeItem.php
3
@@ -59,7 +59,7 @@ class TreeItem {
4
 	}
5
 
6
 	public function getDNEncode() {
7
-		return urlencode(preg_replace('/%([0-9a-fA-F]+)/',"%25\\1",$this->dn));
8
+		return urlencode(preg_replace('/%([0-9a-fA-F]+)/',"%25\\1",is_null($this->dn)? "":$this->dn));
9
 	}
10
 
11
 	/**
(-)b/net/phpldapadmin/files/patch-lib_common.php (-11 / +12 lines)
Lines 1-13 Link Here
1
--- lib/common.php.orig	2021-12-12 02:35:51 UTC
1
--- lib/common.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/common.php
2
+++ lib/common.php
3
@@ -296,7 +296,9 @@ if ($app['language'] == 'auto') {
3
@@ -247,9 +247,9 @@ if ($app['language'] == 'auto') {
4
  * Strip slashes from GET, POST, and COOKIE variables if this
4
 
5
  * PHP install is configured to automatically addslashes()
5
 			$value = preg_split('/[-]+/',$value);
6
  */
6
 			if (sizeof($value) == 2)
7
-if (@get_magic_quotes_gpc() && (! isset($slashes_stripped) || ! $slashes_stripped)) {
7
-				$app['lang_http'][$key] = strtolower($value[0]).'_'.strtoupper($value[1]);
8
+if (@version_compare(phpversion(), '5.4.0', '<') &&
8
+				$app['lang_http'][$key] = strtolower((string) $value[0]).'_'.strtoupper($value[1]);
9
+    @get_magic_quotes_gpc() &&
9
 			else
10
+    (!isset($slashes_stripped) || !$slashes_stripped)) {
10
-				$app['lang_http'][$key] = auto_lang(strtolower($value[0]));
11
 	array_stripslashes($_REQUEST);
11
+				$app['lang_http'][$key] = auto_lang(strtolower((string) $value[0]));
12
 	array_stripslashes($_GET);
12
 		}
13
 	array_stripslashes($_POST);
13
 
14
 		$app['lang_http'] = array_unique($app['lang_http']);
(-)b/net/phpldapadmin/files/patch-lib_ds.php (+29 lines)
Added Link Here
1
--- lib/ds.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/ds.php
3
@@ -371,7 +371,7 @@ abstract class DS {
4
 				$replacement = $this->getValue('login', 'sasl_dn_replacement');
5
 
6
 				if ($regex && $replacement) {
7
-					$userDN = preg_replace($regex, $replacement, $_SERVER['REMOTE_USER']);
8
+					$userDN = preg_replace($regex, $replacement,is_null( $_SERVER['REMOTE_USER'])? "": $_SERVER['REMOTE_USER']);
9
 
10
 					$CACHE[$this->index][$method] = $this->login($userDN, '', $method);
11
 
12
@@ -437,7 +437,7 @@ abstract class DS {
13
 		if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
14
 			debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
15
 
16
-		if (! trim($this->getLogin(null)) && $_SESSION[APPCONFIG]->getValue('appearance','anonymous_bind_implies_read_only'))
17
+		if (! trim((string) $this->getLogin(null)) && $_SESSION[APPCONFIG]->getValue('appearance','anonymous_bind_implies_read_only'))
18
 			return true;
19
 		else
20
 			return $this->getValue('server','read_only');
21
@@ -691,7 +691,7 @@ class Datastore {
22
 			debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
23
 
24
 		# If no index defined, then pick the lowest one.
25
-		if (is_null($index) || ! trim($index) || ! is_numeric($index))
26
+		if (is_null($index) || ! trim((string) $index) || ! is_numeric($index))
27
 			$index = min($this->GetServerList())->getIndex();
28
 
29
 		if (! isset($this->objects[$index]))
(-)b/net/phpldapadmin/files/patch-lib_ds__ldap.php (-22 / +443 lines)
Lines 1-38 Link Here
1
--- lib/ds_ldap.php.orig	2021-12-12 02:35:51 UTC
1
--- lib/ds_ldap.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/ds_ldap.php
2
+++ lib/ds_ldap.php
3
@@ -1768,7 +1768,7 @@ class ldap extends DS {
3
@@ -206,6 +206,7 @@ class ldap extends DS {
4
 			ksort($return);
4
 
5
 		if ($this->getValue('server','port'))
6
 			$resource = ldap_connect($this->getValue('server','host'),$this->getValue('server','port'));
7
+	
8
 		else
9
 			$resource = ldap_connect($this->getValue('server','host'));
10
 
11
@@ -216,7 +217,8 @@ class ldap extends DS {
12
 			debug_log('LDAP Resource [%s], Host [%s], Port [%s]',16,0,__FILE__,__LINE__,__METHOD__,
13
 				$resource,$this->getValue('server','host'),$this->getValue('server','port'));
5
 
14
 
6
 			# cache the schema to prevent multiple schema fetches from LDAP server
15
-		if (! is_resource($resource))
7
-			set_cached_item($this->index,'schema','objectclasses',$return);
16
+		// if (! is_resource($resource))
8
+			set_cached_item($this->index,$return,'schema','objectclasses');
17
+		if ( !$resource )
18
 			debug_dump_backtrace('UNHANDLED, $resource is not a resource',1);
19
 
20
 		# Go with LDAP version 3 if possible (needed for renaming and Novell schema fetching)
21
@@ -328,7 +330,7 @@ class ldap extends DS {
22
 			}
9
 		}
23
 		}
10
 
24
 
11
 		if (DEBUG_ENABLED)
25
-		if (! $this->isAnonBindAllowed() && ! trim($userDN))
12
@@ -1953,7 +1953,7 @@ class ldap extends DS {
26
+		if (! $this->isAnonBindAllowed() && ! trim((string) $userDN))
13
 			$return = $attrs;
27
 			return false;
28
 
29
 		# Temporarily set our user details
30
@@ -337,7 +339,7 @@ class ldap extends DS {
31
 		$connect = $this->connect($method,false,$new);
32
 
33
 		# If we didnt log in...
34
-		if (! is_resource($connect) || $this->noconnect || ! $this->userIsAllowedLogin($userDN)) {
35
+		if (!$connect || $this->noconnect || ! $this->userIsAllowedLogin($userDN)) {
36
 			$this->logout($method);
37
 
38
 			return false;
39
@@ -565,11 +567,11 @@ class ldap extends DS {
40
 
41
 	private function fillDNTemplate($user) {
42
 		foreach($this->getLoginBaseDN() as $base)
43
-			if(substr_compare($user, $base, -strlen($base)) === 0)
44
+			if(substr_compare($user, $base, -strlen((string) $base)) === 0)
45
 				return $user; // $user already passed as DN
46
 
47
 		// fill template
48
-		return sprintf($this->getValue('login', 'bind_dn_template'), preg_replace('/([,\\\\#+<>;"=])/', '\\\\$1', $user));
49
+		return sprintf($this->getValue('login', 'bind_dn_template'), preg_replace('/([,\\\\#+<>;"=])/', '\\\\$1',is_null( $user)? "": $user));
50
 	}
14
 
51
 
15
 			# cache the schema to prevent multiple schema fetches from LDAP server
52
 	/**
16
-			set_cached_item($this->index,'schema','attributes',$return);
53
@@ -684,7 +686,7 @@ class ldap extends DS {
17
+			set_cached_item($this->index,$return,'schema','attributes');
54
 
55
 		if (! in_array($this->getValue('login','auth_type'), array('sasl','sasl_external'))) {
56
 			// check if SASL mech uses login from other auth_types
57
-			if (! in_array(strtolower($this->getValue('sasl', 'mech')), array('plain')))
58
+			if (! in_array(strtolower((string) $this->getValue('sasl', 'mech')), array('plain')))
59
 				return false;
18
 		}
60
 		}
19
 
61
 
20
 		if (DEBUG_ENABLED)
62
@@ -722,7 +724,7 @@ class ldap extends DS {
21
@@ -2029,7 +2029,7 @@ class ldap extends DS {
63
 		}
22
 			$return = $rules;
23
 
64
 
24
 			# cache the schema to prevent multiple schema fetches from LDAP server
65
 		# At the moment, we have only implemented GSSAPI and PLAIN
25
-			set_cached_item($this->index,'schema','matchingrules',$return);
66
-		if (! in_array(strtolower($this->getValue('sasl','mech')),array('gssapi','plain'))) {
26
+			set_cached_item($this->index,$return,'schema','matchingrules');
67
+		if (! in_array(strtolower((string) $this->getValue('sasl','mech')),array('gssapi','plain'))) {
68
 			system_message(array(
69
 				'title'=>_('SASL Method not implemented'),
70
 				'body'=>sprintf('<b>%s</b>: %s %s',_('Error'),$this->getValue('sasl','mech'),_('has not been implemented yet')),
71
@@ -731,7 +733,7 @@ class ldap extends DS {
72
 			return false;
27
 		}
73
 		}
28
 
74
 
75
-		if (strtolower($this->getValue('sasl','mech')) == 'plain') {
76
+		if (strtolower((string) $this->getValue('sasl','mech')) == 'plain') {
77
 			return @ldap_sasl_bind($resource,NULL,$pass,'PLAIN',
78
 					       $this->getValue('sasl','realm'),
79
 					       $login,
80
@@ -746,14 +748,15 @@ class ldap extends DS {
81
 		/*
82
 		# Do we need to rewrite authz_id?
83
 		if (! isset($CACHE['authz_id']))
84
-			if (! trim($this->getValue('sasl','authz_id')) && strtolower($this->getValue('sasl','mech')) != 'gssapi') {
85
+			if (! trim((string) $this->getValue('sasl','authz_id')) && strtolower((string) $this->getValue('sasl','mech')) != 'gssapi') {
86
 				if (DEBUG_ENABLED)
87
 					debug_log('Rewriting bind DN [%s] -> authz_id with regex [%s] and replacement [%s].',9,0,__FILE__,__LINE__,__METHOD__,
88
 						$CACHE['login_dn'],
89
 						$this->getValue('sasl','authz_id_regex'),
90
 						$this->getValue('sasl','authz_id_replacement'));
91
 
92
-				$CACHE['authz_id'] = @preg_replace($this->getValue('sasl','authz_id_regex'),
93
+				$CACHE['authz_id'] = @preg_replace($this->getValue('sasl','authz_id_regex'),is_null(
94
+)? "":
95
 					$this->getValue('sasl','authz_id_replacement'),$CACHE['login_dn']);
96
 
97
 				# Invalid regex?
98
@@ -1212,14 +1215,14 @@ class ldap extends DS {
99
 		if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
100
 			debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
101
 
102
-		if (! trim($dn))
103
+		if (! trim((string) $dn))
104
 			return $dn;
105
 
106
 		# Check if the RDN has a comma and escape it.
107
 		while (preg_match('/([^\\\\]),(\s*[^=]*\s*),/',$dn))
108
-			$dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*),/','$1\\\\2C$2,',$dn);
109
+			$dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*),/','$1\\\\2C$2,',is_null($dn)? "":$dn);
110
 
111
-		$dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*)([^,])$/','$1\\\\2C$2$3',$dn);
112
+		$dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*)([^,])$/','$1\\\\2C$2$3',is_null($dn)? "":$dn);
113
 
29
 		if (DEBUG_ENABLED)
114
 		if (DEBUG_ENABLED)
30
@@ -2078,7 +2078,7 @@ class ldap extends DS {
115
 			debug_log('Returning (%s)',17,0,__FILE__,__LINE__,__METHOD__,$dn);
116
@@ -1237,12 +1240,12 @@ class ldap extends DS {
117
 		if (is_array($dn)) {
118
 			$a = array();
119
 			foreach ($dn as $key => $rdn) {
120
-				$a[$key] = preg_replace_callback('/\\\([0-9A-Fa-f]{2})/', function($m) { return chr(hexdec($m[1])); }, $rdn);
121
+				$a[$key] = preg_replace_callback('/\\\([0-9A-Fa-f]{2})/', function($m) { return chr(hexdec($m[1])); },is_null( $rdn)? "": $rdn);
122
 			}
123
 			return $a;
124
 
125
 		} else {
126
-			return preg_replace_callback('/\\\([0-9A-Fa-f]{2})/', function($m) { return chr(hexdec($m[1])); }, $dn);
127
+			return preg_replace_callback('/\\\([0-9A-Fa-f]{2})/', function($m) { return chr(hexdec($m[1])); },is_null( $dn)? "": $dn);
128
 		}
129
 	}
130
 
131
@@ -1388,7 +1391,7 @@ class ldap extends DS {
132
 			return false;
133
 
134
 		# error checking
135
-		$schema_to_fetch = strtolower($schema_to_fetch);
136
+		$schema_to_fetch = strtolower((string) $schema_to_fetch);
137
 
138
 		if (! is_null($this->_schema_entries) && isset($this->_schema_entries[$schema_to_fetch])) {
139
 			$schema = $this->_schema_entries[$schema_to_fetch];
140
@@ -1408,7 +1411,7 @@ class ldap extends DS {
141
 		$schema_dn = $this->getSchemaDN($method,$dn);
142
 
143
 		# Do we need to try again with the Root DSE?
144
-		if (! $schema_dn && trim($dn))
145
+		if (! $schema_dn && trim((string) $dn))
146
 			$schema_dn = $this->getSchemaDN($method,'');
147
 
148
 		# Store the eventual schema retrieval in $schema_search
149
@@ -1609,7 +1612,7 @@ class ldap extends DS {
150
 					foreach ($entry[$olc_schema] as $schema_definition)
151
 						/* Schema definitions in child nodes prefix the schema entries with "{n}"
152
 						  the preg_replace call strips out this prefix. */
153
-						$schema[] = preg_replace('/^\{\d*\}\(/','(',$schema_definition);
154
+						$schema[] = preg_replace('/^\{\d*\}\(/','(',is_null($schema_definition)? "":$schema_definition);
155
 				}
156
 			}
157
 
158
@@ -1672,7 +1675,7 @@ class ldap extends DS {
159
 		if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
160
 			debug_log('Entered (%%)',25,0,__FILE__,__LINE__,__METHOD__,$fargs);
161
 
162
-		$oclass_name = strtolower($oclass_name);
163
+		$oclass_name = strtolower((string) $oclass_name);
164
 		$socs = $this->SchemaObjectClasses($method,$dn);
165
 
166
 		# Default return value
167
@@ -1703,7 +1706,7 @@ class ldap extends DS {
168
 		if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
169
 			debug_log('Entered (%%)',25,0,__FILE__,__LINE__,__METHOD__,$fargs);
170
 
171
-		$attr_name = strtolower($attr_name);
172
+		$attr_name = strtolower((string) $attr_name);
173
 		$sattrs = $this->SchemaAttributes($method,$dn);
174
 
175
 		# Default return value
176
@@ -1752,7 +1755,7 @@ class ldap extends DS {
177
 			$return = array();
178
 
179
 			foreach ($raw as $line) {
180
-				if (is_null($line) || ! strlen($line))
181
+				if (is_null($line) || ! strlen((string) $line))
182
 					continue;
183
 
184
 				$object_class = new ObjectClass($line,$this);
185
@@ -1762,8 +1765,8 @@ class ldap extends DS {
186
 			# Now go through and reference the parent/child relationships
187
 			foreach ($return as $oclass)
188
 				foreach ($oclass->getSupClasses() as $parent_name)
189
-					if (isset($return[strtolower($parent_name)]))
190
-						$return[strtolower($parent_name)]->addChildObjectClass($oclass->getName(false));
191
+					if (isset($return[strtolower((string) $parent_name)]))
192
+						$return[strtolower((string) $parent_name)]->addChildObjectClass($oclass->getName(false));
193
 
31
 			ksort($return);
194
 			ksort($return);
32
 
195
 
33
 			# cache the schema to prevent multiple schema fetches from LDAP server
196
@@ -1816,7 +1819,7 @@ class ldap extends DS {
34
-			set_cached_item($this->index,'schema','syntaxes',$return);
197
 			 */
35
+			set_cached_item($this->index,$return,'schema','syntaxes');
198
 			$attrs_oid = array();
199
 			foreach ($raw as $line) {
200
-				if (is_null($line) || ! strlen($line))
201
+				if (is_null($line) || ! strlen((string) $line))
202
 					continue;
203
 
204
 				$attr = new AttributeType($line);
205
@@ -1847,7 +1850,7 @@ class ldap extends DS {
206
 						$new_attr->setName($alias_attr_name);
207
 						$new_attr->addAlias($attr->getName(false));
208
 						$new_attr->removeAlias($alias_attr_name);
209
-						$new_attr_key = strtolower($alias_attr_name);
210
+						$new_attr_key = strtolower((string) $alias_attr_name);
211
 						$attrs[$new_attr_key] = $new_attr;
212
 					}
213
 				}
214
@@ -1858,7 +1861,7 @@ class ldap extends DS {
215
 				$sup_attr_name = $attr->getSupAttribute();
216
 				$sup_attr = null;
217
 
218
-				if (trim($sup_attr_name)) {
219
+				if (trim((string) $sup_attr_name)) {
220
 
221
 					/* This loop really should traverse infinite levels of inheritance (SUP) for attributeTypes,
222
 					 * but just in case we get carried away, stop at 100. This shouldn't happen, but for
223
@@ -1871,17 +1874,17 @@ class ldap extends DS {
224
 							$sup_attr_name = $attr->getSupAttribute();
225
 						}
226
 
227
-						if (! isset($attrs[strtolower($sup_attr_name)])){
228
+						if (! isset($attrs[strtolower((string) $sup_attr_name)])){
229
 							error(sprintf('Schema error: attributeType "%s" inherits from "%s", but attributeType "%s" does not exist.',
230
 								$attr->getName(),$sup_attr_name,$sup_attr_name),'error','index.php');
231
 							return;
232
 						}
233
 
234
-						$sup_attr = $attrs[strtolower($sup_attr_name)];
235
+						$sup_attr = $attrs[strtolower((string) $sup_attr_name)];
236
 						$sup_attr_name = $sup_attr->getSupAttribute();
237
 
238
 						# Does this superior attributeType not have a superior attributeType?
239
-						if (is_null($sup_attr_name) || strlen(trim($sup_attr_name)) == 0) {
240
+						if (is_null($sup_attr_name) || strlen((string) trim((string) $sup_attr_name)) == 0) {
241
 
242
 							/* Since this attribute's superior attribute does not have another superior
243
 							 * attribute, clone its properties for this attribute. Then, replace
244
@@ -1936,18 +1939,18 @@ class ldap extends DS {
245
 
246
 				# Add Used In.
247
 				foreach ($oclass_attrs as $attr_name)
248
-					if (isset($attrs[strtolower($attr_name)]))
249
-						$attrs[strtolower($attr_name)]->addUsedInObjectClass($object_class->getName(false));
250
+					if (isset($attrs[strtolower((string) $attr_name)]))
251
+						$attrs[strtolower((string) $attr_name)]->addUsedInObjectClass($object_class->getName(false));
252
 
253
 				# Add Required By.
254
 				foreach ($must_attrs as $attr_name)
255
-					if (isset($attrs[strtolower($attr_name)]))
256
-						$attrs[strtolower($attr_name)]->addRequiredByObjectClass($object_class->getName(false));
257
+					if (isset($attrs[strtolower((string) $attr_name)]))
258
+						$attrs[strtolower((string) $attr_name)]->addRequiredByObjectClass($object_class->getName(false));
259
 
260
 				# Force May
261
 				foreach ($object_class->getForceMayAttrs() as $attr_name)
262
-					if (isset($attrs[strtolower($attr_name->name)]))
263
-						$attrs[strtolower($attr_name->name)]->setForceMay();
264
+					if (isset($attrs[strtolower((string) $attr_name->name)]))
265
+						$attrs[strtolower((string) $attr_name->name)]->setForceMay();
266
 			}
267
 
268
 			$return = $attrs;
269
@@ -1987,7 +1990,7 @@ class ldap extends DS {
270
 			$rules = array();
271
 
272
 			foreach ($raw as $line) {
273
-				if (is_null($line) || ! strlen($line))
274
+				if (is_null($line) || ! strlen((string) $line))
275
 					continue;
276
 
277
 				$rule = new MatchingRule($line);
278
@@ -2003,7 +2006,7 @@ class ldap extends DS {
279
 
280
 			if ($raw != false) {
281
 				foreach ($raw as $line) {
282
-					if (is_null($line) || ! strlen($line))
283
+					if (is_null($line) || ! strlen((string) $line))
284
 						continue;
285
 
286
 					$rule_use = new MatchingRuleUse($line);
287
@@ -2019,7 +2022,7 @@ class ldap extends DS {
288
 				$sattrs = $this->SchemaAttributes($method,$dn);
289
 				if (is_array($sattrs))
290
 					foreach ($sattrs as $attr) {
291
-						$rule_key = strtolower($attr->getEquality());
292
+						$rule_key = strtolower((string) $attr->getEquality());
293
 
294
 						if (isset($rules[$rule_key]))
295
 							$rules[$rule_key]->addUsedByAttr($attr->getName(false));
296
@@ -2063,11 +2066,11 @@ class ldap extends DS {
297
 			$return = array();
298
 
299
 			foreach ($raw as $line) {
300
-				if (is_null($line) || ! strlen($line))
301
+				if (is_null($line) || ! strlen((string) $line))
302
 					continue;
303
 
304
 				$syntax = new Syntax($line);
305
-				$key = strtolower(trim($syntax->getOID()));
306
+				$key = strtolower((string) trim((string) $syntax->getOID()));
307
 
308
 				if (! $key)
309
 					continue;
310
@@ -2097,7 +2100,7 @@ class ldap extends DS {
311
 		if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
312
 			debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
313
 
314
-		return in_array($attr_name,unserialize(strtolower(serialize($this->getValue('server','force_may')))));
315
+		return in_array($attr_name,unserialize(strtolower((string) serialize($this->getValue('server','force_may')))));
316
 	}
317
 
318
 	/**
319
@@ -2133,7 +2136,7 @@ class ldap extends DS {
320
 			debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
321
 
322
 		# Ensure our attr is in lowercase
323
-		$attr = strtolower($attr);
324
+		$attr = strtolower((string) $attr);
325
 
326
 		$values = $this->getDNAttrValues($dn,$method,$deref);
327
 
328
@@ -2247,7 +2250,7 @@ class ldap extends DS {
329
 		# Simple test first
330
 		$dn_attrs = array('aliasedObjectName');
331
 		foreach ($dn_attrs as $dn_attr)
332
-			if (strcasecmp($attr_name,$dn_attr) == 0)
333
+			if (strcasecmp((string) $attr_name,(string) $dn_attr) == 0)
334
 				return true;
335
 
336
 		# Now look at the schema OID
337
@@ -2266,7 +2269,7 @@ class ldap extends DS {
338
 			return false;
339
 
340
 		$syntax_desc = $syntaxes[ $syntax_oid ]->getDescription();
341
-		if (strpos(strtolower($syntax_desc),'distinguished name'))
342
+		if (strpos(strtolower((string) $syntax_desc),'distinguished name'))
343
 			return true;
344
 
345
 		return false;
346
@@ -2286,7 +2289,7 @@ class ldap extends DS {
347
 			debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
348
 
349
 		# easy quick check
350
-		if (! strcasecmp($attr_name,'jpegPhoto') || ! strcasecmp($attr_name,'photo'))
351
+		if (! strcasecmp((string) $attr_name,'jpegPhoto') || ! strcasecmp((string) $attr_name,'photo'))
352
 			return true;
353
 
354
 		# go to the schema and get the Syntax OID
355
@@ -2297,7 +2300,7 @@ class ldap extends DS {
356
 		$oid = $sattr->getSyntaxOID();
357
 		$type = $sattr->getType();
358
 
359
-		if (! strcasecmp($type,'JPEG') || ($oid == '1.3.6.1.4.1.1466.115.121.1.28'))
360
+		if (! strcasecmp((string) $type,'JPEG') || ((string) $oid == '1.3.6.1.4.1.1466.115.121.1.28'))
361
 			return true;
362
 
363
 		return false;
364
@@ -2318,9 +2321,9 @@ class ldap extends DS {
365
 
366
 		$type = ($sattr = $this->getSchemaAttribute($attr_name)) ? $sattr->getType() : null;
367
 
368
-		if (! strcasecmp('boolean',$type) ||
369
-			! strcasecmp('isCriticalSystemObject',$attr_name) ||
370
-			! strcasecmp('showInAdvancedViewOnly',$attr_name))
371
+		if (! strcasecmp('boolean',(string) $type) ||
372
+			! strcasecmp('isCriticalSystemObject',(string) $attr_name) ||
373
+			! strcasecmp('showInAdvancedViewOnly',(string) $attr_name))
374
 			return true;
375
 
376
 		else
377
@@ -2359,7 +2362,7 @@ class ldap extends DS {
378
 
379
 		static $attr_cache;
380
 
381
-		$attr_name = strtolower($attr_name);
382
+		$attr_name = strtolower((string) $attr_name);
383
 
384
 		if (isset($attr_cache[$this->index][$attr_name]))
385
 			return $attr_cache[$this->index][$attr_name];
386
@@ -2370,7 +2373,7 @@ class ldap extends DS {
36
 		}
387
 		}
37
 
388
 
38
 		if (DEBUG_ENABLED)
389
 		# Quick check: If the attr name ends in ";binary", then it's binary.
390
-		if (strcasecmp(substr($attr_name,strlen($attr_name) - 7),';binary') == 0) {
391
+		if (strcasecmp(substr((string) $attr_name,strlen((string) (string) $attr_name) - 7),';binary') == 0) {
392
 			$attr_cache[$this->index][$attr_name] = true;
393
 			return true;
394
 		}
395
@@ -2389,17 +2392,17 @@ class ldap extends DS {
396
 			$syntax = $sattr->getSyntaxOID();
397
 		}
398
 
399
-		if (strcasecmp($type,'Certificate') == 0 ||
400
-			strcasecmp($type,'Binary') == 0 ||
401
-			strcasecmp($attr_name,'usercertificate') == 0 ||
402
-			strcasecmp($attr_name,'usersmimecertificate') == 0 ||
403
-			strcasecmp($attr_name,'networkaddress') == 0 ||
404
-			strcasecmp($attr_name,'objectGUID') == 0 ||
405
-			strcasecmp($attr_name,'objectSID') == 0 ||
406
-			strcasecmp($attr_name,'auditingPolicy') == 0 ||
407
-			strcasecmp($attr_name,'jpegPhoto') == 0 ||
408
-			strcasecmp($attr_name,'krbExtraData') == 0 ||
409
-			strcasecmp($attr_name,'krbPrincipalKey') == 0 ||
410
+		if (strcasecmp((string) $type,'Certificate') == 0 ||
411
+			strcasecmp((string) $type,'Binary') == 0 ||
412
+			strcasecmp((string) $attr_name,'usercertificate') == 0 ||
413
+			strcasecmp((string) $attr_name,'usersmimecertificate') == 0 ||
414
+			strcasecmp((string) $attr_name,'networkaddress') == 0 ||
415
+			strcasecmp((string) $attr_name,'objectGUID') == 0 ||
416
+			strcasecmp((string) $attr_name,'objectSID') == 0 ||
417
+			strcasecmp((string) $attr_name,'auditingPolicy') == 0 ||
418
+			strcasecmp((string) $attr_name,'jpegPhoto') == 0 ||
419
+			strcasecmp((string) $attr_name,'krbExtraData') == 0 ||
420
+			strcasecmp((string) $attr_name,'krbPrincipalKey') == 0 ||
421
 			$syntax == '1.3.6.1.4.1.1466.115.121.1.10' ||
422
 			$syntax == '1.3.6.1.4.1.1466.115.121.1.28' ||
423
 			$syntax == '1.3.6.1.4.1.1466.115.121.1.5' ||
424
@@ -2428,7 +2431,7 @@ class ldap extends DS {
425
 		if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
426
 			debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
427
 
428
-		$user = strtolower($user);
429
+		$user = strtolower((string) $user);
430
 		$group = $this->getDNAttrValues($group);
431
 
432
 		# If you are using groupOfNames objectClass
433
@@ -2459,7 +2462,7 @@ class ldap extends DS {
434
 		if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
435
 			debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
436
 
437
-		$dn = trim(strtolower($dn));
438
+		$dn = trim((string) strtolower((string) $dn));
439
 
440
 		if (! $this->getValue('login','allowed_dns'))
441
 			return true;
442
@@ -2498,7 +2501,7 @@ class ldap extends DS {
443
                                     debug_log('Comparing with [%s]',80,0,__FILE__,__LINE__,__METHOD__,$result_dn);
444
 
445
                                 # Check if $result_dn is a user DN
446
-                                if (strcasecmp($dn,trim(strtolower($result_dn))) == 0)
447
+                                if (strcasecmp((string) $dn,trim((string) strtolower((string) (string) $result_dn))) == 0)
448
                                     return true;
449
 
450
                                 # Check if $result_dn is a group DN
451
@@ -2510,7 +2513,7 @@ class ldap extends DS {
452
             }
453
 
454
             # Check if $login_allowed_dn is a user DN
455
-            if (strcasecmp($dn,trim(strtolower($login_allowed_dn))) == 0)
456
+            if (strcasecmp((string) $dn,trim((string) strtolower((string) (string) $login_allowed_dn))) == 0)
457
                 return true;
458
 
459
             # Check if $login_allowed_dn is a group DN
(-)b/net/phpldapadmin/files/patch-lib_ds__ldap__pla.php (-27 / +38 lines)
Lines 1-29 Link Here
1
--- lib/ds_ldap_pla.php.orig	2021-12-12 02:35:51 UTC
1
--- lib/ds_ldap_pla.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/ds_ldap_pla.php
2
+++ lib/ds_ldap_pla.php
3
@@ -371,7 +371,7 @@ class ldap_pla extends ldap {
3
@@ -248,7 +248,7 @@ class ldap_pla extends ldap {
4
 
4
 		# Next, compare strictly by name first
5
 				$tree->addEntry($dn);
5
 		else
6
 
6
 			foreach ($_SESSION[APPCONFIG]->getValue('appearance','multi_line_attributes') as $multi_line_attr_name)
7
-				set_cached_item($this->index,'tree','null',$tree);
7
-				if (strcasecmp($multi_line_attr_name,$attr_name) == 0) {
8
+				set_cached_item($this->index,$tree,'tree','null');
8
+				if (strcasecmp((string) $multi_line_attr_name,(string) $attr_name) == 0) {
9
 
9
 					$return = true;
10
 				run_hook('post_entry_create',array('server_id'=>$this->index,'method'=>$method,'dn'=>$dn,'attrs'=>$entry_array));
10
 					break;
11
 
11
 				}
12
@@ -403,7 +403,7 @@ class ldap_pla extends ldap {
12
@@ -285,8 +285,8 @@ class ldap_pla extends ldap {
13
 				$tree = get_cached_item($this->index,'tree');
13
 	 * @return boolean
14
 				$tree->delEntry($dn);
14
 	 */
15
 
15
 	private function isAttrTest($attr,$attrs,$except_dn) {
16
-				set_cached_item($this->index,'tree','null',$tree);
16
-		$attr = trim($attr);
17
+				set_cached_item($this->index,$tree,'tree','null');
17
-		if (! trim($attr) || ! count($attrs))
18
 
18
+		$attr = trim((string) $attr);
19
 				run_hook('post_entry_delete',array('server_id'=>$this->index,'method'=>$method,'dn'=>$dn));
19
+		if (! trim((string) $attr) || ! count($attrs))
20
 			}
20
 			return false;
21
@@ -430,7 +430,7 @@ class ldap_pla extends ldap {
21
 
22
 				$newdn = sprintf('%s,%s',$new_rdn,$container);
22
 		# Is the user excluded?
23
 				$tree->renameEntry($dn,$newdn);
23
@@ -294,7 +294,7 @@ class ldap_pla extends ldap {
24
 
24
 			return false;
25
-				set_cached_item($this->index,'tree','null',$tree);
25
 
26
+				set_cached_item($this->index,$tree,'tree','null');
26
 		foreach ($attrs as $attr_name)
27
 
27
-			if (strcasecmp($attr,trim($attr_name)) == 0)
28
 				run_hook('post_entry_rename',array('server_id'=>$this->index,'method'=>$method,'dn'=>$dn,'rdn'=>$new_rdn,'container'=>$container));
28
+			if (strcasecmp((string) $attr,trim((string) (string) $attr_name)) == 0)
29
 			}
29
 				return true;
30
 
31
 		return false;
32
@@ -674,7 +674,7 @@ class ldap_pla extends ldap {
33
 		if ($this->getValue('appearance', 'show_authz') && function_exists('ldap_exop_whoami')) {
34
 			$result = @ldap_exop_whoami($this->connect($method));
35
 			if ($result) // strip any dn: or u: prefix
36
-				$result = preg_replace('/^(u|dn):/i', '', $result);
37
+				$result = preg_replace('/^(u|dn):/i', '',is_null( $result)? "": $result);
38
 			else // fall back to login on error
39
 				$result = $this->getLogin($method);
40
 			return $result;
(-)b/net/phpldapadmin/files/patch-lib_export__functions.php (+46 lines)
Added Link Here
1
--- lib/export_functions.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/export_functions.php
3
@@ -131,7 +131,7 @@ abstract class Export {
4
 		$query['size_limit'] = 0;
5
 		$attrs = get_request('attributes','REQUEST');
6
 
7
-		$attrs = preg_replace('/\s+/','',$attrs);
8
+		$attrs = preg_replace('/\s+/','',is_null($attrs)? "":$attrs);
9
 		if ($attrs)
10
 			$query['attrs'] = explode(',',$attrs);
11
 		else
12
@@ -222,7 +222,7 @@ abstract class Export {
13
 	 * @return boolean true if the string is safe ascii, false otherwise.
14
 	 */
15
 	protected function isSafeAscii($str) {
16
-		for ($i=0;$i<strlen($str);$i++)
17
+		for ($i=0;$i<strlen((string) $str);$i++)
18
 			if (ord($str[$i]) < 32 || ord($str[$i]) > 127)
19
 				return false;
20
 
21
@@ -478,7 +478,7 @@ class ExportLDIF extends Export {
22
 
23
 				$title_string = sprintf('# %s %s: %s%s',_('Entry'),$counter,$dn,$this->br);
24
 
25
-				if (strlen($title_string) > $this->line_length-3)
26
+				if (strlen((string) $title_string) > $this->line_length-3)
27
 					$title_string = substr($title_string,0,$this->line_length-3).'...'.$this->br;
28
 
29
 				$output .= $title_string;
30
@@ -517,14 +517,14 @@ class ExportLDIF extends Export {
31
 	 * @param The line to be wrapped if needed.
32
 	 */
33
 	private function multiLineDisplay($str) {
34
-		$length_string = strlen($str);
35
+		$length_string = strlen((string) $str);
36
 		$length_max = $this->line_length;
37
 
38
 		$output = '';
39
 		while ($length_string > $length_max) {
40
 			$output .= substr($str,0,$length_max).$this->br.' ';
41
 			$str = substr($str,$length_max,$length_string);
42
-			$length_string = strlen($str);
43
+			$length_string = strlen((string) $str);
44
 
45
 			/* Need to do minus one to align on the right
46
 			 * the first line with the possible following lines
(-)b/net/phpldapadmin/files/patch-lib_functions.php (-23 / +446 lines)
Lines 1-31 Link Here
1
--- lib/functions.php.orig	2021-12-12 02:35:51 UTC
1
--- lib/functions.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/functions.php
2
+++ lib/functions.php
3
@@ -928,7 +928,7 @@ function get_cached_item($index,$item,$subitem='null')
3
@@ -161,7 +161,7 @@ function app_error_handler($errno,$errstr,$file,$linen
4
  *
4
 	}
5
  * Returns true on success of false on failure.
5
 
6
  */
6
 	# Take out extra spaces in error strings.
7
-function set_cached_item($index,$item,$subitem='null',$data) {
7
-	$errstr = preg_replace('/\s+/',' ',$errstr);
8
+function set_cached_item($index,$data,$item,$subitem='null') {
8
+	$errstr = preg_replace('/\s+/',' ',is_null($errstr)? "":$errstr);
9
 
10
 	if ($errno == E_NOTICE) {
11
 		$body = '<table class="notice">';
12
@@ -214,9 +214,9 @@ function app_version() {
13
 		$CACHE = 'UNKNOWN';
14
 
15
 	else {
16
-		$version = rtrim(file_get_contents($version_file));
17
+		$version = rtrim((string) file_get_contents($version_file));
18
 
19
-		$CACHE = preg_replace('/^RELEASE-([0-9\.]+(-.*)*)$/','$1',$version);
20
+		$CACHE = preg_replace('/^RELEASE-([0-9\.]+(-.*)*)$/','$1',is_null($version)? "":$version);
21
 
22
 		# Check if we are a CVS copy.
23
 		if (preg_match('/^(DEVEL)?$/',$CACHE))
24
@@ -525,7 +525,8 @@ function debug_log($msg,$level,$indent) {
25
 
26
 	# Pull the file/line/method
27
 	if (is_string($args[0]) && preg_match('/.php$/',$args[0])) {
28
-		$file = preg_replace('/.php$/','',array_shift($args));
29
+		$file_a_shift = array_shift($args);
30
+		$file = preg_replace('/.php$/','',is_null($file_a_shift? "":$file_a_shift));
31
 		$line = array_shift($args);
32
 		$method = array_shift($args);
33
 
34
@@ -550,7 +551,7 @@ function debug_log($msg,$level,$indent) {
35
 	}
36
 
37
 	if (preg_match('/%%/',$msg))
38
-		$msg = preg_replace('/%%/',join('|',$fargs),$msg);
39
+		$msg = preg_replace('/%%/',join('|',$fargs),is_null($msg)? "":$msg);
40
 	else
41
 		$msg = vsprintf($msg,array_values($fargs));
42
 
43
@@ -761,11 +762,11 @@ function blowfish_encrypt($data,$secret=null) {
44
 		debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs);
45
 
46
 	# If our secret is null or blank, get the default.
47
-	if ($secret === null || ! trim($secret))
48
+	if ($secret === null || ! trim((string) $secret))
49
 		$secret = $_SESSION[APPCONFIG]->getValue('session','blowfish') ? $_SESSION[APPCONFIG]->getValue('session','blowfish') : session_id();
50
 
51
 	# If the secret isnt set, then just return the data.
52
-	if (! trim($secret))
53
+	if (! trim((string) $secret))
54
 		return $data;
55
 
56
 	if (! empty($data) && function_exists('openssl_encrypt') && in_array('bf-ecb', openssl_get_cipher_methods())) {
57
@@ -791,10 +792,10 @@ function blowfish_encrypt($data,$secret=null) {
58
 	$pma_cipher = new Horde_Cipher_blowfish;
59
 	$encrypt = '';
60
 
61
-	for ($i=0; $i<strlen($data); $i+=8) {
62
+	for ($i=0; $i<strlen((string) $data); $i+=8) {
63
 		$block = substr($data, $i, 8);
64
 
65
-		if (strlen($block) < 8)
66
+		if (strlen((string) $block) < 8)
67
 			$block = full_str_pad($block,8,"\0", 1);
68
 
69
 		$encrypt .= $pma_cipher->encryptBlock($block, $secret);
70
@@ -822,11 +823,11 @@ function blowfish_decrypt($encdata,$secret=null) {
71
 		return $CACHE[$encdata];
72
 
73
 	# If our secret is null or blank, get the default.
74
-	if ($secret === null || ! trim($secret))
75
+	if ($secret === null || ! trim((string) $secret))
76
 		$secret = $_SESSION[APPCONFIG]->getValue('session','blowfish') ? $_SESSION[APPCONFIG]->getValue('session','blowfish') : session_id();
77
 
78
 	# If the secret isnt set, then just return the data.
79
-	if (! trim($secret))
80
+	if (! trim((string) $secret))
81
 		return $encdata;
82
 
83
 	if (! empty($encdata) && function_exists('openssl_encrypt') && in_array('bf-ecb', openssl_get_cipher_methods())) {
84
@@ -838,7 +839,7 @@ function blowfish_decrypt($encdata,$secret=null) {
85
 		$td = mcrypt_module_open(MCRYPT_BLOWFISH,'',MCRYPT_MODE_ECB,'');
86
 		$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td),MCRYPT_DEV_URANDOM);
87
 		mcrypt_generic_init($td,substr($secret,0,mcrypt_enc_get_key_size($td)),$iv);
88
-		$decrypted_data = trim(mdecrypt_generic($td,base64_decode($encdata)));
89
+		$decrypted_data = trim((string) mdecrypt_generic($td,base64_decode($encdata)));
90
 		mcrypt_generic_deinit($td);
91
 
92
 		return $decrypted_data;
93
@@ -853,11 +854,11 @@ function blowfish_decrypt($encdata,$secret=null) {
94
 	$decrypt = '';
95
 	$data = base64_decode($encdata);
96
 
97
-	for ($i=0; $i<strlen($data); $i+=8)
98
+	for ($i=0; $i<strlen((string) $data); $i+=8)
99
 		$decrypt .= $pma_cipher->decryptBlock(substr($data, $i, 8), $secret);
100
 
101
 	// Strip off our \0's that were added.
102
-	$return = preg_replace("/\\0*$/",'',$decrypt);
103
+	$return = preg_replace("/\\0*$/",'',is_null($decrypt)? "":$decrypt);
104
 	$CACHE[$encdata] = $return;
105
 	return $return;
106
 }
107
@@ -876,7 +877,7 @@ function full_str_pad($input,$pad_length,$pad_string='
108
 		debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs);
109
 
110
 	$str = '';
111
-	$length = $pad_length - strlen($input);
112
+	$length = $pad_length - strlen((string) $input);
113
 
114
 	if ($length > 0) { // str_repeat doesn't like negatives
115
 		if ($pad_type == STR_PAD_RIGHT) { // STR_PAD_RIGHT == 1
116
@@ -1090,7 +1091,7 @@ function masort(&$data,$sortby,$rev=0) {
117
 			$code .= "	\$a = array_change_key_case(\$a);\n";
118
 			$code .= "	\$b = array_change_key_case(\$b);\n";
119
 
120
-			$key = strtolower($key);
121
+			$key = strtolower((string) $key);
122
 
123
 			$code .= "	if ((! isset(\$a['$key'])) && isset(\$b['$key'])) return 1;\n";
124
 			$code .= "	if (isset(\$a['$key']) && (! isset(\$b['$key']))) return -1;\n";
125
@@ -1248,7 +1249,7 @@ function is_dn_string($str) {
126
 		$left = $sub_parts[0];
127
 		$right = $sub_parts[1];
128
 
129
-		if ( ! strlen(trim($left)) || ! strlen(trim($right)))
130
+		if ( ! strlen((string) trim((string) $left)) || ! strlen((string) trim((string) $right)))
131
 			return false;
132
 
133
 		if (strpos($left,'#') !== false)
134
@@ -1343,7 +1344,7 @@ function pla_compare_dns($dn1,$dn2) {
135
 			$dn2 = implode('+',$dn2);
136
 
137
 	# If they are obviously the same, return immediately
138
-	if (! strcasecmp($dn1,$dn2))
139
+	if (! strcasecmp((string) $dn1,(string) $dn2))
140
 		return 0;
141
 
142
 	$dn1_parts = pla_explode_dn(pla_reverse_dn($dn1));
143
@@ -1364,15 +1365,15 @@ function pla_compare_dns($dn1,$dn2) {
144
 		$dn1_sub_parts = explode('=',$dn1_part,2);
145
 		$dn2_sub_parts = explode('=',$dn2_part,2);
146
 
147
-		$dn1_sub_part_attr = trim($dn1_sub_parts[0]);
148
-		$dn2_sub_part_attr = trim($dn2_sub_parts[0]);
149
+		$dn1_sub_part_attr = trim((string) $dn1_sub_parts[0]);
150
+		$dn2_sub_part_attr = trim((string) $dn2_sub_parts[0]);
151
 
152
-		if (0 != ($cmp = strcasecmp($dn1_sub_part_attr,$dn2_sub_part_attr)))
153
+		if (0 != ((string) $cmp = strcasecmp((string) $dn1_sub_part_attr,(string) $dn2_sub_part_attr)))
154
 			return $cmp;
155
 
156
-		$dn1_sub_part_val = trim($dn1_sub_parts[1]);
157
-		$dn2_sub_part_val = trim($dn2_sub_parts[1]);
158
-		if (0 != ($cmp = strcasecmp($dn1_sub_part_val,$dn2_sub_part_val)))
159
+		$dn1_sub_part_val = trim((string) $dn1_sub_parts[1]);
160
+		$dn2_sub_part_val = trim((string) $dn2_sub_parts[1]);
161
+		if (0 != ((string) $cmp = strcasecmp((string) $dn1_sub_part_val,(string) $dn2_sub_part_val)))
162
 			return $cmp;
163
 	}
164
 
165
@@ -1430,7 +1431,7 @@ function get_next_number($base,$attr,$increment=false,
166
 		debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs);
167
 
168
 	$server = $_SESSION[APPCONFIG]->getServer(get_request('server_id','REQUEST'));
169
-	$attr = strtolower($attr);
170
+	$attr = strtolower((string) $attr);
171
 	$query = array();
172
 
173
 	if (! $server->getValue('auto_number','enable')) {
174
@@ -1457,7 +1458,7 @@ function get_next_number($base,$attr,$increment=false,
175
 	if (! $base) {
176
 		$query['base'] = $server->getValue('auto_number','search_base');
177
 
178
-		if (! trim($query['base'])) {
179
+		if (! trim((string) $query['base'])) {
180
 			system_message(array(
181
 				'title'=>_('No AUTO_NUMBER search_base configured for this server'),
182
 				'body'=>_('A call was made to get_next_number(), however, the base to search is empty.'),
183
@@ -1628,7 +1629,7 @@ function get_icon($server_id,$dn,$object_classes=array
184
 		$object_classes = $server->getDNAttrValue($dn,'objectClass');
185
 
186
 	foreach ($object_classes as $index => $value)
187
-		$object_classes[$index] = strtolower($value);
188
+		$object_classes[$index] = strtolower((string) $value);
189
 
190
 	$rdn = get_rdn($dn);
191
 	$rdn_parts = explode('=',$rdn,2);
192
@@ -1638,7 +1639,7 @@ function get_icon($server_id,$dn,$object_classes=array
193
 
194
 	# Return icon filename based upon objectClass value
195
 	if (in_array('sambaaccount',$object_classes) &&
196
-		'$' == $rdn[ strlen($rdn) - 1 ])
197
+		'$' == $rdn[ strlen((string) $rdn) - 1 ])
198
 		return 'nt_machine.png';
199
 
200
 	if (in_array('sambaaccount',$object_classes))
201
@@ -1688,9 +1689,9 @@ function get_icon($server_id,$dn,$object_classes=array
202
 		$cval = explode('=',$tmp[0],2);
203
 		$cval = isset($cval[1]) ? $cval[1] : false;
204
 		if ($cval && false === strpos($cval,'..') &&
205
-			file_exists(realpath(sprintf('%s/../countries/%s.png',IMGDIR,strtolower($cval)))))
206
+			file_exists(realpath(sprintf('%s/../countries/%s.png',IMGDIR,strtolower((string) $cval)))))
207
 
208
-			return sprintf('../countries/%s.png',strtolower($cval));
209
+			return sprintf('../countries/%s.png',strtolower((string) $cval));
210
 
211
 		else
212
 			return 'country.png';
213
@@ -1777,13 +1778,13 @@ function get_icon($server_id,$dn,$object_classes=array
214
 		return 'hard-drive.png';
215
 
216
 	elseif (strpos($rdn_value,'ipsec') === 0 ||
217
-		strcasecmp($rdn_value,'IP Security') == 0||
218
-		strcasecmp($rdn_value,'MSRADIUSPRIVKEY Secret') == 0 ||
219
+		strcasecmp((string) $rdn_value,'IP Security') == 0||
220
+		strcasecmp((string) $rdn_value,'MSRADIUSPRIVKEY Secret') == 0 ||
221
 		strpos($rdn_value,'BCKUPKEY_') === 0)
222
 
223
 		return 'lock.png';
224
 
225
-	elseif (strcasecmp($rdn_value,'MicrosoftDNS') == 0)
226
+	elseif (strcasecmp((string) $rdn_value,'MicrosoftDNS') == 0)
227
 		return 'ldap-dc.png';
228
 
229
 	# Oh well, I don't know what it is. Use a generic icon.
230
@@ -1802,7 +1803,7 @@ function expand_dn_with_base($base,$sub_dn) {
9
 	if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
231
 	if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
10
 		debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs);
232
 		debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs);
11
 
233
 
12
@@ -2032,8 +2032,8 @@ function ldap_error_msg($msg,$errnum) {
234
-	$empty_str = (is_null($sub_dn) || (($len=strlen(trim($sub_dn))) == 0));
13
  *
235
+	$empty_str = (is_null($sub_dn) || (($len=strlen((string) trim((string) $sub_dn))) == 0));
14
  * Usage Examples:
236
 
15
  *  <code>
237
 	if ($empty_str)
16
- *   draw_jpeg_photo(0,'cn=Bob,ou=People,dc=example,dc=com',"jpegPhoto",0,true,array('img_opts'=>"border: 1px; width: 150px"));
238
 		return $base;
17
- *   draw_jpeg_photo(1,'cn=Fred,ou=People,dc=example,dc=com',null,1);
239
@@ -1927,7 +1928,7 @@ function pla_verbose_error($key) {
18
+ *   draw_jpeg_photo(0,'cn=Bob,ou=People,dc=example,dc=com',0,"jpegPhoto",true,array('img_opts'=>"border: 1px; width: 150px"));
240
 			$hex_code = isset($entry[1]) ? $entry[1] : null;
19
+ *   draw_jpeg_photo(1,'cn=Fred,ou=People,dc=example,dc=com',1,null);
241
 			$title = isset($entry[2]) ? $entry[2] : null;
20
  *  </code>
242
 			$desc = isset($entry[3]) ? $entry[3] : null;
21
  *
243
-			$desc = preg_replace('/\s+/',' ',$desc);
22
  * @param object The Server to get the image from.
244
+			$desc = preg_replace('/\s+/',' ',is_null($desc)? "":$desc);
23
@@ -2046,7 +2046,7 @@ function ldap_error_msg($msg,$errnum) {
245
 			$CACHE[$hex_code] = array('title'=>$title,'desc'=>$desc);
24
  * @param array Specifies optional image and CSS style attributes for the table tag. Supported keys are
246
 		}
25
  *                fixed_width, fixed_height, img_opts.
247
 	}
26
  */
248
@@ -1984,7 +1985,7 @@ function support_oid_to_text($key) {
27
-function draw_jpeg_photo($server,$dn,$attr_name='jpegphoto',$index,$draw_delete_buttons=false,$options=array()) {
249
 				$CACHE[$oid_id]['title'] = isset($entry[4]) ? $entry[4] : null;
28
+function draw_jpeg_photo($server,$dn,$index,$attr_name='jpegphoto',$draw_delete_buttons=false,$options=array()) {
250
 				$CACHE[$oid_id]['ref'] = isset($entry[6]) ? $entry[6] : null;
251
 				$desc = isset($entry[8]) ? $entry[8] : sprintf('<acronym title="%s">%s</acronym>',$unknown['desc'],$unknown['title']);
252
-				$CACHE[$oid_id]['desc'] = preg_replace('/\s+/',' ',$desc);
253
+				$CACHE[$oid_id]['desc'] = preg_replace('/\s+/',' ',is_null($desc)? "":$desc);
254
 			}
255
 		}
256
 	}
257
@@ -2164,7 +2165,7 @@ function pla_password_hash($password_clear,$enc_type) 
29
 	if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
258
 	if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
30
 		debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs);
259
 		debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs);
31
 
260
 
261
-	$enc_type = strtolower($enc_type);
262
+	$enc_type = strtolower((string) $enc_type);
263
 
264
 	switch($enc_type) {
265
 		case 'blowfish':
266
@@ -2335,7 +2336,7 @@ function password_check($cryptedpassword,$plainpasswor
267
 
268
 	if (preg_match('/{([^}]+)}(.*)/',$cryptedpassword,$matches)) {
269
 		$cryptedpassword = $matches[2];
270
-		$cypher = strtolower($matches[1]);
271
+		$cypher = strtolower((string) $matches[1]);
272
 
273
 	} else {
274
 		$cypher = null;
275
@@ -2389,7 +2390,7 @@ function password_check($cryptedpassword,$plainpasswor
276
 
277
 		# SHA crypted passwords
278
 		case 'sha':
279
-			if (strcasecmp(pla_password_hash($plainpassword,'sha'),'{SHA}'.$cryptedpassword) == 0)
280
+			if (strcasecmp(pla_password_hash((string) $plainpassword,'sha'),'{SHA}'.(string) $cryptedpassword) == 0)
281
 				return true;
282
 			else
283
 				return false;
284
@@ -2398,7 +2399,7 @@ function password_check($cryptedpassword,$plainpasswor
285
 
286
 		# MD5 crypted passwords
287
 		case 'md5':
288
-			if( strcasecmp(pla_password_hash($plainpassword,'md5'),'{MD5}'.$cryptedpassword) == 0)
289
+			if( strcasecmp(pla_password_hash((string) $plainpassword,'md5'),'{MD5}'.(string) $cryptedpassword) == 0)
290
 				return true;
291
 			else
292
 				return false;
293
@@ -2463,7 +2464,7 @@ function password_check($cryptedpassword,$plainpasswor
294
 
295
 		# SHA256 crypted passwords
296
 		case 'sha256':
297
-			if (strcasecmp(pla_password_hash($plainpassword,'sha256'),'{SHA256}'.$cryptedpassword) == 0)
298
+			if (strcasecmp(pla_password_hash((string) $plainpassword,'sha256'),'{SHA256}'.(string) $cryptedpassword) == 0)
299
 				return true;
300
 			else
301
 				return false;
302
@@ -2485,7 +2486,7 @@ function password_check($cryptedpassword,$plainpasswor
303
 
304
 		# SHA384 crypted passwords
305
 		case 'sha384':
306
-			if (strcasecmp(pla_password_hash($plainpassword,'sha384'),'{SHA384}'.$cryptedpassword) == 0)
307
+			if (strcasecmp(pla_password_hash((string) $plainpassword,'sha384'),'{SHA384}'.(string) $cryptedpassword) == 0)
308
 				return true;
309
 			else
310
 				return false;
311
@@ -2507,7 +2508,7 @@ function password_check($cryptedpassword,$plainpasswor
312
 
313
 		# SHA512 crypted passwords
314
 		case 'sha512':
315
-			if (strcasecmp(pla_password_hash($plainpassword,'sha512'),'{SHA512}'.$cryptedpassword) == 0)
316
+			if (strcasecmp(pla_password_hash((string) $plainpassword,'sha512'),'{SHA512}'.(string) $cryptedpassword) == 0)
317
 				return true;
318
 			else
319
 				return false;
320
@@ -2554,12 +2555,12 @@ function get_enc_type($user_password) {
321
 	$enc_type = null;
322
 
323
 	if (preg_match('/{([^}]+)}/',$user_password,$enc_type))
324
-		$enc_type = strtolower($enc_type[1]);
325
+		$enc_type = strtolower((string) $enc_type[1]);
326
 	else
327
 		return null;
328
 
329
 	# Handle crypt types
330
-	if (strcasecmp($enc_type,'crypt') == 0) {
331
+	if (strcasecmp((string) $enc_type,'crypt') == 0) {
332
 
333
 		# No need to check for standard crypt, because enc_type is already equal to 'crypt'.
334
 		if (preg_match('/{[^}]+}\\$1\\$+/',$user_password))
335
@@ -2698,9 +2699,9 @@ function dn_escape($dn) {
336
 
337
 	# Check if the RDN has a comma and escape it.
338
 	while (preg_match('/([^\\\\]),(\s*[^=]*\s*),/',$dn))
339
-		$dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*),/','$1\\\\2C$2,',$dn);
340
+		$dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*),/','$1\\\\2C$2,',is_null($dn)? "":$dn);
341
 
342
-	$dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*)([^,])$/','$1\\\\2C$2$3',$dn);
343
+	$dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*)([^,])$/','$1\\\\2C$2$3',is_null($dn)? "":$dn);
344
 
345
 	if (DEBUG_ENABLED)
346
 		debug_log('Returning (%s)',1,0,__FILE__,__LINE__,__METHOD__,$dn);
347
@@ -2872,17 +2873,17 @@ function sortAttrs($a,$b) {
348
 	$b_key = array_search($b->getName(),$attrs_display_order);
349
 
350
 	if ((! $a_key) && ($a_key !== 0))
351
-		if ((! $a_key = array_search(strtolower($a->getFriendlyName()),$attrs_display_order)) && ($a_key !== 0))
352
+		if ((! $a_key = array_search(strtolower((string) $a->getFriendlyName()),$attrs_display_order)) && ($a_key !== 0))
353
 			$a_key = count($attrs_display_order)+1;
354
 
355
 	if ((! $b_key) && ($b_key !== 0))
356
-		if ((! $b_key = array_search(strtolower($b->getFriendlyName()),$attrs_display_order)) && ($b_key !== 0))
357
+		if ((! $b_key = array_search(strtolower((string) $b->getFriendlyName()),$attrs_display_order)) && ($b_key !== 0))
358
 			$b_key = count($attrs_display_order)+1;
359
 
360
 	# Case where neither $a, nor $b are in $attrs_display_order, $a_key = $b_key = one greater than num elements.
361
 	# So we sort them alphabetically
362
 	if ($a_key === $b_key)
363
-		return strcasecmp($a->getFriendlyName(),$b->getFriendlyName());
364
+		return strcasecmp((string) $a->getFriendlyName(),(string) $b->getFriendlyName());
365
 
366
 	# Case where at least one attribute or its friendly name is in $attrs_display_order
367
 	# return -1 if $a before $b in $attrs_display_order
368
@@ -2904,7 +2905,7 @@ function arrayLower($array) {
369
 
370
 	$newarray = array();
371
 	foreach ($array as $key => $value)
372
-		$newarray[$key] = strtolower($value);
373
+		$newarray[$key] = strtolower((string) $value);
374
 
375
 	return $newarray;
376
 }
377
@@ -2929,7 +2930,7 @@ function in_array_ignore_case($needle,$haystack) {
378
 	$return = false;
379
 
380
 	foreach ($haystack as $element) {
381
-		if (is_string($element) && (strcasecmp($needle,$element) == 0)) {
382
+		if (is_string((string) $element) && (strcasecmp((string) $needle,(string) $element) == 0)) {
383
 			$return = true;
384
 			break;
385
 		}
386
@@ -2961,13 +2962,13 @@ function draw_formatted_dn($server,$entry) {
387
 			debug_log('The tokens are (%s)',1,0,__FILE__,__LINE__,__METHOD__,$tokens);
388
 
389
 		foreach ($tokens as $token) {
390
-			if (strcasecmp($token,'%dn') == 0)
391
+			if (strcasecmp((string) $token,'%dn') == 0)
392
 				$format = str_replace($token,pretty_print_dn($dn),$format);
393
 
394
-			elseif (strcasecmp($token,'%rdn') == 0)
395
+			elseif (strcasecmp((string) $token,'%rdn') == 0)
396
 				$format = str_replace($token,pretty_print_dn($entry->getRDN()),$format);
397
 
398
-			elseif (strcasecmp($token,'%rdnvalue') == 0) {
399
+			elseif (strcasecmp((string) $token,'%rdnvalue') == 0) {
400
 				$rdn = get_rdn($dn,0,true);
401
 				$rdn_value = explode('=',$rdn,2);
402
 				$rdn_value = $rdn_value[1];
403
@@ -3046,7 +3047,7 @@ function littleEndian($hex) {
404
 
405
 	$result = '';
406
 
407
-	for ($x=strlen($hex)-2;$x>= 0;$x=$x-2)
408
+	for ($x=strlen((string) $hex)-2;$x>= 0;$x=$x-2)
409
 		$result .= substr($hex,$x,2);
410
 
411
 	return $result;
412
@@ -3088,7 +3089,7 @@ function return_ldap_hash($base,$filter,$key,$attrs,$s
413
 		debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs);
414
 
415
 	$server = $_SESSION[APPCONFIG]->getServer(get_request('server_id','REQUEST'));
416
-	$key = strtolower($key);
417
+	$key = strtolower((string) $key);
418
 
419
 	$query = array();
420
 	$query['base'] = $base;
421
@@ -3103,21 +3104,21 @@ function return_ldap_hash($base,$filter,$key,$attrs,$s
422
 			if (is_array($values[$key]))
423
 				foreach ($values[$key] as $i => $k)
424
 					foreach ($attrs as $attr) {
425
-						$lattr = strtolower($attr);
426
+						$lattr = strtolower((string) $attr);
427
 						if (isset($values[$lattr])) {
428
 							$v = '';
429
 
430
 							if (is_array($values[$lattr]) && isset($values[$lattr][$i]))
431
 								$v = $values[$lattr][$i];
432
 
433
-							if (is_string($v) && (strlen($v) > 0))
434
+							if (is_string($v) && (strlen((string) $v) > 0))
435
 								$results[$k][$attr] = $v;
436
 						}
437
 					}
438
 
439
 			else
440
 				foreach ($attrs as $attr) {
441
-					$lattr = strtolower($attr);
442
+					$lattr = strtolower((string) $attr);
443
 					if (isset($values[$lattr]))
444
 						$results[$values[$key]][$attr] = $values[$lattr];
445
 				}
446
@@ -3263,7 +3264,7 @@ function random_junk() {
447
  * @return string
448
  */
449
 function htmlid($sid,$dn) {
450
-	return sprintf('SID%s:%s',$sid,preg_replace('/[\ =,]/','_',$dn));
451
+	return sprintf('SID%s:%s',$sid,preg_replace('/[\ =,]/','_',is_null($dn)? "":$dn));
452
 }
453
 
454
 /**
(-)b/net/phpldapadmin/files/patch-lib_import__functions.php (+104 lines)
Added Link Here
1
--- lib/import_functions.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/import_functions.php
3
@@ -86,7 +86,7 @@ abstract class Import {
4
 		if (get_request('ldif','REQUEST')) {
5
 			$this->input = explode("\n",get_request('ldif','REQUEST'));
6
 			$this->source['name'] = 'STDIN';
7
-			$this->source['size'] = strlen(get_request('ldif','REQUEST'));
8
+			$this->source['size'] = strlen((string) get_request('ldif','REQUEST'));
9
 
10
 		} elseif (isset($_FILES['ldif_file']) && is_array($_FILES['ldif_file']) && ! $_FILES['ldif_file']['error']) {
11
 			$input = file_get_contents($_FILES['ldif_file']['tmp_name']);
12
@@ -253,9 +253,9 @@ class ImportLDIF extends Import {
13
 
14
 		# Get the DN
15
 		if (substr($value,0,1) == ':')
16
-			$value = base64_decode(trim(substr($value,1)));
17
+			$value = base64_decode(trim((string) substr($value,1)));
18
 		else
19
-			$value = trim($value);
20
+			$value = trim((string) $value);
21
 
22
 		return array($attr,$value);
23
 	}
24
@@ -271,7 +271,7 @@ class ImportLDIF extends Import {
25
 
26
 		if ($this->hasMoreEntries() && ! $this->eof()) {
27
 			# The first line is the DN one
28
-			$current[0]= trim($this->_currentLine);
29
+			$current[0]= trim((string) $this->_currentLine);
30
 
31
 			# While we end on a blank line, fetch the attribute lines
32
 			$count = 0;
33
@@ -282,11 +282,11 @@ class ImportLDIF extends Import {
34
 				/* If the next line begin with a space, we append it to the current row
35
 				 * else we push it into the array (unwrap)*/
36
 				if ($this->isWrappedLine())
37
-					$current[$count] .= trim($this->_currentLine);
38
+					$current[$count] .= trim((string) $this->_currentLine);
39
 				elseif ($this->isCommentLine()) {}
40
 				# Do nothing
41
 				elseif (! $this->isBlankLine())
42
-					$current[++$count] = trim($this->_currentLine);
43
+					$current[++$count] = trim((string) $this->_currentLine);
44
 				else
45
 					$endEntryFound = true;
46
 			}
47
@@ -336,7 +336,7 @@ class ImportLDIF extends Import {
48
 	 * @return boolean true if it's a comment line,false otherwise
49
 	 */
50
 	private function isCommentLine() {
51
-		return substr(trim($this->_currentLine),0,1) == '#' ? true : false;
52
+		return substr(trim((string) $this->_currentLine),0,1) == '#' ? true : false;
53
 	}
54
 
55
 	/**
56
@@ -354,7 +354,7 @@ class ImportLDIF extends Import {
57
 	 * @return boolean if it is a blank line,false otherwise.
58
 	 */
59
 	private function isBlankLine() {
60
-		return(trim($this->_currentLine) == '') ? true : false;
61
+		return(trim((string) $this->_currentLine) == '') ? true : false;
62
 	}
63
 
64
 	/**
65
@@ -383,10 +383,10 @@ class ImportLDIF extends Import {
66
 		$return = '';
67
 
68
 		if (substr($value,0,1) == '<') {
69
-			$url = trim(substr($value,1));
70
+			$url = trim((string) substr($value,1));
71
 
72
 			if (preg_match('^file://',$url)) {
73
-				$filename = substr(trim($url),7);
74
+				$filename = substr(trim((string) $url),7);
75
 
76
 				if ($fh = @fopen($filename,'rb')) {
77
 					if (! $return = @fread($fh,filesize($filename)))
78
@@ -404,7 +404,7 @@ class ImportLDIF extends Import {
79
 		} else
80
 			$return = $value;
81
 
82
-		return trim($return);
83
+		return trim((string) $return);
84
 	}
85
 
86
 	/**
87
@@ -480,7 +480,7 @@ class ImportLDIF extends Import {
88
 			# Fetch the attribute for the following line
89
 			$currentLine = array_shift($lines);
90
 
91
-			while ($processline && trim($currentLine) && (trim($currentLine) != '-')) {
92
+			while ($processline && trim((string) $currentLine) && (trim((string) $currentLine) != '-')) {
93
 				$processline = false;
94
 
95
 				# If there is a valid line
96
@@ -541,7 +541,7 @@ class ImportLDIF extends Import {
97
 						array_merge(array($currentLine),$lines));
98
 
99
 				$currentLine = array_shift($lines);
100
-				if (trim($currentLine))
101
+				if (trim((string) $currentLine))
102
 					$processline = true;
103
 			}
104
 
(-)b/net/phpldapadmin/files/patch-lib_page.php (+29 lines)
Added Link Here
1
--- lib/page.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/page.php
3
@@ -184,7 +184,7 @@ class page {
4
 		$empty = true;
5
 		if (function_exists('cmd_control_pane'))
6
 			foreach (cmd_control_pane('main') as $cmddetails)
7
-				if ((isset($cmddetails['enable']) && trim($cmddetails['enable'])) || ! isset($cmddetails['enable'])) {
8
+				if ((isset($cmddetails['enable']) && trim((string) $cmddetails['enable'])) || ! isset($cmddetails['enable'])) {
9
 					if (! $empty)
10
 						echo ' | ';
11
 
12
@@ -358,7 +358,7 @@ class page {
13
 
14
 			if (defined('DEBUG_ENABLED') && DEBUG_ENABLED)
15
 				debug_log('Sending COMPRESSED output to browser[(%s),%s]',129,0,__FILE__,__LINE__,__METHOD__,
16
-					strlen($output),$output);
17
+					strlen((string) $output),$output);
18
 
19
 			print gzencode($output);
20
 		}
21
@@ -445,7 +445,7 @@ class page {
22
 
23
 			if (defined('DEBUG_ENABLED') && DEBUG_ENABLED)
24
 				debug_log('Sending COMPRESSED output to browser[(%s),%s]',129,0,__FILE__,__LINE__,__METHOD__,
25
-					strlen($output),$output);
26
+					strlen((string) $output),$output);
27
 
28
 			print gzencode($output);
29
 		}
(-)b/net/phpldapadmin/files/patch-lib_schema__functions.php (+365 lines)
Added Link Here
1
--- lib/schema_functions.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/schema_functions.php
3
@@ -74,7 +74,7 @@ abstract class SchemaItem {
4
 		if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
5
 			debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->name);
6
 
7
-		return $lower ? strtolower($this->name) : $this->name;
8
+		return $lower ? strtolower((string) $this->name) : $this->name;
9
 	}
10
 }
11
 
12
@@ -125,7 +125,7 @@ class ObjectClass extends SchemaItem {
13
 					if ($strings[$i+1]!='(') {
14
 						do {
15
 							$i++;
16
-							if (strlen($this->name) == 0)
17
+							if (strlen((string) $this->name) == 0)
18
 								$this->name = $strings[$i];
19
 							else
20
 								$this->name .= ' '.$strings[$i];
21
@@ -136,7 +136,7 @@ class ObjectClass extends SchemaItem {
22
 						$i++;
23
 						do {
24
 							$i++;
25
-							if (strlen($this->name) == 0)
26
+							if (strlen((string) $this->name) == 0)
27
 								$this->name = $strings[$i];
28
 							else
29
 								$this->name .= ' '.$strings[$i];
30
@@ -148,8 +148,8 @@ class ObjectClass extends SchemaItem {
31
 						} while (! preg_match('/\)+\)?/',$strings[$i]));
32
 					}
33
 
34
-					$this->name = preg_replace('/^\'/','',$this->name);
35
-					$this->name = preg_replace('/\'$/','',$this->name);
36
+					$this->name = preg_replace('/^\'/','',is_null($this->name)? "":$this->name);
37
+					$this->name = preg_replace('/\'$/','',is_null($this->name)? "":$this->name);
38
 
39
 					if (DEBUG_ENABLED)
40
 						debug_log('Case NAME returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->name);
41
@@ -158,7 +158,7 @@ class ObjectClass extends SchemaItem {
42
 				case 'DESC':
43
 					do {
44
 						$i++;
45
-						if (strlen($this->description) == 0)
46
+						if (strlen((string) $this->description) == 0)
47
 							$this->description=$this->description.$strings[$i];
48
 						else
49
 							$this->description=$this->description.' '.$strings[$i];
50
@@ -179,14 +179,14 @@ class ObjectClass extends SchemaItem {
51
 				case 'SUP':
52
 					if ($strings[$i+1] != '(') {
53
 						$i++;
54
-						array_push($this->sup_classes,preg_replace("/'/",'',$strings[$i]));
55
+						array_push($this->sup_classes,preg_replace("/'/",'',is_null($strings[$i])? "":$strings[$i]));
56
 
57
 					} else {
58
 						$i++;
59
 						do {
60
 							$i++;
61
 							if ($strings[$i] != '$')
62
-								array_push($this->sup_classes,preg_replace("/'/",'',$strings[$i]));
63
+								array_push($this->sup_classes,preg_replace("/'/",'',is_null($strings[$i])? "":$strings[$i]));
64
 
65
 						} while (! preg_match('/\)+\)?/',$strings[$i+1]));
66
 					}
67
@@ -267,8 +267,8 @@ class ObjectClass extends SchemaItem {
68
 			}
69
 		}
70
 
71
-		$this->description = preg_replace("/^\'/",'',$this->description);
72
-		$this->description = preg_replace("/\'$/",'',$this->description);
73
+		$this->description = preg_replace("/^\'/",'',is_null($this->description)? "":$this->description);
74
+		$this->description = preg_replace("/\'$/",'',is_null($this->description)? "":$this->description);
75
 
76
 		if (DEBUG_ENABLED)
77
 			debug_log('Returning () - NAME (%s), DESCRIPTION (%s), MUST (%s), MAY (%s), FORCE MAY (%s)',9,0,__FILE__,__LINE__,__METHOD__,
78
@@ -293,13 +293,13 @@ class ObjectClass extends SchemaItem {
79
 		if (! preg_match('/^\(/',$string)) {
80
 			# A bareword only - can be terminated by a ) if the last item
81
 			if (preg_match('/\)+$/',$string))
82
-				$string = preg_replace('/\)+$/','',$string);
83
+				$string = preg_replace('/\)+$/','',is_null($string)? "":$string);
84
 
85
 			array_push($attrs,$string);
86
 
87
 		} elseif (preg_match('/^\(.*\)$/',$string)) {
88
-			$string = preg_replace('/^\(/','',$string);
89
-			$string = preg_replace('/\)+$/','',$string);
90
+			$string = preg_replace('/^\(/','',is_null($string)? "":$string);
91
+			$string = preg_replace('/\)+$/','',is_null($string)? "":$string);
92
 			array_push($attrs,$string);
93
 
94
 		} else {
95
@@ -308,7 +308,7 @@ class ObjectClass extends SchemaItem {
96
 				$i++;
97
 
98
 			} elseif (preg_match('/^\(./',$string)) {
99
-				$string = preg_replace('/^\(/','',$string);
100
+				$string = preg_replace('/^\(/','',is_null($string)? "":$string);
101
 				array_push($attrs,$string);
102
 				$i++;
103
 			}
104
@@ -323,7 +323,7 @@ class ObjectClass extends SchemaItem {
105
 				}
106
 
107
 				if (preg_match('/\)$/',$string))
108
-					$string = preg_replace('/\)+$/','',$string);
109
+					$string = preg_replace('/\)+$/','',is_null($string)? "":$string);
110
 				else
111
 					$i++;
112
 
113
@@ -519,10 +519,10 @@ class ObjectClass extends SchemaItem {
114
 		if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
115
 			debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs);
116
 
117
-		$name = trim($name);
118
+		$name = trim((string) $name);
119
 
120
 		foreach ($this->children_objectclasses as $existing_objectclass)
121
-			if (strcasecmp($name,$existing_objectclass) == 0)
122
+			if (strcasecmp((string) $name,(string) $existing_objectclass) == 0)
123
 				return false;
124
 
125
 		array_push($this->children_objectclasses,$name);
126
@@ -683,7 +683,7 @@ class ObjectClass_ObjectClassAttribute {
127
 		if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
128
 			debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->name);
129
 
130
-		return $lower ? strtolower($this->name) : $this->name;
131
+		return $lower ? strtolower((string) $this->name) : $this->name;
132
 	}
133
 
134
 	# Gets the name of the ObjectClass which originally specified this attribute.
135
@@ -754,7 +754,7 @@ class AttributeType extends SchemaItem {
136
 					if ($strings[$i+1] != '(' && ! preg_match('/^\(/',$strings[$i+1])) {
137
 						do {
138
 							$i++;
139
-							if (strlen($this->name)==0)
140
+							if (strlen((string) $this->name)==0)
141
 								$this->name = $strings[$i];
142
 							else
143
 								$this->name .= ' '.$strings[$i];
144
@@ -769,11 +769,11 @@ class AttributeType extends SchemaItem {
145
 						do {
146
 							# In case we came here becaues of a ('
147
 							if (preg_match('/^\(/',$strings[$i]))
148
-								$strings[$i] = preg_replace('/^\(/','',$strings[$i]);
149
+								$strings[$i] = preg_replace('/^\(/','',is_null($strings[$i])? "":$strings[$i]);
150
 							else
151
 								$i++;
152
 
153
-							if (strlen($this->name) == 0)
154
+							if (strlen((string) $this->name) == 0)
155
  								$this->name = $strings[$i];
156
 							else
157
 								$this->name .= ' '.$strings[$i];
158
@@ -783,8 +783,8 @@ class AttributeType extends SchemaItem {
159
 						# Add alias names for this attribute
160
 						while ($strings[++$i] != ')') {
161
 							$alias = $strings[$i];
162
-							$alias = preg_replace("/^\'/",'',$alias);
163
-							$alias = preg_replace("/\'$/",'',$alias);
164
+							$alias = preg_replace("/^\'/",'',is_null($alias)? "":$alias);
165
+							$alias = preg_replace("/\'$/",'',is_null($alias)? "":$alias);
166
 							$this->addAlias($alias);
167
 						}
168
 					}
169
@@ -796,7 +796,7 @@ class AttributeType extends SchemaItem {
170
 				case 'DESC':
171
 					do {
172
 						$i++;
173
-						if (strlen($this->description)==0)
174
+						if (strlen((string) $this->description)==0)
175
 							$this->description=$this->description.$strings[$i];
176
 						else
177
 							$this->description=$this->description.' '.$strings[$i];
178
@@ -848,7 +848,7 @@ class AttributeType extends SchemaItem {
179
 				case 'SYNTAX':
180
 					$i++;
181
 					$this->syntax = $strings[$i];
182
-					$this->syntax_oid = preg_replace('/{\d+}$/','',$this->syntax);
183
+					$this->syntax_oid = preg_replace('/{\d+}$/','',is_null($this->syntax)? "":$this->syntax);
184
 
185
 					# Does this SYNTAX string specify a max length (ie, 1.2.3.4{16})
186
 					if (preg_match('/{(\d+)}$/',$this->syntax,$this->max_length))
187
@@ -906,16 +906,16 @@ class AttributeType extends SchemaItem {
188
 			}
189
 		}
190
 
191
-		$this->name = preg_replace("/^\'/",'',$this->name);
192
-		$this->name = preg_replace("/\'$/",'',$this->name);
193
-		$this->description = preg_replace("/^\'/",'',$this->description);
194
-		$this->description = preg_replace("/\'$/",'',$this->description);
195
-		$this->syntax = preg_replace("/^\'/",'',$this->syntax);
196
-		$this->syntax = preg_replace("/\'$/",'',$this->syntax);
197
-		$this->syntax_oid = preg_replace("/^\'/",'',$this->syntax_oid);
198
-		$this->syntax_oid = preg_replace("/\'$/",'',$this->syntax_oid);
199
-		$this->sup_attribute = preg_replace("/^\'/",'',$this->sup_attribute);
200
-		$this->sup_attribute = preg_replace("/\'$/",'',$this->sup_attribute);
201
+		$this->name = preg_replace("/^\'/",'',is_null($this->name)? "":$this->name);
202
+		$this->name = preg_replace("/\'$/",'',is_null($this->name)? "":$this->name);
203
+		$this->description = preg_replace("/^\'/",'',is_null($this->description)? "":$this->description);
204
+		$this->description = preg_replace("/\'$/",'',is_null($this->description)? "":$this->description);
205
+		$this->syntax = preg_replace("/^\'/",'',is_null($this->syntax)? "":$this->syntax);
206
+		$this->syntax = preg_replace("/\'$/",'',is_null($this->syntax)? "":$this->syntax);
207
+		$this->syntax_oid = preg_replace("/^\'/",'',is_null($this->syntax_oid)? "":$this->syntax_oid);
208
+		$this->syntax_oid = preg_replace("/\'$/",'',is_null($this->syntax_oid)? "":$this->syntax_oid);
209
+		$this->sup_attribute = preg_replace("/^\'/",'',is_null($this->sup_attribute)? "":$this->sup_attribute);
210
+		$this->sup_attribute = preg_replace("/\'$/",'',is_null($this->sup_attribute)? "":$this->sup_attribute);
211
 
212
 		if (DEBUG_ENABLED)
213
 			debug_log('Returning ()',9,0,__FILE__,__LINE__,__METHOD__);
214
@@ -1006,7 +1006,7 @@ class AttributeType extends SchemaItem {
215
 			debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs);
216
 
217
 		foreach ($this->aliases as $alias_attr_name)
218
-			if (strcasecmp($alias_attr_name,$attr_name) == 0)
219
+			if (strcasecmp((string) $alias_attr_name,(string) $attr_name) == 0)
220
 				return true;
221
 
222
 		return false;
223
@@ -1125,7 +1125,7 @@ class AttributeType extends SchemaItem {
224
 
225
 		foreach ($this->aliases as $i => $alias_name) {
226
 
227
-			if (strcasecmp($alias_name,$remove_alias_name) == 0) {
228
+			if (strcasecmp((string) $alias_name,(string) $remove_alias_name) == 0) {
229
 				unset($this->aliases[$i]);
230
 
231
 				$this->aliases = array_values($this->aliases);
232
@@ -1209,7 +1209,7 @@ class AttributeType extends SchemaItem {
233
 			if (DEBUG_ENABLED)
234
 				debug_log('Checking (%s) with (%s)',8,0,__FILE__,__LINE__,__METHOD__,$used_in_object_class,$name);
235
 
236
-			if (strcasecmp($used_in_object_class,$name) == 0)
237
+			if (strcasecmp((string) $used_in_object_class,(string) $name) == 0)
238
 				return false;
239
 		}
240
 
241
@@ -1240,7 +1240,7 @@ class AttributeType extends SchemaItem {
242
 			debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs);
243
 
244
 		foreach ($this->required_by_object_classes as $required_by_object_class)
245
-			if (strcasecmp($required_by_object_class,$name) == 0)
246
+			if (strcasecmp((string) $required_by_object_class,(string) $name) == 0)
247
 				return false;
248
 
249
 		array_push($this->required_by_object_classes,$name);
250
@@ -1301,7 +1301,7 @@ class Syntax extends SchemaItem {
251
 				case 'DESC':
252
 					do {
253
 						$i++;
254
-						if (strlen($this->description) == 0)
255
+						if (strlen((string) $this->description) == 0)
256
 							$this->description=$this->description.$strings[$i];
257
 						else
258
 							$this->description=$this->description.' '.$strings[$i];
259
@@ -1314,8 +1314,8 @@ class Syntax extends SchemaItem {
260
 			}
261
 		}
262
 
263
-		$this->description = preg_replace("/^\'/",'',$this->description);
264
-		$this->description = preg_replace("/\'$/",'',$this->description);
265
+		$this->description = preg_replace("/^\'/",'',is_null($this->description)? "":$this->description);
266
+		$this->description = preg_replace("/\'$/",'',is_null($this->description)? "":$this->description);
267
 	}
268
 }
269
 
270
@@ -1349,7 +1349,7 @@ class MatchingRule extends SchemaItem {
271
 					if ($strings[$i+1] != '(') {
272
 						do {
273
 							$i++;
274
-							if (strlen($this->name) == 0)
275
+							if (strlen((string) $this->name) == 0)
276
 								$this->name = $strings[$i];
277
 						else
278
 								$this->name .= ' '.$strings[$i];
279
@@ -1359,7 +1359,7 @@ class MatchingRule extends SchemaItem {
280
 						$i++;
281
 						do {
282
 							$i++;
283
-							if (strlen($this->name) == 0)
284
+							if (strlen((string) $this->name) == 0)
285
 								$this->name = $strings[$i];
286
 							else
287
 								$this->name .= ' '.$strings[$i];
288
@@ -1370,14 +1370,14 @@ class MatchingRule extends SchemaItem {
289
 						} while (! preg_match('/\)+\)?/',$strings[$i]));
290
 					}
291
 
292
-					$this->name = preg_replace("/^\'/",'',$this->name);
293
-					$this->name = preg_replace("/\'$/",'',$this->name);
294
+					$this->name = preg_replace("/^\'/",'',is_null($this->name)? "":$this->name);
295
+					$this->name = preg_replace("/\'$/",'',is_null($this->name)? "":$this->name);
296
 					break;
297
 
298
 				case 'DESC':
299
 					do {
300
 						$i++;
301
-						if (strlen($this->description)==0)
302
+						if (strlen((string) $this->description)==0)
303
 							$this->description=$this->description.$strings[$i];
304
 						else
305
 							$this->description=$this->description.' '.$strings[$i];
306
@@ -1397,8 +1397,8 @@ class MatchingRule extends SchemaItem {
307
 						$this->setOID($strings[$i]);
308
 			}
309
 		}
310
-		$this->description = preg_replace("/^\'/",'',$this->description);
311
-		$this->description = preg_replace("/\'$/",'',$this->description);
312
+		$this->description = preg_replace("/^\'/",'',is_null($this->description)? "":$this->description);
313
+		$this->description = preg_replace("/\'$/",'',is_null($this->description)? "":$this->description);
314
 	}
315
 
316
 	/**
317
@@ -1423,7 +1423,7 @@ class MatchingRule extends SchemaItem {
318
 			debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs);
319
 
320
 		foreach ($this->used_by_attrs as $attr_name)
321
-			if (strcasecmp($attr_name,$attr) == 0)
322
+			if (strcasecmp((string) $attr_name,(string) $attr) == 0)
323
 				return false;
324
 
325
 		array_push($this->used_by_attrs,$attr);
326
@@ -1469,7 +1469,7 @@ class MatchingRuleUse extends SchemaItem {
327
 					if ($strings[$i+1] != '(') {
328
 						do {
329
 							$i++;
330
-							if (! isset($this->name) || strlen($this->name) == 0)
331
+							if (! isset($this->name) || strlen((string) $this->name) == 0)
332
 								$this->name = $strings[$i];
333
 							else
334
 								$this->name .= ' '.$strings[$i];
335
@@ -1480,7 +1480,7 @@ class MatchingRuleUse extends SchemaItem {
336
 						$i++;
337
 						do {
338
 							$i++;
339
-							if (strlen($this->name) == 0)
340
+							if (strlen((string) $this->name) == 0)
341
 								$this->name = $strings[$i];
342
 							else
343
 								$this->name .= ' '.$strings[$i];
344
@@ -1491,8 +1491,8 @@ class MatchingRuleUse extends SchemaItem {
345
 						} while (! preg_match('/\)+\)?/',$strings[$i]));
346
 					}
347
 
348
-					$this->name = preg_replace("/^\'/",'',$this->name);
349
-					$this->name = preg_replace("/\'$/",'',$this->name);
350
+					$this->name = preg_replace("/^\'/",'',is_null($this->name)? "":$this->name);
351
+					$this->name = preg_replace("/\'$/",'',is_null($this->name)? "":$this->name);
352
 					break;
353
 
354
 				case 'APPLIES':
355
@@ -1507,8 +1507,8 @@ class MatchingRuleUse extends SchemaItem {
356
 						while ($strings[$i] != ')') {
357
 							$i++;
358
 							$new_attr = $strings[$i];
359
-							$new_attr = preg_replace("/^\'/",'',$new_attr);
360
-							$new_attr = preg_replace("/\'$/",'',$new_attr);
361
+							$new_attr = preg_replace("/^\'/",'',is_null($new_attr)? "":$new_attr);
362
+							$new_attr = preg_replace("/\'$/",'',is_null($new_attr)? "":$new_attr);
363
 							array_push($this->used_by_attrs,$new_attr);
364
 							$i++;
365
 						}
(-)b/net/phpldapadmin/files/patch-lib_xml2array.php (+20 lines)
Added Link Here
1
--- lib/xml2array.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/xml2array.php
3
@@ -59,7 +59,7 @@ class xml2array {
4
 	}
5
 
6
 	private function tagOpen($parser,$name,$attrs) {
7
-		$name = strtolower($name);
8
+		$name = strtolower((string) $name);
9
 
10
 		if (isset($this->stack_ref[$name])) {
11
 			if (! isset($this->stack_ref[$name][0])) {
12
@@ -86,7 +86,7 @@ class xml2array {
13
 	}
14
 
15
 	private function tagData($parser,$tagData) {
16
-		if (trim($tagData) != '') {
17
+		if (trim((string) $tagData) != '') {
18
 
19
 			if (isset($this->stack_ref['#text']))
20
 				$this->stack_ref['#text'] .= $tagData;
(-)b/net/phpldapadmin/files/patch-lib_xmlTemplates.php (-6 / +42 lines)
Lines 1-11 Link Here
1
--- lib/xmlTemplates.php.orig	2021-12-12 02:35:51 UTC
1
--- lib/xmlTemplates.php.orig	2021-12-12 02:35:51 UTC
2
+++ lib/xmlTemplates.php
2
+++ lib/xmlTemplates.php
3
@@ -140,7 +140,7 @@ abstract class xmlTemplates {
3
@@ -85,7 +85,7 @@ abstract class xmlTemplates {
4
 					$filename = sprintf('%s/%s',$dir,$file);
4
 
5
 
5
 		if ($changed) {
6
 					if (! in_array($filename,$this->getTemplateFiles())) {
6
 			masort($this->templates,'title');
7
-						$templatename = preg_replace('/.xml$/','',$file);
7
-			set_cached_item($server_id,$class['item'],'null',$this->templates);
8
+						$templatename = preg_replace('/.xml$/','',is_null($file)? "":$file);
8
+			set_cached_item($server_id,$this->templates,$class['item'],'null');
9
 	
9
 		}
10
 						$this->templates[$index] = new $class['name']($this->server_id,$templatename,$filename,$type,$index);
11
 						$index++;
12
@@ -128,7 +128,7 @@ abstract class xmlTemplates {
13
 					$filename = sprintf('%s/%s',$dir,$file);
14
 
15
 					# Store the template
16
-					$templatename = preg_replace('/.xml$/','',$file);
17
+					$templatename = preg_replace('/.xml$/','',is_null($file)? "":$file);
18
 					$this->templates[$counter] = new $class['name']($this->server_id,$templatename,$filename,$type,$counter);
19
 					$counter++;
20
 				}
21
@@ -304,7 +304,7 @@ abstract class xmlTemplate {
22
 			debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
23
 
24
 		foreach ($this->attributes as $index => $attribute)
25
-			if (strtolower($attr) == $attribute->getName() || in_array(strtolower($attr),$attribute->getAliases()))
26
+			if (strtolower((string) $attr) == $attribute->getName() || in_array(strtolower($attr),$attribute->getAliases()))
27
 				return $index;
28
 
29
 		return null;
30
@@ -343,7 +343,7 @@ abstract class xmlTemplate {
31
 			debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->name);
32
 
33
 		if ($lower)
34
-			return strtolower($this->name);
35
+			return strtolower((string) $this->name);
36
 		else
37
 			return $this->name;
10
 	}
38
 	}
39
@@ -482,7 +482,7 @@ abstract class xmlTemplate {
40
 			debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
41
 
42
 		foreach ($this->attributes as $attribute)
43
-			if (($attribute->getName() == strtolower($name)) || in_array(strtolower($name),$attribute->getAliases()))
44
+			if (($attribute->getName() == strtolower((string) $name)) || in_array(strtolower($name),$attribute->getAliases()))
45
 				return $attribute;
11
 
46
 
47
 		return null;

Return to bug 266678