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 |
/** |