Ignore:
Timestamp:
Mar 6, 2023, 12:16:38 PM (21 months ago)
Author:
chronos
Message:
  • Fixed: Export error due to PHP 8.1 deprecated code.
  • Modified: Code cleanup.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/Global.php

    r893 r894  
    818818    return preg_replace($find, $replace, $text);
    819819}
     820
     821function NormalizePath(string $Path): string
     822{
     823  $Segments = explode('/', $Path);
     824  $Result = array();
     825  for ($I = 0; $I < count($Segments); $I++)
     826  {
     827    $Segment = $Segments[$I];
     828    if (($Segment == '.') || ((strlen($Segment) == 0) && ($I > 0) && ($I < count($Segments) - 1)))
     829    {
     830      continue;
     831    }
     832    if ($Segment == '..')
     833    {
     834      array_pop($Result);
     835    } else
     836    {
     837      array_push($Result, $Segment);
     838    }
     839  }
     840  return implode('/', $Result);
     841}
Note: See TracChangeset for help on using the changeset viewer.