@@ -327,113 +327,3 @@ function is_dir_writeable($dir)
327
327
}
328
328
return false ;
329
329
}
330
-
331
- if (!function_exists ('sys_get_temp_dir ' )) {
332
- // Based on http://www.phpit.net/
333
- // article/creating-zip-tar-archives-dynamically-php/2/
334
- /**
335
- * @return bool|string
336
- */
337
- function sys_get_temp_dir ()
338
- {
339
- // Try to get from environment variable
340
- if (!empty ($ _ENV ['TMP ' ])) {
341
- return realpath ($ _ENV ['TMP ' ]);
342
- } elseif (!empty ($ _ENV ['TMPDIR ' ])) {
343
- return realpath ($ _ENV ['TMPDIR ' ]);
344
- } elseif (!empty ($ _ENV ['TEMP ' ])) {
345
- return realpath ($ _ENV ['TEMP ' ]);
346
- } else {
347
- // Try to use system's temporary directory
348
- // as random name shouldn't exist
349
- $ temp_file = tempnam (md5 (uniqid (rand (), true )), '' );
350
- if ($ temp_file ) {
351
- $ temp_dir = realpath (dirname ($ temp_file ));
352
- unlink ($ temp_file );
353
- return $ temp_dir ;
354
- } else {
355
- return false ;
356
- }
357
- }
358
- }
359
- }
360
-
361
- if (!function_exists ('hash_equals ' )) {
362
- /**
363
- * Compares two strings using the same time whether they're equal or not.
364
- * A difference in length will leak
365
- *
366
- * @param string $known_string
367
- * @param string $user_string
368
- * @return bool Returns true when the two strings are equal, false otherwise.
369
- */
370
- function hash_equals ($ known_string , $ user_string )
371
- {
372
- $ result = 0 ;
373
-
374
- if (!is_string ($ known_string )) {
375
- trigger_error ("hash_equals(): Expected known_string to be a string " , E_USER_WARNING );
376
- return false ;
377
- }
378
-
379
- if (!is_string ($ user_string )) {
380
- trigger_error ("hash_equals(): Expected user_string to be a string " , E_USER_WARNING );
381
- return false ;
382
- }
383
-
384
- if (strlen ($ known_string ) != strlen ($ user_string )) {
385
- return false ;
386
- }
387
-
388
- for ($ i = 0 ; $ i < strlen ($ known_string ); $ i ++) {
389
- $ result |= (ord ($ known_string [$ i ]) ^ ord ($ user_string [$ i ]));
390
- }
391
-
392
- return $ result === 0 ;
393
- }
394
- }
395
-
396
- /**
397
- * polyfill for PHP 8.0 function "str_contains"
398
- */
399
- if (!function_exists ('str_contains ' )) {
400
- /**
401
- * @param string $haystack
402
- * @param string $needle
403
- * @return bool
404
- */
405
- function str_contains ($ haystack , $ needle )
406
- {
407
- return $ needle === '' || strpos ($ haystack , $ needle ) !== false ;
408
- }
409
- }
410
-
411
- /**
412
- * polyfill for PHP 8.0 function "str_starts_with"
413
- */
414
- if (!function_exists ('str_starts_with ' )) {
415
- /**
416
- * @param string $haystack
417
- * @param string $needle
418
- * @return bool
419
- */
420
- function str_starts_with ($ haystack , $ needle )
421
- {
422
- return strncmp ($ haystack , $ needle , \strlen ($ needle )) === 0 ;
423
- }
424
- }
425
-
426
- /**
427
- * polyfill for PHP 8.0 function "str_ends_with"
428
- */
429
- if (!function_exists ('str_ends_with ' )) {
430
- /**
431
- * @param string $haystack
432
- * @param string $needle
433
- * @return bool
434
- */
435
- function str_ends_with ($ haystack , $ needle )
436
- {
437
- return $ needle === '' || ($ haystack !== '' && substr_compare ($ haystack , $ needle , -\strlen ($ needle )) === 0 );
438
- }
439
- }
0 commit comments